@efolusi/meridian 1.20.0 → 1.21.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 (183) hide show
  1. package/README.md +1 -1
  2. package/ai/Bubble.d.ts +16 -0
  3. package/ai/Bubble.js +71 -0
  4. package/ai/ChatMessage.js +2 -5
  5. package/ai/Confirmation.d.ts +0 -7
  6. package/ai/Confirmation.js +3 -6
  7. package/ai/GeneratedImage.d.ts +0 -2
  8. package/ai/GeneratedImage.js +2 -4
  9. package/ai/Marker.d.ts +26 -0
  10. package/ai/Marker.js +67 -0
  11. package/ai/Message.d.ts +13 -0
  12. package/ai/Message.js +68 -0
  13. package/ai/MessageScroller.d.ts +21 -0
  14. package/ai/MessageScroller.js +283 -0
  15. package/ai/ModelSelector.d.ts +2 -2
  16. package/ai/ModelSelector.js +1 -2
  17. package/ai/Player.js +1 -1
  18. package/ai/PromptSteps.js +4 -2
  19. package/ai/Sandbox.d.ts +0 -2
  20. package/ai/Sandbox.js +2 -4
  21. package/ai/Suggestions.d.ts +0 -2
  22. package/ai/Suggestions.js +1 -4
  23. package/ai/WebPreview.d.ts +0 -2
  24. package/ai/WebPreview.js +2 -4
  25. package/code/Console.js +1 -1
  26. package/code/EnvList.d.ts +0 -2
  27. package/code/EnvList.js +2 -3
  28. package/components.css +652 -418
  29. package/data/BarChart.d.ts +0 -2
  30. package/data/BarChart.js +1 -4
  31. package/data/Chart.d.ts +14 -0
  32. package/data/Chart.js +149 -0
  33. package/data/EmptyState.d.ts +8 -13
  34. package/data/EmptyState.js +62 -24
  35. package/data/LineChart.js +7 -4
  36. package/data/Skeleton.d.ts +2 -11
  37. package/data/Skeleton.js +8 -38
  38. package/data/Sparkline.js +4 -1
  39. package/data/StatusDot.d.ts +0 -4
  40. package/data/StatusDot.js +3 -6
  41. package/data/Table.d.ts +11 -4
  42. package/data/Table.js +39 -7
  43. package/dates/Calendar.d.ts +10 -27
  44. package/dates/Calendar.js +250 -184
  45. package/dates/TimePicker.js +2 -2
  46. package/display/Accordion.d.ts +47 -15
  47. package/display/Accordion.js +257 -27
  48. package/display/AspectRatio.d.ts +4 -6
  49. package/display/AspectRatio.js +7 -5
  50. package/display/Avatar.d.ts +17 -14
  51. package/display/Avatar.js +68 -43
  52. package/display/Badge.d.ts +9 -8
  53. package/display/Badge.js +32 -14
  54. package/display/Card.d.ts +11 -13
  55. package/display/Card.js +74 -29
  56. package/display/Carousel.d.ts +23 -15
  57. package/display/Carousel.js +217 -66
  58. package/display/Collapsible.d.ts +19 -9
  59. package/display/Collapsible.js +140 -28
  60. package/display/Direction.d.ts +10 -0
  61. package/display/Direction.js +24 -0
  62. package/display/Item.d.ts +19 -0
  63. package/display/Item.js +152 -0
  64. package/display/Kbd.d.ts +5 -7
  65. package/display/Kbd.js +22 -10
  66. package/display/Link.js +2 -4
  67. package/display/Resizable.d.ts +6 -16
  68. package/display/Resizable.js +141 -58
  69. package/display/ScrollArea.d.ts +3 -1
  70. package/display/ScrollArea.js +30 -5
  71. package/display/Separator.d.ts +9 -0
  72. package/display/Separator.js +18 -0
  73. package/display/Timeline.d.ts +24 -0
  74. package/display/Timeline.js +51 -0
  75. package/display/Toolbar.js +5 -4
  76. package/display/TreeList.d.ts +0 -2
  77. package/display/TreeList.js +2 -5
  78. package/feedback/Alert.d.ts +13 -13
  79. package/feedback/Alert.js +40 -36
  80. package/feedback/AlertDialog.d.ts +30 -0
  81. package/feedback/AlertDialog.js +249 -0
  82. package/feedback/Banner.d.ts +1 -3
  83. package/feedback/Banner.js +1 -5
  84. package/feedback/ConfirmDialog.d.ts +1 -1
  85. package/feedback/ConfirmDialog.js +18 -20
  86. package/feedback/Dialog.d.ts +13 -16
  87. package/feedback/Dialog.js +204 -62
  88. package/feedback/Progress.d.ts +8 -9
  89. package/feedback/Progress.js +42 -24
  90. package/feedback/Sonner.d.ts +8 -0
  91. package/feedback/Sonner.js +238 -0
  92. package/feedback/Spinner.d.ts +2 -9
  93. package/feedback/Spinner.js +19 -28
  94. package/feedback/Tooltip.d.ts +9 -10
  95. package/feedback/Tooltip.js +147 -96
  96. package/files/Attachment.d.ts +27 -0
  97. package/files/Attachment.js +111 -0
  98. package/files/FileDrop.js +3 -1
  99. package/finance/PaymentCard.js +3 -3
  100. package/forms/Button.d.ts +6 -5
  101. package/forms/Button.js +22 -8
  102. package/forms/ButtonGroup.d.ts +11 -3
  103. package/forms/ButtonGroup.js +57 -6
  104. package/forms/Checkbox.d.ts +14 -3
  105. package/forms/Checkbox.js +84 -16
  106. package/forms/Combobox.d.ts +24 -16
  107. package/forms/Combobox.js +466 -135
  108. package/forms/Field.d.ts +14 -0
  109. package/forms/Field.js +99 -0
  110. package/forms/IconButton.d.ts +1 -1
  111. package/forms/IconButton.js +4 -3
  112. package/forms/Input.d.ts +8 -8
  113. package/forms/Input.js +46 -33
  114. package/forms/InputGroup.d.ts +8 -15
  115. package/forms/InputGroup.js +74 -35
  116. package/forms/InputOTP.d.ts +13 -0
  117. package/forms/InputOTP.js +125 -0
  118. package/forms/Label.d.ts +2 -6
  119. package/forms/Label.js +6 -4
  120. package/forms/NativeSelect.d.ts +16 -0
  121. package/forms/NativeSelect.js +35 -0
  122. package/forms/NumberInput.js +2 -2
  123. package/forms/Radio.d.ts +12 -1
  124. package/forms/Radio.js +76 -6
  125. package/forms/Select.d.ts +12 -9
  126. package/forms/Select.js +254 -42
  127. package/forms/Slider.d.ts +10 -17
  128. package/forms/Slider.js +78 -39
  129. package/forms/Switch.d.ts +8 -2
  130. package/forms/Switch.js +46 -15
  131. package/forms/Textarea.d.ts +1 -1
  132. package/forms/Textarea.js +26 -18
  133. package/forms/Toggle.d.ts +18 -15
  134. package/forms/Toggle.js +96 -42
  135. package/icons/_svg.js +2 -0
  136. package/index.d.ts +20 -8
  137. package/index.js +50 -38
  138. package/navigation/Breadcrumbs.d.ts +18 -11
  139. package/navigation/Breadcrumbs.js +99 -26
  140. package/navigation/Menubar.d.ts +52 -10
  141. package/navigation/Menubar.js +191 -146
  142. package/navigation/NavigationMenu.d.ts +15 -0
  143. package/navigation/NavigationMenu.js +296 -0
  144. package/navigation/Pagination.d.ts +10 -9
  145. package/navigation/Pagination.js +94 -51
  146. package/navigation/SideNav.js +4 -3
  147. package/navigation/Sidebar.d.ts +29 -0
  148. package/navigation/Sidebar.js +311 -0
  149. package/navigation/Tabs.d.ts +9 -5
  150. package/navigation/Tabs.js +132 -44
  151. package/overlay/Command.d.ts +32 -0
  152. package/overlay/Command.js +257 -0
  153. package/overlay/ContextMenu.d.ts +40 -8
  154. package/overlay/ContextMenu.js +468 -107
  155. package/overlay/Drawer.d.ts +29 -14
  156. package/overlay/Drawer.js +178 -80
  157. package/overlay/DropdownMenu.d.ts +43 -0
  158. package/overlay/DropdownMenu.js +502 -0
  159. package/overlay/HoverCard.d.ts +21 -12
  160. package/overlay/HoverCard.js +129 -61
  161. package/overlay/Popover.d.ts +11 -13
  162. package/overlay/Popover.js +138 -65
  163. package/overlay/Portal.js +21 -7
  164. package/overlay/Sheet.d.ts +11 -0
  165. package/overlay/Sheet.js +62 -0
  166. package/package.json +4 -1
  167. package/tokens/base.css +1 -1
  168. package/dates/DatePicker.d.ts +0 -14
  169. package/dates/DatePicker.js +0 -111
  170. package/dates/DateRangePicker.d.ts +0 -23
  171. package/dates/DateRangePicker.js +0 -150
  172. package/display/ListItem.d.ts +0 -19
  173. package/display/ListItem.js +0 -50
  174. package/feedback/Toast.d.ts +0 -78
  175. package/feedback/Toast.js +0 -192
  176. package/forms/DigitEntry.d.ts +0 -15
  177. package/forms/DigitEntry.js +0 -79
  178. package/forms/FormField.d.ts +0 -82
  179. package/forms/FormField.js +0 -209
  180. package/overlay/CommandPalette.d.ts +0 -21
  181. package/overlay/CommandPalette.js +0 -148
  182. package/overlay/Menu.d.ts +0 -24
  183. package/overlay/Menu.js +0 -139
