@calcifer-design/ui 0.2.1 → 0.4.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.
Files changed (75) hide show
  1. package/dist/components/Alert/Alert.js +4 -15
  2. package/dist/components/Alert/Alert.module.js +1 -2
  3. package/dist/components/Alert/Alert_module.css +0 -12
  4. package/dist/components/Avatar/Avatar.js +2 -1
  5. package/dist/components/Avatar/Avatar.module.js +1 -2
  6. package/dist/components/Avatar/Avatar_module.css +0 -12
  7. package/dist/components/Checkbox/Checkbox.d.ts +23 -0
  8. package/dist/components/Checkbox/Checkbox.js +33 -0
  9. package/dist/components/Checkbox/Checkbox.module.js +6 -0
  10. package/dist/components/Checkbox/Checkbox_module.css +16 -0
  11. package/dist/components/DataTable/DataTable.js +7 -2
  12. package/dist/components/DataTable/DataTable_module.css +0 -16
  13. package/dist/components/Dialog/Dialog.d.ts +44 -0
  14. package/dist/components/Dialog/Dialog.js +82 -0
  15. package/dist/components/Dialog/Dialog.module.js +10 -0
  16. package/dist/components/Dialog/Dialog_module.css +51 -0
  17. package/dist/components/Field/Field.d.ts +118 -0
  18. package/dist/components/Field/Field.js +84 -0
  19. package/dist/components/LiveRegion/LiveRegion.js +2 -2
  20. package/dist/components/Menu/Menu.d.ts +35 -0
  21. package/dist/components/Menu/Menu.js +44 -0
  22. package/dist/components/Menu/Menu.module.js +6 -0
  23. package/dist/components/Menu/Menu_module.css +29 -0
  24. package/dist/components/NavMenu/NavMenu.js +4 -2
  25. package/dist/components/NavMenu/NavMenu.module.js +0 -2
  26. package/dist/components/NavMenu/NavMenu_module.css +0 -15
  27. package/dist/components/Popover/Popover.d.ts +42 -0
  28. package/dist/components/Popover/Popover.js +61 -0
  29. package/dist/components/Popover/Popover.module.js +6 -0
  30. package/dist/components/Popover/Popover_module.css +13 -0
  31. package/dist/components/RadioGroup/RadioGroup.d.ts +35 -0
  32. package/dist/components/RadioGroup/RadioGroup.js +64 -0
  33. package/dist/components/RadioGroup/RadioGroup.module.js +6 -0
  34. package/dist/components/RadioGroup/RadioGroup_module.css +13 -0
  35. package/dist/components/Select/Select.d.ts +42 -0
  36. package/dist/components/Select/Select.js +90 -0
  37. package/dist/components/Select/Select.module.js +9 -0
  38. package/dist/components/Select/Select_module.css +70 -0
  39. package/dist/components/Spinner/Spinner.js +2 -1
  40. package/dist/components/Spinner/Spinner.module.js +1 -2
  41. package/dist/components/Spinner/Spinner_module.css +0 -12
  42. package/dist/components/StatusDot/StatusDot.js +6 -1
  43. package/dist/components/StatusDot/StatusDot_module.css +0 -12
  44. package/dist/components/Switch/Switch.d.ts +23 -0
  45. package/dist/components/Switch/Switch.js +25 -0
  46. package/dist/components/Switch/Switch.module.js +6 -0
  47. package/dist/components/Switch/Switch_module.css +41 -0
  48. package/dist/components/TextInput/TextInput.d.ts +17 -0
  49. package/dist/components/TextInput/TextInput.js +18 -0
  50. package/dist/components/ToastRegion/ToastRegion.d.ts +72 -0
  51. package/dist/components/ToastRegion/ToastRegion.js +85 -0
  52. package/dist/components/ToastRegion/ToastRegion.module.js +10 -0
  53. package/dist/components/ToastRegion/ToastRegion_module.css +104 -0
  54. package/dist/components/Tooltip/Tooltip.d.ts +33 -0
  55. package/dist/components/Tooltip/Tooltip.js +28 -0
  56. package/dist/components/Tooltip/TooltipProvider.d.ts +24 -0
  57. package/dist/components/Tooltip/TooltipProvider.js +11 -0
  58. package/dist/icons/CheckIcon.d.ts +6 -0
  59. package/dist/icons/CheckIcon.js +17 -0
  60. package/dist/icons/ChevronDownIcon.d.ts +6 -0
  61. package/dist/icons/ChevronDownIcon.js +17 -0
  62. package/dist/icons/CloseIcon.d.ts +10 -0
  63. package/dist/icons/CloseIcon.js +21 -0
  64. package/dist/icons/MinusIcon.d.ts +5 -0
  65. package/dist/icons/MinusIcon.js +16 -0
  66. package/dist/index.d.ts +24 -0
  67. package/dist/index.js +12 -0
  68. package/dist/styles/a11y.module.js +5 -0
  69. package/dist/{components/LiveRegion/LiveRegion_module.css → styles/a11y_module.css} +1 -1
  70. package/dist/styles/field.module.js +15 -0
  71. package/dist/styles/field_module.css +133 -0
  72. package/dist/styles/popup.module.js +9 -0
  73. package/dist/styles/popup_module.css +109 -0
  74. package/package.json +2 -2
  75. package/dist/components/LiveRegion/LiveRegion.module.js +0 -5
