@hebium-ui/react 0.1.0-alpha.2 → 0.1.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/alert/alert.d.ts +3 -6
- package/dist/components/alert/alert.js +6 -14
- package/dist/components/alert/alert.js.map +1 -1
- package/dist/components/anchor/anchor.d.ts +1 -4
- package/dist/components/anchor/anchor.js +4 -5
- package/dist/components/anchor/anchor.js.map +1 -1
- package/dist/components/avatar/avatar.d.ts +1 -4
- package/dist/components/avatar/avatar.js +4 -5
- package/dist/components/avatar/avatar.js.map +1 -1
- package/dist/components/blockquote/blockquote.d.ts +1 -4
- package/dist/components/blockquote/blockquote.js +4 -5
- package/dist/components/blockquote/blockquote.js.map +1 -1
- package/dist/components/button/button.d.ts +12 -4
- package/dist/components/button/button.js +30 -11
- package/dist/components/button/button.js.map +1 -1
- package/dist/components/checkbox/checkbox.d.ts +2 -5
- package/dist/components/checkbox/checkbox.js +29 -16
- package/dist/components/checkbox/checkbox.js.map +1 -1
- package/dist/components/code/code.d.ts +1 -4
- package/dist/components/code/code.js +4 -5
- package/dist/components/code/code.js.map +1 -1
- package/dist/components/combobox/combobox-option.js +33 -0
- package/dist/components/combobox/combobox-option.js.map +1 -0
- package/dist/components/combobox/combobox.d.ts +61 -0
- package/dist/components/combobox/combobox.js +208 -0
- package/dist/components/combobox/combobox.js.map +1 -0
- package/dist/components/combobox/index.d.ts +2 -0
- package/dist/components/combobox/use-combobox-form.js +33 -0
- package/dist/components/combobox/use-combobox-form.js.map +1 -0
- package/dist/components/combobox/use-combobox-popover.js +66 -0
- package/dist/components/combobox/use-combobox-popover.js.map +1 -0
- package/dist/components/combobox/use-combobox-state.js +96 -0
- package/dist/components/combobox/use-combobox-state.js.map +1 -0
- package/dist/components/details/details.d.ts +1 -4
- package/dist/components/details/details.js +4 -5
- package/dist/components/details/details.js.map +1 -1
- package/dist/components/dialog/dialog.context.js +1 -2
- package/dist/components/dialog/dialog.d.ts +4 -7
- package/dist/components/dialog/dialog.js +29 -9
- package/dist/components/dialog/dialog.js.map +1 -1
- package/dist/components/dialog/index.d.ts +1 -2
- package/dist/components/dl/dl.d.ts +1 -4
- package/dist/components/dl/dl.js +10 -11
- package/dist/components/dl/dl.js.map +1 -1
- package/dist/components/drawer/drawer.context.js +1 -2
- package/dist/components/drawer/drawer.d.ts +4 -7
- package/dist/components/drawer/drawer.js +29 -9
- package/dist/components/drawer/drawer.js.map +1 -1
- package/dist/components/drawer/index.d.ts +1 -2
- package/dist/components/fieldset/fieldset.d.ts +1 -4
- package/dist/components/fieldset/fieldset.js +4 -5
- package/dist/components/fieldset/fieldset.js.map +1 -1
- package/dist/components/heading/heading.d.ts +1 -4
- package/dist/components/heading/heading.js +4 -5
- package/dist/components/heading/heading.js.map +1 -1
- package/dist/components/hr/hr.d.ts +1 -4
- package/dist/components/hr/hr.js +4 -5
- package/dist/components/hr/hr.js.map +1 -1
- package/dist/components/index.d.ts +35 -26
- package/dist/components/inline-feedback/index.d.ts +2 -0
- package/dist/components/inline-feedback/inline-feedback.d.ts +33 -0
- package/dist/components/inline-feedback/inline-feedback.js +30 -0
- package/dist/components/inline-feedback/inline-feedback.js.map +1 -0
- package/dist/components/input/input.d.ts +1 -4
- package/dist/components/input/input.js +4 -5
- package/dist/components/input/input.js.map +1 -1
- package/dist/components/label/label.d.ts +1 -4
- package/dist/components/label/label.js +6 -7
- package/dist/components/label/label.js.map +1 -1
- package/dist/components/menu/index.d.ts +1 -2
- package/dist/components/menu/menu.context.js +1 -2
- package/dist/components/menu/menu.d.ts +3 -6
- package/dist/components/menu/menu.js +23 -9
- package/dist/components/menu/menu.js.map +1 -1
- package/dist/components/multi-combobox/index.d.ts +2 -0
- package/dist/components/multi-combobox/multi-combobox-option.js +42 -0
- package/dist/components/multi-combobox/multi-combobox-option.js.map +1 -0
- package/dist/components/multi-combobox/multi-combobox-tag.js +54 -0
- package/dist/components/multi-combobox/multi-combobox-tag.js.map +1 -0
- package/dist/components/multi-combobox/multi-combobox.d.ts +72 -0
- package/dist/components/multi-combobox/multi-combobox.js +249 -0
- package/dist/components/multi-combobox/multi-combobox.js.map +1 -0
- package/dist/components/multi-combobox/use-multi-combobox-state.js +91 -0
- package/dist/components/multi-combobox/use-multi-combobox-state.js.map +1 -0
- package/dist/components/paragraph/paragraph.d.ts +1 -4
- package/dist/components/paragraph/paragraph.js +4 -5
- package/dist/components/paragraph/paragraph.js.map +1 -1
- package/dist/components/popover/index.d.ts +1 -2
- package/dist/components/popover/popover.context.js +1 -2
- package/dist/components/popover/popover.d.ts +3 -6
- package/dist/components/popover/popover.js +20 -6
- package/dist/components/popover/popover.js.map +1 -1
- package/dist/components/progress/progress.d.ts +1 -4
- package/dist/components/progress/progress.js +4 -5
- package/dist/components/progress/progress.js.map +1 -1
- package/dist/components/radio/radio.d.ts +1 -4
- package/dist/components/radio/radio.js +4 -5
- package/dist/components/radio/radio.js.map +1 -1
- package/dist/components/radiogroup/radiogroup.d.ts +1 -4
- package/dist/components/radiogroup/radiogroup.js +6 -6
- package/dist/components/radiogroup/radiogroup.js.map +1 -1
- package/dist/components/section/section.d.ts +1 -4
- package/dist/components/section/section.js +4 -5
- package/dist/components/section/section.js.map +1 -1
- package/dist/components/segmented-control/segmented-control.context.js +1 -2
- package/dist/components/segmented-control/segmented-control.d.ts +2 -5
- package/dist/components/segmented-control/segmented-control.js +13 -9
- package/dist/components/segmented-control/segmented-control.js.map +1 -1
- package/dist/components/select/select.d.ts +1 -4
- package/dist/components/select/select.js +4 -5
- package/dist/components/select/select.js.map +1 -1
- package/dist/components/skip-link/index.d.ts +2 -0
- package/dist/components/skip-link/skip-link.d.ts +6 -0
- package/dist/components/skip-link/skip-link.js +20 -0
- package/dist/components/skip-link/skip-link.js.map +1 -0
- package/dist/components/status-icon/index.d.ts +2 -0
- package/dist/components/status-icon/status-icon.d.ts +19 -0
- package/dist/components/status-icon/status-icon.js +22 -0
- package/dist/components/status-icon/status-icon.js.map +1 -0
- package/dist/components/table/table.d.ts +4 -7
- package/dist/components/table/table.js +25 -26
- package/dist/components/table/table.js.map +1 -1
- package/dist/components/tabs/tabs.context.d.ts +1 -4
- package/dist/components/tabs/tabs.context.js +1 -2
- package/dist/components/tabs/tabs.d.ts +2 -5
- package/dist/components/tabs/tabs.js +13 -14
- package/dist/components/tabs/tabs.js.map +1 -1
- package/dist/components/tag/index.d.ts +2 -0
- package/dist/components/tag/tag.d.ts +39 -0
- package/dist/components/tag/tag.js +41 -0
- package/dist/components/tag/tag.js.map +1 -0
- package/dist/components/text/index.d.ts +2 -0
- package/dist/components/text/text.d.ts +22 -0
- package/dist/components/text/text.js +23 -0
- package/dist/components/text/text.js.map +1 -0
- package/dist/components/textarea/textarea.d.ts +1 -4
- package/dist/components/textarea/textarea.js +4 -5
- package/dist/components/textarea/textarea.js.map +1 -1
- package/dist/components/tooltip/index.d.ts +1 -2
- package/dist/components/tooltip/tooltip.context.js +1 -2
- package/dist/components/tooltip/tooltip.d.ts +3 -6
- package/dist/components/tooltip/tooltip.js +19 -5
- package/dist/components/tooltip/tooltip.js.map +1 -1
- package/dist/components/visually-hidden/visually-hidden.d.ts +3 -6
- package/dist/components/visually-hidden/visually-hidden.js +4 -5
- package/dist/components/visually-hidden/visually-hidden.js.map +1 -1
- package/dist/index.d.ts +9 -7
- package/dist/index.js +9 -7
- package/dist/provider/hui-provider.context.d.ts +34 -10
- package/dist/provider/hui-provider.context.js +23 -16
- package/dist/provider/hui-provider.context.js.map +1 -1
- package/dist/provider/hui-provider.d.ts +1 -4
- package/dist/provider/hui-provider.js +1 -2
- package/dist/provider/index.d.ts +1 -1
- package/dist/provider/merge-props.js +1 -2
- package/dist/types/distributive.d.ts +1 -0
- package/dist/types/hui-component.d.ts +11 -7
- package/dist/types/index.d.ts +3 -2
- package/dist/types/polymorphic.d.ts +4 -11
- package/dist/utils/attributes/normalize-attributes.js +1 -2
- package/package.json +9 -9
- package/dist/components/dialog/dialog.context.d.ts +0 -4
- package/dist/components/drawer/drawer.context.d.ts +0 -4
- package/dist/components/menu/menu.context.d.ts +0 -4
- package/dist/components/popover/popover.context.d.ts +0 -4
- package/dist/components/tooltip/tooltip.context.d.ts +0 -4
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { HuiComponentProps } from "../../types/hui-component.js";
|
|
2
|
+
import "../../types/index.js";
|
|
3
|
+
import { StatusIconSlots, StatusIconVariants } from "@hebium-ui/core";
|
|
4
|
+
import { ComponentProps, ReactElement } from "react";
|
|
5
|
+
interface StatusIconOwnProps extends Omit<ComponentProps<"span">, "children" | "color"> {
|
|
6
|
+
/**
|
|
7
|
+
* Status to display.
|
|
8
|
+
*/
|
|
9
|
+
status: NonNullable<StatusIconVariants["status"]>;
|
|
10
|
+
/**
|
|
11
|
+
* Icon color.
|
|
12
|
+
*
|
|
13
|
+
* @default "inherit"
|
|
14
|
+
*/
|
|
15
|
+
color?: StatusIconVariants["color"] | undefined;
|
|
16
|
+
}
|
|
17
|
+
export type StatusIconProps = HuiComponentProps<StatusIconOwnProps, StatusIconSlots>;
|
|
18
|
+
export declare function StatusIcon(rawProps: StatusIconProps): ReactElement;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
|
|
2
|
+
import { statusIconRecipe } from "@hebium-ui/core";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
// src/components/status-icon/status-icon.tsx
|
|
5
|
+
function StatusIcon(rawProps) {
|
|
6
|
+
const { status, color, ...restProps } = useHuiProps("StatusIcon", rawProps);
|
|
7
|
+
const recipe = statusIconRecipe({
|
|
8
|
+
status,
|
|
9
|
+
color
|
|
10
|
+
});
|
|
11
|
+
const cls = useHuiClassNames("StatusIcon", recipe, rawProps);
|
|
12
|
+
const sls = useHuiStyles("StatusIcon", rawProps);
|
|
13
|
+
return /* @__PURE__ */ jsx("span", {
|
|
14
|
+
"aria-hidden": true,
|
|
15
|
+
className: cls.root,
|
|
16
|
+
style: sls.root,
|
|
17
|
+
...restProps
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
export { StatusIcon };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=status-icon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-icon.js","names":[],"sources":["../../../src/components/status-icon/status-icon.tsx"],"sourcesContent":["import { statusIconRecipe, type StatusIconSlots, type StatusIconVariants } from \"@hebium-ui/core\";\nimport { type ComponentProps, type ReactElement } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps } from \"~/types\";\n\ninterface StatusIconOwnProps extends Omit<ComponentProps<\"span\">, \"children\" | \"color\"> {\n /**\n * Status to display.\n */\n status: NonNullable<StatusIconVariants[\"status\"]>;\n /**\n * Icon color.\n *\n * @default \"inherit\"\n */\n color?: StatusIconVariants[\"color\"] | undefined;\n}\n\nexport type StatusIconProps = HuiComponentProps<StatusIconOwnProps, StatusIconSlots>;\n\nexport function StatusIcon(rawProps: StatusIconProps): ReactElement {\n const {\n status,\n color,\n ...restProps\n } = useHuiProps(\"StatusIcon\", rawProps);\n const recipe = statusIconRecipe({\n status,\n color,\n });\n\n const cls = useHuiClassNames(\"StatusIcon\", recipe, rawProps);\n const sls = useHuiStyles(\"StatusIcon\", rawProps);\n\n return (\n <span\n aria-hidden\n className={cls.root}\n style={sls.root}\n {...restProps}\n />\n );\n}\n"],"mappings":";;;;AAoBA,SAAgB,WAAW,UAAyC;CAClE,MAAM,EACJ,QACA,OACA,GAAG,cACD,YAAY,cAAc,QAAQ;CACtC,MAAM,SAAS,iBAAiB;EAC9B;EACA;CACF,CAAC;CAED,MAAM,MAAM,iBAAiB,cAAc,QAAQ,QAAQ;CAC3D,MAAM,MAAM,aAAa,cAAc,QAAQ;CAE/C,OACE,oBAAC,QAAD;EACE,eAAA;EACA,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;CACL,CAAA;AAEL"}
|
|
@@ -2,7 +2,6 @@ import { HuiComponentProps } from "../../types/hui-component.js";
|
|
|
2
2
|
import "../../types/index.js";
|
|
3
3
|
import { CaptionSlots, CaptionVariants, TableSlots, TableVariants, TdSlots, ThSlots, TrSlots, TrVariants } from "@hebium-ui/core";
|
|
4
4
|
import { ComponentProps, ReactElement } from "react";
|
|
5
|
-
//#region src/components/table/table.d.ts
|
|
6
5
|
interface TableOwnProps extends Omit<ComponentProps<"table">, "border"> {
|
|
7
6
|
/**
|
|
8
7
|
* The border style of the table.
|
|
@@ -19,11 +18,11 @@ interface CaptionOwnProps extends ComponentProps<"caption"> {
|
|
|
19
18
|
}
|
|
20
19
|
export interface CaptionProps extends HuiComponentProps<CaptionOwnProps, CaptionSlots> {}
|
|
21
20
|
declare function Caption(rawProps: CaptionProps): ReactElement;
|
|
22
|
-
export type TheadProps = ComponentProps<"thead">;
|
|
21
|
+
export type TheadProps = HuiComponentProps<ComponentProps<"thead">, "root">;
|
|
23
22
|
declare function Thead(rawProps: TheadProps): ReactElement;
|
|
24
|
-
export type TbodyProps = ComponentProps<"tbody">;
|
|
23
|
+
export type TbodyProps = HuiComponentProps<ComponentProps<"tbody">, "root">;
|
|
25
24
|
declare function Tbody(rawProps: TbodyProps): ReactElement;
|
|
26
|
-
export type TfootProps = ComponentProps<"tfoot">;
|
|
25
|
+
export type TfootProps = HuiComponentProps<ComponentProps<"tfoot">, "root">;
|
|
27
26
|
declare function Tfoot(rawProps: TfootProps): ReactElement;
|
|
28
27
|
interface TrOwnProps extends ComponentProps<"tr"> {
|
|
29
28
|
/**
|
|
@@ -48,6 +47,4 @@ export declare const Table: typeof TableRoot & {
|
|
|
48
47
|
Th: typeof Th;
|
|
49
48
|
Td: typeof Td;
|
|
50
49
|
};
|
|
51
|
-
|
|
52
|
-
export {};
|
|
53
|
-
//# sourceMappingURL=table.d.ts.map
|
|
50
|
+
export {};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
|
|
2
2
|
import { captionRecipe, tableRecipe, tdRecipe, thRecipe, trRecipe } from "@hebium-ui/core";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
|
|
4
|
+
// src/components/table/table.tsx
|
|
5
5
|
function TableRoot(rawProps) {
|
|
6
|
-
const { border,
|
|
6
|
+
const { border, children, ...restProps } = useHuiProps("Table", rawProps);
|
|
7
7
|
const recipe = tableRecipe({ border });
|
|
8
|
-
const cls = useHuiClassNames("Table", recipe,
|
|
9
|
-
const sls = useHuiStyles("Table",
|
|
8
|
+
const cls = useHuiClassNames("Table", recipe, rawProps);
|
|
9
|
+
const sls = useHuiStyles("Table", rawProps);
|
|
10
10
|
return /* @__PURE__ */ jsx("table", {
|
|
11
11
|
className: cls.root,
|
|
12
12
|
style: sls.root,
|
|
@@ -15,10 +15,10 @@ function TableRoot(rawProps) {
|
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
function Caption(rawProps) {
|
|
18
|
-
const { side,
|
|
18
|
+
const { side, children, ...restProps } = useHuiProps("TableCaption", rawProps);
|
|
19
19
|
const recipe = captionRecipe({ side });
|
|
20
|
-
const cls = useHuiClassNames("TableCaption", recipe,
|
|
21
|
-
const sls = useHuiStyles("TableCaption",
|
|
20
|
+
const cls = useHuiClassNames("TableCaption", recipe, rawProps);
|
|
21
|
+
const sls = useHuiStyles("TableCaption", rawProps);
|
|
22
22
|
return /* @__PURE__ */ jsx("caption", {
|
|
23
23
|
className: cls.root,
|
|
24
24
|
style: sls.root,
|
|
@@ -27,9 +27,9 @@ function Caption(rawProps) {
|
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
function Thead(rawProps) {
|
|
30
|
-
const {
|
|
31
|
-
const cls = useHuiClassNames("TableThead", { root: "" },
|
|
32
|
-
const sls = useHuiStyles("TableThead",
|
|
30
|
+
const { children, ...restProps } = useHuiProps("TableThead", rawProps);
|
|
31
|
+
const cls = useHuiClassNames("TableThead", { root: "" }, rawProps);
|
|
32
|
+
const sls = useHuiStyles("TableThead", rawProps);
|
|
33
33
|
return /* @__PURE__ */ jsx("thead", {
|
|
34
34
|
className: cls.root,
|
|
35
35
|
style: sls.root,
|
|
@@ -38,9 +38,9 @@ function Thead(rawProps) {
|
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
function Tbody(rawProps) {
|
|
41
|
-
const {
|
|
42
|
-
const cls = useHuiClassNames("TableTbody", { root: "" },
|
|
43
|
-
const sls = useHuiStyles("TableTbody",
|
|
41
|
+
const { children, ...restProps } = useHuiProps("TableTbody", rawProps);
|
|
42
|
+
const cls = useHuiClassNames("TableTbody", { root: "" }, rawProps);
|
|
43
|
+
const sls = useHuiStyles("TableTbody", rawProps);
|
|
44
44
|
return /* @__PURE__ */ jsx("tbody", {
|
|
45
45
|
className: cls.root,
|
|
46
46
|
style: sls.root,
|
|
@@ -49,9 +49,9 @@ function Tbody(rawProps) {
|
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
function Tfoot(rawProps) {
|
|
52
|
-
const {
|
|
53
|
-
const cls = useHuiClassNames("TableTfoot", { root: "" },
|
|
54
|
-
const sls = useHuiStyles("TableTfoot",
|
|
52
|
+
const { children, ...restProps } = useHuiProps("TableTfoot", rawProps);
|
|
53
|
+
const cls = useHuiClassNames("TableTfoot", { root: "" }, rawProps);
|
|
54
|
+
const sls = useHuiStyles("TableTfoot", rawProps);
|
|
55
55
|
return /* @__PURE__ */ jsx("tfoot", {
|
|
56
56
|
className: cls.root,
|
|
57
57
|
style: sls.root,
|
|
@@ -60,10 +60,10 @@ function Tfoot(rawProps) {
|
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
function Tr(rawProps) {
|
|
63
|
-
const { border,
|
|
63
|
+
const { border, children, ...restProps } = useHuiProps("TableTr", rawProps);
|
|
64
64
|
const recipe = trRecipe({ border });
|
|
65
|
-
const cls = useHuiClassNames("TableTr", recipe,
|
|
66
|
-
const sls = useHuiStyles("TableTr",
|
|
65
|
+
const cls = useHuiClassNames("TableTr", recipe, rawProps);
|
|
66
|
+
const sls = useHuiStyles("TableTr", rawProps);
|
|
67
67
|
return /* @__PURE__ */ jsx("tr", {
|
|
68
68
|
className: cls.root,
|
|
69
69
|
style: sls.root,
|
|
@@ -72,10 +72,10 @@ function Tr(rawProps) {
|
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
74
|
function Th(rawProps) {
|
|
75
|
-
const {
|
|
75
|
+
const { children, ...restProps } = useHuiProps("TableTh", rawProps);
|
|
76
76
|
const recipe = thRecipe({});
|
|
77
|
-
const cls = useHuiClassNames("TableTh", recipe,
|
|
78
|
-
const sls = useHuiStyles("TableTh",
|
|
77
|
+
const cls = useHuiClassNames("TableTh", recipe, rawProps);
|
|
78
|
+
const sls = useHuiStyles("TableTh", rawProps);
|
|
79
79
|
return /* @__PURE__ */ jsx("th", {
|
|
80
80
|
className: cls.root,
|
|
81
81
|
style: sls.root,
|
|
@@ -84,10 +84,10 @@ function Th(rawProps) {
|
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
86
|
function Td(rawProps) {
|
|
87
|
-
const {
|
|
87
|
+
const { children, ...restProps } = useHuiProps("TableTd", rawProps);
|
|
88
88
|
const recipe = tdRecipe({});
|
|
89
|
-
const cls = useHuiClassNames("TableTd", recipe,
|
|
90
|
-
const sls = useHuiStyles("TableTd",
|
|
89
|
+
const cls = useHuiClassNames("TableTd", recipe, rawProps);
|
|
90
|
+
const sls = useHuiStyles("TableTd", rawProps);
|
|
91
91
|
return /* @__PURE__ */ jsx("td", {
|
|
92
92
|
className: cls.root,
|
|
93
93
|
style: sls.root,
|
|
@@ -104,7 +104,6 @@ const Table = Object.assign(TableRoot, {
|
|
|
104
104
|
Th,
|
|
105
105
|
Td
|
|
106
106
|
});
|
|
107
|
-
//#endregion
|
|
108
107
|
export { Table };
|
|
109
108
|
|
|
110
109
|
//# sourceMappingURL=table.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.js","names":[],"sources":["../../../src/components/table/table.tsx"],"sourcesContent":["import {\n captionRecipe,\n type CaptionSlots,\n type CaptionVariants,\n tableRecipe,\n type TableSlots,\n type TableVariants,\n tdRecipe,\n type TdSlots,\n thRecipe,\n type ThSlots,\n trRecipe,\n type TrSlots,\n type TrVariants,\n} from \"@hebium-ui/core\";\nimport { type ComponentProps, type ReactElement } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps } from \"~/types\";\n\ninterface TableOwnProps extends Omit<ComponentProps<\"table\">, \"border\"> {\n /**\n * The border style of the table.\n */\n border?: TableVariants[\"border\"] | undefined;\n}\nexport interface TableProps extends HuiComponentProps<TableOwnProps, TableSlots> {}\n\nfunction TableRoot(rawProps: TableProps): ReactElement {\n const {\n border,\n
|
|
1
|
+
{"version":3,"file":"table.js","names":[],"sources":["../../../src/components/table/table.tsx"],"sourcesContent":["import {\n captionRecipe,\n type CaptionSlots,\n type CaptionVariants,\n tableRecipe,\n type TableSlots,\n type TableVariants,\n tdRecipe,\n type TdSlots,\n thRecipe,\n type ThSlots,\n trRecipe,\n type TrSlots,\n type TrVariants,\n} from \"@hebium-ui/core\";\nimport { type ComponentProps, type ReactElement } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps } from \"~/types\";\n\ninterface TableOwnProps extends Omit<ComponentProps<\"table\">, \"border\"> {\n /**\n * The border style of the table.\n */\n border?: TableVariants[\"border\"] | undefined;\n}\nexport interface TableProps extends HuiComponentProps<TableOwnProps, TableSlots> {}\n\nfunction TableRoot(rawProps: TableProps): ReactElement {\n const {\n border,\n children,\n ...restProps\n } = useHuiProps(\"Table\", rawProps);\n\n const recipe = tableRecipe({ border });\n const cls = useHuiClassNames(\"Table\", recipe, rawProps);\n const sls = useHuiStyles(\"Table\", rawProps);\n\n return (\n <table\n className={cls.root}\n style={sls.root}\n {...restProps}\n >\n {children}\n </table>\n );\n}\n\ninterface CaptionOwnProps extends ComponentProps<\"caption\"> {\n /**\n * The side on which the caption is displayed.\n */\n side?: CaptionVariants[\"side\"] | undefined;\n}\nexport interface CaptionProps extends HuiComponentProps<CaptionOwnProps, CaptionSlots> {}\n\nfunction Caption(rawProps: CaptionProps): ReactElement {\n const {\n side,\n children,\n ...restProps\n } = useHuiProps(\"TableCaption\", rawProps);\n\n const recipe = captionRecipe({ side });\n const cls = useHuiClassNames(\"TableCaption\", recipe, rawProps);\n const sls = useHuiStyles(\"TableCaption\", rawProps);\n\n return (\n <caption\n className={cls.root}\n style={sls.root}\n {...restProps}\n >\n {children}\n </caption>\n );\n}\n\nexport type TheadProps = HuiComponentProps<ComponentProps<\"thead\">, \"root\">;\n\nfunction Thead(rawProps: TheadProps): ReactElement {\n const { children, ...restProps } = useHuiProps(\"TableThead\", rawProps);\n\n const cls = useHuiClassNames(\"TableThead\", { root: \"\" }, rawProps);\n const sls = useHuiStyles(\"TableThead\", rawProps);\n\n return (\n <thead\n className={cls.root}\n style={sls.root}\n {...restProps}\n >\n {children}\n </thead>\n );\n}\n\nexport type TbodyProps = HuiComponentProps<ComponentProps<\"tbody\">, \"root\">;\n\nfunction Tbody(rawProps: TbodyProps): ReactElement {\n const { children, ...restProps } = useHuiProps(\"TableTbody\", rawProps);\n\n const cls = useHuiClassNames(\"TableTbody\", { root: \"\" }, rawProps);\n const sls = useHuiStyles(\"TableTbody\", rawProps);\n\n return (\n <tbody\n className={cls.root}\n style={sls.root}\n {...restProps}\n >\n {children}\n </tbody>\n );\n}\n\nexport type TfootProps = HuiComponentProps<ComponentProps<\"tfoot\">, \"root\">;\n\nfunction Tfoot(rawProps: TfootProps): ReactElement {\n const { children, ...restProps } = useHuiProps(\"TableTfoot\", rawProps);\n\n const cls = useHuiClassNames(\"TableTfoot\", { root: \"\" }, rawProps);\n const sls = useHuiStyles(\"TableTfoot\", rawProps);\n\n return (\n <tfoot\n className={cls.root}\n style={sls.root}\n {...restProps}\n >\n {children}\n </tfoot>\n );\n}\n\ninterface TrOwnProps extends ComponentProps<\"tr\"> {\n /**\n * The border style of the table row.\n *\n * @default \"block-end\"\n */\n border?: TrVariants[\"border\"] | undefined;\n}\nexport interface TrProps extends HuiComponentProps<TrOwnProps, TrSlots> {}\n\nfunction Tr(rawProps: TrProps): ReactElement {\n const {\n border,\n children,\n ...restProps\n } = useHuiProps(\"TableTr\", rawProps);\n\n const recipe = trRecipe({ border });\n const cls = useHuiClassNames(\"TableTr\", recipe, rawProps);\n const sls = useHuiStyles(\"TableTr\", rawProps);\n\n return (\n <tr\n className={cls.root}\n style={sls.root}\n {...restProps}\n >\n {children}\n </tr>\n );\n}\n\nexport interface ThProps extends HuiComponentProps<ComponentProps<\"th\">, ThSlots> {}\n\nfunction Th(rawProps: ThProps): ReactElement {\n const { children, ...restProps } = useHuiProps(\"TableTh\", rawProps);\n\n const recipe = thRecipe({});\n const cls = useHuiClassNames(\"TableTh\", recipe, rawProps);\n const sls = useHuiStyles(\"TableTh\", rawProps);\n\n return (\n <th\n className={cls.root}\n style={sls.root}\n {...restProps}\n >\n {children}\n </th>\n );\n}\n\nexport interface TdProps extends HuiComponentProps<ComponentProps<\"td\">, TdSlots> {}\n\nfunction Td(rawProps: TdProps): ReactElement {\n const { children, ...restProps } = useHuiProps(\"TableTd\", rawProps);\n\n const recipe = tdRecipe({});\n const cls = useHuiClassNames(\"TableTd\", recipe, rawProps);\n const sls = useHuiStyles(\"TableTd\", rawProps);\n\n return (\n <td\n className={cls.root}\n style={sls.root}\n {...restProps}\n >\n {children}\n </td>\n );\n}\n\nexport const Table = Object.assign(TableRoot, {\n Caption,\n Thead,\n Tbody,\n Tfoot,\n Tr,\n Th,\n Td,\n});\n"],"mappings":"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"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { createContext, useContext } from "react";
|
|
2
|
-
|
|
2
|
+
// src/components/tabs/tabs.context.ts
|
|
3
3
|
const TabsContext = createContext(null);
|
|
4
4
|
function useTabsContext() {
|
|
5
5
|
const context = useContext(TabsContext);
|
|
6
6
|
if (!context) throw new Error("[Hebium UI] Tabs compound components must be used within <Tabs>");
|
|
7
7
|
return context;
|
|
8
8
|
}
|
|
9
|
-
//#endregion
|
|
10
9
|
export { TabsContext, useTabsContext };
|
|
11
10
|
|
|
12
11
|
//# sourceMappingURL=tabs.context.js.map
|
|
@@ -3,12 +3,11 @@ import "../../types/index.js";
|
|
|
3
3
|
import { ActivationMode } from "./tabs.context.js";
|
|
4
4
|
import { TabSlots, TablistSlots, TabpanelSlots, TabrootSlots } from "@hebium-ui/core";
|
|
5
5
|
import { ElementType, ReactElement } from "react";
|
|
6
|
-
//#region src/components/tabs/tabs.d.ts
|
|
7
6
|
interface TabsOwnProps<V extends string> {
|
|
8
7
|
/**
|
|
9
8
|
* The list of allowed tab values.
|
|
10
9
|
*/
|
|
11
|
-
values: V[];
|
|
10
|
+
values: readonly V[];
|
|
12
11
|
/**
|
|
13
12
|
* The currently selected tab value.
|
|
14
13
|
*/
|
|
@@ -55,6 +54,4 @@ export declare const Tabs: typeof TabsRoot & {
|
|
|
55
54
|
Tab: typeof Tab;
|
|
56
55
|
Panel: typeof Panel;
|
|
57
56
|
};
|
|
58
|
-
|
|
59
|
-
export {};
|
|
60
|
-
//# sourceMappingURL=tabs.d.ts.map
|
|
57
|
+
export {};
|
|
@@ -4,17 +4,17 @@ import { TabsContext, useTabsContext } from "./tabs.context.js";
|
|
|
4
4
|
import { tabRecipe, tablistRecipe, tabpanelRecipe, tabrootRecipe, tabsControl } from "@hebium-ui/core";
|
|
5
5
|
import { useCallback, useId, useMemo, useState } from "react";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
|
-
|
|
7
|
+
// src/components/tabs/tabs.tsx
|
|
8
8
|
function TabsRoot(rawProps) {
|
|
9
|
-
const { as, id, values, value, defaultValue, onChange,
|
|
9
|
+
const { as, id, values, value, defaultValue, onChange, children, activation = "manual", ...restProps } = useHuiProps("Tabs", rawProps);
|
|
10
10
|
const Component = as ?? "div";
|
|
11
11
|
const tmpId = useId();
|
|
12
12
|
const rootId = id || tmpId;
|
|
13
13
|
const [uncontrolledValue, setUncontrolledValue] = useState(() => value ?? defaultValue ?? values[0]);
|
|
14
14
|
const selectedValue = value ?? uncontrolledValue;
|
|
15
15
|
const recipe = tabrootRecipe({});
|
|
16
|
-
const cls = useHuiClassNames("Tabs", recipe,
|
|
17
|
-
const sls = useHuiStyles("Tabs",
|
|
16
|
+
const cls = useHuiClassNames("Tabs", recipe, rawProps);
|
|
17
|
+
const sls = useHuiStyles("Tabs", rawProps);
|
|
18
18
|
const onSelect = useCallback((nextValue) => {
|
|
19
19
|
if (!values.includes(nextValue)) throw new Error(`[Hebium UI] Unexpected Tab value: ${nextValue}`);
|
|
20
20
|
const v = nextValue;
|
|
@@ -48,11 +48,11 @@ function TabsRoot(rawProps) {
|
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
function List(rawProps) {
|
|
51
|
-
const { as,
|
|
51
|
+
const { as, children, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...restProps } = useHuiProps("TabsList", rawProps);
|
|
52
52
|
const Component = as ?? "div";
|
|
53
53
|
const recipe = tablistRecipe({});
|
|
54
|
-
const cls = useHuiClassNames("TabsList", recipe,
|
|
55
|
-
const sls = useHuiStyles("TabsList",
|
|
54
|
+
const cls = useHuiClassNames("TabsList", recipe, rawProps);
|
|
55
|
+
const sls = useHuiStyles("TabsList", rawProps);
|
|
56
56
|
const { rootId, selectedValue } = useTabsContext();
|
|
57
57
|
const attrs = normalizeAttributes(tabsControl.getListAttributes({
|
|
58
58
|
rootId,
|
|
@@ -70,12 +70,12 @@ function List(rawProps) {
|
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
function Tab(rawProps) {
|
|
73
|
-
const { as, value,
|
|
73
|
+
const { as, value, children, onClick, onKeyDown, onFocus, ...restProps } = useHuiProps("TabsTab", rawProps);
|
|
74
74
|
const Component = as ?? "button";
|
|
75
75
|
const { rootId, selectedValue, onSelect, activation } = useTabsContext();
|
|
76
76
|
const recipe = tabRecipe({});
|
|
77
|
-
const cls = useHuiClassNames("TabsTab", recipe,
|
|
78
|
-
const sls = useHuiStyles("TabsTab",
|
|
77
|
+
const cls = useHuiClassNames("TabsTab", recipe, rawProps);
|
|
78
|
+
const sls = useHuiStyles("TabsTab", rawProps);
|
|
79
79
|
const attrs = normalizeAttributes(tabsControl.getTabAttributes({
|
|
80
80
|
rootId,
|
|
81
81
|
selectedValue
|
|
@@ -129,12 +129,12 @@ function Tab(rawProps) {
|
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
131
|
function Panel(rawProps) {
|
|
132
|
-
const { as, value,
|
|
132
|
+
const { as, value, children, ...restProps } = useHuiProps("TabsPanel", rawProps);
|
|
133
133
|
const Component = as ?? "div";
|
|
134
134
|
const { rootId, selectedValue } = useTabsContext();
|
|
135
135
|
const recipe = tabpanelRecipe({});
|
|
136
|
-
const cls = useHuiClassNames("TabsPanel", recipe,
|
|
137
|
-
const sls = useHuiStyles("TabsPanel",
|
|
136
|
+
const cls = useHuiClassNames("TabsPanel", recipe, rawProps);
|
|
137
|
+
const sls = useHuiStyles("TabsPanel", rawProps);
|
|
138
138
|
const attrs = normalizeAttributes(tabsControl.getPanelAttributes({
|
|
139
139
|
rootId,
|
|
140
140
|
selectedValue
|
|
@@ -152,7 +152,6 @@ const Tabs = Object.assign(TabsRoot, {
|
|
|
152
152
|
Tab,
|
|
153
153
|
Panel
|
|
154
154
|
});
|
|
155
|
-
//#endregion
|
|
156
155
|
export { Tabs };
|
|
157
156
|
|
|
158
157
|
//# sourceMappingURL=tabs.js.map
|
|
@@ -1 +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":";;;;;;;AA0DA,SAAS,SACP,UACc;CACd,MAAM,EACJ,IACA,IACA,QACA,OACA,cACA,UACA,WACA,OACA,UACA,aAAa,UACb,GAAG,cACD,YAAY,QAAQ,QAAQ;CAEhC,MAAM,YAAY,MAAM;CAExB,MAAM,QAAQ,MAAM;CACpB,MAAM,SAAS,MAAM;CACrB,MAAM,CAAC,mBAAmB,wBAAwB,eAC1C,SAAS,gBAAgB,OAAO,EACxC;CACA,MAAM,gBAAgB,SAAS;CAC/B,MAAM,SAAS,cAAc,CAAC,CAAC;CAC/B,MAAM,MAAM,iBAAiB,QAAQ,QAAQ,EAAE,MAAM,UAAU,CAAC;CAChE,MAAM,MAAM,aAAa,QAAQ,EAAE,MAAM,MAAM,CAAC;CAEhD,MAAM,WAAW,aACd,cAAsB;EACrB,IAAI,CAAE,OAAoB,SAAS,SAAS,GAC1C,MAAM,IAAI,MAAM,qCAAqC,WAAW;EAGlE,MAAM,IAAI;EACV,qBAAqB,CAAC;EACtB,WAAW,CAAC;CACd,GACA,CAAC,UAAU,MAAM,CACnB;CAEA,MAAM,eAAe,eACZ;EACL;EACA;EACA;EACA;CACF,IACA;EACE;EACA;EACA;EACA;CACF,CACF;CACA,MAAM,QAAQ,oBAAoB,YAAY,kBAAkB;EAAE;EAAQ;CAAc,CAAC,CAAC;CAE1F,OACE,oBAAC,YAAY,UAAb;EAAsB,OAAO;EAC3B,UAAA,oBAAC,WAAD;GACE,WAAW,IAAI;GACf,OAAO,IAAI;GACX,GAAI;GACJ,GAAI;GAEH;EACQ,CAAA;CACS,CAAA;AAE1B;AASA,SAAS,KAAoC,UAA0C;CACrF,MAAM,EACJ,IACA,WACA,OACA,UACA,cAAc,WACd,mBAAmB,gBACnB,GAAG,cACD,YAAY,YAAY,QAAQ;CAEpC,MAAM,YAAY,MAAM;CAExB,MAAM,SAAS,cAAc,CAAC,CAAC;CAC/B,MAAM,MAAM,iBAAiB,YAAY,QAAQ,EAAE,MAAM,UAAU,CAAC;CACpE,MAAM,MAAM,aAAa,YAAY,EAAE,MAAM,MAAM,CAAC;CACpD,MAAM,EAAE,QAAQ,kBAAkB,eAAe;CACjD,MAAM,QAAQ,oBACZ,YAAY,kBACV;EAAE;EAAQ;CAAc,GACxB;EAAE;EAAW;CAAe,CAC9B,CACF;CAEA,OACE,oBAAC,WAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EACJ,GAAI;EAEH;CACQ,CAAA;AAEf;AAcA,SAAS,IAAsC,UAAyC;CACtF,MAAM,EACJ,IACA,OACA,WACA,OACA,UACA,SACA,WACA,SACA,GAAG,cACD,YAAY,WAAW,QAAQ;CAEnC,MAAM,YAAY,MAAM;CAExB,MAAM,EAAE,QAAQ,eAAe,UAAU,eAAe,eAAe;CACvE,MAAM,SAAS,UAAU,CAAC,CAAC;CAC3B,MAAM,MAAM,iBAAiB,WAAW,QAAQ,EAAE,MAAM,UAAU,CAAC;CACnE,MAAM,MAAM,aAAa,WAAW,EAAE,MAAM,MAAM,CAAC;CACnD,MAAM,QAAQ,oBACZ,YAAY,iBACV;EAAE;EAAQ;CAAc,GACxB,OACA,EAAE,iBAAiB,OAAO,KAAA,EAAU,CACtC,CACF;CAEA,MAAM,cAAc,aACjB,MAA2C;EAC1C,UAAU,CAAC;EACX,IAAI,EAAE,kBAAkB;EACxB,SAAS,KAAK;CAChB,GACA;EAAC;EAAS;EAAU;CAAK,CAC3B;CAEA,MAAM,gBAAgB,aACnB,MAA8C;EAC7C,YAAY,CAAC;EACb,IAAI,EAAE,kBAAkB;EAGxB,QADe,YAAY,iBAAiB,EAAE,WACjC,GAAb;GACE,KAAK;IACH,SAAS,KAAK;IACd;GACF,KAAK;IACH,YAAY,UAAU,EAAE,aAAa,MAAM;IAC3C;GACF,KAAK,QACH;EACJ;CACF,GACA;EAAC;EAAW;EAAU;EAAQ;CAAK,CACrC;CAEA,MAAM,cAAc,aAAa,MAAkD;EACjF,UAAU,CAAC;EACX,IAAI,EAAE,kBAAkB;EAExB,IAAI,eAAe,QACjB,SAAS,KAAK;CAElB,GAAG;EAAC;EAAS;EAAU;EAAY;CAAK,CAAC;CAEzC,OACE,oBAAC,WAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EACJ,SAAS;EACT,WAAW;EACX,SAAS;EACT,GAAI;EAEH;CACQ,CAAA;AAEf;AAcA,SAAS,MAAqC,UAA2C;CACvF,MAAM,EACJ,IACA,OACA,WACA,OACA,UACA,GAAG,cACD,YAAY,aAAa,QAAQ;CAErC,MAAM,YAAY,MAAM;CAExB,MAAM,EAAE,QAAQ,kBAAkB,eAAe;CACjD,MAAM,SAAS,eAAe,CAAC,CAAC;CAChC,MAAM,MAAM,iBAAiB,aAAa,QAAQ,EAAE,MAAM,UAAU,CAAC;CACrE,MAAM,MAAM,aAAa,aAAa,EAAE,MAAM,MAAM,CAAC;CACrD,MAAM,QAAQ,oBAAoB,YAAY,mBAAmB;EAAE;EAAQ;CAAc,GAAG,KAAK,CAAC;CAElG,OACE,oBAAC,WAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EACJ,GAAI;EAEH;CACQ,CAAA;AAEf;AAEA,MAAa,OAAO,OAAO,OAAO,UAAU;CAC1C;CACA;CACA;AACF,CAAC"}
|
|
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: readonly 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 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, rawProps);\n const sls = useHuiStyles(\"Tabs\", rawProps);\n\n const onSelect = useCallback(\n (nextValue: string) => {\n if (!(values as readonly 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 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, rawProps);\n const sls = useHuiStyles(\"TabsList\", rawProps);\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 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, rawProps);\n const sls = useHuiStyles(\"TabsTab\", rawProps);\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 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, rawProps);\n const sls = useHuiStyles(\"TabsPanel\", rawProps);\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,39 @@
|
|
|
1
|
+
import { HuiComponentProps } from "../../types/hui-component.js";
|
|
2
|
+
import "../../types/index.js";
|
|
3
|
+
import { TagSlots, TagVariants } from "@hebium-ui/core";
|
|
4
|
+
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
5
|
+
interface TagOwnProps extends Omit<ComponentProps<"span">, "color" | "children"> {
|
|
6
|
+
/**
|
|
7
|
+
* The tag text.
|
|
8
|
+
*/
|
|
9
|
+
label: string;
|
|
10
|
+
/**
|
|
11
|
+
* The semantic color of the tag.
|
|
12
|
+
*
|
|
13
|
+
* @default "text"
|
|
14
|
+
*/
|
|
15
|
+
color?: TagVariants["color"] | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* How overflowing label text is displayed.
|
|
18
|
+
*
|
|
19
|
+
* @default "unset"
|
|
20
|
+
*/
|
|
21
|
+
textOverflow?: TagVariants["textOverflow"] | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* The content of the remove button. Set to `null` or `false` to hide the button.
|
|
24
|
+
*
|
|
25
|
+
* @default close icon
|
|
26
|
+
*/
|
|
27
|
+
removeButton?: ReactNode | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Props forwarded to the remove button, overriding its defaults.
|
|
30
|
+
*/
|
|
31
|
+
removeButtonProps?: Omit<ComponentProps<"button">, "children" | "className" | "style"> | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Called when the remove button is activated. Overridden by `removeButtonProps.onClick`.
|
|
34
|
+
*/
|
|
35
|
+
onRemove?: (() => void) | undefined;
|
|
36
|
+
}
|
|
37
|
+
export type TagProps = HuiComponentProps<TagOwnProps, TagSlots>;
|
|
38
|
+
export declare function Tag(rawProps: TagProps): ReactElement;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
|
|
2
|
+
import { tagRecipe, toStrbool } from "@hebium-ui/core";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
// src/components/tag/tag.tsx
|
|
5
|
+
function Tag(rawProps) {
|
|
6
|
+
const { label, color, textOverflow, removeButton, removeButtonProps, onRemove, ...restProps } = useHuiProps("Tag", rawProps);
|
|
7
|
+
const shouldRenderRemoveButton = removeButton !== null && removeButton !== false;
|
|
8
|
+
const recipe = tagRecipe({
|
|
9
|
+
color,
|
|
10
|
+
textOverflow,
|
|
11
|
+
withRemoveButton: toStrbool(shouldRenderRemoveButton)
|
|
12
|
+
});
|
|
13
|
+
const cls = useHuiClassNames("Tag", recipe, rawProps);
|
|
14
|
+
const sls = useHuiStyles("Tag", rawProps);
|
|
15
|
+
const removeButtonContent = removeButton === void 0 ? /* @__PURE__ */ jsx("span", {
|
|
16
|
+
"aria-hidden": true,
|
|
17
|
+
className: cls.removeButtonIcon,
|
|
18
|
+
style: sls.removeButtonIcon
|
|
19
|
+
}) : removeButton;
|
|
20
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
21
|
+
className: cls.root,
|
|
22
|
+
style: sls.root,
|
|
23
|
+
...restProps,
|
|
24
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
25
|
+
className: cls.label,
|
|
26
|
+
style: sls.label,
|
|
27
|
+
children: label
|
|
28
|
+
}), shouldRenderRemoveButton && /* @__PURE__ */ jsx("button", {
|
|
29
|
+
type: "button",
|
|
30
|
+
className: cls.removeButton,
|
|
31
|
+
style: sls.removeButton,
|
|
32
|
+
"aria-label": `Remove ${label} Tag`,
|
|
33
|
+
onClick: onRemove,
|
|
34
|
+
...removeButtonProps,
|
|
35
|
+
children: removeButtonContent
|
|
36
|
+
})]
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
export { Tag };
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=tag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tag.js","names":[],"sources":["../../../src/components/tag/tag.tsx"],"sourcesContent":["import { tagRecipe, type TagSlots, type TagVariants, toStrbool } from \"@hebium-ui/core\";\nimport { type ComponentProps, type ReactElement, type ReactNode } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps } from \"~/types\";\n\ninterface TagOwnProps extends Omit<ComponentProps<\"span\">, \"color\" | \"children\"> {\n /**\n * The tag text.\n */\n label: string;\n /**\n * The semantic color of the tag.\n *\n * @default \"text\"\n */\n color?: TagVariants[\"color\"] | undefined;\n /**\n * How overflowing label text is displayed.\n *\n * @default \"unset\"\n */\n textOverflow?: TagVariants[\"textOverflow\"] | undefined;\n /**\n * The content of the remove button. Set to `null` or `false` to hide the button.\n *\n * @default close icon\n */\n removeButton?: ReactNode | undefined;\n /**\n * Props forwarded to the remove button, overriding its defaults.\n */\n removeButtonProps?: Omit<ComponentProps<\"button\">, \"children\" | \"className\" | \"style\"> | undefined;\n /**\n * Called when the remove button is activated. Overridden by `removeButtonProps.onClick`.\n */\n onRemove?: (() => void) | undefined;\n}\n\nexport type TagProps = HuiComponentProps<TagOwnProps, TagSlots>;\n\nexport function Tag(rawProps: TagProps): ReactElement {\n const {\n label,\n color,\n textOverflow,\n removeButton,\n removeButtonProps,\n onRemove,\n ...restProps\n } = useHuiProps(\"Tag\", rawProps);\n\n const shouldRenderRemoveButton = removeButton !== null && removeButton !== false;\n const recipe = tagRecipe({\n color,\n textOverflow,\n withRemoveButton: toStrbool(shouldRenderRemoveButton),\n });\n const cls = useHuiClassNames(\"Tag\", recipe, rawProps);\n const sls = useHuiStyles(\"Tag\", rawProps);\n\n const removeButtonContent = removeButton === undefined\n ? <span aria-hidden className={cls.removeButtonIcon} style={sls.removeButtonIcon} />\n : removeButton;\n\n return (\n <span\n className={cls.root}\n style={sls.root}\n {...restProps}\n >\n <span\n className={cls.label}\n style={sls.label}\n >\n {label}\n </span>\n {shouldRenderRemoveButton && (\n <button\n type=\"button\"\n className={cls.removeButton}\n style={sls.removeButton}\n aria-label={`Remove ${label} Tag`}\n onClick={onRemove}\n {...removeButtonProps}\n >\n {removeButtonContent}\n </button>\n )}\n </span>\n );\n}\n"],"mappings":";;;;AAwCA,SAAgB,IAAI,UAAkC;CACpD,MAAM,EACJ,OACA,OACA,cACA,cACA,mBACA,UACA,GAAG,cACD,YAAY,OAAO,QAAQ;CAE/B,MAAM,2BAA2B,iBAAiB,QAAQ,iBAAiB;CAC3E,MAAM,SAAS,UAAU;EACvB;EACA;EACA,kBAAkB,UAAU,wBAAwB;CACtD,CAAC;CACD,MAAM,MAAM,iBAAiB,OAAO,QAAQ,QAAQ;CACpD,MAAM,MAAM,aAAa,OAAO,QAAQ;CAExC,MAAM,sBAAsB,iBAAiB,KAAA,IACzC,oBAAC,QAAD;EAAM,eAAA;EAAY,WAAW,IAAI;EAAkB,OAAO,IAAI;CAAmB,CAAA,IACjF;CAEJ,OACE,qBAAC,QAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EAHN,UAAA,CAKE,oBAAC,QAAD;GACE,WAAW,IAAI;GACf,OAAO,IAAI;GAEV,UAAA;EACG,CAAA,GACL,4BACC,oBAAC,UAAD;GACE,MAAK;GACL,WAAW,IAAI;GACf,OAAO,IAAI;GACX,cAAY,UAAU,MAAM;GAC5B,SAAS;GACT,GAAI;GAEH,UAAA;EACK,CAAA,CAEN;;AAEV"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { HuiPolymorphicProps } from "../../types/polymorphic.js";
|
|
2
|
+
import "../../types/index.js";
|
|
3
|
+
import { TextSlots, TextVariants } from "@hebium-ui/core";
|
|
4
|
+
import { ElementType, ReactElement } from "react";
|
|
5
|
+
interface TextOwnProps {
|
|
6
|
+
/**
|
|
7
|
+
* The semantic color of the text.
|
|
8
|
+
*
|
|
9
|
+
* @default "text"
|
|
10
|
+
*/
|
|
11
|
+
color?: TextVariants["color"] | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* How overflowing text is displayed.
|
|
14
|
+
* Use "ellipsis" to truncate text to a single line with an ellipsis.
|
|
15
|
+
*
|
|
16
|
+
* @default "unset"
|
|
17
|
+
*/
|
|
18
|
+
textOverflow?: TextVariants["textOverflow"] | undefined;
|
|
19
|
+
}
|
|
20
|
+
export type TextProps<E extends ElementType = "span"> = HuiPolymorphicProps<E, TextOwnProps, TextSlots>;
|
|
21
|
+
export declare function Text<E extends ElementType = "span">(rawProps: TextProps<E>): ReactElement;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
|
|
2
|
+
import { textRecipe } from "@hebium-ui/core";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
// src/components/text/text.tsx
|
|
5
|
+
function Text(rawProps) {
|
|
6
|
+
const { as, color, textOverflow, children, ...restProps } = useHuiProps("Text", rawProps);
|
|
7
|
+
const Component = as ?? "span";
|
|
8
|
+
const recipe = textRecipe({
|
|
9
|
+
color,
|
|
10
|
+
textOverflow
|
|
11
|
+
});
|
|
12
|
+
const cls = useHuiClassNames("Text", recipe, rawProps);
|
|
13
|
+
const sls = useHuiStyles("Text", rawProps);
|
|
14
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
15
|
+
className: cls.root,
|
|
16
|
+
style: sls.root,
|
|
17
|
+
...restProps,
|
|
18
|
+
children
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export { Text };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.js","names":[],"sources":["../../../src/components/text/text.tsx"],"sourcesContent":["import { textRecipe, type TextSlots, type TextVariants } from \"@hebium-ui/core\";\nimport { type ElementType, type ReactElement } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\n\ninterface TextOwnProps {\n /**\n * The semantic color of the text.\n *\n * @default \"text\"\n */\n color?: TextVariants[\"color\"] | undefined;\n /**\n * How overflowing text is displayed.\n * Use \"ellipsis\" to truncate text to a single line with an ellipsis.\n *\n * @default \"unset\"\n */\n textOverflow?: TextVariants[\"textOverflow\"] | undefined;\n}\n\nexport type TextProps<E extends ElementType = \"span\"> = HuiPolymorphicProps<\n E,\n TextOwnProps,\n TextSlots\n>;\n\nexport function Text<E extends ElementType = \"span\">(rawProps: TextProps<E>): ReactElement {\n const {\n as,\n color,\n textOverflow,\n children,\n ...restProps\n } = useHuiProps(\"Text\", rawProps);\n\n const Component = as ?? \"span\";\n const recipe = textRecipe({\n color,\n textOverflow,\n });\n const cls = useHuiClassNames(\"Text\", recipe, rawProps);\n const sls = useHuiStyles(\"Text\", rawProps);\n\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n"],"mappings":";;;;AA2BA,SAAgB,KAAqC,UAAsC;CACzF,MAAM,EACJ,IACA,OACA,cACA,UACA,GAAG,cACD,YAAY,QAAQ,QAAQ;CAEhC,MAAM,YAAY,MAAM;CACxB,MAAM,SAAS,WAAW;EACxB;EACA;CACF,CAAC;CACD,MAAM,MAAM,iBAAiB,QAAQ,QAAQ,QAAQ;CACrD,MAAM,MAAM,aAAa,QAAQ,QAAQ;CAEzC,OACE,oBAAC,WAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EAEH;CACQ,CAAA;AAEf"}
|
|
@@ -4,7 +4,6 @@ import { LabelProps } from "../label/label.js";
|
|
|
4
4
|
import "../label/index.js";
|
|
5
5
|
import { InputSlots, InputVariants } from "@hebium-ui/core";
|
|
6
6
|
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
7
|
-
//#region src/components/textarea/textarea.d.ts
|
|
8
7
|
type HtmlTextareaProps = Omit<ComponentProps<"textarea">, "children" | "color">;
|
|
9
8
|
interface TextareaOwnProps extends HtmlTextareaProps {
|
|
10
9
|
/**
|
|
@@ -32,6 +31,4 @@ interface TextareaOwnProps extends HtmlTextareaProps {
|
|
|
32
31
|
}
|
|
33
32
|
export type TextareaProps = HuiComponentProps<TextareaOwnProps, InputSlots>;
|
|
34
33
|
export declare function Textarea(rawProps: TextareaProps): ReactElement;
|
|
35
|
-
|
|
36
|
-
export {};
|
|
37
|
-
//# sourceMappingURL=textarea.d.ts.map
|
|
34
|
+
export {};
|
|
@@ -4,9 +4,9 @@ import { Label } from "../label/label.js";
|
|
|
4
4
|
import { inputControl, inputRecipe, toBool, toStrbool } from "@hebium-ui/core";
|
|
5
5
|
import { useId } from "react";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
|
|
7
|
+
// src/components/textarea/textarea.tsx
|
|
8
8
|
function Textarea(rawProps) {
|
|
9
|
-
const { id,
|
|
9
|
+
const { id, color, label, description, error, labelProps, ...restProps } = useHuiProps("Textarea", rawProps);
|
|
10
10
|
const tmpId = useId();
|
|
11
11
|
const inputState = {
|
|
12
12
|
id: id || tmpId,
|
|
@@ -20,8 +20,8 @@ function Textarea(rawProps) {
|
|
|
20
20
|
height: "auto",
|
|
21
21
|
error: toStrbool(inputState.invalid)
|
|
22
22
|
});
|
|
23
|
-
const cls = useHuiClassNames("Textarea", recipe,
|
|
24
|
-
const sls = useHuiStyles("Textarea",
|
|
23
|
+
const cls = useHuiClassNames("Textarea", recipe, rawProps);
|
|
24
|
+
const sls = useHuiStyles("Textarea", rawProps);
|
|
25
25
|
const hasLabel = !!label || !!description || !!error;
|
|
26
26
|
const controlAttrs = normalizeAttributes(inputControl.getControlAttributes(inputState));
|
|
27
27
|
const labelAttrs = normalizeAttributes(inputControl.getLabelAttributes(inputState));
|
|
@@ -42,7 +42,6 @@ function Textarea(rawProps) {
|
|
|
42
42
|
})]
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
|
-
//#endregion
|
|
46
45
|
export { Textarea };
|
|
47
46
|
|
|
48
47
|
//# sourceMappingURL=textarea.js.map
|