@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
@@ -12,55 +12,64 @@ import { Checkbox, CheckboxProps } from "./checkbox/checkbox.js";
12
12
  import "./checkbox/index.js";
13
13
  import { Code, CodeProps } from "./code/code.js";
14
14
  import "./code/index.js";
15
- import { Details, DetailsProps } from "./details/details.js";
15
+ import { Label, LabelProps } from "./label/label.js";
16
+ import "./combobox/index.js";
17
+ import { Combobox, ComboboxFormValueProps, ComboboxProps, ComboboxSelectOption, ComboboxTextOption } from "./combobox/combobox.js";
16
18
  import "./details/index.js";
19
+ import { Details, DetailsProps } from "./details/details.js";
20
+ import "./dialog/index.js";
17
21
  import { Heading, HeadingProps } from "./heading/heading.js";
18
- import "./heading/index.js";
22
+ import "./dl/index.js";
19
23
  import { Dialog, DialogCloseProps, DialogContentProps, DialogProps, DialogTriggerProps } from "./dialog/dialog.js";
20
- import { useDialogId } from "./dialog/dialog.context.js";
21
- import "./dialog/index.js";
24
+ import "./drawer/index.js";
22
25
  import { DdProps, Dl, DlProps, DtProps } from "./dl/dl.js";
23
- import "./dl/index.js";
26
+ import "./fieldset/index.js";
24
27
  import { Drawer, DrawerCloseProps, DrawerContentProps, DrawerProps, DrawerTriggerProps } from "./drawer/drawer.js";
25
- import { useDrawerId } from "./drawer/drawer.context.js";
26
- import "./drawer/index.js";
28
+ import "./heading/index.js";
27
29
  import { Fieldset, FieldsetProps } from "./fieldset/fieldset.js";
28
- import "./fieldset/index.js";
29
- import { Hr, HrProps } from "./hr/hr.js";
30
30
  import "./hr/index.js";
31
- import { Label, LabelProps } from "./label/label.js";
32
- import "./label/index.js";
33
- import { Input, InputProps } from "./input/input.js";
31
+ import { Hr, HrProps } from "./hr/hr.js";
32
+ import "./inline-feedback/index.js";
33
+ import { InlineFeedback, InlineFeedbackProps } from "./inline-feedback/inline-feedback.js";
34
34
  import "./input/index.js";
35
+ import { Input, InputProps } from "./input/input.js";
36
+ import "./label/index.js";
35
37
  import { Menu, MenuContentProps, MenuItemProps, MenuProps, MenuTriggerProps } from "./menu/menu.js";
36
- import { useMenuId } from "./menu/menu.context.js";
37
38
  import "./menu/index.js";
38
- import { Paragraph, ParagraphProps } from "./paragraph/paragraph.js";
39
+ import { Tag, TagProps } from "./tag/tag.js";
40
+ import "./multi-combobox/index.js";
41
+ import { MultiCombobox, MultiComboboxFormValueProps, MultiComboboxItemState, MultiComboboxProps, MultiComboboxTagContext, MultiComboboxTagProps } from "./multi-combobox/multi-combobox.js";
39
42
  import "./paragraph/index.js";
40
- import { Popover, PopoverContentProps, PopoverProps, PopoverTriggerProps } from "./popover/popover.js";
41
- import { usePopoverId } from "./popover/popover.context.js";
43
+ import { Paragraph, ParagraphProps } from "./paragraph/paragraph.js";
42
44
  import "./popover/index.js";
43
- import { Progress, ProgressProps } from "./progress/progress.js";
45
+ import { Popover, PopoverContentProps, PopoverProps, PopoverTriggerProps } from "./popover/popover.js";
44
46
  import "./progress/index.js";
45
- import { Radio, RadioProps } from "./radio/radio.js";
47
+ import { Progress, ProgressProps } from "./progress/progress.js";
46
48
  import "./radio/index.js";
47
- import { Radiogroup, RadiogroupProps } from "./radiogroup/radiogroup.js";
49
+ import { Radio, RadioProps } from "./radio/radio.js";
48
50
  import "./radiogroup/index.js";
