@hebium-ui/react 0.1.0-alpha.2 → 0.1.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/alert/alert.d.ts +3 -6
- package/dist/components/alert/alert.js +6 -14
- package/dist/components/alert/alert.js.map +1 -1
- package/dist/components/anchor/anchor.d.ts +1 -4
- package/dist/components/anchor/anchor.js +4 -5
- package/dist/components/anchor/anchor.js.map +1 -1
- package/dist/components/avatar/avatar.d.ts +1 -4
- package/dist/components/avatar/avatar.js +4 -5
- package/dist/components/avatar/avatar.js.map +1 -1
- package/dist/components/blockquote/blockquote.d.ts +1 -4
- package/dist/components/blockquote/blockquote.js +4 -5
- package/dist/components/blockquote/blockquote.js.map +1 -1
- package/dist/components/button/button.d.ts +12 -4
- package/dist/components/button/button.js +30 -11
- package/dist/components/button/button.js.map +1 -1
- package/dist/components/checkbox/checkbox.d.ts +2 -5
- package/dist/components/checkbox/checkbox.js +29 -16
- package/dist/components/checkbox/checkbox.js.map +1 -1
- package/dist/components/code/code.d.ts +1 -4
- package/dist/components/code/code.js +4 -5
- package/dist/components/code/code.js.map +1 -1
- package/dist/components/combobox/combobox-option.js +33 -0
- package/dist/components/combobox/combobox-option.js.map +1 -0
- package/dist/components/combobox/combobox.d.ts +61 -0
- package/dist/components/combobox/combobox.js +208 -0
- package/dist/components/combobox/combobox.js.map +1 -0
- package/dist/components/combobox/index.d.ts +2 -0
- package/dist/components/combobox/use-combobox-form.js +33 -0
- package/dist/components/combobox/use-combobox-form.js.map +1 -0
- package/dist/components/combobox/use-combobox-popover.js +66 -0
- package/dist/components/combobox/use-combobox-popover.js.map +1 -0
- package/dist/components/combobox/use-combobox-state.js +96 -0
- package/dist/components/combobox/use-combobox-state.js.map +1 -0
- package/dist/components/details/details.d.ts +1 -4
- package/dist/components/details/details.js +4 -5
- package/dist/components/details/details.js.map +1 -1
- package/dist/components/dialog/dialog.context.js +1 -2
- package/dist/components/dialog/dialog.d.ts +4 -7
- package/dist/components/dialog/dialog.js +29 -9
- package/dist/components/dialog/dialog.js.map +1 -1
- package/dist/components/dialog/index.d.ts +1 -2
- package/dist/components/dl/dl.d.ts +1 -4
- package/dist/components/dl/dl.js +10 -11
- package/dist/components/dl/dl.js.map +1 -1
- package/dist/components/drawer/drawer.context.js +1 -2
- package/dist/components/drawer/drawer.d.ts +4 -7
- package/dist/components/drawer/drawer.js +29 -9
- package/dist/components/drawer/drawer.js.map +1 -1
- package/dist/components/drawer/index.d.ts +1 -2
- package/dist/components/fieldset/fieldset.d.ts +1 -4
- package/dist/components/fieldset/fieldset.js +4 -5
- package/dist/components/fieldset/fieldset.js.map +1 -1
- package/dist/components/heading/heading.d.ts +1 -4
- package/dist/components/heading/heading.js +4 -5
- package/dist/components/heading/heading.js.map +1 -1
- package/dist/components/hr/hr.d.ts +1 -4
- package/dist/components/hr/hr.js +4 -5
- package/dist/components/hr/hr.js.map +1 -1
- package/dist/components/index.d.ts +35 -26
- package/dist/components/inline-feedback/index.d.ts +2 -0
- package/dist/components/inline-feedback/inline-feedback.d.ts +33 -0
- package/dist/components/inline-feedback/inline-feedback.js +30 -0
- package/dist/components/inline-feedback/inline-feedback.js.map +1 -0
- package/dist/components/input/input.d.ts +1 -4
- package/dist/components/input/input.js +4 -5
- package/dist/components/input/input.js.map +1 -1
- package/dist/components/label/label.d.ts +1 -4
- package/dist/components/label/label.js +6 -7
- package/dist/components/label/label.js.map +1 -1
- package/dist/components/menu/index.d.ts +1 -2
- package/dist/components/menu/menu.context.js +1 -2
- package/dist/components/menu/menu.d.ts +3 -6
- package/dist/components/menu/menu.js +23 -9
- package/dist/components/menu/menu.js.map +1 -1
- package/dist/components/multi-combobox/index.d.ts +2 -0
- package/dist/components/multi-combobox/multi-combobox-option.js +42 -0
- package/dist/components/multi-combobox/multi-combobox-option.js.map +1 -0
- package/dist/components/multi-combobox/multi-combobox-tag.js +54 -0
- package/dist/components/multi-combobox/multi-combobox-tag.js.map +1 -0
- package/dist/components/multi-combobox/multi-combobox.d.ts +72 -0
- package/dist/components/multi-combobox/multi-combobox.js +249 -0
- package/dist/components/multi-combobox/multi-combobox.js.map +1 -0
- package/dist/components/multi-combobox/use-multi-combobox-state.js +91 -0
- package/dist/components/multi-combobox/use-multi-combobox-state.js.map +1 -0
- package/dist/components/paragraph/paragraph.d.ts +1 -4
- package/dist/components/paragraph/paragraph.js +4 -5
- package/dist/components/paragraph/paragraph.js.map +1 -1
- package/dist/components/popover/index.d.ts +1 -2
- package/dist/components/popover/popover.context.js +1 -2
- package/dist/components/popover/popover.d.ts +3 -6
- package/dist/components/popover/popover.js +20 -6
- package/dist/components/popover/popover.js.map +1 -1
- package/dist/components/progress/progress.d.ts +1 -4
- package/dist/components/progress/progress.js +4 -5
- package/dist/components/progress/progress.js.map +1 -1
- package/dist/components/radio/radio.d.ts +1 -4
- package/dist/components/radio/radio.js +4 -5
- package/dist/components/radio/radio.js.map +1 -1
- package/dist/components/radiogroup/radiogroup.d.ts +1 -4
- package/dist/components/radiogroup/radiogroup.js +6 -6
- package/dist/components/radiogroup/radiogroup.js.map +1 -1
- package/dist/components/section/section.d.ts +1 -4
- package/dist/components/section/section.js +4 -5
- package/dist/components/section/section.js.map +1 -1
- package/dist/components/segmented-control/segmented-control.context.js +1 -2
- package/dist/components/segmented-control/segmented-control.d.ts +2 -5
- package/dist/components/segmented-control/segmented-control.js +13 -9
- package/dist/components/segmented-control/segmented-control.js.map +1 -1
- package/dist/components/select/select.d.ts +1 -4
- package/dist/components/select/select.js +4 -5
- package/dist/components/select/select.js.map +1 -1
- package/dist/components/skip-link/index.d.ts +2 -0
- package/dist/components/skip-link/skip-link.d.ts +6 -0
- package/dist/components/skip-link/skip-link.js +20 -0
- package/dist/components/skip-link/skip-link.js.map +1 -0
- package/dist/components/status-icon/index.d.ts +2 -0
- package/dist/components/status-icon/status-icon.d.ts +19 -0
- package/dist/components/status-icon/status-icon.js +22 -0
- package/dist/components/status-icon/status-icon.js.map +1 -0
- package/dist/components/table/table.d.ts +4 -7
- package/dist/components/table/table.js +25 -26
- package/dist/components/table/table.js.map +1 -1
- package/dist/components/tabs/tabs.context.d.ts +1 -4
- package/dist/components/tabs/tabs.context.js +1 -2
- package/dist/components/tabs/tabs.d.ts +2 -5
- package/dist/components/tabs/tabs.js +13 -14
- package/dist/components/tabs/tabs.js.map +1 -1
- package/dist/components/tag/index.d.ts +2 -0
- package/dist/components/tag/tag.d.ts +39 -0
- package/dist/components/tag/tag.js +41 -0
- package/dist/components/tag/tag.js.map +1 -0
- package/dist/components/text/index.d.ts +2 -0
- package/dist/components/text/text.d.ts +22 -0
- package/dist/components/text/text.js +23 -0
- package/dist/components/text/text.js.map +1 -0
- package/dist/components/textarea/textarea.d.ts +1 -4
- package/dist/components/textarea/textarea.js +4 -5
- package/dist/components/textarea/textarea.js.map +1 -1
- package/dist/components/tooltip/index.d.ts +1 -2
- package/dist/components/tooltip/tooltip.context.js +1 -2
- package/dist/components/tooltip/tooltip.d.ts +3 -6
- package/dist/components/tooltip/tooltip.js +19 -5
- package/dist/components/tooltip/tooltip.js.map +1 -1
- package/dist/components/visually-hidden/visually-hidden.d.ts +3 -6
- package/dist/components/visually-hidden/visually-hidden.js +4 -5
- package/dist/components/visually-hidden/visually-hidden.js.map +1 -1
- package/dist/index.d.ts +9 -7
- package/dist/index.js +9 -7
- package/dist/provider/hui-provider.context.d.ts +34 -10
- package/dist/provider/hui-provider.context.js +23 -16
- package/dist/provider/hui-provider.context.js.map +1 -1
- package/dist/provider/hui-provider.d.ts +1 -4
- package/dist/provider/hui-provider.js +1 -2
- package/dist/provider/index.d.ts +1 -1
- package/dist/provider/merge-props.js +1 -2
- package/dist/types/distributive.d.ts +1 -0
- package/dist/types/hui-component.d.ts +11 -7
- package/dist/types/index.d.ts +3 -2
- package/dist/types/polymorphic.d.ts +4 -11
- package/dist/utils/attributes/normalize-attributes.js +1 -2
- package/package.json +9 -9
- package/dist/components/dialog/dialog.context.d.ts +0 -4
- package/dist/components/drawer/drawer.context.d.ts +0 -4
- package/dist/components/menu/menu.context.d.ts +0 -4
- package/dist/components/popover/popover.context.d.ts +0 -4
- package/dist/components/tooltip/tooltip.context.d.ts +0 -4
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
|
|
2
|
-
import { Button } from "../button/button.js";
|
|
3
2
|
import { normalizeAttributes } from "../../utils/attributes/normalize-attributes.js";
|
|
3
|
+
import { Button } from "../button/button.js";
|
|
4
4
|
import { PopoverContext, usePopoverId } from "./popover.context.js";
|
|
5
5
|
import { popoverControl, popoverRecipe } from "@hebium-ui/core";
|
|
6
6
|
import { useId, useMemo } from "react";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
|
-
|
|
8
|
+
// src/components/popover/popover.tsx
|
|
9
|
+
const BUTTON_CLASSES = {
|
|
10
|
+
root: "",
|
|
11
|
+
content: "",
|
|
12
|
+
spinner: "",
|
|
13
|
+
status: ""
|
|
14
|
+
};
|
|
9
15
|
function PopoverRoot(rawProps) {
|
|
10
16
|
const { id, children } = useHuiProps("Popover", rawProps);
|
|
11
17
|
const tmpId = useId();
|
|
@@ -21,16 +27,25 @@ function PopoverRoot(rawProps) {
|
|
|
21
27
|
function Trigger(rawProps) {
|
|
22
28
|
const { as, children, ...restProps } = useHuiProps("PopoverTrigger", rawProps);
|
|
23
29
|
const Component = as ?? Button;
|
|
30
|
+
const cls = useHuiClassNames("PopoverTrigger", BUTTON_CLASSES, rawProps);
|
|
31
|
+
const sls = useHuiStyles("PopoverTrigger", rawProps);
|
|
24
32
|
const popoverId = usePopoverId();
|
|
25
33
|
const attrs = normalizeAttributes(popoverControl.getTriggerAttributes({ popoverId }, { isButtonElement: as === void 0 }));
|
|
26
34
|
return /* @__PURE__ */ jsx(Component, {
|
|
27
35
|
...attrs,
|
|
36
|
+
...Component === Button ? {
|
|
37
|
+
classNames: cls,
|
|
38
|
+
styles: sls
|
|
39
|
+
} : {
|
|
40
|
+
className: cls.root,
|
|
41
|
+
style: sls.root
|
|
42
|
+
},
|
|
28
43
|
...restProps,
|
|
29
44
|
children
|
|
30
45
|
});
|
|
31
46
|
}
|
|
32
47
|
function Content(rawProps) {
|
|
33
|
-
const { as, position, fallbacks, visibility, padding,
|
|
48
|
+
const { as, position, fallbacks, visibility, padding, children, ...restProps } = useHuiProps("PopoverContent", rawProps);
|
|
34
49
|
const Component = as ?? "div";
|
|
35
50
|
const popoverId = usePopoverId();
|
|
36
51
|
const recipe = popoverRecipe({
|
|
@@ -39,8 +54,8 @@ function Content(rawProps) {
|
|
|
39
54
|
visibility,
|
|
40
55
|
padding
|
|
41
56
|
});
|
|
42
|
-
const cls = useHuiClassNames("PopoverContent", recipe,
|
|
43
|
-
const sls = useHuiStyles("PopoverContent",
|
|
57
|
+
const cls = useHuiClassNames("PopoverContent", recipe, rawProps);
|
|
58
|
+
const sls = useHuiStyles("PopoverContent", rawProps);
|
|
44
59
|
const attrs = normalizeAttributes(popoverControl.getContentAttributes({ popoverId }));
|
|
45
60
|
return /* @__PURE__ */ jsx(Component, {
|
|
46
61
|
...attrs,
|
|
@@ -54,7 +69,6 @@ const Popover = Object.assign(PopoverRoot, {
|
|
|
54
69
|
Trigger,
|
|
55
70
|
Content
|
|
56
71
|
});
|
|
57
|
-
//#endregion
|
|
58
72
|
export { Popover };
|
|
59
73
|
|
|
60
74
|
//# sourceMappingURL=popover.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.js","names":[],"sources":["../../../src/components/popover/popover.tsx"],"sourcesContent":["import {\n type ButtonSlots,\n popoverControl,\n popoverRecipe,\n type PopoverSlots,\n type PopoverVariants,\n} from \"@hebium-ui/core\";\nimport { type ElementType, type ReactElement, type ReactNode, useId, useMemo } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\nimport { normalizeAttributes } from \"~/utils\";\nimport { Button } from \"../button\";\nimport { PopoverContext, type PopoverContextValue, usePopoverId } from \"./popover.context\";\n\nexport interface PopoverProps {\n /**\n * The id of the popover content element.\n */\n id?: string | undefined;\n children?: ReactNode | undefined;\n}\n\nfunction PopoverRoot(rawProps: PopoverProps): ReactElement {\n const {\n id,\n children,\n } = useHuiProps(\"Popover\", rawProps);\n\n const tmpId = useId();\n const popoverId = id || tmpId;\n\n const contextValue = useMemo<PopoverContextValue>(() => {\n return {\n popoverId,\n };\n }, [popoverId]);\n\n return (\n <PopoverContext.Provider\n value={contextValue}\n >\n {children}\n </PopoverContext.Provider>\n );\n}\n\nexport type PopoverTriggerProps<E extends ElementType = typeof Button
|
|
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\nconst BUTTON_CLASSES = { root: \"\", content: \"\", spinner: \"\", status: \"\" } satisfies Record<ButtonSlots, string>;\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<\"button\">> = HuiPolymorphicProps<\n E,\n {},\n ButtonSlots\n>;\n\nfunction Trigger<E extends ElementType = typeof Button<\"button\">>(rawProps: PopoverTriggerProps<E>): ReactNode {\n const {\n as,\n children,\n ...restProps\n } = useHuiProps(\"PopoverTrigger\", rawProps);\n\n const Component = as ?? Button;\n const cls = useHuiClassNames(\"PopoverTrigger\", BUTTON_CLASSES, rawProps);\n const sls = useHuiStyles(\"PopoverTrigger\", rawProps);\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 {...(Component === Button\n ? { classNames: cls, styles: sls }\n : { className: cls.root, style: sls.root })}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n\ninterface PopoverContentOwnProps {\n /**\n * The preferred anchor position of the popover.\n *\n * @default \"block-start\"\n */\n position?: PopoverVariants[\"position\"] | undefined;\n /**\n * The fallback strategy used when the preferred position overflows.\n *\n * @default \"flip\"\n */\n fallbacks?: PopoverVariants[\"fallbacks\"] | undefined;\n /**\n * The visibility behavior when the anchor is off-screen or overflows.\n *\n * @default \"anchors-visible\"\n * @see This setting depends on browser support for {@link https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/position-visibility | MDN: position-visibility}.\n */\n visibility?: PopoverVariants[\"visibility\"] | undefined;\n /**\n * The padding size of the popover content.\n *\n * @default \"md\"\n */\n padding?: PopoverVariants[\"padding\"] | undefined;\n}\nexport type PopoverContentProps<E extends ElementType = \"div\"> = HuiPolymorphicProps<\n E,\n PopoverContentOwnProps,\n PopoverSlots\n>;\n\nfunction Content<E extends ElementType = \"div\">(rawProps: PopoverContentProps<E>): ReactElement {\n const {\n as,\n position,\n fallbacks,\n visibility,\n padding,\n children,\n ...restProps\n } = useHuiProps(\"PopoverContent\", rawProps);\n const Component = as ?? \"div\";\n\n const popoverId = usePopoverId();\n const recipe = popoverRecipe({ position, fallbacks, visibility, padding });\n const cls = useHuiClassNames(\"PopoverContent\", recipe, rawProps);\n const sls = useHuiStyles(\"PopoverContent\", rawProps);\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":";;;;;;;;AAcA,MAAM,iBAAiB;CAAE,MAAM;CAAI,SAAS;CAAI,SAAS;CAAI,QAAQ;AAAG;AAUxE,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,QAAyD,UAA6C;CAC7G,MAAM,EACJ,IACA,UACA,GAAG,cACD,YAAY,kBAAkB,QAAQ;CAE1C,MAAM,YAAY,MAAM;CACxB,MAAM,MAAM,iBAAiB,kBAAkB,gBAAgB,QAAQ;CACvE,MAAM,MAAM,aAAa,kBAAkB,QAAQ;CACnD,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,GAAK,cAAc,SACf;GAAE,YAAY;GAAK,QAAQ;EAAI,IAC/B;GAAE,WAAW,IAAI;GAAM,OAAO,IAAI;EAAK;EAC3C,GAAI;EAEH;CACQ,CAAA;AAEf;AAmCA,SAAS,QAAuC,UAAgD;CAC9F,MAAM,EACJ,IACA,UACA,WACA,YACA,SACA,UACA,GAAG,cACD,YAAY,kBAAkB,QAAQ;CAC1C,MAAM,YAAY,MAAM;CAExB,MAAM,YAAY,aAAa;CAC/B,MAAM,SAAS,cAAc;EAAE;EAAU;EAAW;EAAY;CAAQ,CAAC;CACzE,MAAM,MAAM,iBAAiB,kBAAkB,QAAQ,QAAQ;CAC/D,MAAM,MAAM,aAAa,kBAAkB,QAAQ;CACnD,MAAM,QAAQ,oBAAoB,eAAe,qBAAqB,EAAE,UAAU,CAAC,CAAC;CAEpF,OACE,oBAAC,WAAD;EACE,GAAI;EACJ,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EAEH;CACQ,CAAA;AAEf;AAEA,MAAa,UAAU,OAAO,OAAO,aAAa;CAChD;CACA;AACF,CAAC"}
|
|
@@ -2,7 +2,6 @@ import { HuiComponentProps } from "../../types/hui-component.js";
|
|
|
2
2
|
import "../../types/index.js";
|
|
3
3
|
import { ProgressSlots, ProgressVariants } from "@hebium-ui/core";
|
|
4
4
|
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
5
|
-
//#region src/components/progress/progress.d.ts
|
|
6
5
|
type HtmlDivProps = ComponentProps<"div">;
|
|
7
6
|
interface ProgressOwnProps extends HtmlDivProps {
|
|
8
7
|
/**
|
|
@@ -50,6 +49,4 @@ interface ProgressOwnProps extends HtmlDivProps {
|
|
|
50
49
|
}
|
|
51
50
|
export type ProgressProps = HuiComponentProps<ProgressOwnProps, ProgressSlots>;
|
|
52
51
|
export declare function Progress(rawProps: ProgressProps): ReactElement;
|
|
53
|
-
|
|
54
|
-
export {};
|
|
55
|
-
//# sourceMappingURL=progress.d.ts.map
|
|
52
|
+
export {};
|
|
@@ -2,9 +2,9 @@ import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-
|
|
|
2
2
|
import { CSS_VARS, cc, progressControl, progressRecipe, toStrbool } from "@hebium-ui/core";
|
|
3
3
|
import { useId } from "react";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
-
|
|
5
|
+
// src/components/progress/progress.tsx
|
|
6
6
|
function Progress(rawProps) {
|
|
7
|
-
const { min, max, value, valueText, label, color, radius, size,
|
|
7
|
+
const { min, max, value, valueText, label, color, radius, size, nonce, ...restProps } = useHuiProps("Progress", rawProps);
|
|
8
8
|
const progressId = useId();
|
|
9
9
|
const progress = progressControl.resolve({
|
|
10
10
|
progressId,
|
|
@@ -20,8 +20,8 @@ function Progress(rawProps) {
|
|
|
20
20
|
radius,
|
|
21
21
|
size
|
|
22
22
|
});
|
|
23
|
-
const cls = useHuiClassNames("Progress", recipe,
|
|
24
|
-
const sls = useHuiStyles("Progress",
|
|
23
|
+
const cls = useHuiClassNames("Progress", recipe, rawProps);
|
|
24
|
+
const sls = useHuiStyles("Progress", rawProps);
|
|
25
25
|
const labelAttrs = progressControl.getLabelAttributes(progress);
|
|
26
26
|
const barAttrs = progressControl.getBarAttributes(progress);
|
|
27
27
|
const valueAttrs = progressControl.getValueAttributes();
|
|
@@ -51,7 +51,6 @@ function Progress(rawProps) {
|
|
|
51
51
|
})]
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
-
//#endregion
|
|
55
54
|
export { Progress };
|
|
56
55
|
|
|
57
56
|
//# sourceMappingURL=progress.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress.js","names":[],"sources":["../../../src/components/progress/progress.tsx"],"sourcesContent":["import {\n cc,\n CSS_VARS,\n progressControl,\n progressRecipe,\n type ProgressSlots,\n type ProgressVariants,\n toStrbool,\n} from \"@hebium-ui/core\";\nimport { type ComponentProps, type ReactElement, type ReactNode, useId } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps } from \"~/types\";\n\ntype HtmlDivProps = ComponentProps<\"div\">;\n\ninterface ProgressOwnProps extends HtmlDivProps {\n /**\n * The minimum value of the progress range.\n *\n * @default 0\n */\n min?: number | undefined;\n /**\n * The maximum value of the progress range.\n *\n * @default 100\n */\n max?: number | undefined;\n /**\n * The current value of the progress. Omit this prop when progress is indeterminate.\n */\n value?: number | undefined;\n /**\n * The human-readable text alternative for the current value.\n */\n valueText?: string | undefined;\n /**\n * The label displayed above the progressbar.\n */\n label?: ReactNode | undefined;\n /**\n * The semantic color of the progressbar.\n *\n * @default \"accent\"\n */\n color?: ProgressVariants[\"color\"] | undefined;\n /**\n * The border radius of the progressbar.\n *\n * @default \"rounded\"\n */\n radius?: ProgressVariants[\"radius\"] | undefined;\n /**\n * The size of the progressbar.\n *\n * @default \"md\"\n */\n size?: ProgressVariants[\"size\"] | undefined;\n}\n\nexport type ProgressProps = HuiComponentProps<\n ProgressOwnProps,\n ProgressSlots\n>;\n\nexport function Progress(rawProps: ProgressProps): ReactElement {\n const {\n min,\n max,\n value,\n valueText,\n label,\n color,\n radius,\n size,\n
|
|
1
|
+
{"version":3,"file":"progress.js","names":[],"sources":["../../../src/components/progress/progress.tsx"],"sourcesContent":["import {\n cc,\n CSS_VARS,\n progressControl,\n progressRecipe,\n type ProgressSlots,\n type ProgressVariants,\n toStrbool,\n} from \"@hebium-ui/core\";\nimport { type ComponentProps, type ReactElement, type ReactNode, useId } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps } from \"~/types\";\n\ntype HtmlDivProps = ComponentProps<\"div\">;\n\ninterface ProgressOwnProps extends HtmlDivProps {\n /**\n * The minimum value of the progress range.\n *\n * @default 0\n */\n min?: number | undefined;\n /**\n * The maximum value of the progress range.\n *\n * @default 100\n */\n max?: number | undefined;\n /**\n * The current value of the progress. Omit this prop when progress is indeterminate.\n */\n value?: number | undefined;\n /**\n * The human-readable text alternative for the current value.\n */\n valueText?: string | undefined;\n /**\n * The label displayed above the progressbar.\n */\n label?: ReactNode | undefined;\n /**\n * The semantic color of the progressbar.\n *\n * @default \"accent\"\n */\n color?: ProgressVariants[\"color\"] | undefined;\n /**\n * The border radius of the progressbar.\n *\n * @default \"rounded\"\n */\n radius?: ProgressVariants[\"radius\"] | undefined;\n /**\n * The size of the progressbar.\n *\n * @default \"md\"\n */\n size?: ProgressVariants[\"size\"] | undefined;\n}\n\nexport type ProgressProps = HuiComponentProps<\n ProgressOwnProps,\n ProgressSlots\n>;\n\nexport function Progress(rawProps: ProgressProps): ReactElement {\n const {\n min,\n max,\n value,\n valueText,\n label,\n color,\n radius,\n size,\n nonce,\n ...restProps\n } = useHuiProps(\"Progress\", rawProps);\n const progressId = useId();\n const progress = progressControl.resolve({\n progressId,\n hasLabel: Boolean(label),\n min,\n max,\n value,\n valueText,\n });\n\n const recipe = progressRecipe({\n color,\n indeterminate: toStrbool(progress.isIndeterminate),\n radius,\n size,\n });\n const cls = useHuiClassNames(\"Progress\", recipe, rawProps);\n const sls = useHuiStyles(\"Progress\", rawProps);\n const labelAttrs = progressControl.getLabelAttributes(progress);\n const barAttrs = progressControl.getBarAttributes(progress);\n const valueAttrs = progressControl.getValueAttributes();\n const valueClassName = `progress-value-${progress.progressId}`;\n\n return (\n <div\n className={cls.root}\n style={sls.root}\n >\n {label\n && (\n <div\n className={cls.label}\n style={sls.label}\n {...labelAttrs}\n >\n {label}\n </div>\n )}\n <div\n className={cls.bar}\n style={sls.bar}\n {...barAttrs}\n {...restProps}\n >\n <style nonce={nonce}>\n {`.${valueClassName} {${CSS_VARS.arbitraryWidth}: ${progress.width}}`}\n </style>\n <div\n className={cc(cls.value, valueClassName)}\n style={sls.value}\n {...valueAttrs}\n >\n {progress.isIndeterminate ? undefined : valueText}\n </div>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;AAiEA,SAAgB,SAAS,UAAuC;CAC9D,MAAM,EACJ,KACA,KACA,OACA,WACA,OACA,OACA,QACA,MACA,OACA,GAAG,cACD,YAAY,YAAY,QAAQ;CACpC,MAAM,aAAa,MAAM;CACzB,MAAM,WAAW,gBAAgB,QAAQ;EACvC;EACA,UAAU,QAAQ,KAAK;EACvB;EACA;EACA;EACA;CACF,CAAC;CAED,MAAM,SAAS,eAAe;EAC5B;EACA,eAAe,UAAU,SAAS,eAAe;EACjD;EACA;CACF,CAAC;CACD,MAAM,MAAM,iBAAiB,YAAY,QAAQ,QAAQ;CACzD,MAAM,MAAM,aAAa,YAAY,QAAQ;CAC7C,MAAM,aAAa,gBAAgB,mBAAmB,QAAQ;CAC9D,MAAM,WAAW,gBAAgB,iBAAiB,QAAQ;CAC1D,MAAM,aAAa,gBAAgB,mBAAmB;CACtD,MAAM,iBAAiB,kBAAkB,SAAS;CAElD,OACE,qBAAC,OAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EAFb,UAAA,CAIG,SAEG,oBAAC,OAAD;GACE,WAAW,IAAI;GACf,OAAO,IAAI;GACX,GAAI;GAEH,UAAA;EACE,CAAA,GAET,qBAAC,OAAD;GACE,WAAW,IAAI;GACf,OAAO,IAAI;GACX,GAAI;GACJ,GAAI;GAJN,UAAA,CAME,oBAAC,SAAD;IAAc;IACX,UAAA,IAAI,eAAe,IAAI,SAAS,eAAe,IAAI,SAAS,MAAM;GAC9D,CAAA,GACP,oBAAC,OAAD;IACE,WAAW,GAAG,IAAI,OAAO,cAAc;IACvC,OAAO,IAAI;IACX,GAAI;IAEH,UAAA,SAAS,kBAAkB,KAAA,IAAY;GACrC,CAAA,CACF;EACF,CAAA,CAAA;;AAET"}
|
|
@@ -2,7 +2,6 @@ import { HuiComponentProps } from "../../types/hui-component.js";
|
|
|
2
2
|
import "../../types/index.js";
|
|
3
3
|
import { RadioSlots, RadioVariants } from "@hebium-ui/core";
|
|
4
4
|
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
5
|
-
//#region src/components/radio/radio.d.ts
|
|
6
5
|
type HtmlInputProps = Omit<ComponentProps<"input">, "children" | "type">;
|
|
7
6
|
interface RadioOwnProps extends HtmlInputProps {
|
|
8
7
|
/**
|
|
@@ -22,6 +21,4 @@ interface RadioOwnProps extends HtmlInputProps {
|
|
|
22
21
|
}
|
|
23
22
|
export type RadioProps = HuiComponentProps<RadioOwnProps, RadioSlots>;
|
|
24
23
|
export declare function Radio(rawProps: RadioProps): ReactElement;
|
|
25
|
-
|
|
26
|
-
export {};
|
|
27
|
-
//# sourceMappingURL=radio.d.ts.map
|
|
24
|
+
export {};
|
|
@@ -3,9 +3,9 @@ import { normalizeAttributes } from "../../utils/attributes/normalize-attributes
|
|
|
3
3
|
import { radioControl, radioRecipe, toBool, toStrbool } from "@hebium-ui/core";
|
|
4
4
|
import { useId } from "react";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
|
|
6
|
+
// src/components/radio/radio.tsx
|
|
7
7
|
function Radio(rawProps) {
|
|
8
|
-
const { id,
|
|
8
|
+
const { id, label, error, color, ref, ...restProps } = useHuiProps("Radio", rawProps);
|
|
9
9
|
const tmpId = useId();
|
|
10
10
|
const radioState = {
|
|
11
11
|
id: id ?? tmpId,
|
|
@@ -16,8 +16,8 @@ function Radio(rawProps) {
|
|
|
16
16
|
color,
|
|
17
17
|
error: toStrbool(radioState.invalid)
|
|
18
18
|
});
|
|
19
|
-
const cls = useHuiClassNames("Radio", recipe,
|
|
20
|
-
const sls = useHuiStyles("Radio",
|
|
19
|
+
const cls = useHuiClassNames("Radio", recipe, rawProps);
|
|
20
|
+
const sls = useHuiStyles("Radio", rawProps);
|
|
21
21
|
const controlAttrs = normalizeAttributes(radioControl.getControlAttributes(radioState));
|
|
22
22
|
const labelAttrs = normalizeAttributes(radioControl.getLabelAttributes(radioState));
|
|
23
23
|
const errorAttrs = radioControl.getErrorAttributes(radioState);
|
|
@@ -51,7 +51,6 @@ function Radio(rawProps) {
|
|
|
51
51
|
})] })]
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
-
//#endregion
|
|
55
54
|
export { Radio };
|
|
56
55
|
|
|
57
56
|
//# sourceMappingURL=radio.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio.js","names":[],"sources":["../../../src/components/radio/radio.tsx"],"sourcesContent":["import { radioControl, radioRecipe, type RadioSlots, type RadioVariants, toBool, toStrbool } from \"@hebium-ui/core\";\nimport { type ComponentProps, type ReactElement, type ReactNode, useId } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps } from \"~/types\";\nimport { normalizeAttributes } from \"~/utils\";\n\ntype HtmlInputProps = Omit<ComponentProps<\"input\">, \"children\" | \"type\">;\n\ninterface RadioOwnProps extends HtmlInputProps {\n /**\n * The label displayed next to the radio control.\n */\n label?: ReactNode | undefined;\n /**\n * The error message displayed below the label.\n */\n error?: ReactNode | undefined;\n /**\n * The semantic color of the radio control.\n *\n * @default \"accent\"\n */\n color?: RadioVariants[\"color\"] | undefined;\n}\n\nexport type RadioProps = HuiComponentProps<\n RadioOwnProps,\n RadioSlots\n>;\n\nexport function Radio(rawProps: RadioProps): ReactElement {\n const {\n id,\n
|
|
1
|
+
{"version":3,"file":"radio.js","names":[],"sources":["../../../src/components/radio/radio.tsx"],"sourcesContent":["import { radioControl, radioRecipe, type RadioSlots, type RadioVariants, toBool, toStrbool } from \"@hebium-ui/core\";\nimport { type ComponentProps, type ReactElement, type ReactNode, useId } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps } from \"~/types\";\nimport { normalizeAttributes } from \"~/utils\";\n\ntype HtmlInputProps = Omit<ComponentProps<\"input\">, \"children\" | \"type\">;\n\ninterface RadioOwnProps extends HtmlInputProps {\n /**\n * The label displayed next to the radio control.\n */\n label?: ReactNode | undefined;\n /**\n * The error message displayed below the label.\n */\n error?: ReactNode | undefined;\n /**\n * The semantic color of the radio control.\n *\n * @default \"accent\"\n */\n color?: RadioVariants[\"color\"] | undefined;\n}\n\nexport type RadioProps = HuiComponentProps<\n RadioOwnProps,\n RadioSlots\n>;\n\nexport function Radio(rawProps: RadioProps): ReactElement {\n const {\n id,\n label,\n error,\n color,\n ref,\n ...restProps\n } = useHuiProps(\"Radio\", rawProps);\n\n const tmpId = useId();\n\n const radioState = {\n id: id ?? tmpId,\n invalid: !!error,\n disabled: toBool(restProps.disabled) || toBool(restProps[\"aria-disabled\"]),\n };\n const recipe = radioRecipe({\n color,\n error: toStrbool(radioState.invalid),\n });\n const cls = useHuiClassNames(\"Radio\", recipe, rawProps);\n const sls = useHuiStyles(\"Radio\", rawProps);\n const controlAttrs = normalizeAttributes(radioControl.getControlAttributes(radioState));\n const labelAttrs = normalizeAttributes(radioControl.getLabelAttributes(radioState));\n const errorAttrs = radioControl.getErrorAttributes(radioState);\n\n return (\n <div\n className={cls.root}\n style={sls.root}\n >\n <input\n ref={ref}\n className={cls.radio}\n style={sls.radio}\n {...controlAttrs}\n {...restProps}\n />\n <div>\n {label && (\n <label\n className={cls.label}\n style={sls.label}\n {...labelAttrs}\n >\n {label}\n </label>\n )}\n {error && (\n <p\n className={cls.error}\n style={sls.error}\n {...errorAttrs}\n >\n <span\n aria-hidden\n className={cls.errorIcon}\n style={sls.errorIcon}\n />\n <span\n className={cls.errorMessage}\n style={sls.errorMessage}\n >\n {error}\n </span>\n </p>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;AA8BA,SAAgB,MAAM,UAAoC;CACxD,MAAM,EACJ,IACA,OACA,OACA,OACA,KACA,GAAG,cACD,YAAY,SAAS,QAAQ;CAEjC,MAAM,QAAQ,MAAM;CAEpB,MAAM,aAAa;EACjB,IAAI,MAAM;EACV,SAAS,CAAC,CAAC;EACX,UAAU,OAAO,UAAU,QAAQ,KAAK,OAAO,UAAU,gBAAgB;CAC3E;CACA,MAAM,SAAS,YAAY;EACzB;EACA,OAAO,UAAU,WAAW,OAAO;CACrC,CAAC;CACD,MAAM,MAAM,iBAAiB,SAAS,QAAQ,QAAQ;CACtD,MAAM,MAAM,aAAa,SAAS,QAAQ;CAC1C,MAAM,eAAe,oBAAoB,aAAa,qBAAqB,UAAU,CAAC;CACtF,MAAM,aAAa,oBAAoB,aAAa,mBAAmB,UAAU,CAAC;CAClF,MAAM,aAAa,aAAa,mBAAmB,UAAU;CAE7D,OACE,qBAAC,OAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EAFb,UAAA,CAIE,oBAAC,SAAD;GACO;GACL,WAAW,IAAI;GACf,OAAO,IAAI;GACX,GAAI;GACJ,GAAI;EACL,CAAA,GACD,qBAAC,OAAD,EAAA,UAAA,CACG,SACC,oBAAC,SAAD;GACE,WAAW,IAAI;GACf,OAAO,IAAI;GACX,GAAI;GAEH,UAAA;EACI,CAAA,GAER,SACC,qBAAC,KAAD;GACE,WAAW,IAAI;GACf,OAAO,IAAI;GACX,GAAI;GAHN,UAAA,CAKE,oBAAC,QAAD;IACE,eAAA;IACA,WAAW,IAAI;IACf,OAAO,IAAI;GACZ,CAAA,GACD,oBAAC,QAAD;IACE,WAAW,IAAI;IACf,OAAO,IAAI;IAEV,UAAA;GACG,CAAA,CACL;EAEF,CAAA,CAAA,EAAA,CAAA,CACF;;AAET"}
|
|
@@ -4,7 +4,6 @@ import { LabelProps } from "../label/label.js";
|
|
|
4
4
|
import "../label/index.js";
|
|
5
5
|
import { RadiogroupSlots, RadiogroupVariants } from "@hebium-ui/core";
|
|
6
6
|
import { ElementType, ReactElement, ReactNode } from "react";
|
|
7
|
-
//#region src/components/radiogroup/radiogroup.d.ts
|
|
8
7
|
interface RadiogroupOwnProps {
|
|
9
8
|
/**
|
|
10
9
|
* The direction in which radio options are laid out.
|
|
@@ -31,6 +30,4 @@ interface RadiogroupOwnProps {
|
|
|
31
30
|
}
|
|
32
31
|
export type RadiogroupProps<E extends ElementType = "div"> = HuiPolymorphicProps<E, RadiogroupOwnProps, RadiogroupSlots>;
|
|
33
32
|
export declare function Radiogroup<E extends ElementType = "div">(rawProps: RadiogroupProps<E>): ReactElement;
|
|
34
|
-
|
|
35
|
-
export {};
|
|
36
|
-
//# sourceMappingURL=radiogroup.d.ts.map
|
|
33
|
+
export {};
|
|
@@ -4,18 +4,19 @@ import { Label } from "../label/label.js";
|
|
|
4
4
|
import { radiogroupControl, radiogroupRecipe, toBool } from "@hebium-ui/core";
|
|
5
5
|
import { useId } from "react";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
|
|
7
|
+
// src/components/radiogroup/radiogroup.tsx
|
|
8
8
|
function Radiogroup(rawProps) {
|
|
9
|
-
const
|
|
9
|
+
const props = useHuiProps("Radiogroup", rawProps);
|
|
10
|
+
const { as, direction, label, description, error, labelProps, children, ...restProps } = props;
|
|
10
11
|
const labelId = useId();
|
|
11
12
|
const recipe = radiogroupRecipe({ direction });
|
|
12
|
-
const cls = useHuiClassNames("Radiogroup", recipe,
|
|
13
|
-
const sls = useHuiStyles("Radiogroup",
|
|
13
|
+
const cls = useHuiClassNames("Radiogroup", recipe, rawProps);
|
|
14
|
+
const sls = useHuiStyles("Radiogroup", rawProps);
|
|
14
15
|
const radiogroupState = {
|
|
15
16
|
labelId,
|
|
16
17
|
hasLabel: !!label || !!description || !!error,
|
|
17
18
|
invalid: !!error,
|
|
18
|
-
required: toBool(
|
|
19
|
+
required: toBool(props["aria-required"])
|
|
19
20
|
};
|
|
20
21
|
const rootAttrs = normalizeAttributes(radiogroupControl.getRootAttributes(radiogroupState));
|
|
21
22
|
const labelAttrs = normalizeAttributes(radiogroupControl.getLabelAttributes(radiogroupState));
|
|
@@ -38,7 +39,6 @@ function Radiogroup(rawProps) {
|
|
|
38
39
|
})]
|
|
39
40
|
});
|
|
40
41
|
}
|
|
41
|
-
//#endregion
|
|
42
42
|
export { Radiogroup };
|
|
43
43
|
|
|
44
44
|
//# sourceMappingURL=radiogroup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radiogroup.js","names":[],"sources":["../../../src/components/radiogroup/radiogroup.tsx"],"sourcesContent":["import {\n radiogroupControl,\n radiogroupRecipe,\n type RadiogroupSlots,\n type RadiogroupVariants,\n toBool,\n} from \"@hebium-ui/core\";\nimport { type ElementType, type ReactElement, type ReactNode, useId } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\nimport { normalizeAttributes } from \"~/utils\";\nimport { Label, type LabelProps } from \"../label\";\n\ninterface RadiogroupOwnProps {\n /**\n * The direction in which radio options are laid out.\n *\n * @default \"column\"\n */\n direction?: RadiogroupVariants[\"direction\"] | undefined;\n /**\n * The label displayed above the radio group.\n */\n label?: ReactNode | undefined;\n /**\n * Additional props passed to the internal label component.\n */\n labelProps?: LabelProps<\"div\"> | undefined;\n /**\n * The help text displayed below the label.\n */\n description?: ReactNode | undefined;\n /**\n * The error message displayed below the label.\n */\n error?: ReactNode | undefined;\n}\n\nexport type RadiogroupProps<E extends ElementType = \"div\"> = HuiPolymorphicProps<\n E,\n RadiogroupOwnProps,\n RadiogroupSlots\n>;\n\nexport function Radiogroup<E extends ElementType = \"div\">(rawProps: RadiogroupProps<E>): ReactElement {\n const {\n as,\n direction,\n
|
|
1
|
+
{"version":3,"file":"radiogroup.js","names":[],"sources":["../../../src/components/radiogroup/radiogroup.tsx"],"sourcesContent":["import {\n radiogroupControl,\n radiogroupRecipe,\n type RadiogroupSlots,\n type RadiogroupVariants,\n toBool,\n} from \"@hebium-ui/core\";\nimport { type ElementType, type ReactElement, type ReactNode, useId } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\nimport { normalizeAttributes } from \"~/utils\";\nimport { Label, type LabelProps } from \"../label\";\n\ninterface RadiogroupOwnProps {\n /**\n * The direction in which radio options are laid out.\n *\n * @default \"column\"\n */\n direction?: RadiogroupVariants[\"direction\"] | undefined;\n /**\n * The label displayed above the radio group.\n */\n label?: ReactNode | undefined;\n /**\n * Additional props passed to the internal label component.\n */\n labelProps?: LabelProps<\"div\"> | undefined;\n /**\n * The help text displayed below the label.\n */\n description?: ReactNode | undefined;\n /**\n * The error message displayed below the label.\n */\n error?: ReactNode | undefined;\n}\n\nexport type RadiogroupProps<E extends ElementType = \"div\"> = HuiPolymorphicProps<\n E,\n RadiogroupOwnProps,\n RadiogroupSlots\n>;\n\nexport function Radiogroup<E extends ElementType = \"div\">(rawProps: RadiogroupProps<E>): ReactElement {\n const props = useHuiProps(\"Radiogroup\", rawProps);\n const {\n as,\n direction,\n label,\n description,\n error,\n labelProps,\n children,\n ...restProps\n } = props;\n\n const labelId = useId();\n\n const recipe = radiogroupRecipe({ direction });\n const cls = useHuiClassNames(\"Radiogroup\", recipe, rawProps);\n const sls = useHuiStyles(\"Radiogroup\", rawProps);\n const radiogroupState = {\n labelId,\n hasLabel: !!label || !!description || !!error,\n invalid: !!error,\n required: toBool(props[\"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,QAAQ,YAAY,cAAc,QAAQ;CAChD,MAAM,EACJ,IACA,WACA,OACA,aACA,OACA,YACA,UACA,GAAG,cACD;CAEJ,MAAM,UAAU,MAAM;CAEtB,MAAM,SAAS,iBAAiB,EAAE,UAAU,CAAC;CAC7C,MAAM,MAAM,iBAAiB,cAAc,QAAQ,QAAQ;CAC3D,MAAM,MAAM,aAAa,cAAc,QAAQ;CAC/C,MAAM,kBAAkB;EACtB;EACA,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC,eAAe,CAAC,CAAC;EACxC,SAAS,CAAC,CAAC;EACX,UAAU,OAAO,MAAM,gBAAgB;CACzC;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"}
|
|
@@ -2,7 +2,6 @@ import { HuiPolymorphicProps } from "../../types/polymorphic.js";
|
|
|
2
2
|
import "../../types/index.js";
|
|
3
3
|
import { SectionSlots, SectionVariants } from "@hebium-ui/core";
|
|
4
4
|
import { ElementType, ReactElement } from "react";
|
|
5
|
-
//#region src/components/section/section.d.ts
|
|
6
5
|
interface SectionOwnProps {
|
|
7
6
|
/**
|
|
8
7
|
* The background color of the section.
|
|
@@ -31,6 +30,4 @@ interface SectionOwnProps {
|
|
|
31
30
|
}
|
|
32
31
|
export type SectionProps<E extends ElementType = "section"> = HuiPolymorphicProps<E, SectionOwnProps, SectionSlots>;
|
|
33
32
|
export declare function Section<E extends ElementType = "section">(rawProps: SectionProps<E>): ReactElement;
|
|
34
|
-
|
|
35
|
-
export {};
|
|
36
|
-
//# sourceMappingURL=section.d.ts.map
|
|
33
|
+
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
|
|
2
2
|
import { sectionRecipe } from "@hebium-ui/core";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
|
|
4
|
+
// src/components/section/section.tsx
|
|
5
5
|
function Section(rawProps) {
|
|
6
|
-
const { as, bg, radius, padding, border,
|
|
6
|
+
const { as, bg, radius, padding, border, children, ...restProps } = useHuiProps("Section", rawProps);
|
|
7
7
|
const recipe = sectionRecipe({
|
|
8
8
|
bg,
|
|
9
9
|
radius,
|
|
@@ -11,8 +11,8 @@ function Section(rawProps) {
|
|
|
11
11
|
border
|
|
12
12
|
});
|
|
13
13
|
const Component = as ?? "section";
|
|
14
|
-
const cls = useHuiClassNames("Section", recipe,
|
|
15
|
-
const sls = useHuiStyles("Section",
|
|
14
|
+
const cls = useHuiClassNames("Section", recipe, rawProps);
|
|
15
|
+
const sls = useHuiStyles("Section", rawProps);
|
|
16
16
|
return /* @__PURE__ */ jsx(Component, {
|
|
17
17
|
className: cls.root,
|
|
18
18
|
style: sls.root,
|
|
@@ -20,7 +20,6 @@ function Section(rawProps) {
|
|
|
20
20
|
children
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
|
-
//#endregion
|
|
24
23
|
export { Section };
|
|
25
24
|
|
|
26
25
|
//# sourceMappingURL=section.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"section.js","names":[],"sources":["../../../src/components/section/section.tsx"],"sourcesContent":["import { sectionRecipe, type SectionSlots, type SectionVariants } from \"@hebium-ui/core\";\nimport { type ElementType, type ReactElement } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\n\ninterface SectionOwnProps {\n /**\n * The background color of the section.\n *\n * @default \"section\"\n */\n bg?: SectionVariants[\"bg\"] | undefined;\n /**\n * The border radius of the section.\n *\n * @default \"base\"\n */\n radius?: SectionVariants[\"radius\"] | undefined;\n /**\n * The padding size of the section.\n *\n * @default \"sm\"\n */\n padding?: SectionVariants[\"padding\"] | undefined;\n /**\n * The border style of the section.\n *\n * @default \"none\"\n */\n border?: SectionVariants[\"border\"] | undefined;\n}\n\nexport type SectionProps<E extends ElementType = \"section\"> = HuiPolymorphicProps<\n E,\n SectionOwnProps,\n SectionSlots\n>;\n\nexport function Section<E extends ElementType = \"section\">(rawProps: SectionProps<E>): ReactElement {\n const {\n as,\n bg,\n radius,\n padding,\n border,\n
|
|
1
|
+
{"version":3,"file":"section.js","names":[],"sources":["../../../src/components/section/section.tsx"],"sourcesContent":["import { sectionRecipe, type SectionSlots, type SectionVariants } from \"@hebium-ui/core\";\nimport { type ElementType, type ReactElement } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\n\ninterface SectionOwnProps {\n /**\n * The background color of the section.\n *\n * @default \"section\"\n */\n bg?: SectionVariants[\"bg\"] | undefined;\n /**\n * The border radius of the section.\n *\n * @default \"base\"\n */\n radius?: SectionVariants[\"radius\"] | undefined;\n /**\n * The padding size of the section.\n *\n * @default \"sm\"\n */\n padding?: SectionVariants[\"padding\"] | undefined;\n /**\n * The border style of the section.\n *\n * @default \"none\"\n */\n border?: SectionVariants[\"border\"] | undefined;\n}\n\nexport type SectionProps<E extends ElementType = \"section\"> = HuiPolymorphicProps<\n E,\n SectionOwnProps,\n SectionSlots\n>;\n\nexport function Section<E extends ElementType = \"section\">(rawProps: SectionProps<E>): ReactElement {\n const {\n as,\n bg,\n radius,\n padding,\n border,\n children,\n ...restProps\n } = useHuiProps(\"Section\", rawProps);\n\n const recipe = sectionRecipe({ bg, radius, padding, border });\n const Component = as ?? \"section\";\n const cls = useHuiClassNames(\"Section\", recipe, rawProps);\n const sls = useHuiStyles(\"Section\", rawProps);\n\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n"],"mappings":";;;;AAsCA,SAAgB,QAA2C,UAAyC;CAClG,MAAM,EACJ,IACA,IACA,QACA,SACA,QACA,UACA,GAAG,cACD,YAAY,WAAW,QAAQ;CAEnC,MAAM,SAAS,cAAc;EAAE;EAAI;EAAQ;EAAS;CAAO,CAAC;CAC5D,MAAM,YAAY,MAAM;CACxB,MAAM,MAAM,iBAAiB,WAAW,QAAQ,QAAQ;CACxD,MAAM,MAAM,aAAa,WAAW,QAAQ;CAE5C,OACE,oBAAC,WAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EAEH;CACQ,CAAA;AAEf"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { createContext, useContext } from "react";
|
|
2
|
-
|
|
2
|
+
// src/components/segmented-control/segmented-control.context.ts
|
|
3
3
|
const SegmentedControlContext = createContext(null);
|
|
4
4
|
function useSegmentedControlContext() {
|
|
5
5
|
const context = useContext(SegmentedControlContext);
|
|
6
6
|
if (!context) throw new Error("[Hebium UI] SegmentedControl compound components must be used within <SegmentedControl>");
|
|
7
7
|
return context;
|
|
8
8
|
}
|
|
9
|
-
//#endregion
|
|
10
9
|
export { SegmentedControlContext, useSegmentedControlContext };
|
|
11
10
|
|
|
12
11
|
//# sourceMappingURL=segmented-control.context.js.map
|
|
@@ -3,13 +3,12 @@ import { HuiPolymorphicProps } from "../../types/polymorphic.js";
|
|
|
3
3
|
import "../../types/index.js";
|
|
4
4
|
import { SegmentedControlItemSlots, SegmentedControlRootSlots } from "@hebium-ui/core";
|
|
5
5
|
import { ComponentProps, ElementType, ReactElement } from "react";
|
|
6
|
-
//#region src/components/segmented-control/segmented-control.d.ts
|
|
7
6
|
type HtmlUlProps = Omit<ComponentProps<"ul">, "onChange">;
|
|
8
7
|
interface SegmentedControlOwnProps<V extends string> extends HtmlUlProps {
|
|
9
8
|
/**
|
|
10
9
|
* The list of allowed segmented-control values.
|
|
11
10
|
*/
|
|
12
|
-
values: V[];
|
|
11
|
+
values: readonly V[];
|
|
13
12
|
/**
|
|
14
13
|
* The currently selected segmented-control value.
|
|
15
14
|
*/
|
|
@@ -36,6 +35,4 @@ declare function Item<E extends ElementType = "button">(rawProps: SegmentedContr
|
|
|
36
35
|
export declare const SegmentedControl: typeof SegmentedControlRoot & {
|
|
37
36
|
Item: typeof Item;
|
|
38
37
|
};
|
|
39
|
-
|
|
40
|
-
export {};
|
|
41
|
-
//# sourceMappingURL=segmented-control.d.ts.map
|
|
38
|
+
export {};
|
|
@@ -4,20 +4,25 @@ import { SegmentedControlContext, useSegmentedControlContext } from "./segmented
|
|
|
4
4
|
import { segmentedControl, segmentedControlItemRecipe, segmentedControlRootRecipe } from "@hebium-ui/core";
|
|
5
5
|
import { useCallback, useMemo, useState } from "react";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
|
-
|
|
7
|
+
// src/components/segmented-control/segmented-control.tsx
|
|
8
8
|
function SegmentedControlRoot(rawProps) {
|
|
9
|
-
const { values, value, defaultValue, onChange,
|
|
9
|
+
const { values, value, defaultValue, onChange, children, ...restProps } = useHuiProps("SegmentedControl", rawProps);
|
|
10
10
|
const [uncontrolledValue, setUncontrolledValue] = useState(() => value ?? defaultValue ?? values[0]);
|
|
11
11
|
const selectedValue = value ?? uncontrolledValue;
|
|
12
12
|
const recipe = segmentedControlRootRecipe({});
|
|
13
|
-
const cls = useHuiClassNames("SegmentedControl", recipe,
|
|
14
|
-
const sls = useHuiStyles("SegmentedControl",
|
|
13
|
+
const cls = useHuiClassNames("SegmentedControl", recipe, rawProps);
|
|
14
|
+
const sls = useHuiStyles("SegmentedControl", rawProps);
|
|
15
15
|
const onSelect = useCallback((nextValue) => {
|
|
16
16
|
if (!values.includes(nextValue)) throw new Error(`[Hebium UI] Unexpected SegmentedControl value: ${nextValue}`);
|
|
17
17
|
const v = nextValue;
|
|
18
|
+
if (v === selectedValue) return;
|
|
18
19
|
setUncontrolledValue(v);
|
|
19
20
|
onChange?.(v);
|
|
20
|
-
}, [
|
|
21
|
+
}, [
|
|
22
|
+
onChange,
|
|
23
|
+
selectedValue,
|
|
24
|
+
values
|
|
25
|
+
]);
|
|
21
26
|
const contextValue = useMemo(() => ({
|
|
22
27
|
selectedValue,
|
|
23
28
|
onSelect
|
|
@@ -33,12 +38,12 @@ function SegmentedControlRoot(rawProps) {
|
|
|
33
38
|
});
|
|
34
39
|
}
|
|
35
40
|
function Item(rawProps) {
|
|
36
|
-
const { as, value,
|
|
41
|
+
const { as, value, children, onClick, ...restProps } = useHuiProps("SegmentedControlItem", rawProps);
|
|
37
42
|
const Component = as ?? "button";
|
|
38
43
|
const { selectedValue, onSelect } = useSegmentedControlContext();
|
|
39
44
|
const recipe = segmentedControlItemRecipe({});
|
|
40
|
-
const cls = useHuiClassNames("SegmentedControlItem", recipe,
|
|
41
|
-
const sls = useHuiStyles("SegmentedControlItem",
|
|
45
|
+
const cls = useHuiClassNames("SegmentedControlItem", recipe, rawProps);
|
|
46
|
+
const sls = useHuiStyles("SegmentedControlItem", rawProps);
|
|
42
47
|
const attrs = normalizeAttributes(segmentedControl.getItemAttributes({
|
|
43
48
|
isButtonElement: typeof as === "undefined",
|
|
44
49
|
selectedValue
|
|
@@ -62,7 +67,6 @@ function Item(rawProps) {
|
|
|
62
67
|
}) });
|
|
63
68
|
}
|
|
64
69
|
const SegmentedControl = Object.assign(SegmentedControlRoot, { Item });
|
|
65
|
-
//#endregion
|
|
66
70
|
export { SegmentedControl };
|
|
67
71
|
|
|
68
72
|
//# sourceMappingURL=segmented-control.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"segmented-control.js","names":[],"sources":["../../../src/components/segmented-control/segmented-control.tsx"],"sourcesContent":["import {\n segmentedControl,\n segmentedControlItemRecipe,\n type SegmentedControlItemSlots,\n segmentedControlRootRecipe,\n type SegmentedControlRootSlots,\n} from \"@hebium-ui/core\";\nimport {\n type ComponentProps,\n type ElementType,\n type MouseEvent,\n type ReactElement,\n useCallback,\n useMemo,\n useState,\n} from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps, type HuiPolymorphicProps } from \"~/types\";\nimport { normalizeAttributes } from \"~/utils\";\nimport {\n SegmentedControlContext,\n type SegmentedControlContextValue,\n useSegmentedControlContext,\n} from \"./segmented-control.context\";\n\ntype HtmlUlProps = Omit<ComponentProps<\"ul\">, \"onChange\">;\n\ninterface SegmentedControlOwnProps<V extends string> extends HtmlUlProps {\n /**\n * The list of allowed segmented-control values.\n */\n values: V[];\n /**\n * The currently selected segmented-control value.\n */\n value?: V | undefined;\n /**\n * The initially selected segmented-control value for uncontrolled component.\n */\n defaultValue?: V | undefined;\n /**\n * Called when the selected segmented-control value changes.\n */\n onChange?: ((value: V) => void) | undefined;\n}\nexport type SegmentedControlProps<V extends string> = HuiComponentProps<\n SegmentedControlOwnProps<V>,\n SegmentedControlRootSlots\n>;\n\nfunction SegmentedControlRoot<V extends string>(\n rawProps: SegmentedControlProps<V>,\n): ReactElement {\n const {\n values,\n value,\n defaultValue,\n onChange,\n
|
|
1
|
+
{"version":3,"file":"segmented-control.js","names":[],"sources":["../../../src/components/segmented-control/segmented-control.tsx"],"sourcesContent":["import {\n segmentedControl,\n segmentedControlItemRecipe,\n type SegmentedControlItemSlots,\n segmentedControlRootRecipe,\n type SegmentedControlRootSlots,\n} from \"@hebium-ui/core\";\nimport {\n type ComponentProps,\n type ElementType,\n type MouseEvent,\n type ReactElement,\n useCallback,\n useMemo,\n useState,\n} from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps, type HuiPolymorphicProps } from \"~/types\";\nimport { normalizeAttributes } from \"~/utils\";\nimport {\n SegmentedControlContext,\n type SegmentedControlContextValue,\n useSegmentedControlContext,\n} from \"./segmented-control.context\";\n\ntype HtmlUlProps = Omit<ComponentProps<\"ul\">, \"onChange\">;\n\ninterface SegmentedControlOwnProps<V extends string> extends HtmlUlProps {\n /**\n * The list of allowed segmented-control values.\n */\n values: readonly V[];\n /**\n * The currently selected segmented-control value.\n */\n value?: V | undefined;\n /**\n * The initially selected segmented-control value for uncontrolled component.\n */\n defaultValue?: V | undefined;\n /**\n * Called when the selected segmented-control value changes.\n */\n onChange?: ((value: V) => void) | undefined;\n}\nexport type SegmentedControlProps<V extends string> = HuiComponentProps<\n SegmentedControlOwnProps<V>,\n SegmentedControlRootSlots\n>;\n\nfunction SegmentedControlRoot<V extends string>(\n rawProps: SegmentedControlProps<V>,\n): ReactElement {\n const {\n values,\n value,\n defaultValue,\n onChange,\n children,\n ...restProps\n } = useHuiProps(\"SegmentedControl\", rawProps);\n\n const [uncontrolledValue, setUncontrolledValue] = useState<V | undefined>(\n () => value ?? defaultValue ?? values[0],\n );\n const selectedValue = value ?? uncontrolledValue;\n const recipe = segmentedControlRootRecipe({});\n const cls = useHuiClassNames(\"SegmentedControl\", recipe, rawProps);\n const sls = useHuiStyles(\"SegmentedControl\", rawProps);\n\n const onSelect = useCallback(\n (nextValue: string) => {\n if (!(values as readonly string[]).includes(nextValue)) {\n throw new Error(`[Hebium UI] Unexpected SegmentedControl value: ${nextValue}`);\n }\n\n const v = nextValue as V;\n if (v === selectedValue) return;\n\n setUncontrolledValue(v);\n onChange?.(v);\n },\n [onChange, selectedValue, values],\n );\n\n const contextValue = useMemo<SegmentedControlContextValue>(\n () => ({\n selectedValue,\n onSelect,\n }),\n [\n selectedValue,\n onSelect,\n ],\n );\n\n return (\n <SegmentedControlContext.Provider value={contextValue}>\n <ul\n className={cls.root}\n style={sls.root}\n {...restProps}\n >\n {children}\n </ul>\n </SegmentedControlContext.Provider>\n );\n}\n\ninterface SegmentedControlItemOwnProps {\n /**\n * The value represented by this control.\n */\n value: string;\n}\nexport type SegmentedControlItemProps<E extends ElementType = \"button\"> = HuiPolymorphicProps<\n E,\n SegmentedControlItemOwnProps,\n SegmentedControlItemSlots\n>;\n\nfunction Item<E extends ElementType = \"button\">(rawProps: SegmentedControlItemProps<E>): ReactElement {\n const {\n as,\n value,\n children,\n onClick,\n ...restProps\n } = useHuiProps(\"SegmentedControlItem\", rawProps);\n\n const Component = as ?? \"button\";\n\n const { selectedValue, onSelect } = useSegmentedControlContext();\n const recipe = segmentedControlItemRecipe({});\n const cls = useHuiClassNames(\"SegmentedControlItem\", recipe, rawProps);\n const sls = useHuiStyles(\"SegmentedControlItem\", rawProps);\n const attrs = normalizeAttributes(\n segmentedControl.getItemAttributes({\n isButtonElement: typeof as === \"undefined\",\n selectedValue,\n }, value),\n );\n\n const handleClick = useCallback(\n (e: MouseEvent<HTMLButtonElement>): void => {\n onClick?.(e);\n if (e.defaultPrevented) return;\n onSelect(value);\n },\n [onClick, onSelect, value],\n );\n\n return (\n <li>\n <Component\n className={cls.root}\n style={sls.root}\n {...attrs}\n onClick={handleClick}\n {...restProps}\n >\n {children}\n </Component>\n </li>\n );\n}\n\nexport const SegmentedControl = Object.assign(SegmentedControlRoot, {\n Item,\n});\n"],"mappings":";;;;;;;AAkDA,SAAS,qBACP,UACc;CACd,MAAM,EACJ,QACA,OACA,cACA,UACA,UACA,GAAG,cACD,YAAY,oBAAoB,QAAQ;CAE5C,MAAM,CAAC,mBAAmB,wBAAwB,eAC1C,SAAS,gBAAgB,OAAO,EACxC;CACA,MAAM,gBAAgB,SAAS;CAC/B,MAAM,SAAS,2BAA2B,CAAC,CAAC;CAC5C,MAAM,MAAM,iBAAiB,oBAAoB,QAAQ,QAAQ;CACjE,MAAM,MAAM,aAAa,oBAAoB,QAAQ;CAErD,MAAM,WAAW,aACd,cAAsB;EACrB,IAAI,CAAE,OAA6B,SAAS,SAAS,GACnD,MAAM,IAAI,MAAM,kDAAkD,WAAW;EAG/E,MAAM,IAAI;EACV,IAAI,MAAM,eAAe;EAEzB,qBAAqB,CAAC;EACtB,WAAW,CAAC;CACd,GACA;EAAC;EAAU;EAAe;CAAM,CAClC;CAEA,MAAM,eAAe,eACZ;EACL;EACA;CACF,IACA,CACE,eACA,QACF,CACF;CAEA,OACE,oBAAC,wBAAwB,UAAzB;EAAkC,OAAO;EACvC,UAAA,oBAAC,MAAD;GACE,WAAW,IAAI;GACf,OAAO,IAAI;GACX,GAAI;GAEH;EACC,CAAA;CAC4B,CAAA;AAEtC;AAcA,SAAS,KAAuC,UAAsD;CACpG,MAAM,EACJ,IACA,OACA,UACA,SACA,GAAG,cACD,YAAY,wBAAwB,QAAQ;CAEhD,MAAM,YAAY,MAAM;CAExB,MAAM,EAAE,eAAe,aAAa,2BAA2B;CAC/D,MAAM,SAAS,2BAA2B,CAAC,CAAC;CAC5C,MAAM,MAAM,iBAAiB,wBAAwB,QAAQ,QAAQ;CACrE,MAAM,MAAM,aAAa,wBAAwB,QAAQ;CACzD,MAAM,QAAQ,oBACZ,iBAAiB,kBAAkB;EACjC,iBAAiB,OAAO,OAAO;EAC/B;CACF,GAAG,KAAK,CACV;CAEA,MAAM,cAAc,aACjB,MAA2C;EAC1C,UAAU,CAAC;EACX,IAAI,EAAE,kBAAkB;EACxB,SAAS,KAAK;CAChB,GACA;EAAC;EAAS;EAAU;CAAK,CAC3B;CAEA,OACE,oBAAC,MAAD,EAAA,UACE,oBAAC,WAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EACJ,SAAS;EACT,GAAI;EAEH;CACQ,CAAA,EACT,CAAA;AAER;AAEA,MAAa,mBAAmB,OAAO,OAAO,sBAAsB,EAClE,KACF,CAAC"}
|
|
@@ -4,7 +4,6 @@ import { LabelProps } from "../label/label.js";
|
|
|
4
4
|
import "../label/index.js";
|
|
5
5
|
import { SelectSlots } from "@hebium-ui/core";
|
|
6
6
|
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
7
|
-
//#region src/components/select/select.d.ts
|
|
8
7
|
type HtmlSelectProps = ComponentProps<"select">;
|
|
9
8
|
interface SelectOwnProps extends HtmlSelectProps {
|
|
10
9
|
/**
|
|
@@ -26,6 +25,4 @@ interface SelectOwnProps extends HtmlSelectProps {
|
|
|
26
25
|
}
|
|
27
26
|
export type SelectProps = HuiComponentProps<SelectOwnProps, SelectSlots>;
|
|
28
27
|
export declare function Select(rawProps: SelectProps): ReactElement;
|
|
29
|
-
|
|
30
|
-
export {};
|
|
31
|
-
//# sourceMappingURL=select.d.ts.map
|
|
28
|
+
export {};
|
|
@@ -4,9 +4,9 @@ import { Label } from "../label/label.js";
|
|
|
4
4
|
import { inputControl, selectRecipe, toBool, toStrbool } from "@hebium-ui/core";
|
|
5
5
|
import { useId } from "react";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
|
|
7
|
+
// src/components/select/select.tsx
|
|
8
8
|
function Select(rawProps) {
|
|
9
|
-
const { id,
|
|
9
|
+
const { id, label, description, error, labelProps, ...restProps } = useHuiProps("Select", rawProps);
|
|
10
10
|
const tmpId = useId();
|
|
11
11
|
const inputState = {
|
|
12
12
|
id: id || tmpId,
|
|
@@ -15,8 +15,8 @@ function Select(rawProps) {
|
|
|
15
15
|
disabled: toBool(restProps.disabled) || toBool(restProps["aria-disabled"])
|
|
16
16
|
};
|
|
17
17
|
const recipe = selectRecipe({ error: toStrbool(inputState.invalid) });
|
|
18
|
-
const cls = useHuiClassNames("Select", recipe,
|
|
19
|
-
const sls = useHuiStyles("Select",
|
|
18
|
+
const cls = useHuiClassNames("Select", recipe, rawProps);
|
|
19
|
+
const sls = useHuiStyles("Select", rawProps);
|
|
20
20
|
const hasLabel = !!label || !!description || !!error;
|
|
21
21
|
const controlAttrs = normalizeAttributes(inputControl.getControlAttributes(inputState));
|
|
22
22
|
const labelAttrs = normalizeAttributes(inputControl.getLabelAttributes(inputState));
|
|
@@ -42,7 +42,6 @@ function Select(rawProps) {
|
|
|
42
42
|
})]
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
|
-
//#endregion
|
|
46
45
|
export { Select };
|
|
47
46
|
|
|
48
47
|
//# sourceMappingURL=select.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.js","names":[],"sources":["../../../src/components/select/select.tsx"],"sourcesContent":["import { inputControl, selectRecipe, type SelectSlots, toBool, toStrbool } from \"@hebium-ui/core\";\nimport { type ComponentProps, type ReactElement, type ReactNode, useId } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps } from \"~/types\";\nimport { normalizeAttributes } from \"~/utils\";\nimport { Label, type LabelProps } from \"../label\";\n\ntype HtmlSelectProps = ComponentProps<\"select\">;\n\ninterface SelectOwnProps extends HtmlSelectProps {\n /**\n * The label displayed above the select.\n */\n label?: ReactNode | undefined;\n /**\n * Additional props passed to the internal label component.\n */\n labelProps?: LabelProps | undefined;\n /**\n * The help text displayed below the label.\n */\n description?: ReactNode | undefined;\n /**\n * The validation error message displayed below the label.\n */\n error?: ReactNode | undefined;\n}\n\nexport type SelectProps = HuiComponentProps<\n SelectOwnProps,\n SelectSlots\n>;\n\nexport function Select(rawProps: SelectProps): ReactElement {\n const {\n id,\n
|
|
1
|
+
{"version":3,"file":"select.js","names":[],"sources":["../../../src/components/select/select.tsx"],"sourcesContent":["import { inputControl, selectRecipe, type SelectSlots, toBool, toStrbool } from \"@hebium-ui/core\";\nimport { type ComponentProps, type ReactElement, type ReactNode, useId } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps } from \"~/types\";\nimport { normalizeAttributes } from \"~/utils\";\nimport { Label, type LabelProps } from \"../label\";\n\ntype HtmlSelectProps = ComponentProps<\"select\">;\n\ninterface SelectOwnProps extends HtmlSelectProps {\n /**\n * The label displayed above the select.\n */\n label?: ReactNode | undefined;\n /**\n * Additional props passed to the internal label component.\n */\n labelProps?: LabelProps | undefined;\n /**\n * The help text displayed below the label.\n */\n description?: ReactNode | undefined;\n /**\n * The validation error message displayed below the label.\n */\n error?: ReactNode | undefined;\n}\n\nexport type SelectProps = HuiComponentProps<\n SelectOwnProps,\n SelectSlots\n>;\n\nexport function Select(rawProps: SelectProps): ReactElement {\n const {\n id,\n label,\n description,\n error,\n labelProps,\n ...restProps\n } = useHuiProps(\"Select\", rawProps);\n\n const tmpId = useId();\n\n const inputState = {\n id: id || tmpId,\n invalid: !!error,\n required: restProps.required ?? toBool(restProps[\"aria-required\"]),\n disabled: toBool(restProps.disabled) || toBool(restProps[\"aria-disabled\"]),\n };\n const recipe = selectRecipe({\n error: toStrbool(inputState.invalid),\n });\n const cls = useHuiClassNames(\"Select\", recipe, rawProps);\n const sls = useHuiStyles(\"Select\", rawProps);\n const hasLabel = !!label || !!description || !!error;\n const controlAttrs = normalizeAttributes(inputControl.getControlAttributes(inputState));\n const labelAttrs = normalizeAttributes(inputControl.getLabelAttributes(inputState));\n\n return (\n <div\n data-disabled={inputState.disabled}\n className={cls.root}\n style={sls.root}\n >\n {hasLabel\n && (\n <Label\n {...labelAttrs}\n description={description}\n error={error}\n {...labelProps}\n >\n {label}\n </Label>\n )}\n <div className={cls.wrapper} style={sls.wrapper}>\n <select\n className={cls.select}\n style={sls.select}\n {...controlAttrs}\n {...restProps}\n />\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;AAiCA,SAAgB,OAAO,UAAqC;CAC1D,MAAM,EACJ,IACA,OACA,aACA,OACA,YACA,GAAG,cACD,YAAY,UAAU,QAAQ;CAElC,MAAM,QAAQ,MAAM;CAEpB,MAAM,aAAa;EACjB,IAAI,MAAM;EACV,SAAS,CAAC,CAAC;EACX,UAAU,UAAU,YAAY,OAAO,UAAU,gBAAgB;EACjE,UAAU,OAAO,UAAU,QAAQ,KAAK,OAAO,UAAU,gBAAgB;CAC3E;CACA,MAAM,SAAS,aAAa,EAC1B,OAAO,UAAU,WAAW,OAAO,EACrC,CAAC;CACD,MAAM,MAAM,iBAAiB,UAAU,QAAQ,QAAQ;CACvD,MAAM,MAAM,aAAa,UAAU,QAAQ;CAC3C,MAAM,WAAW,CAAC,CAAC,SAAS,CAAC,CAAC,eAAe,CAAC,CAAC;CAC/C,MAAM,eAAe,oBAAoB,aAAa,qBAAqB,UAAU,CAAC;CACtF,MAAM,aAAa,oBAAoB,aAAa,mBAAmB,UAAU,CAAC;CAElF,OACE,qBAAC,OAAD;EACE,iBAAe,WAAW;EAC1B,WAAW,IAAI;EACf,OAAO,IAAI;EAHb,UAAA,CAKG,YAEG,oBAAC,OAAD;GACE,GAAI;GACS;GACN;GACP,GAAI;GAEH,UAAA;EACI,CAAA,GAEX,oBAAC,OAAD;GAAK,WAAW,IAAI;GAAS,OAAO,IAAI;GACtC,UAAA,oBAAC,UAAD;IACE,WAAW,IAAI;IACf,OAAO,IAAI;IACX,GAAI;IACJ,GAAI;GACL,CAAA;EACE,CAAA,CACF;;AAET"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { HuiPolymorphicProps } from "../../types/polymorphic.js";
|
|
2
|
+
import "../../types/index.js";
|
|
3
|
+
import { SkipLinkSlots } from "@hebium-ui/core";
|
|
4
|
+
import { ElementType, ReactElement } from "react";
|
|
5
|
+
export type SkipLinkProps<E extends ElementType = "div"> = HuiPolymorphicProps<E, {}, SkipLinkSlots>;
|
|
6
|
+
export declare function SkipLink<E extends ElementType = "div">(rawProps: SkipLinkProps<E>): ReactElement;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
|
|
2
|
+
import { skipLinkRecipe } from "@hebium-ui/core";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
// src/components/skip-link/skip-link.tsx
|
|
5
|
+
function SkipLink(rawProps) {
|
|
6
|
+
const { as, children, ...restProps } = useHuiProps("SkipLink", rawProps);
|
|
7
|
+
const Component = as ?? "div";
|
|
8
|
+
const recipe = skipLinkRecipe({});
|
|
9
|
+
const cls = useHuiClassNames("SkipLink", recipe, rawProps);
|
|
10
|
+
const sls = useHuiStyles("SkipLink", rawProps);
|
|
11
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
12
|
+
className: cls.root,
|
|
13
|
+
style: sls.root,
|
|
14
|
+
...restProps,
|
|
15
|
+
children
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export { SkipLink };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=skip-link.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skip-link.js","names":[],"sources":["../../../src/components/skip-link/skip-link.tsx"],"sourcesContent":["import { skipLinkRecipe, type SkipLinkSlots } from \"@hebium-ui/core\";\nimport { type ElementType, type ReactElement } from \"react\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\n\nexport type SkipLinkProps<E extends ElementType = \"div\"> = HuiPolymorphicProps<\n E,\n {},\n SkipLinkSlots\n>;\n\nexport function SkipLink<E extends ElementType = \"div\">(rawProps: SkipLinkProps<E>): ReactElement {\n const {\n as,\n children,\n ...restProps\n } = useHuiProps(\"SkipLink\", rawProps);\n\n const Component = as ?? \"div\";\n const recipe = skipLinkRecipe({});\n const cls = useHuiClassNames(\"SkipLink\", recipe, rawProps);\n const sls = useHuiStyles(\"SkipLink\", rawProps);\n\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n"],"mappings":";;;;AAWA,SAAgB,SAAwC,UAA0C;CAChG,MAAM,EACJ,IACA,UACA,GAAG,cACD,YAAY,YAAY,QAAQ;CAEpC,MAAM,YAAY,MAAM;CACxB,MAAM,SAAS,eAAe,CAAC,CAAC;CAChC,MAAM,MAAM,iBAAiB,YAAY,QAAQ,QAAQ;CACzD,MAAM,MAAM,aAAa,YAAY,QAAQ;CAE7C,OACE,oBAAC,WAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EAEH;CACQ,CAAA;AAEf"}
|