@manakind/ui-core 0.3.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -60,18 +60,22 @@ separately, so an app can load only what it renders.
60
60
  | `@manakind/ui-core/badge` | `Badge` |
61
61
  | `@manakind/ui-core/button` | `Button` + `IconButton` |
62
62
  | `@manakind/ui-core/card` | `Card`, `CardHeader`, `CardTitle`, `CardDescription`, `CardContent`, `CardFooter` |
63
+ | `@manakind/ui-core/dialog` | `Dialog` + `DialogClose` |
63
64
  | `@manakind/ui-core/icon` | `Icon` |
64
65
  | `@manakind/ui-core/illustration` | `Illustration` + `illustrationPaint` |
65
66
  | `@manakind/ui-core/progress` | `Progress` |
66
67
  | `@manakind/ui-core/select` | `Select` |
68
+ | `@manakind/ui-core/switch` | `Switch` |
67
69
  | `@manakind/ui-core/tabs` | `Tabs`, `TabsList`, `TabsTrigger`, `TabsContent` |
68
70
  | `@manakind/ui-core/css/badge` | Badge structural CSS |
69
71
  | `@manakind/ui-core/css/button` | Button + IconButton structural CSS |
70
72
  | `@manakind/ui-core/css/card` | Card structural CSS |
73
+ | `@manakind/ui-core/css/dialog` | Dialog structural CSS; its close button also needs `css/button` and `css/icon` |
71
74
  | `@manakind/ui-core/css/icon` | Icon structural CSS |
72
75
  | `@manakind/ui-core/css/illustration` | Illustration structural CSS, including the paint roles |
73
76
  | `@manakind/ui-core/css/progress` | Progress structural CSS |
74
77
  | `@manakind/ui-core/css/select` | Select structural CSS |
78
+ | `@manakind/ui-core/css/switch` | Switch structural CSS |
75
79
  | `@manakind/ui-core/css/tabs` | Tabs structural CSS |
76
80
 
77
81
  Structural CSS is only half of what a component needs — it consumes `--ds-*` custom