@@ -1,9 +1,9 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import LiveRegion_module from "./LiveRegion.module.js";
2
+ import a11y_module from "../../styles/a11y.module.js";
3
3
  function LiveRegion({ message, politeness = 'polite' }) {
4
4
  const role = 'assertive' === politeness ? 'alert' : 'status';
5
5
  return /*#__PURE__*/ jsx("div", {
6
- className: LiveRegion_module.root,
6
+ className: a11y_module.visuallyHidden,
7
7
  role: role,
8
8
  "aria-live": politeness,
9
9
  "aria-atomic": "true",
@@ -0,0 +1,35 @@
1
+ import { type ReactElement } from 'react';
2
+ import type { PopupAlign, PopupSide } from '../Popover/Popover.js';
3
+ export interface MenuItem {
4
+ /** Stable across renders; used as the React key. */
5
+ id: string;
6
+ /** The visible text, and what Base UI's typeahead matches against. */
7
+ label: string;
8
+ onSelect?: () => void;
9
+ disabled?: boolean;
10
+ /** Draws a hairline above this item, separating the group below from the one above. */
11
+ separatorBefore?: boolean;
12
+ }
13
+ export interface MenuProps {
14
+ /**
15
+ * The control that opens the menu, rendered as the trigger itself: it must be a single element
16
+ * that produces a native `<button>`, and the popup takes its accessible name from it.
17
+ */
18
+ trigger: ReactElement;
19
+ items: MenuItem[];
20
+ side?: PopupSide;
21
+ align?: PopupAlign;
22
+ /** Gap between the trigger and the popup, in pixels. */
23
+ sideOffset?: number;
24
+ /**
25
+ * Base UI defaults this to `true`, which locks page scroll and blocks pointer interaction
26
+ * outside. A menu hanging off a toolbar button is not that, and `NavMenu` already ships
27
+ * `modal={false}` for the same reason, so the default is inverted here.
28
+ */
29
+ modal?: boolean;
30
+ open?: boolean;
31
+ defaultOpen?: boolean;
32
+ /** Base UI calls this as `(open, eventDetails)`; the second argument is passed through. */
33
+ onOpenChange?: (open: boolean, eventDetails: unknown) => void;
34
+ }
35
+ export declare function Menu({ trigger, items, side, align, sideOffset, modal, open, defaultOpen, onOpenChange, }: MenuProps): import("react").JSX.Element;
@@ -0,0 +1,44 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Menu } from "@base-ui/react/menu";
3
+ import { Fragment } from "react";
4
+ import popup_module from "../../styles/popup.module.js";
5
+ import Menu_module from "./Menu.module.js";
6
+ function Menu_Menu({ trigger, items, side = 'bottom', align = 'end', sideOffset = 8, modal = false, open, defaultOpen, onOpenChange }) {
7
+ return /*#__PURE__*/ jsxs(Menu.Root, {
8
+ open: open,
9
+ defaultOpen: defaultOpen,
10
+ onOpenChange: onOpenChange,
11
+ modal: modal,
12
+ children: [
13
+ /*#__PURE__*/ jsx(Menu.Trigger, {
14
+ render: trigger
15
+ }),
16
+ /*#__PURE__*/ jsx(Menu.Portal, {
17
+ children: /*#__PURE__*/ jsx(Menu.Positioner, {
18
+ className: popup_module.layer,
19
+ side: side,
20
+ align: align,
21
+ sideOffset: sideOffset,
22
+ children: /*#__PURE__*/ jsx(Menu.Popup, {
23
+ className: popup_module.surface,
24
+ "data-popup": "menu",
25
+ children: items.map((item)=>/*#__PURE__*/ jsxs(Fragment, {
26
+ children: [
27
+ true === item.separatorBefore ? /*#__PURE__*/ jsx(Menu.Separator, {
28
+ className: Menu_module.separator
29
+ }) : null,
30
+ /*#__PURE__*/ jsx(Menu.Item, {
31
+ className: Menu_module.item,
32
+ disabled: item.disabled,
33
+ onClick: item.onSelect,
34
+ children: item.label
35
+ })
36
+ ]
37
+ }, item.id))
38
+ })
39
+ })
40
+ })
41
+ ]
42
+ });
43
+ }
44
+ export { Menu_Menu as Menu };
@@ -0,0 +1,6 @@
1
+ import "./Menu_module.css";
2
+ const Menu_module = {
3
+ item: "item-toMw6",
4
+ separator: "separator-mmvmF"
5
+ };
6
+ export default Menu_module;
@@ -0,0 +1,29 @@
1
+ .item-toMw6 {
2
+ min-height: var(--size-touch);
3
+ padding-inline: var(--space-3);
4
+ border-radius: var(--radius-md);
5
+ color: var(--color-text);
6
+ font-size: var(--text-md);
7
+ cursor: pointer;
8
+ -webkit-user-select: none;
9
+ user-select: none;
10
+ align-items: center;
11
+ display: flex;
12
+ }
13
+
14
+ .item-toMw6[data-highlighted] {
15
+ background: var(--color-surface-2);
16
+ color: var(--color-text);
17
+ }
18
+
19
+ .item-toMw6[data-disabled] {
20
+ color: var(--color-text-subtle);
21
+ cursor: not-allowed;
22
+ }
23
+
24
+ .separator-mmvmF {
25
+ height: 1px;
26
+ margin-block: var(--space-1);
27
+ background: var(--color-border);
28
+ }
29
+
@@ -2,6 +2,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Menu } from "@base-ui/react/menu";
3
3
  import { useState } from "react";
4
4
  import { minWidth, useMediaQuery } from "../../hooks/useMediaQuery.js";
5
+ import popup_module from "../../styles/popup.module.js";
5
6
  import NavMenu_module from "./NavMenu.module.js";
6
7
  function defaultRenderLink(item, { children, ...linkProps }) {
7
8
  return /*#__PURE__*/ jsx("a", {
@@ -66,12 +67,13 @@ function NavMenu({ items, currentPath, label = 'Primary', renderLink = defaultRe
66
67
  }),
67
68
  /*#__PURE__*/ jsx(Menu.Portal, {
68
69
  children: /*#__PURE__*/ jsx(Menu.Positioner, {
69
- className: NavMenu_module.positioner,
70
+ className: popup_module.layer,
70
71
  side: "bottom",
71
72
  align: "end",
72
73
  sideOffset: 8,
73
74
  children: /*#__PURE__*/ jsx(Menu.Popup, {
74
- className: NavMenu_module.popup,
75
+ className: popup_module.surface,
76
+ "data-popup": "menu",
75
77
  children: items.map((item)=>/*#__PURE__*/ jsx(Menu.Item, {
76
78
  className: NavMenu_module.item,
77
79
  render: renderLink(item, linkPropsFor(item, currentPath))
@@ -5,8 +5,6 @@ const NavMenu_module = {
5
5
  link: "link-R0jaI",
6
6
  trigger: "trigger-dj75u",
7
7
  triggerIcon: "triggerIcon-gSo04",
8
- positioner: "positioner-BPm1p",
9
- popup: "popup-hUQFV",
10
8
  item: "item-yXJoa"
11
9
  };
12
10
  export default NavMenu_module;
@@ -57,21 +57,6 @@
57
57
  height: 1.125rem;
58
58
  }
59
59
 
60
- .positioner-BPm1p {
61
- z-index: 50;
62
- }
63
-
64
- .popup-hUQFV {
65
- min-width: 12rem;
66
- padding: var(--space-2);
67
- border: 1px solid var(--color-border);
68
- border-radius: var(--radius-lg);
69
- background: var(--color-surface-raised);
70
- box-shadow: var(--elevation-2);
71
- flex-direction: column;
72
- display: flex;
73
- }
74
-
75
60
  .item-yXJoa {
76
61
  padding-inline: var(--space-3);
77
62
  border-radius: var(--radius-md);
@@ -0,0 +1,42 @@
1
+ import type { ReactElement, ReactNode } from 'react';
2
+ export type PopupSide = 'top' | 'bottom' | 'left' | 'right';
3
+ export type PopupAlign = 'start' | 'center' | 'end';
4
+ export interface PopoverProps {
5
+ /**
6
+ * The control that opens the popover, rendered as the trigger itself: Base UI merges
7
+ * `aria-haspopup`, `aria-expanded` and `aria-controls` onto this element, so it must be a
8
+ * single element that produces a native `<button>` — `Button` and `IconButton` both do.
9
+ */
10
+ trigger: ReactElement;
11
+ /** Names the popup: it is both the visible heading and the popup's `aria-labelledby` target. */
12
+ heading: string;
13
+ headingLevel?: 2 | 3 | 4;
14
+ /** Sits under the heading and becomes the popup's `aria-describedby` target. */
15
+ description?: ReactNode;
16
+ children?: ReactNode;
17
+ side?: PopupSide;
18
+ align?: PopupAlign;
19
+ /** Gap between the anchor and the popup, in pixels. */
20
+ sideOffset?: number;
21
+ /**
22
+ * `true` locks page scroll, blocks pointer interaction outside, and paints the scrim.
23
+ * `'trap-focus'` traps focus and nothing else: page scroll keeps working and clicks outside
24
+ * still land, so it paints **no** scrim — a full-viewport wash that swallows every outside
25
+ * click is exactly what that mode exists not to do. `false`, the default, does none of it.
26
+ *
27
+ * Either truthy value renders the visually-hidden close control below, because Base UI only
28
+ * arms its focus trap when a `Popover.Close` is present inside the popup — `modal` on its own
29
+ * traps nothing, silently — and because a touch screen reader needs a way out of the popup.
30
+ */
31
+ modal?: boolean | 'trap-focus';
32
+ /** The accessible name of that close control. */
33
+ closeLabel?: string;
34
+ open?: boolean;
35
+ defaultOpen?: boolean;
36
+ /**
37
+ * Base UI calls this as `(open, eventDetails)`; a handler that takes only the first argument
38
+ * is what most callers want, and the second is passed through untouched for one that doesn't.
39
+ */
40
+ onOpenChange?: (open: boolean, eventDetails: unknown) => void;
41
+ }
42
+ export declare function Popover({ trigger, heading, headingLevel, description, children, side, align, sideOffset, modal, closeLabel, open, defaultOpen, onOpenChange, }: PopoverProps): import("react").JSX.Element;
@@ -0,0 +1,61 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Popover } from "@base-ui/react/popover";
3
+ import a11y_module from "../../styles/a11y.module.js";
4
+ import popup_module from "../../styles/popup.module.js";
5
+ import Popover_module from "./Popover.module.js";
6
+ const headingTags = {
7
+ 2: 'h2',
8
+ 3: 'h3',
9
+ 4: 'h4'
10
+ };
11
+ function Popover_Popover({ trigger, heading, headingLevel = 3, description, children, side = 'bottom', align = 'center', sideOffset = 8, modal = false, closeLabel = 'Close', open, defaultOpen, onOpenChange }) {
12
+ const Heading = headingTags[headingLevel] ?? 'h3';
13
+ return /*#__PURE__*/ jsxs(Popover.Root, {
14
+ open: open,
15
+ defaultOpen: defaultOpen,
16
+ onOpenChange: onOpenChange,
17
+ modal: modal,
18
+ children: [
19
+ /*#__PURE__*/ jsx(Popover.Trigger, {
20
+ render: trigger
21
+ }),
22
+ /*#__PURE__*/ jsxs(Popover.Portal, {
23
+ children: [
24
+ true === modal ? /*#__PURE__*/ jsx(Popover.Backdrop, {
25
+ className: [
26
+ popup_module.layer,
27
+ popup_module.scrim
28
+ ].join(' ')
29
+ }) : null,
30
+ /*#__PURE__*/ jsx(Popover.Positioner, {
31
+ className: popup_module.layer,
32
+ side: side,
33
+ align: align,
34
+ sideOffset: sideOffset,
35
+ children: /*#__PURE__*/ jsxs(Popover.Popup, {
36
+ className: popup_module.surface,
37
+ "data-popup": "popover",
38
+ children: [
39
+ /*#__PURE__*/ jsx(Popover.Title, {
40
+ className: Popover_module.heading,
41
+ render: /*#__PURE__*/ jsx(Heading, {}),
42
+ children: heading
43
+ }),
44
+ void 0 === description ? null : /*#__PURE__*/ jsx(Popover.Description, {
45
+ className: Popover_module.description,
46
+ children: description
47
+ }),
48
+ children,
49
+ false === modal ? null : /*#__PURE__*/ jsx(Popover.Close, {
50
+ className: a11y_module.visuallyHidden,
51
+ children: closeLabel
52
+ })
53
+ ]
54
+ })
55
+ })
56
+ ]
57
+ })
58
+ ]
59
+ });
60
+ }
61
+ export { Popover_Popover as Popover };
@@ -0,0 +1,6 @@
1
+ import "./Popover_module.css";
2
+ const Popover_module = {
3
+ heading: "heading-d0Ysc",
4
+ description: "description-IgC4A"
5
+ };
6
+ export default Popover_module;
@@ -0,0 +1,13 @@
1
+ .heading-d0Ysc {
2
+ color: var(--color-text);
3
+ font-size: var(--text-sm);
4
+ font-weight: 600;
5
+ line-height: var(--leading-snug);
6
+ }
7
+
8
+ .description-IgC4A {
9
+ color: var(--color-text-muted);
10
+ font-size: var(--text-sm);
11
+ line-height: var(--leading-prose);
12
+ }
13
+
@@ -0,0 +1,35 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type FieldFrameProps } from '../Field/Field.js';
3
+ export interface RadioOption {
4
+ /** Submitted with the form, and what `value`/`onValueChange` speak in. */
5
+ value: string;
6
+ /** The visible text, and that one radio's accessible name. */
7
+ label: string;
8
+ disabled?: boolean;
9
+ }
10
+ export interface RadioGroupProps extends FieldFrameProps {
11
+ /** Names the group. Rendered as a plain element, not a `<label>` — see the note below. */
12
+ label: string;
13
+ options: RadioOption[];
14
+ /** Sits under the options and joins the group's `aria-describedby`. */
15
+ description?: ReactNode;
16
+ /** Controlled. Pair it with `onValueChange`; use `defaultValue` for an uncontrolled group. */
17
+ value?: string;
18
+ defaultValue?: string;
19
+ /**
20
+ * The newly chosen option's value. One argument, as on every other control in the tier:
21
+ * Base UI calls its own callback `(value, eventDetails)` and this wrapper drops the second,
22
+ * which no consumer can read without a cast.
23
+ */
24
+ onValueChange?: (value: string) => void;
25
+ /**
26
+ * Called when the focus leaves a radio. A form library marks a field touched on blur, and the
27
+ * adapter in `FormExample` spreads one `onBlur` onto every control; without this prop the
28
+ * group silently dropped it. React's blur bubbles, so moving between the options with the
29
+ * arrow keys fires it too — a form library counts that as touched either way.
30
+ */
31
+ onBlur?: () => void;
32
+ /** `horizontal` wraps the options along a row; the arrow keys work on both axes either way. */
33
+ orientation?: 'vertical' | 'horizontal';
34
+ }
35
+ export declare function RadioGroup({ label, options, name, description, error, value, defaultValue, onValueChange, onBlur, required, disabled, orientation, }: RadioGroupProps): import("react").JSX.Element;
@@ -0,0 +1,64 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Field } from "@base-ui/react/field";
3
+ import { Radio } from "@base-ui/react/radio";
4
+ import { RadioGroup } from "@base-ui/react/radio-group";
5
+ import { useId } from "react";
6
+ import field_module from "../../styles/field.module.js";
7
+ import { FieldMessages, RequiredMark } from "../Field/Field.js";
8
+ import RadioGroup_module from "./RadioGroup.module.js";
9
+ function RadioGroup_RadioGroup({ label, options, name, description, error, value, defaultValue, onValueChange, onBlur, required = false, disabled = false, orientation = 'vertical' }) {
10
+ const labelId = useId();
11
+ return /*#__PURE__*/ jsxs(Field.Root, {
12
+ className: field_module.frame,
13
+ name: name,
14
+ disabled: disabled,
15
+ invalid: void 0 !== error,
16
+ children: [
17
+ /*#__PURE__*/ jsxs("span", {
18
+ className: field_module.legend,
19
+ id: labelId,
20
+ "data-disabled": disabled ? '' : void 0,
21
+ children: [
22
+ label,
23
+ /*#__PURE__*/ jsx(RequiredMark, {
24
+ when: required
25
+ })
26
+ ]
27
+ }),
28
+ /*#__PURE__*/ jsx(RadioGroup, {
29
+ className: field_module.options,
30
+ "data-orientation": orientation,
31
+ "aria-labelledby": labelId,
32
+ value: value,
33
+ defaultValue: defaultValue,
34
+ onValueChange: (nextValue)=>onValueChange?.(nextValue),
35
+ onBlur: onBlur,
36
+ required: required,
37
+ children: options.map((option)=>/*#__PURE__*/ jsx(Field.Item, {
38
+ disabled: option.disabled,
39
+ children: /*#__PURE__*/ jsxs(Field.Label, {
40
+ className: field_module.optionLabel,
41
+ children: [
42
+ /*#__PURE__*/ jsx(Radio.Root, {
43
+ className: [
44
+ field_module.controlBox,
45
+ RadioGroup_module.dot
46
+ ].join(' '),
47
+ value: option.value,
48
+ children: /*#__PURE__*/ jsx(Radio.Indicator, {
49
+ className: RadioGroup_module.mark
50
+ })
51
+ }),
52
+ option.label
53
+ ]
54
+ })
55
+ }, option.value))
56
+ }),
57
+ /*#__PURE__*/ jsx(FieldMessages, {
58
+ description: description,
59
+ error: error
60
+ })
61
+ ]
62
+ });
63
+ }
64
+ export { RadioGroup_RadioGroup as RadioGroup };
@@ -0,0 +1,6 @@
1
+ import "./RadioGroup_module.css";
2
+ const RadioGroup_module = {
3
+ dot: "dot-A51b6",
4
+ mark: "mark-zVMGA"
5
+ };
6
+ export default RadioGroup_module;
@@ -0,0 +1,13 @@
1
+ .dot-A51b6 {
2
+ border-radius: var(--radius-full);
3
+ width: 1.25rem;
4
+ height: 1.25rem;
5
+ }
6
+
7
+ .mark-zVMGA {
8
+ border-radius: var(--radius-full);
9
+ background: var(--color-accent-text);
10
+ width: .5rem;
11
+ height: .5rem;
12
+ }
13
+
@@ -0,0 +1,42 @@
1
+ import type { ReactNode } from 'react';
2
+ import { type FieldFrameProps } from '../Field/Field.js';
3
+ import type { PopupAlign, PopupSide } from '../Popover/Popover.js';
4
+ export interface SelectOption {
5
+ /** Submitted with the form, and what `value`/`onValueChange` speak in. */
6
+ value: string;
7
+ /** The visible text, on the option and — once chosen — on the trigger. */
8
+ label: string;
9
+ disabled?: boolean;
10
+ }
11
+ export interface SelectProps extends FieldFrameProps {
12
+ /** The visible label, and the trigger's accessible name. */
13
+ label: string;
14
+ options: SelectOption[];
15
+ /** Sits under the trigger and joins its `aria-describedby`. */
16
+ description?: ReactNode;
17
+ /** Shown on the trigger while nothing is chosen. */
18
+ placeholder?: string;
19
+ /**
20
+ * `null` is a real state — a select that has been cleared — so it is in the type rather than
21
+ * narrowed away. Use with `onValueChange` for a controlled select; `defaultValue` otherwise.
22
+ */
23
+ value?: string | null;
24
+ defaultValue?: string | null;
25
+ /**
26
+ * The chosen value, or `null` once the select has been cleared. One argument, as on every
27
+ * other control in the tier: Base UI calls its own callback `(value, eventDetails)` and this
28
+ * wrapper drops the second, which no consumer can read without a cast.
29
+ */
30
+ onValueChange?: (value: string | null) => void;
31
+ /**
32
+ * Called when the focus leaves the trigger — including when the popup opens and takes it.
33
+ * A form library marks a field touched on blur, and the adapter in `FormExample` spreads one
34
+ * `onBlur` onto every control; without this prop the select silently dropped it.
35
+ */
36
+ onBlur?: () => void;
37
+ side?: PopupSide;
38
+ align?: PopupAlign;
39
+ /** Gap between the trigger and the popup, in pixels. */
40
+ sideOffset?: number;
41
+ }
42
+ export declare function Select({ label, options, name, description, error, required, disabled, placeholder, value, defaultValue, onValueChange, onBlur, side, align, sideOffset, }: SelectProps): import("react").JSX.Element;
@@ -0,0 +1,90 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Field } from "@base-ui/react/field";
3
+ import { Select } from "@base-ui/react/select";
4
+ import { CheckIcon } from "../../icons/CheckIcon.js";
5
+ import { ChevronDownIcon } from "../../icons/ChevronDownIcon.js";
6
+ import field_module from "../../styles/field.module.js";
7
+ import popup_module from "../../styles/popup.module.js";
8
+ import { FieldMessages, RequiredMark } from "../Field/Field.js";
9
+ import Select_module from "./Select.module.js";
10
+ function Select_Select({ label, options, name, description, error, required = false, disabled = false, placeholder = 'Select…', value, defaultValue, onValueChange, onBlur, side = 'bottom', align = 'start', sideOffset = 8 }) {
11
+ return /*#__PURE__*/ jsxs(Field.Root, {
12
+ className: field_module.frame,
13
+ name: name,
14
+ disabled: disabled,
15
+ invalid: void 0 !== error,
16
+ children: [
17
+ /*#__PURE__*/ jsxs(Field.Label, {
18
+ className: field_module.label,
19
+ nativeLabel: false,
20
+ render: /*#__PURE__*/ jsx("span", {}),
21
+ children: [
22
+ label,
23
+ /*#__PURE__*/ jsx(RequiredMark, {
24
+ when: required
25
+ })
26
+ ]
27
+ }),
28
+ /*#__PURE__*/ jsxs(Select.Root, {
29
+ items: options,
30
+ value: value,
31
+ defaultValue: defaultValue,
32
+ onValueChange: (nextValue)=>onValueChange?.(nextValue),
33
+ required: required,
34
+ children: [
35
+ /*#__PURE__*/ jsxs(Select.Trigger, {
36
+ className: [
37
+ field_module.control,
38
+ Select_module.trigger
39
+ ].join(' '),
40
+ onBlur: onBlur,
41
+ children: [
42
+ /*#__PURE__*/ jsx(Select.Value, {
43
+ className: Select_module.value,
44
+ placeholder: placeholder
45
+ }),
46
+ /*#__PURE__*/ jsx(Select.Icon, {
47
+ className: Select_module.icon,
48
+ children: /*#__PURE__*/ jsx(ChevronDownIcon, {})
49
+ })
50
+ ]
51
+ }),
52
+ /*#__PURE__*/ jsx(Select.Portal, {
53
+ children: /*#__PURE__*/ jsx(Select.Positioner, {
54
+ className: popup_module.layer,
55
+ side: side,
56
+ align: align,
57
+ sideOffset: sideOffset,
58
+ alignItemWithTrigger: false,
59
+ children: /*#__PURE__*/ jsx(Select.Popup, {
60
+ className: popup_module.surface,
61
+ "data-popup": "select",
62
+ children: /*#__PURE__*/ jsx(Select.List, {
63
+ children: options.map((option)=>/*#__PURE__*/ jsxs(Select.Item, {
64
+ className: Select_module.option,
65
+ value: option.value,
66
+ disabled: option.disabled,
67
+ children: [
68
+ /*#__PURE__*/ jsx(Select.ItemText, {
69
+ children: option.label
70
+ }),
71
+ /*#__PURE__*/ jsx(Select.ItemIndicator, {
72
+ className: Select_module.indicator,
73
+ children: /*#__PURE__*/ jsx(CheckIcon, {})
74
+ })
75
+ ]
76
+ }, option.value))
77
+ })
78
+ })
79
+ })
80
+ })
81
+ ]
82
+ }),
83
+ /*#__PURE__*/ jsx(FieldMessages, {
84
+ description: description,
85
+ error: error
86
+ })
87
+ ]
88
+ });
89
+ }
90
+ export { Select_Select as Select };
@@ -0,0 +1,9 @@
1
+ import "./Select_module.css";
2
+ const Select_module = {
3
+ trigger: "trigger-UPubf",
4
+ value: "value-fKND1",
5
+ icon: "icon-_ToIv",
6
+ option: "option-vv9zm",
7
+ indicator: "indicator-O12DN"
8
+ };
9
+ export default Select_module;
@@ -0,0 +1,70 @@
1
+ .trigger-UPubf {
2
+ justify-content: space-between;
3
+ gap: var(--space-3);
4
+ text-align: start;
5
+ cursor: pointer;
6
+ }
7
+
8
+ .value-fKND1 {
9
+ white-space: nowrap;
10
+ text-overflow: ellipsis;
11
+ overflow: hidden;
12
+ }
13
+
14
+ .value-fKND1[data-placeholder] {
15
+ color: var(--color-text-subtle);
16
+ }
17
+
18
+ .icon-_ToIv {
19
+ color: var(--color-text-muted);
20
+ transition-property: transform;
21
+ transition-duration: var(--motion-duration-1);
22
+ transition-timing-function: var(--motion-ease);
23
+ flex: none;
24
+ display: inline-flex;
25
+ }
26
+
27
+ .icon-_ToIv > svg {
28
+ width: 1rem;
29
+ height: 1rem;
30
+ }
31
+
32
+ .icon-_ToIv[data-popup-open] {
33
+ transform: rotate(180deg);
34
+ }
35
+
36
+ .option-vv9zm {
37
+ justify-content: space-between;
38
+ align-items: center;
39
+ gap: var(--space-3);
40
+ min-height: var(--size-touch);
41
+ padding-inline: var(--space-3);
42
+ border-radius: var(--radius-md);
43
+ color: var(--color-text);
44
+ font-size: var(--text-md);
45
+ cursor: pointer;
46
+ -webkit-user-select: none;
47
+ user-select: none;
48
+ display: flex;
49
+ }
50
+
51
+ .option-vv9zm[data-highlighted] {
52
+ background: var(--color-surface-2);
53
+ }
54
+
55
+ .option-vv9zm[data-disabled] {
56
+ cursor: not-allowed;
57
+ opacity: .45;
58
+ }
59
+
60
+ .indicator-O12DN {
61
+ color: var(--color-accent);
62
+ flex: none;
63
+ display: inline-flex;
64
+ }
65
+
66
+ .indicator-O12DN > svg {
67
+ width: 1rem;
68
+ height: 1rem;
69
+ }
70
+