@namroodinc/liquid-editorial 0.8.0 → 0.9.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 +13 -7
- package/UPGRADING.md +142 -0
- package/dist/chunks/{Avatar-6t78C9Np.js → Avatar-BK8IdL5W.js} +2 -2
- package/dist/chunks/{Avatar-6t78C9Np.js.map → Avatar-BK8IdL5W.js.map} +1 -1
- package/dist/chunks/{Avatar-Cvj_DqG0.cjs → Avatar-DPnrvkwd.cjs} +2 -2
- package/dist/chunks/{Avatar-Cvj_DqG0.cjs.map → Avatar-DPnrvkwd.cjs.map} +1 -1
- package/dist/chunks/{CollectionView-B18Ihv7X.cjs → CollectionView-BNYx29b1.cjs} +2 -2
- package/dist/chunks/{CollectionView-B18Ihv7X.cjs.map → CollectionView-BNYx29b1.cjs.map} +1 -1
- package/dist/chunks/{CollectionView-C-SwkPWC.js → CollectionView-Vj84E26b.js} +2 -2
- package/dist/chunks/{CollectionView-C-SwkPWC.js.map → CollectionView-Vj84E26b.js.map} +1 -1
- package/dist/chunks/{ColourField-Dohdx7eW.cjs → ColourField-C1qjpIfB.cjs} +2 -2
- package/dist/chunks/{ColourField-Dohdx7eW.cjs.map → ColourField-C1qjpIfB.cjs.map} +1 -1
- package/dist/chunks/{ColourField-DzZ--mQZ.js → ColourField-Ce2oaVcd.js} +2 -2
- package/dist/chunks/{ColourField-DzZ--mQZ.js.map → ColourField-Ce2oaVcd.js.map} +1 -1
- package/dist/chunks/{DatePicker-Bjc4D8Kg.cjs → DatePicker-BCnzFJFF.cjs} +2 -2
- package/dist/chunks/{DatePicker-Bjc4D8Kg.cjs.map → DatePicker-BCnzFJFF.cjs.map} +1 -1
- package/dist/chunks/{DatePicker-DZVOtzoU.js → DatePicker-CnVmsCwO.js} +2 -2
- package/dist/chunks/{DatePicker-DZVOtzoU.js.map → DatePicker-CnVmsCwO.js.map} +1 -1
- package/dist/chunks/{Drawer-CcVF_p4b.cjs → Drawer-BDX9_qHA.cjs} +2 -2
- package/dist/chunks/Drawer-BDX9_qHA.cjs.map +1 -0
- package/dist/chunks/{Drawer-uhJvy3s9.js → Drawer-DTtgAZO2.js} +3 -3
- package/dist/chunks/Drawer-DTtgAZO2.js.map +1 -0
- package/dist/chunks/EntryPicker-Baqn0SQM.cjs +2 -0
- package/dist/chunks/EntryPicker-Baqn0SQM.cjs.map +1 -0
- package/dist/chunks/EntryPicker-DIYjKmBf.js +803 -0
- package/dist/chunks/EntryPicker-DIYjKmBf.js.map +1 -0
- package/dist/chunks/FormEditor-B7Pm_ZzT.cjs +2 -0
- package/dist/chunks/FormEditor-B7Pm_ZzT.cjs.map +1 -0
- package/dist/chunks/{FormEditor-D0J3JN-H.js → FormEditor-HqqFmu7s.js} +156 -150
- package/dist/chunks/FormEditor-HqqFmu7s.js.map +1 -0
- package/dist/chunks/{RichTextEditor-B6H6_3wk.js → RichTextEditor-CuZnjiy2.js} +86 -86
- package/dist/chunks/RichTextEditor-CuZnjiy2.js.map +1 -0
- package/dist/chunks/RichTextEditor-DcbLho2Q.cjs +2 -0
- package/dist/chunks/RichTextEditor-DcbLho2Q.cjs.map +1 -0
- package/dist/chunks/{dialogLabel-3EeaH1Zl.cjs → dialogLabel-2HRYMHbF.cjs} +2 -2
- package/dist/chunks/{dialogLabel-3EeaH1Zl.cjs.map → dialogLabel-2HRYMHbF.cjs.map} +1 -1
- package/dist/chunks/{dialogLabel-BjtTix5C.js → dialogLabel-D18maX-p.js} +2 -2
- package/dist/chunks/{dialogLabel-BjtTix5C.js.map → dialogLabel-D18maX-p.js.map} +1 -1
- package/dist/chunks/{frame-CycTDnzE.js → frame-CzadNYgy.js} +3 -3
- package/dist/chunks/{frame-CycTDnzE.js.map → frame-CzadNYgy.js.map} +1 -1
- package/dist/chunks/{frame-BtIh7K-M.cjs → frame-Mh99nmhR.cjs} +2 -2
- package/dist/chunks/{frame-BtIh7K-M.cjs.map → frame-Mh99nmhR.cjs.map} +1 -1
- package/dist/chunks/group-CJA3-3s5.js +35 -0
- package/dist/chunks/group-CJA3-3s5.js.map +1 -0
- package/dist/chunks/group-DRSLOsXu.cjs +2 -0
- package/dist/chunks/group-DRSLOsXu.cjs.map +1 -0
- package/dist/chunks/limit-BNo4dlRj.cjs +2 -0
- package/dist/chunks/limit-BNo4dlRj.cjs.map +1 -0
- package/dist/chunks/{limit-BHHST_0G.js → limit-s9zfxIMC.js} +5 -4
- package/dist/chunks/limit-s9zfxIMC.js.map +1 -0
- package/dist/chunks/overlayLayer-IuoPVwTO.js +158 -0
- package/dist/chunks/overlayLayer-IuoPVwTO.js.map +1 -0
- package/dist/chunks/overlayLayer-seJG-EFn.cjs +2 -0
- package/dist/chunks/overlayLayer-seJG-EFn.cjs.map +1 -0
- package/dist/chunks/useIsomorphicLayoutEffect-Bc9hxFMc.js +7 -0
- package/dist/chunks/useIsomorphicLayoutEffect-Bc9hxFMc.js.map +1 -0
- package/dist/chunks/useIsomorphicLayoutEffect-XM4Ot6x5.cjs +2 -0
- package/dist/chunks/useIsomorphicLayoutEffect-XM4Ot6x5.cjs.map +1 -0
- package/dist/chunks/{useLimit-WWWDacob.cjs → useLimit-CCv6sAUS.cjs} +2 -2
- package/dist/chunks/{useLimit-WWWDacob.cjs.map → useLimit-CCv6sAUS.cjs.map} +1 -1
- package/dist/chunks/{useLimit-C471qZ4H.js → useLimit-DZOKm4S_.js} +2 -2
- package/dist/chunks/{useLimit-C471qZ4H.js.map → useLimit-DZOKm4S_.js.map} +1 -1
- package/dist/chunks/{useTooltip-DtrE7QYu.cjs → useTooltip-BXAvQwt4.cjs} +2 -2
- package/dist/chunks/{useTooltip-DtrE7QYu.cjs.map → useTooltip-BXAvQwt4.cjs.map} +1 -1
- package/dist/chunks/{useTooltip-DajWQyNL.js → useTooltip-BrC7FdeH.js} +2 -2
- package/dist/chunks/{useTooltip-DajWQyNL.js.map → useTooltip-BrC7FdeH.js.map} +1 -1
- package/dist/components/AppShell/index.cjs +1 -1
- package/dist/components/AppShell/index.js +1 -1
- package/dist/components/Avatar/index.cjs +1 -1
- package/dist/components/Avatar/index.js +1 -1
- package/dist/components/Badge/style.css +1 -1
- package/dist/components/Choice/index.cjs +1 -1
- package/dist/components/Choice/index.cjs.map +1 -1
- package/dist/components/Choice/index.d.cts +13 -2
- package/dist/components/Choice/index.d.cts.map +1 -1
- package/dist/components/Choice/index.d.ts +13 -2
- package/dist/components/Choice/index.d.ts.map +1 -1
- package/dist/components/Choice/index.js +55 -35
- package/dist/components/Choice/index.js.map +1 -1
- package/dist/components/Choice/style.css +7 -2
- package/dist/components/CollectionView/index.cjs +1 -1
- package/dist/components/CollectionView/index.js +1 -1
- package/dist/components/ColourField/index.cjs +1 -1
- package/dist/components/ColourField/index.js +1 -1
- package/dist/components/DatePicker/index.cjs +1 -1
- package/dist/components/DatePicker/index.js +1 -1
- package/dist/components/Drawer/index.cjs +1 -1
- package/dist/components/Drawer/index.d.cts +4 -1
- package/dist/components/Drawer/index.d.cts.map +1 -1
- package/dist/components/Drawer/index.d.ts +4 -1
- package/dist/components/Drawer/index.d.ts.map +1 -1
- package/dist/components/Drawer/index.js +1 -1
- package/dist/components/Drawer/style.css +4 -1
- package/dist/components/EditLayout/index.cjs +1 -1
- package/dist/components/EditLayout/index.cjs.map +1 -1
- package/dist/components/EditLayout/index.d.cts.map +1 -1
- package/dist/components/EditLayout/index.d.ts.map +1 -1
- package/dist/components/EditLayout/index.js +62 -61
- package/dist/components/EditLayout/index.js.map +1 -1
- package/dist/components/EditLayout/style.css +12 -5
- package/dist/components/EntryPicker/blocked.d.cts +21 -0
- package/dist/components/EntryPicker/blocked.d.cts.map +1 -0
- package/dist/components/EntryPicker/blocked.d.ts +21 -0
- package/dist/components/EntryPicker/blocked.d.ts.map +1 -0
- package/dist/components/EntryPicker/dialog.d.cts +7 -3
- package/dist/components/EntryPicker/dialog.d.cts.map +1 -1
- package/dist/components/EntryPicker/dialog.d.ts +7 -3
- package/dist/components/EntryPicker/dialog.d.ts.map +1 -1
- package/dist/components/EntryPicker/index.cjs +1 -1
- package/dist/components/EntryPicker/index.d.cts.map +1 -1
- package/dist/components/EntryPicker/index.d.ts.map +1 -1
- package/dist/components/EntryPicker/index.js +1 -1
- package/dist/components/EntryPicker/item.d.cts +25 -1
- package/dist/components/EntryPicker/item.d.cts.map +1 -1
- package/dist/components/EntryPicker/item.d.ts +25 -1
- package/dist/components/EntryPicker/item.d.ts.map +1 -1
- package/dist/components/EntryPicker/limit.d.cts +25 -2
- package/dist/components/EntryPicker/limit.d.cts.map +1 -1
- package/dist/components/EntryPicker/limit.d.ts +25 -2
- package/dist/components/EntryPicker/limit.d.ts.map +1 -1
- package/dist/components/EntryPicker/results.d.cts +3 -4
- package/dist/components/EntryPicker/results.d.cts.map +1 -1
- package/dist/components/EntryPicker/results.d.ts +3 -4
- package/dist/components/EntryPicker/results.d.ts.map +1 -1
- package/dist/components/EntryPicker/selected-items.d.cts.map +1 -1
- package/dist/components/EntryPicker/selected-items.d.ts.map +1 -1
- package/dist/components/EntryPicker/style.css +79 -12
- package/dist/components/EntryPicker/types.d.cts +8 -0
- package/dist/components/EntryPicker/types.d.cts.map +1 -1
- package/dist/components/EntryPicker/types.d.ts +8 -0
- package/dist/components/EntryPicker/types.d.ts.map +1 -1
- package/dist/components/EntryPicker/use-picker-scroll.d.cts +14 -0
- package/dist/components/EntryPicker/use-picker-scroll.d.cts.map +1 -0
- package/dist/components/EntryPicker/use-picker-scroll.d.ts +14 -0
- package/dist/components/EntryPicker/use-picker-scroll.d.ts.map +1 -0
- package/dist/components/Field/group.d.cts +1 -1
- package/dist/components/Field/group.d.cts.map +1 -1
- package/dist/components/Field/group.d.ts +1 -1
- package/dist/components/Field/group.d.ts.map +1 -1
- package/dist/components/Field/index.cjs +1 -1
- package/dist/components/Field/index.js +1 -1
- package/dist/components/Field/types.d.cts +3 -1
- package/dist/components/Field/types.d.cts.map +1 -1
- package/dist/components/Field/types.d.ts +3 -1
- package/dist/components/Field/types.d.ts.map +1 -1
- package/dist/components/FieldAffix/index.cjs +1 -1
- package/dist/components/FieldAffix/index.cjs.map +1 -1
- package/dist/components/FieldAffix/index.d.cts.map +1 -1
- package/dist/components/FieldAffix/index.d.ts.map +1 -1
- package/dist/components/FieldAffix/index.js +2 -1
- package/dist/components/FieldAffix/index.js.map +1 -1
- package/dist/components/FormEditor/README.md +31 -10
- package/dist/components/FormEditor/index.cjs +1 -1
- package/dist/components/FormEditor/index.d.cts.map +1 -1
- package/dist/components/FormEditor/index.d.ts.map +1 -1
- package/dist/components/FormEditor/index.js +1 -1
- package/dist/components/FormEditor/model.d.cts +9 -2
- package/dist/components/FormEditor/model.d.cts.map +1 -1
- package/dist/components/FormEditor/model.d.ts +9 -2
- package/dist/components/FormEditor/model.d.ts.map +1 -1
- package/dist/components/ImageCropper/index.cjs +1 -1
- package/dist/components/ImageCropper/index.cjs.map +1 -1
- package/dist/components/ImageCropper/index.d.cts.map +1 -1
- package/dist/components/ImageCropper/index.d.ts.map +1 -1
- package/dist/components/ImageCropper/index.js +30 -29
- package/dist/components/ImageCropper/index.js.map +1 -1
- package/dist/components/LimitReading/index.cjs +1 -1
- package/dist/components/LimitReading/index.cjs.map +1 -1
- package/dist/components/LimitReading/index.d.cts +1 -1
- package/dist/components/LimitReading/index.d.cts.map +1 -1
- package/dist/components/LimitReading/index.d.ts +1 -1
- package/dist/components/LimitReading/index.d.ts.map +1 -1
- package/dist/components/LimitReading/index.js +19 -14
- package/dist/components/LimitReading/index.js.map +1 -1
- package/dist/components/LimitReading/limit.d.cts +3 -3
- package/dist/components/LimitReading/limit.d.cts.map +1 -1
- package/dist/components/LimitReading/limit.d.ts +3 -3
- package/dist/components/LimitReading/limit.d.ts.map +1 -1
- package/dist/components/LimitReading/types.d.cts +8 -0
- package/dist/components/LimitReading/types.d.cts.map +1 -1
- package/dist/components/LimitReading/types.d.ts +8 -0
- package/dist/components/LimitReading/types.d.ts.map +1 -1
- package/dist/components/Menu/index.cjs +1 -1
- package/dist/components/Menu/index.js +1 -1
- package/dist/components/Modal/index.cjs +1 -1
- package/dist/components/Modal/index.cjs.map +1 -1
- package/dist/components/Modal/index.d.cts +4 -1
- package/dist/components/Modal/index.d.cts.map +1 -1
- package/dist/components/Modal/index.d.ts +4 -1
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/Modal/index.js +5 -3
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/Modal/style.css +4 -1
- package/dist/components/Popover/index.cjs +1 -1
- package/dist/components/Popover/index.js +1 -1
- package/dist/components/RichTextEditor/expansion.d.cts.map +1 -1
- package/dist/components/RichTextEditor/expansion.d.ts.map +1 -1
- package/dist/components/RichTextEditor/index.cjs +1 -1
- package/dist/components/RichTextEditor/index.js +1 -1
- package/dist/components/SearchField/index.cjs +1 -1
- package/dist/components/SearchField/index.js +1 -1
- package/dist/components/Select/index.cjs +1 -1
- package/dist/components/Select/index.js +1 -1
- package/dist/components/SelectionCard/index.cjs +1 -1
- package/dist/components/SelectionCard/index.js +1 -1
- package/dist/components/SortableList/index.cjs +1 -1
- package/dist/components/SortableList/index.cjs.map +1 -1
- package/dist/components/SortableList/index.d.cts +2 -0
- package/dist/components/SortableList/index.d.cts.map +1 -1
- package/dist/components/SortableList/index.d.ts +2 -0
- package/dist/components/SortableList/index.d.ts.map +1 -1
- package/dist/components/SortableList/index.js +14 -13
- package/dist/components/SortableList/index.js.map +1 -1
- package/dist/components/SubNav/index.cjs +1 -1
- package/dist/components/SubNav/index.cjs.map +1 -1
- package/dist/components/SubNav/index.d.cts.map +1 -1
- package/dist/components/SubNav/index.d.ts.map +1 -1
- package/dist/components/SubNav/index.js +40 -31
- package/dist/components/SubNav/index.js.map +1 -1
- package/dist/components/SubNav/style.css +0 -14
- package/dist/components/TagsInput/index.cjs +1 -1
- package/dist/components/TagsInput/index.js +1 -1
- package/dist/components/TextField/index.cjs +1 -1
- package/dist/components/TextField/index.js +1 -1
- package/dist/components/Time/index.cjs +1 -1
- package/dist/components/Time/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -15
- package/dist/internal/portalScope.d.cts.map +1 -1
- package/dist/internal/portalScope.d.ts.map +1 -1
- package/dist/internal/useIsomorphicLayoutEffect.d.cts +7 -0
- package/dist/internal/useIsomorphicLayoutEffect.d.cts.map +1 -0
- package/dist/internal/useIsomorphicLayoutEffect.d.ts +7 -0
- package/dist/internal/useIsomorphicLayoutEffect.d.ts.map +1 -0
- package/dist/internal/useLatest.d.cts.map +1 -1
- package/dist/internal/useLatest.d.ts.map +1 -1
- package/dist/internal/useModalDialog.d.cts.map +1 -1
- package/dist/internal/useModalDialog.d.ts.map +1 -1
- package/dist/tokens.css +1 -0
- package/package.json +1 -1
- package/dist/chunks/Drawer-CcVF_p4b.cjs.map +0 -1
- package/dist/chunks/Drawer-uhJvy3s9.js.map +0 -1
- package/dist/chunks/EntryPicker-CBquan7o.js +0 -685
- package/dist/chunks/EntryPicker-CBquan7o.js.map +0 -1
- package/dist/chunks/EntryPicker-Dq72wjTt.cjs +0 -2
- package/dist/chunks/EntryPicker-Dq72wjTt.cjs.map +0 -1
- package/dist/chunks/FormEditor-CTcnpR51.cjs +0 -2
- package/dist/chunks/FormEditor-CTcnpR51.cjs.map +0 -1
- package/dist/chunks/FormEditor-D0J3JN-H.js.map +0 -1
- package/dist/chunks/RichTextEditor-B6H6_3wk.js.map +0 -1
- package/dist/chunks/RichTextEditor-BIopdEDA.cjs +0 -2
- package/dist/chunks/RichTextEditor-BIopdEDA.cjs.map +0 -1
- package/dist/chunks/group-67F_I1yw.js +0 -34
- package/dist/chunks/group-67F_I1yw.js.map +0 -1
- package/dist/chunks/group-BSJHLagi.cjs +0 -2
- package/dist/chunks/group-BSJHLagi.cjs.map +0 -1
- package/dist/chunks/limit-BBnpe9o9.cjs +0 -2
- package/dist/chunks/limit-BBnpe9o9.cjs.map +0 -1
- package/dist/chunks/limit-BHHST_0G.js.map +0 -1
- package/dist/chunks/overlayLayer-BgnMskpk.js +0 -158
- package/dist/chunks/overlayLayer-BgnMskpk.js.map +0 -1
- package/dist/chunks/overlayLayer-YVudmo27.cjs +0 -2
- package/dist/chunks/overlayLayer-YVudmo27.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -299,7 +299,7 @@ export function ConfirmPublish({ onPublish }: { onPublish: () => void }) {
|
|
|
299
299
|
}
|
|
300
300
|
```
|
|
301
301
|
|
|
302
|
-
Modal portals to the body, traps Tab and locks scrolling. Opening focuses the first control unless focus is already inside the panel (for example through `autoFocus`). Closing returns focus to the opener only when closing dropped it, and falls back to the opener's nearest focusable container, such as an enclosing Drawer, when the opener can no longer take focus. Tab wraps between the first and last rendered controls, counting a radio group as one stop, and focus that leaves the panel returns on the next Tab. Escape, the scrim, and Close request dismissal; the app updates `isOpen`. A popup inside the panel (Menu, Select, DateField) handles Escape first, and Escape that ends an IME composition never closes the dialog. Nested dialogs share the dialog stack and scroll lock.
|
|
302
|
+
Modal portals to the body, traps Tab and locks scrolling. Opening focuses the first control unless focus is already inside the panel (for example through `autoFocus`). Closing returns focus to the opener only when closing dropped it, and falls back to the opener's nearest focusable container, such as an enclosing Drawer, when the opener can no longer take focus. Tab wraps between the first and last rendered controls, counting a radio group as one stop, and focus that leaves the panel returns on the next Tab. Escape, the scrim, and Close request dismissal; the app updates `isOpen`. A popup inside the panel (Menu, Select, DateField) handles Escape first, and Escape that ends an IME composition never closes the dialog. Nested dialogs share the dialog stack and scroll lock. A dialog hidden by `isHidden`, or suspended with an ancestor overlay, stays laid out but invisible (`visibility: hidden`), inert and hidden from assistive technology, so its scroll areas keep their positions and layout measurements hold; a new opening starts at the top.
|
|
303
303
|
|
|
304
304
|
`hasHeader={false}` removes the title band and its Close button. The title (and description) still name and describe the dialog, so provide another visible way to close it. `aria-label` or `aria-labelledby` replace the title as the dialog's name, as on Drawer. Modal and Drawer share one dialog hook, so their focus, Escape and Tab behaviour match.
|
|
305
305
|
|
|
@@ -682,7 +682,7 @@ TextField reports only for input types where browsers enforce `maxLength`: `text
|
|
|
682
682
|
|
|
683
683
|
Character counts use JavaScript `.length`, matching native `maxLength` and FormEditor validation; an emoji can occupy two UTF-16 code units. Programmatically loaded values are preserved above the cap: the reading shows the actual count, remaining values can be negative, and the ring stops at full. The text turns warning at 85%, then danger and semibold at the limit. Counter descriptions join the active hint or error and stay out of accessible names. A persistent polite live region announces crossing into 85% and reaching the limit, once each, rather than every keystroke; it announces again only after usage drops back below that threshold. Loaded values are described, not announced. Disabled/read-only counters retain full strength. Motion uses the existing reduced-motion tokens.
|
|
684
684
|
|
|
685
|
-
Limited fields add `.ds-field__header` around the label and counter; limited groups retain a direct legend containing the label and counter, with the badge and required marker centred as in unlimited legends. A consumer's `aria-labelledby` or `aria-label` still names a limited standalone group. Use `.ds-field__label` rather than direct-child label selectors when customizing these fields. Existing unbounded frames keep their markup and styles; only labels beside a counter may break long words. Numeric/date bounds and uncapped
|
|
685
|
+
Limited fields add `.ds-field__header` around the label and counter; limited groups retain a direct legend containing the label and counter, with the badge and required marker centred as in unlimited legends. A consumer's `aria-labelledby` or `aria-label` still names a limited standalone group. Use `.ds-field__label` rather than direct-child label selectors when customizing these fields. Existing unbounded frames keep their markup and styles; only labels beside a counter may break long words. Numeric/date bounds and uncapped multiple pickers do not automatically show usage counters. A picker that holds one item (single mode, or `max={1}`), standalone or in FormEditor, shows a neutral one-item reading, `0/1` or `1/1`, in place of its count badge: filling it is the goal, so it never turns warning or danger and announces nothing. Rich-text limits are deferred.
|
|
686
686
|
|
|
687
687
|
### LimitReading
|
|
688
688
|
|
|
@@ -705,7 +705,7 @@ import { LimitReading } from "@namroodinc/liquid-editorial";
|
|
|
705
705
|
| `md` | 14px | 20px |
|
|
706
706
|
| `lg` | 16px | 24px |
|
|
707
707
|
|
|
708
|
-
`count` and `max` are required. `limitDisplay` defaults to `"used"` (`4/5`); `"remaining"` prints `1 left`. `showLimitRing` defaults to true.
|
|
708
|
+
`count` and `max` are required. `limitDisplay` defaults to `"used"` (`4/5`); `"remaining"` prints `1 left`. `showLimitRing` defaults to true. With the default `tone="usage"`, text becomes warning at 85% and danger at 100%, and the ring keeps the continuous theme colour progression. `tone="neutral"` (type `LimitReadingTone`) is for a slot to fill, such as a single selection: the text stays muted and the ring fills in the success colour. A Field `limit` accepts the same `tone`; a neutral limit is never announced. Counts above the cap stay visible, including negative remaining values, while the ring stays full. Invalid counts or nonpositive/nonfinite maxima render nothing.
|
|
709
709
|
|
|
710
710
|
The visible shorthand and ring are decorative to assistive technology; hidden text reads `4 of 5 used` or `1 remaining`. Pass `descriptionId` to connect that text to a control's `aria-describedby`. Standard span attributes, `id`, `className`, `style` and a span ref are supported. The owning component decides live announcements, visibility and enforcement; LimitReading itself adds no live region.
|
|
711
711
|
|
|
@@ -787,7 +787,7 @@ import { Checkbox, ChoiceGroup, Radio } from "@namroodinc/liquid-editorial";
|
|
|
787
787
|
</>;
|
|
788
788
|
```
|
|
789
789
|
|
|
790
|
-
Radios share a `name` for native exclusivity. Use `checked`/`onChange` for controlled options and native `disabled` for unavailable choices. Checkbox supports `isIndeterminate` for a select-all display. Bind the group to a Field with `isGroup` when it belongs to a larger form.
|
|
790
|
+
Radios share a `name` for native exclusivity. Use `checked`/`onChange` for controlled options and native `disabled` for unavailable choices. Add `isFocusableWhenDisabled` to a `disabled` choice that must stay reachable to explain itself, for example with `aria-describedby`. It is marked `aria-disabled` instead of native `disabled` and keeps the disabled look. As with native `disabled`, presses change nothing and run no click or change handlers (its own or an ancestor's), and it is left out of form submission and validation: it renders without `name` and `required`, so a radio also leaves its group's arrow-key order. Setting `aria-disabled` directly only sets the attribute. Checkbox supports `isIndeterminate` for a select-all display. Bind the group to a Field with `isGroup` when it belongs to a larger form.
|
|
791
791
|
|
|
792
792
|
### SelectionCard
|
|
793
793
|
|
|
@@ -1150,7 +1150,7 @@ ColourField supports normal textbox props, refs, `size`, `readOnly`, `isDisabled
|
|
|
1150
1150
|
|
|
1151
1151
|
### EntryPicker
|
|
1152
1152
|
|
|
1153
|
-
Select entries or assets from app-provided items. The value is an ordered array of IDs in both single and multiple mode. The picker owns search, its selection modal, and optional ordering; the app owns loading and persistence.
|
|
1153
|
+
Select entries or assets from app-provided items. The value is an ordered array of IDs in both single and multiple mode. The picker owns search, its selection modal, and optional ordering; the app owns loading and persistence. Selected items retain their individual borders, fills and draft/removed state styling. The surrounding Field and list have no added surface or padding.
|
|
1154
1154
|
|
|
1155
1155
|
```tsx
|
|
1156
1156
|
import { useState } from "react";
|
|
@@ -1191,7 +1191,11 @@ export function RelatedArticles() {
|
|
|
1191
1191
|
}
|
|
1192
1192
|
```
|
|
1193
1193
|
|
|
1194
|
-
Mode defaults to `"multiple"`; multiple selections are reorderable by default. `max`
|
|
1194
|
+
Mode defaults to `"multiple"`; multiple selections are reorderable by default. A finite `max` refuses unpicked items at the limit; `Infinity` or `NaN` means no limit. Items can have `metadata?: ReactNode`, an image URL, keywords, and `isDisabled`. The app composes the complete inline metadata beneath the title, including badges, type, separators and dates; the library supplies wrapping, spacing and muted small text. Use `size="sm"` for condensed status badges and `Time` for dates. The same metadata renders in results and selected rows. Links and focusable metadata handle clicks without selecting the row. Static search matches only titles and `keywords`; include any searchable metadata labels there.
|
|
1195
|
+
|
|
1196
|
+
Optional item `tone="draft"` highlights selected unpublished rows; `tone="removed"` renders a compact removed selection, with `removedLabel` copy and no pencil or thumbnail. Tones apply only to selected rows; dialog results render in full. Applications confirm removal and own persistence. `disabledReason: { label, description }` explains an `isDisabled` item, in dialog results and in already selected rows, on its own line below the item's metadata. Supply it once there rather than in `metadata`. In selected rows it also describes the row's Move and Remove controls; compact removed rows omit it.
|
|
1197
|
+
|
|
1198
|
+
Results refused by `isDisabled` or a full selection keep a focusable checkbox (`isFocusableWhenDisabled`), so keyboard and screen reader users can find out why: it is described by the item's `disabledReason`, or by a note that the selection is full. A `disabledReason` renders only when `isDisabled` is set. While the whole picker is disabled, or a new search is loading, checkboxes are natively disabled.
|
|
1195
1199
|
|
|
1196
1200
|
`defaultValue` supplies local state; `isDisabled` disables editing. Standalone pickers can supply their own `label`, `hint`, and `error`; a bound group Field owns that frame and displays the selected count. Copy options include `emptyLabel`, `addLabel`, `itemLabel`, and `itemsLabel`.
|
|
1197
1201
|
|
|
@@ -1392,6 +1396,8 @@ With `scrollMode="document"` the window scrolls instead of `main`, the desktop n
|
|
|
1392
1396
|
|
|
1393
1397
|
### EditLayout
|
|
1394
1398
|
|
|
1399
|
+
Embedded editors can set `--edit-viewport-height` (default `100dvh`) and `--edit-sticky-top` (default `--topnav-height`) on their scroll host, on EditLayout itself, or on its action bar or rail alone, for example `--edit-sticky-top: 0px` in a drawer. Action bars and Details rails then fit that host. Document-scrolling editors keep their defaults.
|
|
1400
|
+
|
|
1395
1401
|
A presentation layout for an edit page, composed inside the existing main landmark.
|
|
1396
1402
|
|
|
1397
1403
|
```tsx
|
|
@@ -1786,7 +1792,7 @@ export function ReadingOrder() {
|
|
|
1786
1792
|
|
|
1787
1793
|
Use stable unique IDs in render order. SortableListItem accepts an `action` slot for a Button/Menu. By default the dragged row itself moves, lifted with a shadow, keeping its current input values, focus, actions and styling; nothing is copied. `renderDragOverlay` instead shows inert custom content in a floating preview sized to that content, leaving the row behind as a faded placeholder. Name each item for keyboard drag announcements.
|
|
1788
1794
|
|
|
1789
|
-
Set `isDisabled` on SortableList while saving: the same handles stay visible and focusable, marked `aria-disabled`, and cannot start a drag. A drop after disabling cannot change order. Row content is yours to disable. Set `isDisabled` on an individual SortableListItem to disable only its handle. `onDragStart(id)`, `onDragEnd(id)` and `onDragCancel(id)` report pointer and keyboard drags; use the start callback to collapse details, and rows are measured again when the dragged row changes size. Escape during a drag cancels only the drag; an enclosing Modal or Drawer stays open until the next Escape. The forwarded ref and native list attributes target the `ul`.
|
|
1795
|
+
Set `isDisabled` on SortableList while saving: the same handles stay visible and focusable, marked `aria-disabled`, and cannot start a drag. A drop after disabling cannot change order. Row content is yours to disable. Set `isDisabled` on an individual SortableListItem to disable only its handle. `handleDescribedBy` adds element IDs that describe the handle after its drag instructions, such as why a row is restricted. `onDragStart(id)`, `onDragEnd(id)` and `onDragCancel(id)` report pointer and keyboard drags; use the start callback to collapse details, and rows are measured again when the dragged row changes size. Escape during a drag cancels only the drag; an enclosing Modal or Drawer stays open until the next Escape. The forwarded ref and native list attributes target the `ul`.
|
|
1790
1796
|
|
|
1791
1797
|
### AssetCard
|
|
1792
1798
|
|
package/UPGRADING.md
CHANGED
|
@@ -2,6 +2,148 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.9.0
|
|
6
|
+
|
|
7
|
+
### Breaking changes
|
|
8
|
+
|
|
9
|
+
- EntryPicker results refused by an item's `isDisabled` or by a full selection
|
|
10
|
+
now render a focusable checkbox marked `aria-disabled="true"`. In 0.8.0 it
|
|
11
|
+
was natively `disabled`. Clicks and Space still change nothing and reach no
|
|
12
|
+
click or change handler. Their rows keep `data-blocked="true"`. Tests that
|
|
13
|
+
assert these checkboxes with `toBeDisabled()` must assert
|
|
14
|
+
`toHaveAttribute("aria-disabled", "true")` instead. Checkboxes stay natively
|
|
15
|
+
disabled while the whole picker is disabled or a new search loads.
|
|
16
|
+
- EditLayout no longer declares `--edit-sticky-top` on `.ds-edit-layout`; each
|
|
17
|
+
use reads `var(--edit-sticky-top, var(--topnav-height))`. Overrides keep
|
|
18
|
+
working, and now also work from an ancestor or on the bar or rail alone.
|
|
19
|
+
Consumer CSS inside the layout that read `var(--edit-sticky-top)` without
|
|
20
|
+
setting it must add the `var(--topnav-height)` fallback.
|
|
21
|
+
- A picker that holds one item (single mode, `max={1}`, or a FormEditor single
|
|
22
|
+
`asset`/`reference` field in either runtime mode) now shows a neutral
|
|
23
|
+
one-item reading, `0/1` or `1/1` with a ring, beside its label in place of the
|
|
24
|
+
count badge. In 0.8.0 single pickers showed only the badge, and a multiple
|
|
25
|
+
picker capped at one turned danger at `1/1`. Its group's accessible
|
|
26
|
+
description now ends with `0 of 1 used` or `1 of 1 used`, after any hint or
|
|
27
|
+
error, and its legend no longer contains the count. Update exact
|
|
28
|
+
description, legend-text and `.ds-field__count` assertions for these pickers.
|
|
29
|
+
|
|
30
|
+
### Picker states and scrolling
|
|
31
|
+
|
|
32
|
+
EntryItem adds optional `tone: "draft" | "removed"`, `removedLabel`, and
|
|
33
|
+
`disabledReason: { label, description }`. Tones style selected rows only:
|
|
34
|
+
draft rows keep their full presentation with a warning border, and removed rows
|
|
35
|
+
show their title and metadata (or monospace ID) with a Removed on save tag. They
|
|
36
|
+
keep removal and ordering, but have no thumbnail or pencil. Dialog results
|
|
37
|
+
ignore tone and render in full, pencil included. A `disabledReason` renders
|
|
38
|
+
only when `isDisabled` is set, on its own line below the item's metadata in
|
|
39
|
+
results and in already selected rows. In selected rows it also describes the
|
|
40
|
+
row's Move and Remove controls; compact removed rows omit it. Supply it once
|
|
41
|
+
through `disabledReason` and keep the metadata for the record's own details.
|
|
42
|
+
Applications confirm missing records and own save-time cleanup. Loading
|
|
43
|
+
failures must not be called removed.
|
|
44
|
+
|
|
45
|
+
Refused results are described for assistive technology: by the item's
|
|
46
|
+
`disabledReason`, or, when the selection is full, by a note saying so. Load
|
|
47
|
+
more moves focus to the first new row even when it is refused. A non-finite
|
|
48
|
+
`max` (`Infinity`, `NaN`) means no limit, and the dialog description says so.
|
|
49
|
+
In FormEditor, a non-finite runtime-source `max` leaves the schema's
|
|
50
|
+
`picker.max` in place instead of lifting it.
|
|
51
|
+
|
|
52
|
+
A Modal or Drawer hidden by `isHidden`, or suspended by an ancestor overlay,
|
|
53
|
+
now stays laid out but invisible (`visibility: hidden` on its fixed scrim),
|
|
54
|
+
inert and hidden from assistive technology. In 0.8.0 it was `display: none`,
|
|
55
|
+
which reset every scroll area inside. Scroll positions, horizontal included,
|
|
56
|
+
and layout measurements now survive suspension with no bookkeeping. The
|
|
57
|
+
picker's results keep their position this way. Opening and each new search
|
|
58
|
+
start at the top, other renders never write to the scroll pane, and scrolling
|
|
59
|
+
rerenders only when the pane reaches or leaves the top. The scroll pane uses symmetric logical
|
|
60
|
+
inline padding. The search row and refresh banner reserve the same scrollbar
|
|
61
|
+
gutter, so they line up with the rows in RTL and with classic or overlay
|
|
62
|
+
scrollbars.
|
|
63
|
+
|
|
64
|
+
Picker fields keep their unframed layout. Selected items keep their own
|
|
65
|
+
borders, fills, padding and draft/removed styling, in single and sortable modes.
|
|
66
|
+
The surrounding Field and list add no surface or padding. Search and scroll
|
|
67
|
+
padding belong to the dialog. The capped footer LimitReading stays.
|
|
68
|
+
|
|
69
|
+
### Focusable disabled choices
|
|
70
|
+
|
|
71
|
+
Checkbox and Radio accept `isFocusableWhenDisabled`. With `disabled`, the
|
|
72
|
+
control is marked `aria-disabled` instead of native `disabled`, keeps the
|
|
73
|
+
disabled look and stays focusable. As with native `disabled`, presses change
|
|
74
|
+
nothing (checked and indeterminate states included) and run no click or change
|
|
75
|
+
handler, its own or an ancestor's, and the control is left out of form
|
|
76
|
+
submission and validation: it renders without `name` and `required`, so a
|
|
77
|
+
radio also leaves its group's arrow-key order. Setting `aria-disabled`
|
|
78
|
+
directly only sets the attribute, as in 0.8.0. Native `disabled` is unchanged.
|
|
79
|
+
|
|
80
|
+
### Smaller fixes
|
|
81
|
+
|
|
82
|
+
- LimitReading accepts `tone: "usage" | "neutral"` (type `LimitReadingTone`),
|
|
83
|
+
and a Field `limit` accepts the same `tone`. `neutral` is for a slot to fill:
|
|
84
|
+
muted text, a success-coloured ring, no warning or danger tone, and no Field
|
|
85
|
+
announcements. One-item pickers use it; the existing `limitDisplay`,
|
|
86
|
+
`limitVisibility` and `showLimitRing` options still apply.
|
|
87
|
+
- SortableListItem accepts `handleDescribedBy`, element IDs that describe its
|
|
88
|
+
handle after the drag instructions.
|
|
89
|
+
- SubNavItem and SubNavButton counts now use a small, soft count Badge instead
|
|
90
|
+
of custom count styling. The Badge keeps the `.ds-subnav__count` class, so
|
|
91
|
+
selectors still match; the class no longer carries styles of its own. Zero
|
|
92
|
+
and numbers above 99 still render in full.
|
|
93
|
+
- Standalone FieldGroup-based controls (ChoiceGroup, SelectionCardGroup,
|
|
94
|
+
EntryPicker) now render `labelHint`, which they previously dropped.
|
|
95
|
+
- A new `--badge-sm-pad-block` token (1px) drives small Badge padding, with a
|
|
96
|
+
1px fallback for token sheets that lack it. Picker metadata lines take their
|
|
97
|
+
minimum height from it, and plain-text metadata keeps its normal line height.
|
|
98
|
+
- EditLayout reads `--edit-viewport-height` (default `100dvh`) and
|
|
99
|
+
`--edit-sticky-top` from itself or any ancestor, so an embedding drawer can
|
|
100
|
+
set both on its scroll host.
|
|
101
|
+
- Layout effects in every component use an isomorphic helper, so server
|
|
102
|
+
rendering under React 18 no longer warns that `useLayoutEffect` does nothing.
|
|
103
|
+
|
|
104
|
+
Adoption:
|
|
105
|
+
|
|
106
|
+
- One-item pickers need no schema or prop changes. Remove any custom one-item
|
|
107
|
+
usage indicator, and update assertions as listed under Breaking changes.
|
|
108
|
+
- SubNav count props need no changes. Review overrides of the former
|
|
109
|
+
`.ds-subnav__count` styling, which now apply on top of Badge; prefer shared
|
|
110
|
+
Badge tokens.
|
|
111
|
+
- Remove a restricted item's reason from its `metadata` where it duplicated
|
|
112
|
+
`disabledReason`; selected rows now show the reason themselves.
|
|
113
|
+
- Update tests for refused picker results and EditLayout CSS as listed under
|
|
114
|
+
Breaking changes.
|
|
115
|
+
- Compose CMS metadata from small Badge and Time. Supply tones, removed labels
|
|
116
|
+
and disabled reasons from authorized application data, setting `isDisabled`
|
|
117
|
+
with each reason, and remove equivalent consumer CSS.
|
|
118
|
+
- Replace hand-rolled `aria-disabled` checkbox guards with
|
|
119
|
+
`isFocusableWhenDisabled`.
|
|
120
|
+
- Remove any workaround that showed a standalone group's `labelHint` itself,
|
|
121
|
+
and any consumer code that restored dialog scroll after suspension.
|
|
122
|
+
- For embedded editors, set `--edit-viewport-height` and `--edit-sticky-top` on
|
|
123
|
+
the scroll host, on EditLayout, or on the bar or rail alone.
|
|
124
|
+
|
|
125
|
+
Compatibility: no dependency or stored-value changes. Native `disabled` choices
|
|
126
|
+
and picker checkboxes during loading or a disabled picker behave as before.
|
|
127
|
+
Suspended dialogs keep their `hidden` attribute and are inert, but are no longer
|
|
128
|
+
`display: none`. Content inside keeps its size, so resize observers no longer
|
|
129
|
+
see it collapse. `checkVisibility()` without options reports it visible. Code
|
|
130
|
+
that detected suspension through layout should read the `hidden` or `inert`
|
|
131
|
+
state instead.
|
|
132
|
+
|
|
133
|
+
Verification: run the consuming project's lint, typecheck, tests and build
|
|
134
|
+
against a packed build. Check one-item picker readings and rings on empty,
|
|
135
|
+
selected and cleared fields, standalone and in FormEditor, including runtime
|
|
136
|
+
checkbox mode and existing limit presentation options: `1/1` stays muted, with
|
|
137
|
+
no count badge and no live announcement. Check that an already selected
|
|
138
|
+
restricted item shows its reason once, and that its Move and Remove controls are
|
|
139
|
+
described by it. Review SubNav counts in active, inactive and disabled items
|
|
140
|
+
across themes, including zero and counts above 99. Review keyboard Tab and
|
|
141
|
+
screen reader output on refused results (restricted and full), focus after Load
|
|
142
|
+
more at the cap, missing and draft selections, narrow, dark and RTL layouts,
|
|
143
|
+
scrolling during refresh, selection and paging, and scroll positions (vertical
|
|
144
|
+
and horizontal) after a nested editor suspends a picker, Modal or Drawer.
|
|
145
|
+
Server-render a form under React 18 and confirm no layout-effect warnings.
|
|
146
|
+
|
|
5
147
|
## 0.8.0
|
|
6
148
|
|
|
7
149
|
### Attached number steppers and collection view buttons
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Button as e } from "../components/Button/index.js";
|
|
2
2
|
import { t } from "./mergeRefs-C6_5pADN.js";
|
|
3
3
|
import { i as n } from "./colour-CYEF4Q_n.js";
|
|
4
|
-
import { t as r } from "./useTooltip-
|
|
4
|
+
import { t as r } from "./useTooltip-BrC7FdeH.js";
|
|
5
5
|
import { forwardRef as i, useMemo as a } from "react";
|
|
6
6
|
import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
7
7
|
import { extend as l } from "colord";
|
|
@@ -146,4 +146,4 @@ var b = i(function({ people: e, size: t = 24, className: n, ...r }, i) {
|
|
|
146
146
|
//#endregion
|
|
147
147
|
export { b as n, v as t };
|
|
148
148
|
|
|
149
|
-
//# sourceMappingURL=Avatar-
|
|
149
|
+
//# sourceMappingURL=Avatar-BK8IdL5W.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Avatar-6t78C9Np.js","names":["_Fragment","parseColour","useTooltip","Fragment$1","a11yPlugin","extend","avatarColours","background","value","buttonSizes","initialsOf","words","name","splitAria","aria","other","key","props","defaultTabIndex","isActionable","isHidden","hasTooltip","AvatarContent","src","AvatarControl","href","semantics","hasCallback","Button","size","Avatar","forwardRef","label","describedBy","hidden","onClick","tooltip","spanRef","useMemo","mergeRefs","anchorRef","ref","colours","colour","description","tabIndex","className","style","triggerProps","panel","OverflowCount","names","count","AvatarGroup","rest","people","p","index","person"],"sources":["../../src/components/Avatar/colour.ts","../../src/components/Avatar/index.tsx"],"sourcesContent":["import { extend } from \"colord\";\nimport a11yPlugin from \"colord/plugins/a11y\";\nimport { parseColour } from \"../ColourField/colour\";\n\nextend([a11yPlugin]);\n\n/** Opaque colours only: transparency would make contrast depend on the surface below. */\nexport function avatarColours(value?: string) {\n // Share ColourField's parser so both components accept and classify colours identically.\n const background = value ? parseColour(value) : null;\n if (!background || background.alpha() !== 1) {\n return undefined;\n }\n return {\n \"--avatar-background\": background.toHex(),\n \"--avatar-foreground\":\n background.contrast(\"#000\") >= background.contrast(\"#fff\") ? \"#000000\" : \"#ffffff\",\n };\n}\n","import {\n forwardRef,\n useMemo,\n type AnchorHTMLAttributes,\n type AriaAttributes,\n type HTMLAttributes,\n type ReactNode,\n} from \"react\";\nimport { mergeRefs } from \"../../internal/mergeRefs\";\nimport { Button, type ButtonSize } from \"../Button\";\nimport { useTooltip } from \"../Popover/useTooltip\";\nimport { avatarColours } from \"./colour\";\nimport \"./style.css\";\n\nexport type AvatarSize = 24 | 32 | 40;\n\n/** Each avatar size is one of Button's square sizes, so callback avatars use Button unchanged. */\nconst buttonSizes: Record<AvatarSize, ButtonSize> = { 24: \"xs\", 32: \"sm\", 40: \"md\" };\n\nexport interface AvatarProps extends HTMLAttributes<HTMLSpanElement> {\n /** Required — drives the initials and the accessible name. */\n name: string;\n src?: string;\n size?: AvatarSize;\n /** Solid hex, RGB, HSL or named background; initials automatically use contrasting black/white. */\n colour?: string;\n /** Defaults to name; false disables the hover/focus tooltip. */\n tooltip?: string | false;\n href?: string;\n target?: AnchorHTMLAttributes<HTMLAnchorElement>[\"target\"];\n rel?: string;\n}\n\nfunction initialsOf(name: string) {\n const words = name.trim().split(/\\s+/);\n const first = words[0]?.[0] ?? \"\";\n const last = words.length > 1 ? words[words.length - 1][0] : \"\";\n return (first + last).toUpperCase();\n}\n\n/** Separate ARIA attributes so they can follow the element that carries the role. */\nfunction splitAria<T extends object>(props: T) {\n const aria: Record<string, unknown> = {};\n const other: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(props)) {\n (key.startsWith(\"aria-\") ? aria : other)[key] = value;\n }\n return { aria: aria as AriaAttributes, other: other as Omit<T, keyof AriaAttributes> };\n}\n\n/**\n * Links and Buttons are natively focusable, and hidden ones leave the tab order.\n * A passive avatar is focusable only for a visible tooltip.\n */\nfunction defaultTabIndex(isActionable: boolean, isHidden: boolean, hasTooltip: boolean) {\n if (isActionable) {\n return isHidden ? -1 : undefined;\n }\n return !isHidden && hasTooltip ? 0 : undefined;\n}\n\nfunction AvatarContent({ name, src }: Pick<AvatarProps, \"name\" | \"src\">) {\n return (\n <span className=\"ds-avatar__content\">\n {src ? (\n <img\n src={src}\n alt=\"\"\n />\n ) : (\n initialsOf(name)\n )}\n </span>\n );\n}\n\ninterface AvatarControlProps extends Pick<AvatarProps, \"href\" | \"target\" | \"rel\"> {\n hasCallback: boolean;\n size: AvatarSize;\n /** Naming, description, id, ARIA state and tab order for the control. */\n semantics: HTMLAttributes<HTMLElement>;\n children: ReactNode;\n}\n\n/** The inner link or shared Button of an actionable avatar; passive content otherwise. */\nfunction AvatarControl({\n href,\n target,\n rel,\n hasCallback,\n size,\n semantics,\n children,\n}: AvatarControlProps) {\n if (href) {\n return (\n <a\n className=\"ds-avatar__control\"\n href={href}\n target={target}\n rel={rel}\n {...semantics}\n >\n {children}\n </a>\n );\n }\n if (hasCallback) {\n return (\n <Button\n variant=\"simple\"\n size={buttonSizes[size]}\n isIconOnly\n className=\"ds-avatar__control\"\n {...semantics}\n >\n {children}\n </Button>\n );\n }\n return <>{children}</>;\n}\n\n/**\n * A circular person identifier, optionally linked or actionable. The ref stays on\n * the outer span; `id` and ARIA attributes go to the image span, or to the inner\n * link or Button when the avatar is actionable.\n */\nexport const Avatar = forwardRef<HTMLSpanElement, AvatarProps>(function Avatar(\n {\n name,\n src,\n colour,\n style,\n size = 24,\n tooltip = name,\n href,\n target,\n rel,\n className,\n onClick,\n onMouseEnter,\n onMouseLeave,\n onFocus,\n onBlur,\n id,\n tabIndex,\n \"aria-label\": label = name,\n \"aria-describedby\": describedBy,\n \"aria-hidden\": hidden,\n ...props\n },\n ref,\n) {\n const isHidden = hidden === true || hidden === \"true\";\n const isActionable = !!href || !!onClick;\n const { anchorRef, description, triggerProps, panel } = useTooltip<HTMLSpanElement>(\n isHidden ? false : tooltip,\n { placement: \"top\", className: \"ds-avatar-tooltip\" },\n );\n // Stable across renders, so tooltip state changes never detach a caller's callback ref.\n const spanRef = useMemo(() => mergeRefs(anchorRef, ref), [anchorRef, ref]);\n const colours = useMemo(() => avatarColours(colour), [colour]);\n const { aria, other } = splitAria(props);\n const semantics = {\n ...aria,\n id,\n \"aria-label\": label,\n \"aria-describedby\": [describedBy, description].filter(Boolean).join(\" \") || undefined,\n tabIndex: tabIndex ?? defaultTabIndex(isActionable, isHidden, !!tooltip),\n };\n return (\n <>\n <span\n ref={spanRef}\n role={isActionable ? undefined : \"img\"}\n aria-hidden={hidden}\n {...(isActionable ? {} : semantics)}\n data-size={size}\n className={[\"ds-avatar\", className].filter(Boolean).join(\" \")}\n {...other}\n style={{ ...style, ...colours }}\n onClick={onClick}\n {...triggerProps({ onMouseEnter, onMouseLeave, onFocus, onBlur })}\n >\n <AvatarControl\n href={href}\n target={target}\n rel={rel}\n hasCallback={!!onClick}\n size={size}\n semantics={semantics}\n >\n <AvatarContent\n name={name}\n src={src}\n />\n </AvatarControl>\n </span>\n {panel}\n </>\n );\n});\n\ntype AvatarPerson = Pick<\n AvatarProps,\n \"name\" | \"src\" | \"colour\" | \"tooltip\" | \"href\" | \"target\" | \"rel\" | \"onClick\"\n>;\n\nexport interface AvatarGroupProps extends HTMLAttributes<HTMLSpanElement> {\n /** Up to three render; the rest become a +n count with a hidden-name tooltip. */\n people: AvatarPerson[];\n size?: AvatarSize;\n}\n\nfunction OverflowCount({ names }: { names: string[] }) {\n const { anchorRef, description, triggerProps, panel } = useTooltip<HTMLSpanElement>(\n names.join(\", \"),\n { placement: \"top\", className: \"ds-avatar-tooltip\" },\n );\n const count = names.length;\n return (\n <>\n <span\n ref={anchorRef}\n role=\"img\"\n className=\"ds-avatar-group__count\"\n tabIndex={0}\n aria-label={`${count} more ${count === 1 ? \"person\" : \"people\"}`}\n aria-describedby={description}\n {...triggerProps()}\n >\n +{count}\n </span>\n {panel}\n </>\n );\n}\n\n/** Overlapping stack of at most three avatars, then a +n chip. */\nexport const AvatarGroup = forwardRef<HTMLSpanElement, AvatarGroupProps>(function AvatarGroup(\n { people, size = 24, className, ...rest },\n ref,\n) {\n return (\n <span\n ref={ref}\n role=\"group\"\n aria-label={people.map((p) => p.name).join(\", \")}\n className={[\"ds-avatar-group\", className].filter(Boolean).join(\" \")}\n {...rest}\n >\n {/* Only documented person fields reach Avatar; extra application data stays off the DOM. */}\n {people\n .slice(0, 3)\n .map(({ name, src, colour, tooltip, href, target, rel, onClick }, index) => (\n <Avatar\n key={`${name}-${index}`}\n name={name}\n src={src}\n colour={colour}\n tooltip={tooltip}\n href={href}\n target={target}\n rel={rel}\n onClick={onClick}\n size={size}\n />\n ))}\n {people.length > 3 && <OverflowCount names={people.slice(3).map((person) => person.name)} />}\n </span>\n );\n});\n"],"mappings":";;;;;;;;;AAIAK,EAAO,CAACD,CAAU,CAAC;AAGnB,SAAgBE,EAAc,GAAgB;CAE5C,IAAMC,IAAaC,IAAQP,EAAYO,CAAK,IAAI;CAChD,IAAKD,KAAcA,EAAW,MAAM,MAAM,GAG1C,OAAO;EACL,uBAAuBA,EAAW,MAAM;EACxC,uBACEA,EAAW,SAAS,MAAM,KAAKA,EAAW,SAAS,MAAM,IAAI,YAAY;CAC7E;AACF;;;ACDA,IAAME,IAA8C;CAAE,IAAI;CAAM,IAAI;CAAM,IAAI;AAAK;AAgBnF,SAASC,EAAW,GAAc;CAChC,IAAMC,IAAQC,EAAK,KAAK,CAAC,CAAC,MAAM,KAAK;CAGrC,SAFcD,EAAM,EAAE,GAAG,MAAM,OAClBA,EAAM,SAAS,IAAIA,EAAMA,EAAM,SAAS,EAAE,CAAC,KAAK,IAAA,CACvC,YAAY;AACpC;AAGA,SAASE,EAA4B,GAAU;CAC7C,IAAMC,IAAgC,CAAC,GACjCC,IAAiC,CAAC;CACxC,KAAK,IAAM,CAACC,GAAKR,MAAU,OAAO,QAAQS,CAAK,GAC7C,CAACD,EAAI,WAAW,OAAO,IAAIF,IAAOC,EAAA,CAAOC,KAAOR;CAElD,OAAO;EAAQ;EAA+B;CAAuC;AACvF;AAMA,SAASU,EAAgB,GAAuB,GAAmB,GAAqB;CAItF,OAHIC,IACKC,IAAW,KAAK,KAAA,IAElB,CAACA,KAAYC,IAAa,IAAI,KAAA;AACvC;AAEA,SAASC,EAAc,EAAE,SAAM,UAA0C;CACvE,OACE,kBAAC,QAAD;EAAM,WAAU;EACb,UAAAC,IACC,kBAAC,OAAD;GACO;GACL,KAAI;EACL,CAAA,IAEDb,EAAWE,CAAI;CAEb,CAAA;AA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AAD;GAEQ;GACD;GACG;GACC;GACH;GACE;GACH;GACI;GACH;EACP,GAVM,GAAGlB,EAAK,GAAG6C,GAUjB,CACF,GACFF,EAAO,SAAS,KAAK,kBAACL,GAAD,EAAe,OAAOK,EAAO,MAAM,CAAC,CAAC,CAAC,KAAK,MAAWG,EAAO,IAAI,EAAI,CAAA,CACvF;;AAEV,CAAC"}
|
|
1
|
+
{"version":3,"file":"Avatar-BK8IdL5W.js","names":["_Fragment","parseColour","useTooltip","Fragment$1","a11yPlugin","extend","avatarColours","background","value","buttonSizes","initialsOf","words","name","splitAria","aria","other","key","props","defaultTabIndex","isActionable","isHidden","hasTooltip","AvatarContent","src","AvatarControl","href","semantics","hasCallback","Button","size","Avatar","forwardRef","label","describedBy","hidden","onClick","tooltip","spanRef","useMemo","mergeRefs","anchorRef","ref","colours","colour","description","tabIndex","className","style","triggerProps","panel","OverflowCount","names","count","AvatarGroup","rest","people","p","index","person"],"sources":["../../src/components/Avatar/colour.ts","../../src/components/Avatar/index.tsx"],"sourcesContent":["import { extend } from \"colord\";\nimport a11yPlugin from \"colord/plugins/a11y\";\nimport { parseColour } from \"../ColourField/colour\";\n\nextend([a11yPlugin]);\n\n/** Opaque colours only: transparency would make contrast depend on the surface below. */\nexport function avatarColours(value?: string) {\n // Share ColourField's parser so both components accept and classify colours identically.\n const background = value ? parseColour(value) : null;\n if (!background || background.alpha() !== 1) {\n return undefined;\n }\n return {\n \"--avatar-background\": background.toHex(),\n \"--avatar-foreground\":\n background.contrast(\"#000\") >= background.contrast(\"#fff\") ? \"#000000\" : \"#ffffff\",\n };\n}\n","import {\n forwardRef,\n useMemo,\n type AnchorHTMLAttributes,\n type AriaAttributes,\n type HTMLAttributes,\n type ReactNode,\n} from \"react\";\nimport { mergeRefs } from \"../../internal/mergeRefs\";\nimport { Button, type ButtonSize } from \"../Button\";\nimport { useTooltip } from \"../Popover/useTooltip\";\nimport { avatarColours } from \"./colour\";\nimport \"./style.css\";\n\nexport type AvatarSize = 24 | 32 | 40;\n\n/** Each avatar size is one of Button's square sizes, so callback avatars use Button unchanged. */\nconst buttonSizes: Record<AvatarSize, ButtonSize> = { 24: \"xs\", 32: \"sm\", 40: \"md\" };\n\nexport interface AvatarProps extends HTMLAttributes<HTMLSpanElement> {\n /** Required — drives the initials and the accessible name. */\n name: string;\n src?: string;\n size?: AvatarSize;\n /** Solid hex, RGB, HSL or named background; initials automatically use contrasting black/white. */\n colour?: string;\n /** Defaults to name; false disables the hover/focus tooltip. */\n tooltip?: string | false;\n href?: string;\n target?: AnchorHTMLAttributes<HTMLAnchorElement>[\"target\"];\n rel?: string;\n}\n\nfunction initialsOf(name: string) {\n const words = name.trim().split(/\\s+/);\n const first = words[0]?.[0] ?? \"\";\n const last = words.length > 1 ? words[words.length - 1][0] : \"\";\n return (first + last).toUpperCase();\n}\n\n/** Separate ARIA attributes so they can follow the element that carries the role. */\nfunction splitAria<T extends object>(props: T) {\n const aria: Record<string, unknown> = {};\n const other: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(props)) {\n (key.startsWith(\"aria-\") ? aria : other)[key] = value;\n }\n return { aria: aria as AriaAttributes, other: other as Omit<T, keyof AriaAttributes> };\n}\n\n/**\n * Links and Buttons are natively focusable, and hidden ones leave the tab order.\n * A passive avatar is focusable only for a visible tooltip.\n */\nfunction defaultTabIndex(isActionable: boolean, isHidden: boolean, hasTooltip: boolean) {\n if (isActionable) {\n return isHidden ? -1 : undefined;\n }\n return !isHidden && hasTooltip ? 0 : undefined;\n}\n\nfunction AvatarContent({ name, src }: Pick<AvatarProps, \"name\" | \"src\">) {\n return (\n <span className=\"ds-avatar__content\">\n {src ? (\n <img\n src={src}\n alt=\"\"\n />\n ) : (\n initialsOf(name)\n )}\n </span>\n );\n}\n\ninterface AvatarControlProps extends Pick<AvatarProps, \"href\" | \"target\" | \"rel\"> {\n hasCallback: boolean;\n size: AvatarSize;\n /** Naming, description, id, ARIA state and tab order for the control. */\n semantics: HTMLAttributes<HTMLElement>;\n children: ReactNode;\n}\n\n/** The inner link or shared Button of an actionable avatar; passive content otherwise. */\nfunction AvatarControl({\n href,\n target,\n rel,\n hasCallback,\n size,\n semantics,\n children,\n}: AvatarControlProps) {\n if (href) {\n return (\n <a\n className=\"ds-avatar__control\"\n href={href}\n target={target}\n rel={rel}\n {...semantics}\n >\n {children}\n </a>\n );\n }\n if (hasCallback) {\n return (\n <Button\n variant=\"simple\"\n size={buttonSizes[size]}\n isIconOnly\n className=\"ds-avatar__control\"\n {...semantics}\n >\n {children}\n </Button>\n );\n }\n return <>{children}</>;\n}\n\n/**\n * A circular person identifier, optionally linked or actionable. The ref stays on\n * the outer span; `id` and ARIA attributes go to the image span, or to the inner\n * link or Button when the avatar is actionable.\n */\nexport const Avatar = forwardRef<HTMLSpanElement, AvatarProps>(function Avatar(\n {\n name,\n src,\n colour,\n style,\n size = 24,\n tooltip = name,\n href,\n target,\n rel,\n className,\n onClick,\n onMouseEnter,\n onMouseLeave,\n onFocus,\n onBlur,\n id,\n tabIndex,\n \"aria-label\": label = name,\n \"aria-describedby\": describedBy,\n \"aria-hidden\": hidden,\n ...props\n },\n ref,\n) {\n const isHidden = hidden === true || hidden === \"true\";\n const isActionable = !!href || !!onClick;\n const { anchorRef, description, triggerProps, panel } = useTooltip<HTMLSpanElement>(\n isHidden ? false : tooltip,\n { placement: \"top\", className: \"ds-avatar-tooltip\" },\n );\n // Stable across renders, so tooltip state changes never detach a caller's callback ref.\n const spanRef = useMemo(() => mergeRefs(anchorRef, ref), [anchorRef, ref]);\n const colours = useMemo(() => avatarColours(colour), [colour]);\n const { aria, other } = splitAria(props);\n const semantics = {\n ...aria,\n id,\n \"aria-label\": label,\n \"aria-describedby\": [describedBy, description].filter(Boolean).join(\" \") || undefined,\n tabIndex: tabIndex ?? defaultTabIndex(isActionable, isHidden, !!tooltip),\n };\n return (\n <>\n <span\n ref={spanRef}\n role={isActionable ? undefined : \"img\"}\n aria-hidden={hidden}\n {...(isActionable ? {} : semantics)}\n data-size={size}\n className={[\"ds-avatar\", className].filter(Boolean).join(\" \")}\n {...other}\n style={{ ...style, ...colours }}\n onClick={onClick}\n {...triggerProps({ onMouseEnter, onMouseLeave, onFocus, onBlur })}\n >\n <AvatarControl\n href={href}\n target={target}\n rel={rel}\n hasCallback={!!onClick}\n size={size}\n semantics={semantics}\n >\n <AvatarContent\n name={name}\n src={src}\n />\n </AvatarControl>\n </span>\n {panel}\n </>\n );\n});\n\ntype AvatarPerson = Pick<\n AvatarProps,\n \"name\" | \"src\" | \"colour\" | \"tooltip\" | \"href\" | \"target\" | \"rel\" | \"onClick\"\n>;\n\nexport interface AvatarGroupProps extends HTMLAttributes<HTMLSpanElement> {\n /** Up to three render; the rest become a +n count with a hidden-name tooltip. */\n people: AvatarPerson[];\n size?: AvatarSize;\n}\n\nfunction OverflowCount({ names }: { names: string[] }) {\n const { anchorRef, description, triggerProps, panel } = useTooltip<HTMLSpanElement>(\n names.join(\", \"),\n { placement: \"top\", className: \"ds-avatar-tooltip\" },\n );\n const count = names.length;\n return (\n <>\n <span\n ref={anchorRef}\n role=\"img\"\n className=\"ds-avatar-group__count\"\n tabIndex={0}\n aria-label={`${count} more ${count === 1 ? \"person\" : \"people\"}`}\n aria-describedby={description}\n {...triggerProps()}\n >\n +{count}\n </span>\n {panel}\n </>\n );\n}\n\n/** Overlapping stack of at most three avatars, then a +n chip. */\nexport const AvatarGroup = forwardRef<HTMLSpanElement, AvatarGroupProps>(function AvatarGroup(\n { people, size = 24, className, ...rest },\n ref,\n) {\n return (\n <span\n ref={ref}\n role=\"group\"\n aria-label={people.map((p) => p.name).join(\", \")}\n className={[\"ds-avatar-group\", className].filter(Boolean).join(\" \")}\n {...rest}\n >\n {/* Only documented person fields reach Avatar; extra application data stays off the DOM. */}\n {people\n .slice(0, 3)\n .map(({ name, src, colour, tooltip, href, target, rel, onClick }, index) => (\n <Avatar\n key={`${name}-${index}`}\n name={name}\n src={src}\n colour={colour}\n tooltip={tooltip}\n href={href}\n target={target}\n rel={rel}\n onClick={onClick}\n size={size}\n />\n ))}\n {people.length > 3 && <OverflowCount names={people.slice(3).map((person) => person.name)} />}\n </span>\n );\n});\n"],"mappings":";;;;;;;;;AAIAK,EAAO,CAACD,CAAU,CAAC;AAGnB,SAAgBE,EAAc,GAAgB;CAE5C,IAAMC,IAAaC,IAAQP,EAAYO,CAAK,IAAI;CAChD,IAAKD,KAAcA,EAAW,MAAM,MAAM,GAG1C,OAAO;EACL,uBAAuBA,EAAW,MAAM;EACxC,uBACEA,EAAW,SAAS,MAAM,KAAKA,EAAW,SAAS,MAAM,IAAI,YAAY;CAC7E;AACF;;;ACDA,IAAME,IAA8C;CAAE,IAAI;CAAM,IAAI;CAAM,IAAI;AAAK;AAgBnF,SAASC,EAAW,GAAc;CAChC,IAAMC,IAAQC,EAAK,KAAK,CAAC,CAAC,MAAM,KAAK;CAGrC,SAFcD,EAAM,EAAE,GAAG,MAAM,OAClBA,EAAM,SAAS,IAAIA,EAAMA,EAAM,SAAS,EAAE,CAAC,KAAK,IAAA,CACvC,YAAY;AACpC;AAGA,SAASE,EAA4B,GAAU;CAC7C,IAAMC,IAAgC,CAAC,GACjCC,IAAiC,CAAC;CACxC,KAAK,IAAM,CAACC,GAAKR,MAAU,OAAO,QAAQS,CAAK,GAC7C,CAACD,EAAI,WAAW,OAAO,IAAIF,IAAOC,EAAA,CAAOC,KAAOR;CAElD,OAAO;EAAQ;EAA+B;CAAuC;AACvF;AAMA,SAASU,EAAgB,GAAuB,GAAmB,GAAqB;CAItF,OAHIC,IACKC,IAAW,KAAK,KAAA,IAElB,CAACA,KAAYC,IAAa,IAAI,KAAA;AACvC;AAEA,SAASC,EAAc,EAAE,SAAM,UAA0C;CACvE,OACE,kBAAC,QAAD;EAAM,WAAU;EACb,UAAAC,IACC,kBAAC,OAAD;GACO;GACL,KAAI;EACL,CAAA,IAEDb,EAAWE,CAAI;CAEb,CAAA;AAEV;AAWA,SAASY,EAAc,EACrB,SACA,WACA,QACA,gBACA,SACA,cACA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AVM,GAAGlB,EAAK,GAAG6C,GAUjB,CACF,GACFF,EAAO,SAAS,KAAK,kBAACL,GAAD,EAAe,OAAOK,EAAO,MAAM,CAAC,CAAC,CAAC,KAAK,MAAWG,EAAO,IAAI,EAAI,CAAA,CACvF;;AAEV,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./colour-BmtxDlWF.cjs"),t=require("../components/Button/index.cjs"),n=require("./mergeRefs-CZ-SArlE.cjs"),r=require("./useTooltip-
|
|
2
|
-
//# sourceMappingURL=Avatar-
|
|
1
|
+
const e=require("./colour-BmtxDlWF.cjs"),t=require("../components/Button/index.cjs"),n=require("./mergeRefs-CZ-SArlE.cjs"),r=require("./useTooltip-BXAvQwt4.cjs");let i=require("react"),a=require("react/jsx-runtime"),o=require("colord"),s=require("colord/plugins/a11y");s=e.a(s,1),(0,o.extend)([s.default]);function c(t){let n=t?e.i(t):null;if(n&&n.alpha()===1)return{"--avatar-background":n.toHex(),"--avatar-foreground":n.contrast(`#000`)>=n.contrast(`#fff`)?`#000000`:`#ffffff`}}var l={24:`xs`,32:`sm`,40:`md`};function u(e){let t=e.trim().split(/\s+/);return((t[0]?.[0]??``)+(t.length>1?t[t.length-1][0]:``)).toUpperCase()}function d(e){let t={},n={};for(let[r,i]of Object.entries(e))(r.startsWith(`aria-`)?t:n)[r]=i;return{aria:t,other:n}}function f(e,t,n){return e?t?-1:void 0:!t&&n?0:void 0}function p({name:e,src:t}){return(0,a.jsx)(`span`,{className:`ds-avatar__content`,children:t?(0,a.jsx)(`img`,{src:t,alt:``}):u(e)})}function m({href:e,target:n,rel:r,hasCallback:i,size:o,semantics:s,children:c}){return e?(0,a.jsx)(`a`,{className:`ds-avatar__control`,href:e,target:n,rel:r,...s,children:c}):i?(0,a.jsx)(t.Button,{variant:`simple`,size:l[o],isIconOnly:!0,className:`ds-avatar__control`,...s,children:c}):(0,a.jsx)(a.Fragment,{children:c})}var h=(0,i.forwardRef)(function({name:e,src:t,colour:o,style:s,size:l=24,tooltip:u=e,href:h,target:g,rel:_,className:v,onClick:y,onMouseEnter:b,onMouseLeave:x,onFocus:S,onBlur:C,id:w,tabIndex:T,"aria-label":E=e,"aria-describedby":D,"aria-hidden":O,...k},A){let j=O===!0||O===`true`,M=!!h||!!y,{anchorRef:N,description:P,triggerProps:F,panel:I}=r.t(!j&&u,{placement:`top`,className:`ds-avatar-tooltip`}),L=(0,i.useMemo)(()=>n.t(N,A),[N,A]),R=(0,i.useMemo)(()=>c(o),[o]),{aria:z,other:B}=d(k),V={...z,id:w,"aria-label":E,"aria-describedby":[D,P].filter(Boolean).join(` `)||void 0,tabIndex:T??f(M,j,!!u)};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(`span`,{ref:L,role:M?void 0:`img`,"aria-hidden":O,...M?{}:V,"data-size":l,className:[`ds-avatar`,v].filter(Boolean).join(` `),...B,style:{...s,...R},onClick:y,...F({onMouseEnter:b,onMouseLeave:x,onFocus:S,onBlur:C}),children:(0,a.jsx)(m,{href:h,target:g,rel:_,hasCallback:!!y,size:l,semantics:V,children:(0,a.jsx)(p,{name:e,src:t})})}),I]})});function g({names:e}){let{anchorRef:t,description:n,triggerProps:i,panel:o}=r.t(e.join(`, `),{placement:`top`,className:`ds-avatar-tooltip`}),s=e.length;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(`span`,{ref:t,role:`img`,className:`ds-avatar-group__count`,tabIndex:0,"aria-label":`${s} more ${s===1?`person`:`people`}`,"aria-describedby":n,...i(),children:[`+`,s]}),o]})}var _=(0,i.forwardRef)(function({people:e,size:t=24,className:n,...r},i){return(0,a.jsxs)(`span`,{ref:i,role:`group`,"aria-label":e.map(e=>e.name).join(`, `),className:[`ds-avatar-group`,n].filter(Boolean).join(` `),...r,children:[e.slice(0,3).map(({name:e,src:n,colour:r,tooltip:i,href:o,target:s,rel:c,onClick:l},u)=>(0,a.jsx)(h,{name:e,src:n,colour:r,tooltip:i,href:o,target:s,rel:c,onClick:l,size:t},`${e}-${u}`)),e.length>3&&(0,a.jsx)(g,{names:e.slice(3).map(e=>e.name)})]})});Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return h}});
|
|
2
|
+
//# sourceMappingURL=Avatar-DPnrvkwd.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Avatar-Cvj_DqG0.cjs","names":["extend","a11yPlugin","parseColour","Button","_Fragment","forwardRef","useTooltip","useMemo","mergeRefs","require_colour","require_components_Button_index","require_mergeRefs","require_useTooltip","react","react_jsx_runtime","colord","colord_plugins_a11y","avatarColours","background","value","buttonSizes","initialsOf","words","name","splitAria","aria","other","key","props","defaultTabIndex","isActionable","isHidden","hasTooltip","AvatarContent","src","AvatarControl","href","semantics","hasCallback","size","Avatar","label","describedBy","hidden","onClick","tooltip","spanRef","anchorRef","ref","colours","colour","description","tabIndex","className","style","triggerProps","panel","OverflowCount","names","count","AvatarGroup","rest","people","p","index","person"],"sources":["../../src/components/Avatar/colour.ts","../../src/components/Avatar/index.tsx"],"sourcesContent":["import { extend } from \"colord\";\nimport a11yPlugin from \"colord/plugins/a11y\";\nimport { parseColour } from \"../ColourField/colour\";\n\nextend([a11yPlugin]);\n\n/** Opaque colours only: transparency would make contrast depend on the surface below. */\nexport function avatarColours(value?: string) {\n // Share ColourField's parser so both components accept and classify colours identically.\n const background = value ? parseColour(value) : null;\n if (!background || background.alpha() !== 1) {\n return undefined;\n }\n return {\n \"--avatar-background\": background.toHex(),\n \"--avatar-foreground\":\n background.contrast(\"#000\") >= background.contrast(\"#fff\") ? \"#000000\" : \"#ffffff\",\n };\n}\n","import {\n forwardRef,\n useMemo,\n type AnchorHTMLAttributes,\n type AriaAttributes,\n type HTMLAttributes,\n type ReactNode,\n} from \"react\";\nimport { mergeRefs } from \"../../internal/mergeRefs\";\nimport { Button, type ButtonSize } from \"../Button\";\nimport { useTooltip } from \"../Popover/useTooltip\";\nimport { avatarColours } from \"./colour\";\nimport \"./style.css\";\n\nexport type AvatarSize = 24 | 32 | 40;\n\n/** Each avatar size is one of Button's square sizes, so callback avatars use Button unchanged. */\nconst buttonSizes: Record<AvatarSize, ButtonSize> = { 24: \"xs\", 32: \"sm\", 40: \"md\" };\n\nexport interface AvatarProps extends HTMLAttributes<HTMLSpanElement> {\n /** Required — drives the initials and the accessible name. */\n name: string;\n src?: string;\n size?: AvatarSize;\n /** Solid hex, RGB, HSL or named background; initials automatically use contrasting black/white. */\n colour?: string;\n /** Defaults to name; false disables the hover/focus tooltip. */\n tooltip?: string | false;\n href?: string;\n target?: AnchorHTMLAttributes<HTMLAnchorElement>[\"target\"];\n rel?: string;\n}\n\nfunction initialsOf(name: string) {\n const words = name.trim().split(/\\s+/);\n const first = words[0]?.[0] ?? \"\";\n const last = words.length > 1 ? words[words.length - 1][0] : \"\";\n return (first + last).toUpperCase();\n}\n\n/** Separate ARIA attributes so they can follow the element that carries the role. */\nfunction splitAria<T extends object>(props: T) {\n const aria: Record<string, unknown> = {};\n const other: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(props)) {\n (key.startsWith(\"aria-\") ? aria : other)[key] = value;\n }\n return { aria: aria as AriaAttributes, other: other as Omit<T, keyof AriaAttributes> };\n}\n\n/**\n * Links and Buttons are natively focusable, and hidden ones leave the tab order.\n * A passive avatar is focusable only for a visible tooltip.\n */\nfunction defaultTabIndex(isActionable: boolean, isHidden: boolean, hasTooltip: boolean) {\n if (isActionable) {\n return isHidden ? -1 : undefined;\n }\n return !isHidden && hasTooltip ? 0 : undefined;\n}\n\nfunction AvatarContent({ name, src }: Pick<AvatarProps, \"name\" | \"src\">) {\n return (\n <span className=\"ds-avatar__content\">\n {src ? (\n <img\n src={src}\n alt=\"\"\n />\n ) : (\n initialsOf(name)\n )}\n </span>\n );\n}\n\ninterface AvatarControlProps extends Pick<AvatarProps, \"href\" | \"target\" | \"rel\"> {\n hasCallback: boolean;\n size: AvatarSize;\n /** Naming, description, id, ARIA state and tab order for the control. */\n semantics: HTMLAttributes<HTMLElement>;\n children: ReactNode;\n}\n\n/** The inner link or shared Button of an actionable avatar; passive content otherwise. */\nfunction AvatarControl({\n href,\n target,\n rel,\n hasCallback,\n size,\n semantics,\n children,\n}: AvatarControlProps) {\n if (href) {\n return (\n <a\n className=\"ds-avatar__control\"\n href={href}\n target={target}\n rel={rel}\n {...semantics}\n >\n {children}\n </a>\n );\n }\n if (hasCallback) {\n return (\n <Button\n variant=\"simple\"\n size={buttonSizes[size]}\n isIconOnly\n className=\"ds-avatar__control\"\n {...semantics}\n >\n {children}\n </Button>\n );\n }\n return <>{children}</>;\n}\n\n/**\n * A circular person identifier, optionally linked or actionable. The ref stays on\n * the outer span; `id` and ARIA attributes go to the image span, or to the inner\n * link or Button when the avatar is actionable.\n */\nexport const Avatar = forwardRef<HTMLSpanElement, AvatarProps>(function Avatar(\n {\n name,\n src,\n colour,\n style,\n size = 24,\n tooltip = name,\n href,\n target,\n rel,\n className,\n onClick,\n onMouseEnter,\n onMouseLeave,\n onFocus,\n onBlur,\n id,\n tabIndex,\n \"aria-label\": label = name,\n \"aria-describedby\": describedBy,\n \"aria-hidden\": hidden,\n ...props\n },\n ref,\n) {\n const isHidden = hidden === true || hidden === \"true\";\n const isActionable = !!href || !!onClick;\n const { anchorRef, description, triggerProps, panel } = useTooltip<HTMLSpanElement>(\n isHidden ? false : tooltip,\n { placement: \"top\", className: \"ds-avatar-tooltip\" },\n );\n // Stable across renders, so tooltip state changes never detach a caller's callback ref.\n const spanRef = useMemo(() => mergeRefs(anchorRef, ref), [anchorRef, ref]);\n const colours = useMemo(() => avatarColours(colour), [colour]);\n const { aria, other } = splitAria(props);\n const semantics = {\n ...aria,\n id,\n \"aria-label\": label,\n \"aria-describedby\": [describedBy, description].filter(Boolean).join(\" \") || undefined,\n tabIndex: tabIndex ?? defaultTabIndex(isActionable, isHidden, !!tooltip),\n };\n return (\n <>\n <span\n ref={spanRef}\n role={isActionable ? undefined : \"img\"}\n aria-hidden={hidden}\n {...(isActionable ? {} : semantics)}\n data-size={size}\n className={[\"ds-avatar\", className].filter(Boolean).join(\" \")}\n {...other}\n style={{ ...style, ...colours }}\n onClick={onClick}\n {...triggerProps({ onMouseEnter, onMouseLeave, onFocus, onBlur })}\n >\n <AvatarControl\n href={href}\n target={target}\n rel={rel}\n hasCallback={!!onClick}\n size={size}\n semantics={semantics}\n >\n <AvatarContent\n name={name}\n src={src}\n />\n </AvatarControl>\n </span>\n {panel}\n </>\n );\n});\n\ntype AvatarPerson = Pick<\n AvatarProps,\n \"name\" | \"src\" | \"colour\" | \"tooltip\" | \"href\" | \"target\" | \"rel\" | \"onClick\"\n>;\n\nexport interface AvatarGroupProps extends HTMLAttributes<HTMLSpanElement> {\n /** Up to three render; the rest become a +n count with a hidden-name tooltip. */\n people: AvatarPerson[];\n size?: AvatarSize;\n}\n\nfunction OverflowCount({ names }: { names: string[] }) {\n const { anchorRef, description, triggerProps, panel } = useTooltip<HTMLSpanElement>(\n names.join(\", \"),\n { placement: \"top\", className: \"ds-avatar-tooltip\" },\n );\n const count = names.length;\n return (\n <>\n <span\n ref={anchorRef}\n role=\"img\"\n className=\"ds-avatar-group__count\"\n tabIndex={0}\n aria-label={`${count} more ${count === 1 ? \"person\" : \"people\"}`}\n aria-describedby={description}\n {...triggerProps()}\n >\n +{count}\n </span>\n {panel}\n </>\n );\n}\n\n/** Overlapping stack of at most three avatars, then a +n chip. */\nexport const AvatarGroup = forwardRef<HTMLSpanElement, AvatarGroupProps>(function AvatarGroup(\n { people, size = 24, className, ...rest },\n ref,\n) {\n return (\n <span\n ref={ref}\n role=\"group\"\n aria-label={people.map((p) => p.name).join(\", \")}\n className={[\"ds-avatar-group\", className].filter(Boolean).join(\" \")}\n {...rest}\n >\n {/* Only documented person fields reach Avatar; extra application data stays off the DOM. */}\n {people\n .slice(0, 3)\n .map(({ name, src, colour, tooltip, href, target, rel, onClick }, index) => (\n <Avatar\n key={`${name}-${index}`}\n name={name}\n src={src}\n colour={colour}\n tooltip={tooltip}\n href={href}\n target={target}\n rel={rel}\n onClick={onClick}\n size={size}\n />\n ))}\n {people.length > 3 && <OverflowCount names={people.slice(3).map((person) => person.name)} />}\n </span>\n );\n});\n"],"mappings":"A,yRAIAA,EAAAA,EAAAA,OAAAA,CAAO,CAACC,EAAAA,OAAU,CAAC,EAGnB,SAAgBgB,EAAc,EAAgB,CAE5C,IAAMC,EAAaC,EAAQjB,EAAAA,EAAYiB,CAAK,EAAI,KAChD,GAAKD,GAAcA,EAAW,MAAM,IAAM,EAG1C,MAAO,CACL,sBAAuBA,EAAW,MAAM,EACxC,sBACEA,EAAW,SAAS,MAAM,GAAKA,EAAW,SAAS,MAAM,EAAI,UAAY,SAC7E,CACF,CCDA,IAAME,EAA8C,CAAE,GAAI,KAAM,GAAI,KAAM,GAAI,IAAK,EAgBnF,SAASC,EAAW,EAAc,CAChC,IAAMC,EAAQC,EAAK,KAAK,CAAC,CAAC,MAAM,KAAK,EAGrC,QAFcD,EAAM,EAAE,GAAG,IAAM,KAClBA,EAAM,OAAS,EAAIA,EAAMA,EAAM,OAAS,EAAE,CAAC,GAAK,IAAA,CACvC,YAAY,CACpC,CAGA,SAASE,EAA4B,EAAU,CAC7C,IAAMC,EAAgC,CAAC,EACjCC,EAAiC,CAAC,EACxC,IAAK,GAAM,CAACC,EAAKR,KAAU,OAAO,QAAQS,CAAK,EAC7C,CAACD,EAAI,WAAW,OAAO,EAAIF,EAAOC,EAAA,CAAOC,GAAOR,EAElD,MAAO,CAAQ,OAA+B,OAAuC,CACvF,CAMA,SAASU,EAAgB,EAAuB,EAAmB,EAAqB,CAItF,OAHIC,EACKC,EAAW,GAAK,IAAA,GAElB,CAACA,GAAYC,EAAa,EAAI,IAAA,EACvC,CAEA,SAASC,EAAc,CAAE,OAAM,OAA0C,CACvE,OACE,EAAAnB,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,qBACb,SAAAoB,GACC,EAAApB,EAAA,IAAA,CAAC,MA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AO,GAAI,YAAW,GAAGwD,GACnC,EACA,CACA,OACE,EAAA/C,EAAA,KAAA,CAAC,OAAD,CACO,MACL,KAAK,QACL,aAAYgD,EAAO,IAAK,GAAMC,EAAE,IAAI,CAAC,CAAC,KAAK,IAAI,EAC/C,UAAW,CAAC,kBAAmBV,CAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,EAClE,GAAIQ,EALN,SAAA,CAQGC,EACE,MAAM,EAAG,CAAC,CAAC,CACX,KAAK,CAAE,OAAM,MAAK,SAAQ,UAAS,OAAM,SAAQ,MAAK,WAAW,KAChE,EAAAhD,EAAA,IAAA,CAAC0B,EAAD,CAEQ,OACD,MACG,SACC,UACH,OACE,SACH,MACI,UACH,MACP,EAVM,GAAGjB,EAAK,GAAGyC,GAUjB,CACF,EACFF,EAAO,OAAS,IAAK,EAAAhD,EAAA,IAAA,CAAC2C,EAAD,CAAe,MAAOK,EAAO,MAAM,CAAC,CAAC,CAAC,IAAK,GAAWG,EAAO,IAAI,CAAI,CAAA,CACvF,C,EAEV,CAAC,E"}
|
|
1
|
+
{"version":3,"file":"Avatar-DPnrvkwd.cjs","names":["extend","a11yPlugin","parseColour","Button","_Fragment","forwardRef","useTooltip","useMemo","mergeRefs","require_colour","require_components_Button_index","require_mergeRefs","require_useTooltip","react","react_jsx_runtime","colord","colord_plugins_a11y","avatarColours","background","value","buttonSizes","initialsOf","words","name","splitAria","aria","other","key","props","defaultTabIndex","isActionable","isHidden","hasTooltip","AvatarContent","src","AvatarControl","href","semantics","hasCallback","size","Avatar","label","describedBy","hidden","onClick","tooltip","spanRef","anchorRef","ref","colours","colour","description","tabIndex","className","style","triggerProps","panel","OverflowCount","names","count","AvatarGroup","rest","people","p","index","person"],"sources":["../../src/components/Avatar/colour.ts","../../src/components/Avatar/index.tsx"],"sourcesContent":["import { extend } from \"colord\";\nimport a11yPlugin from \"colord/plugins/a11y\";\nimport { parseColour } from \"../ColourField/colour\";\n\nextend([a11yPlugin]);\n\n/** Opaque colours only: transparency would make contrast depend on the surface below. */\nexport function avatarColours(value?: string) {\n // Share ColourField's parser so both components accept and classify colours identically.\n const background = value ? parseColour(value) : null;\n if (!background || background.alpha() !== 1) {\n return undefined;\n }\n return {\n \"--avatar-background\": background.toHex(),\n \"--avatar-foreground\":\n background.contrast(\"#000\") >= background.contrast(\"#fff\") ? \"#000000\" : \"#ffffff\",\n };\n}\n","import {\n forwardRef,\n useMemo,\n type AnchorHTMLAttributes,\n type AriaAttributes,\n type HTMLAttributes,\n type ReactNode,\n} from \"react\";\nimport { mergeRefs } from \"../../internal/mergeRefs\";\nimport { Button, type ButtonSize } from \"../Button\";\nimport { useTooltip } from \"../Popover/useTooltip\";\nimport { avatarColours } from \"./colour\";\nimport \"./style.css\";\n\nexport type AvatarSize = 24 | 32 | 40;\n\n/** Each avatar size is one of Button's square sizes, so callback avatars use Button unchanged. */\nconst buttonSizes: Record<AvatarSize, ButtonSize> = { 24: \"xs\", 32: \"sm\", 40: \"md\" };\n\nexport interface AvatarProps extends HTMLAttributes<HTMLSpanElement> {\n /** Required — drives the initials and the accessible name. */\n name: string;\n src?: string;\n size?: AvatarSize;\n /** Solid hex, RGB, HSL or named background; initials automatically use contrasting black/white. */\n colour?: string;\n /** Defaults to name; false disables the hover/focus tooltip. */\n tooltip?: string | false;\n href?: string;\n target?: AnchorHTMLAttributes<HTMLAnchorElement>[\"target\"];\n rel?: string;\n}\n\nfunction initialsOf(name: string) {\n const words = name.trim().split(/\\s+/);\n const first = words[0]?.[0] ?? \"\";\n const last = words.length > 1 ? words[words.length - 1][0] : \"\";\n return (first + last).toUpperCase();\n}\n\n/** Separate ARIA attributes so they can follow the element that carries the role. */\nfunction splitAria<T extends object>(props: T) {\n const aria: Record<string, unknown> = {};\n const other: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(props)) {\n (key.startsWith(\"aria-\") ? aria : other)[key] = value;\n }\n return { aria: aria as AriaAttributes, other: other as Omit<T, keyof AriaAttributes> };\n}\n\n/**\n * Links and Buttons are natively focusable, and hidden ones leave the tab order.\n * A passive avatar is focusable only for a visible tooltip.\n */\nfunction defaultTabIndex(isActionable: boolean, isHidden: boolean, hasTooltip: boolean) {\n if (isActionable) {\n return isHidden ? -1 : undefined;\n }\n return !isHidden && hasTooltip ? 0 : undefined;\n}\n\nfunction AvatarContent({ name, src }: Pick<AvatarProps, \"name\" | \"src\">) {\n return (\n <span className=\"ds-avatar__content\">\n {src ? (\n <img\n src={src}\n alt=\"\"\n />\n ) : (\n initialsOf(name)\n )}\n </span>\n );\n}\n\ninterface AvatarControlProps extends Pick<AvatarProps, \"href\" | \"target\" | \"rel\"> {\n hasCallback: boolean;\n size: AvatarSize;\n /** Naming, description, id, ARIA state and tab order for the control. */\n semantics: HTMLAttributes<HTMLElement>;\n children: ReactNode;\n}\n\n/** The inner link or shared Button of an actionable avatar; passive content otherwise. */\nfunction AvatarControl({\n href,\n target,\n rel,\n hasCallback,\n size,\n semantics,\n children,\n}: AvatarControlProps) {\n if (href) {\n return (\n <a\n className=\"ds-avatar__control\"\n href={href}\n target={target}\n rel={rel}\n {...semantics}\n >\n {children}\n </a>\n );\n }\n if (hasCallback) {\n return (\n <Button\n variant=\"simple\"\n size={buttonSizes[size]}\n isIconOnly\n className=\"ds-avatar__control\"\n {...semantics}\n >\n {children}\n </Button>\n );\n }\n return <>{children}</>;\n}\n\n/**\n * A circular person identifier, optionally linked or actionable. The ref stays on\n * the outer span; `id` and ARIA attributes go to the image span, or to the inner\n * link or Button when the avatar is actionable.\n */\nexport const Avatar = forwardRef<HTMLSpanElement, AvatarProps>(function Avatar(\n {\n name,\n src,\n colour,\n style,\n size = 24,\n tooltip = name,\n href,\n target,\n rel,\n className,\n onClick,\n onMouseEnter,\n onMouseLeave,\n onFocus,\n onBlur,\n id,\n tabIndex,\n \"aria-label\": label = name,\n \"aria-describedby\": describedBy,\n \"aria-hidden\": hidden,\n ...props\n },\n ref,\n) {\n const isHidden = hidden === true || hidden === \"true\";\n const isActionable = !!href || !!onClick;\n const { anchorRef, description, triggerProps, panel } = useTooltip<HTMLSpanElement>(\n isHidden ? false : tooltip,\n { placement: \"top\", className: \"ds-avatar-tooltip\" },\n );\n // Stable across renders, so tooltip state changes never detach a caller's callback ref.\n const spanRef = useMemo(() => mergeRefs(anchorRef, ref), [anchorRef, ref]);\n const colours = useMemo(() => avatarColours(colour), [colour]);\n const { aria, other } = splitAria(props);\n const semantics = {\n ...aria,\n id,\n \"aria-label\": label,\n \"aria-describedby\": [describedBy, description].filter(Boolean).join(\" \") || undefined,\n tabIndex: tabIndex ?? defaultTabIndex(isActionable, isHidden, !!tooltip),\n };\n return (\n <>\n <span\n ref={spanRef}\n role={isActionable ? undefined : \"img\"}\n aria-hidden={hidden}\n {...(isActionable ? {} : semantics)}\n data-size={size}\n className={[\"ds-avatar\", className].filter(Boolean).join(\" \")}\n {...other}\n style={{ ...style, ...colours }}\n onClick={onClick}\n {...triggerProps({ onMouseEnter, onMouseLeave, onFocus, onBlur })}\n >\n <AvatarControl\n href={href}\n target={target}\n rel={rel}\n hasCallback={!!onClick}\n size={size}\n semantics={semantics}\n >\n <AvatarContent\n name={name}\n src={src}\n />\n </AvatarControl>\n </span>\n {panel}\n </>\n );\n});\n\ntype AvatarPerson = Pick<\n AvatarProps,\n \"name\" | \"src\" | \"colour\" | \"tooltip\" | \"href\" | \"target\" | \"rel\" | \"onClick\"\n>;\n\nexport interface AvatarGroupProps extends HTMLAttributes<HTMLSpanElement> {\n /** Up to three render; the rest become a +n count with a hidden-name tooltip. */\n people: AvatarPerson[];\n size?: AvatarSize;\n}\n\nfunction OverflowCount({ names }: { names: string[] }) {\n const { anchorRef, description, triggerProps, panel } = useTooltip<HTMLSpanElement>(\n names.join(\", \"),\n { placement: \"top\", className: \"ds-avatar-tooltip\" },\n );\n const count = names.length;\n return (\n <>\n <span\n ref={anchorRef}\n role=\"img\"\n className=\"ds-avatar-group__count\"\n tabIndex={0}\n aria-label={`${count} more ${count === 1 ? \"person\" : \"people\"}`}\n aria-describedby={description}\n {...triggerProps()}\n >\n +{count}\n </span>\n {panel}\n </>\n );\n}\n\n/** Overlapping stack of at most three avatars, then a +n chip. */\nexport const AvatarGroup = forwardRef<HTMLSpanElement, AvatarGroupProps>(function AvatarGroup(\n { people, size = 24, className, ...rest },\n ref,\n) {\n return (\n <span\n ref={ref}\n role=\"group\"\n aria-label={people.map((p) => p.name).join(\", \")}\n className={[\"ds-avatar-group\", className].filter(Boolean).join(\" \")}\n {...rest}\n >\n {/* Only documented person fields reach Avatar; extra application data stays off the DOM. */}\n {people\n .slice(0, 3)\n .map(({ name, src, colour, tooltip, href, target, rel, onClick }, index) => (\n <Avatar\n key={`${name}-${index}`}\n name={name}\n src={src}\n colour={colour}\n tooltip={tooltip}\n href={href}\n target={target}\n rel={rel}\n onClick={onClick}\n size={size}\n />\n ))}\n {people.length > 3 && <OverflowCount names={people.slice(3).map((person) => person.name)} />}\n </span>\n );\n});\n"],"mappings":"A,yRAIAA,EAAAA,EAAAA,OAAAA,CAAO,CAACC,EAAAA,OAAU,CAAC,EAGnB,SAAgBgB,EAAc,EAAgB,CAE5C,IAAMC,EAAaC,EAAQjB,EAAAA,EAAYiB,CAAK,EAAI,KAChD,GAAKD,GAAcA,EAAW,MAAM,IAAM,EAG1C,MAAO,CACL,sBAAuBA,EAAW,MAAM,EACxC,sBACEA,EAAW,SAAS,MAAM,GAAKA,EAAW,SAAS,MAAM,EAAI,UAAY,SAC7E,CACF,CCDA,IAAME,EAA8C,CAAE,GAAI,KAAM,GAAI,KAAM,GAAI,IAAK,EAgBnF,SAASC,EAAW,EAAc,CAChC,IAAMC,EAAQC,EAAK,KAAK,CAAC,CAAC,MAAM,KAAK,EAGrC,QAFcD,EAAM,EAAE,GAAG,IAAM,KAClBA,EAAM,OAAS,EAAIA,EAAMA,EAAM,OAAS,EAAE,CAAC,GAAK,IAAA,CACvC,YAAY,CACpC,CAGA,SAASE,EAA4B,EAAU,CAC7C,IAAMC,EAAgC,CAA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KAAK,IAAI,EACf,CAAE,UAAW,MAAO,UAAW,mBAAoB,CACrD,EACMC,EAAQD,EAAM,OACpB,OACE,EAAA5C,EAAA,KAAA,CAAAV,EAAAA,SAAA,CAAA,SAAA,EACE,EAAAU,EAAA,KAAA,CAAC,OAAD,CACE,IAAKiC,EACL,KAAK,MACL,UAAU,yBACV,SAAU,EACV,aAAY,GAAGY,EAAM,QAAQA,IAAU,EAAI,SAAW,WACtD,mBAAkBR,EAClB,GAAII,EAAa,EAPnB,SAAA,CAQC,IACGI,CACE,CACL,CAAA,EAAAH,CACD,CAAA,CAAA,CAEN,CAGA,IAAaI,GAAA,EAAcvD,EAAAA,WAAAA,CAA8C,SACvE,CAAE,SAAQ,OAAO,GAAI,YAAW,GAAGwD,GACnC,EACA,CACA,OACE,EAAA/C,EAAA,KAAA,CAAC,OAAD,CACO,MACL,KAAK,QACL,aAAYgD,EAAO,IAAK,GAAMC,EAAE,IAAI,CAAC,CAAC,KAAK,IAAI,EAC/C,UAAW,CAAC,kBAAmBV,CAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,EAClE,GAAIQ,EALN,SAAA,CAQGC,EACE,MAAM,EAAG,CAAC,CAAC,CACX,KAAK,CAAE,OAAM,MAAK,SAAQ,UAAS,OAAM,SAAQ,MAAK,WAAW,KAChE,EAAAhD,EAAA,IAAA,CAAC0B,EAAD,CAEQ,OACD,MACG,SACC,UACH,OACE,SACH,MACI,UACH,MACP,EAVM,GAAGjB,EAAK,GAAGyC,GAUjB,CACF,EACFF,EAAO,OAAS,IAAK,EAAAhD,EAAA,IAAA,CAAC2C,EAAD,CAAe,MAAOK,EAAO,MAAM,CAAC,CAAC,CAAC,IAAK,GAAWG,EAAO,IAAI,CAAI,CAAA,CACvF,C,EAEV,CAAC,E"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../components/Button/index.cjs"),t=require("./overlayLayer-
|
|
2
|
-
//# sourceMappingURL=CollectionView-
|
|
1
|
+
const e=require("../components/Button/index.cjs"),t=require("./overlayLayer-seJG-EFn.cjs"),n=require("../components/ButtonGroup/index.cjs"),r=require("../components/Badge/index.cjs"),i=require("./LoadState-BXLG-SkQ.cjs"),a=require("../components/SearchField/index.cjs"),o=require("../components/Select/index.cjs"),s=require("../components/Table/index.cjs"),c=require("../components/Pagination/index.cjs");let l=require("react"),u=require("react/jsx-runtime");function d({title:t,query:r,onQueryChange:i,filter:s,mine:c,view:l,actions:d}){return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(a.SearchField,{size:`sm`,maxLength:200,placeholder:`Search ${t.toLowerCase()}`,"aria-label":`Search ${t.toLowerCase()}`,value:r,onChange:e=>i(e.target.value),onClear:()=>i(``)}),s&&(0,u.jsx)(`div`,{className:`ds-collection-view__filter`,children:(0,u.jsx)(o.Select,{size:`sm`,"aria-label":s.label,value:s.value,options:s.options,onValueChange:s.onChange})}),c&&(0,u.jsx)(e.Button,{size:`sm`,iconStart:`user`,variant:c.isPressed?`active`:`neutral`,"aria-pressed":c.isPressed,onClick:()=>c.onChange(!c.isPressed),children:c.label}),l&&(0,u.jsxs)(n.ButtonGroup,{"aria-label":`${t} view`,children:[(0,u.jsx)(e.Button,{size:`sm`,isIconOnly:!0,iconStart:`layout-grid`,"aria-label":`Grid view`,"aria-pressed":l.value===`grid`,variant:l.value===`grid`?`active`:`neutral`,onClick:()=>l.onChange(`grid`)}),(0,u.jsx)(e.Button,{size:`sm`,isIconOnly:!0,iconStart:`list`,"aria-label":`Table view`,"aria-pressed":l.value===`table`,variant:l.value===`table`?`active`:`neutral`,onClick:()=>l.onChange(`table`)})]}),d]})}function f({title:n,count:i,query:a,onQueryChange:o,filter:c,mine:f,view:p,selection:m,actions:h}){let g=!!m?.count,_=(0,l.useRef)(null),v=(0,l.useRef)(null);return(0,l.useEffect)(()=>{let e=v.current;!g&&e&&!e.isConnected&&t.d(document.activeElement)&&(v.current=null,_.current?.focus({preventScroll:!0}))},[g]),(0,u.jsx)(s.TableToolbar,{className:`ds-collection-view__toolbar`,"data-selected":g||void 0,onFocus:e=>{v.current=e.target},onBlur:e=>{e.relatedTarget&&(v.current=null)},start:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`span`,{className:`ds-collection-view__selected`,role:`status`,children:g&&`${m.count} selected`}),!g&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`span`,{ref:_,className:`ds-table-toolbar__title`,tabIndex:-1,children:n}),(0,u.jsx)(r.Badge,{shape:`count`,appearance:`soft`,isCountExact:!0,className:`ds-collection-view__count`,children:i})]})]}),end:g?(0,u.jsxs)(u.Fragment,{children:[m.reason&&(0,u.jsx)(`span`,{className:`ds-collection-view__reason`,children:m.reason}),m.actions,(0,u.jsx)(e.Button,{size:`sm`,variant:`simple`,isDisabled:m.isPending,onClick:m.onClear,children:`Clear`})]}):(0,u.jsx)(d,{title:n,query:a,onQueryChange:o,filter:c,mine:f,view:p,actions:h})})}function p({kind:e,noun:t,icon:n,title:r,description:i,action:a}){return e===`no-match`?(0,u.jsx)(s.TableEmpty,{icon:`search`,title:`No matching ${t}`,description:`Try a different search or clear a filter.`}):(0,u.jsx)(s.TableEmpty,{icon:n,title:r,description:i,action:a})}function m({title:e,count:t,query:n,onQueryChange:r,status:a,error:o,onRetry:l,pagination:d,filter:p,mine:m,view:h,selection:g,actions:_,children:v}){return(0,u.jsxs)(s.TableFrame,{className:`ds-collection-view`,"aria-busy":a===`loading`||g?.isPending||void 0,children:[(0,u.jsx)(f,{title:e,count:t,query:n,onQueryChange:r,filter:p,mine:m,view:h,selection:g,actions:_}),(0,u.jsx)(`div`,{className:`ds-collection-view__body`,"data-feedback":a!==`ready`||void 0,children:(0,u.jsx)(i.t,{status:a,error:o,onRetry:l,children:v})}),(0,u.jsx)(`div`,{className:`ds-collection-view__footer`,children:(0,u.jsx)(c.Pagination,{size:`md`,menuPlacement:`top`,...d,isDisabled:d.isDisabled||g?.isPending})})]})}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return m}});
|
|
2
|
+
//# sourceMappingURL=CollectionView-BNYx29b1.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollectionView-B18Ihv7X.cjs","names":["_Fragment","SearchField","Select","Button","ButtonGroup","useRef","cannotHoldFocus","TableToolbar","_Fragment","Badge","Button","TableEmpty","TableFrame","LoadState","Pagination","require_components_Button_index","require_overlayLayer","require_components_ButtonGroup_index","require_components_Badge_index","require_LoadState","require_components_SearchField_index","require_components_Select_index","require_components_Table_index","require_components_Pagination_index","react","react_jsx_runtime","CollectionFilters","title","query","onQueryChange","event","filter","mine","view","actions","CollectionToolbar","selected","selection","titleRef","focused","previous","count","CollectionEmpty","kind","noun","CollectionView","status","pagination"],"sources":["../../src/components/CollectionView/filters.tsx","../../src/components/CollectionView/toolbar.tsx","../../src/components/CollectionView/empty.tsx","../../src/components/CollectionView/index.tsx"],"sourcesContent":["import { Button } from \"../Button\";\nimport { ButtonGroup } from \"../ButtonGroup\";\nimport { SearchField } from \"../SearchField\";\nimport { Select } from \"../Select\";\nimport type { CollectionViewProps } from \"./types\";\n\ntype FiltersProps = Pick<\n CollectionViewProps,\n \"title\" | \"query\" | \"onQueryChange\" | \"filter\" | \"mine\" | \"view\" | \"actions\"\n>;\n\n/** Search and view controls for a collection without an active selection. */\nexport function CollectionFilters({\n title,\n query,\n onQueryChange,\n filter,\n mine,\n view,\n actions,\n}: FiltersProps) {\n return (\n <>\n <SearchField\n size=\"sm\"\n maxLength={200}\n placeholder={`Search ${title.toLowerCase()}`}\n aria-label={`Search ${title.toLowerCase()}`}\n value={query}\n onChange={(event) => onQueryChange(event.target.value)}\n onClear={() => onQueryChange(\"\")}\n />\n {filter && (\n <div className=\"ds-collection-view__filter\">\n <Select\n size=\"sm\"\n aria-label={filter.label}\n value={filter.value}\n options={filter.options}\n onValueChange={filter.onChange}\n />\n </div>\n )}\n {mine && (\n <Button\n size=\"sm\"\n iconStart=\"user\"\n variant={mine.isPressed ? \"active\" : \"neutral\"}\n aria-pressed={mine.isPressed}\n onClick={() => mine.onChange(!mine.isPressed)}\n >\n {mine.label}\n </Button>\n )}\n {view && (\n <ButtonGroup aria-label={`${title} view`}>\n <Button\n size=\"sm\"\n isIconOnly\n iconStart=\"layout-grid\"\n aria-label=\"Grid view\"\n aria-pressed={view.value === \"grid\"}\n variant={view.value === \"grid\" ? \"active\" : \"neutral\"}\n onClick={() => view.onChange(\"grid\")}\n />\n <Button\n size=\"sm\"\n isIconOnly\n iconStart=\"list\"\n aria-label=\"Table view\"\n aria-pressed={view.value === \"table\"}\n variant={view.value === \"table\" ? \"active\" : \"neutral\"}\n onClick={() => view.onChange(\"table\")}\n />\n </ButtonGroup>\n )}\n {actions}\n </>\n );\n}\n","import { useEffect, useRef } from \"react\";\nimport { Badge } from \"../Badge\";\nimport { Button } from \"../Button\";\nimport { TableToolbar } from \"../Table\";\nimport { cannotHoldFocus } from \"../../internal/dialogFocus\";\nimport type { CollectionViewProps } from \"./types\";\nimport { CollectionFilters } from \"./filters\";\ntype ToolbarProps = Pick<\n CollectionViewProps,\n | \"title\"\n | \"count\"\n | \"query\"\n | \"onQueryChange\"\n | \"filter\"\n | \"mine\"\n | \"view\"\n | \"selection\"\n | \"actions\"\n>;\nexport function CollectionToolbar({\n title,\n count,\n query,\n onQueryChange,\n filter,\n mine,\n view,\n selection,\n actions,\n}: ToolbarProps) {\n const selected = Boolean(selection?.count);\n const titleRef = useRef<HTMLSpanElement>(null);\n // The toolbar control holding focus. A blur toward the page or a removal\n // keeps it, so the selection ending can tell that it took focus away.\n const focused = useRef<Element | null>(null);\n useEffect(() => {\n const previous = focused.current;\n // Clear, or a selection action, unmounted with focus: return it to the\n // collection's title rather than leave it on the page.\n if (!selected && previous && !previous.isConnected && cannotHoldFocus(document.activeElement)) {\n focused.current = null;\n titleRef.current?.focus({ preventScroll: true });\n }\n }, [selected]);\n return (\n <TableToolbar\n className=\"ds-collection-view__toolbar\"\n data-selected={selected || undefined}\n onFocus={(event) => {\n focused.current = event.target;\n }}\n onBlur={(event) => {\n if (event.relatedTarget) {\n focused.current = null;\n }\n }}\n start={\n <>\n {/* Mounted throughout, so screen readers hear the first selection. */}\n <span\n className=\"ds-collection-view__selected\"\n role=\"status\"\n >\n {selected && `${selection!.count} selected`}\n </span>\n {!selected && (\n <>\n <span\n ref={titleRef}\n className=\"ds-table-toolbar__title\"\n tabIndex={-1}\n >\n {title}\n </span>\n <Badge\n shape=\"count\"\n appearance=\"soft\"\n isCountExact\n className=\"ds-collection-view__count\"\n >\n {count}\n </Badge>\n </>\n )}\n </>\n }\n end={\n selected ? (\n <>\n {selection!.reason && (\n <span className=\"ds-collection-view__reason\">{selection!.reason}</span>\n )}\n {selection!.actions}\n <Button\n size=\"sm\"\n variant=\"simple\"\n isDisabled={selection!.isPending}\n onClick={selection!.onClear}\n >\n Clear\n </Button>\n </>\n ) : (\n <CollectionFilters\n title={title}\n query={query}\n onQueryChange={onQueryChange}\n filter={filter}\n mine={mine}\n view={view}\n actions={actions}\n />\n )\n }\n />\n );\n}\n","import { TableEmpty, type TableEmptyProps } from \"../Table\";\nimport type { CollectionEmptyKind } from \"./types\";\n\nexport interface CollectionEmptyProps extends Pick<\n TableEmptyProps,\n \"icon\" | \"description\" | \"action\"\n> {\n kind: CollectionEmptyKind;\n /** Plural noun for the no-match title, e.g. \"entries\". */\n noun: string;\n /** Shown when the collection itself has no items. */\n title: string;\n}\n\n/**\n * What a searchable collection's frame shows instead of its table: how to\n * start an empty collection, or a pointer back to the search field.\n */\nexport function CollectionEmpty({\n kind,\n noun,\n icon,\n title,\n description,\n action,\n}: CollectionEmptyProps) {\n if (kind === \"no-match\") {\n return (\n <TableEmpty\n icon=\"search\"\n title={`No matching ${noun}`}\n description=\"Try a different search or clear a filter.\"\n />\n );\n }\n return (\n <TableEmpty\n icon={icon}\n title={title}\n description={description}\n action={action}\n />\n );\n}\n","import { Pagination } from \"../Pagination\";\nimport { TableFrame } from \"../Table\";\nimport { CollectionToolbar } from \"./toolbar\";\nimport { LoadState } from \"../LoadState\";\nimport type { CollectionViewProps } from \"./types\";\nimport \"./style.css\";\nexport type { CollectionViewProps, CollectionEmptyKind } from \"./types\";\nexport { CollectionEmpty } from \"./empty\";\nexport type { CollectionEmptyProps } from \"./empty\";\n\nexport function CollectionView({\n title,\n count,\n query,\n onQueryChange,\n status,\n error,\n onRetry,\n pagination,\n filter,\n mine,\n view,\n selection,\n actions,\n children,\n}: CollectionViewProps) {\n return (\n <TableFrame\n className=\"ds-collection-view\"\n aria-busy={status === \"loading\" || selection?.isPending || undefined}\n >\n <CollectionToolbar\n title={title}\n count={count}\n query={query}\n onQueryChange={onQueryChange}\n filter={filter}\n mine={mine}\n view={view}\n selection={selection}\n actions={actions}\n />\n <div\n className=\"ds-collection-view__body\"\n data-feedback={status !== \"ready\" || undefined}\n >\n <LoadState\n status={status}\n error={error}\n onRetry={onRetry}\n >\n {children}\n </LoadState>\n </div>\n <div className=\"ds-collection-view__footer\">\n {/* Paging stays live while a page loads: disabling the pressed Next or\n Previous button would drop its focus on every page change. */}\n <Pagination\n size=\"md\"\n menuPlacement=\"top\"\n {...pagination}\n isDisabled={pagination.isDisabled || selection?.isPending}\n />\n </div>\n </TableFrame>\n );\n}\n"],"mappings":"A,2cAYA,SAAgB0B,EAAkB,CAChC,QACA,QACA,gBACA,SACA,OACA,OACA,WACe,CACf,OACE,EAAAD,EAAA,KAAA,CAAAzB,EAAAA,SAAA,CAAA,SAAA,EACE,EAAAyB,EAAA,IAAA,CAACxB,EAAAA,YAAD,CACE,KAAK,KACL,UAAW,IACX,YAAa,UAAU0B,EAAM,YAAY,IACzC,aAAY,UAAUA,EAAM,YAAY,IACxC,MAAOC,EACP,SAAW,GAAUC,EAAcC,EAAM,OAAO,KAAK,EACrD,YAAeD,EAAc,EAAE,CAChC,CAAA,EACAE,IACC,EAAAN,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,6BACb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OACA,OACA,OACA,QACA,cACA,UACuB,CAUvB,OATIC,IAAS,YAET,EAAAlB,EAAA,IAAA,CAACd,EAAAA,WAAD,CACE,KAAK,SACL,MAAO,eAAeiC,IACtB,YAAY,2CACb,CAAA,GAIH,EAAAnB,EAAA,IAAA,CAACd,EAAAA,WAAD,CACQ,OACC,QACM,cACL,QACT,CAAA,CAEL,CCjCA,SAAgBkC,EAAe,CAC7B,QACA,QACA,QACA,gBACA,SACA,QACA,UACA,aACA,SACA,OACA,OACA,YACA,UACA,YACsB,CACtB,OACE,EAAApB,EAAA,KAAA,CAACb,EAAAA,WAAD,CACE,UAAU,qBACV,YAAWkC,IAAW,WAAaT,GAAW,WAAa,IAAA,GAF7D,SAAA,EAIE,EAAAZ,EAAA,IAAA,CAACU,EAAD,CACS,QACA,QACA,QACQ,gBACP,SACF,OACA,OACK,YACF,SACV,CAAA,GACD,EAAAV,EAAA,IAAA,CAAC,MAAD,CACE,UAAU,2BACV,gBAAeqB,IAAW,SAAW,IAAA,GAErC,UAAA,EAAArB,EAAA,IAAA,CAACZ,EAAAA,EAAD,CACU,SACD,QACE,UAER,UACQ,CAAA,CACR,CAAA,GACL,EAAAY,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,6BAGb,UAAA,EAAAA,EAAA,IAAA,CAACX,EAAAA,WAAD,CACE,KAAK,KACL,cAAc,MACd,GAAIiC,EACJ,WAAYA,EAAW,YAAcV,GAAW,SACjD,CAAA,CACE,CAAA,CACK,C,EAEhB,C"}
|
|
1
|
+
{"version":3,"file":"CollectionView-BNYx29b1.cjs","names":["_Fragment","SearchField","Select","Button","ButtonGroup","useRef","cannotHoldFocus","TableToolbar","_Fragment","Badge","Button","TableEmpty","TableFrame","LoadState","Pagination","require_components_Button_index","require_overlayLayer","require_components_ButtonGroup_index","require_components_Badge_index","require_LoadState","require_components_SearchField_index","require_components_Select_index","require_components_Table_index","require_components_Pagination_index","react","react_jsx_runtime","CollectionFilters","title","query","onQueryChange","event","filter","mine","view","actions","CollectionToolbar","selected","selection","titleRef","focused","previous","count","CollectionEmpty","kind","noun","CollectionView","status","pagination"],"sources":["../../src/components/CollectionView/filters.tsx","../../src/components/CollectionView/toolbar.tsx","../../src/components/CollectionView/empty.tsx","../../src/components/CollectionView/index.tsx"],"sourcesContent":["import { Button } from \"../Button\";\nimport { ButtonGroup } from \"../ButtonGroup\";\nimport { SearchField } from \"../SearchField\";\nimport { Select } from \"../Select\";\nimport type { CollectionViewProps } from \"./types\";\n\ntype FiltersProps = Pick<\n CollectionViewProps,\n \"title\" | \"query\" | \"onQueryChange\" | \"filter\" | \"mine\" | \"view\" | \"actions\"\n>;\n\n/** Search and view controls for a collection without an active selection. */\nexport function CollectionFilters({\n title,\n query,\n onQueryChange,\n filter,\n mine,\n view,\n actions,\n}: FiltersProps) {\n return (\n <>\n <SearchField\n size=\"sm\"\n maxLength={200}\n placeholder={`Search ${title.toLowerCase()}`}\n aria-label={`Search ${title.toLowerCase()}`}\n value={query}\n onChange={(event) => onQueryChange(event.target.value)}\n onClear={() => onQueryChange(\"\")}\n />\n {filter && (\n <div className=\"ds-collection-view__filter\">\n <Select\n size=\"sm\"\n aria-label={filter.label}\n value={filter.value}\n options={filter.options}\n onValueChange={filter.onChange}\n />\n </div>\n )}\n {mine && (\n <Button\n size=\"sm\"\n iconStart=\"user\"\n variant={mine.isPressed ? \"active\" : \"neutral\"}\n aria-pressed={mine.isPressed}\n onClick={() => mine.onChange(!mine.isPressed)}\n >\n {mine.label}\n </Button>\n )}\n {view && (\n <ButtonGroup aria-label={`${title} view`}>\n <Button\n size=\"sm\"\n isIconOnly\n iconStart=\"layout-grid\"\n aria-label=\"Grid view\"\n aria-pressed={view.value === \"grid\"}\n variant={view.value === \"grid\" ? \"active\" : \"neutral\"}\n onClick={() => view.onChange(\"grid\")}\n />\n <Button\n size=\"sm\"\n isIconOnly\n iconStart=\"list\"\n aria-label=\"Table view\"\n aria-pressed={view.value === \"table\"}\n variant={view.value === \"table\" ? \"active\" : \"neutral\"}\n onClick={() => view.onChange(\"table\")}\n />\n </ButtonGroup>\n )}\n {actions}\n </>\n );\n}\n","import { useEffect, useRef } from \"react\";\nimport { Badge } from \"../Badge\";\nimport { Button } from \"../Button\";\nimport { TableToolbar } from \"../Table\";\nimport { cannotHoldFocus } from \"../../internal/dialogFocus\";\nimport type { CollectionViewProps } from \"./types\";\nimport { CollectionFilters } from \"./filters\";\ntype ToolbarProps = Pick<\n CollectionViewProps,\n | \"title\"\n | \"count\"\n | \"query\"\n | \"onQueryChange\"\n | \"filter\"\n | \"mine\"\n | \"view\"\n | \"selection\"\n | \"actions\"\n>;\nexport function CollectionToolbar({\n title,\n count,\n query,\n onQueryChange,\n filter,\n mine,\n view,\n selection,\n actions,\n}: ToolbarProps) {\n const selected = Boolean(selection?.count);\n const titleRef = useRef<HTMLSpanElement>(null);\n // The toolbar control holding focus. A blur toward the page or a removal\n // keeps it, so the selection ending can tell that it took focus away.\n const focused = useRef<Element | null>(null);\n useEffect(() => {\n const previous = focused.current;\n // Clear, or a selection action, unmounted with focus: return it to the\n // collection's title rather than leave it on the page.\n if (!selected && previous && !previous.isConnected && cannotHoldFocus(document.activeElement)) {\n focused.current = null;\n titleRef.current?.focus({ preventScroll: true });\n }\n }, [selected]);\n return (\n <TableToolbar\n className=\"ds-collection-view__toolbar\"\n data-selected={selected || undefined}\n onFocus={(event) => {\n focused.current = event.target;\n }}\n onBlur={(event) => {\n if (event.relatedTarget) {\n focused.current = null;\n }\n }}\n start={\n <>\n {/* Mounted throughout, so screen readers hear the first selection. */}\n <span\n className=\"ds-collection-view__selected\"\n role=\"status\"\n >\n {selected && `${selection!.count} selected`}\n </span>\n {!selected && (\n <>\n <span\n ref={titleRef}\n className=\"ds-table-toolbar__title\"\n tabIndex={-1}\n >\n {title}\n </span>\n <Badge\n shape=\"count\"\n appearance=\"soft\"\n isCountExact\n className=\"ds-collection-view__count\"\n >\n {count}\n </Badge>\n </>\n )}\n </>\n }\n end={\n selected ? (\n <>\n {selection!.reason && (\n <span className=\"ds-collection-view__reason\">{selection!.reason}</span>\n )}\n {selection!.actions}\n <Button\n size=\"sm\"\n variant=\"simple\"\n isDisabled={selection!.isPending}\n onClick={selection!.onClear}\n >\n Clear\n </Button>\n </>\n ) : (\n <CollectionFilters\n title={title}\n query={query}\n onQueryChange={onQueryChange}\n filter={filter}\n mine={mine}\n view={view}\n actions={actions}\n />\n )\n }\n />\n );\n}\n","import { TableEmpty, type TableEmptyProps } from \"../Table\";\nimport type { CollectionEmptyKind } from \"./types\";\n\nexport interface CollectionEmptyProps extends Pick<\n TableEmptyProps,\n \"icon\" | \"description\" | \"action\"\n> {\n kind: CollectionEmptyKind;\n /** Plural noun for the no-match title, e.g. \"entries\". */\n noun: string;\n /** Shown when the collection itself has no items. */\n title: string;\n}\n\n/**\n * What a searchable collection's frame shows instead of its table: how to\n * start an empty collection, or a pointer back to the search field.\n */\nexport function CollectionEmpty({\n kind,\n noun,\n icon,\n title,\n description,\n action,\n}: CollectionEmptyProps) {\n if (kind === \"no-match\") {\n return (\n <TableEmpty\n icon=\"search\"\n title={`No matching ${noun}`}\n description=\"Try a different search or clear a filter.\"\n />\n );\n }\n return (\n <TableEmpty\n icon={icon}\n title={title}\n description={description}\n action={action}\n />\n );\n}\n","import { Pagination } from \"../Pagination\";\nimport { TableFrame } from \"../Table\";\nimport { CollectionToolbar } from \"./toolbar\";\nimport { LoadState } from \"../LoadState\";\nimport type { CollectionViewProps } from \"./types\";\nimport \"./style.css\";\nexport type { CollectionViewProps, CollectionEmptyKind } from \"./types\";\nexport { CollectionEmpty } from \"./empty\";\nexport type { CollectionEmptyProps } from \"./empty\";\n\nexport function CollectionView({\n title,\n count,\n query,\n onQueryChange,\n status,\n error,\n onRetry,\n pagination,\n filter,\n mine,\n view,\n selection,\n actions,\n children,\n}: CollectionViewProps) {\n return (\n <TableFrame\n className=\"ds-collection-view\"\n aria-busy={status === \"loading\" || selection?.isPending || undefined}\n >\n <CollectionToolbar\n title={title}\n count={count}\n query={query}\n onQueryChange={onQueryChange}\n filter={filter}\n mine={mine}\n view={view}\n selection={selection}\n actions={actions}\n />\n <div\n className=\"ds-collection-view__body\"\n data-feedback={status !== \"ready\" || undefined}\n >\n <LoadState\n status={status}\n error={error}\n onRetry={onRetry}\n >\n {children}\n </LoadState>\n </div>\n <div className=\"ds-collection-view__footer\">\n {/* Paging stays live while a page loads: disabling the pressed Next or\n Previous button would drop its focus on every page change. */}\n <Pagination\n size=\"md\"\n menuPlacement=\"top\"\n {...pagination}\n isDisabled={pagination.isDisabled || selection?.isPending}\n />\n </div>\n </TableFrame>\n );\n}\n"],"mappings":"A,2cAYA,SAAgB0B,EAAkB,CAChC,QACA,QACA,gBACA,SACA,OACA,OACA,WACe,CACf,OACE,EAAAD,EAAA,KAAA,CAAAzB,EAAAA,SAAA,CAAA,SAAA,EACE,EAAAyB,EAAA,IAAA,CAACxB,EAAAA,YAAD,CACE,KAAK,KACL,UAAW,IACX,YAAa,UAAU0B,EAAM,YAAY,IACzC,aAAY,UAAUA,EAAM,YAAY,IACxC,MAAOC,EACP,SAAW,GAAUC,EAAcC,EAAM,OAAO,KAAK,EACrD,YAAeD,EAAc,EAAE,CAChC,CAAA,EACAE,IACC,EAAAN,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,6BACb,UAAA,EAAAA,EAAA,IAAA,CAACvB,EAAAA,OAAD,CACE,KAAK,KACL,aAAY6B,EAAO,MACnB,MAAOA,EAAO,MACd,QAASA,EAAO,QAChB,cAAeA,EAAO,QACvB,CAAA,CACE,CAAA,EAENC,IACC,EAAAP,EAAA,IAAA,CAACtB,EAAAA,OAAD,CACE,KAAK,KACL,UAAU,OACV,QAAS6B,EAAK,UAAY,SAAW,UACrC,eAAcA,EAAK,UACnB,YAAeA,EAAK,SAAS,CAACA,EAAK,SAAS,EAE3C,SAAAA,EAAK,KACA,CAAA,EAETC,IACC,EAAAR,EAAA,KAAA,CAACrB,EAAAA,YAAD,CAAa,aAAY,GAAGuB,EAAM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a,IAAA,GAF7D,SAAA,EAIE,EAAAZ,EAAA,IAAA,CAACU,EAAD,CACS,QACA,QACA,QACQ,gBACP,SACF,OACA,OACK,YACF,SACV,CAAA,GACD,EAAAV,EAAA,IAAA,CAAC,MAAD,CACE,UAAU,2BACV,gBAAeqB,IAAW,SAAW,IAAA,GAErC,UAAA,EAAArB,EAAA,IAAA,CAACZ,EAAAA,EAAD,CACU,SACD,QACE,UAER,UACQ,CAAA,CACR,CAAA,GACL,EAAAY,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,6BAGb,UAAA,EAAAA,EAAA,IAAA,CAACX,EAAAA,WAAD,CACE,KAAK,KACL,cAAc,MACd,GAAIiC,EACJ,WAAYA,EAAW,YAAcV,GAAW,SACjD,CAAA,CACE,CAAA,CACK,C,EAEhB,C"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Button as e } from "../components/Button/index.js";
|
|
2
|
-
import { d as t } from "./overlayLayer-
|
|
2
|
+
import { d as t } from "./overlayLayer-IuoPVwTO.js";
|
|
3
3
|
import { ButtonGroup as n } from "../components/ButtonGroup/index.js";
|
|
4
4
|
import { Badge as r } from "../components/Badge/index.js";
|
|
5
5
|
import { t as i } from "./LoadState-B056EPu7.js";
|
|
@@ -175,4 +175,4 @@ function y({ title: e, count: t, query: n, onQueryChange: r, status: a, error: o
|
|
|
175
175
|
//#endregion
|
|
176
176
|
export { v as n, y as t };
|
|
177
177
|
|
|
178
|
-
//# sourceMappingURL=CollectionView-
|
|
178
|
+
//# sourceMappingURL=CollectionView-Vj84E26b.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollectionView-C-SwkPWC.js","names":["_Fragment","_Fragment","cannotHoldFocus","LoadState","Fragment$1","CollectionFilters","SearchField","title","query","onQueryChange","event","filter","Select","mine","Button","view","ButtonGroup","actions","CollectionToolbar","selected","selection","titleRef","useRef","focused","useEffect","previous","TableToolbar","Badge","count","CollectionEmpty","kind","TableEmpty","noun","CollectionView","TableFrame","status","Pagination","pagination"],"sources":["../../src/components/CollectionView/filters.tsx","../../src/components/CollectionView/toolbar.tsx","../../src/components/CollectionView/empty.tsx","../../src/components/CollectionView/index.tsx"],"sourcesContent":["import { Button } from \"../Button\";\nimport { ButtonGroup } from \"../ButtonGroup\";\nimport { SearchField } from \"../SearchField\";\nimport { Select } from \"../Select\";\nimport type { CollectionViewProps } from \"./types\";\n\ntype FiltersProps = Pick<\n CollectionViewProps,\n \"title\" | \"query\" | \"onQueryChange\" | \"filter\" | \"mine\" | \"view\" | \"actions\"\n>;\n\n/** Search and view controls for a collection without an active selection. */\nexport function CollectionFilters({\n title,\n query,\n onQueryChange,\n filter,\n mine,\n view,\n actions,\n}: FiltersProps) {\n return (\n <>\n <SearchField\n size=\"sm\"\n maxLength={200}\n placeholder={`Search ${title.toLowerCase()}`}\n aria-label={`Search ${title.toLowerCase()}`}\n value={query}\n onChange={(event) => onQueryChange(event.target.value)}\n onClear={() => onQueryChange(\"\")}\n />\n {filter && (\n <div className=\"ds-collection-view__filter\">\n <Select\n size=\"sm\"\n aria-label={filter.label}\n value={filter.value}\n options={filter.options}\n onValueChange={filter.onChange}\n />\n </div>\n )}\n {mine && (\n <Button\n size=\"sm\"\n iconStart=\"user\"\n variant={mine.isPressed ? \"active\" : \"neutral\"}\n aria-pressed={mine.isPressed}\n onClick={() => mine.onChange(!mine.isPressed)}\n >\n {mine.label}\n </Button>\n )}\n {view && (\n <ButtonGroup aria-label={`${title} view`}>\n <Button\n size=\"sm\"\n isIconOnly\n iconStart=\"layout-grid\"\n aria-label=\"Grid view\"\n aria-pressed={view.value === \"grid\"}\n variant={view.value === \"grid\" ? \"active\" : \"neutral\"}\n onClick={() => view.onChange(\"grid\")}\n />\n <Button\n size=\"sm\"\n isIconOnly\n iconStart=\"list\"\n aria-label=\"Table view\"\n aria-pressed={view.value === \"table\"}\n variant={view.value === \"table\" ? \"active\" : \"neutral\"}\n onClick={() => view.onChange(\"table\")}\n />\n </ButtonGroup>\n )}\n {actions}\n </>\n );\n}\n","import { useEffect, useRef } from \"react\";\nimport { Badge } from \"../Badge\";\nimport { Button } from \"../Button\";\nimport { TableToolbar } from \"../Table\";\nimport { cannotHoldFocus } from \"../../internal/dialogFocus\";\nimport type { CollectionViewProps } from \"./types\";\nimport { CollectionFilters } from \"./filters\";\ntype ToolbarProps = Pick<\n CollectionViewProps,\n | \"title\"\n | \"count\"\n | \"query\"\n | \"onQueryChange\"\n | \"filter\"\n | \"mine\"\n | \"view\"\n | \"selection\"\n | \"actions\"\n>;\nexport function CollectionToolbar({\n title,\n count,\n query,\n onQueryChange,\n filter,\n mine,\n view,\n selection,\n actions,\n}: ToolbarProps) {\n const selected = Boolean(selection?.count);\n const titleRef = useRef<HTMLSpanElement>(null);\n // The toolbar control holding focus. A blur toward the page or a removal\n // keeps it, so the selection ending can tell that it took focus away.\n const focused = useRef<Element | null>(null);\n useEffect(() => {\n const previous = focused.current;\n // Clear, or a selection action, unmounted with focus: return it to the\n // collection's title rather than leave it on the page.\n if (!selected && previous && !previous.isConnected && cannotHoldFocus(document.activeElement)) {\n focused.current = null;\n titleRef.current?.focus({ preventScroll: true });\n }\n }, [selected]);\n return (\n <TableToolbar\n className=\"ds-collection-view__toolbar\"\n data-selected={selected || undefined}\n onFocus={(event) => {\n focused.current = event.target;\n }}\n onBlur={(event) => {\n if (event.relatedTarget) {\n focused.current = null;\n }\n }}\n start={\n <>\n {/* Mounted throughout, so screen readers hear the first selection. */}\n <span\n className=\"ds-collection-view__selected\"\n role=\"status\"\n >\n {selected && `${selection!.count} selected`}\n </span>\n {!selected && (\n <>\n <span\n ref={titleRef}\n className=\"ds-table-toolbar__title\"\n tabIndex={-1}\n >\n {title}\n </span>\n <Badge\n shape=\"count\"\n appearance=\"soft\"\n isCountExact\n className=\"ds-collection-view__count\"\n >\n {count}\n </Badge>\n </>\n )}\n </>\n }\n end={\n selected ? (\n <>\n {selection!.reason && (\n <span className=\"ds-collection-view__reason\">{selection!.reason}</span>\n )}\n {selection!.actions}\n <Button\n size=\"sm\"\n variant=\"simple\"\n isDisabled={selection!.isPending}\n onClick={selection!.onClear}\n >\n Clear\n </Button>\n </>\n ) : (\n <CollectionFilters\n title={title}\n query={query}\n onQueryChange={onQueryChange}\n filter={filter}\n mine={mine}\n view={view}\n actions={actions}\n />\n )\n }\n />\n );\n}\n","import { TableEmpty, type TableEmptyProps } from \"../Table\";\nimport type { CollectionEmptyKind } from \"./types\";\n\nexport interface CollectionEmptyProps extends Pick<\n TableEmptyProps,\n \"icon\" | \"description\" | \"action\"\n> {\n kind: CollectionEmptyKind;\n /** Plural noun for the no-match title, e.g. \"entries\". */\n noun: string;\n /** Shown when the collection itself has no items. */\n title: string;\n}\n\n/**\n * What a searchable collection's frame shows instead of its table: how to\n * start an empty collection, or a pointer back to the search field.\n */\nexport function CollectionEmpty({\n kind,\n noun,\n icon,\n title,\n description,\n action,\n}: CollectionEmptyProps) {\n if (kind === \"no-match\") {\n return (\n <TableEmpty\n icon=\"search\"\n title={`No matching ${noun}`}\n description=\"Try a different search or clear a filter.\"\n />\n );\n }\n return (\n <TableEmpty\n icon={icon}\n title={title}\n description={description}\n action={action}\n />\n );\n}\n","import { Pagination } from \"../Pagination\";\nimport { TableFrame } from \"../Table\";\nimport { CollectionToolbar } from \"./toolbar\";\nimport { LoadState } from \"../LoadState\";\nimport type { CollectionViewProps } from \"./types\";\nimport \"./style.css\";\nexport type { CollectionViewProps, CollectionEmptyKind } from \"./types\";\nexport { CollectionEmpty } from \"./empty\";\nexport type { CollectionEmptyProps } from \"./empty\";\n\nexport function CollectionView({\n title,\n count,\n query,\n onQueryChange,\n status,\n error,\n onRetry,\n pagination,\n filter,\n mine,\n view,\n selection,\n actions,\n children,\n}: CollectionViewProps) {\n return (\n <TableFrame\n className=\"ds-collection-view\"\n aria-busy={status === \"loading\" || selection?.isPending || undefined}\n >\n <CollectionToolbar\n title={title}\n count={count}\n query={query}\n onQueryChange={onQueryChange}\n filter={filter}\n mine={mine}\n view={view}\n selection={selection}\n actions={actions}\n />\n <div\n className=\"ds-collection-view__body\"\n data-feedback={status !== \"ready\" || undefined}\n >\n <LoadState\n status={status}\n error={error}\n onRetry={onRetry}\n >\n {children}\n </LoadState>\n </div>\n <div className=\"ds-collection-view__footer\">\n {/* Paging stays live while a page loads: disabling the pressed Next or\n Previous button would drop its focus on every page change. */}\n <Pagination\n size=\"md\"\n menuPlacement=\"top\"\n {...pagination}\n isDisabled={pagination.isDisabled || selection?.isPending}\n />\n </div>\n </TableFrame>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAYA,SAAgBK,EAAkB,EAChC,UACA,UACA,kBACA,WACA,SACA,SACA,cACe;CACf,OACE,kBAAAL,GAAA,EAAA,UAAA;EACE,kBAACM,GAAD;GACE,MAAK;GACL,WAAW;GACX,aAAa,UAAUC,EAAM,YAAY;GACzC,cAAY,UAAUA,EAAM,YAAY;GACxC,OAAOC;GACP,WAAW,MAAUC,EAAcC,EAAM,OAAO,KAAK;GACrD,eAAeD,EAAc,EAAE;EAChC,CAAA;EACAE,KACC,kBAAC,OAAD;GAAK,WAAU;GACb,UAAA,kBAACC,GAAD;IACE,MAAK;IACL,cAAYD,EAAO;IACnB,OAAOA,EAAO;IACd,SAASA,EAAO;IAChB,eAAeA,EAAO;GACvB,CAAA;EACE,CAAA;EAENE,KACC,kBAACC,GAAD;GACE,MAAK;GACL,WAAU;GACV,SAASD,EAAK,YAAY,WAAW;GACrC,gBAAcA,EAAK;GACnB,eAAeA,EAAK,SAAS,CAACA,EAAK,SAAS;GAE3C,UAAAA,EAAK;EACA,CAAA;EAETE,KACC,kBAACC,GAAD;GAAa,cAAY,GAAGT,EAAM;GAAlC,UAAA,CACE,kBAACO,GAAD;IACE,MAAK;IACL,YAAA;IACA,WAAU;IACV,cAAW;IACX,gBAAcC,EAAK,UAAU;IAC7B,SAASA,EAAK,UAAU,SAAS,WAAW;IAC5C,eAAeA,EAAK,SAAS,MAAM;GACpC,CAAA,GACD,kBAACD,G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Aa,CAAA;GAEvEA,EAAW;GACZ,kBAACN,GAAD;IACE,MAAK;IACL,SAAQ;IACR,YAAYM,EAAW;IACvB,SAASA,EAAW;IACrB,UAAA;GAEO,CAAA;EACR,EAAA,CAAA,IAEF,kBAACf,GAAD;GACS;GACA;GACQ;GACP;GACF;GACA;GACG;EACV,CAAA;CAGN,CAAA;AAEL;;;AClGA,SAAgBwB,EAAgB,EAC9B,SACA,SACA,SACA,UACA,gBACA,aACuB;CAUvB,OATIC,MAAS,aAET,kBAACC,GAAD;EACE,MAAK;EACL,OAAO,eAAeC;EACtB,aAAY;CACb,CAAA,IAIH,kBAACD,GAAD;EACQ;EACC;EACM;EACL;CACT,CAAA;AAEL;;;ACjCA,SAAgBE,EAAe,EAC7B,UACA,UACA,UACA,kBACA,WACA,UACA,YACA,eACA,WACA,SACA,SACA,cACA,YACA,eACsB;CACtB,OACE,kBAACC,GAAD;EACE,WAAU;EACV,aAAWC,MAAW,aAAaf,GAAW,aAAa,KAAA;EAF7D,UAAA;GAIE,kBAACF,GAAD;IACS;IACA;IACA;IACQ;IACP;IACF;IACA;IACK;IACF;GACV,CAAA;GACD,kBAAC,OAAD;IACE,WAAU;IACV,iBAAeiB,MAAW,WAAW,KAAA;IAErC,UAAA,kBAAChC,GAAD;KACU;KACD;KACE;KAER;IACQ,CAAA;GACR,CAAA;GACL,kBAAC,OAAD;IAAK,WAAU;IAGb,UAAA,kBAACiC,GAAD;KACE,MAAK;KACL,eAAc;KACd,GAAIC;KACJ,YAAYA,EAAW,cAAcjB,GAAW;IACjD,CAAA;GACE,CAAA;EACK;;AAEhB"}
|
|
1
|
+
{"version":3,"file":"CollectionView-Vj84E26b.js","names":["_Fragment","_Fragment","cannotHoldFocus","LoadState","Fragment$1","CollectionFilters","SearchField","title","query","onQueryChange","event","filter","Select","mine","Button","view","ButtonGroup","actions","CollectionToolbar","selected","selection","titleRef","useRef","focused","useEffect","previous","TableToolbar","Badge","count","CollectionEmpty","kind","TableEmpty","noun","CollectionView","TableFrame","status","Pagination","pagination"],"sources":["../../src/components/CollectionView/filters.tsx","../../src/components/CollectionView/toolbar.tsx","../../src/components/CollectionView/empty.tsx","../../src/components/CollectionView/index.tsx"],"sourcesContent":["import { Button } from \"../Button\";\nimport { ButtonGroup } from \"../ButtonGroup\";\nimport { SearchField } from \"../SearchField\";\nimport { Select } from \"../Select\";\nimport type { CollectionViewProps } from \"./types\";\n\ntype FiltersProps = Pick<\n CollectionViewProps,\n \"title\" | \"query\" | \"onQueryChange\" | \"filter\" | \"mine\" | \"view\" | \"actions\"\n>;\n\n/** Search and view controls for a collection without an active selection. */\nexport function CollectionFilters({\n title,\n query,\n onQueryChange,\n filter,\n mine,\n view,\n actions,\n}: FiltersProps) {\n return (\n <>\n <SearchField\n size=\"sm\"\n maxLength={200}\n placeholder={`Search ${title.toLowerCase()}`}\n aria-label={`Search ${title.toLowerCase()}`}\n value={query}\n onChange={(event) => onQueryChange(event.target.value)}\n onClear={() => onQueryChange(\"\")}\n />\n {filter && (\n <div className=\"ds-collection-view__filter\">\n <Select\n size=\"sm\"\n aria-label={filter.label}\n value={filter.value}\n options={filter.options}\n onValueChange={filter.onChange}\n />\n </div>\n )}\n {mine && (\n <Button\n size=\"sm\"\n iconStart=\"user\"\n variant={mine.isPressed ? \"active\" : \"neutral\"}\n aria-pressed={mine.isPressed}\n onClick={() => mine.onChange(!mine.isPressed)}\n >\n {mine.label}\n </Button>\n )}\n {view && (\n <ButtonGroup aria-label={`${title} view`}>\n <Button\n size=\"sm\"\n isIconOnly\n iconStart=\"layout-grid\"\n aria-label=\"Grid view\"\n aria-pressed={view.value === \"grid\"}\n variant={view.value === \"grid\" ? \"active\" : \"neutral\"}\n onClick={() => view.onChange(\"grid\")}\n />\n <Button\n size=\"sm\"\n isIconOnly\n iconStart=\"list\"\n aria-label=\"Table view\"\n aria-pressed={view.value === \"table\"}\n variant={view.value === \"table\" ? \"active\" : \"neutral\"}\n onClick={() => view.onChange(\"table\")}\n />\n </ButtonGroup>\n )}\n {actions}\n </>\n );\n}\n","import { useEffect, useRef } from \"react\";\nimport { Badge } from \"../Badge\";\nimport { Button } from \"../Button\";\nimport { TableToolbar } from \"../Table\";\nimport { cannotHoldFocus } from \"../../internal/dialogFocus\";\nimport type { CollectionViewProps } from \"./types\";\nimport { CollectionFilters } from \"./filters\";\ntype ToolbarProps = Pick<\n CollectionViewProps,\n | \"title\"\n | \"count\"\n | \"query\"\n | \"onQueryChange\"\n | \"filter\"\n | \"mine\"\n | \"view\"\n | \"selection\"\n | \"actions\"\n>;\nexport function CollectionToolbar({\n title,\n count,\n query,\n onQueryChange,\n filter,\n mine,\n view,\n selection,\n actions,\n}: ToolbarProps) {\n const selected = Boolean(selection?.count);\n const titleRef = useRef<HTMLSpanElement>(null);\n // The toolbar control holding focus. A blur toward the page or a removal\n // keeps it, so the selection ending can tell that it took focus away.\n const focused = useRef<Element | null>(null);\n useEffect(() => {\n const previous = focused.current;\n // Clear, or a selection action, unmounted with focus: return it to the\n // collection's title rather than leave it on the page.\n if (!selected && previous && !previous.isConnected && cannotHoldFocus(document.activeElement)) {\n focused.current = null;\n titleRef.current?.focus({ preventScroll: true });\n }\n }, [selected]);\n return (\n <TableToolbar\n className=\"ds-collection-view__toolbar\"\n data-selected={selected || undefined}\n onFocus={(event) => {\n focused.current = event.target;\n }}\n onBlur={(event) => {\n if (event.relatedTarget) {\n focused.current = null;\n }\n }}\n start={\n <>\n {/* Mounted throughout, so screen readers hear the first selection. */}\n <span\n className=\"ds-collection-view__selected\"\n role=\"status\"\n >\n {selected && `${selection!.count} selected`}\n </span>\n {!selected && (\n <>\n <span\n ref={titleRef}\n className=\"ds-table-toolbar__title\"\n tabIndex={-1}\n >\n {title}\n </span>\n <Badge\n shape=\"count\"\n appearance=\"soft\"\n isCountExact\n className=\"ds-collection-view__count\"\n >\n {count}\n </Badge>\n </>\n )}\n </>\n }\n end={\n selected ? (\n <>\n {selection!.reason && (\n <span className=\"ds-collection-view__reason\">{selection!.reason}</span>\n )}\n {selection!.actions}\n <Button\n size=\"sm\"\n variant=\"simple\"\n isDisabled={selection!.isPending}\n onClick={selection!.onClear}\n >\n Clear\n </Button>\n </>\n ) : (\n <CollectionFilters\n title={title}\n query={query}\n onQueryChange={onQueryChange}\n filter={filter}\n mine={mine}\n view={view}\n actions={actions}\n />\n )\n }\n />\n );\n}\n","import { TableEmpty, type TableEmptyProps } from \"../Table\";\nimport type { CollectionEmptyKind } from \"./types\";\n\nexport interface CollectionEmptyProps extends Pick<\n TableEmptyProps,\n \"icon\" | \"description\" | \"action\"\n> {\n kind: CollectionEmptyKind;\n /** Plural noun for the no-match title, e.g. \"entries\". */\n noun: string;\n /** Shown when the collection itself has no items. */\n title: string;\n}\n\n/**\n * What a searchable collection's frame shows instead of its table: how to\n * start an empty collection, or a pointer back to the search field.\n */\nexport function CollectionEmpty({\n kind,\n noun,\n icon,\n title,\n description,\n action,\n}: CollectionEmptyProps) {\n if (kind === \"no-match\") {\n return (\n <TableEmpty\n icon=\"search\"\n title={`No matching ${noun}`}\n description=\"Try a different search or clear a filter.\"\n />\n );\n }\n return (\n <TableEmpty\n icon={icon}\n title={title}\n description={description}\n action={action}\n />\n );\n}\n","import { Pagination } from \"../Pagination\";\nimport { TableFrame } from \"../Table\";\nimport { CollectionToolbar } from \"./toolbar\";\nimport { LoadState } from \"../LoadState\";\nimport type { CollectionViewProps } from \"./types\";\nimport \"./style.css\";\nexport type { CollectionViewProps, CollectionEmptyKind } from \"./types\";\nexport { CollectionEmpty } from \"./empty\";\nexport type { CollectionEmptyProps } from \"./empty\";\n\nexport function CollectionView({\n title,\n count,\n query,\n onQueryChange,\n status,\n error,\n onRetry,\n pagination,\n filter,\n mine,\n view,\n selection,\n actions,\n children,\n}: CollectionViewProps) {\n return (\n <TableFrame\n className=\"ds-collection-view\"\n aria-busy={status === \"loading\" || selection?.isPending || undefined}\n >\n <CollectionToolbar\n title={title}\n count={count}\n query={query}\n onQueryChange={onQueryChange}\n filter={filter}\n mine={mine}\n view={view}\n selection={selection}\n actions={actions}\n />\n <div\n className=\"ds-collection-view__body\"\n data-feedback={status !== \"ready\" || undefined}\n >\n <LoadState\n status={status}\n error={error}\n onRetry={onRetry}\n >\n {children}\n </LoadState>\n </div>\n <div className=\"ds-collection-view__footer\">\n {/* Paging stays live while a page loads: disabling the pressed Next or\n Previous button would drop its focus on every page change. */}\n <Pagination\n size=\"md\"\n menuPlacement=\"top\"\n {...pagination}\n isDisabled={pagination.isDisabled || selection?.isPending}\n />\n </div>\n </TableFrame>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAYA,SAAgBK,EAAkB,EAChC,UACA,UACA,kBACA,WACA,SACA,SACA,cACe;CACf,OACE,kBAAAL,GAAA,EAAA,UAAA;EACE,kBAACM,GAAD;GACE,MAAK;GACL,WAAW;GACX,aAAa,UAAUC,EAAM,YAAY;GACzC,cAAY,UAAUA,EAAM,YAAY;GACxC,OAAOC;GACP,WAAW,MAAUC,EAAcC,EAAM,OAAO,KAAK;GACrD,eAAeD,EAAc,EAAE;EAChC,CAAA;EACAE,KACC,kBAAC,OAAD;GAAK,WAAU;GACb,UAAA,kBAACC,GAAD;IACE,MAAK;IACL,cAAYD,EAAO;IACnB,OAAOA,EAAO;IACd,SAASA,EAAO;IAChB,eAAeA,EAAO;GACvB,CAAA;EACE,CAAA;EAENE,KACC,kBAACC,GAAD;GACE,MAAK;GACL,WAAU;GACV,SAASD,EAAK,YAAY,WAAW;GACrC,gBAAcA,EAAK;GACnB,eAAeA,EAAK,SAAS,CAACA,EAAK,SAAS;GAE3C,UAAAA,EAAK;EACA,CAAA;EAETE,KACC,kBAACC,GAAD;GAAa,cAAY,GAAGT,EAAM;GAAlC,UAAA,CACE,kBAACO,GAAD;IACE,MAAK;IACL,YAAA;IACA,WAAU;IACV,cAAW;IACX,gBAAcC,EAAK,UAAU;IAC7B,SAASA,EAAK,UAAU,SAAS,WAAW;IAC5C,eAAeA,EAAK,SAAS,MAAM;GACpC,CAAA,GACD,kBAACD,G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