@efolusi/meridian 1.19.1 → 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 +660 -423
  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 +42 -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
package/forms/Field.js ADDED
@@ -0,0 +1,99 @@
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
+ const FieldCtx = /*#__PURE__*/React.createContext(null);
5
+ export function useFieldProps(own = {}) {
6
+ const ctx = React.useContext(FieldCtx);
7
+ const invalid = !!(own.invalid || own.error || ctx?.invalid);
8
+ const required = own.required != null ? !!own.required : !!ctx?.required;
9
+ const controlProps = {};
10
+ if (own.id) controlProps.id = own.id;
11
+ if (own['aria-describedby']) controlProps['aria-describedby'] = own['aria-describedby'];
12
+ if (invalid) controlProps['aria-invalid'] = true;
13
+ if (required) controlProps['aria-required'] = true;
14
+ return {
15
+ inField: !!ctx,
16
+ id: own.id || null,
17
+ invalid,
18
+ required,
19
+ controlProps
20
+ };
21
+ }
22
+ function slot(Component, name, base) {
23
+ return /*#__PURE__*/React.forwardRef(function FieldSlot({
24
+ className,
25
+ ...props
26
+ }, ref) {
27
+ return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
28
+ ref: ref,
29
+ "data-slot": name,
30
+ className: `${base}${className ? ` ${className}` : ''}`
31
+ }));
32
+ });
33
+ }
34
+ export const Field = /*#__PURE__*/React.forwardRef(function Field({
35
+ orientation = 'vertical',
36
+ className,
37
+ ...props
38
+ }, ref) {
39
+ const value = React.useMemo(() => ({
40
+ invalid: !!props['data-invalid'],
41
+ required: !!props['data-required']
42
+ }), [props['data-invalid'], props['data-required']]);
43
+ return /*#__PURE__*/React.createElement(FieldCtx.Provider, {
44
+ value: value
45
+ }, /*#__PURE__*/React.createElement("div", _extends({}, props, {
46
+ ref: ref,
47
+ role: "group",
48
+ "data-slot": "field",
49
+ "data-orientation": orientation,
50
+ className: `ef-field${className ? ` ${className}` : ''}`
51
+ })));
52
+ });
53
+ export const FieldSet = slot('fieldset', 'field-set', 'ef-field-set');
54
+ export const FieldGroup = slot('div', 'field-group', 'ef-field-group');
55
+ export const FieldContent = slot('div', 'field-content', 'ef-field-content');
56
+ export const FieldLabel = slot('label', 'field-label', 'ef-field-label');
57
+ export const FieldTitle = slot('div', 'field-title', 'ef-field-title');
58
+ export const FieldDescription = slot('p', 'field-description', 'ef-field-description');
59
+ export const FieldLegend = /*#__PURE__*/React.forwardRef(function FieldLegend({
60
+ variant = 'legend',
61
+ className,
62
+ ...props
63
+ }, ref) {
64
+ return /*#__PURE__*/React.createElement("legend", _extends({}, props, {
65
+ ref: ref,
66
+ "data-slot": "field-legend",
67
+ "data-variant": variant,
68
+ className: `ef-field-legend${className ? ` ${className}` : ''}`
69
+ }));
70
+ });
71
+ export const FieldSeparator = /*#__PURE__*/React.forwardRef(function FieldSeparator({
72
+ children,
73
+ className,
74
+ ...props
75
+ }, ref) {
76
+ return /*#__PURE__*/React.createElement("div", _extends({}, props, {
77
+ ref: ref,
78
+ role: "separator",
79
+ "data-slot": "field-separator",
80
+ className: `ef-field-separator${className ? ` ${className}` : ''}`
81
+ }), children ? /*#__PURE__*/React.createElement("span", null, children) : null);
82
+ });
83
+ export const FieldError = /*#__PURE__*/React.forwardRef(function FieldError({
84
+ children,
85
+ errors,
86
+ className,
87
+ ...props
88
+ }, ref) {
89
+ const messages = (errors || []).map(error => error?.message).filter(Boolean);
90
+ if (!children && !messages.length) return null;
91
+ return /*#__PURE__*/React.createElement("div", _extends({}, props, {
92
+ ref: ref,
93
+ role: "alert",
94
+ "data-slot": "field-error",
95
+ className: `ef-field-error${className ? ` ${className}` : ''}`
96
+ }), children || (messages.length === 1 ? messages[0] : /*#__PURE__*/React.createElement("ul", null, [...new Set(messages)].map(message => /*#__PURE__*/React.createElement("li", {
97
+ key: message
98
+ }, message)))));
99
+ });
@@ -8,4 +8,4 @@ export interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonEl
8
8
  /** @default 'md' */
