@hebium-ui/preact 0.1.0-alpha.2 → 0.1.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/components/alert/alert.d.ts +0 -2
  2. package/dist/components/alert/alert.js +5 -6
  3. package/dist/components/alert/alert.js.map +1 -1
  4. package/dist/components/anchor/anchor.d.ts +0 -2
  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 +6 -4
  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 +1 -3
  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 +0 -2
  14. package/dist/components/button/button.js +5 -6
  15. package/dist/components/button/button.js.map +1 -1
  16. package/dist/components/checkbox/checkbox.d.ts +32 -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 +9 -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 +20 -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.d.ts +2 -0
  29. package/dist/components/dialog/dialog.context.js +15 -0
  30. package/dist/components/dialog/dialog.context.js.map +1 -0
  31. package/dist/components/dialog/dialog.d.ts +65 -0
  32. package/dist/components/dialog/dialog.js +131 -0
  33. package/dist/components/dialog/dialog.js.map +1 -0
  34. package/dist/components/dialog/index.d.ts +3 -0
  35. package/dist/components/dl/dl.d.ts +16 -0
  36. package/dist/components/dl/dl.js +47 -0
  37. package/dist/components/dl/dl.js.map +1 -0
  38. package/dist/components/dl/index.d.ts +2 -0
  39. package/dist/components/drawer/drawer.context.d.ts +2 -0
  40. package/dist/components/drawer/drawer.context.js +15 -0
  41. package/dist/components/drawer/drawer.context.js.map +1 -0
  42. package/dist/components/drawer/drawer.d.ts +65 -0
  43. package/dist/components/drawer/drawer.js +111 -0
  44. package/dist/components/drawer/drawer.js.map +1 -0
  45. package/dist/components/drawer/index.d.ts +3 -0
  46. package/dist/components/heading/heading.d.ts +22 -0
  47. package/dist/components/heading/heading.js +23 -0
  48. package/dist/components/heading/heading.js.map +1 -0
  49. package/dist/components/heading/index.d.ts +2 -0
  50. package/dist/components/index.d.ts +17 -1
  51. package/dist/components/progress/progress.d.ts +0 -2
  52. package/dist/components/progress/progress.js +5 -6
  53. package/dist/components/progress/progress.js.map +1 -1
  54. package/dist/components/tabs/tabs.context.d.ts +0 -2
  55. package/dist/components/tabs/tabs.context.js +1 -2
  56. package/dist/components/tabs/tabs.d.ts +1 -3
  57. package/dist/components/tabs/tabs.js +18 -18
  58. package/dist/components/tabs/tabs.js.map +1 -1
  59. package/dist/index.d.ts +11 -2
  60. package/dist/index.js +11 -2
  61. package/dist/provider/hui-provider.context.d.ts +35 -6
  62. package/dist/provider/hui-provider.context.js +25 -16
  63. package/dist/provider/hui-provider.context.js.map +1 -1
  64. package/dist/provider/hui-provider.d.ts +0 -2
  65. package/dist/provider/hui-provider.js +1 -2
  66. package/dist/provider/index.d.ts +2 -2
  67. package/dist/provider/merge-props.js +1 -2
  68. package/dist/types/hui-component.d.ts +13 -7
  69. package/dist/types/index.d.ts +2 -2
  70. package/dist/types/polymorphic.d.ts +4 -10
  71. package/dist/utils/unwrap-signalish.js +10 -0
  72. package/dist/utils/unwrap-signalish.js.map +1 -0
  73. package/package.json +6 -5
@@ -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.styles);
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.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,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,SAAS,MAAM;CACpD,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,4 +1,2 @@
1
- //#region src/components/tabs/tabs.context.d.ts
2
1
  export type ActivationMode = "manual" | "auto";
3
- //#endregion
4
2
  //# sourceMappingURL=tabs.context.d.ts.map
@@ -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,5 @@ export declare const Tabs: typeof TabsRoot & {
55
54
  Tab: typeof Tab;
56
55
  Panel: typeof Panel;
57
56
  };
58
- //#endregion
59
57
  export {};
60
58
  //# sourceMappingURL=tabs.d.ts.map