@@ -0,0 +1,24 @@
1
+ import { type ReactElement } from 'react';
2
+ export interface DialogCloseProps {
3
+ /**
4
+ * The one element that closes the dialog, usually a `Button`. It keeps its
5
+ * own look, label and `ref`; DialogClose adds the closing click.
6
+ */
7
+ children: ReactElement;
8
+ }
9
+ /**
10
+ * Makes its child close the enclosing `Dialog` when activated.
11
+ *
12
+ * ```tsx
13
+ * <DialogClose>
14
+ * <Button variant="secondary">Cancel</Button>
15
+ * </DialogClose>
16
+ * ```
17
+ *
18
+ * Use it for the dismissive action, or for a committing one that should
19
+ * close at once. Closing goes through the dialog's `onOpenChange`, so a
20
+ * controlled dialog decides, as it does for Escape. Must be rendered inside
21
+ * a `Dialog` — in its `actions` or its body.
22
+ */
23
+ export declare function DialogClose({ children }: DialogCloseProps): import("react/jsx-runtime").JSX.Element;
24
+ //# sourceMappingURL=dialog-close.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dialog-close.d.ts","sourceRoot":"","sources":["../../src/dialog/dialog-close.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,YAAY,EAAS,MAAM,OAAO,CAAC;AAEjD,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,QAAQ,EAAE,YAAY,CAAC;CACxB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,EAAE,QAAQ,EAAE,EAAE,gBAAgB,2CASzD"}
@@ -0,0 +1,24 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Dialog as ArkDialog } from '@ark-ui/react/dialog';
3
+ import { useId } from 'react';
4
+ /**
5
+ * Makes its child close the enclosing `Dialog` when activated.
6
+ *
7
+ * ```tsx
8
+ * <DialogClose>
9
+ * <Button variant="secondary">Cancel</Button>
10
+ * </DialogClose>
11
+ * ```
12
+ *
13
+ * Use it for the dismissive action, or for a committing one that should
14
+ * close at once. Closing goes through the dialog's `onOpenChange`, so a
15
+ * controlled dialog decides, as it does for Escape. Must be rendered inside
16
+ * a `Dialog` — in its `actions` or its body.
17
+ */
18
+ export function DialogClose({ children }) {
19
+ // Ark gives every close trigger in a dialog the same id; a dialog with a
20
+ // close button and a Cancel would otherwise carry it twice.
21
+ const id = useId();
22
+ return (_jsx(ArkDialog.CloseTrigger, { asChild: true, id: id, children: children }));
23
+ }
24
+ //# sourceMappingURL=dialog-close.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dialog-close.js","sourceRoot":"","sources":["../../src/dialog/dialog-close.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAqB,KAAK,EAAE,MAAM,OAAO,CAAC;AAUjD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,WAAW,CAAC,EAAE,QAAQ,EAAoB;IACxD,yEAAyE;IACzE,4DAA4D;IAC5D,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC;IACnB,OAAO,CACL,KAAC,SAAS,CAAC,YAAY,IAAC,OAAO,QAAC,EAAE,EAAE,EAAE,YACnC,QAAQ,GACc,CAC1B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,127 @@
1
+ @layer components {
2
+ /*
3
+ * The backdrop and positioner portal into `<body>` as siblings of the page,
4
+ * so they are styled at the top level rather than under `.ds-dialog`.
5
+ *
6
+ * Both sit at 50, the layer the product apps give their own popovers,
7
+ * dialogs and sticky headers, so the dialog covers all of the page. The
8
+ * positioner comes after the backdrop in the DOM and so paints above it at
9
+ * the same index. Select's listbox sits at 60 and opens above a dialog.
10
+ */
11
+ .ds-dialog__backdrop {
12
+ position: fixed;
13
+ inset: 0;
14
+ z-index: 50;
15
+ background-color: var(--ds-dialog-backdrop-bg);
16
+ }
17
+
18
+ .ds-dialog__positioner {
19
+ position: fixed;
20
+ inset: 0;
21
+ z-index: 50;
22
+ display: flex;
23
+ align-items: center;
24
+ justify-content: center;
25
+ padding: var(--ds-dialog-positioner-padding);
26
+ box-sizing: border-box;
27
+ }
28
+
29
+ /*
30
+ * The border carries the separation in dark themes, where a shadow on a
31
+ * dark page barely reads; the shadow carries it in light. Both are always
32
+ * drawn, so neither theme depends on the other's cue.
33
+ */
34
+ .ds-dialog {
35
+ /*
36
+ * The focus ring of a control, stated once as Tabs does: the body's own
37
+ * ring draws it, and the body leaves room for its controls' rings.
38
+ */
39
+ --_dialog-ring-width: 2px;
40
+ --_dialog-ring-offset: 3px;
41
+ --_dialog-ring-reach: calc(var(--_dialog-ring-width) + var(--_dialog-ring-offset));
42
+
43
+ display: flex;
44
+ flex-direction: column;
45
+ gap: var(--ds-dialog-gap);
46
+ box-sizing: border-box;
47
+ inline-size: 100%;
48
+ max-inline-size: var(--ds-dialog-max-inline-size);
49
+ max-block-size: 100%;
50
+ padding: var(--ds-dialog-padding);
51
+ border: 1px solid var(--ds-dialog-border);
52
+ border-radius: var(--ds-dialog-radius);
53
+ background-color: var(--ds-dialog-bg);
54
+ box-shadow: var(--ds-dialog-shadow);
55
+ color: var(--ds-dialog-text);
56
+
57
+ /*
58
+ * The panel takes focus only as the focus trap's fallback, when nothing
59
+ * inside it can, as while every action is disabled mid-commit. It is not
60
+ * a control and is never in the tab order, so it draws no ring.
61
+ */
62
+ &:focus-visible {
63
+ outline: none;
64
+ }
65
+
66
+ & .ds-dialog__header {
67
+ display: flex;
68
+ align-items: flex-start;
69
+ gap: var(--ds-dialog-header-gap);
70
+ }
71
+
72
+ & .ds-dialog__heading {
73
+ display: flex;
74
+ flex: 1;
75
+ flex-direction: column;
76
+ gap: var(--ds-dialog-header-gap);
77
+ min-inline-size: 0;
78
+ }
79
+
80
+ & .ds-dialog__title {
81
+ margin: 0;
82
+ font-family: var(--ds-dialog-title-font-family);
83
+ font-size: var(--ds-dialog-title-font-size);
84
+ font-weight: var(--ds-dialog-title-font-weight);
85
+ }
86
+
87
+ & .ds-dialog__description {
88
+ margin: 0;
89
+ color: var(--ds-dialog-text-muted);
90
+ }
91
+
92
+ & .ds-dialog__close {
93
+ flex-shrink: 0;
94
+ }
95
+
96
+ /*
97
+ * Only the body scrolls. `min-block-size: 0` lets it shrink below its
98
+ * content inside the column, which is what keeps the title and the
99
+ * actions in view when the content is taller than the viewport.
100
+ *
101
+ * A scroll container clips whatever is drawn past its padding, and a
102
+ * full-width control's focus ring is drawn past the body. So the body is
103
+ * larger than its content by the ring's reach and takes that back with a
104
+ * negative margin, as TabsList's scroller does. The panel's own padding
105
+ * is wider than the reach, so nothing moves.
106
+ */
107
+ & .ds-dialog__body {
108
+ flex: 1 1 auto;
109
+ min-block-size: 0;
110
+ margin: calc(-1 * var(--_dialog-ring-reach));
111
+ padding: var(--_dialog-ring-reach);
112
+ overflow-y: auto;
113
+
114
+ &:focus-visible {
115
+ outline: var(--_dialog-ring-width) solid var(--ds-dialog-focus-ring);
116
+ outline-offset: var(--_dialog-ring-offset);
117
+ }
118
+ }
119
+
120
+ & .ds-dialog__actions {
121
+ display: flex;
122
+ flex-wrap: wrap;
123
+ justify-content: flex-end;
124
+ gap: var(--ds-dialog-actions-gap);
125
+ }
126
+ }
127
+ }
@@ -0,0 +1,2 @@
1
+ /* AUTOGENERATED: types for the stylesheet beside it. */
2
+ export {};
@@ -0,0 +1,104 @@
1
+ import { type ReactElement, type ReactNode, type RefObject } from 'react';
2
+ import type { IconSource } from '../icon/icon';
3
+ import './dialog.css';
4
+ export type DialogRole = 'dialog' | 'alertdialog';
5
+ export interface DialogProps {
6
+ /**
7
+ * The dialog's name: rendered as its `<h2>` heading and announced when it
8
+ * opens (`aria-labelledby`). Write it as a short statement or question —
9
+ * "Remove “Site foreman”?".
10
+ */
11
+ title: ReactNode;
12
+ /**
13
+ * One or two sentences under the title, announced with it
14
+ * (`aria-describedby`). For a confirmation, say what the action does and
15
+ * what it leaves alone.
16
+ */
17
+ description?: ReactNode;
18
+ /** Body content. Scrolls inside the panel when it outgrows the viewport. */
19
+ children?: ReactNode;
20
+ /**
21
+ * The footer's buttons, end-aligned, in reading order: the dismissive one
22
+ * first, the committing one last. They wrap onto a second line on a narrow
23
+ * screen. Wrap a dismissive button in `DialogClose` to make it close.
24
+ */
25
+ actions?: ReactNode;
26
+ /**
27
+ * The one element that opens the dialog, such as a `Button`. Focus returns
28
+ * to it when the dialog closes. Leave it out to open the dialog with
29
+ * `open` from elsewhere.
30
+ */
31
+ trigger?: ReactElement;
32
+ /** Controlled open state. Pair with `onOpenChange`. */
33
+ open?: boolean;
34
+ /** Initial open state when uncontrolled. */
35
+ defaultOpen?: boolean;
36
+ /**
37
+ * Fired with the requested state whenever the dialog asks to open (its
38
+ * trigger) or close (a `DialogClose`, the close button, Escape, or for
39
+ * `role="dialog"` a click outside). A controlled dialog stays as it is
40
+ * until `open` changes.
41
+ */
42
+ onOpenChange?: (open: boolean) => void;
43
+ /**
44
+ * `dialog` (default) shows a close button and closes on Escape and on a
45
+ * click outside. `alertdialog` is for confirmations: no close button, and a
46
+ * click outside does nothing, so the explicit cancel action is the way
47
+ * out. Escape still cancels.
48
+ */
49
+ role?: DialogRole;
50
+ /**
51
+ * Where focus lands when the dialog opens. Defaults to the first focusable
52
+ * element: the close button of a `dialog`, the first action of an
53
+ * `alertdialog` with no focusable body. Point an alertdialog at its least
54
+ * destructive action.
55
+ */
56
+ initialFocusRef?: RefObject<HTMLElement | null>;
57
+ /** Accessible name of the close button. Translate it with the rest of the UI. */
58
+ closeLabel?: string;
59
+ /**
60
+ * Glyph for the close button. Defaults to a plain built-in cross so
61
+ * `@manakind/ui-core` renders on its own; products pass their own icon set,
62
+ * as they do for Select's indicators.
63
+ */
64
+ closeIcon?: IconSource;
65
+ /** Extra class names appended to the panel's `ds-dialog`. */
66
+ className?: string;
67
+ }
68
+ /**
69
+ * A modal dialog: a raised panel over a dimmed page, built on Ark UI.
70
+ *
71
+ * Ark owns the behaviour: the focus trap, focus returning to the trigger,
72
+ * Escape, the page's scroll lock, `aria-modal`, and the title and
73
+ * description wiring. This wrapper adds the `ds-` classes, the
74
+ * `--ds-dialog-*` bindings, and a slot API in place of Ark's anatomy.
75
+ *
76
+ * ```tsx
77
+ * <Dialog
78
+ * role="alertdialog"
79
+ * title="Remove “Site foreman”?"
80
+ * description="2 people and 1 Landfall lose this type; nothing else is deleted."
81
+ * trigger={<Button variant="secondary">Remove</Button>}
82
+ * initialFocusRef={cancelRef}
83
+ * actions={
84
+ * <>
85
+ * <DialogClose>
86
+ * <Button ref={cancelRef} variant="secondary">Cancel</Button>
87
+ * </DialogClose>
88
+ * <Button onClick={remove}>Remove</Button>
89
+ * </>
90
+ * }
91
+ * />
92
+ * ```
93
+ *
94
+ * The committing action is the consumer's own button. To close after it
95
+ * runs, control the dialog with `open` and set it false in the handler, or
96
+ * wrap the button in `DialogClose` when closing at once is right.
97
+ *
98
+ * The backdrop and panel portal into `<body>` at `z-index: 50`, the layer
99
+ * the product apps use for their own overlays. A Select inside the dialog
100
+ * portals into its panel (see `PortalContainerContext`) and opens at 60,
101
+ * above it. Nothing is mounted while the dialog is closed.
102
+ */
103
+ export declare function Dialog({ title, description, children, actions, trigger, open, defaultOpen, onOpenChange, role, initialFocusRef, closeLabel, closeIcon, className, }: DialogProps): import("react/jsx-runtime").JSX.Element;
104
+ //# sourceMappingURL=dialog.d.ts.map
@@ -0,0 +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,EAIf,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,cAAc,CAAC;AAGtB,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,aAAa,CAAC;AAElD,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,KAAK,EAAE,SAAS,CAAC;IACjB;;;;OAIG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;;OAIG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB;;;;OAIG;IACH,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,uDAAuD;IACvD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,4CAA4C;IAC5C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAChD,iFAAiF;IACjF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,MAAM,CAAC,EACrB,KAAK,EACL,WAAW,EACX,QAAQ,EACR,OAAO,EACP,OAAO,EACP,IAAI,EACJ,WAAW,EACX,YAAY,EACZ,IAAe,EACf,eAAe,EACf,UAAoB,EACpB,SAAiB,EACjB,SAAS,GACV,EAAE,WAAW,2CAuDb"}
@@ -0,0 +1,82 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Dialog as ArkDialog } from '@ark-ui/react/dialog';
3
+ import { Portal } from '@ark-ui/react/portal';
4
+ import { useCallback, useRef, useState, } from 'react';
5
+ import { IconButton } from '../button/icon-button';
6
+ import { PortalContainerContext } from '../portal-container';
7
+ import './dialog.css';
8
+ import { cx } from '../cx';
9
+ /**
10
+ * A modal dialog: a raised panel over a dimmed page, built on Ark UI.
11
+ *
12
+ * Ark owns the behaviour: the focus trap, focus returning to the trigger,
13
+ * Escape, the page's scroll lock, `aria-modal`, and the title and
14
+ * description wiring. This wrapper adds the `ds-` classes, the
15
+ * `--ds-dialog-*` bindings, and a slot API in place of Ark's anatomy.
16
+ *
17
+ * ```tsx
18
+ * <Dialog
19
+ * role="alertdialog"
20
+ * title="Remove “Site foreman”?"
21
+ * description="2 people and 1 Landfall lose this type; nothing else is deleted."
22
+ * trigger={<Button variant="secondary">Remove</Button>}
23
+ * initialFocusRef={cancelRef}
24
+ * actions={
25
+ * <>
26
+ * <DialogClose>
27
+ * <Button ref={cancelRef} variant="secondary">Cancel</Button>
28
+ * </DialogClose>
29
+ * <Button onClick={remove}>Remove</Button>
30
+ * </>
31
+ * }
32
+ * />
33
+ * ```
34
+ *
35
+ * The committing action is the consumer's own button. To close after it
36
+ * runs, control the dialog with `open` and set it false in the handler, or
37
+ * wrap the button in `DialogClose` when closing at once is right.
38
+ *
39
+ * The backdrop and panel portal into `<body>` at `z-index: 50`, the layer
40
+ * the product apps use for their own overlays. A Select inside the dialog
41
+ * portals into its panel (see `PortalContainerContext`) and opens at 60,
42
+ * above it. Nothing is mounted while the dialog is closed.
43
+ */
44
+ export function Dialog({ title, description, children, actions, trigger, open, defaultOpen, onOpenChange, role = 'dialog', initialFocusRef, closeLabel = 'Close', closeIcon = Cross, className, }) {
45
+ const dismissible = role === 'dialog';
46
+ const panelRef = useRef(null);
47
+ const handleOpenChange = (details) => onOpenChange?.(details.open);
48
+ // Zag types this as returning `HTMLElement | null`, but its focus trap
49
+ // reads undefined as "the first focusable element" and, given null, fails
50
+ // to start at all, leaving the page reachable by Tab.
51
+ const initialFocusEl = (() => initialFocusRef?.current ?? undefined);
52
+ return (_jsxs(ArkDialog.Root, { open: open, defaultOpen: defaultOpen, onOpenChange: handleOpenChange, role: role, closeOnInteractOutside: dismissible, initialFocusEl: initialFocusEl, lazyMount: true, unmountOnExit: true, children: [trigger && _jsx(ArkDialog.Trigger, { asChild: true, children: trigger }), _jsxs(Portal, { children: [_jsx(ArkDialog.Backdrop, { className: "ds-dialog__backdrop" }), _jsx(ArkDialog.Positioner, { className: "ds-dialog__positioner", children: _jsx(ArkDialog.Content, { ref: panelRef, className: cx('ds-dialog', className), children: _jsxs(PortalContainerContext.Provider, { value: panelRef, children: [_jsxs("div", { className: "ds-dialog__header", children: [_jsxs("div", { className: "ds-dialog__heading", children: [_jsx(ArkDialog.Title, { className: "ds-dialog__title", children: title }), description && (_jsx(ArkDialog.Description, { className: "ds-dialog__description", children: description }))] }), dismissible && (_jsx(ArkDialog.CloseTrigger, { asChild: true, children: _jsx(IconButton, { icon: closeIcon, "aria-label": closeLabel, variant: "tertiary", size: "sm", className: "ds-dialog__close" }) }))] }), children && _jsx(DialogBody, { children: children }), actions && _jsx("div", { className: "ds-dialog__actions", children: actions })] }) }) })] })] }));
53
+ }
54
+ /**
55
+ * The scrolling body. While its content overflows it joins the tab order, so
56
+ * a keyboard user can focus it and scroll; a body with nothing to scroll
57
+ * stays out of the way.
58
+ *
59
+ * Two boxes are observed because either can change the answer: the outer one
60
+ * resizes with the viewport, the inner one with the content.
61
+ */
62
+ function DialogBody({ children }) {
63
+ const [scrollable, setScrollable] = useState(false);
64
+ const observe = useCallback((scroller) => {
65
+ const content = scroller?.firstElementChild;
66
+ if (!scroller || !content)
67
+ return;
68
+ const observer = new ResizeObserver(() => setScrollable(scroller.scrollHeight > scroller.clientHeight));
69
+ observer.observe(scroller);
70
+ observer.observe(content);
71
+ return () => observer.disconnect();
72
+ }, []);
73
+ return (_jsx("div", { ref: observe, className: "ds-dialog__body", tabIndex: scrollable ? 0 : undefined, children: _jsx("div", { className: "ds-dialog__body-content", children: children }) }));
74
+ }
75
+ /*
76
+ * Fallback glyph, inlined for the reason Select's are: ui-core is public and
77
+ * may not reference the private icon package, so a default that ships inside
78
+ * it cannot be a licensed icon. Products override it via `closeIcon`.
79
+ */
80
+ const Cross = (props) => (_jsx("svg", { "aria-hidden": "true", viewBox: "0 0 16 16", fill: "none", ...props, children: _jsx("path", { d: "m4 4 8 8m0-8-8 8", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }) }));
81
+ Cross.displayName = 'DialogCross';
82
+ //# sourceMappingURL=dialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../src/dialog/dialog.tsx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B,CAAC;QAC5C,IAAI,CAAC,QAAQ,IAAI,CAAC,OAAO;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;AAED;;;;GAIG;AACH,MAAM,KAAK,GAAe,CAAC,KAAK,EAAE,EAAE,CAAC,CACnC,6BAAiB,MAAM,EAAC,OAAO,EAAC,WAAW,EAAC,IAAI,EAAC,MAAM,KAAK,KAAK,YAC/D,eACE,CAAC,EAAC,kBAAkB,EACpB,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,KAAK,EACjB,aAAa,EAAC,OAAO,GACrB,GACE,CACP,CAAC;AACF,KAAK,CAAC,WAAW,GAAG,aAAa,CAAC"}
@@ -0,0 +1,5 @@
1
+ export type { DialogProps, DialogRole } from './dialog';
2
+ export { Dialog } from './dialog';
3
+ export type { DialogCloseProps } from './dialog-close';
4
+ export { DialogClose } from './dialog-close';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dialog/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { Dialog } from './dialog';
2
+ export { DialogClose } from './dialog-close';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dialog/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -2,9 +2,11 @@ export * from './badge';
2
2
  export * from './button';
