@hebium-ui/preact 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.
Files changed (75) hide show
  1. package/dist/components/alert/alert.d.ts +3 -6
  2. package/dist/components/alert/alert.js +7 -15
  3. package/dist/components/alert/alert.js.map +1 -1
  4. package/dist/components/anchor/anchor.d.ts +1 -4
  5. package/dist/components/anchor/anchor.js +5 -6
  6. package/dist/components/anchor/anchor.js.map +1 -1
  7. package/dist/components/avatar/avatar.d.ts +7 -6
  8. package/dist/components/avatar/avatar.js +16 -19
  9. package/dist/components/avatar/avatar.js.map +1 -1
  10. package/dist/components/blockquote/blockquote.d.ts +2 -5
  11. package/dist/components/blockquote/blockquote.js +5 -6
  12. package/dist/components/blockquote/blockquote.js.map +1 -1
  13. package/dist/components/button/button.d.ts +12 -4
  14. package/dist/components/button/button.js +31 -12
  15. package/dist/components/button/button.js.map +1 -1
  16. package/dist/components/checkbox/checkbox.d.ts +31 -0
  17. package/dist/components/checkbox/checkbox.js +84 -0
  18. package/dist/components/checkbox/checkbox.js.map +1 -0
  19. package/dist/components/checkbox/index.d.ts +2 -0
  20. package/dist/components/code/code.d.ts +8 -0
  21. package/dist/components/code/code.js +20 -0
  22. package/dist/components/code/code.js.map +1 -0
  23. package/dist/components/code/index.d.ts +2 -0
  24. package/dist/components/details/details.d.ts +19 -0
  25. package/dist/components/details/details.js +27 -0
  26. package/dist/components/details/details.js.map +1 -0
  27. package/dist/components/details/index.d.ts +2 -0
  28. package/dist/components/dialog/dialog.context.js +15 -0
  29. package/dist/components/dialog/dialog.context.js.map +1 -0
  30. package/dist/components/dialog/dialog.d.ts +64 -0
  31. package/dist/components/dialog/dialog.js +144 -0
  32. package/dist/components/dialog/dialog.js.map +1 -0
  33. package/dist/components/dialog/index.d.ts +2 -0
  34. package/dist/components/dl/dl.d.ts +15 -0
  35. package/dist/components/dl/dl.js +47 -0
  36. package/dist/components/dl/dl.js.map +1 -0
  37. package/dist/components/dl/index.d.ts +2 -0
  38. package/dist/components/drawer/drawer.context.js +15 -0
  39. package/dist/components/drawer/drawer.context.js.map +1 -0
  40. package/dist/components/drawer/drawer.d.ts +64 -0
  41. package/dist/components/drawer/drawer.js +124 -0
  42. package/dist/components/drawer/drawer.js.map +1 -0
  43. package/dist/components/drawer/index.d.ts +2 -0
  44. package/dist/components/heading/heading.d.ts +21 -0
  45. package/dist/components/heading/heading.js +23 -0
  46. package/dist/components/heading/heading.js.map +1 -0
  47. package/dist/components/heading/index.d.ts +2 -0
  48. package/dist/components/index.d.ts +17 -1
  49. package/dist/components/progress/progress.d.ts +1 -4
  50. package/dist/components/progress/progress.js +5 -6
  51. package/dist/components/progress/progress.js.map +1 -1
  52. package/dist/components/status-icon/index.d.ts +2 -0
  53. package/dist/components/status-icon/status-icon.d.ts +19 -0
  54. package/dist/components/status-icon/status-icon.js +22 -0
  55. package/dist/components/status-icon/status-icon.js.map +1 -0
  56. package/dist/components/tabs/tabs.context.d.ts +1 -4
  57. package/dist/components/tabs/tabs.context.js +1 -2
  58. package/dist/components/tabs/tabs.d.ts +2 -5
  59. package/dist/components/tabs/tabs.js +18 -18
  60. package/dist/components/tabs/tabs.js.map +1 -1
  61. package/dist/index.d.ts +10 -2
  62. package/dist/index.js +10 -2
  63. package/dist/provider/hui-provider.context.d.ts +42 -9
  64. package/dist/provider/hui-provider.context.js +31 -18
  65. package/dist/provider/hui-provider.context.js.map +1 -1
  66. package/dist/provider/hui-provider.d.ts +1 -4
  67. package/dist/provider/hui-provider.js +1 -2
  68. package/dist/provider/index.d.ts +2 -2
  69. package/dist/provider/merge-props.js +1 -2
  70. package/dist/types/hui-component.d.ts +15 -9
  71. package/dist/types/index.d.ts +2 -2
  72. package/dist/types/polymorphic.d.ts +7 -11
  73. package/dist/utils/unwrap-signalish.js +10 -0
  74. package/dist/utils/unwrap-signalish.js.map +1 -0
  75. package/package.json +12 -11
