@hebium-ui/react 0.0.0-stage → 0.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +7 -2
- package/dist/components/alert/alert.d.ts +44 -0
- package/dist/components/alert/alert.js +45 -0
- package/dist/components/alert/alert.js.map +1 -0
- package/dist/components/alert/index.d.ts +2 -0
- package/dist/components/anchor/anchor.d.ts +30 -0
- package/dist/components/anchor/anchor.js +25 -0
- package/dist/components/anchor/anchor.js.map +1 -0
- package/dist/components/anchor/index.d.ts +2 -0
- package/dist/components/avatar/avatar.d.ts +16 -0
- package/dist/components/avatar/avatar.js +50 -0
- package/dist/components/avatar/avatar.js.map +1 -0
- package/dist/components/avatar/index.d.ts +2 -0
- package/dist/components/blockquote/blockquote.d.ts +28 -0
- package/dist/components/blockquote/blockquote.js +29 -0
- package/dist/components/blockquote/blockquote.js.map +1 -0
- package/dist/components/blockquote/index.d.ts +2 -0
- package/dist/components/button/button.d.ts +30 -0
- package/dist/components/button/button.js +25 -0
- package/dist/components/button/button.js.map +1 -0
- package/dist/components/button/index.d.ts +2 -0
- package/dist/components/checkbox/checkbox.d.ts +33 -0
- package/dist/components/checkbox/checkbox.js +68 -0
- package/dist/components/checkbox/checkbox.js.map +1 -0
- package/dist/components/checkbox/index.d.ts +2 -0
- package/dist/components/code/code.d.ts +11 -0
- package/dist/components/code/code.js +21 -0
- package/dist/components/code/code.js.map +1 -0
- package/dist/components/code/index.d.ts +2 -0
- package/dist/components/details/details.d.ts +22 -0
- package/dist/components/details/details.js +28 -0
- package/dist/components/details/details.js.map +1 -0
- package/dist/components/details/index.d.ts +2 -0
- package/dist/components/dialog/dialog.context.d.ts +4 -0
- package/dist/components/dialog/dialog.context.js +15 -0
- package/dist/components/dialog/dialog.context.js.map +1 -0
- package/dist/components/dialog/dialog.d.ts +67 -0
- package/dist/components/dialog/dialog.js +124 -0
- package/dist/components/dialog/dialog.js.map +1 -0
- package/dist/components/dialog/index.d.ts +3 -0
- package/dist/components/dl/dl.d.ts +18 -0
- package/dist/components/dl/dl.js +48 -0
- package/dist/components/dl/dl.js.map +1 -0
- package/dist/components/dl/index.d.ts +2 -0
- package/dist/components/drawer/drawer.context.d.ts +4 -0
- package/dist/components/drawer/drawer.context.js +15 -0
- package/dist/components/drawer/drawer.context.js.map +1 -0
- package/dist/components/drawer/drawer.d.ts +67 -0
- package/dist/components/drawer/drawer.js +104 -0
- package/dist/components/drawer/drawer.js.map +1 -0
- package/dist/components/drawer/index.d.ts +3 -0
- package/dist/components/fieldset/fieldset.d.ts +9 -0
- package/dist/components/fieldset/fieldset.js +20 -0
- package/dist/components/fieldset/fieldset.js.map +1 -0
- package/dist/components/fieldset/index.d.ts +2 -0
- package/dist/components/heading/heading.d.ts +22 -0
- package/dist/components/heading/heading.js +24 -0
- package/dist/components/heading/heading.js.map +1 -0
- package/dist/components/heading/index.d.ts +2 -0
- package/dist/components/hr/hr.d.ts +11 -0
- package/dist/components/hr/hr.js +19 -0
- package/dist/components/hr/hr.js.map +1 -0
- package/dist/components/hr/index.d.ts +2 -0
- package/dist/components/index.d.ts +66 -0
- package/dist/components/input/index.d.ts +2 -0
- package/dist/components/input/input.d.ts +37 -0
- package/dist/components/input/input.js +47 -0
- package/dist/components/input/input.js.map +1 -0
- package/dist/components/label/index.d.ts +2 -0
- package/dist/components/label/label.d.ts +32 -0
- package/dist/components/label/label.js +54 -0
- package/dist/components/label/label.js.map +1 -0
- package/dist/components/menu/index.d.ts +3 -0
- package/dist/components/menu/menu.context.d.ts +4 -0
- package/dist/components/menu/menu.context.js +15 -0
- package/dist/components/menu/menu.context.js.map +1 -0
- package/dist/components/menu/menu.d.ts +82 -0
- package/dist/components/menu/menu.js +133 -0
- package/dist/components/menu/menu.js.map +1 -0
- package/dist/components/paragraph/index.d.ts +2 -0
- package/dist/components/paragraph/paragraph.d.ts +18 -0
- package/dist/components/paragraph/paragraph.js +21 -0
- package/dist/components/paragraph/paragraph.js.map +1 -0
- package/dist/components/popover/index.d.ts +3 -0
- package/dist/components/popover/popover.context.d.ts +4 -0
- package/dist/components/popover/popover.context.js +15 -0
- package/dist/components/popover/popover.context.js.map +1 -0
- package/dist/components/popover/popover.d.ts +53 -0
- package/dist/components/popover/popover.js +60 -0
- package/dist/components/popover/popover.js.map +1 -0
- package/dist/components/progress/index.d.ts +2 -0
- package/dist/components/progress/progress.d.ts +55 -0
- package/dist/components/progress/progress.js +57 -0
- package/dist/components/progress/progress.js.map +1 -0
- package/dist/components/radio/index.d.ts +2 -0
- package/dist/components/radio/radio.d.ts +27 -0
- package/dist/components/radio/radio.js +57 -0
- package/dist/components/radio/radio.js.map +1 -0
- package/dist/components/radiogroup/index.d.ts +2 -0
- package/dist/components/radiogroup/radiogroup.d.ts +36 -0
- package/dist/components/radiogroup/radiogroup.js +44 -0
- package/dist/components/radiogroup/radiogroup.js.map +1 -0
- package/dist/components/section/index.d.ts +2 -0
- package/dist/components/section/section.d.ts +36 -0
- package/dist/components/section/section.js +26 -0
- package/dist/components/section/section.js.map +1 -0
- package/dist/components/segmented-control/index.d.ts +2 -0
- package/dist/components/segmented-control/segmented-control.context.js +12 -0
- package/dist/components/segmented-control/segmented-control.context.js.map +1 -0
- package/dist/components/segmented-control/segmented-control.d.ts +41 -0
- package/dist/components/segmented-control/segmented-control.js +68 -0
- package/dist/components/segmented-control/segmented-control.js.map +1 -0
- package/dist/components/select/index.d.ts +2 -0
- package/dist/components/select/select.d.ts +31 -0
- package/dist/components/select/select.js +48 -0
- package/dist/components/select/select.js.map +1 -0
- package/dist/components/table/index.d.ts +2 -0
- package/dist/components/table/table.d.ts +53 -0
- package/dist/components/table/table.js +110 -0
- package/dist/components/table/table.js.map +1 -0
- package/dist/components/tabs/index.d.ts +2 -0
- package/dist/components/tabs/tabs.context.d.ts +4 -0
- package/dist/components/tabs/tabs.context.js +12 -0
- package/dist/components/tabs/tabs.context.js.map +1 -0
- package/dist/components/tabs/tabs.d.ts +60 -0
- package/dist/components/tabs/tabs.js +158 -0
- package/dist/components/tabs/tabs.js.map +1 -0
- package/dist/components/textarea/index.d.ts +2 -0
- package/dist/components/textarea/textarea.d.ts +37 -0
- package/dist/components/textarea/textarea.js +48 -0
- package/dist/components/textarea/textarea.js.map +1 -0
- package/dist/components/tooltip/index.d.ts +3 -0
- package/dist/components/tooltip/tooltip.context.d.ts +4 -0
- package/dist/components/tooltip/tooltip.context.js +15 -0
- package/dist/components/tooltip/tooltip.context.js.map +1 -0
- package/dist/components/tooltip/tooltip.d.ts +53 -0
- package/dist/components/tooltip/tooltip.js +83 -0
- package/dist/components/tooltip/tooltip.js.map +1 -0
- package/dist/components/visually-hidden/index.d.ts +2 -0
- package/dist/components/visually-hidden/visually-hidden.d.ts +9 -0
- package/dist/components/visually-hidden/visually-hidden.js +21 -0
- package/dist/components/visually-hidden/visually-hidden.js.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +38 -0
- package/dist/provider/hui-provider.context.d.ts +104 -0
- package/dist/provider/hui-provider.context.js +36 -0
- package/dist/provider/hui-provider.context.js.map +1 -0
- package/dist/provider/hui-provider.d.ts +8 -0
- package/dist/provider/hui-provider.js +17 -0
- package/dist/provider/hui-provider.js.map +1 -0
- package/dist/provider/index.d.ts +3 -0
- package/dist/provider/merge-props.js +16 -0
- package/dist/provider/merge-props.js.map +1 -0
- package/dist/types/hui-component.d.ts +8 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/polymorphic.d.ts +13 -0
- package/dist/utils/attributes/normalize-attributes.js +18 -0
- package/dist/utils/attributes/normalize-attributes.js.map +1 -0
- package/package.json +54 -3
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { HuiPolymorphicProps } from "../../types/polymorphic.js";
|
|
2
|
+
import "../../types/index.js";
|
|
3
|
+
import { ParagraphSlots, ParagraphVariants } from "@hebium-ui/core";
|
|
4
|
+
import { ElementType, ReactElement } from "react";
|
|
5
|
+
//#region src/components/paragraph/paragraph.d.ts
|
|
6
|
+
interface ParagraphOwnProps {
|
|
7
|
+
/**
|
|
8
|
+
* The semantic color of the paragraph.
|
|
9
|
+
*
|
|
10
|
+
* @default "text"
|
|
11
|
+
*/
|
|
12
|
+
color?: ParagraphVariants["color"] | undefined;
|
|
13
|
+
}
|
|
14
|
+
export type ParagraphProps<E extends ElementType = "p"> = HuiPolymorphicProps<E, ParagraphOwnProps, ParagraphSlots>;
|
|
15
|
+
export declare function Paragraph<E extends ElementType = "p">(rawProps: ParagraphProps<E>): ReactElement;
|
|
16
|
+
//#endregion
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=paragraph.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
|
|
2
|
+
import { paragraphRecipe } from "@hebium-ui/core";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/paragraph/paragraph.tsx
|
|
5
|
+
function Paragraph(rawProps) {
|
|
6
|
+
const { as, color, className, style, children, ...restProps } = useHuiProps("Paragraph", rawProps);
|
|
7
|
+
const Component = as ?? "p";
|
|
8
|
+
const recipe = paragraphRecipe({ color });
|
|
9
|
+
const cls = useHuiClassNames("Paragraph", recipe, { root: className });
|
|
10
|
+
const sls = useHuiStyles("Paragraph", { root: style });
|
|
11
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
12
|
+
className: cls.root,
|
|
13
|
+
style: sls.root,
|
|
14
|
+
...restProps,
|
|
15
|
+
children
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { Paragraph };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=paragraph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paragraph.js","names":[],"sources":["../../../src/components/paragraph/paragraph.tsx"],"sourcesContent":["import { paragraphRecipe, type ParagraphSlots, type ParagraphVariants } from \"@hebium-ui/core\";\nimport { type ElementType, type ReactElement } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\n\ninterface ParagraphOwnProps {\n /**\n * The semantic color of the paragraph.\n *\n * @default \"text\"\n */\n color?: ParagraphVariants[\"color\"] | undefined;\n}\n\nexport type ParagraphProps<E extends ElementType = \"p\"> = HuiPolymorphicProps<\n E,\n ParagraphOwnProps,\n ParagraphSlots\n>;\n\nexport function Paragraph<E extends ElementType = \"p\">(rawProps: ParagraphProps<E>): ReactElement {\n const {\n as,\n color,\n className,\n style,\n children,\n ...restProps\n } = useHuiProps(\"Paragraph\", rawProps);\n\n const Component = as ?? \"p\";\n const recipe = paragraphRecipe({\n color,\n });\n const cls = useHuiClassNames(\"Paragraph\", recipe, { root: className });\n const sls = useHuiStyles(\"Paragraph\", { root: style });\n\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n"],"mappings":";;;;AAoBA,SAAgB,UAAuC,UAA2C;CAChG,MAAM,EACJ,IACA,OACA,WACA,OACA,UACA,GAAG,cACD,YAAY,aAAa,QAAQ;CAErC,MAAM,YAAY,MAAM;CACxB,MAAM,SAAS,gBAAgB,EAC7B,MACF,CAAC;CACD,MAAM,MAAM,iBAAiB,aAAa,QAAQ,EAAE,MAAM,UAAU,CAAC;CACrE,MAAM,MAAM,aAAa,aAAa,EAAE,MAAM,MAAM,CAAC;CAErD,OACE,oBAAC,WAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EAEH;CACQ,CAAA;AAEf"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
//#region src/components/popover/popover.context.ts
|
|
3
|
+
const PopoverContext = createContext(null);
|
|
4
|
+
function usePopoverContext() {
|
|
5
|
+
const context = useContext(PopoverContext);
|
|
6
|
+
if (!context) throw new Error("[Hebium UI] Popover compound components must be used within <Popover>");
|
|
7
|
+
return context;
|
|
8
|
+
}
|
|
9
|
+
function usePopoverId() {
|
|
10
|
+
return usePopoverContext().popoverId;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { PopoverContext, usePopoverContext, usePopoverId };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=popover.context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"popover.context.js","names":[],"sources":["../../../src/components/popover/popover.context.ts"],"sourcesContent":["import { createContext, useContext } from \"react\";\n\nexport interface PopoverContextValue {\n popoverId: string;\n}\n\nexport const PopoverContext = createContext<PopoverContextValue | null>(null);\n\nexport function usePopoverContext(): PopoverContextValue {\n const context = useContext(PopoverContext);\n if (!context) {\n throw new Error(\"[Hebium UI] Popover compound components must be used within <Popover>\");\n }\n return context;\n}\n\nexport function usePopoverId(): string {\n return usePopoverContext().popoverId;\n}\n"],"mappings":";;AAMA,MAAa,iBAAiB,cAA0C,IAAI;AAE5E,SAAgB,oBAAyC;CACvD,MAAM,UAAU,WAAW,cAAc;CACzC,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,uEAAuE;CAEzF,OAAO;AACT;AAEA,SAAgB,eAAuB;CACrC,OAAO,kBAAkB,CAAC,CAAC;AAC7B"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { HuiPolymorphicProps } from "../../types/polymorphic.js";
|
|
2
|
+
import "../../types/index.js";
|
|
3
|
+
import { Button } from "../button/button.js";
|
|
4
|
+
import "../button/index.js";
|
|
5
|
+
import { ButtonSlots, PopoverSlots, PopoverVariants } from "@hebium-ui/core";
|
|
6
|
+
import { ElementType, ReactElement, ReactNode } from "react";
|
|
7
|
+
//#region src/components/popover/popover.d.ts
|
|
8
|
+
export interface PopoverProps {
|
|
9
|
+
/**
|
|
10
|
+
* The id of the popover content element.
|
|
11
|
+
*/
|
|
12
|
+
id?: string | undefined;
|
|
13
|
+
children?: ReactNode | undefined;
|
|
14
|
+
}
|
|
15
|
+
declare function PopoverRoot(rawProps: PopoverProps): ReactElement;
|
|
16
|
+
export type PopoverTriggerProps<E extends ElementType = typeof Button> = HuiPolymorphicProps<E, {}, ButtonSlots>;
|
|
17
|
+
declare function Trigger<E extends ElementType = typeof Button>(rawProps: PopoverTriggerProps<E>): ReactNode;
|
|
18
|
+
interface PopoverContentOwnProps {
|
|
19
|
+
/**
|
|
20
|
+
* The preferred anchor position of the popover.
|
|
21
|
+
*
|
|
22
|
+
* @default "block-start"
|
|
23
|
+
*/
|
|
24
|
+
position?: PopoverVariants["position"] | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* The fallback strategy used when the preferred position overflows.
|
|
27
|
+
*
|
|
28
|
+
* @default "flip"
|
|
29
|
+
*/
|
|
30
|
+
fallbacks?: PopoverVariants["fallbacks"] | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* The visibility behavior when the anchor is off-screen or overflows.
|
|
33
|
+
*
|
|
34
|
+
* @default "anchors-visible"
|
|
35
|
+
* @see This setting depends on browser support for {@link https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/position-visibility | MDN: position-visibility}.
|
|
36
|
+
*/
|
|
37
|
+
visibility?: PopoverVariants["visibility"] | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* The padding size of the popover content.
|
|
40
|
+
*
|
|
41
|
+
* @default "md"
|
|
42
|
+
*/
|
|
43
|
+
padding?: PopoverVariants["padding"] | undefined;
|
|
44
|
+
}
|
|
45
|
+
export type PopoverContentProps<E extends ElementType = "div"> = HuiPolymorphicProps<E, PopoverContentOwnProps, PopoverSlots>;
|
|
46
|
+
declare function Content<E extends ElementType = "div">(rawProps: PopoverContentProps<E>): ReactElement;
|
|
47
|
+
export declare const Popover: typeof PopoverRoot & {
|
|
48
|
+
Trigger: typeof Trigger;
|
|
49
|
+
Content: typeof Content;
|
|
50
|
+
};
|
|
51
|
+
//#endregion
|
|
52
|
+
export {};
|
|
53
|
+
//# sourceMappingURL=popover.d.ts.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
|
|
2
|
+
import { Button } from "../button/button.js";
|
|
3
|
+
import { normalizeAttributes } from "../../utils/attributes/normalize-attributes.js";
|
|
4
|
+
import { PopoverContext, usePopoverId } from "./popover.context.js";
|
|
5
|
+
import { popoverControl, popoverRecipe } from "@hebium-ui/core";
|
|
6
|
+
import { useId, useMemo } from "react";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
//#region src/components/popover/popover.tsx
|
|
9
|
+
function PopoverRoot(rawProps) {
|
|
10
|
+
const { id, children } = useHuiProps("Popover", rawProps);
|
|
11
|
+
const tmpId = useId();
|
|
12
|
+
const popoverId = id || tmpId;
|
|
13
|
+
const contextValue = useMemo(() => {
|
|
14
|
+
return { popoverId };
|
|
15
|
+
}, [popoverId]);
|
|
16
|
+
return /* @__PURE__ */ jsx(PopoverContext.Provider, {
|
|
17
|
+
value: contextValue,
|
|
18
|
+
children
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function Trigger(rawProps) {
|
|
22
|
+
const { as, children, ...restProps } = useHuiProps("PopoverTrigger", rawProps);
|
|
23
|
+
const Component = as ?? Button;
|
|
24
|
+
const popoverId = usePopoverId();
|
|
25
|
+
const attrs = normalizeAttributes(popoverControl.getTriggerAttributes({ popoverId }, { isButtonElement: as === void 0 }));
|
|
26
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
27
|
+
...attrs,
|
|
28
|
+
...restProps,
|
|
29
|
+
children
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function Content(rawProps) {
|
|
33
|
+
const { as, position, fallbacks, visibility, padding, className, style, children, ...restProps } = useHuiProps("PopoverContent", rawProps);
|
|
34
|
+
const Component = as ?? "div";
|
|
35
|
+
const popoverId = usePopoverId();
|
|
36
|
+
const recipe = popoverRecipe({
|
|
37
|
+
position,
|
|
38
|
+
fallbacks,
|
|
39
|
+
visibility,
|
|
40
|
+
padding
|
|
41
|
+
});
|
|
42
|
+
const cls = useHuiClassNames("PopoverContent", recipe, { root: className });
|
|
43
|
+
const sls = useHuiStyles("PopoverContent", { root: style });
|
|
44
|
+
const attrs = normalizeAttributes(popoverControl.getContentAttributes({ popoverId }));
|
|
45
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
46
|
+
...attrs,
|
|
47
|
+
className: cls.root,
|
|
48
|
+
style: sls.root,
|
|
49
|
+
...restProps,
|
|
50
|
+
children
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
const Popover = Object.assign(PopoverRoot, {
|
|
54
|
+
Trigger,
|
|
55
|
+
Content
|
|
56
|
+
});
|
|
57
|
+
//#endregion
|
|
58
|
+
export { Popover };
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=popover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"popover.js","names":[],"sources":["../../../src/components/popover/popover.tsx"],"sourcesContent":["import {\n type ButtonSlots,\n popoverControl,\n popoverRecipe,\n type PopoverSlots,\n type PopoverVariants,\n} from \"@hebium-ui/core\";\nimport { type ElementType, type ReactElement, type ReactNode, useId, useMemo } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\nimport { normalizeAttributes } from \"~/utils\";\nimport { Button } from \"../button\";\nimport { PopoverContext, type PopoverContextValue, usePopoverId } from \"./popover.context\";\n\nexport interface PopoverProps {\n /**\n * The id of the popover content element.\n */\n id?: string | undefined;\n children?: ReactNode | undefined;\n}\n\nfunction PopoverRoot(rawProps: PopoverProps): ReactElement {\n const {\n id,\n children,\n } = useHuiProps(\"Popover\", rawProps);\n\n const tmpId = useId();\n const popoverId = id || tmpId;\n\n const contextValue = useMemo<PopoverContextValue>(() => {\n return {\n popoverId,\n };\n }, [popoverId]);\n\n return (\n <PopoverContext.Provider\n value={contextValue}\n >\n {children}\n </PopoverContext.Provider>\n );\n}\n\nexport type PopoverTriggerProps<E extends ElementType = typeof Button> = HuiPolymorphicProps<\n E,\n {},\n ButtonSlots\n>;\n\nfunction Trigger<E extends ElementType = typeof Button>(rawProps: PopoverTriggerProps<E>): ReactNode {\n const {\n as,\n children,\n ...restProps\n } = useHuiProps(\"PopoverTrigger\", rawProps);\n\n const Component = as ?? Button;\n const popoverId = usePopoverId();\n const attrs = normalizeAttributes(\n popoverControl.getTriggerAttributes(\n { popoverId },\n { isButtonElement: as === undefined },\n ),\n );\n\n return (\n <Component\n {...attrs}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n\ninterface PopoverContentOwnProps {\n /**\n * The preferred anchor position of the popover.\n *\n * @default \"block-start\"\n */\n position?: PopoverVariants[\"position\"] | undefined;\n /**\n * The fallback strategy used when the preferred position overflows.\n *\n * @default \"flip\"\n */\n fallbacks?: PopoverVariants[\"fallbacks\"] | undefined;\n /**\n * The visibility behavior when the anchor is off-screen or overflows.\n *\n * @default \"anchors-visible\"\n * @see This setting depends on browser support for {@link https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/position-visibility | MDN: position-visibility}.\n */\n visibility?: PopoverVariants[\"visibility\"] | undefined;\n /**\n * The padding size of the popover content.\n *\n * @default \"md\"\n */\n padding?: PopoverVariants[\"padding\"] | undefined;\n}\nexport type PopoverContentProps<E extends ElementType = \"div\"> = HuiPolymorphicProps<\n E,\n PopoverContentOwnProps,\n PopoverSlots\n>;\n\nfunction Content<E extends ElementType = \"div\">(rawProps: PopoverContentProps<E>): ReactElement {\n const {\n as,\n position,\n fallbacks,\n visibility,\n padding,\n className,\n style,\n children,\n ...restProps\n } = useHuiProps(\"PopoverContent\", rawProps);\n const Component = as ?? \"div\";\n\n const popoverId = usePopoverId();\n const recipe = popoverRecipe({ position, fallbacks, visibility, padding });\n const cls = useHuiClassNames(\"PopoverContent\", recipe, { root: className });\n const sls = useHuiStyles(\"PopoverContent\", { root: style });\n const attrs = normalizeAttributes(popoverControl.getContentAttributes({ popoverId }));\n\n return (\n <Component\n {...attrs}\n className={cls.root}\n style={sls.root}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n\nexport const Popover = Object.assign(PopoverRoot, {\n Trigger,\n Content,\n});\n"],"mappings":";;;;;;;;AAsBA,SAAS,YAAY,UAAsC;CACzD,MAAM,EACJ,IACA,aACE,YAAY,WAAW,QAAQ;CAEnC,MAAM,QAAQ,MAAM;CACpB,MAAM,YAAY,MAAM;CAExB,MAAM,eAAe,cAAmC;EACtD,OAAO,EACL,UACF;CACF,GAAG,CAAC,SAAS,CAAC;CAEd,OACE,oBAAC,eAAe,UAAhB;EACE,OAAO;EAEN;CACsB,CAAA;AAE7B;AAQA,SAAS,QAA+C,UAA6C;CACnG,MAAM,EACJ,IACA,UACA,GAAG,cACD,YAAY,kBAAkB,QAAQ;CAE1C,MAAM,YAAY,MAAM;CACxB,MAAM,YAAY,aAAa;CAC/B,MAAM,QAAQ,oBACZ,eAAe,qBACb,EAAE,UAAU,GACZ,EAAE,iBAAiB,OAAO,KAAA,EAAU,CACtC,CACF;CAEA,OACE,oBAAC,WAAD;EACE,GAAI;EACJ,GAAI;EAEH;CACQ,CAAA;AAEf;AAmCA,SAAS,QAAuC,UAAgD;CAC9F,MAAM,EACJ,IACA,UACA,WACA,YACA,SACA,WACA,OACA,UACA,GAAG,cACD,YAAY,kBAAkB,QAAQ;CAC1C,MAAM,YAAY,MAAM;CAExB,MAAM,YAAY,aAAa;CAC/B,MAAM,SAAS,cAAc;EAAE;EAAU;EAAW;EAAY;CAAQ,CAAC;CACzE,MAAM,MAAM,iBAAiB,kBAAkB,QAAQ,EAAE,MAAM,UAAU,CAAC;CAC1E,MAAM,MAAM,aAAa,kBAAkB,EAAE,MAAM,MAAM,CAAC;CAC1D,MAAM,QAAQ,oBAAoB,eAAe,qBAAqB,EAAE,UAAU,CAAC,CAAC;CAEpF,OACE,oBAAC,WAAD;EACE,GAAI;EACJ,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EAEH;CACQ,CAAA;AAEf;AAEA,MAAa,UAAU,OAAO,OAAO,aAAa;CAChD;CACA;AACF,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { HuiComponentProps } from "../../types/hui-component.js";
|
|
2
|
+
import "../../types/index.js";
|
|
3
|
+
import { ProgressSlots, ProgressVariants } from "@hebium-ui/core";
|
|
4
|
+
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
5
|
+
//#region src/components/progress/progress.d.ts
|
|
6
|
+
type HtmlDivProps = ComponentProps<"div">;
|
|
7
|
+
interface ProgressOwnProps extends HtmlDivProps {
|
|
8
|
+
/**
|
|
9
|
+
* The minimum value of the progress range.
|
|
10
|
+
*
|
|
11
|
+
* @default 0
|
|
12
|
+
*/
|
|
13
|
+
min?: number | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* The maximum value of the progress range.
|
|
16
|
+
*
|
|
17
|
+
* @default 100
|
|
18
|
+
*/
|
|
19
|
+
max?: number | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* The current value of the progress. Omit this prop when progress is indeterminate.
|
|
22
|
+
*/
|
|
23
|
+
value?: number | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* The human-readable text alternative for the current value.
|
|
26
|
+
*/
|
|
27
|
+
valueText?: string | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* The label displayed above the progressbar.
|
|
30
|
+
*/
|
|
31
|
+
label?: ReactNode | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* The semantic color of the progressbar.
|
|
34
|
+
*
|
|
35
|
+
* @default "accent"
|
|
36
|
+
*/
|
|
37
|
+
color?: ProgressVariants["color"] | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* The border radius of the progressbar.
|
|
40
|
+
*
|
|
41
|
+
* @default "rounded"
|
|
42
|
+
*/
|
|
43
|
+
radius?: ProgressVariants["radius"] | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* The size of the progressbar.
|
|
46
|
+
*
|
|
47
|
+
* @default "md"
|
|
48
|
+
*/
|
|
49
|
+
size?: ProgressVariants["size"] | undefined;
|
|
50
|
+
}
|
|
51
|
+
export type ProgressProps = HuiComponentProps<ProgressOwnProps, ProgressSlots>;
|
|
52
|
+
export declare function Progress(rawProps: ProgressProps): ReactElement;
|
|
53
|
+
//#endregion
|
|
54
|
+
export {};
|
|
55
|
+
//# sourceMappingURL=progress.d.ts.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
|
|
2
|
+
import { CSS_VARS, cc, progressControl, progressRecipe, toStrbool } from "@hebium-ui/core";
|
|
3
|
+
import { useId } from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/progress/progress.tsx
|
|
6
|
+
function Progress(rawProps) {
|
|
7
|
+
const { min, max, value, valueText, label, color, radius, size, classNames, styles, nonce, ...restProps } = useHuiProps("Progress", rawProps);
|
|
8
|
+
const progressId = useId();
|
|
9
|
+
const progress = progressControl.resolve({
|
|
10
|
+
progressId,
|
|
11
|
+
hasLabel: Boolean(label),
|
|
12
|
+
min,
|
|
13
|
+
max,
|
|
14
|
+
value,
|
|
15
|
+
valueText
|
|
16
|
+
});
|
|
17
|
+
const recipe = progressRecipe({
|
|
18
|
+
color,
|
|
19
|
+
indeterminate: toStrbool(progress.isIndeterminate),
|
|
20
|
+
radius,
|
|
21
|
+
size
|
|
22
|
+
});
|
|
23
|
+
const cls = useHuiClassNames("Progress", recipe, classNames);
|
|
24
|
+
const sls = useHuiStyles("Progress", styles);
|
|
25
|
+
const labelAttrs = progressControl.getLabelAttributes(progress);
|
|
26
|
+
const barAttrs = progressControl.getBarAttributes(progress);
|
|
27
|
+
const valueAttrs = progressControl.getValueAttributes();
|
|
28
|
+
const valueClassName = `progress-value-${progress.progressId}`;
|
|
29
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
30
|
+
className: cls.root,
|
|
31
|
+
style: sls.root,
|
|
32
|
+
children: [label && /* @__PURE__ */ jsx("div", {
|
|
33
|
+
className: cls.label,
|
|
34
|
+
style: sls.label,
|
|
35
|
+
...labelAttrs,
|
|
36
|
+
children: label
|
|
37
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
38
|
+
className: cls.bar,
|
|
39
|
+
style: sls.bar,
|
|
40
|
+
...barAttrs,
|
|
41
|
+
...restProps,
|
|
42
|
+
children: [/* @__PURE__ */ jsx("style", {
|
|
43
|
+
nonce,
|
|
44
|
+
children: `.${valueClassName} {${CSS_VARS.arbitraryWidth}: ${progress.width}}`
|
|
45
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
46
|
+
className: cc(cls.value, valueClassName),
|
|
47
|
+
style: sls.value,
|
|
48
|
+
...valueAttrs,
|
|
49
|
+
children: progress.isIndeterminate ? void 0 : valueText
|
|
50
|
+
})]
|
|
51
|
+
})]
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { Progress };
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.js","names":[],"sources":["../../../src/components/progress/progress.tsx"],"sourcesContent":["import {\n cc,\n CSS_VARS,\n progressControl,\n progressRecipe,\n type ProgressSlots,\n type ProgressVariants,\n toStrbool,\n} from \"@hebium-ui/core\";\nimport { type ComponentProps, type ReactElement, type ReactNode, useId } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps } from \"~/types\";\n\ntype HtmlDivProps = ComponentProps<\"div\">;\n\ninterface ProgressOwnProps extends HtmlDivProps {\n /**\n * The minimum value of the progress range.\n *\n * @default 0\n */\n min?: number | undefined;\n /**\n * The maximum value of the progress range.\n *\n * @default 100\n */\n max?: number | undefined;\n /**\n * The current value of the progress. Omit this prop when progress is indeterminate.\n */\n value?: number | undefined;\n /**\n * The human-readable text alternative for the current value.\n */\n valueText?: string | undefined;\n /**\n * The label displayed above the progressbar.\n */\n label?: ReactNode | undefined;\n /**\n * The semantic color of the progressbar.\n *\n * @default \"accent\"\n */\n color?: ProgressVariants[\"color\"] | undefined;\n /**\n * The border radius of the progressbar.\n *\n * @default \"rounded\"\n */\n radius?: ProgressVariants[\"radius\"] | undefined;\n /**\n * The size of the progressbar.\n *\n * @default \"md\"\n */\n size?: ProgressVariants[\"size\"] | undefined;\n}\n\nexport type ProgressProps = HuiComponentProps<\n ProgressOwnProps,\n ProgressSlots\n>;\n\nexport function Progress(rawProps: ProgressProps): ReactElement {\n const {\n min,\n max,\n value,\n valueText,\n label,\n color,\n radius,\n size,\n classNames,\n styles,\n nonce,\n ...restProps\n } = useHuiProps(\"Progress\", rawProps);\n const progressId = useId();\n const progress = progressControl.resolve({\n progressId,\n hasLabel: Boolean(label),\n min,\n max,\n value,\n valueText,\n });\n\n const recipe = progressRecipe({\n color,\n indeterminate: toStrbool(progress.isIndeterminate),\n radius,\n size,\n });\n const cls = useHuiClassNames(\"Progress\", recipe, classNames);\n const sls = useHuiStyles(\"Progress\", styles);\n const labelAttrs = progressControl.getLabelAttributes(progress);\n const barAttrs = progressControl.getBarAttributes(progress);\n const valueAttrs = progressControl.getValueAttributes();\n const valueClassName = `progress-value-${progress.progressId}`;\n\n return (\n <div\n className={cls.root}\n style={sls.root}\n >\n {label\n && (\n <div\n className={cls.label}\n style={sls.label}\n {...labelAttrs}\n >\n {label}\n </div>\n )}\n <div\n className={cls.bar}\n style={sls.bar}\n {...barAttrs}\n {...restProps}\n >\n <style nonce={nonce}>\n {`.${valueClassName} {${CSS_VARS.arbitraryWidth}: ${progress.width}}`}\n </style>\n <div\n className={cc(cls.value, valueClassName)}\n style={sls.value}\n {...valueAttrs}\n >\n {progress.isIndeterminate ? undefined : valueText}\n </div>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;AAiEA,SAAgB,SAAS,UAAuC;CAC9D,MAAM,EACJ,KACA,KACA,OACA,WACA,OACA,OACA,QACA,MACA,YACA,QACA,OACA,GAAG,cACD,YAAY,YAAY,QAAQ;CACpC,MAAM,aAAa,MAAM;CACzB,MAAM,WAAW,gBAAgB,QAAQ;EACvC;EACA,UAAU,QAAQ,KAAK;EACvB;EACA;EACA;EACA;CACF,CAAC;CAED,MAAM,SAAS,eAAe;EAC5B;EACA,eAAe,UAAU,SAAS,eAAe;EACjD;EACA;CACF,CAAC;CACD,MAAM,MAAM,iBAAiB,YAAY,QAAQ,UAAU;CAC3D,MAAM,MAAM,aAAa,YAAY,MAAM;CAC3C,MAAM,aAAa,gBAAgB,mBAAmB,QAAQ;CAC9D,MAAM,WAAW,gBAAgB,iBAAiB,QAAQ;CAC1D,MAAM,aAAa,gBAAgB,mBAAmB;CACtD,MAAM,iBAAiB,kBAAkB,SAAS;CAElD,OACE,qBAAC,OAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EAFb,UAAA,CAIG,SAEG,oBAAC,OAAD;GACE,WAAW,IAAI;GACf,OAAO,IAAI;GACX,GAAI;GAEH,UAAA;EACE,CAAA,GAET,qBAAC,OAAD;GACE,WAAW,IAAI;GACf,OAAO,IAAI;GACX,GAAI;GACJ,GAAI;GAJN,UAAA,CAME,oBAAC,SAAD;IAAc;IACX,UAAA,IAAI,eAAe,IAAI,SAAS,eAAe,IAAI,SAAS,MAAM;GAC9D,CAAA,GACP,oBAAC,OAAD;IACE,WAAW,GAAG,IAAI,OAAO,cAAc;IACvC,OAAO,IAAI;IACX,GAAI;IAEH,UAAA,SAAS,kBAAkB,KAAA,IAAY;GACrC,CAAA,CACF;EACF,CAAA,CAAA;;AAET"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { HuiComponentProps } from "../../types/hui-component.js";
|
|
2
|
+
import "../../types/index.js";
|
|
3
|
+
import { RadioSlots, RadioVariants } from "@hebium-ui/core";
|
|
4
|
+
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
5
|
+
//#region src/components/radio/radio.d.ts
|
|
6
|
+
type HtmlInputProps = Omit<ComponentProps<"input">, "children" | "type">;
|
|
7
|
+
interface RadioOwnProps extends HtmlInputProps {
|
|
8
|
+
/**
|
|
9
|
+
* The label displayed next to the radio control.
|
|
10
|
+
*/
|
|
11
|
+
label?: ReactNode | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* The error message displayed below the label.
|
|
14
|
+
*/
|
|
15
|
+
error?: ReactNode | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* The semantic color of the radio control.
|
|
18
|
+
*
|
|
19
|
+
* @default "accent"
|
|
20
|
+
*/
|
|
21
|
+
color?: RadioVariants["color"] | undefined;
|
|
22
|
+
}
|
|
23
|
+
export type RadioProps = HuiComponentProps<RadioOwnProps, RadioSlots>;
|
|
24
|
+
export declare function Radio(rawProps: RadioProps): ReactElement;
|
|
25
|
+
//#endregion
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=radio.d.ts.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
|
|
2
|
+
import { normalizeAttributes } from "../../utils/attributes/normalize-attributes.js";
|
|
3
|
+
import { radioControl, radioRecipe, toBool, toStrbool } from "@hebium-ui/core";
|
|
4
|
+
import { useId } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/radio/radio.tsx
|
|
7
|
+
function Radio(rawProps) {
|
|
8
|
+
const { id, classNames, styles, label, error, color, ref, ...restProps } = useHuiProps("Radio", rawProps);
|
|
9
|
+
const tmpId = useId();
|
|
10
|
+
const radioState = {
|
|
11
|
+
id: id ?? tmpId,
|
|
12
|
+
invalid: !!error,
|
|
13
|
+
disabled: toBool(restProps.disabled) || toBool(restProps["aria-disabled"])
|
|
14
|
+
};
|
|
15
|
+
const recipe = radioRecipe({
|
|
16
|
+
color,
|
|
17
|
+
error: toStrbool(radioState.invalid)
|
|
18
|
+
});
|
|
19
|
+
const cls = useHuiClassNames("Radio", recipe, classNames);
|
|
20
|
+
const sls = useHuiStyles("Radio", styles);
|
|
21
|
+
const controlAttrs = normalizeAttributes(radioControl.getControlAttributes(radioState));
|
|
22
|
+
const labelAttrs = normalizeAttributes(radioControl.getLabelAttributes(radioState));
|
|
23
|
+
const errorAttrs = radioControl.getErrorAttributes(radioState);
|
|
24
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
25
|
+
className: cls.root,
|
|
26
|
+
style: sls.root,
|
|
27
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
28
|
+
ref,
|
|
29
|
+
className: cls.radio,
|
|
30
|
+
style: sls.radio,
|
|
31
|
+
...controlAttrs,
|
|
32
|
+
...restProps
|
|
33
|
+
}), /* @__PURE__ */ jsxs("div", { children: [label && /* @__PURE__ */ jsx("label", {
|
|
34
|
+
className: cls.label,
|
|
35
|
+
style: sls.label,
|
|
36
|
+
...labelAttrs,
|
|
37
|
+
children: label
|
|
38
|
+
}), error && /* @__PURE__ */ jsxs("p", {
|
|
39
|
+
className: cls.error,
|
|
40
|
+
style: sls.error,
|
|
41
|
+
...errorAttrs,
|
|
42
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
43
|
+
"aria-hidden": true,
|
|
44
|
+
className: cls.errorIcon,
|
|
45
|
+
style: sls.errorIcon
|
|
46
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
47
|
+
className: cls.errorMessage,
|
|
48
|
+
style: sls.errorMessage,
|
|
49
|
+
children: error
|
|
50
|
+
})]
|
|
51
|
+
})] })]
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { Radio };
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=radio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radio.js","names":[],"sources":["../../../src/components/radio/radio.tsx"],"sourcesContent":["import { radioControl, radioRecipe, type RadioSlots, type RadioVariants, toBool, toStrbool } from \"@hebium-ui/core\";\nimport { type ComponentProps, type ReactElement, type ReactNode, useId } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps } from \"~/types\";\nimport { normalizeAttributes } from \"~/utils\";\n\ntype HtmlInputProps = Omit<ComponentProps<\"input\">, \"children\" | \"type\">;\n\ninterface RadioOwnProps extends HtmlInputProps {\n /**\n * The label displayed next to the radio control.\n */\n label?: ReactNode | undefined;\n /**\n * The error message displayed below the label.\n */\n error?: ReactNode | undefined;\n /**\n * The semantic color of the radio control.\n *\n * @default \"accent\"\n */\n color?: RadioVariants[\"color\"] | undefined;\n}\n\nexport type RadioProps = HuiComponentProps<\n RadioOwnProps,\n RadioSlots\n>;\n\nexport function Radio(rawProps: RadioProps): ReactElement {\n const {\n id,\n classNames,\n styles,\n label,\n error,\n color,\n ref,\n ...restProps\n } = useHuiProps(\"Radio\", rawProps);\n\n const tmpId = useId();\n\n const radioState = {\n id: id ?? tmpId,\n invalid: !!error,\n disabled: toBool(restProps.disabled) || toBool(restProps[\"aria-disabled\"]),\n };\n const recipe = radioRecipe({\n color,\n error: toStrbool(radioState.invalid),\n });\n const cls = useHuiClassNames(\"Radio\", recipe, classNames);\n const sls = useHuiStyles(\"Radio\", styles);\n const controlAttrs = normalizeAttributes(radioControl.getControlAttributes(radioState));\n const labelAttrs = normalizeAttributes(radioControl.getLabelAttributes(radioState));\n const errorAttrs = radioControl.getErrorAttributes(radioState);\n\n return (\n <div\n className={cls.root}\n style={sls.root}\n >\n <input\n ref={ref}\n className={cls.radio}\n style={sls.radio}\n {...controlAttrs}\n {...restProps}\n />\n <div>\n {label && (\n <label\n className={cls.label}\n style={sls.label}\n {...labelAttrs}\n >\n {label}\n </label>\n )}\n {error && (\n <p\n className={cls.error}\n style={sls.error}\n {...errorAttrs}\n >\n <span\n aria-hidden\n className={cls.errorIcon}\n style={sls.errorIcon}\n />\n <span\n className={cls.errorMessage}\n style={sls.errorMessage}\n >\n {error}\n </span>\n </p>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;AA8BA,SAAgB,MAAM,UAAoC;CACxD,MAAM,EACJ,IACA,YACA,QACA,OACA,OACA,OACA,KACA,GAAG,cACD,YAAY,SAAS,QAAQ;CAEjC,MAAM,QAAQ,MAAM;CAEpB,MAAM,aAAa;EACjB,IAAI,MAAM;EACV,SAAS,CAAC,CAAC;EACX,UAAU,OAAO,UAAU,QAAQ,KAAK,OAAO,UAAU,gBAAgB;CAC3E;CACA,MAAM,SAAS,YAAY;EACzB;EACA,OAAO,UAAU,WAAW,OAAO;CACrC,CAAC;CACD,MAAM,MAAM,iBAAiB,SAAS,QAAQ,UAAU;CACxD,MAAM,MAAM,aAAa,SAAS,MAAM;CACxC,MAAM,eAAe,oBAAoB,aAAa,qBAAqB,UAAU,CAAC;CACtF,MAAM,aAAa,oBAAoB,aAAa,mBAAmB,UAAU,CAAC;CAClF,MAAM,aAAa,aAAa,mBAAmB,UAAU;CAE7D,OACE,qBAAC,OAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EAFb,UAAA,CAIE,oBAAC,SAAD;GACO;GACL,WAAW,IAAI;GACf,OAAO,IAAI;GACX,GAAI;GACJ,GAAI;EACL,CAAA,GACD,qBAAC,OAAD,EAAA,UAAA,CACG,SACC,oBAAC,SAAD;GACE,WAAW,IAAI;GACf,OAAO,IAAI;GACX,GAAI;GAEH,UAAA;EACI,CAAA,GAER,SACC,qBAAC,KAAD;GACE,WAAW,IAAI;GACf,OAAO,IAAI;GACX,GAAI;GAHN,UAAA,CAKE,oBAAC,QAAD;IACE,eAAA;IACA,WAAW,IAAI;IACf,OAAO,IAAI;GACZ,CAAA,GACD,oBAAC,QAAD;IACE,WAAW,IAAI;IACf,OAAO,IAAI;IAEV,UAAA;GACG,CAAA,CACL;EAEF,CAAA,CAAA,EAAA,CAAA,CACF;;AAET"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { HuiPolymorphicProps } from "../../types/polymorphic.js";
|
|
2
|
+
import "../../types/index.js";
|
|
3
|
+
import { LabelProps } from "../label/label.js";
|
|
4
|
+
import "../label/index.js";
|
|
5
|
+
import { RadiogroupSlots, RadiogroupVariants } from "@hebium-ui/core";
|
|
6
|
+
import { ElementType, ReactElement, ReactNode } from "react";
|
|
7
|
+
//#region src/components/radiogroup/radiogroup.d.ts
|
|
8
|
+
interface RadiogroupOwnProps {
|
|
9
|
+
/**
|
|
10
|
+
* The direction in which radio options are laid out.
|
|
11
|
+
*
|
|
12
|
+
* @default "column"
|
|
13
|
+
*/
|
|
14
|
+
direction?: RadiogroupVariants["direction"] | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* The label displayed above the radio group.
|
|
17
|
+
*/
|
|
18
|
+
label?: ReactNode | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Additional props passed to the internal label component.
|
|
21
|
+
*/
|
|
22
|
+
labelProps?: LabelProps<"div"> | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* The help text displayed below the label.
|
|
25
|
+
*/
|
|
26
|
+
description?: ReactNode | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* The error message displayed below the label.
|
|
29
|
+
*/
|
|
30
|
+
error?: ReactNode | undefined;
|
|
31
|
+
}
|
|
32
|
+
export type RadiogroupProps<E extends ElementType = "div"> = HuiPolymorphicProps<E, RadiogroupOwnProps, RadiogroupSlots>;
|
|
33
|
+
export declare function Radiogroup<E extends ElementType = "div">(rawProps: RadiogroupProps<E>): ReactElement;
|
|
34
|
+
//#endregion
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=radiogroup.d.ts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
|
|
2
|
+
import { normalizeAttributes } from "../../utils/attributes/normalize-attributes.js";
|
|
3
|
+
import { Label } from "../label/label.js";
|
|
4
|
+
import { radiogroupControl, radiogroupRecipe, toBool } from "@hebium-ui/core";
|
|
5
|
+
import { useId } from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/radiogroup/radiogroup.tsx
|
|
8
|
+
function Radiogroup(rawProps) {
|
|
9
|
+
const { as, direction, classNames, styles, label, description, error, labelProps, children, ...restProps } = useHuiProps("Radiogroup", rawProps);
|
|
10
|
+
const labelId = useId();
|
|
11
|
+
const recipe = radiogroupRecipe({ direction });
|
|
12
|
+
const cls = useHuiClassNames("Radiogroup", recipe, classNames);
|
|
13
|
+
const sls = useHuiStyles("Radiogroup", styles);
|
|
14
|
+
const radiogroupState = {
|
|
15
|
+
labelId,
|
|
16
|
+
hasLabel: !!label || !!description || !!error,
|
|
17
|
+
invalid: !!error,
|
|
18
|
+
required: toBool(restProps["aria-required"])
|
|
19
|
+
};
|
|
20
|
+
const rootAttrs = normalizeAttributes(radiogroupControl.getRootAttributes(radiogroupState));
|
|
21
|
+
const labelAttrs = normalizeAttributes(radiogroupControl.getLabelAttributes(radiogroupState));
|
|
22
|
+
return /* @__PURE__ */ jsxs(as ?? "div", {
|
|
23
|
+
className: cls.root,
|
|
24
|
+
style: sls.root,
|
|
25
|
+
...rootAttrs,
|
|
26
|
+
...restProps,
|
|
27
|
+
children: [radiogroupState.hasLabel && /* @__PURE__ */ jsx(Label, {
|
|
28
|
+
as: "div",
|
|
29
|
+
...labelAttrs,
|
|
30
|
+
description,
|
|
31
|
+
error,
|
|
32
|
+
...labelProps,
|
|
33
|
+
children: label
|
|
34
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
35
|
+
className: cls.group,
|
|
36
|
+
style: sls.group,
|
|
37
|
+
children
|
|
38
|
+
})]
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { Radiogroup };
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=radiogroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radiogroup.js","names":[],"sources":["../../../src/components/radiogroup/radiogroup.tsx"],"sourcesContent":["import {\n radiogroupControl,\n radiogroupRecipe,\n type RadiogroupSlots,\n type RadiogroupVariants,\n toBool,\n} from \"@hebium-ui/core\";\nimport { type ElementType, type ReactElement, type ReactNode, useId } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\nimport { normalizeAttributes } from \"~/utils\";\nimport { Label, type LabelProps } from \"../label\";\n\ninterface RadiogroupOwnProps {\n /**\n * The direction in which radio options are laid out.\n *\n * @default \"column\"\n */\n direction?: RadiogroupVariants[\"direction\"] | undefined;\n /**\n * The label displayed above the radio group.\n */\n label?: ReactNode | undefined;\n /**\n * Additional props passed to the internal label component.\n */\n labelProps?: LabelProps<\"div\"> | undefined;\n /**\n * The help text displayed below the label.\n */\n description?: ReactNode | undefined;\n /**\n * The error message displayed below the label.\n */\n error?: ReactNode | undefined;\n}\n\nexport type RadiogroupProps<E extends ElementType = \"div\"> = HuiPolymorphicProps<\n E,\n RadiogroupOwnProps,\n RadiogroupSlots\n>;\n\nexport function Radiogroup<E extends ElementType = \"div\">(rawProps: RadiogroupProps<E>): ReactElement {\n const {\n as,\n direction,\n classNames,\n styles,\n label,\n description,\n error,\n labelProps,\n children,\n ...restProps\n } = useHuiProps(\"Radiogroup\", rawProps);\n\n const labelId = useId();\n\n const recipe = radiogroupRecipe({ direction });\n const cls = useHuiClassNames(\"Radiogroup\", recipe, classNames);\n const sls = useHuiStyles(\"Radiogroup\", styles);\n const radiogroupState = {\n labelId,\n hasLabel: !!label || !!description || !!error,\n invalid: !!error,\n required: toBool(restProps[\"aria-required\"]),\n };\n const rootAttrs = normalizeAttributes(radiogroupControl.getRootAttributes(radiogroupState));\n const labelAttrs = normalizeAttributes(radiogroupControl.getLabelAttributes(radiogroupState));\n\n const Component = as ?? \"div\";\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...rootAttrs}\n {...restProps}\n >\n {radiogroupState.hasLabel\n && (\n <Label\n as=\"div\"\n {...labelAttrs}\n description={description}\n error={error}\n {...labelProps}\n >\n {label}\n </Label>\n )}\n <div\n className={cls.group}\n style={sls.group}\n >\n {children}\n </div>\n </Component>\n );\n}\n"],"mappings":";;;;;;;AA4CA,SAAgB,WAA0C,UAA4C;CACpG,MAAM,EACJ,IACA,WACA,YACA,QACA,OACA,aACA,OACA,YACA,UACA,GAAG,cACD,YAAY,cAAc,QAAQ;CAEtC,MAAM,UAAU,MAAM;CAEtB,MAAM,SAAS,iBAAiB,EAAE,UAAU,CAAC;CAC7C,MAAM,MAAM,iBAAiB,cAAc,QAAQ,UAAU;CAC7D,MAAM,MAAM,aAAa,cAAc,MAAM;CAC7C,MAAM,kBAAkB;EACtB;EACA,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC,eAAe,CAAC,CAAC;EACxC,SAAS,CAAC,CAAC;EACX,UAAU,OAAO,UAAU,gBAAgB;CAC7C;CACA,MAAM,YAAY,oBAAoB,kBAAkB,kBAAkB,eAAe,CAAC;CAC1F,MAAM,aAAa,oBAAoB,kBAAkB,mBAAmB,eAAe,CAAC;CAG5F,OACE,qBAFgB,MAAM,OAEtB;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EACJ,GAAI;EAJN,UAAA,CAMG,gBAAgB,YAEb,oBAAC,OAAD;GACE,IAAG;GACH,GAAI;GACS;GACN;GACP,GAAI;GAEH,UAAA;EACI,CAAA,GAEX,oBAAC,OAAD;GACE,WAAW,IAAI;GACf,OAAO,IAAI;GAEV;EACE,CAAA,CACI;;AAEf"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { HuiPolymorphicProps } from "../../types/polymorphic.js";
|
|
2
|
+
import "../../types/index.js";
|
|
3
|
+
import { SectionSlots, SectionVariants } from "@hebium-ui/core";
|
|
4
|
+
import { ElementType, ReactElement } from "react";
|
|
5
|
+
//#region src/components/section/section.d.ts
|
|
6
|
+
interface SectionOwnProps {
|
|
7
|
+
/**
|
|
8
|
+
* The background color of the section.
|
|
9
|
+
*
|
|
10
|
+
* @default "section"
|
|
11
|
+
*/
|
|
12
|
+
bg?: SectionVariants["bg"] | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* The border radius of the section.
|
|
15
|
+
*
|
|
16
|
+
* @default "base"
|
|
17
|
+
*/
|
|
18
|
+
radius?: SectionVariants["radius"] | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* The padding size of the section.
|
|
21
|
+
*
|
|
22
|
+
* @default "sm"
|
|
23
|
+
*/
|
|
24
|
+
padding?: SectionVariants["padding"] | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* The border style of the section.
|
|
27
|
+
*
|
|
28
|
+
* @default "none"
|
|
29
|
+
*/
|
|
30
|
+
border?: SectionVariants["border"] | undefined;
|
|
31
|
+
}
|
|
32
|
+
export type SectionProps<E extends ElementType = "section"> = HuiPolymorphicProps<E, SectionOwnProps, SectionSlots>;
|
|
33
|
+
export declare function Section<E extends ElementType = "section">(rawProps: SectionProps<E>): ReactElement;
|
|
34
|
+
//#endregion
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=section.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
|
|
2
|
+
import { sectionRecipe } from "@hebium-ui/core";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/section/section.tsx
|
|
5
|
+
function Section(rawProps) {
|
|
6
|
+
const { as, bg, radius, padding, border, className, style, children, ...restProps } = useHuiProps("Section", rawProps);
|
|
7
|
+
const recipe = sectionRecipe({
|
|
8
|
+
bg,
|
|
9
|
+
radius,
|
|
10
|
+
padding,
|
|
11
|
+
border
|
|
12
|
+
});
|
|
13
|
+
const Component = as ?? "section";
|
|
14
|
+
const cls = useHuiClassNames("Section", recipe, { root: className });
|
|
15
|
+
const sls = useHuiStyles("Section", { root: style });
|
|
16
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
17
|
+
className: cls.root,
|
|
18
|
+
style: sls.root,
|
|
19
|
+
...restProps,
|
|
20
|
+
children
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { Section };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=section.js.map
|
|
@@ -0,0 +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 className,\n style,\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: className });\n const sls = useHuiStyles(\"Section\", { root: style });\n\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n"],"mappings":";;;;AAsCA,SAAgB,QAA2C,UAAyC;CAClG,MAAM,EACJ,IACA,IACA,QACA,SACA,QACA,WACA,OACA,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,UAAU,CAAC;CACnE,MAAM,MAAM,aAAa,WAAW,EAAE,MAAM,MAAM,CAAC;CAEnD,OACE,oBAAC,WAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EAEH;CACQ,CAAA;AAEf"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
//#region src/components/segmented-control/segmented-control.context.ts
|
|
3
|
+
const SegmentedControlContext = createContext(null);
|
|
4
|
+
function useSegmentedControlContext() {
|
|
5
|
+
const context = useContext(SegmentedControlContext);
|
|
6
|
+
if (!context) throw new Error("[Hebium UI] SegmentedControl compound components must be used within <SegmentedControl>");
|
|
7
|
+
return context;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { SegmentedControlContext, useSegmentedControlContext };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=segmented-control.context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"segmented-control.context.js","names":[],"sources":["../../../src/components/segmented-control/segmented-control.context.ts"],"sourcesContent":["import { createContext, useContext } from \"react\";\n\nexport interface SegmentedControlContextValue {\n selectedValue: string | undefined;\n onSelect: (value: string) => void;\n}\n\nexport const SegmentedControlContext = createContext<SegmentedControlContextValue | null>(null);\n\nexport function useSegmentedControlContext(): SegmentedControlContextValue {\n const context = useContext(SegmentedControlContext);\n if (!context) {\n throw new Error(\"[Hebium UI] SegmentedControl compound components must be used within <SegmentedControl>\");\n }\n return context;\n}\n"],"mappings":";;AAOA,MAAa,0BAA0B,cAAmD,IAAI;AAE9F,SAAgB,6BAA2D;CACzE,MAAM,UAAU,WAAW,uBAAuB;CAClD,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,yFAAyF;CAE3G,OAAO;AACT"}
|