@hebium-ui/react 0.1.0-alpha.1 → 0.1.0-alpha.3
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 +0 -2
- package/dist/components/alert/alert.js +4 -5
- package/dist/components/alert/alert.js.map +1 -1
- package/dist/components/anchor/anchor.d.ts +0 -2
- package/dist/components/anchor/anchor.js +4 -5
- package/dist/components/anchor/anchor.js.map +1 -1
- package/dist/components/avatar/avatar.d.ts +0 -2
- package/dist/components/avatar/avatar.js +4 -5
- package/dist/components/avatar/avatar.js.map +1 -1
- package/dist/components/blockquote/blockquote.d.ts +0 -2
- package/dist/components/blockquote/blockquote.js +4 -5
- package/dist/components/blockquote/blockquote.js.map +1 -1
- package/dist/components/button/button.d.ts +0 -2
- package/dist/components/button/button.js +4 -5
- package/dist/components/button/button.js.map +1 -1
- package/dist/components/checkbox/checkbox.d.ts +1 -3
- package/dist/components/checkbox/checkbox.js +29 -16
- package/dist/components/checkbox/checkbox.js.map +1 -1
- package/dist/components/code/code.d.ts +0 -2
- package/dist/components/code/code.js +4 -5
- package/dist/components/code/code.js.map +1 -1
- package/dist/components/details/details.d.ts +0 -2
- package/dist/components/details/details.js +4 -5
- package/dist/components/details/details.js.map +1 -1
- package/dist/components/dialog/dialog.context.d.ts +0 -2
- package/dist/components/dialog/dialog.context.js +1 -2
- package/dist/components/dialog/dialog.d.ts +0 -2
- package/dist/components/dialog/dialog.js +13 -6
- package/dist/components/dialog/dialog.js.map +1 -1
- package/dist/components/dl/dl.d.ts +0 -2
- package/dist/components/dl/dl.js +10 -11
- package/dist/components/dl/dl.js.map +1 -1
- package/dist/components/drawer/drawer.context.d.ts +0 -2
- package/dist/components/drawer/drawer.context.js +1 -2
- package/dist/components/drawer/drawer.d.ts +0 -2
- package/dist/components/drawer/drawer.js +13 -6
- package/dist/components/drawer/drawer.js.map +1 -1
- package/dist/components/fieldset/fieldset.d.ts +0 -2
- package/dist/components/fieldset/fieldset.js +4 -5
- package/dist/components/fieldset/fieldset.js.map +1 -1
- package/dist/components/heading/heading.d.ts +0 -2
- package/dist/components/heading/heading.js +4 -5
- package/dist/components/heading/heading.js.map +1 -1
- package/dist/components/hr/hr.d.ts +0 -2
- package/dist/components/hr/hr.js +4 -5
- package/dist/components/hr/hr.js.map +1 -1
- package/dist/components/index.d.ts +5 -1
- package/dist/components/input/input.d.ts +0 -2
- package/dist/components/input/input.js +4 -5
- package/dist/components/input/input.js.map +1 -1
- package/dist/components/label/label.d.ts +0 -2
- package/dist/components/label/label.js +4 -5
- package/dist/components/label/label.js.map +1 -1
- package/dist/components/menu/menu.context.d.ts +0 -2
- package/dist/components/menu/menu.context.js +1 -2
- package/dist/components/menu/menu.d.ts +0 -2
- package/dist/components/menu/menu.js +11 -8
- package/dist/components/menu/menu.js.map +1 -1
- package/dist/components/paragraph/paragraph.d.ts +6 -2
- package/dist/components/paragraph/paragraph.js +8 -6
- package/dist/components/paragraph/paragraph.js.map +1 -1
- package/dist/components/popover/popover.context.d.ts +0 -2
- package/dist/components/popover/popover.context.js +1 -2
- package/dist/components/popover/popover.d.ts +0 -2
- package/dist/components/popover/popover.js +8 -5
- package/dist/components/popover/popover.js.map +1 -1
- package/dist/components/progress/progress.d.ts +0 -2
- package/dist/components/progress/progress.js +4 -5
- package/dist/components/progress/progress.js.map +1 -1
- package/dist/components/radio/radio.d.ts +0 -2
- package/dist/components/radio/radio.js +4 -5
- package/dist/components/radio/radio.js.map +1 -1
- package/dist/components/radiogroup/radiogroup.d.ts +0 -2
- package/dist/components/radiogroup/radiogroup.js +4 -5
- package/dist/components/radiogroup/radiogroup.js.map +1 -1
- package/dist/components/section/section.d.ts +0 -2
- 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 +1 -3
- package/dist/components/segmented-control/segmented-control.js +7 -8
- package/dist/components/segmented-control/segmented-control.js.map +1 -1
- package/dist/components/select/select.d.ts +0 -2
- 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 +7 -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/table/table.d.ts +0 -2
- 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 +0 -2
- package/dist/components/tabs/tabs.context.js +1 -2
- package/dist/components/tabs/tabs.d.ts +1 -3
- package/dist/components/tabs/tabs.js +13 -14
- package/dist/components/tabs/tabs.js.map +1 -1
- package/dist/components/text/index.d.ts +2 -0
- package/dist/components/text/text.d.ts +23 -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 +0 -2
- package/dist/components/textarea/textarea.js +4 -5
- package/dist/components/textarea/textarea.js.map +1 -1
- package/dist/components/tooltip/tooltip.context.d.ts +0 -2
- package/dist/components/tooltip/tooltip.context.js +1 -2
- package/dist/components/tooltip/tooltip.d.ts +0 -2
- package/dist/components/tooltip/tooltip.js +8 -5
- package/dist/components/tooltip/tooltip.js.map +1 -1
- package/dist/components/visually-hidden/visually-hidden.d.ts +2 -4
- 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 +3 -1
- package/dist/index.js +3 -1
- package/dist/provider/hui-provider.context.d.ts +12 -4
- package/dist/provider/hui-provider.context.js +10 -4
- package/dist/provider/hui-provider.context.js.map +1 -1
- package/dist/provider/hui-provider.d.ts +0 -2
- package/dist/provider/hui-provider.js +1 -2
- package/dist/provider/merge-props.js +1 -2
- package/dist/types/hui-component.d.ts +0 -2
- package/dist/types/polymorphic.d.ts +0 -2
- package/dist/utils/attributes/normalize-attributes.js +1 -2
- package/package.json +9 -9
|
@@ -2,7 +2,6 @@ import { HuiPolymorphicProps } from "../../types/polymorphic.js";
|
|
|
2
2
|
import "../../types/index.js";
|
|
3
3
|
import { LabelMarker, LabelSlots, LabelVariants } from "@hebium-ui/core";
|
|
4
4
|
import { ElementType, ReactElement, ReactNode } from "react";
|
|
5
|
-
//#region src/components/label/label.d.ts
|
|
6
5
|
interface LabelOwnProps {
|
|
7
6
|
/**
|
|
8
7
|
* The visual state of the label.
|
|
@@ -27,6 +26,5 @@ interface LabelOwnProps {
|
|
|
27
26
|
}
|
|
28
27
|
export type LabelProps<E extends ElementType = "label"> = HuiPolymorphicProps<E, LabelOwnProps, LabelSlots>;
|
|
29
28
|
export declare function Label<E extends ElementType = "label">(rawProps: LabelProps<E>): ReactElement;
|
|
30
|
-
//#endregion
|
|
31
29
|
export {};
|
|
32
30
|
//# sourceMappingURL=label.d.ts.map
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
|
|
2
2
|
import { DEFAULT_LABEL_MAKER, labelMarker, labelRecipe, toBool } from "@hebium-ui/core";
|
|
3
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
-
|
|
4
|
+
// src/components/label/label.tsx
|
|
5
5
|
function Label(rawProps) {
|
|
6
|
-
const { as, variant, children, marker, description, error, "data-required": dataRequired,
|
|
6
|
+
const { as, variant, children, marker, description, error, "data-required": dataRequired, ...restProps } = useHuiProps("Label", rawProps);
|
|
7
7
|
const resolvedMarker = labelMarker(marker ?? DEFAULT_LABEL_MAKER, toBool(dataRequired));
|
|
8
8
|
const recipe = labelRecipe({
|
|
9
9
|
marker: resolvedMarker.label ? resolvedMarker.variant : void 0,
|
|
10
10
|
variant
|
|
11
11
|
});
|
|
12
|
-
const cls = useHuiClassNames("Label", recipe, classNames);
|
|
13
|
-
const sls = useHuiStyles("Label", styles);
|
|
12
|
+
const cls = useHuiClassNames("Label", recipe, rawProps.classNames);
|
|
13
|
+
const sls = useHuiStyles("Label", rawProps.styles);
|
|
14
14
|
return /* @__PURE__ */ jsxs(as ?? "label", {
|
|
15
15
|
className: cls.root,
|
|
16
16
|
style: sls.root,
|
|
@@ -48,7 +48,6 @@ function Label(rawProps) {
|
|
|
48
48
|
]
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
-
//#endregion
|
|
52
51
|
export { Label };
|
|
53
52
|
|
|
54
53
|
//# sourceMappingURL=label.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"label.js","names":[],"sources":["../../../src/components/label/label.tsx"],"sourcesContent":["import {\n DEFAULT_LABEL_MAKER,\n type LabelMarker,\n labelMarker,\n labelRecipe,\n type LabelSlots,\n type LabelVariants,\n toBool,\n} from \"@hebium-ui/core\";\nimport { type ElementType, type ReactElement, type ReactNode } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\n\ninterface LabelOwnProps {\n /**\n * The visual state of the label.\n */\n variant?: LabelVariants[\"variant\"] | undefined;\n /**\n * The marker displayed for required or optional fields. Use the `asterisk` variant for a highlighted asterisk marker.\n */\n marker?: LabelMarker<ReactNode> | undefined;\n /**\n * The help text displayed below the label.\n */\n description?: ReactNode | undefined;\n /**\n * The validation error message displayed below the label.\n */\n error?: ReactNode | undefined;\n /**\n * Whether the label should render the required marker.\n */\n \"data-required\"?: boolean | \"true\" | \"false\" | undefined;\n}\n\nexport type LabelProps<E extends ElementType = \"label\"> = HuiPolymorphicProps<\n E,\n LabelOwnProps,\n LabelSlots\n>;\n\nexport function Label<E extends ElementType = \"label\">(rawProps: LabelProps<E>): ReactElement {\n const {\n as,\n variant,\n children,\n marker,\n description,\n error,\n \"data-required\": dataRequired,\n
|
|
1
|
+
{"version":3,"file":"label.js","names":[],"sources":["../../../src/components/label/label.tsx"],"sourcesContent":["import {\n DEFAULT_LABEL_MAKER,\n type LabelMarker,\n labelMarker,\n labelRecipe,\n type LabelSlots,\n type LabelVariants,\n toBool,\n} from \"@hebium-ui/core\";\nimport { type ElementType, type ReactElement, type ReactNode } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\n\ninterface LabelOwnProps {\n /**\n * The visual state of the label.\n */\n variant?: LabelVariants[\"variant\"] | undefined;\n /**\n * The marker displayed for required or optional fields. Use the `asterisk` variant for a highlighted asterisk marker.\n */\n marker?: LabelMarker<ReactNode> | undefined;\n /**\n * The help text displayed below the label.\n */\n description?: ReactNode | undefined;\n /**\n * The validation error message displayed below the label.\n */\n error?: ReactNode | undefined;\n /**\n * Whether the label should render the required marker.\n */\n \"data-required\"?: boolean | \"true\" | \"false\" | undefined;\n}\n\nexport type LabelProps<E extends ElementType = \"label\"> = HuiPolymorphicProps<\n E,\n LabelOwnProps,\n LabelSlots\n>;\n\nexport function Label<E extends ElementType = \"label\">(rawProps: LabelProps<E>): ReactElement {\n const {\n as,\n variant,\n children,\n marker,\n description,\n error,\n \"data-required\": dataRequired,\n ...restProps\n } = useHuiProps(\"Label\", rawProps);\n\n const resolvedMarker = labelMarker(marker ?? DEFAULT_LABEL_MAKER, toBool(dataRequired));\n const recipe = labelRecipe({\n marker: resolvedMarker.label ? resolvedMarker.variant : undefined,\n variant,\n });\n const cls = useHuiClassNames(\"Label\", recipe, rawProps.classNames);\n const sls = useHuiStyles(\"Label\", rawProps.styles);\n\n const Component = as ?? \"label\";\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...restProps}\n >\n {children && (\n <span\n className={cls.fieldName}\n style={sls.fieldName}\n >\n {children}\n </span>\n )}\n {resolvedMarker.label && (\n <span\n aria-label={resolvedMarker[\"aria-label\"]}\n className={cls.fieldMarker}\n style={sls.fieldMarker}\n >\n {resolvedMarker.label}\n </span>\n )}\n {description && (\n <p\n className={cls.description}\n style={sls.description}\n >\n {description}\n </p>\n )}\n {error && (\n <p\n className={cls.error}\n style={sls.error}\n >\n <span\n aria-hidden\n className={cls.errorIcon}\n style={sls.errorIcon}\n />\n <span\n className={cls.errorMessage}\n style={sls.errorMessage}\n >\n {error}\n </span>\n </p>\n )}\n </Component>\n );\n}\n"],"mappings":";;;;AA0CA,SAAgB,MAAuC,UAAuC;CAC5F,MAAM,EACJ,IACA,SACA,UACA,QACA,aACA,OACA,iBAAiB,cACjB,GAAG,cACD,YAAY,SAAS,QAAQ;CAEjC,MAAM,iBAAiB,YAAY,UAAU,qBAAqB,OAAO,YAAY,CAAC;CACtF,MAAM,SAAS,YAAY;EACzB,QAAQ,eAAe,QAAQ,eAAe,UAAU,KAAA;EACxD;CACF,CAAC;CACD,MAAM,MAAM,iBAAiB,SAAS,QAAQ,SAAS,UAAU;CACjE,MAAM,MAAM,aAAa,SAAS,SAAS,MAAM;CAGjD,OACE,qBAFgB,MAAM,SAEtB;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EAHN,UAAA;GAKG,YACC,oBAAC,QAAD;IACE,WAAW,IAAI;IACf,OAAO,IAAI;IAEV;GACG,CAAA;GAEP,eAAe,SACd,oBAAC,QAAD;IACE,cAAY,eAAe;IAC3B,WAAW,IAAI;IACf,OAAO,IAAI;IAEV,UAAA,eAAe;GACZ,CAAA;GAEP,eACC,oBAAC,KAAD;IACE,WAAW,IAAI;IACf,OAAO,IAAI;IAEV,UAAA;GACA,CAAA;GAEJ,SACC,qBAAC,KAAD;IACE,WAAW,IAAI;IACf,OAAO,IAAI;IAFb,UAAA,CAIE,oBAAC,QAAD;KACE,eAAA;KACA,WAAW,IAAI;KACf,OAAO,IAAI;IACZ,CAAA,GACD,oBAAC,QAAD;KACE,WAAW,IAAI;KACf,OAAO,IAAI;KAEV,UAAA;IACG,CAAA,CACL;;EAEI;;AAEf"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createContext, useContext } from "react";
|
|
2
|
-
|
|
2
|
+
// src/components/menu/menu.context.ts
|
|
3
3
|
const MenuContext = createContext(null);
|
|
4
4
|
function useMenuContext() {
|
|
5
5
|
const context = useContext(MenuContext);
|
|
@@ -9,7 +9,6 @@ function useMenuContext() {
|
|
|
9
9
|
function useMenuId() {
|
|
10
10
|
return useMenuContext().menuId;
|
|
11
11
|
}
|
|
12
|
-
//#endregion
|
|
13
12
|
export { MenuContext, useMenuContext, useMenuId };
|
|
14
13
|
|
|
15
14
|
//# sourceMappingURL=menu.context.js.map
|
|
@@ -4,7 +4,6 @@ import { Button } from "../button/button.js";
|
|
|
4
4
|
import "../button/index.js";
|
|
5
5
|
import { ButtonSlots, MenuItemActivation, MenuitemSlots, MenuitemVariants, PopoverSlots, PopoverVariants } from "@hebium-ui/core";
|
|
6
6
|
import { ElementType, ReactElement, ReactNode } from "react";
|
|
7
|
-
//#region src/components/menu/menu.d.ts
|
|
8
7
|
export interface MenuProps {
|
|
9
8
|
/**
|
|
10
9
|
* The id of the menu content element.
|
|
@@ -77,6 +76,5 @@ export declare const Menu: typeof MenuRoot & {
|
|
|
77
76
|
Content: typeof Content;
|
|
78
77
|
Item: typeof Item;
|
|
79
78
|
};
|
|
80
|
-
//#endregion
|
|
81
79
|
export {};
|
|
82
80
|
//# sourceMappingURL=menu.d.ts.map
|
|
@@ -5,7 +5,7 @@ import { MenuContext, useMenuId } from "./menu.context.js";
|
|
|
5
5
|
import { menuControl, menuitemRecipe, popoverRecipe, toBool } from "@hebium-ui/core";
|
|
6
6
|
import { useCallback, useId, useMemo } from "react";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
|
-
|
|
8
|
+
// src/components/menu/menu.tsx
|
|
9
9
|
function MenuRoot(rawProps) {
|
|
10
10
|
const { id, children } = useHuiProps("Menu", rawProps);
|
|
11
11
|
const tmpId = useId();
|
|
@@ -21,6 +21,8 @@ function MenuRoot(rawProps) {
|
|
|
21
21
|
function Trigger(rawProps) {
|
|
22
22
|
const { as, onKeyDown, children, ...restProps } = useHuiProps("MenuTrigger", rawProps);
|
|
23
23
|
const Component = as ?? Button;
|
|
24
|
+
const cls = useHuiClassNames("MenuTrigger", { root: "" }, { root: rawProps["className"] });
|
|
25
|
+
const sls = useHuiStyles("MenuTrigger", { root: rawProps["style"] });
|
|
24
26
|
const menuId = useMenuId();
|
|
25
27
|
const attrs = normalizeAttributes(menuControl.getTriggerAttributes({ menuId }, { isButtonElement: as === void 0 }));
|
|
26
28
|
const handleKeyDown = useCallback((e) => {
|
|
@@ -30,13 +32,15 @@ function Trigger(rawProps) {
|
|
|
30
32
|
}, [onKeyDown, menuId]);
|
|
31
33
|
return /* @__PURE__ */ jsx(Component, {
|
|
32
34
|
...attrs,
|
|
35
|
+
className: cls.root,
|
|
36
|
+
style: sls.root,
|
|
33
37
|
onKeyDown: handleKeyDown,
|
|
34
38
|
...restProps,
|
|
35
39
|
children
|
|
36
40
|
});
|
|
37
41
|
}
|
|
38
42
|
function Content(rawProps) {
|
|
39
|
-
const { as, position, fallbacks, visibility, padding,
|
|
43
|
+
const { as, position, fallbacks, visibility, padding, children, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...restProps } = useHuiProps("MenuContent", rawProps);
|
|
40
44
|
const Component = as ?? "div";
|
|
41
45
|
const menuId = useMenuId();
|
|
42
46
|
const recipe = popoverRecipe({
|
|
@@ -45,8 +49,8 @@ function Content(rawProps) {
|
|
|
45
49
|
visibility,
|
|
46
50
|
padding: padding ?? "sm"
|
|
47
51
|
});
|
|
48
|
-
const cls = useHuiClassNames("MenuContent", recipe, { root: className });
|
|
49
|
-
const sls = useHuiStyles("MenuContent", { root: style });
|
|
52
|
+
const cls = useHuiClassNames("MenuContent", recipe, { root: rawProps["className"] });
|
|
53
|
+
const sls = useHuiStyles("MenuContent", { root: rawProps["style"] });
|
|
50
54
|
const attrs = normalizeAttributes(menuControl.getContentAttributes({ menuId }, {
|
|
51
55
|
ariaLabel,
|
|
52
56
|
ariaLabelledBy
|
|
@@ -60,13 +64,13 @@ function Content(rawProps) {
|
|
|
60
64
|
});
|
|
61
65
|
}
|
|
62
66
|
function Item(rawProps) {
|
|
63
|
-
const { as,
|
|
67
|
+
const { as, color, focusKey, activation = "managed", onClick, onAction, onKeyDown, children, "aria-disabled": ariaDisabled, ...restProps } = useHuiProps("MenuItem", rawProps);
|
|
64
68
|
const Component = as ?? "div";
|
|
65
69
|
const menuId = useMenuId();
|
|
66
70
|
const isDisabled = toBool(ariaDisabled);
|
|
67
71
|
const recipe = menuitemRecipe({ color });
|
|
68
|
-
const cls = useHuiClassNames("MenuItem", recipe, { root: className });
|
|
69
|
-
const sls = useHuiStyles("MenuItem", { root: style });
|
|
72
|
+
const cls = useHuiClassNames("MenuItem", recipe, { root: rawProps["className"] });
|
|
73
|
+
const sls = useHuiStyles("MenuItem", { root: rawProps["style"] });
|
|
70
74
|
const attrs = normalizeAttributes(menuControl.getItemAttributes({ menuId }, {
|
|
71
75
|
focusKey,
|
|
72
76
|
disabled: ariaDisabled == null ? void 0 : isDisabled
|
|
@@ -127,7 +131,6 @@ const Menu = Object.assign(MenuRoot, {
|
|
|
127
131
|
Content,
|
|
128
132
|
Item
|
|
129
133
|
});
|
|
130
|
-
//#endregion
|
|
131
134
|
export { Menu };
|
|
132
135
|
|
|
133
136
|
//# sourceMappingURL=menu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu.js","names":[],"sources":["../../../src/components/menu/menu.tsx"],"sourcesContent":["import {\n type ButtonSlots,\n menuControl,\n type MenuItemActivation,\n menuitemRecipe,\n type MenuitemSlots,\n type MenuitemVariants,\n popoverRecipe,\n type PopoverSlots,\n type PopoverVariants,\n toBool,\n} from \"@hebium-ui/core\";\nimport {\n type ElementType,\n type KeyboardEvent,\n type MouseEvent,\n type ReactElement,\n type ReactNode,\n useCallback,\n useId,\n useMemo,\n} from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\nimport { normalizeAttributes } from \"~/utils\";\nimport { Button } from \"../button\";\nimport { MenuContext, type MenuContextValue, useMenuId } from \"./menu.context\";\n\nexport interface MenuProps {\n /**\n * The id of the menu content element.\n */\n id?: string | undefined;\n children?: ReactNode | undefined;\n}\n\nfunction MenuRoot(rawProps: MenuProps): ReactElement {\n const {\n id,\n children,\n } = useHuiProps(\"Menu\", rawProps);\n\n const tmpId = useId();\n const menuId = id || tmpId;\n\n const contextValue = useMemo<MenuContextValue>(() => {\n return {\n menuId,\n };\n }, [menuId]);\n\n return (\n <MenuContext.Provider\n value={contextValue}\n >\n {children}\n </MenuContext.Provider>\n );\n}\n\nexport type MenuTriggerProps<E extends ElementType = typeof Button> = HuiPolymorphicProps<\n E,\n {},\n ButtonSlots\n>;\n\nfunction Trigger<E extends ElementType = typeof Button>(rawProps: MenuTriggerProps<E>): ReactNode {\n const {\n as,\n onKeyDown,\n children,\n ...restProps\n } = useHuiProps(\"MenuTrigger\", rawProps);\n\n const Component = as ?? Button;\n const menuId = useMenuId();\n const attrs = normalizeAttributes(\n menuControl.getTriggerAttributes(\n { menuId },\n { isButtonElement: as === undefined },\n ),\n );\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent<HTMLElement>): void => {\n onKeyDown?.(e);\n if (e.defaultPrevented) return;\n\n menuControl.handleMenuTriggerKeydown(e.nativeEvent, menuId);\n },\n [onKeyDown, menuId],\n );\n\n return (\n <Component\n {...attrs}\n onKeyDown={handleKeyDown}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n\ninterface MenuContentOwnProps {\n /**\n * The preferred anchor position of the menu.\n *\n * @default \"block-start\"\n */\n position?: PopoverVariants[\"position\"] | undefined;\n /**\n * The fallback strategy used when the preferred position overflows.\n *\n * @default \"flip\"\n */\n fallbacks?: PopoverVariants[\"fallbacks\"] | undefined;\n /**\n * The visibility behavior when the anchor is off-screen or overflows.\n *\n * @default \"anchors-visible\"\n * @see This setting depends on browser support for {@link https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/position-visibility | MDN: position-visibility}.\n */\n visibility?: PopoverVariants[\"visibility\"] | undefined;\n /**\n * The padding size of the menu content.\n *\n * @default \"sm\"\n */\n padding?: PopoverVariants[\"padding\"] | undefined;\n}\nexport type MenuContentProps<E extends ElementType = \"div\"> = HuiPolymorphicProps<\n E,\n MenuContentOwnProps,\n PopoverSlots\n>;\n\nfunction Content<E extends ElementType = \"div\">(rawProps: MenuContentProps<E>): ReactElement {\n const {\n as,\n position,\n fallbacks,\n visibility,\n padding,\n className,\n style,\n children,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n ...restProps\n } = useHuiProps(\"MenuContent\", rawProps);\n\n const Component = as ?? \"div\";\n\n const menuId = useMenuId();\n const recipe = popoverRecipe({\n position,\n fallbacks,\n visibility,\n padding: padding ?? \"sm\",\n });\n const cls = useHuiClassNames(\"MenuContent\", recipe, { root: className });\n const sls = useHuiStyles(\"MenuContent\", { root: style });\n const attrs = normalizeAttributes(\n menuControl.getContentAttributes(\n { menuId },\n { ariaLabel, ariaLabelledBy },\n ),\n );\n\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...attrs}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n\ninterface MenuItemOwnProps {\n /**\n * The semantic color of the menu item.\n *\n * @default \"neutral\"\n */\n color?: MenuitemVariants[\"color\"] | undefined;\n /**\n * A printable character used for key navigation within the menu.\n * When the user types a matching key, focus moves to this item.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/menuitem_role#any_key_that_corresponds_to_a_printable_character_optional | MDN: Keyboard interactions for the menuitem role}\n */\n focusKey?: string | undefined;\n /**\n * Controls the menu item's native action.\n * Managed activation prevents it; native activation allows it.\n *\n * @default \"managed\"\n */\n activation?: MenuItemActivation | undefined;\n /**\n * Called when the menu item is activated by click or keyboard.\n */\n onAction?: (() => void) | undefined;\n}\nexport type MenuItemProps<E extends ElementType = \"div\"> = HuiPolymorphicProps<\n E,\n MenuItemOwnProps,\n Exclude<MenuitemSlots, \"disabled\">\n>;\n\nfunction Item<E extends ElementType = \"div\">(rawProps: MenuItemProps<E>): ReactElement {\n const {\n as,\n className,\n style,\n color,\n focusKey,\n activation = \"managed\",\n onClick,\n onAction,\n onKeyDown,\n children,\n \"aria-disabled\": ariaDisabled,\n ...restProps\n } = useHuiProps(\"MenuItem\", rawProps);\n\n const Component = as ?? \"div\";\n\n const menuId = useMenuId();\n const isDisabled = toBool(ariaDisabled);\n const recipe = menuitemRecipe({\n color,\n });\n const cls = useHuiClassNames(\"MenuItem\", recipe, { root: className });\n const sls = useHuiStyles(\"MenuItem\", { root: style });\n const attrs = normalizeAttributes(\n menuControl.getItemAttributes(\n { menuId },\n {\n focusKey,\n disabled: ariaDisabled == null ? undefined : isDisabled,\n },\n ),\n );\n\n const handleClick = useCallback((e: MouseEvent<HTMLElement>) => {\n onClick?.(e);\n menuControl.handleMenuitemActivation(e.nativeEvent, menuId, { activation, disabled: isDisabled }, onAction);\n }, [activation, isDisabled, menuId, onClick, onAction]);\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent<HTMLElement>): void => {\n onKeyDown?.(e);\n if (e.defaultPrevented) return;\n\n const action = menuControl.handleMenuitemKeydown(e.nativeEvent, activation);\n switch (action) {\n case \"action\":\n menuControl.handleMenuitemActivation(e.nativeEvent, menuId, { activation, disabled: isDisabled }, onAction);\n return;\n case \"focus-move\":\n menuControl.moveMenuitemFocus(e.nativeEvent, menuId);\n return;\n case \"focus-set\":\n menuControl.setMenuitemFocus(e.nativeEvent, menuId);\n return;\n case \"focus-out\":\n menuControl.hideMenu(menuId);\n return;\n case \"none\":\n return;\n }\n },\n [\n onKeyDown,\n activation,\n onAction,\n menuId,\n isDisabled,\n ],\n );\n\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...attrs}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n\nexport const Menu = Object.assign(MenuRoot, {\n Trigger,\n Content,\n Item,\n});\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"menu.js","names":[],"sources":["../../../src/components/menu/menu.tsx"],"sourcesContent":["import {\n type ButtonSlots,\n menuControl,\n type MenuItemActivation,\n menuitemRecipe,\n type MenuitemSlots,\n type MenuitemVariants,\n popoverRecipe,\n type PopoverSlots,\n type PopoverVariants,\n toBool,\n} from \"@hebium-ui/core\";\nimport {\n type ElementType,\n type KeyboardEvent,\n type MouseEvent,\n type ReactElement,\n type ReactNode,\n useCallback,\n useId,\n useMemo,\n} from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\nimport { normalizeAttributes } from \"~/utils\";\nimport { Button } from \"../button\";\nimport { MenuContext, type MenuContextValue, useMenuId } from \"./menu.context\";\n\nexport interface MenuProps {\n /**\n * The id of the menu content element.\n */\n id?: string | undefined;\n children?: ReactNode | undefined;\n}\n\nfunction MenuRoot(rawProps: MenuProps): ReactElement {\n const {\n id,\n children,\n } = useHuiProps(\"Menu\", rawProps);\n\n const tmpId = useId();\n const menuId = id || tmpId;\n\n const contextValue = useMemo<MenuContextValue>(() => {\n return {\n menuId,\n };\n }, [menuId]);\n\n return (\n <MenuContext.Provider\n value={contextValue}\n >\n {children}\n </MenuContext.Provider>\n );\n}\n\nexport type MenuTriggerProps<E extends ElementType = typeof Button> = HuiPolymorphicProps<\n E,\n {},\n ButtonSlots\n>;\n\nfunction Trigger<E extends ElementType = typeof Button>(rawProps: MenuTriggerProps<E>): ReactNode {\n const {\n as,\n onKeyDown,\n children,\n ...restProps\n } = useHuiProps(\"MenuTrigger\", rawProps);\n\n const Component = as ?? Button;\n const cls = useHuiClassNames(\"MenuTrigger\", { root: \"\" }, { root: rawProps[\"className\"] });\n const sls = useHuiStyles(\"MenuTrigger\", { root: rawProps[\"style\"] });\n const menuId = useMenuId();\n const attrs = normalizeAttributes(\n menuControl.getTriggerAttributes(\n { menuId },\n { isButtonElement: as === undefined },\n ),\n );\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent<HTMLElement>): void => {\n onKeyDown?.(e);\n if (e.defaultPrevented) return;\n\n menuControl.handleMenuTriggerKeydown(e.nativeEvent, menuId);\n },\n [onKeyDown, menuId],\n );\n\n return (\n <Component\n {...attrs}\n className={cls.root}\n style={sls.root}\n onKeyDown={handleKeyDown}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n\ninterface MenuContentOwnProps {\n /**\n * The preferred anchor position of the menu.\n *\n * @default \"block-start\"\n */\n position?: PopoverVariants[\"position\"] | undefined;\n /**\n * The fallback strategy used when the preferred position overflows.\n *\n * @default \"flip\"\n */\n fallbacks?: PopoverVariants[\"fallbacks\"] | undefined;\n /**\n * The visibility behavior when the anchor is off-screen or overflows.\n *\n * @default \"anchors-visible\"\n * @see This setting depends on browser support for {@link https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/position-visibility | MDN: position-visibility}.\n */\n visibility?: PopoverVariants[\"visibility\"] | undefined;\n /**\n * The padding size of the menu content.\n *\n * @default \"sm\"\n */\n padding?: PopoverVariants[\"padding\"] | undefined;\n}\nexport type MenuContentProps<E extends ElementType = \"div\"> = HuiPolymorphicProps<\n E,\n MenuContentOwnProps,\n PopoverSlots\n>;\n\nfunction Content<E extends ElementType = \"div\">(rawProps: MenuContentProps<E>): ReactElement {\n const {\n as,\n position,\n fallbacks,\n visibility,\n padding,\n children,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n ...restProps\n } = useHuiProps(\"MenuContent\", rawProps);\n\n const Component = as ?? \"div\";\n\n const menuId = useMenuId();\n const recipe = popoverRecipe({\n position,\n fallbacks,\n visibility,\n padding: padding ?? \"sm\",\n });\n const cls = useHuiClassNames(\"MenuContent\", recipe, { root: rawProps[\"className\"] });\n const sls = useHuiStyles(\"MenuContent\", { root: rawProps[\"style\"] });\n const attrs = normalizeAttributes(\n menuControl.getContentAttributes(\n { menuId },\n { ariaLabel, ariaLabelledBy },\n ),\n );\n\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...attrs}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n\ninterface MenuItemOwnProps {\n /**\n * The semantic color of the menu item.\n *\n * @default \"neutral\"\n */\n color?: MenuitemVariants[\"color\"] | undefined;\n /**\n * A printable character used for key navigation within the menu.\n * When the user types a matching key, focus moves to this item.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/menuitem_role#any_key_that_corresponds_to_a_printable_character_optional | MDN: Keyboard interactions for the menuitem role}\n */\n focusKey?: string | undefined;\n /**\n * Controls the menu item's native action.\n * Managed activation prevents it; native activation allows it.\n *\n * @default \"managed\"\n */\n activation?: MenuItemActivation | undefined;\n /**\n * Called when the menu item is activated by click or keyboard.\n */\n onAction?: (() => void) | undefined;\n}\nexport type MenuItemProps<E extends ElementType = \"div\"> = HuiPolymorphicProps<\n E,\n MenuItemOwnProps,\n Exclude<MenuitemSlots, \"disabled\">\n>;\n\nfunction Item<E extends ElementType = \"div\">(rawProps: MenuItemProps<E>): ReactElement {\n const {\n as,\n color,\n focusKey,\n activation = \"managed\",\n onClick,\n onAction,\n onKeyDown,\n children,\n \"aria-disabled\": ariaDisabled,\n ...restProps\n } = useHuiProps(\"MenuItem\", rawProps);\n\n const Component = as ?? \"div\";\n\n const menuId = useMenuId();\n const isDisabled = toBool(ariaDisabled);\n const recipe = menuitemRecipe({\n color,\n });\n const cls = useHuiClassNames(\"MenuItem\", recipe, { root: rawProps[\"className\"] });\n const sls = useHuiStyles(\"MenuItem\", { root: rawProps[\"style\"] });\n const attrs = normalizeAttributes(\n menuControl.getItemAttributes(\n { menuId },\n {\n focusKey,\n disabled: ariaDisabled == null ? undefined : isDisabled,\n },\n ),\n );\n\n const handleClick = useCallback((e: MouseEvent<HTMLElement>) => {\n onClick?.(e);\n menuControl.handleMenuitemActivation(e.nativeEvent, menuId, { activation, disabled: isDisabled }, onAction);\n }, [activation, isDisabled, menuId, onClick, onAction]);\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent<HTMLElement>): void => {\n onKeyDown?.(e);\n if (e.defaultPrevented) return;\n\n const action = menuControl.handleMenuitemKeydown(e.nativeEvent, activation);\n switch (action) {\n case \"action\":\n menuControl.handleMenuitemActivation(e.nativeEvent, menuId, { activation, disabled: isDisabled }, onAction);\n return;\n case \"focus-move\":\n menuControl.moveMenuitemFocus(e.nativeEvent, menuId);\n return;\n case \"focus-set\":\n menuControl.setMenuitemFocus(e.nativeEvent, menuId);\n return;\n case \"focus-out\":\n menuControl.hideMenu(menuId);\n return;\n case \"none\":\n return;\n }\n },\n [\n onKeyDown,\n activation,\n onAction,\n menuId,\n isDisabled,\n ],\n );\n\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...attrs}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n\nexport const Menu = Object.assign(MenuRoot, {\n Trigger,\n Content,\n Item,\n});\n"],"mappings":"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"}
|
|
@@ -2,7 +2,6 @@ import { HuiPolymorphicProps } from "../../types/polymorphic.js";
|
|
|
2
2
|
import "../../types/index.js";
|
|
3
3
|
import { ParagraphSlots, ParagraphVariants } from "@hebium-ui/core";
|
|
4
4
|
import { ElementType, ReactElement } from "react";
|
|
5
|
-
//#region src/components/paragraph/paragraph.d.ts
|
|
6
5
|
interface ParagraphOwnProps {
|
|
7
6
|
/**
|
|
8
7
|
* The semantic color of the paragraph.
|
|
@@ -10,9 +9,14 @@ interface ParagraphOwnProps {
|
|
|
10
9
|
* @default "text"
|
|
11
10
|
*/
|
|
12
11
|
color?: ParagraphVariants["color"] | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* The block margin applied to the paragraph.
|
|
14
|
+
*
|
|
15
|
+
* @default "block"
|
|
16
|
+
*/
|
|
17
|
+
margin?: ParagraphVariants["margin"] | undefined;
|
|
13
18
|
}
|
|
14
19
|
export type ParagraphProps<E extends ElementType = "p"> = HuiPolymorphicProps<E, ParagraphOwnProps, ParagraphSlots>;
|
|
15
20
|
export declare function Paragraph<E extends ElementType = "p">(rawProps: ParagraphProps<E>): ReactElement;
|
|
16
|
-
//#endregion
|
|
17
21
|
export {};
|
|
18
22
|
//# sourceMappingURL=paragraph.d.ts.map
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
|
|
2
2
|
import { paragraphRecipe } from "@hebium-ui/core";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
|
|
4
|
+
// src/components/paragraph/paragraph.tsx
|
|
5
5
|
function Paragraph(rawProps) {
|
|
6
|
-
const { as, color,
|
|
6
|
+
const { as, color, margin, children, ...restProps } = useHuiProps("Paragraph", rawProps);
|
|
7
7
|
const Component = as ?? "p";
|
|
8
|
-
const recipe = paragraphRecipe({
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const recipe = paragraphRecipe({
|
|
9
|
+
color,
|
|
10
|
+
margin
|
|
11
|
+
});
|
|
12
|
+
const cls = useHuiClassNames("Paragraph", recipe, { root: rawProps["className"] });
|
|
13
|
+
const sls = useHuiStyles("Paragraph", { root: rawProps["style"] });
|
|
11
14
|
return /* @__PURE__ */ jsx(Component, {
|
|
12
15
|
className: cls.root,
|
|
13
16
|
style: sls.root,
|
|
@@ -15,7 +18,6 @@ function Paragraph(rawProps) {
|
|
|
15
18
|
children
|
|
16
19
|
});
|
|
17
20
|
}
|
|
18
|
-
//#endregion
|
|
19
21
|
export { Paragraph };
|
|
20
22
|
|
|
21
23
|
//# sourceMappingURL=paragraph.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paragraph.js","names":[],"sources":["../../../src/components/paragraph/paragraph.tsx"],"sourcesContent":["import { paragraphRecipe, type ParagraphSlots, type ParagraphVariants } from \"@hebium-ui/core\";\nimport { type ElementType, type ReactElement } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\n\ninterface ParagraphOwnProps {\n /**\n * The semantic color of the paragraph.\n *\n * @default \"text\"\n */\n color?: ParagraphVariants[\"color\"] | undefined;\n}\n\nexport type ParagraphProps<E extends ElementType = \"p\"> = HuiPolymorphicProps<\n E,\n ParagraphOwnProps,\n ParagraphSlots\n>;\n\nexport function Paragraph<E extends ElementType = \"p\">(rawProps: ParagraphProps<E>): ReactElement {\n const {\n as,\n color,\n
|
|
1
|
+
{"version":3,"file":"paragraph.js","names":[],"sources":["../../../src/components/paragraph/paragraph.tsx"],"sourcesContent":["import { paragraphRecipe, type ParagraphSlots, type ParagraphVariants } from \"@hebium-ui/core\";\nimport { type ElementType, type ReactElement } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\n\ninterface ParagraphOwnProps {\n /**\n * The semantic color of the paragraph.\n *\n * @default \"text\"\n */\n color?: ParagraphVariants[\"color\"] | undefined;\n /**\n * The block margin applied to the paragraph.\n *\n * @default \"block\"\n */\n margin?: ParagraphVariants[\"margin\"] | undefined;\n}\n\nexport type ParagraphProps<E extends ElementType = \"p\"> = HuiPolymorphicProps<\n E,\n ParagraphOwnProps,\n ParagraphSlots\n>;\n\nexport function Paragraph<E extends ElementType = \"p\">(rawProps: ParagraphProps<E>): ReactElement {\n const {\n as,\n color,\n margin,\n children,\n ...restProps\n } = useHuiProps(\"Paragraph\", rawProps);\n\n const Component = as ?? \"p\";\n const recipe = paragraphRecipe({\n color,\n margin,\n });\n const cls = useHuiClassNames(\"Paragraph\", recipe, { root: rawProps[\"className\"] });\n const sls = useHuiStyles(\"Paragraph\", { root: rawProps[\"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":";;;;AA0BA,SAAgB,UAAuC,UAA2C;CAChG,MAAM,EACJ,IACA,OACA,QACA,UACA,GAAG,cACD,YAAY,aAAa,QAAQ;CAErC,MAAM,YAAY,MAAM;CACxB,MAAM,SAAS,gBAAgB;EAC7B;EACA;CACF,CAAC;CACD,MAAM,MAAM,iBAAiB,aAAa,QAAQ,EAAE,MAAM,SAAS,aAAa,CAAC;CACjF,MAAM,MAAM,aAAa,aAAa,EAAE,MAAM,SAAS,SAAS,CAAC;CAEjE,OACE,oBAAC,WAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EAEH;CACQ,CAAA;AAEf"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createContext, useContext } from "react";
|
|
2
|
-
|
|
2
|
+
// src/components/popover/popover.context.ts
|
|
3
3
|
const PopoverContext = createContext(null);
|
|
4
4
|
function usePopoverContext() {
|
|
5
5
|
const context = useContext(PopoverContext);
|
|
@@ -9,7 +9,6 @@ function usePopoverContext() {
|
|
|
9
9
|
function usePopoverId() {
|
|
10
10
|
return usePopoverContext().popoverId;
|
|
11
11
|
}
|
|
12
|
-
//#endregion
|
|
13
12
|
export { PopoverContext, usePopoverContext, usePopoverId };
|
|
14
13
|
|
|
15
14
|
//# sourceMappingURL=popover.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/popover/popover.d.ts
|
|
8
7
|
export interface PopoverProps {
|
|
9
8
|
/**
|
|
10
9
|
* The id of the popover content element.
|
|
@@ -48,6 +47,5 @@ export declare const Popover: typeof PopoverRoot & {
|
|
|
48
47
|
Trigger: typeof Trigger;
|
|
49
48
|
Content: typeof Content;
|
|
50
49
|
};
|
|
51
|
-
//#endregion
|
|
52
50
|
export {};
|
|
53
51
|
//# sourceMappingURL=popover.d.ts.map
|
|
@@ -5,7 +5,7 @@ import { PopoverContext, usePopoverId } from "./popover.context.js";
|
|
|
5
5
|
import { popoverControl, popoverRecipe } from "@hebium-ui/core";
|
|
6
6
|
import { useId, useMemo } from "react";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
|
-
|
|
8
|
+
// src/components/popover/popover.tsx
|
|
9
9
|
function PopoverRoot(rawProps) {
|
|
10
10
|
const { id, children } = useHuiProps("Popover", rawProps);
|
|
11
11
|
const tmpId = useId();
|
|
@@ -21,16 +21,20 @@ function PopoverRoot(rawProps) {
|
|
|
21
21
|
function Trigger(rawProps) {
|
|
22
22
|
const { as, children, ...restProps } = useHuiProps("PopoverTrigger", rawProps);
|
|
23
23
|
const Component = as ?? Button;
|
|
24
|
+
const cls = useHuiClassNames("PopoverTrigger", { root: "" }, { root: rawProps["className"] });
|
|
25
|
+
const sls = useHuiStyles("PopoverTrigger", { root: rawProps["style"] });
|
|
24
26
|
const popoverId = usePopoverId();
|
|
25
27
|
const attrs = normalizeAttributes(popoverControl.getTriggerAttributes({ popoverId }, { isButtonElement: as === void 0 }));
|
|
26
28
|
return /* @__PURE__ */ jsx(Component, {
|
|
27
29
|
...attrs,
|
|
30
|
+
className: cls.root,
|
|
31
|
+
style: sls.root,
|
|
28
32
|
...restProps,
|
|
29
33
|
children
|
|
30
34
|
});
|
|
31
35
|
}
|
|
32
36
|
function Content(rawProps) {
|
|
33
|
-
const { as, position, fallbacks, visibility, padding,
|
|
37
|
+
const { as, position, fallbacks, visibility, padding, children, ...restProps } = useHuiProps("PopoverContent", rawProps);
|
|
34
38
|
const Component = as ?? "div";
|
|
35
39
|
const popoverId = usePopoverId();
|
|
36
40
|
const recipe = popoverRecipe({
|
|
@@ -39,8 +43,8 @@ function Content(rawProps) {
|
|
|
39
43
|
visibility,
|
|
40
44
|
padding
|
|
41
45
|
});
|
|
42
|
-
const cls = useHuiClassNames("PopoverContent", recipe, { root: className });
|
|
43
|
-
const sls = useHuiStyles("PopoverContent", { root: style });
|
|
46
|
+
const cls = useHuiClassNames("PopoverContent", recipe, { root: rawProps["className"] });
|
|
47
|
+
const sls = useHuiStyles("PopoverContent", { root: rawProps["style"] });
|
|
44
48
|
const attrs = normalizeAttributes(popoverControl.getContentAttributes({ popoverId }));
|
|
45
49
|
return /* @__PURE__ */ jsx(Component, {
|
|
46
50
|
...attrs,
|
|
@@ -54,7 +58,6 @@ const Popover = Object.assign(PopoverRoot, {
|
|
|
54
58
|
Trigger,
|
|
55
59
|
Content
|
|
56
60
|
});
|
|
57
|
-
//#endregion
|
|
58
61
|
export { Popover };
|
|
59
62
|
|
|
60
63
|
//# sourceMappingURL=popover.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.js","names":[],"sources":["../../../src/components/popover/popover.tsx"],"sourcesContent":["import {\n type ButtonSlots,\n popoverControl,\n popoverRecipe,\n type PopoverSlots,\n type PopoverVariants,\n} from \"@hebium-ui/core\";\nimport { type ElementType, type ReactElement, type ReactNode, useId, useMemo } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\nimport { normalizeAttributes } from \"~/utils\";\nimport { Button } from \"../button\";\nimport { PopoverContext, type PopoverContextValue, usePopoverId } from \"./popover.context\";\n\nexport interface PopoverProps {\n /**\n * The id of the popover content element.\n */\n id?: string | undefined;\n children?: ReactNode | undefined;\n}\n\nfunction PopoverRoot(rawProps: PopoverProps): ReactElement {\n const {\n id,\n children,\n } = useHuiProps(\"Popover\", rawProps);\n\n const tmpId = useId();\n const popoverId = id || tmpId;\n\n const contextValue = useMemo<PopoverContextValue>(() => {\n return {\n popoverId,\n };\n }, [popoverId]);\n\n return (\n <PopoverContext.Provider\n value={contextValue}\n >\n {children}\n </PopoverContext.Provider>\n );\n}\n\nexport type PopoverTriggerProps<E extends ElementType = typeof Button> = HuiPolymorphicProps<\n E,\n {},\n ButtonSlots\n>;\n\nfunction Trigger<E extends ElementType = typeof Button>(rawProps: PopoverTriggerProps<E>): ReactNode {\n const {\n as,\n children,\n ...restProps\n } = useHuiProps(\"PopoverTrigger\", rawProps);\n\n const Component = as ?? Button;\n const popoverId = usePopoverId();\n const attrs = normalizeAttributes(\n popoverControl.getTriggerAttributes(\n { popoverId },\n { isButtonElement: as === undefined },\n ),\n );\n\n return (\n <Component\n {...attrs}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n\ninterface PopoverContentOwnProps {\n /**\n * The preferred anchor position of the popover.\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 popover content.\n *\n * @default \"md\"\n */\n padding?: PopoverVariants[\"padding\"] | undefined;\n}\nexport type PopoverContentProps<E extends ElementType = \"div\"> = HuiPolymorphicProps<\n E,\n PopoverContentOwnProps,\n PopoverSlots\n>;\n\nfunction Content<E extends ElementType = \"div\">(rawProps: PopoverContentProps<E>): ReactElement {\n const {\n as,\n position,\n fallbacks,\n visibility,\n padding,\n
|
|
1
|
+
{"version":3,"file":"popover.js","names":[],"sources":["../../../src/components/popover/popover.tsx"],"sourcesContent":["import {\n type ButtonSlots,\n popoverControl,\n popoverRecipe,\n type PopoverSlots,\n type PopoverVariants,\n} from \"@hebium-ui/core\";\nimport { type ElementType, type ReactElement, type ReactNode, useId, useMemo } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\nimport { normalizeAttributes } from \"~/utils\";\nimport { Button } from \"../button\";\nimport { PopoverContext, type PopoverContextValue, usePopoverId } from \"./popover.context\";\n\nexport interface PopoverProps {\n /**\n * The id of the popover content element.\n */\n id?: string | undefined;\n children?: ReactNode | undefined;\n}\n\nfunction PopoverRoot(rawProps: PopoverProps): ReactElement {\n const {\n id,\n children,\n } = useHuiProps(\"Popover\", rawProps);\n\n const tmpId = useId();\n const popoverId = id || tmpId;\n\n const contextValue = useMemo<PopoverContextValue>(() => {\n return {\n popoverId,\n };\n }, [popoverId]);\n\n return (\n <PopoverContext.Provider\n value={contextValue}\n >\n {children}\n </PopoverContext.Provider>\n );\n}\n\nexport type PopoverTriggerProps<E extends ElementType = typeof Button> = HuiPolymorphicProps<\n E,\n {},\n ButtonSlots\n>;\n\nfunction Trigger<E extends ElementType = typeof Button>(rawProps: PopoverTriggerProps<E>): ReactNode {\n const {\n as,\n children,\n ...restProps\n } = useHuiProps(\"PopoverTrigger\", rawProps);\n\n const Component = as ?? Button;\n const cls = useHuiClassNames(\"PopoverTrigger\", { root: \"\" }, { root: rawProps[\"className\"] });\n const sls = useHuiStyles(\"PopoverTrigger\", { root: rawProps[\"style\"] });\n const popoverId = usePopoverId();\n const attrs = normalizeAttributes(\n popoverControl.getTriggerAttributes(\n { popoverId },\n { isButtonElement: as === undefined },\n ),\n );\n\n return (\n <Component\n {...attrs}\n className={cls.root}\n style={sls.root}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n\ninterface PopoverContentOwnProps {\n /**\n * The preferred anchor position of the popover.\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 popover content.\n *\n * @default \"md\"\n */\n padding?: PopoverVariants[\"padding\"] | undefined;\n}\nexport type PopoverContentProps<E extends ElementType = \"div\"> = HuiPolymorphicProps<\n E,\n PopoverContentOwnProps,\n PopoverSlots\n>;\n\nfunction Content<E extends ElementType = \"div\">(rawProps: PopoverContentProps<E>): ReactElement {\n const {\n as,\n position,\n fallbacks,\n visibility,\n padding,\n children,\n ...restProps\n } = useHuiProps(\"PopoverContent\", rawProps);\n const Component = as ?? \"div\";\n\n const popoverId = usePopoverId();\n const recipe = popoverRecipe({ position, fallbacks, visibility, padding });\n const cls = useHuiClassNames(\"PopoverContent\", recipe, { root: rawProps[\"className\"] });\n const sls = useHuiStyles(\"PopoverContent\", { root: rawProps[\"style\"] });\n const attrs = normalizeAttributes(popoverControl.getContentAttributes({ popoverId }));\n\n return (\n <Component\n {...attrs}\n className={cls.root}\n style={sls.root}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n\nexport const Popover = Object.assign(PopoverRoot, {\n Trigger,\n Content,\n});\n"],"mappings":";;;;;;;;AAsBA,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,UACA,GAAG,cACD,YAAY,kBAAkB,QAAQ;CAE1C,MAAM,YAAY,MAAM;CACxB,MAAM,MAAM,iBAAiB,kBAAkB,EAAE,MAAM,GAAG,GAAG,EAAE,MAAM,SAAS,aAAa,CAAC;CAC5F,MAAM,MAAM,aAAa,kBAAkB,EAAE,MAAM,SAAS,SAAS,CAAC;CACtE,MAAM,YAAY,aAAa;CAC/B,MAAM,QAAQ,oBACZ,eAAe,qBACb,EAAE,UAAU,GACZ,EAAE,iBAAiB,OAAO,KAAA,EAAU,CACtC,CACF;CAEA,OACE,oBAAC,WAAD;EACE,GAAI;EACJ,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EAEH;CACQ,CAAA;AAEf;AAmCA,SAAS,QAAuC,UAAgD;CAC9F,MAAM,EACJ,IACA,UACA,WACA,YACA,SACA,UACA,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,SAAS,aAAa,CAAC;CACtF,MAAM,MAAM,aAAa,kBAAkB,EAAE,MAAM,SAAS,SAAS,CAAC;CACtE,MAAM,QAAQ,oBAAoB,eAAe,qBAAqB,EAAE,UAAU,CAAC,CAAC;CAEpF,OACE,oBAAC,WAAD;EACE,GAAI;EACJ,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EAEH;CACQ,CAAA;AAEf;AAEA,MAAa,UAAU,OAAO,OAAO,aAAa;CAChD;CACA;AACF,CAAC"}
|
|
@@ -2,7 +2,6 @@ import { HuiComponentProps } from "../../types/hui-component.js";
|
|
|
2
2
|
import "../../types/index.js";
|
|
3
3
|
import { ProgressSlots, ProgressVariants } from "@hebium-ui/core";
|
|
4
4
|
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
5
|
-
//#region src/components/progress/progress.d.ts
|
|
6
5
|
type HtmlDivProps = ComponentProps<"div">;
|
|
7
6
|
interface ProgressOwnProps extends HtmlDivProps {
|
|
8
7
|
/**
|
|
@@ -50,6 +49,5 @@ interface ProgressOwnProps extends HtmlDivProps {
|
|
|
50
49
|
}
|
|
51
50
|
export type ProgressProps = HuiComponentProps<ProgressOwnProps, ProgressSlots>;
|
|
52
51
|
export declare function Progress(rawProps: ProgressProps): ReactElement;
|
|
53
|
-
//#endregion
|
|
54
52
|
export {};
|
|
55
53
|
//# sourceMappingURL=progress.d.ts.map
|
|
@@ -2,9 +2,9 @@ import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-
|
|
|
2
2
|
import { CSS_VARS, cc, progressControl, progressRecipe, toStrbool } from "@hebium-ui/core";
|
|
3
3
|
import { useId } from "react";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
-
|
|
5
|
+
// src/components/progress/progress.tsx
|
|
6
6
|
function Progress(rawProps) {
|
|
7
|
-
const { min, max, value, valueText, label, color, radius, size,
|
|
7
|
+
const { min, max, value, valueText, label, color, radius, size, nonce, ...restProps } = useHuiProps("Progress", rawProps);
|
|
8
8
|
const progressId = useId();
|
|
9
9
|
const progress = progressControl.resolve({
|
|
10
10
|
progressId,
|
|
@@ -20,8 +20,8 @@ function Progress(rawProps) {
|
|
|
20
20
|
radius,
|
|
21
21
|
size
|
|
22
22
|
});
|
|
23
|
-
const cls = useHuiClassNames("Progress", recipe, classNames);
|
|
24
|
-
const sls = useHuiStyles("Progress", styles);
|
|
23
|
+
const cls = useHuiClassNames("Progress", recipe, rawProps.classNames);
|
|
24
|
+
const sls = useHuiStyles("Progress", rawProps.styles);
|
|
25
25
|
const labelAttrs = progressControl.getLabelAttributes(progress);
|
|
26
26
|
const barAttrs = progressControl.getBarAttributes(progress);
|
|
27
27
|
const valueAttrs = progressControl.getValueAttributes();
|
|
@@ -51,7 +51,6 @@ function Progress(rawProps) {
|
|
|
51
51
|
})]
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
-
//#endregion
|
|
55
54
|
export { Progress };
|
|
56
55
|
|
|
57
56
|
//# sourceMappingURL=progress.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress.js","names":[],"sources":["../../../src/components/progress/progress.tsx"],"sourcesContent":["import {\n cc,\n CSS_VARS,\n progressControl,\n progressRecipe,\n type ProgressSlots,\n type ProgressVariants,\n toStrbool,\n} 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\";\n\ntype HtmlDivProps = ComponentProps<\"div\">;\n\ninterface ProgressOwnProps extends HtmlDivProps {\n /**\n * The minimum value of the progress range.\n *\n * @default 0\n */\n min?: number | undefined;\n /**\n * The maximum value of the progress range.\n *\n * @default 100\n */\n max?: number | undefined;\n /**\n * The current value of the progress. Omit this prop when progress is indeterminate.\n */\n value?: number | undefined;\n /**\n * The human-readable text alternative for the current value.\n */\n valueText?: string | undefined;\n /**\n * The label displayed above the progressbar.\n */\n label?: ReactNode | undefined;\n /**\n * The semantic color of the progressbar.\n *\n * @default \"accent\"\n */\n color?: ProgressVariants[\"color\"] | undefined;\n /**\n * The border radius of the progressbar.\n *\n * @default \"rounded\"\n */\n radius?: ProgressVariants[\"radius\"] | undefined;\n /**\n * The size of the progressbar.\n *\n * @default \"md\"\n */\n size?: ProgressVariants[\"size\"] | undefined;\n}\n\nexport type ProgressProps = HuiComponentProps<\n ProgressOwnProps,\n ProgressSlots\n>;\n\nexport function Progress(rawProps: ProgressProps): ReactElement {\n const {\n min,\n max,\n value,\n valueText,\n label,\n color,\n radius,\n size,\n
|
|
1
|
+
{"version":3,"file":"progress.js","names":[],"sources":["../../../src/components/progress/progress.tsx"],"sourcesContent":["import {\n cc,\n CSS_VARS,\n progressControl,\n progressRecipe,\n type ProgressSlots,\n type ProgressVariants,\n toStrbool,\n} 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\";\n\ntype HtmlDivProps = ComponentProps<\"div\">;\n\ninterface ProgressOwnProps extends HtmlDivProps {\n /**\n * The minimum value of the progress range.\n *\n * @default 0\n */\n min?: number | undefined;\n /**\n * The maximum value of the progress range.\n *\n * @default 100\n */\n max?: number | undefined;\n /**\n * The current value of the progress. Omit this prop when progress is indeterminate.\n */\n value?: number | undefined;\n /**\n * The human-readable text alternative for the current value.\n */\n valueText?: string | undefined;\n /**\n * The label displayed above the progressbar.\n */\n label?: ReactNode | undefined;\n /**\n * The semantic color of the progressbar.\n *\n * @default \"accent\"\n */\n color?: ProgressVariants[\"color\"] | undefined;\n /**\n * The border radius of the progressbar.\n *\n * @default \"rounded\"\n */\n radius?: ProgressVariants[\"radius\"] | undefined;\n /**\n * The size of the progressbar.\n *\n * @default \"md\"\n */\n size?: ProgressVariants[\"size\"] | undefined;\n}\n\nexport type ProgressProps = HuiComponentProps<\n ProgressOwnProps,\n ProgressSlots\n>;\n\nexport function Progress(rawProps: ProgressProps): ReactElement {\n const {\n min,\n max,\n value,\n valueText,\n label,\n color,\n radius,\n size,\n nonce,\n ...restProps\n } = useHuiProps(\"Progress\", rawProps);\n const progressId = useId();\n const progress = progressControl.resolve({\n progressId,\n hasLabel: Boolean(label),\n min,\n max,\n value,\n valueText,\n });\n\n const recipe = progressRecipe({\n color,\n indeterminate: toStrbool(progress.isIndeterminate),\n radius,\n size,\n });\n const cls = useHuiClassNames(\"Progress\", recipe, rawProps.classNames);\n const sls = useHuiStyles(\"Progress\", rawProps.styles);\n const labelAttrs = progressControl.getLabelAttributes(progress);\n const barAttrs = progressControl.getBarAttributes(progress);\n const valueAttrs = progressControl.getValueAttributes();\n const valueClassName = `progress-value-${progress.progressId}`;\n\n return (\n <div\n className={cls.root}\n style={sls.root}\n >\n {label\n && (\n <div\n className={cls.label}\n style={sls.label}\n {...labelAttrs}\n >\n {label}\n </div>\n )}\n <div\n className={cls.bar}\n style={sls.bar}\n {...barAttrs}\n {...restProps}\n >\n <style nonce={nonce}>\n {`.${valueClassName} {${CSS_VARS.arbitraryWidth}: ${progress.width}}`}\n </style>\n <div\n className={cc(cls.value, valueClassName)}\n style={sls.value}\n {...valueAttrs}\n >\n {progress.isIndeterminate ? undefined : valueText}\n </div>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;AAiEA,SAAgB,SAAS,UAAuC;CAC9D,MAAM,EACJ,KACA,KACA,OACA,WACA,OACA,OACA,QACA,MACA,OACA,GAAG,cACD,YAAY,YAAY,QAAQ;CACpC,MAAM,aAAa,MAAM;CACzB,MAAM,WAAW,gBAAgB,QAAQ;EACvC;EACA,UAAU,QAAQ,KAAK;EACvB;EACA;EACA;EACA;CACF,CAAC;CAED,MAAM,SAAS,eAAe;EAC5B;EACA,eAAe,UAAU,SAAS,eAAe;EACjD;EACA;CACF,CAAC;CACD,MAAM,MAAM,iBAAiB,YAAY,QAAQ,SAAS,UAAU;CACpE,MAAM,MAAM,aAAa,YAAY,SAAS,MAAM;CACpD,MAAM,aAAa,gBAAgB,mBAAmB,QAAQ;CAC9D,MAAM,WAAW,gBAAgB,iBAAiB,QAAQ;CAC1D,MAAM,aAAa,gBAAgB,mBAAmB;CACtD,MAAM,iBAAiB,kBAAkB,SAAS;CAElD,OACE,qBAAC,OAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EAFb,UAAA,CAIG,SAEG,oBAAC,OAAD;GACE,WAAW,IAAI;GACf,OAAO,IAAI;GACX,GAAI;GAEH,UAAA;EACE,CAAA,GAET,qBAAC,OAAD;GACE,WAAW,IAAI;GACf,OAAO,IAAI;GACX,GAAI;GACJ,GAAI;GAJN,UAAA,CAME,oBAAC,SAAD;IAAc;IACX,UAAA,IAAI,eAAe,IAAI,SAAS,eAAe,IAAI,SAAS,MAAM;GAC9D,CAAA,GACP,oBAAC,OAAD;IACE,WAAW,GAAG,IAAI,OAAO,cAAc;IACvC,OAAO,IAAI;IACX,GAAI;IAEH,UAAA,SAAS,kBAAkB,KAAA,IAAY;GACrC,CAAA,CACF;EACF,CAAA,CAAA;;AAET"}
|
|
@@ -2,7 +2,6 @@ import { HuiComponentProps } from "../../types/hui-component.js";
|
|
|
2
2
|
import "../../types/index.js";
|
|
3
3
|
import { RadioSlots, RadioVariants } from "@hebium-ui/core";
|
|
4
4
|
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
5
|
-
//#region src/components/radio/radio.d.ts
|
|
6
5
|
type HtmlInputProps = Omit<ComponentProps<"input">, "children" | "type">;
|
|
7
6
|
interface RadioOwnProps extends HtmlInputProps {
|
|
8
7
|
/**
|
|
@@ -22,6 +21,5 @@ interface RadioOwnProps extends HtmlInputProps {
|
|
|
22
21
|
}
|
|
23
22
|
export type RadioProps = HuiComponentProps<RadioOwnProps, RadioSlots>;
|
|
24
23
|
export declare function Radio(rawProps: RadioProps): ReactElement;
|
|
25
|
-
//#endregion
|
|
26
24
|
export {};
|
|
27
25
|
//# sourceMappingURL=radio.d.ts.map
|
|
@@ -3,9 +3,9 @@ import { normalizeAttributes } from "../../utils/attributes/normalize-attributes
|
|
|
3
3
|
import { radioControl, radioRecipe, toBool, toStrbool } from "@hebium-ui/core";
|
|
4
4
|
import { useId } from "react";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
|
|
6
|
+
// src/components/radio/radio.tsx
|
|
7
7
|
function Radio(rawProps) {
|
|
8
|
-
const { id,
|
|
8
|
+
const { id, label, error, color, ref, ...restProps } = useHuiProps("Radio", rawProps);
|
|
9
9
|
const tmpId = useId();
|
|
10
10
|
const radioState = {
|
|
11
11
|
id: id ?? tmpId,
|
|
@@ -16,8 +16,8 @@ function Radio(rawProps) {
|
|
|
16
16
|
color,
|
|
17
17
|
error: toStrbool(radioState.invalid)
|
|
18
18
|
});
|
|
19
|
-
const cls = useHuiClassNames("Radio", recipe, classNames);
|
|
20
|
-
const sls = useHuiStyles("Radio", styles);
|
|
19
|
+
const cls = useHuiClassNames("Radio", recipe, rawProps.classNames);
|
|
20
|
+
const sls = useHuiStyles("Radio", rawProps.styles);
|
|
21
21
|
const controlAttrs = normalizeAttributes(radioControl.getControlAttributes(radioState));
|
|
22
22
|
const labelAttrs = normalizeAttributes(radioControl.getLabelAttributes(radioState));
|
|
23
23
|
const errorAttrs = radioControl.getErrorAttributes(radioState);
|
|
@@ -51,7 +51,6 @@ function Radio(rawProps) {
|
|
|
51
51
|
})] })]
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
-
//#endregion
|
|
55
54
|
export { Radio };
|
|
56
55
|
|
|
57
56
|
//# sourceMappingURL=radio.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio.js","names":[],"sources":["../../../src/components/radio/radio.tsx"],"sourcesContent":["import { radioControl, radioRecipe, type RadioSlots, type RadioVariants, 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\";\n\ntype HtmlInputProps = Omit<ComponentProps<\"input\">, \"children\" | \"type\">;\n\ninterface RadioOwnProps extends HtmlInputProps {\n /**\n * The label displayed next to the radio control.\n */\n label?: ReactNode | undefined;\n /**\n * The error message displayed below the label.\n */\n error?: ReactNode | undefined;\n /**\n * The semantic color of the radio control.\n *\n * @default \"accent\"\n */\n color?: RadioVariants[\"color\"] | undefined;\n}\n\nexport type RadioProps = HuiComponentProps<\n RadioOwnProps,\n RadioSlots\n>;\n\nexport function Radio(rawProps: RadioProps): ReactElement {\n const {\n id,\n
|
|
1
|
+
{"version":3,"file":"radio.js","names":[],"sources":["../../../src/components/radio/radio.tsx"],"sourcesContent":["import { radioControl, radioRecipe, type RadioSlots, type RadioVariants, 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\";\n\ntype HtmlInputProps = Omit<ComponentProps<\"input\">, \"children\" | \"type\">;\n\ninterface RadioOwnProps extends HtmlInputProps {\n /**\n * The label displayed next to the radio control.\n */\n label?: ReactNode | undefined;\n /**\n * The error message displayed below the label.\n */\n error?: ReactNode | undefined;\n /**\n * The semantic color of the radio control.\n *\n * @default \"accent\"\n */\n color?: RadioVariants[\"color\"] | undefined;\n}\n\nexport type RadioProps = HuiComponentProps<\n RadioOwnProps,\n RadioSlots\n>;\n\nexport function Radio(rawProps: RadioProps): ReactElement {\n const {\n id,\n label,\n error,\n color,\n ref,\n ...restProps\n } = useHuiProps(\"Radio\", rawProps);\n\n const tmpId = useId();\n\n const radioState = {\n id: id ?? tmpId,\n invalid: !!error,\n disabled: toBool(restProps.disabled) || toBool(restProps[\"aria-disabled\"]),\n };\n const recipe = radioRecipe({\n color,\n error: toStrbool(radioState.invalid),\n });\n const cls = useHuiClassNames(\"Radio\", recipe, rawProps.classNames);\n const sls = useHuiStyles(\"Radio\", rawProps.styles);\n const controlAttrs = normalizeAttributes(radioControl.getControlAttributes(radioState));\n const labelAttrs = normalizeAttributes(radioControl.getLabelAttributes(radioState));\n const errorAttrs = radioControl.getErrorAttributes(radioState);\n\n return (\n <div\n className={cls.root}\n style={sls.root}\n >\n <input\n ref={ref}\n className={cls.radio}\n style={sls.radio}\n {...controlAttrs}\n {...restProps}\n />\n <div>\n {label && (\n <label\n className={cls.label}\n style={sls.label}\n {...labelAttrs}\n >\n {label}\n </label>\n )}\n {error && (\n <p\n className={cls.error}\n style={sls.error}\n {...errorAttrs}\n >\n <span\n aria-hidden\n className={cls.errorIcon}\n style={sls.errorIcon}\n />\n <span\n className={cls.errorMessage}\n style={sls.errorMessage}\n >\n {error}\n </span>\n </p>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;AA8BA,SAAgB,MAAM,UAAoC;CACxD,MAAM,EACJ,IACA,OACA,OACA,OACA,KACA,GAAG,cACD,YAAY,SAAS,QAAQ;CAEjC,MAAM,QAAQ,MAAM;CAEpB,MAAM,aAAa;EACjB,IAAI,MAAM;EACV,SAAS,CAAC,CAAC;EACX,UAAU,OAAO,UAAU,QAAQ,KAAK,OAAO,UAAU,gBAAgB;CAC3E;CACA,MAAM,SAAS,YAAY;EACzB;EACA,OAAO,UAAU,WAAW,OAAO;CACrC,CAAC;CACD,MAAM,MAAM,iBAAiB,SAAS,QAAQ,SAAS,UAAU;CACjE,MAAM,MAAM,aAAa,SAAS,SAAS,MAAM;CACjD,MAAM,eAAe,oBAAoB,aAAa,qBAAqB,UAAU,CAAC;CACtF,MAAM,aAAa,oBAAoB,aAAa,mBAAmB,UAAU,CAAC;CAClF,MAAM,aAAa,aAAa,mBAAmB,UAAU;CAE7D,OACE,qBAAC,OAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EAFb,UAAA,CAIE,oBAAC,SAAD;GACO;GACL,WAAW,IAAI;GACf,OAAO,IAAI;GACX,GAAI;GACJ,GAAI;EACL,CAAA,GACD,qBAAC,OAAD,EAAA,UAAA,CACG,SACC,oBAAC,SAAD;GACE,WAAW,IAAI;GACf,OAAO,IAAI;GACX,GAAI;GAEH,UAAA;EACI,CAAA,GAER,SACC,qBAAC,KAAD;GACE,WAAW,IAAI;GACf,OAAO,IAAI;GACX,GAAI;GAHN,UAAA,CAKE,oBAAC,QAAD;IACE,eAAA;IACA,WAAW,IAAI;IACf,OAAO,IAAI;GACZ,CAAA,GACD,oBAAC,QAAD;IACE,WAAW,IAAI;IACf,OAAO,IAAI;IAEV,UAAA;GACG,CAAA,CACL;EAEF,CAAA,CAAA,EAAA,CAAA,CACF;;AAET"}
|
|
@@ -4,7 +4,6 @@ import { LabelProps } from "../label/label.js";
|
|
|
4
4
|
import "../label/index.js";
|
|
5
5
|
import { RadiogroupSlots, RadiogroupVariants } from "@hebium-ui/core";
|
|
6
6
|
import { ElementType, ReactElement, ReactNode } from "react";
|
|
7
|
-
//#region src/components/radiogroup/radiogroup.d.ts
|
|
8
7
|
interface RadiogroupOwnProps {
|
|
9
8
|
/**
|
|
10
9
|
* The direction in which radio options are laid out.
|
|
@@ -31,6 +30,5 @@ interface RadiogroupOwnProps {
|
|
|
31
30
|
}
|
|
32
31
|
export type RadiogroupProps<E extends ElementType = "div"> = HuiPolymorphicProps<E, RadiogroupOwnProps, RadiogroupSlots>;
|
|
33
32
|
export declare function Radiogroup<E extends ElementType = "div">(rawProps: RadiogroupProps<E>): ReactElement;
|
|
34
|
-
//#endregion
|
|
35
33
|
export {};
|
|
36
34
|
//# sourceMappingURL=radiogroup.d.ts.map
|
|
@@ -4,13 +4,13 @@ import { Label } from "../label/label.js";
|
|
|
4
4
|
import { radiogroupControl, radiogroupRecipe, toBool } from "@hebium-ui/core";
|
|
5
5
|
import { useId } from "react";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
|
|
7
|
+
// src/components/radiogroup/radiogroup.tsx
|
|
8
8
|
function Radiogroup(rawProps) {
|
|
9
|
-
const { as, direction,
|
|
9
|
+
const { as, direction, label, description, error, labelProps, children, ...restProps } = useHuiProps("Radiogroup", rawProps);
|
|
10
10
|
const labelId = useId();
|
|
11
11
|
const recipe = radiogroupRecipe({ direction });
|
|
12
|
-
const cls = useHuiClassNames("Radiogroup", recipe, classNames);
|
|
13
|
-
const sls = useHuiStyles("Radiogroup", styles);
|
|
12
|
+
const cls = useHuiClassNames("Radiogroup", recipe, rawProps.classNames);
|
|
13
|
+
const sls = useHuiStyles("Radiogroup", rawProps.styles);
|
|
14
14
|
const radiogroupState = {
|
|
15
15
|
labelId,
|
|
16
16
|
hasLabel: !!label || !!description || !!error,
|
|
@@ -38,7 +38,6 @@ function Radiogroup(rawProps) {
|
|
|
38
38
|
})]
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
-
//#endregion
|
|
42
41
|
export { Radiogroup };
|
|
43
42
|
|
|
44
43
|
//# sourceMappingURL=radiogroup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radiogroup.js","names":[],"sources":["../../../src/components/radiogroup/radiogroup.tsx"],"sourcesContent":["import {\n radiogroupControl,\n radiogroupRecipe,\n type RadiogroupSlots,\n type RadiogroupVariants,\n toBool,\n} from \"@hebium-ui/core\";\nimport { type ElementType, type ReactElement, type ReactNode, useId } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\nimport { normalizeAttributes } from \"~/utils\";\nimport { Label, type LabelProps } from \"../label\";\n\ninterface RadiogroupOwnProps {\n /**\n * The direction in which radio options are laid out.\n *\n * @default \"column\"\n */\n direction?: RadiogroupVariants[\"direction\"] | undefined;\n /**\n * The label displayed above the radio group.\n */\n label?: ReactNode | undefined;\n /**\n * Additional props passed to the internal label component.\n */\n labelProps?: LabelProps<\"div\"> | undefined;\n /**\n * The help text displayed below the label.\n */\n description?: ReactNode | undefined;\n /**\n * The error message displayed below the label.\n */\n error?: ReactNode | undefined;\n}\n\nexport type RadiogroupProps<E extends ElementType = \"div\"> = HuiPolymorphicProps<\n E,\n RadiogroupOwnProps,\n RadiogroupSlots\n>;\n\nexport function Radiogroup<E extends ElementType = \"div\">(rawProps: RadiogroupProps<E>): ReactElement {\n const {\n as,\n direction,\n
|
|
1
|
+
{"version":3,"file":"radiogroup.js","names":[],"sources":["../../../src/components/radiogroup/radiogroup.tsx"],"sourcesContent":["import {\n radiogroupControl,\n radiogroupRecipe,\n type RadiogroupSlots,\n type RadiogroupVariants,\n toBool,\n} from \"@hebium-ui/core\";\nimport { type ElementType, type ReactElement, type ReactNode, useId } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\nimport { normalizeAttributes } from \"~/utils\";\nimport { Label, type LabelProps } from \"../label\";\n\ninterface RadiogroupOwnProps {\n /**\n * The direction in which radio options are laid out.\n *\n * @default \"column\"\n */\n direction?: RadiogroupVariants[\"direction\"] | undefined;\n /**\n * The label displayed above the radio group.\n */\n label?: ReactNode | undefined;\n /**\n * Additional props passed to the internal label component.\n */\n labelProps?: LabelProps<\"div\"> | undefined;\n /**\n * The help text displayed below the label.\n */\n description?: ReactNode | undefined;\n /**\n * The error message displayed below the label.\n */\n error?: ReactNode | undefined;\n}\n\nexport type RadiogroupProps<E extends ElementType = \"div\"> = HuiPolymorphicProps<\n E,\n RadiogroupOwnProps,\n RadiogroupSlots\n>;\n\nexport function Radiogroup<E extends ElementType = \"div\">(rawProps: RadiogroupProps<E>): ReactElement {\n const {\n as,\n direction,\n label,\n description,\n error,\n labelProps,\n children,\n ...restProps\n } = useHuiProps(\"Radiogroup\", rawProps);\n\n const labelId = useId();\n\n const recipe = radiogroupRecipe({ direction });\n const cls = useHuiClassNames(\"Radiogroup\", recipe, rawProps.classNames);\n const sls = useHuiStyles(\"Radiogroup\", rawProps.styles);\n const radiogroupState = {\n labelId,\n hasLabel: !!label || !!description || !!error,\n invalid: !!error,\n required: toBool(restProps[\"aria-required\"]),\n };\n const rootAttrs = normalizeAttributes(radiogroupControl.getRootAttributes(radiogroupState));\n const labelAttrs = normalizeAttributes(radiogroupControl.getLabelAttributes(radiogroupState));\n\n const Component = as ?? \"div\";\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...rootAttrs}\n {...restProps}\n >\n {radiogroupState.hasLabel\n && (\n <Label\n as=\"div\"\n {...labelAttrs}\n description={description}\n error={error}\n {...labelProps}\n >\n {label}\n </Label>\n )}\n <div\n className={cls.group}\n style={sls.group}\n >\n {children}\n </div>\n </Component>\n );\n}\n"],"mappings":";;;;;;;AA4CA,SAAgB,WAA0C,UAA4C;CACpG,MAAM,EACJ,IACA,WACA,OACA,aACA,OACA,YACA,UACA,GAAG,cACD,YAAY,cAAc,QAAQ;CAEtC,MAAM,UAAU,MAAM;CAEtB,MAAM,SAAS,iBAAiB,EAAE,UAAU,CAAC;CAC7C,MAAM,MAAM,iBAAiB,cAAc,QAAQ,SAAS,UAAU;CACtE,MAAM,MAAM,aAAa,cAAc,SAAS,MAAM;CACtD,MAAM,kBAAkB;EACtB;EACA,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC,eAAe,CAAC,CAAC;EACxC,SAAS,CAAC,CAAC;EACX,UAAU,OAAO,UAAU,gBAAgB;CAC7C;CACA,MAAM,YAAY,oBAAoB,kBAAkB,kBAAkB,eAAe,CAAC;CAC1F,MAAM,aAAa,oBAAoB,kBAAkB,mBAAmB,eAAe,CAAC;CAG5F,OACE,qBAFgB,MAAM,OAEtB;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EACJ,GAAI;EAJN,UAAA,CAMG,gBAAgB,YAEb,oBAAC,OAAD;GACE,IAAG;GACH,GAAI;GACS;GACN;GACP,GAAI;GAEH,UAAA;EACI,CAAA,GAEX,oBAAC,OAAD;GACE,WAAW,IAAI;GACf,OAAO,IAAI;GAEV;EACE,CAAA,CACI;;AAEf"}
|