@mistriwork/ui 1.0.0-rc.58 → 1.0.0-rc.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/README.md +46 -12
  2. package/dist/Avatar.js +3 -3
  3. package/dist/Button.d.ts +4 -14
  4. package/dist/Button.js +26 -13
  5. package/dist/Carousel.d.ts +6 -5
  6. package/dist/Carousel.js +58 -67
  7. package/dist/Choices.d.ts +2 -9
  8. package/dist/Choices.js +127 -64
  9. package/dist/DateField.d.ts +9 -4
  10. package/dist/DateField.js +102 -119
  11. package/dist/Drawer.d.ts +1 -19
  12. package/dist/Drawer.js +8 -9
  13. package/dist/DropMenu.d.ts +8 -21
  14. package/dist/DropMenu.js +84 -30
  15. package/dist/Dropdown.d.ts +9 -8
  16. package/dist/Dropdown.js +69 -65
  17. package/dist/Field.d.ts +2 -1
  18. package/dist/Field.js +12 -18
  19. package/dist/FileField.d.ts +3 -10
  20. package/dist/FileField.js +12 -9
  21. package/dist/FormParts.d.ts +17 -10
  22. package/dist/FormParts.js +26 -41
  23. package/dist/HeroBlocks.d.ts +7 -3
  24. package/dist/HeroBlocks.js +11 -6
  25. package/dist/Modal.d.ts +6 -17
  26. package/dist/Modal.js +90 -21
  27. package/dist/Pagination.d.ts +1 -12
  28. package/dist/Pagination.js +17 -3
  29. package/dist/Popover.d.ts +1 -15
  30. package/dist/Popover.js +10 -15
  31. package/dist/Resizable.d.ts +3 -21
  32. package/dist/Resizable.js +14 -91
  33. package/dist/ScrollArea.d.ts +4 -2
  34. package/dist/ScrollArea.js +11 -11
  35. package/dist/Select.d.ts +1 -6
  36. package/dist/Select.js +16 -7
  37. package/dist/SensitiveField.d.ts +1 -8
  38. package/dist/SensitiveField.js +6 -4
  39. package/dist/Slider.d.ts +1 -5
  40. package/dist/Slider.js +13 -5
  41. package/dist/Switch.d.ts +1 -11
  42. package/dist/Switch.js +10 -9
  43. package/dist/Tabs.d.ts +3 -3
  44. package/dist/Tabs.js +3 -3
  45. package/dist/TextArea.d.ts +4 -6
  46. package/dist/TextArea.js +14 -5
  47. package/dist/TextField.d.ts +5 -9
  48. package/dist/TextField.js +67 -9
  49. package/dist/Tooltip.d.ts +1 -21
  50. package/dist/Tooltip.js +13 -31
  51. package/dist/Typeahead.d.ts +15 -18
  52. package/dist/Typeahead.js +151 -86
  53. package/dist/UiKit.d.ts +63 -4
  54. package/dist/UiKit.js +46 -5
  55. package/dist/behaviors/DaysParts.js +28 -0
  56. package/dist/behaviors/EditableParts.js +21 -0
  57. package/dist/behaviors/PickParts.js +30 -0
  58. package/dist/behaviors/ScrubParts.js +21 -0
  59. package/dist/behaviors/SortableParts.js +32 -0
  60. package/dist/behaviors/SpansParts.js +12 -0
  61. package/dist/behaviors/TransferParts.js +37 -0
  62. package/dist/behaviors/TurnsParts.js +31 -0
  63. package/dist/behaviors/WidthsParts.js +27 -0
  64. package/dist/behaviors/days.js +216 -0
  65. package/dist/behaviors/dress.js +86 -0
  66. package/dist/behaviors/editable.js +104 -0
  67. package/dist/behaviors/heard.js +22 -0
  68. package/dist/behaviors/index.d.ts +310 -0
  69. package/dist/behaviors/index.js +44 -0
  70. package/dist/behaviors/pick.js +158 -0
  71. package/dist/behaviors/scrub.js +152 -0
  72. package/dist/behaviors/sortable.js +170 -0
  73. package/dist/behaviors/spans.js +240 -0
  74. package/dist/behaviors/testing.js +48 -0
  75. package/dist/behaviors/transfer.js +202 -0
  76. package/dist/behaviors/turns.js +106 -0
  77. package/dist/behaviors/widths.js +150 -0
  78. package/dist/behaviors.css +309 -0
  79. package/dist/changeDetails.d.ts +4 -8
  80. package/dist/changeDetails.js +0 -6
  81. package/dist/conformance.js +107 -1
  82. package/dist/controls.css +36 -0
  83. package/dist/fieldFrame.d.ts +2 -15
  84. package/dist/fieldFrame.js +1 -17
  85. package/dist/index.d.ts +6 -5
  86. package/dist/index.js +6 -5
  87. package/dist/internal/Frame.d.ts +6 -0
  88. package/dist/internal/Frame.js +25 -0
  89. package/dist/internal/HelpTip.d.ts +5 -0
  90. package/dist/internal/HelpTip.js +37 -0
  91. package/dist/internal/layers.d.ts +21 -0
  92. package/dist/internal/layers.js +66 -0
  93. package/dist/internal/popups.d.ts +12 -10
  94. package/dist/internal/popups.js +18 -14
  95. package/dist/internal/told.d.ts +14 -0
  96. package/dist/internal/told.js +20 -0
  97. package/dist/internal/uiKitContext.js +6 -4
  98. package/dist/preferences.css +2 -3
  99. package/dist/style.css +5 -16
  100. package/dist/styles/extras.css +463 -0
  101. package/dist/styles/forms.css +346 -0
  102. package/dist/styles/guard.css +114 -0
  103. package/dist/styles/kit-fields.css +181 -0
  104. package/dist/styles/kit-parts.css +130 -0
  105. package/dist/styles/kit.css +558 -0
  106. package/dist/styles/layers.css +4 -0
  107. package/dist/styles/looks.css +374 -0
  108. package/dist/styles/m-tokens.css +173 -0
  109. package/dist/styles/overlays.css +107 -0
  110. package/dist/styles/parts.css +456 -0
  111. package/dist/styles/screens.css +76 -0
  112. package/dist/styles/ui-sdk.css +1635 -0
  113. package/dist/tokens.css +15 -4
  114. package/dist/uiKitSlots.d.ts +1 -1
  115. package/dist/uiKitSlots.js +18 -2
  116. package/package.json +13 -11
  117. package/dist/forms.css +0 -225
  118. package/dist/hero.css +0 -23
  119. package/dist/internal/anchor.d.ts +0 -19
  120. package/dist/internal/anchor.js +0 -52
  121. package/dist/primitives.css +0 -200
  122. package/dist/standalone.css +0 -478
