@hebium-ui/react 0.1.0-alpha.2 → 0.1.0-alpha.4

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 (166) hide show
  1. package/dist/components/alert/alert.d.ts +3 -6
  2. package/dist/components/alert/alert.js +6 -14
  3. package/dist/components/alert/alert.js.map +1 -1
  4. package/dist/components/anchor/anchor.d.ts +1 -4
  5. package/dist/components/anchor/anchor.js +4 -5
  6. package/dist/components/anchor/anchor.js.map +1 -1
  7. package/dist/components/avatar/avatar.d.ts +1 -4
  8. package/dist/components/avatar/avatar.js +4 -5
  9. package/dist/components/avatar/avatar.js.map +1 -1
  10. package/dist/components/blockquote/blockquote.d.ts +1 -4
  11. package/dist/components/blockquote/blockquote.js +4 -5
  12. package/dist/components/blockquote/blockquote.js.map +1 -1
  13. package/dist/components/button/button.d.ts +12 -4
  14. package/dist/components/button/button.js +30 -11
  15. package/dist/components/button/button.js.map +1 -1
  16. package/dist/components/checkbox/checkbox.d.ts +2 -5
  17. package/dist/components/checkbox/checkbox.js +29 -16
  18. package/dist/components/checkbox/checkbox.js.map +1 -1
  19. package/dist/components/code/code.d.ts +1 -4
  20. package/dist/components/code/code.js +4 -5
  21. package/dist/components/code/code.js.map +1 -1
  22. package/dist/components/combobox/combobox-option.js +33 -0
  23. package/dist/components/combobox/combobox-option.js.map +1 -0
  24. package/dist/components/combobox/combobox.d.ts +61 -0
  25. package/dist/components/combobox/combobox.js +208 -0
  26. package/dist/components/combobox/combobox.js.map +1 -0
  27. package/dist/components/combobox/index.d.ts +2 -0
  28. package/dist/components/combobox/use-combobox-form.js +33 -0
  29. package/dist/components/combobox/use-combobox-form.js.map +1 -0
  30. package/dist/components/combobox/use-combobox-popover.js +66 -0
  31. package/dist/components/combobox/use-combobox-popover.js.map +1 -0
  32. package/dist/components/combobox/use-combobox-state.js +96 -0
  33. package/dist/components/combobox/use-combobox-state.js.map +1 -0
  34. package/dist/components/details/details.d.ts +1 -4
  35. package/dist/components/details/details.js +4 -5
  36. package/dist/components/details/details.js.map +1 -1
  37. package/dist/components/dialog/dialog.context.js +1 -2
  38. package/dist/components/dialog/dialog.d.ts +4 -7
  39. package/dist/components/dialog/dialog.js +29 -9
  40. package/dist/components/dialog/dialog.js.map +1 -1
  41. package/dist/components/dialog/index.d.ts +1 -2
  42. package/dist/components/dl/dl.d.ts +1 -4
  43. package/dist/components/dl/dl.js +10 -11
  44. package/dist/components/dl/dl.js.map +1 -1
  45. package/dist/components/drawer/drawer.context.js +1 -2
  46. package/dist/components/drawer/drawer.d.ts +4 -7
  47. package/dist/components/drawer/drawer.js +29 -9
  48. package/dist/components/drawer/drawer.js.map +1 -1
  49. package/dist/components/drawer/index.d.ts +1 -2
  50. package/dist/components/fieldset/fieldset.d.ts +1 -4
  51. package/dist/components/fieldset/fieldset.js +4 -5
  52. package/dist/components/fieldset/fieldset.js.map +1 -1
  53. package/dist/components/heading/heading.d.ts +1 -4
  54. package/dist/components/heading/heading.js +4 -5
  55. package/dist/components/heading/heading.js.map +1 -1
  56. package/dist/components/hr/hr.d.ts +1 -4
  57. package/dist/components/hr/hr.js +4 -5
  58. package/dist/components/hr/hr.js.map +1 -1
  59. package/dist/components/index.d.ts +35 -26
  60. package/dist/components/inline-feedback/index.d.ts +2 -0
  61. package/dist/components/inline-feedback/inline-feedback.d.ts +33 -0
  62. package/dist/components/inline-feedback/inline-feedback.js +30 -0
  63. package/dist/components/inline-feedback/inline-feedback.js.map +1 -0
  64. package/dist/components/input/input.d.ts +1 -4
  65. package/dist/components/input/input.js +4 -5
  66. package/dist/components/input/input.js.map +1 -1
  67. package/dist/components/label/label.d.ts +1 -4
  68. package/dist/components/label/label.js +6 -7
  69. package/dist/components/label/label.js.map +1 -1
  70. package/dist/components/menu/index.d.ts +1 -2
  71. package/dist/components/menu/menu.context.js +1 -2
  72. package/dist/components/menu/menu.d.ts +3 -6
  73. package/dist/components/menu/menu.js +23 -9
  74. package/dist/components/menu/menu.js.map +1 -1
  75. package/dist/components/multi-combobox/index.d.ts +2 -0
  76. package/dist/components/multi-combobox/multi-combobox-option.js +42 -0
  77. package/dist/components/multi-combobox/multi-combobox-option.js.map +1 -0
  78. package/dist/components/multi-combobox/multi-combobox-tag.js +54 -0
  79. package/dist/components/multi-combobox/multi-combobox-tag.js.map +1 -0
  80. package/dist/components/multi-combobox/multi-combobox.d.ts +72 -0
  81. package/dist/components/multi-combobox/multi-combobox.js +249 -0
  82. package/dist/components/multi-combobox/multi-combobox.js.map +1 -0
  83. package/dist/components/multi-combobox/use-multi-combobox-state.js +91 -0
  84. package/dist/components/multi-combobox/use-multi-combobox-state.js.map +1 -0
  85. package/dist/components/paragraph/paragraph.d.ts +1 -4
  86. package/dist/components/paragraph/paragraph.js +4 -5
  87. package/dist/components/paragraph/paragraph.js.map +1 -1
  88. package/dist/components/popover/index.d.ts +1 -2
  89. package/dist/components/popover/popover.context.js +1 -2
  90. package/dist/components/popover/popover.d.ts +3 -6
  91. package/dist/components/popover/popover.js +20 -6
  92. package/dist/components/popover/popover.js.map +1 -1
  93. package/dist/components/progress/progress.d.ts +1 -4
  94. package/dist/components/progress/progress.js +4 -5
  95. package/dist/components/progress/progress.js.map +1 -1
  96. package/dist/components/radio/radio.d.ts +1 -4
  97. package/dist/components/radio/radio.js +4 -5
  98. package/dist/components/radio/radio.js.map +1 -1
  99. package/dist/components/radiogroup/radiogroup.d.ts +1 -4
  100. package/dist/components/radiogroup/radiogroup.js +6 -6
  101. package/dist/components/radiogroup/radiogroup.js.map +1 -1
  102. package/dist/components/section/section.d.ts +1 -4
  103. package/dist/components/section/section.js +4 -5
  104. package/dist/components/section/section.js.map +1 -1
  105. package/dist/components/segmented-control/segmented-control.context.js +1 -2
  106. package/dist/components/segmented-control/segmented-control.d.ts +2 -5
  107. package/dist/components/segmented-control/segmented-control.js +13 -9
  108. package/dist/components/segmented-control/segmented-control.js.map +1 -1
  109. package/dist/components/select/select.d.ts +1 -4
  110. package/dist/components/select/select.js +4 -5
  111. package/dist/components/select/select.js.map +1 -1
  112. package/dist/components/skip-link/index.d.ts +2 -0
  113. package/dist/components/skip-link/skip-link.d.ts +6 -0
  114. package/dist/components/skip-link/skip-link.js +20 -0
  115. package/dist/components/skip-link/skip-link.js.map +1 -0
  116. package/dist/components/status-icon/index.d.ts +2 -0
  117. package/dist/components/status-icon/status-icon.d.ts +19 -0
  118. package/dist/components/status-icon/status-icon.js +22 -0
  119. package/dist/components/status-icon/status-icon.js.map +1 -0
  120. package/dist/components/table/table.d.ts +4 -7
  121. package/dist/components/table/table.js +25 -26
  122. package/dist/components/table/table.js.map +1 -1
  123. package/dist/components/tabs/tabs.context.d.ts +1 -4
  124. package/dist/components/tabs/tabs.context.js +1 -2
  125. package/dist/components/tabs/tabs.d.ts +2 -5
  126. package/dist/components/tabs/tabs.js +13 -14
  127. package/dist/components/tabs/tabs.js.map +1 -1
  128. package/dist/components/tag/index.d.ts +2 -0
  129. package/dist/components/tag/tag.d.ts +39 -0
  130. package/dist/components/tag/tag.js +41 -0
  131. package/dist/components/tag/tag.js.map +1 -0
  132. package/dist/components/text/index.d.ts +2 -0
  133. package/dist/components/text/text.d.ts +22 -0
  134. package/dist/components/text/text.js +23 -0
  135. package/dist/components/text/text.js.map +1 -0
  136. package/dist/components/textarea/textarea.d.ts +1 -4
  137. package/dist/components/textarea/textarea.js +4 -5
  138. package/dist/components/textarea/textarea.js.map +1 -1
  139. package/dist/components/tooltip/index.d.ts +1 -2
  140. package/dist/components/tooltip/tooltip.context.js +1 -2
  141. package/dist/components/tooltip/tooltip.d.ts +3 -6
  142. package/dist/components/tooltip/tooltip.js +19 -5
  143. package/dist/components/tooltip/tooltip.js.map +1 -1
  144. package/dist/components/visually-hidden/visually-hidden.d.ts +3 -6
  145. package/dist/components/visually-hidden/visually-hidden.js +4 -5
  146. package/dist/components/visually-hidden/visually-hidden.js.map +1 -1
  147. package/dist/index.d.ts +9 -7
  148. package/dist/index.js +9 -7
  149. package/dist/provider/hui-provider.context.d.ts +34 -10
  150. package/dist/provider/hui-provider.context.js +23 -16
  151. package/dist/provider/hui-provider.context.js.map +1 -1
  152. package/dist/provider/hui-provider.d.ts +1 -4
  153. package/dist/provider/hui-provider.js +1 -2
  154. package/dist/provider/index.d.ts +1 -1
  155. package/dist/provider/merge-props.js +1 -2
  156. package/dist/types/distributive.d.ts +1 -0
  157. package/dist/types/hui-component.d.ts +11 -7
  158. package/dist/types/index.d.ts +3 -2
  159. package/dist/types/polymorphic.d.ts +4 -11
  160. package/dist/utils/attributes/normalize-attributes.js +1 -2
  161. package/package.json +9 -9
  162. package/dist/components/dialog/dialog.context.d.ts +0 -4
  163. package/dist/components/drawer/drawer.context.d.ts +0 -4
  164. package/dist/components/menu/menu.context.d.ts +0 -4
  165. package/dist/components/popover/popover.context.d.ts +0 -4
  166. package/dist/components/tooltip/tooltip.context.d.ts +0 -4
