@gopherium/godmin 0.23.1 → 0.25.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.
Files changed (43) hide show
  1. package/README.md +27 -2
  2. package/dist/base.css +332 -27
  3. package/dist/breakpoints.d.ts +7 -3
  4. package/dist/breakpoints.js +8 -4
  5. package/dist/drilldown-item.d.ts +17 -0
  6. package/dist/drilldown-item.js +31 -0
  7. package/dist/frame.d.ts +21 -11
  8. package/dist/frame.js +69 -28
  9. package/dist/index.d.ts +6 -4
  10. package/dist/index.js +3 -2
  11. package/dist/list-chrome/es-ES.d.ts +1 -1
  12. package/dist/list-chrome/es-ES.js +5 -1
  13. package/dist/list-chrome/fr-FR.d.ts +1 -1
  14. package/dist/list-chrome/fr-FR.js +5 -1
  15. package/dist/list-chrome.d.ts +1 -1
  16. package/dist/list-chrome.js +1 -1
  17. package/dist/list-empty.d.ts +1 -1
  18. package/dist/list-empty.js +4 -2
  19. package/dist/menu-count.d.ts +12 -0
  20. package/dist/menu-count.js +14 -0
  21. package/dist/menu-item.d.ts +29 -0
  22. package/dist/menu-item.js +33 -0
  23. package/dist/navigation-item.d.ts +45 -0
  24. package/dist/navigation-item.js +50 -0
  25. package/dist/navigation-list.d.ts +14 -0
  26. package/dist/navigation-list.js +62 -0
  27. package/dist/navigation-screen.d.ts +24 -0
  28. package/dist/navigation-screen.js +47 -0
  29. package/dist/navigation-state.d.ts +83 -0
  30. package/dist/navigation-state.js +88 -0
  31. package/dist/navigation.d.ts +23 -0
  32. package/dist/navigation.js +133 -0
  33. package/dist/page-tabs.d.ts +5 -4
  34. package/dist/page-tabs.js +12 -3
  35. package/dist/page.d.ts +20 -6
  36. package/dist/page.js +32 -10
  37. package/dist/path-matching.d.ts +68 -0
  38. package/dist/path-matching.js +126 -0
  39. package/dist/router.d.ts +24 -2
  40. package/dist/router.js +16 -3
  41. package/package.json +3 -6
  42. package/dist/nav-screen.d.ts +0 -17
  43. package/dist/nav-screen.js +0 -31
package/README.md CHANGED
@@ -52,15 +52,40 @@ two lines do for you.
52
52
 
53
53
  | Entry point | Contents |
54
54
  | --- | --- |
55
- | `@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`, `ListEmpty`, `ConfirmBody`, `RenameBody`, `FormBody`, `FileButton`, `useServerPaging`, `pageWindow`, `paginationOf`, `runEach`, `bulkNotes`, `useListRun`, `useBulkRun`, `RunConfirm`, `viewNarrows`, `offeredView`, `offeredSize`, `sizedView`, `useMediaQuery`, `useTokenDocument`, the breakpoints `RAIL_BREAKPOINT`, `EDGE_BREAKPOINT`, `DENSE_BREAKPOINT`, `SHEET_BREAKPOINT`, `TITLE_BREAKPOINT` and `SMALL_VIEWPORT`, `SUPPORTED_WPDS` |
55
+ | `@gopherium/godmin` | `AdminRoot`, `Frame`, `Page`, `PageTitle`, `PageTabs`, `PageTab`, `SectionTitle`, `InitialsAvatar`, `NavigationScreen`, `MenuCount`, `ErrorNotice`, `LoadMore`, `LogList`, `LogItem`, `LogTime`, `LoadingScreen`, `LoadingRows`, `Toaster`, `useToaster`, `RepeatRows`, `RowControls`, `useRowKeys`, `keyFromLabel`, `listChromeCatalogFor`, `LIST_CHROME_DOMAIN`, `ListEmpty`, `ConfirmBody`, `RenameBody`, `FormBody`, `FileButton`, `useServerPaging`, `pageWindow`, `paginationOf`, `runEach`, `bulkNotes`, `useListRun`, `useBulkRun`, `RunConfirm`, `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` |
56
56
  | `@gopherium/godmin/base.css` | Cascade layer order, design tokens, host rules, frame and screen styles |