49
- import { Section, SectionProps } from "./section/section.js";
51
+ import { Radiogroup, RadiogroupProps } from "./radiogroup/radiogroup.js";
50
52
  import "./section/index.js";
51
- import { SegmentedControl, SegmentedControlItemProps, SegmentedControlProps } from "./segmented-control/segmented-control.js";
53
+ import { Section, SectionProps } from "./section/section.js";
52
54
  import "./segmented-control/index.js";
53
- import { Select, SelectProps } from "./select/select.js";
55
+ import { SegmentedControl, SegmentedControlItemProps, SegmentedControlProps } from "./segmented-control/segmented-control.js";
54
56
  import "./select/index.js";
55
- import { CaptionProps, Table, TableProps, TbodyProps, TdProps, TfootProps, ThProps, TheadProps, TrProps } from "./table/table.js";
57
+ import { Select, SelectProps } from "./select/select.js";
58
+ import "./skip-link/index.js";
59
+ import { SkipLink, SkipLinkProps } from "./skip-link/skip-link.js";
60
+ import "./status-icon/index.js";
61
+ import { StatusIcon, StatusIconProps } from "./status-icon/status-icon.js";
56
62
  import "./table/index.js";
57
- import { Tabs, TabsListProps, TabsPanelProps, TabsProps, TabsTabProps } from "./tabs/tabs.js";
63
+ import { CaptionProps, Table, TableProps, TbodyProps, TdProps, TfootProps, ThProps, TheadProps, TrProps } from "./table/table.js";
58
64
  import "./tabs/index.js";
65
+ import { Tabs, TabsListProps, TabsPanelProps, TabsProps, TabsTabProps } from "./tabs/tabs.js";
66
+ import "./tag/index.js";
67
+ import { Text, TextProps } from "./text/text.js";
68
+ import "./text/index.js";
59
69
  import { Textarea, TextareaProps } from "./textarea/textarea.js";
60
70
  import "./textarea/index.js";
61
71
  import { Tooltip, TooltipContentProps, TooltipProps, TooltipTriggerProps } from "./tooltip/tooltip.js";
62
- import { useTooltipId } from "./tooltip/tooltip.context.js";
63
72
  import "./tooltip/index.js";
64
73
  import { VisuallyHidden, VisuallyHiddenProps } from "./visually-hidden/visually-hidden.js";
65
74
  import "./visually-hidden/index.js";