package/dist/Drawer.d.ts CHANGED
@@ -1,23 +1,5 @@
1
- /**
2
- * A drawer: a sheet that slides in from an edge, over Base UI's Drawer,
3
- * which gives it the scrim, focus held inside, Escape and a click on the
4
- * scrim to dismiss, focus handed back on close, and the swipe to dismiss
5
- * on a phone. Controlled with `open`/`onOpenChange`; a closed drawer is
6
- * dismissed (its exit animation aside, the sheet stays in the tree only
7
- * while that runs), so nothing inside it is read while it is shut.
8
- * `side` is the edge it comes from, right by default,
9
- * and the panel is at most 420px wide (a left drawer the same), full
10
- * width on a phone. The sheet is named by its `title` or, where it draws
11
- * none, by `ariaLabel`; one of the two is required.
12
- *
13
- * It wears what a layer wears: a scrim over the whole window, a head with the
14
- * title and a close control (`closeLabel` says its word), an edge against the
15
- * page, and the scope of the component that drew it, so a page's own classes
16
- * apply to the markup it puts in here as they do in the page (Modal.tsx does
17
- * the same).
18
- */
19
1
  import { type ReactNode } from 'react';
20
- import { type ChangeDetails } from './changeDetails.js';
2
+ import type { ChangeDetails } from './changeDetails.js';
21
3
  export type DrawerSide = 'left' | 'right';
22
4
  interface DrawerBase {
23
5
  open: boolean;
package/dist/Drawer.js CHANGED
@@ -1,11 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  /**
3
- * A drawer: a sheet that slides in from an edge, over Base UI's Drawer,
3
+ * A drawer: a sheet that slides in from an edge, over UI SDK's Drawer,
4
4
  * which gives it the scrim, focus held inside, Escape and a click on the
5
5
  * scrim to dismiss, focus handed back on close, and the swipe to dismiss
6
6
  * on a phone. Controlled with `open`/`onOpenChange`; a closed drawer is
7
- * dismissed (its exit animation aside, the sheet stays in the tree only
8
- * while that runs), so nothing inside it is read while it is shut.
7
+ * out of the tree, so nothing inside it is read while it is shut.
9
8
  * `side` is the edge it comes from, right by default,
10
9
  * and the panel is at most 420px wide (a left drawer the same), full
11
10
  * width on a phone. The sheet is named by its `title` or, where it draws
@@ -17,22 +16,22 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
17
16
  * apply to the markup it puts in here as they do in the page (Modal.tsx does
18
17
  * the same).
19
18
  */
19
+ import { Drawer as Sheet, DrawerBackdrop, DrawerClose, DrawerContent, DrawerTitle } from '@ui-sdk/react/drawer';
20
20
  import { useContext } from 'react';
21
- import { Drawer as BaseDrawer } from '@base-ui/react/drawer';
22
21
  import { ComponentStyleScope } from './internal/ComponentStyleScope.js';
22
+ import { heard } from './internal/layers.js';
23
23
  import { popupContainer } from './internal/popups.js';
24
- import { fromBaseUi } from './changeDetails.js';
25
24
  import { slotted } from './internal/uiKitContext.js';
26
25
  function DefaultDrawer({ open, onOpenChange, side = 'right', title, ariaLabel, children, className, closeDisabled = false, closeLabel = 'Close', }) {
27
26
  const componentScope = useContext(ComponentStyleScope);
28
- return (_jsx(BaseDrawer.Root, { open: open, disablePointerDismissal: closeDisabled, onOpenChange: (next, details) => {
27
+ return (_jsxs(Sheet, { container: popupContainer(), open: open, side: side, onOpenChange: (next, details) => {
29
28
  /* A non-cancellable operation: a dismissal request (Escape, a
30
29
  click outside) is refused here, as Modal's beforeClose refuses
31
30
  one, and the controlled drawer stays open. */
32
31
  if (!next && closeDisabled)
33
- return;
34
- onOpenChange?.(next, fromBaseUi(details, 'implicit'));
35
- }, children: _jsxs(BaseDrawer.Portal, { container: popupContainer(), children: [_jsx(BaseDrawer.Backdrop, { className: "ui-drawer-backdrop" }), _jsx(BaseDrawer.Viewport, { className: ['ui-drawer-viewport', `ui-drawer-${side}`, className].filter(Boolean).join(' '), "data-component": componentScope, children: _jsxs(BaseDrawer.Popup, { className: "ui-drawer", "aria-label": ariaLabel ?? (typeof title === 'string' ? title : undefined), children: [_jsxs("div", { className: "ui-drawer-head", children: [title !== undefined ? _jsx(BaseDrawer.Title, { className: "ui-drawer-title", children: title }) : null, _jsx(BaseDrawer.Close, { className: "ui-drawer-close", "aria-label": closeLabel, disabled: closeDisabled, children: _jsx("svg", { viewBox: "0 0 16 16", width: "16", height: "16", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "M3.5 3.5l9 9M12.5 3.5l-9 9", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }) }) })] }), children] }) })] }) }));
32
+ return details.cancel();
33
+ onOpenChange?.(next, heard(details));
34
+ }, children: [_jsx(DrawerBackdrop, {}), _jsxs(DrawerContent, { "data-kind": "sheet", "data-component": componentScope, className: className, "aria-label": ariaLabel ?? (typeof title === 'string' ? title : undefined), children: [_jsxs("header", { "data-slot": "sheet-head", children: [title !== undefined ? _jsx(DrawerTitle, { children: title }) : _jsx("span", {}), _jsx(DrawerClose, { "aria-label": closeLabel, disabled: closeDisabled, "data-variant": "quiet", children: _jsx("svg", { viewBox: "0 0 16 16", width: "16", height: "16", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "M3.5 3.5l9 9M12.5 3.5l-9 9", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }) }) })] }), _jsx("div", { "data-slot": "sheet-body", children: children })] })] }));
36
35
  }
37
36
  /* Slotted (UiKit.tsx): an App's control kit may draw its own in place of the default, with the same props. */
38
37
  export const Drawer = slotted('Drawer', DefaultDrawer, { onOpenChange: [1, 'implicit'] });