@@ -0,0 +1,35 @@
1
+ 'use client';
2
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
+ import React from 'react';
4
+ import { Icon } from "../icons/Icon.js";
5
+ import { mergeRefs } from "./Button.js";
6
+ export const NativeSelect = /*#__PURE__*/React.forwardRef(function NativeSelect({
7
+ size = 'md',
8
+ className,
9
+ style,
10
+ ...props
11
+ }, ref) {
12
+ return /*#__PURE__*/React.createElement("span", {
13
+ "data-slot": "native-select",
14
+ "data-size": size,
15
+ className: `ef-native-select${className ? ` ${className}` : ''}`,
16
+ style: style
17
+ }, /*#__PURE__*/React.createElement("select", _extends({}, props, {
18
+ ref: ref
19
+ })), /*#__PURE__*/React.createElement("span", {
20
+ className: "ef-native-select__icon"
21
+ }, /*#__PURE__*/React.createElement(Icon, {
22
+ name: "chevron-down",
23
+ size: 16
24
+ })));
25
+ });
26
+ export const NativeSelectOption = /*#__PURE__*/React.forwardRef(function NativeSelectOption(props, ref) {
27
+ return /*#__PURE__*/React.createElement("option", _extends({}, props, {
28
+ ref: ref
29
+ }));
30
+ });
31
+ export const NativeSelectOptGroup = /*#__PURE__*/React.forwardRef(function NativeSelectOptGroup(props, ref) {
32
+ return /*#__PURE__*/React.createElement("optgroup", _extends({}, props, {
33
+ ref: ref
34
+ }));
35
+ });
@@ -2,7 +2,7 @@
2
2
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
3
  import React from 'react';
