@hebium-ui/react 0.1.0-alpha.2 → 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 +0 -2
- package/dist/components/paragraph/paragraph.js +4 -5
- 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 +4 -4
|
@@ -2,7 +2,6 @@ import { HuiPolymorphicProps } from "../../types/polymorphic.js";
|
|
|
2
2
|
import "../../types/index.js";
|
|
3
3
|
import { SectionSlots, SectionVariants } from "@hebium-ui/core";
|
|
4
4
|
import { ElementType, ReactElement } from "react";
|
|
5
|
-
//#region src/components/section/section.d.ts
|
|
6
5
|
interface SectionOwnProps {
|
|
7
6
|
/**
|
|
8
7
|
* The background color of the section.
|
|
@@ -31,6 +30,5 @@ interface SectionOwnProps {
|
|
|
31
30
|
}
|
|
32
31
|
export type SectionProps<E extends ElementType = "section"> = HuiPolymorphicProps<E, SectionOwnProps, SectionSlots>;
|
|
33
32
|
export declare function Section<E extends ElementType = "section">(rawProps: SectionProps<E>): ReactElement;
|
|
34
|
-
//#endregion
|
|
35
33
|
export {};
|
|
36
34
|
//# sourceMappingURL=section.d.ts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
|
|
2
2
|
import { sectionRecipe } from "@hebium-ui/core";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
|
|
4
|
+
// src/components/section/section.tsx
|
|
5
5
|
function Section(rawProps) {
|
|
6
|
-
const { as, bg, radius, padding, border,
|
|
6
|
+
const { as, bg, radius, padding, border, children, ...restProps } = useHuiProps("Section", rawProps);
|
|
7
7
|
const recipe = sectionRecipe({
|
|
8
8
|
bg,
|
|
9
9
|
radius,
|
|
@@ -11,8 +11,8 @@ function Section(rawProps) {
|
|
|
11
11
|
border
|
|
12
12
|
});
|
|
13
13
|
const Component = as ?? "section";
|
|
14
|
-
const cls = useHuiClassNames("Section", recipe, { root: className });
|
|
15
|
-
const sls = useHuiStyles("Section", { root: style });
|
|
14
|
+
const cls = useHuiClassNames("Section", recipe, { root: rawProps["className"] });
|
|
15
|
+
const sls = useHuiStyles("Section", { root: rawProps["style"] });
|
|
16
16
|
return /* @__PURE__ */ jsx(Component, {
|
|
17
17
|
className: cls.root,
|
|
18
18
|
style: sls.root,
|
|
@@ -20,7 +20,6 @@ function Section(rawProps) {
|
|
|
20
20
|
children
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
|
-
//#endregion
|
|
24
23
|
export { Section };
|
|
25
24
|
|
|
26
25
|
//# sourceMappingURL=section.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"section.js","names":[],"sources":["../../../src/components/section/section.tsx"],"sourcesContent":["import { sectionRecipe, type SectionSlots, type SectionVariants } from \"@hebium-ui/core\";\nimport { type ElementType, type ReactElement } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\n\ninterface SectionOwnProps {\n /**\n * The background color of the section.\n *\n * @default \"section\"\n */\n bg?: SectionVariants[\"bg\"] | undefined;\n /**\n * The border radius of the section.\n *\n * @default \"base\"\n */\n radius?: SectionVariants[\"radius\"] | undefined;\n /**\n * The padding size of the section.\n *\n * @default \"sm\"\n */\n padding?: SectionVariants[\"padding\"] | undefined;\n /**\n * The border style of the section.\n *\n * @default \"none\"\n */\n border?: SectionVariants[\"border\"] | undefined;\n}\n\nexport type SectionProps<E extends ElementType = \"section\"> = HuiPolymorphicProps<\n E,\n SectionOwnProps,\n SectionSlots\n>;\n\nexport function Section<E extends ElementType = \"section\">(rawProps: SectionProps<E>): ReactElement {\n const {\n as,\n bg,\n radius,\n padding,\n border,\n
|
|
1
|
+
{"version":3,"file":"section.js","names":[],"sources":["../../../src/components/section/section.tsx"],"sourcesContent":["import { sectionRecipe, type SectionSlots, type SectionVariants } from \"@hebium-ui/core\";\nimport { type ElementType, type ReactElement } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\n\ninterface SectionOwnProps {\n /**\n * The background color of the section.\n *\n * @default \"section\"\n */\n bg?: SectionVariants[\"bg\"] | undefined;\n /**\n * The border radius of the section.\n *\n * @default \"base\"\n */\n radius?: SectionVariants[\"radius\"] | undefined;\n /**\n * The padding size of the section.\n *\n * @default \"sm\"\n */\n padding?: SectionVariants[\"padding\"] | undefined;\n /**\n * The border style of the section.\n *\n * @default \"none\"\n */\n border?: SectionVariants[\"border\"] | undefined;\n}\n\nexport type SectionProps<E extends ElementType = \"section\"> = HuiPolymorphicProps<\n E,\n SectionOwnProps,\n SectionSlots\n>;\n\nexport function Section<E extends ElementType = \"section\">(rawProps: SectionProps<E>): ReactElement {\n const {\n as,\n bg,\n radius,\n padding,\n border,\n children,\n ...restProps\n } = useHuiProps(\"Section\", rawProps);\n\n const recipe = sectionRecipe({ bg, radius, padding, border });\n const Component = as ?? \"section\";\n const cls = useHuiClassNames(\"Section\", recipe, { root: rawProps[\"className\"] });\n const sls = useHuiStyles(\"Section\", { 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":";;;;AAsCA,SAAgB,QAA2C,UAAyC;CAClG,MAAM,EACJ,IACA,IACA,QACA,SACA,QACA,UACA,GAAG,cACD,YAAY,WAAW,QAAQ;CAEnC,MAAM,SAAS,cAAc;EAAE;EAAI;EAAQ;EAAS;CAAO,CAAC;CAC5D,MAAM,YAAY,MAAM;CACxB,MAAM,MAAM,iBAAiB,WAAW,QAAQ,EAAE,MAAM,SAAS,aAAa,CAAC;CAC/E,MAAM,MAAM,aAAa,WAAW,EAAE,MAAM,SAAS,SAAS,CAAC;CAE/D,OACE,oBAAC,WAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EAEH;CACQ,CAAA;AAEf"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { createContext, useContext } from "react";
|
|
2
|
-
|
|
2
|
+
// src/components/segmented-control/segmented-control.context.ts
|
|
3
3
|
const SegmentedControlContext = createContext(null);
|
|
4
4
|
function useSegmentedControlContext() {
|
|
5
5
|
const context = useContext(SegmentedControlContext);
|
|
6
6
|
if (!context) throw new Error("[Hebium UI] SegmentedControl compound components must be used within <SegmentedControl>");
|
|
7
7
|
return context;
|
|
8
8
|
}
|
|
9
|
-
//#endregion
|
|
10
9
|
export { SegmentedControlContext, useSegmentedControlContext };
|
|
11
10
|
|
|
12
11
|
//# sourceMappingURL=segmented-control.context.js.map
|
|
@@ -3,13 +3,12 @@ import { HuiPolymorphicProps } from "../../types/polymorphic.js";
|
|
|
3
3
|
import "../../types/index.js";
|
|
4
4
|
import { SegmentedControlItemSlots, SegmentedControlRootSlots } from "@hebium-ui/core";
|
|
5
5
|
import { ComponentProps, ElementType, ReactElement } from "react";
|
|
6
|
-
//#region src/components/segmented-control/segmented-control.d.ts
|
|
7
6
|
type HtmlUlProps = Omit<ComponentProps<"ul">, "onChange">;
|
|
8
7
|
interface SegmentedControlOwnProps<V extends string> extends HtmlUlProps {
|
|
9
8
|
/**
|
|
10
9
|
* The list of allowed segmented-control values.
|
|
11
10
|
*/
|
|
12
|
-
values: V[];
|
|
11
|
+
values: readonly V[];
|
|
13
12
|
/**
|
|
14
13
|
* The currently selected segmented-control value.
|
|
15
14
|
*/
|
|
@@ -36,6 +35,5 @@ declare function Item<E extends ElementType = "button">(rawProps: SegmentedContr
|
|
|
36
35
|
export declare const SegmentedControl: typeof SegmentedControlRoot & {
|
|
37
36
|
Item: typeof Item;
|
|
38
37
|
};
|
|
39
|
-
//#endregion
|
|
40
38
|
export {};
|
|
41
39
|
//# sourceMappingURL=segmented-control.d.ts.map
|
|
@@ -4,14 +4,14 @@ import { SegmentedControlContext, useSegmentedControlContext } from "./segmented
|
|
|
4
4
|
import { segmentedControl, segmentedControlItemRecipe, segmentedControlRootRecipe } from "@hebium-ui/core";
|
|
5
5
|
import { useCallback, useMemo, useState } from "react";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
|
-
|
|
7
|
+
// src/components/segmented-control/segmented-control.tsx
|
|
8
8
|
function SegmentedControlRoot(rawProps) {
|
|
9
|
-
const { values, value, defaultValue, onChange,
|
|
9
|
+
const { values, value, defaultValue, onChange, children, ...restProps } = useHuiProps("SegmentedControl", rawProps);
|
|
10
10
|
const [uncontrolledValue, setUncontrolledValue] = useState(() => value ?? defaultValue ?? values[0]);
|
|
11
11
|
const selectedValue = value ?? uncontrolledValue;
|
|
12
12
|
const recipe = segmentedControlRootRecipe({});
|
|
13
|
-
const cls = useHuiClassNames("SegmentedControl", recipe, { root: className });
|
|
14
|
-
const sls = useHuiStyles("SegmentedControl", { root: style });
|
|
13
|
+
const cls = useHuiClassNames("SegmentedControl", recipe, { root: rawProps.className });
|
|
14
|
+
const sls = useHuiStyles("SegmentedControl", { root: rawProps.style });
|
|
15
15
|
const onSelect = useCallback((nextValue) => {
|
|
16
16
|
if (!values.includes(nextValue)) throw new Error(`[Hebium UI] Unexpected SegmentedControl value: ${nextValue}`);
|
|
17
17
|
const v = nextValue;
|
|
@@ -33,12 +33,12 @@ function SegmentedControlRoot(rawProps) {
|
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
function Item(rawProps) {
|
|
36
|
-
const { as, value,
|
|
36
|
+
const { as, value, children, onClick, ...restProps } = useHuiProps("SegmentedControlItem", rawProps);
|
|
37
37
|
const Component = as ?? "button";
|
|
38
38
|
const { selectedValue, onSelect } = useSegmentedControlContext();
|
|
39
39
|
const recipe = segmentedControlItemRecipe({});
|
|
40
|
-
const cls = useHuiClassNames("SegmentedControlItem", recipe, { root: className });
|
|
41
|
-
const sls = useHuiStyles("SegmentedControlItem", { root: style });
|
|
40
|
+
const cls = useHuiClassNames("SegmentedControlItem", recipe, { root: rawProps["className"] });
|
|
41
|
+
const sls = useHuiStyles("SegmentedControlItem", { root: rawProps["style"] });
|
|
42
42
|
const attrs = normalizeAttributes(segmentedControl.getItemAttributes({
|
|
43
43
|
isButtonElement: typeof as === "undefined",
|
|
44
44
|
selectedValue
|
|
@@ -62,7 +62,6 @@ function Item(rawProps) {
|
|
|
62
62
|
}) });
|
|
63
63
|
}
|
|
64
64
|
const SegmentedControl = Object.assign(SegmentedControlRoot, { Item });
|
|
65
|
-
//#endregion
|
|
66
65
|
export { SegmentedControl };
|
|
67
66
|
|
|
68
67
|
//# sourceMappingURL=segmented-control.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"segmented-control.js","names":[],"sources":["../../../src/components/segmented-control/segmented-control.tsx"],"sourcesContent":["import {\n segmentedControl,\n segmentedControlItemRecipe,\n type SegmentedControlItemSlots,\n segmentedControlRootRecipe,\n type SegmentedControlRootSlots,\n} from \"@hebium-ui/core\";\nimport {\n type ComponentProps,\n type ElementType,\n type MouseEvent,\n type ReactElement,\n useCallback,\n useMemo,\n useState,\n} from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps, type HuiPolymorphicProps } from \"~/types\";\nimport { normalizeAttributes } from \"~/utils\";\nimport {\n SegmentedControlContext,\n type SegmentedControlContextValue,\n useSegmentedControlContext,\n} from \"./segmented-control.context\";\n\ntype HtmlUlProps = Omit<ComponentProps<\"ul\">, \"onChange\">;\n\ninterface SegmentedControlOwnProps<V extends string> extends HtmlUlProps {\n /**\n * The list of allowed segmented-control values.\n */\n values: V[];\n /**\n * The currently selected segmented-control value.\n */\n value?: V | undefined;\n /**\n * The initially selected segmented-control value for uncontrolled component.\n */\n defaultValue?: V | undefined;\n /**\n * Called when the selected segmented-control value changes.\n */\n onChange?: ((value: V) => void) | undefined;\n}\nexport type SegmentedControlProps<V extends string> = HuiComponentProps<\n SegmentedControlOwnProps<V>,\n SegmentedControlRootSlots\n>;\n\nfunction SegmentedControlRoot<V extends string>(\n rawProps: SegmentedControlProps<V>,\n): ReactElement {\n const {\n values,\n value,\n defaultValue,\n onChange,\n
|
|
1
|
+
{"version":3,"file":"segmented-control.js","names":[],"sources":["../../../src/components/segmented-control/segmented-control.tsx"],"sourcesContent":["import {\n segmentedControl,\n segmentedControlItemRecipe,\n type SegmentedControlItemSlots,\n segmentedControlRootRecipe,\n type SegmentedControlRootSlots,\n} from \"@hebium-ui/core\";\nimport {\n type ComponentProps,\n type ElementType,\n type MouseEvent,\n type ReactElement,\n useCallback,\n useMemo,\n useState,\n} from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps, type HuiPolymorphicProps } from \"~/types\";\nimport { normalizeAttributes } from \"~/utils\";\nimport {\n SegmentedControlContext,\n type SegmentedControlContextValue,\n useSegmentedControlContext,\n} from \"./segmented-control.context\";\n\ntype HtmlUlProps = Omit<ComponentProps<\"ul\">, \"onChange\">;\n\ninterface SegmentedControlOwnProps<V extends string> extends HtmlUlProps {\n /**\n * The list of allowed segmented-control values.\n */\n values: readonly V[];\n /**\n * The currently selected segmented-control value.\n */\n value?: V | undefined;\n /**\n * The initially selected segmented-control value for uncontrolled component.\n */\n defaultValue?: V | undefined;\n /**\n * Called when the selected segmented-control value changes.\n */\n onChange?: ((value: V) => void) | undefined;\n}\nexport type SegmentedControlProps<V extends string> = HuiComponentProps<\n SegmentedControlOwnProps<V>,\n SegmentedControlRootSlots\n>;\n\nfunction SegmentedControlRoot<V extends string>(\n rawProps: SegmentedControlProps<V>,\n): ReactElement {\n const {\n values,\n value,\n defaultValue,\n onChange,\n children,\n ...restProps\n } = useHuiProps(\"SegmentedControl\", rawProps);\n\n const [uncontrolledValue, setUncontrolledValue] = useState<V | undefined>(\n () => value ?? defaultValue ?? values[0],\n );\n const selectedValue = value ?? uncontrolledValue;\n const recipe = segmentedControlRootRecipe({});\n const cls = useHuiClassNames(\"SegmentedControl\", recipe, { root: rawProps.className });\n const sls = useHuiStyles(\"SegmentedControl\", { root: rawProps.style });\n\n const onSelect = useCallback(\n (nextValue: string) => {\n if (!(values as readonly string[]).includes(nextValue)) {\n throw new Error(`[Hebium UI] Unexpected SegmentedControl 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<SegmentedControlContextValue>(\n () => ({\n selectedValue,\n onSelect,\n }),\n [\n selectedValue,\n onSelect,\n ],\n );\n\n return (\n <SegmentedControlContext.Provider value={contextValue}>\n <ul\n className={cls.root}\n style={sls.root}\n {...restProps}\n >\n {children}\n </ul>\n </SegmentedControlContext.Provider>\n );\n}\n\ninterface SegmentedControlItemOwnProps {\n /**\n * The value represented by this control.\n */\n value: string;\n}\nexport type SegmentedControlItemProps<E extends ElementType = \"button\"> = HuiPolymorphicProps<\n E,\n SegmentedControlItemOwnProps,\n SegmentedControlItemSlots\n>;\n\nfunction Item<E extends ElementType = \"button\">(rawProps: SegmentedControlItemProps<E>): ReactElement {\n const {\n as,\n value,\n children,\n onClick,\n ...restProps\n } = useHuiProps(\"SegmentedControlItem\", rawProps);\n\n const Component = as ?? \"button\";\n\n const { selectedValue, onSelect } = useSegmentedControlContext();\n const recipe = segmentedControlItemRecipe({});\n const cls = useHuiClassNames(\"SegmentedControlItem\", recipe, { root: rawProps[\"className\"] });\n const sls = useHuiStyles(\"SegmentedControlItem\", { root: rawProps[\"style\"] });\n const attrs = normalizeAttributes(\n segmentedControl.getItemAttributes({\n isButtonElement: typeof as === \"undefined\",\n selectedValue,\n }, value),\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 return (\n <li>\n <Component\n className={cls.root}\n style={sls.root}\n {...attrs}\n onClick={handleClick}\n {...restProps}\n >\n {children}\n </Component>\n </li>\n );\n}\n\nexport const SegmentedControl = Object.assign(SegmentedControlRoot, {\n Item,\n});\n"],"mappings":";;;;;;;AAkDA,SAAS,qBACP,UACc;CACd,MAAM,EACJ,QACA,OACA,cACA,UACA,UACA,GAAG,cACD,YAAY,oBAAoB,QAAQ;CAE5C,MAAM,CAAC,mBAAmB,wBAAwB,eAC1C,SAAS,gBAAgB,OAAO,EACxC;CACA,MAA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AAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EACJ,SAAS;EACT,GAAI;EAEH;CACQ,CAAA,EACT,CAAA;AAER;AAEA,MAAa,mBAAmB,OAAO,OAAO,sBAAsB,EAClE,KACF,CAAC"}
|
|
@@ -4,7 +4,6 @@ import { LabelProps } from "../label/label.js";
|
|
|
4
4
|
import "../label/index.js";
|
|
5
5
|
import { SelectSlots } from "@hebium-ui/core";
|
|
6
6
|
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
7
|
-
//#region src/components/select/select.d.ts
|
|
8
7
|
type HtmlSelectProps = ComponentProps<"select">;
|
|
9
8
|
interface SelectOwnProps extends HtmlSelectProps {
|
|
10
9
|
/**
|
|
@@ -26,6 +25,5 @@ interface SelectOwnProps extends HtmlSelectProps {
|
|
|
26
25
|
}
|
|
27
26
|
export type SelectProps = HuiComponentProps<SelectOwnProps, SelectSlots>;
|
|
28
27
|
export declare function Select(rawProps: SelectProps): ReactElement;
|
|
29
|
-
//#endregion
|
|
30
28
|
export {};
|
|
31
29
|
//# sourceMappingURL=select.d.ts.map
|
|
@@ -4,9 +4,9 @@ import { Label } from "../label/label.js";
|
|
|
4
4
|
import { inputControl, selectRecipe, 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/select/select.tsx
|
|
8
8
|
function Select(rawProps) {
|
|
9
|
-
const { id,
|
|
9
|
+
const { id, label, description, error, labelProps, ...restProps } = useHuiProps("Select", rawProps);
|
|
10
10
|
const tmpId = useId();
|
|
11
11
|
const inputState = {
|
|
12
12
|
id: id || tmpId,
|
|
@@ -15,8 +15,8 @@ function Select(rawProps) {
|
|
|
15
15
|
disabled: toBool(restProps.disabled) || toBool(restProps["aria-disabled"])
|
|
16
16
|
};
|
|
17
17
|
const recipe = selectRecipe({ error: toStrbool(inputState.invalid) });
|
|
18
|
-
const cls = useHuiClassNames("Select", recipe, classNames);
|
|
19
|
-
const sls = useHuiStyles("Select", styles);
|
|
18
|
+
const cls = useHuiClassNames("Select", recipe, rawProps.classNames);
|
|
19
|
+
const sls = useHuiStyles("Select", rawProps.styles);
|
|
20
20
|
const hasLabel = !!label || !!description || !!error;
|
|
21
21
|
const controlAttrs = normalizeAttributes(inputControl.getControlAttributes(inputState));
|
|
22
22
|
const labelAttrs = normalizeAttributes(inputControl.getLabelAttributes(inputState));
|
|
@@ -42,7 +42,6 @@ function Select(rawProps) {
|
|
|
42
42
|
})]
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
|
-
//#endregion
|
|
46
45
|
export { Select };
|
|
47
46
|
|
|
48
47
|
//# sourceMappingURL=select.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.js","names":[],"sources":["../../../src/components/select/select.tsx"],"sourcesContent":["import { inputControl, selectRecipe, type SelectSlots, toBool, toStrbool } from \"@hebium-ui/core\";\nimport { type ComponentProps, type ReactElement, type ReactNode, useId } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps } from \"~/types\";\nimport { normalizeAttributes } from \"~/utils\";\nimport { Label, type LabelProps } from \"../label\";\n\ntype HtmlSelectProps = ComponentProps<\"select\">;\n\ninterface SelectOwnProps extends HtmlSelectProps {\n /**\n * The label displayed above the select.\n */\n label?: ReactNode | undefined;\n /**\n * Additional props passed to the internal label component.\n */\n labelProps?: LabelProps | undefined;\n /**\n * The help text displayed below the label.\n */\n description?: ReactNode | undefined;\n /**\n * The validation error message displayed below the label.\n */\n error?: ReactNode | undefined;\n}\n\nexport type SelectProps = HuiComponentProps<\n SelectOwnProps,\n SelectSlots\n>;\n\nexport function Select(rawProps: SelectProps): ReactElement {\n const {\n id,\n
|
|
1
|
+
{"version":3,"file":"select.js","names":[],"sources":["../../../src/components/select/select.tsx"],"sourcesContent":["import { inputControl, selectRecipe, type SelectSlots, toBool, toStrbool } from \"@hebium-ui/core\";\nimport { type ComponentProps, type ReactElement, type ReactNode, useId } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps } from \"~/types\";\nimport { normalizeAttributes } from \"~/utils\";\nimport { Label, type LabelProps } from \"../label\";\n\ntype HtmlSelectProps = ComponentProps<\"select\">;\n\ninterface SelectOwnProps extends HtmlSelectProps {\n /**\n * The label displayed above the select.\n */\n label?: ReactNode | undefined;\n /**\n * Additional props passed to the internal label component.\n */\n labelProps?: LabelProps | undefined;\n /**\n * The help text displayed below the label.\n */\n description?: ReactNode | undefined;\n /**\n * The validation error message displayed below the label.\n */\n error?: ReactNode | undefined;\n}\n\nexport type SelectProps = HuiComponentProps<\n SelectOwnProps,\n SelectSlots\n>;\n\nexport function Select(rawProps: SelectProps): ReactElement {\n const {\n id,\n label,\n description,\n error,\n labelProps,\n ...restProps\n } = useHuiProps(\"Select\", rawProps);\n\n const tmpId = useId();\n\n const inputState = {\n id: id || tmpId,\n invalid: !!error,\n required: restProps.required ?? toBool(restProps[\"aria-required\"]),\n disabled: toBool(restProps.disabled) || toBool(restProps[\"aria-disabled\"]),\n };\n const recipe = selectRecipe({\n error: toStrbool(inputState.invalid),\n });\n const cls = useHuiClassNames(\"Select\", recipe, rawProps.classNames);\n const sls = useHuiStyles(\"Select\", rawProps.styles);\n const hasLabel = !!label || !!description || !!error;\n const controlAttrs = normalizeAttributes(inputControl.getControlAttributes(inputState));\n const labelAttrs = normalizeAttributes(inputControl.getLabelAttributes(inputState));\n\n return (\n <div\n data-disabled={inputState.disabled}\n className={cls.root}\n style={sls.root}\n >\n {hasLabel\n && (\n <Label\n {...labelAttrs}\n description={description}\n error={error}\n {...labelProps}\n >\n {label}\n </Label>\n )}\n <div className={cls.wrapper} style={sls.wrapper}>\n <select\n className={cls.select}\n style={sls.select}\n {...controlAttrs}\n {...restProps}\n />\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;AAiCA,SAAgB,OAAO,UAAqC;CAC1D,MAAM,EACJ,IACA,OACA,aACA,OACA,YACA,GAAG,cACD,YAAY,UAAU,QAAQ;CAElC,MAAM,QAAQ,MAAM;CAEpB,MAAM,aAAa;EACjB,IAAI,MAAM;EACV,SAAS,CAAC,CAAC;EACX,UAAU,UAAU,YAAY,OAAO,UAAU,gBAAgB;EACjE,UAAU,OAAO,UAAU,QAAQ,KAAK,OAAO,UAAU,gBAAgB;CAC3E;CACA,MAAM,SAAS,aAAa,EAC1B,OAAO,UAAU,WAAW,OAAO,EACrC,CAAC;CACD,MAAM,MAAM,iBAAiB,UAAU,QAAQ,SAAS,UAAU;CAClE,MAAM,MAAM,aAAa,UAAU,SAAS,MAAM;CAClD,MAAM,WAAW,CAAC,CAAC,SAAS,CAAC,CAAC,eAAe,CAAC,CAAC;CAC/C,MAAM,eAAe,oBAAoB,aAAa,qBAAqB,UAAU,CAAC;CACtF,MAAM,aAAa,oBAAoB,aAAa,mBAAmB,UAAU,CAAC;CAElF,OACE,qBAAC,OAAD;EACE,iBAAe,WAAW;EAC1B,WAAW,IAAI;EACf,OAAO,IAAI;EAHb,UAAA,CAKG,YAEG,oBAAC,OAAD;GACE,GAAI;GACS;GACN;GACP,GAAI;GAEH,UAAA;EACI,CAAA,GAEX,oBAAC,OAAD;GAAK,WAAW,IAAI;GAAS,OAAO,IAAI;GACtC,UAAA,oBAAC,UAAD;IACE,WAAW,IAAI;IACf,OAAO,IAAI;IACX,GAAI;IACJ,GAAI;GACL,CAAA;EACE,CAAA,CACF;;AAET"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { HuiPolymorphicProps } from "../../types/polymorphic.js";
|
|
2
|
+
import "../../types/index.js";
|
|
3
|
+
import { SkipLinkSlots } from "@hebium-ui/core";
|
|
4
|
+
import { ElementType, ReactElement } from "react";
|
|
5
|
+
export type SkipLinkProps<E extends ElementType = "div"> = HuiPolymorphicProps<E, {}, SkipLinkSlots>;
|
|
6
|
+
export declare function SkipLink<E extends ElementType = "div">(rawProps: SkipLinkProps<E>): ReactElement;
|
|
7
|
+
//# sourceMappingURL=skip-link.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
|
|
2
|
+
import { skipLinkRecipe } from "@hebium-ui/core";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
// src/components/skip-link/skip-link.tsx
|
|
5
|
+
function SkipLink(rawProps) {
|
|
6
|
+
const { as, children, ...restProps } = useHuiProps("SkipLink", rawProps);
|
|
7
|
+
const Component = as ?? "div";
|
|
8
|
+
const recipe = skipLinkRecipe({});
|
|
9
|
+
const cls = useHuiClassNames("SkipLink", recipe, { root: rawProps["className"] });
|
|
10
|
+
const sls = useHuiStyles("SkipLink", { root: rawProps["style"] });
|
|
11
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
12
|
+
className: cls.root,
|
|
13
|
+
style: sls.root,
|
|
14
|
+
...restProps,
|
|
15
|
+
children
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export { SkipLink };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=skip-link.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skip-link.js","names":[],"sources":["../../../src/components/skip-link/skip-link.tsx"],"sourcesContent":["import { skipLinkRecipe, type SkipLinkSlots } from \"@hebium-ui/core\";\nimport { type ElementType, type ReactElement } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\n\nexport type SkipLinkProps<E extends ElementType = \"div\"> = HuiPolymorphicProps<\n E,\n {},\n SkipLinkSlots\n>;\n\nexport function SkipLink<E extends ElementType = \"div\">(rawProps: SkipLinkProps<E>): ReactElement {\n const {\n as,\n children,\n ...restProps\n } = useHuiProps(\"SkipLink\", rawProps);\n\n const Component = as ?? \"div\";\n const recipe = skipLinkRecipe({});\n const cls = useHuiClassNames(\"SkipLink\", recipe, { root: rawProps[\"className\"] });\n const sls = useHuiStyles(\"SkipLink\", { 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":";;;;AAWA,SAAgB,SAAwC,UAA0C;CAChG,MAAM,EACJ,IACA,UACA,GAAG,cACD,YAAY,YAAY,QAAQ;CAEpC,MAAM,YAAY,MAAM;CACxB,MAAM,SAAS,eAAe,CAAC,CAAC;CAChC,MAAM,MAAM,iBAAiB,YAAY,QAAQ,EAAE,MAAM,SAAS,aAAa,CAAC;CAChF,MAAM,MAAM,aAAa,YAAY,EAAE,MAAM,SAAS,SAAS,CAAC;CAEhE,OACE,oBAAC,WAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EAEH;CACQ,CAAA;AAEf"}
|
|
@@ -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.
|
|
@@ -48,6 +47,5 @@ export declare const Table: typeof TableRoot & {
|
|
|
48
47
|
Th: typeof Th;
|
|
49
48
|
Td: typeof Td;
|
|
50
49
|
};
|
|
51
|
-
//#endregion
|
|
52
50
|
export {};
|
|
53
51
|
//# sourceMappingURL=table.d.ts.map
|
|
@@ -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, { root: className });
|
|
9
|
-
const sls = useHuiStyles("Table", { root: style });
|
|
8
|
+
const cls = useHuiClassNames("Table", recipe, { root: rawProps.className });
|
|
9
|
+
const sls = useHuiStyles("Table", { root: rawProps.style });
|
|
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, { root: className });
|
|
21
|
-
const sls = useHuiStyles("TableCaption", { root: style });
|
|
20
|
+
const cls = useHuiClassNames("TableCaption", recipe, { root: rawProps.className });
|
|
21
|
+
const sls = useHuiStyles("TableCaption", { root: rawProps.style });
|
|
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: "" }, { root: className });
|
|
32
|
-
const sls = useHuiStyles("TableThead", { root: style });
|
|
30
|
+
const { children, ...restProps } = useHuiProps("TableThead", rawProps);
|
|
31
|
+
const cls = useHuiClassNames("TableThead", { root: "" }, { root: rawProps.className });
|
|
32
|
+
const sls = useHuiStyles("TableThead", { root: rawProps.style });
|
|
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: "" }, { root: className });
|
|
43
|
-
const sls = useHuiStyles("TableTbody", { root: style });
|
|
41
|
+
const { children, ...restProps } = useHuiProps("TableTbody", rawProps);
|
|
42
|
+
const cls = useHuiClassNames("TableTbody", { root: "" }, { root: rawProps.className });
|
|
43
|
+
const sls = useHuiStyles("TableTbody", { root: rawProps.style });
|
|
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: "" }, { root: className });
|
|
54
|
-
const sls = useHuiStyles("TableTfoot", { root: style });
|
|
52
|
+
const { children, ...restProps } = useHuiProps("TableTfoot", rawProps);
|
|
53
|
+
const cls = useHuiClassNames("TableTfoot", { root: "" }, { root: rawProps.className });
|
|
54
|
+
const sls = useHuiStyles("TableTfoot", { root: rawProps.style });
|
|
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, { root: className });
|
|
66
|
-
const sls = useHuiStyles("TableTr", { root: style });
|
|
65
|
+
const cls = useHuiClassNames("TableTr", recipe, { root: rawProps.className });
|
|
66
|
+
const sls = useHuiStyles("TableTr", { root: rawProps.style });
|
|
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, { root: className });
|
|
78
|
-
const sls = useHuiStyles("TableTh", { root: style });
|
|
77
|
+
const cls = useHuiClassNames("TableTh", recipe, { root: rawProps.className });
|
|
78
|
+
const sls = useHuiStyles("TableTh", { root: rawProps.style });
|
|
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, { root: className });
|
|
90
|
-
const sls = useHuiStyles("TableTd", { root: style });
|
|
89
|
+
const cls = useHuiClassNames("TableTd", recipe, { root: rawProps.className });
|
|
90
|
+
const sls = useHuiStyles("TableTd", { root: rawProps.style });
|
|
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, { root: rawProps.className });\n const sls = useHuiStyles(\"Table\", { root: rawProps.style });\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, { root: rawProps.className });\n const sls = useHuiStyles(\"TableCaption\", { root: rawProps.style });\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 = ComponentProps<\"thead\">;\n\nfunction Thead(rawProps: TheadProps): ReactElement {\n const { children, ...restProps } = useHuiProps(\"TableThead\", rawProps);\n\n const cls = useHuiClassNames(\"TableThead\", { root: \"\" }, { root: rawProps.className });\n const sls = useHuiStyles(\"TableThead\", { root: rawProps.style });\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 = ComponentProps<\"tbody\">;\n\nfunction Tbody(rawProps: TbodyProps): ReactElement {\n const { children, ...restProps } = useHuiProps(\"TableTbody\", rawProps);\n\n const cls = useHuiClassNames(\"TableTbody\", { root: \"\" }, { root: rawProps.className });\n const sls = useHuiStyles(\"TableTbody\", { root: rawProps.style });\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 = ComponentProps<\"tfoot\">;\n\nfunction Tfoot(rawProps: TfootProps): ReactElement {\n const { children, ...restProps } = useHuiProps(\"TableTfoot\", rawProps);\n\n const cls = useHuiClassNames(\"TableTfoot\", { root: \"\" }, { root: rawProps.className });\n const sls = useHuiStyles(\"TableTfoot\", { root: rawProps.style });\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, { root: rawProps.className });\n const sls = useHuiStyles(\"TableTr\", { root: rawProps.style });\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, { root: rawProps.className });\n const sls = useHuiStyles(\"TableTh\", { root: rawProps.style });\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, { root: rawProps.className });\n const sls = useHuiStyles(\"TableTd\", { root: rawProps.style });\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":";;;;AA2BA,SAAS,U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AC1B,MAAM,MAAM,iBAAiB,WAAW,QAAQ,EAAE,MAAM,SAAS,UAAU,CAAC;CAC5E,MAAM,MAAM,aAAa,WAAW,EAAE,MAAM,SAAS,MAAM,CAAC;CAE5D,OACE,oBAAC,MAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EAEH;CACC,CAAA;AAER;AAEA,MAAa,QAAQ,OAAO,OAAO,WAAW;CAC5C;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC"}
|
|
@@ -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,5 @@ export declare const Tabs: typeof TabsRoot & {
|
|
|
55
54
|
Tab: typeof Tab;
|
|
56
55
|
Panel: typeof Panel;
|
|
57
56
|
};
|
|
58
|
-
//#endregion
|
|
59
57
|
export {};
|
|
60
58
|
//# sourceMappingURL=tabs.d.ts.map
|
|
@@ -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, { root: className });
|
|
17
|
-
const sls = useHuiStyles("Tabs", { root: style });
|
|
16
|
+
const cls = useHuiClassNames("Tabs", recipe, { root: rawProps["className"] });
|
|
17
|
+
const sls = useHuiStyles("Tabs", { root: rawProps["style"] });
|
|
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, { root: className });
|
|
55
|
-
const sls = useHuiStyles("TabsList", { root: style });
|
|
54
|
+
const cls = useHuiClassNames("TabsList", recipe, { root: rawProps["className"] });
|
|
55
|
+
const sls = useHuiStyles("TabsList", { root: rawProps["style"] });
|
|
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, { root: className });
|
|
78
|
-
const sls = useHuiStyles("TabsTab", { root: style });
|
|
77
|
+
const cls = useHuiClassNames("TabsTab", recipe, { root: rawProps["className"] });
|
|
78
|
+
const sls = useHuiStyles("TabsTab", { root: rawProps["style"] });
|
|
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, { root: className });
|
|
137
|
-
const sls = useHuiStyles("TabsPanel", { root: style });
|
|
136
|
+
const cls = useHuiClassNames("TabsPanel", recipe, { root: rawProps["className"] });
|
|
137
|
+
const sls = useHuiStyles("TabsPanel", { root: rawProps["style"] });
|
|
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
|