@gopherium/godmin 0.30.0 → 0.32.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 +2 -3
- package/dist/base.css +159 -29
- 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 +59 -10
- package/dist/bulk.d.ts +3 -0
- package/dist/confirm-dialog.d.ts +14 -14
- package/dist/confirm-dialog.js +8 -28
- package/dist/dialog-open.d.ts +63 -0
- package/dist/dialog-open.js +110 -0
- package/dist/focus-back.d.ts +20 -0
- package/dist/focus-back.js +36 -12
- package/dist/form-dialog.d.ts +14 -16
- package/dist/form-dialog.js +53 -13
- package/dist/index.d.ts +13 -13
- package/dist/index.js +7 -8
- package/dist/list-chrome/es-ES.js +3 -3
- package/dist/list-chrome/fr-FR.js +1 -0
- package/dist/list-run.js +39 -48
- package/dist/page-breadcrumbs.d.ts +28 -0
- package/dist/page-breadcrumbs.js +18 -0
- package/dist/page-tabs.js +18 -6
- package/dist/page.d.ts +8 -3
- package/dist/page.js +36 -9
- package/dist/rename-dialog.d.ts +24 -0
- package/dist/rename-dialog.js +16 -0
- package/dist/router.d.ts +2 -0
- package/dist/router.js +1 -0
- package/dist/toaster.js +21 -2
- package/dist/unsaved-changes-dialog.d.ts +19 -0
- package/dist/unsaved-changes-dialog.js +33 -0
- package/docs/build-and-versioning.md +92 -9
- package/docs/design-system/accessibility.md +12 -7
- package/docs/design-system/custom-properties.md +6 -2
- package/docs/design-system/dialogs.md +240 -0
- package/docs/design-system/layout.md +5 -3
- package/docs/design-system/lists.md +3 -1
- package/docs/design-system/loading.md +2 -0
- package/docs/design-system/motion.md +3 -2
- package/docs/design-system/overview.md +7 -1
- package/docs/design-system/record-pages.md +199 -0
- package/docs/design-system/toasts.md +13 -10
- package/docs/design-system/typography.md +1 -1
- package/docs/lists.md +321 -434
- package/docs/loading-and-feedback.md +14 -11
- package/docs/overview.md +2 -3
- package/docs/screens.md +87 -34
- package/docs/testing.md +11 -9
- package/package.json +20 -28
- 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
|
@@ -43,6 +43,8 @@ decides how it shows:
|
|
|
43
43
|
page, under the title, as on a WordPress screen.
|
|
44
44
|
- Inside a dialog, when nothing of the dialog body is known yet. It
|
|
45
45
|
shows at once there too.
|
|
46
|
+
[When to ask first](./design-system/dialogs.md#when-to-ask-first)
|
|
47
|
+
says when an action opens a dialog at all.
|
|
46
48
|
- Alone, when nothing of the screen is known yet, such as while the
|
|
47
49
|
session loads before the frame is drawn. It then waits a moment, so
|
|
48
50
|
a fast load shows nothing, and fades in, in the middle of the space
|
|
@@ -199,22 +201,23 @@ Name an item in straight double quotes and in full, like
|
|
|
199
201
|
snackbar, and godmin does not either.
|
|
200
202
|
[Size](./design-system/toasts.md#size) says how a long one wraps.
|
|
201
203
|
|
|
202
|
-
Use a toast for a write that failed
|
|
203
|
-
rows
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
204
|
+
Use a toast for a write that failed too, on a page or in a run over
|
|
205
|
+
list rows. WordPress shows those in its snackbar, never above the
|
|
206
|
+
list, and godmin's list runs do the same. A dialog that closes says
|
|
207
|
+
how its write went in a toast too. A dialog that stays open says why
|
|
208
|
+
inside, as [a failed write](./design-system/dialogs.md#a-failed-write)
|
|
209
|
+
says.
|
|
210
|
+
Say what failed, in the words your server sent when it sent some. A
|
|
211
|
+
server message about one field goes under that field.
|
|
212
|
+
[A failure from a dialog](./lists.md#a-failure-from-a-dialog)
|
|
207
213
|
shows how to raise one from a dialog.
|
|
208
214
|
[Running an action over the picked rows](./lists.md#running-an-action-over-the-picked-rows)
|
|
209
215
|
raises it for you after a run over a list.
|
|
210
216
|
|
|
211
217
|
Keep an [`ErrorNotice`](./screens.md#errornotice) for a failure
|
|
212
|
-
that has to stay on the screen until the user acts
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
content would be.
|
|
216
|
-
- A form on a page of its own, not in a dialog. Show the notice next
|
|
217
|
-
to the form, so the user sees what failed while they fix it.
|
|
218
|
+
that has to stay on the screen until the user acts, such as a screen
|
|
219
|
+
or a list that failed to load. Show the notice where the content
|
|
220
|
+
would be.
|
|
218
221
|
|
|
219
222
|
Skip the toast in three more cases:
|
|
220
223
|
|
package/docs/overview.md
CHANGED
|
@@ -29,11 +29,10 @@ duplicates something the packages above already ship.
|
|
|
29
29
|
|
|
30
30
|
| Entry point | Contents |
|
|
31
31
|
| --- | --- |
|
|
32
|
-
| `@gopherium/godmin` | `AdminRoot`, `Frame`, `Page`, `PageTitle`, `PageTabs`, `PageTab`, `SectionTitle`, `InitialsAvatar`, `NavigationScreen`, `MenuCount`, `ErrorNotice`, `LoadMore`, `LogList`, `LogItem`, `LogTime`, `LoadingScreen`, `Toaster`, `useToaster`, `RepeatRows`, `RowControls`, `useRowKeys`, `keyFromLabel`, `listChromeCatalogFor`, `LIST_CHROME_DOMAIN`, `ListEmpty`, `ListNoResults`, `
|
|
32
|
+
| `@gopherium/godmin` | `AdminRoot`, `Frame`, `Page`, `PageTitle`, `PageTabs`, `PageTab`, `PageBreadcrumbs`, `PageBreadcrumb`, `SectionTitle`, `InitialsAvatar`, `NavigationScreen`, `MenuCount`, `ErrorNotice`, `LoadMore`, `LogList`, `LogItem`, `LogTime`, `LoadingScreen`, `Toaster`, `useToaster`, `RepeatRows`, `RowControls`, `useRowKeys`, `keyFromLabel`, `listChromeCatalogFor`, `LIST_CHROME_DOMAIN`, `ListEmpty`, `ListNoResults`, `ConfirmDialog`, `FormDialog`, `RenameDialog`, `FileButton`, `useServerPaging`, `pageWindow`, `paginationOf`, `runEach`, `bulkNotes`, `useListRun`, `useBulkRun`, `useDialogRun`, `focusInDialog`, `useFocusBack`, `focusedTrigger`, `openOnTap`, `useUnsavedText`, `markLatest`, `viewNarrows`, `offeredView`, `offeredSize`, `sizedView`, `useMediaQuery`, `useTokenDocument`, the breakpoints `HUGE_BREAKPOINT`, `SIDEBAR_BREAKPOINT`, `EDGE_BREAKPOINT`, `DENSE_BREAKPOINT`, `SHEET_BREAKPOINT`, `TITLE_BREAKPOINT` and `SMALL_VIEWPORT`, `SUPPORTED_WPDS` |
|
|
33
33
|
| `@gopherium/godmin/base.css` | Cascade layer order, design tokens, host rules, frame and screen styles |
|
|
34
34
|
| `@gopherium/godmin/dates` | `startListDates`, `listDate`, the only entry that loads `@wordpress/date` |
|
|
35
|
-
| `@gopherium/godmin/
|
|
36
|
-
| `@gopherium/godmin/router` | `Navigation`, `NavigationList`, `NavigationItem`, `DrilldownItem`, `useCanAccess` and the `MenuItem` type with its optional `count`, `useListView`, `listSearch`, `openOnTap`, `useCanvas`, `useFrameLocation`, `routerDefaults`, the `canvas`, `Sidebar` and `capability` route static data |
|
|
35
|
+
| `@gopherium/godmin/router` | `Navigation`, `NavigationList`, `NavigationItem`, `DrilldownItem`, `useCanAccess` and the `MenuItem` type with its optional `count`, `useListView`, `listSearch`, `openOnTap`, `useCanvas`, `useFrameLocation`, `routerDefaults`, `UnsavedChangesDialog`, the `canvas`, `Sidebar` and `capability` route static data |
|
|
37
36
|
| `@gopherium/godmin/testing` | `installTestEnvironment`, `renderAdmin`, `setViewport` and its `TestViewport` type, `getAnnouncement`, `clearAnnouncements`, `assertElementPatched`, `WPDS_IGNORE_SELECTOR`, `textClasses`, `badgeClasses`, `buttonClasses`, `stubLayout` |
|
|
38
37
|
| `@gopherium/godmin/vite` | `godminDedupe`, `godminSingleCopy`, `godminStylesheetFirst`, `duplicateCopies`, `hoistStylesheet` |
|
|
39
38
|
| `@gopherium/godmin/stylelint` | The design system stylelint rules |
|
package/docs/screens.md
CHANGED
|
@@ -19,40 +19,47 @@ one in a component of your own.
|
|
|
19
19
|
</Page>
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
`title` is required and becomes the page's heading, at
|
|
23
|
-
|
|
22
|
+
`title` is required and becomes the page's heading, at the size of a
|
|
23
|
+
WordPress page title. It is an `h1` unless you pass
|
|
24
24
|
`headingLevel`, as [heading levels](#heading-levels) explains.
|
|
25
25
|
`actions` renders top right,
|
|
26
26
|
and `className` and `children` do what they always do. When the
|
|
27
27
|
actions no longer fit beside the title, on a phone for example, they
|
|
28
|
-
move to a line of their own under it.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
page
|
|
28
|
+
move to a line of their own under it. Beside breadcrumbs the title
|
|
29
|
+
gives way first, and the actions move only once it reaches its
|
|
30
|
+
smallest width.
|
|
31
|
+
|
|
32
|
+
`subtitle` renders as one grey line under the title and the actions,
|
|
33
|
+
the way WordPress sets the sentence under a page title. The title row
|
|
34
|
+
keeps its height even with no actions, so the title and the subtitle
|
|
35
|
+
sit in the same place on every page. Give the page compact buttons,
|
|
36
|
+
`size="compact"`, to match the buttons of a WordPress page header. A
|
|
37
|
+
button of the default size makes the row taller.
|
|
38
|
+
[The page header](./design-system/record-pages.md#the-page-header)
|
|
39
|
+
gives the values.
|
|
36
40
|
|
|
37
41
|
`tabs` renders a row of tabs under the title block. See
|
|
38
42
|
[PageTabs](#pagetabs) below.
|
|
39
43
|
|
|
40
|
-
`
|
|
41
|
-
|
|
44
|
+
`breadcrumbs` renders links back to what a record belongs to, before
|
|
45
|
+
the title. See [PageBreadcrumbs](#pagebreadcrumbs) below.
|
|
46
|
+
|
|
47
|
+
`aside` adds the details of a record in a fixed column at the end of
|
|
48
|
+
the page. `asideLabel` names that column for a screen reader:
|
|
42
49
|
|
|
43
50
|
```tsx
|
|
44
|
-
<Page title="Invoice 1042" aside={<InvoiceDetails />}>
|
|
51
|
+
<Page title="Invoice 1042" aside={<InvoiceDetails />} asideLabel="Invoice details">
|
|
45
52
|
<InvoiceLines />
|
|
46
53
|
</Page>
|
|
47
54
|
```
|
|
48
55
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
Put what grows, such as the invoice lines or a history, in the
|
|
57
|
+
content, and the record's own short fields and facts in the aside.
|
|
58
|
+
When the page is too narrow for both, the aside moves under the
|
|
59
|
+
content. An aside that renders nothing takes no room. A page with an
|
|
60
|
+
aside keeps its title in view while the content scrolls under it.
|
|
61
|
+
[Record pages](./design-system/record-pages.md) gives every value, and
|
|
62
|
+
what goes where.
|
|
56
63
|
|
|
57
64
|
`list` marks a page whose content is a list, such as a DataViews
|
|
58
65
|
table. The content then reaches out to the canvas edges, so the
|
|
@@ -84,7 +91,7 @@ and uses `PageTitle` directly, so the page still gets its heading:
|
|
|
84
91
|
<PageTitle>Conversations</PageTitle>
|
|
85
92
|
```
|
|
86
93
|
|
|
87
|
-
It draws the
|
|
94
|
+
It draws the large heading by default. Pass `variant` to change
|
|
88
95
|
the text size, and `level` to change the heading level.
|
|
89
96
|
|
|
90
97
|
## PageTabs
|
|
@@ -130,8 +137,10 @@ navigation region, and a screen reader lists it beside the sidebar,
|
|
|
130
137
|
so the name tells them apart.
|
|
131
138
|
|
|
132
139
|
The tabs look like the WordPress tabs: 13px labels 16px apart, the
|
|
133
|
-
current one underlined by a 2px
|
|
134
|
-
1px light line under the row that runs to the canvas edges.
|
|
140
|
+
current one underlined by a 2px dark line as wide as its label, and a
|
|
141
|
+
1px light line under the row that runs to the canvas edges. A tab
|
|
142
|
+
under the pointer or the keyboard gets a soft shade that reaches 4px
|
|
143
|
+
past its label. The current tab keeps its plain look under the pointer.
|
|
135
144
|
|
|
136
145
|
They are links and not the design system `Tabs` component on
|
|
137
146
|
purpose. `Tabs` switches panels inside one page and moves between
|
|
@@ -140,6 +149,47 @@ link, reached with Tab and marked with `aria-current`, which is how
|
|
|
140
149
|
assistive technology expects page navigation to work. godmin copies
|
|
141
150
|
the look of the WordPress tabs and keeps the behavior of links.
|
|
142
151
|
|
|
152
|
+
## PageBreadcrumbs
|
|
153
|
+
|
|
154
|
+
`PageBreadcrumbs` and `PageBreadcrumb` lead the title of a record with
|
|
155
|
+
links back to what it belongs to, like `Contacts / Maria Perez`, the
|
|
156
|
+
way a WordPress record page names its list:
|
|
157
|
+
|
|
158
|
+
```tsx
|
|
159
|
+
<Page
|
|
160
|
+
title="Maria Perez"
|
|
161
|
+
breadcrumbs={
|
|
162
|
+
<PageBreadcrumbs label="Breadcrumbs">
|
|
163
|
+
<PageBreadcrumb render={<Link to="/contacts" activeOptions={{ exact: true }} />}>Contacts</PageBreadcrumb>
|
|
164
|
+
</PageBreadcrumbs>
|
|
165
|
+
}
|
|
166
|
+
aside={<ContactDetails />}
|
|
167
|
+
>
|
|
168
|
+
<ContactTasks />
|
|
169
|
+
</Page>
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Each breadcrumb is a link. Pass your router's link element as
|
|
173
|
+
`render`, or a plain address as `href`, as with `PageTab`. Leave the
|
|
174
|
+
page on screen out of the list, since its title already names it.
|
|
175
|
+
|
|
176
|
+
No breadcrumb is the current page, yet a router link can mark itself
|
|
177
|
+
as one for screen readers. TanStack Router counts a link to
|
|
178
|
+
`/contacts` as active on `/contacts/42` too, so without
|
|
179
|
+
`activeOptions={{ exact: true }}` a screen reader would hear the
|
|
180
|
+
breadcrumb as the page on screen. Pass it on every breadcrumb link, as
|
|
181
|
+
the example does.
|
|
182
|
+
|
|
183
|
+
`label` names the links for assistive technology. They are a
|
|
184
|
+
navigation region, and a screen reader lists it beside the sidebar and
|
|
185
|
+
any tabs, so the name tells them apart. Translate it.
|
|
186
|
+
|
|
187
|
+
Every page opened from a list takes breadcrumbs, a create page too,
|
|
188
|
+
as in `Contacts / New contact`. Beside breadcrumbs the title stays on
|
|
189
|
+
one line, so a long one ends in an ellipsis.
|
|
190
|
+
[The page header](./design-system/record-pages.md#the-page-header)
|
|
191
|
+
gives the values.
|
|
192
|
+
|
|
143
193
|
## SectionTitle
|
|
144
194
|
|
|
145
195
|
`SectionTitle` heads a section inside a page, one size step above
|
|
@@ -213,10 +263,10 @@ reader came from after Back.
|
|
|
213
263
|
It renders the design system's error notice and announces the
|
|
214
264
|
message to screen readers. Use it wherever you would otherwise
|
|
215
265
|
render a bare error string, such as a screen that failed to load. A
|
|
216
|
-
write that fails
|
|
217
|
-
toast instead, as
|
|
266
|
+
write that fails goes in a toast instead, as
|
|
218
267
|
[what goes in a toast](./loading-and-feedback.md#what-goes-in-a-toast)
|
|
219
|
-
explains.
|
|
268
|
+
explains. A dialog that stays open draws its own notice, as
|
|
269
|
+
[a failed write](./design-system/dialogs.md#a-failed-write) says.
|
|
220
270
|
|
|
221
271
|
## LoadMore
|
|
222
272
|
|
|
@@ -351,7 +401,7 @@ runs into:
|
|
|
351
401
|
|
|
352
402
|
| Name | For |
|
|
353
403
|
| --- | --- |
|
|
354
|
-
| `godmin-form` | A single column form
|
|
404
|
+
| `godmin-form` | A single column form |
|
|
355
405
|
| `godmin-form--inline` | A form that is one row, filling its column |
|
|
356
406
|
| `godmin-form__row` | Short fields side by side inside a form |
|
|
357
407
|
| `godmin-form__grow` | The field of a row that takes most of the free room |
|
|
@@ -380,12 +430,14 @@ A form row puts short fields and a button on one line:
|
|
|
380
430
|
</form>
|
|
381
431
|
```
|
|
382
432
|
|
|
383
|
-
Each field
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
433
|
+
Each field takes a share of the line. The button keeps its own width.
|
|
434
|
+
When the line is too narrow, the fields wrap onto the next line, and
|
|
435
|
+
a button left alone sits at the end of its line. A form that is only
|
|
436
|
+
one row takes `godmin-form--inline`, so it fills its column instead
|
|
437
|
+
of stopping at its width. In a stacked form, a button keeps its own
|
|
438
|
+
width instead of stretching across the form.
|
|
439
|
+
[Forms on a page](./design-system/record-pages.md#forms-on-a-page)
|
|
440
|
+
gives the values.
|
|
389
441
|
|
|
390
442
|
`godmin-table` and `godmin-table-scroll` are a pair, and they solve
|
|
391
443
|
a phone problem: a table wider than the screen drags the whole page
|
|
@@ -400,7 +452,8 @@ instead:
|
|
|
400
452
|
|
|
401
453
|
The scroll rule only activates on a phone, as
|
|
402
454
|
[tables that stay custom](./design-system/lists.md#tables-that-stay-custom)
|
|
403
|
-
gives
|
|
455
|
+
gives, and in a column of a record page at every width. On a phone
|
|
456
|
+
the actions column, the cell marked
|
|
404
457
|
`godmin-table__actions`, stays pinned to the right edge, so a row's
|
|
405
458
|
buttons are in view before any scroll. On a
|
|
406
459
|
desktop the wrapper only draws a focus ring when a keyboard user
|
package/docs/testing.md
CHANGED
|
@@ -135,20 +135,22 @@ setViewport(PHONE)
|
|
|
135
135
|
## Giving elements a layout box
|
|
136
136
|
|
|
137
137
|
jsdom lays nothing out, so no element has a size or a place on the
|
|
138
|
-
screen. The
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
138
|
+
screen. The `Modal` of `@wordpress/components`, such as one your app
|
|
139
|
+
draws itself or one DataViews opens for an action with a
|
|
140
|
+
`RenderModal`, looks for the first element it can focus among those
|
|
141
|
+
on screen, finds none, and leaves the focus where it was.
|
|
142
|
+
A test that checks such a modal put the cursor in its first field
|
|
143
|
+
then fails, though a browser moves the focus there. godmin's own
|
|
144
|
+
dialogs need no box for that. `stubLayout` gives every element one
|
|
145
|
+
small box, as a browser does for an element on screen:
|
|
144
146
|
|
|
145
147
|
```ts
|
|
146
148
|
import { stubLayout } from '@gopherium/godmin/testing'
|
|
147
149
|
|
|
148
|
-
test('
|
|
150
|
+
test('puts the cursor in the note field when the export modal opens', async () => {
|
|
149
151
|
stubLayout()
|
|
150
|
-
await user.click(screen.getByRole('button', { name: '
|
|
151
|
-
await waitFor(() => expect(document.activeElement).toBe(screen.getByRole('
|
|
152
|
+
await user.click(screen.getByRole('button', { name: 'Export' }))
|
|
153
|
+
await waitFor(() => expect(document.activeElement).toBe(screen.getByRole('textbox', { name: 'Note' })))
|
|
152
154
|
})
|
|
153
155
|
```
|
|
154
156
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gopherium/godmin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.0",
|
|
4
4
|
"description": "The admin kit for Gopherium projects: host layer for React admin applications on the WordPress Design System.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -31,10 +31,6 @@
|
|
|
31
31
|
"types": "./dist/dates.d.ts",
|
|
32
32
|
"default": "./dist/dates.js"
|
|
33
33
|
},
|
|
34
|
-
"./dialogs": {
|
|
35
|
-
"types": "./dist/dialogs.d.ts",
|
|
36
|
-
"default": "./dist/dialogs.js"
|
|
37
|
-
},
|
|
38
34
|
"./router": {
|
|
39
35
|
"types": "./dist/router.d.ts",
|
|
40
36
|
"default": "./dist/router.js"
|
|
@@ -60,7 +56,7 @@
|
|
|
60
56
|
"lint:css": "stylelint 'src/**/*.css'",
|
|
61
57
|
"storybook:dev": "storybook dev",
|
|
62
58
|
"storybook:test": "vitest run --project storybook",
|
|
63
|
-
"test:browser": "vitest run --project browser",
|
|
59
|
+
"test:browser": "vitest run --project browser --project scrollbars",
|
|
64
60
|
"typecheck": "tsc --noEmit",
|
|
65
61
|
"prepublishOnly": "pnpm run build"
|
|
66
62
|
},
|
|
@@ -70,15 +66,14 @@
|
|
|
70
66
|
"peerDependencies": {
|
|
71
67
|
"@tanstack/react-router": "^1.170.44",
|
|
72
68
|
"@testing-library/react": "^16.3.2",
|
|
73
|
-
"@wordpress/a11y": ">=
|
|
74
|
-
"@wordpress/
|
|
75
|
-
"@wordpress/
|
|
76
|
-
"@wordpress/
|
|
77
|
-
"@wordpress/
|
|
78
|
-
"@wordpress/
|
|
79
|
-
"@wordpress/
|
|
80
|
-
"@wordpress/
|
|
81
|
-
"@wordpress/ui": ">=0.24.0 <0.25.0",
|
|
69
|
+
"@wordpress/a11y": ">=5.0.0 <6.0.0",
|
|
70
|
+
"@wordpress/dataviews": ">=21.0.0 <22.0.0",
|
|
71
|
+
"@wordpress/date": ">=6.0.0 <7.0.0",
|
|
72
|
+
"@wordpress/i18n": ">=7.0.0 <8.0.0",
|
|
73
|
+
"@wordpress/icons": ">=19.0.0 <20.0.0",
|
|
74
|
+
"@wordpress/style-runtime": ">=0.14.0 <0.15.0",
|
|
75
|
+
"@wordpress/theme": ">=3.0.0 <4.0.0",
|
|
76
|
+
"@wordpress/ui": ">=0.25.0 <0.26.0",
|
|
82
77
|
"react": "^19.2.0",
|
|
83
78
|
"stylelint": "^16 || ^17",
|
|
84
79
|
"vitest": "^4.1.10 || ^5.0.0"
|
|
@@ -90,9 +85,6 @@
|
|
|
90
85
|
"@testing-library/react": {
|
|
91
86
|
"optional": true
|
|
92
87
|
},
|
|
93
|
-
"@wordpress/components": {
|
|
94
|
-
"optional": true
|
|
95
|
-
},
|
|
96
88
|
"@wordpress/dataviews": {
|
|
97
89
|
"optional": true
|
|
98
90
|
},
|
|
@@ -120,16 +112,16 @@
|
|
|
120
112
|
"@vitejs/plugin-react": "^6.0.3",
|
|
121
113
|
"@vitest/browser-playwright": "^5.0.3",
|
|
122
114
|
"@vitest/coverage-v8": "^5.0.3",
|
|
123
|
-
"@wordpress/a11y": "
|
|
124
|
-
"@wordpress/components": "
|
|
125
|
-
"@wordpress/dataviews": "
|
|
126
|
-
"@wordpress/date": "
|
|
127
|
-
"@wordpress/element": "
|
|
128
|
-
"@wordpress/i18n": "
|
|
129
|
-
"@wordpress/icons": "
|
|
130
|
-
"@wordpress/style-runtime": "0.
|
|
131
|
-
"@wordpress/theme": "
|
|
132
|
-
"@wordpress/ui": "0.
|
|
115
|
+
"@wordpress/a11y": "5.0.0",
|
|
116
|
+
"@wordpress/components": "43.0.0",
|
|
117
|
+
"@wordpress/dataviews": "21.0.0",
|
|
118
|
+
"@wordpress/date": "6.0.0",
|
|
119
|
+
"@wordpress/element": "10.0.0",
|
|
120
|
+
"@wordpress/i18n": "7.0.0",
|
|
121
|
+
"@wordpress/icons": "19.0.0",
|
|
122
|
+
"@wordpress/style-runtime": "0.14.0",
|
|
123
|
+
"@wordpress/theme": "3.0.0",
|
|
124
|
+
"@wordpress/ui": "0.25.0",
|
|
133
125
|
"eslint": "^10.7.0",
|
|
134
126
|
"eslint-plugin-jsdoc": "^63.2.0",
|
|
135
127
|
"eslint-plugin-sonarjs": "^4.2.0",
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns the close of a dialog body that acts only while that body is on screen, never on a dialog opened since.
|
|
3
|
-
* @param close - Closes the dialog, none for a body drawn outside a dialog.
|
|
4
|
-
* @returns The close, which does nothing once the body left the screen.
|
|
5
|
-
*/
|
|
6
|
-
export declare function useCloseWhileOpen(close: (() => void) | undefined): () => void;
|
package/dist/close-while-open.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
import { useEffect, useRef } from 'react';
|
|
3
|
-
/**
|
|
4
|
-
* Returns the close of a dialog body that acts only while that body is on screen, never on a dialog opened since.
|
|
5
|
-
* @param close - Closes the dialog, none for a body drawn outside a dialog.
|
|
6
|
-
* @returns The close, which does nothing once the body left the screen.
|
|
7
|
-
*/
|
|
8
|
-
export function useCloseWhileOpen(close) {
|
|
9
|
-
const open = useRef(true);
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
open.current = true;
|
|
12
|
-
return () => {
|
|
13
|
-
open.current = false;
|
|
14
|
-
};
|
|
15
|
-
}, []);
|
|
16
|
-
return () => {
|
|
17
|
-
if (open.current) {
|
|
18
|
-
close?.();
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
}
|
package/dist/confirm.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
export interface ConfirmBodyProps {
|
|
3
|
-
/** The question the modal asks. */
|
|
4
|
-
children: ReactNode;
|
|
5
|
-
/** The label of the button that carries the action out. */
|
|
6
|
-
confirmLabel: string;
|
|
7
|
-
/** The label of the button that closes the modal. */
|
|
8
|
-
cancelLabel: string;
|
|
9
|
-
/** Whether the action is running, the confirm button then busy and Cancel greyed out. */
|
|
10
|
-
busy?: boolean;
|
|
11
|
-
/** Carries the action out. */
|
|
12
|
-
onConfirm: () => void;
|
|
13
|
-
/** Closes the modal. */
|
|
14
|
-
onCancel?: () => void;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Renders a confirmation modal body: the question, an accent text Cancel and the confirm button, 20px apart.
|
|
18
|
-
* @param props - The question, the labels, the busy flag and the handlers.
|
|
19
|
-
* @returns The confirmation body.
|
|
20
|
-
*/
|
|
21
|
-
export declare function ConfirmBody({ children, confirmLabel, cancelLabel, busy, onConfirm, onCancel, }: ConfirmBodyProps): import("react").JSX.Element;
|
package/dist/confirm.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { Button, Stack, Text } from '@wordpress/ui';
|
|
4
|
-
/**
|
|
5
|
-
* Renders a confirmation modal body: the question, an accent text Cancel and the confirm button, 20px apart.
|
|
6
|
-
* @param props - The question, the labels, the busy flag and the handlers.
|
|
7
|
-
* @returns The confirmation body.
|
|
8
|
-
*/
|
|
9
|
-
export function ConfirmBody({ children, confirmLabel, cancelLabel, busy = false, onConfirm, onCancel, }) {
|
|
10
|
-
return (_jsxs("div", { className: "godmin-modal-body", children: [_jsx(Text, { className: "godmin-modal-body__question", children: children }), _jsxs(Stack, { direction: "row", gap: "sm", justify: "flex-end", children: [_jsx(Button, { variant: "minimal", disabled: busy, onClick: onCancel, children: cancelLabel }), _jsx(Button, { loading: busy, onClick: onConfirm, children: confirmLabel })] })] }));
|
|
11
|
-
}
|
package/dist/dialogs.d.ts
DELETED
package/dist/dialogs.js
DELETED
package/dist/form.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
/** What a form does, which sets the space above its buttons as WordPress spaces it. */
|
|
3
|
-
export type FormKind = 'edit' | 'copy' | 'create';
|
|
4
|
-
/** The props of the body of a form modal. */
|
|
5
|
-
export interface FormBodyProps {
|
|
6
|
-
/** The fields, and any help sentence before them, in the order the reader meets them. */
|
|
7
|
-
children: ReactNode;
|
|
8
|
-
/** The label of the button that sends the form. */
|
|
9
|
-
submitLabel: string;
|
|
10
|
-
/** The label of the button that closes the modal. */
|
|
11
|
-
cancelLabel: string;
|
|
12
|
-
/** Whether the form may be sent now, false while a needed field is empty, true when left out. */
|
|
13
|
-
canSubmit?: boolean;
|
|
14
|
-
/** Whether the write runs, the submit button then busy and a second send ignored. */
|
|
15
|
-
busy?: boolean;
|
|
16
|
-
/** What the form does: 20px above the buttons for an edit, the default, 12px for a copy, 16px for a create. */
|
|
17
|
-
kind?: FormKind;
|
|
18
|
-
/** Sends the form, from the submit button or Enter in a field. */
|
|
19
|
-
onSubmit: () => void;
|
|
20
|
-
/** Closes the modal. */
|
|
21
|
-
onCancel?: () => void;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Renders the body of a form modal: the fields, an accent text Cancel and the submit button.
|
|
25
|
-
* @param props - The fields, the labels, the send gate, the busy flag, the kind and the handlers.
|
|
26
|
-
* @returns The form.
|
|
27
|
-
*/
|
|
28
|
-
export declare function FormBody({ children, submitLabel, cancelLabel, canSubmit, busy, kind, onSubmit, onCancel, }: FormBodyProps): import("react").JSX.Element;
|
package/dist/form.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { Button, Stack } from '@wordpress/ui';
|
|
4
|
-
/** The classes of a form body of each kind. */
|
|
5
|
-
const KIND_CLASSES = {
|
|
6
|
-
edit: 'godmin-modal-body',
|
|
7
|
-
copy: 'godmin-modal-body godmin-modal-body--copy',
|
|
8
|
-
create: 'godmin-modal-body godmin-modal-body--create',
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Renders the body of a form modal: the fields, an accent text Cancel and the submit button.
|
|
12
|
-
* @param props - The fields, the labels, the send gate, the busy flag, the kind and the handlers.
|
|
13
|
-
* @returns The form.
|
|
14
|
-
*/
|
|
15
|
-
export function FormBody({ children, submitLabel, cancelLabel, canSubmit = true, busy = false, kind = 'edit', onSubmit, onCancel, }) {
|
|
16
|
-
const sendable = canSubmit && !busy;
|
|
17
|
-
return (_jsxs("form", { className: KIND_CLASSES[kind], onSubmit: (event) => {
|
|
18
|
-
event.preventDefault();
|
|
19
|
-
if (sendable) {
|
|
20
|
-
onSubmit();
|
|
21
|
-
}
|
|
22
|
-
}, children: [children, _jsxs(Stack, { direction: "row", gap: "sm", justify: "flex-end", children: [_jsx(Button, { variant: "minimal", onClick: onCancel, children: cancelLabel }), _jsx(Button, { type: "submit", loading: busy, disabled: !sendable, children: submitLabel })] })] }));
|
|
23
|
-
}
|
package/dist/rename.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export interface RenameBodyProps {
|
|
2
|
-
/** The text the field starts with: the name the item carries, or the name a failed write turned away. */
|
|
3
|
-
name: string;
|
|
4
|
-
/** The label of the name field. */
|
|
5
|
-
fieldLabel: string;
|
|
6
|
-
/** The label of the button that writes the new name. */
|
|
7
|
-
submitLabel: string;
|
|
8
|
-
/** The label of the button that closes the modal. */
|
|
9
|
-
cancelLabel: string;
|
|
10
|
-
/** Writes the name as typed, the one the item already has included. */
|
|
11
|
-
onSubmit: (name: string) => void;
|
|
12
|
-
/** Closes the modal. */
|
|
13
|
-
onCancel?: () => void;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Renders the body of a rename modal: the name field, an accent text Cancel and the submit button, off while blank.
|
|
17
|
-
* @param props - The first name, the labels and the handlers.
|
|
18
|
-
* @returns The rename form.
|
|
19
|
-
*/
|
|
20
|
-
export declare function RenameBody({ name, fieldLabel, submitLabel, cancelLabel, onSubmit, onCancel }: RenameBodyProps): import("react").JSX.Element;
|
package/dist/rename.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { InputControl } from '@wordpress/ui';
|
|
4
|
-
import { useState } from 'react';
|
|
5
|
-
import { FormBody } from './form.js';
|
|
6
|
-
/**
|
|
7
|
-
* Renders the body of a rename modal: the name field, an accent text Cancel and the submit button, off while blank.
|
|
8
|
-
* @param props - The first name, the labels and the handlers.
|
|
9
|
-
* @returns The rename form.
|
|
10
|
-
*/
|
|
11
|
-
export function RenameBody({ name, fieldLabel, submitLabel, cancelLabel, onSubmit, onCancel }) {
|
|
12
|
-
const [value, setValue] = useState(name);
|
|
13
|
-
return (_jsx(FormBody, { submitLabel: submitLabel, cancelLabel: cancelLabel, canSubmit: value.trim() !== '', onSubmit: () => onSubmit(value), onCancel: onCancel, children: _jsx(InputControl, { label: fieldLabel, value: value, onChange: (event) => setValue(event.target.value) }) }));
|
|
14
|
-
}
|
package/dist/run-confirm.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
/** The props of a run confirm, the first two as a DataViews modal hands them. */
|
|
3
|
-
export interface RunConfirmProps<Item> {
|
|
4
|
-
/** The items the action runs over. */
|
|
5
|
-
items: Item[];
|
|
6
|
-
/** Closes the modal. */
|
|
7
|
-
closeModal?: () => void;
|
|
8
|
-
/** The question the modal asks. */
|
|
9
|
-
children: ReactNode;
|
|
10
|
-
/** The label of the button that starts the run. */
|
|
11
|
-
confirmLabel: string;
|
|
12
|
-
/** The label of the button that closes the modal. */
|
|
13
|
-
cancelLabel: string;
|
|
14
|
-
/** Runs the action over the items, settling once the list shows how it went. */
|
|
15
|
-
run: (items: Item[]) => Promise<unknown>;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Renders a confirmation that runs the action, keeps Cancel inert while it runs and closes only itself once it settles.
|
|
19
|
-
* @param props - The items, the close handler, the question, the labels and the run.
|
|
20
|
-
* @returns The confirmation body.
|
|
21
|
-
*/
|
|
22
|
-
export declare function RunConfirm<Item>({ items, closeModal, children, confirmLabel, cancelLabel, run, }: RunConfirmProps<Item>): import("react").JSX.Element;
|
package/dist/run-confirm.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { useState } from 'react';
|
|
4
|
-
import { useCloseWhileOpen } from './close-while-open.js';
|
|
5
|
-
import { ConfirmBody } from './confirm.js';
|
|
6
|
-
/**
|
|
7
|
-
* Renders a confirmation that runs the action, keeps Cancel inert while it runs and closes only itself once it settles.
|
|
8
|
-
* @param props - The items, the close handler, the question, the labels and the run.
|
|
9
|
-
* @returns The confirmation body.
|
|
10
|
-
*/
|
|
11
|
-
export function RunConfirm({ items, closeModal, children, confirmLabel, cancelLabel, run, }) {
|
|
12
|
-
const [busy, setBusy] = useState(false);
|
|
13
|
-
const close = useCloseWhileOpen(closeModal);
|
|
14
|
-
return (_jsx(ConfirmBody, { confirmLabel: confirmLabel, cancelLabel: cancelLabel, busy: busy, onCancel: closeModal, onConfirm: () => {
|
|
15
|
-
setBusy(true);
|
|
16
|
-
void Promise.resolve()
|
|
17
|
-
.then(() => run(items))
|
|
18
|
-
.finally(() => {
|
|
19
|
-
setBusy(false);
|
|
20
|
-
close();
|
|
21
|
-
});
|
|
22
|
-
}, children: children }));
|
|
23
|
-
}
|