@@ -0,0 +1,61 @@
1
+ import { HuiComponentProps } from "../../types/hui-component.js";
2
+ import "../../types/index.js";
3
+ import { LabelProps } from "../label/label.js";
4
+ import "../label/index.js";
5
+ import { ComboboxFormValueProps, ComboboxFormValueProps as ComboboxFormValueProps$1, ComboboxSelectOption, ComboboxSelectOption as ComboboxSelectOption$1, ComboboxSlots, ComboboxTextOption, ComboboxTextOption as ComboboxTextOption$1, ComboboxVariants } from "@hebium-ui/core";
6
+ import { ComponentProps, ReactElement, ReactNode } from "react";
7
+ interface ComboboxOwnProps<O extends ComboboxSelectOption$1> {
8
+ /** Available options. Values must be unique. */
9
+ options: readonly O[];
10
+ /** The input's semantic color. @default "accent" */
11
+ color?: ComboboxVariants["color"] | undefined;
12
+ /** The label displayed above the input. */
13
+ label?: ReactNode | undefined;
14
+ /** Additional props passed to the label. */
15
+ labelProps?: LabelProps | undefined;
16
+ /** Help text displayed below the label. */
17
+ description?: ReactNode | undefined;
18
+ /** Inline validation feedback. */
19
+ error?: ReactNode | undefined;
20
+ /** The name used for form submission. */
21
+ name?: string | undefined;
22
+ /** The id of the associated form. */
23
+ form?: string | undefined;
24
+ /** Prevents interaction and excludes the value from form submission. */
25
+ disabled?: boolean | undefined;
26
+ /** Prevents editing and opening the list. The value is still submitted. */
27
+ readOnly?: boolean | undefined;
28
+ /** Requires a nonempty committed value. */
29
+ required?: boolean | undefined;
30
+ /** Native validation message. @default "Please fill out this field." */
31
+ requiredMessage?: string | undefined;
32
+ /** Props passed to the input element. */
33
+ inputProps?: Omit<ComponentProps<"input">, "children"> | undefined;
34
+ /** Props passed to the listbox element. */
35
+ listProps?: Omit<ComponentProps<"div">, "children"> | undefined;
36
+ /** Props for each option wrapper. */
37
+ itemProps?: ((option: O) => Omit<ComponentProps<"div">, "children">) | undefined;
38
+ /** Custom option content. */
39
+ renderItem?: ((option: O) => ReactNode) | undefined;
40
+ /** Renders custom form submission elements for the committed value. */
41
+ renderFormValue?: ((props: ComboboxFormValueProps$1) => ReactNode) | undefined;
42
+ }
43
+ type ComboboxValueProps<O extends ComboboxSelectOption$1> = {
44
+ /** Select from options or allow free text. @default "select" */
45
+ mode?: "select" | undefined;
46
+ /** The controlled value. Use null for no selection. */
47
+ value?: string | null | undefined;
48
+ /** The initial uncontrolled value. */
49
+ defaultValue?: string | null | undefined;
50
+ /** Called with the next value. */
51
+ onChange?: ((value: string | null) => void) | undefined;
52
+ } | {
53
+ mode: "text";
54
+ options: readonly (O & ComboboxTextOption$1)[];
55
+ value?: string | undefined;
56
+ defaultValue?: string | undefined;
57
+ onChange?: ((value: string) => void) | undefined;
58
+ };
59
+ export type ComboboxProps<O extends ComboboxSelectOption$1 = ComboboxSelectOption$1> = HuiComponentProps<ComboboxOwnProps<O>, ComboboxSlots> & ComboboxValueProps<O>;
60
+ export declare function Combobox<O extends ComboboxSelectOption$1>(rawProps: ComboboxProps<O>): ReactElement;
61
+ export type { ComboboxFormValueProps, ComboboxSelectOption, ComboboxTextOption };
@@ -0,0 +1,208 @@
1
+ import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
2
+ import { normalizeAttributes } from "../../utils/attributes/normalize-attributes.js";
3
+ import { Label } from "../label/label.js";
4
+ import { ComboboxOption } from "./combobox-option.js";
5
+ import { useComboboxForm } from "./use-combobox-form.js";
6
+ import { useComboboxPopover } from "./use-combobox-popover.js";
7
+ import { useComboboxState } from "./use-combobox-state.js";
8
+ import { cc, comboboxControl, comboboxRecipe, inputControl, moveComboboxActiveValue, popoverControl, toStrbool } from "@hebium-ui/core";
9
+ import { useCallback, useId, useMemo, useRef } from "react";
10
+ import { jsx, jsxs } from "react/jsx-runtime";
11
+ // src/components/combobox/combobox.tsx
12
+ function Combobox(rawProps) {
13
+ const props = useHuiProps("Combobox", rawProps);
14
+ const { options, color, label, labelProps, description, error, required = false, requiredMessage, name, form, inputProps = {}, listProps = {}, itemProps, renderItem, renderFormValue } = props;
15
+ const generatedId = useId();
16
+ const inputId = inputProps.id ?? `${generatedId}-input`;
17
+ const listId = listProps.id ?? `${generatedId}-list`;
18
+ const { state, inputValue, filteredOptions, activeOption, setActiveValue, clearActiveValue, edit, select: selectValue, clearQuery, reset } = useComboboxState(props);
19
+ const inputRef = useRef(null);
20
+ const composingRef = useRef(false);
21
+ const attachInput = useComboboxForm({
22
+ inputRef,
23
+ externalRef: inputProps.ref,
24
+ associatedFormId: inputProps.form ?? form,
25
+ validationMessage: comboboxControl.getValidationMessage({
26
+ value: state.value,
27
+ required,
28
+ disabled: state.disabled,
29
+ readOnly: state.readOnly,
30
+ requiredMessage
31
+ }),
32
+ onReset: reset
33
+ });
34
+ const { opened, listRef, attachList, showList, closeList, handleToggle } = useComboboxPopover({
35
+ state,
36
+ filteredOptions,
37
+ inputRef,
38
+ externalRef: listProps.ref,
39
+ onClose: clearActiveValue,
40
+ onToggle: listProps.onToggle
41
+ });
42
+ const select = useCallback((candidateValue) => {
43
+ if (!selectValue(candidateValue)) return;
44
+ inputRef.current?.focus({ preventScroll: true });
45
+ closeList();
46
+ }, [selectValue, closeList]);
47
+ const handleChange = useCallback((event) => {
48
+ inputProps.onChange?.(event);
49
+ if (event.defaultPrevented) return;
50
+ edit(event.currentTarget.value);
51
+ showList();
52
+ }, [
53
+ inputProps,
54
+ edit,
55
+ showList
56
+ ]);
57
+ const handleKeyDown = useCallback((event) => {
58
+ inputProps.onKeyDown?.(event);
59
+ if (event.defaultPrevented || composingRef.current) return;
60
+ const visible = popoverControl.isOpened(listRef.current);
61
+ const action = comboboxControl.getKeyAction(event.nativeEvent, {
62
+ ...state,
63
+ opened: visible
64
+ }, visible ? activeOption : void 0);
65
+ switch (action) {
66
+ case "next":
67
+ case "previous":
68
+ event.preventDefault();
69
+ if (showList()) {
70
+ const nextActiveValue = moveComboboxActiveValue(filteredOptions, visible ? state.activeValue : null, action);
71
+ setActiveValue(nextActiveValue);
72
+ }
73
+ return;
74
+ case "commit":
75
+ event.preventDefault();
76
+ if (activeOption) select(activeOption.value);
77
+ return;
78
+ case "blocked":
79
+ event.preventDefault();
80
+ return;
81
+ case "submit":
82
+ closeList();
83
+ return;
84
+ case "none": return;
85
+ }
86
+ }, [
87
+ inputProps,
88
+ state,
89
+ activeOption,
90
+ listRef,
91
+ showList,
92
+ filteredOptions,
93
+ setActiveValue,
94
+ select,
95
+ closeList
96
+ ]);
97
+ const handleInputClick = useCallback((event) => {
98
+ inputProps.onClick?.(event);
99
+ if (!event.defaultPrevented) showList();
100
+ }, [inputProps, showList]);
101
+ const handleBlur = useCallback((event) => {
102
+ if (event.defaultPrevented || !(event.relatedTarget instanceof Node) || event.currentTarget.contains(event.relatedTarget)) return;
103
+ clearQuery();
104
+ closeList();
105
+ }, [clearQuery, closeList]);
106
+ const handleCompositionStart = useCallback((event) => {
107
+ inputProps.onCompositionStart?.(event);
108
+ composingRef.current = true;
109
+ }, [inputProps]);
110
+ const handleCompositionEnd = useCallback((event) => {
111
+ inputProps.onCompositionEnd?.(event);
112
+ composingRef.current = false;
113
+ }, [inputProps]);
114
+ const itemIds = useMemo(() => new Map(options.map((option, index) => [option.value, `${listId}-option-${index}`])), [options, listId]);
115
+ const inputAttributes = normalizeAttributes(comboboxControl.getInputAttributes({
116
+ inputId,
117
+ listId,
118
+ opened,
119
+ required,
120
+ activeId: activeOption ? itemIds.get(activeOption.value) : void 0
121
+ }));
122
+ const formValueProps = comboboxControl.getFormValueProps({
123
+ name,
124
+ value: state.value,
125
+ form,
126
+ disabled: state.disabled
127
+ });
128
+ const labelAttrs = normalizeAttributes(inputControl.getLabelAttributes({
129
+ id: inputId,
130
+ invalid: !!error,
131
+ required,
132
+ disabled: state.disabled,
133
+ readOnly: state.readOnly
134
+ }));
135
+ const recipe = comboboxRecipe({
136
+ color,
137
+ error: toStrbool(!!error)
138
+ });
139
+ const cls = useHuiClassNames("Combobox", recipe, rawProps);
140
+ const sls = useHuiStyles("Combobox", rawProps);
141
+ return /* @__PURE__ */ jsxs("div", {
142
+ className: cls.root,
143
+ style: sls.root,
144
+ onBlur: handleBlur,
145
+ children: [
146
+ (!!label || !!description || !!error) && /* @__PURE__ */ jsx(Label, {
147
+ ...labelAttrs,
148
+ description,
149
+ error,
150
+ ...labelProps,
151
+ children: label
152
+ }),
153
+ /* @__PURE__ */ jsx("input", {
154
+ ...inputAttributes,
155
+ "aria-invalid": !!error,
156
+ disabled: state.disabled,
157
+ readOnly: state.readOnly,
158
+ form,
159
+ value: inputValue,
160
+ ...inputProps,
161
+ className: cc(cls.input, inputProps.className),
162
+ style: {
163
+ ...sls.input,
164
+ ...inputProps.style
165
+ },
166
+ ref: attachInput,
167
+ onChange: handleChange,
168
+ onKeyDown: handleKeyDown,
169
+ onClick: handleInputClick,
170
+ onCompositionStart: handleCompositionStart,
171
+ onCompositionEnd: handleCompositionEnd
172
+ }),
173
+ /* @__PURE__ */ jsx("div", {
174
+ ...normalizeAttributes(comboboxControl.getListAttributes(listId, inputId, state)),
175
+ ...listProps,
176
+ className: cc(cls.list, listProps.className),
177
+ style: {
178
+ ...sls.list,
179
+ ...listProps.style
180
+ },
181
+ ref: attachList,
182
+ onToggle: handleToggle,
183
+ children: filteredOptions.map((option) => {
184
+ const id = itemIds.get(option.value);
185
+ if (id === void 0) return null;
186
+ return /* @__PURE__ */ jsx(ComboboxOption, {
187
+ option,
188
+ id,
189
+ mode: state.mode,
190
+ active: opened && activeOption?.value === option.value,
191
+ className: cls.item,
192
+ style: sls.item,
193
+ itemProps,
194
+ renderItem,
195
+ select
196
+ }, option.value);
197
+ })
198
+ }),
199
+ formValueProps && (renderFormValue ? renderFormValue(formValueProps) : /* @__PURE__ */ jsx("input", {
200
+ type: "hidden",
201
+ ...formValueProps
202
+ }))
203
+ ]
204
+ });
205
+ }
206
+ export { Combobox };
207
+
208
+ //# sourceMappingURL=combobox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"combobox.js","names":[],"sources":["../../../src/components/combobox/combobox.tsx"],"sourcesContent":["import {\n cc,\n comboboxControl,\n type ComboboxFormValueProps,\n comboboxRecipe,\n type ComboboxSelectOption,\n type ComboboxSlots,\n type ComboboxTextOption,\n type ComboboxVariants,\n inputControl,\n moveComboboxActiveValue,\n popoverControl,\n toStrbool,\n} from \"@hebium-ui/core\";\nimport {\n type ChangeEvent,\n type ComponentProps,\n type CompositionEvent,\n type FocusEvent,\n type KeyboardEvent,\n type MouseEvent,\n type ReactElement,\n type ReactNode,\n useCallback,\n useId,\n useMemo,\n useRef,\n} from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps } from \"~/types\";\nimport { normalizeAttributes } from \"~/utils\";\nimport { Label, type LabelProps } from \"../label\";\nimport { ComboboxOption } from \"./combobox-option\";\nimport { useComboboxForm } from \"./use-combobox-form\";\nimport { useComboboxPopover } from \"./use-combobox-popover\";\nimport { useComboboxState } from \"./use-combobox-state\";\n\ninterface ComboboxOwnProps<O extends ComboboxSelectOption> {\n /** Available options. Values must be unique. */\n options: readonly O[];\n /** The input's semantic color. @default \"accent\" */\n color?: ComboboxVariants[\"color\"] | undefined;\n /** The label displayed above the input. */\n label?: ReactNode | undefined;\n /** Additional props passed to the label. */\n labelProps?: LabelProps | undefined;\n /** Help text displayed below the label. */\n description?: ReactNode | undefined;\n /** Inline validation feedback. */\n error?: ReactNode | undefined;\n /** The name used for form submission. */\n name?: string | undefined;\n /** The id of the associated form. */\n form?: string | undefined;\n /** Prevents interaction and excludes the value from form submission. */\n disabled?: boolean | undefined;\n /** Prevents editing and opening the list. The value is still submitted. */\n readOnly?: boolean | undefined;\n /** Requires a nonempty committed value. */\n required?: boolean | undefined;\n /** Native validation message. @default \"Please fill out this field.\" */\n requiredMessage?: string | undefined;\n /** Props passed to the input element. */\n inputProps?: Omit<ComponentProps<\"input\">, \"children\"> | undefined;\n /** Props passed to the listbox element. */\n listProps?: Omit<ComponentProps<\"div\">, \"children\"> | undefined;\n /** Props for each option wrapper. */\n itemProps?: ((option: O) => Omit<ComponentProps<\"div\">, \"children\">) | undefined;\n /** Custom option content. */\n renderItem?: ((option: O) => ReactNode) | undefined;\n /** Renders custom form submission elements for the committed value. */\n renderFormValue?: ((props: ComboboxFormValueProps) => ReactNode) | undefined;\n}\n\ntype ComboboxValueProps<O extends ComboboxSelectOption> =\n | {\n /** Select from options or allow free text. @default \"select\" */\n mode?: \"select\" | undefined;\n /** The controlled value. Use null for no selection. */\n value?: string | null | undefined;\n /** The initial uncontrolled value. */\n defaultValue?: string | null | undefined;\n /** Called with the next value. */\n onChange?: ((value: string | null) => void) | undefined;\n }\n | {\n mode: \"text\";\n options: readonly (O & ComboboxTextOption)[];\n value?: string | undefined;\n defaultValue?: string | undefined;\n onChange?: ((value: string) => void) | undefined;\n };\n\nexport type ComboboxProps<O extends ComboboxSelectOption = ComboboxSelectOption> =\n & HuiComponentProps<ComboboxOwnProps<O>, ComboboxSlots>\n & ComboboxValueProps<O>;\n\nexport function Combobox<O extends ComboboxSelectOption>(rawProps: ComboboxProps<O>): ReactElement {\n const props = useHuiProps(\"Combobox\", rawProps);\n const {\n options,\n color,\n label,\n labelProps,\n description,\n error,\n required = false,\n requiredMessage,\n name,\n form,\n inputProps = {},\n listProps = {},\n itemProps,\n renderItem,\n renderFormValue,\n } = props;\n const generatedId = useId();\n const inputId = inputProps.id ?? `${generatedId}-input`;\n const listId = listProps.id ?? `${generatedId}-list`;\n const {\n state,\n inputValue,\n filteredOptions,\n activeOption,\n setActiveValue,\n clearActiveValue,\n edit,\n select: selectValue,\n clearQuery,\n reset,\n } = useComboboxState<O>(props);\n const inputRef = useRef<HTMLInputElement | null>(null);\n const composingRef = useRef(false);\n const attachInput = useComboboxForm({\n inputRef,\n externalRef: inputProps.ref,\n associatedFormId: inputProps.form ?? form,\n validationMessage: comboboxControl.getValidationMessage({\n value: state.value,\n required,\n disabled: state.disabled,\n readOnly: state.readOnly,\n requiredMessage,\n }),\n onReset: reset,\n });\n const {\n opened,\n listRef,\n attachList,\n showList,\n closeList,\n handleToggle,\n } = useComboboxPopover({\n state,\n filteredOptions,\n inputRef,\n externalRef: listProps.ref,\n onClose: clearActiveValue,\n onToggle: listProps.onToggle,\n });\n\n const select = useCallback((candidateValue: string): void => {\n const didSelectValue = selectValue(candidateValue);\n if (!didSelectValue) return;\n inputRef.current?.focus({ preventScroll: true });\n closeList();\n }, [selectValue, closeList]);\n\n const handleChange = useCallback((event: ChangeEvent<HTMLInputElement>): void => {\n inputProps.onChange?.(event);\n if (event.defaultPrevented) return;\n edit(event.currentTarget.value);\n showList();\n }, [inputProps, edit, showList]);\n\n const handleKeyDown = useCallback((event: KeyboardEvent<HTMLInputElement>): void => {\n inputProps.onKeyDown?.(event);\n if (event.defaultPrevented || composingRef.current) return;\n const visible = popoverControl.isOpened(listRef.current);\n const action = comboboxControl.getKeyAction(\n event.nativeEvent,\n { ...state, opened: visible },\n visible ? activeOption : undefined,\n );\n switch (action) {\n case \"next\":\n case \"previous\": {\n event.preventDefault();\n const isListOpened = showList();\n if (isListOpened) {\n const nextActiveValue = moveComboboxActiveValue(\n filteredOptions,\n visible ? state.activeValue : null,\n action,\n );\n setActiveValue(nextActiveValue);\n }\n return;\n }\n case \"commit\":\n event.preventDefault();\n if (activeOption) select(activeOption.value);\n return;\n case \"blocked\":\n event.preventDefault();\n return;\n case \"submit\":\n closeList();\n return;\n case \"none\":\n return;\n }\n }, [\n inputProps,\n state,\n activeOption,\n listRef,\n showList,\n filteredOptions,\n setActiveValue,\n select,\n closeList,\n ]);\n\n const handleInputClick = useCallback((event: MouseEvent<HTMLInputElement>): void => {\n inputProps.onClick?.(event);\n if (!event.defaultPrevented) showList();\n }, [inputProps, showList]);\n\n const handleBlur = useCallback((event: FocusEvent<HTMLDivElement>): void => {\n if (\n event.defaultPrevented\n || !(event.relatedTarget instanceof Node)\n || event.currentTarget.contains(event.relatedTarget)\n ) return;\n clearQuery();\n closeList();\n }, [clearQuery, closeList]);\n\n const handleCompositionStart = useCallback((event: CompositionEvent<HTMLInputElement>): void => {\n inputProps.onCompositionStart?.(event);\n composingRef.current = true;\n }, [inputProps]);\n const handleCompositionEnd = useCallback((event: CompositionEvent<HTMLInputElement>): void => {\n inputProps.onCompositionEnd?.(event);\n composingRef.current = false;\n }, [inputProps]);\n\n const itemIds = useMemo(\n () => new Map(options.map((option, index) => [option.value, `${listId}-option-${index}`])),\n [options, listId],\n );\n const inputAttributes = normalizeAttributes(comboboxControl.getInputAttributes({\n inputId,\n listId,\n opened,\n required,\n activeId: activeOption ? itemIds.get(activeOption.value) : undefined,\n }));\n const formValueProps = comboboxControl.getFormValueProps({\n name,\n value: state.value,\n form,\n disabled: state.disabled,\n });\n\n const labelAttrs = normalizeAttributes(inputControl.getLabelAttributes({\n id: inputId,\n invalid: !!error,\n required,\n disabled: state.disabled,\n readOnly: state.readOnly,\n }));\n const recipe = comboboxRecipe({\n color,\n error: toStrbool(!!error),\n });\n const cls = useHuiClassNames(\"Combobox\", recipe, rawProps);\n const sls = useHuiStyles(\"Combobox\", rawProps);\n\n return (\n <div\n className={cls.root}\n style={sls.root}\n onBlur={handleBlur}\n >\n {(!!label || !!description || !!error) && (\n <Label\n {...labelAttrs}\n description={description}\n error={error}\n {...labelProps}\n >\n {label}\n </Label>\n )}\n <input\n {...inputAttributes}\n aria-invalid={!!error}\n disabled={state.disabled}\n readOnly={state.readOnly}\n form={form}\n value={inputValue}\n {...inputProps}\n className={cc(cls.input, inputProps.className)}\n style={{ ...sls.input, ...inputProps.style }}\n ref={attachInput}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n onClick={handleInputClick}\n onCompositionStart={handleCompositionStart}\n onCompositionEnd={handleCompositionEnd}\n />\n <div\n {...normalizeAttributes(comboboxControl.getListAttributes(listId, inputId, state))}\n {...listProps}\n className={cc(cls.list, listProps.className)}\n style={{ ...sls.list, ...listProps.style }}\n ref={attachList}\n onToggle={handleToggle}\n >\n {filteredOptions.map((option) => {\n const id = itemIds.get(option.value);\n if (id === undefined) return null;\n return (\n <ComboboxOption\n key={option.value}\n option={option}\n id={id}\n mode={state.mode}\n active={opened && activeOption?.value === option.value}\n className={cls.item}\n style={sls.item}\n itemProps={itemProps}\n renderItem={renderItem}\n select={select}\n />\n );\n })}\n </div>\n {formValueProps && (renderFormValue\n ? renderFormValue(formValueProps)\n : (\n <input\n type=\"hidden\"\n {...formValueProps}\n />\n ))}\n </div>\n );\n}\nexport type { ComboboxFormValueProps, ComboboxSelectOption, ComboboxTextOption } from \"@hebium-ui/core\";\n"],"mappings":";;;;;;;;;;;AAiGA,SAAgB,SAAyC,UAA0C;CACjG,MAAM,QAAQ,YAAY,YAAY,QAAQ;CAC9C,MAAM,EACJ,SACA,OACA,OACA,YACA,aACA,OACA,WAAW,OACX,iBACA,MACA,MACA,aAAa,CAAC,GACd,YAAY,CAAC,GACb,WACA,YACA,oBACE;CACJ,MAAM,cAAc,MAAM;CAC1B,MAAM,UAAU,WAAW,MAAM,GAAG,YAAY;CAChD,MAAM,SAAS,UAAU,MAAM,GAAG,YAAY;CAC9C,MAAM,EACJ,OACA,YACA,iBACA,cACA,gBACA,kBACA,MACA,QAAQ,aACR,YACA,UACE,iBAAoB,KAAK;CAC7B,M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
@@ -0,0 +1,2 @@
1
+ import { Combobox, ComboboxFormValueProps, ComboboxProps, ComboboxSelectOption, ComboboxTextOption } from "./combobox.js";
2
+ export { Combobox, type ComboboxFormValueProps, ComboboxProps, type ComboboxSelectOption, type ComboboxTextOption };
@@ -0,0 +1,33 @@
1
+ import { useCallback, useImperativeHandle } from "react";
2
+ // src/components/combobox/use-combobox-form.ts
3
+ function useComboboxForm({ inputRef, externalRef, associatedFormId, validationMessage, onReset }) {
4
+ const attachInput = useCallback((input) => {
5
+ inputRef.current = input;
6
+ if (!input) return;
7
+ input.setCustomValidity(validationMessage);
8
+ const associatedForm = associatedFormId === void 0 ? input.form : input.ownerDocument.getElementById(associatedFormId);
9
+ const handleReset = (event) => {
10
+ if (event.defaultPrevented) return;
11
+ onReset();
12
+ };
13
+ const controller = new AbortController();
14
+ if (associatedForm instanceof HTMLFormElement) associatedForm.addEventListener("reset", handleReset, { signal: controller.signal });
15
+ return () => {
16
+ controller.abort();
17
+ inputRef.current = null;
18
+ };
19
+ }, [
20
+ inputRef,
21
+ validationMessage,
22
+ associatedFormId,
23
+ onReset
24
+ ]);
25
+ useImperativeHandle(externalRef, () => {
26
+ if (!inputRef.current) throw new Error("[Hebium UI] Combobox input ref is not attached");
27
+ return inputRef.current;
28
+ }, [inputRef]);
29
+ return attachInput;
30
+ }
31
+ export { useComboboxForm };
32
+
33
+ //# sourceMappingURL=use-combobox-form.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-combobox-form.js","names":[],"sources":["../../../src/components/combobox/use-combobox-form.ts"],"sourcesContent":["import { type Ref, type RefCallback, type RefObject, useCallback, useImperativeHandle } from \"react\";\n\ninterface UseComboboxFormOptions {\n inputRef: RefObject<HTMLInputElement | null>;\n externalRef: Ref<HTMLInputElement> | undefined;\n associatedFormId: string | undefined;\n validationMessage: string;\n onReset: () => void;\n}\n\nexport function useComboboxForm({\n inputRef,\n externalRef,\n associatedFormId,\n validationMessage,\n onReset,\n}: UseComboboxFormOptions): RefCallback<HTMLInputElement> {\n const attachInput = useCallback((input: HTMLInputElement | null): (() => void) | undefined => {\n inputRef.current = input;\n if (!input) return;\n input.setCustomValidity(validationMessage);\n const associatedForm = associatedFormId === undefined\n ? input.form\n : input.ownerDocument.getElementById(associatedFormId);\n const handleReset = (event: Event): void => {\n if (event.defaultPrevented) return;\n onReset();\n };\n const controller = new AbortController();\n if (associatedForm instanceof HTMLFormElement) {\n associatedForm.addEventListener(\"reset\", handleReset, { signal: controller.signal });\n }\n return () => {\n controller.abort();\n inputRef.current = null;\n };\n }, [inputRef, validationMessage, associatedFormId, onReset]);\n\n useImperativeHandle(externalRef, () => {\n if (!inputRef.current) throw new Error(\"[Hebium UI] Combobox input ref is not attached\");\n return inputRef.current;\n }, [inputRef]);\n\n return attachInput;\n}\n"],"mappings":";;AAUA,SAAgB,gBAAgB,EAC9B,UACA,aACA,kBACA,mBACA,WACwD;CACxD,MAAM,cAAc,aAAa,UAA6D;EAC5F,SAAS,UAAU;EACnB,IAAI,CAAC,OAAO;EACZ,MAAM,kBAAkB,iBAAiB;EACzC,MAAM,iBAAiB,qBAAqB,KAAA,IACxC,MAAM,OACN,MAAM,cAAc,eAAe,gBAAgB;EACvD,MAAM,eAAe,UAAuB;GAC1C,IAAI,MAAM,kBAAkB;GAC5B,QAAQ;EACV;EACA,MAAM,aAAa,IAAI,gBAAgB;EACvC,IAAI,0BAA0B,iBAC5B,eAAe,iBAAiB,SAAS,aAAa,EAAE,QAAQ,WAAW,OAAO,CAAC;EAErF,aAAa;GACX,WAAW,MAAM;GACjB,SAAS,UAAU;EACrB;CACF,GAAG;EAAC;EAAU;EAAmB;EAAkB;CAAO,CAAC;CAE3D,oBAAoB,mBAAmB;EACrC,IAAI,CAAC,SAAS,SAAS,MAAM,IAAI,MAAM,gDAAgD;EACvF,OAAO,SAAS;CAClB,GAAG,CAAC,QAAQ,CAAC;CAEb,OAAO;AACT"}
@@ -0,0 +1,66 @@
1
+ import { comboboxControl, popoverControl } from "@hebium-ui/core";
2
+ import { useCallback, useImperativeHandle, useRef, useState } from "react";
3
+ // src/components/combobox/use-combobox-popover.ts
4
+ function scrollActiveOptionIntoView(list) {
5
+ const item = list.querySelector("[data-focus=\"true\"]");
6
+ if (!item) return;
7
+ const bounds = item.getBoundingClientRect();
8
+ const listBounds = list.getBoundingClientRect();
9
+ if (bounds.top < listBounds.top) list.scrollTop -= listBounds.top - bounds.top;
10
+ else if (bounds.bottom > listBounds.bottom) list.scrollTop += bounds.bottom - listBounds.bottom;
11
+ }
12
+ function useComboboxPopover({ state: { disabled, readOnly, activeValue }, filteredOptions, inputRef, externalRef, onClose, onToggle }) {
13
+ const listRef = useRef(null);
14
+ const [opened, setOpened] = useState(false);
15
+ const syncOpened = useCallback((nextOpened) => {
16
+ setOpened(nextOpened);
17
+ if (!nextOpened) onClose();
18
+ }, [onClose]);
19
+ const closeList = useCallback(() => {
20
+ const list = listRef.current;
21
+ if (list && popoverControl.isOpened(list)) list.hidePopover();
22
+ syncOpened(false);
23
+ }, [syncOpened]);
24
+ const attachList = useCallback((list) => {
25
+ listRef.current = list;
26
+ if (!list) return;
27
+ if (popoverControl.isOpened(list) && filteredOptions.some((option) => option.value === activeValue)) scrollActiveOptionIntoView(list);
28
+ return () => {
29
+ listRef.current = null;
30
+ };
31
+ }, [filteredOptions, activeValue]);
32
+ useImperativeHandle(externalRef, () => {
33
+ if (!listRef.current) throw new Error("[Hebium UI] Combobox list ref is not attached");
34
+ return listRef.current;
35
+ }, []);
36
+ return {
37
+ opened,
38
+ listRef,
39
+ attachList,
40
+ showList: useCallback(() => {
41
+ const input = inputRef.current;
42
+ const list = listRef.current;
43
+ if (!comboboxControl.canEdit({
44
+ disabled,
45
+ readOnly
46
+ }) || !input || !list) return false;
47
+ if (!popoverControl.isOpened(list)) list.showPopover({ source: input });
48
+ const visible = popoverControl.isOpened(list);
49
+ syncOpened(visible);
50
+ return visible;
51
+ }, [
52
+ disabled,
53
+ readOnly,
54
+ inputRef,
55
+ syncOpened
56
+ ]),
57
+ closeList,
58
+ handleToggle: useCallback((event) => {
59
+ onToggle?.(event);
60
+ syncOpened(popoverControl.isOpened(event.currentTarget));
61
+ }, [onToggle, syncOpened])
62
+ };
63
+ }
64
+ export { useComboboxPopover };
65
+
66
+ //# sourceMappingURL=use-combobox-popover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-combobox-popover.js","names":[],"sources":["../../../src/components/combobox/use-combobox-popover.ts"],"sourcesContent":["import { comboboxControl, type ComboboxSelectOption, type ComboboxState, popoverControl } from \"@hebium-ui/core\";\nimport {\n type Ref,\n type RefCallback,\n type RefObject,\n type ToggleEvent,\n type ToggleEventHandler,\n useCallback,\n useImperativeHandle,\n useRef,\n useState,\n} from \"react\";\n\nfunction scrollActiveOptionIntoView(list: HTMLElement): void {\n const item = list.querySelector<HTMLElement>(\"[data-focus=\\\"true\\\"]\");\n if (!item) return;\n const bounds = item.getBoundingClientRect();\n const listBounds = list.getBoundingClientRect();\n if (bounds.top < listBounds.top) list.scrollTop -= listBounds.top - bounds.top;\n else if (bounds.bottom > listBounds.bottom) list.scrollTop += bounds.bottom - listBounds.bottom;\n}\n\ninterface UseComboboxPopoverOptions<O extends ComboboxSelectOption> {\n state: Pick<ComboboxState, \"disabled\" | \"readOnly\" | \"activeValue\">;\n filteredOptions: readonly O[];\n inputRef: RefObject<HTMLInputElement | null>;\n externalRef: Ref<HTMLDivElement> | undefined;\n onClose: () => void;\n onToggle: ToggleEventHandler<HTMLDivElement> | undefined;\n}\n\ninterface ComboboxPopoverController {\n opened: boolean;\n listRef: RefObject<HTMLDivElement | null>;\n attachList: RefCallback<HTMLDivElement>;\n showList: () => boolean;\n closeList: () => void;\n handleToggle: ToggleEventHandler<HTMLDivElement>;\n}\n\nexport function useComboboxPopover<O extends ComboboxSelectOption>({\n state: { disabled, readOnly, activeValue },\n filteredOptions,\n inputRef,\n externalRef,\n onClose,\n onToggle,\n}: UseComboboxPopoverOptions<O>): ComboboxPopoverController {\n const listRef = useRef<HTMLDivElement | null>(null);\n const [opened, setOpened] = useState(false);\n\n const syncOpened = useCallback((nextOpened: boolean): void => {\n setOpened(nextOpened);\n if (!nextOpened) onClose();\n }, [onClose]);\n\n const closeList = useCallback((): void => {\n const list = listRef.current;\n if (list && popoverControl.isOpened(list)) list.hidePopover();\n syncOpened(false);\n }, [syncOpened]);\n\n const attachList = useCallback((list: HTMLDivElement | null): (() => void) | undefined => {\n listRef.current = list;\n if (!list) return;\n if (popoverControl.isOpened(list) && filteredOptions.some((option) => option.value === activeValue)) {\n scrollActiveOptionIntoView(list);\n }\n return () => {\n listRef.current = null;\n };\n }, [filteredOptions, activeValue]);\n\n useImperativeHandle(externalRef, () => {\n if (!listRef.current) throw new Error(\"[Hebium UI] Combobox list ref is not attached\");\n return listRef.current;\n }, []);\n\n const showList = useCallback((): boolean => {\n const input = inputRef.current;\n const list = listRef.current;\n if (!comboboxControl.canEdit({ disabled, readOnly }) || !input || !list) return false;\n if (!popoverControl.isOpened(list)) list.showPopover({ source: input });\n const visible = popoverControl.isOpened(list);\n syncOpened(visible);\n return visible;\n }, [disabled, readOnly, inputRef, syncOpened]);\n\n const handleToggle = useCallback((event: ToggleEvent<HTMLDivElement>): void => {\n onToggle?.(event);\n syncOpened(popoverControl.isOpened(event.currentTarget));\n }, [onToggle, syncOpened]);\n\n return {\n opened,\n listRef,\n attachList,\n showList,\n closeList,\n handleToggle,\n };\n}\n"],"mappings":";;;AAaA,SAAS,2BAA2B,MAAyB;CAC3D,MAAM,OAAO,KAAK,cAA2B,uBAAuB;CACpE,IAAI,CAAC,MAAM;CACX,MAAM,SAAS,KAAK,sBAAsB;CAC1C,MAAM,aAAa,KAAK,sBAAsB;CAC9C,IAAI,OAAO,MAAM,WAAW,KAAK,KAAK,aAAa,WAAW,MAAM,OAAO;MACtE,IAAI,OAAO,SAAS,WAAW,QAAQ,KAAK,aAAa,OAAO,SAAS,WAAW;AAC3F;AAoBA,SAAgB,mBAAmD,EACjE,OAAO,EA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M,aAAa,CAAC;EACzD,GAAG,CAAC,UAAU,UAAU,CAQX;CACb;AACF"}
@@ -0,0 +1,96 @@
1
+ import { comboboxControl, filterComboboxOptions } from "@hebium-ui/core";
2
+ import { useCallback, useMemo, useState } from "react";
3
+ // src/components/combobox/use-combobox-state.ts
4
+ function useComboboxState(props) {
5
+ const { options, mode = "select", value, defaultValue, disabled = false, readOnly = false } = props;
6
+ const controlled = value !== void 0;
7
+ const initialValue = defaultValue === void 0 ? mode === "text" ? "" : null : defaultValue;
8
+ const [uncontrolledValue, setUncontrolledValue] = useState(initialValue);
9
+ const currentValue = controlled ? value : uncontrolledValue;
10
+ const selectedValue = mode === "text" ? currentValue ?? "" : currentValue;
11
+ const [query, setQuery] = useState("");
12
+ const [activeValue, setActiveValue] = useState(null);
13
+ const state = useMemo(() => ({
14
+ mode,
15
+ value: selectedValue,
16
+ query,
17
+ activeValue,
18
+ disabled,
19
+ readOnly
20
+ }), [
21
+ mode,
22
+ selectedValue,
23
+ query,
24
+ activeValue,
25
+ disabled,
26
+ readOnly
27
+ ]);
28
+ const inputValue = comboboxControl.getInputValue(state, options);
29
+ const filteredOptions = useMemo(() => {
30
+ return filterComboboxOptions(mode, options, inputValue);
31
+ }, [
32
+ mode,
33
+ options,
34
+ inputValue
35
+ ]);
36
+ const activeOption = filteredOptions.find((option) => option.value === activeValue);
37
+ const changeValue = useCallback((nextValue) => {
38
+ const onChange = props.onChange;
39
+ setUncontrolledValue(nextValue);
40
+ onChange?.(nextValue);
41
+ }, [props.onChange]);
42
+ const edit = useCallback((text) => {
43
+ if (!comboboxControl.canEdit(state)) return;
44
+ const result = comboboxControl.edit(mode, text);
45
+ setActiveValue(null);
46
+ setQuery(result.query);
47
+ if (props.mode === "text") changeValue(text);
48
+ else if (selectedValue !== null) {
49
+ setUncontrolledValue(null);
50
+ const onChange = props.onChange;
51
+ onChange?.(null);
52
+ }
53
+ }, [
54
+ state,
55
+ mode,
56
+ selectedValue,
57
+ changeValue,
58
+ props.mode,
59
+ props.onChange
60
+ ]);
61
+ const select = useCallback((candidateValue) => {
62
+ const option = options.find((candidate) => candidate.value === candidateValue);
63
+ if (!option) return false;
64
+ const result = comboboxControl.select(state, option);
65
+ if (!result) return false;
66
+ setQuery(result.query);
67
+ changeValue(result.value);
68
+ return true;
69
+ }, [
70
+ options,
71
+ state,
72
+ changeValue
73
+ ]);
74
+ return {
75
+ state,
76
+ inputValue,
77
+ filteredOptions,
78
+ activeOption,
79
+ setActiveValue,
80
+ clearActiveValue: useCallback(() => {
81
+ setActiveValue(null);
82
+ }, []),
83
+ edit,
84
+ select,
85
+ clearQuery: useCallback(() => {
86
+ setQuery("");
87
+ }, []),
88
+ reset: useCallback(() => {
89
+ setQuery("");
90
+ if (!controlled) setUncontrolledValue(initialValue);
91
+ }, [controlled, initialValue])
92
+ };
93
+ }
94
+ export { useComboboxState };
95
+
96
+ //# sourceMappingURL=use-combobox-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-combobox-state.js","names":[],"sources":["../../../src/components/combobox/use-combobox-state.ts"],"sourcesContent":["import { comboboxControl, type ComboboxSelectOption, type ComboboxState, filterComboboxOptions } from \"@hebium-ui/core\";\nimport { useCallback, useMemo, useState } from \"react\";\nimport { type DistributivePick } from \"~/types\";\nimport { type ComboboxProps } from \"./combobox\";\n\ntype UseComboboxStateOptions<O extends ComboboxSelectOption> = DistributivePick<\n ComboboxProps<O>,\n \"options\" | \"mode\" | \"value\" | \"defaultValue\" | \"onChange\" | \"disabled\" | \"readOnly\"\n>;\n\ninterface ComboboxStateController<O extends ComboboxSelectOption> {\n state: ComboboxState;\n inputValue: string;\n filteredOptions: readonly O[];\n activeOption: O | undefined;\n setActiveValue: (value: string | null) => void;\n clearActiveValue: () => void;\n edit: (text: string) => void;\n select: (value: string) => boolean;\n clearQuery: () => void;\n reset: () => void;\n}\n\nexport function useComboboxState<O extends ComboboxSelectOption>(\n props: UseComboboxStateOptions<O>,\n): ComboboxStateController<O> {\n const {\n options,\n mode = \"select\",\n value,\n defaultValue,\n disabled = false,\n readOnly = false,\n } = props;\n const controlled = value !== undefined;\n const initialValue = defaultValue === undefined ? mode === \"text\" ? \"\" : null : defaultValue;\n const [uncontrolledValue, setUncontrolledValue] = useState<string | null>(initialValue);\n const currentValue = controlled ? value : uncontrolledValue;\n const selectedValue = mode === \"text\" ? currentValue ?? \"\" : currentValue;\n const [query, setQuery] = useState(\"\");\n const [activeValue, setActiveValue] = useState<string | null>(null);\n const state = useMemo<ComboboxState>(\n () => ({\n mode,\n value: selectedValue,\n query,\n activeValue,\n disabled,\n readOnly,\n }),\n [\n mode,\n selectedValue,\n query,\n activeValue,\n disabled,\n readOnly,\n ],\n );\n\n const inputValue = comboboxControl.getInputValue(state, options);\n const filteredOptions = useMemo(() => {\n return filterComboboxOptions(mode, options, inputValue);\n }, [\n mode,\n options,\n inputValue,\n ]);\n\n const activeOption = filteredOptions.find((option) => option.value === activeValue);\n\n const changeValue = useCallback((nextValue: string): void => {\n const onChange = props.onChange;\n setUncontrolledValue(nextValue);\n onChange?.(nextValue);\n }, [props.onChange]);\n\n const edit = useCallback((text: string): void => {\n if (!comboboxControl.canEdit(state)) return;\n const result = comboboxControl.edit(mode, text);\n setActiveValue(null);\n setQuery(result.query);\n if (props.mode === \"text\") {\n changeValue(text);\n } else if (selectedValue !== null) {\n setUncontrolledValue(null);\n const onChange = props.onChange;\n onChange?.(null);\n }\n }, [state, mode, selectedValue, changeValue, props.mode, props.onChange]);\n\n const select = useCallback((candidateValue: string): boolean => {\n const option = options.find((candidate) => candidate.value === candidateValue);\n if (!option) return false;\n const result = comboboxControl.select(state, option);\n if (!result) return false;\n setQuery(result.query);\n changeValue(result.value);\n return true;\n }, [options, state, changeValue]);\n\n const clearActiveValue = useCallback((): void => {\n setActiveValue(null);\n }, []);\n\n const clearQuery = useCallback((): void => {\n setQuery(\"\");\n }, []);\n\n const reset = useCallback((): void => {\n setQuery(\"\");\n if (!controlled) setUncontrolledValue(initialValue);\n }, [controlled, initialValue]);\n\n return {\n state,\n inputValue,\n filteredOptions,\n activeOption,\n setActiveValue,\n clearActiveValue,\n edit,\n select,\n clearQuery,\n reset,\n };\n}\n"],"mappings":";;;AAuBA,SAAgB,iBACd,OAC4B;CAC5B,MAAM,EACJ,SACA,OAAO,UACP,OACA,cACA,WAAW,OACX,WAAW,UACT;CACJ,MAAM,aAAa,UAAU,KAAA;CAC7B,MAAM,eAAe,iBAAiB,KAAA,IAAY,SAAS,SAAS,KAAK,OAAO;CAChF,MAAM,CAAC,mBAAmB,wBAAwB,SAAwB,YAAY;CACtF,MAAM,eAAe,aAAa,QAAQ;CAC1C,MAAM,gBAAgB,SAAS,SAAS,gBAAgB,KAAK;CAC7D,MAAM,CAAC,OAAO,YAAY,SAAS,EAAE;CACrC,MAAM,CAAC,aAAa,kBAAkB,SAAwB,IAAI;CAClE,MAAM,QAAQ,eACL;EACL;EACA,OAAO;EACP;EACA;EACA;EACA;CACF,IACA;EACE;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAEA,MAAM,aAAa,gBAAgB,cAAc,OAAO,OAAO;CAC/D,MAAM,kBAAkB,cAAc;EACpC,OAAO,sBAAsB,MAAM,SAAS,UAAU;CACxD,GAAG;EACD;EACA;EACA;CACF,CAAC;CAED,MAAM,eAAe,gBAAgB,MAAM,WAAW,OAAO,UAAU,WAAW;CAElF,MAAM,cAAc,aAAa,cAA4B;EAC3D,MAAM,WAAW,MAAM;EACvB,qBAAqB,SAAS;EAC9B,WAAW,SAAS;CACtB,GAAG,CAAC,MAAM,QAAQ,CAAC;CAEnB,MAAM,OAAO,aAAa,SAAuB;EAC/C,IAAI,CAAC,gBAAgB,QAAQ,KAAK,GAAG;EACrC,MAAM,SAAS,gBAAgB,KAAK,MAAM,IAAI;EAC9C,eAAe,IAAI;EACnB,SAAS,OAAO,KAAK;EACrB,IAAI,MAAM,SAAS,QACjB,YAAY,IAAI;OACX,IAAI,kBAAkB,MAAM;GACjC,qBAAqB,IAAI;GACzB,MAAM,WAAW,MAAM;GACvB,WAAW,IAAI;EACjB;CACF,GAAG;EAAC;EAAO;EAAM;EAAe;EAAa,MAAM;EAAM,MAAM;CAAQ,CAAC;CAExE,MAAM,SAAS,aAAa,mBAAoC;EAC9D,MAAM,SAAS,QAAQ,MAAM,cAAc,UAAU,UAAU,cAAc;EAC7E,IAAI,CAAC,QAAQ,OAAO;EACpB,MAAM,SAAS,gBAAgB,OAAO,OAAO,MAAM;EACnD,IAAI,CAAC,QAAQ,OAAO;EACpB,SAAS,OAAO,KAAK;EACrB,YAAY,OAAO,KAAK;EACxB,OAAO;CACT,GAAG;EAAC;EAAS;EAAO;CAAW,CAAC;CAehC,OAAO;EACL;EACA;EACA;EACA;EACA;EACA,kBAnBuB,kBAAwB;GAC/C,eAAe,IAAI;EACrB,GAAG,CAAC,CAiBa;EACf;EACA;EACA,YAlBiB,kBAAwB;GACzC,SAAS,EAAE;EACb,GAAG,CAAC,CAgBO;EACT,OAfY,kBAAwB;GACpC,SAAS,EAAE;GACX,IAAI,CAAC,YAAY,qBAAqB,YAAY;EACpD,GAAG,CAAC,YAAY,YAAY,CAYtB;CACN;AACF"}
@@ -2,7 +2,6 @@ import { HuiComponentProps } from "../../types/hui-component.js";
2
2
  import "../../types/index.js";