66
- export { Alert, AlertProps, Anchor, AnchorProps, Avatar, AvatarProps, Blockquote, BlockquoteProps, Button, ButtonProps, CaptionProps, Checkbox, CheckboxProps, Code, CodeProps, DdProps, Details, DetailsProps, Dialog, DialogCloseProps, DialogContentProps, DialogProps, DialogTriggerProps, Dl, DlProps, Drawer, DrawerCloseProps, DrawerContentProps, DrawerProps, DrawerTriggerProps, DtProps, Fieldset, FieldsetProps, Heading, HeadingProps, Hr, HrProps, Input, InputProps, Label, LabelProps, Menu, MenuContentProps, MenuItemProps, MenuProps, MenuTriggerProps, Paragraph, ParagraphProps, Popover, PopoverContentProps, PopoverProps, PopoverTriggerProps, Progress, ProgressProps, Radio, RadioProps, Radiogroup, RadiogroupProps, Section, SectionProps, SegmentedControl, SegmentedControlItemProps, SegmentedControlProps, Select, SelectProps, Table, TableProps, Tabs, TabsListProps, TabsPanelProps, TabsProps, TabsTabProps, TbodyProps, TdProps, Textarea, TextareaProps, TfootProps, ThProps, TheadProps, Tooltip, TooltipContentProps, TooltipProps, TooltipTriggerProps, TrProps, VisuallyHidden, VisuallyHiddenProps, useDialogId, useDrawerId, useMenuId, usePopoverId, useTooltipId };
75
+ export { Alert, AlertProps, Anchor, AnchorProps, Avatar, AvatarProps, Blockquote, BlockquoteProps, Button, ButtonProps, CaptionProps, Checkbox, CheckboxProps, Code, CodeProps, Combobox, type ComboboxFormValueProps, ComboboxProps, type ComboboxSelectOption, type ComboboxTextOption, DdProps, Details, DetailsProps, Dialog, DialogCloseProps, DialogContentProps, DialogProps, DialogTriggerProps, Dl, DlProps, Drawer, DrawerCloseProps, DrawerContentProps, DrawerProps, DrawerTriggerProps, DtProps, Fieldset, FieldsetProps, Heading, HeadingProps, Hr, HrProps, InlineFeedback, InlineFeedbackProps, Input, InputProps, Label, LabelProps, Menu, MenuContentProps, MenuItemProps, MenuProps, MenuTriggerProps, MultiCombobox, type MultiComboboxFormValueProps, type MultiComboboxItemState, MultiComboboxProps, MultiComboboxTagContext, MultiComboboxTagProps, Paragraph, ParagraphProps, Popover, PopoverContentProps, PopoverProps, PopoverTriggerProps, Progress, ProgressProps, Radio, RadioProps, Radiogroup, RadiogroupProps, Section, SectionProps, SegmentedControl, SegmentedControlItemProps, SegmentedControlProps, Select, SelectProps, SkipLink, SkipLinkProps, StatusIcon, StatusIconProps, Table, TableProps, Tabs, TabsListProps, TabsPanelProps, TabsProps, TabsTabProps, Tag, TagProps, TbodyProps, TdProps, Text, TextProps, Textarea, TextareaProps, TfootProps, ThProps, TheadProps, Tooltip, TooltipContentProps, TooltipProps, TooltipTriggerProps, TrProps, VisuallyHidden, VisuallyHiddenProps };
@@ -0,0 +1,2 @@
1
+ import { InlineFeedback, InlineFeedbackProps } from "./inline-feedback.js";
2
+ export { InlineFeedback, InlineFeedbackProps };
@@ -0,0 +1,33 @@
1
+ import { HuiComponentProps } from "../../types/hui-component.js";
2
+ import "../../types/index.js";
3
+ import { InlineFeedbackSlots, InlineFeedbackVariants } from "@hebium-ui/core";
4
+ import { ComponentProps, ReactElement, ReactNode } from "react";
5
+ interface InlineFeedbackOwnProps extends Omit<ComponentProps<"div">, "color" | "role"> {
6
+ /**
7
+ * Whether to show the icon and message. For live announcements, mount with
8
+ * `when={false}` and keep the component mounted as you toggle visibility.
9
+ */
10
+ when: boolean;
11
+ /**
12
+ * The icon content, rendered without changing its attributes or styles.
13
+ * Set to `null` or `false` to omit.
14
+ *
15
+ * @default StatusIcon with status="info"
16
+ */
17
+ icon?: ReactNode | undefined;
18
+ /**
19
+ * The color inherited by the icon and message.
20
+ *
21
+ * @default "text"
22
+ */
23
+ color?: InlineFeedbackVariants["color"] | undefined;
24
+ /**
25
+ * The ARIA role of the feedback container.
26
+ *
27
+ * @default "status"
28
+ */
29
+ role?: "status" | "alert" | "log" | "none" | undefined;
30
+ }
31
+ export type InlineFeedbackProps = HuiComponentProps<InlineFeedbackOwnProps, InlineFeedbackSlots>;
32
+ export declare function InlineFeedback(rawProps: InlineFeedbackProps): ReactElement;
33
+ export {};
@@ -0,0 +1,30 @@
1
+ import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
2
+ import { StatusIcon } from "../status-icon/status-icon.js";
3
+ import { inlineFeedbackRecipe, toStrbool } from "@hebium-ui/core";
4
+ import { useRef } from "react";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ // src/components/inline-feedback/inline-feedback.tsx
7
+ function InlineFeedback(rawProps) {
8
+ const { when, children, icon, color, role = "status", ...restProps } = useHuiProps("InlineFeedback", rawProps);
9
+ const diagnosed = useRef(null);
10
+ if (diagnosed.current === null) {
11
+ diagnosed.current = true;
12
+ if ((role === "status" || role === "log") && when) console.warn("[Hebium UI] InlineFeedback: Content shown on the first render with role \"status\" or \"log\" may not be announced by screen readers. Mount InlineFeedback with when={false}, then set when to true after the user action.");
13
+ }
14
+ const recipe = inlineFeedbackRecipe({
15
+ color,
16
+ empty: toStrbool(!when)
17
+ });
18
+ const cls = useHuiClassNames("InlineFeedback", recipe, rawProps);
19
+ const sls = useHuiStyles("InlineFeedback", rawProps);
20
+ return /* @__PURE__ */ jsx("div", {
21
+ className: cls.root,
22
+ style: sls.root,
23
+ role,
24
+ ...restProps,
25
+ children: when && /* @__PURE__ */ jsxs(Fragment, { children: [typeof icon === "undefined" ? /* @__PURE__ */ jsx(StatusIcon, { status: "info" }) : icon, children] })
26
+ });
27
+ }
28
+ export { InlineFeedback };
29
+
30
+ //# sourceMappingURL=inline-feedback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inline-feedback.js","names":[],"sources":["../../../src/components/inline-feedback/inline-feedback.tsx"],"sourcesContent":["import {\n inlineFeedbackRecipe,\n type InlineFeedbackSlots,\n type InlineFeedbackVariants,\n toStrbool,\n} from \"@hebium-ui/core\";\nimport { type ComponentProps, type ReactElement, type ReactNode, useRef } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps } from \"~/types\";\nimport { StatusIcon } from \"../status-icon\";\n\ninterface InlineFeedbackOwnProps extends Omit<ComponentProps<\"div\">, \"color\" | \"role\"> {\n /**\n * Whether to show the icon and message. For live announcements, mount with\n * `when={false}` and keep the component mounted as you toggle visibility.\n */\n when: boolean;\n /**\n * The icon content, rendered without changing its attributes or styles.\n * Set to `null` or `false` to omit.\n *\n * @default StatusIcon with status=\"info\"\n */\n icon?: ReactNode | undefined;\n /**\n * The color inherited by the icon and message.\n *\n * @default \"text\"\n */\n color?: InlineFeedbackVariants[\"color\"] | undefined;\n /**\n * The ARIA role of the feedback container.\n *\n * @default \"status\"\n */\n role?: \"status\" | \"alert\" | \"log\" | \"none\" | undefined;\n}\n\nexport type InlineFeedbackProps = HuiComponentProps<InlineFeedbackOwnProps, InlineFeedbackSlots>;\n\nexport function InlineFeedback(rawProps: InlineFeedbackProps): ReactElement {\n const {\n when,\n children,\n icon,\n color,\n role = \"status\",\n ...restProps\n } = useHuiProps(\"InlineFeedback\", rawProps);\n const diagnosed = useRef<true | null>(null);\n\n if (diagnosed.current === null) {\n diagnosed.current = true;\n if ((role === \"status\" || role === \"log\") && when) {\n console.warn(\n \"[Hebium UI] InlineFeedback: Content shown on the first render with role \\\"status\\\" or \\\"log\\\" may not be announced by screen readers. Mount InlineFeedback with when={false}, then set when to true after the user action.\",\n );\n }\n }\n\n const recipe = inlineFeedbackRecipe({ color, empty: toStrbool(!when) });\n const cls = useHuiClassNames(\"InlineFeedback\", recipe, rawProps);\n const sls = useHuiStyles(\"InlineFeedback\", rawProps);\n\n return (\n <div\n className={cls.root}\n style={sls.root}\n role={role}\n {...restProps}\n >\n {when && (\n <>\n {typeof icon === \"undefined\"\n ? <StatusIcon status=\"info\" />\n : icon}\n {children}\n </>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;AAwCA,SAAgB,eAAe,UAA6C;CAC1E,MAAM,EACJ,MACA,UACA,MACA,OACA,OAAO,UACP,GAAG,cACD,YAAY,kBAAkB,QAAQ;CAC1C,MAAM,YAAY,OAAoB,IAAI;CAE1C,IAAI,UAAU,YAAY,MAAM;EAC9B,UAAU,UAAU;EACpB,KAAK,SAAS,YAAY,SAAS,UAAU,MAC3C,QAAQ,KACN,4NACF;CAEJ;CAEA,MAAM,SAAS,qBAAqB;EAAE;EAAO,OAAO,UAAU,CAAC,IAAI;CAAE,CAAC;CACtE,MAAM,MAAM,iBAAiB,kBAAkB,QAAQ,QAAQ;CAC/D,MAAM,MAAM,aAAa,kBAAkB,QAAQ;CAEnD,OACE,oBAAC,OAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACL;EACN,GAAI;EAEH,UAAA,QACC,qBAAA,UAAA,EAAA,UAAA,CACG,OAAO,SAAS,cACb,oBAAC,YAAD,EAAY,QAAO,OAAQ,CAAA,IAC3B,MACH,QACD,EAAA,CAAA;CAED,CAAA;AAET"}
@@ -4,7 +4,6 @@ import { LabelProps } from "../label/label.js";
4
4
  import "../label/index.js";
