@gopherium/godmin 0.30.0 → 0.31.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 CHANGED
@@ -49,7 +49,7 @@ those two lines do for you.
49
49
 
50
50
  | Entry point | Contents |
51
51
  | --- | --- |
52
- | `@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`, `ConfirmBody`, `RenameBody`, `FormBody`, `FileButton`, `useServerPaging`, `pageWindow`, `paginationOf`, `runEach`, `bulkNotes`, `useListRun`, `useBulkRun`, `RunConfirm`, `useCloseWhileOpen`, `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` |
52
+ | `@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`, `ConfirmBody`, `RenameBody`, `FormBody`, `FileButton`, `useServerPaging`, `pageWindow`, `paginationOf`, `runEach`, `bulkNotes`, `useListRun`, `useBulkRun`, `RunConfirm`, `useCloseWhileOpen`, `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` |
53
53
  | `@gopherium/godmin/base.css` | Cascade layer order, design tokens, host rules, frame and screen styles |
54
54
  | `@gopherium/godmin/dates` | `startListDates`, `listDate`, the only entry that loads `@wordpress/date` |
55
55
  | `@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 |
package/dist/base.css CHANGED
@@ -690,7 +690,43 @@ body {
690
690
  }
691
691
 
692
692
  .godmin-page__head {
693
- min-block-size: var(--wpds-dimension-size-lg);
693
+ min-block-size: var(--wpds-dimension-size-md);
694
+ }
695
+
696
+ .godmin-page__heading {
697
+ display: flex;
698
+ flex: 1 1 calc(var(--wpds-dimension-surface-width-xs) / 2);
699
+ flex-wrap: wrap;
700
+ align-items: center;
701
+ min-inline-size: 0;
702
+ }
703
+
704
+ .godmin-page__heading > :last-child {
705
+ flex: 1 1 calc(var(--wpds-dimension-surface-width-xs) / 2);
706
+ overflow: hidden;
707
+ text-overflow: ellipsis;
708
+ white-space: nowrap;
709
+ }
710
+
711
+ .godmin-page__breadcrumbs {
712
+ flex: none;
713
+ max-inline-size: 100%;
714
+ overflow-wrap: anywhere;
715
+ }
716
+
717
+ .godmin-page__breadcrumbs ul {
718
+ display: flex;
719
+ flex-wrap: wrap;
720
+ align-items: center;
721
+ margin: 0;
722
+ padding: 0;
723
+ list-style: none;
724
+ }
725
+
726
+ .godmin-page__separator {
727
+ margin-inline: var(--wpds-dimension-gap-sm);
728
+ color: var(--wpds-color-stroke-surface-neutral);
729
+ user-select: none;
694
730
  }
695
731
 
696
732
  .godmin-page__subtitle {
@@ -698,23 +734,64 @@ body {
698
734
  color: var(--wpds-color-foreground-content-neutral-weak);
699
735
  }
700
736
 
737
+ .godmin-page:has(> .godmin-page__split) {
738
+ flex: 1 1 0;
739
+ min-block-size: 0;
740
+ }
741
+
701
742
  .godmin-page__split {
743
+ --godmin-page-stacked: calc((2 * var(--wpds-dimension-surface-width-md) + var(--wpds-dimension-gap-xl) + 2 * var(--wpds-dimension-padding-xs) - 100cqi) * 999999);
744
+ container-type: inline-size;
702
745
  display: flex;
746
+ flex: 1 1 auto;
703
747
  flex-wrap: wrap;
748
+ align-content: flex-start;
704
749
  align-items: flex-start;
705
- gap: var(--wpds-dimension-gap-xl);
750
+ column-gap: calc(var(--wpds-dimension-gap-xl) - 2 * var(--wpds-dimension-padding-xs));
751
+ row-gap: calc(var(--wpds-dimension-gap-xl) - var(--godmin-canvas-gutter-block, 0px));
752
+ margin-inline: calc(-1 * var(--godmin-canvas-gutter, 0px));
753
+ margin-block-end: calc(-1 * var(--godmin-canvas-gutter-block, 0px));
754
+ padding-inline: calc(var(--godmin-canvas-gutter, 0px) - var(--wpds-dimension-padding-xs));
755
+ border-block-start: var(--wpds-border-width-xs) solid var(--wpds-color-stroke-surface-neutral-weak);
756
+ overflow: hidden auto;
757
+ }
758
+
759
+ .godmin-page > .godmin-page__tabs + .godmin-page__split {
760
+ margin-block-start: calc(-1 * var(--wpds-dimension-gap-lg));
761
+ border-block-start: none;
706
762
  }
707
763
 
708
764
  .godmin-page__main {
709
- flex: 1 1 var(--wpds-dimension-surface-width-lg);
765
+ flex: 1 1 0;
766
+ padding-block-start: var(--wpds-dimension-padding-lg);
767
+ }
768
+
769
+ .godmin-page__aside {
770
+ flex: 0 1 min(100%, max(var(--wpds-dimension-surface-width-md) + 2 * var(--wpds-dimension-padding-xs), var(--godmin-page-stacked)));
771
+ padding-block-start: clamp(0px, calc(var(--wpds-dimension-padding-lg) - var(--godmin-page-stacked)), var(--wpds-dimension-padding-lg));
710
772
  }
711
773
 
774
+ .godmin-page__main,
712
775
  .godmin-page__aside {
713
- flex: 999 1 0;
714
- min-inline-size: min(100%, var(--wpds-dimension-surface-width-xs));
776
+ box-sizing: border-box;
777
+ max-block-size: max(100%, var(--godmin-page-stacked));
778
+ padding-inline: var(--wpds-dimension-padding-xs);
779
+ padding-block-end: var(--godmin-canvas-gutter-block, 0px);
780
+ overflow: hidden auto;
715
781
  overflow-wrap: anywhere;
716
782
  }
717
783
 
784
+ .godmin-page__main > *,
785
+ .godmin-page__aside > * {
786
+ flex-shrink: 0;
787
+ }
788
+
789
+ .godmin-page__main .godmin-table-scroll,
790
+ .godmin-page__aside .godmin-table-scroll {
791
+ position: relative;
792
+ overflow-x: auto;
793
+ }
794
+
718
795
  .godmin-page__aside:empty {
719
796
  display: none;
720
797
  }
@@ -750,6 +827,11 @@ body {
750
827
  margin-inline: calc(-1 * min(var(--wpds-dimension-padding-2xl), var(--godmin-canvas-gutter, 0px)));
751
828
  }
752
829
 
830
+ .godmin-page__main .godmin-list,
831
+ .godmin-page__aside .godmin-list {
832
+ margin-inline: 0;
833
+ }
834
+
753
835
  .godmin-page > .godmin-page__list > :not(.dataviews-wrapper, .godmin-table-scroll, .godmin-table) {
754
836
  margin-inline: var(--wpds-dimension-padding-2xl);
755
837
  }
@@ -818,6 +900,10 @@ body {
818
900
  overscroll-behavior-inline: none;
819
901
  }
820
902
 
903
+ .godmin-page-tabs:not(.godmin-page-tabs--scrolling) {
904
+ overflow: visible;
905
+ }
906
+
821
907
  .godmin-page-tabs:dir(rtl) {
822
908
  --godmin-page-tabs-start: right;
823
909
  --godmin-page-tabs-end: left;
@@ -841,6 +927,8 @@ body {
841
927
  display: flex;
842
928
  align-items: center;
843
929
  position: relative;
930
+ z-index: 1;
931
+ cursor: var(--wpds-cursor-control);
844
932
  block-size: 48px;
845
933
  padding: 0;
846
934
  scroll-margin: 24px;
@@ -853,35 +941,83 @@ body {
853
941
  white-space: nowrap;
854
942
  }
855
943
 
856
- .godmin-page-tabs__tab:is(:hover, :focus-visible) {
857
- color: var(--wpds-color-foreground-interactive-neutral-active);
944
+ .godmin-page-tabs__tab--current {
945
+ cursor: default;
858
946
  }
859
947
 
860
948
  .godmin-page-tabs__tab:focus-visible {
861
949
  outline: none;
862
950
  }
863
951
 
952
+ .godmin-page-tabs__tab:not(.godmin-page-tabs__tab--current):is(:hover, :active),
953
+ .godmin-page-tabs__tab:focus-visible {
954
+ color: var(--wpds-color-foreground-interactive-neutral-active);
955
+ }
956
+
957
+ .godmin-page-tabs__tab::after,
864
958
  .godmin-page-tabs__tab::before {
865
- content: '';
866
959
  position: absolute;
867
- inset: var(--wpds-dimension-padding-md) var(--wpds-border-width-focus);
960
+ z-index: -1;
868
961
  border-radius: var(--wpds-border-radius-sm);
869
- outline: var(--wpds-border-width-focus) solid var(--wpds-color-stroke-focus);
962
+ outline: var(--wpds-border-width-focus) solid transparent;
870
963
  opacity: 0;
871
964
  pointer-events: none;
872
965
  }
873
966
 
874
- .godmin-page-tabs__tab:focus-visible::before {
967
+ @media not (prefers-reduced-motion) {
968
+ .godmin-page-tabs__tab::after,
969
+ .godmin-page-tabs__tab::before {
970
+ transition: opacity 0.1s linear;
971
+ }
972
+ }
973
+
974
+ .godmin-page-tabs__tab::after {
975
+ content: '';
976
+ inset-block: calc(var(--wpds-dimension-padding-md) + var(--wpds-dimension-padding-xs));
977
+ inset-inline: 0;
978
+ outline-offset: var(--wpds-dimension-padding-xs);
979
+ }
980
+
981
+ .godmin-page-tabs__tab:focus-visible::after {
982
+ outline-color: var(--wpds-color-stroke-focus);
983
+ }
984
+
985
+ .godmin-page-tabs__tab:not(.godmin-page-tabs__tab--current):is(:hover, :active)::after,
986
+ .godmin-page-tabs__tab:focus-visible::after {
987
+ background-color: var(--wpds-color-background-interactive-neutral-weak-active);
988
+ box-shadow: 0 0 0 var(--wpds-dimension-padding-xs) var(--wpds-color-background-interactive-neutral-weak-active);
875
989
  opacity: 1;
876
990
  }
877
991
 
878
- .godmin-page-tabs__tab--current::after {
992
+ .godmin-page-tabs--scrolling .godmin-page-tabs__tab::before {
879
993
  content: '';
994
+ z-index: 0;
995
+ inset-block: var(--wpds-dimension-padding-md);
996
+ inset-inline: round(up, var(--wpds-border-width-focus), 1px);
997
+ }
998
+
999
+ .godmin-page-tabs--scrolling .godmin-page-tabs__tab:focus-visible::before {
1000
+ outline-color: var(--wpds-color-stroke-focus);
1001
+ opacity: 1;
1002
+ }
1003
+
1004
+ .godmin-page-tabs--scrolling .godmin-page-tabs__tab:focus-visible::after {
1005
+ outline-color: transparent;
1006
+ }
1007
+
1008
+ .godmin-page-tabs__line {
880
1009
  position: absolute;
881
1010
  inset-inline: 0;
882
1011
  inset-block-end: 0;
883
1012
  block-size: var(--wpds-border-width-focus);
884
- background: var(--wpds-color-stroke-interactive-neutral-strong);
1013
+ background-color: var(--wpds-color-foreground-interactive-neutral);
1014
+ outline: 2px solid transparent;
1015
+ outline-offset: -1px;
1016
+ pointer-events: none;
1017
+ }
1018
+
1019
+ .godmin-page-tabs__tab:focus-visible .godmin-page-tabs__line {
1020
+ background-color: var(--wpds-color-foreground-interactive-neutral-active);
885
1021
  }
886
1022
 
887
1023
  .godmin-page:has(> .godmin-page__list) > .godmin-page__header {
@@ -957,6 +1093,7 @@ body {
957
1093
  font-size: var(--wpds-typography-font-size-md);
958
1094
  line-height: var(--wpds-typography-line-height-sm);
959
1095
  text-align: left;
1096
+ overflow-wrap: normal;
960
1097
  }
961
1098
 
962
1099
  .godmin-table th,
@@ -12,11 +12,31 @@ declare const TRIGGERS: {
12
12
  type ItemTrigger = keyof typeof TRIGGERS;
13
13
  /** The trigger a list dialog opened from: an item's title, media, phone row or actions menu, or the bulk bar. */
14
14
  export type Trigger = ItemTrigger | 'bulk';
15
+ /** One request to put the focus back on the trigger a dialog opened from, a new one each time it is asked. */
16
+ export interface FocusBack {
17
+ /** The item the dialog acted on. */
18
+ id: string;
19
+ /** The trigger the dialog opened from. */
20
+ trigger: Trigger;
21
+ }
15
22
  /**
16
23
  * Returns the trigger a click, a tap or a key opened a dialog from, read from the focus it left there.
17
24
  * @returns The bulk bar, the media, the title or the phone row holding the focus, the actions menu otherwise.
18
25
  */
19
26
  export declare function focusedTrigger(): Trigger;
27
+ /**
28
+ * Returns the item a control sits on and the trigger it stands for.
29
+ * @param control - The control.
30
+ * @returns The item and the trigger, none for a control in no card or row, or in one the app marks with no id.
31
+ */
32
+ export declare function itemAt(control: Element): FocusBack | null;
33
+ /**
34
+ * Returns a trigger on an item, found wherever its card or row now sits.
35
+ * @param list - The list region.
36
+ * @param asked - The item and the trigger.
37
+ * @returns The trigger, else the item's actions menu, none for a bulk action or an item with neither in the list.
38
+ */
39
+ export declare function triggerOnItem(list: HTMLElement, { id, trigger }: FocusBack): HTMLElement | null;
20
40
  /**
21
41
  * Returns the handler putting a focus the page lost back on the trigger a list dialog opened from, once drawn again.
22
42
  * @param busy - Whether the list reads its items again, its cards and rows then out of reach of the focus.
@@ -14,16 +14,32 @@ const TRIGGERS = {
14
14
  /** Finds the bar DataViews draws the actions on the ticked items in. */
15
15
  const BULK_BAR = '.dataviews-bulk-actions-footer__container';
16
16
  /**
17
- * Returns the trigger a click, a tap or a key opened a dialog from, read from the focus it left there.
18
- * @returns The bulk bar, the media, the title or the phone row holding the focus, the actions menu otherwise.
17
+ * Returns the trigger a control stands for.
18
+ * @param control - The control.
19
+ * @returns The bulk bar, the media, the title or the phone row holding the control, the actions menu otherwise.
19
20
  */
20
- export function focusedTrigger() {
21
- const focused = document.activeElement;
22
- if (focused.closest(BULK_BAR) !== null) {
21
+ function triggerAt(control) {
22
+ if (control.closest(BULK_BAR) !== null) {
23
23
  return 'bulk';
24
24
  }
25
25
  const triggers = ['media', 'title', 'row'];
26
- return triggers.find((trigger) => focused.closest(TRIGGERS[trigger]) !== null) ?? 'actions';
26
+ return triggers.find((trigger) => control.closest(TRIGGERS[trigger]) !== null) ?? 'actions';
27
+ }
28
+ /**
29
+ * Returns the trigger a click, a tap or a key opened a dialog from, read from the focus it left there.
30
+ * @returns The bulk bar, the media, the title or the phone row holding the focus, the actions menu otherwise.
31
+ */
32
+ export function focusedTrigger() {
33
+ return triggerAt(document.activeElement);
34
+ }
35
+ /**
36
+ * Returns the item a control sits on and the trigger it stands for.
37
+ * @param control - The control.
38
+ * @returns The item and the trigger, none for a control in no card or row, or in one the app marks with no id.
39
+ */
40
+ export function itemAt(control) {
41
+ const id = control.closest(HOLDERS)?.querySelector(MARKED)?.dataset.itemId;
42
+ return id === undefined ? null : { id, trigger: triggerAt(control) };
27
43
  }
28
44
  /**
29
45
  * Returns the card or the row holding an item inside the list, found through the mark on its cells.
@@ -36,18 +52,26 @@ function holderOf(list, id) {
36
52
  return marked?.closest(HOLDERS) ?? null;
37
53
  }
38
54
  /**
39
- * Returns the trigger a dialog on an item opened from, found wherever its card or row now sits.
55
+ * Returns a trigger on an item, found wherever its card or row now sits.
40
56
  * @param list - The list region.
41
57
  * @param asked - The item and the trigger.
42
- * @returns The trigger, else the item's actions menu, else the list, which a bulk action always gets.
58
+ * @returns The trigger, else the item's actions menu, none for a bulk action or an item with neither in the list.
43
59
  */
44
- function triggerOf(list, { id, trigger }) {
60
+ export function triggerOnItem(list, { id, trigger }) {
45
61
  const holder = holderOf(list, id);
46
62
  if (trigger === 'bulk' || holder === null) {
47
- return list;
63
+ return null;
48
64
  }
49
- const found = holder.querySelector(TRIGGERS[trigger]);
50
- return found ?? holder.querySelector(TRIGGERS.actions) ?? list;
65
+ return holder.querySelector(TRIGGERS[trigger]) ?? holder.querySelector(TRIGGERS.actions);
66
+ }
67
+ /**
68
+ * Returns the trigger a dialog on an item opened from, found wherever its card or row now sits.
69
+ * @param list - The list region.
70
+ * @param asked - The item and the trigger.
71
+ * @returns The trigger, else the item's actions menu, else the list, which a bulk action always gets.
72
+ */
73
+ function triggerOf(list, asked) {
74
+ return triggerOnItem(list, asked) ?? list;
51
75
  }
52
76
  /** Stops nothing, for a focus put on the list region, which no layout of the list takes off the page. */
53
77
  function stopNothing() { }
package/dist/index.d.ts CHANGED
@@ -38,6 +38,8 @@ export { openOnTap } from './open-on-tap.js';
38
38
  export type { TapList } from './open-on-tap.js';
39
39
  export { ErrorNotice, LoadMore, Page, PageTitle, SectionTitle } from './page.js';
40
40
  export type { LoadMoreQuery, PageProps } from './page.js';
41
+ export { PageBreadcrumb, PageBreadcrumbs } from './page-breadcrumbs.js';
42
+ export type { PageBreadcrumbProps, PageBreadcrumbsProps } from './page-breadcrumbs.js';
41
43
  export { PageTab, PageTabs } from './page-tabs.js';
42
44
  export type { PageTabProps, PageTabsProps } from './page-tabs.js';
43
45
  export { RenameBody } from './rename.js';
@@ -62,6 +64,6 @@ export type { GuardedField, OfferedView, ViewGuard } from './view-guard.js';
62
64
  * The design system version window this build was tested against.
63
65
  */
64
66
  export declare const SUPPORTED_WPDS: {
65
- readonly '@wordpress/ui': ">=0.24.0 <0.25.0";
66
- readonly '@wordpress/theme': ">=2.3.0 <3.0.0";
67
+ readonly '@wordpress/ui': ">=0.25.0 <0.26.0";
68
+ readonly '@wordpress/theme': ">=3.0.0 <4.0.0";
67
69
  };
package/dist/index.js CHANGED
@@ -20,6 +20,7 @@ export { MenuCount } from './menu-count.js';
20
20
  export { NavigationScreen } from './navigation-screen.js';
21
21
  export { openOnTap } from './open-on-tap.js';
22
22
  export { ErrorNotice, LoadMore, Page, PageTitle, SectionTitle } from './page.js';
23
+ export { PageBreadcrumb, PageBreadcrumbs } from './page-breadcrumbs.js';
23
24
  export { PageTab, PageTabs } from './page-tabs.js';
24
25
  export { RenameBody } from './rename.js';
25
26
  export { useRowKeys } from './row-keys.js';
@@ -35,6 +36,6 @@ export { offeredView, viewNarrows } from './view-guard.js';
35
36
  * The design system version window this build was tested against.
36
37
  */
37
38
  export const SUPPORTED_WPDS = {
38
- '@wordpress/ui': '>=0.24.0 <0.25.0',
39
- '@wordpress/theme': '>=2.3.0 <3.0.0',
39
+ '@wordpress/ui': '>=0.25.0 <0.26.0',
40
+ '@wordpress/theme': '>=3.0.0 <4.0.0',
40
41
  };
@@ -2,11 +2,11 @@
2
2
  /** The Spanish list chrome, list dates, sidebar and no results words, compiled from the es-ES.po source beside it. */
3
3
  const catalog = {
4
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'],
5
+ '%1$s of %2$s Item': ['%1$s de %2$s elemento', '%1$s de %2$s elementos'],
6
6
  '%1$s, %2$s': ['%1$s, %2$s'],
7
7
  '%1$s: %2$s': ['%1$s: %2$s'],
8
- '%d Item': ['%d elemento', '%d elementos'],
9
- '%d Item selected': ['%d elemento seleccionado', '%d elementos seleccionados'],
8
+ '%s Item': ['%s elemento', '%s elementos'],
9
+ '%s Item selected': ['%s elemento seleccionado', '%s elementos seleccionados'],
10
10
  '%s, selected': ['%s, seleccionado'],
11
11
  '%s: <groupName />': ['%s: <groupName />'],
12
12
  '(no title)': ['(sin título)'],
package/dist/list-run.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  import { useLayoutEffect, useRef, useState } from 'react';
3
- import { HOLDERS } from './focus-back.js';
3
+ import { HOLDERS, itemAt, triggerOnItem } from './focus-back.js';
4
4
  /** Finds the dialog or the alert dialog holding the focus. */
5
5
  const DIALOG_IN_FOCUS = '[role="dialog"]:focus-within, [role="alertdialog"]:focus-within';
6
6
  /** Finds a part that turned inert while it holds the focus. */
@@ -98,7 +98,17 @@ function placeOf(list, focused) {
98
98
  return null;
99
99
  }
100
100
  const control = focused;
101
- return { control, row: [...list.querySelectorAll(HOLDERS)].indexOf(control.closest(HOLDERS)) };
101
+ const row = [...list.querySelectorAll(HOLDERS)].indexOf(control.closest(HOLDERS));
102
+ return { control, row, item: itemAt(control) };
103
+ }
104
+ /**
105
+ * Returns the trigger on the item the reader stood on, found wherever its card or row now sits.
106
+ * @param list - The list region.
107
+ * @param place - Where the reader stood.
108
+ * @returns The trigger, none once the item left the list or when the app marks no item there.
109
+ */
110
+ function onSameItem(list, { item }) {
111
+ return item === null ? null : triggerOnItem(list, item);
102
112
  }
103
113
  /**
104
114
  * Returns the first control of the card or row that now sits where the place's sat, the last one when fewer came back.
@@ -112,7 +122,7 @@ function firstInPlace(list, { row }) {
112
122
  return first?.matches(ACTION_BUTTON) ? null : first;
113
123
  }
114
124
  /**
115
- * Gives the focus back from the list region to the pressed control, else to the first control of the row in its place.
125
+ * Gives the focus back from the list region to the pressed control, else the same item, else the row in its place.
116
126
  * @param list - The list region, none while the screen draws no list.
117
127
  * @param place - Where the reader stood as the list took the focus, none when they stood nowhere in it.
118
128
  */
@@ -121,7 +131,7 @@ function putBack(list, place) {
121
131
  return;
122
132
  }
123
133
  const preventScroll = !list.matches(':focus-visible');
124
- for (const control of [place.control, firstInPlace(list, place)]) {
134
+ for (const control of [place.control, onSameItem(list, place), firstInPlace(list, place)]) {
125
135
  if (document.activeElement === list) {
126
136
  control?.focus({ preventScroll });
127
137
  }
@@ -0,0 +1,28 @@
1
+ import { Link } from '@wordpress/ui';
2
+ import type { ComponentProps, ReactNode } from 'react';
3
+ export interface PageBreadcrumbsProps {
4
+ /** The name of the navigation region, read by assistive technology. */
5
+ label: string;
6
+ /** The links, one PageBreadcrumb each. */
7
+ children: ReactNode;
8
+ }
9
+ /**
10
+ * Renders the links that lead back from a record as a navigation region holding a list, as admin-ui draws its trail.
11
+ * @param props - The navigation name and the links.
12
+ * @returns The navigation element.
13
+ */
14
+ export declare function PageBreadcrumbs({ label, children }: PageBreadcrumbsProps): import("react").JSX.Element;
15
+ export interface PageBreadcrumbProps {
16
+ /** The address the link leads to, when it renders as a plain link. */
17
+ href?: string;
18
+ /** The link element the breadcrumb renders through, such as a router link. */
19
+ render?: ComponentProps<typeof Link>['render'];
20
+ /** The link label. */
21
+ children: ReactNode;
22
+ }
23
+ /**
24
+ * Renders one link of the breadcrumbs as a list item, with the slash after it.
25
+ * @param props - The address or the link element, and the label.
26
+ * @returns The list item element.
27
+ */
28
+ export declare function PageBreadcrumb({ href, render, children }: PageBreadcrumbProps): import("react").JSX.Element;
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Link, Text } from '@wordpress/ui';
3
+ /**
4
+ * Renders the links that lead back from a record as a navigation region holding a list, as admin-ui draws its trail.
5
+ * @param props - The navigation name and the links.
6
+ * @returns The navigation element.
7
+ */
8
+ export function PageBreadcrumbs({ label, children }) {
9
+ return (_jsx("nav", { "aria-label": label, className: "godmin-page__breadcrumbs", children: _jsx("ul", { role: "list", children: children }) }));
10
+ }
11
+ /**
12
+ * Renders one link of the breadcrumbs as a list item, with the slash after it.
13
+ * @param props - The address or the link element, and the label.
14
+ * @returns The list item element.
15
+ */
16
+ export function PageBreadcrumb({ href, render, children }) {
17
+ return (_jsxs("li", { children: [_jsx(Text, { variant: "body-lg", render: _jsx(Link, { tone: "neutral", href: href, render: render }), children: children }), _jsx(Text, { variant: "body-lg", "aria-hidden": "true", className: "godmin-page__separator", children: "/" })] }));
18
+ }
package/dist/page-tabs.js CHANGED
@@ -1,10 +1,14 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { cloneElement, useLayoutEffect, useRef, useState } from 'react';
3
3
  import { ROUNDING_SLACK, useSizeWatch } from './size-watch.js';
4
4
  /**
5
5
  * The class every tab row carries.
6
6
  */
7
7
  const ROW_CLASS = 'godmin-page-tabs';
8
+ /**
9
+ * The class of a tab row wider than its space.
10
+ */
11
+ const SCROLLS_CLASS = 'godmin-page-tabs--scrolling';
8
12
  /**
9
13
  * The class that fades the start edge of a tab row scrolled past its first tabs.
10
14
  */
@@ -22,7 +26,11 @@ const TAB_CLASS = 'godmin-page-tabs__tab';
22
26
  */
23
27
  const CURRENT_CLASS = 'godmin-page-tabs__tab--current';
24
28
  /**
25
- * Returns the classes of a tab row, fading each edge that tabs lie past.
29
+ * The class of the line under the tab of the page on screen.
30
+ */
31
+ const LINE_CLASS = 'godmin-page-tabs__line';
32
+ /**
33
+ * Returns the classes of a tab row, marking one wider than its space and fading each edge that tabs lie past.
26
34
  * @param row - The tab row element.
27
35
  * @returns The class list.
28
36
  */
@@ -30,6 +38,9 @@ function rowClass(row) {
30
38
  const travelled = Math.abs(row.scrollLeft);
31
39
  const room = row.scrollWidth - row.clientWidth;
32
40
  let classes = ROW_CLASS;
41
+ if (room > 0) {
42
+ classes += ` ${SCROLLS_CLASS}`;
43
+ }
33
44
  if (travelled > ROUNDING_SLACK) {
34
45
  classes += ` ${FADES_START_CLASS}`;
35
46
  }
@@ -79,14 +90,14 @@ function reveal(row, tab) {
79
90
  }
80
91
  }
81
92
  /**
82
- * Scrolls a tab row to its current tab each time a tab becomes current, forgetting the last one while none is.
93
+ * Scrolls a tab row to its current tab as a tab becomes current or the row starts to scroll, forgetting it otherwise.
83
94
  * @param ref - The tab row element.
84
95
  */
85
96
  function useRevealCurrent(ref) {
86
97
  const shown = useRef(null);
87
98
  useLayoutEffect(() => {
88
99
  const row = ref.current;
89
- const tab = row.querySelector(`.${CURRENT_CLASS}`);
100
+ const tab = row.classList.contains(SCROLLS_CLASS) ? row.querySelector(`.${CURRENT_CLASS}`) : null;
90
101
  const last = shown.current;
91
102
  shown.current = tab;
92
103
  if (tab === null || tab === last) {
@@ -115,14 +126,15 @@ export function PageTabs({ label, children }) {
115
126
  function TabLink({ href, render, current = false, children }) {
116
127
  const ariaCurrent = current ? 'page' : undefined;
117
128
  const tabClass = current ? `${TAB_CLASS} ${CURRENT_CLASS}` : TAB_CLASS;
129
+ const label = (_jsxs(_Fragment, { children: [children, current && _jsx("span", { className: LINE_CLASS })] }));
118
130
  if (render === undefined) {
119
- return (_jsx("a", { href: href, className: tabClass, "aria-current": ariaCurrent, children: children }));
131
+ return (_jsx("a", { href: href, className: tabClass, "aria-current": ariaCurrent, children: label }));
120
132
  }
121
133
  const own = render.props.className;
122
134
  return cloneElement(render, {
123
135
  className: own === undefined ? tabClass : `${own} ${tabClass}`,
124
136
  'aria-current': ariaCurrent,
125
- children,
137
+ children: label,
126
138
  });
127
139
  }
128
140
  /**
package/dist/page.d.ts CHANGED
@@ -37,7 +37,12 @@ export interface PageProps {
37
37
  subtitle?: string;
38
38
  actions?: ReactNode;
39
39
  tabs?: ReactNode;
40
+ /** The details of a record, in a fixed column at the end of the page. */
40
41
  aside?: ReactNode;
42
+ /** The name of the details column. */
43
+ asideLabel?: string;
44
+ /** The links back to what a record belongs to, before the title. */
45
+ breadcrumbs?: ReactNode;
41
46
  list?: boolean;
42
47
  /** The name of the list region. */
43
48
  listLabel?: string;
@@ -50,11 +55,11 @@ export interface PageProps {
50
55
  }
51
56
  /**
52
57
  * Renders a screen: a header with the title, actions and subtitle, then optional tabs and the content.
53
- * @param props - The title, subtitle, actions, tabs, aside, list flag, list name and ref, extra class, title level
54
- * and content.
58
+ * @param props - The title, subtitle, actions, tabs, aside and its name, breadcrumbs, list flag, list name and ref,
59
+ * extra class, title level and content.
55
60
  * @returns The page element.
56
61
  */
57
- export declare function Page({ title, subtitle, actions, tabs, aside, list, listLabel, listRef, className, headingLevel, children, }: PageProps): import("react").JSX.Element;
62
+ export declare function Page({ title, subtitle, actions, tabs, aside, asideLabel, breadcrumbs, list, listLabel, listRef, className, headingLevel, children, }: PageProps): import("react").JSX.Element;
58
63
  /**
59
64
  * Renders a failure message that a screen reader announces.
60
65
  * @param props - The message to announce.