@@ -1,19 +1,20 @@
1
- import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
1
+ import { unwrapSignalish } from "../../utils/unwrap-signalish.js";
2
+ import { useHuiClasses, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.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", { root: rawProps.style });
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", { root: rawProps.style });
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", { root: rawProps.style });
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", { root: rawProps.style });
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":";;;;;;AAsDA,SAAS,SACP,UACO;CACP,MAAM,EACJ,IACA,IACA,QACA,OACA,cACA,UACA,WACA,OACA,UACA,aAAa,UACb,GAAG,cACD,YAAY,QAAQ,QAAQ;CAEhC,MAAM,YAAY,MAAM;CAExB,MAAM,QAAQ,MAAM;CACpB,MAAM,SAAS,MAAM;CACrB,MAAM,CAAC,mBAAmB,wBAAwB,eAC1C,SAAS,gBAAgB,OAAO,EACxC;CACA,MAAM,gBAAgB,SAAS;CAC/B,MAAM,SAAS,cAAc,CAAC,CAAC;CAC/B,MAAM,MAAM,iBAAiB,QAAQ,QAAQ,EAAE,MAAM,UAAU,CAAC;CAChE,MAAM,MAAM,aAAa,QAAQ,EAAE,MAAM,MAAM,CAAC;CAEhD,MAAM,WAAW,aACd,cAAsB;EACrB,IAAI,CAAE,OAAoB,SAAS,SAAS,GAC1C,MAAM,IAA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;CAE7E,OACE,oBAAC,WAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EACJ,GAAI;EAEH;CACQ,CAAA;AAEf;AAEA,MAAa,OAAO,OAAO,OAAO,UAAU;CAC1C;CACA;CACA;AACF,CAAC"}
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\", { root: rawProps.style });\n\n const onSelect = useCallback(\n (nextValue: string) => {\n if (!(values as readonly string[]).includes(nextValue)) {\n throw new Error(`[Hebium UI] Unexpected 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\", { root: rawProps.style });\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\", { root: rawProps.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 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\", { root: rawProps.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":";;;;;;;AAuDA,SAAS,SACP,UACO;CACP,MAAM,EACJ,IACA,IACA,QACA,OACA,cACA,UACA,UACA,aAAa,UACb,GAAG,cACD,YAAY,QAAQ,QAAQ;CAEhC,MAAM,YAAY,MAAM;CAExB,MAAM,QAAQ,MAAM;CACpB,MAAM,SAAS,gBAAgB,EAAE,KAAK;CACtC,MAAM,CAAC,mBAAmB,wBAAwB,eAC1C,SAAS,gBAAgB,OAAO,EACxC;CACA,MAAM,gBAAgB,SAAS;CAC/B,MAAM,SAAS,cAAc,CAAC,CAAC;CAC/B,MAAM,MAAM,cAAc,QAAQ,QAAQ,QAAQ;CAClD,MAAM,MAAM,aAAa,QAAQ,EAAE,MAAM,SAAS,MAAM,CAAC;CAEzD,MAAM,WAAW,aACd,cAAsB;EACrB,IAAI,CAAE,OAA6B,SAAS,SAAS,GACnD,MAAM,IAAI,MAAM,qCAAqC,WAAW;EAGlE,MA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IAAI;EACX,GAAI;EACJ,GAAI;EAEH;CACQ,CAAA;AAEf;AAEA,MAAa,OAAO,OAAO,OAAO,UAAU;CAC1C;CACA;CACA;AACF,CAAC"}
package/dist/index.d.ts CHANGED
@@ -3,10 +3,19 @@ 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 { useDialogId } from "./components/dialog/dialog.context.js";
12
+ import { DdProps, Dl, DlProps, DtProps } from "./components/dl/dl.js";
13
+ import { Drawer, DrawerCloseProps, DrawerContentProps, DrawerProps, DrawerTriggerProps } from "./components/drawer/drawer.js";
14
+ import { useDrawerId } from "./components/drawer/drawer.context.js";
6
15
  import { Progress, ProgressProps } from "./components/progress/progress.js";
7
16
  import { Tabs, TabsListProps, TabsPanelProps, TabsProps, TabsTabProps } from "./components/tabs/tabs.js";
8
17
  import "./components/index.js";
9
- import { HuiComponentPropsMap, HuiProviderContext, HuiProviderContextValue, useHuiClassNames, useHuiProps, useHuiProviderContext, useHuiStyles } from "./provider/hui-provider.context.js";
18
+ import { HuiComponentPropsMap, HuiProviderContext, HuiProviderContextValue, useHuiClasses, useHuiProps, useHuiProviderContext, useHuiStyles } from "./provider/hui-provider.context.js";
10
19
  import { HuiProvider } from "./provider/hui-provider.js";
11
20
  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 };
21
+ 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, Tabs, TabsListProps, TabsPanelProps, TabsProps, TabsTabProps, useDialogId, useDrawerId, useHuiClasses, useHuiProps, useHuiProviderContext, useHuiStyles };
package/dist/index.js CHANGED
@@ -1,10 +1,19 @@
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
3
  import { Alert } from "./components/alert/alert.js";
4
4
  import { Anchor } from "./components/anchor/anchor.js";
5
5
  import { Avatar } from "./components/avatar/avatar.js";
6
6
  import { Blockquote } from "./components/blockquote/blockquote.js";
7
7
  import { Button } from "./components/button/button.js";
8
+ import { Checkbox } from "./components/checkbox/checkbox.js";
9
+ import { Code } from "./components/code/code.js";
10
+ import { Details } from "./components/details/details.js";
11
+ import { Heading } from "./components/heading/heading.js";
12
+ import { useDialogId } from "./components/dialog/dialog.context.js";
13
+ import { Dialog } from "./components/dialog/dialog.js";
14
+ import { Dl } from "./components/dl/dl.js";
15
+ import { useDrawerId } from "./components/drawer/drawer.context.js";
16
+ import { Drawer } from "./components/drawer/drawer.js";
8
17
  import { Progress } from "./components/progress/progress.js";