@@ -1,38 +1,25 @@
1
- /**
2
- * A button that opens a menu, over Base UI's Menu — what the `<details>`
3
- * menus here did with a summary and a hook (react to a click, close on
4
- * Escape or a click outside, hand focus back), plus what they never did:
5
- * arrows between the items, Home and End, typeahead, and the roles a
6
- * screen reader expects of a menu.
7
- *
8
- * The wrapper keeps the caller's class (`export`, `pb-picker`) because the
9
- * stylesheet places the control by it; the trigger and the popup wear the
10
- * classes the summary and the panel wore. The popup is anchored on the
11
- * zoom-aware ruler (anchor.ts) and fixed to the viewport, so a scrolling
12
- * panel cannot clip it. The open state can be the caller's, for a menu
13
- * that has to stay up while a click inside it fetches.
14
- */
15
- import { type ReactNode, type Ref } from 'react';
16
- import { Menu } from '@base-ui/react/menu';
17
- import { type ChangeDetails } from './changeDetails.js';
1
+ import { type ReactNode, type Ref, type RefObject } from 'react';
2
+ import type { ChangeDetails } from './changeDetails.js';
18
3
  interface DropMenuProps {
19
4
  /** The wrapper's class — where the stylesheet places the control. */
20
5
  className?: string;
21
- /** The trigger's classes; a secondary button's by default. */
6
+ /** The trigger's classes, in place of the menu's own trigger, which is a secondary button: a trigger that has them
7
+ * says `data-own` and is dressed by them alone. */
22
8
  triggerClassName?: string;
23
9
  triggerTitle?: string;
24
10
  /** The trigger's accessible name, when its visible label is shared with another menu on the page. */
25
11
  triggerLabel?: string;
26
12
  label: ReactNode;
27
- /** The popup's classes; the house listbox surface (`dd-list`) by default. */
13
+ /** The popup's classes, over the menu's own surface. */
28
14
  popupClassName?: string;
29
15
  side?: 'top' | 'bottom';
30
16
  align?: 'start' | 'end';
31
17
  sideOffset?: number;
32
18
  open?: boolean;
33
19
  onOpenChange?: (open: boolean, details: ChangeDetails<'trigger-hover' | 'trigger-focus' | 'trigger-press' | 'outside-press' | 'focus-out' | 'list-navigation' | 'escape-key' | 'item-press' | 'close-press' | 'sibling-open' | 'cancel-open' | 'imperative-action' | 'implicit'>) => void;
34
- /** Where the focus goes when the menu closes; absent, back to the trigger. */
35
- finalFocus?: Menu.Popup.Props['finalFocus'];
20
+ /** Where the focus goes when the menu closes; absent, back to the trigger. An element, a ref to one, or a function
21
+ that answers once the page has drawn again: an element, `true` for the trigger, `false` to leave the focus be. */
22
+ finalFocus?: boolean | RefObject<HTMLElement | null> | (() => boolean | HTMLElement | null | void);
36
23
  children: ReactNode;
37
24
  }
38
25
  declare function DefaultDropMenu({ className, triggerClassName, triggerTitle, triggerLabel, label, popupClassName, side, align, sideOffset, open, onOpenChange, finalFocus, children, }: DropMenuProps): import("react").JSX.Element;
package/dist/DropMenu.js CHANGED
@@ -1,56 +1,110 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  /**
3
- * A button that opens a menu, over Base UI's Menu — what the `<details>`
3
+ * A button that opens a menu, over UI SDK's Menu — what the `<details>`
4
4
  * menus here did with a summary and a hook (react to a click, close on
5
5
  * Escape or a click outside, hand focus back), plus what they never did:
6
6
  * arrows between the items, Home and End, typeahead, and the roles a
7
7
  * screen reader expects of a menu.
8
8
  *
9
9
  * The wrapper keeps the caller's class (`export`, `pb-picker`) because the
10
- * stylesheet places the control by it; the trigger and the popup wear the
11
- * classes the summary and the panel wore. The popup is anchored on the
12
- * zoom-aware ruler (anchor.ts) and fixed to the viewport, so a scrolling
13
- * panel cannot clip it. The open state can be the caller's, for a menu
14
- * that has to stay up while a click inside it fetches.
10
+ * caller's stylesheet places the control by it; the trigger and the popup
11
+ * wear the classes the caller gives them, over the menu's own parts. The
12
+ * popup is shown in the browser's top layer where it has one, so nothing
13
+ * here says how it stacks. The
14
+ * popup is drawn inside an enclosing dialog, and otherwise where the page
15
+ * says its popups go, so a scrolling panel cannot clip it. The open state
16
+ * can be the caller's, for a menu that has to stay up while a click inside
17
+ * it fetches.
15
18
  */
19
+ import { Menu, MenuContent, MenuGroup, MenuGroupLabel, MenuItem, MenuSeparator, MenuTrigger } from '@ui-sdk/react/menu';
16
20
  import { useEffect, useRef, useState } from 'react';
17
- import { Menu } from '@base-ui/react/menu';
18
- import { layoutViewport, zoomAnchor } from './internal/anchor.js';
19
- import { popupContainer } from './internal/popups.js';
20
- import { buttonClass } from './Button.js';
21
- import { fromBaseUi } from './changeDetails.js';
21
+ import { heard } from './internal/layers.js';
22
+ import { popupContainer, useDialogContainer } from './internal/popups.js';
22
23
  import { slotted } from './internal/uiKitContext.js';
23
- function DefaultDropMenu({ className, triggerClassName = buttonClass(), triggerTitle, triggerLabel, label, popupClassName = 'dd-list', side = 'bottom', align = 'end', sideOffset = 4, open, onOpenChange, finalFocus, children, }) {
24
+ function DefaultDropMenu({ className, triggerClassName, triggerTitle, triggerLabel, label, popupClassName, side = 'bottom', align = 'end', sideOffset = 4, open, onOpenChange, finalFocus, children, }) {
25
+ const root = useRef(null);
24
26
  const trigger = useRef(null);
27
+ const popup = useRef(null);
25
28
  /* Inside a dialog the popup is drawn into that dialog, so it shares its
26
- stacking context rather than landing behind it; elsewhere it goes to
27
- the body the way every floating surface here does. */
28
- const [container, setContainer] = useState(null);
29
+ stacking context rather than landing behind it; elsewhere it goes
30
+ where the page says its popups go. */
31
+ const container = useDialogContainer(root);
32
+ /* Where the caller says the focus goes is answered here and not by UI SDK, which would ask as the menu closes:
33
+ a caller's answer is often a row its own item just moved, which is where it will be only once the page has
34
+ drawn again. So the close is noted, and the answer is asked for after that draw. */
35
+ const closing = useRef(null);
36
+ const [closes, setCloses] = useState(0);
29
37
  useEffect(() => {
30
- setContainer(trigger.current?.closest('dialog, [role="dialog"]'));
31
- }, []);
38
+ const noted = closing.current;
39
+ closing.current = null;
40
+ if (!noted?.held || finalFocus === undefined)
41
+ return;
42
+ // A function that answers nothing means the default, as an answer of true does.
43
+ const answer = (typeof finalFocus === 'function' ? finalFocus() : finalFocus);
44
+ if (answer === false)
45
+ return;
46
+ const to = answer === true || answer == null ? trigger.current : 'current' in answer ? answer.current : answer;
47
+ const at = document.activeElement;
48
+ // Only while the focus is still the menu's to give: a reader who has moved on is not pulled back.
49
+ if (to?.isConnected && (!at || at === document.body || !at.isConnected || popup.current?.contains(at)))
50
+ to.focus({ preventScroll: true });
51
+ // Asked once for each close; what the caller's answer reads is its own to keep current.
52
+ // eslint-disable-next-line react-hooks/exhaustive-deps
53
+ }, [closes]);
54
+ /* A menu that opens before its items have arrived (a caller that fetches on open) has nothing to give the
55
+ keyboard, and UI SDK leaves it on the button. When the first item is drawn the keyboard is given it, as it
56
+ would have been had the item been there: only while it is still where the opening left it, and only for a
57
+ menu that opened empty, so one that opened with its items under a pointer keeps no item lit. */
32
58
  const [own, setOwn] = useState(false);
