@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.
- package/dist/components/alert/alert.d.ts +3 -4
- package/dist/components/alert/alert.js +4 -11
- package/dist/components/alert/alert.js.map +1 -1
- package/dist/components/anchor/anchor.d.ts +1 -2
- package/dist/components/anchor/anchor.js +2 -2
- package/dist/components/anchor/anchor.js.map +1 -1
- package/dist/components/avatar/avatar.d.ts +1 -2
- package/dist/components/avatar/avatar.js +2 -2
- package/dist/components/avatar/avatar.js.map +1 -1
- package/dist/components/blockquote/blockquote.d.ts +1 -2
- package/dist/components/blockquote/blockquote.js +2 -2
- package/dist/components/blockquote/blockquote.js.map +1 -1
- package/dist/components/button/button.d.ts +12 -2
- package/dist/components/button/button.js +29 -9
- package/dist/components/button/button.js.map +1 -1
- package/dist/components/checkbox/checkbox.d.ts +1 -2
- package/dist/components/checkbox/checkbox.js +2 -2
- package/dist/components/checkbox/checkbox.js.map +1 -1
- package/dist/components/code/code.d.ts +1 -2
- package/dist/components/code/code.js +2 -2
- package/dist/components/code/code.js.map +1 -1
- package/dist/components/combobox/combobox-option.js +33 -0
- package/dist/components/combobox/combobox-option.js.map +1 -0
- package/dist/components/combobox/combobox.d.ts +61 -0
- package/dist/components/combobox/combobox.js +208 -0
- package/dist/components/combobox/combobox.js.map +1 -0
- package/dist/components/combobox/index.d.ts +2 -0
- package/dist/components/combobox/use-combobox-form.js +33 -0
- package/dist/components/combobox/use-combobox-form.js.map +1 -0
- package/dist/components/combobox/use-combobox-popover.js +66 -0
- package/dist/components/combobox/use-combobox-popover.js.map +1 -0
- package/dist/components/combobox/use-combobox-state.js +96 -0
- package/dist/components/combobox/use-combobox-state.js.map +1 -0
- package/dist/components/details/details.d.ts +1 -2
- package/dist/components/details/details.js +2 -2
- package/dist/components/details/details.js.map +1 -1
- package/dist/components/dialog/dialog.d.ts +4 -5
- package/dist/components/dialog/dialog.js +26 -13
- package/dist/components/dialog/dialog.js.map +1 -1
- package/dist/components/dialog/index.d.ts +1 -2
- package/dist/components/dl/dl.d.ts +1 -2
- package/dist/components/dl/dl.js +6 -6
- package/dist/components/dl/dl.js.map +1 -1
- package/dist/components/drawer/drawer.d.ts +4 -5
- package/dist/components/drawer/drawer.js +26 -13
- package/dist/components/drawer/drawer.js.map +1 -1
- package/dist/components/drawer/index.d.ts +1 -2
- package/dist/components/fieldset/fieldset.d.ts +1 -2
- package/dist/components/fieldset/fieldset.js +2 -2
- package/dist/components/fieldset/fieldset.js.map +1 -1
- package/dist/components/heading/heading.d.ts +1 -2
- package/dist/components/heading/heading.js +2 -2
- package/dist/components/heading/heading.js.map +1 -1
- package/dist/components/hr/hr.d.ts +1 -2
- package/dist/components/hr/hr.js +2 -2
- package/dist/components/hr/hr.js.map +1 -1
- package/dist/components/index.d.ts +32 -27
- package/dist/components/inline-feedback/index.d.ts +2 -0
- package/dist/components/inline-feedback/inline-feedback.d.ts +33 -0
- package/dist/components/inline-feedback/inline-feedback.js +30 -0
- package/dist/components/inline-feedback/inline-feedback.js.map +1 -0
- package/dist/components/input/input.d.ts +1 -2
- package/dist/components/input/input.js +2 -2
- package/dist/components/input/input.js.map +1 -1
- package/dist/components/label/label.d.ts +1 -2
- package/dist/components/label/label.js +4 -4
- package/dist/components/label/label.js.map +1 -1
- package/dist/components/menu/index.d.ts +1 -2
- package/dist/components/menu/menu.d.ts +3 -4
- package/dist/components/menu/menu.js +20 -9
- package/dist/components/menu/menu.js.map +1 -1
- package/dist/components/multi-combobox/index.d.ts +2 -0
- package/dist/components/multi-combobox/multi-combobox-option.js +42 -0
- package/dist/components/multi-combobox/multi-combobox-option.js.map +1 -0
- package/dist/components/multi-combobox/multi-combobox-tag.js +54 -0
- package/dist/components/multi-combobox/multi-combobox-tag.js.map +1 -0
- package/dist/components/multi-combobox/multi-combobox.d.ts +72 -0
- package/dist/components/multi-combobox/multi-combobox.js +249 -0
- package/dist/components/multi-combobox/multi-combobox.js.map +1 -0
- package/dist/components/multi-combobox/use-multi-combobox-state.js +91 -0
- package/dist/components/multi-combobox/use-multi-combobox-state.js.map +1 -0
- package/dist/components/paragraph/paragraph.d.ts +1 -2
- package/dist/components/paragraph/paragraph.js +2 -2
- package/dist/components/paragraph/paragraph.js.map +1 -1
- package/dist/components/popover/index.d.ts +1 -2
- package/dist/components/popover/popover.d.ts +3 -4
- package/dist/components/popover/popover.js +18 -7
- package/dist/components/popover/popover.js.map +1 -1
- package/dist/components/progress/progress.d.ts +1 -2
- package/dist/components/progress/progress.js +2 -2
- package/dist/components/progress/progress.js.map +1 -1
- package/dist/components/radio/radio.d.ts +1 -2
- package/dist/components/radio/radio.js +2 -2
- package/dist/components/radio/radio.js.map +1 -1
- package/dist/components/radiogroup/radiogroup.d.ts +1 -2
- package/dist/components/radiogroup/radiogroup.js +5 -4
- package/dist/components/radiogroup/radiogroup.js.map +1 -1
- package/dist/components/section/section.d.ts +1 -2
- package/dist/components/section/section.js +2 -2
- package/dist/components/section/section.js.map +1 -1
- package/dist/components/segmented-control/segmented-control.d.ts +1 -2
- package/dist/components/segmented-control/segmented-control.js +10 -5
- package/dist/components/segmented-control/segmented-control.js.map +1 -1
- package/dist/components/select/select.d.ts +1 -2
- package/dist/components/select/select.js +2 -2
- package/dist/components/select/select.js.map +1 -1
- package/dist/components/skip-link/skip-link.d.ts +1 -2
- package/dist/components/skip-link/skip-link.js +2 -2
- package/dist/components/skip-link/skip-link.js.map +1 -1
- package/dist/components/status-icon/index.d.ts +2 -0
- package/dist/components/status-icon/status-icon.d.ts +19 -0
- package/dist/components/status-icon/status-icon.js +22 -0
- package/dist/components/status-icon/status-icon.js.map +1 -0
- package/dist/components/table/table.d.ts +4 -5
- package/dist/components/table/table.js +16 -16
- package/dist/components/table/table.js.map +1 -1
- package/dist/components/tabs/tabs.context.d.ts +1 -2
- package/dist/components/tabs/tabs.d.ts +1 -2
- package/dist/components/tabs/tabs.js +8 -8
- package/dist/components/tabs/tabs.js.map +1 -1
- package/dist/components/tag/index.d.ts +2 -0
- package/dist/components/tag/tag.d.ts +39 -0
- package/dist/components/tag/tag.js +41 -0
- package/dist/components/tag/tag.js.map +1 -0
- package/dist/components/text/text.d.ts +1 -2
- package/dist/components/text/text.js +2 -2
- package/dist/components/text/text.js.map +1 -1
- package/dist/components/textarea/textarea.d.ts +1 -2
- package/dist/components/textarea/textarea.js +2 -2
- package/dist/components/textarea/textarea.js.map +1 -1
- package/dist/components/tooltip/index.d.ts +1 -2
- package/dist/components/tooltip/tooltip.d.ts +3 -4
- package/dist/components/tooltip/tooltip.js +17 -6
- package/dist/components/tooltip/tooltip.js.map +1 -1
- package/dist/components/visually-hidden/visually-hidden.d.ts +1 -2
- package/dist/components/visually-hidden/visually-hidden.js +2 -2
- package/dist/components/visually-hidden/visually-hidden.js.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.js +7 -7
- package/dist/provider/hui-provider.context.d.ts +23 -7
- package/dist/provider/hui-provider.context.js +13 -12
- package/dist/provider/hui-provider.context.js.map +1 -1
- package/dist/provider/hui-provider.d.ts +1 -2
- package/dist/provider/index.d.ts +1 -1
- package/dist/types/distributive.d.ts +1 -0
- package/dist/types/hui-component.d.ts +11 -5
- package/dist/types/index.d.ts +3 -2
- package/dist/types/polymorphic.d.ts +4 -9
- package/package.json +9 -9
- package/dist/components/dialog/dialog.context.d.ts +0 -2
- package/dist/components/drawer/drawer.context.d.ts +0 -2
- package/dist/components/menu/menu.context.d.ts +0 -2
- package/dist/components/popover/popover.context.d.ts +0 -2
- package/dist/components/tooltip/tooltip.context.d.ts +0 -2
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
|
|
2
|
+
import { tagRecipe, toStrbool } from "@hebium-ui/core";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
// src/components/tag/tag.tsx
|
|
5
|
+
function Tag(rawProps) {
|
|
6
|
+
const { label, color, textOverflow, removeButton, removeButtonProps, onRemove, ...restProps } = useHuiProps("Tag", rawProps);
|
|
7
|
+
const shouldRenderRemoveButton = removeButton !== null && removeButton !== false;
|
|
8
|
+
const recipe = tagRecipe({
|
|
9
|
+
color,
|
|
10
|
+
textOverflow,
|
|
11
|
+
withRemoveButton: toStrbool(shouldRenderRemoveButton)
|
|
12
|
+
});
|
|
13
|
+
const cls = useHuiClassNames("Tag", recipe, rawProps);
|
|
14
|
+
const sls = useHuiStyles("Tag", rawProps);
|
|
15
|
+
const removeButtonContent = removeButton === void 0 ? /* @__PURE__ */ jsx("span", {
|
|
16
|
+
"aria-hidden": true,
|
|
17
|
+
className: cls.removeButtonIcon,
|
|
18
|
+
style: sls.removeButtonIcon
|
|
19
|
+
}) : removeButton;
|
|
20
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
21
|
+
className: cls.root,
|
|
22
|
+
style: sls.root,
|
|
23
|
+
...restProps,
|
|
24
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
25
|
+
className: cls.label,
|
|
26
|
+
style: sls.label,
|
|
27
|
+
children: label
|
|
28
|
+
}), shouldRenderRemoveButton && /* @__PURE__ */ jsx("button", {
|
|
29
|
+
type: "button",
|
|
30
|
+
className: cls.removeButton,
|
|
31
|
+
style: sls.removeButton,
|
|
32
|
+
"aria-label": `Remove ${label} Tag`,
|
|
33
|
+
onClick: onRemove,
|
|
34
|
+
...removeButtonProps,
|
|
35
|
+
children: removeButtonContent
|
|
36
|
+
})]
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
export { Tag };
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=tag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tag.js","names":[],"sources":["../../../src/components/tag/tag.tsx"],"sourcesContent":["import { tagRecipe, type TagSlots, type TagVariants, toStrbool } from \"@hebium-ui/core\";\nimport { type ComponentProps, type ReactElement, type ReactNode } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps } from \"~/types\";\n\ninterface TagOwnProps extends Omit<ComponentProps<\"span\">, \"color\" | \"children\"> {\n /**\n * The tag text.\n */\n label: string;\n /**\n * The semantic color of the tag.\n *\n * @default \"text\"\n */\n color?: TagVariants[\"color\"] | undefined;\n /**\n * How overflowing label text is displayed.\n *\n * @default \"unset\"\n */\n textOverflow?: TagVariants[\"textOverflow\"] | undefined;\n /**\n * The content of the remove button. Set to `null` or `false` to hide the button.\n *\n * @default close icon\n */\n removeButton?: ReactNode | undefined;\n /**\n * Props forwarded to the remove button, overriding its defaults.\n */\n removeButtonProps?: Omit<ComponentProps<\"button\">, \"children\" | \"className\" | \"style\"> | undefined;\n /**\n * Called when the remove button is activated. Overridden by `removeButtonProps.onClick`.\n */\n onRemove?: (() => void) | undefined;\n}\n\nexport type TagProps = HuiComponentProps<TagOwnProps, TagSlots>;\n\nexport function Tag(rawProps: TagProps): ReactElement {\n const {\n label,\n color,\n textOverflow,\n removeButton,\n removeButtonProps,\n onRemove,\n ...restProps\n } = useHuiProps(\"Tag\", rawProps);\n\n const shouldRenderRemoveButton = removeButton !== null && removeButton !== false;\n const recipe = tagRecipe({\n color,\n textOverflow,\n withRemoveButton: toStrbool(shouldRenderRemoveButton),\n });\n const cls = useHuiClassNames(\"Tag\", recipe, rawProps);\n const sls = useHuiStyles(\"Tag\", rawProps);\n\n const removeButtonContent = removeButton === undefined\n ? <span aria-hidden className={cls.removeButtonIcon} style={sls.removeButtonIcon} />\n : removeButton;\n\n return (\n <span\n className={cls.root}\n style={sls.root}\n {...restProps}\n >\n <span\n className={cls.label}\n style={sls.label}\n >\n {label}\n </span>\n {shouldRenderRemoveButton && (\n <button\n type=\"button\"\n className={cls.removeButton}\n style={sls.removeButton}\n aria-label={`Remove ${label} Tag`}\n onClick={onRemove}\n {...removeButtonProps}\n >\n {removeButtonContent}\n </button>\n )}\n </span>\n );\n}\n"],"mappings":";;;;AAwCA,SAAgB,IAAI,UAAkC;CACpD,MAAM,EACJ,OACA,OACA,cACA,cACA,mBACA,UACA,GAAG,cACD,YAAY,OAAO,QAAQ;CAE/B,MAAM,2BAA2B,iBAAiB,QAAQ,iBAAiB;CAC3E,MAAM,SAAS,UAAU;EACvB;EACA;EACA,kBAAkB,UAAU,wBAAwB;CACtD,CAAC;CACD,MAAM,MAAM,iBAAiB,OAAO,QAAQ,QAAQ;CACpD,MAAM,MAAM,aAAa,OAAO,QAAQ;CAExC,MAAM,sBAAsB,iBAAiB,KAAA,IACzC,oBAAC,QAAD;EAAM,eAAA;EAAY,WAAW,IAAI;EAAkB,OAAO,IAAI;CAAmB,CAAA,IACjF;CAEJ,OACE,qBAAC,QAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EAHN,UAAA,CAKE,oBAAC,QAAD;GACE,WAAW,IAAI;GACf,OAAO,IAAI;GAEV,UAAA;EACG,CAAA,GACL,4BACC,oBAAC,UAAD;GACE,MAAK;GACL,WAAW,IAAI;GACf,OAAO,IAAI;GACX,cAAY,UAAU,MAAM;GAC5B,SAAS;GACT,GAAI;GAEH,UAAA;EACK,CAAA,CAEN;;AAEV"}
|
|
@@ -19,5 +19,4 @@ interface TextOwnProps {
|
|
|
19
19
|
}
|
|
20
20
|
export type TextProps<E extends ElementType = "span"> = HuiPolymorphicProps<E, TextOwnProps, TextSlots>;
|
|
21
21
|
export declare function Text<E extends ElementType = "span">(rawProps: TextProps<E>): ReactElement;
|
|
22
|
-
export {};
|
|
23
|
-
//# sourceMappingURL=text.d.ts.map
|
|
22
|
+
export {};
|
|
@@ -9,8 +9,8 @@ function Text(rawProps) {
|
|
|
9
9
|
color,
|
|
10
10
|
textOverflow
|
|
11
11
|
});
|
|
12
|
-
const cls = useHuiClassNames("Text", recipe,
|
|
13
|
-
const sls = useHuiStyles("Text",
|
|
12
|
+
const cls = useHuiClassNames("Text", recipe, rawProps);
|
|
13
|
+
const sls = useHuiStyles("Text", rawProps);
|
|
14
14
|
return /* @__PURE__ */ jsx(Component, {
|
|
15
15
|
className: cls.root,
|
|
16
16
|
style: sls.root,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","names":[],"sources":["../../../src/components/text/text.tsx"],"sourcesContent":["import { textRecipe, type TextSlots, type TextVariants } from \"@hebium-ui/core\";\nimport { type ElementType, type ReactElement } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\n\ninterface TextOwnProps {\n /**\n * The semantic color of the text.\n *\n * @default \"text\"\n */\n color?: TextVariants[\"color\"] | undefined;\n /**\n * How overflowing text is displayed.\n * Use \"ellipsis\" to truncate text to a single line with an ellipsis.\n *\n * @default \"unset\"\n */\n textOverflow?: TextVariants[\"textOverflow\"] | undefined;\n}\n\nexport type TextProps<E extends ElementType = \"span\"> = HuiPolymorphicProps<\n E,\n TextOwnProps,\n TextSlots\n>;\n\nexport function Text<E extends ElementType = \"span\">(rawProps: TextProps<E>): ReactElement {\n const {\n as,\n color,\n textOverflow,\n children,\n ...restProps\n } = useHuiProps(\"Text\", rawProps);\n\n const Component = as ?? \"span\";\n const recipe = textRecipe({\n color,\n textOverflow,\n });\n const cls = useHuiClassNames(\"Text\", recipe,
|
|
1
|
+
{"version":3,"file":"text.js","names":[],"sources":["../../../src/components/text/text.tsx"],"sourcesContent":["import { textRecipe, type TextSlots, type TextVariants } from \"@hebium-ui/core\";\nimport { type ElementType, type ReactElement } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\n\ninterface TextOwnProps {\n /**\n * The semantic color of the text.\n *\n * @default \"text\"\n */\n color?: TextVariants[\"color\"] | undefined;\n /**\n * How overflowing text is displayed.\n * Use \"ellipsis\" to truncate text to a single line with an ellipsis.\n *\n * @default \"unset\"\n */\n textOverflow?: TextVariants[\"textOverflow\"] | undefined;\n}\n\nexport type TextProps<E extends ElementType = \"span\"> = HuiPolymorphicProps<\n E,\n TextOwnProps,\n TextSlots\n>;\n\nexport function Text<E extends ElementType = \"span\">(rawProps: TextProps<E>): ReactElement {\n const {\n as,\n color,\n textOverflow,\n children,\n ...restProps\n } = useHuiProps(\"Text\", rawProps);\n\n const Component = as ?? \"span\";\n const recipe = textRecipe({\n color,\n textOverflow,\n });\n const cls = useHuiClassNames(\"Text\", recipe, rawProps);\n const sls = useHuiStyles(\"Text\", rawProps);\n\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n"],"mappings":";;;;AA2BA,SAAgB,KAAqC,UAAsC;CACzF,MAAM,EACJ,IACA,OACA,cACA,UACA,GAAG,cACD,YAAY,QAAQ,QAAQ;CAEhC,MAAM,YAAY,MAAM;CACxB,MAAM,SAAS,WAAW;EACxB;EACA;CACF,CAAC;CACD,MAAM,MAAM,iBAAiB,QAAQ,QAAQ,QAAQ;CACrD,MAAM,MAAM,aAAa,QAAQ,QAAQ;CAEzC,OACE,oBAAC,WAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EAEH;CACQ,CAAA;AAEf"}
|
|
@@ -31,5 +31,4 @@ interface TextareaOwnProps extends HtmlTextareaProps {
|
|
|
31
31
|
}
|
|
32
32
|
export type TextareaProps = HuiComponentProps<TextareaOwnProps, InputSlots>;
|
|
33
33
|
export declare function Textarea(rawProps: TextareaProps): ReactElement;
|
|
34
|
-
export {};
|
|
35
|
-
//# sourceMappingURL=textarea.d.ts.map
|
|
34
|
+
export {};
|
|
@@ -20,8 +20,8 @@ function Textarea(rawProps) {
|
|
|
20
20
|
height: "auto",
|
|
21
21
|
error: toStrbool(inputState.invalid)
|
|
22
22
|
});
|
|
23
|
-
const cls = useHuiClassNames("Textarea", recipe, rawProps
|
|
24
|
-
const sls = useHuiStyles("Textarea", rawProps
|
|
23
|
+
const cls = useHuiClassNames("Textarea", recipe, rawProps);
|
|
24
|
+
const sls = useHuiStyles("Textarea", rawProps);
|
|
25
25
|
const hasLabel = !!label || !!description || !!error;
|
|
26
26
|
const controlAttrs = normalizeAttributes(inputControl.getControlAttributes(inputState));
|
|
27
27
|
const labelAttrs = normalizeAttributes(inputControl.getLabelAttributes(inputState));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textarea.js","names":[],"sources":["../../../src/components/textarea/textarea.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 HtmlTextareaProps = Omit<ComponentProps<\"textarea\">, \"children\" | \"color\">;\n\ninterface TextareaOwnProps extends HtmlTextareaProps {\n /**\n * The semantic color of the textarea.\n *\n * @default \"accent\"\n */\n color?: InputVariants[\"color\"] | undefined;\n /**\n * The label displayed above the textarea.\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 TextareaProps = HuiComponentProps<\n TextareaOwnProps,\n InputSlots\n>;\n\nexport function Textarea(rawProps: TextareaProps): ReactElement {\n const {\n id,\n color,\n label,\n description,\n error,\n labelProps,\n ...restProps\n } = useHuiProps(\"Textarea\", rawProps);\n\n const tmpId = useId();\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 height: \"auto\",\n error: toStrbool(inputState.invalid),\n });\n const cls = useHuiClassNames(\"Textarea\", recipe, rawProps
|
|
1
|
+
{"version":3,"file":"textarea.js","names":[],"sources":["../../../src/components/textarea/textarea.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 HtmlTextareaProps = Omit<ComponentProps<\"textarea\">, \"children\" | \"color\">;\n\ninterface TextareaOwnProps extends HtmlTextareaProps {\n /**\n * The semantic color of the textarea.\n *\n * @default \"accent\"\n */\n color?: InputVariants[\"color\"] | undefined;\n /**\n * The label displayed above the textarea.\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 TextareaProps = HuiComponentProps<\n TextareaOwnProps,\n InputSlots\n>;\n\nexport function Textarea(rawProps: TextareaProps): ReactElement {\n const {\n id,\n color,\n label,\n description,\n error,\n labelProps,\n ...restProps\n } = useHuiProps(\"Textarea\", rawProps);\n\n const tmpId = useId();\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 height: \"auto\",\n error: toStrbool(inputState.invalid),\n });\n const cls = useHuiClassNames(\"Textarea\", recipe, rawProps);\n const sls = useHuiStyles(\"Textarea\", rawProps);\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 <textarea\n className={cls.input}\n style={sls.input}\n {...controlAttrs}\n {...restProps}\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;AAuCA,SAAgB,SAAS,UAAuC;CAC9D,MAAM,EACJ,IACA,OACA,OACA,aACA,OACA,YACA,GAAG,cACD,YAAY,YAAY,QAAQ;CAEpC,MAAM,QAAQ,MAAM;CAEpB,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,QAAQ;EACR,OAAO,UAAU,WAAW,OAAO;CACrC,CAAC;CACD,MAAM,MAAM,iBAAiB,YAAY,QAAQ,QAAQ;CACzD,MAAM,MAAM,aAAa,YAAY,QAAQ;CAC7C,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,YAAD;GACE,WAAW,IAAI;GACf,OAAO,IAAI;GACX,GAAI;GACJ,GAAI;EACL,CAAA,CACE;;AAET"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import { Tooltip, TooltipContentProps, TooltipProps, TooltipTriggerProps } from "./tooltip.js";
|
|
2
|
-
|
|
3
|
-
export { Tooltip, TooltipContentProps, TooltipProps, TooltipTriggerProps, useTooltipId };
|
|
2
|
+
export { Tooltip, TooltipContentProps, TooltipProps, TooltipTriggerProps };
|
|
@@ -12,8 +12,8 @@ export interface TooltipProps {
|
|
|
12
12
|
children?: ReactNode | undefined;
|
|
13
13
|
}
|
|
14
14
|
declare function TooltipRoot(rawProps: TooltipProps): ReactElement;
|
|
15
|
-
export type TooltipTriggerProps<E extends ElementType = typeof Button
|
|
16
|
-
declare function Trigger<E extends ElementType = typeof Button
|
|
15
|
+
export type TooltipTriggerProps<E extends ElementType = typeof Button<"button">> = HuiPolymorphicProps<E, {}, ButtonSlots>;
|
|
16
|
+
declare function Trigger<E extends ElementType = typeof Button<"button">>(rawProps: TooltipTriggerProps<E>): ReactNode;
|
|
17
17
|
interface TooltipContentOwnProps {
|
|
18
18
|
/**
|
|
19
19
|
* The preferred anchor position of the tooltip.
|
|
@@ -47,5 +47,4 @@ export declare const Tooltip: typeof TooltipRoot & {
|
|
|
47
47
|
Trigger: typeof Trigger;
|
|
48
48
|
Content: typeof Content;
|
|
49
49
|
};
|
|
50
|
-
export {};
|
|
51
|
-
//# sourceMappingURL=tooltip.d.ts.map
|
|
50
|
+
export {};
|
|
@@ -5,6 +5,12 @@ import { popoverRecipe, tooltipControl } from "@hebium-ui/core";
|
|
|
5
5
|
import { useCallback, useId, useMemo } from "react";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
// src/components/tooltip/tooltip.tsx
|
|
8
|
+
const BUTTON_CLASSES = {
|
|
9
|
+
root: "",
|
|
10
|
+
content: "",
|
|
11
|
+
spinner: "",
|
|
12
|
+
status: ""
|
|
13
|
+
};
|
|
8
14
|
function TooltipRoot(rawProps) {
|
|
9
15
|
const { id, children } = useHuiProps("Tooltip", rawProps);
|
|
10
16
|
const tmpId = useId();
|
|
@@ -20,8 +26,8 @@ function TooltipRoot(rawProps) {
|
|
|
20
26
|
function Trigger(rawProps) {
|
|
21
27
|
const { as, onPointerEnter, onPointerLeave, onFocus, onBlur, ...restProps } = useHuiProps("TooltipTrigger", rawProps);
|
|
22
28
|
const Component = as ?? Button;
|
|
23
|
-
const cls = useHuiClassNames("TooltipTrigger",
|
|
24
|
-
const sls = useHuiStyles("TooltipTrigger",
|
|
29
|
+
const cls = useHuiClassNames("TooltipTrigger", BUTTON_CLASSES, rawProps);
|
|
30
|
+
const sls = useHuiStyles("TooltipTrigger", rawProps);
|
|
25
31
|
const tooltipId = useTooltipId();
|
|
26
32
|
const attrs = tooltipControl.getTriggerAttributes({ tooltipId }, { isButtonElement: as === void 0 });
|
|
27
33
|
const handlePointerEnter = useCallback((e) => {
|
|
@@ -42,8 +48,13 @@ function Trigger(rawProps) {
|
|
|
42
48
|
}, [onBlur, tooltipId]);
|
|
43
49
|
return /* @__PURE__ */ jsx(Component, {
|
|
44
50
|
...attrs,
|
|
45
|
-
|
|
46
|
-
|
|
51
|
+
...Component === Button ? {
|
|
52
|
+
classNames: cls,
|
|
53
|
+
styles: sls
|
|
54
|
+
} : {
|
|
55
|
+
className: cls.root,
|
|
56
|
+
style: sls.root
|
|
57
|
+
},
|
|
47
58
|
onPointerEnter: handlePointerEnter,
|
|
48
59
|
onPointerLeave: handlePointerLeave,
|
|
49
60
|
onFocus: handleFocus,
|
|
@@ -61,8 +72,8 @@ function Content(rawProps) {
|
|
|
61
72
|
visibility,
|
|
62
73
|
padding
|
|
63
74
|
});
|
|
64
|
-
const cls = useHuiClassNames("TooltipContent", recipe,
|
|
65
|
-
const sls = useHuiStyles("TooltipContent",
|
|
75
|
+
const cls = useHuiClassNames("TooltipContent", recipe, rawProps);
|
|
76
|
+
const sls = useHuiStyles("TooltipContent", rawProps);
|
|
66
77
|
const attrs = tooltipControl.getContentAttributes({ tooltipId });
|
|
67
78
|
const handlePointerLeave = useCallback((e) => {
|
|
68
79
|
onPointerLeave?.(e);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.js","names":[],"sources":["../../../src/components/tooltip/tooltip.tsx"],"sourcesContent":["import {\n type ButtonSlots,\n popoverRecipe,\n type PopoverSlots,\n type PopoverVariants,\n tooltipControl,\n} from \"@hebium-ui/core\";\nimport {\n type ElementType,\n type PointerEvent,\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 { Button } from \"../button\";\nimport { TooltipContext, type TooltipContextValue, useTooltipId } from \"./tooltip.context\";\n\nexport interface TooltipProps {\n /**\n * The id of the tooltip content element.\n */\n id?: string | undefined;\n children?: ReactNode | undefined;\n}\n\nfunction TooltipRoot(rawProps: TooltipProps): ReactElement {\n const {\n id,\n children,\n } = useHuiProps(\"Tooltip\", rawProps);\n\n const tmpId = useId();\n const tooltipId = id || tmpId;\n\n const contextValue = useMemo<TooltipContextValue>(() => {\n return {\n tooltipId,\n };\n }, [tooltipId]);\n\n return (\n <TooltipContext.Provider\n value={contextValue}\n >\n {children}\n </TooltipContext.Provider>\n );\n}\n\nexport type TooltipTriggerProps<E extends ElementType = typeof Button
|
|
1
|
+
{"version":3,"file":"tooltip.js","names":[],"sources":["../../../src/components/tooltip/tooltip.tsx"],"sourcesContent":["import {\n type ButtonSlots,\n popoverRecipe,\n type PopoverSlots,\n type PopoverVariants,\n tooltipControl,\n} from \"@hebium-ui/core\";\nimport {\n type ElementType,\n type PointerEvent,\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 { Button } from \"../button\";\nimport { TooltipContext, type TooltipContextValue, useTooltipId } from \"./tooltip.context\";\n\nconst BUTTON_CLASSES = { root: \"\", content: \"\", spinner: \"\", status: \"\" } satisfies Record<ButtonSlots, string>;\n\nexport interface TooltipProps {\n /**\n * The id of the tooltip content element.\n */\n id?: string | undefined;\n children?: ReactNode | undefined;\n}\n\nfunction TooltipRoot(rawProps: TooltipProps): ReactElement {\n const {\n id,\n children,\n } = useHuiProps(\"Tooltip\", rawProps);\n\n const tmpId = useId();\n const tooltipId = id || tmpId;\n\n const contextValue = useMemo<TooltipContextValue>(() => {\n return {\n tooltipId,\n };\n }, [tooltipId]);\n\n return (\n <TooltipContext.Provider\n value={contextValue}\n >\n {children}\n </TooltipContext.Provider>\n );\n}\n\nexport type TooltipTriggerProps<E extends ElementType = typeof Button<\"button\">> = HuiPolymorphicProps<\n E,\n {},\n ButtonSlots\n>;\n\nfunction Trigger<E extends ElementType = typeof Button<\"button\">>(rawProps: TooltipTriggerProps<E>): ReactNode {\n const {\n as,\n onPointerEnter,\n onPointerLeave,\n onFocus,\n onBlur,\n ...restProps\n } = useHuiProps(\"TooltipTrigger\", rawProps);\n\n const Component = as ?? Button;\n const cls = useHuiClassNames(\"TooltipTrigger\", BUTTON_CLASSES, rawProps);\n const sls = useHuiStyles(\"TooltipTrigger\", rawProps);\n\n const tooltipId = useTooltipId();\n const attrs = tooltipControl.getTriggerAttributes(\n { tooltipId },\n { isButtonElement: as === undefined },\n );\n\n const handlePointerEnter = useCallback((e: PointerEvent<HTMLElement>): void => {\n onPointerEnter?.(e);\n tooltipControl.showTooltip(tooltipId, e.currentTarget);\n }, [onPointerEnter, tooltipId]);\n\n const handlePointerLeave = useCallback((e: PointerEvent<HTMLElement>): void => {\n onPointerLeave?.(e);\n tooltipControl.hideTooltip(tooltipId);\n }, [onPointerLeave, tooltipId]);\n\n const handleFocus = useCallback((e: React.FocusEvent<HTMLElement>): void => {\n onFocus?.(e);\n tooltipControl.showTooltip(tooltipId, e.currentTarget);\n }, [onFocus, tooltipId]);\n\n const handleBlur = useCallback((e: React.FocusEvent<HTMLElement>): void => {\n onBlur?.(e);\n tooltipControl.hideTooltip(tooltipId);\n }, [onBlur, tooltipId]);\n\n return (\n <Component\n {...attrs}\n {...(Component === Button\n ? { classNames: cls, styles: sls }\n : { className: cls.root, style: sls.root })}\n onPointerEnter={handlePointerEnter}\n onPointerLeave={handlePointerLeave}\n onFocus={handleFocus}\n onBlur={handleBlur}\n {...restProps}\n />\n );\n}\n\ninterface TooltipContentOwnProps {\n /**\n * The preferred anchor position of the tooltip.\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 tooltip content.\n *\n * @default \"md\"\n */\n padding?: PopoverVariants[\"padding\"] | undefined;\n}\nexport type TooltipContentProps<E extends ElementType = \"div\"> = HuiPolymorphicProps<\n E,\n TooltipContentOwnProps,\n PopoverSlots\n>;\n\nfunction Content<E extends ElementType = \"div\">(rawProps: TooltipContentProps<E>): ReactElement {\n const {\n as,\n position,\n fallbacks,\n visibility,\n padding,\n children,\n onPointerLeave,\n ...restProps\n } = useHuiProps(\"TooltipContent\", rawProps);\n const Component = as ?? \"div\";\n\n const tooltipId = useTooltipId();\n const recipe = popoverRecipe({ position, fallbacks, visibility, padding });\n const cls = useHuiClassNames(\"TooltipContent\", recipe, rawProps);\n const sls = useHuiStyles(\"TooltipContent\", rawProps);\n const attrs = tooltipControl.getContentAttributes({ tooltipId });\n\n const handlePointerLeave = useCallback((e: PointerEvent<HTMLElement>): void => {\n onPointerLeave?.(e);\n tooltipControl.hideTooltip(tooltipId);\n }, [onPointerLeave, tooltipId]);\n\n return (\n <Component\n {...attrs}\n className={cls.root}\n style={sls.root}\n onPointerLeave={handlePointerLeave}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n\nexport const Tooltip = Object.assign(TooltipRoot, {\n Trigger,\n Content,\n});\n"],"mappings":";;;;;;;AAqBA,MAAM,iBAAiB;CAAE,MAAM;CAAI,SAAS;CAAI,SAAS;CAAI,QAAQ;AAAG;AAUxE,SAAS,YAAY,UAAsC;CACzD,MAAM,EACJ,IACA,aACE,YAAY,WAAW,QAAQ;CAEnC,MAAM,QAAQ,MAAM;CACpB,MAAM,YAAY,MAAM;CAExB,MAAM,eAAe,cAAmC;EACtD,OAAO,EACL,UACF;CACF,GAAG,CAAC,SAAS,CAAC;CAEd,OACE,oBAAC,eAAe,UAAhB;EACE,OAAO;EAEN;CACsB,CAAA;AAE7B;AAQA,SAAS,QAAyD,UAA6C;CAC7G,MAAM,EACJ,IACA,gBACA,gBACA,SACA,QACA,GAAG,cACD,YAAY,kBAAkB,QAAQ;CAE1C,MAAM,YAAY,MAAM;CACxB,MAAM,MAAM,iBAAiB,kBAAkB,gBAAgB,QAAQ;CACvE,MAAM,MAAM,aAAa,kBAAkB,QAAQ;CAEnD,MAAM,YAAY,aAAa;CAC/B,MAAM,QAAQ,eAAe,qBAC3B,EAAE,UAAU,GACZ,EAAE,iBAAiB,OAAO,KAAA,EAAU,CACtC;CAEA,MAAM,qBAAqB,aAAa,MAAuC;EAC7E,iBAAiB,CAAC;EAClB,eAAe,YAAY,WAAW,EAAE,aAAa;CACvD,GAAG,CAAC,gBAAgB,SAAS,CAAC;CAE9B,MAAM,qBAAqB,aAAa,MAAuC;EAC7E,iBAAiB,CAAC;EAClB,eAAe,YAAY,SAAS;CACtC,GAAG,CAAC,gBAAgB,SAAS,CAAC;CAE9B,MAAM,cAAc,aAAa,MAA2C;EAC1E,UAAU,CAAC;EACX,eAAe,YAAY,WAAW,EAAE,aAAa;CACvD,GAAG,CAAC,SAAS,SAAS,CAAC;CAEvB,MAAM,aAAa,aAAa,MAA2C;EACzE,SAAS,CAAC;EACV,eAAe,YAAY,SAAS;CACtC,GAAG,CAAC,QAAQ,SAAS,CAAC;CAEtB,OACE,oBAAC,WAAD;EACE,GAAI;EACJ,GAAK,cAAc,SACf;GAAE,YAAY;GAAK,QAAQ;EAAI,IAC/B;GAAE,WAAW,IAAI;GAAM,OAAO,IAAI;EAAK;EAC3C,gBAAgB;EAChB,gBAAgB;EAChB,SAAS;EACT,QAAQ;EACR,GAAI;CACL,CAAA;AAEL;AAmCA,SAAS,QAAuC,UAAgD;CAC9F,MAAM,EACJ,IACA,UACA,WACA,YACA,SACA,UACA,gBACA,GAAG,cACD,YAAY,kBAAkB,QAAQ;CAC1C,MAAM,YAAY,MAAM;CAExB,MAAM,YAAY,aAAa;CAC/B,MAAM,SAAS,cAAc;EAAE;EAAU;EAAW;EAAY;CAAQ,CAAC;CACzE,MAAM,MAAM,iBAAiB,kBAAkB,QAAQ,QAAQ;CAC/D,MAAM,MAAM,aAAa,kBAAkB,QAAQ;CACnD,MAAM,QAAQ,eAAe,qBAAqB,EAAE,UAAU,CAAC;CAE/D,MAAM,qBAAqB,aAAa,MAAuC;EAC7E,iBAAiB,CAAC;EAClB,eAAe,YAAY,SAAS;CACtC,GAAG,CAAC,gBAAgB,SAAS,CAAC;CAE9B,OACE,oBAAC,WAAD;EACE,GAAI;EACJ,WAAW,IAAI;EACf,OAAO,IAAI;EACX,gBAAgB;EAChB,GAAI;EAEH;CACQ,CAAA;AAEf;AAEA,MAAa,UAAU,OAAO,OAAO,aAAa;CAChD;CACA;AACF,CAAC"}
|
|
@@ -3,5 +3,4 @@ import "../../types/index.js";
|
|
|
3
3
|
import { VisuallyHiddenSlots } from "@hebium-ui/core";
|
|
4
4
|
import { ElementType, ReactElement } from "react";
|
|
5
5
|
export type VisuallyHiddenProps<E extends ElementType = "span"> = HuiPolymorphicProps<E, {}, VisuallyHiddenSlots>;
|
|
6
|
-
export declare function VisuallyHidden<E extends ElementType = "span">(rawProps: VisuallyHiddenProps<E>): ReactElement;
|
|
7
|
-
//# sourceMappingURL=visually-hidden.d.ts.map
|
|
6
|
+
export declare function VisuallyHidden<E extends ElementType = "span">(rawProps: VisuallyHiddenProps<E>): ReactElement;
|
|
@@ -6,8 +6,8 @@ function VisuallyHidden(rawProps) {
|
|
|
6
6
|
const { as, children, ...restProps } = useHuiProps("VisuallyHidden", rawProps);
|
|
7
7
|
const Component = as ?? "span";
|
|
8
8
|
const recipe = visuallyHiddenRecipe({});
|
|
9
|
-
const cls = useHuiClassNames("VisuallyHidden", recipe,
|
|
10
|
-
const sls = useHuiStyles("VisuallyHidden",
|
|
9
|
+
const cls = useHuiClassNames("VisuallyHidden", recipe, rawProps);
|
|
10
|
+
const sls = useHuiStyles("VisuallyHidden", rawProps);
|
|
11
11
|
return /* @__PURE__ */ jsx(Component, {
|
|
12
12
|
className: cls.root,
|
|
13
13
|
style: sls.root,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visually-hidden.js","names":[],"sources":["../../../src/components/visually-hidden/visually-hidden.tsx"],"sourcesContent":["import { visuallyHiddenRecipe, type VisuallyHiddenSlots } from \"@hebium-ui/core\";\nimport { type ElementType, type ReactElement } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\n\nexport type VisuallyHiddenProps<E extends ElementType = \"span\"> = HuiPolymorphicProps<\n E,\n {},\n VisuallyHiddenSlots\n>;\n\nexport function VisuallyHidden<E extends ElementType = \"span\">(rawProps: VisuallyHiddenProps<E>): ReactElement {\n const {\n as,\n children,\n ...restProps\n } = useHuiProps(\"VisuallyHidden\", rawProps);\n\n const Component = as ?? \"span\";\n const recipe = visuallyHiddenRecipe({});\n const cls = useHuiClassNames(\"VisuallyHidden\", recipe,
|
|
1
|
+
{"version":3,"file":"visually-hidden.js","names":[],"sources":["../../../src/components/visually-hidden/visually-hidden.tsx"],"sourcesContent":["import { visuallyHiddenRecipe, type VisuallyHiddenSlots } from \"@hebium-ui/core\";\nimport { type ElementType, type ReactElement } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\n\nexport type VisuallyHiddenProps<E extends ElementType = \"span\"> = HuiPolymorphicProps<\n E,\n {},\n VisuallyHiddenSlots\n>;\n\nexport function VisuallyHidden<E extends ElementType = \"span\">(rawProps: VisuallyHiddenProps<E>): ReactElement {\n const {\n as,\n children,\n ...restProps\n } = useHuiProps(\"VisuallyHidden\", rawProps);\n\n const Component = as ?? \"span\";\n const recipe = visuallyHiddenRecipe({});\n const cls = useHuiClassNames(\"VisuallyHidden\", recipe, rawProps);\n const sls = useHuiStyles(\"VisuallyHidden\", rawProps);\n\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n"],"mappings":";;;;AAWA,SAAgB,eAA+C,UAAgD;CAC7G,MAAM,EACJ,IACA,UACA,GAAG,cACD,YAAY,kBAAkB,QAAQ;CAE1C,MAAM,YAAY,MAAM;CACxB,MAAM,SAAS,qBAAqB,CAAC,CAAC;CACtC,MAAM,MAAM,iBAAiB,kBAAkB,QAAQ,QAAQ;CAC/D,MAAM,MAAM,aAAa,kBAAkB,QAAQ;CAEnD,OACE,oBAAC,WAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EAEH;CACQ,CAAA;AAEf"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,22 +5,22 @@ import { Blockquote, BlockquoteProps } from "./components/blockquote/blockquote.
|
|
|
5
5
|
import { Button, ButtonProps } from "./components/button/button.js";
|
|
6
6
|
import { Checkbox, CheckboxProps } from "./components/checkbox/checkbox.js";
|
|
7
7
|
import { Code, CodeProps } from "./components/code/code.js";
|
|
8
|
+
import { Label, LabelProps } from "./components/label/label.js";
|
|
9
|
+
import { Combobox, ComboboxFormValueProps, ComboboxProps, ComboboxSelectOption, ComboboxTextOption } from "./components/combobox/combobox.js";
|
|
8
10
|
import { Details, DetailsProps } from "./components/details/details.js";
|
|
9
11
|
import { Heading, HeadingProps } from "./components/heading/heading.js";
|
|
10
12
|
import { Dialog, DialogCloseProps, DialogContentProps, DialogProps, DialogTriggerProps } from "./components/dialog/dialog.js";
|
|
11
|
-
import { useDialogId } from "./components/dialog/dialog.context.js";
|
|
12
13
|
import { DdProps, Dl, DlProps, DtProps } from "./components/dl/dl.js";
|
|
13
14
|
import { Drawer, DrawerCloseProps, DrawerContentProps, DrawerProps, DrawerTriggerProps } from "./components/drawer/drawer.js";
|
|
14
|
-
import { useDrawerId } from "./components/drawer/drawer.context.js";
|
|
15
15
|
import { Fieldset, FieldsetProps } from "./components/fieldset/fieldset.js";
|
|
16
16
|
import { Hr, HrProps } from "./components/hr/hr.js";
|
|
17
|
-
import {
|
|
17
|
+
import { InlineFeedback, InlineFeedbackProps } from "./components/inline-feedback/inline-feedback.js";
|
|
18
18
|
import { Input, InputProps } from "./components/input/input.js";
|
|
19
19
|
import { Menu, MenuContentProps, MenuItemProps, MenuProps, MenuTriggerProps } from "./components/menu/menu.js";
|
|
20
|
-
import {
|
|
20
|
+
import { Tag, TagProps } from "./components/tag/tag.js";
|
|
21
|
+
import { MultiCombobox, MultiComboboxFormValueProps, MultiComboboxItemState, MultiComboboxProps, MultiComboboxTagContext, MultiComboboxTagProps } from "./components/multi-combobox/multi-combobox.js";
|
|
21
22
|
import { Paragraph, ParagraphProps } from "./components/paragraph/paragraph.js";
|
|
22
23
|
import { Popover, PopoverContentProps, PopoverProps, PopoverTriggerProps } from "./components/popover/popover.js";
|
|
23
|
-
import { usePopoverId } from "./components/popover/popover.context.js";
|
|
24
24
|
import { Progress, ProgressProps } from "./components/progress/progress.js";
|
|
25
25
|
import { Radio, RadioProps } from "./components/radio/radio.js";
|
|
26
26
|
import { Radiogroup, RadiogroupProps } from "./components/radiogroup/radiogroup.js";
|
|
@@ -28,15 +28,15 @@ import { Section, SectionProps } from "./components/section/section.js";
|
|
|
28
28
|
import { SegmentedControl, SegmentedControlItemProps, SegmentedControlProps } from "./components/segmented-control/segmented-control.js";
|
|
29
29
|
import { Select, SelectProps } from "./components/select/select.js";
|
|
30
30
|
import { SkipLink, SkipLinkProps } from "./components/skip-link/skip-link.js";
|
|
31
|
+
import { StatusIcon, StatusIconProps } from "./components/status-icon/status-icon.js";
|
|
31
32
|
import { CaptionProps, Table, TableProps, TbodyProps, TdProps, TfootProps, ThProps, TheadProps, TrProps } from "./components/table/table.js";
|
|
32
33
|
import { Tabs, TabsListProps, TabsPanelProps, TabsProps, TabsTabProps } from "./components/tabs/tabs.js";
|
|
33
34
|
import { Text, TextProps } from "./components/text/text.js";
|
|
34
35
|
import { Textarea, TextareaProps } from "./components/textarea/textarea.js";
|
|
35
36
|
import { Tooltip, TooltipContentProps, TooltipProps, TooltipTriggerProps } from "./components/tooltip/tooltip.js";
|
|
36
|
-
import { useTooltipId } from "./components/tooltip/tooltip.context.js";
|
|
37
37
|
import { VisuallyHidden, VisuallyHiddenProps } from "./components/visually-hidden/visually-hidden.js";
|
|
38
38
|
import "./components/index.js";
|
|
39
39
|
import { HuiComponentPropsMap, HuiProviderContext, HuiProviderContextValue, useHuiClassNames, useHuiProps, useHuiProviderContext, useHuiStyles } from "./provider/hui-provider.context.js";
|
|
40
40
|
import { HuiProvider } from "./provider/hui-provider.js";
|
|
41
41
|
import "./provider/index.js";
|
|
42
|
-
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, HuiComponentPropsMap, HuiProvider, HuiProviderContext, HuiProviderContextValue, 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, SkipLink, SkipLinkProps, Table, TableProps, Tabs, TabsListProps, TabsPanelProps, TabsProps, TabsTabProps, TbodyProps, TdProps, Text, TextProps, Textarea, TextareaProps, TfootProps, ThProps, TheadProps, Tooltip, TooltipContentProps, TooltipProps, TooltipTriggerProps, TrProps, VisuallyHidden, VisuallyHiddenProps,
|
|
42
|
+
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, HuiComponentPropsMap, HuiProvider, HuiProviderContext, HuiProviderContextValue, 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, useHuiClassNames, useHuiProps, useHuiProviderContext, useHuiStyles };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { HuiProviderContext, useHuiClassNames, useHuiProps, useHuiProviderContext, useHuiStyles } from "./provider/hui-provider.context.js";
|
|
2
2
|
import { HuiProvider } from "./provider/hui-provider.js";
|
|
3
|
+
import { StatusIcon } from "./components/status-icon/status-icon.js";
|
|
3
4
|
import { Alert } from "./components/alert/alert.js";
|
|
4
5
|
import { Anchor } from "./components/anchor/anchor.js";
|
|
5
6
|
import { Avatar } from "./components/avatar/avatar.js";
|
|
@@ -7,21 +8,21 @@ import { Blockquote } from "./components/blockquote/blockquote.js";
|
|
|
7
8
|
import { Button } from "./components/button/button.js";
|
|
8
9
|
import { Checkbox } from "./components/checkbox/checkbox.js";
|
|
9
10
|
import { Code } from "./components/code/code.js";
|
|
11
|
+
import { Label } from "./components/label/label.js";
|
|
12
|
+
import { Combobox } from "./components/combobox/combobox.js";
|
|
10
13
|
import { Details } from "./components/details/details.js";
|
|
11
14
|
import { Heading } from "./components/heading/heading.js";
|
|
12
|
-
import { useDialogId } from "./components/dialog/dialog.context.js";
|
|
13
15
|
import { Dialog } from "./components/dialog/dialog.js";
|
|
14
16
|
import { Dl } from "./components/dl/dl.js";
|
|
15
|
-
import { useDrawerId } from "./components/drawer/drawer.context.js";
|
|
16
17
|
import { Drawer } from "./components/drawer/drawer.js";
|
|
17
18
|
import { Fieldset } from "./components/fieldset/fieldset.js";
|
|
18
19
|
import { Hr } from "./components/hr/hr.js";
|
|
19
|
-
import {
|
|
20
|
+
import { InlineFeedback } from "./components/inline-feedback/inline-feedback.js";
|
|
20
21
|
import { Input } from "./components/input/input.js";
|
|
21
|
-
import { useMenuId } from "./components/menu/menu.context.js";
|
|
22
22
|
import { Menu } from "./components/menu/menu.js";
|
|
23
|
+
import { Tag } from "./components/tag/tag.js";
|
|
24
|
+
import { MultiCombobox } from "./components/multi-combobox/multi-combobox.js";
|
|
23
25
|
import { Paragraph } from "./components/paragraph/paragraph.js";
|
|
24
|
-
import { usePopoverId } from "./components/popover/popover.context.js";
|
|
25
26
|
import { Popover } from "./components/popover/popover.js";
|
|
26
27
|
import { Progress } from "./components/progress/progress.js";
|
|
27
28
|
import { Radio } from "./components/radio/radio.js";
|
|
@@ -34,7 +35,6 @@ import { Table } from "./components/table/table.js";
|
|
|
34
35
|
import { Tabs } from "./components/tabs/tabs.js";
|
|
35
36
|
import { Text } from "./components/text/text.js";
|
|
36
37
|
import { Textarea } from "./components/textarea/textarea.js";
|
|
37
|
-
import { useTooltipId } from "./components/tooltip/tooltip.context.js";
|
|
38
38
|
import { Tooltip } from "./components/tooltip/tooltip.js";
|
|
39
39
|
import { VisuallyHidden } from "./components/visually-hidden/visually-hidden.js";
|
|
40
|
-
export { Alert, Anchor, Avatar, Blockquote, Button, Checkbox, Code, Details, Dialog, Dl, Drawer, Fieldset, Heading, Hr, HuiProvider, HuiProviderContext, Input, Label, Menu, Paragraph, Popover, Progress, Radio, Radiogroup, Section, SegmentedControl, Select, SkipLink, Table, Tabs, Text, Textarea, Tooltip, VisuallyHidden,
|
|
40
|
+
export { Alert, Anchor, Avatar, Blockquote, Button, Checkbox, Code, Combobox, Details, Dialog, Dl, Drawer, Fieldset, Heading, Hr, HuiProvider, HuiProviderContext, InlineFeedback, Input, Label, Menu, MultiCombobox, Paragraph, Popover, Progress, Radio, Radiogroup, Section, SegmentedControl, Select, SkipLink, StatusIcon, Table, Tabs, Tag, Text, Textarea, Tooltip, VisuallyHidden, useHuiClassNames, useHuiProps, useHuiProviderContext, useHuiStyles };
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { DistributiveOmit } from "../types/distributive.js";
|
|
2
|
+
import { HuiStyleProps } from "../types/hui-component.js";
|
|
3
|
+
import "../components/index.js";
|
|
1
4
|
import { AlertProps } from "../components/alert/alert.js";
|
|
2
5
|
import { AnchorProps } from "../components/anchor/anchor.js";
|
|
3
6
|
import { AvatarProps } from "../components/avatar/avatar.js";
|
|
@@ -5,6 +8,8 @@ import { BlockquoteProps } from "../components/blockquote/blockquote.js";
|
|
|
5
8
|
import { ButtonProps } from "../components/button/button.js";
|
|
6
9
|
import { CheckboxProps } from "../components/checkbox/checkbox.js";
|
|
7
10
|
import { CodeProps } from "../components/code/code.js";
|
|
11
|
+
import { LabelProps } from "../components/label/label.js";
|
|
12
|
+
import { ComboboxProps } from "../components/combobox/combobox.js";
|
|
8
13
|
import { DetailsProps } from "../components/details/details.js";
|
|
9
14
|
import { HeadingProps } from "../components/heading/heading.js";
|
|
10
15
|
import { DialogCloseProps, DialogContentProps, DialogProps, DialogTriggerProps } from "../components/dialog/dialog.js";
|
|
@@ -12,9 +17,11 @@ import { DdProps, DlProps, DtProps } from "../components/dl/dl.js";
|
|
|
12
17
|
import { DrawerCloseProps, DrawerContentProps, DrawerProps, DrawerTriggerProps } from "../components/drawer/drawer.js";
|
|
13
18
|
import { FieldsetProps } from "../components/fieldset/fieldset.js";
|
|
14
19
|
import { HrProps } from "../components/hr/hr.js";
|
|
15
|
-
import {
|
|
20
|
+
import { InlineFeedbackProps } from "../components/inline-feedback/inline-feedback.js";
|
|
16
21
|
import { InputProps } from "../components/input/input.js";
|
|
17
22
|
import { MenuContentProps, MenuItemProps, MenuProps, MenuTriggerProps } from "../components/menu/menu.js";
|
|
23
|
+
import { TagProps } from "../components/tag/tag.js";
|
|
24
|
+
import { MultiComboboxProps } from "../components/multi-combobox/multi-combobox.js";
|
|
18
25
|
import { ParagraphProps } from "../components/paragraph/paragraph.js";
|
|
19
26
|
import { PopoverContentProps, PopoverProps, PopoverTriggerProps } from "../components/popover/popover.js";
|
|
20
27
|
import { ProgressProps } from "../components/progress/progress.js";
|
|
@@ -24,13 +31,14 @@ import { SectionProps } from "../components/section/section.js";
|
|
|
24
31
|
import { SegmentedControlItemProps, SegmentedControlProps } from "../components/segmented-control/segmented-control.js";
|
|
25
32
|
import { SelectProps } from "../components/select/select.js";
|
|
26
33
|
import { SkipLinkProps } from "../components/skip-link/skip-link.js";
|
|
34
|
+
import { StatusIconProps } from "../components/status-icon/status-icon.js";
|
|
27
35
|
import { CaptionProps, TableProps, TbodyProps, TdProps, TfootProps, ThProps, TheadProps, TrProps } from "../components/table/table.js";
|
|
28
36
|
import { TabsListProps, TabsPanelProps, TabsProps, TabsTabProps } from "../components/tabs/tabs.js";
|
|
29
37
|
import { TextProps } from "../components/text/text.js";
|
|
30
38
|
import { TextareaProps } from "../components/textarea/textarea.js";
|
|
31
39
|
import { TooltipContentProps, TooltipProps, TooltipTriggerProps } from "../components/tooltip/tooltip.js";
|
|
32
40
|
import { VisuallyHiddenProps } from "../components/visually-hidden/visually-hidden.js";
|
|
33
|
-
import "../
|
|
41
|
+
import "../types/index.js";
|
|
34
42
|
import { CSSProperties, ElementType } from "react";
|
|
35
43
|
export interface HuiComponentPropsMap {
|
|
36
44
|
Alert: Partial<AlertProps>;
|
|
@@ -40,6 +48,7 @@ export interface HuiComponentPropsMap {
|
|
|
40
48
|
Button: Partial<ButtonProps>;
|
|
41
49
|
Checkbox: Partial<CheckboxProps>;
|
|
42
50
|
Code: Partial<CodeProps>;
|
|
51
|
+
Combobox: Partial<ComboboxProps>;
|
|
43
52
|
Details: Partial<DetailsProps>;
|
|
44
53
|
Dialog: Partial<DialogProps>;
|
|
45
54
|
DialogTrigger: Partial<DialogTriggerProps>;
|
|
@@ -55,12 +64,14 @@ export interface HuiComponentPropsMap {
|
|
|
55
64
|
Fieldset: Partial<FieldsetProps>;
|
|
56
65
|
Heading: Partial<HeadingProps>;
|
|
57
66
|
Hr: Partial<HrProps>;
|
|
67
|
+
InlineFeedback: Partial<InlineFeedbackProps>;
|
|
58
68
|
Input: Partial<InputProps>;
|
|
59
69
|
Label: Partial<LabelProps>;
|
|
60
70
|
Menu: Partial<MenuProps>;
|
|
61
71
|
MenuContent: Partial<MenuContentProps>;
|
|
62
72
|
MenuItem: Partial<MenuItemProps>;
|
|
63
73
|
MenuTrigger: Partial<MenuTriggerProps>;
|
|
74
|
+
MultiCombobox: Partial<MultiComboboxProps>;
|
|
64
75
|
Paragraph: Partial<ParagraphProps>;
|
|
65
76
|
Popover: Partial<PopoverProps>;
|
|
66
77
|
PopoverTrigger: Partial<PopoverTriggerProps>;
|
|
@@ -73,6 +84,7 @@ export interface HuiComponentPropsMap {
|
|
|
73
84
|
SegmentedControlItem: Partial<SegmentedControlItemProps>;
|
|
74
85
|
SegmentedControl: Partial<SegmentedControlProps<string>>;
|
|
75
86
|
SkipLink: Partial<SkipLinkProps>;
|
|
87
|
+
StatusIcon: Partial<StatusIconProps>;
|
|
76
88
|
Table: Partial<TableProps>;
|
|
77
89
|
TableCaption: Partial<CaptionProps>;
|
|
78
90
|
TableThead: Partial<TheadProps>;
|
|
@@ -85,6 +97,7 @@ export interface HuiComponentPropsMap {
|
|
|
85
97
|
TabsList: Partial<TabsListProps>;
|
|
86
98
|
TabsTab: Partial<TabsTabProps>;
|
|
87
99
|
TabsPanel: Partial<TabsPanelProps>;
|
|
100
|
+
Tag: Partial<TagProps>;
|
|
88
101
|
Text: Partial<TextProps>;
|
|
89
102
|
Textarea: Partial<TextareaProps>;
|
|
90
103
|
Tooltip: Partial<TooltipProps>;
|
|
@@ -94,19 +107,22 @@ export interface HuiComponentPropsMap {
|
|
|
94
107
|
}
|
|
95
108
|
type HuiComponentName = keyof HuiComponentPropsMap;
|
|
96
109
|
type HuiDefaultProps = Partial<HuiComponentPropsMap>;
|
|
110
|
+
type HuiComponentSlots<K extends HuiComponentName> = { [P in HuiComponentName]: HuiComponentPropsMap[P] extends {
|
|
111
|
+
classNames?: infer C;
|
|
112
|
+
} ? Extract<keyof NonNullable<C>, string> : never; }[K];
|
|
113
|
+
type HuiStyledComponentName = { [K in HuiComponentName]: [HuiComponentSlots<K>] extends [never] ? never : K; }[HuiComponentName];
|
|
97
114
|
export interface HuiProviderContextValue {
|
|
98
115
|
defaultProps: HuiDefaultProps;
|
|
99
116
|
}
|
|
100
117
|
export declare const HuiProviderContext: import("react").Context<HuiProviderContextValue | null>;
|
|
101
118
|
export declare function useHuiProviderContext(): HuiProviderContextValue;
|
|
102
119
|
declare const STYLING_PROPS: readonly ["className", "style", "classNames", "styles"];
|
|
103
|
-
type HuiProps<P extends object, E extends ElementType> =
|
|
120
|
+
type HuiProps<P extends object, E extends ElementType> = DistributiveOmit<P, typeof STYLING_PROPS[number] | "as"> & Pick<{
|
|
104
121
|
as?: E | undefined;
|
|
105
122
|
}, "as" & keyof P>;
|
|
106
123
|
export declare function useHuiProps<K extends HuiComponentName, P extends object, E extends ElementType = Extract<P["as" & keyof P], ElementType>>(key: K, rawProps: P & {
|
|
107
124
|
as?: E | undefined;
|
|
108
125
|
}): HuiProps<P, E>;
|
|
109
|
-
export declare function useHuiClassNames<K extends
|
|
110
|
-
export declare function useHuiStyles<K extends
|
|
111
|
-
export {};
|
|
112
|
-
//# sourceMappingURL=hui-provider.context.d.ts.map
|
|
126
|
+
export declare function useHuiClassNames<K extends HuiStyledComponentName>(key: K, recipe: Record<HuiComponentSlots<NoInfer<K>>, string>, rawProps?: Pick<HuiStyleProps<HuiComponentSlots<NoInfer<K>>>, "className" | "classNames">): Record<HuiComponentSlots<K>, string>;
|
|
127
|
+
export declare function useHuiStyles<K extends HuiStyledComponentName>(key: K, rawProps?: Pick<HuiStyleProps<HuiComponentSlots<NoInfer<K>>>, "style" | "styles">): Partial<Record<HuiComponentSlots<K>, CSSProperties>>;
|
|
128
|
+
export {};
|
|
@@ -9,6 +9,9 @@ function useHuiProviderContext() {
|
|
|
9
9
|
function useHuiDefaultProps(key) {
|
|
10
10
|
return useHuiProviderContext().defaultProps[key];
|
|
11
11
|
}
|
|
12
|
+
function useHuiStyleDefaultProps(key) {
|
|
13
|
+
return useHuiDefaultProps(key);
|
|
14
|
+
}
|
|
12
15
|
const STYLING_PROPS = [
|
|
13
16
|
"className",
|
|
14
17
|
"style",
|
|
@@ -23,19 +26,17 @@ function useHuiProps(key, rawProps) {
|
|
|
23
26
|
return props;
|
|
24
27
|
}, [defaultProps, rawProps]);
|
|
25
28
|
}
|
|
26
|
-
function useHuiClassNames(key, recipe,
|
|
27
|
-
const defaultProps =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
else if ("className" in defaultProps && defaultProps.className) return ccAll(recipe, { root: defaultProps.className }, rawClassNames);
|
|
31
|
-
else return ccAll(recipe, rawClassNames);
|
|
29
|
+
function useHuiClassNames(key, recipe, rawProps = {}) {
|
|
30
|
+
const defaultProps = useHuiStyleDefaultProps(key);
|
|
31
|
+
const emptyClassNames = {};
|
|
32
|
+
return ccAll(recipe, { root: defaultProps?.className }, defaultProps?.classNames ?? emptyClassNames, { root: rawProps.className }, rawProps.classNames ?? emptyClassNames);
|
|
32
33
|
}
|
|
33
|
-
function
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
function resolveStyles(props = {}) {
|
|
35
|
+
return msAll({ root: props.style }, props.styles ?? {});
|
|
36
|
+
}
|
|
37
|
+
function useHuiStyles(key, rawProps = {}) {
|
|
38
|
+
const defaultProps = useHuiStyleDefaultProps(key);
|
|
39
|
+
return msAll(resolveStyles(defaultProps), resolveStyles(rawProps));
|
|
39
40
|
}
|
|
40
41
|
export { HuiProviderContext, useHuiClassNames, useHuiProps, useHuiProviderContext, useHuiStyles };
|
|
41
42
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hui-provider.context.js","names":[],"sources":["../../src/provider/hui-provider.context.ts"],"sourcesContent":["import { ccAll, msAll } from \"@hebium-ui/core\";\nimport { createContext, type CSSProperties, type ElementType, useContext, useMemo } from \"react\";\nimport type {\n AlertProps,\n AnchorProps,\n AvatarProps,\n BlockquoteProps,\n ButtonProps,\n CaptionProps,\n CheckboxProps,\n CodeProps,\n DdProps,\n DetailsProps,\n DialogCloseProps,\n DialogContentProps,\n DialogProps,\n DialogTriggerProps,\n DlProps,\n DrawerCloseProps,\n DrawerContentProps,\n DrawerProps,\n DrawerTriggerProps,\n DtProps,\n FieldsetProps,\n HeadingProps,\n HrProps,\n InputProps,\n LabelProps,\n MenuContentProps,\n MenuItemProps,\n MenuProps,\n MenuTriggerProps,\n ParagraphProps,\n PopoverContentProps,\n PopoverProps,\n PopoverTriggerProps,\n ProgressProps,\n RadiogroupProps,\n RadioProps,\n SectionProps,\n SegmentedControlItemProps,\n SegmentedControlProps,\n SelectProps,\n SkipLinkProps,\n TableProps,\n TabsListProps,\n TabsPanelProps,\n TabsProps,\n TabsTabProps,\n TbodyProps,\n TdProps,\n TextareaProps,\n TextProps,\n TfootProps,\n TheadProps,\n ThProps,\n TooltipContentProps,\n TooltipProps,\n TooltipTriggerProps,\n TrProps,\n VisuallyHiddenProps,\n} from \"~/components\";\nimport { mergeProps } from \"./merge-props\";\n\nexport interface HuiComponentPropsMap {\n Alert: Partial<AlertProps>;\n Anchor: Partial<AnchorProps>;\n Avatar: Partial<AvatarProps>;\n Blockquote: Partial<BlockquoteProps>;\n Button: Partial<ButtonProps>;\n Checkbox: Partial<CheckboxProps>;\n Code: Partial<CodeProps>;\n Details: Partial<DetailsProps>;\n Dialog: Partial<DialogProps>;\n DialogTrigger: Partial<DialogTriggerProps>;\n DialogContent: Partial<DialogContentProps>;\n DialogClose: Partial<DialogCloseProps>;\n Drawer: Partial<DrawerProps>;\n DrawerTrigger: Partial<DrawerTriggerProps>;\n DrawerContent: Partial<DrawerContentProps>;\n DrawerClose: Partial<DrawerCloseProps>;\n Dl: Partial<DlProps>;\n DlDt: Partial<DtProps>;\n DlDd: Partial<DdProps>;\n Fieldset: Partial<FieldsetProps>;\n Heading: Partial<HeadingProps>;\n Hr: Partial<HrProps>;\n Input: Partial<InputProps>;\n Label: Partial<LabelProps>;\n Menu: Partial<MenuProps>;\n MenuContent: Partial<MenuContentProps>;\n MenuItem: Partial<MenuItemProps>;\n MenuTrigger: Partial<MenuTriggerProps>;\n Paragraph: Partial<ParagraphProps>;\n Popover: Partial<PopoverProps>;\n PopoverTrigger: Partial<PopoverTriggerProps>;\n PopoverContent: Partial<PopoverContentProps>;\n Progress: Partial<ProgressProps>;\n Radio: Partial<RadioProps>;\n Radiogroup: Partial<RadiogroupProps>;\n Section: Partial<SectionProps>;\n Select: Partial<SelectProps>;\n SegmentedControlItem: Partial<SegmentedControlItemProps>;\n SegmentedControl: Partial<SegmentedControlProps<string>>;\n SkipLink: Partial<SkipLinkProps>;\n Table: Partial<TableProps>;\n TableCaption: Partial<CaptionProps>;\n TableThead: Partial<TheadProps>;\n TableTbody: Partial<TbodyProps>;\n TableTfoot: Partial<TfootProps>;\n TableTr: Partial<TrProps>;\n TableTh: Partial<ThProps>;\n TableTd: Partial<TdProps>;\n Tabs: Partial<TabsProps<string>>;\n TabsList: Partial<TabsListProps>;\n TabsTab: Partial<TabsTabProps>;\n TabsPanel: Partial<TabsPanelProps>;\n Text: Partial<TextProps>;\n Textarea: Partial<TextareaProps>;\n Tooltip: Partial<TooltipProps>;\n TooltipTrigger: Partial<TooltipTriggerProps>;\n TooltipContent: Partial<TooltipContentProps>;\n VisuallyHidden: Partial<VisuallyHiddenProps>;\n}\n\ntype HuiComponentName = keyof HuiComponentPropsMap;\ntype HuiDefaultProps = Partial<HuiComponentPropsMap>;\n\nexport interface HuiProviderContextValue {\n defaultProps: HuiDefaultProps;\n}\n\nexport const HuiProviderContext = createContext<HuiProviderContextValue | null>(null);\n\nexport function useHuiProviderContext(): HuiProviderContextValue {\n const context = useContext(HuiProviderContext);\n return context ?? { defaultProps: {} };\n}\n\nfunction useHuiDefaultProps<K extends HuiComponentName>(key: K): HuiDefaultProps[K] {\n const ctx = useHuiProviderContext();\n return ctx.defaultProps[key];\n}\n\nconst STYLING_PROPS = [\"className\", \"style\", \"classNames\", \"styles\"] as const;\n\n// Keep `as` explicit so JSX element inference survives omission of generic props.\ntype HuiProps<P extends object, E extends ElementType> =\n &
|
|
1
|
+
{"version":3,"file":"hui-provider.context.js","names":[],"sources":["../../src/provider/hui-provider.context.ts"],"sourcesContent":["import { ccAll, msAll } from \"@hebium-ui/core\";\nimport { createContext, type CSSProperties, type ElementType, useContext, useMemo } from \"react\";\nimport type {\n AlertProps,\n AnchorProps,\n AvatarProps,\n BlockquoteProps,\n ButtonProps,\n CaptionProps,\n CheckboxProps,\n CodeProps,\n ComboboxProps,\n DdProps,\n DetailsProps,\n DialogCloseProps,\n DialogContentProps,\n DialogProps,\n DialogTriggerProps,\n DlProps,\n DrawerCloseProps,\n DrawerContentProps,\n DrawerProps,\n DrawerTriggerProps,\n DtProps,\n FieldsetProps,\n HeadingProps,\n HrProps,\n InlineFeedbackProps,\n InputProps,\n LabelProps,\n MenuContentProps,\n MenuItemProps,\n MenuProps,\n MenuTriggerProps,\n MultiComboboxProps,\n ParagraphProps,\n PopoverContentProps,\n PopoverProps,\n PopoverTriggerProps,\n ProgressProps,\n RadiogroupProps,\n RadioProps,\n SectionProps,\n SegmentedControlItemProps,\n SegmentedControlProps,\n SelectProps,\n SkipLinkProps,\n StatusIconProps,\n TableProps,\n TabsListProps,\n TabsPanelProps,\n TabsProps,\n TabsTabProps,\n TagProps,\n TbodyProps,\n TdProps,\n TextareaProps,\n TextProps,\n TfootProps,\n TheadProps,\n ThProps,\n TooltipContentProps,\n TooltipProps,\n TooltipTriggerProps,\n TrProps,\n VisuallyHiddenProps,\n} from \"~/components\";\nimport { type DistributiveOmit, type HuiStyleProps } from \"~/types\";\nimport { mergeProps } from \"./merge-props\";\n\nexport interface HuiComponentPropsMap {\n Alert: Partial<AlertProps>;\n Anchor: Partial<AnchorProps>;\n Avatar: Partial<AvatarProps>;\n Blockquote: Partial<BlockquoteProps>;\n Button: Partial<ButtonProps>;\n Checkbox: Partial<CheckboxProps>;\n Code: Partial<CodeProps>;\n Combobox: Partial<ComboboxProps>;\n Details: Partial<DetailsProps>;\n Dialog: Partial<DialogProps>;\n DialogTrigger: Partial<DialogTriggerProps>;\n DialogContent: Partial<DialogContentProps>;\n DialogClose: Partial<DialogCloseProps>;\n Drawer: Partial<DrawerProps>;\n DrawerTrigger: Partial<DrawerTriggerProps>;\n DrawerContent: Partial<DrawerContentProps>;\n DrawerClose: Partial<DrawerCloseProps>;\n Dl: Partial<DlProps>;\n DlDt: Partial<DtProps>;\n DlDd: Partial<DdProps>;\n Fieldset: Partial<FieldsetProps>;\n Heading: Partial<HeadingProps>;\n Hr: Partial<HrProps>;\n InlineFeedback: Partial<InlineFeedbackProps>;\n Input: Partial<InputProps>;\n Label: Partial<LabelProps>;\n Menu: Partial<MenuProps>;\n MenuContent: Partial<MenuContentProps>;\n MenuItem: Partial<MenuItemProps>;\n MenuTrigger: Partial<MenuTriggerProps>;\n MultiCombobox: Partial<MultiComboboxProps>;\n Paragraph: Partial<ParagraphProps>;\n Popover: Partial<PopoverProps>;\n PopoverTrigger: Partial<PopoverTriggerProps>;\n PopoverContent: Partial<PopoverContentProps>;\n Progress: Partial<ProgressProps>;\n Radio: Partial<RadioProps>;\n Radiogroup: Partial<RadiogroupProps>;\n Section: Partial<SectionProps>;\n Select: Partial<SelectProps>;\n SegmentedControlItem: Partial<SegmentedControlItemProps>;\n SegmentedControl: Partial<SegmentedControlProps<string>>;\n SkipLink: Partial<SkipLinkProps>;\n StatusIcon: Partial<StatusIconProps>;\n Table: Partial<TableProps>;\n TableCaption: Partial<CaptionProps>;\n TableThead: Partial<TheadProps>;\n TableTbody: Partial<TbodyProps>;\n TableTfoot: Partial<TfootProps>;\n TableTr: Partial<TrProps>;\n TableTh: Partial<ThProps>;\n TableTd: Partial<TdProps>;\n Tabs: Partial<TabsProps<string>>;\n TabsList: Partial<TabsListProps>;\n TabsTab: Partial<TabsTabProps>;\n TabsPanel: Partial<TabsPanelProps>;\n Tag: Partial<TagProps>;\n Text: Partial<TextProps>;\n Textarea: Partial<TextareaProps>;\n Tooltip: Partial<TooltipProps>;\n TooltipTrigger: Partial<TooltipTriggerProps>;\n TooltipContent: Partial<TooltipContentProps>;\n VisuallyHidden: Partial<VisuallyHiddenProps>;\n}\n\ntype HuiComponentName = keyof HuiComponentPropsMap;\ntype HuiDefaultProps = Partial<HuiComponentPropsMap>;\n\ntype HuiComponentSlots<K extends HuiComponentName> = {\n [P in HuiComponentName]: HuiComponentPropsMap[P] extends { classNames?: infer C }\n ? Extract<keyof NonNullable<C>, string>\n : never;\n}[K];\n\ntype HuiStyledComponentName = {\n [K in HuiComponentName]: [HuiComponentSlots<K>] extends [never] ? never : K;\n}[HuiComponentName];\n\nexport interface HuiProviderContextValue {\n defaultProps: HuiDefaultProps;\n}\n\nexport const HuiProviderContext = createContext<HuiProviderContextValue | null>(null);\n\nexport function useHuiProviderContext(): HuiProviderContextValue {\n const context = useContext(HuiProviderContext);\n return context ?? { defaultProps: {} };\n}\n\nfunction useHuiDefaultProps<K extends HuiComponentName>(key: K): HuiDefaultProps[K] {\n const ctx = useHuiProviderContext();\n return ctx.defaultProps[key];\n}\n\nfunction useHuiStyleDefaultProps<K extends HuiStyledComponentName>(\n key: K,\n): HuiStyleProps<HuiComponentSlots<K>> | undefined {\n return useHuiDefaultProps(key);\n}\n\nconst STYLING_PROPS = [\"className\", \"style\", \"classNames\", \"styles\"] as const;\n\n// Keep `as` explicit so JSX element inference survives omission of generic props.\ntype HuiProps<P extends object, E extends ElementType> =\n & DistributiveOmit<P, typeof STYLING_PROPS[number] | \"as\">\n & Pick<{ as?: E | undefined }, \"as\" & keyof P>;\n\nexport function useHuiProps<\n K extends HuiComponentName,\n P extends object,\n E extends ElementType = Extract<P[\"as\" & keyof P], ElementType>,\n>(\n key: K,\n rawProps: P & { as?: E | undefined },\n): HuiProps<P, E> {\n const defaultProps = useHuiDefaultProps(key);\n return useMemo(() => {\n const props = mergeProps((defaultProps ?? {}) as Partial<P>, rawProps);\n // Styling helpers resolve Provider and local values separately from rawProps.\n for (const prop of STYLING_PROPS) {\n delete props[prop as keyof P];\n }\n // Runtime removal establishes the distributive shape, which TypeScript cannot infer for generic P.\n return props as unknown as HuiProps<P, E>;\n }, [defaultProps, rawProps]);\n}\n\nexport function useHuiClassNames<K extends HuiStyledComponentName>(\n key: K,\n recipe: Record<HuiComponentSlots<NoInfer<K>>, string>,\n rawProps: Pick<HuiStyleProps<HuiComponentSlots<NoInfer<K>>>, \"className\" | \"classNames\"> = {},\n): Record<HuiComponentSlots<K>, string> {\n const defaultProps = useHuiStyleDefaultProps(key);\n const emptyClassNames: Partial<Record<HuiComponentSlots<K>, string | undefined>> = {};\n return ccAll<HuiComponentSlots<K>>(\n recipe,\n { root: defaultProps?.className } as Partial<Record<HuiComponentSlots<K>, string | undefined>>,\n defaultProps?.classNames ?? emptyClassNames,\n { root: rawProps.className } as Partial<Record<HuiComponentSlots<K>, string | undefined>>,\n rawProps.classNames ?? emptyClassNames,\n );\n}\n\nfunction resolveStyles<S extends string>(\n props: Pick<HuiStyleProps<S>, \"style\" | \"styles\"> = {},\n): Partial<Record<S, CSSProperties>> {\n return msAll(\n { root: props.style } as Partial<Record<S, CSSProperties | undefined>>,\n props.styles ?? {},\n );\n}\n\nexport function useHuiStyles<K extends HuiStyledComponentName>(\n key: K,\n rawProps: Pick<HuiStyleProps<HuiComponentSlots<NoInfer<K>>>, \"style\" | \"styles\"> = {},\n): Partial<Record<HuiComponentSlots<K>, CSSProperties>> {\n const defaultProps = useHuiStyleDefaultProps(key);\n return msAll(resolveStyles<HuiComponentSlots<K>>(defaultProps), resolveStyles<HuiComponentSlots<K>>(rawProps));\n}\n"],"mappings":";;;;AAyJA,MAAa,qBAAqB,cAA8C,IAAI;AAEpF,SAAgB,wBAAiD;CAE/D,OADgB,WAAW,kBACd,KAAK,EAAE,cAAc,CAAC,EAAE;AACvC;AAEA,SAAS,mBAA+C,KAA4B;CAElF,OADY,sBACH,CAAC,CAAC,aAAa;AAC1B;AAEA,SAAS,wBACP,KACiD;CACjD,OAAO,mBAAmB,GAAG;AAC/B;AAEA,MAAM,gBAAgB;CAAC;CAAa;CAAS;CAAc;AAAQ;AAOnE,SAAgB,YAKd,KACA,UACgB;CAChB,MAAM,eAAe,mBAAmB,GAAG;CAC3C,OAAO,cAAc;EACnB,MAAM,QAAQ,WAAY,gBAAgB,CAAC,GAAkB,QAAQ;EAErE,KAAK,MAAM,QAAQ,eACjB,OAAO,MAAM;EAGf,OAAO;CACT,GAAG,CAAC,cAAc,QAAQ,CAAC;AAC7B;AAEA,SAAgB,iBACd,KACA,QACA,WAA2F,CAAC,GACtD;CACtC,MAAM,eAAe,wBAAwB,GAAG;CAChD,MAAM,kBAA6E,CAAC;CACpF,OAAO,MACL,QACA,EAAE,MAAM,cAAc,UAAU,GAChC,cAAc,cAAc,iBAC5B,EAAE,MAAM,SAAS,UAAU,GAC3B,SAAS,cAAc,eACzB;AACF;AAEA,SAAS,cACP,QAAoD,CAAC,GAClB;CACnC,OAAO,MACL,EAAE,MAAM,MAAM,MAAM,GACpB,MAAM,UAAU,CAAC,CACnB;AACF;AAEA,SAAgB,aACd,KACA,WAAmF,CAAC,GAC9B;CACtD,MAAM,eAAe,wBAAwB,GAAG;CAChD,OAAO,MAAM,cAAoC,YAAY,GAAG,cAAoC,QAAQ,CAAC;AAC/G"}
|
|
@@ -2,5 +2,4 @@ import { HuiProviderContextValue } from "./hui-provider.context.js";
|
|
|
2
2
|
import { PropsWithChildren, ReactElement } from "react";
|
|
3
3
|
interface HuiProviderProps extends Partial<HuiProviderContextValue>, PropsWithChildren {}
|
|
4
4
|
export declare function HuiProvider({ defaultProps, children }: HuiProviderProps): ReactElement;
|
|
5
|
-
export {};
|
|
6
|
-
//# sourceMappingURL=hui-provider.d.ts.map
|
|
5
|
+
export {};
|
package/dist/provider/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { HuiComponentPropsMap, HuiProviderContext, HuiProviderContextValue, useHuiClassNames, useHuiProps, useHuiProviderContext, useHuiStyles } from "./hui-provider.context.js";
|
|
2
1
|
import { HuiProvider } from "./hui-provider.js";
|
|
2
|
+
import { HuiComponentPropsMap, HuiProviderContext, HuiProviderContextValue, useHuiClassNames, useHuiProps, useHuiProviderContext, useHuiStyles } from "./hui-provider.context.js";
|
|
3
3
|
export { HuiComponentPropsMap, HuiProvider, HuiProviderContext, HuiProviderContextValue, useHuiClassNames, useHuiProps, useHuiProviderContext, useHuiStyles };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
|