3
3
  export * from './card';
4
4
  export { cx } from './cx';
5
+ export * from './dialog';
5
6
  export * from './icon';
6
7
  export * from './illustration';
7
8
  export * from './progress';
8
9
  export * from './select';
10
+ export * from './switch';
9
11
  export * from './tabs';
10
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
package/dist/index.js CHANGED
@@ -2,9 +2,11 @@ export * from './badge';
2
2
  export * from './button';
3
3
  export * from './card';
4
4
  export { cx } from './cx';
5
+ export * from './dialog';
5
6
  export * from './icon';
6
7
  export * from './illustration';
7
8
  export * from './progress';
8
9
  export * from './select';
10
+ export * from './switch';
9
11
  export * from './tabs';
10
12
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { type RefObject } from 'react';
2
+ /**
3
+ * Where a ui-core popup portals to. Unset, popups portal into `<body>`.
4
+ *
5
+ * A modal `Dialog` sets it to its panel. While a modal is open, Ark hides
6
+ * every sibling of the panel in `<body>` from assistive tech, once, when it
7
+ * opens; a popup portalled there afterwards, such as a Select's listbox,
8
+ * would be focused but hidden. Rendered inside the panel, it stays readable,
9
+ * inside the focus trap, and inside the area a click does not dismiss.
10
+ */
11
+ export declare const PortalContainerContext: import("react").Context<RefObject<HTMLElement | null> | undefined>;
12
+ //# sourceMappingURL=portal-container.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"portal-container.d.ts","sourceRoot":"","sources":["../src/portal-container.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtD;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,oEAElC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { createContext } from 'react';
2
+ /**
3
+ * Where a ui-core popup portals to. Unset, popups portal into `<body>`.
4
+ *
5
+ * A modal `Dialog` sets it to its panel. While a modal is open, Ark hides
6
+ * every sibling of the panel in `<body>` from assistive tech, once, when it
7
+ * opens; a popup portalled there afterwards, such as a Select's listbox,
8
+ * would be focused but hidden. Rendered inside the panel, it stays readable,
9
+ * inside the focus trap, and inside the area a click does not dismiss.
10
+ */
11
+ export const PortalContainerContext = createContext(undefined);
12
+ //# sourceMappingURL=portal-container.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"portal-container.js","sourceRoot":"","sources":["../src/portal-container.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAkB,MAAM,OAAO,CAAC;AAEtD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,aAAa,CACjD,SAAS,CACV,CAAC"}
@@ -131,7 +131,9 @@ export interface SelectProps {
131
131
  * The listbox renders in a portal, so it escapes ancestor `overflow: hidden`
132
132
  * rather than being clipped inside a card. It sits at `z-index: 60`, a step
133
133
  * above the products' overlay layer (50), so it paints above the page or
134
- * dialog it opens from.
134
+ * dialog it opens from. Inside a ui-core `Dialog` it portals into the
135
+ * dialog's panel instead of `<body>`, so the modal does not hide it from
136
+ * assistive tech.
135
137
  */
136
138
  export declare function Select({ items, label, placeholder, value, defaultValue, onValueChange, size, disabled, loading, loadingText, invalid, name, className, renderItem, indicator, itemIndicator, 'aria-label': ariaLabel, }: SelectProps): import("react/jsx-runtime").JSX.Element;
137
139
  //# sourceMappingURL=select.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../src/select/select.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAwB,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,cAAc,CAAC;AAGtB,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE5C,MAAM,WAAW,UAAU;IACzB,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,8BAA8B;IAC9B,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB;;;;OAIG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,4CAA4C;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;;;;;;;;;;;;OAiBG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,uCAAuC;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;;;;;;;;;;;OAgBG;IACH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IACpD,qCAAqC;IACrC,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,iCAAiC;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;;;OAOG;IAC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,EACP,IAAI,EACJ,SAAS,EACT,UAAU,EACV,SAAwB,EACxB,aAAqB,EACrB,YAAY,EAAE,SAAS,GACxB,EAAE,WAAW,2CA8Fb"}
@@ -1,8 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Portal } from '@ark-ui/react/portal';
3
3
  import { Select as ArkSelect, createListCollection } from '@ark-ui/react/select';