4
4
  import { Icon } from "../icons/Icon.js";
5
- import { useFieldProps } from "./FormField.js";
5
+ import { useFieldProps } from "./Field.js";
6
6
  // How many decimal places a number carries, so a commit can round away float
7
7
  // noise: 0.1 + 0.2 must land as 0.3, not 0.30000000000000004.
8
8
  function decimalsOf(n) {
@@ -70,7 +70,7 @@ export function NumberInput({
70
70
  // explicit format or parse always wins over it, and no locale keeps the old
71
71
  // plain behaviour, so this is additive.
72
72
  const loc = locale && !(format && parse) ? localeNumber(locale) : null;
73
- // Picks up id / aria wiring when nested in a FormField; standalone this is a no-op.
73
+ // Picks up id / aria wiring when nested in a Field; standalone this is a no-op.
74
74
  const field = useFieldProps({
75
75
  invalid,
76
76
  error,
package/forms/Radio.d.ts CHANGED
@@ -3,4 +3,15 @@ export interface RadioProps extends React.InputHTMLAttributes<HTMLInputElement>
3
3
  /** Muted second line under the label */
4
4
  description?: string;
5
5
  }
6
- export declare function Radio(props: RadioProps): React.JSX.Element;
6
+ export declare const Radio: React.ForwardRefExoticComponent<RadioProps & React.RefAttributes<HTMLInputElement>>;
7
+ export interface RadioGroupProps extends React.HTMLAttributes<HTMLDivElement> {
8
+ value?: string;
9
+ defaultValue?: string;
10
+ onValueChange?: (value: string) => void;
11
+ name?: string;
12
+ required?: boolean;
13
+ disabled?: boolean;
14
+ orientation?: 'horizontal' | 'vertical';
15
+ }
16
+ export declare const RadioGroup: React.ForwardRefExoticComponent<RadioGroupProps & React.RefAttributes<HTMLDivElement>>;
17
+ export declare const RadioGroupItem: React.ForwardRefExoticComponent<Omit<RadioProps, 'type'> & { value: string } & React.RefAttributes<HTMLInputElement>>;
package/forms/Radio.js CHANGED
@@ -1,16 +1,82 @@
1
1
  'use client';
2
2
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
3
  import React from 'react';
4
- import { useFieldProps } from "./FormField.js";
5
- export function Radio({
4
+ import { useFieldProps } from "./Field.js";
5
+ const RadioGroupContext = /*#__PURE__*/React.createContext(null);
6
+ export const RadioGroup = /*#__PURE__*/React.forwardRef(function RadioGroup({
7
+ value: valueProp,
8
+ defaultValue,
9
+ onValueChange,
10
+ name,
11
+ required,
12
+ disabled,
13
+ orientation = 'vertical',
14
+ className,
15
+ style,
16
+ children,
17
+ ...rest
18
+ }, ref) {
19
+ const [inner, setInner] = React.useState(defaultValue);
20
+ const value = valueProp !== undefined ? valueProp : inner;
21
+ const generatedName = React.useId();
22
+ const change = next => {
23
+ if (valueProp === undefined) setInner(next);
24
+ onValueChange?.(next);
25
+ };
26
+ return /*#__PURE__*/React.createElement(RadioGroupContext.Provider, {
27
+ value: {
28
+ value,
29
+ change,
30
+ name: name || generatedName,
31
+ required,
32
+ disabled
33
+ }
34
+ }, /*#__PURE__*/React.createElement("div", _extends({}, rest, {
35
+ ref: ref,
36
+ role: "radiogroup",
37
+ "aria-orientation": orientation,
38
+ "data-slot": "radio-group",
39
+ "data-orientation": orientation,
40
+ "data-disabled": disabled ? '' : undefined,
41
+ className: `ef-radio-group${className ? ' ' + className : ''}`,
42
+ style: style
43
+ }), children));
44
+ });
45
+ export const RadioGroupItem = /*#__PURE__*/React.forwardRef(function RadioGroupItem({
46
+ value,
47
+ disabled,
48
+ onChange,
49
+ className,
50
+ style,
51
+ ...rest
52
+ }, ref) {
53
+ const group = React.useContext(RadioGroupContext);
54
+ const unavailable = disabled || group?.disabled;
55
+ return /*#__PURE__*/React.createElement(Radio, _extends({
56
+ ref: ref,
57
+ value: value,
58
+ name: group?.name,
59
+ required: group?.required,
60
+ disabled: unavailable,
61
+ checked: group ? group.value === value : rest.checked,
62
+ "data-disabled": unavailable ? '' : undefined,
63
+ onChange: e => {
64
+ if (group) group.change(value);
65
+ onChange?.(e);
66
+ },
67
+ className: className,
68
+ style: style
69
+ }, rest));
70
+ });
71
+ export const Radio = /*#__PURE__*/React.forwardRef(function Radio({
6
72
  label,
7
73
  description,
8
74
  disabled,
9
75
  style,
10
76
  className,
11
77
  ...rest
12
- }) {
13
- // Picks up id / aria wiring when nested in a FormField; standalone this is a no-op.
78
+ }, ref) {
79
+ // Picks up id / aria wiring when nested in a Field; standalone this is a no-op.
14
80
  const field = useFieldProps({
15
81
  id: rest.id,
16
82
  'aria-describedby': rest['aria-describedby']
@@ -19,14 +85,18 @@ export function Radio({
19
85
  className: `ef-radio${disabled ? ' ef-radio--disabled' : ''}${className ? ' ' + className : ''}`,
20
86
  style: style
21
87
  }, /*#__PURE__*/React.createElement("input", _extends({
88
+ ref: ref,
22
89
  type: "radio",
90
+ "data-slot": "radio-group-item",
91
+ "data-state": rest.checked ? 'checked' : 'unchecked',
23
92
  className: "ef-radio__input",
24
93
  disabled: disabled
25
94
  }, rest, field.controlProps)), /*#__PURE__*/React.createElement("span", {
26
- className: "ef-radio__dot"
95
+ className: "ef-radio__dot",
96
+ "aria-hidden": "true"
27
97
  }), label ? /*#__PURE__*/React.createElement("span", {
28
98
  className: "ef-radio__label"
29
99
  }, label, description ? /*#__PURE__*/React.createElement("span", {
30
100
  className: "ef-radio__desc"
31
101
  }, description) : null) : null);
32
- }
102
+ });
package/forms/Select.d.ts CHANGED
@@ -1,10 +1,13 @@
1
- export interface SelectProps extends Omit<React.SelectHTMLAttributes<HTMLSelectElement>, 'size'> {
2
- label?: string;
3
- hint?: string;
4
- /** Options as strings or {value, label}; alternatively pass <option> children */
5
- options?: Array<string | { value: string; label: string }>;
6
- /** @default 'md' */
7
- size?: 'sm' | 'md' | 'lg';
8
- invalid?: boolean;
9
- }
1
+ export interface SelectProps { value?: string; defaultValue?: string; onValueChange?: (value: string) => void; open?: boolean; defaultOpen?: boolean; onOpenChange?: (open: boolean) => void; disabled?: boolean; name?: string; required?: boolean; children?: React.ReactNode }
10
2
  export declare function Select(props: SelectProps): React.JSX.Element;
3
+ export type SelectTriggerProps = React.ComponentPropsWithoutRef<'button'>;
4
+ export declare const SelectTrigger: React.ForwardRefExoticComponent<SelectTriggerProps & React.RefAttributes<HTMLButtonElement>>;
5
+ export interface SelectValueProps { placeholder?: React.ReactNode; children?: React.ReactNode; className?: string }
6
+ export declare function SelectValue(props: SelectValueProps): React.JSX.Element;
7
+ export type SelectContentProps = React.ComponentPropsWithoutRef<'div'> & { position?: 'item-aligned' | 'popper'; align?: 'start' | 'center' | 'end'; sideOffset?: number };
8
+ export declare const SelectContent: React.ForwardRefExoticComponent<SelectContentProps & React.RefAttributes<HTMLDivElement>>;
9
+ export declare const SelectGroup: React.ForwardRefExoticComponent<React.ComponentPropsWithoutRef<'div'> & React.RefAttributes<HTMLDivElement>>;
10
+ export declare const SelectLabel: React.ForwardRefExoticComponent<React.ComponentPropsWithoutRef<'div'> & React.RefAttributes<HTMLDivElement>>;
11
+ export type SelectItemProps = Omit<React.ComponentPropsWithoutRef<'button'>, 'value'> & { value: string };
12
+ export declare const SelectItem: React.ForwardRefExoticComponent<SelectItemProps & React.RefAttributes<HTMLButtonElement>>;
13
+ export declare const SelectSeparator: React.ForwardRefExoticComponent<React.ComponentPropsWithoutRef<'div'> & React.RefAttributes<HTMLDivElement>>;
package/forms/Select.js CHANGED
@@ -2,51 +2,263 @@
2
2
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
3
  import React from 'react';
4
4
  import { Icon } from "../icons/Icon.js";
5
- import { useFieldProps } from "./FormField.js";
5
+ import { mergeRefs } from "./Button.js";
6
+ import { Portal, useAnchoredStyle } from "../overlay/Portal.js";
7
+ const SelectCtx = /*#__PURE__*/React.createContext(null);
8
+ const itemText = children => typeof children === 'string' || typeof children === 'number' ? String(children) : '';
9
+ function collectLabels(children, out = {}) {
10
+ React.Children.forEach(children, child => {
11
+ if (! /*#__PURE__*/React.isValidElement(child)) return;
12
+ if (child.type === SelectItem) out[child.props.value] = itemText(child.props.children) || child.props.value;
13
+ if (child.props.children) collectLabels(child.props.children, out);
14
+ });
15
+ return out;
16
+ }
6
17
  export function Select({
7
- label,
8
- hint,
9
- options,
10
- size = 'md',
11
- invalid,
18
+ value: controlled,
19
+ defaultValue = '',
20
+ onValueChange,
21
+ onOpenChange,
22
+ open: controlledOpen,
23
+ defaultOpen = false,
24
+ disabled = false,
25
+ name,
26
+ required,
27
+ children
28
+ }) {
29
+ const [innerValue, setInnerValue] = React.useState(defaultValue);
30
+ const [innerOpen, setInnerOpen] = React.useState(defaultOpen);
31
+ const value = controlled !== undefined ? controlled : innerValue;
32
+ const open = controlledOpen !== undefined ? controlledOpen : innerOpen;
33
+ const triggerRef = React.useRef(null);
34
+ const contentRef = React.useRef(null);
35
+ const declaredLabels = React.useMemo(() => collectLabels(children), [children]);
36
+ const [labels, setLabels] = React.useState(declaredLabels);
37
+ const setOpen = React.useCallback(next => {
38
+ if (controlledOpen === undefined) setInnerOpen(next);
39
+ onOpenChange?.(next);
40
+ }, [controlledOpen, onOpenChange]);
41
+ const choose = React.useCallback((next, label) => {
42
+ if (controlled === undefined) setInnerValue(next);
43
+ onValueChange?.(next);
44
+ setLabels(prev => prev[next] === label ? prev : {
45
+ ...prev,
46
+ [next]: label
47
+ });
48
+ setOpen(false);
49
+ triggerRef.current?.focus();
50
+ }, [controlled, onValueChange, setOpen]);
51
+ const register = React.useCallback((next, label) => setLabels(prev => prev[next] === label ? prev : {
52
+ ...prev,
53
+ [next]: label
54
+ }), []);
55
+ const allLabels = {
56
+ ...declaredLabels,
57
+ ...labels
58
+ };
59
+ const ctx = React.useMemo(() => ({
60
+ value,
61
+ open,
62
+ disabled,
63
+ labels: allLabels,
64
+ setOpen,
65
+ choose,
66
+ register,
67
+ triggerRef,
68
+ contentRef
69
+ }), [value, open, disabled, allLabels, setOpen, choose, register]);
70
+ React.useEffect(() => {
71
+ if (!open) return;
72
+ const away = event => {
73
+ if (!triggerRef.current?.contains(event.target) && !contentRef.current?.contains(event.target)) setOpen(false);
74
+ };
75
+ document.addEventListener('pointerdown', away);
76
+ return () => document.removeEventListener('pointerdown', away);
77
+ }, [open, setOpen]);
78
+ return /*#__PURE__*/React.createElement(SelectCtx.Provider, {
79
+ value: ctx
80
+ }, name ? /*#__PURE__*/React.createElement("input", {
81
+ type: "hidden",
82
+ name: name,
83
+ value: value,
84
+ required: required
85
+ }) : null, children);
86
+ }
87
+ export const SelectTrigger = /*#__PURE__*/React.forwardRef(function SelectTrigger({
12
88
  children,
13
- style,
14
89
  className,
15
- ...rest
16
- }) {
17
- // Picks up id / aria wiring when nested in a FormField; standalone this is a no-op.
18
- const field = useFieldProps({
19
- invalid,
20
- id: rest.id,
21
- 'aria-describedby': rest['aria-describedby']
22
- });
23
- const control = /*#__PURE__*/React.createElement("span", {
24
- className: `ef-select ef-select--${size}${field.invalid ? ' ef-select--invalid' : ''}`
25
- }, /*#__PURE__*/React.createElement("select", _extends({
26
- className: "ef-select__el",
27
- "aria-invalid": field.invalid || undefined
28
- }, rest, field.controlProps), options ? options.map(o => typeof o === 'string' ? /*#__PURE__*/React.createElement("option", {
29
- key: o,
30
- value: o
31
- }, o) : /*#__PURE__*/React.createElement("option", {
32
- key: o.value,
33
- value: o.value
34
- }, o.label)) : children), /*#__PURE__*/React.createElement("span", {
35
- className: "ef-select__chevron"
36
- }, /*#__PURE__*/React.createElement(Icon, {
90
+ onClick,
91
+ onKeyDown,
92
+ ...props
93
+ }, ref) {
94
+ const ctx = React.useContext(SelectCtx);
95
+ const key = event => {
96
+ onKeyDown?.(event);
97
+ if (!event.defaultPrevented && ['Enter', ' ', 'ArrowDown', 'ArrowUp'].includes(event.key)) {
98
+ event.preventDefault();
99
+ ctx?.setOpen(true);
100
+ }
101
+ };
102
+ return /*#__PURE__*/React.createElement("button", _extends({}, props, {
103
+ ref: mergeRefs(ref, ctx?.triggerRef),
104
+ type: "button",
105
+ role: "combobox",
106
+ "aria-haspopup": "listbox",
107
+ "aria-expanded": !!ctx?.open,
108
+ disabled: ctx?.disabled || props.disabled,
109
+ "data-slot": "select-trigger",
110
+ className: `ef-select-trigger${className ? ` ${className}` : ''}`,
111
+ onClick: event => {
112
+ onClick?.(event);
113
+ if (!event.defaultPrevented) ctx?.setOpen(!ctx.open);
114
+ },
115
+ onKeyDown: key
116
+ }), children, /*#__PURE__*/React.createElement(Icon, {
37
117
  name: "chevron-down",
38
118
  size: 16
39
- })));
40
- if (!label && !hint) return /*#__PURE__*/React.cloneElement(control, {
41
- style,
42
- className: control.props.className + (className ? ' ' + className : '')
119
+ }));
120
+ });
121
+ export function SelectValue({
122
+ placeholder,
123
+ children,
124
+ className
125
+ }) {
126
+ const ctx = React.useContext(SelectCtx);
127
+ const shown = children ?? ctx?.labels[ctx?.value];
128
+ return /*#__PURE__*/React.createElement("span", {
129
+ "data-slot": "select-value",
130
+ "data-placeholder": shown ? undefined : '',
131
+ className: `ef-select-value${className ? ` ${className}` : ''}`
132
+ }, shown || placeholder);
133
+ }
134
+ export const SelectContent = /*#__PURE__*/React.forwardRef(function SelectContent({
135
+ children,
136
+ className,
137
+ position,
138
+ align = 'start',
139
+ sideOffset = 5,
140
+ onKeyDown,
141
+ style,
142
+ ...props
143
+ }, ref) {
144
+ const ctx = React.useContext(SelectCtx);
145
+ const {
146
+ style: anchored
147
+ } = useAnchoredStyle(ctx?.triggerRef, ctx?.contentRef, {
148
+ open: !!ctx?.open,
149
+ placement: 'bottom',
150
+ align,
151
+ offset: sideOffset
43
152
  });
44
- return /*#__PURE__*/React.createElement("label", {
45
- className: `ef-field${className ? ' ' + className : ''}`,
46
- style: style
47
- }, label ? /*#__PURE__*/React.createElement("span", {
48
- className: "ef-field__label"
49
- }, label) : null, control, hint ? /*#__PURE__*/React.createElement("span", {
50
- className: "ef-field__hint"
51
- }, hint) : null);
52
- }
153
+ React.useEffect(() => {
154
+ if (!ctx?.open) return;
155
+ requestAnimationFrame(() => {
156
+ const selected = ctx.contentRef.current?.querySelector('[aria-selected="true"]');
157
+ const first = ctx.contentRef.current?.querySelector('[role="option"]:not(:disabled)');
158
+ (selected || first)?.focus();
159
+ });
160
+ }, [ctx?.open]);
161
+ if (!ctx?.open) return null;
162
+ const key = event => {
163
+ onKeyDown?.(event);
164
+ if (event.defaultPrevented) return;
165
+ const items = [...event.currentTarget.querySelectorAll('[role="option"]:not(:disabled)')];
166
+ const index = items.indexOf(document.activeElement);
167
+ if (event.key === 'Escape') {
168
+ event.preventDefault();
169
+ ctx.setOpen(false);
170
+ ctx.triggerRef.current?.focus();
171
+ } else if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
172
+ event.preventDefault();
173
+ items[(index + (event.key === 'ArrowDown' ? 1 : -1) + items.length) % items.length]?.focus();
174
+ } else if (event.key === 'Home' || event.key === 'End') {
175
+ event.preventDefault();
176
+ items[event.key === 'Home' ? 0 : items.length - 1]?.focus();
177
+ } else if (event.key === 'Tab') ctx.setOpen(false);else if (event.key.length === 1 && /\S/.test(event.key) && !event.metaKey && !event.ctrlKey && !event.altKey) {
178
+ const query = event.key.toLocaleLowerCase();
179
+ const match = items.slice(index + 1).concat(items.slice(0, index + 1)).find(item => (item.textContent || '').trim().toLocaleLowerCase().startsWith(query));
180
+ if (match) {
181
+ event.preventDefault();
182
+ match.focus();
183
+ }
184
+ }
185
+ };
186
+ return /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement("div", _extends({}, props, {
187
+ ref: mergeRefs(ref, ctx.contentRef),
188
+ role: "listbox",
189
+ "data-slot": "select-content",
190
+ "data-position": position,
191
+ className: `ef-select-content${className ? ` ${className}` : ''}`,
192
+ style: {
193
+ ...anchored,
194
+ '--select-trigger-width': `${ctx.triggerRef.current?.offsetWidth || 160}px`,
195
+ ...style
196
+ },
197
+ onKeyDown: key
198
+ }), children));
199
+ });
200
+ export const SelectGroup = /*#__PURE__*/React.forwardRef(function SelectGroup({
201
+ className,
202
+ ...props
203
+ }, ref) {
204
+ return /*#__PURE__*/React.createElement("div", _extends({}, props, {
205
+ ref: ref,
206
+ role: "group",
207
+ "data-slot": "select-group",
208
+ className: `ef-select-group${className ? ` ${className}` : ''}`
209
+ }));
210
+ });
211
+ export const SelectLabel = /*#__PURE__*/React.forwardRef(function SelectLabel({
212
+ className,
213
+ ...props
214
+ }, ref) {
215
+ return /*#__PURE__*/React.createElement("div", _extends({}, props, {
216
+ ref: ref,
217
+ "data-slot": "select-label",
218
+ className: `ef-select-label${className ? ` ${className}` : ''}`
219
+ }));
220
+ });
221
+ export const SelectSeparator = /*#__PURE__*/React.forwardRef(function SelectSeparator({
222
+ className,
223
+ ...props
224
+ }, ref) {
225
+ return /*#__PURE__*/React.createElement("div", _extends({}, props, {
226
+ ref: ref,
227
+ role: "separator",
228
+ "data-slot": "select-separator",
229
+ className: `ef-select-separator${className ? ` ${className}` : ''}`
230
+ }));
231
+ });
232
+ export const SelectItem = /*#__PURE__*/React.forwardRef(function SelectItem({
233
+ value,
234
+ disabled = false,
235
+ children,
236
+ className,
237
+ onClick,
238
+ ...props
239
+ }, ref) {
240
+ const ctx = React.useContext(SelectCtx);
241
+ const label = itemText(children) || value;
242
+ React.useEffect(() => {
243
+ ctx?.register(value, label);
244
+ }, [ctx?.register, value, label]);
245
+ const selected = ctx?.value === value;
246
+ return /*#__PURE__*/React.createElement("button", _extends({}, props, {
247
+ ref: ref,
248
+ type: "button",
249
+ role: "option",
250
+ "aria-selected": selected,
251
+ disabled: disabled,
252
+ "data-slot": "select-item",
253
+ className: `ef-select-item${className ? ` ${className}` : ''}`,
254
+ onClick: event => {
255
+ onClick?.(event);
256
+ if (!event.defaultPrevented) ctx?.choose(value, label);
257
+ }
258
+ }), children, selected ? /*#__PURE__*/React.createElement("span", {
259
+ className: "ef-select-check"
260
+ }, /*#__PURE__*/React.createElement(Icon, {
261
+ name: "check",
262
+ size: 15
263
+ })) : null);
264
+ });
package/forms/Slider.d.ts CHANGED
@@ -1,18 +1,11 @@
1
- export interface SliderProps {
2
- label?: string;
3
- /** Show current value right of the label */
4
- showValue?: boolean;
5
- /** Format the shown value, e.g. v => v + '%' */
6
- format?: (v: number) => string;
7
- /** @default 0 */ min?: number;
8
- /** @default 100 */ max?: number;
9
- /** @default 1 */ step?: number;
10
- /** Controlled value */
11
- value?: number;
12
- defaultValue?: number;
13
- onChange?: (value: number, e: React.ChangeEvent) => void;
14
- disabled?: boolean;
15
- style?: React.CSSProperties;
16
- className?: string;
1
+ export interface SliderProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'value' | 'defaultValue' | 'onChange' | 'min' | 'max' | 'step' | 'size'> {
2
+ min?: number; max?: number; step?: number;
3
+ value?: number[]; defaultValue?: number[];
4
+ onValueChange?: (value: number[]) => void;
5
+ onValueCommit?: (value: number[]) => void;
6
+ orientation?: 'horizontal' | 'vertical';
7
+ minStepsBetweenThumbs?: number;
8
+ inverted?: boolean;
9
+ dir?: 'ltr' | 'rtl';
17
10
  }
18
- export declare function Slider(props: SliderProps): React.JSX.Element;
11
+ export declare const Slider: React.ForwardRefExoticComponent<SliderProps & React.RefAttributes<HTMLSpanElement>>;