33
59
  const isOpen = open ?? own;
34
- const change = (next, details) => {
35
- // Return focus before unmount so a containing dialog does not reclaim it — unless the caller says where it goes.
36
- if (!next && details.reason === 'escape-key' && finalFocus === undefined)
37
- trigger.current?.focus({ preventScroll: true });
38
- setOwn(next);
39
- onOpenChange?.(next, fromBaseUi(details, 'implicit'));
40
- };
41
- return (_jsx("div", { className: className || undefined, children: _jsxs(Menu.Root, { open: isOpen, onOpenChange: change, children: [_jsx(Menu.Trigger, { render: _jsx("button", { type: "button", className: triggerClassName, title: triggerTitle, "aria-label": triggerLabel, ref: trigger }), children: label }), _jsx(Menu.Portal, { container: container ?? popupContainer(), children: _jsx(Menu.Positioner, { anchor: () => (trigger.current ? zoomAnchor(trigger.current) : null), positionMethod: "fixed", side: side, align: align, sideOffset: sideOffset, collisionBoundary: layoutViewport(), collisionPadding: 8, style: { zIndex: 90 }, children: _jsx(Menu.Popup, { className: popupClassName, finalFocus: finalFocus, children: children }) }) })] }) }));
60
+ const openedEmpty = useRef(false);
61
+ useEffect(() => {
62
+ if (!isOpen) {
63
+ openedEmpty.current = false;
64
+ return undefined;
65
+ }
66
+ const frame = requestAnimationFrame(() => {
67
+ const menu = popup.current;
68
+ if (!menu)
69
+ return;
70
+ const first = menu.querySelector('[role^="menuitem"]:not([aria-disabled="true"], :disabled)');
71
+ if (!first) {
72
+ openedEmpty.current = true;
73
+ return;
74
+ }
75
+ if (!openedEmpty.current)
76
+ return;
77
+ openedEmpty.current = false;
78
+ const at = document.activeElement;
79
+ if (!at || at === document.body || !at.isConnected || at === trigger.current || at === menu)
80
+ first.focus({ preventScroll: true });
81
+ });
82
+ return () => cancelAnimationFrame(frame);
83
+ // After every draw while open: the items are the caller's children, which arrive as a draw and nothing else.
84
+ });
85
+ return (_jsx("div", { className: className || undefined, "data-slot": "drop-menu", ref: root, children: _jsxs(Menu, { open: open, onOpenChange: (next, details) => {
86
+ setOwn(next);
87
+ if (!next && finalFocus !== undefined) {
88
+ const at = document.activeElement;
89
+ closing.current = { held: !at || at === document.body || Boolean(popup.current?.contains(at)) };
90
+ setCloses((count) => count + 1);
91
+ }
92
+ onOpenChange?.(next, heard(details));
93
+ }, children: [_jsx(MenuTrigger, { ref: trigger, className: triggerClassName, "data-own": triggerClassName ? '' : undefined, title: triggerTitle, "aria-label": triggerLabel, children: label }), _jsx(MenuContent, { ref: popup, className: popupClassName, side: side, align: align, sideOffset: sideOffset, collisionPadding: 8, container: container ?? popupContainer(), finalFocus: finalFocus === undefined ? undefined : 'none', children: children })] }) }));
42
94
  }
43
95
  /** A labelled run of items: a menu that changes several things says which each item changes. */
44
96
  function DefaultDropGroup({ className, labelClassName, label, children, }) {
45
- return (_jsxs(Menu.Group, { className: className, children: [_jsx(Menu.GroupLabel, { className: labelClassName, children: label }), children] }));
97
+ return (_jsxs(MenuGroup, { className: className, children: [_jsx(MenuGroupLabel, { className: labelClassName, children: label }), children] }));
46
98
  }
47
99
  /** A rule between two runs of items, a separator to a screen reader. */
