@hebium-ui/react 0.1.0-alpha.3 → 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 (154) hide show
  1. package/dist/components/alert/alert.d.ts +3 -4
  2. package/dist/components/alert/alert.js +4 -11
  3. package/dist/components/alert/alert.js.map +1 -1
  4. package/dist/components/anchor/anchor.d.ts +1 -2
  5. package/dist/components/anchor/anchor.js +2 -2
  6. package/dist/components/anchor/anchor.js.map +1 -1
  7. package/dist/components/avatar/avatar.d.ts +1 -2
  8. package/dist/components/avatar/avatar.js +2 -2
  9. package/dist/components/avatar/avatar.js.map +1 -1
  10. package/dist/components/blockquote/blockquote.d.ts +1 -2
  11. package/dist/components/blockquote/blockquote.js +2 -2
  12. package/dist/components/blockquote/blockquote.js.map +1 -1
  13. package/dist/components/button/button.d.ts +12 -2
  14. package/dist/components/button/button.js +29 -9
  15. package/dist/components/button/button.js.map +1 -1
  16. package/dist/components/checkbox/checkbox.d.ts +1 -2
  17. package/dist/components/checkbox/checkbox.js +2 -2
  18. package/dist/components/checkbox/checkbox.js.map +1 -1
  19. package/dist/components/code/code.d.ts +1 -2
  20. package/dist/components/code/code.js +2 -2
  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 -2
  35. package/dist/components/details/details.js +2 -2
  36. package/dist/components/details/details.js.map +1 -1
  37. package/dist/components/dialog/dialog.d.ts +4 -5
  38. package/dist/components/dialog/dialog.js +26 -13
  39. package/dist/components/dialog/dialog.js.map +1 -1
  40. package/dist/components/dialog/index.d.ts +1 -2
  41. package/dist/components/dl/dl.d.ts +1 -2
  42. package/dist/components/dl/dl.js +6 -6
  43. package/dist/components/dl/dl.js.map +1 -1
  44. package/dist/components/drawer/drawer.d.ts +4 -5
  45. package/dist/components/drawer/drawer.js +26 -13
  46. package/dist/components/drawer/drawer.js.map +1 -1
  47. package/dist/components/drawer/index.d.ts +1 -2
  48. package/dist/components/fieldset/fieldset.d.ts +1 -2
  49. package/dist/components/fieldset/fieldset.js +2 -2
  50. package/dist/components/fieldset/fieldset.js.map +1 -1
  51. package/dist/components/heading/heading.d.ts +1 -2
  52. package/dist/components/heading/heading.js +2 -2
  53. package/dist/components/heading/heading.js.map +1 -1
  54. package/dist/components/hr/hr.d.ts +1 -2
  55. package/dist/components/hr/hr.js +2 -2
  56. package/dist/components/hr/hr.js.map +1 -1
  57. package/dist/components/index.d.ts +32 -27
  58. package/dist/components/inline-feedback/index.d.ts +2 -0
  59. package/dist/components/inline-feedback/inline-feedback.d.ts +33 -0
  60. package/dist/components/inline-feedback/inline-feedback.js +30 -0
  61. package/dist/components/inline-feedback/inline-feedback.js.map +1 -0
  62. package/dist/components/input/input.d.ts +1 -2
  63. package/dist/components/input/input.js +2 -2
  64. package/dist/components/input/input.js.map +1 -1
  65. package/dist/components/label/label.d.ts +1 -2
  66. package/dist/components/label/label.js +4 -4
  67. package/dist/components/label/label.js.map +1 -1
  68. package/dist/components/menu/index.d.ts +1 -2
  69. package/dist/components/menu/menu.d.ts +3 -4
  70. package/dist/components/menu/menu.js +20 -9
  71. package/dist/components/menu/menu.js.map +1 -1
  72. package/dist/components/multi-combobox/index.d.ts +2 -0
  73. package/dist/components/multi-combobox/multi-combobox-option.js +42 -0
  74. package/dist/components/multi-combobox/multi-combobox-option.js.map +1 -0
  75. package/dist/components/multi-combobox/multi-combobox-tag.js +54 -0
  76. package/dist/components/multi-combobox/multi-combobox-tag.js.map +1 -0
  77. package/dist/components/multi-combobox/multi-combobox.d.ts +72 -0
  78. package/dist/components/multi-combobox/multi-combobox.js +249 -0
  79. package/dist/components/multi-combobox/multi-combobox.js.map +1 -0
  80. package/dist/components/multi-combobox/use-multi-combobox-state.js +91 -0
  81. package/dist/components/multi-combobox/use-multi-combobox-state.js.map +1 -0
  82. package/dist/components/paragraph/paragraph.d.ts +1 -2
  83. package/dist/components/paragraph/paragraph.js +2 -2
  84. package/dist/components/paragraph/paragraph.js.map +1 -1
  85. package/dist/components/popover/index.d.ts +1 -2
  86. package/dist/components/popover/popover.d.ts +3 -4
  87. package/dist/components/popover/popover.js +18 -7
  88. package/dist/components/popover/popover.js.map +1 -1
  89. package/dist/components/progress/progress.d.ts +1 -2
  90. package/dist/components/progress/progress.js +2 -2
  91. package/dist/components/progress/progress.js.map +1 -1
  92. package/dist/components/radio/radio.d.ts +1 -2
  93. package/dist/components/radio/radio.js +2 -2
  94. package/dist/components/radio/radio.js.map +1 -1
  95. package/dist/components/radiogroup/radiogroup.d.ts +1 -2
  96. package/dist/components/radiogroup/radiogroup.js +5 -4
  97. package/dist/components/radiogroup/radiogroup.js.map +1 -1
  98. package/dist/components/section/section.d.ts +1 -2
  99. package/dist/components/section/section.js +2 -2
  100. package/dist/components/section/section.js.map +1 -1
  101. package/dist/components/segmented-control/segmented-control.d.ts +1 -2
  102. package/dist/components/segmented-control/segmented-control.js +10 -5
  103. package/dist/components/segmented-control/segmented-control.js.map +1 -1
  104. package/dist/components/select/select.d.ts +1 -2
  105. package/dist/components/select/select.js +2 -2
  106. package/dist/components/select/select.js.map +1 -1
  107. package/dist/components/skip-link/skip-link.d.ts +1 -2
  108. package/dist/components/skip-link/skip-link.js +2 -2
  109. package/dist/components/skip-link/skip-link.js.map +1 -1
  110. package/dist/components/status-icon/index.d.ts +2 -0
  111. package/dist/components/status-icon/status-icon.d.ts +19 -0
  112. package/dist/components/status-icon/status-icon.js +22 -0
  113. package/dist/components/status-icon/status-icon.js.map +1 -0
  114. package/dist/components/table/table.d.ts +4 -5
  115. package/dist/components/table/table.js +16 -16
  116. package/dist/components/table/table.js.map +1 -1
  117. package/dist/components/tabs/tabs.context.d.ts +1 -2
  118. package/dist/components/tabs/tabs.d.ts +1 -2
  119. package/dist/components/tabs/tabs.js +8 -8
  120. package/dist/components/tabs/tabs.js.map +1 -1
  121. package/dist/components/tag/index.d.ts +2 -0
  122. package/dist/components/tag/tag.d.ts +39 -0
  123. package/dist/components/tag/tag.js +41 -0
  124. package/dist/components/tag/tag.js.map +1 -0
  125. package/dist/components/text/text.d.ts +1 -2
  126. package/dist/components/text/text.js +2 -2
  127. package/dist/components/text/text.js.map +1 -1
  128. package/dist/components/textarea/textarea.d.ts +1 -2
  129. package/dist/components/textarea/textarea.js +2 -2
  130. package/dist/components/textarea/textarea.js.map +1 -1
  131. package/dist/components/tooltip/index.d.ts +1 -2
  132. package/dist/components/tooltip/tooltip.d.ts +3 -4
  133. package/dist/components/tooltip/tooltip.js +17 -6
  134. package/dist/components/tooltip/tooltip.js.map +1 -1
  135. package/dist/components/visually-hidden/visually-hidden.d.ts +1 -2
  136. package/dist/components/visually-hidden/visually-hidden.js +2 -2
  137. package/dist/components/visually-hidden/visually-hidden.js.map +1 -1
  138. package/dist/index.d.ts +7 -7
  139. package/dist/index.js +7 -7
  140. package/dist/provider/hui-provider.context.d.ts +23 -7
  141. package/dist/provider/hui-provider.context.js +13 -12
  142. package/dist/provider/hui-provider.context.js.map +1 -1
  143. package/dist/provider/hui-provider.d.ts +1 -2
  144. package/dist/provider/index.d.ts +1 -1
  145. package/dist/types/distributive.d.ts +1 -0
  146. package/dist/types/hui-component.d.ts +11 -5
  147. package/dist/types/index.d.ts +3 -2
  148. package/dist/types/polymorphic.d.ts +4 -9
  149. package/package.json +9 -9
  150. package/dist/components/dialog/dialog.context.d.ts +0 -2
  151. package/dist/components/drawer/drawer.context.d.ts +0 -2
  152. package/dist/components/menu/menu.context.d.ts +0 -2
  153. package/dist/components/popover/popover.context.d.ts +0 -2
  154. package/dist/components/tooltip/tooltip.context.d.ts +0 -2