9
9
  size?: 'sm' | 'md' | 'lg';
10
10
  }
11
- export declare function IconButton(props: IconButtonProps): React.JSX.Element;
11
+ export declare const IconButton: React.ForwardRefExoticComponent<IconButtonProps & React.RefAttributes<HTMLButtonElement>>;
@@ -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
- export function IconButton({
5
+ export const IconButton = /*#__PURE__*/React.forwardRef(function IconButton({
6
6
  icon,
7
7
  label,
8
8
  variant = 'quiet',
@@ -11,9 +11,10 @@ export function IconButton({
11
11
  style,
12
12
  className,
13
13
  ...rest
14
- }) {
14
+ }, ref) {
15
15
  const isz = size === 'sm' ? 16 : size === 'lg' ? 20 : 18;
16
16
  return /*#__PURE__*/React.createElement("button", _extends({
17
+ ref: ref,
17
18
  "aria-label": label,
18
19
  title: label,
19
20
  className: `ef-iconbtn ef-iconbtn--${variant} ef-iconbtn--${size}${className ? ' ' + className : ''}`,
@@ -23,4 +24,4 @@ export function IconButton({
23
24
  name: icon,
24
25
  size: isz
25
26
  }));
26
- }
27
+ });
package/forms/Input.d.ts CHANGED
@@ -1,20 +1,20 @@
1
1
  export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size'> {
2
- /** Field label rendered above */
2
+ /** Field label rendered above. */
3
3
  label?: string;
4
- /** Muted helper text below */
4
+ /** Muted helper text below. */
5
5
  hint?: string;
6
- /** Error message below — also sets invalid styling */
6
+ /** Error message below; also sets invalid styling. */
7
7
  error?: string;
8
- /** Lucide icon name inside the field, left */
8
+ /** Meridian icon name inside the field at inline start. */
9
9
  iconLeft?: string;
10
- /** @default 'md' */
11
- size?: 'sm' | 'md' | 'lg';
10
+ /** Native numeric width or Meridian's additive visual sizes. */
11
+ size?: number | 'sm' | 'md' | 'lg';
12
12
  invalid?: boolean;
13
- /** Adds a show/hide button to a `type="password"` field */
13
+ /** Adds a show/hide button to a password field. */
14
14
  revealable?: boolean;
15
15
  /** @default 'Show password' */
16
16
  revealLabel?: string;
17
17
  /** @default 'Hide password' */
18
18
  hideLabel?: string;
19
19
  }
20
- export declare function Input(props: InputProps): React.JSX.Element;
20
+ export declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
package/forms/Input.js CHANGED
@@ -2,13 +2,16 @@
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";
6
- export function Input({
5
+ import { useFieldProps } from "./Field.js";
6
+ function classes(...values) {
7
+ return values.filter(Boolean).join(' ');
8
+ }
9
+ export const Input = /*#__PURE__*/React.forwardRef(function Input({
7
10
  label,
8
11
  hint,
9
12
  error,
10
13
  iconLeft,
11
- size = 'md',
14
+ size,
12
15
  invalid,
13
16
  revealable,
14
17
  revealLabel = 'Show password',
@@ -16,57 +19,67 @@ export function Input({
16
19
  style,
17
20
  className,
18
21
  ...rest
19
- }) {
20
- // A password field people cannot read back is a password field people mistype.
21
- // The toggle is a real button so it is reachable by keyboard, and it is left
22
- // out of the tab order only when there is nothing to reveal.
22
+ }, ref) {
23
+ const uid = React.useId();
23
24
  const [revealed, setRevealed] = React.useState(false);
24
- const showToggle = revealable && rest.type === 'password';
25
- // Picks up id / aria wiring when nested in a FormField; standalone this is a no-op.
25
+ const customSize = typeof size === 'string' && ['sm', 'md', 'lg'].includes(size) ? size : 'md';
26
+ const nativeSize = typeof size === 'number' ? size : undefined;
27
+ const showToggle = !!(revealable && rest.type === 'password');
26
28
  const field = useFieldProps({
27
29
  invalid,
28
30
  error,
29
31
  id: rest.id,
30
- 'aria-describedby': rest['aria-describedby']
32
+ 'aria-describedby': rest['aria-describedby'],
33
+ required: rest.required
31
34
  });
32
35
  const bad = field.invalid;
33
- const control = /*#__PURE__*/React.createElement("span", {
34
- className: `ef-input ef-input--${size}${iconLeft ? ' ef-input--icon' : ''}${showToggle ? ' ef-input--reveal' : ''}${bad ? ' ef-input--invalid' : ''}`
36
+ const controlId = field.id || rest.id || (label || hint || error ? `${uid}c` : undefined);
37
+ const noteId = hint || error ? `${uid}n` : undefined;
38
+ const describedBy = [...new Set([field.controlProps['aria-describedby'], rest['aria-describedby'], noteId].filter(Boolean))].join(' ') || undefined;
39
+ const input = /*#__PURE__*/React.createElement("input", _extends({}, rest, field.controlProps, {
40
+ ref: ref,
41
+ id: controlId,
42
+ size: nativeSize,
43
+ "data-slot": "input",
44
+ "aria-describedby": describedBy,
45
+ "aria-invalid": bad || rest['aria-invalid'] || undefined,
46
+ type: showToggle && revealed ? 'text' : rest.type,
47
+ className: classes('ef-input__el', customSize !== 'md' && `ef-input__el--${customSize}`, className),
48
+ style: style
49
+ }));
50
+ const decorated = iconLeft || showToggle ? /*#__PURE__*/React.createElement("span", {
51
+ className: classes('ef-input', iconLeft && 'ef-input--icon', showToggle && 'ef-input--reveal')
35
52
  }, iconLeft ? /*#__PURE__*/React.createElement("span", {
36
- className: "ef-input__icon"
53
+ className: "ef-input__icon",
54
+ "aria-hidden": "true"
37
55
  }, /*#__PURE__*/React.createElement(Icon, {
38
56
  name: iconLeft,
39
- size: size === 'lg' ? 18 : 16
40
- })) : null, /*#__PURE__*/React.createElement("input", _extends({
41
- className: "ef-input__el",
42
- "aria-invalid": bad || undefined
43
- }, rest, field.controlProps, {
44
- type: showToggle && revealed ? 'text' : rest.type
45
- })), showToggle ? /*#__PURE__*/React.createElement("button", {
57
+ size: customSize === 'lg' ? 18 : 16
58
+ })) : null, input, showToggle ? /*#__PURE__*/React.createElement("button", {
46
59
  type: "button",
47
60
  className: "ef-input__reveal",
48
61
  "aria-label": revealed ? hideLabel : revealLabel,
49
62
  "aria-pressed": revealed,
50
- onClick: () => setRevealed(v => !v)
63
+ onClick: () => setRevealed(current => !current)
51
64
  }, /*#__PURE__*/React.createElement(Icon, {
52
65
  name: revealed ? 'eye-off' : 'eye',
53
66
  size: 16
54
- })) : null);
55
- if (!label && !hint && !error) return /*#__PURE__*/React.cloneElement(control, {
56
- style,
57
- className: control.props.className + (className ? ' ' + className : '')
58
- });
59
- return /*#__PURE__*/React.createElement("label", {
60
- className: `ef-field${className ? ' ' + className : ''}`,
61
- style: style
62
- }, label ? /*#__PURE__*/React.createElement("span", {
63
- className: "ef-field__label"
64
- }, label) : null, control, error ? /*#__PURE__*/React.createElement("span", {
67
+ })) : null) : input;
68
+ if (!label && !hint && !error) return decorated;
69
+ return /*#__PURE__*/React.createElement("div", {
70
+ className: "ef-field"
71
+ }, label ? /*#__PURE__*/React.createElement("label", {
72
+ className: "ef-field__label",
73
+ htmlFor: controlId
74
+ }, label) : null, decorated, error ? /*#__PURE__*/React.createElement("span", {
75
+ id: noteId,
76
+ role: "alert",
65
77
  className: "ef-field__error"
66
78
  }, /*#__PURE__*/React.createElement(Icon, {
67
79
  name: "circle-alert",
68
80
  size: 12
69
81
  }), error) : hint ? /*#__PURE__*/React.createElement("span", {
82
+ id: noteId,
70
83
  className: "ef-field__hint"
71
84
  }, hint) : null);
72
- }
85
+ });
@@ -1,15 +1,8 @@
1
- export interface InputGroupProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size' | 'prefix'> {
2
- /** Field label rendered above */
3
- label?: string;
4
- /** Muted helper text below */
5
- hint?: string;
6
- /** Error message below — also sets invalid styling */
7
- error?: string;
8
- /** Leading addon: string renders a tinted cell, a node renders bare */
9
- prefix?: React.ReactNode;
10
- /** Trailing addon: string renders a tinted cell, a node renders bare */
11
- suffix?: React.ReactNode;
12
- /** @default 'md' */
13
- size?: 'sm' | 'md' | 'lg';
14
- }
15
- export declare function InputGroup(props: InputGroupProps): React.JSX.Element;
1
+ export declare const InputGroup: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
2
+ export interface InputGroupAddonProps extends React.HTMLAttributes<HTMLDivElement> { align?: 'inline-start'|'inline-end'|'block-start'|'block-end'; }
3
+ export declare const InputGroupAddon: React.ForwardRefExoticComponent<InputGroupAddonProps & React.RefAttributes<HTMLDivElement>>;
4
+ export interface InputGroupButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> { size?: 'xs'|'icon-xs'|'sm'|'icon-sm'; variant?: 'default'|'destructive'|'outline'|'secondary'|'ghost'|'link'; }
5
+ export declare const InputGroupButton: React.ForwardRefExoticComponent<InputGroupButtonProps & React.RefAttributes<HTMLButtonElement>>;
6
+ export declare const InputGroupInput: React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & React.RefAttributes<HTMLInputElement>>;
7
+ export declare const InputGroupTextarea: React.ForwardRefExoticComponent<React.TextareaHTMLAttributes<HTMLTextAreaElement> & React.RefAttributes<HTMLTextAreaElement>>;
8
+ export declare const InputGroupText: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & React.RefAttributes<HTMLSpanElement>>;
@@ -1,40 +1,79 @@
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 InputGroup({
6
- label,
7
- hint,
8
- error,
9
- prefix,
10
- suffix,
11
- size = 'md',
12
- style,
4
+ import { useFieldProps } from "./Field.js";
5
+ function cx(base, className) {
6
+ return base + (className ? ` ${className}` : '');
7
+ }
8
+ export const InputGroup = /*#__PURE__*/React.forwardRef(function InputGroup({
13
9
  className,
14
10
  ...rest
15
- }) {
16
- // Picks up id / aria wiring when nested in a FormField; standalone this is a no-op.
17
- const field = useFieldProps({
18
- error,
19
- id: rest.id,
20
- 'aria-describedby': rest['aria-describedby']
21
- });
22
- const addon = (node, where) => node == null ? null : /*#__PURE__*/React.createElement("span", {
23
- className: `ef-igroup__addon ef-igroup__addon--${where}${typeof node !== 'string' ? ' ef-igroup__addon--bare' : ''}`
24
- }, node);
25
- return /*#__PURE__*/React.createElement("label", {
26
- className: `ef-igroup ef-igroup--${size}${error ? ' ef-igroup--invalid' : ''}${className ? ' ' + className : ''}`,
27
- style: style
28
- }, label ? /*#__PURE__*/React.createElement("span", {
29
- className: "ef-igroup__label"
30
- }, label) : null, /*#__PURE__*/React.createElement("span", {
31
- className: "ef-igroup__row"
32
- }, addon(prefix, 'lead'), /*#__PURE__*/React.createElement("input", _extends({
33
- className: "ef-igroup__input",
34
- "aria-invalid": field.invalid || undefined
35
- }, rest, field.controlProps)), addon(suffix, 'trail')), error ? /*#__PURE__*/React.createElement("span", {
36
- className: "ef-igroup__note ef-igroup__note--error"
37
- }, error) : hint ? /*#__PURE__*/React.createElement("span", {
38
- className: "ef-igroup__note"
39
- }, hint) : null);
40
- }
11
+ }, ref) {
12
+ return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
13
+ ref: ref,
14
+ "data-slot": "input-group",
15
+ role: "group",
16
+ className: cx('ef-input-group', className)
17
+ }));
18
+ });
19
+ export const InputGroupAddon = /*#__PURE__*/React.forwardRef(function InputGroupAddon({
20
+ align = 'inline-start',
21
+ className,
22
+ ...rest
23
+ }, ref) {
24
+ const valid = ['inline-start', 'inline-end', 'block-start', 'block-end'].includes(align) ? align : 'inline-start';
25
+ return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
26
+ ref: ref,
27
+ "data-slot": "input-group-addon",
28
+ "data-align": valid,
29
+ className: cx('ef-input-group__addon', className)
30
+ }));
31
+ });
32
+ export const InputGroupButton = /*#__PURE__*/React.forwardRef(function InputGroupButton({
33
+ size = 'xs',
34
+ variant = 'ghost',
35
+ className,
36
+ type = 'button',
37
+ ...rest
38
+ }, ref) {
39
+ return /*#__PURE__*/React.createElement("button", _extends({}, rest, {
40
+ ref: ref,
41
+ type: type,
42
+ "data-slot": "input-group-button",
43
+ "data-size": size,
44
+ "data-variant": variant,
45
+ className: cx('ef-input-group__button', className)
46
+ }));
47
+ });
48
+ export const InputGroupInput = /*#__PURE__*/React.forwardRef(function InputGroupInput({
49
+ className,
50
+ ...rest
51
+ }, ref) {
52
+ const field = useFieldProps(rest);
53
+ return /*#__PURE__*/React.createElement("input", _extends({}, rest, field.controlProps, {
54
+ ref: ref,
55
+ "data-slot": "input-group-control",
56
+ className: cx('ef-input-group__control', className)
57
+ }));
58
+ });
59
+ export const InputGroupTextarea = /*#__PURE__*/React.forwardRef(function InputGroupTextarea({
60
+ className,
61
+ ...rest
62
+ }, ref) {
63
+ const field = useFieldProps(rest);
64
+ return /*#__PURE__*/React.createElement("textarea", _extends({}, rest, field.controlProps, {
65
+ ref: ref,
66
+ "data-slot": "input-group-control",
67
+ className: cx('ef-input-group__control', className)
68
+ }));
69
+ });
70
+ export const InputGroupText = /*#__PURE__*/React.forwardRef(function InputGroupText({
71
+ className,
72
+ ...rest
73
+ }, ref) {
74
+ return /*#__PURE__*/React.createElement("span", _extends({}, rest, {
75
+ ref: ref,
76
+ "data-slot": "input-group-text",
77
+ className: cx('ef-input-group__text', className)
78
+ }));
79
+ });
@@ -0,0 +1,13 @@
1
+ export interface InputOTPProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'maxLength' | 'onChange' | 'value' | 'defaultValue'> {
2
+ maxLength: number;
3
+ value?: string;
4
+ defaultValue?: string;
5
+ onChange?: (value: string) => void;
6
+ onComplete?: (value: string) => void;
7
+ containerClassName?: string;
8
+ }
9
+ export declare const InputOTP: React.ForwardRefExoticComponent<InputOTPProps & React.RefAttributes<HTMLInputElement>>;
10
+ export declare const InputOTPGroup: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
11
+ export interface InputOTPSlotProps extends React.HTMLAttributes<HTMLDivElement> { index: number; }
12
+ export declare const InputOTPSlot: React.ForwardRefExoticComponent<InputOTPSlotProps & React.RefAttributes<HTMLDivElement>>;
13
+ export declare const InputOTPSeparator: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,125 @@
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
+ const InputOTPCtx = /*#__PURE__*/React.createContext(null);
5
+ function acceptsPattern(value, pattern) {
6
+ if (!pattern || !value) return true;
7
+ try {
8
+ return new RegExp(`^(?:${pattern})+$`).test(value);
9
+ } catch {
10
+ return true;
11
+ }
12
+ }
13
+ export const InputOTP = /*#__PURE__*/React.forwardRef(function InputOTP({
14
+ maxLength,
15
+ value,
16
+ defaultValue = '',
17
+ onChange,
18
+ onComplete,
19
+ pattern,
20
+ disabled,
21
+ containerClassName,
22
+ children,
23
+ className,
24
+ onFocus,
25
+ onBlur,
26
+ ...props
27
+ }, ref) {
28
+ const controlled = value != null;
29
+ const [inner, setInner] = React.useState(() => String(defaultValue).slice(0, maxLength));
30
+ const [focused, setFocused] = React.useState(false);
31
+ const inputRef = React.useRef(null);
32
+ const setInputRef = React.useCallback(element => {
33
+ inputRef.current = element;
34
+ if (typeof ref === 'function') ref(element);else if (ref) ref.current = element;
35
+ }, [ref]);
36
+ const current = String(controlled ? value : inner).slice(0, maxLength);
37
+ const commit = nextValue => {
38
+ const next = String(nextValue).slice(0, maxLength);
39
+ if (!acceptsPattern(next, pattern)) return;
40
+ if (!controlled) setInner(next);
41
+ onChange?.(next);
42
+ if (next.length === maxLength) onComplete?.(next);
43
+ };
44
+ const activeIndex = focused ? Math.min(current.length, Math.max(0, maxLength - 1)) : -1;
45
+ const slots = React.useMemo(() => Array.from({
46
+ length: maxLength
47
+ }, (_, index) => ({
48
+ char: current[index] || null,
49
+ hasFakeCaret: index === activeIndex && current.length < maxLength,
50
+ isActive: index === activeIndex
51
+ })), [activeIndex, current, maxLength]);
52
+ const context = React.useMemo(() => ({
53
+ slots
54
+ }), [slots]);
55
+ return /*#__PURE__*/React.createElement(InputOTPCtx.Provider, {
56
+ value: context
57
+ }, /*#__PURE__*/React.createElement("div", {
58
+ "data-slot": "input-otp",
59
+ "data-disabled": disabled ? '' : undefined,
60
+ className: `ef-otp${containerClassName ? ' ' + containerClassName : ''}`,
61
+ onClick: () => !disabled && inputRef.current?.focus()
62
+ }, /*#__PURE__*/React.createElement("input", _extends({}, props, {
63
+ ref: setInputRef,
64
+ className: `ef-otp__input${className ? ' ' + className : ''}`,
65
+ value: current,
66
+ maxLength: maxLength,
67
+ pattern: pattern,
68
+ disabled: disabled,
69
+ autoComplete: props.autoComplete || 'one-time-code',
70
+ inputMode: props.inputMode || 'numeric',
71
+ onChange: event => commit(event.target.value),
72
+ onFocus: event => {
73
+ setFocused(true);
74
+ onFocus?.(event);
75
+ },
76
+ onBlur: event => {
77
+ setFocused(false);
78
+ onBlur?.(event);
79
+ }
80
+ })), children));
81
+ });
82
+ export const InputOTPGroup = /*#__PURE__*/React.forwardRef(function InputOTPGroup({
83
+ className,
84
+ ...props
85
+ }, ref) {
86
+ return /*#__PURE__*/React.createElement("div", _extends({}, props, {
87
+ ref: ref,
88
+ "data-slot": "input-otp-group",
89
+ className: `ef-otp__group${className ? ' ' + className : ''}`
90
+ }));
91
+ });
92
+ export const InputOTPSlot = /*#__PURE__*/React.forwardRef(function InputOTPSlot({
93
+ index,
94
+ className,
95
+ ...props
96
+ }, ref) {
97
+ const slot = React.useContext(InputOTPCtx)?.slots[index] || {
98
+ char: null,
99
+ hasFakeCaret: false,
100
+ isActive: false
101
+ };
102
+ return /*#__PURE__*/React.createElement("div", _extends({}, props, {
103
+ ref: ref,
104
+ "data-slot": "input-otp-slot",
105
+ "data-active": slot.isActive ? '' : undefined,
106
+ className: `ef-otp__slot${className ? ' ' + className : ''}`
107
+ }), slot.char, slot.hasFakeCaret ? /*#__PURE__*/React.createElement("span", {
108
+ className: "ef-otp__caret",
109
+ "aria-hidden": "true"
110
+ }) : null);
111
+ });
112
+ export const InputOTPSeparator = /*#__PURE__*/React.forwardRef(function InputOTPSeparator({
113
+ className,
114
+ children,
115
+ ...props
116
+ }, ref) {
117
+ return /*#__PURE__*/React.createElement("div", _extends({}, props, {
118
+ ref: ref,
119
+ role: "separator",
120
+ "data-slot": "input-otp-separator",
121
+ className: `ef-otp__separator${className ? ' ' + className : ''}`
122
+ }), children || /*#__PURE__*/React.createElement("span", {
123
+ "aria-hidden": "true"
124
+ }, "\u2212"));
125
+ });
package/forms/Label.d.ts CHANGED
@@ -1,11 +1,7 @@
1
- export interface LabelProps {
2
- htmlFor?: string;
1
+ export interface LabelProps extends React.LabelHTMLAttributes<HTMLLabelElement> {
3
2
  /** Red asterisk */
4
3
  required?: boolean;
5
4
  /** Muted inline hint after the text */
6
5
  hint?: React.ReactNode;
7
- children: React.ReactNode;
8
- style?: React.CSSProperties;
9
- className?: string;
10
6
  }
11
- export declare function Label(props: LabelProps): React.JSX.Element;
7
+ export declare const Label: React.ForwardRefExoticComponent<LabelProps & React.RefAttributes<HTMLLabelElement>>;
package/forms/Label.js CHANGED
@@ -1,7 +1,7 @@
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
- export function Label({
4
+ export const Label = /*#__PURE__*/React.forwardRef(function Label({
5
5
  htmlFor,
6
6
  required,
7
7
  hint,
@@ -9,8 +9,10 @@ export function Label({
9
9
  style,
10
10
  className,
11
11
  ...rest
12
- }) {
13
- return /*#__PURE__*/React.createElement("label", _extends({}, rest, {
12
+ }, ref) {
13
+ return /*#__PURE__*/React.createElement("label", _extends({
14
+ ref: ref
15
+ }, rest, {
14
16
  htmlFor: htmlFor,
15
17
  className: `ef-label${className ? ' ' + className : ''}`,
16
18
  style: style
@@ -20,4 +22,4 @@ export function Label({
20
22
  }, "*") : null, hint ? /*#__PURE__*/React.createElement("span", {
21
23
  className: "ef-label__hint"
22
24
  }, hint) : null);
23
- }
25
+ });
@@ -0,0 +1,16 @@
1
+ export type NativeSelectProps = Omit<React.ComponentPropsWithoutRef<'select'>, 'size'> & {
2
+ /** Meridian control height. @default 'md' */
3
+ size?: 'sm' | 'md' | 'lg';
4
+ };
5
+ export type NativeSelectOptionProps = React.ComponentPropsWithoutRef<'option'>;
6
+ export type NativeSelectOptGroupProps = React.ComponentPropsWithoutRef<'optgroup'>;
7
+
8
+ export declare const NativeSelect: React.ForwardRefExoticComponent<
9
+ NativeSelectProps & React.RefAttributes<HTMLSelectElement>
10
+ >;
11
+ export declare const NativeSelectOption: React.ForwardRefExoticComponent<
12
+ NativeSelectOptionProps & React.RefAttributes<HTMLOptionElement>
13
+ >;
14
+ export declare const NativeSelectOptGroup: React.ForwardRefExoticComponent<
15
+ NativeSelectOptGroupProps & React.RefAttributes<HTMLOptGroupElement>
16
+ >;