@gopherium/godmin 0.13.0 → 0.14.1
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 +1 -1
- package/dist/avatar.d.ts +21 -0
- package/dist/avatar.js +42 -0
- package/dist/base.css +409 -20
- package/dist/breakpoints.d.ts +5 -1
- package/dist/breakpoints.js +5 -1
- package/dist/frame.js +4 -4
- package/dist/index.d.ts +7 -1
- package/dist/index.js +4 -1
- package/dist/list-chrome/es-ES.d.ts +4 -0
- package/dist/list-chrome/es-ES.js +147 -0
- package/dist/list-chrome.d.ts +10 -0
- package/dist/list-chrome.js +15 -0
- package/dist/page-tabs.d.ts +31 -0
- package/dist/page-tabs.js +36 -0
- package/dist/page.d.ts +5 -4
- package/dist/page.js +5 -6
- package/dist/toaster.d.ts +7 -2
- package/dist/toaster.js +122 -24
- package/dist/vite.js +1 -0
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ two lines do for you.
|
|
|
47
47
|
|
|
48
48
|
| Entry point | Contents |
|
|
49
49
|
| --- | --- |
|
|
50
|
-
| `@gopherium/godmin` | `AdminRoot`, `Frame`, `Page`, `PageTitle`, `SectionTitle`, `NavScreen`, `ErrorNotice`, `LoadMore`, `LogList`, `LogItem`, `LogTime`, `LoadingScreen`, `LoadingRows`, `Toaster`, `useToaster`, `RepeatRows`, `RowControls`, `useRowKeys`, `keyFromLabel`, `useMediaQuery`, `useTokenDocument`, the breakpoints, `SUPPORTED_WPDS` |
|
|
50
|
+
| `@gopherium/godmin` | `AdminRoot`, `Frame`, `Page`, `PageTitle`, `PageTabs`, `PageTab`, `SectionTitle`, `InitialsAvatar`, `NavScreen`, `ErrorNotice`, `LoadMore`, `LogList`, `LogItem`, `LogTime`, `LoadingScreen`, `LoadingRows`, `Toaster`, `useToaster`, `RepeatRows`, `RowControls`, `useRowKeys`, `keyFromLabel`, `listChromeCatalogFor`, `LIST_CHROME_DOMAIN`, `useMediaQuery`, `useTokenDocument`, the breakpoints, `SUPPORTED_WPDS` |
|
|
51
51
|
| `@gopherium/godmin/base.css` | Cascade layer order, design tokens, host rules, frame and screen styles |
|
|
52
52
|
| `@gopherium/godmin/router` | `useCanvas`, `useFrameLocation`, the `canvas` route static data |
|
|
53
53
|
| `@gopherium/godmin/testing` | `installTestEnvironment`, `renderAdmin`, `setViewport`, `getAnnouncement`, `clearAnnouncements`, `assertElementPatched`, `WPDS_IGNORE_SELECTOR` |
|
package/dist/avatar.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** A circle colour of the initials avatar and the colour its letter takes on it. */
|
|
2
|
+
export interface AvatarColor {
|
|
3
|
+
/** The circle colour as #rrggbb. */
|
|
4
|
+
background: string;
|
|
5
|
+
/** The letter colour as #rrggbb. */
|
|
6
|
+
letter: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The colours an initials avatar paints with, the WordPress blue, raspberry and purple first with their pale letters.
|
|
10
|
+
*/
|
|
11
|
+
export declare const AVATAR_COLORS: readonly AvatarColor[];
|
|
12
|
+
export interface InitialsAvatarProps {
|
|
13
|
+
/** The name the avatar stands for, whose first letter it draws. */
|
|
14
|
+
name: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Renders a round avatar with the first letter of a name, in the letter colour of the circle colour the name picks.
|
|
18
|
+
* @param props - The name the avatar stands for.
|
|
19
|
+
* @returns The avatar element.
|
|
20
|
+
*/
|
|
21
|
+
export declare function InitialsAvatar({ name }: InitialsAvatarProps): import("react").JSX.Element;
|
package/dist/avatar.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* The colours an initials avatar paints with, the WordPress blue, raspberry and purple first with their pale letters.
|
|
4
|
+
*/
|
|
5
|
+
export const AVATAR_COLORS = [
|
|
6
|
+
{ background: '#3b59e4', letter: '#f7ecbd' },
|
|
7
|
+
{ background: '#c6396e', letter: '#ecfaf4' },
|
|
8
|
+
{ background: '#964c9a', letter: '#deefdd' },
|
|
9
|
+
{ background: '#007017', letter: '#ffffff' },
|
|
10
|
+
{ background: '#996800', letter: '#ffffff' },
|
|
11
|
+
{ background: '#50575e', letter: '#ffffff' },
|
|
12
|
+
];
|
|
13
|
+
/**
|
|
14
|
+
* Returns the palette colours a name always gets, whatever its case.
|
|
15
|
+
* @param name - The name the avatar stands for.
|
|
16
|
+
* @returns The circle and letter colours.
|
|
17
|
+
*/
|
|
18
|
+
function colorFor(name) {
|
|
19
|
+
let hash = 0;
|
|
20
|
+
for (const letter of name.trim().toLocaleLowerCase()) {
|
|
21
|
+
hash = (hash * 31 + letter.codePointAt(0)) % 2147483647;
|
|
22
|
+
}
|
|
23
|
+
return AVATAR_COLORS[hash % AVATAR_COLORS.length];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns the first letter of a name in capitals, or nothing for an empty name.
|
|
27
|
+
* @param name - The name the avatar stands for.
|
|
28
|
+
* @returns The letter to draw.
|
|
29
|
+
*/
|
|
30
|
+
function initialOf(name) {
|
|
31
|
+
const [first = ''] = Array.from(name.trim());
|
|
32
|
+
return first.toLocaleUpperCase();
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Renders a round avatar with the first letter of a name, in the letter colour of the circle colour the name picks.
|
|
36
|
+
* @param props - The name the avatar stands for.
|
|
37
|
+
* @returns The avatar element.
|
|
38
|
+
*/
|
|
39
|
+
export function InitialsAvatar({ name }) {
|
|
40
|
+
const { background, letter } = colorFor(name);
|
|
41
|
+
return (_jsx("span", { className: "godmin-avatar", "aria-hidden": "true", style: { backgroundColor: background, color: letter }, children: initialOf(name) }));
|
|
42
|
+
}
|
package/dist/base.css
CHANGED
|
@@ -12,6 +12,76 @@ body {
|
|
|
12
12
|
position: relative;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
/* Keeps the sticky DataViews toolbar and filters of a list page at the edge the list reaches. */
|
|
16
|
+
.godmin-page > .godmin-page__list :is(.dataviews__view-actions, .dataviews-filters__container) {
|
|
17
|
+
inset-inline-start: calc(-1 * var(--godmin-canvas-gutter, 0px));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/* Keeps the sticky DataViews footer of a list page or a list inside a page on the canvas bottom. */
|
|
21
|
+
.godmin-page > .godmin-page__list .dataviews-footer,
|
|
22
|
+
.godmin-list .dataviews-footer {
|
|
23
|
+
inset-block-end: calc(-1 * var(--godmin-canvas-gutter-block, 0px));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/* Draws a DataViews title link without an underline, as WordPress does. */
|
|
27
|
+
.dataviews-title-field--clickable {
|
|
28
|
+
text-decoration: none;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* Draws a DataViews media link without an underline or the browser link colour. */
|
|
32
|
+
.dataviews-column-primary__media--clickable {
|
|
33
|
+
color: inherit;
|
|
34
|
+
text-decoration: none;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* Sets the name 8px after an initials avatar in a DataViews table. */
|
|
38
|
+
.dataviews-column-primary__media:has(> .godmin-avatar) {
|
|
39
|
+
margin-inline-end: calc(var(--wpds-dimension-gap-sm) - var(--wpds-dimension-gap-md));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/* Fills the larger media box of the DataViews list with an initials avatar. */
|
|
43
|
+
.dataviews-view-list .dataviews-view-list__media-wrapper:has(> .godmin-avatar) {
|
|
44
|
+
container-type: size;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.dataviews-view-list .dataviews-view-list__media-wrapper > .godmin-avatar {
|
|
48
|
+
inline-size: 100%;
|
|
49
|
+
block-size: 100%;
|
|
50
|
+
font-size: 37.5cqi;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* Rounds the DataViews media box around an initials avatar. */
|
|
54
|
+
.dataviews-column-primary__media:has(> .godmin-avatar),
|
|
55
|
+
.dataviews-view-list .dataviews-view-list__media-wrapper:has(> .godmin-avatar) {
|
|
56
|
+
border-radius: 50%;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* Drops the dark DataViews media ring around an initials avatar. */
|
|
60
|
+
.dataviews-column-primary__media:has(> .godmin-avatar)::after,
|
|
61
|
+
.dataviews-view-list .dataviews-view-list__media-wrapper:has(> .godmin-avatar)::after {
|
|
62
|
+
box-shadow: none;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* Centres the media of a list row on its title and description. */
|
|
66
|
+
.godmin-page__list .dataviews-view-table tbody .dataviews-column-primary__media {
|
|
67
|
+
align-self: center;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* Sets a list title and its description as the WordPress list does, a 64px row for both. */
|
|
71
|
+
.godmin-page__list .dataviews-view-table tbody .dataviews-view-table__primary-column-content {
|
|
72
|
+
justify-content: center;
|
|
73
|
+
gap: var(--wpds-dimension-gap-xs);
|
|
74
|
+
min-block-size: var(--wpds-dimension-size-md);
|
|
75
|
+
font-size: var(--wpds-typography-font-size-sm);
|
|
76
|
+
line-height: var(--wpds-typography-line-height-xs);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.godmin-page__list .dataviews-view-table tbody .dataviews-view-table__primary-column-content > .dataviews-title-field {
|
|
80
|
+
min-block-size: 0;
|
|
81
|
+
font-weight: var(--wpds-typography-font-weight-default);
|
|
82
|
+
line-height: var(--wpds-typography-line-height-sm);
|
|
83
|
+
}
|
|
84
|
+
|
|
15
85
|
@layer godmin {
|
|
16
86
|
body {
|
|
17
87
|
margin: 0;
|
|
@@ -22,6 +92,11 @@ body {
|
|
|
22
92
|
}
|
|
23
93
|
|
|
24
94
|
@layer godmin {
|
|
95
|
+
:root {
|
|
96
|
+
--godmin-rail-width: 300px;
|
|
97
|
+
--godmin-canvas-margin: 16px;
|
|
98
|
+
}
|
|
99
|
+
|
|
25
100
|
.godmin-layout {
|
|
26
101
|
display: flex;
|
|
27
102
|
height: 100vh;
|
|
@@ -38,7 +113,7 @@ body {
|
|
|
38
113
|
display: flex;
|
|
39
114
|
flex-direction: column;
|
|
40
115
|
flex-shrink: 0;
|
|
41
|
-
width:
|
|
116
|
+
width: var(--godmin-rail-width);
|
|
42
117
|
padding: 16px;
|
|
43
118
|
box-sizing: border-box;
|
|
44
119
|
overflow-y: auto;
|
|
@@ -49,7 +124,28 @@ body {
|
|
|
49
124
|
flex-shrink: 0;
|
|
50
125
|
align-items: center;
|
|
51
126
|
gap: 8px;
|
|
52
|
-
|
|
127
|
+
block-size: 46px;
|
|
128
|
+
padding-inline-end: 16px;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.godmin-layout__menu {
|
|
132
|
+
display: flex;
|
|
133
|
+
flex: none;
|
|
134
|
+
padding: 0;
|
|
135
|
+
border: 0;
|
|
136
|
+
background: none;
|
|
137
|
+
color: color-mix(in srgb, var(--wpds-color-foreground-content-neutral) 60%, transparent);
|
|
138
|
+
cursor: var(--wpds-cursor-control);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.godmin-layout__menu:is(:hover, :focus-visible) {
|
|
142
|
+
background: var(--wpds-color-background-interactive-neutral-weak-active);
|
|
143
|
+
color: var(--wpds-color-foreground-interactive-brand);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.godmin-layout__menu:focus-visible {
|
|
147
|
+
outline: var(--wpds-border-width-focus) solid var(--wpds-color-stroke-focus);
|
|
148
|
+
outline-offset: calc(-1 * var(--wpds-border-width-focus));
|
|
53
149
|
}
|
|
54
150
|
|
|
55
151
|
.godmin-layout__drawer {
|
|
@@ -61,15 +157,18 @@ body {
|
|
|
61
157
|
}
|
|
62
158
|
|
|
63
159
|
.godmin-layout__canvas {
|
|
160
|
+
--godmin-canvas-gutter: 24px;
|
|
161
|
+
--godmin-canvas-gutter-block: var(--wpds-dimension-padding-lg);
|
|
162
|
+
--wp-dataviews-color-background: var(--wpds-color-background-surface-neutral-strong);
|
|
64
163
|
display: flex;
|
|
65
164
|
flex-direction: column;
|
|
66
165
|
flex: 1;
|
|
67
166
|
min-width: 0;
|
|
68
|
-
margin:
|
|
69
|
-
padding:
|
|
167
|
+
margin: var(--godmin-canvas-margin);
|
|
168
|
+
padding: var(--godmin-canvas-gutter-block) var(--godmin-canvas-gutter);
|
|
70
169
|
box-sizing: border-box;
|
|
71
170
|
border-radius: var(--wpds-border-radius-xl);
|
|
72
|
-
background: var(--wpds-color-background-surface-neutral);
|
|
171
|
+
background: var(--wpds-color-background-surface-neutral-strong);
|
|
73
172
|
color: var(--wpds-color-foreground-content-neutral);
|
|
74
173
|
box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
|
|
75
174
|
overflow-x: hidden;
|
|
@@ -77,17 +176,116 @@ body {
|
|
|
77
176
|
}
|
|
78
177
|
|
|
79
178
|
.godmin-layout__canvas--bleed {
|
|
80
|
-
|
|
179
|
+
--godmin-canvas-gutter: 0px;
|
|
180
|
+
--godmin-canvas-gutter-block: 0px;
|
|
81
181
|
overflow: hidden;
|
|
82
182
|
}
|
|
83
183
|
|
|
184
|
+
.godmin-layout:has(> .godmin-layout__rail) .godmin-layout__canvas {
|
|
185
|
+
margin-inline-start: 0;
|
|
186
|
+
}
|
|
187
|
+
|
|
84
188
|
.godmin-toasts {
|
|
85
189
|
position: fixed;
|
|
86
|
-
|
|
87
|
-
bottom:
|
|
190
|
+
inset-inline: 0;
|
|
191
|
+
bottom: 32px;
|
|
88
192
|
z-index: 1;
|
|
89
|
-
|
|
90
|
-
|
|
193
|
+
display: flex;
|
|
194
|
+
flex-direction: column;
|
|
195
|
+
align-items: center;
|
|
196
|
+
gap: var(--wpds-dimension-gap-sm);
|
|
197
|
+
padding-inline: 16px;
|
|
198
|
+
box-sizing: border-box;
|
|
199
|
+
pointer-events: none;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
:root:has(.godmin-layout__rail) .godmin-toasts {
|
|
203
|
+
inset-inline-start: var(--godmin-rail-width);
|
|
204
|
+
inset-inline-end: var(--godmin-canvas-margin);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.godmin-toasts:focus {
|
|
208
|
+
outline: none;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.godmin-toast {
|
|
212
|
+
display: flex;
|
|
213
|
+
align-items: baseline;
|
|
214
|
+
justify-content: space-between;
|
|
215
|
+
width: fit-content;
|
|
216
|
+
max-width: var(--wpds-dimension-surface-width-lg);
|
|
217
|
+
box-sizing: border-box;
|
|
218
|
+
padding: var(--wpds-dimension-padding-md) var(--wpds-dimension-padding-xl);
|
|
219
|
+
border-radius: var(--wpds-border-radius-md);
|
|
220
|
+
background: rgb(0 0 0 / 0.85);
|
|
221
|
+
backdrop-filter: blur(16px) saturate(180%);
|
|
222
|
+
box-shadow:
|
|
223
|
+
0 1px 2px rgb(0 0 0 / 0.05),
|
|
224
|
+
0 2px 3px rgb(0 0 0 / 0.04),
|
|
225
|
+
0 6px 6px rgb(0 0 0 / 0.03),
|
|
226
|
+
0 8px 8px rgb(0 0 0 / 0.02);
|
|
227
|
+
color: #fff;
|
|
228
|
+
font-family: var(--wpds-typography-font-family-body);
|
|
229
|
+
font-size: var(--wpds-typography-font-size-md);
|
|
230
|
+
line-height: 1.4;
|
|
231
|
+
overflow-wrap: anywhere;
|
|
232
|
+
cursor: default;
|
|
233
|
+
pointer-events: auto;
|
|
234
|
+
animation: godmin-fade-in var(--wpds-motion-duration-md) var(--wpds-motion-easing-balanced);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.godmin-toast--leaving {
|
|
238
|
+
animation: godmin-fade-out var(--wpds-motion-duration-sm) var(--wpds-motion-easing-balanced) forwards;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.godmin-toast--plain {
|
|
242
|
+
margin: 0;
|
|
243
|
+
border: 0;
|
|
244
|
+
text-align: start;
|
|
245
|
+
cursor: var(--wpds-cursor-control);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.godmin-toast__action {
|
|
249
|
+
flex: none;
|
|
250
|
+
margin-inline-start: var(--wpds-dimension-gap-2xl);
|
|
251
|
+
padding: 0;
|
|
252
|
+
border: 0;
|
|
253
|
+
background: none;
|
|
254
|
+
color: inherit;
|
|
255
|
+
font: inherit;
|
|
256
|
+
line-height: normal;
|
|
257
|
+
text-decoration: underline;
|
|
258
|
+
text-underline-offset: 0.2em;
|
|
259
|
+
text-decoration-thickness: from-font;
|
|
260
|
+
cursor: var(--wpds-cursor-control);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.godmin-toast__action:hover {
|
|
264
|
+
text-decoration: none;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.godmin-toast__dismiss {
|
|
268
|
+
flex: none;
|
|
269
|
+
margin-inline-start: var(--wpds-dimension-gap-xl);
|
|
270
|
+
padding: 0;
|
|
271
|
+
border: 0;
|
|
272
|
+
background: none;
|
|
273
|
+
color: inherit;
|
|
274
|
+
font: inherit;
|
|
275
|
+
cursor: var(--wpds-cursor-control);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
.godmin-toast--plain:focus-visible {
|
|
279
|
+
box-shadow:
|
|
280
|
+
inset 0 0 0 var(--wpds-border-width-xs) #fff,
|
|
281
|
+
0 0 0 var(--wpds-border-width-focus) var(--wpds-color-stroke-focus);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.godmin-toast__action:focus-visible {
|
|
285
|
+
outline: var(--wpds-border-width-xs) dotted #fff;
|
|
286
|
+
outline-offset: 2px;
|
|
287
|
+
border-radius: var(--wpds-border-radius-sm);
|
|
288
|
+
text-decoration: none;
|
|
91
289
|
}
|
|
92
290
|
|
|
93
291
|
.godmin-nav-screen__title {
|
|
@@ -114,7 +312,12 @@ body {
|
|
|
114
312
|
color: var(--wpds-color-foreground-content-neutral-weak);
|
|
115
313
|
}
|
|
116
314
|
|
|
315
|
+
.godmin-page__head {
|
|
316
|
+
min-block-size: var(--wpds-dimension-size-lg);
|
|
317
|
+
}
|
|
318
|
+
|
|
117
319
|
.godmin-page__subtitle {
|
|
320
|
+
padding-block-end: var(--wpds-dimension-padding-xs);
|
|
118
321
|
color: var(--wpds-color-foreground-content-neutral-weak);
|
|
119
322
|
}
|
|
120
323
|
|
|
@@ -139,6 +342,111 @@ body {
|
|
|
139
342
|
display: none;
|
|
140
343
|
}
|
|
141
344
|
|
|
345
|
+
.godmin-page:has(> .godmin-page__list) {
|
|
346
|
+
flex: 1 0 auto;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
.godmin-page:has(> .godmin-page__list > .dataviews-wrapper) {
|
|
350
|
+
flex-shrink: 1;
|
|
351
|
+
min-block-size: 0;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
.godmin-page > .godmin-page__list,
|
|
355
|
+
.godmin-page__main > .godmin-page__list {
|
|
356
|
+
display: flex;
|
|
357
|
+
flex-direction: column;
|
|
358
|
+
gap: var(--wpds-dimension-gap-lg);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
.godmin-page > .godmin-page__list {
|
|
362
|
+
flex: 1 0 auto;
|
|
363
|
+
margin-inline: calc(-1 * var(--godmin-canvas-gutter, 0px));
|
|
364
|
+
margin-block-end: calc(-1 * var(--godmin-canvas-gutter-block, 0px));
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
.godmin-page > .godmin-page__list:has(> .dataviews-wrapper) {
|
|
368
|
+
flex-shrink: 1;
|
|
369
|
+
min-block-size: 0;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
.godmin-list {
|
|
373
|
+
margin-inline: calc(-1 * min(var(--wpds-dimension-padding-2xl), var(--godmin-canvas-gutter, 0px)));
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
.godmin-page > .godmin-page__list > :not(.dataviews-wrapper, .godmin-table-scroll, .godmin-table) {
|
|
377
|
+
margin-inline: var(--wpds-dimension-padding-2xl);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
.godmin-page__tabs {
|
|
381
|
+
margin-inline: calc(-1 * var(--godmin-canvas-gutter, 0px));
|
|
382
|
+
padding-inline: var(--godmin-canvas-gutter, 0px);
|
|
383
|
+
border-block-end: var(--wpds-border-width-xs) solid var(--wpds-color-stroke-surface-neutral-weak);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
.godmin-page:has(> .godmin-page__list) > .godmin-page__tabs {
|
|
387
|
+
padding-inline: var(--wpds-dimension-padding-2xl);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
.godmin-page > .godmin-page__tabs + .godmin-page__list:has(> .dataviews-wrapper:first-child) {
|
|
391
|
+
margin-block-start: calc(-1 * var(--wpds-dimension-gap-lg));
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
.godmin-page-tabs {
|
|
395
|
+
display: flex;
|
|
396
|
+
gap: var(--wpds-dimension-gap-lg);
|
|
397
|
+
overflow-x: auto;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
.godmin-page-tabs__tab {
|
|
401
|
+
display: flex;
|
|
402
|
+
align-items: center;
|
|
403
|
+
position: relative;
|
|
404
|
+
block-size: 48px;
|
|
405
|
+
padding: 0;
|
|
406
|
+
color: var(--wpds-color-foreground-interactive-neutral);
|
|
407
|
+
font-family: var(--wpds-typography-font-family-body);
|
|
408
|
+
font-size: var(--wpds-typography-font-size-md);
|
|
409
|
+
font-weight: var(--wpds-typography-font-weight-default);
|
|
410
|
+
line-height: 1.2;
|
|
411
|
+
text-decoration: none;
|
|
412
|
+
white-space: nowrap;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
.godmin-page-tabs__tab:is(:hover, :focus-visible) {
|
|
416
|
+
color: var(--wpds-color-foreground-interactive-neutral-active);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
.godmin-page-tabs__tab:focus-visible {
|
|
420
|
+
outline: none;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
.godmin-page-tabs__tab::before {
|
|
424
|
+
content: '';
|
|
425
|
+
position: absolute;
|
|
426
|
+
inset: var(--wpds-dimension-padding-md) var(--wpds-border-width-focus);
|
|
427
|
+
border-radius: var(--wpds-border-radius-sm);
|
|
428
|
+
outline: var(--wpds-border-width-focus) solid var(--wpds-color-stroke-focus);
|
|
429
|
+
opacity: 0;
|
|
430
|
+
pointer-events: none;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
.godmin-page-tabs__tab:focus-visible::before {
|
|
434
|
+
opacity: 1;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
.godmin-page-tabs__tab--current::after {
|
|
438
|
+
content: '';
|
|
439
|
+
position: absolute;
|
|
440
|
+
inset-inline: 0;
|
|
441
|
+
inset-block-end: 0;
|
|
442
|
+
block-size: var(--wpds-border-width-focus);
|
|
443
|
+
background: var(--wpds-color-stroke-interactive-neutral-strong);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
.godmin-page:has(> .godmin-page__list) > .godmin-page__header {
|
|
447
|
+
padding-inline: calc(var(--wpds-dimension-padding-2xl) - var(--godmin-canvas-gutter, 0px));
|
|
448
|
+
}
|
|
449
|
+
|
|
142
450
|
.godmin-form {
|
|
143
451
|
display: flex;
|
|
144
452
|
flex-direction: column;
|
|
@@ -183,19 +491,62 @@ body {
|
|
|
183
491
|
.godmin-table {
|
|
184
492
|
width: 100%;
|
|
185
493
|
border-collapse: collapse;
|
|
494
|
+
font-size: var(--wpds-typography-font-size-md);
|
|
495
|
+
line-height: var(--wpds-typography-line-height-sm);
|
|
186
496
|
text-align: left;
|
|
187
497
|
}
|
|
188
498
|
|
|
189
499
|
.godmin-table th,
|
|
190
500
|
.godmin-table td {
|
|
191
|
-
padding:
|
|
192
|
-
border-bottom: 1px solid var(--wpds-color-stroke-surface-neutral);
|
|
501
|
+
padding: var(--wpds-dimension-padding-md);
|
|
193
502
|
vertical-align: middle;
|
|
194
503
|
}
|
|
195
504
|
|
|
196
|
-
.godmin-table th {
|
|
197
|
-
|
|
198
|
-
|
|
505
|
+
.godmin-table thead th {
|
|
506
|
+
padding-block: var(--wpds-dimension-padding-sm);
|
|
507
|
+
font-size: var(--wpds-typography-font-size-xs);
|
|
508
|
+
font-weight: var(--wpds-typography-font-weight-emphasis);
|
|
509
|
+
text-transform: uppercase;
|
|
510
|
+
color: var(--wpds-color-foreground-content-neutral);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
.godmin-table tbody tr {
|
|
514
|
+
border-block-start: var(--wpds-border-width-xs) solid var(--wpds-color-stroke-surface-neutral-weak);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
.godmin-table tbody td {
|
|
518
|
+
height: var(--wpds-dimension-size-md);
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
.godmin-page > .godmin-page__list .godmin-table tr > :first-child {
|
|
522
|
+
padding-inline-start: var(--wpds-dimension-padding-2xl);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
.godmin-page > .godmin-page__list .godmin-table tr > :last-child {
|
|
526
|
+
padding-inline-end: var(--wpds-dimension-padding-2xl);
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
.godmin-table__title {
|
|
530
|
+
font-weight: var(--wpds-typography-font-weight-emphasis);
|
|
531
|
+
color: var(--wpds-color-foreground-content-neutral);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
.godmin-page__list .godmin-table__title {
|
|
535
|
+
font-weight: var(--wpds-typography-font-weight-default);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
.godmin-table__title a {
|
|
539
|
+
color: var(--wpds-color-foreground-interactive-neutral);
|
|
540
|
+
text-decoration: none;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
.godmin-table__title a:hover {
|
|
544
|
+
color: var(--wpds-color-foreground-interactive-brand);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
.godmin-table__title a:focus-visible {
|
|
548
|
+
outline: var(--wpds-border-width-focus) solid var(--wpds-color-stroke-focus);
|
|
549
|
+
outline-offset: 2px;
|
|
199
550
|
}
|
|
200
551
|
|
|
201
552
|
.godmin-table__actions {
|
|
@@ -203,6 +554,22 @@ body {
|
|
|
203
554
|
white-space: nowrap;
|
|
204
555
|
}
|
|
205
556
|
|
|
557
|
+
.godmin-avatar {
|
|
558
|
+
display: inline-block;
|
|
559
|
+
text-align: center;
|
|
560
|
+
align-content: center;
|
|
561
|
+
flex: none;
|
|
562
|
+
inline-size: var(--wpds-dimension-size-md);
|
|
563
|
+
block-size: var(--wpds-dimension-size-md);
|
|
564
|
+
border-radius: 50%;
|
|
565
|
+
font-family: var(--wpds-typography-font-family-body);
|
|
566
|
+
font-size: var(--wpds-typography-font-size-sm);
|
|
567
|
+
font-weight: var(--wpds-typography-font-weight-emphasis);
|
|
568
|
+
line-height: 1;
|
|
569
|
+
text-box: trim-both cap alphabetic;
|
|
570
|
+
user-select: none;
|
|
571
|
+
}
|
|
572
|
+
|
|
206
573
|
.godmin-table__actions * {
|
|
207
574
|
white-space: nowrap;
|
|
208
575
|
}
|
|
@@ -238,10 +605,21 @@ body {
|
|
|
238
605
|
}
|
|
239
606
|
}
|
|
240
607
|
|
|
608
|
+
@keyframes godmin-fade-out {
|
|
609
|
+
0% {
|
|
610
|
+
opacity: 1;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
100% {
|
|
614
|
+
opacity: 0;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
|
|
241
618
|
@media (prefers-reduced-motion: reduce) {
|
|
242
619
|
.godmin-loading-screen,
|
|
243
620
|
.godmin-loading-rows,
|
|
244
|
-
.godmin-arrival
|
|
621
|
+
.godmin-arrival,
|
|
622
|
+
.godmin-toast {
|
|
245
623
|
animation-duration: 1ms;
|
|
246
624
|
}
|
|
247
625
|
}
|
|
@@ -370,16 +748,21 @@ body {
|
|
|
370
748
|
|
|
371
749
|
/* Small viewport overrides live together at the end of the sheet, so they
|
|
372
750
|
always win over the rules above them without extra specificity. */
|
|
373
|
-
@media (max-width:
|
|
751
|
+
@media (max-width: 781px) {
|
|
374
752
|
.godmin-layout__canvas {
|
|
375
753
|
margin: 0;
|
|
376
|
-
padding: 16px;
|
|
377
754
|
border-radius: 0;
|
|
378
755
|
box-shadow: none;
|
|
379
756
|
}
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
@media (max-width: 639px) {
|
|
760
|
+
.godmin-layout__canvas {
|
|
761
|
+
--godmin-canvas-gutter: 16px;
|
|
762
|
+
}
|
|
380
763
|
|
|
381
764
|
.godmin-layout__canvas--bleed {
|
|
382
|
-
|
|
765
|
+
--godmin-canvas-gutter: 0px;
|
|
383
766
|
}
|
|
384
767
|
|
|
385
768
|
/* The region needs a containing block, or absolutely positioned content
|
|
@@ -392,7 +775,7 @@ body {
|
|
|
392
775
|
.godmin-table-scroll .godmin-table__actions {
|
|
393
776
|
position: sticky;
|
|
394
777
|
inset-inline-end: 0;
|
|
395
|
-
background: var(--wpds-color-background-surface-neutral);
|
|
778
|
+
background: var(--wpds-color-background-surface-neutral-strong);
|
|
396
779
|
box-shadow: inset var(--wpds-border-width-xs) 0 0 var(--wpds-color-stroke-surface-neutral);
|
|
397
780
|
}
|
|
398
781
|
|
|
@@ -400,4 +783,10 @@ body {
|
|
|
400
783
|
box-shadow: inset calc(-1 * var(--wpds-border-width-xs)) 0 0 var(--wpds-color-stroke-surface-neutral);
|
|
401
784
|
}
|
|
402
785
|
}
|
|
786
|
+
|
|
787
|
+
@media (max-width: 599px) {
|
|
788
|
+
.godmin-toast {
|
|
789
|
+
width: 100%;
|
|
790
|
+
}
|
|
791
|
+
}
|
|
403
792
|
}
|
package/dist/breakpoints.d.ts
CHANGED
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export declare const RAIL_BREAKPOINT = 1024;
|
|
5
5
|
/**
|
|
6
|
-
* The viewport width below which the canvas meets the screen edges.
|
|
6
|
+
* The viewport width below which the canvas meets the screen edges, the WordPress medium breakpoint.
|
|
7
|
+
*/
|
|
8
|
+
export declare const EDGE_BREAKPOINT = 782;
|
|
9
|
+
/**
|
|
10
|
+
* The viewport width below which the canvas gutter narrows to 16px.
|
|
7
11
|
*/
|
|
8
12
|
export declare const DENSE_BREAKPOINT = 640;
|
|
9
13
|
/**
|
package/dist/breakpoints.js
CHANGED
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const RAIL_BREAKPOINT = 1024;
|
|
5
5
|
/**
|
|
6
|
-
* The viewport width below which the canvas meets the screen edges.
|
|
6
|
+
* The viewport width below which the canvas meets the screen edges, the WordPress medium breakpoint.
|
|
7
|
+
*/
|
|
8
|
+
export const EDGE_BREAKPOINT = 782;
|
|
9
|
+
/**
|
|
10
|
+
* The viewport width below which the canvas gutter narrows to 16px.
|
|
7
11
|
*/
|
|
8
12
|
export const DENSE_BREAKPOINT = 640;
|
|
9
13
|
/**
|
package/dist/frame.js
CHANGED
|
@@ -2,14 +2,14 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
/* oxlint-disable react/only-export-components -- a compound component is an
|
|
3
3
|
object export standing beside the parts it is built from. */
|
|
4
4
|
import { ThemeProvider } from '@wordpress/theme';
|
|
5
|
-
import { Drawer,
|
|
5
|
+
import { Drawer, VisuallyHidden } from '@wordpress/ui';
|
|
6
6
|
import { createContext, useContext, useEffect, useState } from 'react';
|
|
7
7
|
import { SMALL_VIEWPORT } from './breakpoints.js';
|
|
8
8
|
import { useMediaQuery } from './use-media-query.js';
|
|
9
9
|
/**
|
|
10
|
-
* The glyph on the button that opens the rail drawer.
|
|
10
|
+
* The glyph on the button that opens the rail drawer, drawn where the admin bar menu toggle draws its bars.
|
|
11
11
|
*/
|
|
12
|
-
const menuIcon = (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0
|
|
12
|
+
const menuIcon = (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "52", height: "46", viewBox: "0 0 52 46", fill: "currentColor", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "M11 11h28v4H11zm0 10h28v4H11zm0 10h28v4H11z" }) }));
|
|
13
13
|
const FrameContext = createContext({ small: false, location: undefined, layout: null });
|
|
14
14
|
/**
|
|
15
15
|
* Frames an admin application, folding its rail away on a narrow viewport.
|
|
@@ -48,7 +48,7 @@ function TopBar({ children, brand, menuLabel, }) {
|
|
|
48
48
|
useEffect(() => {
|
|
49
49
|
setOpen(false);
|
|
50
50
|
}, [location]);
|
|
51
|
-
return (_jsxs("div", { className: "godmin-layout__topbar", children: [_jsxs(Drawer.Root, { open: open, onOpenChange: setOpen, children: [_jsx(Drawer.Trigger, { render: _jsx(
|
|
51
|
+
return (_jsxs("div", { className: "godmin-layout__topbar", children: [_jsxs(Drawer.Root, { open: open, onOpenChange: setOpen, children: [_jsx(Drawer.Trigger, { render: _jsx("button", { type: "button", className: "godmin-layout__menu", "aria-label": menuLabel }), children: menuIcon }), _jsxs(Drawer.Popup, { className: "godmin-layout__drawer", portal: _jsx(Drawer.Portal, { container: layout }), children: [_jsx(VisuallyHidden, { render: _jsx(Drawer.Title, {}), children: menuLabel }), children] })] }), brand] }));
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* Renders the region showing the active screen.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
export { AdminRoot } from './admin-root.js';
|
|
2
2
|
export type { AdminRootProps } from './admin-root.js';
|
|
3
|
-
export {
|
|
3
|
+
export { InitialsAvatar } from './avatar.js';
|
|
4
|
+
export type { InitialsAvatarProps } from './avatar.js';
|
|
5
|
+
export { DENSE_BREAKPOINT, EDGE_BREAKPOINT, RAIL_BREAKPOINT, SMALL_VIEWPORT } from './breakpoints.js';
|
|
4
6
|
export { Frame } from './frame.js';
|
|
5
7
|
export type { CanvasMode, FrameCanvasProps, FrameRailProps, FrameRootProps, } from './frame.js';
|
|
6
8
|
export { keyFromLabel } from './keys.js';
|
|
7
9
|
export type { KeyOptions, KeyStyle } from './keys.js';
|
|
10
|
+
export { LIST_CHROME_DOMAIN, listChromeCatalogFor } from './list-chrome.js';
|
|
11
|
+
export type { ListChromeCatalog } from './list-chrome.js';
|
|
8
12
|
export { LoadingRows, LoadingScreen } from './loading.js';
|
|
9
13
|
export { LogItem, LogList, LogTime } from './log-list.js';
|
|
10
14
|
export type { LogItemProps, LogListProps, LogTimeProps } from './log-list.js';
|
|
@@ -12,6 +16,8 @@ export { NavScreen } from './nav-screen.js';
|
|
|
12
16
|
export type { NavScreenProps } from './nav-screen.js';
|
|
13
17
|
export { ErrorNotice, LoadMore, Page, PageTitle, SectionTitle } from './page.js';
|
|
14
18
|
export type { LoadMoreQuery, PageProps } from './page.js';
|
|
19
|
+
export { PageTab, PageTabs } from './page-tabs.js';
|
|
20
|
+
export type { PageTabProps, PageTabsProps } from './page-tabs.js';
|
|
15
21
|
export { useRowKeys } from './row-keys.js';
|
|
16
22
|
export type { RowBounds, RowKeys } from './row-keys.js';
|
|
17
23
|
export { RepeatRows, RowControls } from './rows.js';
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
export { AdminRoot } from './admin-root.js';
|
|
3
|
-
export {
|
|
3
|
+
export { InitialsAvatar } from './avatar.js';
|
|
4
|
+
export { DENSE_BREAKPOINT, EDGE_BREAKPOINT, RAIL_BREAKPOINT, SMALL_VIEWPORT } from './breakpoints.js';
|
|
4
5
|
export { Frame } from './frame.js';
|
|
5
6
|
export { keyFromLabel } from './keys.js';
|
|
7
|
+
export { LIST_CHROME_DOMAIN, listChromeCatalogFor } from './list-chrome.js';
|
|
6
8
|
export { LoadingRows, LoadingScreen } from './loading.js';
|
|
7
9
|
export { LogItem, LogList, LogTime } from './log-list.js';
|
|
8
10
|
export { NavScreen } from './nav-screen.js';
|
|
9
11
|
export { ErrorNotice, LoadMore, Page, PageTitle, SectionTitle } from './page.js';
|
|
12
|
+
export { PageTab, PageTabs } from './page-tabs.js';
|
|
10
13
|
export { useRowKeys } from './row-keys.js';
|
|
11
14
|
export { RepeatRows, RowControls } from './rows.js';
|
|
12
15
|
export { Toaster, useToaster } from './toaster.js';
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
/** The Spanish list chrome, compiled from the es-ES.po source beside it. */
|
|
3
|
+
const catalog = {
|
|
4
|
+
'': { lang: 'es-ES', 'plural-forms': 'nplurals=2; plural=(n != 1);' },
|
|
5
|
+
'%1$d of %2$d Item': ['%1$d de %2$d elemento', '%1$d de %2$d elementos'],
|
|
6
|
+
'%1$s: %2$s': ['%1$s: %2$s'],
|
|
7
|
+
'%d Item': ['%d elemento', '%d elementos'],
|
|
8
|
+
'%d Item selected': ['%d elemento seleccionado', '%d elementos seleccionados'],
|
|
9
|
+
'%s: <groupName />': ['%s: <groupName />'],
|
|
10
|
+
'(no title)': ['(sin título)'],
|
|
11
|
+
'<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>': [
|
|
12
|
+
'<Name>%1$s entre (incl.): </Name><Value>%2$s y %3$s</Value>',
|
|
13
|
+
],
|
|
14
|
+
'<Name>%1$s contains: </Name><Value>%2$s</Value>': [
|
|
15
|
+
'<Name>%1$s contiene: </Name><Value>%2$s</Value>',
|
|
16
|
+
],
|
|
17
|
+
"<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>": [
|
|
18
|
+
'<Name>%1$s no contiene: </Name><Value>%2$s</Value>',
|
|
19
|
+
],
|
|
20
|
+
'<Name>%1$s includes all: </Name><Value>%2$s</Value>': [
|
|
21
|
+
'<Name>%1$s incluye todos: </Name><Value>%2$s</Value>',
|
|
22
|
+
],
|
|
23
|
+
'<Name>%1$s includes: </Name><Value>%2$s</Value>': [
|
|
24
|
+
'<Name>%1$s incluye: </Name><Value>%2$s</Value>',
|
|
25
|
+
],
|
|
26
|
+
'<Name>%1$s is after: </Name><Value>%2$s</Value>': [
|
|
27
|
+
'<Name>%1$s es posterior a: </Name><Value>%2$s</Value>',
|
|
28
|
+
],
|
|
29
|
+
'<Name>%1$s is before: </Name><Value>%2$s</Value>': [
|
|
30
|
+
'<Name>%1$s es anterior a: </Name><Value>%2$s</Value>',
|
|
31
|
+
],
|
|
32
|
+
'<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>': [
|
|
33
|
+
'<Name>%1$s es mayor o igual que: </Name><Value>%2$s</Value>',
|
|
34
|
+
],
|
|
35
|
+
'<Name>%1$s is greater than: </Name><Value>%2$s</Value>': [
|
|
36
|
+
'<Name>%1$s es mayor que: </Name><Value>%2$s</Value>',
|
|
37
|
+
],
|
|
38
|
+
'<Name>%1$s is in the past: </Name><Value>%2$s</Value>': [
|
|
39
|
+
'<Name>%1$s en los últimos: </Name><Value>%2$s</Value>',
|
|
40
|
+
],
|
|
41
|
+
'<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>': [
|
|
42
|
+
'<Name>%1$s es menor o igual que: </Name><Value>%2$s</Value>',
|
|
43
|
+
],
|
|
44
|
+
'<Name>%1$s is less than: </Name><Value>%2$s</Value>': [
|
|
45
|
+
'<Name>%1$s es menor que: </Name><Value>%2$s</Value>',
|
|
46
|
+
],
|
|
47
|
+
'<Name>%1$s is none of: </Name><Value>%2$s</Value>': [
|
|
48
|
+
'<Name>%1$s no es ninguno de: </Name><Value>%2$s</Value>',
|
|
49
|
+
],
|
|
50
|
+
'<Name>%1$s is not: </Name><Value>%2$s</Value>': [
|
|
51
|
+
'<Name>%1$s no es: </Name><Value>%2$s</Value>',
|
|
52
|
+
],
|
|
53
|
+
'<Name>%1$s is on or after: </Name><Value>%2$s</Value>': [
|
|
54
|
+
'<Name>%1$s es igual o posterior a: </Name><Value>%2$s</Value>',
|
|
55
|
+
],
|
|
56
|
+
'<Name>%1$s is on or before: </Name><Value>%2$s</Value>': [
|
|
57
|
+
'<Name>%1$s es igual o anterior a: </Name><Value>%2$s</Value>',
|
|
58
|
+
],
|
|
59
|
+
'<Name>%1$s is over: </Name><Value>%2$s</Value>': [
|
|
60
|
+
'<Name>%1$s hace más de: </Name><Value>%2$s</Value>',
|
|
61
|
+
],
|
|
62
|
+
'<Name>%1$s is: </Name><Value>%2$s</Value>': [
|
|
63
|
+
'<Name>%1$s es: </Name><Value>%2$s</Value>',
|
|
64
|
+
],
|
|
65
|
+
'<Name>%1$s starts with: </Name><Value>%2$s</Value>': [
|
|
66
|
+
'<Name>%1$s empieza por: </Name><Value>%2$s</Value>',
|
|
67
|
+
],
|
|
68
|
+
Actions: ['Acciones'],
|
|
69
|
+
Activity: ['Actividad'],
|
|
70
|
+
'Add filter': ['Añadir filtro'],
|
|
71
|
+
After: ['Después de'],
|
|
72
|
+
'After (inc)': ['Después de (incl.)'],
|
|
73
|
+
Appearance: ['Apariencia'],
|
|
74
|
+
'Automatically load more content as you scroll, instead of showing pagination links.': [
|
|
75
|
+
'Carga más contenido de forma automática al desplazarte, en lugar de mostrar enlaces de paginación.',
|
|
76
|
+
],
|
|
77
|
+
Before: ['Antes de'],
|
|
78
|
+
'Before (inc)': ['Antes de (incl.)'],
|
|
79
|
+
'Between (inc)': ['Entre (incl.)'],
|
|
80
|
+
Cancel: ['Cancelar'],
|
|
81
|
+
Close: ['Cerrar'],
|
|
82
|
+
Conditions: ['Condiciones'],
|
|
83
|
+
Contains: ['Contiene'],
|
|
84
|
+
'Current page': ['Página actual'],
|
|
85
|
+
Density: ['Densidad'],
|
|
86
|
+
'Density option for DataView layout\u0004Balanced': ['Equilibrada'],
|
|
87
|
+
'Density option for DataView layout\u0004Comfortable': ['Cómoda'],
|
|
88
|
+
'Density option for DataView layout\u0004Compact': ['Compacta'],
|
|
89
|
+
'Deselect all': ['Deseleccionar todo'],
|
|
90
|
+
"Doesn't contain": ['No contiene'],
|
|
91
|
+
'Enable infinite scroll': ['Activar el desplazamiento infinito'],
|
|
92
|
+
False: ['Falso'],
|
|
93
|
+
'Filter by: %1$s': ['Filtrar por: %1$s'],
|
|
94
|
+
'Greater than': ['Mayor que'],
|
|
95
|
+
'Greater than or equal': ['Mayor o igual que'],
|
|
96
|
+
Grid: ['Cuadrícula'],
|
|
97
|
+
'Hide column': ['Ocultar columna'],
|
|
98
|
+
'In the past': ['En los últimos'],
|
|
99
|
+
Includes: ['Incluye'],
|
|
100
|
+
'Includes all': ['Incluye todos'],
|
|
101
|
+
'Insert left': ['Insertar a la izquierda'],
|
|
102
|
+
'Insert right': ['Insertar a la derecha'],
|
|
103
|
+
Is: ['Es'],
|
|
104
|
+
'Is none of': ['No es ninguno de'],
|
|
105
|
+
'Is not': ['No es'],
|
|
106
|
+
'Items per page': ['Elementos por página'],
|
|
107
|
+
Layout: ['Diseño'],
|
|
108
|
+
'Less than': ['Menor que'],
|
|
109
|
+
'Less than or equal': ['Menor o igual que'],
|
|
110
|
+
List: ['Lista'],
|
|
111
|
+
'List of: %1$s': ['Lista de: %1$s'],
|
|
112
|
+
'Move left': ['Mover a la izquierda'],
|
|
113
|
+
'Move right': ['Mover a la derecha'],
|
|
114
|
+
'Navigate to item': ['Ir al elemento'],
|
|
115
|
+
'Next page': ['Página siguiente'],
|
|
116
|
+
'No elements found': ['No se han encontrado elementos'],
|
|
117
|
+
'No results': ['Sin resultados'],
|
|
118
|
+
'No results found': ['No se han encontrado resultados'],
|
|
119
|
+
'Not on': ['No en la fecha'],
|
|
120
|
+
On: ['En la fecha'],
|
|
121
|
+
Order: ['Orden'],
|
|
122
|
+
'Original aspect ratio': ['Proporción original'],
|
|
123
|
+
Over: ['Hace más de'],
|
|
124
|
+
'Page %1$d of %2$d': ['Página %1$d de %2$d'],
|
|
125
|
+
'Preview size': ['Tamaño de la vista previa'],
|
|
126
|
+
'Previous page': ['Página anterior'],
|
|
127
|
+
Properties: ['Propiedades'],
|
|
128
|
+
Remove: ['Quitar'],
|
|
129
|
+
Reset: ['Restablecer'],
|
|
130
|
+
'Reset search': ['Restablecer la búsqueda'],
|
|
131
|
+
'Reset view': ['Restablecer la vista'],
|
|
132
|
+
'Row %d': ['Fila %d'],
|
|
133
|
+
Search: ['Buscar'],
|
|
134
|
+
'Search items': ['Buscar elementos'],
|
|
135
|
+
'Select all': ['Seleccionar todo'],
|
|
136
|
+
'Sort ascending': ['Orden ascendente'],
|
|
137
|
+
'Sort by': ['Ordenar por'],
|
|
138
|
+
'Sort descending': ['Orden descendente'],
|
|
139
|
+
'Starts with': ['Empieza por'],
|
|
140
|
+
Table: ['Tabla'],
|
|
141
|
+
True: ['Verdadero'],
|
|
142
|
+
'Unknown status for %1$s': ['Estado desconocido de %1$s'],
|
|
143
|
+
'View is used as a noun\u0004View options': ['Opciones de vista'],
|
|
144
|
+
'paging\u0004<div>Page</div>%1$s<div>of %2$d</div>': ['<div>Página</div>%1$s<div>de %2$d</div>'],
|
|
145
|
+
'verb\u0004Filter': ['Filtrar'],
|
|
146
|
+
};
|
|
147
|
+
export default catalog;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** A compiled catalogue as the i18n runtime reads it, the metadata entry first. */
|
|
2
|
+
export type ListChromeCatalog = Record<string, string[] | Record<string, string>>;
|
|
3
|
+
/** The text domain the WordPress list chrome reads its strings from. */
|
|
4
|
+
export declare const LIST_CHROME_DOMAIN = "default";
|
|
5
|
+
/**
|
|
6
|
+
* Returns the list chrome catalogue this package ships for a language.
|
|
7
|
+
* @param locale - The language the reader settled on.
|
|
8
|
+
* @returns The catalogue, or nothing when the package ships none for it.
|
|
9
|
+
*/
|
|
10
|
+
export declare function listChromeCatalogFor(locale: string): Promise<ListChromeCatalog | undefined>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
/** The text domain the WordPress list chrome reads its strings from. */
|
|
3
|
+
export const LIST_CHROME_DOMAIN = 'default';
|
|
4
|
+
/** The list chrome catalogue this package ships for each language it has one for. */
|
|
5
|
+
const SHIPPED = {
|
|
6
|
+
'es-ES': () => import('./list-chrome/es-ES.js'),
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Returns the list chrome catalogue this package ships for a language.
|
|
10
|
+
* @param locale - The language the reader settled on.
|
|
11
|
+
* @returns The catalogue, or nothing when the package ships none for it.
|
|
12
|
+
*/
|
|
13
|
+
export async function listChromeCatalogFor(locale) {
|
|
14
|
+
return Object.hasOwn(SHIPPED, locale) ? (await SHIPPED[locale]()).default : undefined;
|
|
15
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
2
|
+
export interface PageTabsProps {
|
|
3
|
+
/** The name of the tab navigation, read by assistive technology. */
|
|
4
|
+
label: string;
|
|
5
|
+
/** The tabs, one PageTab each. */
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Renders the tabs of a page as a navigation region of links.
|
|
10
|
+
* @param props - The navigation name and the tabs.
|
|
11
|
+
* @returns The tab navigation element.
|
|
12
|
+
*/
|
|
13
|
+
export declare function PageTabs({ label, children }: PageTabsProps): import("react").JSX.Element;
|
|
14
|
+
export interface PageTabProps {
|
|
15
|
+
/** The address the tab leads to, when it renders as a plain link. */
|
|
16
|
+
href?: string;
|
|
17
|
+
/** The link element the tab renders through, such as a router link. */
|
|
18
|
+
render?: ReactElement<{
|
|
19
|
+
className?: string;
|
|
20
|
+
}>;
|
|
21
|
+
/** Whether the tab leads to the page on screen, which alone decides the underline. */
|
|
22
|
+
current?: boolean;
|
|
23
|
+
/** The tab label. */
|
|
24
|
+
children: ReactNode;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Renders one page tab as a link, marked and underlined as the current page when it leads to the page on screen.
|
|
28
|
+
* @param props - The address or the link element, whether it is current, and the label.
|
|
29
|
+
* @returns The tab link element.
|
|
30
|
+
*/
|
|
31
|
+
export declare function PageTab({ href, render, current, children }: PageTabProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cloneElement } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Renders the tabs of a page as a navigation region of links.
|
|
5
|
+
* @param props - The navigation name and the tabs.
|
|
6
|
+
* @returns The tab navigation element.
|
|
7
|
+
*/
|
|
8
|
+
export function PageTabs({ label, children }) {
|
|
9
|
+
return (_jsx("nav", { className: "godmin-page-tabs", "aria-label": label, children: children }));
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The class every page tab carries.
|
|
13
|
+
*/
|
|
14
|
+
const TAB_CLASS = 'godmin-page-tabs__tab';
|
|
15
|
+
/**
|
|
16
|
+
* The class that underlines the tab of the page on screen.
|
|
17
|
+
*/
|
|
18
|
+
const CURRENT_CLASS = 'godmin-page-tabs__tab--current';
|
|
19
|
+
/**
|
|
20
|
+
* Renders one page tab as a link, marked and underlined as the current page when it leads to the page on screen.
|
|
21
|
+
* @param props - The address or the link element, whether it is current, and the label.
|
|
22
|
+
* @returns The tab link element.
|
|
23
|
+
*/
|
|
24
|
+
export function PageTab({ href, render, current = false, children }) {
|
|
25
|
+
const ariaCurrent = current ? 'page' : undefined;
|
|
26
|
+
const tabClass = current ? `${TAB_CLASS} ${CURRENT_CLASS}` : TAB_CLASS;
|
|
27
|
+
if (render === undefined) {
|
|
28
|
+
return (_jsx("a", { href: href, className: tabClass, "aria-current": ariaCurrent, children: children }));
|
|
29
|
+
}
|
|
30
|
+
const own = render.props.className;
|
|
31
|
+
return cloneElement(render, {
|
|
32
|
+
className: own === undefined ? tabClass : `${own} ${tabClass}`,
|
|
33
|
+
'aria-current': ariaCurrent,
|
|
34
|
+
children,
|
|
35
|
+
});
|
|
36
|
+
}
|
package/dist/page.d.ts
CHANGED
|
@@ -25,17 +25,18 @@ export interface PageProps {
|
|
|
25
25
|
title: string;
|
|
26
26
|
subtitle?: string;
|
|
27
27
|
actions?: ReactNode;
|
|
28
|
+
tabs?: ReactNode;
|
|
28
29
|
aside?: ReactNode;
|
|
30
|
+
list?: boolean;
|
|
29
31
|
className?: string;
|
|
30
32
|
children: ReactNode;
|
|
31
33
|
}
|
|
32
34
|
/**
|
|
33
|
-
* Renders a screen:
|
|
34
|
-
*
|
|
35
|
-
* @param props - The title, subtitle, actions, aside, extra class and content.
|
|
35
|
+
* Renders a screen: a header with the title, actions and subtitle, then optional tabs and the content.
|
|
36
|
+
* @param props - The title, subtitle, actions, tabs, aside, list flag, extra class and content.
|
|
36
37
|
* @returns The page element.
|
|
37
38
|
*/
|
|
38
|
-
export declare function Page({ title, subtitle, actions, aside, className, children }: PageProps): import("react").JSX.Element;
|
|
39
|
+
export declare function Page({ title, subtitle, actions, tabs, aside, list, className, children }: PageProps): import("react").JSX.Element;
|
|
39
40
|
/**
|
|
40
41
|
* Renders a failure message that a screen reader announces.
|
|
41
42
|
* @param props - The message to announce.
|
package/dist/page.js
CHANGED
|
@@ -7,7 +7,7 @@ import { Button, Notice, Stack, Text } from '@wordpress/ui';
|
|
|
7
7
|
* @param props - The title text and the type scale to render it at.
|
|
8
8
|
* @returns The page title element.
|
|
9
9
|
*/
|
|
10
|
-
export function PageTitle({ children, variant = 'heading-
|
|
10
|
+
export function PageTitle({ children, variant = 'heading-lg', }) {
|
|
11
11
|
return (_jsx(Text, { variant: variant, render: _jsx("h1", {}), children: children }));
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
@@ -20,14 +20,13 @@ export function SectionTitle({ children, level = 2, id, tabIndex, }) {
|
|
|
20
20
|
return (_jsx(Text, { variant: second ? 'heading-lg' : 'heading-md', render: second ? _jsx("h2", {}) : _jsx("h3", {}), id: id, tabIndex: tabIndex, children: children }));
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
|
-
* Renders a screen:
|
|
24
|
-
*
|
|
25
|
-
* @param props - The title, subtitle, actions, aside, extra class and content.
|
|
23
|
+
* Renders a screen: a header with the title, actions and subtitle, then optional tabs and the content.
|
|
24
|
+
* @param props - The title, subtitle, actions, tabs, aside, list flag, extra class and content.
|
|
26
25
|
* @returns The page element.
|
|
27
26
|
*/
|
|
28
|
-
export function Page({ title, subtitle, actions, aside, className, children }) {
|
|
27
|
+
export function Page({ title, subtitle, actions, tabs, aside, list = false, className, children }) {
|
|
29
28
|
const classes = className === undefined ? 'godmin-page' : `godmin-page ${className}`;
|
|
30
|
-
return (_jsxs(Stack, { direction: "column", gap: "lg", className: classes, children: [_jsxs(Stack, { direction: "
|
|
29
|
+
return (_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(PageTitle, { children: title }), 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, children: list ? _jsx("div", { className: "godmin-page__list", children: children }) : children })] }));
|
|
31
30
|
}
|
|
32
31
|
/**
|
|
33
32
|
* Renders a page's content, beside its aside when it has one.
|
package/dist/toaster.d.ts
CHANGED
|
@@ -12,13 +12,18 @@ export interface ToasterHandle {
|
|
|
12
12
|
*/
|
|
13
13
|
export declare function useToaster(): ToasterHandle;
|
|
14
14
|
export interface ToasterProps {
|
|
15
|
+
/** The tree the toast region wraps. */
|
|
15
16
|
children: ReactNode;
|
|
17
|
+
/** How many milliseconds a toast nobody touches stays on screen. */
|
|
16
18
|
dismissAfter?: number;
|
|
19
|
+
/** The name of the close button, also the hint screen readers hear that a click clears a plain toast. */
|
|
17
20
|
dismissLabel?: string;
|
|
21
|
+
/** How many toasts stay on screen at once, the oldest leaving first. */
|
|
22
|
+
limit?: number;
|
|
18
23
|
}
|
|
19
24
|
/**
|
|
20
25
|
* Renders the region holding raised messages around the given tree.
|
|
21
|
-
* @param props - The tree the region wraps, how long a toast stays,
|
|
26
|
+
* @param props - The tree the region wraps, how long a toast stays, the dismiss control name and how many stay.
|
|
22
27
|
* @returns The wrapped tree with its region.
|
|
23
28
|
*/
|
|
24
|
-
export declare function Toaster({ children, dismissAfter, dismissLabel, }: ToasterProps): import("react").JSX.Element;
|
|
29
|
+
export declare function Toaster({ children, dismissAfter, dismissLabel, limit, }: ToasterProps): import("react").JSX.Element;
|
package/dist/toaster.js
CHANGED
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/* oxlint-disable react/only-export-components -- the region ships beside the
|
|
3
3
|
hook that reaches it. */
|
|
4
|
-
import {
|
|
5
|
-
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
|
+
import { speak } from '@wordpress/a11y';
|
|
5
|
+
import { createContext, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, } from 'react';
|
|
6
6
|
/**
|
|
7
7
|
* How long a toast nobody touches stays on screen.
|
|
8
8
|
*/
|
|
9
|
-
const DISMISS_AFTER =
|
|
9
|
+
const DISMISS_AFTER = 6000;
|
|
10
10
|
/**
|
|
11
11
|
* The name of the control clearing a toast.
|
|
12
12
|
*/
|
|
13
13
|
const DISMISS_LABEL = 'Dismiss';
|
|
14
|
+
/**
|
|
15
|
+
* The cross the WordPress snackbar draws in its close button.
|
|
16
|
+
*/
|
|
17
|
+
const DISMISS_GLYPH = '✕';
|
|
18
|
+
/**
|
|
19
|
+
* How many toasts stay on screen at once.
|
|
20
|
+
*/
|
|
21
|
+
const LIMIT = 3;
|
|
14
22
|
const ToasterContext = createContext(null);
|
|
15
23
|
/**
|
|
16
24
|
* Returns the handle raising messages in the toast region.
|
|
@@ -24,43 +32,133 @@ export function useToaster() {
|
|
|
24
32
|
return handle;
|
|
25
33
|
}
|
|
26
34
|
/**
|
|
27
|
-
*
|
|
28
|
-
* @param
|
|
35
|
+
* Returns the toasts with a new one at the bottom and the oldest past the limit leaving.
|
|
36
|
+
* @param held - The toasts on screen, oldest first.
|
|
37
|
+
* @param arriving - The toast to add.
|
|
38
|
+
* @param limit - How many toasts may stay on screen.
|
|
39
|
+
* @returns The toasts to show.
|
|
40
|
+
*/
|
|
41
|
+
function admit(held, arriving, limit) {
|
|
42
|
+
const staying = held.filter((toast) => !toast.leaving);
|
|
43
|
+
const pushed = new Set(staying.slice(0, Math.max(staying.length + 1 - limit, 0)).map((toast) => toast.id));
|
|
44
|
+
return [...held.map((toast) => (pushed.has(toast.id) ? { ...toast, leaving: true } : toast)), arriving];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Returns the fades running on an element, none where the browser cannot report them.
|
|
48
|
+
* @param element - The element to ask.
|
|
49
|
+
* @returns The running animations.
|
|
50
|
+
*/
|
|
51
|
+
function runningFades(element) {
|
|
52
|
+
return typeof element.getAnimations === 'function' ? element.getAnimations() : [];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Returns the ref of a toast element that gives up focus as the toast leaves and drops the toast once faded.
|
|
56
|
+
* @param toast - The toast the element draws.
|
|
57
|
+
* @param region - The toast region taking the focus a leaving toast held.
|
|
58
|
+
* @param onGone - The handler dropping a toast that finished leaving.
|
|
59
|
+
* @returns The ref to attach to the toast element.
|
|
60
|
+
*/
|
|
61
|
+
function useDeparture(toast, region, onGone) {
|
|
62
|
+
const ref = useRef(null);
|
|
63
|
+
const { id, leaving } = toast;
|
|
64
|
+
useLayoutEffect(() => {
|
|
65
|
+
if (!leaving) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const element = ref.current;
|
|
69
|
+
const holder = region.current;
|
|
70
|
+
if (element.contains(document.activeElement)) {
|
|
71
|
+
holder.focus();
|
|
72
|
+
}
|
|
73
|
+
const fades = runningFades(element);
|
|
74
|
+
if (fades.length === 0) {
|
|
75
|
+
onGone(id);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
Promise.allSettled(fades.map((fade) => fade.finished)).then(() => onGone(id));
|
|
79
|
+
}, [id, leaving, region, onGone]);
|
|
80
|
+
return ref;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Runs the timer that sends a toast nobody touched away, cleared once the toast leaves or goes.
|
|
84
|
+
* @param toast - The toast the timer belongs to.
|
|
85
|
+
* @param dismissAfter - How many milliseconds the toast stays.
|
|
86
|
+
* @param onLeave - The handler sending a toast away.
|
|
87
|
+
*/
|
|
88
|
+
function useExpiry(toast, dismissAfter, onLeave) {
|
|
89
|
+
const { id, leaving } = toast;
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
if (leaving) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const timer = setTimeout(() => onLeave(id), dismissAfter);
|
|
95
|
+
return () => clearTimeout(timer);
|
|
96
|
+
}, [id, leaving, dismissAfter, onLeave]);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Returns the classes of a toast, with the leaving look while it fades out.
|
|
100
|
+
* @param base - The classes the toast always carries.
|
|
101
|
+
* @param leaving - Whether the toast is fading out.
|
|
102
|
+
* @returns The class list.
|
|
103
|
+
*/
|
|
104
|
+
function toastClass(base, leaving) {
|
|
105
|
+
return leaving ? `${base} godmin-toast--leaving` : base;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Renders a toast with no action as one button that clears it, described by the dismiss hint.
|
|
109
|
+
* @param props - The toast, how long it stays, the id of the dismiss hint, the region and the handlers clearing it.
|
|
29
110
|
* @returns The toast element.
|
|
30
111
|
*/
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
112
|
+
function PlainToast({ toast, dismissAfter, hint, region, onLeave, onGone, }) {
|
|
113
|
+
useExpiry(toast, dismissAfter, onLeave);
|
|
114
|
+
const ref = useDeparture(toast, region, onGone);
|
|
115
|
+
return (_jsx("button", { ref: ref, type: "button", className: toastClass('godmin-toast godmin-toast--plain', toast.leaving), "aria-describedby": hint, inert: toast.leaving, onClick: () => onLeave(toast.id), children: toast.message }));
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Renders a toast with its action and a close button beside it.
|
|
119
|
+
* @param props - The toast, its action, its time, the close button name, the region and the handlers clearing it.
|
|
120
|
+
* @returns The toast element.
|
|
121
|
+
*/
|
|
122
|
+
function ActionToast({ toast, action, dismissAfter, dismissLabel, region, onLeave, onGone, }) {
|
|
123
|
+
useExpiry(toast, dismissAfter, onLeave);
|
|
124
|
+
const ref = useDeparture(toast, region, onGone);
|
|
125
|
+
return (_jsxs("div", { ref: ref, className: toastClass('godmin-toast', toast.leaving), inert: toast.leaving, children: [_jsx("span", { className: "godmin-toast__message", children: toast.message }), _jsx("button", { type: "button", className: "godmin-toast__action", onClick: () => {
|
|
126
|
+
action.onAct();
|
|
127
|
+
onLeave(toast.id);
|
|
128
|
+
}, children: action.label }), _jsx("button", { type: "button", className: "godmin-toast__dismiss", "aria-label": dismissLabel, onClick: () => onLeave(toast.id), children: DISMISS_GLYPH })] }));
|
|
36
129
|
}
|
|
37
130
|
/**
|
|
38
131
|
* Renders the region holding raised messages around the given tree.
|
|
39
|
-
* @param props - The tree the region wraps, how long a toast stays,
|
|
132
|
+
* @param props - The tree the region wraps, how long a toast stays, the dismiss control name and how many stay.
|
|
40
133
|
* @returns The wrapped tree with its region.
|
|
41
134
|
*/
|
|
42
|
-
export function Toaster({ children, dismissAfter = DISMISS_AFTER, dismissLabel = DISMISS_LABEL, }) {
|
|
135
|
+
export function Toaster({ children, dismissAfter = DISMISS_AFTER, dismissLabel = DISMISS_LABEL, limit = LIMIT, }) {
|
|
43
136
|
const [toasts, setToasts] = useState([]);
|
|
44
137
|
const nextId = useRef(0);
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
138
|
+
const region = useRef(null);
|
|
139
|
+
const mounted = useRef(true);
|
|
140
|
+
useLayoutEffect(() => {
|
|
141
|
+
mounted.current = true;
|
|
48
142
|
return () => {
|
|
49
|
-
|
|
50
|
-
clearTimeout(timer);
|
|
51
|
-
}
|
|
52
|
-
held.clear();
|
|
143
|
+
mounted.current = false;
|
|
53
144
|
};
|
|
54
145
|
}, []);
|
|
55
|
-
const
|
|
146
|
+
const leave = useCallback((id) => {
|
|
147
|
+
setToasts((held) => held.map((toast) => (toast.id === id ? { ...toast, leaving: true } : toast)));
|
|
148
|
+
}, []);
|
|
149
|
+
const gone = useCallback((id) => {
|
|
56
150
|
setToasts((held) => held.filter((toast) => toast.id !== id));
|
|
57
151
|
}, []);
|
|
58
152
|
const show = useCallback((message, action) => {
|
|
153
|
+
if (!mounted.current) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
59
156
|
nextId.current += 1;
|
|
60
157
|
const id = nextId.current;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}, [
|
|
158
|
+
speak(message, 'polite');
|
|
159
|
+
setToasts((held) => admit(held, { id, message, action, leaving: false }, limit));
|
|
160
|
+
}, [limit]);
|
|
64
161
|
const handle = useMemo(() => ({ show }), [show]);
|
|
65
|
-
|
|
162
|
+
const hint = useId();
|
|
163
|
+
return (_jsxs(ToasterContext.Provider, { value: handle, children: [children, _jsx("div", { ref: region, className: "godmin-toasts", tabIndex: -1, children: toasts.map((toast) => toast.action === undefined ? (_jsx(PlainToast, { toast: toast, dismissAfter: dismissAfter, hint: hint, region: region, onLeave: leave, onGone: gone }, toast.id)) : (_jsx(ActionToast, { toast: toast, action: toast.action, dismissAfter: dismissAfter, dismissLabel: dismissLabel, region: region, onLeave: leave, onGone: gone }, toast.id))) }), _jsx("span", { id: hint, hidden: true, children: dismissLabel })] }));
|
|
66
164
|
}
|
package/dist/vite.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gopherium/godmin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.1",
|
|
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",
|
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"@tanstack/react-router": "^1.170.0",
|
|
60
60
|
"@testing-library/react": "^16.3.2",
|
|
61
|
+
"@wordpress/a11y": ">=4.55.0 <5.0.0",
|
|
61
62
|
"@wordpress/icons": ">=16.0.0 <17.0.0",
|
|
62
63
|
"@wordpress/style-runtime": ">=0.11.0 <0.12.0",
|
|
63
64
|
"@wordpress/theme": ">=2.1.0 <3.0.0",
|
|
@@ -88,6 +89,7 @@
|
|
|
88
89
|
"@vitejs/plugin-react": "^6.0.3",
|
|
89
90
|
"@vitest/coverage-v8": "^4.1.10",
|
|
90
91
|
"@wordpress/a11y": "4.55.0",
|
|
92
|
+
"@wordpress/dataviews": "19.0.0",
|
|
91
93
|
"@wordpress/element": "8.7.0",
|
|
92
94
|
"@wordpress/icons": "16.0.0",
|
|
93
95
|
"@wordpress/style-runtime": "0.11.0",
|