@gopherium/godmin 0.31.0 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -10
- package/dist/admin-root.d.ts +4 -2
- package/dist/admin-root.js +6 -3
- package/dist/announcer-heading.d.ts +4 -0
- package/dist/announcer-heading.js +25 -0
- package/dist/base.css +42 -17
- package/dist/breakpoints.d.ts +1 -1
- package/dist/breakpoints.js +1 -1
- package/dist/bulk-run.d.ts +10 -0
- package/dist/bulk-run.js +76 -11
- package/dist/bulk.d.ts +3 -0
- package/dist/confirm-dialog.d.ts +14 -14
- package/dist/confirm-dialog.js +9 -28
- package/dist/dialog-open.d.ts +77 -0
- package/dist/dialog-open.js +231 -0
- package/dist/drilldown-item.d.ts +5 -2
- package/dist/drilldown-item.js +14 -2
- package/dist/filter-offer.d.ts +5 -5
- package/dist/filter-offer.js +9 -9
- package/dist/focus-back.js +12 -2
- package/dist/form-dialog.d.ts +14 -16
- package/dist/form-dialog.js +54 -13
- package/dist/frame.d.ts +8 -4
- package/dist/frame.js +16 -6
- package/dist/index.d.ts +13 -13
- package/dist/index.js +7 -8
- package/dist/list-chrome/es-ES.d.ts +1 -1
- package/dist/list-chrome/es-ES.js +11 -8
- package/dist/list-chrome/fr-FR.d.ts +1 -1
- package/dist/list-chrome/fr-FR.js +10 -1
- package/dist/list-run.js +25 -44
- package/dist/navigation-item.d.ts +4 -2
- package/dist/navigation-item.js +2 -2
- package/dist/navigation-screen.js +10 -3
- package/dist/navigation.js +5 -1
- package/dist/page.d.ts +3 -2
- package/dist/page.js +23 -4
- package/dist/rejected-field.d.ts +25 -0
- package/dist/rejected-field.js +121 -0
- package/dist/rename-dialog.d.ts +24 -0
- package/dist/rename-dialog.js +16 -0
- package/dist/route-not-found.d.ts +5 -0
- package/dist/route-not-found.js +12 -0
- package/dist/router.d.ts +10 -2
- package/dist/router.js +11 -2
- package/dist/screen-title.d.ts +52 -0
- package/dist/screen-title.js +165 -0
- package/dist/stylelint.d.ts +1 -4
- package/dist/stylelint.js +4 -7
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +3 -3
- package/dist/toaster.js +21 -2
- package/dist/unsaved-changes-dialog.d.ts +19 -0
- package/dist/unsaved-changes-dialog.js +33 -0
- package/dist/vite.js +1 -0
- package/docs/build-and-versioning.md +199 -11
- package/docs/design-system/accessibility.md +23 -12
- package/docs/design-system/color.md +1 -1
- package/docs/design-system/custom-properties.md +3 -3
- package/docs/design-system/dialogs.md +302 -0
- package/docs/design-system/frame.md +276 -0
- package/docs/design-system/layout.md +25 -17
- package/docs/design-system/lists.md +20 -12
- package/docs/design-system/loading.md +20 -12
- package/docs/design-system/motion.md +41 -46
- package/docs/design-system/overview.md +11 -3
- package/docs/design-system/radius-and-elevation.md +2 -2
- package/docs/design-system/record-pages.md +13 -3
- package/docs/design-system/toasts.md +18 -8
- package/docs/framing-an-application.md +77 -23
- package/docs/lists.md +372 -452
- package/docs/loading-and-feedback.md +11 -6
- package/docs/overview.md +9 -4
- package/docs/screens.md +104 -5
- package/docs/testing.md +40 -9
- package/package.json +27 -27
- package/dist/close-while-open.d.ts +0 -6
- package/dist/close-while-open.js +0 -21
- package/dist/confirm.d.ts +0 -21
- package/dist/confirm.js +0 -11
- package/dist/dialogs.d.ts +0 -4
- package/dist/dialogs.js +0 -3
- package/dist/form.d.ts +0 -28
- package/dist/form.js +0 -23
- package/dist/rename.d.ts +0 -20
- package/dist/rename.js +0 -14
- package/dist/run-confirm.d.ts +0 -22
- package/dist/run-confirm.js +0 -23
package/dist/index.d.ts
CHANGED
|
@@ -3,19 +3,19 @@ export type { AdminRootProps } from './admin-root.js';
|
|
|
3
3
|
export { InitialsAvatar } from './avatar.js';
|
|
4
4
|
export type { InitialsAvatarProps } from './avatar.js';
|
|
5
5
|
export { DENSE_BREAKPOINT, EDGE_BREAKPOINT, HUGE_BREAKPOINT, SHEET_BREAKPOINT, SIDEBAR_BREAKPOINT, SMALL_VIEWPORT, TITLE_BREAKPOINT, } from './breakpoints.js';
|
|
6
|
-
export { useBulkRun } from './bulk-run.js';
|
|
7
|
-
export type { BulkRun } from './bulk-run.js';
|
|
6
|
+
export { useBulkRun, useDialogRun } from './bulk-run.js';
|
|
7
|
+
export type { BulkRun, DialogRun } from './bulk-run.js';
|
|
8
8
|
export { bulkNotes, runEach } from './bulk.js';
|
|
9
9
|
export type { BulkFailure, BulkNotes, BulkOutcome, BulkWords } from './bulk.js';
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export type {
|
|
10
|
+
export { ConfirmDialog } from './confirm-dialog.js';
|
|
11
|
+
export type { ConfirmDialogProps } from './confirm-dialog.js';
|
|
12
|
+
export type { DialogAnswer } from './dialog-open.js';
|
|
13
13
|
export { FileButton } from './file-button.js';
|
|
14
14
|
export type { FileButtonProps } from './file-button.js';
|
|
15
15
|
export { focusedTrigger, useFocusBack } from './focus-back.js';
|
|
16
16
|
export type { Trigger } from './focus-back.js';
|
|
17
|
-
export {
|
|
18
|
-
export type {
|
|
17
|
+
export { FormDialog } from './form-dialog.js';
|
|
18
|
+
export type { FormDialogProps } from './form-dialog.js';
|
|
19
19
|
export { Frame } from './frame.js';
|
|
20
20
|
export type { CanvasMode, FrameCanvasProps, FrameRootProps, FrameSidebarProps, } from './frame.js';
|
|
21
21
|
export { keyFromLabel } from './keys.js';
|
|
@@ -42,14 +42,14 @@ export { PageBreadcrumb, PageBreadcrumbs } from './page-breadcrumbs.js';
|
|
|
42
42
|
export type { PageBreadcrumbProps, PageBreadcrumbsProps } from './page-breadcrumbs.js';
|
|
43
43
|
export { PageTab, PageTabs } from './page-tabs.js';
|
|
44
44
|
export type { PageTabProps, PageTabsProps } from './page-tabs.js';
|
|
45
|
-
export {
|
|
46
|
-
export type {
|
|
45
|
+
export { useRejectedField } from './rejected-field.js';
|
|
46
|
+
export type { RejectedField, RejectedValidity } from './rejected-field.js';
|
|
47
|
+
export { RenameDialog } from './rename-dialog.js';
|
|
48
|
+
export type { RenameDialogProps } from './rename-dialog.js';
|
|
47
49
|
export { useRowKeys } from './row-keys.js';
|
|
48
50
|
export type { RowBounds, RowKeys } from './row-keys.js';
|
|
49
51
|
export { RepeatRows, RowControls } from './rows.js';
|
|
50
52
|
export type { RepeatRowsProps, RowControlsProps, RowLabels } from './rows.js';
|
|
51
|
-
export { RunConfirm } from './run-confirm.js';
|
|
52
|
-
export type { RunConfirmProps } from './run-confirm.js';
|
|
53
53
|
export { offeredSize, pageWindow, paginationOf, sizedView, useServerPaging } from './server-page.js';
|
|
54
54
|
export type { PagedView, PageWindow, PaginationInfo, ServedPage, ServedSize, ServerPaging } from './server-page.js';
|
|
55
55
|
export { Toaster, useToaster } from './toaster.js';
|
|
@@ -64,6 +64,6 @@ export type { GuardedField, OfferedView, ViewGuard } from './view-guard.js';
|
|
|
64
64
|
* The design system version window this build was tested against.
|
|
65
65
|
*/
|
|
66
66
|
export declare const SUPPORTED_WPDS: {
|
|
67
|
-
readonly '@wordpress/ui': ">=0.
|
|
68
|
-
readonly '@wordpress/theme': ">=
|
|
67
|
+
readonly '@wordpress/ui': ">=0.26.0 <0.27.0";
|
|
68
|
+
readonly '@wordpress/theme': ">=4.0.0 <5.0.0";
|
|
69
69
|
};
|
package/dist/index.js
CHANGED
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
export { AdminRoot } from './admin-root.js';
|
|
3
3
|
export { InitialsAvatar } from './avatar.js';
|
|
4
4
|
export { DENSE_BREAKPOINT, EDGE_BREAKPOINT, HUGE_BREAKPOINT, SHEET_BREAKPOINT, SIDEBAR_BREAKPOINT, SMALL_VIEWPORT, TITLE_BREAKPOINT, } from './breakpoints.js';
|
|
5
|
-
export { useBulkRun } from './bulk-run.js';
|
|
5
|
+
export { useBulkRun, useDialogRun } from './bulk-run.js';
|
|
6
6
|
export { bulkNotes, runEach } from './bulk.js';
|
|
7
|
-
export {
|
|
8
|
-
export { ConfirmBody } from './confirm.js';
|
|
7
|
+
export { ConfirmDialog } from './confirm-dialog.js';
|
|
9
8
|
export { FileButton } from './file-button.js';
|
|
10
9
|
export { focusedTrigger, useFocusBack } from './focus-back.js';
|
|
11
|
-
export {
|
|
10
|
+
export { FormDialog } from './form-dialog.js';
|
|
12
11
|
export { Frame } from './frame.js';
|
|
13
12
|
export { keyFromLabel } from './keys.js';
|
|
14
13
|
export { LIST_CHROME_DOMAIN, listChromeCatalogFor } from './list-chrome.js';
|
|
@@ -22,10 +21,10 @@ export { openOnTap } from './open-on-tap.js';
|
|
|
22
21
|
export { ErrorNotice, LoadMore, Page, PageTitle, SectionTitle } from './page.js';
|
|
23
22
|
export { PageBreadcrumb, PageBreadcrumbs } from './page-breadcrumbs.js';
|
|
24
23
|
export { PageTab, PageTabs } from './page-tabs.js';
|
|
25
|
-
export {
|
|
24
|
+
export { useRejectedField } from './rejected-field.js';
|
|
25
|
+
export { RenameDialog } from './rename-dialog.js';
|
|
26
26
|
export { useRowKeys } from './row-keys.js';
|
|
27
27
|
export { RepeatRows, RowControls } from './rows.js';
|
|
28
|
-
export { RunConfirm } from './run-confirm.js';
|
|
29
28
|
export { offeredSize, pageWindow, paginationOf, sizedView, useServerPaging } from './server-page.js';
|
|
30
29
|
export { Toaster, useToaster } from './toaster.js';
|
|
31
30
|
export { markLatest, useUnsavedText } from './unsaved-text.js';
|
|
@@ -36,6 +35,6 @@ export { offeredView, viewNarrows } from './view-guard.js';
|
|
|
36
35
|
* The design system version window this build was tested against.
|
|
37
36
|
*/
|
|
38
37
|
export const SUPPORTED_WPDS = {
|
|
39
|
-
'@wordpress/ui': '>=0.
|
|
40
|
-
'@wordpress/theme': '>=
|
|
38
|
+
'@wordpress/ui': '>=0.26.0 <0.27.0',
|
|
39
|
+
'@wordpress/theme': '>=4.0.0 <5.0.0',
|
|
41
40
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ListChromeCatalog } from '../list-chrome.js';
|
|
2
|
-
/** The Spanish list chrome, list dates, sidebar
|
|
2
|
+
/** The Spanish list chrome, list dates, sidebar, frame, no results, time-out and live region words, from es-ES.po. */
|
|
3
3
|
declare const catalog: ListChromeCatalog;
|
|
4
4
|
export default catalog;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
/** The Spanish list chrome, list dates, sidebar
|
|
2
|
+
/** The Spanish list chrome, list dates, sidebar, frame, no results, time-out and live region words, from es-ES.po. */
|
|
3
3
|
const catalog = {
|
|
4
4
|
'': { lang: 'es-ES', 'plural-forms': 'nplurals=2; plural=(n != 1);' },
|
|
5
|
-
'%1$s of %2$s
|
|
5
|
+
'%1$s of %2$s item': ['%1$s de %2$s elemento', '%1$s de %2$s elementos'],
|
|
6
|
+
'%1$s ‹ %2$s': ['%1$s ‹ %2$s'],
|
|
6
7
|
'%1$s, %2$s': ['%1$s, %2$s'],
|
|
7
8
|
'%1$s: %2$s': ['%1$s: %2$s'],
|
|
8
|
-
'%s
|
|
9
|
-
'%s
|
|
9
|
+
'%s item': ['%s elemento', '%s elementos'],
|
|
10
|
+
'%s item selected': ['%s elemento seleccionado', '%s elementos seleccionados'],
|
|
10
11
|
'%s, selected': ['%s, seleccionado'],
|
|
11
12
|
'%s: <groupName />': ['%s: <groupName />'],
|
|
12
13
|
'(no title)': ['(sin título)'],
|
|
@@ -78,9 +79,6 @@ const catalog = {
|
|
|
78
79
|
'April abbreviation\u0004Apr': ['Abr'],
|
|
79
80
|
August: ['agosto'],
|
|
80
81
|
'August abbreviation\u0004Aug': ['Ago'],
|
|
81
|
-
'Automatically load more content as you scroll, instead of showing pagination links.': [
|
|
82
|
-
'Carga automáticamente más contenido a medida que navegas, en lugar de mostrar enlaces de paginación.',
|
|
83
|
-
],
|
|
84
82
|
Back: ['Volver'],
|
|
85
83
|
Before: ['Antes'],
|
|
86
84
|
'Before (inc)': ['Antes (incl.)'],
|
|
@@ -91,6 +89,7 @@ const catalog = {
|
|
|
91
89
|
Conditions: ['Condiciones'],
|
|
92
90
|
Contains: ['Contiene'],
|
|
93
91
|
'Coordinated Universal Time': ['Hora universal coordinada'],
|
|
92
|
+
'Could not get a valid response from the server.': ['No se pudo obtener una respuesta válida del servidor.'],
|
|
94
93
|
'Current page': ['Página actual'],
|
|
95
94
|
'Date calendar': ['Calendario de fechas'],
|
|
96
95
|
'Date range calendar': ['Calendario de rango de fechas'],
|
|
@@ -103,7 +102,6 @@ const catalog = {
|
|
|
103
102
|
'Density option for DataView layout\u0004Compact': ['Compacto'],
|
|
104
103
|
'Deselect all': ['Anular selección de todo'],
|
|
105
104
|
"Doesn't contain": ['No contiene'],
|
|
106
|
-
'Enable infinite scroll': ['Activar el desplazamiento infinito'],
|
|
107
105
|
'F j, Y g:i a': ['j \\d\\e F \\d\\e Y H:i'],
|
|
108
106
|
False: ['Falso'],
|
|
109
107
|
February: ['febrero'],
|
|
@@ -154,6 +152,7 @@ const catalog = {
|
|
|
154
152
|
'No results': ['No hay resultados'],
|
|
155
153
|
'No results found': ['No se encontraron resultados'],
|
|
156
154
|
'Not on': ['No el'],
|
|
155
|
+
Notifications: ['Avisos'],
|
|
157
156
|
November: ['noviembre'],
|
|
158
157
|
'November abbreviation\u0004Nov': ['Nov'],
|
|
159
158
|
October: ['octubre'],
|
|
@@ -175,6 +174,7 @@ const catalog = {
|
|
|
175
174
|
Reset: ['Restablecer'],
|
|
176
175
|
'Reset search': ['Restablecer la búsqueda'],
|
|
177
176
|
'Reset view': ['Restablecer vista'],
|
|
177
|
+
'Route not found': ['Ruta no encontrada'],
|
|
178
178
|
'Row %d': ['Fila %d'],
|
|
179
179
|
Sat: ['Sáb'],
|
|
180
180
|
Saturday: ['sábado'],
|
|
@@ -191,6 +191,7 @@ const catalog = {
|
|
|
191
191
|
Sun: ['Dom'],
|
|
192
192
|
Sunday: ['domingo'],
|
|
193
193
|
Table: ['Tabla'],
|
|
194
|
+
"The page you're looking for does not exist": ['La página que estás buscando no existe'],
|
|
194
195
|
Thu: ['Jue'],
|
|
195
196
|
Thursday: ['jueves'],
|
|
196
197
|
'Timezone: %s': ['Zona horaria: %s'],
|
|
@@ -202,11 +203,13 @@ const catalog = {
|
|
|
202
203
|
],
|
|
203
204
|
Tue: ['Mar'],
|
|
204
205
|
Tuesday: ['martes'],
|
|
206
|
+
'Unable to connect. Please check your Internet connection.': ['No se puede conectar. Revisa tu conexión a Internet.'],
|
|
205
207
|
'Unknown status for %1$s': ['Estado desconocido para %1$s'],
|
|
206
208
|
'View is used as a noun\u0004View options': ['Ver opciones'],
|
|
207
209
|
Wed: ['Mié'],
|
|
208
210
|
Wednesday: ['miércoles'],
|
|
209
211
|
am: ['am'],
|
|
212
|
+
'menu item requiring further input\u0004%s…': ['%s…'],
|
|
210
213
|
'paging\u0004<div>Page</div>%1$s<div>of %2$d</div>': ['<div>Página</div>%1$s<div>de %2$d</div>'],
|
|
211
214
|
pm: ['pm'],
|
|
212
215
|
'start of week\u00041': ['1'],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ListChromeCatalog } from '../list-chrome.js';
|
|
2
|
-
/** The French list dates, dialog, sidebar
|
|
2
|
+
/** The French list dates, dialog, sidebar, frame, no results, time-out and live region words, from fr-FR.po. */
|
|
3
3
|
declare const catalog: ListChromeCatalog;
|
|
4
4
|
export default catalog;
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
/** The French list dates, dialog, sidebar
|
|
2
|
+
/** The French list dates, dialog, sidebar, frame, no results, time-out and live region words, from fr-FR.po. */
|
|
3
3
|
const catalog = {
|
|
4
4
|
'': { lang: 'fr-FR', 'plural-forms': 'nplurals=2; plural=(n > 1);' },
|
|
5
|
+
'%1$s ‹ %2$s': ['%1$s ‹ %2$s'],
|
|
5
6
|
AM: ['AM'],
|
|
6
7
|
April: ['avril'],
|
|
7
8
|
'April abbreviation\u0004Apr': ['Avr'],
|
|
8
9
|
August: ['août'],
|
|
9
10
|
'August abbreviation\u0004Aug': ['Août'],
|
|
10
11
|
Back: ['Retour'],
|
|
12
|
+
Close: ['Fermer'],
|
|
11
13
|
'Close navigation panel': ['Fermer le panneau de navigation'],
|
|
14
|
+
'Could not get a valid response from the server.': ['Impossible d’obtenir du serveur une réponse valide.'],
|
|
12
15
|
December: ['décembre'],
|
|
13
16
|
'December abbreviation\u0004Dec': ['Déc'],
|
|
14
17
|
'F j, Y g:i a': ['d F Y G\\hi'],
|
|
@@ -32,12 +35,14 @@ const catalog = {
|
|
|
32
35
|
Monday: ['lundi'],
|
|
33
36
|
Navigation: ['Navigation'],
|
|
34
37
|
'No results found': ['Aucun résultat trouvé'],
|
|
38
|
+
Notifications: ['Notifications'],
|
|
35
39
|
November: ['novembre'],
|
|
36
40
|
'November abbreviation\u0004Nov': ['Nov'],
|
|
37
41
|
October: ['octobre'],
|
|
38
42
|
'October abbreviation\u0004Oct': ['Oct'],
|
|
39
43
|
'Open navigation panel': ['Ouvrir le panneau de navigation'],
|
|
40
44
|
PM: ['PM'],
|
|
45
|
+
'Route not found': ['Route introuvable'],
|
|
41
46
|
Sat: ['Sam'],
|
|
42
47
|
Saturday: ['samedi'],
|
|
43
48
|
'Scrollable section': ['Section défilable'],
|
|
@@ -45,6 +50,7 @@ const catalog = {
|
|
|
45
50
|
'September abbreviation\u0004Sep': ['Sep'],
|
|
46
51
|
Sun: ['Dim'],
|
|
47
52
|
Sunday: ['dimanche'],
|
|
53
|
+
"The page you're looking for does not exist": ["La page que vous cherchez n'existe pas"],
|
|
48
54
|
Thu: ['Jeu'],
|
|
49
55
|
Thursday: ['jeudi'],
|
|
50
56
|
"Try adjusting your search or filters to find what you're looking for.": [
|
|
@@ -52,6 +58,9 @@ const catalog = {
|
|
|
52
58
|
],
|
|
53
59
|
Tue: ['Mar'],
|
|
54
60
|
Tuesday: ['mardi'],
|
|
61
|
+
'Unable to connect. Please check your Internet connection.': [
|
|
62
|
+
'Impossible de se connecter. Veuillez vérifier votre connexion Internet.',
|
|
63
|
+
],
|
|
55
64
|
Wed: ['Mer'],
|
|
56
65
|
Wednesday: ['mercredi'],
|
|
57
66
|
am: ['am'],
|
package/dist/list-run.js
CHANGED
|
@@ -5,14 +5,14 @@ import { HOLDERS, itemAt, triggerOnItem } from './focus-back.js';
|
|
|
5
5
|
const DIALOG_IN_FOCUS = '[role="dialog"]:focus-within, [role="alertdialog"]:focus-within';
|
|
6
6
|
/** Finds a part that turned inert while it holds the focus. */
|
|
7
7
|
const INERT_IN_FOCUS = '[inert]:focus-within';
|
|
8
|
-
/** Finds a dialog or an alert dialog
|
|
8
|
+
/** Finds a dialog or an alert dialog. */
|
|
9
9
|
const DIALOG = '[role="dialog"], [role="alertdialog"]';
|
|
10
|
+
/** Finds the toast region, which takes the focus a leaving toast held. */
|
|
11
|
+
const TOAST_REGION = '.godmin-toasts';
|
|
10
12
|
/** Finds every control a reader can focus inside a card or a row. */
|
|
11
13
|
const CONTROLS = 'a[href], button, input, select, textarea, [tabindex]';
|
|
12
14
|
/** Finds a button of a row that runs an action, never the actions menu button, which only opens a menu. */
|
|
13
15
|
const ACTION_BUTTON = '.dataviews-item-actions button:not(.dataviews-all-actions-button)';
|
|
14
|
-
/** Stops nothing, for a run that watches no focus. */
|
|
15
|
-
function stopNothing() { }
|
|
16
16
|
/**
|
|
17
17
|
* Counts the reloads a list has open, each ended once, and drops them all when the list changes.
|
|
18
18
|
* @returns Whether a reload is open, and how to start one or drop them all.
|
|
@@ -50,33 +50,13 @@ export function focusInDialog() {
|
|
|
50
50
|
return document.querySelector(DIALOG_IN_FOCUS) !== null;
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
53
|
+
* Reports whether the dialog a run started in has left the page while the focus sits on the control that opened it.
|
|
54
54
|
* @param startedIn - The dialog that held the focus as the run started, none for a run started outside every dialog.
|
|
55
|
-
* @
|
|
55
|
+
* @param openedBy - The control that opened each dialog.
|
|
56
|
+
* @returns Whether that dialog has gone and the focus sits on that control.
|
|
56
57
|
*/
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
if (startedIn === null) {
|
|
60
|
-
return landing;
|
|
61
|
-
}
|
|
62
|
-
const note = (event) => {
|
|
63
|
-
if (startedIn.isConnected && !startedIn.contains(event.target)) {
|
|
64
|
-
landing.element = event.target;
|
|
65
|
-
landing.stop();
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
document.addEventListener('focusin', note, true);
|
|
69
|
-
landing.stop = () => document.removeEventListener('focusin', note, true);
|
|
70
|
-
return landing;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Reports whether the dialog a run started in has closed while the focus stays where it first landed, in no dialog.
|
|
74
|
-
* @param startedIn - The dialog that held the focus as the run started, none for a run started outside every dialog.
|
|
75
|
-
* @param landed - The element the focus first landed on outside that dialog, none while it never did.
|
|
76
|
-
* @returns Whether that dialog has gone and the focus stays on the element it handed the focus back to.
|
|
77
|
-
*/
|
|
78
|
-
function stillWhereDialogLeftIt(startedIn, landed) {
|
|
79
|
-
return startedIn?.isConnected === false && document.activeElement === landed && !focusInDialog();
|
|
58
|
+
function stillWhereDialogLeftIt(startedIn, openedBy) {
|
|
59
|
+
return startedIn?.isConnected === false && document.activeElement === openedBy.get(startedIn);
|
|
80
60
|
}
|
|
81
61
|
/**
|
|
82
62
|
* Moves the focus to the list region, scrolling nothing, when it sits in a part of that list that turned inert.
|
|
@@ -138,32 +118,38 @@ function putBack(list, place) {
|
|
|
138
118
|
}
|
|
139
119
|
}
|
|
140
120
|
/**
|
|
141
|
-
* Notes the
|
|
121
|
+
* Notes what the focus leaves for a dialog: the control that opened it, and its place when it stands in the list.
|
|
142
122
|
* @param region - The list region, none while the screen draws no list.
|
|
143
|
-
* @param opener - Where the
|
|
123
|
+
* @param opener - Where the place goes, none once the focus leaves the list for anything but a dialog.
|
|
124
|
+
* @param openedBy - Where the control goes, the first one only for each dialog.
|
|
144
125
|
* @returns What stops noting.
|
|
145
126
|
*/
|
|
146
|
-
function noteOpener(region, opener) {
|
|
127
|
+
function noteOpener(region, opener, openedBy) {
|
|
147
128
|
const note = (event) => {
|
|
148
129
|
const list = region.current;
|
|
130
|
+
const dialog = event.relatedTarget?.closest(DIALOG);
|
|
149
131
|
if (list?.contains(event.target)) {
|
|
150
|
-
opener.current =
|
|
132
|
+
opener.current = dialog ? placeOf(list, event.target) : null;
|
|
133
|
+
}
|
|
134
|
+
if (dialog && !event.target.closest(DIALOG)) {
|
|
135
|
+
openedBy.set(dialog, openedBy.get(dialog) ?? event.target);
|
|
151
136
|
}
|
|
152
137
|
};
|
|
153
138
|
document.addEventListener('focusout', note, true);
|
|
154
139
|
return () => document.removeEventListener('focusout', note, true);
|
|
155
140
|
}
|
|
156
141
|
/**
|
|
157
|
-
* Reports whether the focus sits on the page,
|
|
142
|
+
* Reports whether the focus sits on the page, the toast region, the list, the dialog that ran, or where it left it.
|
|
158
143
|
* @param list - The list region, none while the screen draws no list.
|
|
159
144
|
* @param startedIn - The dialog that held the focus as the run started, none for a run started outside every dialog.
|
|
160
|
-
* @param
|
|
145
|
+
* @param openedBy - The control that opened each dialog.
|
|
161
146
|
* @returns Whether a finished run may move the focus to the list.
|
|
162
147
|
*/
|
|
163
|
-
function readerOnList(list, startedIn,
|
|
148
|
+
function readerOnList(list, startedIn, openedBy) {
|
|
164
149
|
const active = document.activeElement;
|
|
165
150
|
const holds = [list, startedIn].some((holder) => holder !== null && holder.contains(active));
|
|
166
|
-
|
|
151
|
+
const leftByToast = active?.matches(TOAST_REGION) === true;
|
|
152
|
+
return active === document.body || leftByToast || holds || stillWhereDialogLeftIt(startedIn, openedBy);
|
|
167
153
|
}
|
|
168
154
|
/**
|
|
169
155
|
* Holds the region a run focuses, gives its focus back once the list reloaded, and drops old runs on a list change.
|
|
@@ -174,15 +160,14 @@ function readerOnList(list, startedIn, landed) {
|
|
|
174
160
|
export function useListRun(scope, onChangeSelection) {
|
|
175
161
|
const region = useRef(null);
|
|
176
162
|
const latest = useRef(0);
|
|
177
|
-
const watching = useRef(stopNothing);
|
|
178
163
|
const committed = useRef(scope);
|
|
179
164
|
const place = useRef(null);
|
|
180
165
|
const opener = useRef(null);
|
|
166
|
+
const [openedBy] = useState(() => new WeakMap());
|
|
181
167
|
const [refreshing, reloads] = useReloads();
|
|
182
|
-
useLayoutEffect(() => noteOpener(region, opener), []);
|
|
168
|
+
useLayoutEffect(() => noteOpener(region, opener, openedBy), [openedBy]);
|
|
183
169
|
useLayoutEffect(() => {
|
|
184
170
|
latest.current += 1;
|
|
185
|
-
return () => watching.current();
|
|
186
171
|
}, [scope]);
|
|
187
172
|
useLayoutEffect(() => {
|
|
188
173
|
if (committed.current !== scope) {
|
|
@@ -202,15 +187,11 @@ export function useListRun(scope, onChangeSelection) {
|
|
|
202
187
|
}, [refreshing]);
|
|
203
188
|
const [run] = useState(() => ({
|
|
204
189
|
onStart: () => {
|
|
205
|
-
watching.current();
|
|
206
190
|
latest.current += 1;
|
|
207
191
|
const id = latest.current;
|
|
208
192
|
const startedIn = document.querySelector(DIALOG_IN_FOCUS);
|
|
209
193
|
place.current = startedIn === null ? null : opener.current;
|
|
210
|
-
const landing = watchLanding(startedIn);
|
|
211
|
-
watching.current = landing.stop;
|
|
212
194
|
return (moved) => {
|
|
213
|
-
landing.stop();
|
|
214
195
|
if (latest.current !== id) {
|
|
215
196
|
return;
|
|
216
197
|
}
|
|
@@ -218,7 +199,7 @@ export function useListRun(scope, onChangeSelection) {
|
|
|
218
199
|
place.current = null;
|
|
219
200
|
return;
|
|
220
201
|
}
|
|
221
|
-
if (readerOnList(region.current, startedIn,
|
|
202
|
+
if (readerOnList(region.current, startedIn, openedBy)) {
|
|
222
203
|
place.current ??= placeOf(region.current, document.activeElement);
|
|
223
204
|
region.current?.focus({ preventScroll: true });
|
|
224
205
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AnyRouter, LinkComponentProps, RegisteredRouter } from '@tanstack/react-router';
|
|
2
|
-
import type { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import type { ComponentType, ReactElement, ReactNode } from 'react';
|
|
3
3
|
import type { RowRoutes } from './path-matching.js';
|
|
4
4
|
/** The class every sidebar row link carries. */
|
|
5
5
|
export declare const ROW_CLASS = "godmin-navigation-item";
|
|
@@ -28,6 +28,8 @@ interface RowProps {
|
|
|
28
28
|
id?: string;
|
|
29
29
|
/** What ends the row, such as a suffix or a chevron. */
|
|
30
30
|
end?: ReactNode;
|
|
31
|
+
/** The router link the row draws, TanStack's Link when absent. */
|
|
32
|
+
linkComponent?: ComponentType<LinkComponentProps>;
|
|
31
33
|
children: ReactNode;
|
|
32
34
|
}
|
|
33
35
|
/**
|
|
@@ -43,7 +45,7 @@ export declare function RowSuffix({ children }: {
|
|
|
43
45
|
* @param props - The link props, where the row goes, the icon, the classes, the id, the end of the row and its label.
|
|
44
46
|
* @returns The list item element, or null.
|
|
45
47
|
*/
|
|
46
|
-
export declare function Row({ link, routes, icon, className, id, end, children }: RowProps): import("react").JSX.Element | null;
|
|
48
|
+
export declare function Row({ link, routes, icon, className, id, end, linkComponent: RowLink, children }: RowProps): import("react").JSX.Element | null;
|
|
47
49
|
/**
|
|
48
50
|
* Renders a sidebar row that goes to a page: its icon, its label and its suffix, current on every address under it.
|
|
49
51
|
* @param props - The TanStack Link props, the icon, the suffix and the label.
|
package/dist/navigation-item.js
CHANGED
|
@@ -35,12 +35,12 @@ export function RowSuffix({ children }) {
|
|
|
35
35
|
* @param props - The link props, where the row goes, the icon, the classes, the id, the end of the row and its label.
|
|
36
36
|
* @returns The list item element, or null.
|
|
37
37
|
*/
|
|
38
|
-
export function Row({ link, routes, icon, className, id, end, children }) {
|
|
38
|
+
export function Row({ link, routes, icon, className, id, end, linkComponent: RowLink = Link, children }) {
|
|
39
39
|
const { can } = useContext(ScreenContext);
|
|
40
40
|
if (!canOpenRoutes(routes.capabilities, can)) {
|
|
41
41
|
return null;
|
|
42
42
|
}
|
|
43
|
-
return (_jsx("li", { children: _jsxs(
|
|
43
|
+
return (_jsx("li", { children: _jsxs(RowLink, { ...link, id: id ?? link.id, className: link.className === undefined ? className : `${className} ${link.className}`, children: [_jsx(RowIcon, { icon: icon }), _jsx("div", { className: "godmin-navigation-item__label", children: children }), end] }) }));
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
* Renders a sidebar row that goes to a page: its icon, its label and its suffix, current on every address under it.
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { __, isRTL } from '@wordpress/i18n';
|
|
3
3
|
import { Icon, chevronLeft, chevronRight } from '@wordpress/icons';
|
|
4
|
-
import {
|
|
5
|
-
import { useContext } from 'react';
|
|
4
|
+
import { cloneElement, useContext } from 'react';
|
|
6
5
|
import { NavigationStateContext, ScreenContext, isPlainClick, recordBack } from './navigation-state.js';
|
|
7
6
|
/** The class of the title row, the Site Editor's name for it. */
|
|
8
7
|
const TITLE_ROW = 'godmin-navigation-screen__title-icon';
|
|
8
|
+
/** The class of Back. */
|
|
9
|
+
const BACK = 'godmin-navigation-screen__back';
|
|
9
10
|
/** The class of the region holding the title row and the content. */
|
|
10
11
|
const MAIN = 'godmin-navigation-screen__main';
|
|
11
12
|
/**
|
|
@@ -27,12 +28,18 @@ function Region({ content, className, as: Tag = 'div' }) {
|
|
|
27
28
|
function BackLink({ target, label }) {
|
|
28
29
|
const state = useContext(NavigationStateContext);
|
|
29
30
|
const { targetOf } = useContext(ScreenContext);
|
|
31
|
+
const own = target.props;
|
|
30
32
|
const onClick = (event) => {
|
|
33
|
+
own.onClick?.(event);
|
|
31
34
|
if (state !== undefined && isPlainClick(event)) {
|
|
32
35
|
recordBack(state, targetOf?.(target));
|
|
33
36
|
}
|
|
34
37
|
};
|
|
35
|
-
return (
|
|
38
|
+
return cloneElement(target, {
|
|
39
|
+
'aria-label': own['aria-label'] ?? label,
|
|
40
|
+
className: own.className === undefined ? BACK : `${BACK} ${own.className}`,
|
|
41
|
+
onClick,
|
|
42
|
+
}, _jsx(Icon, { icon: isRTL() ? chevronRight : chevronLeft, size: 24 }));
|
|
36
43
|
}
|
|
37
44
|
/**
|
|
38
45
|
* Renders a sidebar screen as the Site Editor draws it: a title row with Back, the title and the actions,
|
package/dist/navigation.js
CHANGED
|
@@ -110,7 +110,11 @@ function ScreenWrapper({ state, children }) {
|
|
|
110
110
|
setDirection(move.direction);
|
|
111
111
|
}
|
|
112
112
|
}, [state, router]);
|
|
113
|
-
return (_jsx("div", { ref: wrapper, tabIndex: -1, className: direction === undefined ? WRAPPER : `${WRAPPER} ${WRAPPER}--${direction}`,
|
|
113
|
+
return (_jsx("div", { ref: wrapper, tabIndex: -1, className: direction === undefined ? WRAPPER : `${WRAPPER} ${WRAPPER}--${direction}`, onAnimationEnd: (event) => {
|
|
114
|
+
if (event.target === event.currentTarget) {
|
|
115
|
+
setDirection(undefined);
|
|
116
|
+
}
|
|
117
|
+
}, children: children }));
|
|
114
118
|
}
|
|
115
119
|
/**
|
|
116
120
|
* Renders the sidebar menu, as WordPress's new admin names it: the root screen drawn from its title and rows,
|
package/dist/page.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ type HeadingTag = 'h1' | 'h2' | 'h3' | 'h4';
|
|
|
11
11
|
*/
|
|
12
12
|
export declare function useHeadingUnderPage(): HeadingTag;
|
|
13
13
|
/**
|
|
14
|
-
* Renders a screen's title as the page heading.
|
|
14
|
+
* Renders a screen's title as the page heading, and reports its text to the frame when no Page holds it.
|
|
15
15
|
* @param props - The title text, the type scale to render it at and its heading level, 1 when absent.
|
|
16
16
|
* @returns The page title element.
|
|
17
17
|
*/
|
|
@@ -54,7 +54,8 @@ export interface PageProps {
|
|
|
54
54
|
children: ReactNode;
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
|
-
* Renders a screen: a header with the title, actions and subtitle, then optional tabs and the content
|
|
57
|
+
* Renders a screen: a header with the title, actions and subtitle, then optional tabs and the content, and
|
|
58
|
+
* reports its title to the frame, as waiting while it holds nothing but one LoadingScreen.
|
|
58
59
|
* @param props - The title, subtitle, actions, tabs, aside and its name, breadcrumbs, list flag, list name and ref,
|
|
59
60
|
* extra class, title level and content.
|
|
60
61
|
* @returns The page element.
|
package/dist/page.js
CHANGED
|
@@ -2,10 +2,14 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
/* oxlint-disable react/only-export-components -- the page kit ships its parts
|
|
3
3
|
beside the type they share. */
|
|
4
4
|
import { Button, Notice, Stack, Text } from '@wordpress/ui';
|
|
5
|
-
import { Children, createContext, useContext, useImperativeHandle, useRef } from 'react';
|
|
5
|
+
import { Children, createContext, isValidElement, useContext, useImperativeHandle, useRef } from 'react';
|
|
6
|
+
import { LoadingScreen } from './loading.js';
|
|
7
|
+
import { useReportTitle } from './screen-title.js';
|
|
6
8
|
import { useWideList } from './wide-list.js';
|
|
7
9
|
/** The level of the title of the Page around a section title, 1 outside any Page. */
|
|
8
10
|
const PageLevelContext = createContext(1);
|
|
11
|
+
/** How many Pages hold a part, 0 outside any Page. */
|
|
12
|
+
const PageDepthContext = createContext(0);
|
|
9
13
|
/**
|
|
10
14
|
* Returns the heading element of a level.
|
|
11
15
|
* @param level - The heading level, 1 to 4.
|
|
@@ -22,11 +26,13 @@ export function useHeadingUnderPage() {
|
|
|
22
26
|
return headingTag(useContext(PageLevelContext) + 1);
|
|
23
27
|
}
|
|
24
28
|
/**
|
|
25
|
-
* Renders a screen's title as the page heading.
|
|
29
|
+
* Renders a screen's title as the page heading, and reports its text to the frame when no Page holds it.
|
|
26
30
|
* @param props - The title text, the type scale to render it at and its heading level, 1 when absent.
|
|
27
31
|
* @returns The page title element.
|
|
28
32
|
*/
|
|
29
33
|
export function PageTitle({ children, variant = 'heading-lg', level = 1, }) {
|
|
34
|
+
const alone = useContext(PageDepthContext) === 0;
|
|
35
|
+
useReportTitle(alone && typeof children === 'string' ? children : undefined, 0, false);
|
|
30
36
|
const Heading = headingTag(level);
|
|
31
37
|
return (_jsx(Text, { variant: variant, render: _jsx(Heading, {}), children: children }));
|
|
32
38
|
}
|
|
@@ -90,14 +96,27 @@ function PageHeading({ title, level, breadcrumbs }) {
|
|
|
90
96
|
return (_jsxs("div", { className: "godmin-page__heading", children: [breadcrumbs, _jsx(PageTitle, { level: level, children: title })] }));
|
|
91
97
|
}
|
|
92
98
|
/**
|
|
93
|
-
*
|
|
99
|
+
* Tells whether a page waits for its record: its whole content is one LoadingScreen element and it has no aside.
|
|
100
|
+
* @param aside - The aside the page was given.
|
|
101
|
+
* @param children - The content the page was given.
|
|
102
|
+
* @returns Whether the page holds nothing but that LoadingScreen.
|
|
103
|
+
*/
|
|
104
|
+
function waitsForRecord(aside, children) {
|
|
105
|
+
const content = Children.toArray(children);
|
|
106
|
+
return aside === undefined && content.length === 1 && isValidElement(content[0]) && content[0].type === LoadingScreen;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Renders a screen: a header with the title, actions and subtitle, then optional tabs and the content, and
|
|
110
|
+
* reports its title to the frame, as waiting while it holds nothing but one LoadingScreen.
|
|
94
111
|
* @param props - The title, subtitle, actions, tabs, aside and its name, breadcrumbs, list flag, list name and ref,
|
|
95
112
|
* extra class, title level and content.
|
|
96
113
|
* @returns The page element.
|
|
97
114
|
*/
|
|
98
115
|
export function Page({ title, subtitle, actions, tabs, aside, asideLabel, breadcrumbs, list = false, listLabel, listRef, className, headingLevel = 1, children, }) {
|
|
99
116
|
const classes = className === undefined ? 'godmin-page' : `godmin-page ${className}`;
|
|
100
|
-
|
|
117
|
+
const depth = useContext(PageDepthContext) + 1;
|
|
118
|
+
useReportTitle(title, depth, waitsForRecord(aside, children));
|
|
119
|
+
return (_jsx(PageDepthContext.Provider, { value: depth, children: _jsx(PageLevelContext.Provider, { value: headingLevel, children: _jsxs(Stack, { direction: "column", gap: "lg", className: classes, children: [_jsxs(Stack, { direction: "column", render: _jsx("header", {}), className: "godmin-page__header", children: [_jsxs(Stack, { direction: "row", wrap: "wrap", gap: "md", align: "center", justify: "space-between", className: "godmin-page__head", children: [_jsx(PageHeading, { title: title, level: headingLevel, breadcrumbs: breadcrumbs }), actions !== undefined && (_jsx(Stack, { direction: "row", gap: "sm", align: "center", children: actions }))] }), subtitle !== undefined && (_jsx(Text, { variant: "body-md", render: _jsx("p", {}), className: "godmin-page__subtitle", children: subtitle }))] }), tabs !== undefined && _jsx("div", { className: "godmin-page__tabs", children: tabs }), _jsx(PageBody, { aside: aside, asideLabel: asideLabel, children: list ? (_jsx(ListRegion, { label: listLabel, listRef: listRef, children: children })) : (children) })] }) }) }));
|
|
101
120
|
}
|
|
102
121
|
/**
|
|
103
122
|
* Renders a page's content, beside its aside when it has one.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** The custom validity a WPDS field takes while a server's message stands under it. */
|
|
2
|
+
export interface RejectedValidity {
|
|
3
|
+
/** Always invalid, so the message shows and holds the form back. */
|
|
4
|
+
type: 'invalid';
|
|
5
|
+
/** The words the field shows under it. */
|
|
6
|
+
message: string;
|
|
7
|
+
}
|
|
8
|
+
/** A form control that holds a validity message of its own. */
|
|
9
|
+
type FieldElement = HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement;
|
|
10
|
+
/** What a field takes from the hook, and the way to put a server's message under it. */
|
|
11
|
+
export interface RejectedField {
|
|
12
|
+
/** The ref the field takes, so the hook knows the field it rejects. */
|
|
13
|
+
ref: (field: FieldElement | null) => void;
|
|
14
|
+
/** The custom validity the field takes, none while no message stands. */
|
|
15
|
+
validity: RejectedValidity | undefined;
|
|
16
|
+
/** Puts the message under the field and answers true, or answers false so the caller says it another way. */
|
|
17
|
+
reject: (message: string, sent: string) => boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Holds a server's message about one field under it, until what the message is about changes.
|
|
21
|
+
* @param held - What the message is about now, the value of the field in most forms.
|
|
22
|
+
* @returns The ref and the custom validity the field takes, and the way to reject what was sent.
|
|
23
|
+
*/
|
|
24
|
+
export declare function useRejectedField(held: string): RejectedField;
|
|
25
|
+
export {};
|