3
3
  import { DetailsSlots, DetailsVariants } from "@hebium-ui/core";
4
4
  import { ComponentProps, ReactElement, ReactNode } from "react";
5
- //#region src/components/details/details.d.ts
6
5
  interface DetailsOwnProps extends ComponentProps<"details"> {
7
6
  /**
8
7
  * The summary displayed in the disclosure button.
@@ -17,6 +16,4 @@ interface DetailsOwnProps extends ComponentProps<"details"> {
17
16
  }
18
17
  export type DetailsProps = HuiComponentProps<DetailsOwnProps, DetailsSlots>;
19
18
  export declare function Details(rawProps: DetailsProps): ReactElement;
20
- //#endregion
21
- export {};
22
- //# sourceMappingURL=details.d.ts.map
19
+ export {};
@@ -1,12 +1,12 @@
1
1
  import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
2
2
  import { detailsRecipe } from "@hebium-ui/core";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
- //#region src/components/details/details.tsx
4
+ // src/components/details/details.tsx
5
5
  function Details(rawProps) {
6
- const { summary, border, classNames, styles, children, ...restProps } = useHuiProps("Details", rawProps);
6
+ const { summary, border, children, ...restProps } = useHuiProps("Details", rawProps);
7
7
  const recipe = detailsRecipe({ border });
8
- const cls = useHuiClassNames("Details", recipe, classNames);
9
- const sls = useHuiStyles("Details", styles);
8
+ const cls = useHuiClassNames("Details", recipe, rawProps);
9
+ const sls = useHuiStyles("Details", rawProps);
10
10
  return /* @__PURE__ */ jsxs("details", {
11
11
  className: cls.root,
12
12
  style: sls.root,
@@ -22,7 +22,6 @@ function Details(rawProps) {
22
22
  })]
23
23
  });