4
- import { useCallback, useMemo } from 'react';
4
+ import { useCallback, useContext, useMemo } from 'react';
5
5
  import { Icon } from '../icon/icon';
6
+ import { PortalContainerContext } from '../portal-container';
6
7
  import './select.css';
7
8
  import { cx } from '../cx';
8
9
  /**
@@ -30,7 +31,9 @@ import { cx } from '../cx';
30
31
  * The listbox renders in a portal, so it escapes ancestor `overflow: hidden`
31
32
  * rather than being clipped inside a card. It sits at `z-index: 60`, a step
32
33
  * above the products' overlay layer (50), so it paints above the page or
33
- * dialog it opens from.
34
+ * dialog it opens from. Inside a ui-core `Dialog` it portals into the
35
+ * dialog's panel instead of `<body>`, so the modal does not hide it from
36
+ * assistive tech.
34
37
  */
35
38
  export function Select({ items, label, placeholder, value, defaultValue, onValueChange, size = 'md', disabled, loading = false, loadingText = 'Loading…', invalid, name, className, renderItem, indicator = ChevronRight, itemIndicator = Check, 'aria-label': ariaLabel, }) {
36
39
  const collection = useMemo(() => createListCollection({
@@ -65,8 +68,9 @@ export function Select({ items, label, placeholder, value, defaultValue, onValue
65
68
  return undefined;
66
69
  return items.some((item) => item.value === defaultValue) ? [defaultValue] : [];
67
70
  }, [defaultValue, items]);
71
+ const portalContainer = useContext(PortalContainerContext);
68
72
  const handleValueChange = useCallback((details) => onValueChange?.(details.value[0]), [onValueChange]);
69
- return (_jsxs(ArkSelect.Root, { collection: collection, className: cx('ds-select', `ds-select--${size}`, className), value: controlledValue, defaultValue: initialValue, onValueChange: handleValueChange, disabled: disabled || loading, invalid: invalid, name: name, positioning: { sameWidth: true }, children: [label && _jsx(ArkSelect.Label, { className: "ds-select__label", children: label }), _jsx(ArkSelect.Control, { children: _jsxs(ArkSelect.Trigger, { className: "ds-select__trigger", "aria-label": ariaLabel, "aria-busy": loading || undefined, children: [_jsx(ArkSelect.ValueText, { placeholder: loading ? loadingText : placeholder, className: "ds-select__value-text" }), _jsx(ArkSelect.Indicator, { className: "ds-select__indicator", children: _jsx(Icon, { source: indicator, size: "sm", decorative: true }) })] }) }), _jsx(Portal, { children: _jsx(ArkSelect.Positioner, { children: _jsx(ArkSelect.Content, { className: "ds-select__content", children: items.map((item) => (_jsxs(ArkSelect.Item, { item: item, className: "ds-select__item", children: [_jsx(ArkSelect.ItemText, { children: renderItem ? renderItem(item) : item.label }), _jsx(ArkSelect.ItemIndicator, { className: "ds-select__item-indicator", children: _jsx(Icon, { source: itemIndicator, size: "sm", decorative: true }) })] }, item.value))) }) }) }), _jsx(ArkSelect.HiddenSelect, {})] }));
73
+ return (_jsxs(ArkSelect.Root, { collection: collection, className: cx('ds-select', `ds-select--${size}`, className), value: controlledValue, defaultValue: initialValue, onValueChange: handleValueChange, disabled: disabled || loading, invalid: invalid, name: name, positioning: { sameWidth: true }, children: [label && _jsx(ArkSelect.Label, { className: "ds-select__label", children: label }), _jsx(ArkSelect.Control, { children: _jsxs(ArkSelect.Trigger, { className: "ds-select__trigger", "aria-label": ariaLabel, "aria-busy": loading || undefined, children: [_jsx(ArkSelect.ValueText, { placeholder: loading ? loadingText : placeholder, className: "ds-select__value-text" }), _jsx(ArkSelect.Indicator, { className: "ds-select__indicator", children: _jsx(Icon, { source: indicator, size: "sm", decorative: true }) })] }) }), _jsx(Portal, { container: portalContainer, children: _jsx(ArkSelect.Positioner, { children: _jsx(ArkSelect.Content, { className: "ds-select__content", children: items.map((item) => (_jsxs(ArkSelect.Item, { item: item, className: "ds-select__item", children: [_jsx(ArkSelect.ItemText, { children: renderItem ? renderItem(item) : item.label }), _jsx(ArkSelect.ItemIndicator, { className: "ds-select__item-indicator", children: _jsx(Icon, { source: itemIndicator, size: "sm", decorative: true }) })] }, item.value))) }) }) }), _jsx(ArkSelect.HiddenSelect, {})] }));
70
74
  }
71
75
  /*
72
76
  * Fallback glyphs, inlined on purpose.
@@ -1 +1 @@
1
- {"version":3,"file":"select.js","sourceRoot":"","sources":["../../src/select/select.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAkB,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAmB,MAAM,cAAc,CAAC;AACrD,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AA8G3B;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,MAAM,CAAC,EACrB,KAAK,EACL,KAAK,EACL,WAAW,EACX,KAAK,EACL,YAAY,EACZ,aAAa,EACb,IAAI,GAAG,IAAI,EACX,QAAQ,EACR,OAAO,GAAG,KAAK,EACf,WAAW,GAAG,UAAU,EACxB,OAAO,EACP,IAAI,EACJ,SAAS,EACT,UAAU,EACV,SAAS,GAAG,YAAY,EACxB,aAAa,GAAG,KAAK,EACrB,YAAY,EAAE,SAAS,GACX;IACZ,MAAM,UAAU,GAAG,OAAO,CACxB,GAAG,EAAE,CACH,oBAAoB,CAAC;QACnB,KAAK;QACL,WAAW,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK;QACjC,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK;QAClC,cAAc,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,IAAI,KAAK;KACjD,CAAC,EACJ,CAAC,KAAK,CAAC,CACR,CAAC;IAEF;;;;;;;;;;;OAWG;IACH,MAAM,eAAe,GAAG,OAAO,CA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K,EACjB,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,GACtB,GACE,CACP,CAAC;AACF,KAAK,CAAC,WAAW,GAAG,aAAa,CAAC"}
@@ -0,0 +1,3 @@
1
+ export type { SwitchLabelPlacement, SwitchProps, SwitchSize } from './switch';
2
+ export { Switch } from './switch';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/switch/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,oBAAoB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { Switch } from './switch';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/switch/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,141 @@
1
+ @layer components {
2
+ .ds-switch {
3
+ /*
4
+ * Underscore-prefixed, NOT `--ds-`: that namespace is the contract a
5
+ * product implements. These are the component's own derivations from it.
6
+ *
7
+ * The thumb is the track's height less its border and inset on each
8
+ * side, and it travels the difference between the track's width and
9
+ * height, so the gap around it is the same at every size and in every
10
+ * state: the invalid state widens the border and the thumb shrinks with
11
+ * it.
12
+ */
13
+ --_switch-track-border-width: 1px;
14
+ --_switch-track-inset: 2px;
15
+ --_switch-thumb-size: calc(
16
+ var(--_switch-track-height) -
17
+ 2 *
18
+ var(--_switch-track-border-width) -
19
+ 2 *
20
+ var(--_switch-track-inset)
21
+ );
22
+ --_switch-thumb-travel: calc(var(--_switch-track-width) - var(--_switch-track-height));
23
+
24
+ display: inline-flex;
25
+ align-items: center;
26
+ gap: var(--ds-switch-label-gap);
27
+ color: var(--ds-switch-label-text);
28
+ font-size: var(--_switch-font-size);
29
+ cursor: pointer;
30
+
31
+ &[data-disabled] {
32
+ cursor: not-allowed;
33
+ }
34
+
35
+ &[data-readonly] {
36
+ cursor: default;
37
+ }
38
+
39
+ & .ds-switch__control {
40
+ box-sizing: border-box;
41
+ display: inline-flex;
42
+ align-items: center;
43
+ flex-shrink: 0;
44
+ width: var(--_switch-track-width);
45
+ height: var(--_switch-track-height);
46
+ padding: var(--_switch-track-inset);
47
+ border: var(--_switch-track-border-width) solid var(--ds-switch-track-border);
48
+ border-radius: var(--ds-switch-track-radius);
49
+ background-color: var(--ds-switch-track-bg);
50
+ transition:
51
+ background-color 150ms cubic-bezier(0, 0, 0.2, 1),
52
+ border-color 150ms cubic-bezier(0, 0, 0.2, 1);
53
+
54
+ /*
55
+ * The border stays in the checked state. The checked fill is a brand
56
+ * colour that may not clear 3:1 against the page on its own (Manuia's
57
+ * olive does not in light), so the border is what bounds the track.
58
+ */
59
+ &[data-state="checked"] {
60
+ background-color: var(--ds-switch-track-bg-checked);
61
+ }
62
+
63
+ /*
64
+ * Thicker as well as red, as on Select: colour alone is a weak signal on
65
+ * a control, and this one has to survive a red-green colour deficiency.
66
+ * Scoped above `checked` on purpose, so an invalid switch keeps saying
67
+ * so in either state.
68
+ */
69
+ &[data-invalid] {
70
+ --_switch-track-border-width: 2px;
71
+
72
+ border-color: var(--ds-switch-track-border-invalid);
73
+ }
74
+
75
+ /*
76
+ * Ark moves focus to the hidden input and mirrors its `:focus-visible`
77
+ * onto the control as a data attribute, so the ring is drawn here, where
78
+ * the user is looking. Same ring as every control: 2px, 3px out.
79
+ */
80
+ &[data-focus-visible] {
81
+ outline: 2px solid var(--ds-switch-focus-ring);
82
+ outline-offset: 3px;
83
+ }
84
+
85
+ &[data-disabled] {
86
+ opacity: var(--ds-opacity-disabled);
87
+ }
88
+ }
89
+
90
+ /*
91
+ * The thumb carries its own border. On the resting track it sits on a
92
+ * neighbouring neutral, where its fill alone is near-invisible, and the
93
+ * thumb's position is what says "off".
94
+ */
95
+ & .ds-switch__thumb {
96
+ box-sizing: border-box;
97
+ width: var(--_switch-thumb-size);
98
+ height: var(--_switch-thumb-size);
99
+ border: 1px solid var(--ds-switch-thumb-border);
100
+ border-radius: var(--ds-switch-track-radius);
101
+ background-color: var(--ds-switch-thumb-bg);
102
+ box-shadow: var(--ds-switch-thumb-shadow);
103
+ transition: translate 150ms cubic-bezier(0, 0, 0.2, 1);
104
+
105
+ /*
106
+ * On the checked track the thumb's fill may not contrast with the fill
107
+ * behind it, so the border changes with the state. A product whose
108
+ * thumb already contrasts sets it to the thumb's own colour.
109
+ */
110
+ &[data-state="checked"] {
111
+ border-color: var(--ds-switch-thumb-border-checked);
112
+ translate: var(--_switch-thumb-travel) 0;
113
+ }
114
+ }
115
+
116
+ @media (prefers-reduced-motion: reduce) {
117
+ & .ds-switch__control,
118
+ & .ds-switch__thumb {
119
+ transition: none;
120
+ }
121
+ }
122
+
123
+ &.ds-switch--sm {
124
+ --_switch-track-width: var(--ds-switch-size-sm-track-width);
125
+ --_switch-track-height: var(--ds-switch-size-sm-track-height);
126
+ --_switch-font-size: var(--ds-switch-size-sm-font-size);
127
+ }
128
+
129
+ &.ds-switch--md {
130
+ --_switch-track-width: var(--ds-switch-size-md-track-width);
131
+ --_switch-track-height: var(--ds-switch-size-md-track-height);
132
+ --_switch-font-size: var(--ds-switch-size-md-font-size);
133
+ }
134
+
135
+ &.ds-switch--lg {
136
+ --_switch-track-width: var(--ds-switch-size-lg-track-width);
137
+ --_switch-track-height: var(--ds-switch-size-lg-track-height);
138
+ --_switch-font-size: var(--ds-switch-size-lg-font-size);
139
+ }
140
+ }
141
+ }
@@ -0,0 +1,2 @@
1
+ /* AUTOGENERATED: types for the stylesheet beside it. */
2
+ export {};
@@ -0,0 +1,76 @@
1
+ import { type ReactNode } from 'react';
2
+ import './switch.css';
3
+ export type SwitchSize = 'sm' | 'md' | 'lg';
4
+ export type SwitchLabelPlacement = 'start' | 'end';
5
+ /**
6
+ * A switch has to have a name. A visible `label` is the one to reach for: the
7
+ * whole label is the click target, so it also enlarges the hit area. Expressed
8
+ * as a union so an unnamed switch is a compile error rather than an axe
9
+ * finding, the way `IconProps` pairs label and decorative.
10
+ */
11
+ type SwitchName = {
12
+ /** Visible label. The whole label is the click target. */
13
+ label: ReactNode;
14
+ 'aria-label'?: string;
15
+ } | {
16
+ label?: undefined;
17
+ /** Accessible name when no visible label fits, such as a table cell whose row already says what the switch is. */
18
+ 'aria-label': string;
19
+ };
20
+ export type SwitchProps = SwitchName & {
21
+ /**
22
+ * Which side of the control the label sits on. `end` (default) reads
23
+ * "control, then what it does"; `start` puts the label first, for a
24
+ * settings row. Only the order changes; the row's layout is the caller's.
25
+ */
26
+ labelPlacement?: SwitchLabelPlacement;
27
+ /** Controlled checked state. Leave undefined to let the component own it. */
28
+ checked?: boolean;
29
+ /** Initial state when uncontrolled. */
30
+ defaultChecked?: boolean;
31
+ /** Fired with the new state whenever the user toggles the switch. */
32
+ onCheckedChange?: (checked: boolean) => void;
33
+ /** Control size and label type scale. */
34
+ size?: SwitchSize;
35
+ /** Disable the control. It keeps its state and stops responding. */
36
+ disabled?: boolean;
37
+ /**
38
+ * Marks the control invalid for assistive tech and styling (`data-invalid`).
39
+ * Pair it with a message the control points at through `aria-describedby`;
40
+ * a red border alone is not an accessible error.
41
+ */
42
+ invalid?: boolean;
43
+ /** Id of the element that describes the control, such as an error message. */
44
+ 'aria-describedby'?: string;
45
+ /** Show the state without letting the user change it. */
46
+ readOnly?: boolean;
47
+ /** Marks the hidden input required for native form validation. */
48
+ required?: boolean;
49
+ /** Name for native form participation. */
50
+ name?: string;
51
+ /** Value submitted under `name` while checked. Defaults to `on`. */
52
+ value?: string;
53
+ /** Extra class names appended after the `ds-switch` modifiers. */
54
+ className?: string;
55
+ };
56
+ /**
57
+ * On/off control for a setting that takes effect at once, built on Ark UI.
58
+ *
59
+ * Ark owns the behaviour: a hidden checkbox carries the checked state, the
60
+ * root is the `<label>` that names it, and keyboard (Space) and pointer
61
+ * toggling come for free. The input is given `role="switch"` and
62
+ * `aria-readonly` here, which Ark leaves off, so it is announced as a switch
63
+ * rather than a checkbox, and a read-only one says so. This wrapper contributes `ds-`
64
+ * classes, the `--ds-switch-*` bindings, and a flat prop API.
65
+ *
66
+ * ```tsx
67
+ * <Switch label="Gap view" checked={gapView} onCheckedChange={setGapView} />
68
+ * ```
69
+ *
70
+ * A switch is for a setting that applies immediately. A choice that is only
71
+ * saved on submit is a checkbox; a choice between several values is a select
72
+ * or a segmented control.
73
+ */
74
+ export declare function Switch({ label, labelPlacement, checked, defaultChecked, onCheckedChange, size, disabled, invalid, readOnly, required, name, value, className, 'aria-label': ariaLabel, 'aria-describedby': ariaDescribedBy, }: SwitchProps): import("react/jsx-runtime").JSX.Element;
75
+ export {};
76
+ //# sourceMappingURL=switch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../src/switch/switch.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAU,MAAM,OAAO,CAAC;AAC/C,OAAO,cAAc,CAAC;AAGtB,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE5C,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,KAAK,CAAC;AAEnD;;;;;GAKG;AACH,KAAK,UAAU,GACX;IACE,0DAA0D;IAC1D,KAAK,EAAE,SAAS,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GACD;IACE,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,kHAAkH;IAClH,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEN,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG;IACrC;;;;OAIG;IACH,cAAc,CAAC,EAAE,oBAAoB,CAAC;IACtC,6EAA6E;IAC7E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,uCAAuC;IACvC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,qEAAqE;IACrE,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7C,yCAAyC;IACzC,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,oEAAoE;IACpE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8EAA8E;IAC9E,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,yDAAyD;IACzD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kEAAkE;IAClE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,0CAA0C;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,MAAM,CAAC,EACrB,KAAK,EACL,cAAsB,EACtB,OAAO,EACP,cAAc,EACd,eAAe,EACf,IAAW,EACX,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,SAAS,EACT,YAAY,EAAE,SAAS,EACvB,kBAAkB,EAAE,eAAe,GACpC,EAAE,WAAW,2CA+Cb"}
@@ -0,0 +1,42 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Switch as ArkSwitch } from '@ark-ui/react/switch';
3
+ import { useRef } from 'react';
4
+ import './switch.css';
5
+ import { cx } from '../cx';
6
+ /**
7
+ * On/off control for a setting that takes effect at once, built on Ark UI.
8
+ *
9
+ * Ark owns the behaviour: a hidden checkbox carries the checked state, the
10
+ * root is the `<label>` that names it, and keyboard (Space) and pointer
11
+ * toggling come for free. The input is given `role="switch"` and
12
+ * `aria-readonly` here, which Ark leaves off, so it is announced as a switch
13
+ * rather than a checkbox, and a read-only one says so. This wrapper contributes `ds-`
14
+ * classes, the `--ds-switch-*` bindings, and a flat prop API.
15
+ *
16
+ * ```tsx
17
+ * <Switch label="Gap view" checked={gapView} onCheckedChange={setGapView} />
18
+ * ```
19
+ *
20
+ * A switch is for a setting that applies immediately. A choice that is only
21
+ * saved on submit is a checkbox; a choice between several values is a select
22
+ * or a segmented control.
23
+ */
24
+ export function Switch({ label, labelPlacement = 'end', checked, defaultChecked, onCheckedChange, size = 'md', disabled, invalid, readOnly, required, name, value, className, 'aria-label': ariaLabel, 'aria-describedby': ariaDescribedBy, }) {
25
+ const labelNode = label ? (_jsx(ArkSwitch.Label, { className: "ds-switch__label", children: label })) : null;
26
+ const inputRef = useRef(null);
27
+ /*
28
+ * Ark renders the hidden input uncontrolled (`defaultChecked`) and syncs it
29
+ * only when its own state changes. A controlled parent that declines a
30
+ * toggle therefore leaves the native input flipped while the control shows
31
+ * the old state, and assistive tech reads the input. Ark reports the toggle
32
+ * after reading the input, so restoring the parent's value here is safe:
33
+ * a parent that accepts re-renders, and Ark syncs the input again.
34
+ */
35
+ const handleCheckedChange = (details) => {
36
+ onCheckedChange?.(details.checked);
37
+ if (checked !== undefined && inputRef.current)
38
+ inputRef.current.checked = checked;
39
+ };
40
+ return (_jsxs(ArkSwitch.Root, { className: cx('ds-switch', `ds-switch--${size}`, className), checked: checked, defaultChecked: defaultChecked, onCheckedChange: handleCheckedChange, disabled: disabled, invalid: invalid, readOnly: readOnly, required: required, name: name, value: value, children: [labelPlacement === 'start' && labelNode, _jsx(ArkSwitch.Control, { className: "ds-switch__control", children: _jsx(ArkSwitch.Thumb, { className: "ds-switch__thumb" }) }), labelPlacement === 'end' && labelNode, _jsx(ArkSwitch.HiddenInput, { ref: inputRef, role: "switch", "aria-label": ariaLabel, "aria-describedby": ariaDescribedBy, "aria-readonly": readOnly || undefined })] }));
41
+ }
42
+ //# sourceMappingURL=switch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switch.js","sourceRoot":"","sources":["../../src/switch/switch.tsx"],"names":[],"mappings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Q,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,aAEX,cAAc,KAAK,OAAO,IAAI,SAAS,EACxC,KAAC,SAAS,CAAC,OAAO,IAAC,SAAS,EAAC,oBAAoB,YAC/C,KAAC,SAAS,CAAC,KAAK,IAAC,SAAS,EAAC,kBAAkB,GAAG,GAC9B,EACnB,cAAc,KAAK,KAAK,IAAI,SAAS,EACtC,KAAC,SAAS,CAAC,WAAW,IACpB,GAAG,EAAE,QAAQ,EACb,IAAI,EAAC,QAAQ,gBACD,SAAS,sBACH,eAAe,mBAClB,QAAQ,IAAI,SAAS,GACpC,IACa,CAClB,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manakind/ui-core",
3
- "version": "0.3.1",
3
+ "version": "0.5.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -36,6 +36,10 @@
36
36
  "types": "./dist/card/index.d.ts",
