@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.
- package/dist/components/alert/alert.d.ts +3 -6
- package/dist/components/alert/alert.js +6 -14
- package/dist/components/alert/alert.js.map +1 -1
- package/dist/components/anchor/anchor.d.ts +1 -4
- package/dist/components/anchor/anchor.js +4 -5
- package/dist/components/anchor/anchor.js.map +1 -1
- package/dist/components/avatar/avatar.d.ts +1 -4
- package/dist/components/avatar/avatar.js +4 -5
- package/dist/components/avatar/avatar.js.map +1 -1
- package/dist/components/blockquote/blockquote.d.ts +1 -4
- package/dist/components/blockquote/blockquote.js +4 -5
- package/dist/components/blockquote/blockquote.js.map +1 -1
- package/dist/components/button/button.d.ts +12 -4
- package/dist/components/button/button.js +30 -11
- package/dist/components/button/button.js.map +1 -1
- package/dist/components/checkbox/checkbox.d.ts +2 -5
- package/dist/components/checkbox/checkbox.js +29 -16
- package/dist/components/checkbox/checkbox.js.map +1 -1
- package/dist/components/code/code.d.ts +1 -4
- package/dist/components/code/code.js +4 -5
- 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 -4
- package/dist/components/details/details.js +4 -5
- package/dist/components/details/details.js.map +1 -1
- package/dist/components/dialog/dialog.context.js +1 -2
- package/dist/components/dialog/dialog.d.ts +4 -7
- package/dist/components/dialog/dialog.js +29 -9
- 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 -4
- package/dist/components/dl/dl.js +10 -11
- package/dist/components/dl/dl.js.map +1 -1
- package/dist/components/drawer/drawer.context.js +1 -2
- package/dist/components/drawer/drawer.d.ts +4 -7
- package/dist/components/drawer/drawer.js +29 -9
- 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 -4
- package/dist/components/fieldset/fieldset.js +4 -5
- package/dist/components/fieldset/fieldset.js.map +1 -1
- package/dist/components/heading/heading.d.ts +1 -4
- package/dist/components/heading/heading.js +4 -5
- package/dist/components/heading/heading.js.map +1 -1
- package/dist/components/hr/hr.d.ts +1 -4
- package/dist/components/hr/hr.js +4 -5
- package/dist/components/hr/hr.js.map +1 -1
- package/dist/components/index.d.ts +35 -26
- 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 -4
- package/dist/components/input/input.js +4 -5
- package/dist/components/input/input.js.map +1 -1
- package/dist/components/label/label.d.ts +1 -4
- package/dist/components/label/label.js +6 -7
- package/dist/components/label/label.js.map +1 -1
- package/dist/components/menu/index.d.ts +1 -2
- package/dist/components/menu/menu.context.js +1 -2
- package/dist/components/menu/menu.d.ts +3 -6
- package/dist/components/menu/menu.js +23 -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 -4
- package/dist/components/paragraph/paragraph.js +4 -5
- package/dist/components/paragraph/paragraph.js.map +1 -1
- package/dist/components/popover/index.d.ts +1 -2
- package/dist/components/popover/popover.context.js +1 -2
- package/dist/components/popover/popover.d.ts +3 -6
- package/dist/components/popover/popover.js +20 -6
- package/dist/components/popover/popover.js.map +1 -1
- package/dist/components/progress/progress.d.ts +1 -4
- package/dist/components/progress/progress.js +4 -5
- package/dist/components/progress/progress.js.map +1 -1
- package/dist/components/radio/radio.d.ts +1 -4
- package/dist/components/radio/radio.js +4 -5
- package/dist/components/radio/radio.js.map +1 -1
- package/dist/components/radiogroup/radiogroup.d.ts +1 -4
- package/dist/components/radiogroup/radiogroup.js +6 -6
- package/dist/components/radiogroup/radiogroup.js.map +1 -1
- package/dist/components/section/section.d.ts +1 -4
- package/dist/components/section/section.js +4 -5
- package/dist/components/section/section.js.map +1 -1
- package/dist/components/segmented-control/segmented-control.context.js +1 -2
- package/dist/components/segmented-control/segmented-control.d.ts +2 -5
- package/dist/components/segmented-control/segmented-control.js +13 -9
- package/dist/components/segmented-control/segmented-control.js.map +1 -1
- package/dist/components/select/select.d.ts +1 -4
- package/dist/components/select/select.js +4 -5
- package/dist/components/select/select.js.map +1 -1
- package/dist/components/skip-link/index.d.ts +2 -0
- package/dist/components/skip-link/skip-link.d.ts +6 -0
- package/dist/components/skip-link/skip-link.js +20 -0
- package/dist/components/skip-link/skip-link.js.map +1 -0
- 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 -7
- package/dist/components/table/table.js +25 -26
- package/dist/components/table/table.js.map +1 -1
- package/dist/components/tabs/tabs.context.d.ts +1 -4
- package/dist/components/tabs/tabs.context.js +1 -2
- package/dist/components/tabs/tabs.d.ts +2 -5
- package/dist/components/tabs/tabs.js +13 -14
- 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/index.d.ts +2 -0
- package/dist/components/text/text.d.ts +22 -0
- package/dist/components/text/text.js +23 -0
- package/dist/components/text/text.js.map +1 -0
- package/dist/components/textarea/textarea.d.ts +1 -4
- package/dist/components/textarea/textarea.js +4 -5
- package/dist/components/textarea/textarea.js.map +1 -1
- package/dist/components/tooltip/index.d.ts +1 -2
- package/dist/components/tooltip/tooltip.context.js +1 -2
- package/dist/components/tooltip/tooltip.d.ts +3 -6
- package/dist/components/tooltip/tooltip.js +19 -5
- package/dist/components/tooltip/tooltip.js.map +1 -1
- package/dist/components/visually-hidden/visually-hidden.d.ts +3 -6
- package/dist/components/visually-hidden/visually-hidden.js +4 -5
- package/dist/components/visually-hidden/visually-hidden.js.map +1 -1
- package/dist/index.d.ts +9 -7
- package/dist/index.js +9 -7
- package/dist/provider/hui-provider.context.d.ts +34 -10
- package/dist/provider/hui-provider.context.js +23 -16
- package/dist/provider/hui-provider.context.js.map +1 -1
- package/dist/provider/hui-provider.d.ts +1 -4
- package/dist/provider/hui-provider.js +1 -2
- package/dist/provider/index.d.ts +1 -1
- package/dist/provider/merge-props.js +1 -2
- package/dist/types/distributive.d.ts +1 -0
- package/dist/types/hui-component.d.ts +11 -7
- package/dist/types/index.d.ts +3 -2
- package/dist/types/polymorphic.d.ts +4 -11
- package/dist/utils/attributes/normalize-attributes.js +1 -2
- package/package.json +9 -9
- package/dist/components/dialog/dialog.context.d.ts +0 -4
- package/dist/components/drawer/drawer.context.d.ts +0 -4
- package/dist/components/menu/menu.context.d.ts +0 -4
- package/dist/components/popover/popover.context.d.ts +0 -4
- package/dist/components/tooltip/tooltip.context.d.ts +0 -4
|
@@ -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
|
|
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 };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createContext, useContext } from "react";
|
|
2
|
-
|
|
2
|
+
// src/components/tooltip/tooltip.context.ts
|
|
3
3
|
const TooltipContext = createContext(null);
|
|
4
4
|
function useTooltipContext() {
|
|
5
5
|
const context = useContext(TooltipContext);
|
|
@@ -9,7 +9,6 @@ function useTooltipContext() {
|
|
|
9
9
|
function useTooltipId() {
|
|
10
10
|
return useTooltipContext().tooltipId;
|
|
11
11
|
}
|
|
12
|
-
//#endregion
|
|
13
12
|
export { TooltipContext, useTooltipContext, useTooltipId };
|
|
14
13
|
|
|
15
14
|
//# sourceMappingURL=tooltip.context.js.map
|
|
@@ -4,7 +4,6 @@ import { Button } from "../button/button.js";
|
|
|
4
4
|
import "../button/index.js";
|
|
5
5
|
import { ButtonSlots, PopoverSlots, PopoverVariants } from "@hebium-ui/core";
|
|
6
6
|
import { ElementType, ReactElement, ReactNode } from "react";
|
|
7
|
-
//#region src/components/tooltip/tooltip.d.ts
|
|
8
7
|
export interface TooltipProps {
|
|
9
8
|
/**
|
|
10
9
|
* The id of the tooltip content element.
|
|
@@ -13,8 +12,8 @@ export interface TooltipProps {
|
|
|
13
12
|
children?: ReactNode | undefined;
|
|
14
13
|
}
|
|
15
14
|
declare function TooltipRoot(rawProps: TooltipProps): ReactElement;
|
|
16
|
-
export type TooltipTriggerProps<E extends ElementType = typeof Button
|
|
17
|
-
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;
|
|
18
17
|
interface TooltipContentOwnProps {
|
|
19
18
|
/**
|
|
20
19
|
* The preferred anchor position of the tooltip.
|
|
@@ -48,6 +47,4 @@ export declare const Tooltip: typeof TooltipRoot & {
|
|
|
48
47
|
Trigger: typeof Trigger;
|
|
49
48
|
Content: typeof Content;
|
|
50
49
|
};
|
|
51
|
-
|
|
52
|
-
export {};
|
|
53
|
-
//# sourceMappingURL=tooltip.d.ts.map
|
|
50
|
+
export {};
|
|
@@ -4,7 +4,13 @@ import { TooltipContext, useTooltipId } from "./tooltip.context.js";
|
|
|
4
4
|
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,6 +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;
|
|
29
|
+
const cls = useHuiClassNames("TooltipTrigger", BUTTON_CLASSES, rawProps);
|
|
30
|
+
const sls = useHuiStyles("TooltipTrigger", rawProps);
|
|
23
31
|
const tooltipId = useTooltipId();
|
|
24
32
|
const attrs = tooltipControl.getTriggerAttributes({ tooltipId }, { isButtonElement: as === void 0 });
|
|
25
33
|
const handlePointerEnter = useCallback((e) => {
|
|
@@ -40,6 +48,13 @@ function Trigger(rawProps) {
|
|
|
40
48
|
}, [onBlur, tooltipId]);
|
|
41
49
|
return /* @__PURE__ */ jsx(Component, {
|
|
42
50
|
...attrs,
|
|
51
|
+
...Component === Button ? {
|
|
52
|
+
classNames: cls,
|
|
53
|
+
styles: sls
|
|
54
|
+
} : {
|
|
55
|
+
className: cls.root,
|
|
56
|
+
style: sls.root
|
|
57
|
+
},
|
|
43
58
|
onPointerEnter: handlePointerEnter,
|
|
44
59
|
onPointerLeave: handlePointerLeave,
|
|
45
60
|
onFocus: handleFocus,
|
|
@@ -48,7 +63,7 @@ function Trigger(rawProps) {
|
|
|
48
63
|
});
|
|
49
64
|
}
|
|
50
65
|
function Content(rawProps) {
|
|
51
|
-
const { as, position, fallbacks, visibility, padding,
|
|
66
|
+
const { as, position, fallbacks, visibility, padding, children, onPointerLeave, ...restProps } = useHuiProps("TooltipContent", rawProps);
|
|
52
67
|
const Component = as ?? "div";
|
|
53
68
|
const tooltipId = useTooltipId();
|
|
54
69
|
const recipe = popoverRecipe({
|
|
@@ -57,8 +72,8 @@ function Content(rawProps) {
|
|
|
57
72
|
visibility,
|
|
58
73
|
padding
|
|
59
74
|
});
|
|
60
|
-
const cls = useHuiClassNames("TooltipContent", recipe,
|
|
61
|
-
const sls = useHuiStyles("TooltipContent",
|
|
75
|
+
const cls = useHuiClassNames("TooltipContent", recipe, rawProps);
|
|
76
|
+
const sls = useHuiStyles("TooltipContent", rawProps);
|
|
62
77
|
const attrs = tooltipControl.getContentAttributes({ tooltipId });
|
|
63
78
|
const handlePointerLeave = useCallback((e) => {
|
|
64
79
|
onPointerLeave?.(e);
|
|
@@ -77,7 +92,6 @@ const Tooltip = Object.assign(TooltipRoot, {
|
|
|
77
92
|
Trigger,
|
|
78
93
|
Content
|
|
79
94
|
});
|
|
80
|
-
//#endregion
|
|
81
95
|
export { Tooltip };
|
|
82
96
|
|
|
83
97
|
//# sourceMappingURL=tooltip.js.map
|
|
@@ -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"}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { HuiPolymorphicProps } from "../../types/polymorphic.js";
|
|
2
2
|
import "../../types/index.js";
|
|
3
|
-
import {
|
|
3
|
+
import { VisuallyHiddenSlots } from "@hebium-ui/core";
|
|
4
4
|
import { ElementType, ReactElement } from "react";
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
export declare function VisuallyHidden<E extends ElementType = "span">(rawProps: VisuallyHiddenProps<E>): ReactElement;
|
|
8
|
-
//#endregion
|
|
9
|
-
//# sourceMappingURL=visually-hidden.d.ts.map
|
|
5
|
+
export type VisuallyHiddenProps<E extends ElementType = "span"> = HuiPolymorphicProps<E, {}, VisuallyHiddenSlots>;
|
|
6
|
+
export declare function VisuallyHidden<E extends ElementType = "span">(rawProps: VisuallyHiddenProps<E>): ReactElement;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
|
|
2
2
|
import { visuallyHiddenRecipe } from "@hebium-ui/core";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
|
|
4
|
+
// src/components/visually-hidden/visually-hidden.tsx
|
|
5
5
|
function VisuallyHidden(rawProps) {
|
|
6
|
-
const { as,
|
|
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,
|
|
@@ -15,7 +15,6 @@ function VisuallyHidden(rawProps) {
|
|
|
15
15
|
children
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
|
-
//#endregion
|
|
19
18
|
export { VisuallyHidden };
|
|
20
19
|
|
|
21
20
|
//# sourceMappingURL=visually-hidden.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visually-hidden.js","names":[],"sources":["../../../src/components/visually-hidden/visually-hidden.tsx"],"sourcesContent":["import { type
|
|
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,36 +5,38 @@ 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";
|
|
27
27
|
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
|
+
import { SkipLink, SkipLinkProps } from "./components/skip-link/skip-link.js";
|
|
31
|
+
import { StatusIcon, StatusIconProps } from "./components/status-icon/status-icon.js";
|
|
30
32
|
import { CaptionProps, Table, TableProps, TbodyProps, TdProps, TfootProps, ThProps, TheadProps, TrProps } from "./components/table/table.js";
|
|
31
33
|
import { Tabs, TabsListProps, TabsPanelProps, TabsProps, TabsTabProps } from "./components/tabs/tabs.js";
|
|
34
|
+
import { Text, TextProps } from "./components/text/text.js";
|
|
32
35
|
import { Textarea, TextareaProps } from "./components/textarea/textarea.js";
|
|
33
36
|
import { Tooltip, TooltipContentProps, TooltipProps, TooltipTriggerProps } from "./components/tooltip/tooltip.js";
|
|
34
|
-
import { useTooltipId } from "./components/tooltip/tooltip.context.js";
|
|
35
37
|
import { VisuallyHidden, VisuallyHiddenProps } from "./components/visually-hidden/visually-hidden.js";
|
|
36
38
|
import "./components/index.js";
|
|
37
39
|
import { HuiComponentPropsMap, HuiProviderContext, HuiProviderContextValue, useHuiClassNames, useHuiProps, useHuiProviderContext, useHuiStyles } from "./provider/hui-provider.context.js";
|
|
38
40
|
import { HuiProvider } from "./provider/hui-provider.js";
|
|
39
41
|
import "./provider/index.js";
|
|
40
|
-
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, Table, TableProps, Tabs, TabsListProps, TabsPanelProps, TabsProps, TabsTabProps, TbodyProps, TdProps, 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";
|
|
@@ -29,10 +30,11 @@ import { Radiogroup } from "./components/radiogroup/radiogroup.js";
|
|
|
29
30
|
import { Section } from "./components/section/section.js";
|
|
30
31
|
import { SegmentedControl } from "./components/segmented-control/segmented-control.js";
|
|
31
32
|
import { Select } from "./components/select/select.js";
|
|
33
|
+
import { SkipLink } from "./components/skip-link/skip-link.js";
|
|
32
34
|
import { Table } from "./components/table/table.js";
|
|
33
35
|
import { Tabs } from "./components/tabs/tabs.js";
|
|
36
|
+
import { Text } from "./components/text/text.js";
|
|
34
37
|
import { Textarea } from "./components/textarea/textarea.js";
|
|
35
|
-
import { useTooltipId } from "./components/tooltip/tooltip.context.js";
|
|
36
38
|
import { Tooltip } from "./components/tooltip/tooltip.js";
|
|
37
39
|
import { VisuallyHidden } from "./components/visually-hidden/visually-hidden.js";
|
|
38
|
-
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, Table, Tabs,
|
|
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";
|
|
@@ -23,14 +30,16 @@ import { RadiogroupProps } from "../components/radiogroup/radiogroup.js";
|
|
|
23
30
|
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";
|
|
33
|
+
import { SkipLinkProps } from "../components/skip-link/skip-link.js";
|
|
34
|
+
import { StatusIconProps } from "../components/status-icon/status-icon.js";
|
|
26
35
|
import { CaptionProps, TableProps, TbodyProps, TdProps, TfootProps, ThProps, TheadProps, TrProps } from "../components/table/table.js";
|
|
27
36
|
import { TabsListProps, TabsPanelProps, TabsProps, TabsTabProps } from "../components/tabs/tabs.js";
|
|
37
|
+
import { TextProps } from "../components/text/text.js";
|
|
28
38
|
import { TextareaProps } from "../components/textarea/textarea.js";
|
|
29
39
|
import { TooltipContentProps, TooltipProps, TooltipTriggerProps } from "../components/tooltip/tooltip.js";
|
|
30
40
|
import { VisuallyHiddenProps } from "../components/visually-hidden/visually-hidden.js";
|
|
31
|
-
import "../
|
|
32
|
-
import { CSSProperties } from "react";
|
|
33
|
-
//#region src/provider/hui-provider.context.d.ts
|
|
41
|
+
import "../types/index.js";
|
|
42
|
+
import { CSSProperties, ElementType } from "react";
|
|
34
43
|
export interface HuiComponentPropsMap {
|
|
35
44
|
Alert: Partial<AlertProps>;
|
|
36
45
|
Anchor: Partial<AnchorProps>;
|
|
@@ -39,6 +48,7 @@ export interface HuiComponentPropsMap {
|
|
|
39
48
|
Button: Partial<ButtonProps>;
|
|
40
49
|
Checkbox: Partial<CheckboxProps>;
|
|
41
50
|
Code: Partial<CodeProps>;
|
|
51
|
+
Combobox: Partial<ComboboxProps>;
|
|
42
52
|
Details: Partial<DetailsProps>;
|
|
43
53
|
Dialog: Partial<DialogProps>;
|
|
44
54
|
DialogTrigger: Partial<DialogTriggerProps>;
|
|
@@ -54,12 +64,14 @@ export interface HuiComponentPropsMap {
|
|
|
54
64
|
Fieldset: Partial<FieldsetProps>;
|
|
55
65
|
Heading: Partial<HeadingProps>;
|
|
56
66
|
Hr: Partial<HrProps>;
|
|
67
|
+
InlineFeedback: Partial<InlineFeedbackProps>;
|
|
57
68
|
Input: Partial<InputProps>;
|
|
58
69
|
Label: Partial<LabelProps>;
|
|
59
70
|
Menu: Partial<MenuProps>;
|
|
60
71
|
MenuContent: Partial<MenuContentProps>;
|
|
61
72
|
MenuItem: Partial<MenuItemProps>;
|
|
62
73
|
MenuTrigger: Partial<MenuTriggerProps>;
|
|
74
|
+
MultiCombobox: Partial<MultiComboboxProps>;
|
|
63
75
|
Paragraph: Partial<ParagraphProps>;
|
|
64
76
|
Popover: Partial<PopoverProps>;
|
|
65
77
|
PopoverTrigger: Partial<PopoverTriggerProps>;
|
|
@@ -71,6 +83,8 @@ export interface HuiComponentPropsMap {
|
|
|
71
83
|
Select: Partial<SelectProps>;
|
|
72
84
|
SegmentedControlItem: Partial<SegmentedControlItemProps>;
|
|
73
85
|
SegmentedControl: Partial<SegmentedControlProps<string>>;
|
|
86
|
+
SkipLink: Partial<SkipLinkProps>;
|
|
87
|
+
StatusIcon: Partial<StatusIconProps>;
|
|
74
88
|
Table: Partial<TableProps>;
|
|
75
89
|
TableCaption: Partial<CaptionProps>;
|
|
76
90
|
TableThead: Partial<TheadProps>;
|
|
@@ -83,6 +97,8 @@ export interface HuiComponentPropsMap {
|
|
|
83
97
|
TabsList: Partial<TabsListProps>;
|
|
84
98
|
TabsTab: Partial<TabsTabProps>;
|
|
85
99
|
TabsPanel: Partial<TabsPanelProps>;
|
|
100
|
+
Tag: Partial<TagProps>;
|
|
101
|
+
Text: Partial<TextProps>;
|
|
86
102
|
Textarea: Partial<TextareaProps>;
|
|
87
103
|
Tooltip: Partial<TooltipProps>;
|
|
88
104
|
TooltipTrigger: Partial<TooltipTriggerProps>;
|
|
@@ -91,14 +107,22 @@ export interface HuiComponentPropsMap {
|
|
|
91
107
|
}
|
|
92
108
|
type HuiComponentName = keyof HuiComponentPropsMap;
|
|
93
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];
|
|
94
114
|
export interface HuiProviderContextValue {
|
|
95
115
|
defaultProps: HuiDefaultProps;
|
|
96
116
|
}
|
|
97
117
|
export declare const HuiProviderContext: import("react").Context<HuiProviderContextValue | null>;
|
|
98
118
|
export declare function useHuiProviderContext(): HuiProviderContextValue;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
export {
|
|
104
|
-
|
|
119
|
+
declare const STYLING_PROPS: readonly ["className", "style", "classNames", "styles"];
|
|
120
|
+
type HuiProps<P extends object, E extends ElementType> = DistributiveOmit<P, typeof STYLING_PROPS[number] | "as"> & Pick<{
|
|
121
|
+
as?: E | undefined;
|
|
122
|
+
}, "as" & keyof P>;
|
|
123
|
+
export declare function useHuiProps<K extends HuiComponentName, P extends object, E extends ElementType = Extract<P["as" & keyof P], ElementType>>(key: K, rawProps: P & {
|
|
124
|
+
as?: E | undefined;
|
|
125
|
+
}): HuiProps<P, E>;
|
|
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 {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mergeProps } from "./merge-props.js";
|
|
2
2
|
import { ccAll, msAll } from "@hebium-ui/core";
|
|
3
3
|
import { createContext, useContext, useMemo } from "react";
|
|
4
|
-
|
|
4
|
+
// src/provider/hui-provider.context.ts
|
|
5
5
|
const HuiProviderContext = createContext(null);
|
|
6
6
|
function useHuiProviderContext() {
|
|
7
7
|
return useContext(HuiProviderContext) ?? { defaultProps: {} };
|
|
@@ -9,28 +9,35 @@ function useHuiProviderContext() {
|
|
|
9
9
|
function useHuiDefaultProps(key) {
|
|
10
10
|
return useHuiProviderContext().defaultProps[key];
|
|
11
11
|
}
|
|
12
|
+
function useHuiStyleDefaultProps(key) {
|
|
13
|
+
return useHuiDefaultProps(key);
|
|
14
|
+
}
|
|
15
|
+
const STYLING_PROPS = [
|
|
16
|
+
"className",
|
|
17
|
+
"style",
|
|
18
|
+
"classNames",
|
|
19
|
+
"styles"
|
|
20
|
+
];
|
|
12
21
|
function useHuiProps(key, rawProps) {
|
|
13
22
|
const defaultProps = useHuiDefaultProps(key);
|
|
14
23
|
return useMemo(() => {
|
|
15
|
-
|
|
16
|
-
|
|
24
|
+
const props = mergeProps(defaultProps ?? {}, rawProps);
|
|
25
|
+
for (const prop of STYLING_PROPS) delete props[prop];
|
|
26
|
+
return props;
|
|
17
27
|
}, [defaultProps, rawProps]);
|
|
18
28
|
}
|
|
19
|
-
function useHuiClassNames(key, recipe,
|
|
20
|
-
const defaultProps =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
else if ("className" in defaultProps && defaultProps.className) return ccAll(recipe, { root: defaultProps.className }, rawClassNames);
|
|
24
|
-
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);
|
|
25
33
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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));
|
|
32
40
|
}
|
|
33
|
-
//#endregion
|
|
34
41
|
export { HuiProviderContext, useHuiClassNames, useHuiProps, useHuiProviderContext, useHuiStyles };
|
|
35
42
|
|
|
36
43
|
//# sourceMappingURL=hui-provider.context.js.map
|
|
@@ -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, 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 TableProps,\n TabsListProps,\n TabsPanelProps,\n TabsProps,\n TabsTabProps,\n TbodyProps,\n TdProps,\n TextareaProps,\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 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 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\
|
|
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"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { HuiProviderContextValue } from "./hui-provider.context.js";
|
|
2
2
|
import { PropsWithChildren, ReactElement } from "react";
|
|
3
|
-
//#region src/provider/hui-provider.d.ts
|
|
4
3
|
interface HuiProviderProps extends Partial<HuiProviderContextValue>, PropsWithChildren {}
|
|
5
4
|
export declare function HuiProvider({ defaultProps, children }: HuiProviderProps): ReactElement;
|
|
6
|
-
|
|
7
|
-
export {};
|
|
8
|
-
//# sourceMappingURL=hui-provider.d.ts.map
|
|
5
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HuiProviderContext } from "./hui-provider.context.js";
|
|
2
2
|
import { useMemo } from "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
|
|
4
|
+
// src/provider/hui-provider.tsx
|
|
5
5
|
function HuiProvider({ defaultProps, children }) {
|
|
6
6
|
const context = useMemo(() => {
|
|
7
7
|
return { defaultProps: defaultProps ?? {} };
|
|
@@ -11,7 +11,6 @@ function HuiProvider({ defaultProps, children }) {
|
|
|
11
11
|
children
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
|
-
//#endregion
|
|
15
14
|
export { HuiProvider };
|
|
16
15
|
|
|
17
16
|
//# sourceMappingURL=hui-provider.js.map
|
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 };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/provider/merge-props.ts
|
|
2
2
|
function mergeProps(defaultProps, rawProps) {
|
|
3
3
|
const filteredProps = {};
|
|
4
4
|
for (const key of Object.keys(rawProps)) {
|
|
@@ -10,7 +10,6 @@ function mergeProps(defaultProps, rawProps) {
|
|
|
10
10
|
...filteredProps
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
-
//#endregion
|
|
14
13
|
export { mergeProps };
|
|
15
14
|
|
|
16
15
|
//# sourceMappingURL=merge-props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
|