57
57
  | `@gopherium/godmin/dates` | `startListDates`, `listDate`, the only entry that loads `@wordpress/date` |
58
58
  | `@gopherium/godmin/dialogs` | `ConfirmDialog`, `FormDialog`, the only entry that loads `@wordpress/components`. Load `@wordpress/components/build-style/style.css` once in your app, as DataViews asks |
59
- | `@gopherium/godmin/router` | `useListView`, `listSearch`, `openOnTap`, `useCanvas`, `useFrameLocation`, the `canvas` route static data |
59
+ | `@gopherium/godmin/router` | `Navigation`, `NavigationList`, `NavigationItem`, `DrilldownItem`, `useCanAccess` and the `MenuItem` type, `useListView`, `listSearch`, `openOnTap`, `useCanvas`, `useFrameLocation`, `routerDefaults`, the `canvas`, `Sidebar` and `capability` route static data |
60
60
  | `@gopherium/godmin/testing` | `installTestEnvironment`, `renderAdmin`, `setViewport` and its `TestViewport` type, `getAnnouncement`, `clearAnnouncements`, `assertElementPatched`, `WPDS_IGNORE_SELECTOR`, `textClasses`, `badgeClasses`, `buttonClasses`, `stubLayout` |
61
61
  | `@gopherium/godmin/vite` | `godminDedupe`, `godminSingleCopy`, `godminStylesheetFirst`, `duplicateCopies`, `hoistStylesheet` |
62
62
  | `@gopherium/godmin/stylelint` | The design system stylelint rules |
63
63
 
64
+ ## Translations
65
+
66
+ GodMin speaks a few words of its own: Back on a sidebar screen, the name of
67
+ the sidebar column and its phone drawer, and the phone menu button and the
68
+ drawer's close button, which only a screen reader meets. It
69
+ translates them in the WordPress `default` text domain, as `@wordpress/ui`
70
+ translates its own, so `@wordpress/i18n` is a required peer. Every app
71
+ already has it, since
72
+ `@wordpress/ui` depends on it.
73
+
74
+ `listChromeCatalogFor` returns the catalogue GodMin ships for a language,
75
+ Spanish and French today. Both hold these words and the list dates, and the
76
+ Spanish one also holds the list chrome. Load it into `LIST_CHROME_DOMAIN`, the
77
+ `default` domain:
78
+
79
+ ```ts
80
+ import { setLocaleData } from '@wordpress/i18n'
81
+ import { LIST_CHROME_DOMAIN, listChromeCatalogFor } from '@gopherium/godmin'
82
+
83
+ const catalogue = await listChromeCatalogFor('es-ES')
84
+ if (catalogue !== undefined) {
85
+ setLocaleData(catalogue, LIST_CHROME_DOMAIN)
86
+ }
87
+ ```
88
+
64
89
  ## Before your first build
65
90
 
66
91
  Duplicate packages break the application, and nothing points at the cause.