9
18
  import { Tabs } from "./components/tabs/tabs.js";
10
- export { Alert, Anchor, Avatar, Blockquote, Button, HuiProvider, HuiProviderContext, Progress, Tabs, useHuiClassNames, useHuiProps, useHuiProviderContext, useHuiStyles };
19
+ export { Alert, Anchor, Avatar, Blockquote, Button, Checkbox, Code, Details, Dialog, Dl, Drawer, Heading, HuiProvider, HuiProviderContext, Progress, Tabs, useDialogId, useDrawerId, useHuiClasses, useHuiProps, useHuiProviderContext, useHuiStyles };
@@ -1,19 +1,42 @@
1
+ import { HuiRootStyleProps, HuiSlotStyleProps, HuiStyles } from "../types/hui-component.js";
2
+ import "../types/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";
7
16
  import { TabsListProps, TabsPanelProps, TabsProps, TabsTabProps } from "../components/tabs/tabs.js";
8
17
  import "../components/index.js";
9
- import { CSSProperties } from "preact";
10
- //#region src/provider/hui-provider.context.d.ts
18
+ import { CSSProperties, JSX } from "preact";
11
19
  export interface HuiComponentPropsMap {
12
20
  Alert: Partial<AlertProps>;
13
21
  Anchor: Partial<AnchorProps>;
14
22
  Avatar: Partial<AvatarProps>;
15
23
  Blockquote: Partial<BlockquoteProps>;
16
24
  Button: Partial<ButtonProps>;
25
+ Checkbox: Partial<CheckboxProps>;
26
+ Code: Partial<CodeProps>;
27
+ Details: Partial<DetailsProps>;
28
+ Dialog: Partial<DialogProps>;
29
+ DialogTrigger: Partial<DialogTriggerProps>;
30
+ DialogContent: Partial<DialogContentProps>;
31
+ DialogClose: Partial<DialogCloseProps>;
32
+ Dl: Partial<DlProps>;
33
+ DlDt: Partial<DtProps>;
34
+ DlDd: Partial<DdProps>;
35
+ Drawer: Partial<DrawerProps>;
36
+ DrawerTrigger: Partial<DrawerTriggerProps>;
37
+ DrawerContent: Partial<DrawerContentProps>;
38
+ DrawerClose: Partial<DrawerCloseProps>;
39
+ Heading: Partial<HeadingProps>;
17
40
  Progress: Partial<ProgressProps>;
18
41
  Tabs: Partial<TabsProps<string>>;
19
42
  TabsList: Partial<TabsListProps>;
@@ -27,9 +50,15 @@ export interface HuiProviderContextValue {
27
50
  }
28
51
  export declare const HuiProviderContext: import("preact").Context<HuiProviderContextValue | null>;
29
52
  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
53
+ declare const STYLING_PROPS: readonly ["class", "className", "style", "classes", "styles"];
54
+ type HuiProps<P extends object, E extends JSX.ElementType> = Omit<P, typeof STYLING_PROPS[number] | "as"> & Pick<{
55
+ as?: E | undefined;
56
+ }, "as" & keyof P>;
57
+ 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 & {
58
+ as?: E | undefined;
59
+ }): HuiProps<P, E>;
60
+ type HuiClassesProps<S extends string> = Pick<HuiRootStyleProps, "class" | "className"> & Pick<HuiSlotStyleProps<S>, "classes">;
61
+ export declare function useHuiClasses<K extends HuiComponentName, S extends string>(key: K, recipe: Record<S, string>, rawProps?: HuiClassesProps<S>): Record<S, string>;
62
+ export declare function useHuiStyles<K extends HuiComponentName, S extends string>(key: K, rawStyles?: HuiStyles<S>): Partial<Record<S, CSSProperties>>;
34
63
  export {};
35
64
  //# sourceMappingURL=hui-provider.context.d.ts.map