24
24
  }
25
- //#endregion
26
25
  export { Details };
27
26
 
28
27
  //# sourceMappingURL=details.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"details.js","names":[],"sources":["../../../src/components/details/details.tsx"],"sourcesContent":["import { detailsRecipe, type DetailsSlots, type DetailsVariants } from \"@hebium-ui/core\";\nimport { type ComponentProps, type ReactElement, type ReactNode } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps } from \"~/types\";\n\ninterface DetailsOwnProps extends ComponentProps<\"details\"> {\n /**\n * The summary displayed in the disclosure button.\n */\n summary: ReactNode;\n /**\n * The border style of the details container.\n *\n * @default \"block\"\n */\n border?: DetailsVariants[\"border\"] | undefined;\n}\n\nexport type DetailsProps = HuiComponentProps<\n DetailsOwnProps,\n DetailsSlots\n>;\n\nexport function Details(rawProps: DetailsProps): ReactElement {\n const {\n summary,\n border,\n classNames,\n styles,\n children,\n ...restProps\n } = useHuiProps(\"Details\", rawProps);\n\n const recipe = detailsRecipe({ border });\n const cls = useHuiClassNames(\"Details\", recipe, classNames);\n const sls = useHuiStyles(\"Details\", styles);\n\n return (\n <details\n className={cls.root}\n style={sls.root}\n {...restProps}\n >\n <summary\n className={cls.summary}\n style={sls.summary}\n >\n {summary}\n </summary>\n {children != null && (\n <div\n className={cls.content}\n style={sls.content}\n >\n {children}\n </div>\n )}\n </details>\n );\n}\n"],"mappings":";;;;AAuBA,SAAgB,QAAQ,UAAsC;CAC5D,MAAM,EACJ,SACA,QACA,YACA,QACA,UACA,GAAG,cACD,YAAY,WAAW,QAAQ;CAEnC,MAAM,SAAS,cAAc,EAAE,OAAO,CAAC;CACvC,MAAM,MAAM,iBAAiB,WAAW,QAAQ,UAAU;CAC1D,MAAM,MAAM,aAAa,WAAW,MAAM;CAE1C,OACE,qBAAC,WAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EAHN,UAAA,CAKE,oBAAC,WAAD;GACE,WAAW,IAAI;GACf,OAAO,IAAI;GAEV,UAAA;EACM,CAAA,GACR,YAAY,QACX,oBAAC,OAAD;GACE,WAAW,IAAI;GACf,OAAO,IAAI;GAEV;EACE,CAAA,CAEA;;AAEb"}