@@ -0,0 +1,21 @@
1
+ import { HuiComponentProps } from "../../types/hui-component.js";
2
+ import "../../types/index.js";
3
+ import { HeadingSlots, HeadingVariants } from "@hebium-ui/core";
4
+ import { ComponentProps, VNode } from "preact";
5
+ interface HeadingOwnProps {
6
+ /**
7
+ * The heading level used to choose the rendered heading element.
8
+ *
9
+ * @default 2
10
+ */
11
+ level?: 1 | 2 | 3 | 4 | 5 | 6 | undefined;
12
+ /**
13
+ * The block margin applied to the heading.
14
+ *
15
+ * @default "none"
16
+ */
17
+ margin?: HeadingVariants["margin"] | undefined;
18
+ }
19
+ export type HeadingProps = HuiComponentProps<ComponentProps<"h2"> & HeadingOwnProps, HeadingSlots>;
20
+ export declare function Heading(rawProps: HeadingProps): VNode;
21
+ export {};
@@ -0,0 +1,23 @@
1
+ import { useHuiClasses, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
2
+ import { headingRecipe } from "@hebium-ui/core";
3
+ import { jsx } from "preact/jsx-runtime";
4
+ // src/components/heading/heading.tsx
5
+ function Heading(rawProps) {
6
+ const { level = 2, margin, children, ...restProps } = useHuiProps("Heading", rawProps);
7
+ const Component = `h${level}`;
8
+ const recipe = headingRecipe({
9
+ level: `${level}`,
10
+ margin
11
+ });
12
+ const cls = useHuiClasses("Heading", recipe, rawProps);
13
+ const sls = useHuiStyles("Heading", rawProps);
14
+ return /* @__PURE__ */ jsx(Component, {
15
+ className: cls.root,
16
+ style: sls.root,
17
+ ...restProps,
18
+ children
19
+ });
20
+ }
21
+ export { Heading };
22
+
23
+ //# 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 VNode } from \"preact\";\nimport { useHuiClasses, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps } from \"~/types\";\n\ninterface HeadingOwnProps {\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 type HeadingProps = HuiComponentProps<ComponentProps<\"h2\"> & HeadingOwnProps, HeadingSlots>;\n\nexport function Heading(rawProps: HeadingProps): VNode {\n const {\n level = 2,\n margin,\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 = useHuiClasses(\"Heading\", recipe, rawProps);\n const sls = useHuiStyles(\"Heading\", 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":";;;;AAsBA,SAAgB,QAAQ,UAA+B;CACrD,MAAM,EACJ,QAAQ,GACR,QACA,UACA,GAAG,cACD,YAAY,WAAW,QAAQ;CAEnC,MAAM,YAAY,IAAI;CAEtB,MAAM,SAAS,cAAc;EAAE,OAAO,GAAG;EAAS;CAAO,CAAC;CAC1D,MAAM,MAAM,cAAc,WAAW,QAAQ,QAAQ;CACrD,MAAM,MAAM,aAAa,WAAW,QAAQ;CAE5C,OACE,oBAAC,WAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EAEH;CACQ,CAAA;AAEf"}
@@ -0,0 +1,2 @@
1
+ import { Heading, HeadingProps } from "./heading.js";
2
+ export { Heading, HeadingProps };
@@ -8,8 +8,24 @@ import { Blockquote, BlockquoteProps } from "./blockquote/blockquote.js";
8
8
  import "./blockquote/index.js";
9
9
  import { Button, ButtonProps } from "./button/button.js";
10
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 "./dialog/index.js";
19
+ import { Dialog, DialogCloseProps, DialogContentProps, DialogProps, DialogTriggerProps } from "./dialog/dialog.js";
20
+ import "./dl/index.js";
21
+ import { DdProps, Dl, DlProps, DtProps } from "./dl/dl.js";
22
+ import "./drawer/index.js";
23
+ import { Drawer, DrawerCloseProps, DrawerContentProps, DrawerProps, DrawerTriggerProps } from "./drawer/drawer.js";
24
+ import "./heading/index.js";
11
25
  import { Progress, ProgressProps } from "./progress/progress.js";
12
26
  import "./progress/index.js";
27
+ import { StatusIcon, StatusIconProps } from "./status-icon/status-icon.js";
28
+ import "./status-icon/index.js";
13
29
  import { Tabs, TabsListProps, TabsPanelProps, TabsProps, TabsTabProps } from "./tabs/tabs.js";
14
30
  import "./tabs/index.js";
15
- export { Alert, AlertProps, Anchor, AnchorProps, Avatar, AvatarProps, Blockquote, BlockquoteProps, Button, ButtonProps, Progress, ProgressProps, Tabs, TabsListProps, TabsPanelProps, TabsProps, TabsTabProps };
31
+ export { Alert, AlertProps, Anchor, AnchorProps, Avatar, AvatarProps, Blockquote, BlockquoteProps, Button, ButtonProps, Checkbox, CheckboxProps, Code, CodeProps, DdProps, Details, DetailsProps, Dialog, DialogCloseProps, DialogContentProps, DialogProps, DialogTriggerProps, Dl, DlProps, Drawer, DrawerCloseProps, DrawerContentProps, DrawerProps, DrawerTriggerProps, DtProps, Heading, HeadingProps, Progress, ProgressProps, StatusIcon, StatusIconProps, Tabs, TabsListProps, TabsPanelProps, TabsProps, TabsTabProps };
@@ -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 { ComponentChildren, ComponentProps, VNode } from "preact";
5
- //#region src/components/progress/progress.d.ts
6
5
  interface ProgressOwnProps {
7
6
  /**
8
7
  * The minimum value of the progress range.
@@ -49,6 +48,4 @@ interface ProgressOwnProps {
49
48
  }
50
49
  export type ProgressProps = HuiComponentProps<ComponentProps<"div"> & ProgressOwnProps, ProgressSlots>;
51
50
  export declare function Progress(rawProps: ProgressProps): VNode;
52
- //#endregion
53
- export {};
54
- //# sourceMappingURL=progress.d.ts.map
51
+ export {};
@@ -1,10 +1,10 @@
1
- import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
1
+ import { useHuiClasses, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
2
2
  import { CSS_VARS, cc, progressControl, progressRecipe, toStrbool } from "@hebium-ui/core";
3
3
  import { useId } from "preact/hooks";
4
4
  import { jsx, jsxs } from "preact/jsx-runtime";
5
- //#region src/components/progress/progress.tsx
5
+ // src/components/progress/progress.tsx
6
6
  function Progress(rawProps) {
7
- const { min, max, value, valueText, label, color, radius, size, classNames, styles, nonce, children: _children, ...restProps } = useHuiProps("Progress", rawProps);
7
+ const { min, max, value, valueText, label, color, radius, size, nonce, children: _children, ...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, classNames);
24
- const sls = useHuiStyles("Progress", styles);
23
+ const cls = useHuiClasses("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 ComponentChildren, type ComponentProps, type VNode } from \"preact\";\nimport { useId } from \"preact/hooks\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps } from \"~/types\";\n\ninterface ProgressOwnProps {\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?: ComponentChildren | 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<ComponentProps<\"div\"> & ProgressOwnProps, ProgressSlots>;\n\nexport function Progress(rawProps: ProgressProps): VNode {\n const {\n min,\n max,\n value,\n valueText,\n label,\n color,\n radius,\n size,\n classNames,\n styles,\n nonce,\n children: _children,\n ...restProps\n } = useHuiProps(\"Progress\", rawProps);\n const progressId = useId();\n const progress = progressControl.resolve({\n progressId,\n hasLabel: Boolean(label),\n min,\n max,\n value,\n valueText,\n });\n\n const recipe = progressRecipe({\n color,\n indeterminate: toStrbool(progress.isIndeterminate),\n radius,\n size,\n });\n const cls = useHuiClassNames(\"Progress\", recipe, classNames);\n const sls = useHuiStyles(\"Progress\", styles);\n const labelAttrs = progressControl.getLabelAttributes(progress);\n const barAttrs = progressControl.getBarAttributes(progress);\n const valueAttrs = progressControl.getValueAttributes();\n const valueClassName = `progress-value-${progress.progressId}`;\n\n return (\n <div\n className={cls.root}\n style={sls.root}\n >\n {label\n && (\n <div\n className={cls.label}\n style={sls.label}\n {...labelAttrs}\n >\n {label}\n </div>\n )}\n <div\n className={cls.bar}\n style={sls.bar}\n {...barAttrs}\n {...restProps}\n >\n <style nonce={nonce}>\n {`.${valueClassName} {${CSS_VARS.arbitraryWidth}: ${progress.width}}`}\n </style>\n <div\n className={cc(cls.value, valueClassName)}\n style={sls.value}\n {...valueAttrs}\n >\n {progress.isIndeterminate ? undefined : valueText}\n </div>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;AA6DA,SAAgB,SAAS,UAAgC;CACvD,MAAM,EACJ,KACA,KACA,OACA,WACA,OACA,OACA,QACA,MACA,YACA,QACA,OACA,UAAU,WACV,GAAG,cACD,YAAY,YAAY,QAAQ;CACpC,MAAM,aAAa,MAAM;CACzB,MAAM,WAAW,gBAAgB,QAAQ;EACvC;EACA,UAAU,QAAQ,KAAK;EACvB;EACA;EACA;EACA;CACF,CAAC;CAED,MAAM,SAAS,eAAe;EAC5B;EACA,eAAe,UAAU,SAAS,eAAe;EACjD;EACA;CACF,CAAC;CACD,MAAM,MAAM,iBAAiB,YAAY,QAAQ,UAAU;CAC3D,MAAM,MAAM,aAAa,YAAY,MAAM;CAC3C,MAAM,aAAa,gBAAgB,mBAAmB,QAAQ;CAC9D,MAAM,WAAW,gBAAgB,iBAAiB,QAAQ;CAC1D,MAAM,aAAa,gBAAgB,mBAAmB;CACtD,MAAM,iBAAiB,kBAAkB,SAAS;CAElD,OACE,qBAAC,OAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EAFb,UAAA,CAIG,SAEG,oBAAC,OAAD;GACE,WAAW,IAAI;GACf,OAAO,IAAI;GACX,GAAI;GAEH,UAAA;EACE,CAAA,GAET,qBAAC,OAAD;GACE,WAAW,IAAI;GACf,OAAO,IAAI;GACX,GAAI;GACJ,GAAI;GAJN,UAAA,CAME,oBAAC,SAAD;IAAc;IACX,UAAA,IAAI,eAAe,IAAI,SAAS,eAAe,IAAI,SAAS,MAAM;GAC9D,CAAA,GACP,oBAAC,OAAD;IACE,WAAW,GAAG,IAAI,OAAO,cAAc;IACvC,OAAO,IAAI;IACX,GAAI;IAEH,UAAA,SAAS,kBAAkB,KAAA,IAAY;GACrC,CAAA,CACF;EACF,CAAA,CAAA;;AAET"}
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 ComponentChildren, type ComponentProps, type VNode } from \"preact\";\nimport { useId } from \"preact/hooks\";\nimport { useHuiClasses, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps } from \"~/types\";\n\ninterface ProgressOwnProps {\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?: ComponentChildren | 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<ComponentProps<\"div\"> & ProgressOwnProps, ProgressSlots>;\n\nexport function Progress(rawProps: ProgressProps): VNode {\n const {\n min,\n max,\n value,\n valueText,\n label,\n color,\n radius,\n size,\n nonce,\n children: _children,\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 = useHuiClasses(\"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":";;;;;AA6DA,SAAgB,SAAS,UAAgC;CACvD,MAAM,EACJ,KACA,KACA,OACA,WACA,OACA,OACA,QACA,MACA,OACA,UAAU,WACV,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,cAAc,YAAY,QAAQ,QAAQ;CACtD,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"}
@@ -0,0 +1,2 @@
1
+ import { StatusIcon, StatusIconProps } from "./status-icon.js";
2
+ export { StatusIcon, StatusIconProps };
@@ -0,0 +1,19 @@
1
+ import { HuiComponentProps } from "../../types/hui-component.js";
2
+ import "../../types/index.js";
3
+ import { StatusIconSlots, StatusIconVariants } from "@hebium-ui/core";
4
+ import { ComponentProps, VNode } from "preact";
5
+ interface StatusIconOwnProps {
6
+ /**
7
+ * Status to display.
8
+ */
9
+ status: NonNullable<StatusIconVariants["status"]>;
10
+ /**
11
+ * Icon color.
12
+ *
13
+ * @default "inherit"
14
+ */
15
+ color?: StatusIconVariants["color"] | undefined;
16
+ }
17
+ export type StatusIconProps = HuiComponentProps<Omit<ComponentProps<"span">, "children" | "color"> & StatusIconOwnProps, StatusIconSlots>;
18
+ export declare function StatusIcon(rawProps: StatusIconProps): VNode;
19
+ export {};
@@ -0,0 +1,22 @@
1
+ import { useHuiClasses, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
2
+ import { statusIconRecipe } from "@hebium-ui/core";
3
+ import { jsx } from "preact/jsx-runtime";
4
+ // src/components/status-icon/status-icon.tsx
5
+ function StatusIcon(rawProps) {
6
+ const { status, color, ...restProps } = useHuiProps("StatusIcon", rawProps);
7
+ const recipe = statusIconRecipe({
8
+ status,
9
+ color
10
+ });
11
+ const cls = useHuiClasses("StatusIcon", recipe, rawProps);
12
+ const sls = useHuiStyles("StatusIcon", rawProps);
13
+ return /* @__PURE__ */ jsx("span", {
14
+ "aria-hidden": true,
15
+ className: cls.root,
16
+ style: sls.root,
17
+ ...restProps
18
+ });
19
+ }
20
+ export { StatusIcon };
21
+
22
+ //# sourceMappingURL=status-icon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status-icon.js","names":[],"sources":["../../../src/components/status-icon/status-icon.tsx"],"sourcesContent":["import { statusIconRecipe, type StatusIconSlots, type StatusIconVariants } from \"@hebium-ui/core\";\nimport { type ComponentProps, type VNode } from \"preact\";\nimport { useHuiClasses, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps } from \"~/types\";\n\ninterface StatusIconOwnProps {\n /**\n * Status to display.\n */\n status: NonNullable<StatusIconVariants[\"status\"]>;\n /**\n * Icon color.\n *\n * @default \"inherit\"\n */\n color?: StatusIconVariants[\"color\"] | undefined;\n}\n\nexport type StatusIconProps = HuiComponentProps<\n Omit<ComponentProps<\"span\">, \"children\" | \"color\"> & StatusIconOwnProps,\n StatusIconSlots\n>;\n\nexport function StatusIcon(rawProps: StatusIconProps): VNode {\n const {\n status,\n color,\n ...restProps\n } = useHuiProps(\"StatusIcon\", rawProps);\n const recipe = statusIconRecipe({\n status,\n color,\n });\n\n const cls = useHuiClasses(\"StatusIcon\", recipe, rawProps);\n const sls = useHuiStyles(\"StatusIcon\", rawProps);\n\n return (\n <span\n aria-hidden\n className={cls.root}\n style={sls.root}\n {...restProps}\n />\n );\n}\n"],"mappings":";;;;AAuBA,SAAgB,WAAW,UAAkC;CAC3D,MAAM,EACJ,QACA,OACA,GAAG,cACD,YAAY,cAAc,QAAQ;CACtC,MAAM,SAAS,iBAAiB;EAC9B;EACA;CACF,CAAC;CAED,MAAM,MAAM,cAAc,cAAc,QAAQ,QAAQ;CACxD,MAAM,MAAM,aAAa,cAAc,QAAQ;CAE/C,OACE,oBAAC,QAAD;EACE,eAAA;EACA,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;CACL,CAAA;AAEL"}
@@ -1,4 +1 @@
1
- //#region src/components/tabs/tabs.context.d.ts
2
- export type ActivationMode = "manual" | "auto";
3
- //#endregion
4
- //# sourceMappingURL=tabs.context.d.ts.map
1
+ export type ActivationMode = "manual" | "auto";
@@ -1,13 +1,12 @@
1
1
  import { useContext } from "preact/hooks";
2
2
  import { createContext } from "preact";
3
- //#region src/components/tabs/tabs.context.ts
3
+ // src/components/tabs/tabs.context.ts
4
4
  const TabsContext = createContext(null);
5
5
  function useTabsContext() {
6
6
  const context = useContext(TabsContext);
7
7
  if (!context) throw new Error("[Hebium UI] Tabs compound components must be used within <Tabs>");
8
8
  return context;
9
9
  }
10
- //#endregion
11
10
  export { TabsContext, useTabsContext };
12
11
 
13
12
  //# sourceMappingURL=tabs.context.js.map
@@ -3,12 +3,11 @@ import "../../types/index.js";
3
3
  import { ActivationMode } from "./tabs.context.js";
4
4
  import { TabSlots, TablistSlots, TabpanelSlots, TabrootSlots } from "@hebium-ui/core";
5
5
  import { JSX, VNode } from "preact";
6
- //#region src/components/tabs/tabs.d.ts
7
6
  interface TabsOwnProps<V extends string> {
8
7
  /**
9
8
  * The list of allowed tab values.
10
9
  */
11
- values: V[];
10
+ values: readonly V[];
12
11
  /**
13
12
  * The currently selected tab value.
14
13
  */
@@ -55,6 +54,4 @@ export declare const Tabs: typeof TabsRoot & {
55
54
  Tab: typeof Tab;
56
55
  Panel: typeof Panel;
57
56
  };
58
- //#endregion
59
- export {};
60
- //# sourceMappingURL=tabs.d.ts.map
57
+ export {};
@@ -1,19 +1,20 @@
1
- import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
1
+ import { useHuiClasses, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
2
+ import { unwrapSignalish } from "../../utils/unwrap-signalish.js";
2
3
  import { TabsContext, useTabsContext } from "./tabs.context.js";
3
4
  import { tabRecipe, tablistRecipe, tabpanelRecipe, tabrootRecipe, tabsControl } from "@hebium-ui/core";
4
5
  import { useCallback, useId, useMemo, useState } from "preact/hooks";
5
6
  import { jsx } from "preact/jsx-runtime";
6
- //#region src/components/tabs/tabs.tsx
7
+ // src/components/tabs/tabs.tsx
7
8
  function TabsRoot(rawProps) {
8
- const { as, id, values, value, defaultValue, onChange, className, style, children, activation = "manual", ...restProps } = useHuiProps("Tabs", rawProps);
9
+ const { as, id, values, value, defaultValue, onChange, children, activation = "manual", ...restProps } = useHuiProps("Tabs", rawProps);
9
10
  const Component = as ?? "div";
10
11
  const tmpId = useId();
11
- const rootId = id || tmpId;
12
+ const rootId = unwrapSignalish(id) || tmpId;
12
13
  const [uncontrolledValue, setUncontrolledValue] = useState(() => value ?? defaultValue ?? values[0]);
13
14
  const selectedValue = value ?? uncontrolledValue;
14
15
  const recipe = tabrootRecipe({});
15
- const cls = useHuiClassNames("Tabs", recipe, { root: className });
16
- const sls = useHuiStyles("Tabs", { root: style });
16
+ const cls = useHuiClasses("Tabs", recipe, rawProps);
17
+ const sls = useHuiStyles("Tabs", rawProps);
17
18
  const onSelect = useCallback((nextValue) => {
18
19
  if (!values.includes(nextValue)) throw new Error(`[Hebium UI] Unexpected Tab value: ${nextValue}`);
19
20
  const v = nextValue;
@@ -47,18 +48,18 @@ function TabsRoot(rawProps) {
47
48
  });
48
49
  }
49
50
  function List(rawProps) {
50
- const { as, className, style, children, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...restProps } = useHuiProps("TabsList", rawProps);
51
+ const { as, children, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...restProps } = useHuiProps("TabsList", rawProps);
51
52
  const Component = as ?? "div";
52
53
  const recipe = tablistRecipe({});
53
- const cls = useHuiClassNames("TabsList", recipe, { root: className });
54
- const sls = useHuiStyles("TabsList", { root: style });
54
+ const cls = useHuiClasses("TabsList", recipe, rawProps);
55
+ const sls = useHuiStyles("TabsList", rawProps);
55
56
  const { rootId, selectedValue } = useTabsContext();
56
57
  const attrs = tabsControl.getListAttributes({
57
58
  rootId,
58
59
  selectedValue
59
60
  }, {
60
- ariaLabel,
61
- ariaLabelledBy
61
+ ariaLabel: unwrapSignalish(ariaLabel),
62
+ ariaLabelledBy: unwrapSignalish(ariaLabelledBy)
62
63
  });
63
64
  return /* @__PURE__ */ jsx(Component, {
64
65
  className: cls.root,
@@ -69,12 +70,12 @@ function List(rawProps) {
69
70
  });
70
71
  }
71
72
  function Tab(rawProps) {
72
- const { as, value, className, style, children, onClick, onKeyDown, onFocus, ...restProps } = useHuiProps("TabsTab", rawProps);
73
+ const { as, value, children, onClick, onKeyDown, onFocus, ...restProps } = useHuiProps("TabsTab", rawProps);
73
74
  const Component = as ?? "button";
74
75
  const { rootId, selectedValue, onSelect, activation } = useTabsContext();
75
76
  const recipe = tabRecipe({});
76
- const cls = useHuiClassNames("TabsTab", recipe, { root: className });
77
- const sls = useHuiStyles("TabsTab", { root: style });
77
+ const cls = useHuiClasses("TabsTab", recipe, rawProps);
78
+ const sls = useHuiStyles("TabsTab", rawProps);
78
79
  const attrs = tabsControl.getTabAttributes({
79
80
  rootId,
80
81
  selectedValue
@@ -128,12 +129,12 @@ function Tab(rawProps) {
128
129
  });
129
130
  }
130
131
  function Panel(rawProps) {
131
- const { as, value, className, style, children, ...restProps } = useHuiProps("TabsPanel", rawProps);
132
+ const { as, value, children, ...restProps } = useHuiProps("TabsPanel", rawProps);
132
133
  const Component = as ?? "div";
133
134
  const { rootId, selectedValue } = useTabsContext();
134
135
  const recipe = tabpanelRecipe({});
135
- const cls = useHuiClassNames("TabsPanel", recipe, { root: className });
136
- const sls = useHuiStyles("TabsPanel", { root: style });
136
+ const cls = useHuiClasses("TabsPanel", recipe, rawProps);
137
+ const sls = useHuiStyles("TabsPanel", rawProps);
137
138
  const attrs = tabsControl.getPanelAttributes({
138
139
  rootId,
139
140
  selectedValue
@@ -151,7 +152,6 @@ const Tabs = Object.assign(TabsRoot, {
151
152
  Tab,
152
153
  Panel
153
154
  });
154
- //#endregion
155
155
  export { Tabs };
156
156
 
157
157
  //# sourceMappingURL=tabs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tabs.js","names":[],"sources":["../../../src/components/tabs/tabs.tsx"],"sourcesContent":["import {\n tablistRecipe,\n type TablistSlots,\n tabpanelRecipe,\n type TabpanelSlots,\n tabRecipe,\n tabrootRecipe,\n type TabrootSlots,\n tabsControl,\n type TabSlots,\n} from \"@hebium-ui/core\";\nimport {\n type JSX,\n type TargetedFocusEvent,\n type TargetedKeyboardEvent,\n type TargetedMouseEvent,\n type VNode,\n} from \"preact\";\nimport { useCallback, useId, useMemo, useState } from \"preact/hooks\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\nimport { type ActivationMode, TabsContext, type TabsContextValue, useTabsContext } from \"./tabs.context\";\n\ninterface TabsOwnProps<V extends string> {\n /**\n * The list of allowed tab values.\n */\n values: V[];\n /**\n * The currently selected tab value.\n */\n value?: V | undefined;\n /**\n * The initially selected tab value for uncontrolled tabs.\n */\n defaultValue?: V | undefined;\n /**\n * Called when the selected tab value changes.\n */\n onChange?: ((value: V) => void) | undefined;\n /**\n * The activation mode used when focus moves between tabs.\n *\n * @default \"manual\"\n * @see {@link https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_selection_follows_focus | WAI-ARIA APG: Deciding When to Make Selection Automatically Follow Focus}\n */\n activation?: ActivationMode;\n}\nexport type TabsProps<V extends string, E extends JSX.ElementType = \"div\"> = HuiPolymorphicProps<\n E,\n TabsOwnProps<V>,\n TabrootSlots\n>;\n\nfunction TabsRoot<V extends string, E extends JSX.ElementType = \"div\">(\n rawProps: TabsProps<V, E>,\n): VNode {\n const {\n as,\n id,\n values,\n value,\n defaultValue,\n onChange,\n className,\n style,\n children,\n activation = \"manual\",\n ...restProps\n } = useHuiProps(\"Tabs\", rawProps);\n\n const Component = as ?? \"div\";\n\n const tmpId = useId();\n const rootId = id || tmpId;\n const [uncontrolledValue, setUncontrolledValue] = useState<V | undefined>(\n () => value ?? defaultValue ?? values[0],\n );\n const selectedValue = value ?? uncontrolledValue;\n const recipe = tabrootRecipe({});\n const cls = useHuiClassNames(\"Tabs\", recipe, { root: className });\n const sls = useHuiStyles(\"Tabs\", { root: style });\n\n const onSelect = useCallback(\n (nextValue: string) => {\n if (!(values as string[]).includes(nextValue)) {\n throw new Error(`[Hebium UI] Unexpected Tab value: ${nextValue}`);\n }\n\n const v = nextValue as V;\n setUncontrolledValue(v);\n onChange?.(v);\n },\n [onChange, values],\n );\n\n const contextValue = useMemo<TabsContextValue>(\n () => ({\n rootId,\n selectedValue,\n onSelect,\n activation,\n }),\n [\n rootId,\n selectedValue,\n onSelect,\n activation,\n ],\n );\n const attrs = tabsControl.getRootAttributes({ rootId, selectedValue });\n\n return (\n <TabsContext.Provider value={contextValue}>\n <Component\n className={cls.root}\n style={sls.root}\n {...attrs}\n {...restProps}\n >\n {children}\n </Component>\n </TabsContext.Provider>\n );\n}\n\ninterface TabsListOwnProps {}\nexport type TabsListProps<E extends JSX.ElementType = \"div\"> = HuiPolymorphicProps<\n E,\n TabsListOwnProps,\n TablistSlots\n>;\n\nfunction List<E extends JSX.ElementType = \"div\">(rawProps: TabsListProps<E>): VNode {\n const {\n as,\n className,\n style,\n children,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n ...restProps\n } = useHuiProps(\"TabsList\", rawProps);\n\n const Component = as ?? \"div\";\n\n const recipe = tablistRecipe({});\n const cls = useHuiClassNames(\"TabsList\", recipe, { root: className });\n const sls = useHuiStyles(\"TabsList\", { root: style });\n const { rootId, selectedValue } = useTabsContext();\n const attrs = tabsControl.getListAttributes(\n { rootId, selectedValue },\n { ariaLabel, ariaLabelledBy },\n );\n\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...attrs}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n\ninterface TabsTabOwnProps {\n /**\n * The value represented by this tab.\n */\n value: string;\n}\nexport type TabsTabProps<E extends JSX.ElementType = \"button\"> = HuiPolymorphicProps<\n E,\n TabsTabOwnProps,\n TabSlots\n>;\n\nfunction Tab<E extends JSX.ElementType = \"button\">(rawProps: TabsTabProps<E>): VNode {\n const {\n as,\n value,\n className,\n style,\n children,\n onClick,\n onKeyDown,\n onFocus,\n ...restProps\n } = useHuiProps(\"TabsTab\", rawProps);\n\n const Component = as ?? \"button\";\n\n const { rootId, selectedValue, onSelect, activation } = useTabsContext();\n const recipe = tabRecipe({});\n const cls = useHuiClassNames(\"TabsTab\", recipe, { root: className });\n const sls = useHuiStyles(\"TabsTab\", { root: style });\n const attrs = tabsControl.getTabAttributes(\n { rootId, selectedValue },\n value,\n { isButtonElement: as === undefined },\n );\n\n const handleClick = useCallback(\n (e: TargetedMouseEvent<HTMLButtonElement>): void => {\n onClick?.(e);\n if (e.defaultPrevented) return;\n onSelect(value);\n },\n [onClick, onSelect, value],\n );\n\n const handleKeyDown = useCallback(\n (e: TargetedKeyboardEvent<HTMLButtonElement>): void => {\n onKeyDown?.(e);\n if (e.defaultPrevented) return;\n\n const action = tabsControl.handleTabKeydown(e);\n switch (action) {\n case \"activate\":\n onSelect(value);\n return;\n case \"focus-move\":\n tabsControl.moveFocus(e, rootId);\n return;\n case \"none\":\n return;\n }\n },\n [onKeyDown, onSelect, rootId, value],\n );\n\n const handleFocus = useCallback((e: TargetedFocusEvent<HTMLButtonElement>) => {\n onFocus?.(e);\n if (e.defaultPrevented) return;\n\n if (activation === \"auto\") {\n onSelect(value);\n }\n }, [onFocus, onSelect, activation, value]);\n\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...attrs}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n onFocus={handleFocus}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n\ninterface TabsPanelOwnProps {\n /**\n * The tab value associated with this panel.\n */\n value: string;\n}\nexport type TabsPanelProps<E extends JSX.ElementType = \"div\"> = HuiPolymorphicProps<\n E,\n TabsPanelOwnProps,\n TabpanelSlots\n>;\n\nfunction Panel<E extends JSX.ElementType = \"div\">(rawProps: TabsPanelProps<E>): VNode {\n const {\n as,\n value,\n className,\n style,\n children,\n ...restProps\n } = useHuiProps(\"TabsPanel\", rawProps);\n\n const Component = as ?? \"div\";\n\n const { rootId, selectedValue } = useTabsContext();\n const recipe = tabpanelRecipe({});\n const cls = useHuiClassNames(\"TabsPanel\", recipe, { root: className });\n const sls = useHuiStyles(\"TabsPanel\", { root: style });\n const attrs = tabsControl.getPanelAttributes({ rootId, selectedValue }, value);\n\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...attrs}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n\nexport const Tabs = Object.assign(TabsRoot, {\n List,\n Tab,\n Panel,\n});\n"],"mappings":"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"}
1
+ {"version":3,"file":"tabs.js","names":[],"sources":["../../../src/components/tabs/tabs.tsx"],"sourcesContent":["import {\n tablistRecipe,\n type TablistSlots,\n tabpanelRecipe,\n type TabpanelSlots,\n tabRecipe,\n tabrootRecipe,\n type TabrootSlots,\n tabsControl,\n type TabSlots,\n} from \"@hebium-ui/core\";\nimport {\n type JSX,\n type TargetedFocusEvent,\n type TargetedKeyboardEvent,\n type TargetedMouseEvent,\n type VNode,\n} from \"preact\";\nimport { useCallback, useId, useMemo, useState } from \"preact/hooks\";\nimport { useHuiClasses, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\nimport { unwrapSignalish } from \"~/utils\";\nimport { type ActivationMode, TabsContext, type TabsContextValue, useTabsContext } from \"./tabs.context\";\n\ninterface TabsOwnProps<V extends string> {\n /**\n * The list of allowed tab values.\n */\n values: readonly V[];\n /**\n * The currently selected tab value.\n */\n value?: V | undefined;\n /**\n * The initially selected tab value for uncontrolled tabs.\n */\n defaultValue?: V | undefined;\n /**\n * Called when the selected tab value changes.\n */\n onChange?: ((value: V) => void) | undefined;\n /**\n * The activation mode used when focus moves between tabs.\n *\n * @default \"manual\"\n * @see {@link https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_selection_follows_focus | WAI-ARIA APG: Deciding When to Make Selection Automatically Follow Focus}\n */\n activation?: ActivationMode;\n}\nexport type TabsProps<V extends string, E extends JSX.ElementType = \"div\"> = HuiPolymorphicProps<\n E,\n TabsOwnProps<V>,\n TabrootSlots\n>;\n\nfunction TabsRoot<V extends string, E extends JSX.ElementType = \"div\">(\n rawProps: TabsProps<V, E>,\n): VNode {\n const {\n as,\n id,\n values,\n value,\n defaultValue,\n onChange,\n children,\n activation = \"manual\",\n ...restProps\n } = useHuiProps(\"Tabs\", rawProps);\n\n const Component = as ?? \"div\";\n\n const tmpId = useId();\n const rootId = unwrapSignalish(id) || tmpId;\n const [uncontrolledValue, setUncontrolledValue] = useState<V | undefined>(\n () => value ?? defaultValue ?? values[0],\n );\n const selectedValue = value ?? uncontrolledValue;\n const recipe = tabrootRecipe({});\n const cls = useHuiClasses(\"Tabs\", recipe, rawProps);\n const sls = useHuiStyles(\"Tabs\", rawProps);\n\n const onSelect = useCallback(\n (nextValue: string) => {\n if (!(values as readonly string[]).includes(nextValue)) {\n throw new Error(`[Hebium UI] Unexpected Tab value: ${nextValue}`);\n }\n\n const v = nextValue as V;\n setUncontrolledValue(v);\n onChange?.(v);\n },\n [onChange, values],\n );\n\n const contextValue = useMemo<TabsContextValue>(\n () => ({\n rootId,\n selectedValue,\n onSelect,\n activation,\n }),\n [\n rootId,\n selectedValue,\n onSelect,\n activation,\n ],\n );\n const attrs = tabsControl.getRootAttributes({ rootId, selectedValue });\n\n return (\n <TabsContext.Provider value={contextValue}>\n <Component\n className={cls.root}\n style={sls.root}\n {...attrs}\n {...restProps}\n >\n {children}\n </Component>\n </TabsContext.Provider>\n );\n}\n\ninterface TabsListOwnProps {}\nexport type TabsListProps<E extends JSX.ElementType = \"div\"> = HuiPolymorphicProps<\n E,\n TabsListOwnProps,\n TablistSlots\n>;\n\nfunction List<E extends JSX.ElementType = \"div\">(rawProps: TabsListProps<E>): VNode {\n const {\n as,\n children,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n ...restProps\n } = useHuiProps(\"TabsList\", rawProps);\n\n const Component = as ?? \"div\";\n\n const recipe = tablistRecipe({});\n const cls = useHuiClasses(\"TabsList\", recipe, rawProps);\n const sls = useHuiStyles(\"TabsList\", rawProps);\n const { rootId, selectedValue } = useTabsContext();\n const attrs = tabsControl.getListAttributes(\n { rootId, selectedValue },\n { ariaLabel: unwrapSignalish(ariaLabel), ariaLabelledBy: unwrapSignalish(ariaLabelledBy) },\n );\n\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...attrs}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n\ninterface TabsTabOwnProps {\n /**\n * The value represented by this tab.\n */\n value: string;\n}\nexport type TabsTabProps<E extends JSX.ElementType = \"button\"> = HuiPolymorphicProps<\n E,\n TabsTabOwnProps,\n TabSlots\n>;\n\nfunction Tab<E extends JSX.ElementType = \"button\">(rawProps: TabsTabProps<E>): VNode {\n const {\n as,\n value,\n children,\n onClick,\n onKeyDown,\n onFocus,\n ...restProps\n } = useHuiProps(\"TabsTab\", rawProps);\n\n const Component = as ?? \"button\";\n\n const { rootId, selectedValue, onSelect, activation } = useTabsContext();\n const recipe = tabRecipe({});\n const cls = useHuiClasses(\"TabsTab\", recipe, rawProps);\n const sls = useHuiStyles(\"TabsTab\", rawProps);\n const attrs = tabsControl.getTabAttributes(\n { rootId, selectedValue },\n value,\n { isButtonElement: as === undefined },\n );\n\n const handleClick = useCallback(\n (e: TargetedMouseEvent<HTMLButtonElement>): void => {\n onClick?.(e);\n if (e.defaultPrevented) return;\n onSelect(value);\n },\n [onClick, onSelect, value],\n );\n\n const handleKeyDown = useCallback(\n (e: TargetedKeyboardEvent<HTMLButtonElement>): void => {\n onKeyDown?.(e);\n if (e.defaultPrevented) return;\n\n const action = tabsControl.handleTabKeydown(e);\n switch (action) {\n case \"activate\":\n onSelect(value);\n return;\n case \"focus-move\":\n tabsControl.moveFocus(e, rootId);\n return;\n case \"none\":\n return;\n }\n },\n [onKeyDown, onSelect, rootId, value],\n );\n\n const handleFocus = useCallback((e: TargetedFocusEvent<HTMLButtonElement>) => {\n onFocus?.(e);\n if (e.defaultPrevented) return;\n\n if (activation === \"auto\") {\n onSelect(value);\n }\n }, [onFocus, onSelect, activation, value]);\n\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...attrs}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n onFocus={handleFocus}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n\ninterface TabsPanelOwnProps {\n /**\n * The tab value associated with this panel.\n */\n value: string;\n}\nexport type TabsPanelProps<E extends JSX.ElementType = \"div\"> = HuiPolymorphicProps<\n E,\n TabsPanelOwnProps,\n TabpanelSlots\n>;\n\nfunction Panel<E extends JSX.ElementType = \"div\">(rawProps: TabsPanelProps<E>): VNode {\n const {\n as,\n value,\n children,\n ...restProps\n } = useHuiProps(\"TabsPanel\", rawProps);\n\n const Component = as ?? \"div\";\n\n const { rootId, selectedValue } = useTabsContext();\n const recipe = tabpanelRecipe({});\n const cls = useHuiClasses(\"TabsPanel\", recipe, rawProps);\n const sls = useHuiStyles(\"TabsPanel\", rawProps);\n const attrs = tabsControl.getPanelAttributes({ rootId, selectedValue }, value);\n\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...attrs}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n\nexport const Tabs = Object.assign(TabsRoot, {\n List,\n Tab,\n Panel,\n});\n"],"mappings":"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"}
package/dist/index.d.ts CHANGED
@@ -3,10 +3,18 @@ import { Anchor, AnchorProps } from "./components/anchor/anchor.js";
3
3
  import { Avatar, AvatarProps } from "./components/avatar/avatar.js";
4
4
  import { Blockquote, BlockquoteProps } from "./components/blockquote/blockquote.js";
5
5
  import { Button, ButtonProps } from "./components/button/button.js";
6
+ import { Checkbox, CheckboxProps } from "./components/checkbox/checkbox.js";
7
+ import { Code, CodeProps } from "./components/code/code.js";
8
+ import { Details, DetailsProps } from "./components/details/details.js";
9
+ import { Heading, HeadingProps } from "./components/heading/heading.js";
10
+ import { Dialog, DialogCloseProps, DialogContentProps, DialogProps, DialogTriggerProps } from "./components/dialog/dialog.js";
11
+ import { DdProps, Dl, DlProps, DtProps } from "./components/dl/dl.js";
12
+ import { Drawer, DrawerCloseProps, DrawerContentProps, DrawerProps, DrawerTriggerProps } from "./components/drawer/drawer.js";
6
13
  import { Progress, ProgressProps } from "./components/progress/progress.js";
14
+ import { StatusIcon, StatusIconProps } from "./components/status-icon/status-icon.js";
7
15
  import { Tabs, TabsListProps, TabsPanelProps, TabsProps, TabsTabProps } from "./components/tabs/tabs.js";
8
16
  import "./components/index.js";
9
- import { HuiComponentPropsMap, HuiProviderContext, HuiProviderContextValue, useHuiClassNames, useHuiProps, useHuiProviderContext, useHuiStyles } from "./provider/hui-provider.context.js";
17
+ import { HuiComponentPropsMap, HuiProviderContext, HuiProviderContextValue, useHuiClasses, useHuiProps, useHuiProviderContext, useHuiStyles } from "./provider/hui-provider.context.js";
10
18
  import { HuiProvider } from "./provider/hui-provider.js";
11
19
  import "./provider/index.js";
12
- export { Alert, AlertProps, Anchor, AnchorProps, Avatar, AvatarProps, Blockquote, BlockquoteProps, Button, ButtonProps, HuiComponentPropsMap, HuiProvider, HuiProviderContext, HuiProviderContextValue, Progress, ProgressProps, Tabs, TabsListProps, TabsPanelProps, TabsProps, TabsTabProps, useHuiClassNames, useHuiProps, useHuiProviderContext, useHuiStyles };
20
+ export { Alert, AlertProps, Anchor, AnchorProps, Avatar, AvatarProps, Blockquote, BlockquoteProps, Button, ButtonProps, Checkbox, CheckboxProps, Code, CodeProps, DdProps, Details, DetailsProps, Dialog, DialogCloseProps, DialogContentProps, DialogProps, DialogTriggerProps, Dl, DlProps, Drawer, DrawerCloseProps, DrawerContentProps, DrawerProps, DrawerTriggerProps, DtProps, Heading, HeadingProps, HuiComponentPropsMap, HuiProvider, HuiProviderContext, HuiProviderContextValue, Progress, ProgressProps, StatusIcon, StatusIconProps, Tabs, TabsListProps, TabsPanelProps, TabsProps, TabsTabProps, useHuiClasses, useHuiProps, useHuiProviderContext, useHuiStyles };
package/dist/index.js CHANGED
@@ -1,10 +1,18 @@
1
- import { HuiProviderContext, useHuiClassNames, useHuiProps, useHuiProviderContext, useHuiStyles } from "./provider/hui-provider.context.js";
1
+ import { HuiProviderContext, useHuiClasses, useHuiProps, useHuiProviderContext, useHuiStyles } from "./provider/hui-provider.context.js";
2
2
  import { HuiProvider } from "./provider/hui-provider.js";
3
+ import { StatusIcon } from "./components/status-icon/status-icon.js";
3
4
  import { Alert } from "./components/alert/alert.js";
4
5
  import { Anchor } from "./components/anchor/anchor.js";
5
6
  import { Avatar } from "./components/avatar/avatar.js";
6
7
  import { Blockquote } from "./components/blockquote/blockquote.js";
7
8
  import { Button } from "./components/button/button.js";
9
+ import { Checkbox } from "./components/checkbox/checkbox.js";
10
+ import { Code } from "./components/code/code.js";
11
+ import { Details } from "./components/details/details.js";
12
+ import { Heading } from "./components/heading/heading.js";
13
+ import { Dialog } from "./components/dialog/dialog.js";
14
+ import { Dl } from "./components/dl/dl.js";
15
+ import { Drawer } from "./components/drawer/drawer.js";
8
16
  import { Progress } from "./components/progress/progress.js";
9
17
  import { Tabs } from "./components/tabs/tabs.js";
10
- export { Alert, Anchor, Avatar, Blockquote, Button, HuiProvider, HuiProviderContext, Progress, Tabs, useHuiClassNames, useHuiProps, useHuiProviderContext, useHuiStyles };
18
+ export { Alert, Anchor, Avatar, Blockquote, Button, Checkbox, Code, Details, Dialog, Dl, Drawer, Heading, HuiProvider, HuiProviderContext, Progress, StatusIcon, Tabs, useHuiClasses, useHuiProps, useHuiProviderContext, useHuiStyles };
@@ -1,20 +1,45 @@
1
+ import { HuiStyleProps } from "../types/hui-component.js";
2
+ import "../components/index.js";
1
3
  import { AlertProps } from "../components/alert/alert.js";
2
4
  import { AnchorProps } from "../components/anchor/anchor.js";
3
5
  import { AvatarProps } from "../components/avatar/avatar.js";
4
6
  import { BlockquoteProps } from "../components/blockquote/blockquote.js";
5
7
  import { ButtonProps } from "../components/button/button.js";
8
+ import { CheckboxProps } from "../components/checkbox/checkbox.js";
9
+ import { CodeProps } from "../components/code/code.js";
10
+ import { DetailsProps } from "../components/details/details.js";
11
+ import { HeadingProps } from "../components/heading/heading.js";
12
+ import { DialogCloseProps, DialogContentProps, DialogProps, DialogTriggerProps } from "../components/dialog/dialog.js";
13
+ import { DdProps, DlProps, DtProps } from "../components/dl/dl.js";
14
+ import { DrawerCloseProps, DrawerContentProps, DrawerProps, DrawerTriggerProps } from "../components/drawer/drawer.js";
6
15
  import { ProgressProps } from "../components/progress/progress.js";
16
+ import { StatusIconProps } from "../components/status-icon/status-icon.js";
7
17
  import { TabsListProps, TabsPanelProps, TabsProps, TabsTabProps } from "../components/tabs/tabs.js";
8
- import "../components/index.js";
9
- import { CSSProperties } from "preact";
10
- //#region src/provider/hui-provider.context.d.ts
18
+ import "../types/index.js";
19
+ import { CSSProperties, JSX } from "preact";
11
20
  export interface HuiComponentPropsMap {
12
21
  Alert: Partial<AlertProps>;
13
22
  Anchor: Partial<AnchorProps>;
14
23
  Avatar: Partial<AvatarProps>;
15
24
  Blockquote: Partial<BlockquoteProps>;
16
25
  Button: Partial<ButtonProps>;
26
+ Checkbox: Partial<CheckboxProps>;
27
+ Code: Partial<CodeProps>;
28
+ Details: Partial<DetailsProps>;
29
+ Dialog: Partial<DialogProps>;
30
+ DialogTrigger: Partial<DialogTriggerProps>;
31
+ DialogContent: Partial<DialogContentProps>;
32
+ DialogClose: Partial<DialogCloseProps>;
33
+ Dl: Partial<DlProps>;
34
+ DlDt: Partial<DtProps>;
35
+ DlDd: Partial<DdProps>;
36
+ Drawer: Partial<DrawerProps>;
37
+ DrawerTrigger: Partial<DrawerTriggerProps>;
38
+ DrawerContent: Partial<DrawerContentProps>;
39
+ DrawerClose: Partial<DrawerCloseProps>;
40
+ Heading: Partial<HeadingProps>;
17
41
  Progress: Partial<ProgressProps>;
42
+ StatusIcon: Partial<StatusIconProps>;
18
43
  Tabs: Partial<TabsProps<string>>;
19
44
  TabsList: Partial<TabsListProps>;
20
45
  TabsTab: Partial<TabsTabProps>;
@@ -22,14 +47,22 @@ export interface HuiComponentPropsMap {
22
47
  }
23
48
  type HuiComponentName = keyof HuiComponentPropsMap;
24
49
  type HuiDefaultProps = Partial<HuiComponentPropsMap>;
50
+ type HuiComponentSlots<K extends HuiComponentName> = { [P in HuiComponentName]: HuiComponentPropsMap[P] extends {
51
+ classes?: infer C;
52
+ } ? Extract<keyof NonNullable<C>, string> : never; }[K];
53
+ type HuiStyledComponentName = { [K in HuiComponentName]: [HuiComponentSlots<K>] extends [never] ? never : K; }[HuiComponentName];
25
54
  export interface HuiProviderContextValue {
26
55
  defaultProps: HuiDefaultProps;
27
56
  }
28
57
  export declare const HuiProviderContext: import("preact").Context<HuiProviderContextValue | null>;
29
58
  export declare function useHuiProviderContext(): HuiProviderContextValue;
30
- export declare function useHuiProps<K extends HuiComponentName, P extends object>(key: K, rawProps: P): P;
31
- export declare function useHuiClassNames<K extends HuiComponentName, S extends string>(key: K, recipe: Record<S, string>, rawClassNames?: Partial<Record<S, string | undefined>>): Record<S, string>;
32
- export declare function useHuiStyles<K extends HuiComponentName, S extends string>(key: K, rawStyles?: Partial<Record<S, CSSProperties | undefined>>): Partial<Record<S, CSSProperties>>;
33
- //#endregion
34
- export {};
35
- //# sourceMappingURL=hui-provider.context.d.ts.map
59
+ declare const STYLING_PROPS: readonly ["class", "className", "style", "classes", "styles"];
60
+ type HuiProps<P extends object, E extends JSX.ElementType> = Omit<P, typeof STYLING_PROPS[number] | "as"> & Pick<{
61
+ as?: E | undefined;
62
+ }, "as" & keyof P>;
63
+ export declare function useHuiProps<K extends HuiComponentName, P extends object, E extends JSX.ElementType = Extract<P["as" & keyof P], JSX.ElementType>>(key: K, rawProps: P & {
64
+ as?: E | undefined;
65
+ }): HuiProps<P, E>;
66
+ export declare function useHuiClasses<K extends HuiStyledComponentName>(key: K, recipe: Record<HuiComponentSlots<NoInfer<K>>, string>, rawProps?: Pick<HuiStyleProps<HuiComponentSlots<NoInfer<K>>>, "class" | "className" | "classes">): Record<HuiComponentSlots<K>, string>;
67
+ export declare function useHuiStyles<K extends HuiStyledComponentName>(key: K, rawProps?: Pick<HuiStyleProps<HuiComponentSlots<NoInfer<K>>>, "style" | "styles">): Partial<Record<HuiComponentSlots<K>, CSSProperties>>;
68
+ export {};
@@ -1,8 +1,9 @@
1
+ import { unwrapSignalish } from "../utils/unwrap-signalish.js";
1
2
  import { mergeProps } from "./merge-props.js";
2
- import { ccAll, msAll } from "@hebium-ui/core";
3
+ import { cc, ccAll, msAll } from "@hebium-ui/core";
3
4
  import { useContext, useMemo } from "preact/hooks";
4
5
  import { createContext } from "preact";
5
- //#region src/provider/hui-provider.context.ts
6
+ // src/provider/hui-provider.context.ts
6
7
  const HuiProviderContext = createContext(null);
7
8
  function useHuiProviderContext() {
8
9
  return useContext(HuiProviderContext) ?? { defaultProps: {} };
@@ -10,28 +11,40 @@ function useHuiProviderContext() {
10
11
  function useHuiDefaultProps(key) {
11
12
  return useHuiProviderContext().defaultProps[key];
12
13
  }
14
+ function useHuiStyleDefaultProps(key) {
15
+ return useHuiDefaultProps(key);
16
+ }
17
+ const STYLING_PROPS = [
18
+ "class",
19
+ "className",
20
+ "style",
21
+ "classes",
22
+ "styles"
23
+ ];
13
24
  function useHuiProps(key, rawProps) {
14
25
  const defaultProps = useHuiDefaultProps(key);
15
26
  return useMemo(() => {
16
- if (typeof defaultProps === "undefined") return rawProps;
17
- return mergeProps(defaultProps, rawProps);
27
+ const props = mergeProps(defaultProps ?? {}, rawProps);
28
+ for (const prop of STYLING_PROPS) delete props[prop];
29
+ return props;
18
30
  }, [defaultProps, rawProps]);
19
31
  }
20
- function useHuiClassNames(key, recipe, rawClassNames = {}) {
21
- const defaultProps = useHuiDefaultProps(key);
22
- if (!defaultProps) return ccAll(recipe, rawClassNames);
23
- if ("classNames" in defaultProps && defaultProps.classNames) return ccAll(recipe, defaultProps.classNames, rawClassNames);
24
- else if ("className" in defaultProps && defaultProps.className) return ccAll(recipe, { root: defaultProps.className }, rawClassNames);
25
- else return ccAll(recipe, rawClassNames);
32
+ function resolveSlotValues(values = {}) {
33
+ const resolved = {};
34
+ for (const slot in values) resolved[slot] = unwrapSignalish(values[slot]);
35
+ return resolved;
26
36
  }
27
- function useHuiStyles(key, rawStyles = {}) {
28
- const defaultProps = useHuiDefaultProps(key);
29
- if (!defaultProps) return rawStyles ?? {};
30
- if ("styles" in defaultProps && defaultProps.styles) return msAll(defaultProps.styles, rawStyles);
31
- else if ("style" in defaultProps && defaultProps.style) return msAll({ root: defaultProps.style }, rawStyles);
32
- else return rawStyles ?? {};
37
+ function useHuiClasses(key, recipe, rawProps = {}) {
38
+ const defaultProps = useHuiStyleDefaultProps(key);
39
+ return ccAll(recipe, { root: cc(unwrapSignalish(defaultProps?.class), unwrapSignalish(defaultProps?.className)) }, resolveSlotValues(defaultProps?.classes), { root: cc(unwrapSignalish(rawProps.class), unwrapSignalish(rawProps.className)) }, resolveSlotValues(rawProps.classes));
40
+ }
41
+ function resolveStyles(props = {}) {
42
+ return msAll({ root: unwrapSignalish(props.style) }, resolveSlotValues(props.styles));
43
+ }
44
+ function useHuiStyles(key, rawProps = {}) {
45
+ const defaultProps = useHuiStyleDefaultProps(key);
46
+ return msAll(resolveStyles(defaultProps), resolveStyles(rawProps));
33
47
  }
34
- //#endregion
35
- export { HuiProviderContext, useHuiClassNames, useHuiProps, useHuiProviderContext, useHuiStyles };
48
+ export { HuiProviderContext, useHuiClasses, useHuiProps, useHuiProviderContext, useHuiStyles };
36
49
 
37
50
  //# sourceMappingURL=hui-provider.context.js.map