5
5
  import { InputSlots, InputVariants } from "@hebium-ui/core";
6
6
  import { ComponentProps, ReactElement, ReactNode } from "react";
7
- //#region src/components/input/input.d.ts
8
7
  type HtmlInputProps = Omit<ComponentProps<"input">, "children" | "color">;
9
8
  interface InputOwnProps extends HtmlInputProps {
10
9
  /**
@@ -32,6 +31,4 @@ interface InputOwnProps extends HtmlInputProps {
32
31
  }
33
32
  export type InputProps = HuiComponentProps<InputOwnProps, InputSlots>;
34
33
  export declare function Input(rawProps: InputProps): ReactElement;
35
- //#endregion
36
- export {};
37
- //# sourceMappingURL=input.d.ts.map
34
+ export {};
@@ -4,10 +4,10 @@ import { Label } from "../label/label.js";
4
4
  import { inputControl, inputRecipe, toBool, toStrbool } from "@hebium-ui/core";
5
5
  import { useId } from "react";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
7
- //#region src/components/input/input.tsx
7
+ // src/components/input/input.tsx
8
8
  function Input(rawProps) {
9
9
  const tmpId = useId();
10
- const { id, classNames, styles, color, label, description, error, labelProps, ...restProps } = useHuiProps("Input", rawProps);
10
+ const { id, color, label, description, error, labelProps, ...restProps } = useHuiProps("Input", rawProps);
11
11
  const inputState = {
12
12
  id: id || tmpId,
13
13
  invalid: !!error,
@@ -19,8 +19,8 @@ function Input(rawProps) {
19
19
  color,
20
20
  error: toStrbool(inputState.invalid)
21
21
  });
22
- const cls = useHuiClassNames("Input", recipe, classNames);
23
- const sls = useHuiStyles("Input", styles);
22
+ const cls = useHuiClassNames("Input", recipe, rawProps);
23
+ const sls = useHuiStyles("Input", rawProps);
24
24
  const hasLabel = !!label || !!description || !!error;
25
25
  const controlAttrs = normalizeAttributes(inputControl.getControlAttributes(inputState));
26
26
  const labelAttrs = normalizeAttributes(inputControl.getLabelAttributes(inputState));
@@ -41,7 +41,6 @@ function Input(rawProps) {
41
41
  })]
42
42
  });
43
43
  }
44
- //#endregion
45
44
  export { Input };
46
45
 
47
46
  //# sourceMappingURL=input.js.map
@@ -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 classNames,\n styles,\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, classNames);\n const sls = useHuiStyles(\"Input\", 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,YACA,QACA,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,UAAU;CACxD,MAAM,MAAM,aAAa,SAAS,MAAM;CAExC,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"}
@@ -2,7 +2,6 @@ import { HuiPolymorphicProps } from "../../types/polymorphic.js";
2
2
  import "../../types/index.js";
3
3
  import { LabelMarker, LabelSlots, LabelVariants } from "@hebium-ui/core";
4
4
  import { ElementType, ReactElement, ReactNode } from "react";
5
- //#region src/components/label/label.d.ts
6
5
  interface LabelOwnProps {
7
6
  /**
8
7
  * The visual state of the label.
@@ -27,6 +26,4 @@ interface LabelOwnProps {
27
26
  }
28
27
  export type LabelProps<E extends ElementType = "label"> = HuiPolymorphicProps<E, LabelOwnProps, LabelSlots>;
29
28
  export declare function Label<E extends ElementType = "label">(rawProps: LabelProps<E>): ReactElement;
30
- //#endregion
31
- export {};
32
- //# sourceMappingURL=label.d.ts.map
29
+ export {};
@@ -1,16 +1,16 @@
1
1
  import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
2
2
  import { DEFAULT_LABEL_MAKER, labelMarker, labelRecipe, toBool } from "@hebium-ui/core";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
- //#region src/components/label/label.tsx
4
+ // src/components/label/label.tsx
5
5
  function Label(rawProps) {
6
- const { as, variant, children, marker, description, error, "data-required": dataRequired, classNames, styles, ...restProps } = useHuiProps("Label", rawProps);
6
+ const { as, variant, children, marker, description, error, "data-required": dataRequired, ...restProps } = useHuiProps("Label", rawProps);
7
7
  const resolvedMarker = labelMarker(marker ?? DEFAULT_LABEL_MAKER, toBool(dataRequired));
8
8
  const recipe = labelRecipe({
9
9
  marker: resolvedMarker.label ? resolvedMarker.variant : void 0,
10
10
  variant
11
11
  });
12
- const cls = useHuiClassNames("Label", recipe, classNames);
13
- const sls = useHuiStyles("Label", 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", {
@@ -48,7 +48,6 @@ function Label(rawProps) {
48
48
  ]
49
49
  });
50
50
  }
51
- //#endregion
52
51
  export { Label };
53
52
 
54
53
  //# sourceMappingURL=label.js.map
@@ -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 classNames,\n styles,\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, classNames);\n const sls = useHuiStyles(\"Label\", 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,YACA,QACA,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,UAAU;CACxD,MAAM,MAAM,aAAa,SAAS,MAAM;CAGxC,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 };
@@ -1,5 +1,5 @@
1
1
  import { createContext, useContext } from "react";
2
- //#region src/components/menu/menu.context.ts
2
+ // src/components/menu/menu.context.ts
3
3
  const MenuContext = createContext(null);
4
4
  function useMenuContext() {
5
5
  const context = useContext(MenuContext);
@@ -9,7 +9,6 @@ function useMenuContext() {
9
9
  function useMenuId() {
10
10
  return useMenuContext().menuId;
11
11
  }
12
- //#endregion
13
12
  export { MenuContext, useMenuContext, useMenuId };
14
13
 
15
14
  //# sourceMappingURL=menu.context.js.map
@@ -4,7 +4,6 @@ import { Button } from "../button/button.js";
4
4
  import "../button/index.js";
5
5
  import { ButtonSlots, MenuItemActivation, MenuitemSlots, MenuitemVariants, PopoverSlots, PopoverVariants } from "@hebium-ui/core";
6
6
  import { ElementType, ReactElement, ReactNode } from "react";
7
- //#region src/components/menu/menu.d.ts
8
7
  export interface MenuProps {
9
8
  /**
10
9
  * The id of the menu content element.
@@ -13,8 +12,8 @@ export interface MenuProps {
13
12
  children?: ReactNode | undefined;
14
13
  }
15
14
  declare function MenuRoot(rawProps: MenuProps): ReactElement;
16
- export type MenuTriggerProps<E extends ElementType = typeof Button> = HuiPolymorphicProps<E, {}, ButtonSlots>;
17
- 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;
18
17
  interface MenuContentOwnProps {
19
18
  /**
20
19
  * The preferred anchor position of the menu.
@@ -77,6 +76,4 @@ export declare const Menu: typeof MenuRoot & {
77
76
  Content: typeof Content;
78
77
  Item: typeof Item;
79
78
  };
80
- //#endregion
81
- export {};
82
- //# 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
- //#region src/components/menu/menu.tsx
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,6 +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;
30
+ const cls = useHuiClassNames("MenuTrigger", BUTTON_CLASSES, rawProps);
31
+ const sls = useHuiStyles("MenuTrigger", rawProps);
24
32
  const menuId = useMenuId();
25
33
  const attrs = normalizeAttributes(menuControl.getTriggerAttributes({ menuId }, { isButtonElement: as === void 0 }));
26
34
  const handleKeyDown = useCallback((e) => {
@@ -30,13 +38,20 @@ function Trigger(rawProps) {
30
38
  }, [onKeyDown, menuId]);
31
39
  return /* @__PURE__ */ jsx(Component, {
32
40
  ...attrs,
41
+ ...Component === Button ? {
42
+ classNames: cls,
43
+ styles: sls
44
+ } : {
45
+ className: cls.root,
46
+ style: sls.root
47
+ },
33
48
  onKeyDown: handleKeyDown,
34
49
  ...restProps,
35
50
  children
36
51
  });
37
52
  }