@@ -1 +1 @@
1
- {"version":3,"file":"input.js","names":[],"sources":["../../../src/components/input/input.tsx"],"sourcesContent":["import { inputControl, inputRecipe, type InputSlots, type InputVariants, toBool, toStrbool } from \"@hebium-ui/core\";\nimport { type ComponentProps, type ReactElement, type ReactNode, useId } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps } from \"~/types\";\nimport { normalizeAttributes } from \"~/utils\";\nimport { Label, type LabelProps } from \"../label\";\n\ntype HtmlInputProps = Omit<ComponentProps<\"input\">, \"children\" | \"color\">;\n\ninterface InputOwnProps extends HtmlInputProps {\n /**\n * The semantic color of the input.\n *\n * @default \"accent\"\n */\n color?: InputVariants[\"color\"] | undefined;\n /**\n * The label displayed above the input.\n */\n label?: ReactNode | undefined;\n /**\n * Additional props passed to the internal label component.\n */\n labelProps?: LabelProps | undefined;\n /**\n * The help text displayed below the label.\n */\n description?: ReactNode | undefined;\n /**\n * The validation error message displayed below the label.\n */\n error?: ReactNode | undefined;\n}\n\nexport type InputProps = HuiComponentProps<\n InputOwnProps,\n InputSlots\n>;\n\nexport function Input(rawProps: InputProps): ReactElement {\n const tmpId = useId();\n const {\n id,\n color,\n label,\n description,\n error,\n labelProps,\n ...restProps\n } = useHuiProps(\"Input\", rawProps);\n\n const inputState = {\n id: id || tmpId,\n invalid: !!error,\n required: restProps.required ?? toBool(restProps[\"aria-required\"]),\n disabled: toBool(restProps.disabled) || toBool(restProps[\"aria-disabled\"]),\n readOnly: toBool(restProps.readOnly) || toBool(restProps[\"aria-readonly\"]),\n };\n const recipe = inputRecipe({\n color,\n error: toStrbool(inputState.invalid),\n });\n const cls = useHuiClassNames(\"Input\", recipe, rawProps.classNames);\n const sls = useHuiStyles(\"Input\", rawProps.styles);\n\n const hasLabel = !!label || !!description || !!error;\n const controlAttrs = normalizeAttributes(inputControl.getControlAttributes(inputState));\n const labelAttrs = normalizeAttributes(inputControl.getLabelAttributes(inputState));\n\n return (\n <div\n className={cls.root}\n style={sls.root}\n >\n {hasLabel\n && (\n <Label\n {...labelAttrs}\n description={description}\n error={error}\n {...labelProps}\n >\n {label}\n </Label>\n )}\n <input\n className={cls.input}\n style={sls.input}\n {...controlAttrs}\n {...restProps}\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;AAuCA,SAAgB,MAAM,UAAoC;CACxD,MAAM,QAAQ,MAAM;CACpB,MAAM,EACJ,IACA,OACA,OACA,aACA,OACA,YACA,GAAG,cACD,YAAY,SAAS,QAAQ;CAEjC,MAAM,aAAa;EACjB,IAAI,MAAM;EACV,SAAS,CAAC,CAAC;EACX,UAAU,UAAU,YAAY,OAAO,UAAU,gBAAgB;EACjE,UAAU,OAAO,UAAU,QAAQ,KAAK,OAAO,UAAU,gBAAgB;EACzE,UAAU,OAAO,UAAU,QAAQ,KAAK,OAAO,UAAU,gBAAgB;CAC3E;CACA,MAAM,SAAS,YAAY;EACzB;EACA,OAAO,UAAU,WAAW,OAAO;CACrC,CAAC;CACD,MAAM,MAAM,iBAAiB,SAAS,QAAQ,SAAS,UAAU;CACjE,MAAM,MAAM,aAAa,SAAS,SAAS,MAAM;CAEjD,MAAM,WAAW,CAAC,CAAC,SAAS,CAAC,CAAC,eAAe,CAAC,CAAC;CAC/C,MAAM,eAAe,oBAAoB,aAAa,qBAAqB,UAAU,CAAC;CACtF,MAAM,aAAa,oBAAoB,aAAa,mBAAmB,UAAU,CAAC;CAElF,OACE,qBAAC,OAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EAFb,UAAA,CAIG,YAEG,oBAAC,OAAD;GACE,GAAI;GACS;GACN;GACP,GAAI;GAEH,UAAA;EACI,CAAA,GAEX,oBAAC,SAAD;GACE,WAAW,IAAI;GACf,OAAO,IAAI;GACX,GAAI;GACJ,GAAI;EACL,CAAA,CACE;;AAET"}
1
+ {"version":3,"file":"input.js","names":[],"sources":["../../../src/components/input/input.tsx"],"sourcesContent":["import { inputControl, inputRecipe, type InputSlots, type InputVariants, toBool, toStrbool } from \"@hebium-ui/core\";\nimport { type ComponentProps, type ReactElement, type ReactNode, useId } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps } from \"~/types\";\nimport { normalizeAttributes } from \"~/utils\";\nimport { Label, type LabelProps } from \"../label\";\n\ntype HtmlInputProps = Omit<ComponentProps<\"input\">, \"children\" | \"color\">;\n\ninterface InputOwnProps extends HtmlInputProps {\n /**\n * The semantic color of the input.\n *\n * @default \"accent\"\n */\n color?: InputVariants[\"color\"] | undefined;\n /**\n * The label displayed above the input.\n */\n label?: ReactNode | undefined;\n /**\n * Additional props passed to the internal label component.\n */\n labelProps?: LabelProps | undefined;\n /**\n * The help text displayed below the label.\n */\n description?: ReactNode | undefined;\n /**\n * The validation error message displayed below the label.\n */\n error?: ReactNode | undefined;\n}\n\nexport type InputProps = HuiComponentProps<\n InputOwnProps,\n InputSlots\n>;\n\nexport function Input(rawProps: InputProps): ReactElement {\n const tmpId = useId();\n const {\n id,\n color,\n label,\n description,\n error,\n labelProps,\n ...restProps\n } = useHuiProps(\"Input\", rawProps);\n\n const inputState = {\n id: id || tmpId,\n invalid: !!error,\n required: restProps.required ?? toBool(restProps[\"aria-required\"]),\n disabled: toBool(restProps.disabled) || toBool(restProps[\"aria-disabled\"]),\n readOnly: toBool(restProps.readOnly) || toBool(restProps[\"aria-readonly\"]),\n };\n const recipe = inputRecipe({\n color,\n error: toStrbool(inputState.invalid),\n });\n const cls = useHuiClassNames(\"Input\", recipe, rawProps);\n const sls = useHuiStyles(\"Input\", rawProps);\n\n const hasLabel = !!label || !!description || !!error;\n const controlAttrs = normalizeAttributes(inputControl.getControlAttributes(inputState));\n const labelAttrs = normalizeAttributes(inputControl.getLabelAttributes(inputState));\n\n return (\n <div\n className={cls.root}\n style={sls.root}\n >\n {hasLabel\n && (\n <Label\n {...labelAttrs}\n description={description}\n error={error}\n {...labelProps}\n >\n {label}\n </Label>\n )}\n <input\n className={cls.input}\n style={sls.input}\n {...controlAttrs}\n {...restProps}\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;AAuCA,SAAgB,MAAM,UAAoC;CACxD,MAAM,QAAQ,MAAM;CACpB,MAAM,EACJ,IACA,OACA,OACA,aACA,OACA,YACA,GAAG,cACD,YAAY,SAAS,QAAQ;CAEjC,MAAM,aAAa;EACjB,IAAI,MAAM;EACV,SAAS,CAAC,CAAC;EACX,UAAU,UAAU,YAAY,OAAO,UAAU,gBAAgB;EACjE,UAAU,OAAO,UAAU,QAAQ,KAAK,OAAO,UAAU,gBAAgB;EACzE,UAAU,OAAO,UAAU,QAAQ,KAAK,OAAO,UAAU,gBAAgB;CAC3E;CACA,MAAM,SAAS,YAAY;EACzB;EACA,OAAO,UAAU,WAAW,OAAO;CACrC,CAAC;CACD,MAAM,MAAM,iBAAiB,SAAS,QAAQ,QAAQ;CACtD,MAAM,MAAM,aAAa,SAAS,QAAQ;CAE1C,MAAM,WAAW,CAAC,CAAC,SAAS,CAAC,CAAC,eAAe,CAAC,CAAC;CAC/C,MAAM,eAAe,oBAAoB,aAAa,qBAAqB,UAAU,CAAC;CACtF,MAAM,aAAa,oBAAoB,aAAa,mBAAmB,UAAU,CAAC;CAElF,OACE,qBAAC,OAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EAFb,UAAA,CAIG,YAEG,oBAAC,OAAD;GACE,GAAI;GACS;GACN;GACP,GAAI;GAEH,UAAA;EACI,CAAA,GAEX,oBAAC,SAAD;GACE,WAAW,IAAI;GACf,OAAO,IAAI;GACX,GAAI;GACJ,GAAI;EACL,CAAA,CACE;;AAET"}
@@ -26,5 +26,4 @@ interface LabelOwnProps {
26
26
  }
27
27
  export type LabelProps<E extends ElementType = "label"> = HuiPolymorphicProps<E, LabelOwnProps, LabelSlots>;
28
28
  export declare function Label<E extends ElementType = "label">(rawProps: LabelProps<E>): ReactElement;
29
- export {};
30
- //# sourceMappingURL=label.d.ts.map
29
+ export {};
@@ -9,8 +9,8 @@ function Label(rawProps) {
9
9
  marker: resolvedMarker.label ? resolvedMarker.variant : void 0,
10
10
  variant
11
11
  });
12
- const cls = useHuiClassNames("Label", recipe, rawProps.classNames);
13
- const sls = useHuiStyles("Label", rawProps.styles);
12
+ const cls = useHuiClassNames("Label", recipe, rawProps);
13
+ const sls = useHuiStyles("Label", rawProps);
14
14
  return /* @__PURE__ */ jsxs(as ?? "label", {
15
15
  className: cls.root,
16
16
  style: sls.root,
@@ -27,12 +27,12 @@ function Label(rawProps) {
27
27
  style: sls.fieldMarker,
28
28
  children: resolvedMarker.label
29
29
  }),
30
- description && /* @__PURE__ */ jsx("p", {
30
+ description && /* @__PURE__ */ jsx("span", {
31
31
  className: cls.description,
32
32
  style: sls.description,
33
33
  children: description
34
34
  }),
35
- error && /* @__PURE__ */ jsxs("p", {
35
+ error && /* @__PURE__ */ jsxs("span", {
36
36
  className: cls.error,
37
37
  style: sls.error,
38
38
  children: [/* @__PURE__ */ jsx("span", {
@@ -1 +1 @@
1
- {"version":3,"file":"label.js","names":[],"sources":["../../../src/components/label/label.tsx"],"sourcesContent":["import {\n DEFAULT_LABEL_MAKER,\n type LabelMarker,\n labelMarker,\n labelRecipe,\n type LabelSlots,\n type LabelVariants,\n toBool,\n} from \"@hebium-ui/core\";\nimport { type ElementType, type ReactElement, type ReactNode } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\n\ninterface LabelOwnProps {\n /**\n * The visual state of the label.\n */\n variant?: LabelVariants[\"variant\"] | undefined;\n /**\n * The marker displayed for required or optional fields. Use the `asterisk` variant for a highlighted asterisk marker.\n */\n marker?: LabelMarker<ReactNode> | undefined;\n /**\n * The help text displayed below the label.\n */\n description?: ReactNode | undefined;\n /**\n * The validation error message displayed below the label.\n */\n error?: ReactNode | undefined;\n /**\n * Whether the label should render the required marker.\n */\n \"data-required\"?: boolean | \"true\" | \"false\" | undefined;\n}\n\nexport type LabelProps<E extends ElementType = \"label\"> = HuiPolymorphicProps<\n E,\n LabelOwnProps,\n LabelSlots\n>;\n\nexport function Label<E extends ElementType = \"label\">(rawProps: LabelProps<E>): ReactElement {\n const {\n as,\n variant,\n children,\n marker,\n description,\n error,\n \"data-required\": dataRequired,\n ...restProps\n } = useHuiProps(\"Label\", rawProps);\n\n const resolvedMarker = labelMarker(marker ?? DEFAULT_LABEL_MAKER, toBool(dataRequired));\n const recipe = labelRecipe({\n marker: resolvedMarker.label ? resolvedMarker.variant : undefined,\n variant,\n });\n const cls = useHuiClassNames(\"Label\", recipe, rawProps.classNames);\n const sls = useHuiStyles(\"Label\", rawProps.styles);\n\n const Component = as ?? \"label\";\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...restProps}\n >\n {children && (\n <span\n className={cls.fieldName}\n style={sls.fieldName}\n >\n {children}\n </span>\n )}\n {resolvedMarker.label && (\n <span\n aria-label={resolvedMarker[\"aria-label\"]}\n className={cls.fieldMarker}\n style={sls.fieldMarker}\n >\n {resolvedMarker.label}\n </span>\n )}\n {description && (\n <p\n className={cls.description}\n style={sls.description}\n >\n {description}\n </p>\n )}\n {error && (\n <p\n className={cls.error}\n style={sls.error}\n >\n <span\n aria-hidden\n className={cls.errorIcon}\n style={sls.errorIcon}\n />\n <span\n className={cls.errorMessage}\n style={sls.errorMessage}\n >\n {error}\n </span>\n </p>\n )}\n </Component>\n );\n}\n"],"mappings":";;;;AA0CA,SAAgB,MAAuC,UAAuC;CAC5F,MAAM,EACJ,IACA,SACA,UACA,QACA,aACA,OACA,iBAAiB,cACjB,GAAG,cACD,YAAY,SAAS,QAAQ;CAEjC,MAAM,iBAAiB,YAAY,UAAU,qBAAqB,OAAO,YAAY,CAAC;CACtF,MAAM,SAAS,YAAY;EACzB,QAAQ,eAAe,QAAQ,eAAe,UAAU,KAAA;EACxD;CACF,CAAC;CACD,MAAM,MAAM,iBAAiB,SAAS,QAAQ,SAAS,UAAU;CACjE,MAAM,MAAM,aAAa,SAAS,SAAS,MAAM;CAGjD,OACE,qBAFgB,MAAM,SAEtB;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EAHN,UAAA;GAKG,YACC,oBAAC,QAAD;IACE,WAAW,IAAI;IACf,OAAO,IAAI;IAEV;GACG,CAAA;GAEP,eAAe,SACd,oBAAC,QAAD;IACE,cAAY,eAAe;IAC3B,WAAW,IAAI;IACf,OAAO,IAAI;IAEV,UAAA,eAAe;GACZ,CAAA;GAEP,eACC,oBAAC,KAAD;IACE,WAAW,IAAI;IACf,OAAO,IAAI;IAEV,UAAA;GACA,CAAA;GAEJ,SACC,qBAAC,KAAD;IACE,WAAW,IAAI;IACf,OAAO,IAAI;IAFb,UAAA,CAIE,oBAAC,QAAD;KACE,eAAA;KACA,WAAW,IAAI;KACf,OAAO,IAAI;IACZ,CAAA,GACD,oBAAC,QAAD;KACE,WAAW,IAAI;KACf,OAAO,IAAI;KAEV,UAAA;IACG,CAAA,CACL;;EAEI;;AAEf"}
1
+ {"version":3,"file":"label.js","names":[],"sources":["../../../src/components/label/label.tsx"],"sourcesContent":["import {\n DEFAULT_LABEL_MAKER,\n type LabelMarker,\n labelMarker,\n labelRecipe,\n type LabelSlots,\n type LabelVariants,\n toBool,\n} from \"@hebium-ui/core\";\nimport { type ElementType, type ReactElement, type ReactNode } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\n\ninterface LabelOwnProps {\n /**\n * The visual state of the label.\n */\n variant?: LabelVariants[\"variant\"] | undefined;\n /**\n * The marker displayed for required or optional fields. Use the `asterisk` variant for a highlighted asterisk marker.\n */\n marker?: LabelMarker<ReactNode> | undefined;\n /**\n * The help text displayed below the label.\n */\n description?: ReactNode | undefined;\n /**\n * The validation error message displayed below the label.\n */\n error?: ReactNode | undefined;\n /**\n * Whether the label should render the required marker.\n */\n \"data-required\"?: boolean | \"true\" | \"false\" | undefined;\n}\n\nexport type LabelProps<E extends ElementType = \"label\"> = HuiPolymorphicProps<\n E,\n LabelOwnProps,\n LabelSlots\n>;\n\nexport function Label<E extends ElementType = \"label\">(rawProps: LabelProps<E>): ReactElement {\n const {\n as,\n variant,\n children,\n marker,\n description,\n error,\n \"data-required\": dataRequired,\n ...restProps\n } = useHuiProps(\"Label\", rawProps);\n\n const resolvedMarker = labelMarker(marker ?? DEFAULT_LABEL_MAKER, toBool(dataRequired));\n const recipe = labelRecipe({\n marker: resolvedMarker.label ? resolvedMarker.variant : undefined,\n variant,\n });\n const cls = useHuiClassNames(\"Label\", recipe, rawProps);\n const sls = useHuiStyles(\"Label\", rawProps);\n\n const Component = as ?? \"label\";\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...restProps}\n >\n {children && (\n <span\n className={cls.fieldName}\n style={sls.fieldName}\n >\n {children}\n </span>\n )}\n {resolvedMarker.label && (\n <span\n aria-label={resolvedMarker[\"aria-label\"]}\n className={cls.fieldMarker}\n style={sls.fieldMarker}\n >\n {resolvedMarker.label}\n </span>\n )}\n {description && (\n <span\n className={cls.description}\n style={sls.description}\n >\n {description}\n </span>\n )}\n {error && (\n <span\n className={cls.error}\n style={sls.error}\n >\n <span\n aria-hidden\n className={cls.errorIcon}\n style={sls.errorIcon}\n />\n <span\n className={cls.errorMessage}\n style={sls.errorMessage}\n >\n {error}\n </span>\n </span>\n )}\n </Component>\n );\n}\n"],"mappings":";;;;AA0CA,SAAgB,MAAuC,UAAuC;CAC5F,MAAM,EACJ,IACA,SACA,UACA,QACA,aACA,OACA,iBAAiB,cACjB,GAAG,cACD,YAAY,SAAS,QAAQ;CAEjC,MAAM,iBAAiB,YAAY,UAAU,qBAAqB,OAAO,YAAY,CAAC;CACtF,MAAM,SAAS,YAAY;EACzB,QAAQ,eAAe,QAAQ,eAAe,UAAU,KAAA;EACxD;CACF,CAAC;CACD,MAAM,MAAM,iBAAiB,SAAS,QAAQ,QAAQ;CACtD,MAAM,MAAM,aAAa,SAAS,QAAQ;CAG1C,OACE,qBAFgB,MAAM,SAEtB;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EAHN,UAAA;GAKG,YACC,oBAAC,QAAD;IACE,WAAW,IAAI;IACf,OAAO,IAAI;IAEV;GACG,CAAA;GAEP,eAAe,SACd,oBAAC,QAAD;IACE,cAAY,eAAe;IAC3B,WAAW,IAAI;IACf,OAAO,IAAI;IAEV,UAAA,eAAe;GACZ,CAAA;GAEP,eACC,oBAAC,QAAD;IACE,WAAW,IAAI;IACf,OAAO,IAAI;IAEV,UAAA;GACG,CAAA;GAEP,SACC,qBAAC,QAAD;IACE,WAAW,IAAI;IACf,OAAO,IAAI;IAFb,UAAA,CAIE,oBAAC,QAAD;KACE,eAAA;KACA,WAAW,IAAI;KACf,OAAO,IAAI;IACZ,CAAA,GACD,oBAAC,QAAD;KACE,WAAW,IAAI;KACf,OAAO,IAAI;KAEV,UAAA;IACG,CAAA,CACF;;EAEC;;AAEf"}
@@ -1,3 +1,2 @@
1
1
  import { Menu, MenuContentProps, MenuItemProps, MenuProps, MenuTriggerProps } from "./menu.js";
2
- import { useMenuId } from "./menu.context.js";
3
- export { Menu, MenuContentProps, MenuItemProps, MenuProps, MenuTriggerProps, useMenuId };
2
+ export { Menu, MenuContentProps, MenuItemProps, MenuProps, MenuTriggerProps };
@@ -12,8 +12,8 @@ export interface MenuProps {
12
12
  children?: ReactNode | undefined;
13
13
  }
14
14
  declare function MenuRoot(rawProps: MenuProps): ReactElement;
15
- export type MenuTriggerProps<E extends ElementType = typeof Button> = HuiPolymorphicProps<E, {}, ButtonSlots>;
16
- declare function Trigger<E extends ElementType = typeof Button>(rawProps: MenuTriggerProps<E>): ReactNode;
15
+ export type MenuTriggerProps<E extends ElementType = typeof Button<"button">> = HuiPolymorphicProps<E, {}, ButtonSlots>;
16
+ declare function Trigger<E extends ElementType = typeof Button<"button">>(rawProps: MenuTriggerProps<E>): ReactNode;
17
17
  interface MenuContentOwnProps {
18
18
  /**
19
19
  * The preferred anchor position of the menu.
@@ -76,5 +76,4 @@ export declare const Menu: typeof MenuRoot & {
76
76
  Content: typeof Content;
77
77
  Item: typeof Item;
78
78
  };
79
- export {};
80
- //# sourceMappingURL=menu.d.ts.map
79
+ export {};
@@ -1,11 +1,17 @@
1
1
  import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
2
- import { Button } from "../button/button.js";
3
2
  import { normalizeAttributes } from "../../utils/attributes/normalize-attributes.js";
3
+ import { Button } from "../button/button.js";
4
4
  import { MenuContext, useMenuId } from "./menu.context.js";
5
5
  import { menuControl, menuitemRecipe, popoverRecipe, toBool } from "@hebium-ui/core";
6
6
  import { useCallback, useId, useMemo } from "react";
7
7
  import { jsx } from "react/jsx-runtime";
8
8
  // src/components/menu/menu.tsx
9
+ const BUTTON_CLASSES = {
10
+ root: "",
11
+ content: "",
12
+ spinner: "",
13
+ status: ""
14
+ };
9
15
  function MenuRoot(rawProps) {
10
16
  const { id, children } = useHuiProps("Menu", rawProps);
11
17
  const tmpId = useId();
@@ -21,8 +27,8 @@ function MenuRoot(rawProps) {
21
27
  function Trigger(rawProps) {
22
28
  const { as, onKeyDown, children, ...restProps } = useHuiProps("MenuTrigger", rawProps);
23
29
  const Component = as ?? Button;
24
- const cls = useHuiClassNames("MenuTrigger", { root: "" }, { root: rawProps["className"] });
25
- const sls = useHuiStyles("MenuTrigger", { root: rawProps["style"] });
30
+ const cls = useHuiClassNames("MenuTrigger", BUTTON_CLASSES, rawProps);
31
+ const sls = useHuiStyles("MenuTrigger", rawProps);
26
32
  const menuId = useMenuId();
27
33
  const attrs = normalizeAttributes(menuControl.getTriggerAttributes({ menuId }, { isButtonElement: as === void 0 }));
28
34
  const handleKeyDown = useCallback((e) => {
@@ -32,8 +38,13 @@ function Trigger(rawProps) {
32
38
  }, [onKeyDown, menuId]);
33
39
  return /* @__PURE__ */ jsx(Component, {
34
40
  ...attrs,
35
- className: cls.root,
36
- style: sls.root,
41
+ ...Component === Button ? {
42
+ classNames: cls,
43
+ styles: sls
44
+ } : {
45
+ className: cls.root,
46
+ style: sls.root
47
+ },
37
48
  onKeyDown: handleKeyDown,
38
49
  ...restProps,
39
50
  children
@@ -49,8 +60,8 @@ function Content(rawProps) {
49
60
  visibility,
50
61
  padding: padding ?? "sm"
51
62
  });
52
- const cls = useHuiClassNames("MenuContent", recipe, { root: rawProps["className"] });
53
- const sls = useHuiStyles("MenuContent", { root: rawProps["style"] });
63
+ const cls = useHuiClassNames("MenuContent", recipe, rawProps);
64
+ const sls = useHuiStyles("MenuContent", rawProps);
54
65
  const attrs = normalizeAttributes(menuControl.getContentAttributes({ menuId }, {
55
66
  ariaLabel,
56
67
  ariaLabelledBy
@@ -69,8 +80,8 @@ function Item(rawProps) {
69
80
  const menuId = useMenuId();
70
81
  const isDisabled = toBool(ariaDisabled);
71
82
  const recipe = menuitemRecipe({ color });
72
- const cls = useHuiClassNames("MenuItem", recipe, { root: rawProps["className"] });
73
- const sls = useHuiStyles("MenuItem", { root: rawProps["style"] });
83
+ const cls = useHuiClassNames("MenuItem", recipe, rawProps);
84
+ const sls = useHuiStyles("MenuItem", rawProps);
74
85
  const attrs = normalizeAttributes(menuControl.getItemAttributes({ menuId }, {
75
86
  focusKey,
76
87
  disabled: ariaDisabled == null ? void 0 : isDisabled
@@ -1 +1 @@
1
- {"version":3,"file":"menu.js","names":[],"sources":["../../../src/components/menu/menu.tsx"],"sourcesContent":["import {\n type ButtonSlots,\n menuControl,\n type MenuItemActivation,\n menuitemRecipe,\n type MenuitemSlots,\n type MenuitemVariants,\n popoverRecipe,\n type PopoverSlots,\n type PopoverVariants,\n toBool,\n} from \"@hebium-ui/core\";\nimport {\n type ElementType,\n type KeyboardEvent,\n type MouseEvent,\n type ReactElement,\n type ReactNode,\n useCallback,\n useId,\n useMemo,\n} from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\nimport { normalizeAttributes } from \"~/utils\";\nimport { Button } from \"../button\";\nimport { MenuContext, type MenuContextValue, useMenuId } from \"./menu.context\";\n\nexport interface MenuProps {\n /**\n * The id of the menu content element.\n */\n id?: string | undefined;\n children?: ReactNode | undefined;\n}\n\nfunction MenuRoot(rawProps: MenuProps): ReactElement {\n const {\n id,\n children,\n } = useHuiProps(\"Menu\", rawProps);\n\n const tmpId = useId();\n const menuId = id || tmpId;\n\n const contextValue = useMemo<MenuContextValue>(() => {\n return {\n menuId,\n };\n }, [menuId]);\n\n return (\n <MenuContext.Provider\n value={contextValue}\n >\n {children}\n </MenuContext.Provider>\n );\n}\n\nexport type MenuTriggerProps<E extends ElementType = typeof Button> = HuiPolymorphicProps<\n E,\n {},\n ButtonSlots\n>;\n\nfunction Trigger<E extends ElementType = typeof Button>(rawProps: MenuTriggerProps<E>): ReactNode {\n const {\n as,\n onKeyDown,\n children,\n ...restProps\n } = useHuiProps(\"MenuTrigger\", rawProps);\n\n const Component = as ?? Button;\n const cls = useHuiClassNames(\"MenuTrigger\", { root: \"\" }, { root: rawProps[\"className\"] });\n const sls = useHuiStyles(\"MenuTrigger\", { root: rawProps[\"style\"] });\n const menuId = useMenuId();\n const attrs = normalizeAttributes(\n menuControl.getTriggerAttributes(\n { menuId },\n { isButtonElement: as === undefined },\n ),\n );\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent<HTMLElement>): void => {\n onKeyDown?.(e);\n if (e.defaultPrevented) return;\n\n menuControl.handleMenuTriggerKeydown(e.nativeEvent, menuId);\n },\n [onKeyDown, menuId],\n );\n\n return (\n <Component\n {...attrs}\n className={cls.root}\n style={sls.root}\n onKeyDown={handleKeyDown}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n\ninterface MenuContentOwnProps {\n /**\n * The preferred anchor position of the menu.\n *\n * @default \"block-start\"\n */\n position?: PopoverVariants[\"position\"] | undefined;\n /**\n * The fallback strategy used when the preferred position overflows.\n *\n * @default \"flip\"\n */\n fallbacks?: PopoverVariants[\"fallbacks\"] | undefined;\n /**\n * The visibility behavior when the anchor is off-screen or overflows.\n *\n * @default \"anchors-visible\"\n * @see This setting depends on browser support for {@link https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/position-visibility | MDN: position-visibility}.\n */\n visibility?: PopoverVariants[\"visibility\"] | undefined;\n /**\n * The padding size of the menu content.\n *\n * @default \"sm\"\n */\n padding?: PopoverVariants[\"padding\"] | undefined;\n}\nexport type MenuContentProps<E extends ElementType = \"div\"> = HuiPolymorphicProps<\n E,\n MenuContentOwnProps,\n PopoverSlots\n>;\n\nfunction Content<E extends ElementType = \"div\">(rawProps: MenuContentProps<E>): ReactElement {\n const {\n as,\n position,\n fallbacks,\n visibility,\n padding,\n children,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n ...restProps\n } = useHuiProps(\"MenuContent\", rawProps);\n\n const Component = as ?? \"div\";\n\n const menuId = useMenuId();\n const recipe = popoverRecipe({\n position,\n fallbacks,\n visibility,\n padding: padding ?? \"sm\",\n });\n const cls = useHuiClassNames(\"MenuContent\", recipe, { root: rawProps[\"className\"] });\n const sls = useHuiStyles(\"MenuContent\", { root: rawProps[\"style\"] });\n const attrs = normalizeAttributes(\n menuControl.getContentAttributes(\n { menuId },\n { ariaLabel, ariaLabelledBy },\n ),\n );\n\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...attrs}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n\ninterface MenuItemOwnProps {\n /**\n * The semantic color of the menu item.\n *\n * @default \"neutral\"\n */\n color?: MenuitemVariants[\"color\"] | undefined;\n /**\n * A printable character used for key navigation within the menu.\n * When the user types a matching key, focus moves to this item.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/menuitem_role#any_key_that_corresponds_to_a_printable_character_optional | MDN: Keyboard interactions for the menuitem role}\n */\n focusKey?: string | undefined;\n /**\n * Controls the menu item's native action.\n * Managed activation prevents it; native activation allows it.\n *\n * @default \"managed\"\n */\n activation?: MenuItemActivation | undefined;\n /**\n * Called when the menu item is activated by click or keyboard.\n */\n onAction?: (() => void) | undefined;\n}\nexport type MenuItemProps<E extends ElementType = \"div\"> = HuiPolymorphicProps<\n E,\n MenuItemOwnProps,\n Exclude<MenuitemSlots, \"disabled\">\n>;\n\nfunction Item<E extends ElementType = \"div\">(rawProps: MenuItemProps<E>): ReactElement {\n const {\n as,\n color,\n focusKey,\n activation = \"managed\",\n onClick,\n onAction,\n onKeyDown,\n children,\n \"aria-disabled\": ariaDisabled,\n ...restProps\n } = useHuiProps(\"MenuItem\", rawProps);\n\n const Component = as ?? \"div\";\n\n const menuId = useMenuId();\n const isDisabled = toBool(ariaDisabled);\n const recipe = menuitemRecipe({\n color,\n });\n const cls = useHuiClassNames(\"MenuItem\", recipe, { root: rawProps[\"className\"] });\n const sls = useHuiStyles(\"MenuItem\", { root: rawProps[\"style\"] });\n const attrs = normalizeAttributes(\n menuControl.getItemAttributes(\n { menuId },\n {\n focusKey,\n disabled: ariaDisabled == null ? undefined : isDisabled,\n },\n ),\n );\n\n const handleClick = useCallback((e: MouseEvent<HTMLElement>) => {\n onClick?.(e);\n menuControl.handleMenuitemActivation(e.nativeEvent, menuId, { activation, disabled: isDisabled }, onAction);\n }, [activation, isDisabled, menuId, onClick, onAction]);\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent<HTMLElement>): void => {\n onKeyDown?.(e);\n if (e.defaultPrevented) return;\n\n const action = menuControl.handleMenuitemKeydown(e.nativeEvent, activation);\n switch (action) {\n case \"action\":\n menuControl.handleMenuitemActivation(e.nativeEvent, menuId, { activation, disabled: isDisabled }, onAction);\n return;\n case \"focus-move\":\n menuControl.moveMenuitemFocus(e.nativeEvent, menuId);\n return;\n case \"focus-set\":\n menuControl.setMenuitemFocus(e.nativeEvent, menuId);\n return;\n case \"focus-out\":\n menuControl.hideMenu(menuId);\n return;\n case \"none\":\n return;\n }\n },\n [\n onKeyDown,\n activation,\n onAction,\n menuId,\n isDisabled,\n ],\n );\n\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...attrs}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n\nexport const Menu = Object.assign(MenuRoot, {\n Trigger,\n Content,\n Item,\n});\n"],"mappings":";;;;;;;;AAoCA,SAAS,SAAS,UAAmC;CACnD,MAAM,EACJ,IACA,aACE,YAAY,QAAQ,QAAQ;CAEhC,MAAM,QAAQ,MAAM;CACpB,MAAM,SAAS,MAAM;CAErB,MAAM,eAAe,cAAgC;EACnD,OAAO,EACL,OACF;CACF,GAAG,CAAC,MAAM,CAAC;CAEX,OACE,oBAAC,YAAY,UAAb;EACE,OAAO;EAEN;CACmB,CAAA;AAE1B;AAQA,SAAS,QAA+C,UAA0C;CAChG,MAAM,EACJ,IACA,WACA,UACA,GAAG,cACD,YAAY,eAAe,QAAQ;CAEvC,MAAM,YAAY,MAAM;CACxB,MAAM,MAAM,iBAAiB,eAAe,EAAE,MAAM,GAAG,GAAG,EAAE,MAAM,SAAS,aAAa,CAAC;CACzF,MAAM,MAAM,aAAa,eAAe,EAAE,MAAM,SAAS,SAAS,CAAC;CACnE,MAAM,SAAS,UAAU;CACzB,MAAM,QAAQ,oBACZ,YAAY,qBACV,EAAE,OAAO,GACT,EAAE,iBAAiB,OAAO,KAAA,EAAU,CACtC,CACF;CAEA,MAAM,gBAAgB,aACnB,MAAwC;EACvC,YAAY,CAAC;EACb,IAAI,EAAE,kBAAkB;EAExB,YAAY,yBAAyB,EAAE,aAAa,MAAM;CAC5D,GACA,CAAC,WAAW,MAAM,CACpB;CAEA,OACE,oBAAC,WAAD;EACE,GAAI;EACJ,WAAW,IAAI;EACf,OAAO,IAAI;EACX,WAAW;EACX,GAAI;EAEH;CACQ,CAAA;AAEf;AAmCA,SAAS,QAAuC,UAA6C;CAC3F,MAAM,EACJ,IACA,UACA,WACA,YACA,SACA,UACA,cAAc,WACd,mBAAmB,gBACnB,GAAG,cACD,YAAY,eAAe,QAAQ;CAEvC,MAAM,YAAY,MAAM;CAExB,MAAM,SAAS,UAAU;CACzB,MAAM,SAAS,cAAc;EAC3B;EACA;EACA;EACA,SAAS,WAAW;CACtB,CAAC;CACD,MAAM,MAAM,iBAAiB,eAAe,QAAQ,EAAE,MAAM,SAAS,aAAa,CAAC;CACnF,MAAM,MAAM,aAAa,eAAe,EAAE,MAAM,SAAS,SAAS,CAAC;CACnE,MAAM,QAAQ,oBACZ,YAAY,qBACV,EAAE,OAAO,GACT;EAAE;EAAW;CAAe,CAC9B,CACF;CAEA,OACE,oBAAC,WAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EACJ,GAAI;EAEH;CACQ,CAAA;AAEf;AAkCA,SAAS,KAAoC,UAA0C;CACrF,MAAM,EACJ,IACA,OACA,UACA,aAAa,WACb,SACA,UACA,WACA,UACA,iBAAiB,cACjB,GAAG,cACD,YAAY,YAAY,QAAQ;CAEpC,MAAM,YAAY,MAAM;CAExB,MAAM,SAAS,UAAU;CACzB,MAAM,aAAa,OAAO,YAAY;CACtC,MAAM,SAAS,eAAe,EAC5B,MACF,CAAC;CACD,MAAM,MAAM,iBAAiB,YAAY,QAAQ,EAAE,MAAM,SAAS,aAAa,CAAC;CAChF,MAAM,MAAM,aAAa,YAAY,EAAE,MAAM,SAAS,SAAS,CAAC;CAChE,MAAM,QAAQ,oBACZ,YAAY,kBACV,EAAE,OAAO,GACT;EACE;EACA,UAAU,gBAAgB,OAAO,KAAA,IAAY;CAC/C,CACF,CACF;CAEA,MAAM,cAAc,aAAa,MAA+B;EAC9D,UAAU,CAAC;EACX,YAAY,yBAAyB,EAAE,aAAa,QAAQ;GAAE;GAAY,UAAU;EAAW,GAAG,QAAQ;CAC5G,GAAG;EAAC;EAAY;EAAY;EAAQ;EAAS;CAAQ,CAAC;CAEtD,MAAM,gBAAgB,aACnB,MAAwC;EACvC,YAAY,CAAC;EACb,IAAI,EAAE,kBAAkB;EAGxB,QADe,YAAY,sBAAsB,EAAE,aAAa,UACnD,GAAb;GACE,KAAK;IACH,YAAY,yBAAyB,EAAE,aAAa,QAAQ;KAAE;KAAY,UAAU;IAAW,GAAG,QAAQ;IAC1G;GACF,KAAK;IACH,YAAY,kBAAkB,EAAE,aAAa,MAAM;IACnD;GACF,KAAK;IACH,YAAY,iBAAiB,EAAE,aAAa,MAAM;IAClD;GACF,KAAK;IACH,YAAY,SAAS,MAAM;IAC3B;GACF,KAAK,QACH;EACJ;CACF,GACA;EACE;EACA;EACA;EACA;EACA;CACF,CACF;CAEA,OACE,oBAAC,WAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EACJ,SAAS;EACT,WAAW;EACX,GAAI;EAEH;CACQ,CAAA;AAEf;AAEA,MAAa,OAAO,OAAO,OAAO,UAAU;CAC1C;CACA;CACA;AACF,CAAC"}
1
+ {"version":3,"file":"menu.js","names":[],"sources":["../../../src/components/menu/menu.tsx"],"sourcesContent":["import {\n type ButtonSlots,\n menuControl,\n type MenuItemActivation,\n menuitemRecipe,\n type MenuitemSlots,\n type MenuitemVariants,\n popoverRecipe,\n type PopoverSlots,\n type PopoverVariants,\n toBool,\n} from \"@hebium-ui/core\";\nimport {\n type ElementType,\n type KeyboardEvent,\n type MouseEvent,\n type ReactElement,\n type ReactNode,\n useCallback,\n useId,\n useMemo,\n} from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\nimport { normalizeAttributes } from \"~/utils\";\nimport { Button } from \"../button\";\nimport { MenuContext, type MenuContextValue, useMenuId } from \"./menu.context\";\n\nconst BUTTON_CLASSES = { root: \"\", content: \"\", spinner: \"\", status: \"\" } satisfies Record<ButtonSlots, string>;\n\nexport interface MenuProps {\n /**\n * The id of the menu content element.\n */\n id?: string | undefined;\n children?: ReactNode | undefined;\n}\n\nfunction MenuRoot(rawProps: MenuProps): ReactElement {\n const {\n id,\n children,\n } = useHuiProps(\"Menu\", rawProps);\n\n const tmpId = useId();\n const menuId = id || tmpId;\n\n const contextValue = useMemo<MenuContextValue>(() => {\n return {\n menuId,\n };\n }, [menuId]);\n\n return (\n <MenuContext.Provider\n value={contextValue}\n >\n {children}\n </MenuContext.Provider>\n );\n}\n\nexport type MenuTriggerProps<E extends ElementType = typeof Button<\"button\">> = HuiPolymorphicProps<\n E,\n {},\n ButtonSlots\n>;\n\nfunction Trigger<E extends ElementType = typeof Button<\"button\">>(rawProps: MenuTriggerProps<E>): ReactNode {\n const {\n as,\n onKeyDown,\n children,\n ...restProps\n } = useHuiProps(\"MenuTrigger\", rawProps);\n\n const Component = as ?? Button;\n const cls = useHuiClassNames(\"MenuTrigger\", BUTTON_CLASSES, rawProps);\n const sls = useHuiStyles(\"MenuTrigger\", rawProps);\n const menuId = useMenuId();\n const attrs = normalizeAttributes(\n menuControl.getTriggerAttributes(\n { menuId },\n { isButtonElement: as === undefined },\n ),\n );\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent<HTMLElement>): void => {\n onKeyDown?.(e);\n if (e.defaultPrevented) return;\n\n menuControl.handleMenuTriggerKeydown(e.nativeEvent, menuId);\n },\n [onKeyDown, menuId],\n );\n\n return (\n <Component\n {...attrs}\n {...(Component === Button\n ? { classNames: cls, styles: sls }\n : { className: cls.root, style: sls.root })}\n onKeyDown={handleKeyDown}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n\ninterface MenuContentOwnProps {\n /**\n * The preferred anchor position of the menu.\n *\n * @default \"block-start\"\n */\n position?: PopoverVariants[\"position\"] | undefined;\n /**\n * The fallback strategy used when the preferred position overflows.\n *\n * @default \"flip\"\n */\n fallbacks?: PopoverVariants[\"fallbacks\"] | undefined;\n /**\n * The visibility behavior when the anchor is off-screen or overflows.\n *\n * @default \"anchors-visible\"\n * @see This setting depends on browser support for {@link https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/position-visibility | MDN: position-visibility}.\n */\n visibility?: PopoverVariants[\"visibility\"] | undefined;\n /**\n * The padding size of the menu content.\n *\n * @default \"sm\"\n */\n padding?: PopoverVariants[\"padding\"] | undefined;\n}\nexport type MenuContentProps<E extends ElementType = \"div\"> = HuiPolymorphicProps<\n E,\n MenuContentOwnProps,\n PopoverSlots\n>;\n\nfunction Content<E extends ElementType = \"div\">(rawProps: MenuContentProps<E>): ReactElement {\n const {\n as,\n position,\n fallbacks,\n visibility,\n padding,\n children,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n ...restProps\n } = useHuiProps(\"MenuContent\", rawProps);\n\n const Component = as ?? \"div\";\n\n const menuId = useMenuId();\n const recipe = popoverRecipe({\n position,\n fallbacks,\n visibility,\n padding: padding ?? \"sm\",\n });\n const cls = useHuiClassNames(\"MenuContent\", recipe, rawProps);\n const sls = useHuiStyles(\"MenuContent\", rawProps);\n const attrs = normalizeAttributes(\n menuControl.getContentAttributes(\n { menuId },\n { ariaLabel, ariaLabelledBy },\n ),\n );\n\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...attrs}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n\ninterface MenuItemOwnProps {\n /**\n * The semantic color of the menu item.\n *\n * @default \"neutral\"\n */\n color?: MenuitemVariants[\"color\"] | undefined;\n /**\n * A printable character used for key navigation within the menu.\n * When the user types a matching key, focus moves to this item.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/menuitem_role#any_key_that_corresponds_to_a_printable_character_optional | MDN: Keyboard interactions for the menuitem role}\n */\n focusKey?: string | undefined;\n /**\n * Controls the menu item's native action.\n * Managed activation prevents it; native activation allows it.\n *\n * @default \"managed\"\n */\n activation?: MenuItemActivation | undefined;\n /**\n * Called when the menu item is activated by click or keyboard.\n */\n onAction?: (() => void) | undefined;\n}\nexport type MenuItemProps<E extends ElementType = \"div\"> = HuiPolymorphicProps<\n E,\n MenuItemOwnProps,\n Exclude<MenuitemSlots, \"disabled\">\n>;\n\nfunction Item<E extends ElementType = \"div\">(rawProps: MenuItemProps<E>): ReactElement {\n const {\n as,\n color,\n focusKey,\n activation = \"managed\",\n onClick,\n onAction,\n onKeyDown,\n children,\n \"aria-disabled\": ariaDisabled,\n ...restProps\n } = useHuiProps(\"MenuItem\", rawProps);\n\n const Component = as ?? \"div\";\n\n const menuId = useMenuId();\n const isDisabled = toBool(ariaDisabled);\n const recipe = menuitemRecipe({\n color,\n });\n const cls = useHuiClassNames(\"MenuItem\", recipe, rawProps);\n const sls = useHuiStyles(\"MenuItem\", rawProps);\n const attrs = normalizeAttributes(\n menuControl.getItemAttributes(\n { menuId },\n {\n focusKey,\n disabled: ariaDisabled == null ? undefined : isDisabled,\n },\n ),\n );\n\n const handleClick = useCallback((e: MouseEvent<HTMLElement>) => {\n onClick?.(e);\n menuControl.handleMenuitemActivation(e.nativeEvent, menuId, { activation, disabled: isDisabled }, onAction);\n }, [activation, isDisabled, menuId, onClick, onAction]);\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent<HTMLElement>): void => {\n onKeyDown?.(e);\n if (e.defaultPrevented) return;\n\n const action = menuControl.handleMenuitemKeydown(e.nativeEvent, activation);\n switch (action) {\n case \"action\":\n menuControl.handleMenuitemActivation(e.nativeEvent, menuId, { activation, disabled: isDisabled }, onAction);\n return;\n case \"focus-move\":\n menuControl.moveMenuitemFocus(e.nativeEvent, menuId);\n return;\n case \"focus-set\":\n menuControl.setMenuitemFocus(e.nativeEvent, menuId);\n return;\n case \"focus-out\":\n menuControl.hideMenu(menuId);\n return;\n case \"none\":\n return;\n }\n },\n [\n onKeyDown,\n activation,\n onAction,\n menuId,\n isDisabled,\n ],\n );\n\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...attrs}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n\nexport const Menu = Object.assign(MenuRoot, {\n Trigger,\n Content,\n Item,\n});\n"],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ import { MultiCombobox, MultiComboboxFormValueProps, MultiComboboxItemState, MultiComboboxProps, MultiComboboxTagContext, MultiComboboxTagProps } from "./multi-combobox.js";
2
+ export { MultiCombobox, type MultiComboboxFormValueProps, type MultiComboboxItemState, MultiComboboxProps, MultiComboboxTagContext, MultiComboboxTagProps };
@@ -0,0 +1,42 @@
1
+ import { cc, getComboboxOptionText, multiComboboxControl, toStrbool } from "@hebium-ui/core";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ // src/components/multi-combobox/multi-combobox-option.tsx
4
+ function getOptionProps({ option, id, className, style, itemProps, toggle }, state) {
5
+ const props = itemProps?.(option, state) ?? {};
6
+ return {
7
+ ...multiComboboxControl.getItemAttributes(id, state, !!option.disabled),
8
+ ...props,
9
+ className: cc(className, props.className),
10
+ style: {
11
+ ...style,
12
+ ...props.style
13
+ },
14
+ onMouseDown: (event) => {
15
+ props.onMouseDown?.(event);
16
+ if (!event.defaultPrevented && event.button === 0) event.preventDefault();
17
+ },
18
+ onClick: (event) => {
19
+ props.onClick?.(event);
20
+ if (!event.defaultPrevented) toggle(option.value);
21
+ }
22
+ };
23
+ }
24
+ function MultiComboboxOption(props) {
25
+ const { option, mode, selected, active, renderItem, indicatorClassName, indicatorStyle } = props;
26
+ const state = {
27
+ selected,
28
+ active
29
+ };
30
+ return /* @__PURE__ */ jsx("div", {
31
+ ...getOptionProps(props, state),
32
+ children: renderItem ? renderItem(option, state) : /* @__PURE__ */ jsxs(Fragment, { children: [getComboboxOptionText(mode, option), /* @__PURE__ */ jsx("span", {
33
+ "aria-hidden": true,
34
+ "data-selected": toStrbool(state.selected),
35
+ className: indicatorClassName,
36
+ style: indicatorStyle
37
+ })] })
38
+ });
39
+ }
40
+ export { MultiComboboxOption };
41
+
42
+ //# sourceMappingURL=multi-combobox-option.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multi-combobox-option.js","names":[],"sources":["../../../src/components/multi-combobox/multi-combobox-option.tsx"],"sourcesContent":["import {\n cc,\n type ComboboxMode,\n type ComboboxSelectOption,\n getComboboxOptionText,\n multiComboboxControl,\n type MultiComboboxItemState,\n toStrbool,\n} from \"@hebium-ui/core\";\nimport { type ComponentProps, type CSSProperties, type ReactElement, type ReactNode } from \"react\";\n\ntype NativeOptionProps = Omit<ComponentProps<\"div\">, \"children\">;\n\ninterface MultiComboboxOptionProps<O extends ComboboxSelectOption> {\n option: O;\n id: string;\n mode: ComboboxMode;\n selected: boolean;\n active: boolean;\n className: string;\n style: CSSProperties | undefined;\n indicatorClassName: string;\n indicatorStyle: CSSProperties | undefined;\n itemProps: ((option: O, state: MultiComboboxItemState) => NativeOptionProps) | undefined;\n renderItem: ((option: O, state: MultiComboboxItemState) => ReactNode) | undefined;\n toggle: (value: string) => void;\n}\n\nfunction getOptionProps<O extends ComboboxSelectOption>({\n option,\n id,\n className,\n style,\n itemProps,\n toggle,\n}: MultiComboboxOptionProps<O>, state: MultiComboboxItemState): NativeOptionProps {\n const props = itemProps?.(option, state) ?? {};\n return {\n ...multiComboboxControl.getItemAttributes(id, state, !!option.disabled),\n ...props,\n className: cc(className, props.className),\n style: { ...style, ...props.style },\n onMouseDown: (event): void => {\n props.onMouseDown?.(event);\n if (!event.defaultPrevented && event.button === 0) event.preventDefault();\n },\n onClick: (event): void => {\n props.onClick?.(event);\n if (!event.defaultPrevented) toggle(option.value);\n },\n };\n}\n\nexport function MultiComboboxOption<O extends ComboboxSelectOption>(props: MultiComboboxOptionProps<O>): ReactElement {\n const {\n option,\n mode,\n selected,\n active,\n renderItem,\n indicatorClassName,\n indicatorStyle,\n } = props;\n const state = { selected, active };\n return (\n <div {...getOptionProps(props, state)}>\n {renderItem\n ? renderItem(option, state)\n : (\n <>\n {getComboboxOptionText(mode, option)}\n <span\n aria-hidden\n data-selected={toStrbool(state.selected)}\n className={indicatorClassName}\n style={indicatorStyle}\n />\n </>\n )}\n </div>\n );\n}\n"],"mappings":";;;AA4BA,SAAS,eAA+C,EACtD,QACA,IACA,WACA,OACA,WACA,UAC8B,OAAkD;CAChF,MAAM,QAAQ,YAAY,QAAQ,KAAK,KAAK,CAAC;CAC7C,OAAO;EACL,GAAG,qBAAqB,kBAAkB,IAAI,OAAO,CAAC,CAAC,OAAO,QAAQ;EACtE,GAAG;EACH,WAAW,GAAG,WAAW,MAAM,SAAS;EACxC,OAAO;GAAE,GAAG;GAAO,GAAG,MAAM;EAAM;EAClC,cAAc,UAAgB;GAC5B,MAAM,cAAc,KAAK;GACzB,IAAI,CAAC,MAAM,oBAAoB,MAAM,WAAW,GAAG,MAAM,eAAe;EAC1E;EACA,UAAU,UAAgB;GACxB,MAAM,UAAU,KAAK;GACrB,IAAI,CAAC,MAAM,kBAAkB,OAAO,OAAO,KAAK;EAClD;CACF;AACF;AAEA,SAAgB,oBAAoD,OAAkD;CACpH,MAAM,EACJ,QACA,MACA,UACA,QACA,YACA,oBACA,mBACE;CACJ,MAAM,QAAQ;EAAE;EAAU;CAAO;CACjC,OACE,oBAAC,OAAD;EAAK,GAAI,eAAe,OAAO,KAAK;EACjC,UAAA,aACG,WAAW,QAAQ,KAAK,IAExB,qBAAA,UAAA,EAAA,UAAA,CACG,sBAAsB,MAAM,MAAM,GACnC,oBAAC,QAAD;GACE,eAAA;GACA,iBAAe,UAAU,MAAM,QAAQ;GACvC,WAAW;GACX,OAAO;EACR,CAAA,CACD,EAAA,CAAA;CAEH,CAAA;AAET"}
@@ -0,0 +1,54 @@
1
+ import { Tag } from "../tag/tag.js";
2
+ import { multiComboboxControl } from "@hebium-ui/core";
3
+ import { useCallback, useMemo } from "react";
4
+ import { jsx } from "react/jsx-runtime";
5
+ // src/components/multi-combobox/multi-combobox-tag.tsx
6
+ const EMPTY_BUTTON_PROPS = {};
7
+ function MultiComboboxTag({ value, label, option, tagProps, disabled, remove }) {
8
+ const props = tagProps?.({
9
+ value,
10
+ label,
11
+ option
12
+ }) ?? {};
13
+ const buttonProps = props.removeButtonProps ?? EMPTY_BUTTON_PROPS;
14
+ const onClick = buttonProps.onClick;
15
+ const handleClick = useCallback((event) => {
16
+ onClick?.(event);
17
+ if (!event.defaultPrevented) remove(value, event.currentTarget);
18
+ }, [
19
+ onClick,
20
+ remove,
21
+ value
22
+ ]);
23
+ const onKeyDown = buttonProps.onKeyDown;
24
+ const handleKeyDown = useCallback((event) => {
25
+ onKeyDown?.(event);
26
+ if (event.defaultPrevented) return;
27
+ if (event.nativeEvent.isComposing || event.nativeEvent.keyCode === 229) return;
28
+ if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return;
29
+ if (event.key !== "Backspace" || event.repeat) return;
30
+ event.preventDefault();
31
+ event.currentTarget.click();
32
+ }, [onKeyDown]);
33
+ const resolvedButtonProps = useMemo(() => ({
34
+ ...buttonProps,
35
+ ...multiComboboxControl.getTagRemoveButtonAttributes(value),
36
+ disabled: disabled || buttonProps.disabled,
37
+ onClick: handleClick,
38
+ onKeyDown: handleKeyDown
39
+ }), [
40
+ buttonProps,
41
+ value,
42
+ disabled,
43
+ handleClick,
44
+ handleKeyDown
45
+ ]);
46
+ return /* @__PURE__ */ jsx(Tag, {
47
+ ...props,
48
+ label,
49
+ removeButtonProps: resolvedButtonProps
50
+ });
51
+ }
52
+ export { MultiComboboxTag };
53
+
54
+ //# sourceMappingURL=multi-combobox-tag.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multi-combobox-tag.js","names":[],"sources":["../../../src/components/multi-combobox/multi-combobox-tag.tsx"],"sourcesContent":["import { type ComboboxSelectOption, multiComboboxControl } from \"@hebium-ui/core\";\nimport { type KeyboardEvent, type MouseEvent, type ReactElement, useCallback, useMemo } from \"react\";\nimport { Tag } from \"../tag\";\nimport { type MultiComboboxTagContext, type MultiComboboxTagProps } from \"./multi-combobox\";\n\nconst EMPTY_BUTTON_PROPS: NonNullable<MultiComboboxTagProps[\"removeButtonProps\"]> = {};\n\ninterface MultiComboboxTagOwnProps<O extends ComboboxSelectOption> {\n value: string;\n label: string;\n option: O | undefined;\n tagProps: ((context: MultiComboboxTagContext<O>) => MultiComboboxTagProps) | undefined;\n disabled: boolean;\n remove: (value: string, button: HTMLButtonElement) => void;\n}\n\nexport function MultiComboboxTag<O extends ComboboxSelectOption>({\n value,\n label,\n option,\n tagProps,\n disabled,\n remove,\n}: MultiComboboxTagOwnProps<O>): ReactElement {\n const props = tagProps?.({ value, label, option }) ?? {};\n const buttonProps = props.removeButtonProps ?? EMPTY_BUTTON_PROPS;\n\n const onClick = buttonProps.onClick;\n const handleClick = useCallback((event: MouseEvent<HTMLButtonElement>): void => {\n onClick?.(event);\n if (!event.defaultPrevented) remove(value, event.currentTarget);\n }, [onClick, remove, value]);\n\n const onKeyDown = buttonProps.onKeyDown;\n const handleKeyDown = useCallback((event: KeyboardEvent<HTMLButtonElement>): void => {\n onKeyDown?.(event);\n if (event.defaultPrevented) return;\n if (event.nativeEvent.isComposing || event.nativeEvent.keyCode === 229) return;\n if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return;\n if (event.key !== \"Backspace\" || event.repeat) return;\n event.preventDefault();\n event.currentTarget.click();\n }, [onKeyDown]);\n\n const resolvedButtonProps = useMemo(() => ({\n ...buttonProps,\n ...multiComboboxControl.getTagRemoveButtonAttributes(value),\n disabled: disabled || buttonProps.disabled,\n onClick: handleClick,\n onKeyDown: handleKeyDown,\n }), [\n buttonProps,\n value,\n disabled,\n handleClick,\n handleKeyDown,\n ]);\n\n return (\n <Tag\n {...props}\n label={label}\n removeButtonProps={resolvedButtonProps}\n />\n );\n}\n"],"mappings":";;;;;AAKA,MAAM,qBAA8E,CAAC;AAWrF,SAAgB,iBAAiD,EAC/D,OACA,OACA,QACA,UACA,UACA,UAC4C;CAC5C,MAAM,QAAQ,WAAW;EAAE;EAAO;EAAO;CAAO,CAAC,KAAK,CAAC;CACvD,MAAM,cAAc,MAAM,qBAAqB;CAE/C,MAAM,UAAU,YAAY;CAC5B,MAAM,cAAc,aAAa,UAA+C;EAC9E,UAAU,KAAK;EACf,IAAI,CAAC,MAAM,kBAAkB,OAAO,OAAO,MAAM,aAAa;CAChE,GAAG;EAAC;EAAS;EAAQ;CAAK,CAAC;CAE3B,MAAM,YAAY,YAAY;CAC9B,MAAM,gBAAgB,aAAa,UAAkD;EACnF,YAAY,KAAK;EACjB,IAAI,MAAM,kBAAkB;EAC5B,IAAI,MAAM,YAAY,eAAe,MAAM,YAAY,YAAY,KAAK;EACxE,IAAI,MAAM,UAAU,MAAM,WAAW,MAAM,WAAW,MAAM,UAAU;EACtE,IAAI,MAAM,QAAQ,eAAe,MAAM,QAAQ;EAC/C,MAAM,eAAe;EACrB,MAAM,cAAc,MAAM;CAC5B,GAAG,CAAC,SAAS,CAAC;CAEd,MAAM,sBAAsB,eAAe;EACzC,GAAG;EACH,GAAG,qBAAqB,6BAA6B,KAAK;EAC1D,UAAU,YAAY,YAAY;EAClC,SAAS;EACT,WAAW;CACb,IAAI;EACF;EACA;EACA;EACA;EACA;CACF,CAAC;CAED,OACE,oBAAC,KAAD;EACE,GAAI;EACG;EACP,mBAAmB;CACpB,CAAA;AAEL"}
@@ -0,0 +1,72 @@
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 { TagProps } from "../tag/tag.js";
6
+ import "../tag/index.js";
7
+ import { ComboboxSelectOption as ComboboxSelectOption$1, ComboboxTextOption as ComboboxTextOption$1, MultiComboboxFormValueProps, MultiComboboxFormValueProps as MultiComboboxFormValueProps$1, MultiComboboxItemState, MultiComboboxItemState as MultiComboboxItemState$1, MultiComboboxSlots, MultiComboboxVariants } from "@hebium-ui/core";
8
+ import { ComponentProps, ReactElement, ReactNode } from "react";
9
+ export interface MultiComboboxTagContext<O extends ComboboxSelectOption$1 = ComboboxSelectOption$1> {
10
+ value: string;
11
+ /** Standard display text. In text mode this is the committed value itself. */
12
+ label: string;
13
+ /** The matching candidate, if one exists. */
14
+ option: O | undefined;
15
+ }
16
+ export type MultiComboboxTagProps = Omit<TagProps, "label" | "onRemove">;
17
+ interface MultiComboboxOwnProps<O extends ComboboxSelectOption$1> {
18
+ /** Available options. Values must be unique. */
19
+ options: readonly O[];
20
+ /** The controlled values. Values must be unique. */
21
+ value?: readonly string[] | undefined;
22
+ /** The initial uncontrolled values. @default [] */
23
+ defaultValue?: readonly string[] | undefined;
24
+ /**
25
+ * Called with the next values. In controlled mode, call the optional focus callback when accepting a Tag removal.
26
+ */
27
+ onChange?: ((value: string[], moveFocus?: () => void) => void) | undefined;
28
+ /** The input's semantic color. @default "accent" */
29
+ color?: MultiComboboxVariants["color"] | undefined;
30
+ /** The label displayed above the input. */
31
+ label?: ReactNode | undefined;
32
+ /** Additional props passed to the label. */
33
+ labelProps?: LabelProps | undefined;
34
+ /** Help text displayed below the label. */
35
+ description?: ReactNode | undefined;
36
+ /** Inline validation feedback. */
37
+ error?: ReactNode | undefined;
38
+ /** The name used for form submission. */
39
+ name?: string | undefined;
40
+ /** The id of the associated form. */
41
+ form?: string | undefined;
42
+ /** Prevents interaction and excludes values from form submission. */
43
+ disabled?: boolean | undefined;
44
+ /** Prevents editing and opening the list. Values are still submitted. */
45
+ readOnly?: boolean | undefined;
46
+ /** Requires at least one selected value. */
47
+ required?: boolean | undefined;
48
+ /** Native validation message. @default "Please fill out this field." */
49
+ requiredMessage?: string | undefined;
50
+ /** Props passed to the input element. */
51
+ inputProps?: Omit<ComponentProps<"input">, "children"> | undefined;
52
+ /** Props passed to the listbox element. */
53
+ listProps?: Omit<ComponentProps<"div">, "children"> | undefined;
54
+ /** Props for each option wrapper. */
55
+ itemProps?: ((option: O, state: MultiComboboxItemState$1) => Omit<ComponentProps<"div">, "children">) | undefined;
56
+ /** Custom option content, including the check mark. */
57
+ renderItem?: ((option: O, state: MultiComboboxItemState$1) => ReactNode) | undefined;
58
+ /** Props for each selected Tag. */
59
+ tagProps?: ((context: MultiComboboxTagContext<O>) => MultiComboboxTagProps) | undefined;
60
+ /** Renders custom form submission elements for all selected values. */
61
+ renderFormValue?: ((props: MultiComboboxFormValueProps$1) => ReactNode) | undefined;
62
+ }
63
+ type MultiComboboxModeProps<O extends ComboboxSelectOption$1> = {
64
+ /** Select from options or allow free text. @default "select" */
65
+ mode?: "select" | undefined;
66
+ } | {
67
+ mode: "text";
68
+ options: readonly (O & ComboboxTextOption$1)[];
69
+ };
70
+ export type MultiComboboxProps<O extends ComboboxSelectOption$1 = ComboboxSelectOption$1> = HuiComponentProps<MultiComboboxOwnProps<O>, MultiComboboxSlots> & MultiComboboxModeProps<O>;
71
+ export declare function MultiCombobox<O extends ComboboxSelectOption$1>(rawProps: MultiComboboxProps<O>): ReactElement;
72
+ export type { MultiComboboxFormValueProps, MultiComboboxItemState };