1
+ {"version":3,"file":"details.js","names":[],"sources":["../../../src/components/details/details.tsx"],"sourcesContent":["import { detailsRecipe, type DetailsSlots, type DetailsVariants } from \"@hebium-ui/core\";\nimport { type ComponentProps, type ReactElement, type ReactNode } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps } from \"~/types\";\n\ninterface DetailsOwnProps extends ComponentProps<\"details\"> {\n /**\n * The summary displayed in the disclosure button.\n */\n summary: ReactNode;\n /**\n * The border style of the details container.\n *\n * @default \"block\"\n */\n border?: DetailsVariants[\"border\"] | undefined;\n}\n\nexport type DetailsProps = HuiComponentProps<\n DetailsOwnProps,\n DetailsSlots\n>;\n\nexport function Details(rawProps: DetailsProps): ReactElement {\n const {\n summary,\n border,\n children,\n ...restProps\n } = useHuiProps(\"Details\", rawProps);\n\n const recipe = detailsRecipe({ border });\n const cls = useHuiClassNames(\"Details\", recipe, rawProps);\n const sls = useHuiStyles(\"Details\", rawProps);\n\n return (\n <details\n className={cls.root}\n style={sls.root}\n {...restProps}\n >\n <summary\n className={cls.summary}\n style={sls.summary}\n >\n {summary}\n </summary>\n {children != null && (\n <div\n className={cls.content}\n style={sls.content}\n >\n {children}\n </div>\n )}\n </details>\n );\n}\n"],"mappings":";;;;AAuBA,SAAgB,QAAQ,UAAsC;CAC5D,MAAM,EACJ,SACA,QACA,UACA,GAAG,cACD,YAAY,WAAW,QAAQ;CAEnC,MAAM,SAAS,cAAc,EAAE,OAAO,CAAC;CACvC,MAAM,MAAM,iBAAiB,WAAW,QAAQ,QAAQ;CACxD,MAAM,MAAM,aAAa,WAAW,QAAQ;CAE5C,OACE,qBAAC,WAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EAHN,UAAA,CAKE,oBAAC,WAAD;GACE,WAAW,IAAI;GACf,OAAO,IAAI;GAEV,UAAA;EACM,CAAA,GACR,YAAY,QACX,oBAAC,OAAD;GACE,WAAW,IAAI;GACf,OAAO,IAAI;GAEV;EACE,CAAA,CAEA;;AAEb"}
@@ -1,5 +1,5 @@
1
1
  import { createContext, useContext } from "react";