37
37
  "import": "./dist/card/index.js"
38
38
  },
39
+ "./dialog": {
40
+ "types": "./dist/dialog/index.d.ts",
41
+ "import": "./dist/dialog/index.js"
42
+ },
39
43
  "./css/badge": {
40
44
  "types": "./dist/badge/badge.css.d.ts",
41
45
  "default": "./dist/badge/badge.css"
@@ -48,6 +52,10 @@
48
52
  "types": "./dist/card/card.css.d.ts",
49
53
  "default": "./dist/card/card.css"
50
54
  },
55
+ "./css/dialog": {
56
+ "types": "./dist/dialog/dialog.css.d.ts",
57
+ "default": "./dist/dialog/dialog.css"
58
+ },
51
59
  "./css/icon": {
52
60
  "types": "./dist/icon/icon.css.d.ts",
53
61
  "default": "./dist/icon/icon.css"
@@ -64,6 +72,10 @@
64
72
  "types": "./dist/select/select.css.d.ts",
65
73
  "default": "./dist/select/select.css"
66
74
  },
75
+ "./css/switch": {
76
+ "types": "./dist/switch/switch.css.d.ts",
77
+ "default": "./dist/switch/switch.css"
78
+ },
67
79
  "./css/tabs": {
68
80
  "types": "./dist/tabs/tabs.css.d.ts",
69
81
  "default": "./dist/tabs/tabs.css"
@@ -84,6 +96,10 @@
84
96
  "types": "./dist/select/index.d.ts",
85
97
  "import": "./dist/select/index.js"
86
98
  },
99
+ "./switch": {
100
+ "types": "./dist/switch/index.d.ts",
101
+ "import": "./dist/switch/index.js"
102
+ },
87
103
  "./tabs": {
88
104
  "types": "./dist/tabs/index.d.ts",
89
105
  "import": "./dist/tabs/index.js"
@@ -106,7 +122,7 @@
106
122
  },
107
123
  "devDependencies": {
108
124
  "@manakind/ds-config": "*",
109
- "@manakind/manuia-tokens": "0.3.0",
125
+ "@manakind/manuia-tokens": "0.5.0",
110
126
  "@testing-library/jest-dom": "^6.9.1",
111
127
  "@testing-library/react": "^16.3.2",
112
128
  "@testing-library/user-event": "^14.6.1",