@hebium-ui/react 0.0.0-stage → 0.1.0-alpha.0
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/LICENSE +21 -0
- package/README.md +7 -2
- package/dist/components/alert/alert.d.ts +44 -0
- package/dist/components/alert/alert.js +45 -0
- package/dist/components/alert/alert.js.map +1 -0
- package/dist/components/alert/index.d.ts +2 -0
- package/dist/components/anchor/anchor.d.ts +30 -0
- package/dist/components/anchor/anchor.js +25 -0
- package/dist/components/anchor/anchor.js.map +1 -0
- package/dist/components/anchor/index.d.ts +2 -0
- package/dist/components/avatar/avatar.d.ts +16 -0
- package/dist/components/avatar/avatar.js +50 -0
- package/dist/components/avatar/avatar.js.map +1 -0
- package/dist/components/avatar/index.d.ts +2 -0
- package/dist/components/blockquote/blockquote.d.ts +28 -0
- package/dist/components/blockquote/blockquote.js +29 -0
- package/dist/components/blockquote/blockquote.js.map +1 -0
- package/dist/components/blockquote/index.d.ts +2 -0
- package/dist/components/button/button.d.ts +30 -0
- package/dist/components/button/button.js +25 -0
- package/dist/components/button/button.js.map +1 -0
- package/dist/components/button/index.d.ts +2 -0
- package/dist/components/checkbox/checkbox.d.ts +33 -0
- package/dist/components/checkbox/checkbox.js +68 -0
- package/dist/components/checkbox/checkbox.js.map +1 -0
- package/dist/components/checkbox/index.d.ts +2 -0
- package/dist/components/code/code.d.ts +11 -0
- package/dist/components/code/code.js +21 -0
- package/dist/components/code/code.js.map +1 -0
- package/dist/components/code/index.d.ts +2 -0
- package/dist/components/details/details.d.ts +22 -0
- package/dist/components/details/details.js +28 -0
- package/dist/components/details/details.js.map +1 -0
- package/dist/components/details/index.d.ts +2 -0
- package/dist/components/dialog/dialog.context.d.ts +4 -0
- package/dist/components/dialog/dialog.context.js +15 -0
- package/dist/components/dialog/dialog.context.js.map +1 -0
- package/dist/components/dialog/dialog.d.ts +67 -0
- package/dist/components/dialog/dialog.js +124 -0
- package/dist/components/dialog/dialog.js.map +1 -0
- package/dist/components/dialog/index.d.ts +3 -0
- package/dist/components/dl/dl.d.ts +18 -0
- package/dist/components/dl/dl.js +48 -0
- package/dist/components/dl/dl.js.map +1 -0
- package/dist/components/dl/index.d.ts +2 -0
- package/dist/components/drawer/drawer.context.d.ts +4 -0
- package/dist/components/drawer/drawer.context.js +15 -0
- package/dist/components/drawer/drawer.context.js.map +1 -0
- package/dist/components/drawer/drawer.d.ts +67 -0
- package/dist/components/drawer/drawer.js +104 -0
- package/dist/components/drawer/drawer.js.map +1 -0
- package/dist/components/drawer/index.d.ts +3 -0
- package/dist/components/fieldset/fieldset.d.ts +9 -0
- package/dist/components/fieldset/fieldset.js +20 -0
- package/dist/components/fieldset/fieldset.js.map +1 -0
- package/dist/components/fieldset/index.d.ts +2 -0
- package/dist/components/heading/heading.d.ts +22 -0
- package/dist/components/heading/heading.js +24 -0
- package/dist/components/heading/heading.js.map +1 -0
- package/dist/components/heading/index.d.ts +2 -0
- package/dist/components/hr/hr.d.ts +11 -0
- package/dist/components/hr/hr.js +19 -0
- package/dist/components/hr/hr.js.map +1 -0
- package/dist/components/hr/index.d.ts +2 -0
- package/dist/components/index.d.ts +66 -0
- package/dist/components/input/index.d.ts +2 -0
- package/dist/components/input/input.d.ts +37 -0
- package/dist/components/input/input.js +47 -0
- package/dist/components/input/input.js.map +1 -0
- package/dist/components/label/index.d.ts +2 -0
- package/dist/components/label/label.d.ts +32 -0
- package/dist/components/label/label.js +54 -0
- package/dist/components/label/label.js.map +1 -0
- package/dist/components/menu/index.d.ts +3 -0
- package/dist/components/menu/menu.context.d.ts +4 -0
- package/dist/components/menu/menu.context.js +15 -0
- package/dist/components/menu/menu.context.js.map +1 -0
- package/dist/components/menu/menu.d.ts +82 -0
- package/dist/components/menu/menu.js +133 -0
- package/dist/components/menu/menu.js.map +1 -0
- package/dist/components/paragraph/index.d.ts +2 -0
- package/dist/components/paragraph/paragraph.d.ts +18 -0
- package/dist/components/paragraph/paragraph.js +21 -0
- package/dist/components/paragraph/paragraph.js.map +1 -0
- package/dist/components/popover/index.d.ts +3 -0
- package/dist/components/popover/popover.context.d.ts +4 -0
- package/dist/components/popover/popover.context.js +15 -0
- package/dist/components/popover/popover.context.js.map +1 -0
- package/dist/components/popover/popover.d.ts +53 -0
- package/dist/components/popover/popover.js +60 -0
- package/dist/components/popover/popover.js.map +1 -0
- package/dist/components/progress/index.d.ts +2 -0
- package/dist/components/progress/progress.d.ts +55 -0
- package/dist/components/progress/progress.js +57 -0
- package/dist/components/progress/progress.js.map +1 -0
- package/dist/components/radio/index.d.ts +2 -0
- package/dist/components/radio/radio.d.ts +27 -0
- package/dist/components/radio/radio.js +57 -0
- package/dist/components/radio/radio.js.map +1 -0
- package/dist/components/radiogroup/index.d.ts +2 -0
- package/dist/components/radiogroup/radiogroup.d.ts +36 -0
- package/dist/components/radiogroup/radiogroup.js +44 -0
- package/dist/components/radiogroup/radiogroup.js.map +1 -0
- package/dist/components/section/index.d.ts +2 -0
- package/dist/components/section/section.d.ts +36 -0
- package/dist/components/section/section.js +26 -0
- package/dist/components/section/section.js.map +1 -0
- package/dist/components/segmented-control/index.d.ts +2 -0
- package/dist/components/segmented-control/segmented-control.context.js +12 -0
- package/dist/components/segmented-control/segmented-control.context.js.map +1 -0
- package/dist/components/segmented-control/segmented-control.d.ts +41 -0
- package/dist/components/segmented-control/segmented-control.js +68 -0
- package/dist/components/segmented-control/segmented-control.js.map +1 -0
- package/dist/components/select/index.d.ts +2 -0
- package/dist/components/select/select.d.ts +31 -0
- package/dist/components/select/select.js +48 -0
- package/dist/components/select/select.js.map +1 -0
- package/dist/components/table/index.d.ts +2 -0
- package/dist/components/table/table.d.ts +53 -0
- package/dist/components/table/table.js +110 -0
- package/dist/components/table/table.js.map +1 -0
- package/dist/components/tabs/index.d.ts +2 -0
- package/dist/components/tabs/tabs.context.d.ts +4 -0
- package/dist/components/tabs/tabs.context.js +12 -0
- package/dist/components/tabs/tabs.context.js.map +1 -0
- package/dist/components/tabs/tabs.d.ts +60 -0
- package/dist/components/tabs/tabs.js +158 -0
- package/dist/components/tabs/tabs.js.map +1 -0
- package/dist/components/textarea/index.d.ts +2 -0
- package/dist/components/textarea/textarea.d.ts +37 -0
- package/dist/components/textarea/textarea.js +48 -0
- package/dist/components/textarea/textarea.js.map +1 -0
- package/dist/components/tooltip/index.d.ts +3 -0
- package/dist/components/tooltip/tooltip.context.d.ts +4 -0
- package/dist/components/tooltip/tooltip.context.js +15 -0
- package/dist/components/tooltip/tooltip.context.js.map +1 -0
- package/dist/components/tooltip/tooltip.d.ts +53 -0
- package/dist/components/tooltip/tooltip.js +83 -0
- package/dist/components/tooltip/tooltip.js.map +1 -0
- package/dist/components/visually-hidden/index.d.ts +2 -0
- package/dist/components/visually-hidden/visually-hidden.d.ts +9 -0
- package/dist/components/visually-hidden/visually-hidden.js +21 -0
- package/dist/components/visually-hidden/visually-hidden.js.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +38 -0
- package/dist/provider/hui-provider.context.d.ts +104 -0
- package/dist/provider/hui-provider.context.js +36 -0
- package/dist/provider/hui-provider.context.js.map +1 -0
- package/dist/provider/hui-provider.d.ts +8 -0
- package/dist/provider/hui-provider.js +17 -0
- package/dist/provider/hui-provider.js.map +1 -0
- package/dist/provider/index.d.ts +3 -0
- package/dist/provider/merge-props.js +16 -0
- package/dist/provider/merge-props.js.map +1 -0
- package/dist/types/hui-component.d.ts +8 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/polymorphic.d.ts +13 -0
- package/dist/utils/attributes/normalize-attributes.js +18 -0
- package/dist/utils/attributes/normalize-attributes.js.map +1 -0
- package/package.json +54 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabs.js","names":[],"sources":["../../../src/components/tabs/tabs.tsx"],"sourcesContent":["import {\n tablistRecipe,\n type TablistSlots,\n tabpanelRecipe,\n type TabpanelSlots,\n tabRecipe,\n tabrootRecipe,\n type TabrootSlots,\n tabsControl,\n type TabSlots,\n} from \"@hebium-ui/core\";\nimport {\n type ElementType,\n type FocusEvent,\n type KeyboardEvent,\n type MouseEvent,\n type ReactElement,\n useCallback,\n useId,\n useMemo,\n useState,\n} from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\nimport { normalizeAttributes } from \"~/utils\";\nimport { type ActivationMode, TabsContext, type TabsContextValue, useTabsContext } from \"./tabs.context\";\n\ninterface TabsOwnProps<V extends string> {\n /**\n * The list of allowed tab values.\n */\n values: V[];\n /**\n * The currently selected tab value.\n */\n value?: V | undefined;\n /**\n * The initially selected tab value for uncontrolled tabs.\n */\n defaultValue?: V | undefined;\n /**\n * Called when the selected tab value changes.\n */\n onChange?: ((value: V) => void) | undefined;\n /**\n * The activation mode used when focus moves between tabs.\n *\n * @default \"manual\"\n * @see {@link https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_selection_follows_focus | WAI-ARIA APG: Deciding When to Make Selection Automatically Follow Focus}\n */\n activation?: ActivationMode;\n}\nexport type TabsProps<V extends string, E extends ElementType = \"div\"> = HuiPolymorphicProps<\n E,\n TabsOwnProps<V>,\n TabrootSlots\n>;\n\nfunction TabsRoot<V extends string, E extends ElementType = \"div\">(\n rawProps: TabsProps<V, E>,\n): ReactElement {\n const {\n as,\n id,\n values,\n value,\n defaultValue,\n onChange,\n className,\n style,\n children,\n activation = \"manual\",\n ...restProps\n } = useHuiProps(\"Tabs\", rawProps);\n\n const Component = as ?? \"div\";\n\n const tmpId = useId();\n const rootId = id || tmpId;\n const [uncontrolledValue, setUncontrolledValue] = useState<V | undefined>(\n () => value ?? defaultValue ?? values[0],\n );\n const selectedValue = value ?? uncontrolledValue;\n const recipe = tabrootRecipe({});\n const cls = useHuiClassNames(\"Tabs\", recipe, { root: className });\n const sls = useHuiStyles(\"Tabs\", { root: style });\n\n const onSelect = useCallback(\n (nextValue: string) => {\n if (!(values as string[]).includes(nextValue)) {\n throw new Error(`[Hebium UI] Unexpected Tab value: ${nextValue}`);\n }\n\n const v = nextValue as V;\n setUncontrolledValue(v);\n onChange?.(v);\n },\n [onChange, values],\n );\n\n const contextValue = useMemo<TabsContextValue>(\n () => ({\n rootId,\n selectedValue,\n onSelect,\n activation,\n }),\n [\n rootId,\n selectedValue,\n onSelect,\n activation,\n ],\n );\n const attrs = normalizeAttributes(tabsControl.getRootAttributes({ rootId, selectedValue }));\n\n return (\n <TabsContext.Provider value={contextValue}>\n <Component\n className={cls.root}\n style={sls.root}\n {...attrs}\n {...restProps}\n >\n {children}\n </Component>\n </TabsContext.Provider>\n );\n}\n\ninterface TabsListOwnProps {}\nexport type TabsListProps<E extends ElementType = \"div\"> = HuiPolymorphicProps<\n E,\n TabsListOwnProps,\n TablistSlots\n>;\n\nfunction List<E extends ElementType = \"div\">(rawProps: TabsListProps<E>): ReactElement {\n const {\n as,\n className,\n style,\n children,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n ...restProps\n } = useHuiProps(\"TabsList\", rawProps);\n\n const Component = as ?? \"div\";\n\n const recipe = tablistRecipe({});\n const cls = useHuiClassNames(\"TabsList\", recipe, { root: className });\n const sls = useHuiStyles(\"TabsList\", { root: style });\n const { rootId, selectedValue } = useTabsContext();\n const attrs = normalizeAttributes(\n tabsControl.getListAttributes(\n { rootId, selectedValue },\n { ariaLabel, ariaLabelledBy },\n ),\n );\n\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...attrs}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n\ninterface TabsTabOwnProps {\n /**\n * The value represented by this tab.\n */\n value: string;\n}\nexport type TabsTabProps<E extends ElementType = \"button\"> = HuiPolymorphicProps<\n E,\n TabsTabOwnProps,\n TabSlots\n>;\n\nfunction Tab<E extends ElementType = \"button\">(rawProps: TabsTabProps<E>): ReactElement {\n const {\n as,\n value,\n className,\n style,\n children,\n onClick,\n onKeyDown,\n onFocus,\n ...restProps\n } = useHuiProps(\"TabsTab\", rawProps);\n\n const Component = as ?? \"button\";\n\n const { rootId, selectedValue, onSelect, activation } = useTabsContext();\n const recipe = tabRecipe({});\n const cls = useHuiClassNames(\"TabsTab\", recipe, { root: className });\n const sls = useHuiStyles(\"TabsTab\", { root: style });\n const attrs = normalizeAttributes(\n tabsControl.getTabAttributes(\n { rootId, selectedValue },\n value,\n { isButtonElement: as === undefined },\n ),\n );\n\n const handleClick = useCallback(\n (e: MouseEvent<HTMLButtonElement>): void => {\n onClick?.(e);\n if (e.defaultPrevented) return;\n onSelect(value);\n },\n [onClick, onSelect, value],\n );\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent<HTMLButtonElement>): void => {\n onKeyDown?.(e);\n if (e.defaultPrevented) return;\n\n const action = tabsControl.handleTabKeydown(e.nativeEvent);\n switch (action) {\n case \"activate\":\n onSelect(value);\n return;\n case \"focus-move\":\n tabsControl.moveFocus(e.nativeEvent, rootId);\n return;\n case \"none\":\n return;\n }\n },\n [onKeyDown, onSelect, rootId, value],\n );\n\n const handleFocus = useCallback((e: FocusEvent<HTMLButtonElement, HTMLElement>) => {\n onFocus?.(e);\n if (e.defaultPrevented) return;\n\n if (activation === \"auto\") {\n onSelect(value);\n }\n }, [onFocus, onSelect, activation, value]);\n\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...attrs}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n onFocus={handleFocus}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n\ninterface TabsPanelOwnProps {\n /**\n * The tab value associated with this panel.\n */\n value: string;\n}\nexport type TabsPanelProps<E extends ElementType = \"div\"> = HuiPolymorphicProps<\n E,\n TabsPanelOwnProps,\n TabpanelSlots\n>;\n\nfunction Panel<E extends ElementType = \"div\">(rawProps: TabsPanelProps<E>): ReactElement {\n const {\n as,\n value,\n className,\n style,\n children,\n ...restProps\n } = useHuiProps(\"TabsPanel\", rawProps);\n\n const Component = as ?? \"div\";\n\n const { rootId, selectedValue } = useTabsContext();\n const recipe = tabpanelRecipe({});\n const cls = useHuiClassNames(\"TabsPanel\", recipe, { root: className });\n const sls = useHuiStyles(\"TabsPanel\", { root: style });\n const attrs = normalizeAttributes(tabsControl.getPanelAttributes({ rootId, selectedValue }, value));\n\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...attrs}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n\nexport const Tabs = Object.assign(TabsRoot, {\n List,\n Tab,\n Panel,\n});\n"],"mappings":"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"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { HuiComponentProps } from "../../types/hui-component.js";
|
|
2
|
+
import "../../types/index.js";
|
|
3
|
+
import { LabelProps } from "../label/label.js";
|
|
4
|
+
import "../label/index.js";
|
|
5
|
+
import { InputSlots, InputVariants } from "@hebium-ui/core";
|
|
6
|
+
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
7
|
+
//#region src/components/textarea/textarea.d.ts
|
|
8
|
+
type HtmlTextareaProps = Omit<ComponentProps<"textarea">, "children" | "color">;
|
|
9
|
+
interface TextareaOwnProps extends HtmlTextareaProps {
|
|
10
|
+
/**
|
|
11
|
+
* The semantic color of the textarea.
|
|
12
|
+
*
|
|
13
|
+
* @default "accent"
|
|
14
|
+
*/
|
|
15
|
+
color?: InputVariants["color"] | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* The label displayed above the textarea.
|
|
18
|
+
*/
|
|
19
|
+
label?: ReactNode | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Additional props passed to the internal label component.
|
|
22
|
+
*/
|
|
23
|
+
labelProps?: LabelProps | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* The help text displayed below the label.
|
|
26
|
+
*/
|
|
27
|
+
description?: ReactNode | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* The validation error message displayed below the label.
|
|
30
|
+
*/
|
|
31
|
+
error?: ReactNode | undefined;
|
|
32
|
+
}
|
|
33
|
+
export type TextareaProps = HuiComponentProps<TextareaOwnProps, InputSlots>;
|
|
34
|
+
export declare function Textarea(rawProps: TextareaProps): ReactElement;
|
|
35
|
+
//#endregion
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=textarea.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
|
|
2
|
+
import { normalizeAttributes } from "../../utils/attributes/normalize-attributes.js";
|
|
3
|
+
import { Label } from "../label/label.js";
|
|
4
|
+
import { inputControl, inputRecipe, toBool, toStrbool } from "@hebium-ui/core";
|
|
5
|
+
import { useId } from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/textarea/textarea.tsx
|
|
8
|
+
function Textarea(rawProps) {
|
|
9
|
+
const { id, classNames, styles, color, label, description, error, labelProps, ...restProps } = useHuiProps("Textarea", rawProps);
|
|
10
|
+
const tmpId = useId();
|
|
11
|
+
const inputState = {
|
|
12
|
+
id: id || tmpId,
|
|
13
|
+
invalid: !!error,
|
|
14
|
+
required: restProps.required ?? toBool(restProps["aria-required"]),
|
|
15
|
+
disabled: toBool(restProps.disabled) || toBool(restProps["aria-disabled"]),
|
|
16
|
+
readOnly: toBool(restProps.readOnly) || toBool(restProps["aria-readonly"])
|
|
17
|
+
};
|
|
18
|
+
const recipe = inputRecipe({
|
|
19
|
+
color,
|
|
20
|
+
height: "auto",
|
|
21
|
+
error: toStrbool(inputState.invalid)
|
|
22
|
+
});
|
|
23
|
+
const cls = useHuiClassNames("Textarea", recipe, classNames);
|
|
24
|
+
const sls = useHuiStyles("Textarea", styles);
|
|
25
|
+
const hasLabel = !!label || !!description || !!error;
|
|
26
|
+
const controlAttrs = normalizeAttributes(inputControl.getControlAttributes(inputState));
|
|
27
|
+
const labelAttrs = normalizeAttributes(inputControl.getLabelAttributes(inputState));
|
|
28
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
29
|
+
className: cls.root,
|
|
30
|
+
style: sls.root,
|
|
31
|
+
children: [hasLabel && /* @__PURE__ */ jsx(Label, {
|
|
32
|
+
...labelAttrs,
|
|
33
|
+
description,
|
|
34
|
+
error,
|
|
35
|
+
...labelProps,
|
|
36
|
+
children: label
|
|
37
|
+
}), /* @__PURE__ */ jsx("textarea", {
|
|
38
|
+
className: cls.input,
|
|
39
|
+
style: sls.input,
|
|
40
|
+
...controlAttrs,
|
|
41
|
+
...restProps
|
|
42
|
+
})]
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { Textarea };
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=textarea.js.map
|
|
@@ -0,0 +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 classNames,\n styles,\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, classNames);\n const sls = useHuiStyles(\"Textarea\", styles);\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,YACA,QACA,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,UAAU;CAC3D,MAAM,MAAM,aAAa,YAAY,MAAM;CAC3C,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"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
//#region src/components/tooltip/tooltip.context.ts
|
|
3
|
+
const TooltipContext = createContext(null);
|
|
4
|
+
function useTooltipContext() {
|
|
5
|
+
const context = useContext(TooltipContext);
|
|
6
|
+
if (!context) throw new Error("[Hebium UI] Tooltip compound components must be used within <Tooltip>");
|
|
7
|
+
return context;
|
|
8
|
+
}
|
|
9
|
+
function useTooltipId() {
|
|
10
|
+
return useTooltipContext().tooltipId;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { TooltipContext, useTooltipContext, useTooltipId };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=tooltip.context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tooltip.context.js","names":[],"sources":["../../../src/components/tooltip/tooltip.context.ts"],"sourcesContent":["import { createContext, useContext } from \"react\";\n\nexport interface TooltipContextValue {\n tooltipId: string;\n}\n\nexport const TooltipContext = createContext<TooltipContextValue | null>(null);\n\nexport function useTooltipContext(): TooltipContextValue {\n const context = useContext(TooltipContext);\n if (!context) {\n throw new Error(\"[Hebium UI] Tooltip compound components must be used within <Tooltip>\");\n }\n return context;\n}\n\nexport function useTooltipId(): string {\n return useTooltipContext().tooltipId;\n}\n"],"mappings":";;AAMA,MAAa,iBAAiB,cAA0C,IAAI;AAE5E,SAAgB,oBAAyC;CACvD,MAAM,UAAU,WAAW,cAAc;CACzC,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,uEAAuE;CAEzF,OAAO;AACT;AAEA,SAAgB,eAAuB;CACrC,OAAO,kBAAkB,CAAC,CAAC;AAC7B"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { HuiPolymorphicProps } from "../../types/polymorphic.js";
|
|
2
|
+
import "../../types/index.js";
|
|
3
|
+
import { Button } from "../button/button.js";
|
|
4
|
+
import "../button/index.js";
|
|
5
|
+
import { ButtonSlots, PopoverSlots, PopoverVariants } from "@hebium-ui/core";
|
|
6
|
+
import { ElementType, ReactElement, ReactNode } from "react";
|
|
7
|
+
//#region src/components/tooltip/tooltip.d.ts
|
|
8
|
+
export interface TooltipProps {
|
|
9
|
+
/**
|
|
10
|
+
* The id of the tooltip content element.
|
|
11
|
+
*/
|
|
12
|
+
id?: string | undefined;
|
|
13
|
+
children?: ReactNode | undefined;
|
|
14
|
+
}
|
|
15
|
+
declare function TooltipRoot(rawProps: TooltipProps): ReactElement;
|
|
16
|
+
export type TooltipTriggerProps<E extends ElementType = typeof Button> = HuiPolymorphicProps<E, {}, ButtonSlots>;
|
|
17
|
+
declare function Trigger<E extends ElementType = typeof Button>(rawProps: TooltipTriggerProps<E>): ReactNode;
|
|
18
|
+
interface TooltipContentOwnProps {
|
|
19
|
+
/**
|
|
20
|
+
* The preferred anchor position of the tooltip.
|
|
21
|
+
*
|
|
22
|
+
* @default "block-start"
|
|
23
|
+
*/
|
|
24
|
+
position?: PopoverVariants["position"] | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* The fallback strategy used when the preferred position overflows.
|
|
27
|
+
*
|
|
28
|
+
* @default "flip"
|
|
29
|
+
*/
|
|
30
|
+
fallbacks?: PopoverVariants["fallbacks"] | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* The visibility behavior when the anchor is off-screen or overflows.
|
|
33
|
+
*
|
|
34
|
+
* @default "anchors-visible"
|
|
35
|
+
* @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}.
|
|
36
|
+
*/
|
|
37
|
+
visibility?: PopoverVariants["visibility"] | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* The padding size of the tooltip content.
|
|
40
|
+
*
|
|
41
|
+
* @default "md"
|
|
42
|
+
*/
|
|
43
|
+
padding?: PopoverVariants["padding"] | undefined;
|
|
44
|
+
}
|
|
45
|
+
export type TooltipContentProps<E extends ElementType = "div"> = HuiPolymorphicProps<E, TooltipContentOwnProps, PopoverSlots>;
|
|
46
|
+
declare function Content<E extends ElementType = "div">(rawProps: TooltipContentProps<E>): ReactElement;
|
|
47
|
+
export declare const Tooltip: typeof TooltipRoot & {
|
|
48
|
+
Trigger: typeof Trigger;
|
|
49
|
+
Content: typeof Content;
|
|
50
|
+
};
|
|
51
|
+
//#endregion
|
|
52
|
+
export {};
|
|
53
|
+
//# sourceMappingURL=tooltip.d.ts.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
|
|
2
|
+
import { Button } from "../button/button.js";
|
|
3
|
+
import { TooltipContext, useTooltipId } from "./tooltip.context.js";
|
|
4
|
+
import { popoverRecipe, tooltipControl } from "@hebium-ui/core";
|
|
5
|
+
import { useCallback, useId, useMemo } from "react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/tooltip/tooltip.tsx
|
|
8
|
+
function TooltipRoot(rawProps) {
|
|
9
|
+
const { id, children } = useHuiProps("Tooltip", rawProps);
|
|
10
|
+
const tmpId = useId();
|
|
11
|
+
const tooltipId = id || tmpId;
|
|
12
|
+
const contextValue = useMemo(() => {
|
|
13
|
+
return { tooltipId };
|
|
14
|
+
}, [tooltipId]);
|
|
15
|
+
return /* @__PURE__ */ jsx(TooltipContext.Provider, {
|
|
16
|
+
value: contextValue,
|
|
17
|
+
children
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function Trigger(rawProps) {
|
|
21
|
+
const { as, onPointerEnter, onPointerLeave, onFocus, onBlur, ...restProps } = useHuiProps("TooltipTrigger", rawProps);
|
|
22
|
+
const Component = as ?? Button;
|
|
23
|
+
const tooltipId = useTooltipId();
|
|
24
|
+
const attrs = tooltipControl.getTriggerAttributes({ tooltipId }, { isButtonElement: as === void 0 });
|
|
25
|
+
const handlePointerEnter = useCallback((e) => {
|
|
26
|
+
onPointerEnter?.(e);
|
|
27
|
+
tooltipControl.showTooltip(tooltipId, e.currentTarget);
|
|
28
|
+
}, [onPointerEnter, tooltipId]);
|
|
29
|
+
const handlePointerLeave = useCallback((e) => {
|
|
30
|
+
onPointerLeave?.(e);
|
|
31
|
+
tooltipControl.hideTooltip(tooltipId);
|
|
32
|
+
}, [onPointerLeave, tooltipId]);
|
|
33
|
+
const handleFocus = useCallback((e) => {
|
|
34
|
+
onFocus?.(e);
|
|
35
|
+
tooltipControl.showTooltip(tooltipId, e.currentTarget);
|
|
36
|
+
}, [onFocus, tooltipId]);
|
|
37
|
+
const handleBlur = useCallback((e) => {
|
|
38
|
+
onBlur?.(e);
|
|
39
|
+
tooltipControl.hideTooltip(tooltipId);
|
|
40
|
+
}, [onBlur, tooltipId]);
|
|
41
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
42
|
+
...attrs,
|
|
43
|
+
onPointerEnter: handlePointerEnter,
|
|
44
|
+
onPointerLeave: handlePointerLeave,
|
|
45
|
+
onFocus: handleFocus,
|
|
46
|
+
onBlur: handleBlur,
|
|
47
|
+
...restProps
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function Content(rawProps) {
|
|
51
|
+
const { as, position, fallbacks, visibility, padding, className, style, children, onPointerLeave, ...restProps } = useHuiProps("TooltipContent", rawProps);
|
|
52
|
+
const Component = as ?? "div";
|
|
53
|
+
const tooltipId = useTooltipId();
|
|
54
|
+
const recipe = popoverRecipe({
|
|
55
|
+
position,
|
|
56
|
+
fallbacks,
|
|
57
|
+
visibility,
|
|
58
|
+
padding
|
|
59
|
+
});
|
|
60
|
+
const cls = useHuiClassNames("TooltipContent", recipe, { root: className });
|
|
61
|
+
const sls = useHuiStyles("TooltipContent", { root: style });
|
|
62
|
+
const attrs = tooltipControl.getContentAttributes({ tooltipId });
|
|
63
|
+
const handlePointerLeave = useCallback((e) => {
|
|
64
|
+
onPointerLeave?.(e);
|
|
65
|
+
tooltipControl.hideTooltip(tooltipId);
|
|
66
|
+
}, [onPointerLeave, tooltipId]);
|
|
67
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
68
|
+
...attrs,
|
|
69
|
+
className: cls.root,
|
|
70
|
+
style: sls.root,
|
|
71
|
+
onPointerLeave: handlePointerLeave,
|
|
72
|
+
...restProps,
|
|
73
|
+
children
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
const Tooltip = Object.assign(TooltipRoot, {
|
|
77
|
+
Trigger,
|
|
78
|
+
Content
|
|
79
|
+
});
|
|
80
|
+
//#endregion
|
|
81
|
+
export { Tooltip };
|
|
82
|
+
|
|
83
|
+
//# sourceMappingURL=tooltip.js.map
|
|
@@ -0,0 +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> = HuiPolymorphicProps<\n E,\n {},\n ButtonSlots\n>;\n\nfunction Trigger<E extends ElementType = typeof 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\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 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 className,\n style,\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, { root: className });\n const sls = useHuiStyles(\"TooltipContent\", { root: style });\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":";;;;;;;AA6BA,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,QAA+C,UAA6C;CACnG,MAAM,EACJ,IACA,gBACA,gBACA,SACA,QACA,GAAG,cACD,YAAY,kBAAkB,QAAQ;CAE1C,MAAM,YAAY,MAAM;CAExB,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,gBAAgB;EAChB,gBAAgB;EAChB,SAAS;EACT,QAAQ;EACR,GAAI;CACL,CAAA;AAEL;AAmCA,SAAS,QAAuC,UAAgD;CAC9F,MAAM,EACJ,IACA,UACA,WACA,YACA,SACA,WACA,OACA,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,EAAE,MAAM,UAAU,CAAC;CAC1E,MAAM,MAAM,aAAa,kBAAkB,EAAE,MAAM,MAAM,CAAC;CAC1D,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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { HuiPolymorphicProps } from "../../types/polymorphic.js";
|
|
2
|
+
import "../../types/index.js";
|
|
3
|
+
import { ParagraphSlots } from "@hebium-ui/core";
|
|
4
|
+
import { ElementType, ReactElement } from "react";
|
|
5
|
+
//#region src/components/visually-hidden/visually-hidden.d.ts
|
|
6
|
+
export type VisuallyHiddenProps<E extends ElementType = "span"> = HuiPolymorphicProps<E, {}, ParagraphSlots>;
|
|
7
|
+
export declare function VisuallyHidden<E extends ElementType = "span">(rawProps: VisuallyHiddenProps<E>): ReactElement;
|
|
8
|
+
//#endregion
|
|
9
|
+
//# sourceMappingURL=visually-hidden.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
|
|
2
|
+
import { visuallyHiddenRecipe } from "@hebium-ui/core";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/visually-hidden/visually-hidden.tsx
|
|
5
|
+
function VisuallyHidden(rawProps) {
|
|
6
|
+
const { as, className, style, children, ...restProps } = useHuiProps("VisuallyHidden", rawProps);
|
|
7
|
+
const Component = as ?? "span";
|
|
8
|
+
const recipe = visuallyHiddenRecipe({});
|
|
9
|
+
const cls = useHuiClassNames("VisuallyHidden", recipe, { root: className });
|
|
10
|
+
const sls = useHuiStyles("VisuallyHidden", { root: style });
|
|
11
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
12
|
+
className: cls.root,
|
|
13
|
+
style: sls.root,
|
|
14
|
+
...restProps,
|
|
15
|
+
children
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { VisuallyHidden };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=visually-hidden.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visually-hidden.js","names":[],"sources":["../../../src/components/visually-hidden/visually-hidden.tsx"],"sourcesContent":["import { type ParagraphSlots, visuallyHiddenRecipe } 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 ParagraphSlots\n>;\n\nexport function VisuallyHidden<E extends ElementType = \"span\">(rawProps: VisuallyHiddenProps<E>): ReactElement {\n const {\n as,\n className,\n style,\n children,\n ...restProps\n } = useHuiProps(\"VisuallyHidden\", rawProps);\n\n const Component = as ?? \"span\";\n const recipe = visuallyHiddenRecipe({});\n const cls = useHuiClassNames(\"VisuallyHidden\", recipe, { root: className });\n const sls = useHuiStyles(\"VisuallyHidden\", { root: style });\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,WACA,OACA,UACA,GAAG,cACD,YAAY,kBAAkB,QAAQ;CAE1C,MAAM,YAAY,MAAM;CACxB,MAAM,SAAS,qBAAqB,CAAC,CAAC;CACtC,MAAM,MAAM,iBAAiB,kBAAkB,QAAQ,EAAE,MAAM,UAAU,CAAC;CAC1E,MAAM,MAAM,aAAa,kBAAkB,EAAE,MAAM,MAAM,CAAC;CAE1D,OACE,oBAAC,WAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EAEH;CACQ,CAAA;AAEf"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Alert, AlertProps } from "./components/alert/alert.js";
|
|
2
|
+
import { Anchor, AnchorProps } from "./components/anchor/anchor.js";
|
|
3
|
+
import { Avatar, AvatarProps } from "./components/avatar/avatar.js";
|
|
4
|
+
import { Blockquote, BlockquoteProps } from "./components/blockquote/blockquote.js";
|
|
5
|
+
import { Button, ButtonProps } from "./components/button/button.js";
|
|
6
|
+
import { Checkbox, CheckboxProps } from "./components/checkbox/checkbox.js";
|
|
7
|
+
import { Code, CodeProps } from "./components/code/code.js";
|
|
8
|
+
import { Details, DetailsProps } from "./components/details/details.js";
|
|
9
|
+
import { Heading, HeadingProps } from "./components/heading/heading.js";
|
|
10
|
+
import { Dialog, DialogCloseProps, DialogContentProps, DialogProps, DialogTriggerProps } from "./components/dialog/dialog.js";
|
|
11
|
+
import { useDialogId } from "./components/dialog/dialog.context.js";
|
|
12
|
+
import { DdProps, Dl, DlProps, DtProps } from "./components/dl/dl.js";
|
|
13
|
+
import { Drawer, DrawerCloseProps, DrawerContentProps, DrawerProps, DrawerTriggerProps } from "./components/drawer/drawer.js";
|
|
14
|
+
import { useDrawerId } from "./components/drawer/drawer.context.js";
|
|
15
|
+
import { Fieldset, FieldsetProps } from "./components/fieldset/fieldset.js";
|
|
16
|
+
import { Hr, HrProps } from "./components/hr/hr.js";
|
|
17
|
+
import { Label, LabelProps } from "./components/label/label.js";
|
|
18
|
+
import { Input, InputProps } from "./components/input/input.js";
|
|
19
|
+
import { Menu, MenuContentProps, MenuItemProps, MenuProps, MenuTriggerProps } from "./components/menu/menu.js";
|
|
20
|
+
import { useMenuId } from "./components/menu/menu.context.js";
|
|
21
|
+
import { Paragraph, ParagraphProps } from "./components/paragraph/paragraph.js";
|
|
22
|
+
import { Popover, PopoverContentProps, PopoverProps, PopoverTriggerProps } from "./components/popover/popover.js";
|
|
23
|
+
import { usePopoverId } from "./components/popover/popover.context.js";
|
|
24
|
+
import { Progress, ProgressProps } from "./components/progress/progress.js";
|
|
25
|
+
import { Radio, RadioProps } from "./components/radio/radio.js";
|
|
26
|
+
import { Radiogroup, RadiogroupProps } from "./components/radiogroup/radiogroup.js";
|
|
27
|
+
import { Section, SectionProps } from "./components/section/section.js";
|
|
28
|
+
import { SegmentedControl, SegmentedControlItemProps, SegmentedControlProps } from "./components/segmented-control/segmented-control.js";
|
|
29
|
+
import { Select, SelectProps } from "./components/select/select.js";
|
|
30
|
+
import { CaptionProps, Table, TableProps, TbodyProps, TdProps, TfootProps, ThProps, TheadProps, TrProps } from "./components/table/table.js";
|
|
31
|
+
import { Tabs, TabsListProps, TabsPanelProps, TabsProps, TabsTabProps } from "./components/tabs/tabs.js";
|
|
32
|
+
import { Textarea, TextareaProps } from "./components/textarea/textarea.js";
|
|
33
|
+
import { Tooltip, TooltipContentProps, TooltipProps, TooltipTriggerProps } from "./components/tooltip/tooltip.js";
|
|
34
|
+
import { useTooltipId } from "./components/tooltip/tooltip.context.js";
|
|
35
|
+
import { VisuallyHidden, VisuallyHiddenProps } from "./components/visually-hidden/visually-hidden.js";
|
|
36
|
+
import "./components/index.js";
|
|
37
|
+
import { HuiComponentPropsMap, HuiProviderContext, HuiProviderContextValue, useHuiClassNames, useHuiProps, useHuiProviderContext, useHuiStyles } from "./provider/hui-provider.context.js";
|
|
38
|
+
import { HuiProvider } from "./provider/hui-provider.js";
|
|
39
|
+
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, useDialogId, useDrawerId, useHuiClassNames, useHuiProps, useHuiProviderContext, useHuiStyles, useMenuId, usePopoverId, useTooltipId };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { HuiProviderContext, useHuiClassNames, useHuiProps, useHuiProviderContext, useHuiStyles } from "./provider/hui-provider.context.js";
|
|
2
|
+
import { HuiProvider } from "./provider/hui-provider.js";
|
|
3
|
+
import { Alert } from "./components/alert/alert.js";
|
|
4
|
+
import { Anchor } from "./components/anchor/anchor.js";
|
|
5
|
+
import { Avatar } from "./components/avatar/avatar.js";
|
|
6
|
+
import { Blockquote } from "./components/blockquote/blockquote.js";
|
|
7
|
+
import { Button } from "./components/button/button.js";
|
|
8
|
+
import { Checkbox } from "./components/checkbox/checkbox.js";
|
|
9
|
+
import { Code } from "./components/code/code.js";
|
|
10
|
+
import { Details } from "./components/details/details.js";
|
|
11
|
+
import { Heading } from "./components/heading/heading.js";
|
|
12
|
+
import { useDialogId } from "./components/dialog/dialog.context.js";
|
|
13
|
+
import { Dialog } from "./components/dialog/dialog.js";
|
|
14
|
+
import { Dl } from "./components/dl/dl.js";
|
|
15
|
+
import { useDrawerId } from "./components/drawer/drawer.context.js";
|
|
16
|
+
import { Drawer } from "./components/drawer/drawer.js";
|
|
17
|
+
import { Fieldset } from "./components/fieldset/fieldset.js";
|
|
18
|
+
import { Hr } from "./components/hr/hr.js";
|
|
19
|
+
import { Label } from "./components/label/label.js";
|
|
20
|
+
import { Input } from "./components/input/input.js";
|
|
21
|
+
import { useMenuId } from "./components/menu/menu.context.js";
|
|
22
|
+
import { Menu } from "./components/menu/menu.js";
|
|
23
|
+
import { Paragraph } from "./components/paragraph/paragraph.js";
|
|
24
|
+
import { usePopoverId } from "./components/popover/popover.context.js";
|
|
25
|
+
import { Popover } from "./components/popover/popover.js";
|
|
26
|
+
import { Progress } from "./components/progress/progress.js";
|
|
27
|
+
import { Radio } from "./components/radio/radio.js";
|
|
28
|
+
import { Radiogroup } from "./components/radiogroup/radiogroup.js";
|
|
29
|
+
import { Section } from "./components/section/section.js";
|
|
30
|
+
import { SegmentedControl } from "./components/segmented-control/segmented-control.js";
|
|
31
|
+
import { Select } from "./components/select/select.js";
|
|
32
|
+
import { Table } from "./components/table/table.js";
|
|
33
|
+
import { Tabs } from "./components/tabs/tabs.js";
|
|
34
|
+
import { Textarea } from "./components/textarea/textarea.js";
|
|
35
|
+
import { useTooltipId } from "./components/tooltip/tooltip.context.js";
|
|
36
|
+
import { Tooltip } from "./components/tooltip/tooltip.js";
|
|
37
|
+
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, Textarea, Tooltip, VisuallyHidden, useDialogId, useDrawerId, useHuiClassNames, useHuiProps, useHuiProviderContext, useHuiStyles, useMenuId, usePopoverId, useTooltipId };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { AlertProps } from "../components/alert/alert.js";
|
|
2
|
+
import { AnchorProps } from "../components/anchor/anchor.js";
|
|
3
|
+
import { AvatarProps } from "../components/avatar/avatar.js";
|
|
4
|
+
import { BlockquoteProps } from "../components/blockquote/blockquote.js";
|
|
5
|
+
import { ButtonProps } from "../components/button/button.js";
|
|
6
|
+
import { CheckboxProps } from "../components/checkbox/checkbox.js";
|
|
7
|
+
import { CodeProps } from "../components/code/code.js";
|
|
8
|
+
import { DetailsProps } from "../components/details/details.js";
|
|
9
|
+
import { HeadingProps } from "../components/heading/heading.js";
|
|
10
|
+
import { DialogCloseProps, DialogContentProps, DialogProps, DialogTriggerProps } from "../components/dialog/dialog.js";
|
|
11
|
+
import { DdProps, DlProps, DtProps } from "../components/dl/dl.js";
|
|
12
|
+
import { DrawerCloseProps, DrawerContentProps, DrawerProps, DrawerTriggerProps } from "../components/drawer/drawer.js";
|
|
13
|
+
import { FieldsetProps } from "../components/fieldset/fieldset.js";
|
|
14
|
+
import { HrProps } from "../components/hr/hr.js";
|
|
15
|
+
import { LabelProps } from "../components/label/label.js";
|
|
16
|
+
import { InputProps } from "../components/input/input.js";
|
|
17
|
+
import { MenuContentProps, MenuItemProps, MenuProps, MenuTriggerProps } from "../components/menu/menu.js";
|
|
18
|
+
import { ParagraphProps } from "../components/paragraph/paragraph.js";
|
|
19
|
+
import { PopoverContentProps, PopoverProps, PopoverTriggerProps } from "../components/popover/popover.js";
|
|
20
|
+
import { ProgressProps } from "../components/progress/progress.js";
|
|
21
|
+
import { RadioProps } from "../components/radio/radio.js";
|
|
22
|
+
import { RadiogroupProps } from "../components/radiogroup/radiogroup.js";
|
|
23
|
+
import { SectionProps } from "../components/section/section.js";
|
|
24
|
+
import { SegmentedControlItemProps, SegmentedControlProps } from "../components/segmented-control/segmented-control.js";
|
|
25
|
+
import { SelectProps } from "../components/select/select.js";
|
|
26
|
+
import { CaptionProps, TableProps, TbodyProps, TdProps, TfootProps, ThProps, TheadProps, TrProps } from "../components/table/table.js";
|
|
27
|
+
import { TabsListProps, TabsPanelProps, TabsProps, TabsTabProps } from "../components/tabs/tabs.js";
|
|
28
|
+
import { TextareaProps } from "../components/textarea/textarea.js";
|
|
29
|
+
import { TooltipContentProps, TooltipProps, TooltipTriggerProps } from "../components/tooltip/tooltip.js";
|
|
30
|
+
import { VisuallyHiddenProps } from "../components/visually-hidden/visually-hidden.js";
|
|
31
|
+
import "../components/index.js";
|
|
32
|
+
import { CSSProperties } from "react";
|
|
33
|
+
//#region src/provider/hui-provider.context.d.ts
|
|
34
|
+
export interface HuiComponentPropsMap {
|
|
35
|
+
Alert: Partial<AlertProps>;
|
|
36
|
+
Anchor: Partial<AnchorProps>;
|
|
37
|
+
Avatar: Partial<AvatarProps>;
|
|
38
|
+
Blockquote: Partial<BlockquoteProps>;
|
|
39
|
+
Button: Partial<ButtonProps>;
|
|
40
|
+
Checkbox: Partial<CheckboxProps>;
|
|
41
|
+
Code: Partial<CodeProps>;
|
|
42
|
+
Details: Partial<DetailsProps>;
|
|
43
|
+
Dialog: Partial<DialogProps>;
|
|
44
|
+
DialogTrigger: Partial<DialogTriggerProps>;
|
|
45
|
+
DialogContent: Partial<DialogContentProps>;
|
|
46
|
+
DialogClose: Partial<DialogCloseProps>;
|
|
47
|
+
Drawer: Partial<DrawerProps>;
|
|
48
|
+
DrawerTrigger: Partial<DrawerTriggerProps>;
|
|
49
|
+
DrawerContent: Partial<DrawerContentProps>;
|
|
50
|
+
DrawerClose: Partial<DrawerCloseProps>;
|
|
51
|
+
Dl: Partial<DlProps>;
|
|
52
|
+
DlDt: Partial<DtProps>;
|
|
53
|
+
DlDd: Partial<DdProps>;
|
|
54
|
+
Fieldset: Partial<FieldsetProps>;
|
|
55
|
+
Heading: Partial<HeadingProps>;
|
|
56
|
+
Hr: Partial<HrProps>;
|
|
57
|
+
Input: Partial<InputProps>;
|
|
58
|
+
Label: Partial<LabelProps>;
|
|
59
|
+
Menu: Partial<MenuProps>;
|
|
60
|
+
MenuContent: Partial<MenuContentProps>;
|
|
61
|
+
MenuItem: Partial<MenuItemProps>;
|
|
62
|
+
MenuTrigger: Partial<MenuTriggerProps>;
|
|
63
|
+
Paragraph: Partial<ParagraphProps>;
|
|
64
|
+
Popover: Partial<PopoverProps>;
|
|
65
|
+
PopoverTrigger: Partial<PopoverTriggerProps>;
|
|
66
|
+
PopoverContent: Partial<PopoverContentProps>;
|
|
67
|
+
Progress: Partial<ProgressProps>;
|
|
68
|
+
Radio: Partial<RadioProps>;
|
|
69
|
+
Radiogroup: Partial<RadiogroupProps>;
|
|
70
|
+
Section: Partial<SectionProps>;
|
|
71
|
+
Select: Partial<SelectProps>;
|
|
72
|
+
SegmentedControlItem: Partial<SegmentedControlItemProps>;
|
|
73
|
+
SegmentedControl: Partial<SegmentedControlProps<string>>;
|
|
74
|
+
Table: Partial<TableProps>;
|
|
75
|
+
TableCaption: Partial<CaptionProps>;
|
|
76
|
+
TableThead: Partial<TheadProps>;
|
|
77
|
+
TableTbody: Partial<TbodyProps>;
|
|
78
|
+
TableTfoot: Partial<TfootProps>;
|
|
79
|
+
TableTr: Partial<TrProps>;
|
|
80
|
+
TableTh: Partial<ThProps>;
|
|
81
|
+
TableTd: Partial<TdProps>;
|
|
82
|
+
Tabs: Partial<TabsProps<string>>;
|
|
83
|
+
TabsList: Partial<TabsListProps>;
|
|
84
|
+
TabsTab: Partial<TabsTabProps>;
|
|
85
|
+
TabsPanel: Partial<TabsPanelProps>;
|
|
86
|
+
Textarea: Partial<TextareaProps>;
|
|
87
|
+
Tooltip: Partial<TooltipProps>;
|
|
88
|
+
TooltipTrigger: Partial<TooltipTriggerProps>;
|
|
89
|
+
TooltipContent: Partial<TooltipContentProps>;
|
|
90
|
+
VisuallyHidden: Partial<VisuallyHiddenProps>;
|
|
91
|
+
}
|
|
92
|
+
type HuiComponentName = keyof HuiComponentPropsMap;
|
|
93
|
+
type HuiDefaultProps = Partial<HuiComponentPropsMap>;
|
|
94
|
+
export interface HuiProviderContextValue {
|
|
95
|
+
defaultProps: HuiDefaultProps;
|
|
96
|
+
}
|
|
97
|
+
export declare const HuiProviderContext: import("react").Context<HuiProviderContextValue | null>;
|
|
98
|
+
export declare function useHuiProviderContext(): HuiProviderContextValue;
|
|
99
|
+
export declare function useHuiProps<K extends HuiComponentName, P extends object>(key: K, rawProps: P): P;
|
|
100
|
+
export declare function useHuiClassNames<K extends HuiComponentName, S extends string>(key: K, recipe: Record<S, string>, rawClassNames?: Partial<Record<S, string | undefined>>): Record<S, string>;
|
|
101
|
+
export declare function useHuiStyles<K extends HuiComponentName, S extends string>(key: K, rawStyles?: Partial<Record<S, CSSProperties | undefined>>): Partial<Record<S, CSSProperties>>;
|
|
102
|
+
//#endregion
|
|
103
|
+
export {};
|
|
104
|
+
//# sourceMappingURL=hui-provider.context.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { mergeProps } from "./merge-props.js";
|
|
2
|
+
import { ccAll, msAll } from "@hebium-ui/core";
|
|
3
|
+
import { createContext, useContext, useMemo } from "react";
|
|
4
|
+
//#region src/provider/hui-provider.context.ts
|
|
5
|
+
const HuiProviderContext = createContext(null);
|
|
6
|
+
function useHuiProviderContext() {
|
|
7
|
+
return useContext(HuiProviderContext) ?? { defaultProps: {} };
|
|
8
|
+
}
|
|
9
|
+
function useHuiDefaultProps(key) {
|
|
10
|
+
return useHuiProviderContext().defaultProps[key];
|
|
11
|
+
}
|
|
12
|
+
function useHuiProps(key, rawProps) {
|
|
13
|
+
const defaultProps = useHuiDefaultProps(key);
|
|
14
|
+
return useMemo(() => {
|
|
15
|
+
if (typeof defaultProps === "undefined") return rawProps;
|
|
16
|
+
return mergeProps(defaultProps, rawProps);
|
|
17
|
+
}, [defaultProps, rawProps]);
|
|
18
|
+
}
|
|
19
|
+
function useHuiClassNames(key, recipe, rawClassNames = {}) {
|
|
20
|
+
const defaultProps = useHuiDefaultProps(key);
|
|
21
|
+
if (!defaultProps) return ccAll(recipe, rawClassNames);
|
|
22
|
+
if ("classNames" in defaultProps && defaultProps.classNames) return ccAll(recipe, defaultProps.classNames, rawClassNames);
|
|
23
|
+
else if ("className" in defaultProps && defaultProps.className) return ccAll(recipe, { root: defaultProps.className }, rawClassNames);
|
|
24
|
+
else return ccAll(recipe, rawClassNames);
|
|
25
|
+
}
|
|
26
|
+
function useHuiStyles(key, rawStyles = {}) {
|
|
27
|
+
const defaultProps = useHuiDefaultProps(key);
|
|
28
|
+
if (!defaultProps) return rawStyles ?? {};
|
|
29
|
+
if ("styles" in defaultProps && defaultProps.styles) return msAll(defaultProps.styles, rawStyles);
|
|
30
|
+
else if ("style" in defaultProps && defaultProps.style) return msAll({ root: defaultProps.style }, rawStyles);
|
|
31
|
+
else return rawStyles ?? {};
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { HuiProviderContext, useHuiClassNames, useHuiProps, useHuiProviderContext, useHuiStyles };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=hui-provider.context.js.map
|
|
@@ -0,0 +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\nexport function useHuiProps<K extends HuiComponentName, P extends object>(\n key: K,\n rawProps: P,\n): P {\n const defaultProps = useHuiDefaultProps(key);\n const props = useMemo(() => {\n if (typeof defaultProps === \"undefined\") {\n return rawProps;\n }\n\n return mergeProps(defaultProps as Partial<P>, rawProps);\n }, [defaultProps, rawProps]);\n return props as P;\n}\n\nexport function useHuiClassNames<K extends HuiComponentName, S extends string>(\n key: K,\n recipe: Record<S, string>,\n rawClassNames: Partial<Record<S, string | undefined>> = {},\n): Record<S, string> {\n const defaultProps = useHuiDefaultProps(key);\n if (!defaultProps) return ccAll(recipe, rawClassNames);\n\n if (\"classNames\" in defaultProps && defaultProps.classNames) {\n return ccAll(recipe, defaultProps.classNames as Record<S, string>, rawClassNames);\n } else if (\"className\" in defaultProps && defaultProps.className) {\n return ccAll(recipe, { root: defaultProps.className } as Record<S, string>, rawClassNames);\n } else {\n return ccAll(recipe, rawClassNames);\n }\n}\n\nexport function useHuiStyles<K extends HuiComponentName, S extends string>(\n key: K,\n rawStyles: Partial<Record<S, CSSProperties | undefined>> = {},\n): Partial<Record<S, CSSProperties>> {\n const defaultProps = useHuiDefaultProps(key);\n if (!defaultProps) return rawStyles ?? {};\n\n if (\"styles\" in defaultProps && defaultProps.styles) {\n return msAll(defaultProps.styles as Partial<Record<S, CSSProperties>>, rawStyles);\n } else if (\"style\" in defaultProps && defaultProps.style) {\n return msAll({ root: defaultProps.style } as Partial<Record<S, CSSProperties>>, rawStyles);\n } else {\n return rawStyles ?? {};\n }\n}\n"],"mappings":";;;;AAgIA,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,SAAgB,YACd,KACA,UACG;CACH,MAAM,eAAe,mBAAmB,GAAG;CAQ3C,OAPc,cAAc;EAC1B,IAAI,OAAO,iBAAiB,aAC1B,OAAO;EAGT,OAAO,WAAW,cAA4B,QAAQ;CACxD,GAAG,CAAC,cAAc,QAAQ,CACf;AACb;AAEA,SAAgB,iBACd,KACA,QACA,gBAAwD,CAAC,GACtC;CACnB,MAAM,eAAe,mBAAmB,GAAG;CAC3C,IAAI,CAAC,cAAc,OAAO,MAAM,QAAQ,aAAa;CAErD,IAAI,gBAAgB,gBAAgB,aAAa,YAC/C,OAAO,MAAM,QAAQ,aAAa,YAAiC,aAAa;MAC3E,IAAI,eAAe,gBAAgB,aAAa,WACrD,OAAO,MAAM,QAAQ,EAAE,MAAM,aAAa,UAAU,GAAwB,aAAa;MAEzF,OAAO,MAAM,QAAQ,aAAa;AAEtC;AAEA,SAAgB,aACd,KACA,YAA2D,CAAC,GACzB;CACnC,MAAM,eAAe,mBAAmB,GAAG;CAC3C,IAAI,CAAC,cAAc,OAAO,aAAa,CAAC;CAExC,IAAI,YAAY,gBAAgB,aAAa,QAC3C,OAAO,MAAM,aAAa,QAA6C,SAAS;MAC3E,IAAI,WAAW,gBAAgB,aAAa,OACjD,OAAO,MAAM,EAAE,MAAM,aAAa,MAAM,GAAwC,SAAS;MAEzF,OAAO,aAAa,CAAC;AAEzB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { HuiProviderContextValue } from "./hui-provider.context.js";
|
|
2
|
+
import { PropsWithChildren, ReactElement } from "react";
|
|
3
|
+
//#region src/provider/hui-provider.d.ts
|
|
4
|
+
interface HuiProviderProps extends Partial<HuiProviderContextValue>, PropsWithChildren {}
|
|
5
|
+
export declare function HuiProvider({ defaultProps, children }: HuiProviderProps): ReactElement;
|
|
6
|
+
//#endregion
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=hui-provider.d.ts.map
|