2
- //#region src/components/dialog/dialog.context.ts
2
+ // src/components/dialog/dialog.context.ts
3
3
  const DialogContext = createContext(null);
4
4
  function useDialogContext() {
5
5
  const context = useContext(DialogContext);
@@ -9,7 +9,6 @@ function useDialogContext() {
9
9
  function useDialogId() {
10
10
  return useDialogContext().dialogId;
11
11
  }
12
- //#endregion
13
12
  export { DialogContext, useDialogContext, useDialogId };
14
13
 
15
14
  //# sourceMappingURL=dialog.context.js.map
@@ -7,7 +7,6 @@ import { HeadingProps } from "../heading/heading.js";
7
7
  import "../heading/index.js";
8
8
  import { ButtonSlots, DialogSlots } from "@hebium-ui/core";
9
9
  import { ComponentProps, ElementType, ReactElement, ReactNode } from "react";
10
- //#region src/components/dialog/dialog.d.ts
11
10
  export interface DialogProps {
12
11
  /**
13
12
  * The id of the dialog content element.
@@ -22,8 +21,8 @@ export interface DialogProps {
22
21
  children?: ReactNode | undefined;
23
22
  }
24
23
  declare function DialogRoot(rawProps: DialogProps): ReactElement;
25
- export type DialogTriggerProps<E extends ElementType = typeof Button> = HuiPolymorphicProps<E, {}, ButtonSlots>;
26
- declare function Trigger<E extends ElementType = typeof Button>(rawProps: DialogTriggerProps<E>): ReactNode;
24
+ export type DialogTriggerProps<E extends ElementType = typeof Button<"button">> = HuiPolymorphicProps<E, {}, ButtonSlots>;
25
+ declare function Trigger<E extends ElementType = typeof Button<"button">>(rawProps: DialogTriggerProps<E>): ReactNode;
27
26
  type HtmlDialogProps = Omit<ComponentProps<"dialog">, "children" | "id" | "open">;
28
27
  interface DialogContentOwnProps extends HtmlDialogProps {
29
28
  /**
@@ -43,7 +42,7 @@ interface DialogContentOwnProps extends HtmlDialogProps {
43
42
  /**
44
43
  * Additional props passed to the internal close button.
45
44
  */
46
- closeButtonProps?: Omit<DialogCloseProps, "children" | "className" | "style"> | undefined;
45
+ closeButtonProps?: Omit<DialogCloseProps, "children" | "classNames" | "styles"> | undefined;
47
46
  children?: ReactNode | undefined;
48
47
  }
49
48
  export type DialogContentProps = HuiComponentProps<DialogContentOwnProps, DialogSlots>;
@@ -62,6 +61,4 @@ export declare const Dialog: typeof DialogRoot & {
62
61
  Content: typeof Content;
63
62
  Close: typeof Close;
64
63
  };
65
- //#endregion
66
- export {};
67
- //# sourceMappingURL=dialog.d.ts.map
64
+ export {};