38
53
  function Content(rawProps) {
39
- const { as, position, fallbacks, visibility, padding, className, style, children, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...restProps } = useHuiProps("MenuContent", rawProps);
54
+ const { as, position, fallbacks, visibility, padding, children, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...restProps } = useHuiProps("MenuContent", rawProps);
40
55
  const Component = as ?? "div";
41
56
  const menuId = useMenuId();
42
57
  const recipe = popoverRecipe({
@@ -45,8 +60,8 @@ function Content(rawProps) {
45
60
  visibility,
46
61
  padding: padding ?? "sm"
47
62
  });
48
- const cls = useHuiClassNames("MenuContent", recipe, { root: className });
49
- const sls = useHuiStyles("MenuContent", { root: style });
63
+ const cls = useHuiClassNames("MenuContent", recipe, rawProps);
64
+ const sls = useHuiStyles("MenuContent", rawProps);
50
65
  const attrs = normalizeAttributes(menuControl.getContentAttributes({ menuId }, {
51
66
  ariaLabel,
52
67
  ariaLabelledBy
@@ -60,13 +75,13 @@ function Content(rawProps) {
60
75
  });
61
76
  }
62
77
  function Item(rawProps) {
63
- const { as, className, style, color, focusKey, activation = "managed", onClick, onAction, onKeyDown, children, "aria-disabled": ariaDisabled, ...restProps } = useHuiProps("MenuItem", rawProps);
78
+ const { as, color, focusKey, activation = "managed", onClick, onAction, onKeyDown, children, "aria-disabled": ariaDisabled, ...restProps } = useHuiProps("MenuItem", rawProps);
64
79
  const Component = as ?? "div";
65
80
  const menuId = useMenuId();
66
81
  const isDisabled = toBool(ariaDisabled);
67
82
  const recipe = menuitemRecipe({ color });
68
- const cls = useHuiClassNames("MenuItem", recipe, { root: className });
69
- const sls = useHuiStyles("MenuItem", { root: style });
83
+ const cls = useHuiClassNames("MenuItem", recipe, rawProps);
84
+ const sls = useHuiStyles("MenuItem", rawProps);
70
85
  const attrs = normalizeAttributes(menuControl.getItemAttributes({ menuId }, {
71
86
  focusKey,
72
87
  disabled: ariaDisabled == null ? void 0 : isDisabled
@@ -127,7 +142,6 @@ const Menu = Object.assign(MenuRoot, {
127
142
  Content,
128
143
  Item
129
144
  });
130
- //#endregion
131
145
  export { Menu };
132
146
 
133
147
  //# sourceMappingURL=menu.js.map
@@ -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 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 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 className,\n style,\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: className });\n const sls = useHuiStyles(\"MenuContent\", { root: 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 className,\n style,\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: className });\n const sls = useHuiStyles(\"MenuItem\", { root: 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":"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"}
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"}