48
- function DefaultDropSeparator({ className = 'dd-divider' }) {
49
- return _jsx(Menu.Separator, { className: className });
100
+ function DefaultDropSeparator({ className }) {
101
+ return _jsx(MenuSeparator, { className: className });
50
102
  }
51
103
  /** An item drawn as a button, so `disabled` and the button styles hold. Closes the menu unless told not to. */
52
- function DefaultDropItem({ className = 'dd-option', disabled, closeOnClick, onClick, title, children, ref, }) {
53
- return (_jsx(Menu.Item, { render: _jsx("button", { type: "button", className: className, title: title, ref: ref }), nativeButton: true, disabled: disabled, closeOnClick: closeOnClick, onClick: onClick, children: children }));
104
+ function DefaultDropItem({ className, disabled, closeOnClick, onClick, title, children, ref, }) {
105
+ return (_jsx(MenuItem, { render: _jsx("button", { type: "button" }),
106
+ // The part is typed as the element it is by default; here it is drawn as the button the caller's ref is for.
107
+ ref: ref, className: className, title: title, disabled: disabled, closeOnSelect: closeOnClick, onSelect: () => onClick(), children: children }));
54
108
  }
55
109
  /* Slotted (UiKit.tsx): an App's control kit may draw its own in place of the default, with the same props. */
56
110
  export const DropMenu = slotted('DropMenu', DefaultDropMenu, { onOpenChange: [1, 'implicit'] });
@@ -1,21 +1,21 @@
1
1
  /**
2
- * A themed listbox, over Base UI's Select.
2
+ * A themed listbox, over UI SDK's Select.
3
3
  *
4
4
  * A native `<select>` cannot be styled where it matters: the open menu is
5
5
  * drawn by the operating system, in the system font, with the system
6
- * highlight colour, ignoring the page entirely. Base UI gives back what
6
+ * highlight colour, ignoring the page entirely. UI SDK gives back what
7
7
  * the native one gave for free — arrows move, Home and End jump, Enter and
8
8
  * Space choose, Escape closes and returns focus, Tab closes, typing jumps
9
9
  * to a matching option, the roles and `aria-expanded` — and this draws it
10
- * in the tool's own classes, so the stylesheet and the browser suite see
11
- * the control they always saw.
10
+ * on its parts' slots (`select-trigger`, `select-content`, `select-item`),
11
+ * which the stylesheet dresses.
12
12
  *
13
13
  * Actions ride under a divider and are walked with the same arrows, but
14
14
  * run rather than become the value: the value stays what the caller says
15
15
  * it is, so choosing "re-read the schema" cannot select it.
16
16
  */
17
17
  import { type Ref } from 'react';
18
- import { type ChangeDetails } from './changeDetails.js';
18
+ import type { ChangeDetails } from './changeDetails.js';
19
19
  export interface DropdownItem {
20
20
  value: string;
21
21
  label: string;
@@ -26,9 +26,10 @@ export interface DropdownItem {
26
26
  tone?: 'good' | 'warn' | 'bad' | 'info' | 'neutral';
27
27
  swatches?: string[];
28
28
  }
29
- /** Why a dropdown's choice moved: an option pressed (or chosen by key); `autofill`, the browser filling the hidden
30
- field; or `sync`, which Base UI reports with no event at all — a letter typed on the closed button, or a chosen option
31
- that left the list — and cannot be told apart, so it reads as the page's own change. */
29
+ /** Why a dropdown's choice moved: an option pressed (or chosen by key); `autofill`, the browser putting back what the
30
+ hidden field held; or `sync`, every other way the value follows something else: a letter typed on the closed
31
+ button, a form reset, a chosen option that left the list. A `sync` with a key behind it says `keyboard`; with
32
+ nothing behind it, it is the page's own change. */
32
33
  export type DropdownChange = ChangeDetails<'item-press' | 'autofill' | 'sync'>;
33
34
  interface DropdownBase {
34
35
  items: DropdownItem[];
package/dist/Dropdown.js CHANGED
@@ -1,25 +1,25 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  /**
3
- * A themed listbox, over Base UI's Select.
3
+ * A themed listbox, over UI SDK's Select.
4
4
  *
5
5
  * A native `<select>` cannot be styled where it matters: the open menu is
6
6
  * drawn by the operating system, in the system font, with the system
7
- * highlight colour, ignoring the page entirely. Base UI gives back what
7
+ * highlight colour, ignoring the page entirely. UI SDK gives back what
8
8
  * the native one gave for free — arrows move, Home and End jump, Enter and
9
9
  * Space choose, Escape closes and returns focus, Tab closes, typing jumps
10
10
  * to a matching option, the roles and `aria-expanded` — and this draws it
11
- * in the tool's own classes, so the stylesheet and the browser suite see
12
- * the control they always saw.
11
+ * on its parts' slots (`select-trigger`, `select-content`, `select-item`),
12
+ * which the stylesheet dresses.
13
13
  *
14
14
  * Actions ride under a divider and are walked with the same arrows, but
15
15
  * run rather than become the value: the value stays what the caller says
16
16
  * it is, so choosing "re-read the schema" cannot select it.
17
17
  */
18
- import { useEffect, useId, useRef, useState } from 'react';
19
- import { Select } from '@base-ui/react/select';
20
- import { layoutViewport, zoomAnchor } from './internal/anchor.js';
21
- import { popupContainer } from './internal/popups.js';
22
- import { fromBaseUi } from './changeDetails.js';
18
+ import { useId, useRef } from 'react';
19
+ import { Select as Listbox, SelectContent, SelectItem, SelectItemIndicator, SelectSeparator, SelectTrigger, SelectValue, } from '@ui-sdk/react/select';
20
+ import { useFieldControl } from '@ui-sdk/react/field';
21
+ import { popupContainer, useDialogContainer } from './internal/popups.js';
22
+ import { told } from './internal/told.js';
23
23
  import { slotted } from './internal/uiKitContext.js';
24
24
  /* A value no option could carry, so an action's row is told apart from an option's. */
25
25
  const ACTION = '~~action:';
@@ -30,67 +30,71 @@ function DefaultDropdown(props) {
30
30
  function DefaultMultiDropdown(props) {
31
31
  return _jsx(DropdownList, { ...props, multiple: true });
32
32
  }
33
+ /* Why the list opened or closed: UI SDK's own word where it is one this callback's type lists, `implicit` for the
34
+ ones it has that no caller here reads (the window losing focus, a swipe, the page's own call). */
35
+ const OPENS = new Set(['trigger-press', 'outside-press', 'escape-key', 'item-press', 'focus-out', 'list-navigation']);
36
+ const openReason = (said) => (said && OPENS.has(said) ? said : 'implicit');
37
+ /* UI SDK's word for why the value moved, in the three a caller here can hear. `restore` is the browser putting a
38
+ form's values back (history, autofill); everything else that is not a press follows something else. */
39
+ const changeReason = (said) => said === 'item-press' ? 'item-press' : said === 'restore' ? 'autofill' : 'sync';
40
+ /* The mark beside a chosen option of several. */
41
+ const Tick = () => (_jsx("svg", { viewBox: "0 0 16 16", width: "1em", height: "1em", fill: "none", stroke: "currentColor", strokeWidth: "2", "aria-hidden": "true", children: _jsx("path", { d: "M3 8.5l3.25 3.25L13 4.75", strokeLinecap: "round", strokeLinejoin: "round" }) }));
42
+ function Swatches({ colours }) {
43
+ return (_jsx("span", { "data-slot": "swatches", "aria-hidden": "true", children: colours.map((colour, index) => (_jsx("span", { style: { background: colour } }, index))) }));
44
+ }
45
+ /* The listbox, one choice or several. The button is a button to a reader, as it has always been announced, where
46
+ UI SDK's trigger calls itself a combobox: the role is said on the element handed to `render`, which is the one
47
+ place a part's role gives way. */
33
48
  function DropdownList(props) {
34
- const { items, ariaLabel, ariaInvalid, ariaDescribedBy, ariaLabelledBy, id, buttonRef, popupRef, onOpenChange, disabled, readOnly, valueClassName, actions = [], buttonClassName, listClassName, valueId, placeholder, } = props;
35
- const many = props.multiple === true;
36
- /* A button named only by `ariaLabel` is named by it and then by the value it shows (WCAG 2.5.3, label in name): its
37
- own label first, the shown value after, as a field's `labelledby` names it with `valueId`. */
38
- const own = useId();
39
- const shownId = useId();
40
- const buttonId = id ?? own;
41
- const chosen = props.multiple === true ? props.value : [props.value];
42
- const selected = items.find((i) => i.value === chosen[0]);
43
- /* Nothing chosen: a value no item carries (a form's empty answer) reads as no selection, not as a stray one. */
44
- const said = many
45
- ? items
46
- .filter((i) => chosen.includes(i.value))
47
- .map((i) => i.label)
48
- .join(', ')
49
- : (selected?.label ?? '');
50
- /* Where the list is drawn. A list portalled to the end of the body sits
51
- behind a modal <dialog>'s top layer, and half the pickers here live in
52
- one — so inside a dialog the list is drawn into that dialog, and keeps
53
- its stacking context; elsewhere it goes to the body the way every
54
- floating surface here does. */
49
+ const { items, actions = [] } = props;
50
+ /* Where the list is drawn. A list portalled to the end of the body sits behind a modal <dialog>'s top layer, and
51
+ half the pickers here live in one, so inside a dialog the list is drawn into that dialog and keeps its stacking
52
+ context; elsewhere it goes where every floating surface here does (internal/popups.ts), which an embedded
53
+ shell names for itself. */
55
54
  const root = useRef(null);
56
- const [container, setContainer] = useState(null);
57
- useEffect(() => {
58
- setContainer(root.current?.closest('dialog, [role="dialog"]'));
59
- }, []);
60
- /* The trigger, for the anchor measured with the zoom-aware ruler (anchor.ts). */
61
- const trigger = useRef(null);
62
- const setTrigger = (node) => {
63
- trigger.current = node;
64
- if (typeof buttonRef === 'function')
65
- buttonRef(node);
66
- else if (buttonRef)
67
- buttonRef.current = node;
55
+ const dialog = useDialogContainer(root);
56
+ /* Nothing chosen: a value no item carries (a form's empty answer) reads as no selection, not as a stray one. An
57
+ item may itself be the empty value (a sort's "Default order"), and is then the one chosen. */
58
+ const chosen = props.multiple === true ? props.value : [props.value];
59
+ const known = items.filter((item) => chosen.includes(item.value));
60
+ /* An action's row is pressed like an option's, and the press is refused before it becomes the value. */
61
+ const run = (value, details) => {
62
+ const picked = [value].flat().find((one) => typeof one === 'string' && one.startsWith(ACTION));
63
+ if (typeof picked !== 'string')
64
+ return false;
65
+ details.cancel();
66
+ actions[Number(picked.slice(ACTION.length))]?.onSelect();
67
+ return true;
68
68
  };
69
- return (_jsx("div", { className: "dd", ref: root, children: _jsxs(Select.Root, { multiple: many || undefined, value: (many ? chosen : selected ? selected.value : null), disabled: disabled, readOnly: readOnly, onOpenChange: onOpenChange && ((next, details) => onOpenChange(next, fromBaseUi(details, 'implicit'))),
70
- /* The labels, handed over: without them Base UI mounts the list
71
- once, hidden, to read the selected label off an item. */
72
- items: items.map((i) => ({ value: i.value, label: i.label })), onValueChange: (next, details) => {
73
- const unnamed = details.event?.type === 'base-ui' ? 'sync' : 'autofill';
74
- const change = fromBaseUi(details, unnamed);
75
- if (props.multiple === true) {
76
- if (!Array.isArray(next))
77
- return;
78
- const ran = next.find((v) => typeof v === 'string' && v.startsWith(ACTION));
79
- if (ran)
80
- actions[Number(ran.slice(ACTION.length))]?.onSelect();
81
- else
82
- props.onChange(items.map((i) => i.value).filter((v) => next.includes(v)), change);
83
- return;
84
- }
85
- if (typeof next !== 'string')
69
+ /* A button named only by `ariaLabel` is named by it and then by the value it shows (WCAG 2.5.3, label in name):
70
+ its own label first, the shown value after, as a field's `ariaLabelledBy` names it with `valueId`. */
71
+ const made = useId();
72
+ const buttonId = props.id ?? `dropdown-${made}`;
73
+ const shownId = props.valueId ?? `${buttonId}-value`;
74
+ const label = props.ariaLabelledBy?.split(' ')[0];
75
+ const first = props.multiple === true ? undefined : known[0];
76
+ /* Inside a field UI SDK describes the trigger by the field's hint and problem itself. A Select hands the same
77
+ ids on as props (so a kit's Dropdown hears them too), and saying them twice would list each id twice. */
78
+ const wired = useFieldControl()?.props({})?.['aria-describedby'];
79
+ const described = props.ariaDescribedBy && props.ariaDescribedBy === wired ? undefined : props.ariaDescribedBy;
80
+ const trigger = (_jsxs(SelectTrigger, { render: _jsx("button", { type: "button", role: "button" }), id: buttonId, ref: props.buttonRef, className: props.buttonClassName, "aria-label": props.ariaLabelledBy ? undefined : props.ariaLabel, "aria-labelledby": props.ariaLabelledBy ?? (props.ariaLabel ? `${buttonId} ${shownId}` : undefined), "aria-describedby": described, "aria-invalid": props.ariaInvalid || undefined, title: first?.detail, children: [first?.swatches?.length ? _jsx(Swatches, { colours: first.swatches }) : null, _jsx(SelectValue, { id: shownId, className: props.valueClassName, "data-placeholder": known.length ? undefined : '', children: known.length ? known.map((item) => item.label).join(', ') : (props.placeholder ?? '—') })] }));
81
+ const content = (_jsxs(SelectContent, { ref: props.popupRef, className: props.listClassName, container: dialog ?? popupContainer(),
82
+ // The list is called what the button is, without the value the button also says: UI SDK names it by the
83
+ // whole button, so the name is put on what it draws.
84
+ render: (drawn) => _jsx("div", { ...drawn, "aria-label": props.ariaLabel, "aria-labelledby": props.ariaLabel ? undefined : label }), children: [items.map((item) => (_jsxs(SelectItem, { value: item.value, label: item.label, disabled: item.disabled, "data-tone": item.tone, children: [props.multiple === true && (_jsx(SelectItemIndicator, { keepMounted: true, children: _jsx(Tick, {}) })), item.swatches?.length ? _jsx(Swatches, { colours: item.swatches }) : null, _jsx("span", { "data-slot": "option-label", children: item.label }), item.detail ? _jsx("span", { "data-slot": "option-detail", children: item.detail }) : null, item.badge ? _jsx("span", { "data-slot": "option-badge", children: item.badge }) : null] }, item.value))), actions.length ? _jsx(SelectSeparator, {}) : null, actions.map((action, index) => (_jsx(SelectItem, { value: `${ACTION}${index}`, "data-kind": "action", children: action.label }, action.label)))] }));
85
+ const open = props.onOpenChange &&
86
+ ((next, details) => props.onOpenChange?.(next, told(openReason(details?.reason), details)));
87
+ return (_jsx("span", { ref: root, "data-slot": "dropdown", children: props.multiple === true ? (_jsxs(Listbox, { multiple: true, value: props.value, disabled: props.disabled, readOnly: props.readOnly, onOpenChange: open, onValueChange: (next, details) => {
88
+ if (run(next, details))
86
89
  return;
87
- if (next.startsWith(ACTION)) {
88
- actions[Number(next.slice(ACTION.length))]?.onSelect();
90
+ const picked = next.map(String);
91
+ // Kept in the items' order, whatever order they were chosen in.
92
+ props.onChange(items.map((item) => item.value).filter((value) => picked.includes(value)), told(changeReason(details.reason), details));
93
+ }, children: [trigger, content] })) : (_jsxs(Listbox, { value: known[0]?.value ?? null, disabled: props.disabled, readOnly: props.readOnly, onOpenChange: open, onValueChange: (next, details) => {
94
+ if (run(next, details))
89
95
  return;
90
- }
91
- if (next !== props.value)
92
- props.onChange(next, change);
93
- }, children: [_jsxs(Select.Trigger, { render: _jsx("button", { type: "button", role: "button", id: buttonId, className: buttonClassName ? `dd-button ${buttonClassName}` : 'dd-button', ref: setTrigger, "aria-label": ariaLabelledBy ? undefined : ariaLabel, "aria-labelledby": ariaLabelledBy ?? (ariaLabel ? `${buttonId} ${valueId ?? shownId}` : undefined), "aria-invalid": ariaInvalid || undefined, "aria-describedby": ariaDescribedBy, title: selected?.detail ?? '' }), children: [selected?.swatches && (_jsx("span", { className: "dd-swatches", "aria-hidden": "true", children: selected.swatches.map((color, index) => (_jsx("span", { style: { background: color } }, index))) })), _jsx("span", { id: valueId ?? shownId, className: `dd-value${valueClassName ? ` ${valueClassName}` : ''}${said ? '' : ' is-empty'}`, children: said || placeholder || '—' }), _jsx("span", { className: "dd-caret", "aria-hidden": "true", children: "\u25BE" })] }), _jsx(Select.Portal, { container: container ?? popupContainer(), children: _jsx(Select.Positioner, { anchor: () => (trigger.current ? zoomAnchor(trigger.current) : null), alignItemWithTrigger: false, positionMethod: "fixed", side: "bottom", align: "start", sideOffset: 4, collisionBoundary: layoutViewport(), collisionPadding: 8, style: { zIndex: 40 }, children: _jsx(Select.Popup, { ref: popupRef, className: "dd-popup", children: _jsxs(Select.List, { className: ['dd-list', many ? 'dd-list-multi' : '', listClassName].filter(Boolean).join(' '), "aria-label": ariaLabel, "aria-labelledby": ariaLabel ? undefined : ariaLabelledBy?.split(' ')[0], children: [items.map((item) => (_jsxs(Select.Item, { value: item.value, label: item.label, disabled: item.disabled, className: (s) => `dd-option${s.selected ? ' selected' : ''}${item.disabled ? ' disabled' : ''}${item.tone ? ` dd-tone-${item.tone}` : ''}${s.highlighted ? ' active' : ''}`, children: [many ? (_jsx("span", { className: "dd-box", "aria-hidden": "true" })) : (_jsx("span", { className: "dd-check", "aria-hidden": "true", children: item.value === props.value ? '✓' : '' })), item.swatches && (_jsx("span", { className: "dd-swatches", "aria-hidden": "true", children: item.swatches.map((color, index) => (_jsx("span", { style: { background: color } }, index))) })), _jsxs("span", { className: "dd-text", children: [_jsx("span", { className: "dd-label", children: item.label }), item.detail && _jsx("span", { className: "dd-detail", children: item.detail })] }), item.badge && _jsx("span", { className: "dd-badge", children: item.badge })] }, item.value))), actions.length ? _jsx("div", { className: "dd-divider", role: "presentation" }) : null, actions.map((action, i) => (_jsxs(Select.Item, { value: `${ACTION}${i}`, label: action.label, className: (s) => `dd-option dd-action${s.highlighted ? ' active' : ''}`, children: [_jsx("span", { className: "dd-check", "aria-hidden": "true" }), _jsx("span", { className: "dd-text", children: _jsx("span", { className: "dd-label", children: action.label }) })] }, action.label)))] }) }) }) })] }) }));
96
+ props.onChange(next === null ? '' : String(next), told(changeReason(details.reason), details));
97
+ }, children: [trigger, content] })) }));
94
98
  }
95
99
  const DROPDOWN_FILLS = { onChange: [1, 'item-press'], onOpenChange: [1, 'implicit'] };
96
100
  /* Slotted (UiKit.tsx): an App's control kit may draw its own in place of the default, with the same props. */
package/dist/Field.d.ts CHANGED
@@ -55,5 +55,6 @@ interface FieldProps {
55
55
  className?: string;
56
56
  children: ReactElement<Record<string, unknown>> | ((control: FieldControlProps) => ReactNode);
57
57
  }
58
- export declare function Field({ label, hint, problem, required, id, group, check, size, kind, optional, labelAside, labelHidden, reserve, className, children, }: FieldProps): import("react").JSX.Element;
58
+ declare function DefaultField({ label, hint, problem, required, id, group, check, size, kind, optional, labelAside, labelHidden, reserve, className, children, }: FieldProps): import("react").JSX.Element;
59
+ export declare const Field: typeof DefaultField;
59
60
  export {};
package/dist/Field.js CHANGED
@@ -13,16 +13,14 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
13
13
  * its focusable is.
14
14
  */
15
15
  import { cloneElement, isValidElement, useId } from 'react';
16
- export function Field({ label, hint, problem, required = false, id, group = false, check = false, size = 'default', kind, optional, labelAside, labelHidden = false, reserve = false, className = '', children, }) {
16
+ import { slotted } from './internal/uiKitContext.js';
17
+ function DefaultField({ label, hint, problem, required = false, id, group = false, check = false, size = 'default', kind, optional, labelAside, labelHidden = false, reserve = false, className, children, }) {
17
18
  const made = useId();
18
19
  const controlId = id ?? `field-${made}`;
19
20
  const hintId = hint ? `${controlId}-hint` : undefined;
20
21
  const problemId = `${controlId}-problem`;
21
22
  const holdsProblem = problem !== undefined && problem !== null && problem !== false && problem !== '';
22
23
  const labelId = `${controlId}-label`;
23
- const labelClass = labelHidden ? 'form-field-label form-field-label-hidden' : 'form-field-label';
24
- const caption = group ? (_jsx("span", { id: labelId, className: labelClass, children: label })) : (_jsx("label", { id: labelId, htmlFor: controlId, className: labelClass, children: label }));
25
- const word = optional && !required ? _jsx("span", { className: "form-field-optional-word", children: optional }) : null;
26
24
  const control = {
27
25
  id: controlId,
28
26
  ...(hintId || holdsProblem ? { 'aria-describedby': [hintId, holdsProblem ? problemId : undefined].filter(Boolean).join(' ') } : {}),
@@ -35,20 +33,14 @@ export function Field({ label, hint, problem, required = false, id, group = fals
35
33
  : isValidElement(children)
36
34
  ? cloneElement(children, { ...control, ...joined(children.props, control) })
37
35
  : children;
38
- /* The star is the stylesheet's (`.is-required`), not text: a label's words
39
- stay its name, to a query by label as to a screen reader, which hears
40
- "required" from `aria-required` instead. */
41
- return (_jsxs("div", { "data-kind": kind, className: [
42
- 'form-field',
43
- size === 'compact' ? 'form-field-compact' : '',
44
- check ? 'form-field-check' : '',
45
- reserve ? 'form-field-reserve' : '',
46
- required ? 'is-required' : '',
47
- holdsProblem ? 'is-invalid' : '',
48
- className,
49
- ]
50
- .filter(Boolean)
51
- .join(' '), children: [check ? (_jsxs("div", { className: "form-field-check-row", children: [drawn, _jsx("label", { id: labelId, htmlFor: controlId, className: "form-field-label", children: label }), word] })) : (_jsxs(_Fragment, { children: [labelAside || word ? (_jsxs("div", { className: "form-field-label-row", children: [caption, word, labelAside] })) : (caption), drawn] })), hint ? (_jsx("p", { id: hintId, className: "form-field-hint", children: hint })) : null, _jsx("p", { id: problemId, className: "form-field-problem", "aria-live": "polite", hidden: !holdsProblem && !reserve, children: holdsProblem ? problem : null })] }));
36
+ const caption = group ? (_jsx("span", { id: labelId, "data-slot": "field-label", "data-hidden": labelHidden ? '' : undefined, children: label })) : (_jsx("label", { id: labelId, htmlFor: controlId, "data-slot": "field-label", "data-hidden": labelHidden ? '' : undefined, children: label }));
37
+ /* Beside the label and not in it, so a label's words stay its name, to a query by label as to a screen reader,
38
+ which hears "required" from `aria-required` instead: the mark for what must be answered, and the word for what
39
+ need not, which a theme shows in the mark's place (`recipes.required`). */
40
+ const marks = (_jsxs(_Fragment, { children: [required && (_jsx("span", { "data-slot": "field-required", "aria-hidden": "true", children: "*" })), optional && !required ? _jsx("span", { "data-slot": "field-optional", children: optional }) : null] }));
41
+ /* `data-kind` is the stylesheet's word for which shape of a slot this is (a check row), so the answer's kind is
42
+ said as `data-answer`. */
43
+ return (_jsxs("div", { "data-slot": "field", "data-kind": check ? 'check' : undefined, "data-answer": kind, "data-size": size === 'compact' ? 'compact' : undefined, "data-invalid": holdsProblem ? '' : undefined, "data-required": required ? '' : undefined, className: className || undefined, children: [check ? (_jsxs("div", { "data-slot": "field-check-row", children: [drawn, _jsx("label", { id: labelId, htmlFor: controlId, "data-slot": "field-label", children: label }), marks] })) : (_jsxs(_Fragment, { children: [_jsxs("div", { "data-slot": "field-head", "data-kind": labelHidden ? 'visually-hidden' : undefined, children: [caption, marks, labelAside] }), drawn] })), hint ? (_jsx("p", { id: hintId, "data-slot": "field-description", children: hint })) : null, _jsx("p", { id: problemId, "data-slot": "field-error", "aria-live": "polite", hidden: !holdsProblem && !reserve, "data-reserve": reserve && !holdsProblem ? '' : undefined, children: holdsProblem ? problem : null })] }));
52
44
  }
53
45
  /** A control's own description joins the field's rather than being replaced by it. */
54
46
  function joined(props, control) {
@@ -56,3 +48,5 @@ function joined(props, control) {
56
48
  const described = [own, control['aria-describedby']].filter(Boolean).join(' ');
57
49
  return described ? { 'aria-describedby': described } : {};
58
50
  }
51
+ /* Slotted (UiKit.tsx): an App's control kit may draw its own in place of the default, with the same props. */
52
+ export const Field = slotted('Field', DefaultField);
@@ -1,14 +1,6 @@
1
- /**
2
- * A file chosen in the browser, handed to the page as a `File` (or null): for a page that reads a file before any
3
- * command runs, a CSV parsed and shown, say. It is drawn as the look draws a control, the kit's button and the chosen
4
- * names beside it, not the browser's grey "Choose Files"; underneath it is still the browser's own input (hidden
5
- * visually, never removed), so the label, hint and problem are wired in as they are for a text box, and the keyboard
6
- * (Tab to it, Enter or Space) and the file dialog are the platform's. A command's form has `field.file`, which sends
7
- * the bytes; this sends nothing. Props only. Preview: @mistriwork/ui is Preview at 1.0.
8
- */
9
1
  import { type ReactNode, type Ref } from 'react';
10
2
  import { type ChangeDetails } from './changeDetails.js';
11
- import { type FieldFrame } from './fieldFrame.js';
3
+ import type { FieldFrame } from './fieldFrame.js';
12
4
  interface FileFieldBase extends FieldFrame {
13
5
  /** What the picker offers, as the input's `accept`: `.csv`, `text/csv`, `image/*`, separated by commas. */
14
6
  accept?: string;
@@ -36,5 +28,6 @@ export type FileFieldProps = FileFieldBase & ({
36
28
  value: File[];
37
29
  onChange: (files: File[], details: ChangeDetails<'file-pick'>) => void;
38
30
  });
39
- export declare function FileField(props: FileFieldProps): ReactNode;
31
+ declare function DefaultFileField(props: FileFieldProps): ReactNode;
32
+ export declare const FileField: typeof DefaultFileField;
40
33
  export {};