@manakind/ui-core 0.34.0 → 0.35.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 +4 -0
- package/dist/dialog/dialog.d.ts.map +1 -1
- package/dist/dialog/dialog.js +4 -14
- package/dist/dialog/dialog.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/nav-list/index.d.ts +3 -0
- package/dist/nav-list/index.d.ts.map +1 -0
- package/dist/nav-list/index.js +2 -0
- package/dist/nav-list/index.js.map +1 -0
- package/dist/nav-list/nav-list.css +148 -0
- package/dist/nav-list/nav-list.css.d.ts +2 -0
- package/dist/nav-list/nav-list.d.ts +83 -0
- package/dist/nav-list/nav-list.d.ts.map +1 -0
- package/dist/nav-list/nav-list.js +50 -0
- package/dist/nav-list/nav-list.js.map +1 -0
- package/dist/scroll-area/scroll-area.css +12 -0
- package/dist/scroll-area/scroll-area.d.ts +6 -4
- package/dist/scroll-area/scroll-area.d.ts.map +1 -1
- package/dist/scroll-area/scroll-area.js +22 -2
- package/dist/scroll-area/scroll-area.js.map +1 -1
- package/dist/status-dot/index.d.ts +3 -0
- package/dist/status-dot/index.d.ts.map +1 -0
- package/dist/status-dot/index.js +2 -0
- package/dist/status-dot/index.js.map +1 -0
- package/dist/status-dot/status-dot.css +70 -0
- package/dist/status-dot/status-dot.css.d.ts +2 -0
- package/dist/status-dot/status-dot.d.ts +36 -0
- package/dist/status-dot/status-dot.d.ts.map +1 -0
- package/dist/status-dot/status-dot.js +19 -0
- package/dist/status-dot/status-dot.js.map +1 -0
- package/dist/table/table.d.ts +5 -3
- package/dist/table/table.d.ts.map +1 -1
- package/dist/table/table.js.map +1 -1
- package/dist/use-overflow.d.ts +21 -0
- package/dist/use-overflow.d.ts.map +1 -0
- package/dist/use-overflow.js +66 -0
- package/dist/use-overflow.js.map +1 -0
- package/package.json +18 -2
package/README.md
CHANGED
|
@@ -70,6 +70,7 @@ separately, so an app can load only what it renders.
|
|
|
70
70
|
| `@manakind/ui-core/icon` | `Icon` |
|
|
71
71
|
| `@manakind/ui-core/illustration` | `Illustration` + `illustrationPaint` |
|
|
72
72
|
| `@manakind/ui-core/menu` | `Menu`, `MenuTrigger`, `ActionMenu`; `MenuItem.icon` adds a decorative glyph before its label |
|
|
73
|
+
| `@manakind/ui-core/nav-list` | `NavList` + `NavListItem`; links to a section's places with the current one marked, a count per item, and a sideways row below a viewport step |
|
|
73
74
|
| `@manakind/ui-core/popover` | `Popover` |
|
|
74
75
|
| `@manakind/ui-core/checkbox` | `Checkbox` |
|
|
75
76
|
| `@manakind/ui-core/combobox` | `Combobox`; `ComboboxItem.group` collects options under named headings, with keyboard navigation in displayed order; `toolbar`, `status` and `facets` put filters, a status line and a pinnable facet column inside the open list |
|
|
@@ -92,6 +93,7 @@ separately, so an app can load only what it renders.
|
|
|
92
93
|
| `@manakind/ui-core/spinner` | `Spinner` |
|
|
93
94
|
| `@manakind/ui-core/radio-group` | `RadioGroup` |
|
|
94
95
|
| `@manakind/ui-core/scroll-area` | `ScrollArea` |
|
|
96
|
+
| `@manakind/ui-core/status-dot` | `StatusDot`; a dot that marks something unread, live or new, with its meaning in words for assistive technology |
|
|
95
97
|
| `@manakind/ui-core/sticky` | `Sticky` |
|
|
96
98
|
| `@manakind/ui-core/empty-state` | `EmptyState` |
|
|
97
99
|
| `@manakind/ui-core/page-layout` | `PageLayout`, `PageHeader`, `PageTitle`, `PageDescription`, `PageActions` |
|
|
@@ -115,6 +117,7 @@ separately, so an app can load only what it renders.
|
|
|
115
117
|
| `@manakind/ui-core/css/icon` | Icon structural CSS |
|
|
116
118
|
| `@manakind/ui-core/css/illustration` | Illustration structural CSS, including the paint roles |
|
|
117
119
|
| `@manakind/ui-core/css/menu` | Menu and ActionMenu structural CSS; an ActionMenu's glyphs also need `css/icon` |
|
|
120
|
+
| `@manakind/ui-core/css/nav-list` | NavList structural CSS; a count's noun also needs `css/visually-hidden` |
|
|
118
121
|
| `@manakind/ui-core/css/popover` | Popover structural CSS |
|
|
119
122
|
| `@manakind/ui-core/css/checkbox` | Checkbox structural CSS |
|
|
120
123
|
| `@manakind/ui-core/css/combobox` | Combobox structural CSS; its pin and chip-remove captions also need `css/tooltip` |
|
|
@@ -137,6 +140,7 @@ separately, so an app can load only what it renders.
|
|
|
137
140
|
| `@manakind/ui-core/css/spinner` | Spinner structural CSS; its label also needs `css/visually-hidden` |
|
|
138
141
|
| `@manakind/ui-core/css/radio-group` | RadioGroup structural CSS |
|
|
139
142
|
| `@manakind/ui-core/css/scroll-area` | ScrollArea structural CSS |
|
|
143
|
+
| `@manakind/ui-core/css/status-dot` | StatusDot structural CSS; its label also needs `css/visually-hidden` |
|
|
140
144
|
| `@manakind/ui-core/css/sticky` | Sticky structural CSS |
|
|
141
145
|
| `@manakind/ui-core/css/empty-state` | EmptyState structural CSS; its glyph also needs `css/icon` |
|
|
142
146
|
| `@manakind/ui-core/css/page-layout` | PageLayout structural CSS; its title and description also need `css/text` |
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../../src/dialog/dialog.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,SAAS,EAMf,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/C,OAAO,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../../src/dialog/dialog.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,SAAS,EAMf,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/C,OAAO,cAAc,CAAC;AAKtB,MAAM,MAAM,UAAU,GAAG,QAAQ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OAAO,EACP,OAAO,EACP,IAAI,EACJ,WAAW,EACX,YAAY,EACZ,IAAe,EACf,eAAe,EACf,aAAa,EACb,UAAoB,EACpB,SAAS,EAAE,aAAa,EACxB,IAAW,EACX,YAAsB,EACtB,SAAS,GACV,EAAE,WAAW,2CAgHb"}
|
package/dist/dialog/dialog.js
CHANGED
|
@@ -9,6 +9,7 @@ import { SidePanelSlotContext } from '../side-panel-layout/side-panel-context';
|
|
|
9
9
|
import './dialog.css';
|
|
10
10
|
import { cx } from '../cx';
|
|
11
11
|
import { useIconDefaults } from '../icon-defaults';
|
|
12
|
+
import { useOverflow } from '../use-overflow';
|
|
12
13
|
/**
|
|
13
14
|
* A modal dialog: a raised panel over a dimmed page, built on Ark UI.
|
|
14
15
|
*
|
|
@@ -126,22 +127,11 @@ function SidePanelSeat({ claim, panel, triggerRef, finalFocusRef, }) {
|
|
|
126
127
|
/**
|
|
127
128
|
* The scrolling body. While its content overflows it joins the tab order, so
|
|
128
129
|
* a keyboard user can focus it and scroll; a body with nothing to scroll
|
|
129
|
-
* stays out of the way
|
|
130
|
-
*
|
|
131
|
-
* Two boxes are observed because either can change the answer: the outer one
|
|
132
|
-
* resizes with the viewport, the inner one with the content.
|
|
130
|
+
* stays out of the way, unless it holds focus as its content comes to fit
|
|
131
|
+
* (`useOverflow` decides both).
|
|
133
132
|
*/
|
|
134
133
|
function DialogBody({ children }) {
|
|
135
|
-
const [
|
|
136
|
-
const observe = useCallback((scroller) => {
|
|
137
|
-
const content = scroller?.firstElementChild;
|
|
138
|
-
if (!scroller || !content)
|
|
139
|
-
return;
|
|
140
|
-
const observer = new ResizeObserver(() => setScrollable(scroller.scrollHeight > scroller.clientHeight));
|
|
141
|
-
observer.observe(scroller);
|
|
142
|
-
observer.observe(content);
|
|
143
|
-
return () => observer.disconnect();
|
|
144
|
-
}, []);
|
|
134
|
+
const [observe, scrollable] = useOverflow('y');
|
|
145
135
|
return (_jsx("div", { ref: observe, className: "ds-dialog__body", tabIndex: scrollable ? 0 : undefined, children: _jsx("div", { className: "ds-dialog__body-content", children: children }) }));
|
|
146
136
|
}
|
|
147
137
|
//# sourceMappingURL=dialog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../src/dialog/dialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAIL,WAAW,EACX,UAAU,EACV,eAAe,EACf,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAsB,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AACnG,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AA4GnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,UAAU,MAAM,CAAC,EACrB,KAAK,EACL,WAAW,EACX,QAAQ,EACR,OAAO,EACP,OAAO,EACP,IAAI,EACJ,WAAW,EACX,YAAY,EACZ,IAAI,GAAG,QAAQ,EACf,eAAe,EACf,aAAa,EACb,UAAU,GAAG,OAAO,EACpB,SAAS,EAAE,aAAa,EACxB,IAAI,GAAG,IAAI,EACX,YAAY,GAAG,OAAO,EACtB,SAAS,GACG;IACZ,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAChC,MAAM,SAAS,GAAG,aAAa,IAAI,KAAK,CAAC,KAAK,CAAC;IAC/C,MAAM,WAAW,GAAG,IAAI,KAAK,QAA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;YAAE,OAAO;QAClC,MAAM,QAAQ,GAAG,IAAI,cAAc,CAAC,GAAG,EAAE,CACvC,aAAa,CAAC,QAAQ,CAAC,YAAY,GAAG,QAAQ,CAAC,YAAY,CAAC,CAC7D,CAAC;QACF,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC3B,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC1B,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IACrC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL,cAAK,GAAG,EAAE,OAAO,EAAE,SAAS,EAAC,iBAAiB,EAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,YACjF,cAAK,SAAS,EAAC,yBAAyB,YAAE,QAAQ,GAAO,GACrD,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { Dialog as ArkDialog, useDialogContext } from '@ark-ui/react/dialog';\nimport { Portal } from '@ark-ui/react/portal';\nimport {\n type ReactElement,\n type ReactNode,\n type RefObject,\n useCallback,\n useContext,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { IconButton } from '../button/icon-button';\nimport type { IconSource } from '../icon/icon';\nimport { PortalContainerContext } from '../portal-container';\nimport { type SidePanelSlot, SidePanelSlotContext } from '../side-panel-layout/side-panel-context';\nimport './dialog.css';\nimport { cx } from '../cx';\nimport { useIconDefaults } from '../icon-defaults';\n\nexport type DialogRole = 'dialog' | 'alertdialog';\n\n/** How wide the panel may grow: a message or short form, or a form with fields side by side. */\nexport type DialogSize = 'md' | 'lg';\n\n/** Over the page with the rest of it shut off, or in a drawer beside it. */\nexport type DialogPresentation = 'modal' | 'side';\n\nexport interface DialogProps {\n /**\n * The dialog's name: rendered as its `<h2>` heading and announced when it\n * opens (`aria-labelledby`). Write it as a short statement or question —\n * \"Remove “Site foreman”?\".\n */\n title: ReactNode;\n /**\n * One or two sentences under the title, announced with it\n * (`aria-describedby`). For a confirmation, say what the action does and\n * what it leaves alone.\n */\n description?: ReactNode;\n /** Body content. Scrolls inside the panel when it outgrows the viewport. */\n children?: ReactNode;\n /**\n * The footer's buttons, end-aligned, in reading order: the dismissive one\n * first, the committing one last. They wrap onto a second line on a narrow\n * screen. Wrap a dismissive button in `DialogClose` to make it close.\n */\n actions?: ReactNode;\n /**\n * The one element that opens the dialog, such as a `Button`. Focus returns\n * to it when the dialog closes, unless `finalFocusRef` names another\n * element. Leave it out to open the dialog with `open` from elsewhere.\n */\n trigger?: ReactElement;\n /** Controlled open state. Pair with `onOpenChange`. */\n open?: boolean;\n /** Initial open state when uncontrolled. */\n defaultOpen?: boolean;\n /**\n * Fired with the requested state whenever the dialog asks to open (its\n * trigger) or close (a `DialogClose`, the close button, Escape, or for\n * `role=\"dialog\"` a click outside). A controlled dialog stays as it is\n * until `open` changes.\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * `dialog` (default) shows a close button and closes on Escape and on a\n * click outside. `alertdialog` is for confirmations: no close button, and a\n * click outside does nothing, so the explicit cancel action is the way\n * out. Escape still cancels.\n */\n role?: DialogRole;\n /**\n * Where focus lands when the dialog opens. Defaults to the first focusable\n * element: the close button of a `dialog`, the first action of an\n * `alertdialog` with no focusable body. Point an alertdialog at its least\n * destructive action.\n */\n initialFocusRef?: RefObject<HTMLElement | null>;\n /**\n * Where focus lands when the dialog closes, in place of the trigger. Use it\n * when the confirmed action removes the trigger, such as a row's Remove\n * button: focus would return to an element that is about to unmount and\n * fall to the page body. Point it at something that stays, such as the\n * list's heading, which needs `tabIndex={-1}` to take focus.\n *\n * The ref is read as the dialog closes, however it closes. Fill it in the\n * committing action, so Cancel and Escape still return focus to the\n * trigger, which is still there. While the ref holds no element, focus\n * returns to the trigger as usual.\n */\n finalFocusRef?: RefObject<HTMLElement | null>;\n /** Accessible name of the close button. Translate it with the rest of the UI. */\n closeLabel?: string;\n /**\n * Glyph for the close button. Defaults to the `IconDefaultsProvider`'s\n * `cross`, or a plain built-in one.\n */\n closeIcon?: IconSource;\n /**\n * How wide the panel may grow: `md` (the default) for a message or a short\n * form, `lg` for a form with fields side by side.\n */\n size?: DialogSize;\n /**\n * `modal` (the default) floats the panel over a dimmed page. `side` opens\n * it in the drawer of the nearest `SidePanelLayout`, beside the content,\n * which stays in view and usable: a form for one item of a list the user\n * may want to browse while filling it in. A side panel traps no focus,\n * locks no scroll and stays open on a click outside. Escape closes it\n * while focus is in it or on no control, and leaves an Escape pressed on a\n * control in the page to that control. On close, focus returns as from a\n * modal unless the user had moved it onto the page. It is as wide as a `md` dialog, so `size`\n * does not apply. Opening another side dialog in the layout closes this\n * one through `onOpenChange`; a controlled dialog should honour it.\n *\n * Outside a `SidePanelLayout`, for `role=\"alertdialog\"`, which must hold\n * the user until they answer, and inside another dialog, the dialog opens\n * as a modal.\n */\n presentation?: DialogPresentation;\n /** Extra class names appended to the panel's `ds-dialog`. */\n className?: string;\n}\n\n/**\n * A modal dialog: a raised panel over a dimmed page, built on Ark UI.\n *\n * Ark owns the behaviour: the focus trap, focus returning to the trigger\n * (or to `finalFocusRef`), Escape, the page's scroll lock, `aria-modal`, and the title and\n * description wiring. This wrapper adds the `ds-` classes, the\n * `--ds-dialog-*` bindings, and a slot API in place of Ark's anatomy.\n *\n * ```tsx\n * <Dialog\n * role=\"alertdialog\"\n * title=\"Remove “Site foreman”?\"\n * description=\"2 people and 1 Landfall lose this type; nothing else is deleted.\"\n * trigger={<Button variant=\"secondary\">Remove</Button>}\n * initialFocusRef={cancelRef}\n * actions={\n * <>\n * <DialogClose>\n * <Button ref={cancelRef} variant=\"secondary\">Cancel</Button>\n * </DialogClose>\n * <Button variant=\"danger\" onClick={remove}>Remove</Button>\n * </>\n * }\n * />\n * ```\n *\n * The committing action is the consumer's own button. To close after it\n * runs, control the dialog with `open` and set it false in the handler, or\n * wrap the button in `DialogClose` when closing at once is right.\n *\n * The backdrop and panel portal into `<body>` at `z-index: 50`, the layer\n * the product apps use for their own overlays. A Select or Menu inside the\n * dialog portals into its panel (see `PortalContainerContext`) and opens at\n * 60, above it. Nothing is mounted while the dialog is closed.\n */\nexport function Dialog({\n title,\n description,\n children,\n actions,\n trigger,\n open,\n defaultOpen,\n onOpenChange,\n role = 'dialog',\n initialFocusRef,\n finalFocusRef,\n closeLabel = 'Close',\n closeIcon: closeIconProp,\n size = 'md',\n presentation = 'modal',\n className,\n}: DialogProps) {\n const icons = useIconDefaults();\n const closeIcon = closeIconProp ?? icons.cross;\n const dismissible = role === 'dialog';\n const slot = useContext(SidePanelSlotContext);\n const side = presentation === 'side' && dismissible && slot ? slot : undefined;\n const panelRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const [sidePanel, setSidePanel] = useState<HTMLDivElement | null>(null);\n const sidePanelRef = useCallback((element: HTMLDivElement | null) => {\n panelRef.current = element;\n setSidePanel(element);\n }, []);\n const handleOpenChange = (details: { open: boolean }) => onOpenChange?.(details.open);\n // Zag types this as returning `HTMLElement | null`, but its focus trap\n // reads undefined as \"the first focusable element\" and, given null, fails\n // to start at all, leaving the page reachable by Tab.\n const initialFocusEl = (() => initialFocusRef?.current ?? undefined) as () => HTMLElement | null;\n const finalFocusEl = () => finalFocusRef?.current ?? null;\n // Zag's dismiss layer takes Escape anywhere in the document. A side panel\n // leaves the page usable, so an Escape meant for a control on the page,\n // such as a ReorderControl dropping its draft, must not close it too.\n const keepEscapeOnThePage = (event: KeyboardEvent) => {\n const target = event.target;\n const onThePage =\n target instanceof Node &&\n target !== target.ownerDocument?.body &&\n !panelRef.current?.contains(target);\n if (onThePage) event.preventDefault();\n };\n const panel = (\n <PortalContainerContext.Provider value={panelRef}>\n <div className=\"ds-dialog__header\">\n <div className=\"ds-dialog__heading\">\n <ArkDialog.Title className=\"ds-dialog__title\">{title}</ArkDialog.Title>\n {description && (\n <ArkDialog.Description className=\"ds-dialog__description\">\n {description}\n </ArkDialog.Description>\n )}\n </div>\n {dismissible && (\n <ArkDialog.CloseTrigger asChild>\n <IconButton\n icon={closeIcon}\n aria-label={closeLabel}\n variant=\"tertiary\"\n size=\"sm\"\n className=\"ds-dialog__close\"\n />\n </ArkDialog.CloseTrigger>\n )}\n </div>\n {children && <DialogBody>{children}</DialogBody>}\n {actions && <div className=\"ds-dialog__actions\">{actions}</div>}\n </PortalContainerContext.Provider>\n );\n const content = (\n <SidePanelSlotContext.Provider value={undefined}>{panel}</SidePanelSlotContext.Provider>\n );\n\n return (\n <ArkDialog.Root\n open={open}\n defaultOpen={defaultOpen}\n onOpenChange={handleOpenChange}\n role={role}\n modal={!side}\n closeOnInteractOutside={dismissible && !side}\n onEscapeKeyDown={side ? keepEscapeOnThePage : undefined}\n initialFocusEl={initialFocusEl}\n finalFocusEl={finalFocusEl}\n lazyMount\n unmountOnExit\n >\n {trigger && (\n <ArkDialog.Trigger ref={triggerRef} asChild>\n {trigger}\n </ArkDialog.Trigger>\n )}\n {side ? (\n side.container &&\n createPortal(\n <ArkDialog.Content\n ref={sidePanelRef}\n className={cx('ds-dialog', 'ds-dialog--side', className)}\n >\n <SidePanelSeat\n claim={side.claim}\n panel={sidePanel}\n triggerRef={triggerRef}\n finalFocusRef={finalFocusRef}\n />\n {content}\n </ArkDialog.Content>,\n side.container,\n )\n ) : (\n <Portal>\n <ArkDialog.Backdrop className=\"ds-dialog__backdrop\" />\n <ArkDialog.Positioner className=\"ds-dialog__positioner\">\n <ArkDialog.Content\n ref={panelRef}\n className={cx('ds-dialog', size === 'lg' && 'ds-dialog--lg', className)}\n >\n {content}\n </ArkDialog.Content>\n </ArkDialog.Positioner>\n </Portal>\n )}\n </ArkDialog.Root>\n );\n}\n\n/**\n * What a side panel needs that Ark leaves to a modal's focus trap: the slot,\n * taken on open so any other panel closes; the panel scrolled into view,\n * since below the `lg` step it sits above the content in the page's flow;\n * and focus put back on close. Focus moves when it was inside the panel or\n * on nothing, as after a save whose button disabled itself and so dropped\n * focus, so closing the panel never pulls the user out of the list they\n * moved to but never leaves them on the page's body either.\n * It goes where the trap would send it: `finalFocusRef`'s element, else the\n * trigger, else what had focus when the panel opened. The trigger is named\n * outright because Safari does not focus a button on click.\n *\n * The panel arrives as state from its callback ref: a child's layout effect\n * runs before its parent's ref is attached. A layout effect, because its\n * cleanup runs while the panel is still in the document and can still hold\n * focus, and before Ark moves focus into the panel a frame after it opens.\n * It runs once per opening: the callbacks and refs it reads at close are\n * kept current beside it, so a re-render never closes and reopens the seat.\n */\nfunction SidePanelSeat({\n claim,\n panel,\n triggerRef,\n finalFocusRef,\n}: {\n claim: SidePanelSlot['claim'];\n panel: HTMLDivElement | null;\n triggerRef: RefObject<HTMLElement | null>;\n finalFocusRef?: RefObject<HTMLElement | null>;\n}) {\n const dialog = useDialogContext();\n const latest = useRef({ setOpen: dialog.setOpen, finalFocusRef });\n useLayoutEffect(() => {\n latest.current = { setOpen: dialog.setOpen, finalFocusRef };\n });\n\n useLayoutEffect(() => {\n if (!panel) return;\n const opener = panel.ownerDocument.activeElement;\n const release = claim(() => latest.current.setOpen(false));\n panel.scrollIntoView({ block: 'nearest' });\n return () => {\n release();\n const active = panel.ownerDocument.activeElement;\n const movedToThePage =\n active && active !== panel.ownerDocument.body && !panel.contains(active);\n if (movedToThePage) return;\n const target = [latest.current.finalFocusRef?.current, triggerRef.current, opener].find(\n (element) => element instanceof HTMLElement && element.isConnected,\n );\n if (target instanceof HTMLElement) target.focus();\n };\n }, [claim, panel, triggerRef]);\n\n return null;\n}\n\n/**\n * The scrolling body. While its content overflows it joins the tab order, so\n * a keyboard user can focus it and scroll; a body with nothing to scroll\n * stays out of the way.\n *\n * Two boxes are observed because either can change the answer: the outer one\n * resizes with the viewport, the inner one with the content.\n */\nfunction DialogBody({ children }: { children: ReactNode }) {\n const [scrollable, setScrollable] = useState(false);\n const observe = useCallback((scroller: HTMLDivElement | null) => {\n const content = scroller?.firstElementChild;\n if (!scroller || !content) return;\n const observer = new ResizeObserver(() =>\n setScrollable(scroller.scrollHeight > scroller.clientHeight),\n );\n observer.observe(scroller);\n observer.observe(content);\n return () => observer.disconnect();\n }, []);\n\n return (\n <div ref={observe} className=\"ds-dialog__body\" tabIndex={scrollable ? 0 : undefined}>\n <div className=\"ds-dialog__body-content\">{children}</div>\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../src/dialog/dialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAIL,WAAW,EACX,UAAU,EACV,eAAe,EACf,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAsB,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AACnG,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AA4G9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,UAAU,MAAM,CAAC,EACrB,KAAK,EACL,WAAW,EACX,QAAQ,EACR,OAAO,EACP,OAAO,EACP,IAAI,EACJ,WAAW,EACX,YAAY,EACZ,IAAI,GAAG,QAAQ,EACf,eAAe,EACf,aAAa,EACb,UAAU,GAAG,OAAO,EACpB,SAAS,EAAE,aAAa,EACxB,IAAI,GAAG,IAAI,EACX,YAAY,GAAG,OAAO,EACtB,SAAS,GACG;IACZ,MAAM,KAAK,GAAG,eAA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E,SAAS,EAAC,iBAAiB,EAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,YACjF,cAAK,SAAS,EAAC,yBAAyB,YAAE,QAAQ,GAAO,GACrD,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { Dialog as ArkDialog, useDialogContext } from '@ark-ui/react/dialog';\nimport { Portal } from '@ark-ui/react/portal';\nimport {\n type ReactElement,\n type ReactNode,\n type RefObject,\n useCallback,\n useContext,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { IconButton } from '../button/icon-button';\nimport type { IconSource } from '../icon/icon';\nimport { PortalContainerContext } from '../portal-container';\nimport { type SidePanelSlot, SidePanelSlotContext } from '../side-panel-layout/side-panel-context';\nimport './dialog.css';\nimport { cx } from '../cx';\nimport { useIconDefaults } from '../icon-defaults';\nimport { useOverflow } from '../use-overflow';\n\nexport type DialogRole = 'dialog' | 'alertdialog';\n\n/** How wide the panel may grow: a message or short form, or a form with fields side by side. */\nexport type DialogSize = 'md' | 'lg';\n\n/** Over the page with the rest of it shut off, or in a drawer beside it. */\nexport type DialogPresentation = 'modal' | 'side';\n\nexport interface DialogProps {\n /**\n * The dialog's name: rendered as its `<h2>` heading and announced when it\n * opens (`aria-labelledby`). Write it as a short statement or question —\n * \"Remove “Site foreman”?\".\n */\n title: ReactNode;\n /**\n * One or two sentences under the title, announced with it\n * (`aria-describedby`). For a confirmation, say what the action does and\n * what it leaves alone.\n */\n description?: ReactNode;\n /** Body content. Scrolls inside the panel when it outgrows the viewport. */\n children?: ReactNode;\n /**\n * The footer's buttons, end-aligned, in reading order: the dismissive one\n * first, the committing one last. They wrap onto a second line on a narrow\n * screen. Wrap a dismissive button in `DialogClose` to make it close.\n */\n actions?: ReactNode;\n /**\n * The one element that opens the dialog, such as a `Button`. Focus returns\n * to it when the dialog closes, unless `finalFocusRef` names another\n * element. Leave it out to open the dialog with `open` from elsewhere.\n */\n trigger?: ReactElement;\n /** Controlled open state. Pair with `onOpenChange`. */\n open?: boolean;\n /** Initial open state when uncontrolled. */\n defaultOpen?: boolean;\n /**\n * Fired with the requested state whenever the dialog asks to open (its\n * trigger) or close (a `DialogClose`, the close button, Escape, or for\n * `role=\"dialog\"` a click outside). A controlled dialog stays as it is\n * until `open` changes.\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * `dialog` (default) shows a close button and closes on Escape and on a\n * click outside. `alertdialog` is for confirmations: no close button, and a\n * click outside does nothing, so the explicit cancel action is the way\n * out. Escape still cancels.\n */\n role?: DialogRole;\n /**\n * Where focus lands when the dialog opens. Defaults to the first focusable\n * element: the close button of a `dialog`, the first action of an\n * `alertdialog` with no focusable body. Point an alertdialog at its least\n * destructive action.\n */\n initialFocusRef?: RefObject<HTMLElement | null>;\n /**\n * Where focus lands when the dialog closes, in place of the trigger. Use it\n * when the confirmed action removes the trigger, such as a row's Remove\n * button: focus would return to an element that is about to unmount and\n * fall to the page body. Point it at something that stays, such as the\n * list's heading, which needs `tabIndex={-1}` to take focus.\n *\n * The ref is read as the dialog closes, however it closes. Fill it in the\n * committing action, so Cancel and Escape still return focus to the\n * trigger, which is still there. While the ref holds no element, focus\n * returns to the trigger as usual.\n */\n finalFocusRef?: RefObject<HTMLElement | null>;\n /** Accessible name of the close button. Translate it with the rest of the UI. */\n closeLabel?: string;\n /**\n * Glyph for the close button. Defaults to the `IconDefaultsProvider`'s\n * `cross`, or a plain built-in one.\n */\n closeIcon?: IconSource;\n /**\n * How wide the panel may grow: `md` (the default) for a message or a short\n * form, `lg` for a form with fields side by side.\n */\n size?: DialogSize;\n /**\n * `modal` (the default) floats the panel over a dimmed page. `side` opens\n * it in the drawer of the nearest `SidePanelLayout`, beside the content,\n * which stays in view and usable: a form for one item of a list the user\n * may want to browse while filling it in. A side panel traps no focus,\n * locks no scroll and stays open on a click outside. Escape closes it\n * while focus is in it or on no control, and leaves an Escape pressed on a\n * control in the page to that control. On close, focus returns as from a\n * modal unless the user had moved it onto the page. It is as wide as a `md` dialog, so `size`\n * does not apply. Opening another side dialog in the layout closes this\n * one through `onOpenChange`; a controlled dialog should honour it.\n *\n * Outside a `SidePanelLayout`, for `role=\"alertdialog\"`, which must hold\n * the user until they answer, and inside another dialog, the dialog opens\n * as a modal.\n */\n presentation?: DialogPresentation;\n /** Extra class names appended to the panel's `ds-dialog`. */\n className?: string;\n}\n\n/**\n * A modal dialog: a raised panel over a dimmed page, built on Ark UI.\n *\n * Ark owns the behaviour: the focus trap, focus returning to the trigger\n * (or to `finalFocusRef`), Escape, the page's scroll lock, `aria-modal`, and the title and\n * description wiring. This wrapper adds the `ds-` classes, the\n * `--ds-dialog-*` bindings, and a slot API in place of Ark's anatomy.\n *\n * ```tsx\n * <Dialog\n * role=\"alertdialog\"\n * title=\"Remove “Site foreman”?\"\n * description=\"2 people and 1 Landfall lose this type; nothing else is deleted.\"\n * trigger={<Button variant=\"secondary\">Remove</Button>}\n * initialFocusRef={cancelRef}\n * actions={\n * <>\n * <DialogClose>\n * <Button ref={cancelRef} variant=\"secondary\">Cancel</Button>\n * </DialogClose>\n * <Button variant=\"danger\" onClick={remove}>Remove</Button>\n * </>\n * }\n * />\n * ```\n *\n * The committing action is the consumer's own button. To close after it\n * runs, control the dialog with `open` and set it false in the handler, or\n * wrap the button in `DialogClose` when closing at once is right.\n *\n * The backdrop and panel portal into `<body>` at `z-index: 50`, the layer\n * the product apps use for their own overlays. A Select or Menu inside the\n * dialog portals into its panel (see `PortalContainerContext`) and opens at\n * 60, above it. Nothing is mounted while the dialog is closed.\n */\nexport function Dialog({\n title,\n description,\n children,\n actions,\n trigger,\n open,\n defaultOpen,\n onOpenChange,\n role = 'dialog',\n initialFocusRef,\n finalFocusRef,\n closeLabel = 'Close',\n closeIcon: closeIconProp,\n size = 'md',\n presentation = 'modal',\n className,\n}: DialogProps) {\n const icons = useIconDefaults();\n const closeIcon = closeIconProp ?? icons.cross;\n const dismissible = role === 'dialog';\n const slot = useContext(SidePanelSlotContext);\n const side = presentation === 'side' && dismissible && slot ? slot : undefined;\n const panelRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const [sidePanel, setSidePanel] = useState<HTMLDivElement | null>(null);\n const sidePanelRef = useCallback((element: HTMLDivElement | null) => {\n panelRef.current = element;\n setSidePanel(element);\n }, []);\n const handleOpenChange = (details: { open: boolean }) => onOpenChange?.(details.open);\n // Zag types this as returning `HTMLElement | null`, but its focus trap\n // reads undefined as \"the first focusable element\" and, given null, fails\n // to start at all, leaving the page reachable by Tab.\n const initialFocusEl = (() => initialFocusRef?.current ?? undefined) as () => HTMLElement | null;\n const finalFocusEl = () => finalFocusRef?.current ?? null;\n // Zag's dismiss layer takes Escape anywhere in the document. A side panel\n // leaves the page usable, so an Escape meant for a control on the page,\n // such as a ReorderControl dropping its draft, must not close it too.\n const keepEscapeOnThePage = (event: KeyboardEvent) => {\n const target = event.target;\n const onThePage =\n target instanceof Node &&\n target !== target.ownerDocument?.body &&\n !panelRef.current?.contains(target);\n if (onThePage) event.preventDefault();\n };\n const panel = (\n <PortalContainerContext.Provider value={panelRef}>\n <div className=\"ds-dialog__header\">\n <div className=\"ds-dialog__heading\">\n <ArkDialog.Title className=\"ds-dialog__title\">{title}</ArkDialog.Title>\n {description && (\n <ArkDialog.Description className=\"ds-dialog__description\">\n {description}\n </ArkDialog.Description>\n )}\n </div>\n {dismissible && (\n <ArkDialog.CloseTrigger asChild>\n <IconButton\n icon={closeIcon}\n aria-label={closeLabel}\n variant=\"tertiary\"\n size=\"sm\"\n className=\"ds-dialog__close\"\n />\n </ArkDialog.CloseTrigger>\n )}\n </div>\n {children && <DialogBody>{children}</DialogBody>}\n {actions && <div className=\"ds-dialog__actions\">{actions}</div>}\n </PortalContainerContext.Provider>\n );\n const content = (\n <SidePanelSlotContext.Provider value={undefined}>{panel}</SidePanelSlotContext.Provider>\n );\n\n return (\n <ArkDialog.Root\n open={open}\n defaultOpen={defaultOpen}\n onOpenChange={handleOpenChange}\n role={role}\n modal={!side}\n closeOnInteractOutside={dismissible && !side}\n onEscapeKeyDown={side ? keepEscapeOnThePage : undefined}\n initialFocusEl={initialFocusEl}\n finalFocusEl={finalFocusEl}\n lazyMount\n unmountOnExit\n >\n {trigger && (\n <ArkDialog.Trigger ref={triggerRef} asChild>\n {trigger}\n </ArkDialog.Trigger>\n )}\n {side ? (\n side.container &&\n createPortal(\n <ArkDialog.Content\n ref={sidePanelRef}\n className={cx('ds-dialog', 'ds-dialog--side', className)}\n >\n <SidePanelSeat\n claim={side.claim}\n panel={sidePanel}\n triggerRef={triggerRef}\n finalFocusRef={finalFocusRef}\n />\n {content}\n </ArkDialog.Content>,\n side.container,\n )\n ) : (\n <Portal>\n <ArkDialog.Backdrop className=\"ds-dialog__backdrop\" />\n <ArkDialog.Positioner className=\"ds-dialog__positioner\">\n <ArkDialog.Content\n ref={panelRef}\n className={cx('ds-dialog', size === 'lg' && 'ds-dialog--lg', className)}\n >\n {content}\n </ArkDialog.Content>\n </ArkDialog.Positioner>\n </Portal>\n )}\n </ArkDialog.Root>\n );\n}\n\n/**\n * What a side panel needs that Ark leaves to a modal's focus trap: the slot,\n * taken on open so any other panel closes; the panel scrolled into view,\n * since below the `lg` step it sits above the content in the page's flow;\n * and focus put back on close. Focus moves when it was inside the panel or\n * on nothing, as after a save whose button disabled itself and so dropped\n * focus, so closing the panel never pulls the user out of the list they\n * moved to but never leaves them on the page's body either.\n * It goes where the trap would send it: `finalFocusRef`'s element, else the\n * trigger, else what had focus when the panel opened. The trigger is named\n * outright because Safari does not focus a button on click.\n *\n * The panel arrives as state from its callback ref: a child's layout effect\n * runs before its parent's ref is attached. A layout effect, because its\n * cleanup runs while the panel is still in the document and can still hold\n * focus, and before Ark moves focus into the panel a frame after it opens.\n * It runs once per opening: the callbacks and refs it reads at close are\n * kept current beside it, so a re-render never closes and reopens the seat.\n */\nfunction SidePanelSeat({\n claim,\n panel,\n triggerRef,\n finalFocusRef,\n}: {\n claim: SidePanelSlot['claim'];\n panel: HTMLDivElement | null;\n triggerRef: RefObject<HTMLElement | null>;\n finalFocusRef?: RefObject<HTMLElement | null>;\n}) {\n const dialog = useDialogContext();\n const latest = useRef({ setOpen: dialog.setOpen, finalFocusRef });\n useLayoutEffect(() => {\n latest.current = { setOpen: dialog.setOpen, finalFocusRef };\n });\n\n useLayoutEffect(() => {\n if (!panel) return;\n const opener = panel.ownerDocument.activeElement;\n const release = claim(() => latest.current.setOpen(false));\n panel.scrollIntoView({ block: 'nearest' });\n return () => {\n release();\n const active = panel.ownerDocument.activeElement;\n const movedToThePage =\n active && active !== panel.ownerDocument.body && !panel.contains(active);\n if (movedToThePage) return;\n const target = [latest.current.finalFocusRef?.current, triggerRef.current, opener].find(\n (element) => element instanceof HTMLElement && element.isConnected,\n );\n if (target instanceof HTMLElement) target.focus();\n };\n }, [claim, panel, triggerRef]);\n\n return null;\n}\n\n/**\n * The scrolling body. While its content overflows it joins the tab order, so\n * a keyboard user can focus it and scroll; a body with nothing to scroll\n * stays out of the way, unless it holds focus as its content comes to fit\n * (`useOverflow` decides both).\n */\nfunction DialogBody({ children }: { children: ReactNode }) {\n const [observe, scrollable] = useOverflow('y');\n\n return (\n <div ref={observe} className=\"ds-dialog__body\" tabIndex={scrollable ? 0 : undefined}>\n <div className=\"ds-dialog__body-content\">{children}</div>\n </div>\n );\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export * from './layout';
|
|
|
24
24
|
export * from './link';
|
|
25
25
|
export type { LinkComponentProps } from './link-component';
|
|
26
26
|
export * from './menu';
|
|
27
|
+
export * from './nav-list';
|
|
27
28
|
export * from './page-layout';
|
|
28
29
|
export * from './popover';
|
|
29
30
|
export * from './progress';
|
|
@@ -39,6 +40,7 @@ export * from './skeleton';
|
|
|
39
40
|
export * from './slider';
|
|
40
41
|
export * from './spinner';
|
|
41
42
|
export * from './split-layout';
|
|
43
|
+
export * from './status-dot';
|
|
42
44
|
export * from './sticky';
|
|
43
45
|
export * from './switch';
|
|
44
46
|
export * from './table';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,OAAO,EACL,KAAK,IAAI,aAAa,EACtB,WAAW,IAAI,mBAAmB,EAClC,YAAY,IAAI,oBAAoB,EACpC,KAAK,IAAI,aAAa,EACtB,GAAG,IAAI,WAAW,GACnB,MAAM,mBAAmB,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC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M,kBAAkB,CAAC;AAC3D,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -23,6 +23,7 @@ export * from './illustration';
|
|
|
23
23
|
export * from './layout';
|
|
24
24
|
export * from './link';
|
|
25
25
|
export * from './menu';
|
|
26
|
+
export * from './nav-list';
|
|
26
27
|
export * from './page-layout';
|
|
27
28
|
export * from './popover';
|
|
28
29
|
export * from './progress';
|
|
@@ -38,6 +39,7 @@ export * from './skeleton';
|
|
|
38
39
|
export * from './slider';
|
|
39
40
|
export * from './spinner';
|
|
40
41
|
export * from './split-layout';
|
|
42
|
+
export * from './status-dot';
|
|
41
43
|
export * from './sticky';
|
|
42
44
|
export * from './switch';
|
|
43
45
|
export * from './table';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAA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AAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC","sourcesContent":["export * from './accordion';\nexport * from './alert';\nexport * from './avatar';\nexport * from './badge';\nexport * from './breadcrumb';\nexport * from './button';\nexport * from './calendar';\nexport * from './card';\nexport * from './centered-layout';\nexport * from './checkbox';\nexport * from './combobox';\nexport { cx } from './cx';\nexport * from './date-input';\nexport * from './dialog';\nexport * from './divider';\nexport * from './empty-state';\nexport {\n Check as FallbackCheck,\n ChevronLeft as FallbackChevronLeft,\n ChevronRight as FallbackChevronRight,\n Cross as FallbackCross,\n Pin as FallbackPin,\n} from './fallback-glyphs';\nexport * from './field';\nexport * from './form-layout';\nexport * from './icon';\nexport * from './icon-defaults';\nexport * from './illustration';\nexport * from './layout';\nexport * from './link';\nexport type { LinkComponentProps } from './link-component';\nexport * from './menu';\nexport * from './page-layout';\nexport * from './popover';\nexport * from './progress';\nexport * from './radio-group';\nexport * from './reorder-control';\nexport * from './scroll-area';\nexport * from './section';\nexport * from './segment-group';\nexport * from './select';\nexport * from './show';\nexport * from './side-panel-layout';\nexport * from './skeleton';\nexport * from './slider';\nexport * from './spinner';\nexport * from './split-layout';\nexport * from './sticky';\nexport * from './switch';\nexport * from './table';\nexport * from './tabs';\nexport * from './text';\nexport * from './tooltip';\nexport * from './visually-hidden';\nexport * from './wizard-layout';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,OAAO,EACL,KAAK,IAAI,aAAa,EACtB,WAAW,IAAI,mBAAmB,EAClC,YAAY,IAAI,oBAAoB,EACpC,KAAK,IAAI,aAAa,EACtB,GAAG,IAAI,WAAW,GACnB,MAAM,mBAAmB,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AAEvB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC","sourcesContent":["export * from './accordion';\nexport * from './alert';\nexport * from './avatar';\nexport * from './badge';\nexport * from './breadcrumb';\nexport * from './button';\nexport * from './calendar';\nexport * from './card';\nexport * from './centered-layout';\nexport * from './checkbox';\nexport * from './combobox';\nexport { cx } from './cx';\nexport * from './date-input';\nexport * from './dialog';\nexport * from './divider';\nexport * from './empty-state';\nexport {\n Check as FallbackCheck,\n ChevronLeft as FallbackChevronLeft,\n ChevronRight as FallbackChevronRight,\n Cross as FallbackCross,\n Pin as FallbackPin,\n} from './fallback-glyphs';\nexport * from './field';\nexport * from './form-layout';\nexport * from './icon';\nexport * from './icon-defaults';\nexport * from './illustration';\nexport * from './layout';\nexport * from './link';\nexport type { LinkComponentProps } from './link-component';\nexport * from './menu';\nexport * from './nav-list';\nexport * from './page-layout';\nexport * from './popover';\nexport * from './progress';\nexport * from './radio-group';\nexport * from './reorder-control';\nexport * from './scroll-area';\nexport * from './section';\nexport * from './segment-group';\nexport * from './select';\nexport * from './show';\nexport * from './side-panel-layout';\nexport * from './skeleton';\nexport * from './slider';\nexport * from './spinner';\nexport * from './split-layout';\nexport * from './status-dot';\nexport * from './sticky';\nexport * from './switch';\nexport * from './table';\nexport * from './tabs';\nexport * from './text';\nexport * from './tooltip';\nexport * from './visually-hidden';\nexport * from './wizard-layout';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/nav-list/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/nav-list/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC","sourcesContent":["export type { NavListItemProps, NavListProps } from './nav-list';\nexport { NavList, NavListItem } from './nav-list';\n"]}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
@layer components {
|
|
2
|
+
.ds-nav-list {
|
|
3
|
+
font-size: var(--ds-nav-list-font-size);
|
|
4
|
+
overflow-wrap: anywhere;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.ds-nav-list__list {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
margin: 0;
|
|
11
|
+
padding: 0;
|
|
12
|
+
list-style: none;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/*
|
|
16
|
+
* The edge is drawn at rest too, transparent, so marking an item current
|
|
17
|
+
* moves no text. The ring is inset: a list in a scrolling sidebar, or in its
|
|
18
|
+
* sideways row, would crop a ring drawn outside the link.
|
|
19
|
+
*/
|
|
20
|
+
.ds-nav-list__link {
|
|
21
|
+
display: flex;
|
|
22
|
+
align-items: baseline;
|
|
23
|
+
justify-content: space-between;
|
|
24
|
+
gap: var(--ds-nav-list-item-gap);
|
|
25
|
+
padding-block: var(--ds-nav-list-item-padding-block);
|
|
26
|
+
padding-inline: calc(
|
|
27
|
+
var(--ds-nav-list-item-padding-inline) +
|
|
28
|
+
var(--_nav-list-depth, 0) *
|
|
29
|
+
var(--ds-nav-list-item-indent)
|
|
30
|
+
)
|
|
31
|
+
var(--ds-nav-list-item-padding-inline);
|
|
32
|
+
border-inline-start: 2px solid var(--ds-nav-list-item-border);
|
|
33
|
+
color: var(--ds-nav-list-item-text);
|
|
34
|
+
font: inherit;
|
|
35
|
+
text-decoration: none;
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
transition:
|
|
38
|
+
color 150ms cubic-bezier(0, 0, 0.2, 1),
|
|
39
|
+
background-color 150ms cubic-bezier(0, 0, 0.2, 1);
|
|
40
|
+
|
|
41
|
+
&:hover {
|
|
42
|
+
color: var(--ds-nav-list-item-text-hover);
|
|
43
|
+
background-color: var(--ds-nav-list-item-bg-hover);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
&[aria-current="page"] {
|
|
47
|
+
color: var(--ds-nav-list-item-text-current);
|
|
48
|
+
border-inline-start-color: var(--ds-nav-list-item-border-current);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
&:focus-visible {
|
|
52
|
+
outline: 2px solid var(--ds-nav-list-focus-ring);
|
|
53
|
+
outline-offset: -2px;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.ds-nav-list__label {
|
|
58
|
+
min-width: 0;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.ds-nav-list__count {
|
|
62
|
+
flex-shrink: 0;
|
|
63
|
+
color: var(--ds-nav-list-count-text);
|
|
64
|
+
font-variant-numeric: tabular-nums;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/*
|
|
68
|
+
* Below the step, one row that scrolls sideways: the labels keep to one
|
|
69
|
+
* line, as a sideways scroller may, and depth no longer indents. The
|
|
70
|
+
* breakpoints are the viewport tokens, written as literals because
|
|
71
|
+
* `@media` cannot read a custom property (`check:breakpoints`).
|
|
72
|
+
*/
|
|
73
|
+
@media (width < 40rem) {
|
|
74
|
+
.ds-nav-list--inline-below-sm {
|
|
75
|
+
.ds-nav-list__list {
|
|
76
|
+
flex-direction: row;
|
|
77
|
+
overflow-x: auto;
|
|
78
|
+
overflow-y: hidden;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.ds-nav-list__item {
|
|
82
|
+
flex-shrink: 0;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.ds-nav-list__link {
|
|
86
|
+
padding-inline: var(--ds-nav-list-item-padding-inline);
|
|
87
|
+
white-space: nowrap;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@media (width < 48rem) {
|
|
93
|
+
.ds-nav-list--inline-below-md {
|
|
94
|
+
.ds-nav-list__list {
|
|
95
|
+
flex-direction: row;
|
|
96
|
+
overflow-x: auto;
|
|
97
|
+
overflow-y: hidden;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.ds-nav-list__item {
|
|
101
|
+
flex-shrink: 0;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.ds-nav-list__link {
|
|
105
|
+
padding-inline: var(--ds-nav-list-item-padding-inline);
|
|
106
|
+
white-space: nowrap;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
@media (width < 64rem) {
|
|
112
|
+
.ds-nav-list--inline-below-lg {
|
|
113
|
+
.ds-nav-list__list {
|
|
114
|
+
flex-direction: row;
|
|
115
|
+
overflow-x: auto;
|
|
116
|
+
overflow-y: hidden;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.ds-nav-list__item {
|
|
120
|
+
flex-shrink: 0;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.ds-nav-list__link {
|
|
124
|
+
padding-inline: var(--ds-nav-list-item-padding-inline);
|
|
125
|
+
white-space: nowrap;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@media (width < 80rem) {
|
|
131
|
+
.ds-nav-list--inline-below-xl {
|
|
132
|
+
.ds-nav-list__list {
|
|
133
|
+
flex-direction: row;
|
|
134
|
+
overflow-x: auto;
|
|
135
|
+
overflow-y: hidden;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.ds-nav-list__item {
|
|
139
|
+
flex-shrink: 0;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.ds-nav-list__link {
|
|
143
|
+
padding-inline: var(--ds-nav-list-item-padding-inline);
|
|
144
|
+
white-space: nowrap;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { type ComponentProps, type CSSProperties, type ReactElement, type ReactNode } from 'react';
|
|
2
|
+
import './nav-list.css';
|
|
3
|
+
import type { Breakpoint } from '../layout/layout';
|
|
4
|
+
export interface NavListProps extends Omit<ComponentProps<'nav'>, 'aria-label' | 'aria-labelledby'> {
|
|
5
|
+
/** Names the navigation landmark ("Mail folders"). Required: a page can hold several. */
|
|
6
|
+
label: string;
|
|
7
|
+
/**
|
|
8
|
+
* Below this viewport step the items sit in one row that scrolls sideways,
|
|
9
|
+
* for a list that runs down a sidebar on a wide screen and across the top
|
|
10
|
+
* on a narrow one. Depth indents only in the column.
|
|
11
|
+
*/
|
|
12
|
+
inlineBelow?: Breakpoint;
|
|
13
|
+
/** `NavListItem`s. */
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A list of links to the places a section of an app holds, with the current
|
|
18
|
+
* one marked: the folders of a mailbox, the pages of a settings area.
|
|
19
|
+
*
|
|
20
|
+
* Renders a `nav` landmark around a list. Each `NavListItem` is a link; the
|
|
21
|
+
* current one carries `aria-current="page"`, an edge and text in the
|
|
22
|
+
* product's accent. For links that switch a panel in place rather than
|
|
23
|
+
* navigate, use `Tabs`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function NavList({ label, inlineBelow, className, children, ...props }: NavListProps): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
/**
|
|
27
|
+
* A count at the end of the item and the noun it counts, which is said after
|
|
28
|
+
* the number but not shown ("3 unread"). Together, so a bare number is never
|
|
29
|
+
* announced.
|
|
30
|
+
*/
|
|
31
|
+
type NavListItemCount = {
|
|
32
|
+
/** How many things wait at this destination. Nothing shows for zero. */
|
|
33
|
+
count: number;
|
|
34
|
+
/** The noun the count counts ("unread"), said after the number. */
|
|
35
|
+
countLabel: string;
|
|
36
|
+
} | {
|
|
37
|
+
count?: undefined;
|
|
38
|
+
countLabel?: undefined;
|
|
39
|
+
};
|
|
40
|
+
type NavListItemOwnProps = NavListItemCount & {
|
|
41
|
+
/** The page the reader is on: `aria-current="page"`, the accent edge and text. */
|
|
42
|
+
current?: boolean;
|
|
43
|
+
/** How many steps the item is indented under its parent, from 0. Defaults to 0. */
|
|
44
|
+
depth?: number;
|
|
45
|
+
};
|
|
46
|
+
type NavListItemAsLinkProps = NavListItemOwnProps & Omit<ComponentProps<'a'>, 'aria-current'> & {
|
|
47
|
+
asChild?: false;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* With `asChild` the child is the link, so its `href` or `to`, handlers, `ref`
|
|
51
|
+
* and ARIA go on the child; the item adds its look, state and count and
|
|
52
|
+
* nothing else, as `Button asChild` does.
|
|
53
|
+
*/
|
|
54
|
+
type NavListItemAsChildProps = NavListItemOwnProps & {
|
|
55
|
+
/** Render the single child element, a router's link, as the item's link. */
|
|
56
|
+
asChild: true;
|
|
57
|
+
/**
|
|
58
|
+
* The one link element. Its own children become the label. A component
|
|
59
|
+
* works if it passes `className`, `style` and `children` on to the element
|
|
60
|
+
* it renders, as a router's link does.
|
|
61
|
+
*/
|
|
62
|
+
children: ReactElement<{
|
|
63
|
+
className?: string;
|
|
64
|
+
style?: CSSProperties;
|
|
65
|
+
children?: ReactNode;
|
|
66
|
+
}>;
|
|
67
|
+
/** Extra class names appended to the link's. */
|
|
68
|
+
className?: string;
|
|
69
|
+
};
|
|
70
|
+
export type NavListItemProps = NavListItemAsLinkProps | NavListItemAsChildProps;
|
|
71
|
+
/**
|
|
72
|
+
* One destination in a `NavList`: a list item holding a link.
|
|
73
|
+
*
|
|
74
|
+
* Renders an `a`; for a router's link, pass `asChild` and the link as the
|
|
75
|
+
* only child, which keeps its own `to` and behaviour while taking the item's
|
|
76
|
+
* class, state and count
|
|
77
|
+
* (`<NavListItem asChild current><Link to="/mail">Inbox</Link></NavListItem>`).
|
|
78
|
+
* A link that marks itself `aria-current="page"` is drawn current too, since
|
|
79
|
+
* the look follows the attribute.
|
|
80
|
+
*/
|
|
81
|
+
export declare function NavListItem(props: NavListItemProps): import("react/jsx-runtime").JSX.Element;
|
|
82
|
+
export {};
|
|
83
|
+
//# sourceMappingURL=nav-list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nav-list.d.ts","sourceR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AE,IAAI,CAAC;IACd;;;;OAIG;IACH,QAAQ,EAAE,YAAY,CAAC;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,aAAa,CAAC;QAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC;IAC5F,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,sBAAsB,GAAG,uBAAuB,CAAC;AAkFhF;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,2CAMlD"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { cloneElement, Fragment, isValidElement, } from 'react';
|
|
3
|
+
import './nav-list.css';
|
|
4
|
+
import { cx } from '../cx';
|
|
5
|
+
import { VisuallyHidden } from '../visually-hidden/visually-hidden';
|
|
6
|
+
/**
|
|
7
|
+
* A list of links to the places a section of an app holds, with the current
|
|
8
|
+
* one marked: the folders of a mailbox, the pages of a settings area.
|
|
9
|
+
*
|
|
10
|
+
* Renders a `nav` landmark around a list. Each `NavListItem` is a link; the
|
|
11
|
+
* current one carries `aria-current="page"`, an edge and text in the
|
|
12
|
+
* product's accent. For links that switch a panel in place rather than
|
|
13
|
+
* navigate, use `Tabs`.
|
|
14
|
+
*/
|
|
15
|
+
export function NavList({ label, inlineBelow, className, children, ...props }) {
|
|
16
|
+
return (_jsx("nav", { "aria-label": label, className: cx('ds-nav-list', inlineBelow && `ds-nav-list--inline-below-${inlineBelow}`, className), ...props, children: _jsx("ul", { className: "ds-nav-list__list", children: children }) }));
|
|
17
|
+
}
|
|
18
|
+
function NavListItemContent({ count, countLabel, children, }) {
|
|
19
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { className: "ds-nav-list__label", children: children }), count !== undefined && count > 0 ? (_jsxs(_Fragment, { children: [' ', _jsxs("span", { className: "ds-nav-list__count", children: [count, " ", _jsx(VisuallyHidden, { children: countLabel })] })] })) : null] }));
|
|
20
|
+
}
|
|
21
|
+
const indentFor = (depth) => depth > 0 ? { '--_nav-list-depth': depth } : undefined;
|
|
22
|
+
function NavListItemAsChild({ current = false, depth = 0, count, countLabel, className, children, }) {
|
|
23
|
+
if (!isValidElement(children) || children.type === Fragment) {
|
|
24
|
+
throw new Error('NavListItem asChild needs exactly one element as its child, such as <a> or a router link.');
|
|
25
|
+
}
|
|
26
|
+
const indent = indentFor(depth);
|
|
27
|
+
return cloneElement(children, {
|
|
28
|
+
className: cx('ds-nav-list__link', className, children.props.className),
|
|
29
|
+
style: indent ? { ...indent, ...children.props.style } : children.props.style,
|
|
30
|
+
...(current ? { 'aria-current': 'page' } : {}),
|
|
31
|
+
}, _jsx(NavListItemContent, { count: count, countLabel: countLabel, children: children.props.children }));
|
|
32
|
+
}
|
|
33
|
+
function NavListItemAsLink({ current = false, depth = 0, count, countLabel, className, style, children, asChild: _asChild, ...props }) {
|
|
34
|
+
const indent = indentFor(depth);
|
|
35
|
+
return (_jsx("a", { "aria-current": current ? 'page' : undefined, className: cx('ds-nav-list__link', className), style: indent ? { ...indent, ...style } : style, ...props, children: _jsx(NavListItemContent, { count: count, countLabel: countLabel, children: children }) }));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* One destination in a `NavList`: a list item holding a link.
|
|
39
|
+
*
|
|
40
|
+
* Renders an `a`; for a router's link, pass `asChild` and the link as the
|
|
41
|
+
* only child, which keeps its own `to` and behaviour while taking the item's
|
|
42
|
+
* class, state and count
|
|
43
|
+
* (`<NavListItem asChild current><Link to="/mail">Inbox</Link></NavListItem>`).
|
|
44
|
+
* A link that marks itself `aria-current="page"` is drawn current too, since
|
|
45
|
+
* the look follows the attribute.
|
|
46
|
+
*/
|
|
47
|
+
export function NavListItem(props) {
|
|
48
|
+
return (_jsx("li", { className: "ds-nav-list__item", children: props.asChild ? _jsx(NavListItemAsChild, { ...props }) : _jsx(NavListItemAsLink, { ...props }) }));
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=nav-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nav-list.js","sourceRoot":"","sources":["../../src/nav-list/nav-list.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,YAAY,EACZ,QAAQ,EACR,cAAc,GAGf,MAAM,OAAO,CAAC;AACf,OAAO,gBAAgB,CAAC;AACxB,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAE3B,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAgBpE;;;;;;;;GAQG;AACH,MAAM,UAAU,OAAO,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAgB;IACzF,OAAO,CACL,4BACc,KAAK,EACjB,SAAS,EAAE,EAAE,CACX,aAAa,EACb,WAAW,IAAI,6BAA6B,WAAW,EAAE,EACzD,SAAS,CACV,KACG,KAAK,YAET,aAAI,SAAS,EAAC,mBAAmB,YAAE,QAAQ,GAAM,GAC7C,CACP,CAAC;AACJ,CAAC;AA8CD,SAAS,kBAAkB,CAAC,EAC1B,KAAK,EACL,UAAU,EACV,QAAQ,GAKT;IACC,OAAO,CACL,8BACE,eAAM,SAAS,EAAC,oBAAoB,YAAE,QAAQ,GAAQ,EACrD,KAAK,KAAK,SAAS,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAClC,8BACG,GAAG,EACJ,gBAAM,SAAS,EAAC,oBAAoB,aACjC,KAAK,OAAE,KAAC,cAAc,cAAE,UAAU,GAAkB,IAChD,IACN,CACJ,CAAC,CAAC,CAAC,IAAI,IACP,CACJ,CAAC;AACJ,CAAC;AAED,MAAM,SAAS,GAAG,CAAC,KAAa,EAAE,EAAE,CAClC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAE,EAAE,mBAAmB,EAAE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S,EAAE,EAAE,CAAC,mBAAmB,EAAE,SAAS,CAAC,EAC7C,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,KAC3C,KAAK,YAET,KAAC,kBAAkB,IAAC,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,YACrD,QAAQ,GACU,GACnB,CACL,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,WAAW,CAAC,KAAuB;IACjD,OAAO,CACL,aAAI,SAAS,EAAC,mBAAmB,YAC9B,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAC,kBAAkB,OAAK,KAAK,GAAI,CAAC,CAAC,CAAC,KAAC,iBAAiB,OAAK,KAAK,GAAI,GAClF,CACN,CAAC;AACJ,CAAC","sourcesContent":["import {\n type ComponentProps,\n type CSSProperties,\n cloneElement,\n Fragment,\n isValidElement,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport './nav-list.css';\nimport { cx } from '../cx';\nimport type { Breakpoint } from '../layout/layout';\nimport { VisuallyHidden } from '../visually-hidden/visually-hidden';\n\nexport interface NavListProps\n extends Omit<ComponentProps<'nav'>, 'aria-label' | 'aria-labelledby'> {\n /** Names the navigation landmark (\"Mail folders\"). Required: a page can hold several. */\n label: string;\n /**\n * Below this viewport step the items sit in one row that scrolls sideways,\n * for a list that runs down a sidebar on a wide screen and across the top\n * on a narrow one. Depth indents only in the column.\n */\n inlineBelow?: Breakpoint;\n /** `NavListItem`s. */\n children: ReactNode;\n}\n\n/**\n * A list of links to the places a section of an app holds, with the current\n * one marked: the folders of a mailbox, the pages of a settings area.\n *\n * Renders a `nav` landmark around a list. Each `NavListItem` is a link; the\n * current one carries `aria-current=\"page\"`, an edge and text in the\n * product's accent. For links that switch a panel in place rather than\n * navigate, use `Tabs`.\n */\nexport function NavList({ label, inlineBelow, className, children, ...props }: NavListProps) {\n return (\n <nav\n aria-label={label}\n className={cx(\n 'ds-nav-list',\n inlineBelow && `ds-nav-list--inline-below-${inlineBelow}`,\n className,\n )}\n {...props}\n >\n <ul className=\"ds-nav-list__list\">{children}</ul>\n </nav>\n );\n}\n\n/**\n * A count at the end of the item and the noun it counts, which is said after\n * the number but not shown (\"3 unread\"). Together, so a bare number is never\n * announced.\n */\ntype NavListItemCount =\n | {\n /** How many things wait at this destination. Nothing shows for zero. */\n count: number;\n /** The noun the count counts (\"unread\"), said after the number. */\n countLabel: string;\n }\n | { count?: undefined; countLabel?: undefined };\n\ntype NavListItemOwnProps = NavListItemCount & {\n /** The page the reader is on: `aria-current=\"page\"`, the accent edge and text. */\n current?: boolean;\n /** How many steps the item is indented under its parent, from 0. Defaults to 0. */\n depth?: number;\n};\n\ntype NavListItemAsLinkProps = NavListItemOwnProps &\n Omit<ComponentProps<'a'>, 'aria-current'> & { asChild?: false };\n\n/**\n * With `asChild` the child is the link, so its `href` or `to`, handlers, `ref`\n * and ARIA go on the child; the item adds its look, state and count and\n * nothing else, as `Button asChild` does.\n */\ntype NavListItemAsChildProps = NavListItemOwnProps & {\n /** Render the single child element, a router's link, as the item's link. */\n asChild: true;\n /**\n * The one link element. Its own children become the label. A component\n * works if it passes `className`, `style` and `children` on to the element\n * it renders, as a router's link does.\n */\n children: ReactElement<{ className?: string; style?: CSSProperties; children?: ReactNode }>;\n /** Extra class names appended to the link's. */\n className?: string;\n};\n\nexport type NavListItemProps = NavListItemAsLinkProps | NavListItemAsChildProps;\n\nfunction NavListItemContent({\n count,\n countLabel,\n children,\n}: {\n count?: number;\n countLabel?: string;\n children: ReactNode;\n}) {\n return (\n <>\n <span className=\"ds-nav-list__label\">{children}</span>\n {count !== undefined && count > 0 ? (\n <>\n {' '}\n <span className=\"ds-nav-list__count\">\n {count} <VisuallyHidden>{countLabel}</VisuallyHidden>\n </span>\n </>\n ) : null}\n </>\n );\n}\n\nconst indentFor = (depth: number) =>\n depth > 0 ? ({ '--_nav-list-depth': depth } as CSSProperties) : undefined;\n\nfunction NavListItemAsChild({\n current = false,\n depth = 0,\n count,\n countLabel,\n className,\n children,\n}: NavListItemAsChildProps) {\n if (!isValidElement(children) || children.type === Fragment) {\n throw new Error(\n 'NavListItem asChild needs exactly one element as its child, such as <a> or a router link.',\n );\n }\n const indent = indentFor(depth);\n return cloneElement(\n children,\n {\n className: cx('ds-nav-list__link', className, children.props.className),\n style: indent ? { ...indent, ...children.props.style } : children.props.style,\n ...(current ? { 'aria-current': 'page' } : {}),\n },\n <NavListItemContent count={count} countLabel={countLabel}>\n {children.props.children}\n </NavListItemContent>,\n );\n}\n\nfunction NavListItemAsLink({\n current = false,\n depth = 0,\n count,\n countLabel,\n className,\n style,\n children,\n asChild: _asChild,\n ...props\n}: NavListItemAsLinkProps) {\n const indent = indentFor(depth);\n return (\n <a\n aria-current={current ? 'page' : undefined}\n className={cx('ds-nav-list__link', className)}\n style={indent ? { ...indent, ...style } : style}\n {...props}\n >\n <NavListItemContent count={count} countLabel={countLabel}>\n {children}\n </NavListItemContent>\n </a>\n );\n}\n\n/**\n * One destination in a `NavList`: a list item holding a link.\n *\n * Renders an `a`; for a router's link, pass `asChild` and the link as the\n * only child, which keeps its own `to` and behaviour while taking the item's\n * class, state and count\n * (`<NavListItem asChild current><Link to=\"/mail\">Inbox</Link></NavListItem>`).\n * A link that marks itself `aria-current=\"page\"` is drawn current too, since\n * the look follows the attribute.\n */\nexport function NavListItem(props: NavListItemProps) {\n return (\n <li className=\"ds-nav-list__item\">\n {props.asChild ? <NavListItemAsChild {...props} /> : <NavListItemAsLink {...props} />}\n </li>\n );\n}\n"]}
|
|
@@ -18,6 +18,18 @@
|
|
|
18
18
|
overflow-y: hidden;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
/*
|
|
22
|
+
* A no-wrap row directly inside a sideways scroller is at least as wide
|
|
23
|
+
* as its content, so it overflows and scrolls. Otherwise its items shrink
|
|
24
|
+
* to their min-content, which the `overflow-wrap: anywhere` on Inline,
|
|
25
|
+
* Text and every component root makes one letter wide. A minimum, not a
|
|
26
|
+
* width, so a row that fits still fills the scroller and keeps its
|
|
27
|
+
* `justify`.
|
|
28
|
+
*/
|
|
29
|
+
&.ds-scroll-area--x > .ds-inline--nowrap {
|
|
30
|
+
min-width: max-content;
|
|
31
|
+
}
|
|
32
|
+
|
|
21
33
|
&:focus-visible {
|
|
22
34
|
outline: 2px solid var(--ds-link-focus-ring);
|
|
23
35
|
outline-offset: 2px;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ark } from '@ark-ui/react/factory';
|
|
2
|
-
import type
|
|
2
|
+
import { type ComponentProps } from 'react';
|
|
3
3
|
import './scroll-area.css';
|
|
4
4
|
/** The axis a scroll area scrolls along. */
|
|
5
5
|
export type ScrollAxis = 'x' | 'y';
|
|
@@ -9,8 +9,10 @@ export interface ScrollAreaProps extends ComponentProps<typeof ark.div> {
|
|
|
9
9
|
/**
|
|
10
10
|
* The region's name. A scroller with nothing focusable inside cannot be
|
|
11
11
|
* reached from the keyboard, so naming it makes it a focusable region
|
|
12
|
-
* that the arrow keys scroll
|
|
13
|
-
* focus
|
|
12
|
+
* that the arrow keys scroll, while its content overflows; a named box
|
|
13
|
+
* that fits adds no tab stop and no landmark, unless it holds focus as the
|
|
14
|
+
* content comes to fit. An empty label counts as none. Leave it out when a
|
|
15
|
+
* control inside takes focus already.
|
|
14
16
|
*/
|
|
15
17
|
label?: string;
|
|
16
18
|
}
|
|
@@ -22,5 +24,5 @@ export interface ScrollAreaProps extends ComponentProps<typeof ark.div> {
|
|
|
22
24
|
* dialog body, a popover, a Frame): the scroll area only keeps its content
|
|
23
25
|
* inside. Renders a `div`; pass `asChild` to scroll your own element.
|
|
24
26
|
*/
|
|
25
|
-
export declare function ScrollArea({ axis, label, className, children, ...props }: ScrollAreaProps): import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export declare function ScrollArea({ axis, label, className, children, ref, ...props }: ScrollAreaProps): import("react/jsx-runtime").JSX.Element;
|
|
26
28
|
//# sourceMappingURL=scroll-area.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scroll-area.d.ts","sourceRoot":"","sources":["../../src/scroll-area/scroll-area.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"scroll-area.d.ts","sourceRoot":"","sources":["../../src/scroll-area/scroll-area.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,KAAK,cAAc,EAAe,MAAM,OAAO,CAAC;AACzD,OAAO,mBAAmB,CAAC;AAI3B,4CAA4C;AAC5C,MAAM,MAAM,UAAU,GAAG,GAAG,GAAG,GAAG,CAAC;AAEnC,MAAM,WAAW,eAAgB,SAAQ,cAAc,CAAC,OAAO,GAAG,CAAC,GAAG,CAAC;IACrE,mGAAmG;IACnG,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,EACzB,IAAU,EACV,KAAK,EACL,SAAS,EACT,QAAQ,EACR,GAAG,EACH,GAAG,KAAK,EACT,EAAE,eAAe,2CA8BjB"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { ark } from '@ark-ui/react/factory';
|
|
3
|
+
import { useCallback } from 'react';
|
|
3
4
|
import './scroll-area.css';
|
|
4
5
|
import { cx } from '../cx';
|
|
6
|
+
import { useOverflow } from '../use-overflow';
|
|
5
7
|
/**
|
|
6
8
|
* A box whose content scrolls inside it instead of widening the page.
|
|
7
9
|
*
|
|
@@ -10,7 +12,25 @@ import { cx } from '../cx';
|
|
|
10
12
|
* dialog body, a popover, a Frame): the scroll area only keeps its content
|
|
11
13
|
* inside. Renders a `div`; pass `asChild` to scroll your own element.
|
|
12
14
|
*/
|
|
13
|
-
export function ScrollArea({ axis = 'y', label, className, children, ...props }) {
|
|
14
|
-
|
|
15
|
+
export function ScrollArea({ axis = 'y', label, className, children, ref, ...props }) {
|
|
16
|
+
const named = Boolean(label);
|
|
17
|
+
const [observe, scrollable] = useOverflow(axis, named);
|
|
18
|
+
const composedRef = useCallback((node) => {
|
|
19
|
+
const stopObserving = observe(node);
|
|
20
|
+
const releaseRef = typeof ref === 'function' ? ref(node) : undefined;
|
|
21
|
+
if (ref && typeof ref === 'object')
|
|
22
|
+
ref.current = node;
|
|
23
|
+
return () => {
|
|
24
|
+
stopObserving?.();
|
|
25
|
+
if (typeof releaseRef === 'function')
|
|
26
|
+
releaseRef();
|
|
27
|
+
else if (typeof ref === 'function')
|
|
28
|
+
ref(null);
|
|
29
|
+
else if (ref)
|
|
30
|
+
ref.current = null;
|
|
31
|
+
};
|
|
32
|
+
}, [observe, ref]);
|
|
33
|
+
const region = named && scrollable;
|
|
34
|
+
return (_jsx(ark.div, { ref: composedRef, role: region ? 'region' : undefined, "aria-label": region ? label : undefined, tabIndex: region ? 0 : undefined, className: cx('ds-scroll-area', `ds-scroll-area--${axis}`, className), ...props, children: children }));
|
|
15
35
|
}
|
|
16
36
|
//# sourceMappingURL=scroll-area.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scroll-area.js","sourceRoot":"","sources":["../../src/scroll-area/scroll-area.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"scroll-area.js","sourceRoot":"","sources":["../../src/scroll-area/scroll-area.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAuB,WAAW,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,mBAAmB,CAAC;AAC3B,OAAO,EAAE,EAAE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CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,EACtC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,EAChC,SAAS,EAAE,EAAE,CAAC,gBAAgB,EAAE,mBAAmB,IAAI,EAAE,EAAE,SAAS,CAAC,KACjE,KAAK,YAER,QAAQ,GACD,CACX,CAAC;AACJ,CAAC","sourcesContent":["import { ark } from '@ark-ui/react/factory';\nimport { type ComponentProps, useCallback } from 'react';\nimport './scroll-area.css';\nimport { cx } from '../cx';\nimport { useOverflow } from '../use-overflow';\n\n/** The axis a scroll area scrolls along. */\nexport type ScrollAxis = 'x' | 'y';\n\nexport interface ScrollAreaProps extends ComponentProps<typeof ark.div> {\n /** `y` (the default) scrolls a column that outgrows its box; `x` a row that outgrows its width. */\n axis?: ScrollAxis;\n /**\n * The region's name. A scroller with nothing focusable inside cannot be\n * reached from the keyboard, so naming it makes it a focusable region\n * that the arrow keys scroll, while its content overflows; a named box\n * that fits adds no tab stop and no landmark, unless it holds focus as the\n * content comes to fit. An empty label counts as none. Leave it out when a\n * control inside takes focus already.\n */\n label?: string;\n}\n\n/**\n * A box whose content scrolls inside it instead of widening the page.\n *\n * A tree or a grid wider than its card scrolls sideways; a list that must\n * not outgrow its panel scrolls down. The box is sized by its parent (a\n * dialog body, a popover, a Frame): the scroll area only keeps its content\n * inside. Renders a `div`; pass `asChild` to scroll your own element.\n */\nexport function ScrollArea({\n axis = 'y',\n label,\n className,\n children,\n ref,\n ...props\n}: ScrollAreaProps) {\n const named = Boolean(label);\n const [observe, scrollable] = useOverflow(axis, named);\n const composedRef = useCallback(\n (node: HTMLDivElement | null) => {\n const stopObserving = observe(node);\n const releaseRef = typeof ref === 'function' ? ref(node) : undefined;\n if (ref && typeof ref === 'object') ref.current = node;\n return () => {\n stopObserving?.();\n if (typeof releaseRef === 'function') releaseRef();\n else if (typeof ref === 'function') ref(null);\n else if (ref) ref.current = null;\n };\n },\n [observe, ref],\n );\n const region = named && scrollable;\n return (\n <ark.div\n ref={composedRef}\n role={region ? 'region' : undefined}\n aria-label={region ? label : undefined}\n tabIndex={region ? 0 : undefined}\n className={cx('ds-scroll-area', `ds-scroll-area--${axis}`, className)}\n {...props}\n >\n {children}\n </ark.div>\n );\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/status-dot/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/status-dot/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export type { StatusDotProps, StatusDotTone } from './status-dot';\nexport { StatusDot } from './status-dot';\n"]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
@layer components {
|
|
2
|
+
/*
|
|
3
|
+
* The tone sets the colour once, as `color`, so the fill and the glow both
|
|
4
|
+
* read `currentColor`. The glow is the tone at 80% under a blur the theme
|
|
5
|
+
* sets; a theme that sets it to zero draws a flat dot.
|
|
6
|
+
*/
|
|
7
|
+
.ds-status-dot {
|
|
8
|
+
--_status-dot-glow: 0 0 var(--ds-status-dot-glow-size)
|
|
9
|
+
color-mix(in srgb, currentColor 80%, transparent);
|
|
10
|
+
|
|
11
|
+
position: relative;
|
|
12
|
+
display: inline-block;
|
|
13
|
+
flex-shrink: 0;
|
|
14
|
+
vertical-align: middle;
|
|
15
|
+
width: var(--ds-status-dot-size);
|
|
16
|
+
height: var(--ds-status-dot-size);
|
|
17
|
+
border-radius: 50%;
|
|
18
|
+
background-color: currentColor;
|
|
19
|
+
box-shadow: var(--_status-dot-glow);
|
|
20
|
+
|
|
21
|
+
&.ds-status-dot--success {
|
|
22
|
+
color: var(--ds-status-dot-success-bg);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&.ds-status-dot--warning {
|
|
26
|
+
color: var(--ds-status-dot-warning-bg);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&.ds-status-dot--danger {
|
|
30
|
+
color: var(--ds-status-dot-danger-bg);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&.ds-status-dot--info {
|
|
34
|
+
color: var(--ds-status-dot-info-bg);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* Nothing waiting: a glow would light what is settled. */
|
|
38
|
+
&.ds-status-dot--neutral {
|
|
39
|
+
color: var(--ds-status-dot-neutral-bg);
|
|
40
|
+
box-shadow: none;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&.ds-status-dot--pulse {
|
|
44
|
+
animation: ds-status-dot-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@keyframes ds-status-dot-pulse {
|
|
49
|
+
50% {
|
|
50
|
+
opacity: 50%;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@media (prefers-reduced-motion: reduce) {
|
|
55
|
+
.ds-status-dot.ds-status-dot--pulse {
|
|
56
|
+
animation: none;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/*
|
|
61
|
+
* Forced colours paint backgrounds as the page, which would erase the dot,
|
|
62
|
+
* but draw borders in the text colour: the dot becomes a border that fills it.
|
|
63
|
+
*/
|
|
64
|
+
@media (forced-colors: active) {
|
|
65
|
+
.ds-status-dot {
|
|
66
|
+
box-sizing: border-box;
|
|
67
|
+
border: calc(var(--ds-status-dot-size) / 2) solid currentColor;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
|
+
import './status-dot.css';
|
|
3
|
+
/** The status a dot reports, drawn in that status's colour. */
|
|
4
|
+
export type StatusDotTone = 'success' | 'warning' | 'danger' | 'info' | 'neutral';
|
|
5
|
+
export interface StatusDotProps extends Omit<ComponentProps<'span'>, 'children'> {
|
|
6
|
+
/**
|
|
7
|
+
* The status the dot reports. Required: the colour is the dot's whole
|
|
8
|
+
* message, so it is chosen at the call site rather than defaulted.
|
|
9
|
+
*/
|
|
10
|
+
tone: StatusDotTone;
|
|
11
|
+
/**
|
|
12
|
+
* What the dot means, in words ("Unread", "Live"). Rendered visually
|
|
13
|
+
* hidden inside the dot, so it joins the name of a link or row the dot
|
|
14
|
+
* sits in; a dot never stands alone.
|
|
15
|
+
*/
|
|
16
|
+
label: string;
|
|
17
|
+
/**
|
|
18
|
+
* Breathes slowly, for something live right now (a pipeline that is
|
|
19
|
+
* running). Still under `prefers-reduced-motion: reduce`, where the colour
|
|
20
|
+
* alone carries the state.
|
|
21
|
+
*/
|
|
22
|
+
pulse?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A small round dot that marks something unread, live or new, beside the
|
|
26
|
+
* text it belongs to.
|
|
27
|
+
*
|
|
28
|
+
* It renders inline, so it sits in a line of text or a row of a list. The
|
|
29
|
+
* colour comes from the status tokens through the `--ds-status-dot-*`
|
|
30
|
+
* contract, and so does a glow in the same colour where a product's theme
|
|
31
|
+
* gives it one; a `neutral` dot never glows. Its `label` is spoken in place of the colour; when the words
|
|
32
|
+
* beside it already say the same thing ("pipeline nominal"), the label still
|
|
33
|
+
* names the dot's own state ("Live").
|
|
34
|
+
*/
|
|
35
|
+
export declare function StatusDot({ tone, label, pulse, className, ...props }: StatusDotProps): import("react/jsx-runtime").JSX.Element;
|
|
36
|
+
//# sourceMappingURL=status-dot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-dot.d.ts","sourceRoot":"","sources":["../../src/status-dot/status-dot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,kBAAkB,CAAC;AAI1B,+DAA+D;AAC/D,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;AAElF,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC;IAC9E;;;OAGG;IACH,IAAI,EAAE,aAAa,CAAC;IACpB;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAa,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,2CAc5F"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import './status-dot.css';
|
|
3
|
+
import { cx } from '../cx';
|
|
4
|
+
import { VisuallyHidden } from '../visually-hidden/visually-hidden';
|
|
5
|
+
/**
|
|
6
|
+
* A small round dot that marks something unread, live or new, beside the
|
|
7
|
+
* text it belongs to.
|
|
8
|
+
*
|
|
9
|
+
* It renders inline, so it sits in a line of text or a row of a list. The
|
|
10
|
+
* colour comes from the status tokens through the `--ds-status-dot-*`
|
|
11
|
+
* contract, and so does a glow in the same colour where a product's theme
|
|
12
|
+
* gives it one; a `neutral` dot never glows. Its `label` is spoken in place of the colour; when the words
|
|
13
|
+
* beside it already say the same thing ("pipeline nominal"), the label still
|
|
14
|
+
* names the dot's own state ("Live").
|
|
15
|
+
*/
|
|
16
|
+
export function StatusDot({ tone, label, pulse = false, className, ...props }) {
|
|
17
|
+
return (_jsx("span", { className: cx('ds-status-dot', `ds-status-dot--${tone}`, pulse && 'ds-status-dot--pulse', className), ...props, children: _jsx(VisuallyHidden, { children: label }) }));
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=status-dot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-dot.js","sourceRoot":"","sources":["../../src/status-dot/status-dot.tsx"],"names":[],"mappings":";AACA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAyBpE;;;;;;;;;;GAUG;AACH,MAAM,UAAU,SAAS,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,EAAE,SAAS,EAAE,GAAG,KAAK,EAAkB;IAC3F,OAAO,CACL,eACE,SAAS,EAAE,EAAE,CACX,eAAe,EACf,kBAAkB,IAAI,EAAE,EACxB,KAAK,IAAI,sBAAsB,EAC/B,SAAS,CACV,KACG,KAAK,YAET,KAAC,cAAc,cAAE,KAAK,GAAkB,GACnC,CACR,CAAC;AACJ,CAAC","sourcesContent":["import type { ComponentProps } from 'react';\nimport './status-dot.css';\nimport { cx } from '../cx';\nimport { VisuallyHidden } from '../visually-hidden/visually-hidden';\n\n/** The status a dot reports, drawn in that status's colour. */\nexport type StatusDotTone = 'success' | 'warning' | 'danger' | 'info' | 'neutral';\n\nexport interface StatusDotProps extends Omit<ComponentProps<'span'>, 'children'> {\n /**\n * The status the dot reports. Required: the colour is the dot's whole\n * message, so it is chosen at the call site rather than defaulted.\n */\n tone: StatusDotTone;\n /**\n * What the dot means, in words (\"Unread\", \"Live\"). Rendered visually\n * hidden inside the dot, so it joins the name of a link or row the dot\n * sits in; a dot never stands alone.\n */\n label: string;\n /**\n * Breathes slowly, for something live right now (a pipeline that is\n * running). Still under `prefers-reduced-motion: reduce`, where the colour\n * alone carries the state.\n */\n pulse?: boolean;\n}\n\n/**\n * A small round dot that marks something unread, live or new, beside the\n * text it belongs to.\n *\n * It renders inline, so it sits in a line of text or a row of a list. The\n * colour comes from the status tokens through the `--ds-status-dot-*`\n * contract, and so does a glow in the same colour where a product's theme\n * gives it one; a `neutral` dot never glows. Its `label` is spoken in place of the colour; when the words\n * beside it already say the same thing (\"pipeline nominal\"), the label still\n * names the dot's own state (\"Live\").\n */\nexport function StatusDot({ tone, label, pulse = false, className, ...props }: StatusDotProps) {\n return (\n <span\n className={cx(\n 'ds-status-dot',\n `ds-status-dot--${tone}`,\n pulse && 'ds-status-dot--pulse',\n className,\n )}\n {...props}\n >\n <VisuallyHidden>{label}</VisuallyHidden>\n </span>\n );\n}\n"]}
|
package/dist/table/table.d.ts
CHANGED
|
@@ -6,9 +6,11 @@ export type TableAlign = 'start' | 'end';
|
|
|
6
6
|
export type TableSort = 'ascending' | 'descending' | 'none';
|
|
7
7
|
export interface TableProps extends ComponentProps<'div'> {
|
|
8
8
|
/**
|
|
9
|
-
* The table's name, required: it names the table for a screen reader and
|
|
10
|
-
* the scroll region around it, which takes
|
|
11
|
-
* than its column can be scrolled with the
|
|
9
|
+
* The table's name, required: it names the table for a screen reader and,
|
|
10
|
+
* while the columns overflow, the scroll region around it, which then takes
|
|
11
|
+
* keyboard focus so a table wider than its column can be scrolled with the
|
|
12
|
+
* arrow keys. A table that fits adds no region and no tab stop, unless the
|
|
13
|
+
* region holds focus as the columns come to fit.
|
|
12
14
|
*/
|
|
13
15
|
label: string;
|
|
14
16
|
/** Tint every other body row, so a long row is easier to follow across. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/table/table.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAS,MAAM,OAAO,CAAC;AACnE,OAAO,aAAa,CAAC;AAMrB,4EAA4E;AAC5E,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,KAAK,CAAC;AAEzC,+EAA+E;AAC/E,MAAM,MAAM,SAAS,GAAG,WAAW,GAAG,YAAY,GAAG,MAAM,CAAC;AAE5D,MAAM,WA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M,WAAW,cAAe,SAAQ,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IACzE,iFAAiF;IACjF,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,OAAe,EACf,SAAiB,EACjB,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,cAAc,2CAqBhB;AAED,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAC,cAAc,EAAE,OAAO,GAAG,SAAS,GAAG,WAAW,CAAC,CAAC;AAE5F;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,qBAAqB,2CAMxF;AAED,MAAM,WAAW,eAAgB,SAAQ,cAAc,CAAC,IAAI,CAAC;IAC3D,wEAAwE;IACxE,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,eAAe,2CAQrF"}
|
package/dist/table/table.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.js","sourceRoot":"","sources":["../../src/table/table.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAuC,KAAK,EAAE,MAAM,OAAO,CAAC;AACnE,OAAO,aAAa,CAAC;AACrB,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAiCxD;;;;;;;;;;;;;;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,OAAO,EAAE,KAAK,EAAC,KAAK,KAAK,KAAK,YAC1C,QAAQ,GACN,CACN,CAAC;IACJ,CAAC;IACD,OAAO,CACL,aAAI,SAAS,EAAE,OAAO,KAAM,KAAK,YAC9B,QAAQ,GACN,CACN,CAAC;AACJ,CAAC;AAID;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAyB;IACvF,OAAO,CACL,aAAI,SAAS,EAAE,EAAE,CAAC,gBAAgB,EAAE,yBAAyB,EAAE,SAAS,CAAC,KAAM,KAAK,YAClF,eAAM,SAAS,EAAC,mBAAmB,YAAE,QAAQ,GAAQ,GAClD,CACN,CAAC;AACJ,CAAC;AAOD;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAmB;IACpF,OAAO,CACL,aAAI,SAAS,EAAE,EAAE,CAAC,eAAe,EAAE,iBAAiB,EAAE,SAAS,CAAC,KAAM,KAAK,YACzE,aAAI,SAAS,EAAC,gBAAgB,EAAC,OAAO,EAAE,OAAO,YAC5C,QAAQ,GACN,GACF,CACN,CAAC;AACJ,CAAC","sourcesContent":["import { type ComponentProps, type ReactNode, useId } from 'react';\nimport './table.css';\nimport { cx } from '../cx';\nimport { Icon } from '../icon/icon';\nimport { useIconDefaults } from '../icon-defaults';\nimport { ScrollArea } from '../scroll-area/scroll-area';\n\n/** Where a column's content sits: text at the start, numbers at the end. */\nexport type TableAlign = 'start' | 'end';\n\n/** A sortable column's state. `none` is sortable but not the sort in force. */\nexport type TableSort = 'ascending' | 'descending' | 'none';\n\nexport interface TableProps extends ComponentProps<'div'> {\n /**\n * The table's name, required: it names the table for a screen reader and\n * the scroll region around it, which takes keyboard focus so a table wider\n * than its column can be scrolled with the arrow keys.\n */\n label: string;\n /** Tint every other body row, so a long row is easier to follow across. */\n striped?: boolean;\n /**\n * Highlight the body row under the pointer, to read it across or compare\n * it with its neighbours. Not a sign that the row is clickable: a row that\n * opens something puts a link in its first cell.\n */\n rowHover?: boolean;\n /**\n * What sits above the table: a {@link TableToolbar} with the table's\n * actions (add a row, history), and optionally a search or filter at its\n * start.\n */\n toolbar?: ReactNode;\n /** The rows are loading: marks the table busy while skeleton rows stand in. */\n busy?: boolean;\n}\n\n/**\n * Rows and columns of data in a real `<table>`, so a screen reader can move\n * by row and column and announce each cell's column.\n *\n * A structural primitive, styled against the `--ds-table-*` contract. It\n * holds no data and no sorting of its own: the product passes the rows in\n * the order it wants and owns the sort and filter state, which on a server-\n * paged list is the only place it can live.\n *\n * Compose with {@link TableHead}, {@link TableBody} and {@link TableFoot},\n * made of {@link TableRow}s holding {@link TableHeaderCell}s and\n * {@link TableCell}s; {@link TableActionsCell} holds a row's icon buttons and\n * {@link TableEmpty} stands in for the rows when there are none.\n *\n * The table scrolls sideways inside its box when its columns don't fit, so a\n * phone keeps every column instead of squeezing them. `className` and the\n * other props go to that box, which holds the toolbar and the table.\n */\nexport function Table({\n label,\n striped = false,\n rowHover = false,\n toolbar,\n busy = false,\n className,\n children,\n ...props\n}: TableProps) {\n return (\n <div\n className={cx(\n 'ds-table',\n striped && 'ds-table--striped',\n rowHover && 'ds-table--row-hover',\n className,\n )}\n {...props}\n >\n {toolbar}\n <ScrollArea axis=\"x\" className=\"ds-table__scroll\" label={label}>\n <table aria-busy={busy || undefined} aria-label={label} className=\"ds-table__table\">\n {children}\n </table>\n </ScrollArea>\n </div>\n );\n}\n\nexport interface TableToolbarProps extends ComponentProps<'div'> {\n /** What sits at the start of the row: a search or a filter for the whole table. */\n start?: ReactNode;\n}\n\n/**\n * The row above a table: its actions at the end (add a row, history,\n * export), and optionally a search or filter at the start. Pass it to\n * {@link Table}'s `toolbar`.\n */\nexport function TableToolbar({ start, className, children, ...props }: TableToolbarProps) {\n return (\n <div className={cx('ds-table__toolbar', className)} {...props}>\n {start ? <div className=\"ds-table__toolbar-start\">{start}</div> : null}\n <div className=\"ds-table__toolbar-actions\">{children}</div>\n </div>\n );\n}\n\nexport type TableHeadProps = ComponentProps<'thead'>;\n\n/** The column heads: a {@link TableRow} of {@link TableHeaderCell}s. */\nexport function TableHead({ className, children, ...props }: TableHeadProps) {\n return (\n <thead className={cx('ds-table__head', className)} {...props}>\n {children}\n </thead>\n );\n}\n\nexport type TableBodyProps = ComponentProps<'tbody'>;\n\n/** The data rows. */\nexport function TableBody({ className, children, ...props }: TableBodyProps) {\n return (\n <tbody className={cx('ds-table__body', className)} {...props}>\n {children}\n </tbody>\n );\n}\n\nexport type TableFootProps = ComponentProps<'tfoot'>;\n\n/** A totals row under the data, set apart by a rule and the footer weight. */\nexport function TableFoot({ className, children, ...props }: TableFootProps) {\n return (\n <tfoot className={cx('ds-table__foot', className)} {...props}>\n {children}\n </tfoot>\n );\n}\n\nexport type TableRowProps = ComponentProps<'tr'>;\n\n/** One row of cells. */\nexport function TableRow({ className, children, ...props }: TableRowProps) {\n return (\n <tr className={cx('ds-table__row', className)} {...props}>\n {children}\n </tr>\n );\n}\n\n/** A sortable column's state and its handler, which come together or not at all. */\ntype TableHeaderCellSorting =\n | { sort?: undefined; onSortChange?: undefined }\n | {\n /**\n * Makes the column sortable and says how it is sorted now. The head\n * becomes a button, and the sorted column carries `aria-sort`.\n */\n sort: TableSort;\n /**\n * Called with the direction a press asks for: `ascending` from an\n * unsorted or descending column, `descending` from an ascending one.\n * The product sorts its rows and passes the new `sort` back.\n */\n onSortChange: (next: Exclude<TableSort, 'none'>) => void;\n };\n\nexport type TableHeaderCellProps = Omit<ComponentProps<'th'>, 'align'> &\n TableHeaderCellSorting & {\n /** Where the head sits: at the end over a column of numbers. Defaults to `start`. */\n align?: TableAlign;\n /**\n * A control after the label that filters this column, typically an\n * `IconButton` opening a `Popover`. It stays outside the sort button, so\n * opening the filter never re-sorts, and out of the column's name.\n */\n filter?: ReactNode;\n };\n\nconst ARIA_SORT = { ascending: 'ascending', descending: 'descending', none: undefined } as const;\n\n/**\n * A column's head, a `th` scoped to its column, in the small-caps label\n * style. With `sort` it is a button that re-sorts the column; with `filter`\n * it carries the column's filter control beside the label. The column is\n * named by its label alone, so each of its cells is announced with that.\n */\nexport function TableHeaderCell({\n align = 'start',\n sort,\n onSortChange,\n filter,\n className,\n children,\n ...props\n}: TableHeaderCellProps) {\n const icons = useIconDefaults();\n const labelId = useId();\n const text = (\n <span className=\"ds-table__header-label\" id={labelId}>\n {children}\n </span>\n );\n const label =\n sort === undefined ? (\n text\n ) : (\n <button\n className=\"ds-table__sort\"\n data-sort={sort}\n onClick={() => onSortChange(sort === 'ascending' ? 'descending' : 'ascending')}\n type=\"button\"\n >\n {text}\n <span aria-hidden=\"true\" className=\"ds-table__sort-indicator\">\n <Icon decorative size=\"sm\" source={icons.chevronRight} />\n {sort === 'none' ? <Icon decorative size=\"sm\" source={icons.chevronRight} /> : null}\n </span>\n </button>\n );\n return (\n <th\n aria-labelledby={labelId}\n aria-sort={sort === undefined ? undefined : ARIA_SORT[sort]}\n className={cx('ds-table__header-cell', align === 'end' && 'ds-table__cell--end', className)}\n scope=\"col\"\n {...props}\n >\n <span className=\"ds-table__header-content\">\n {label}\n {filter}\n </span>\n </th>\n );\n}\n\nexport interface TableCellProps extends Omit<ComponentProps<'td'>, 'align'> {\n /** Where the content sits. Defaults to `start`; `numeric` puts it at the end. */\n align?: TableAlign;\n /**\n * A number: set at the end of the cell with tabular figures, so a column\n * of amounts lines up digit under digit. Format it (currency, decimals)\n * before passing it in.\n */\n numeric?: boolean;\n /**\n * The cell that names its row, rendered as a `th` scoped to the row, so a\n * screen reader announces it with each of the row's other cells.\n */\n rowHeader?: boolean;\n}\n\n/**\n * One cell of data: text by default, a number with `numeric`, or the row's\n * name with `rowHeader`. A date, a status (`Badge`) or a link to the row's\n * page (`Link`) goes inside as content.\n */\nexport function TableCell({\n align,\n numeric = false,\n rowHeader = false,\n className,\n children,\n ...props\n}: TableCellProps) {\n const end = (align ?? (numeric ? 'end' : 'start')) === 'end';\n const classes = cx(\n 'ds-table__cell',\n end && 'ds-table__cell--end',\n numeric && 'ds-table__cell--numeric',\n rowHeader && 'ds-table__cell--row-header',\n className,\n );\n if (rowHeader) {\n return (\n <th className={classes} scope=\"row\" {...props}>\n {children}\n </th>\n );\n }\n return (\n <td className={classes} {...props}>\n {children}\n </td>\n );\n}\n\nexport type TableActionsCellProps = Omit<TableCellProps, 'align' | 'numeric' | 'rowHeader'>;\n\n/**\n * The row's actions at the end of the row: up to two `IconButton`s, and an\n * `ActionMenu` for any more, so the column stays narrow. Name each button\n * after its row (\"Delete Stratechery\"), since the column head can't.\n */\nexport function TableActionsCell({ className, children, ...props }: TableActionsCellProps) {\n return (\n <td className={cx('ds-table__cell', 'ds-table__cell--actions', className)} {...props}>\n <span className=\"ds-table__actions\">{children}</span>\n </td>\n );\n}\n\nexport interface TableEmptyProps extends ComponentProps<'tr'> {\n /** How many columns the table has, so the message spans all of them. */\n colSpan: number;\n}\n\n/**\n * Stands in for the body's rows when there are none: one row whose single\n * cell spans every column, holding an `EmptyState` that says why.\n */\nexport function TableEmpty({ colSpan, className, children, ...props }: TableEmptyProps) {\n return (\n <tr className={cx('ds-table__row', 'ds-table__empty', className)} {...props}>\n <td className=\"ds-table__cell\" colSpan={colSpan}>\n {children}\n </td>\n </tr>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"table.js","sourceRoot":"","sources":["../../src/table/table.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAuC,KAAK,EAAE,MAAM,OAAO,CAAC;AACnE,OAAO,aAAa,CAAC;AACrB,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAmCxD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,KAAK,CAAC,EACpB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AC1C,QAAQ,GACN,CACN,CAAC;IACJ,CAAC;IACD,OAAO,CACL,aAAI,SAAS,EAAE,OAAO,KAAM,KAAK,YAC9B,QAAQ,GACN,CACN,CAAC;AACJ,CAAC;AAID;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAyB;IACvF,OAAO,CACL,aAAI,SAAS,EAAE,EAAE,CAAC,gBAAgB,EAAE,yBAAyB,EAAE,SAAS,CAAC,KAAM,KAAK,YAClF,eAAM,SAAS,EAAC,mBAAmB,YAAE,QAAQ,GAAQ,GAClD,CACN,CAAC;AACJ,CAAC;AAOD;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAmB;IACpF,OAAO,CACL,aAAI,SAAS,EAAE,EAAE,CAAC,eAAe,EAAE,iBAAiB,EAAE,SAAS,CAAC,KAAM,KAAK,YACzE,aAAI,SAAS,EAAC,gBAAgB,EAAC,OAAO,EAAE,OAAO,YAC5C,QAAQ,GACN,GACF,CACN,CAAC;AACJ,CAAC","sourcesContent":["import { type ComponentProps, type ReactNode, useId } from 'react';\nimport './table.css';\nimport { cx } from '../cx';\nimport { Icon } from '../icon/icon';\nimport { useIconDefaults } from '../icon-defaults';\nimport { ScrollArea } from '../scroll-area/scroll-area';\n\n/** Where a column's content sits: text at the start, numbers at the end. */\nexport type TableAlign = 'start' | 'end';\n\n/** A sortable column's state. `none` is sortable but not the sort in force. */\nexport type TableSort = 'ascending' | 'descending' | 'none';\n\nexport interface TableProps extends ComponentProps<'div'> {\n /**\n * The table's name, required: it names the table for a screen reader and,\n * while the columns overflow, the scroll region around it, which then takes\n * keyboard focus so a table wider than its column can be scrolled with the\n * arrow keys. A table that fits adds no region and no tab stop, unless the\n * region holds focus as the columns come to fit.\n */\n label: string;\n /** Tint every other body row, so a long row is easier to follow across. */\n striped?: boolean;\n /**\n * Highlight the body row under the pointer, to read it across or compare\n * it with its neighbours. Not a sign that the row is clickable: a row that\n * opens something puts a link in its first cell.\n */\n rowHover?: boolean;\n /**\n * What sits above the table: a {@link TableToolbar} with the table's\n * actions (add a row, history), and optionally a search or filter at its\n * start.\n */\n toolbar?: ReactNode;\n /** The rows are loading: marks the table busy while skeleton rows stand in. */\n busy?: boolean;\n}\n\n/**\n * Rows and columns of data in a real `<table>`, so a screen reader can move\n * by row and column and announce each cell's column.\n *\n * A structural primitive, styled against the `--ds-table-*` contract. It\n * holds no data and no sorting of its own: the product passes the rows in\n * the order it wants and owns the sort and filter state, which on a server-\n * paged list is the only place it can live.\n *\n * Compose with {@link TableHead}, {@link TableBody} and {@link TableFoot},\n * made of {@link TableRow}s holding {@link TableHeaderCell}s and\n * {@link TableCell}s; {@link TableActionsCell} holds a row's icon buttons and\n * {@link TableEmpty} stands in for the rows when there are none.\n *\n * The table scrolls sideways inside its box when its columns don't fit, so a\n * phone keeps every column instead of squeezing them. `className` and the\n * other props go to that box, which holds the toolbar and the table.\n */\nexport function Table({\n label,\n striped = false,\n rowHover = false,\n toolbar,\n busy = false,\n className,\n children,\n ...props\n}: TableProps) {\n return (\n <div\n className={cx(\n 'ds-table',\n striped && 'ds-table--striped',\n rowHover && 'ds-table--row-hover',\n className,\n )}\n {...props}\n >\n {toolbar}\n <ScrollArea axis=\"x\" className=\"ds-table__scroll\" label={label}>\n <table aria-busy={busy || undefined} aria-label={label} className=\"ds-table__table\">\n {children}\n </table>\n </ScrollArea>\n </div>\n );\n}\n\nexport interface TableToolbarProps extends ComponentProps<'div'> {\n /** What sits at the start of the row: a search or a filter for the whole table. */\n start?: ReactNode;\n}\n\n/**\n * The row above a table: its actions at the end (add a row, history,\n * export), and optionally a search or filter at the start. Pass it to\n * {@link Table}'s `toolbar`.\n */\nexport function TableToolbar({ start, className, children, ...props }: TableToolbarProps) {\n return (\n <div className={cx('ds-table__toolbar', className)} {...props}>\n {start ? <div className=\"ds-table__toolbar-start\">{start}</div> : null}\n <div className=\"ds-table__toolbar-actions\">{children}</div>\n </div>\n );\n}\n\nexport type TableHeadProps = ComponentProps<'thead'>;\n\n/** The column heads: a {@link TableRow} of {@link TableHeaderCell}s. */\nexport function TableHead({ className, children, ...props }: TableHeadProps) {\n return (\n <thead className={cx('ds-table__head', className)} {...props}>\n {children}\n </thead>\n );\n}\n\nexport type TableBodyProps = ComponentProps<'tbody'>;\n\n/** The data rows. */\nexport function TableBody({ className, children, ...props }: TableBodyProps) {\n return (\n <tbody className={cx('ds-table__body', className)} {...props}>\n {children}\n </tbody>\n );\n}\n\nexport type TableFootProps = ComponentProps<'tfoot'>;\n\n/** A totals row under the data, set apart by a rule and the footer weight. */\nexport function TableFoot({ className, children, ...props }: TableFootProps) {\n return (\n <tfoot className={cx('ds-table__foot', className)} {...props}>\n {children}\n </tfoot>\n );\n}\n\nexport type TableRowProps = ComponentProps<'tr'>;\n\n/** One row of cells. */\nexport function TableRow({ className, children, ...props }: TableRowProps) {\n return (\n <tr className={cx('ds-table__row', className)} {...props}>\n {children}\n </tr>\n );\n}\n\n/** A sortable column's state and its handler, which come together or not at all. */\ntype TableHeaderCellSorting =\n | { sort?: undefined; onSortChange?: undefined }\n | {\n /**\n * Makes the column sortable and says how it is sorted now. The head\n * becomes a button, and the sorted column carries `aria-sort`.\n */\n sort: TableSort;\n /**\n * Called with the direction a press asks for: `ascending` from an\n * unsorted or descending column, `descending` from an ascending one.\n * The product sorts its rows and passes the new `sort` back.\n */\n onSortChange: (next: Exclude<TableSort, 'none'>) => void;\n };\n\nexport type TableHeaderCellProps = Omit<ComponentProps<'th'>, 'align'> &\n TableHeaderCellSorting & {\n /** Where the head sits: at the end over a column of numbers. Defaults to `start`. */\n align?: TableAlign;\n /**\n * A control after the label that filters this column, typically an\n * `IconButton` opening a `Popover`. It stays outside the sort button, so\n * opening the filter never re-sorts, and out of the column's name.\n */\n filter?: ReactNode;\n };\n\nconst ARIA_SORT = { ascending: 'ascending', descending: 'descending', none: undefined } as const;\n\n/**\n * A column's head, a `th` scoped to its column, in the small-caps label\n * style. With `sort` it is a button that re-sorts the column; with `filter`\n * it carries the column's filter control beside the label. The column is\n * named by its label alone, so each of its cells is announced with that.\n */\nexport function TableHeaderCell({\n align = 'start',\n sort,\n onSortChange,\n filter,\n className,\n children,\n ...props\n}: TableHeaderCellProps) {\n const icons = useIconDefaults();\n const labelId = useId();\n const text = (\n <span className=\"ds-table__header-label\" id={labelId}>\n {children}\n </span>\n );\n const label =\n sort === undefined ? (\n text\n ) : (\n <button\n className=\"ds-table__sort\"\n data-sort={sort}\n onClick={() => onSortChange(sort === 'ascending' ? 'descending' : 'ascending')}\n type=\"button\"\n >\n {text}\n <span aria-hidden=\"true\" className=\"ds-table__sort-indicator\">\n <Icon decorative size=\"sm\" source={icons.chevronRight} />\n {sort === 'none' ? <Icon decorative size=\"sm\" source={icons.chevronRight} /> : null}\n </span>\n </button>\n );\n return (\n <th\n aria-labelledby={labelId}\n aria-sort={sort === undefined ? undefined : ARIA_SORT[sort]}\n className={cx('ds-table__header-cell', align === 'end' && 'ds-table__cell--end', className)}\n scope=\"col\"\n {...props}\n >\n <span className=\"ds-table__header-content\">\n {label}\n {filter}\n </span>\n </th>\n );\n}\n\nexport interface TableCellProps extends Omit<ComponentProps<'td'>, 'align'> {\n /** Where the content sits. Defaults to `start`; `numeric` puts it at the end. */\n align?: TableAlign;\n /**\n * A number: set at the end of the cell with tabular figures, so a column\n * of amounts lines up digit under digit. Format it (currency, decimals)\n * before passing it in.\n */\n numeric?: boolean;\n /**\n * The cell that names its row, rendered as a `th` scoped to the row, so a\n * screen reader announces it with each of the row's other cells.\n */\n rowHeader?: boolean;\n}\n\n/**\n * One cell of data: text by default, a number with `numeric`, or the row's\n * name with `rowHeader`. A date, a status (`Badge`) or a link to the row's\n * page (`Link`) goes inside as content.\n */\nexport function TableCell({\n align,\n numeric = false,\n rowHeader = false,\n className,\n children,\n ...props\n}: TableCellProps) {\n const end = (align ?? (numeric ? 'end' : 'start')) === 'end';\n const classes = cx(\n 'ds-table__cell',\n end && 'ds-table__cell--end',\n numeric && 'ds-table__cell--numeric',\n rowHeader && 'ds-table__cell--row-header',\n className,\n );\n if (rowHeader) {\n return (\n <th className={classes} scope=\"row\" {...props}>\n {children}\n </th>\n );\n }\n return (\n <td className={classes} {...props}>\n {children}\n </td>\n );\n}\n\nexport type TableActionsCellProps = Omit<TableCellProps, 'align' | 'numeric' | 'rowHeader'>;\n\n/**\n * The row's actions at the end of the row: up to two `IconButton`s, and an\n * `ActionMenu` for any more, so the column stays narrow. Name each button\n * after its row (\"Delete Stratechery\"), since the column head can't.\n */\nexport function TableActionsCell({ className, children, ...props }: TableActionsCellProps) {\n return (\n <td className={cx('ds-table__cell', 'ds-table__cell--actions', className)} {...props}>\n <span className=\"ds-table__actions\">{children}</span>\n </td>\n );\n}\n\nexport interface TableEmptyProps extends ComponentProps<'tr'> {\n /** How many columns the table has, so the message spans all of them. */\n colSpan: number;\n}\n\n/**\n * Stands in for the body's rows when there are none: one row whose single\n * cell spans every column, holding an `EmptyState` that says why.\n */\nexport function TableEmpty({ colSpan, className, children, ...props }: TableEmptyProps) {\n return (\n <tr className={cx('ds-table__row', 'ds-table__empty', className)} {...props}>\n <td className=\"ds-table__cell\" colSpan={colSpan}>\n {children}\n </td>\n </tr>\n );\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** The axis to watch for overflow. */
|
|
2
|
+
export type OverflowAxis = 'x' | 'y';
|
|
3
|
+
/**
|
|
4
|
+
* Whether a scroller belongs in the tab order: while its content is larger
|
|
5
|
+
* than its box along `axis`, and for as long as it holds focus, so a box
|
|
6
|
+
* whose content comes to fit under the keyboard doesn't drop focus to the
|
|
7
|
+
* page. Focus moving elsewhere re-evaluates it; a switch to another window or
|
|
8
|
+
* tab blurs the element but leaves focus on it, so it keeps its stop.
|
|
9
|
+
*
|
|
10
|
+
* The callback ref measures the element as it attaches, so the first paint is
|
|
11
|
+
* already right. It then measures again when the element's box or one of its
|
|
12
|
+
* children's boxes resizes, and when content anywhere inside is added,
|
|
13
|
+
* removed or rewritten, or is shown or hidden through `hidden`, and when a
|
|
14
|
+
* web font finishes loading, since a late font can widen a no-wrap row with
|
|
15
|
+
* no other change. A style change deeper inside that resizes no child is not
|
|
16
|
+
* seen.
|
|
17
|
+
*
|
|
18
|
+
* Pass `watch: false` to observe nothing.
|
|
19
|
+
*/
|
|
20
|
+
export declare function useOverflow(axis: OverflowAxis, watch?: boolean): readonly [(scroller: HTMLElement | null) => (() => void) | undefined, boolean];
|
|
21
|
+
//# sourceMappingURL=use-overflow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-overflow.d.ts","sourceRoot":"","sources":["../src/use-overflow.ts"],"names":[],"mappings":"AAEA,sCAAsC;AACtC,MAAM,MAAM,YAAY,GAAG,GAAG,GAAG,GAAG,CAAC;AAErC;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,UAAO,wBAI7C,WAAW,GAAG,IAAI,wCA8ChC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Whether a scroller belongs in the tab order: while its content is larger
|
|
4
|
+
* than its box along `axis`, and for as long as it holds focus, so a box
|
|
5
|
+
* whose content comes to fit under the keyboard doesn't drop focus to the
|
|
6
|
+
* page. Focus moving elsewhere re-evaluates it; a switch to another window or
|
|
7
|
+
* tab blurs the element but leaves focus on it, so it keeps its stop.
|
|
8
|
+
*
|
|
9
|
+
* The callback ref measures the element as it attaches, so the first paint is
|
|
10
|
+
* already right. It then measures again when the element's box or one of its
|
|
11
|
+
* children's boxes resizes, and when content anywhere inside is added,
|
|
12
|
+
* removed or rewritten, or is shown or hidden through `hidden`, and when a
|
|
13
|
+
* web font finishes loading, since a late font can widen a no-wrap row with
|
|
14
|
+
* no other change. A style change deeper inside that resizes no child is not
|
|
15
|
+
* seen.
|
|
16
|
+
*
|
|
17
|
+
* Pass `watch: false` to observe nothing.
|
|
18
|
+
*/
|
|
19
|
+
export function useOverflow(axis, watch = true) {
|
|
20
|
+
const [overflows, setOverflows] = useState(false);
|
|
21
|
+
const [focused, setFocused] = useState(false);
|
|
22
|
+
const observe = useCallback((scroller) => {
|
|
23
|
+
if (!scroller || !watch)
|
|
24
|
+
return;
|
|
25
|
+
const measure = () => setOverflows(axis === 'x'
|
|
26
|
+
? scroller.scrollWidth > scroller.clientWidth
|
|
27
|
+
: scroller.scrollHeight > scroller.clientHeight);
|
|
28
|
+
const resizes = new ResizeObserver(measure);
|
|
29
|
+
const observeBoxes = () => {
|
|
30
|
+
resizes.disconnect();
|
|
31
|
+
resizes.observe(scroller);
|
|
32
|
+
for (const child of scroller.children)
|
|
33
|
+
resizes.observe(child);
|
|
34
|
+
};
|
|
35
|
+
observeBoxes();
|
|
36
|
+
measure();
|
|
37
|
+
const mutations = new MutationObserver((records) => {
|
|
38
|
+
if (records.some((record) => record.type === 'childList' && record.target === scroller)) {
|
|
39
|
+
observeBoxes();
|
|
40
|
+
}
|
|
41
|
+
measure();
|
|
42
|
+
});
|
|
43
|
+
mutations.observe(scroller, {
|
|
44
|
+
childList: true,
|
|
45
|
+
characterData: true,
|
|
46
|
+
subtree: true,
|
|
47
|
+
attributeFilter: ['hidden'],
|
|
48
|
+
});
|
|
49
|
+
const fonts = scroller.ownerDocument.fonts;
|
|
50
|
+
fonts?.addEventListener('loadingdone', measure);
|
|
51
|
+
const onFocus = () => setFocused(true);
|
|
52
|
+
const onBlur = () => setFocused(scroller.ownerDocument.activeElement === scroller);
|
|
53
|
+
scroller.addEventListener('focus', onFocus);
|
|
54
|
+
scroller.addEventListener('blur', onBlur);
|
|
55
|
+
setFocused(scroller.ownerDocument.activeElement === scroller);
|
|
56
|
+
return () => {
|
|
57
|
+
resizes.disconnect();
|
|
58
|
+
mutations.disconnect();
|
|
59
|
+
fonts?.removeEventListener('loadingdone', measure);
|
|
60
|
+
scroller.removeEventListener('focus', onFocus);
|
|
61
|
+
scroller.removeEventListener('blur', onBlur);
|
|
62
|
+
};
|
|
63
|
+
}, [axis, watch]);
|
|
64
|
+
return [observe, overflows || focused];
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=use-overflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-overflow.js","sourceRoot":"","sources":["../src/use-overflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAK9C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,WAAW,CAAC,IAAkB,EAAE,KAAK,GAAG,IAAI;IAC1D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,OAAO,GAAG,WAAW,CACzB,CAAC,QAA4B,EAAE,EAAE;QAC/B,IAAI,CAAC,QAAQ,IAAI,CAAC,KAAK;YAAE,OAAO;QAChC,MAAM,OAAO,GAAG,GAAG,EAAE,CACnB,YAAY,CACV,IAAI,KAAK,GAAG;YACV,CAAC,CAAC,QAAQ,CAAC,WAAW,GAAG,QAAQ,CAAC,WAAW;YAC7C,CAAC,CAAC,QAAQ,CAAC,YAAY,GAAG,QAAQ,CAAC,YAAY,CAClD,CAAC;QACJ,MAAM,OAAO,GAAG,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC;QAC5C,MAAM,YAAY,GAAG,GAAG,EAAE;YACxB,OAAO,CAAC,UAAU,EAAE,CAAC;YACrB,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAC1B,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,QAAQ;gBAAE,OAAO,CAAC,OAAO,CAAC,KAAK,CA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AC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC/C,QAAQ,CAAC,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC/C,CAAC,CAAC;IACJ,CAAC,EACD,CAAC,IAAI,EAAE,KAAK,CAAC,CACd,CAAC;IACF,OAAO,CAAC,OAAO,EAAE,SAAS,IAAI,OAAO,CAAU,CAAC;AAClD,CAAC","sourcesContent":["import { useCallback, useState } from 'react';\n\n/** The axis to watch for overflow. */\nexport type OverflowAxis = 'x' | 'y';\n\n/**\n * Whether a scroller belongs in the tab order: while its content is larger\n * than its box along `axis`, and for as long as it holds focus, so a box\n * whose content comes to fit under the keyboard doesn't drop focus to the\n * page. Focus moving elsewhere re-evaluates it; a switch to another window or\n * tab blurs the element but leaves focus on it, so it keeps its stop.\n *\n * The callback ref measures the element as it attaches, so the first paint is\n * already right. It then measures again when the element's box or one of its\n * children's boxes resizes, and when content anywhere inside is added,\n * removed or rewritten, or is shown or hidden through `hidden`, and when a\n * web font finishes loading, since a late font can widen a no-wrap row with\n * no other change. A style change deeper inside that resizes no child is not\n * seen.\n *\n * Pass `watch: false` to observe nothing.\n */\nexport function useOverflow(axis: OverflowAxis, watch = true) {\n const [overflows, setOverflows] = useState(false);\n const [focused, setFocused] = useState(false);\n const observe = useCallback(\n (scroller: HTMLElement | null) => {\n if (!scroller || !watch) return;\n const measure = () =>\n setOverflows(\n axis === 'x'\n ? scroller.scrollWidth > scroller.clientWidth\n : scroller.scrollHeight > scroller.clientHeight,\n );\n const resizes = new ResizeObserver(measure);\n const observeBoxes = () => {\n resizes.disconnect();\n resizes.observe(scroller);\n for (const child of scroller.children) resizes.observe(child);\n };\n observeBoxes();\n measure();\n const mutations = new MutationObserver((records) => {\n if (records.some((record) => record.type === 'childList' && record.target === scroller)) {\n observeBoxes();\n }\n measure();\n });\n mutations.observe(scroller, {\n childList: true,\n characterData: true,\n subtree: true,\n attributeFilter: ['hidden'],\n });\n const fonts = scroller.ownerDocument.fonts;\n fonts?.addEventListener('loadingdone', measure);\n const onFocus = () => setFocused(true);\n const onBlur = () => setFocused(scroller.ownerDocument.activeElement === scroller);\n scroller.addEventListener('focus', onFocus);\n scroller.addEventListener('blur', onBlur);\n setFocused(scroller.ownerDocument.activeElement === scroller);\n return () => {\n resizes.disconnect();\n mutations.disconnect();\n fonts?.removeEventListener('loadingdone', measure);\n scroller.removeEventListener('focus', onFocus);\n scroller.removeEventListener('blur', onBlur);\n };\n },\n [axis, watch],\n );\n return [observe, overflows || focused] as const;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manakind/ui-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -112,6 +112,10 @@
|
|
|
112
112
|
"types": "./dist/menu/index.d.ts",
|
|
113
113
|
"import": "./dist/menu/index.js"
|
|
114
114
|
},
|
|
115
|
+
"./nav-list": {
|
|
116
|
+
"types": "./dist/nav-list/index.d.ts",
|
|
117
|
+
"import": "./dist/nav-list/index.js"
|
|
118
|
+
},
|
|
115
119
|
"./page-layout": {
|
|
116
120
|
"types": "./dist/page-layout/index.d.ts",
|
|
117
121
|
"import": "./dist/page-layout/index.js"
|
|
@@ -168,6 +172,10 @@
|
|
|
168
172
|
"types": "./dist/split-layout/index.d.ts",
|
|
169
173
|
"import": "./dist/split-layout/index.js"
|
|
170
174
|
},
|
|
175
|
+
"./status-dot": {
|
|
176
|
+
"types": "./dist/status-dot/index.d.ts",
|
|
177
|
+
"import": "./dist/status-dot/index.js"
|
|
178
|
+
},
|
|
171
179
|
"./sticky": {
|
|
172
180
|
"types": "./dist/sticky/index.d.ts",
|
|
173
181
|
"import": "./dist/sticky/index.js"
|
|
@@ -284,6 +292,10 @@
|
|
|
284
292
|
"types": "./dist/menu/menu.css.d.ts",
|
|
285
293
|
"default": "./dist/menu/menu.css"
|
|
286
294
|
},
|
|
295
|
+
"./css/nav-list": {
|
|
296
|
+
"types": "./dist/nav-list/nav-list.css.d.ts",
|
|
297
|
+
"default": "./dist/nav-list/nav-list.css"
|
|
298
|
+
},
|
|
287
299
|
"./css/page-layout": {
|
|
288
300
|
"types": "./dist/page-layout/page-layout.css.d.ts",
|
|
289
301
|
"default": "./dist/page-layout/page-layout.css"
|
|
@@ -340,6 +352,10 @@
|
|
|
340
352
|
"types": "./dist/split-layout/split-layout.css.d.ts",
|
|
341
353
|
"default": "./dist/split-layout/split-layout.css"
|
|
342
354
|
},
|
|
355
|
+
"./css/status-dot": {
|
|
356
|
+
"types": "./dist/status-dot/status-dot.css.d.ts",
|
|
357
|
+
"default": "./dist/status-dot/status-dot.css"
|
|
358
|
+
},
|
|
343
359
|
"./css/sticky": {
|
|
344
360
|
"types": "./dist/sticky/sticky.css.d.ts",
|
|
345
361
|
"default": "./dist/sticky/sticky.css"
|
|
@@ -396,7 +412,7 @@
|
|
|
396
412
|
},
|
|
397
413
|
"devDependencies": {
|
|
398
414
|
"@manakind/ds-config": "*",
|
|
399
|
-
"@manakind/manuia-tokens": "0.
|
|
415
|
+
"@manakind/manuia-tokens": "0.33.0",
|
|
400
416
|
"@testing-library/jest-dom": "^6.9.1",
|
|
401
417
|
"@testing-library/react": "^16.3.2",
|
|
402
418
|
"@testing-library/user-event": "^14.6.1",
|