@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,22 @@
|
|
|
1
|
+
import { HuiComponentProps } from "../../types/hui-component.js";
|
|
2
|
+
import "../../types/index.js";
|
|
3
|
+
import { HeadingSlots, HeadingVariants } from "@hebium-ui/core";
|
|
4
|
+
import { ComponentProps, ReactElement } from "react";
|
|
5
|
+
//#region src/components/heading/heading.d.ts
|
|
6
|
+
export interface HeadingProps extends HuiComponentProps<ComponentProps<"h2">, HeadingSlots> {
|
|
7
|
+
/**
|
|
8
|
+
* The heading level used to choose the rendered heading element.
|
|
9
|
+
*
|
|
10
|
+
* @default 2
|
|
11
|
+
*/
|
|
12
|
+
level?: 1 | 2 | 3 | 4 | 5 | 6 | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* The block margin applied to the heading.
|
|
15
|
+
*
|
|
16
|
+
* @default "none"
|
|
17
|
+
*/
|
|
18
|
+
margin?: HeadingVariants["margin"] | undefined;
|
|
19
|
+
}
|
|
20
|
+
export declare function Heading(rawProps: HeadingProps): ReactElement;
|
|
21
|
+
//#endregion
|
|
22
|
+
//# sourceMappingURL=heading.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
|
|
2
|
+
import { headingRecipe } from "@hebium-ui/core";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/heading/heading.tsx
|
|
5
|
+
function Heading(rawProps) {
|
|
6
|
+
const { level = 2, margin, className, style, children, ...restProps } = useHuiProps("Heading", rawProps);
|
|
7
|
+
const Component = `h${level}`;
|
|
8
|
+
const recipe = headingRecipe({
|
|
9
|
+
level: `${level}`,
|
|
10
|
+
margin
|
|
11
|
+
});
|
|
12
|
+
const cls = useHuiClassNames("Heading", recipe, { root: className });
|
|
13
|
+
const sls = useHuiStyles("Heading", { root: style });
|
|
14
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
15
|
+
className: cls.root,
|
|
16
|
+
style: sls.root,
|
|
17
|
+
...restProps,
|
|
18
|
+
children
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { Heading };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=heading.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heading.js","names":[],"sources":["../../../src/components/heading/heading.tsx"],"sourcesContent":["import { headingRecipe, type HeadingSlots, type HeadingVariants } from \"@hebium-ui/core\";\nimport { type ComponentProps, type ReactElement } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps } from \"~/types\";\n\nexport interface HeadingProps extends HuiComponentProps<ComponentProps<\"h2\">, HeadingSlots> {\n /**\n * The heading level used to choose the rendered heading element.\n *\n * @default 2\n */\n level?: 1 | 2 | 3 | 4 | 5 | 6 | undefined;\n /**\n * The block margin applied to the heading.\n *\n * @default \"none\"\n */\n margin?: HeadingVariants[\"margin\"] | undefined;\n}\n\nexport function Heading(rawProps: HeadingProps): ReactElement {\n const {\n level = 2,\n margin,\n className,\n style,\n children,\n ...restProps\n } = useHuiProps(\"Heading\", rawProps);\n\n const Component = `h${level}` as const;\n\n const recipe = headingRecipe({ level: `${level}`, margin });\n const cls = useHuiClassNames(\"Heading\", recipe, { root: className });\n const sls = useHuiStyles(\"Heading\", { 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,QAAQ,UAAsC;CAC5D,MAAM,EACJ,QAAQ,GACR,QACA,WACA,OACA,UACA,GAAG,cACD,YAAY,WAAW,QAAQ;CAEnC,MAAM,YAAY,IAAI;CAEtB,MAAM,SAAS,cAAc;EAAE,OAAO,GAAG;EAAS;CAAO,CAAC;CAC1D,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,11 @@
|
|
|
1
|
+
import { HuiPolymorphicProps } from "../../types/polymorphic.js";
|
|
2
|
+
import "../../types/index.js";
|
|
3
|
+
import { HrSlots } from "@hebium-ui/core";
|
|
4
|
+
import { ComponentProps, ElementType, ReactElement } from "react";
|
|
5
|
+
//#region src/components/hr/hr.d.ts
|
|
6
|
+
interface HrOwnProps extends ComponentProps<"hr"> {}
|
|
7
|
+
export type HrProps<E extends ElementType = "hr"> = HuiPolymorphicProps<E, HrOwnProps, HrSlots>;
|
|
8
|
+
export declare function Hr<E extends ElementType = "hr">(rawProps: HrProps<E>): ReactElement;
|
|
9
|
+
//#endregion
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=hr.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
|
|
2
|
+
import { hrRecipe } from "@hebium-ui/core";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/hr/hr.tsx
|
|
5
|
+
function Hr(rawProps) {
|
|
6
|
+
const { as, className, style, ...restProps } = useHuiProps("Hr", rawProps);
|
|
7
|
+
const recipe = hrRecipe();
|
|
8
|
+
const cls = useHuiClassNames("Hr", recipe, { root: className });
|
|
9
|
+
const sls = useHuiStyles("Hr", { root: style });
|
|
10
|
+
return /* @__PURE__ */ jsx(as ?? "hr", {
|
|
11
|
+
className: cls.root,
|
|
12
|
+
style: sls.root,
|
|
13
|
+
...restProps
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { Hr };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=hr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hr.js","names":[],"sources":["../../../src/components/hr/hr.tsx"],"sourcesContent":["import { hrRecipe, type HrSlots } from \"@hebium-ui/core\";\nimport { type ComponentProps, type ElementType, type ReactElement } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\n\ninterface HrOwnProps extends ComponentProps<\"hr\"> {}\n\nexport type HrProps<E extends ElementType = \"hr\"> = HuiPolymorphicProps<\n E,\n HrOwnProps,\n HrSlots\n>;\n\nexport function Hr<E extends ElementType = \"hr\">(rawProps: HrProps<E>): ReactElement {\n const {\n as,\n className,\n style,\n ...restProps\n } = useHuiProps(\"Hr\", rawProps);\n\n const recipe = hrRecipe();\n const cls = useHuiClassNames(\"Hr\", recipe, { root: className });\n const sls = useHuiStyles(\"Hr\", { root: style });\n\n const Component = as ?? \"hr\";\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...restProps}\n />\n );\n}\n"],"mappings":";;;;AAaA,SAAgB,GAAiC,UAAoC;CACnF,MAAM,EACJ,IACA,WACA,OACA,GAAG,cACD,YAAY,MAAM,QAAQ;CAE9B,MAAM,SAAS,SAAS;CACxB,MAAM,MAAM,iBAAiB,MAAM,QAAQ,EAAE,MAAM,UAAU,CAAC;CAC9D,MAAM,MAAM,aAAa,MAAM,EAAE,MAAM,MAAM,CAAC;CAG9C,OACE,oBAFgB,MAAM,MAEtB;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;CACL,CAAA;AAEL"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Alert, AlertProps } from "./alert/alert.js";
|
|
2
|
+
import "./alert/index.js";
|
|
3
|
+
import { Anchor, AnchorProps } from "./anchor/anchor.js";
|
|
4
|
+
import "./anchor/index.js";
|
|
5
|
+
import { Avatar, AvatarProps } from "./avatar/avatar.js";
|
|
6
|
+
import "./avatar/index.js";
|
|
7
|
+
import { Blockquote, BlockquoteProps } from "./blockquote/blockquote.js";
|
|
8
|
+
import "./blockquote/index.js";
|
|
9
|
+
import { Button, ButtonProps } from "./button/button.js";
|
|
10
|
+
import "./button/index.js";
|
|
11
|
+
import { Checkbox, CheckboxProps } from "./checkbox/checkbox.js";
|
|
12
|
+
import "./checkbox/index.js";
|
|
13
|
+
import { Code, CodeProps } from "./code/code.js";
|
|
14
|
+
import "./code/index.js";
|
|
15
|
+
import { Details, DetailsProps } from "./details/details.js";
|
|
16
|
+
import "./details/index.js";
|
|
17
|
+
import { Heading, HeadingProps } from "./heading/heading.js";
|
|
18
|
+
import "./heading/index.js";
|
|
19
|
+
import { Dialog, DialogCloseProps, DialogContentProps, DialogProps, DialogTriggerProps } from "./dialog/dialog.js";
|
|
20
|
+
import { useDialogId } from "./dialog/dialog.context.js";
|
|
21
|
+
import "./dialog/index.js";
|
|
22
|
+
import { DdProps, Dl, DlProps, DtProps } from "./dl/dl.js";
|
|
23
|
+
import "./dl/index.js";
|
|
24
|
+
import { Drawer, DrawerCloseProps, DrawerContentProps, DrawerProps, DrawerTriggerProps } from "./drawer/drawer.js";
|
|
25
|
+
import { useDrawerId } from "./drawer/drawer.context.js";
|
|
26
|
+
import "./drawer/index.js";
|
|
27
|
+
import { Fieldset, FieldsetProps } from "./fieldset/fieldset.js";
|
|
28
|
+
import "./fieldset/index.js";
|
|
29
|
+
import { Hr, HrProps } from "./hr/hr.js";
|
|
30
|
+
import "./hr/index.js";
|
|
31
|
+
import { Label, LabelProps } from "./label/label.js";
|
|
32
|
+
import "./label/index.js";
|
|
33
|
+
import { Input, InputProps } from "./input/input.js";
|
|
34
|
+
import "./input/index.js";
|
|
35
|
+
import { Menu, MenuContentProps, MenuItemProps, MenuProps, MenuTriggerProps } from "./menu/menu.js";
|
|
36
|
+
import { useMenuId } from "./menu/menu.context.js";
|
|
37
|
+
import "./menu/index.js";
|
|
38
|
+
import { Paragraph, ParagraphProps } from "./paragraph/paragraph.js";
|
|
39
|
+
import "./paragraph/index.js";
|
|
40
|
+
import { Popover, PopoverContentProps, PopoverProps, PopoverTriggerProps } from "./popover/popover.js";
|
|
41
|
+
import { usePopoverId } from "./popover/popover.context.js";
|
|
42
|
+
import "./popover/index.js";
|
|
43
|
+
import { Progress, ProgressProps } from "./progress/progress.js";
|
|
44
|
+
import "./progress/index.js";
|
|
45
|
+
import { Radio, RadioProps } from "./radio/radio.js";
|
|
46
|
+
import "./radio/index.js";
|
|
47
|
+
import { Radiogroup, RadiogroupProps } from "./radiogroup/radiogroup.js";
|
|
48
|
+
import "./radiogroup/index.js";
|
|
49
|
+
import { Section, SectionProps } from "./section/section.js";
|
|
50
|
+
import "./section/index.js";
|
|
51
|
+
import { SegmentedControl, SegmentedControlItemProps, SegmentedControlProps } from "./segmented-control/segmented-control.js";
|
|
52
|
+
import "./segmented-control/index.js";
|
|
53
|
+
import { Select, SelectProps } from "./select/select.js";
|
|
54
|
+
import "./select/index.js";
|
|
55
|
+
import { CaptionProps, Table, TableProps, TbodyProps, TdProps, TfootProps, ThProps, TheadProps, TrProps } from "./table/table.js";
|
|
56
|
+
import "./table/index.js";
|
|
57
|
+
import { Tabs, TabsListProps, TabsPanelProps, TabsProps, TabsTabProps } from "./tabs/tabs.js";
|
|
58
|
+
import "./tabs/index.js";
|
|
59
|
+
import { Textarea, TextareaProps } from "./textarea/textarea.js";
|
|
60
|
+
import "./textarea/index.js";
|
|
61
|
+
import { Tooltip, TooltipContentProps, TooltipProps, TooltipTriggerProps } from "./tooltip/tooltip.js";
|
|
62
|
+
import { useTooltipId } from "./tooltip/tooltip.context.js";
|
|
63
|
+
import "./tooltip/index.js";
|
|
64
|
+
import { VisuallyHidden, VisuallyHiddenProps } from "./visually-hidden/visually-hidden.js";
|
|
65
|
+
import "./visually-hidden/index.js";
|
|
66
|
+
export { Alert, AlertProps, Anchor, AnchorProps, Avatar, AvatarProps, Blockquote, BlockquoteProps, Button, ButtonProps, CaptionProps, Checkbox, CheckboxProps, Code, CodeProps, DdProps, Details, DetailsProps, Dialog, DialogCloseProps, DialogContentProps, DialogProps, DialogTriggerProps, Dl, DlProps, Drawer, DrawerCloseProps, DrawerContentProps, DrawerProps, DrawerTriggerProps, DtProps, Fieldset, FieldsetProps, Heading, HeadingProps, Hr, HrProps, Input, InputProps, Label, LabelProps, Menu, MenuContentProps, MenuItemProps, MenuProps, MenuTriggerProps, Paragraph, ParagraphProps, Popover, PopoverContentProps, PopoverProps, PopoverTriggerProps, Progress, ProgressProps, Radio, RadioProps, Radiogroup, RadiogroupProps, Section, SectionProps, SegmentedControl, SegmentedControlItemProps, SegmentedControlProps, Select, SelectProps, Table, TableProps, Tabs, TabsListProps, TabsPanelProps, TabsProps, TabsTabProps, TbodyProps, TdProps, Textarea, TextareaProps, TfootProps, ThProps, TheadProps, Tooltip, TooltipContentProps, TooltipProps, TooltipTriggerProps, TrProps, VisuallyHidden, VisuallyHiddenProps, useDialogId, useDrawerId, useMenuId, usePopoverId, useTooltipId };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { HuiComponentProps } from "../../types/hui-component.js";
|
|
2
|
+
import "../../types/index.js";
|
|
3
|
+
import { LabelProps } from "../label/label.js";
|
|
4
|
+
import "../label/index.js";
|
|
5
|
+
import { InputSlots, InputVariants } from "@hebium-ui/core";
|
|
6
|
+
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
7
|
+
//#region src/components/input/input.d.ts
|
|
8
|
+
type HtmlInputProps = Omit<ComponentProps<"input">, "children" | "color">;
|
|
9
|
+
interface InputOwnProps extends HtmlInputProps {
|
|
10
|
+
/**
|
|
11
|
+
* The semantic color of the input.
|
|
12
|
+
*
|
|
13
|
+
* @default "accent"
|
|
14
|
+
*/
|
|
15
|
+
color?: InputVariants["color"] | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* The label displayed above the input.
|
|
18
|
+
*/
|
|
19
|
+
label?: ReactNode | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Additional props passed to the internal label component.
|
|
22
|
+
*/
|
|
23
|
+
labelProps?: LabelProps | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* The help text displayed below the label.
|
|
26
|
+
*/
|
|
27
|
+
description?: ReactNode | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* The validation error message displayed below the label.
|
|
30
|
+
*/
|
|
31
|
+
error?: ReactNode | undefined;
|
|
32
|
+
}
|
|
33
|
+
export type InputProps = HuiComponentProps<InputOwnProps, InputSlots>;
|
|
34
|
+
export declare function Input(rawProps: InputProps): ReactElement;
|
|
35
|
+
//#endregion
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=input.d.ts.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
|
|
2
|
+
import { normalizeAttributes } from "../../utils/attributes/normalize-attributes.js";
|
|
3
|
+
import { Label } from "../label/label.js";
|
|
4
|
+
import { inputControl, inputRecipe, toBool, toStrbool } from "@hebium-ui/core";
|
|
5
|
+
import { useId } from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/input/input.tsx
|
|
8
|
+
function Input(rawProps) {
|
|
9
|
+
const tmpId = useId();
|
|
10
|
+
const { id, classNames, styles, color, label, description, error, labelProps, ...restProps } = useHuiProps("Input", rawProps);
|
|
11
|
+
const inputState = {
|
|
12
|
+
id: id || tmpId,
|
|
13
|
+
invalid: !!error,
|
|
14
|
+
required: restProps.required ?? toBool(restProps["aria-required"]),
|
|
15
|
+
disabled: toBool(restProps.disabled) || toBool(restProps["aria-disabled"]),
|
|
16
|
+
readOnly: toBool(restProps.readOnly) || toBool(restProps["aria-readonly"])
|
|
17
|
+
};
|
|
18
|
+
const recipe = inputRecipe({
|
|
19
|
+
color,
|
|
20
|
+
error: toStrbool(inputState.invalid)
|
|
21
|
+
});
|
|
22
|
+
const cls = useHuiClassNames("Input", recipe, classNames);
|
|
23
|
+
const sls = useHuiStyles("Input", styles);
|
|
24
|
+
const hasLabel = !!label || !!description || !!error;
|
|
25
|
+
const controlAttrs = normalizeAttributes(inputControl.getControlAttributes(inputState));
|
|
26
|
+
const labelAttrs = normalizeAttributes(inputControl.getLabelAttributes(inputState));
|
|
27
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
28
|
+
className: cls.root,
|
|
29
|
+
style: sls.root,
|
|
30
|
+
children: [hasLabel && /* @__PURE__ */ jsx(Label, {
|
|
31
|
+
...labelAttrs,
|
|
32
|
+
description,
|
|
33
|
+
error,
|
|
34
|
+
...labelProps,
|
|
35
|
+
children: label
|
|
36
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
37
|
+
className: cls.input,
|
|
38
|
+
style: sls.input,
|
|
39
|
+
...controlAttrs,
|
|
40
|
+
...restProps
|
|
41
|
+
})]
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { Input };
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.js","names":[],"sources":["../../../src/components/input/input.tsx"],"sourcesContent":["import { inputControl, inputRecipe, type InputSlots, type InputVariants, toBool, toStrbool } from \"@hebium-ui/core\";\nimport { type ComponentProps, type ReactElement, type ReactNode, useId } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps } from \"~/types\";\nimport { normalizeAttributes } from \"~/utils\";\nimport { Label, type LabelProps } from \"../label\";\n\ntype HtmlInputProps = Omit<ComponentProps<\"input\">, \"children\" | \"color\">;\n\ninterface InputOwnProps extends HtmlInputProps {\n /**\n * The semantic color of the input.\n *\n * @default \"accent\"\n */\n color?: InputVariants[\"color\"] | undefined;\n /**\n * The label displayed above the input.\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 InputProps = HuiComponentProps<\n InputOwnProps,\n InputSlots\n>;\n\nexport function Input(rawProps: InputProps): ReactElement {\n const tmpId = useId();\n const {\n id,\n classNames,\n styles,\n color,\n label,\n description,\n error,\n labelProps,\n ...restProps\n } = useHuiProps(\"Input\", rawProps);\n\n const inputState = {\n id: id || tmpId,\n invalid: !!error,\n required: restProps.required ?? toBool(restProps[\"aria-required\"]),\n disabled: toBool(restProps.disabled) || toBool(restProps[\"aria-disabled\"]),\n readOnly: toBool(restProps.readOnly) || toBool(restProps[\"aria-readonly\"]),\n };\n const recipe = inputRecipe({\n color,\n error: toStrbool(inputState.invalid),\n });\n const cls = useHuiClassNames(\"Input\", recipe, classNames);\n const sls = useHuiStyles(\"Input\", styles);\n\n const hasLabel = !!label || !!description || !!error;\n const controlAttrs = normalizeAttributes(inputControl.getControlAttributes(inputState));\n const labelAttrs = normalizeAttributes(inputControl.getLabelAttributes(inputState));\n\n return (\n <div\n className={cls.root}\n style={sls.root}\n >\n {hasLabel\n && (\n <Label\n {...labelAttrs}\n description={description}\n error={error}\n {...labelProps}\n >\n {label}\n </Label>\n )}\n <input\n className={cls.input}\n style={sls.input}\n {...controlAttrs}\n {...restProps}\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;AAuCA,SAAgB,MAAM,UAAoC;CACxD,MAAM,QAAQ,MAAM;CACpB,MAAM,EACJ,IACA,YACA,QACA,OACA,OACA,aACA,OACA,YACA,GAAG,cACD,YAAY,SAAS,QAAQ;CAEjC,MAAM,aAAa;EACjB,IAAI,MAAM;EACV,SAAS,CAAC,CAAC;EACX,UAAU,UAAU,YAAY,OAAO,UAAU,gBAAgB;EACjE,UAAU,OAAO,UAAU,QAAQ,KAAK,OAAO,UAAU,gBAAgB;EACzE,UAAU,OAAO,UAAU,QAAQ,KAAK,OAAO,UAAU,gBAAgB;CAC3E;CACA,MAAM,SAAS,YAAY;EACzB;EACA,OAAO,UAAU,WAAW,OAAO;CACrC,CAAC;CACD,MAAM,MAAM,iBAAiB,SAAS,QAAQ,UAAU;CACxD,MAAM,MAAM,aAAa,SAAS,MAAM;CAExC,MAAM,WAAW,CAAC,CAAC,SAAS,CAAC,CAAC,eAAe,CAAC,CAAC;CAC/C,MAAM,eAAe,oBAAoB,aAAa,qBAAqB,UAAU,CAAC;CACtF,MAAM,aAAa,oBAAoB,aAAa,mBAAmB,UAAU,CAAC;CAElF,OACE,qBAAC,OAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EAFb,UAAA,CAIG,YAEG,oBAAC,OAAD;GACE,GAAI;GACS;GACN;GACP,GAAI;GAEH,UAAA;EACI,CAAA,GAEX,oBAAC,SAAD;GACE,WAAW,IAAI;GACf,OAAO,IAAI;GACX,GAAI;GACJ,GAAI;EACL,CAAA,CACE;;AAET"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { HuiPolymorphicProps } from "../../types/polymorphic.js";
|
|
2
|
+
import "../../types/index.js";
|
|
3
|
+
import { LabelMarker, LabelSlots, LabelVariants } from "@hebium-ui/core";
|
|
4
|
+
import { ElementType, ReactElement, ReactNode } from "react";
|
|
5
|
+
//#region src/components/label/label.d.ts
|
|
6
|
+
interface LabelOwnProps {
|
|
7
|
+
/**
|
|
8
|
+
* The visual state of the label.
|
|
9
|
+
*/
|
|
10
|
+
variant?: LabelVariants["variant"] | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* The marker displayed for required or optional fields. Use the `asterisk` variant for a highlighted asterisk marker.
|
|
13
|
+
*/
|
|
14
|
+
marker?: LabelMarker<ReactNode> | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* The help text displayed below the label.
|
|
17
|
+
*/
|
|
18
|
+
description?: ReactNode | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* The validation error message displayed below the label.
|
|
21
|
+
*/
|
|
22
|
+
error?: ReactNode | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Whether the label should render the required marker.
|
|
25
|
+
*/
|
|
26
|
+
"data-required"?: boolean | "true" | "false" | undefined;
|
|
27
|
+
}
|
|
28
|
+
export type LabelProps<E extends ElementType = "label"> = HuiPolymorphicProps<E, LabelOwnProps, LabelSlots>;
|
|
29
|
+
export declare function Label<E extends ElementType = "label">(rawProps: LabelProps<E>): ReactElement;
|
|
30
|
+
//#endregion
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=label.d.ts.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
|
|
2
|
+
import { DEFAULT_LABEL_MAKER, labelMarker, labelRecipe, toBool } from "@hebium-ui/core";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/label/label.tsx
|
|
5
|
+
function Label(rawProps) {
|
|
6
|
+
const { as, variant, children, marker, description, error, "data-required": dataRequired, classNames, styles, ...restProps } = useHuiProps("Label", rawProps);
|
|
7
|
+
const resolvedMarker = labelMarker(marker ?? DEFAULT_LABEL_MAKER, toBool(dataRequired));
|
|
8
|
+
const recipe = labelRecipe({
|
|
9
|
+
marker: resolvedMarker.label ? resolvedMarker.variant : void 0,
|
|
10
|
+
variant
|
|
11
|
+
});
|
|
12
|
+
const cls = useHuiClassNames("Label", recipe, classNames);
|
|
13
|
+
const sls = useHuiStyles("Label", styles);
|
|
14
|
+
return /* @__PURE__ */ jsxs(as ?? "label", {
|
|
15
|
+
className: cls.root,
|
|
16
|
+
style: sls.root,
|
|
17
|
+
...restProps,
|
|
18
|
+
children: [
|
|
19
|
+
children && /* @__PURE__ */ jsx("span", {
|
|
20
|
+
className: cls.fieldName,
|
|
21
|
+
style: sls.fieldName,
|
|
22
|
+
children
|
|
23
|
+
}),
|
|
24
|
+
resolvedMarker.label && /* @__PURE__ */ jsx("span", {
|
|
25
|
+
"aria-label": resolvedMarker["aria-label"],
|
|
26
|
+
className: cls.fieldMarker,
|
|
27
|
+
style: sls.fieldMarker,
|
|
28
|
+
children: resolvedMarker.label
|
|
29
|
+
}),
|
|
30
|
+
description && /* @__PURE__ */ jsx("p", {
|
|
31
|
+
className: cls.description,
|
|
32
|
+
style: sls.description,
|
|
33
|
+
children: description
|
|
34
|
+
}),
|
|
35
|
+
error && /* @__PURE__ */ jsxs("p", {
|
|
36
|
+
className: cls.error,
|
|
37
|
+
style: sls.error,
|
|
38
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
39
|
+
"aria-hidden": true,
|
|
40
|
+
className: cls.errorIcon,
|
|
41
|
+
style: sls.errorIcon
|
|
42
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
43
|
+
className: cls.errorMessage,
|
|
44
|
+
style: sls.errorMessage,
|
|
45
|
+
children: error
|
|
46
|
+
})]
|
|
47
|
+
})
|
|
48
|
+
]
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { Label };
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=label.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label.js","names":[],"sources":["../../../src/components/label/label.tsx"],"sourcesContent":["import {\n DEFAULT_LABEL_MAKER,\n type LabelMarker,\n labelMarker,\n labelRecipe,\n type LabelSlots,\n type LabelVariants,\n toBool,\n} from \"@hebium-ui/core\";\nimport { type ElementType, type ReactElement, type ReactNode } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\n\ninterface LabelOwnProps {\n /**\n * The visual state of the label.\n */\n variant?: LabelVariants[\"variant\"] | undefined;\n /**\n * The marker displayed for required or optional fields. Use the `asterisk` variant for a highlighted asterisk marker.\n */\n marker?: LabelMarker<ReactNode> | undefined;\n /**\n * The help text displayed below the label.\n */\n description?: ReactNode | undefined;\n /**\n * The validation error message displayed below the label.\n */\n error?: ReactNode | undefined;\n /**\n * Whether the label should render the required marker.\n */\n \"data-required\"?: boolean | \"true\" | \"false\" | undefined;\n}\n\nexport type LabelProps<E extends ElementType = \"label\"> = HuiPolymorphicProps<\n E,\n LabelOwnProps,\n LabelSlots\n>;\n\nexport function Label<E extends ElementType = \"label\">(rawProps: LabelProps<E>): ReactElement {\n const {\n as,\n variant,\n children,\n marker,\n description,\n error,\n \"data-required\": dataRequired,\n classNames,\n styles,\n ...restProps\n } = useHuiProps(\"Label\", rawProps);\n\n const resolvedMarker = labelMarker(marker ?? DEFAULT_LABEL_MAKER, toBool(dataRequired));\n const recipe = labelRecipe({\n marker: resolvedMarker.label ? resolvedMarker.variant : undefined,\n variant,\n });\n const cls = useHuiClassNames(\"Label\", recipe, classNames);\n const sls = useHuiStyles(\"Label\", styles);\n\n const Component = as ?? \"label\";\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...restProps}\n >\n {children && (\n <span\n className={cls.fieldName}\n style={sls.fieldName}\n >\n {children}\n </span>\n )}\n {resolvedMarker.label && (\n <span\n aria-label={resolvedMarker[\"aria-label\"]}\n className={cls.fieldMarker}\n style={sls.fieldMarker}\n >\n {resolvedMarker.label}\n </span>\n )}\n {description && (\n <p\n className={cls.description}\n style={sls.description}\n >\n {description}\n </p>\n )}\n {error && (\n <p\n className={cls.error}\n style={sls.error}\n >\n <span\n aria-hidden\n className={cls.errorIcon}\n style={sls.errorIcon}\n />\n <span\n className={cls.errorMessage}\n style={sls.errorMessage}\n >\n {error}\n </span>\n </p>\n )}\n </Component>\n );\n}\n"],"mappings":";;;;AA0CA,SAAgB,MAAuC,UAAuC;CAC5F,MAAM,EACJ,IACA,SACA,UACA,QACA,aACA,OACA,iBAAiB,cACjB,YACA,QACA,GAAG,cACD,YAAY,SAAS,QAAQ;CAEjC,MAAM,iBAAiB,YAAY,UAAU,qBAAqB,OAAO,YAAY,CAAC;CACtF,MAAM,SAAS,YAAY;EACzB,QAAQ,eAAe,QAAQ,eAAe,UAAU,KAAA;EACxD;CACF,CAAC;CACD,MAAM,MAAM,iBAAiB,SAAS,QAAQ,UAAU;CACxD,MAAM,MAAM,aAAa,SAAS,MAAM;CAGxC,OACE,qBAFgB,MAAM,SAEtB;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EAHN,UAAA;GAKG,YACC,oBAAC,QAAD;IACE,WAAW,IAAI;IACf,OAAO,IAAI;IAEV;GACG,CAAA;GAEP,eAAe,SACd,oBAAC,QAAD;IACE,cAAY,eAAe;IAC3B,WAAW,IAAI;IACf,OAAO,IAAI;IAEV,UAAA,eAAe;GACZ,CAAA;GAEP,eACC,oBAAC,KAAD;IACE,WAAW,IAAI;IACf,OAAO,IAAI;IAEV,UAAA;GACA,CAAA;GAEJ,SACC,qBAAC,KAAD;IACE,WAAW,IAAI;IACf,OAAO,IAAI;IAFb,UAAA,CAIE,oBAAC,QAAD;KACE,eAAA;KACA,WAAW,IAAI;KACf,OAAO,IAAI;IACZ,CAAA,GACD,oBAAC,QAAD;KACE,WAAW,IAAI;KACf,OAAO,IAAI;KAEV,UAAA;IACG,CAAA,CACL;;EAEI;;AAEf"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
//#region src/components/menu/menu.context.ts
|
|
3
|
+
const MenuContext = createContext(null);
|
|
4
|
+
function useMenuContext() {
|
|
5
|
+
const context = useContext(MenuContext);
|
|
6
|
+
if (!context) throw new Error("[Hebium UI] Menu compound components must be used within <Menu>");
|
|
7
|
+
return context;
|
|
8
|
+
}
|
|
9
|
+
function useMenuId() {
|
|
10
|
+
return useMenuContext().menuId;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { MenuContext, useMenuContext, useMenuId };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=menu.context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu.context.js","names":[],"sources":["../../../src/components/menu/menu.context.ts"],"sourcesContent":["import { createContext, useContext } from \"react\";\n\nexport interface MenuContextValue {\n menuId: string;\n}\n\nexport const MenuContext = createContext<MenuContextValue | null>(null);\n\nexport function useMenuContext(): MenuContextValue {\n const context = useContext(MenuContext);\n if (!context) {\n throw new Error(\"[Hebium UI] Menu compound components must be used within <Menu>\");\n }\n return context;\n}\n\nexport function useMenuId(): string {\n return useMenuContext().menuId;\n}\n"],"mappings":";;AAMA,MAAa,cAAc,cAAuC,IAAI;AAEtE,SAAgB,iBAAmC;CACjD,MAAM,UAAU,WAAW,WAAW;CACtC,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,iEAAiE;CAEnF,OAAO;AACT;AAEA,SAAgB,YAAoB;CAClC,OAAO,eAAe,CAAC,CAAC;AAC1B"}
|
|
@@ -0,0 +1,82 @@
|
|
|
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, MenuItemActivation, MenuitemSlots, MenuitemVariants, PopoverSlots, PopoverVariants } from "@hebium-ui/core";
|
|
6
|
+
import { ElementType, ReactElement, ReactNode } from "react";
|
|
7
|
+
//#region src/components/menu/menu.d.ts
|
|
8
|
+
export interface MenuProps {
|
|
9
|
+
/**
|
|
10
|
+
* The id of the menu content element.
|
|
11
|
+
*/
|
|
12
|
+
id?: string | undefined;
|
|
13
|
+
children?: ReactNode | undefined;
|
|
14
|
+
}
|
|
15
|
+
declare function MenuRoot(rawProps: MenuProps): ReactElement;
|
|
16
|
+
export type MenuTriggerProps<E extends ElementType = typeof Button> = HuiPolymorphicProps<E, {}, ButtonSlots>;
|
|
17
|
+
declare function Trigger<E extends ElementType = typeof Button>(rawProps: MenuTriggerProps<E>): ReactNode;
|
|
18
|
+
interface MenuContentOwnProps {
|
|
19
|
+
/**
|
|
20
|
+
* The preferred anchor position of the menu.
|
|
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 menu content.
|
|
40
|
+
*
|
|
41
|
+
* @default "sm"
|
|
42
|
+
*/
|
|
43
|
+
padding?: PopoverVariants["padding"] | undefined;
|
|
44
|
+
}
|
|
45
|
+
export type MenuContentProps<E extends ElementType = "div"> = HuiPolymorphicProps<E, MenuContentOwnProps, PopoverSlots>;
|
|
46
|
+
declare function Content<E extends ElementType = "div">(rawProps: MenuContentProps<E>): ReactElement;
|
|
47
|
+
interface MenuItemOwnProps {
|
|
48
|
+
/**
|
|
49
|
+
* The semantic color of the menu item.
|
|
50
|
+
*
|
|
51
|
+
* @default "neutral"
|
|
52
|
+
*/
|
|
53
|
+
color?: MenuitemVariants["color"] | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* A printable character used for key navigation within the menu.
|
|
56
|
+
* When the user types a matching key, focus moves to this item.
|
|
57
|
+
*
|
|
58
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/menuitem_role#any_key_that_corresponds_to_a_printable_character_optional | MDN: Keyboard interactions for the menuitem role}
|
|
59
|
+
*/
|
|
60
|
+
focusKey?: string | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Controls the menu item's native action.
|
|
63
|
+
* Managed activation prevents it; native activation allows it.
|
|
64
|
+
*
|
|
65
|
+
* @default "managed"
|
|
66
|
+
*/
|
|
67
|
+
activation?: MenuItemActivation | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Called when the menu item is activated by click or keyboard.
|
|
70
|
+
*/
|
|
71
|
+
onAction?: (() => void) | undefined;
|
|
72
|
+
}
|
|
73
|
+
export type MenuItemProps<E extends ElementType = "div"> = HuiPolymorphicProps<E, MenuItemOwnProps, Exclude<MenuitemSlots, "disabled">>;
|
|
74
|
+
declare function Item<E extends ElementType = "div">(rawProps: MenuItemProps<E>): ReactElement;
|
|
75
|
+
export declare const Menu: typeof MenuRoot & {
|
|
76
|
+
Trigger: typeof Trigger;
|
|
77
|
+
Content: typeof Content;
|
|
78
|
+
Item: typeof Item;
|
|
79
|
+
};
|
|
80
|
+
//#endregion
|
|
81
|
+
export {};
|
|
82
|
+
//# sourceMappingURL=menu.d.ts.map
|
|
@@ -0,0 +1,133 @@
|
|
|
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 { MenuContext, useMenuId } from "./menu.context.js";
|
|
5
|
+
import { menuControl, menuitemRecipe, popoverRecipe, toBool } from "@hebium-ui/core";
|
|
6
|
+
import { useCallback, useId, useMemo } from "react";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
//#region src/components/menu/menu.tsx
|
|
9
|
+
function MenuRoot(rawProps) {
|
|
10
|
+
const { id, children } = useHuiProps("Menu", rawProps);
|
|
11
|
+
const tmpId = useId();
|
|
12
|
+
const menuId = id || tmpId;
|
|
13
|
+
const contextValue = useMemo(() => {
|
|
14
|
+
return { menuId };
|
|
15
|
+
}, [menuId]);
|
|
16
|
+
return /* @__PURE__ */ jsx(MenuContext.Provider, {
|
|
17
|
+
value: contextValue,
|
|
18
|
+
children
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function Trigger(rawProps) {
|
|
22
|
+
const { as, onKeyDown, children, ...restProps } = useHuiProps("MenuTrigger", rawProps);
|
|
23
|
+
const Component = as ?? Button;
|
|
24
|
+
const menuId = useMenuId();
|
|
25
|
+
const attrs = normalizeAttributes(menuControl.getTriggerAttributes({ menuId }, { isButtonElement: as === void 0 }));
|
|
26
|
+
const handleKeyDown = useCallback((e) => {
|
|
27
|
+
onKeyDown?.(e);
|
|
28
|
+
if (e.defaultPrevented) return;
|
|
29
|
+
menuControl.handleMenuTriggerKeydown(e.nativeEvent, menuId);
|
|
30
|
+
}, [onKeyDown, menuId]);
|
|
31
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
32
|
+
...attrs,
|
|
33
|
+
onKeyDown: handleKeyDown,
|
|
34
|
+
...restProps,
|
|
35
|
+
children
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function Content(rawProps) {
|
|
39
|
+
const { as, position, fallbacks, visibility, padding, className, style, children, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...restProps } = useHuiProps("MenuContent", rawProps);
|
|
40
|
+
const Component = as ?? "div";
|
|
41
|
+
const menuId = useMenuId();
|
|
42
|
+
const recipe = popoverRecipe({
|
|
43
|
+
position,
|
|
44
|
+
fallbacks,
|
|
45
|
+
visibility,
|
|
46
|
+
padding: padding ?? "sm"
|
|
47
|
+
});
|
|
48
|
+
const cls = useHuiClassNames("MenuContent", recipe, { root: className });
|
|
49
|
+
const sls = useHuiStyles("MenuContent", { root: style });
|
|
50
|
+
const attrs = normalizeAttributes(menuControl.getContentAttributes({ menuId }, {
|
|
51
|
+
ariaLabel,
|
|
52
|
+
ariaLabelledBy
|
|
53
|
+
}));
|
|
54
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
55
|
+
className: cls.root,
|
|
56
|
+
style: sls.root,
|
|
57
|
+
...attrs,
|
|
58
|
+
...restProps,
|
|
59
|
+
children
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function Item(rawProps) {
|
|
63
|
+
const { as, className, style, color, focusKey, activation = "managed", onClick, onAction, onKeyDown, children, "aria-disabled": ariaDisabled, ...restProps } = useHuiProps("MenuItem", rawProps);
|
|
64
|
+
const Component = as ?? "div";
|
|
65
|
+
const menuId = useMenuId();
|
|
66
|
+
const isDisabled = toBool(ariaDisabled);
|
|
67
|
+
const recipe = menuitemRecipe({ color });
|
|
68
|
+
const cls = useHuiClassNames("MenuItem", recipe, { root: className });
|
|
69
|
+
const sls = useHuiStyles("MenuItem", { root: style });
|
|
70
|
+
const attrs = normalizeAttributes(menuControl.getItemAttributes({ menuId }, {
|
|
71
|
+
focusKey,
|
|
72
|
+
disabled: ariaDisabled == null ? void 0 : isDisabled
|
|
73
|
+
}));
|
|
74
|
+
const handleClick = useCallback((e) => {
|
|
75
|
+
onClick?.(e);
|
|
76
|
+
menuControl.handleMenuitemActivation(e.nativeEvent, menuId, {
|
|
77
|
+
activation,
|
|
78
|
+
disabled: isDisabled
|
|
79
|
+
}, onAction);
|
|
80
|
+
}, [
|
|
81
|
+
activation,
|
|
82
|
+
isDisabled,
|
|
83
|
+
menuId,
|
|
84
|
+
onClick,
|
|
85
|
+
onAction
|
|
86
|
+
]);
|
|
87
|
+
const handleKeyDown = useCallback((e) => {
|
|
88
|
+
onKeyDown?.(e);
|
|
89
|
+
if (e.defaultPrevented) return;
|
|
90
|
+
switch (menuControl.handleMenuitemKeydown(e.nativeEvent, activation)) {
|
|
91
|
+
case "action":
|
|
92
|
+
menuControl.handleMenuitemActivation(e.nativeEvent, menuId, {
|
|
93
|
+
activation,
|
|
94
|
+
disabled: isDisabled
|
|
95
|
+
}, onAction);
|
|
96
|
+
return;
|
|
97
|
+
case "focus-move":
|
|
98
|
+
menuControl.moveMenuitemFocus(e.nativeEvent, menuId);
|
|
99
|
+
return;
|
|
100
|
+
case "focus-set":
|
|
101
|
+
menuControl.setMenuitemFocus(e.nativeEvent, menuId);
|
|
102
|
+
return;
|
|
103
|
+
case "focus-out":
|
|
104
|
+
menuControl.hideMenu(menuId);
|
|
105
|
+
return;
|
|
106
|
+
case "none": return;
|
|
107
|
+
}
|
|
108
|
+
}, [
|
|
109
|
+
onKeyDown,
|
|
110
|
+
activation,
|
|
111
|
+
onAction,
|
|
112
|
+
menuId,
|
|
113
|
+
isDisabled
|
|
114
|
+
]);
|
|
115
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
116
|
+
className: cls.root,
|
|
117
|
+
style: sls.root,
|
|
118
|
+
...attrs,
|
|
119
|
+
onClick: handleClick,
|
|
120
|
+
onKeyDown: handleKeyDown,
|
|
121
|
+
...restProps,
|
|
122
|
+
children
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
const Menu = Object.assign(MenuRoot, {
|
|
126
|
+
Trigger,
|
|
127
|
+
Content,
|
|
128
|
+
Item
|
|
129
|
+
});
|
|
130
|
+
//#endregion
|
|
131
|
+
export { Menu };
|
|
132
|
+
|
|
133
|
+
//# sourceMappingURL=menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu.js","names":[],"sources":["../../../src/components/menu/menu.tsx"],"sourcesContent":["import {\n type ButtonSlots,\n menuControl,\n type MenuItemActivation,\n menuitemRecipe,\n type MenuitemSlots,\n type MenuitemVariants,\n popoverRecipe,\n type PopoverSlots,\n type PopoverVariants,\n toBool,\n} from \"@hebium-ui/core\";\nimport {\n type ElementType,\n type KeyboardEvent,\n type MouseEvent,\n type ReactElement,\n type ReactNode,\n useCallback,\n useId,\n useMemo,\n} from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\nimport { normalizeAttributes } from \"~/utils\";\nimport { Button } from \"../button\";\nimport { MenuContext, type MenuContextValue, useMenuId } from \"./menu.context\";\n\nexport interface MenuProps {\n /**\n * The id of the menu content element.\n */\n id?: string | undefined;\n children?: ReactNode | undefined;\n}\n\nfunction MenuRoot(rawProps: MenuProps): ReactElement {\n const {\n id,\n children,\n } = useHuiProps(\"Menu\", rawProps);\n\n const tmpId = useId();\n const menuId = id || tmpId;\n\n const contextValue = useMemo<MenuContextValue>(() => {\n return {\n menuId,\n };\n }, [menuId]);\n\n return (\n <MenuContext.Provider\n value={contextValue}\n >\n {children}\n </MenuContext.Provider>\n );\n}\n\nexport type MenuTriggerProps<E extends ElementType = typeof Button> = HuiPolymorphicProps<\n E,\n {},\n ButtonSlots\n>;\n\nfunction Trigger<E extends ElementType = typeof Button>(rawProps: MenuTriggerProps<E>): ReactNode {\n const {\n as,\n onKeyDown,\n children,\n ...restProps\n } = useHuiProps(\"MenuTrigger\", rawProps);\n\n const Component = as ?? Button;\n const menuId = useMenuId();\n const attrs = normalizeAttributes(\n menuControl.getTriggerAttributes(\n { menuId },\n { isButtonElement: as === undefined },\n ),\n );\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent<HTMLElement>): void => {\n onKeyDown?.(e);\n if (e.defaultPrevented) return;\n\n menuControl.handleMenuTriggerKeydown(e.nativeEvent, menuId);\n },\n [onKeyDown, menuId],\n );\n\n return (\n <Component\n {...attrs}\n onKeyDown={handleKeyDown}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n\ninterface MenuContentOwnProps {\n /**\n * The preferred anchor position of the menu.\n *\n * @default \"block-start\"\n */\n position?: PopoverVariants[\"position\"] | undefined;\n /**\n * The fallback strategy used when the preferred position overflows.\n *\n * @default \"flip\"\n */\n fallbacks?: PopoverVariants[\"fallbacks\"] | undefined;\n /**\n * The visibility behavior when the anchor is off-screen or overflows.\n *\n * @default \"anchors-visible\"\n * @see This setting depends on browser support for {@link https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/position-visibility | MDN: position-visibility}.\n */\n visibility?: PopoverVariants[\"visibility\"] | undefined;\n /**\n * The padding size of the menu content.\n *\n * @default \"sm\"\n */\n padding?: PopoverVariants[\"padding\"] | undefined;\n}\nexport type MenuContentProps<E extends ElementType = \"div\"> = HuiPolymorphicProps<\n E,\n MenuContentOwnProps,\n PopoverSlots\n>;\n\nfunction Content<E extends ElementType = \"div\">(rawProps: MenuContentProps<E>): ReactElement {\n const {\n as,\n position,\n fallbacks,\n visibility,\n padding,\n className,\n style,\n children,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n ...restProps\n } = useHuiProps(\"MenuContent\", rawProps);\n\n const Component = as ?? \"div\";\n\n const menuId = useMenuId();\n const recipe = popoverRecipe({\n position,\n fallbacks,\n visibility,\n padding: padding ?? \"sm\",\n });\n const cls = useHuiClassNames(\"MenuContent\", recipe, { root: className });\n const sls = useHuiStyles(\"MenuContent\", { root: style });\n const attrs = normalizeAttributes(\n menuControl.getContentAttributes(\n { menuId },\n { ariaLabel, ariaLabelledBy },\n ),\n );\n\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...attrs}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n\ninterface MenuItemOwnProps {\n /**\n * The semantic color of the menu item.\n *\n * @default \"neutral\"\n */\n color?: MenuitemVariants[\"color\"] | undefined;\n /**\n * A printable character used for key navigation within the menu.\n * When the user types a matching key, focus moves to this item.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/menuitem_role#any_key_that_corresponds_to_a_printable_character_optional | MDN: Keyboard interactions for the menuitem role}\n */\n focusKey?: string | undefined;\n /**\n * Controls the menu item's native action.\n * Managed activation prevents it; native activation allows it.\n *\n * @default \"managed\"\n */\n activation?: MenuItemActivation | undefined;\n /**\n * Called when the menu item is activated by click or keyboard.\n */\n onAction?: (() => void) | undefined;\n}\nexport type MenuItemProps<E extends ElementType = \"div\"> = HuiPolymorphicProps<\n E,\n MenuItemOwnProps,\n Exclude<MenuitemSlots, \"disabled\">\n>;\n\nfunction Item<E extends ElementType = \"div\">(rawProps: MenuItemProps<E>): ReactElement {\n const {\n as,\n className,\n style,\n color,\n focusKey,\n activation = \"managed\",\n onClick,\n onAction,\n onKeyDown,\n children,\n \"aria-disabled\": ariaDisabled,\n ...restProps\n } = useHuiProps(\"MenuItem\", rawProps);\n\n const Component = as ?? \"div\";\n\n const menuId = useMenuId();\n const isDisabled = toBool(ariaDisabled);\n const recipe = menuitemRecipe({\n color,\n });\n const cls = useHuiClassNames(\"MenuItem\", recipe, { root: className });\n const sls = useHuiStyles(\"MenuItem\", { root: style });\n const attrs = normalizeAttributes(\n menuControl.getItemAttributes(\n { menuId },\n {\n focusKey,\n disabled: ariaDisabled == null ? undefined : isDisabled,\n },\n ),\n );\n\n const handleClick = useCallback((e: MouseEvent<HTMLElement>) => {\n onClick?.(e);\n menuControl.handleMenuitemActivation(e.nativeEvent, menuId, { activation, disabled: isDisabled }, onAction);\n }, [activation, isDisabled, menuId, onClick, onAction]);\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent<HTMLElement>): void => {\n onKeyDown?.(e);\n if (e.defaultPrevented) return;\n\n const action = menuControl.handleMenuitemKeydown(e.nativeEvent, activation);\n switch (action) {\n case \"action\":\n menuControl.handleMenuitemActivation(e.nativeEvent, menuId, { activation, disabled: isDisabled }, onAction);\n return;\n case \"focus-move\":\n menuControl.moveMenuitemFocus(e.nativeEvent, menuId);\n return;\n case \"focus-set\":\n menuControl.setMenuitemFocus(e.nativeEvent, menuId);\n return;\n case \"focus-out\":\n menuControl.hideMenu(menuId);\n return;\n case \"none\":\n return;\n }\n },\n [\n onKeyDown,\n activation,\n onAction,\n menuId,\n isDisabled,\n ],\n );\n\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...attrs}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n\nexport const Menu = Object.assign(MenuRoot, {\n Trigger,\n Content,\n Item,\n});\n"],"mappings":"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"}
|