@@ -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,36 @@ function useHuiProviderContext() {
10
11
  function useHuiDefaultProps(key) {
11
12
  return useHuiProviderContext().defaultProps[key];
12
13
  }
14
+ const STYLING_PROPS = [
15
+ "class",
16
+ "className",
17
+ "style",
18
+ "classes",
19
+ "styles"
20
+ ];
13
21
  function useHuiProps(key, rawProps) {
14
22
  const defaultProps = useHuiDefaultProps(key);
15
23
  return useMemo(() => {
16
- if (typeof defaultProps === "undefined") return rawProps;
17
- return mergeProps(defaultProps, rawProps);
24
+ const props = mergeProps(defaultProps ?? {}, rawProps);
25
+ for (const prop of STYLING_PROPS) delete props[prop];
26
+ return props;
18
27
  }, [defaultProps, rawProps]);
19
28
  }
20
- function useHuiClassNames(key, recipe, rawClassNames = {}) {
29
+ function resolveSlotValues(values = {}) {
30
+ const resolved = {};
31
+ for (const slot in values) resolved[slot] = unwrapSignalish(values[slot]);
32
+ return resolved;
33
+ }
34
+ function useHuiClasses(key, recipe, rawProps = {}) {
21
35
  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);
36
+ const rootClass = cc(unwrapSignalish(defaultProps?.class), unwrapSignalish(defaultProps?.className), unwrapSignalish(rawProps.class), unwrapSignalish(rawProps.className));
37
+ return ccAll(recipe, resolveSlotValues(defaultProps?.classes), { root: rootClass }, resolveSlotValues(rawProps.classes));
26
38
  }
27
- function useHuiStyles(key, rawStyles = {}) {
39
+ function useHuiStyles(key, rawStyles) {
28
40
  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 ?? {};
41
+ const defaultStyles = defaultProps?.styles ?? { root: defaultProps?.style };
42
+ return msAll(resolveSlotValues(defaultStyles), resolveSlotValues(rawStyles));
33
43
  }
34
- //#endregion
35
- export { HuiProviderContext, useHuiClassNames, useHuiProps, useHuiProviderContext, useHuiStyles };
44
+ export { HuiProviderContext, useHuiClasses, useHuiProps, useHuiProviderContext, useHuiStyles };
36
45
 
37
46
  //# sourceMappingURL=hui-provider.context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hui-provider.context.js","names":[],"sources":["../../src/provider/hui-provider.context.ts"],"sourcesContent":["import { ccAll, msAll } from \"@hebium-ui/core\";\nimport { createContext, type CSSProperties } from \"preact\";\nimport { useContext, useMemo } from \"preact/hooks\";\nimport type {\n AlertProps,\n AnchorProps,\n AvatarProps,\n BlockquoteProps,\n ButtonProps,\n ProgressProps,\n TabsListProps,\n TabsPanelProps,\n TabsProps,\n TabsTabProps,\n} from \"~/components\";\nimport { mergeProps } from \"./merge-props\";\n\nexport interface HuiComponentPropsMap {\n Alert: Partial<AlertProps>;\n Anchor: Partial<AnchorProps>;\n Avatar: Partial<AvatarProps>;\n Blockquote: Partial<BlockquoteProps>;\n Button: Partial<ButtonProps>;\n Progress: Partial<ProgressProps>;\n Tabs: Partial<TabsProps<string>>;\n TabsList: Partial<TabsListProps>;\n TabsTab: Partial<TabsTabProps>;\n TabsPanel: Partial<TabsPanelProps>;\n}\n\ntype HuiComponentName = keyof HuiComponentPropsMap;\ntype HuiDefaultProps = Partial<HuiComponentPropsMap>;\n\nexport interface HuiProviderContextValue {\n defaultProps: HuiDefaultProps;\n}\n\nexport const HuiProviderContext = createContext<HuiProviderContextValue | null>(null);\n\nexport function useHuiProviderContext(): HuiProviderContextValue {\n const context = useContext(HuiProviderContext);\n return context ?? { defaultProps: {} };\n}\n\nfunction useHuiDefaultProps<K extends HuiComponentName>(key: K): HuiDefaultProps[K] {\n const ctx = useHuiProviderContext();\n return ctx.defaultProps[key];\n}\n\nexport function useHuiProps<K extends HuiComponentName, P extends object>(\n key: K,\n rawProps: P,\n): P {\n const defaultProps = useHuiDefaultProps(key);\n const props = useMemo(() => {\n if (typeof defaultProps === \"undefined\") {\n return rawProps;\n }\n\n return mergeProps(defaultProps as Partial<P>, rawProps);\n }, [defaultProps, rawProps]);\n return props as P;\n}\n\nexport function useHuiClassNames<K extends HuiComponentName, S extends string>(\n key: K,\n recipe: Record<S, string>,\n rawClassNames: Partial<Record<S, string | undefined>> = {},\n): Record<S, string> {\n const defaultProps = useHuiDefaultProps(key);\n if (!defaultProps) return ccAll(recipe, rawClassNames);\n\n if (\"classNames\" in defaultProps && defaultProps.classNames) {\n return ccAll(recipe, defaultProps.classNames as Record<S, string>, rawClassNames);\n } else if (\"className\" in defaultProps && defaultProps.className) {\n return ccAll(recipe, { root: defaultProps.className } as Record<S, string>, rawClassNames);\n } else {\n return ccAll(recipe, rawClassNames);\n }\n}\n\nexport function useHuiStyles<K extends HuiComponentName, S extends string>(\n key: K,\n rawStyles: Partial<Record<S, CSSProperties | undefined>> = {},\n): Partial<Record<S, CSSProperties>> {\n const defaultProps = useHuiDefaultProps(key);\n if (!defaultProps) return rawStyles ?? {};\n\n if (\"styles\" in defaultProps && defaultProps.styles) {\n return msAll(defaultProps.styles as Partial<Record<S, CSSProperties>>, rawStyles);\n } else if (\"style\" in defaultProps && defaultProps.style) {\n return msAll({ root: defaultProps.style } as Partial<Record<S, CSSProperties>>, rawStyles);\n } else {\n return rawStyles ?? {};\n }\n}\n"],"mappings":";;;;;AAqCA,MAAa,qBAAqB,cAA8C,IAAI;AAEpF,SAAgB,wBAAiD;CAE/D,OADgB,WAAW,kBACd,KAAK,EAAE,cAAc,CAAC,EAAE;AACvC;AAEA,SAAS,mBAA+C,KAA4B;CAElF,OADY,sBACH,CAAC,CAAC,aAAa;AAC1B;AAEA,SAAgB,YACd,KACA,UACG;CACH,MAAM,eAAe,mBAAmB,GAAG;CAQ3C,OAPc,cAAc;EAC1B,IAAI,OAAO,iBAAiB,aAC1B,OAAO;EAGT,OAAO,WAAW,cAA4B,QAAQ;CACxD,GAAG,CAAC,cAAc,QAAQ,CACf;AACb;AAEA,SAAgB,iBACd,KACA,QACA,gBAAwD,CAAC,GACtC;CACnB,MAAM,eAAe,mBAAmB,GAAG;CAC3C,IAAI,CAAC,cAAc,OAAO,MAAM,QAAQ,aAAa;CAErD,IAAI,gBAAgB,gBAAgB,aAAa,YAC/C,OAAO,MAAM,QAAQ,aAAa,YAAiC,aAAa;MAC3E,IAAI,eAAe,gBAAgB,aAAa,WACrD,OAAO,MAAM,QAAQ,EAAE,MAAM,aAAa,UAAU,GAAwB,aAAa;MAEzF,OAAO,MAAM,QAAQ,aAAa;AAEtC;AAEA,SAAgB,aACd,KACA,YAA2D,CAAC,GACzB;CACnC,MAAM,eAAe,mBAAmB,GAAG;CAC3C,IAAI,CAAC,cAAc,OAAO,aAAa,CAAC;CAExC,IAAI,YAAY,gBAAgB,aAAa,QAC3C,OAAO,MAAM,aAAa,QAA6C,SAAS;MAC3E,IAAI,WAAW,gBAAgB,aAAa,OACjD,OAAO,MAAM,EAAE,MAAM,aAAa,MAAM,GAAwC,SAAS;MAEzF,OAAO,aAAa,CAAC;AAEzB"}
1
+ {"version":3,"file":"hui-provider.context.js","names":[],"sources":["../../src/provider/hui-provider.context.ts"],"sourcesContent":["import { cc, ccAll, msAll } from \"@hebium-ui/core\";\nimport { createContext, type CSSProperties, type JSX, type Signalish } from \"preact\";\nimport { useContext, useMemo } from \"preact/hooks\";\nimport type {\n AlertProps,\n AnchorProps,\n AvatarProps,\n BlockquoteProps,\n ButtonProps,\n CheckboxProps,\n CodeProps,\n DdProps,\n DetailsProps,\n DialogCloseProps,\n DialogContentProps,\n DialogProps,\n DialogTriggerProps,\n DlProps,\n DrawerCloseProps,\n DrawerContentProps,\n DrawerProps,\n DrawerTriggerProps,\n DtProps,\n HeadingProps,\n ProgressProps,\n TabsListProps,\n TabsPanelProps,\n TabsProps,\n TabsTabProps,\n} from \"~/components\";\nimport type { HuiRootStyleProps, HuiSlotStyleProps, HuiStyles } from \"~/types\";\nimport { unwrapSignalish } from \"~/utils\";\nimport { mergeProps } from \"./merge-props\";\n\nexport interface HuiComponentPropsMap {\n Alert: Partial<AlertProps>;\n Anchor: Partial<AnchorProps>;\n Avatar: Partial<AvatarProps>;\n Blockquote: Partial<BlockquoteProps>;\n Button: Partial<ButtonProps>;\n Checkbox: Partial<CheckboxProps>;\n Code: Partial<CodeProps>;\n Details: Partial<DetailsProps>;\n Dialog: Partial<DialogProps>;\n DialogTrigger: Partial<DialogTriggerProps>;\n DialogContent: Partial<DialogContentProps>;\n DialogClose: Partial<DialogCloseProps>;\n Dl: Partial<DlProps>;\n DlDt: Partial<DtProps>;\n DlDd: Partial<DdProps>;\n Drawer: Partial<DrawerProps>;\n DrawerTrigger: Partial<DrawerTriggerProps>;\n DrawerContent: Partial<DrawerContentProps>;\n DrawerClose: Partial<DrawerCloseProps>;\n Heading: Partial<HeadingProps>;\n Progress: Partial<ProgressProps>;\n Tabs: Partial<TabsProps<string>>;\n TabsList: Partial<TabsListProps>;\n TabsTab: Partial<TabsTabProps>;\n TabsPanel: Partial<TabsPanelProps>;\n}\n\ntype HuiComponentName = keyof HuiComponentPropsMap;\ntype HuiDefaultProps = Partial<HuiComponentPropsMap>;\n\nexport interface HuiProviderContextValue {\n defaultProps: HuiDefaultProps;\n}\n\nexport const HuiProviderContext = createContext<HuiProviderContextValue | null>(null);\n\nexport function useHuiProviderContext(): HuiProviderContextValue {\n const context = useContext(HuiProviderContext);\n return context ?? { defaultProps: {} };\n}\n\nfunction useHuiDefaultProps<K extends HuiComponentName>(key: K): HuiDefaultProps[K] {\n const ctx = useHuiProviderContext();\n return ctx.defaultProps[key];\n}\n\nconst STYLING_PROPS = [\"class\", \"className\", \"style\", \"classes\", \"styles\"] as const;\n\n// Keep `as` explicit so JSX element inference survives omission of generic props.\ntype HuiProps<P extends object, E extends JSX.ElementType> =\n & Omit<P, typeof STYLING_PROPS[number] | \"as\">\n & Pick<{ as?: E | undefined }, \"as\" & keyof P>;\n\nexport function useHuiProps<\n K extends HuiComponentName,\n P extends object,\n E extends JSX.ElementType = Extract<P[\"as\" & keyof P], JSX.ElementType>,\n>(\n key: K,\n rawProps: P & { as?: E | undefined },\n): HuiProps<P, E> {\n const defaultProps = useHuiDefaultProps(key);\n return useMemo(() => {\n const props = mergeProps((defaultProps ?? {}) as Partial<P>, rawProps);\n // Styling helpers resolve Provider and local values separately from rawProps.\n for (const prop of STYLING_PROPS) {\n delete props[prop as keyof P];\n }\n return props as HuiProps<P, E>;\n }, [defaultProps, rawProps]);\n}\n\nfunction resolveSlotValues<S extends string, T>(\n values: Partial<Record<S, Signalish<T>>> = {},\n): Partial<Record<S, T>> {\n const resolved: Partial<Record<S, T>> = {};\n for (const slot in values) {\n resolved[slot] = unwrapSignalish<T | undefined>(values[slot]);\n }\n return resolved;\n}\n\ntype HuiClassesProps<S extends string> =\n & Pick<HuiRootStyleProps, \"class\" | \"className\">\n & Pick<HuiSlotStyleProps<S>, \"classes\">;\n\nexport function useHuiClasses<K extends HuiComponentName, S extends string>(\n key: K,\n recipe: Record<S, string>,\n rawProps: HuiClassesProps<S> = {},\n): Record<S, string> {\n const defaultProps = useHuiDefaultProps(key) as HuiClassesProps<S> | undefined;\n const rootClass = cc(\n unwrapSignalish(defaultProps?.class),\n unwrapSignalish(defaultProps?.className),\n unwrapSignalish(rawProps.class),\n unwrapSignalish(rawProps.className),\n );\n\n return ccAll(\n recipe,\n resolveSlotValues(defaultProps?.classes),\n { root: rootClass } as Record<S, string>,\n resolveSlotValues(rawProps.classes),\n );\n}\n\nexport function useHuiStyles<K extends HuiComponentName, S extends string>(\n key: K,\n rawStyles?: HuiStyles<S>,\n): Partial<Record<S, CSSProperties>> {\n const defaultProps = useHuiDefaultProps(key) as (HuiRootStyleProps & HuiSlotStyleProps<S>) | undefined;\n const defaultStyles = defaultProps?.styles ?? { root: defaultProps?.style } as HuiStyles<S>;\n\n return msAll(resolveSlotValues(defaultStyles), resolveSlotValues(rawStyles));\n}\n"],"mappings":";;;;;;AAqEA,MAAa,qBAAqB,cAA8C,IAAI;AAEpF,SAAgB,wBAAiD;CAE/D,OADgB,WAAW,kBACd,KAAK,EAAE,cAAc,CAAC,EAAE;AACvC;AAEA,SAAS,mBAA+C,KAA4B;CAElF,OADY,sBACH,CAAC,CAAC,aAAa;AAC1B;AAEA,MAAM,gBAAgB;CAAC;CAAS;CAAa;CAAS;CAAW;AAAQ;AAOzE,SAAgB,YAKd,KACA,UACgB;CAChB,MAAM,eAAe,mBAAmB,GAAG;CAC3C,OAAO,cAAc;EACnB,MAAM,QAAQ,WAAY,gBAAgB,CAAC,GAAkB,QAAQ;EAErE,KAAK,MAAM,QAAQ,eACjB,OAAO,MAAM;EAEf,OAAO;CACT,GAAG,CAAC,cAAc,QAAQ,CAAC;AAC7B;AAEA,SAAS,kBACP,SAA2C,CAAC,GACrB;CACvB,MAAM,WAAkC,CAAC;CACzC,KAAK,MAAM,QAAQ,QACjB,SAAS,QAAQ,gBAA+B,OAAO,KAAK;CAE9D,OAAO;AACT;AAMA,SAAgB,cACd,KACA,QACA,WAA+B,CAAC,GACb;CACnB,MAAM,eAAe,mBAAmB,GAAG;CAC3C,MAAM,YAAY,GAChB,gBAAgB,cAAc,KAAK,GACnC,gBAAgB,cAAc,SAAS,GACvC,gBAAgB,SAAS,KAAK,GAC9B,gBAAgB,SAAS,SAAS,CACpC;CAEA,OAAO,MACL,QACA,kBAAkB,cAAc,OAAO,GACvC,EAAE,MAAM,UAAU,GAClB,kBAAkB,SAAS,OAAO,CACpC;AACF;AAEA,SAAgB,aACd,KACA,WACmC;CACnC,MAAM,eAAe,mBAAmB,GAAG;CAC3C,MAAM,gBAAgB,cAAc,UAAU,EAAE,MAAM,cAAc,MAAM;CAE1E,OAAO,MAAM,kBAAkB,aAAa,GAAG,kBAAkB,SAAS,CAAC;AAC7E"}
@@ -1,10 +1,8 @@
1
1
  import { HuiProviderContextValue } from "./hui-provider.context.js";
2
2
  import { ComponentChildren, VNode } from "preact";
3
- //#region src/provider/hui-provider.d.ts
4
3
  interface HuiProviderProps extends Partial<HuiProviderContextValue> {
5
4
  children: ComponentChildren;
6
5
  }
7
6
  export declare function HuiProvider({ defaultProps, children }: HuiProviderProps): VNode;
8
- //#endregion
9
7
  export {};
10
8
  //# sourceMappingURL=hui-provider.d.ts.map
@@ -1,7 +1,7 @@
1
1
  import { HuiProviderContext } from "./hui-provider.context.js";
2
2
  import { useMemo } from "preact/hooks";
3
3
  import { jsx } from "preact/jsx-runtime";
4
- //#region src/provider/hui-provider.tsx
4
+ // src/provider/hui-provider.tsx
5
5
  function HuiProvider({ defaultProps, children }) {
6
6
  const context = useMemo(() => {
7
7
  return { defaultProps: defaultProps ?? {} };
@@ -11,7 +11,6 @@ function HuiProvider({ defaultProps, children }) {
11
11
  children
12
12
  });
13
13
  }
14
- //#endregion
15
14
  export { HuiProvider };
16
15
 
17
16
  //# sourceMappingURL=hui-provider.js.map
@@ -1,3 +1,3 @@
1
- import { HuiComponentPropsMap, HuiProviderContext, HuiProviderContextValue, useHuiClassNames, useHuiProps, useHuiProviderContext, useHuiStyles } from "./hui-provider.context.js";
1
+ import { HuiComponentPropsMap, HuiProviderContext, HuiProviderContextValue, useHuiClasses, useHuiProps, useHuiProviderContext, useHuiStyles } from "./hui-provider.context.js";
2
2
  import { HuiProvider } from "./hui-provider.js";
3
- export { HuiComponentPropsMap, HuiProvider, HuiProviderContext, HuiProviderContextValue, useHuiClassNames, useHuiProps, useHuiProviderContext, useHuiStyles };
3
+ export { HuiComponentPropsMap, HuiProvider, HuiProviderContext, HuiProviderContextValue, useHuiClasses, useHuiProps, useHuiProviderContext, useHuiStyles };
@@ -1,4 +1,4 @@
1
- //#region src/provider/merge-props.ts
1
+ // src/provider/merge-props.ts
2
2
  function mergeProps(defaultProps, rawProps) {
3
3
  const filteredProps = {};
4
4
  for (const key of Object.keys(rawProps)) {
@@ -10,7 +10,6 @@ function mergeProps(defaultProps, rawProps) {
10
10
  ...filteredProps
11
11
  };
12
12
  }
13
- //#endregion
14
13
  export { mergeProps };
15
14
 
16
15
  //# sourceMappingURL=merge-props.js.map
@@ -1,10 +1,16 @@
1
- import { CSSProperties } from "preact";
2
- //#region src/types/hui-component.d.ts
1
+ import { CSSProperties, Signalish } from "preact";
3
2
  type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
4
- export type HuiComponentProps<Props extends object, Slots extends string> = [Slots] extends ["root"] ? Props : DistributiveOmit<Props, "className" | "style"> & {
5
- classNames?: Partial<Record<Slots, string>> | undefined;
6
- styles?: Partial<Record<Slots, CSSProperties>> | undefined;
7
- };
8
- //#endregion
3
+ export interface HuiRootStyleProps {
4
+ class?: Signalish<string | undefined>;
5
+ className?: Signalish<string | undefined>;
6
+ style?: Signalish<CSSProperties | undefined>;
7
+ }
8
+ export type HuiClassNames<Slots extends string> = Partial<Record<Slots, Signalish<string | undefined>>>;
9
+ export type HuiStyles<Slots extends string> = Partial<Record<Slots, Signalish<CSSProperties | undefined>>>;
10
+ export interface HuiSlotStyleProps<Slots extends string> {
11
+ classes?: HuiClassNames<Slots> | undefined;
12
+ styles?: HuiStyles<Slots> | undefined;
13
+ }
14
+ export type HuiComponentProps<Props extends object, Slots extends string> = DistributiveOmit<Props, keyof HuiRootStyleProps> & ([Slots] extends ["root"] ? HuiRootStyleProps : HuiSlotStyleProps<Slots>);
9
15
  export {};
10
16
  //# sourceMappingURL=hui-component.d.ts.map
@@ -1,3 +1,3 @@
1
- import { HuiComponentProps } from "./hui-component.js";
1
+ import { HuiClassNames, HuiComponentProps, HuiRootStyleProps, HuiSlotStyleProps, HuiStyles } from "./hui-component.js";
2
2
  import { HuiPolymorphicProps, PolymorphicComponentProps } from "./polymorphic.js";
3
- export { HuiComponentProps, HuiPolymorphicProps, PolymorphicComponentProps };
3
+ export { HuiClassNames, HuiComponentProps, HuiPolymorphicProps, HuiRootStyleProps, HuiSlotStyleProps, HuiStyles, PolymorphicComponentProps };
@@ -1,13 +1,7 @@
1
- import { CSSProperties, ComponentProps, JSX } from "preact";
2
- //#region src/types/polymorphic.d.ts
1
+ import { HuiComponentProps } from "./hui-component.js";
2
+ import { ComponentProps, JSX } from "preact";
3
3
  export type PolymorphicComponentProps<E extends JSX.ElementType, OwnProps extends object> = OwnProps & {
4
4
  as?: E | undefined;
5
- } & Omit<ComponentProps<E>, keyof OwnProps | "as" | "className" | "style">;
6
- export type HuiPolymorphicProps<E extends JSX.ElementType, OwnProps extends object, Slots extends string> = [Slots] extends ["root"] ? OwnProps & {
7
- as?: E | undefined;
8
- } & Omit<ComponentProps<E>, keyof OwnProps | "as"> : PolymorphicComponentProps<E, OwnProps & {
9
- classNames?: Partial<Record<Slots, string | undefined>> | undefined;
10
- styles?: Partial<Record<Slots, CSSProperties | undefined>> | undefined;
11
- }>;
12
- //#endregion
5
+ } & Omit<ComponentProps<E>, keyof OwnProps | "as" | "class" | "className" | "style">;
6
+ export type HuiPolymorphicProps<E extends JSX.ElementType, OwnProps extends object, Slots extends string> = PolymorphicComponentProps<E, OwnProps> & HuiComponentProps<{}, Slots>;
13
7
  //# sourceMappingURL=polymorphic.d.ts.map
@@ -0,0 +1,10 @@
1
+ // src/utils/unwrap-signalish.ts
2
+ function isSignalLike(value) {
3
+ return typeof value === "object" && value !== null && "value" in value && "peek" in value && typeof value.peek === "function" && "subscribe" in value && typeof value.subscribe === "function";
4
+ }
5
+ function unwrapSignalish(value) {
6
+ return isSignalLike(value) ? value.value : value;
7
+ }
8
+ export { unwrapSignalish };
9
+
10
+ //# sourceMappingURL=unwrap-signalish.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unwrap-signalish.js","names":[],"sources":["../../src/utils/unwrap-signalish.ts"],"sourcesContent":["import { type Signalish, type SignalLike } from \"preact\";\n\nfunction isSignalLike<T>(value: Signalish<T>): value is SignalLike<T> {\n return typeof value === \"object\" && value !== null\n && \"value\" in value\n && \"peek\" in value && typeof value.peek === \"function\"\n && \"subscribe\" in value && typeof value.subscribe === \"function\";\n}\n\nexport function unwrapSignalish<T>(value: Signalish<T>): T {\n return isSignalLike(value) ? value.value : value;\n}\n"],"mappings":";AAEA,SAAS,aAAgB,OAA6C;CACpE,OAAO,OAAO,UAAU,YAAY,UAAU,QACzC,WAAW,SACX,UAAU,SAAS,OAAO,MAAM,SAAS,cACzC,eAAe,SAAS,OAAO,MAAM,cAAc;AAC1D;AAEA,SAAgB,gBAAmB,OAAwB;CACzD,OAAO,aAAa,KAAK,IAAI,MAAM,QAAQ;AAC7C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hebium-ui/preact",
3
- "version": "0.1.0-alpha.2",
3
+ "version": "0.1.0-alpha.3",
4
4
  "description": "Experimental Preact bindings for the Hebium UI core components.",
5
5
  "type": "module",
6
6
  "files": [
@@ -26,19 +26,20 @@
26
26
  "access": "public"
27
27
  },
28
28
  "devDependencies": {
29
+ "@preact/signals": "2.11.4",
29
30
  "@vitest/browser-playwright": "5.0.5",
30
31
  "axe-core": "4.14.0",
31
- "oxlint": "1.88.0",
32
+ "oxlint": "1.90.0",
32
33
  "playwright": "1.64.1",
33
- "preact": "11.0.1",
34
+ "preact": "11.0.2",
34
35
  "tsdown": "0.23.1",
35
36
  "typescript": "6.0.3",
36
- "vite": "8.3.4",
37
+ "vite": "8.3.5",
37
38
  "vitest": "5.0.5",
38
39
  "vitest-browser-preact": "1.1.0"
39
40
  },
40
41
  "peerDependencies": {
41
- "@hebium-ui/core": "0.1.0-alpha.2",
42
+ "@hebium-ui/core": "0.1.0-alpha.3",
42
43
  "preact": "^11.0.0"
43
44
  },
44
45
  "scripts": {