package/dist/base.css CHANGED
@@ -85,7 +85,6 @@ body {
85
85
 
86
86
  .godmin-page__list .dataviews-view-table tbody .dataviews-view-table__primary-column-content > .dataviews-title-field {
87
87
  min-block-size: 0;
88
- font-weight: var(--wpds-typography-font-weight-default);
89
88
  line-height: var(--wpds-typography-line-height-sm);
90
89
  }
91
90
 
@@ -100,8 +99,10 @@ body {
100
99
 
101
100
  @layer godmin {
102
101
  :root {
103
- --godmin-rail-width: 300px;
102
+ --godmin-nav-sidebar-width: 300px;
104
103
  --godmin-canvas-margin: 16px;
104
+ --godmin-navigation-slide-distance: 50px;
105
+ --godmin-navigation-slide-duration: 140ms;
105
106
  }
106
107
 
107
108
  .godmin-layout {
@@ -116,14 +117,14 @@ body {
116
117
  flex-direction: column;
117
118
  }
118
119
 
119
- .godmin-layout__rail {
120
+ .godmin-layout__sidebar {
121
+ z-index: 1;
120
122
  display: flex;
121
123
  flex-direction: column;
122
124
  flex-shrink: 0;
123
- width: var(--godmin-rail-width);
124
- padding: 16px;
125
+ width: var(--godmin-nav-sidebar-width);
126
+ padding: 0;
125
127
  box-sizing: border-box;
126
- overflow-y: auto;
127
128
  }
128
129
 
129
130
  .godmin-layout__topbar {
@@ -138,10 +139,14 @@ body {
138
139
  .godmin-layout__menu {
139
140
  display: flex;
140
141
  flex: none;
142
+ align-items: center;
143
+ justify-content: center;
144
+ inline-size: 52px;
145
+ block-size: 46px;
141
146
  padding: 0;
142
147
  border: 0;
143
148
  background: none;
144
- color: color-mix(in srgb, var(--wpds-color-foreground-content-neutral) 60%, transparent);
149
+ color: var(--wpds-color-foreground-content-neutral);
145
150
  cursor: var(--wpds-cursor-control);
146
151
  }
147
152
 
@@ -156,11 +161,64 @@ body {
156
161
  }
157
162
 
158
163
  .godmin-layout__drawer {
164
+ top: 0;
159
165
  display: flex;
160
166
  flex-direction: column;
161
- padding: 16px;
167
+ width: var(--godmin-nav-sidebar-width);
168
+ max-width: 85vw;
169
+ padding: 0;
162
170
  box-sizing: border-box;
171
+ border: 0;
172
+ border-radius: 0;
173
+ background: var(--wpds-color-background-surface-neutral-weak);
174
+ box-shadow: 2px 0 8px rgba(0, 0, 0, 0.2);
175
+ }
176
+
177
+ [role='presentation']:has(+ * > .godmin-layout__drawer) {
178
+ --backdrop-opacity: 0.5;
179
+ background-color: #000;
180
+ cursor: var(--wpds-cursor-control);
181
+ }
182
+
183
+ .godmin-sidebar__content {
184
+ flex: 1 1 0;
185
+ min-height: 0;
186
+ overflow-x: hidden;
163
187
  overflow-y: auto;
188
+ contain: content;
189
+ }
190
+
191
+ .godmin-sidebar__footer {
192
+ display: flex;
193
+ flex-direction: column;
194
+ flex-shrink: 0;
195
+ gap: 8px;
196
+ padding: 16px;
197
+ border-top: 1px solid var(--wpds-color-stroke-surface-neutral);
198
+ }
199
+
200
+ .godmin-sidebar__footer-note {
201
+ color: var(--wpds-color-foreground-content-neutral-weak);
202
+ font-size: var(--wpds-typography-font-size-sm);
203
+ line-height: var(--wpds-typography-line-height-xs);
204
+ }
205
+
206
+ .godmin-menu-count__badge {
207
+ --godmin-menu-count-size: 18px;
208
+ display: inline-block;
209
+ vertical-align: top;
210
+ box-sizing: border-box;
211
+ min-inline-size: var(--godmin-menu-count-size);
212
+ block-size: var(--godmin-menu-count-size);
213
+ margin-block: 1px -1px;
214
+ margin-inline-start: 2px;
215
+ padding-block: 0;
216
+ padding-inline: 5px;
217
+ border-radius: calc(var(--godmin-menu-count-size) / 2);
218
+ font-size: var(--wpds-typography-font-size-xs);
219
+ font-weight: inherit;
220
+ line-height: 1.6;
221
+ text-align: center;
164
222
  }
165
223
 
166
224
  .godmin-layout__canvas {
@@ -188,10 +246,35 @@ body {
188
246
  overflow: hidden;
189
247
  }
190
248
 
191
- .godmin-layout:has(> .godmin-layout__rail) .godmin-layout__canvas {
249
+ .godmin-layout:has(> .godmin-layout__sidebar) .godmin-layout__canvas {
192
250
  margin-inline-start: 0;
193
251
  }
194
252
 
253
+ .godmin-layout__notices {
254
+ display: flex;
255
+ flex: none;
256
+ flex-direction: column;
257
+ gap: var(--wpds-dimension-gap-md);
258
+ margin-block-end: var(--godmin-canvas-gutter-block);
259
+ }
260
+
261
+ .godmin-layout__notices:empty {
262
+ display: none;
263
+ }
264
+
265
+ .godmin-layout__canvas:not(.godmin-layout__canvas--bleed):has(.godmin-page > .godmin-page__list) > .godmin-layout__notices {
266
+ padding-inline: calc(var(--wpds-dimension-padding-2xl) - var(--godmin-canvas-gutter));
267
+ }
268
+
269
+ .godmin-layout__canvas--bleed .godmin-layout__notices {
270
+ gap: 0;
271
+ }
272
+
273
+ .godmin-layout__canvas--bleed .godmin-layout__notices > * {
274
+ border-block-start-width: 0;
275
+ border-inline-width: 0;
276
+ }
277
+
195
278
  .godmin-toasts {
196
279
  position: fixed;
197
280
  inset-inline: 0;
@@ -206,8 +289,8 @@ body {
206
289
  pointer-events: none;
207
290
  }
208
291
 
209
- :root:has(.godmin-layout__rail) .godmin-toasts {
210
- inset-inline-start: var(--godmin-rail-width);
292
+ :root:has(.godmin-layout__sidebar) .godmin-toasts {
293
+ inset-inline-start: var(--godmin-nav-sidebar-width);
211
294
  inset-inline-end: var(--godmin-canvas-margin);
212
295
  }
213
296
 
@@ -295,28 +378,247 @@ body {
295
378
  text-decoration: none;
296
379
  }
297
380
 
298
- .godmin-nav-screen__title {
299
- flex: 1;
300
- min-width: 0;
381
+ .godmin-navigation {
382
+ display: flex;
383
+ flex-direction: column;
384
+ height: 100%;
301
385
  }
302
386
 
303
- .godmin-nav-screen__title:focus {
304
- outline: none;
387
+ .godmin-navigation__screen-wrapper {
388
+ display: flex;
389
+ flex-direction: column;
390
+ height: 100%;
391
+ max-height: 100%;
392
+ padding: 0 12px;
393
+ overflow-x: auto;
394
+ scrollbar-width: thin;
395
+ scrollbar-gutter: stable;
396
+ scrollbar-color: transparent transparent;
397
+ animation-duration: var(--godmin-navigation-slide-duration);
398
+ animation-timing-function: ease-in-out;
399
+ will-change: transform, opacity;
400
+ }
401
+
402
+ .godmin-navigation__screen-wrapper:is(:hover, :focus, :focus-within) {
403
+ scrollbar-color: var(--wpds-color-stroke-surface-neutral-strong) transparent;
404
+ }
405
+
406
+ .godmin-navigation__screen-wrapper::-webkit-scrollbar {
407
+ width: 12px;
408
+ height: 12px;
409
+ }
410
+
411
+ .godmin-navigation__screen-wrapper::-webkit-scrollbar-track {
412
+ background-color: transparent;
413
+ }
414
+
415
+ .godmin-navigation__screen-wrapper::-webkit-scrollbar-thumb {
416
+ border: 3px solid transparent;
417
+ border-radius: 8px;
418
+ background-color: transparent;
419
+ background-clip: padding-box;
420
+ }
421
+
422
+ .godmin-navigation__screen-wrapper:hover::-webkit-scrollbar-thumb,
423
+ .godmin-navigation__screen-wrapper:focus::-webkit-scrollbar-thumb,
424
+ .godmin-navigation__screen-wrapper:focus-within::-webkit-scrollbar-thumb {
425
+ background-color: var(--wpds-color-stroke-surface-neutral-strong);
426
+ }
427
+
428
+ @media (hover: none) {
429
+ .godmin-navigation__screen-wrapper {
430
+ scrollbar-color: var(--wpds-color-stroke-surface-neutral-strong) transparent;
431
+ }
432
+ }
433
+
434
+ .godmin-navigation__screen-wrapper--forward {
435
+ animation-name: godmin-slide-from-end;
436
+ }
437
+
438
+ .godmin-navigation__screen-wrapper--backward {
439
+ animation-name: godmin-slide-from-start;
440
+ }
441
+
442
+ .godmin-navigation__screen-wrapper--forward:dir(rtl) {
443
+ animation-name: godmin-slide-from-start;
444
+ }
445
+
446
+ .godmin-navigation__screen-wrapper--backward:dir(rtl) {
447
+ animation-name: godmin-slide-from-end;
448
+ }
449
+
450
+ @keyframes godmin-slide-from-end {
451
+ 0% {
452
+ opacity: 0;
453
+ transform: translateX(var(--godmin-navigation-slide-distance));
454
+ }
455
+
456
+ 100% {
457
+ opacity: 1;
458
+ transform: none;
459
+ }
460
+ }
461
+
462
+ @keyframes godmin-slide-from-start {
463
+ 0% {
464
+ opacity: 0;
465
+ transform: translateX(calc(-1 * var(--godmin-navigation-slide-distance)));
466
+ }
467
+
468
+ 100% {
469
+ opacity: 1;
470
+ transform: none;
471
+ }
472
+ }
473
+
474
+ .godmin-navigation-screen {
475
+ display: flex;
476
+ flex-direction: column;
477
+ flex-grow: 1;
478
+ }
479
+
480
+ .godmin-navigation-screen__main {
481
+ flex-grow: 1;
482
+ margin-bottom: 16px;
483
+ }
484
+
485
+ .godmin-navigation-screen__main--has-footer {
486
+ margin-bottom: 0;
487
+ }
488
+
489
+ .godmin-navigation-screen__title-icon {
490
+ position: sticky;
491
+ top: 0;
492
+ z-index: 1;
493
+ display: flex;
494
+ align-items: flex-start;
495
+ gap: 12px;
496
+ margin-bottom: 8px;
497
+ padding-top: 32px;
498
+ padding-bottom: 8px;
499
+ background: var(--wpds-color-background-surface-neutral-weak);
500
+ }
501
+
502
+ .godmin-navigation-screen__title-icon--root {
503
+ padding-inline-start: 44px;
305
504
  }
306
505
 
307
- .godmin-nav-screen__back {
506
+ .godmin-navigation-screen__back {
308
507
  display: inline-flex;
309
- color: inherit;
310
- border-radius: var(--wpds-border-radius-md);
508
+ flex-shrink: 0;
509
+ align-items: center;
510
+ justify-content: center;
511
+ inline-size: 32px;
512
+ block-size: 32px;
513
+ border-radius: var(--wpds-border-radius-sm);
514
+ color: var(--wpds-color-foreground-interactive-neutral);
311
515
  }
312
516
 
313
- .godmin-nav-screen__back:focus-visible {
517
+ .godmin-navigation-screen__back:is(:hover, :focus) {
518
+ color: var(--wpds-color-foreground-interactive-neutral-active);
519
+ }
520
+
521
+ .godmin-navigation-screen__back:focus-visible {
314
522
  outline: var(--wpds-border-width-focus) solid var(--wpds-color-stroke-focus);
315
- outline-offset: 2px;
523
+ outline-offset: var(--wpds-border-width-focus);
316
524
  }
317
525
 
318
- .godmin-nav-screen__description {
319
- color: var(--wpds-color-foreground-content-neutral-weak);
526
+ .godmin-navigation-screen__back:focus:not(:focus-visible) {
527
+ outline: none;
528
+ }
529
+
530
+ .godmin-navigation-screen__title {
531
+ flex-grow: 1;
532
+ min-width: 0;
533
+ margin: 0;
534
+ color: var(--wpds-color-foreground-content-neutral);
535
+ font-size: var(--wpds-typography-font-size-xl);
536
+ font-weight: var(--wpds-typography-font-weight-emphasis);
537
+ line-height: var(--wpds-typography-line-height-xl);
538
+ overflow-wrap: break-word;
539
+ }
540
+
541
+ .godmin-navigation-screen__actions {
542
+ display: flex;
543
+ flex-shrink: 0;
544
+ }
545
+
546
+ .godmin-navigation-screen__content {
547
+ padding: 0 16px;
548
+ color: var(--wpds-color-foreground-content-neutral);
549
+ }
550
+
551
+ .godmin-navigation-screen__description {
552
+ margin: 0 0 32px;
553
+ color: var(--wpds-color-foreground-content-neutral);
554
+ }
555
+
556
+ .godmin-navigation-screen__footer {
557
+ position: sticky;
558
+ bottom: 0;
559
+ margin-top: 16px;
560
+ padding: 8px 16px;
561
+ border-top: 1px solid var(--wpds-color-stroke-surface-neutral);
562
+ background: var(--wpds-color-background-surface-neutral-weak);
563
+ }
564
+
565
+ .godmin-navigation-list {
566
+ margin-block: 0;
567
+ margin-inline: -16px;
568
+ padding: 0;
569
+ list-style: none;
570
+ }
571
+
572
+ .godmin-navigation-item {
573
+ display: flex;
574
+ align-items: center;
575
+ gap: var(--wpds-dimension-gap-sm);
576
+ box-sizing: border-box;
577
+ min-height: 40px;
578
+ padding: calc((36px - 13px * 1.4 - 2px) / 2) 12px;
579
+ border: 1px solid transparent;
580
+ border-radius: var(--wpds-border-radius-sm);
581
+ color: var(--wpds-color-foreground-interactive-neutral-weak);
582
+ font-size: var(--wpds-typography-font-size-md);
583
+ font-weight: var(--wpds-typography-font-weight-default);
584
+ line-height: normal;
585
+ text-decoration: none;
586
+ }
587
+
588
+ .godmin-navigation-item--with-suffix {
589
+ padding-inline-end: 16px;
590
+ }
591
+
592
+ .godmin-navigation-item:is(:hover, :focus) {
593
+ color: var(--wpds-color-foreground-interactive-neutral-weak-active);
594
+ }
595
+
596
+ .godmin-navigation-item[aria-current='page'] {
597
+ background: var(--wpds-color-background-interactive-neutral-weak-active);
598
+ color: var(--wpds-color-foreground-interactive-neutral-weak-active);
599
+ font-weight: var(--wpds-typography-font-weight-emphasis);
600
+ }
601
+
602
+ .godmin-navigation-item:focus-visible {
603
+ outline: var(--wpds-border-width-focus) solid var(--wpds-color-stroke-focus);
604
+ outline-offset: var(--wpds-border-width-focus);
605
+ transform: translateZ(0);
606
+ }
607
+
608
+ .godmin-navigation-item__icon,
609
+ .godmin-navigation-item__drilldown-indicator {
610
+ flex: none;
611
+ inline-size: 24px;
612
+ block-size: 24px;
613
+ }
614
+
615
+ .godmin-navigation-item__label {
616
+ flex: 1;
617
+ min-width: 0;
618
+ }
619
+
620
+ .godmin-navigation-item__suffix {
621
+ flex: none;
320
622
  }
321
623
 
322
624
  .godmin-page__head {
@@ -421,6 +723,9 @@ body {
421
723
  display: flex;
422
724
  position: relative;
423
725
  gap: var(--wpds-dimension-gap-lg);
726
+ margin: 0;
727
+ padding: 0;
728
+ list-style: none;
424
729
  overflow-x: auto;
425
730
  overscroll-behavior-inline: none;
426
731
  }
@@ -597,10 +902,6 @@ body {
597
902
  color: var(--wpds-color-foreground-content-neutral);
598
903
  }
599
904
 
600
- .godmin-page__list .godmin-table__title {
601
- font-weight: var(--wpds-typography-font-weight-default);
602
- }
603
-
604
905
  .godmin-table__title a {
605
906
  color: var(--wpds-color-foreground-interactive-neutral);
606
907
  text-decoration: none;
@@ -696,6 +997,10 @@ body {
696
997
  .godmin-toast {
697
998
  animation-duration: 1ms;
698
999
  }
1000
+
1001
+ .godmin-navigation__screen-wrapper {
1002
+ animation-duration: 0s;
1003
+ }
699
1004
  }
700
1005
 
701
1006
  .godmin-loading-screen {
@@ -1,7 +1,11 @@
1
1
  /**
2
- * The viewport width below which the rail becomes a drawer.
2
+ * The viewport width from which a screen counts as huge, the WordPress huge breakpoint.
3
3
  */
4
- export declare const RAIL_BREAKPOINT = 1024;
4
+ export declare const HUGE_BREAKPOINT = 1440;
5
+ /**
6
+ * The viewport width below which the sidebar becomes a drawer.
7
+ */
8
+ export declare const SIDEBAR_BREAKPOINT = 1024;
5
9
  /**
6
10
  * The viewport width below which the canvas meets the screen edges, the WordPress medium breakpoint.
7
11
  */
@@ -19,6 +23,6 @@ export declare const SHEET_BREAKPOINT = 600;
19
23
  */
20
24
  export declare const TITLE_BREAKPOINT = 404;
21
25
  /**
22
- * The media query the frame folds its rail at.
26
+ * The media query the frame folds its sidebar at.
23
27
  */
24
28
  export declare const SMALL_VIEWPORT = "(max-width: 1023px)";
@@ -1,7 +1,11 @@
1
1
  /**
2
- * The viewport width below which the rail becomes a drawer.
2
+ * The viewport width from which a screen counts as huge, the WordPress huge breakpoint.
3
3
  */
4
- export const RAIL_BREAKPOINT = 1024;
4
+ export const HUGE_BREAKPOINT = 1440;
5
+ /**
6
+ * The viewport width below which the sidebar becomes a drawer.
7
+ */
8
+ export const SIDEBAR_BREAKPOINT = 1024;
5
9
  /**
6
10
  * The viewport width below which the canvas meets the screen edges, the WordPress medium breakpoint.
7
11
  */
@@ -19,6 +23,6 @@ export const SHEET_BREAKPOINT = 600;
19
23
  */
20
24
  export const TITLE_BREAKPOINT = 404;
21
25
  /**
22
- * The media query the frame folds its rail at.
26
+ * The media query the frame folds its sidebar at.
23
27
  */
24
- export const SMALL_VIEWPORT = `(max-width: ${RAIL_BREAKPOINT - 1}px)`;
28
+ export const SMALL_VIEWPORT = `(max-width: ${SIDEBAR_BREAKPOINT - 1}px)`;
@@ -0,0 +1,17 @@
1
+ import type { AnyRouter, LinkComponentProps, RegisteredRouter } from '@tanstack/react-router';
2
+ import type { ReactElement, ReactNode } from 'react';
3
+ /** A row whose address opens a route that declares a Sidebar. Draws the chevron. Sits inside a NavigationList. */
4
+ export type DrilldownItemProps<TRouter extends AnyRouter = RegisteredRouter, TFrom extends string = string, TTo extends string | undefined = undefined, TMaskFrom extends string = TFrom, TMaskTo extends string = ''> = LinkComponentProps<'a', TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & {
5
+ /** None, since the row takes its id from its address. */
6
+ id?: never;
7
+ /** A glyph from `@wordpress/icons`, drawn at 24px. */
8
+ icon?: ReactElement;
9
+ children: ReactNode;
10
+ };
11
+ /**
12
+ * Renders a sidebar row that opens a sub menu: its icon, its label and the chevron, with an id taken from its address.
13
+ * A plain click inside a frame records a forward move from this row to its address.
14
+ * @param props - The TanStack Link props, the icon and the label.
15
+ * @returns The row element, or null when its address opens a route the reader may not open.
16
+ */
17
+ export declare function DrilldownItem<TRouter extends AnyRouter = RegisteredRouter, const TFrom extends string = string, const TTo extends string | undefined = undefined, const TMaskFrom extends string = TFrom, const TMaskTo extends string = ''>({ icon, children, ...link }: DrilldownItemProps<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>): import("react").JSX.Element;
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { useRouter } from '@tanstack/react-router';
4
+ import { isRTL } from '@wordpress/i18n';
5
+ import { Icon, chevronLeftSmall, chevronRightSmall } from '@wordpress/icons';
6
+ import { useContext } from 'react';
7
+ import { ROW_CLASS, Row } from './navigation-item.js';
8
+ import { NavigationStateContext, isPlainClick, recordDrilldown } from './navigation-state.js';
9
+ import { findMoveTarget, findRowRoutes } from './path-matching.js';
10
+ /** The start of the id a drilldown row takes from its address. */
11
+ const ID_PREFIX = 'godmin-drilldown-item-';
12
+ /**
13
+ * Renders a sidebar row that opens a sub menu: its icon, its label and the chevron, with an id taken from its address.
14
+ * A plain click inside a frame records a forward move from this row to its address.
15
+ * @param props - The TanStack Link props, the icon and the label.
16
+ * @returns The row element, or null when its address opens a route the reader may not open.
17
+ */
18
+ export function DrilldownItem({ icon, children, ...link }) {
19
+ const router = useRouter();
20
+ const state = useContext(NavigationStateContext);
21
+ const address = link;
22
+ const routes = findRowRoutes(router, address);
23
+ const id = ID_PREFIX + routes.href;
24
+ const onClick = (event) => {
25
+ address.onClick?.(event);
26
+ if (state !== undefined && isPlainClick(event)) {
27
+ recordDrilldown(state, id, findMoveTarget(router, address));
28
+ }
29
+ };
30
+ return (_jsx(Row, { link: { ...address, onClick }, routes: routes, icon: icon, className: ROW_CLASS, id: id, end: _jsx(Icon, { icon: isRTL() ? chevronLeftSmall : chevronRightSmall, size: 24, className: "godmin-navigation-item__drilldown-indicator" }), children: children }));
31
+ }
package/dist/frame.d.ts CHANGED
@@ -10,23 +10,31 @@ export interface FrameRootProps {
10
10
  canvasColor?: ThemeColor;
11
11
  }
12
12
  /**
13
- * Frames an admin application, folding its rail away on a narrow viewport.
13
+ * Frames an admin application, folding its sidebar away on a narrow viewport,
14
+ * and holds the moves its sidebar parts share.
14
15
  * @param props - The regions, the current location, and the region colors.
15
16
  * @returns The frame element.
16
17
  */
17
18
  declare function Root({ children, location, chromeColor, canvasColor }: FrameRootProps): import("react").JSX.Element;
18
- export interface FrameRailProps {
19
+ export interface FrameSidebarProps {
19
20
  children: ReactNode;
20
21
  brand?: ReactNode;
22
+ /** The name of the menu button, godmin's translated "Open navigation panel" when absent. */
21
23
  menuLabel?: string;
24
+ /** The name of the region the column is, godmin's translated "Navigation" when absent. */
25
+ label?: string;
26
+ /** What sits under the menu and never moves, such as the account panel. */
27
+ footer?: ReactNode;
28
+ /** One short line of small grey text under the footer, such as the version. */
29
+ footerNote?: ReactNode;
22
30
  }
23
31
  /**
24
- * Renders the navigation region, as a rail when there is room and as a top bar
25
- * with a drawer when there is not.
26
- * @param props - The rail content, the brand, and the menu button label.
27
- * @returns The rail element.
32
+ * Renders the navigation region, as a sidebar when there is room and as a top bar
33
+ * with a drawer when there is not, its content above its footer in both.
34
+ * @param props - The sidebar content, the brand, the menu button label, the region name, the footer and its note.
35
+ * @returns The sidebar element.
28
36
  */
29
- declare function Rail({ children, brand, menuLabel }: FrameRailProps): import("react").JSX.Element;
37
+ declare function Sidebar({ children, brand, menuLabel, label, footer, footerNote, }: FrameSidebarProps): import("react").JSX.Element;
30
38
  /**
31
39
  * How a screen fills its canvas region.
32
40
  */
@@ -34,19 +42,21 @@ export type CanvasMode = 'padded' | 'bleed';
34
42
  export interface FrameCanvasProps {
35
43
  children: ReactNode;
36
44
  canvas?: CanvasMode;
45
+ /** The notices drawn in a band above the screen, such as a notice that an update is available. */
46
+ notices?: ReactNode;
37
47
  }
38
48
  /**
39
- * Renders the region showing the active screen.
40
- * @param props - The screen, and whether it fills the canvas edge to edge.
49
+ * Renders the region showing the active screen, under a band of notices when the app gives some.
50
+ * @param props - The screen, whether it fills the canvas edge to edge, and the notices.
41
51
  * @returns The canvas element.
42
52
  */
43
- declare function Canvas({ children, canvas }: FrameCanvasProps): import("react").JSX.Element;
53
+ declare function Canvas({ children, canvas, notices }: FrameCanvasProps): import("react").JSX.Element;
44
54
  /**
45
55
  * The admin frame, whose regions are present when their element is rendered.
46
56
  */
47
57
  export declare const Frame: {
48
58
  Root: typeof Root;
49
- Rail: typeof Rail;
59
+ Sidebar: typeof Sidebar;
50
60
  Canvas: typeof Canvas;
51
61
  };
52
62
  export {};