@hebium-ui/preact 0.0.0-stage → 0.1.0-alpha.0

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 (49) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +7 -2
  3. package/dist/components/alert/alert.d.ts +44 -0
  4. package/dist/components/alert/alert.js +45 -0
  5. package/dist/components/alert/alert.js.map +1 -0
  6. package/dist/components/alert/index.d.ts +2 -0
  7. package/dist/components/anchor/anchor.d.ts +30 -0
  8. package/dist/components/anchor/anchor.js +25 -0
  9. package/dist/components/anchor/anchor.js.map +1 -0
  10. package/dist/components/anchor/index.d.ts +2 -0
  11. package/dist/components/avatar/avatar.d.ts +16 -0
  12. package/dist/components/avatar/avatar.js +56 -0
  13. package/dist/components/avatar/avatar.js.map +1 -0
  14. package/dist/components/avatar/index.d.ts +2 -0
  15. package/dist/components/blockquote/blockquote.d.ts +27 -0
  16. package/dist/components/blockquote/blockquote.js +29 -0
  17. package/dist/components/blockquote/blockquote.js.map +1 -0
  18. package/dist/components/blockquote/index.d.ts +2 -0
  19. package/dist/components/button/button.d.ts +30 -0
  20. package/dist/components/button/button.js +25 -0
  21. package/dist/components/button/button.js.map +1 -0
  22. package/dist/components/button/index.d.ts +2 -0
  23. package/dist/components/index.d.ts +15 -0
  24. package/dist/components/progress/index.d.ts +2 -0
  25. package/dist/components/progress/progress.d.ts +54 -0
  26. package/dist/components/progress/progress.js +57 -0
  27. package/dist/components/progress/progress.js.map +1 -0
  28. package/dist/components/tabs/index.d.ts +2 -0
  29. package/dist/components/tabs/tabs.context.d.ts +4 -0
  30. package/dist/components/tabs/tabs.context.js +13 -0
  31. package/dist/components/tabs/tabs.context.js.map +1 -0
  32. package/dist/components/tabs/tabs.d.ts +60 -0
  33. package/dist/components/tabs/tabs.js +157 -0
  34. package/dist/components/tabs/tabs.js.map +1 -0
  35. package/dist/index.d.ts +12 -0
  36. package/dist/index.js +10 -0
  37. package/dist/provider/hui-provider.context.d.ts +35 -0
  38. package/dist/provider/hui-provider.context.js +37 -0
  39. package/dist/provider/hui-provider.context.js.map +1 -0
  40. package/dist/provider/hui-provider.d.ts +10 -0
  41. package/dist/provider/hui-provider.js +17 -0
  42. package/dist/provider/hui-provider.js.map +1 -0
  43. package/dist/provider/index.d.ts +3 -0
  44. package/dist/provider/merge-props.js +16 -0
  45. package/dist/provider/merge-props.js.map +1 -0
  46. package/dist/types/hui-component.d.ts +10 -0
  47. package/dist/types/index.d.ts +3 -0
  48. package/dist/types/polymorphic.d.ts +13 -0
  49. package/package.json +50 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 wancup
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,8 @@
1
- # Temporary Holding Version
1
+ # @hebium-ui/preact
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Experimental Preact bindings for the Hebium UI core components.
4
+
5
+ > [!WARNING]
6
+ > Hebium UI is under active development. Its APIs may change without notice, including breaking changes.
7
+
8
+ The source repository is currently private. Public release is planned, but no timeline has been set.
@@ -0,0 +1,44 @@
1
+ import { HuiComponentProps } from "../../types/hui-component.js";
2
+ import "../../types/index.js";
3
+ import { AlertSlots, AlertVariants } from "@hebium-ui/core";
4
+ import { ComponentChildren, ComponentProps, VNode } from "preact";
5
+ //#region src/components/alert/alert.d.ts
6
+ interface AlertOwnProps {
7
+ /**
8
+ * The main message displayed in the alert.
9
+ */
10
+ message?: ComponentChildren | undefined;
11
+ /**
12
+ * The description displayed below the alert message.
13
+ */
14
+ description?: ComponentChildren | undefined;
15
+ /**
16
+ * The icon displayed beside the alert content. Set to `null` or `false` to hide the icon.
17
+ *
18
+ * @default error icon
19
+ */
20
+ icon?: ComponentChildren | undefined;
21
+ /**
22
+ * The visual style of the alert.
23
+ *
24
+ * @default "light"
25
+ */
26
+ variant?: AlertVariants["variant"] | undefined;
27
+ /**
28
+ * The semantic color of the alert.
29
+ *
30
+ * @default "danger"
31
+ */
32
+ color?: AlertVariants["color"] | undefined;
33
+ /**
34
+ * The padding of the alert.
35
+ *
36
+ * @default "md"
37
+ */
38
+ padding?: AlertVariants["padding"] | undefined;
39
+ }
40
+ export type AlertProps = HuiComponentProps<Omit<ComponentProps<"div">, "children"> & AlertOwnProps, AlertSlots>;
41
+ export declare function Alert(rawProps: AlertProps): VNode;
42
+ //#endregion
43
+ export {};
44
+ //# sourceMappingURL=alert.d.ts.map
@@ -0,0 +1,45 @@
1
+ import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
2
+ import { alertRecipe } from "@hebium-ui/core";
3
+ import { jsx, jsxs } from "preact/jsx-runtime";
4
+ //#region src/components/alert/alert.tsx
5
+ function Alert(rawProps) {
6
+ const { classNames, styles, description, icon, variant, color, padding, message, ...restProps } = useHuiProps("Alert", rawProps);
7
+ const recipe = alertRecipe({
8
+ variant,
9
+ color,
10
+ padding
11
+ });
12
+ const cls = useHuiClassNames("Alert", recipe, classNames);
13
+ const sls = useHuiStyles("Alert", styles);
14
+ return /* @__PURE__ */ jsxs("div", {
15
+ className: cls.root,
16
+ style: sls.root,
17
+ role: "alert",
18
+ ...restProps,
19
+ children: [/* @__PURE__ */ jsx("div", {
20
+ className: cls.icon,
21
+ style: sls.icon,
22
+ children: typeof icon === "undefined" ? /* @__PURE__ */ jsx("span", {
23
+ "aria-hidden": true,
24
+ className: cls.errorIcon,
25
+ style: sls.errorIcon
26
+ }) : icon
27
+ }), /* @__PURE__ */ jsxs("div", {
28
+ className: cls.content,
29
+ style: sls.content,
30
+ children: [message && /* @__PURE__ */ jsx("div", {
31
+ className: cls.message,
32
+ style: sls.message,
33
+ children: message
34
+ }), description && /* @__PURE__ */ jsx("div", {
35
+ className: cls.description,
36
+ style: sls.description,
37
+ children: description
38
+ })]
39
+ })]
40
+ });
41
+ }
42
+ //#endregion
43
+ export { Alert };
44
+
45
+ //# sourceMappingURL=alert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert.js","names":[],"sources":["../../../src/components/alert/alert.tsx"],"sourcesContent":["import { alertRecipe, type AlertSlots, type AlertVariants } from \"@hebium-ui/core\";\nimport { type ComponentChildren, type ComponentProps, type VNode } from \"preact\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps } from \"~/types\";\n\ninterface AlertOwnProps {\n /**\n * The main message displayed in the alert.\n */\n message?: ComponentChildren | undefined;\n /**\n * The description displayed below the alert message.\n */\n description?: ComponentChildren | undefined;\n /**\n * The icon displayed beside the alert content. Set to `null` or `false` to hide the icon.\n *\n * @default error icon\n */\n icon?: ComponentChildren | undefined;\n /**\n * The visual style of the alert.\n *\n * @default \"light\"\n */\n variant?: AlertVariants[\"variant\"] | undefined;\n /**\n * The semantic color of the alert.\n *\n * @default \"danger\"\n */\n color?: AlertVariants[\"color\"] | undefined;\n /**\n * The padding of the alert.\n *\n * @default \"md\"\n */\n padding?: AlertVariants[\"padding\"] | undefined;\n}\n\nexport type AlertProps = HuiComponentProps<Omit<ComponentProps<\"div\">, \"children\"> & AlertOwnProps, AlertSlots>;\n\nexport function Alert(rawProps: AlertProps): VNode {\n const {\n classNames,\n styles,\n description,\n icon,\n variant,\n color,\n padding,\n message,\n ...restProps\n } = useHuiProps(\"Alert\", rawProps);\n\n const recipe = alertRecipe({\n variant,\n color,\n padding,\n });\n const cls = useHuiClassNames(\"Alert\", recipe, classNames);\n const sls = useHuiStyles(\"Alert\", styles);\n\n return (\n <div\n className={cls.root}\n style={sls.root}\n role=\"alert\"\n {...restProps}\n >\n <div className={cls.icon} style={sls.icon}>\n {typeof icon === \"undefined\"\n ? (\n <span\n aria-hidden\n className={cls.errorIcon}\n style={sls.errorIcon}\n />\n )\n : icon}\n </div>\n <div className={cls.content} style={sls.content}>\n {message && <div className={cls.message} style={sls.message}>{message}</div>}\n {description\n && (\n <div className={cls.description} style={sls.description}>\n {description}\n </div>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;AA0CA,SAAgB,MAAM,UAA6B;CACjD,MAAM,EACJ,YACA,QACA,aACA,MACA,SACA,OACA,SACA,SACA,GAAG,cACD,YAAY,SAAS,QAAQ;CAEjC,MAAM,SAAS,YAAY;EACzB;EACA;EACA;CACF,CAAC;CACD,MAAM,MAAM,iBAAiB,SAAS,QAAQ,UAAU;CACxD,MAAM,MAAM,aAAa,SAAS,MAAM;CAExC,OACE,qBAAC,OAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,MAAK;EACL,GAAI;EAJN,UAAA,CAME,oBAAC,OAAD;GAAK,WAAW,IAAI;GAAM,OAAO,IAAI;GAClC,UAAA,OAAO,SAAS,cAEb,oBAAC,QAAD;IACE,eAAA;IACA,WAAW,IAAI;IACf,OAAO,IAAI;GACZ,CAAA,IAED;EACD,CAAA,GACL,qBAAC,OAAD;GAAK,WAAW,IAAI;GAAS,OAAO,IAAI;GAAxC,UAAA,CACG,WAAW,oBAAC,OAAD;IAAK,WAAW,IAAI;IAAS,OAAO,IAAI;IAAU,UAAA;GAAa,CAAA,GAC1E,eAEG,oBAAC,OAAD;IAAK,WAAW,IAAI;IAAa,OAAO,IAAI;IACzC,UAAA;GACE,CAAA,CAEN;EACF,CAAA,CAAA;;AAET"}
@@ -0,0 +1,2 @@
1
+ import { Alert, AlertProps } from "./alert.js";
2
+ export { Alert, AlertProps };
@@ -0,0 +1,30 @@
1
+ import { HuiPolymorphicProps } from "../../types/polymorphic.js";
2
+ import "../../types/index.js";
3
+ import { AnchorSlots, AnchorVariants } from "@hebium-ui/core";
4
+ import { JSX, VNode } from "preact";
5
+ //#region src/components/anchor/anchor.d.ts
6
+ interface AnchorOwnProps {
7
+ /**
8
+ * The semantic color of the anchor.
9
+ *
10
+ * @default "accent"
11
+ */
12
+ color?: AnchorVariants["color"] | undefined;
13
+ /**
14
+ * The marker displayed before or after the anchor text.
15
+ * Override `--hui-anchor-marker` to customize the marker content.
16
+ * Include quotes in the CSS variable value because it is used as CSS `content`.
17
+ */
18
+ marker?: AnchorVariants["marker"] | undefined;
19
+ /**
20
+ * The text decoration style of the anchor.
21
+ *
22
+ * @default "underline"
23
+ */
24
+ decoration?: AnchorVariants["decoration"] | undefined;
25
+ }
26
+ export type AnchorProps<E extends JSX.ElementType = "a"> = HuiPolymorphicProps<E, AnchorOwnProps, AnchorSlots>;
27
+ export declare function Anchor<E extends JSX.ElementType = "a">(rawProps: AnchorProps<E>): VNode;
28
+ //#endregion
29
+ export {};
30
+ //# sourceMappingURL=anchor.d.ts.map
@@ -0,0 +1,25 @@
1
+ import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
2
+ import { anchorRecipe } from "@hebium-ui/core";
3
+ import { jsx } from "preact/jsx-runtime";
4
+ //#region src/components/anchor/anchor.tsx
5
+ function Anchor(rawProps) {
6
+ const { as, color, marker, decoration, className, style, children, ...restProps } = useHuiProps("Anchor", rawProps);
7
+ const recipe = anchorRecipe({
8
+ color,
9
+ marker,
10
+ decoration
11
+ });
12
+ const Component = as ?? "a";
13
+ const cls = useHuiClassNames("Anchor", recipe, { root: className });
14
+ const sls = useHuiStyles("Anchor", { root: style });
15
+ return /* @__PURE__ */ jsx(Component, {
16
+ className: cls.root,
17
+ style: sls.root,
18
+ ...restProps,
19
+ children
20
+ });
21
+ }
22
+ //#endregion
23
+ export { Anchor };
24
+
25
+ //# sourceMappingURL=anchor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anchor.js","names":[],"sources":["../../../src/components/anchor/anchor.tsx"],"sourcesContent":["import { anchorRecipe, type AnchorSlots, type AnchorVariants } from \"@hebium-ui/core\";\nimport { type JSX, type VNode } from \"preact\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\n\ninterface AnchorOwnProps {\n /**\n * The semantic color of the anchor.\n *\n * @default \"accent\"\n */\n color?: AnchorVariants[\"color\"] | undefined;\n /**\n * The marker displayed before or after the anchor text.\n * Override `--hui-anchor-marker` to customize the marker content.\n * Include quotes in the CSS variable value because it is used as CSS `content`.\n */\n marker?: AnchorVariants[\"marker\"] | undefined;\n /**\n * The text decoration style of the anchor.\n *\n * @default \"underline\"\n */\n decoration?: AnchorVariants[\"decoration\"] | undefined;\n}\n\nexport type AnchorProps<E extends JSX.ElementType = \"a\"> = HuiPolymorphicProps<\n E,\n AnchorOwnProps,\n AnchorSlots\n>;\n\nexport function Anchor<E extends JSX.ElementType = \"a\">(rawProps: AnchorProps<E>): VNode {\n const {\n as,\n color,\n marker,\n decoration,\n className,\n style,\n children,\n ...restProps\n } = useHuiProps(\"Anchor\", rawProps);\n\n const recipe = anchorRecipe({ color, marker, decoration });\n const Component = as ?? \"a\";\n\n const cls = useHuiClassNames(\"Anchor\", recipe, { root: className });\n const sls = useHuiStyles(\"Anchor\", { root: style });\n\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n"],"mappings":";;;;AAgCA,SAAgB,OAAwC,UAAiC;CACvF,MAAM,EACJ,IACA,OACA,QACA,YACA,WACA,OACA,UACA,GAAG,cACD,YAAY,UAAU,QAAQ;CAElC,MAAM,SAAS,aAAa;EAAE;EAAO;EAAQ;CAAW,CAAC;CACzD,MAAM,YAAY,MAAM;CAExB,MAAM,MAAM,iBAAiB,UAAU,QAAQ,EAAE,MAAM,UAAU,CAAC;CAClE,MAAM,MAAM,aAAa,UAAU,EAAE,MAAM,MAAM,CAAC;CAElD,OACE,oBAAC,WAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EAEH;CACQ,CAAA;AAEf"}
@@ -0,0 +1,2 @@
1
+ import { Anchor, AnchorProps } from "./anchor.js";
2
+ export { Anchor, AnchorProps };
@@ -0,0 +1,16 @@
1
+ import { HuiComponentProps } from "../../types/hui-component.js";
2
+ import "../../types/index.js";
3
+ import { AvatarSlots } from "@hebium-ui/core";
4
+ import { ComponentProps, VNode } from "preact";
5
+ //#region src/components/avatar/avatar.d.ts
6
+ interface AvatarOwnProps {
7
+ /**
8
+ * The name represented by the avatar. It is used as the default image alternative text and to generate placeholder initials.
9
+ */
10
+ name: string;
11
+ }
12
+ export type AvatarProps = HuiComponentProps<ComponentProps<"img"> & AvatarOwnProps, AvatarSlots>;
13
+ export declare function Avatar(rawProps: AvatarProps): VNode;
14
+ //#endregion
15
+ export {};
16
+ //# sourceMappingURL=avatar.d.ts.map
@@ -0,0 +1,56 @@
1
+ import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
2
+ import { avatartRecipe, getAvatarPlaceholder, shouldShowAvatarPlaceholder } from "@hebium-ui/core";
3
+ import { useCallback, useState } from "preact/hooks";
4
+ import { jsx } from "preact/jsx-runtime";
5
+ //#region src/components/avatar/avatar.tsx
6
+ function Avatar(rawProps) {
7
+ const { classNames, styles, name, src, srcSet, srcset, onError, ...restProps } = useHuiProps("Avatar", rawProps);
8
+ const imageSrcSet = srcSet ?? srcset;
9
+ const [failedSource, setFailedSource] = useState(null);
10
+ const shouldShowPlaceholder = shouldShowAvatarPlaceholder({
11
+ src,
12
+ srcSet: imageSrcSet,
13
+ failedSource
14
+ });
15
+ const recipe = avatartRecipe({ background: shouldShowPlaceholder ? "box" : "transparent" });
16
+ const cls = useHuiClassNames("Avatar", recipe, classNames);
17
+ const sls = useHuiStyles("Avatar", styles);
18
+ const handleOnError = useCallback((event) => {
19
+ onError?.(event);
20
+ setFailedSource({
21
+ src,
22
+ srcSet: imageSrcSet
23
+ });
24
+ }, [
25
+ onError,
26
+ src,
27
+ imageSrcSet
28
+ ]);
29
+ const placeholder = getAvatarPlaceholder(name);
30
+ const imageAlt = ("alt" in restProps ? restProps.alt : void 0) ?? name;
31
+ const imageProps = {
32
+ className: cls.img,
33
+ style: sls.img,
34
+ src,
35
+ srcSet: imageSrcSet,
36
+ ...restProps,
37
+ alt: imageAlt,
38
+ onError: handleOnError
39
+ };
40
+ return /* @__PURE__ */ jsx("div", {
41
+ className: cls.root,
42
+ style: sls.root,
43
+ children: shouldShowPlaceholder ? /* @__PURE__ */ jsx("span", {
44
+ className: cls.placeholder,
45
+ style: sls.placeholder,
46
+ children: placeholder
47
+ }) : /* @__PURE__ */ jsx("img", {
48
+ ...imageProps,
49
+ alt: imageProps.alt
50
+ })
51
+ });
52
+ }
53
+ //#endregion
54
+ export { Avatar };
55
+
56
+ //# sourceMappingURL=avatar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"avatar.js","names":[],"sources":["../../../src/components/avatar/avatar.tsx"],"sourcesContent":["import {\n type AvatarSlots,\n type AvatarSource,\n avatartRecipe,\n getAvatarPlaceholder,\n shouldShowAvatarPlaceholder,\n} from \"@hebium-ui/core\";\nimport { type ComponentProps, type TargetedEvent, type VNode } from \"preact\";\nimport { useCallback, useState } from \"preact/hooks\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps } from \"~/types\";\n\ninterface AvatarOwnProps {\n /**\n * The name represented by the avatar. It is used as the default image alternative text and to generate placeholder initials.\n */\n name: string;\n}\n\nexport type AvatarProps = HuiComponentProps<ComponentProps<\"img\"> & AvatarOwnProps, AvatarSlots>;\n\nexport function Avatar(rawProps: AvatarProps): VNode {\n const {\n classNames,\n styles,\n name,\n src,\n srcSet,\n srcset,\n onError,\n ...restProps\n } = useHuiProps(\"Avatar\", rawProps);\n\n const imageSrcSet = srcSet ?? srcset;\n const [failedSource, setFailedSource] = useState<AvatarSource<AvatarProps[\"src\"]> | null>(null);\n const shouldShowPlaceholder = shouldShowAvatarPlaceholder({ src, srcSet: imageSrcSet, failedSource });\n\n const recipe = avatartRecipe({\n background: shouldShowPlaceholder ? \"box\" : \"transparent\",\n });\n\n const cls = useHuiClassNames(\"Avatar\", recipe, classNames);\n const sls = useHuiStyles(\"Avatar\", styles);\n\n const handleOnError = useCallback((event: TargetedEvent<HTMLImageElement>) => {\n onError?.(event);\n\n setFailedSource({ src, srcSet: imageSrcSet });\n }, [onError, src, imageSrcSet]);\n\n const placeholder = getAvatarPlaceholder(name);\n\n const imageAlt = (\"alt\" in restProps ? restProps.alt : undefined) ?? name;\n\n // Preact's JSX accessibility union does not model the default alt supplied by name.\n const imageProps = {\n className: cls.img,\n style: sls.img,\n src,\n srcSet: imageSrcSet,\n ...restProps,\n alt: imageAlt,\n onError: handleOnError,\n } as ComponentProps<\"img\"> & { alt: typeof imageAlt };\n\n return (\n <div\n className={cls.root}\n style={sls.root}\n >\n {shouldShowPlaceholder\n ? (\n <span\n className={cls.placeholder}\n style={sls.placeholder}\n >\n {placeholder}\n </span>\n )\n : <img {...imageProps} alt={imageProps.alt} />}\n </div>\n );\n}\n"],"mappings":";;;;;AAqBA,SAAgB,OAAO,UAA8B;CACnD,MAAM,EACJ,YACA,QACA,MACA,KACA,QACA,QACA,SACA,GAAG,cACD,YAAY,UAAU,QAAQ;CAElC,MAAM,cAAc,UAAU;CAC9B,MAAM,CAAC,cAAc,mBAAmB,SAAkD,IAAI;CAC9F,MAAM,wBAAwB,4BAA4B;EAAE;EAAK,QAAQ;EAAa;CAAa,CAAC;CAEpG,MAAM,SAAS,cAAc,EAC3B,YAAY,wBAAwB,QAAQ,cAC9C,CAAC;CAED,MAAM,MAAM,iBAAiB,UAAU,QAAQ,UAAU;CACzD,MAAM,MAAM,aAAa,UAAU,MAAM;CAEzC,MAAM,gBAAgB,aAAa,UAA2C;EAC5E,UAAU,KAAK;EAEf,gBAAgB;GAAE;GAAK,QAAQ;EAAY,CAAC;CAC9C,GAAG;EAAC;EAAS;EAAK;CAAW,CAAC;CAE9B,MAAM,cAAc,qBAAqB,IAAI;CAE7C,MAAM,YAAY,SAAS,YAAY,UAAU,MAAM,KAAA,MAAc;CAGrE,MAAM,aAAa;EACjB,WAAW,IAAI;EACf,OAAO,IAAI;EACX;EACA,QAAQ;EACR,GAAG;EACH,KAAK;EACL,SAAS;CACX;CAEA,OACE,oBAAC,OAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EAEV,UAAA,wBAEG,oBAAC,QAAD;GACE,WAAW,IAAI;GACf,OAAO,IAAI;GAEV,UAAA;EACG,CAAA,IAEN,oBAAC,OAAD;GAAK,GAAI;GAAY,KAAK,WAAW;EAAM,CAAA;CAC5C,CAAA;AAET"}
@@ -0,0 +1,2 @@
1
+ import { Avatar, AvatarProps } from "./avatar.js";
2
+ export { Avatar, AvatarProps };
@@ -0,0 +1,27 @@
1
+ import { HuiComponentProps } from "../../types/hui-component.js";
2
+ import "../../types/index.js";
3
+ import { BlockquoteSlots, BlockquoteVariants } from "@hebium-ui/core";
4
+ import { ComponentChildren, ComponentProps, VNode } from "preact";
5
+ //#region src/components/blockquote/blockquote.d.ts
6
+ type HtmlFigcaptionProps = Omit<ComponentProps<"figcaption">, "children" | "className" | "style">;
7
+ interface BlockquoteOwnProps {
8
+ /**
9
+ * The semantic color of the blockquote accent.
10
+ *
11
+ * @default "neutral"
12
+ */
13
+ color?: BlockquoteVariants["color"] | undefined;
14
+ /**
15
+ * The citation or attribution displayed below the quote.
16
+ */
17
+ caption?: ComponentChildren | undefined;
18
+ /**
19
+ * Additional props passed to the caption element.
20
+ */
21
+ captionProps?: HtmlFigcaptionProps | undefined;
22
+ }
23
+ export type BlockquoteProps = HuiComponentProps<Omit<ComponentProps<"blockquote">, "color"> & BlockquoteOwnProps, BlockquoteSlots>;
24
+ export declare function Blockquote(rawProps: BlockquoteProps): VNode;
25
+ //#endregion
26
+ export {};
27
+ //# sourceMappingURL=blockquote.d.ts.map
@@ -0,0 +1,29 @@
1
+ import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
2
+ import { blockquoteRecipe } from "@hebium-ui/core";
3
+ import { jsx, jsxs } from "preact/jsx-runtime";
4
+ //#region src/components/blockquote/blockquote.tsx
5
+ function Blockquote(rawProps) {
6
+ const { color, caption, captionProps, classNames, styles, children, ...restProps } = useHuiProps("Blockquote", rawProps);
7
+ const recipe = blockquoteRecipe({ color });
8
+ const cls = useHuiClassNames("Blockquote", recipe, classNames);
9
+ const sls = useHuiStyles("Blockquote", styles);
10
+ return /* @__PURE__ */ jsxs("figure", {
11
+ className: cls.root,
12
+ style: sls.root,
13
+ children: [/* @__PURE__ */ jsx("blockquote", {
14
+ className: cls.blockquote,
15
+ style: sls.blockquote,
16
+ ...restProps,
17
+ children
18
+ }), caption != null && /* @__PURE__ */ jsx("figcaption", {
19
+ className: cls.caption,
20
+ style: sls.caption,
21
+ ...captionProps,
22
+ children: caption
23
+ })]
24
+ });
25
+ }
26
+ //#endregion
27
+ export { Blockquote };
28
+
29
+ //# sourceMappingURL=blockquote.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blockquote.js","names":[],"sources":["../../../src/components/blockquote/blockquote.tsx"],"sourcesContent":["import { blockquoteRecipe, type BlockquoteSlots, type BlockquoteVariants } from \"@hebium-ui/core\";\nimport { type ComponentChildren, type ComponentProps, type VNode } from \"preact\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiComponentProps } from \"~/types\";\n\ntype HtmlFigcaptionProps = Omit<ComponentProps<\"figcaption\">, \"children\" | \"className\" | \"style\">;\n\ninterface BlockquoteOwnProps {\n /**\n * The semantic color of the blockquote accent.\n *\n * @default \"neutral\"\n */\n color?: BlockquoteVariants[\"color\"] | undefined;\n /**\n * The citation or attribution displayed below the quote.\n */\n caption?: ComponentChildren | undefined;\n /**\n * Additional props passed to the caption element.\n */\n captionProps?: HtmlFigcaptionProps | undefined;\n}\n\nexport type BlockquoteProps = HuiComponentProps<\n Omit<ComponentProps<\"blockquote\">, \"color\"> & BlockquoteOwnProps,\n BlockquoteSlots\n>;\n\nexport function Blockquote(rawProps: BlockquoteProps): VNode {\n const {\n color,\n caption,\n captionProps,\n classNames,\n styles,\n children,\n ...restProps\n } = useHuiProps(\"Blockquote\", rawProps);\n\n const recipe = blockquoteRecipe({ color });\n const cls = useHuiClassNames(\"Blockquote\", recipe, classNames);\n const sls = useHuiStyles(\"Blockquote\", styles);\n\n return (\n <figure\n className={cls.root}\n style={sls.root}\n >\n <blockquote\n className={cls.blockquote}\n style={sls.blockquote}\n {...restProps}\n >\n {children}\n </blockquote>\n {caption != null && (\n <figcaption\n className={cls.caption}\n style={sls.caption}\n {...captionProps}\n >\n {caption}\n </figcaption>\n )}\n </figure>\n );\n}\n"],"mappings":";;;;AA6BA,SAAgB,WAAW,UAAkC;CAC3D,MAAM,EACJ,OACA,SACA,cACA,YACA,QACA,UACA,GAAG,cACD,YAAY,cAAc,QAAQ;CAEtC,MAAM,SAAS,iBAAiB,EAAE,MAAM,CAAC;CACzC,MAAM,MAAM,iBAAiB,cAAc,QAAQ,UAAU;CAC7D,MAAM,MAAM,aAAa,cAAc,MAAM;CAE7C,OACE,qBAAC,UAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EAFb,UAAA,CAIE,oBAAC,cAAD;GACE,WAAW,IAAI;GACf,OAAO,IAAI;GACX,GAAI;GAEH;EACS,CAAA,GACX,WAAW,QACV,oBAAC,cAAD;GACE,WAAW,IAAI;GACf,OAAO,IAAI;GACX,GAAI;GAEH,UAAA;EACS,CAAA,CAER;;AAEZ"}
@@ -0,0 +1,2 @@
1
+ import { Blockquote, BlockquoteProps } from "./blockquote.js";
2
+ export { Blockquote, BlockquoteProps };
@@ -0,0 +1,30 @@
1
+ import { HuiPolymorphicProps } from "../../types/polymorphic.js";
2
+ import "../../types/index.js";
3
+ import { ButtonSlots, ButtonVariants } from "@hebium-ui/core";
4
+ import { JSX, VNode } from "preact";
5
+ //#region src/components/button/button.d.ts
6
+ interface ButtonOwnProps {
7
+ /**
8
+ * The visual style of the button.
9
+ *
10
+ * @default "solid"
11
+ */
12
+ variant?: ButtonVariants["variant"] | undefined;
13
+ /**
14
+ * The semantic color of the button.
15
+ *
16
+ * @default "accent"
17
+ */
18
+ color?: ButtonVariants["color"] | undefined;
19
+ /**
20
+ * The shape of the button.
21
+ *
22
+ * @default "rectangle"
23
+ */
24
+ shape?: ButtonVariants["shape"] | undefined;
25
+ }
26
+ export type ButtonProps<E extends JSX.ElementType = "button"> = HuiPolymorphicProps<E, ButtonOwnProps, ButtonSlots>;
27
+ export declare function Button<E extends JSX.ElementType = "button">(rawProps: ButtonProps<E>): VNode;
28
+ //#endregion
29
+ export {};
30
+ //# sourceMappingURL=button.d.ts.map
@@ -0,0 +1,25 @@
1
+ import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
2
+ import { buttonRecipe } from "@hebium-ui/core";
3
+ import { jsx } from "preact/jsx-runtime";
4
+ //#region src/components/button/button.tsx
5
+ function Button(rawProps) {
6
+ const { as, variant, color, shape, className, style, children, ...restProps } = useHuiProps("Button", rawProps);
7
+ const Component = as ?? "button";
8
+ const recipe = buttonRecipe({
9
+ variant,
10
+ color,
11
+ shape
12
+ });
13
+ const cls = useHuiClassNames("Button", recipe, { root: className });
14
+ const sls = useHuiStyles("Button", { root: style });
15
+ return /* @__PURE__ */ jsx(Component, {
16
+ className: cls.root,
17
+ style: sls.root,
18
+ ...restProps,
19
+ children
20
+ });
21
+ }
22
+ //#endregion
23
+ export { Button };
24
+
25
+ //# sourceMappingURL=button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"button.js","names":[],"sources":["../../../src/components/button/button.tsx"],"sourcesContent":["import { buttonRecipe, type ButtonSlots, type ButtonVariants } from \"@hebium-ui/core\";\nimport { type JSX, type VNode } from \"preact\";\nimport { useHuiClassNames, useHuiProps, useHuiStyles } from \"~/provider\";\nimport { type HuiPolymorphicProps } from \"~/types\";\n\ninterface ButtonOwnProps {\n /**\n * The visual style of the button.\n *\n * @default \"solid\"\n */\n variant?: ButtonVariants[\"variant\"] | undefined;\n /**\n * The semantic color of the button.\n *\n * @default \"accent\"\n */\n color?: ButtonVariants[\"color\"] | undefined;\n /**\n * The shape of the button.\n *\n * @default \"rectangle\"\n */\n shape?: ButtonVariants[\"shape\"] | undefined;\n}\n\nexport type ButtonProps<E extends JSX.ElementType = \"button\"> = HuiPolymorphicProps<\n E,\n ButtonOwnProps,\n ButtonSlots\n>;\n\nexport function Button<E extends JSX.ElementType = \"button\">(rawProps: ButtonProps<E>): VNode {\n const {\n as,\n variant,\n color,\n shape,\n className,\n style,\n children,\n ...restProps\n } = useHuiProps(\"Button\", rawProps);\n\n const Component = as ?? \"button\";\n const recipe = buttonRecipe({\n variant,\n color,\n shape,\n });\n const cls = useHuiClassNames(\"Button\", recipe, { root: className });\n const sls = useHuiStyles(\"Button\", { root: style });\n\n return (\n <Component\n className={cls.root}\n style={sls.root}\n {...restProps}\n >\n {children}\n </Component>\n );\n}\n"],"mappings":";;;;AAgCA,SAAgB,OAA6C,UAAiC;CAC5F,MAAM,EACJ,IACA,SACA,OACA,OACA,WACA,OACA,UACA,GAAG,cACD,YAAY,UAAU,QAAQ;CAElC,MAAM,YAAY,MAAM;CACxB,MAAM,SAAS,aAAa;EAC1B;EACA;EACA;CACF,CAAC;CACD,MAAM,MAAM,iBAAiB,UAAU,QAAQ,EAAE,MAAM,UAAU,CAAC;CAClE,MAAM,MAAM,aAAa,UAAU,EAAE,MAAM,MAAM,CAAC;CAElD,OACE,oBAAC,WAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EAEH;CACQ,CAAA;AAEf"}
@@ -0,0 +1,2 @@
1
+ import { Button, ButtonProps } from "./button.js";
2
+ export { Button, ButtonProps };
@@ -0,0 +1,15 @@
1
+ import { Alert, AlertProps } from "./alert/alert.js";
2
+ import "./alert/index.js";
3
+ import { Anchor, AnchorProps } from "./anchor/anchor.js";
4
+ import "./anchor/index.js";
5
+ import { Avatar, AvatarProps } from "./avatar/avatar.js";
6
+ import "./avatar/index.js";
7
+ import { Blockquote, BlockquoteProps } from "./blockquote/blockquote.js";
8
+ import "./blockquote/index.js";
9
+ import { Button, ButtonProps } from "./button/button.js";
10
+ import "./button/index.js";
11
+ import { Progress, ProgressProps } from "./progress/progress.js";
12
+ import "./progress/index.js";
13
+ import { Tabs, TabsListProps, TabsPanelProps, TabsProps, TabsTabProps } from "./tabs/tabs.js";
14
+ import "./tabs/index.js";
15
+ export { Alert, AlertProps, Anchor, AnchorProps, Avatar, AvatarProps, Blockquote, BlockquoteProps, Button, ButtonProps, Progress, ProgressProps, Tabs, TabsListProps, TabsPanelProps, TabsProps, TabsTabProps };
@@ -0,0 +1,2 @@
1
+ import { Progress, ProgressProps } from "./progress.js";
2
+ export { Progress, ProgressProps };
@@ -0,0 +1,54 @@
1
+ import { HuiComponentProps } from "../../types/hui-component.js";
2
+ import "../../types/index.js";
3
+ import { ProgressSlots, ProgressVariants } from "@hebium-ui/core";
4
+ import { ComponentChildren, ComponentProps, VNode } from "preact";
5
+ //#region src/components/progress/progress.d.ts
6
+ interface ProgressOwnProps {
7
+ /**
8
+ * The minimum value of the progress range.
9
+ *
10
+ * @default 0
11
+ */
12
+ min?: number | undefined;
13
+ /**
14
+ * The maximum value of the progress range.
15
+ *
16
+ * @default 100
17
+ */
18
+ max?: number | undefined;
19
+ /**
20
+ * The current value of the progress. Omit this prop when progress is indeterminate.
21
+ */
22
+ value?: number | undefined;
23
+ /**
24
+ * The human-readable text alternative for the current value.
25
+ */
26
+ valueText?: string | undefined;
27
+ /**
28
+ * The label displayed above the progressbar.
29
+ */
30
+ label?: ComponentChildren | undefined;
31
+ /**
32
+ * The semantic color of the progressbar.
33
+ *
34
+ * @default "accent"
35
+ */
36
+ color?: ProgressVariants["color"] | undefined;
37
+ /**
38
+ * The border radius of the progressbar.
39
+ *
40
+ * @default "rounded"
41
+ */
42
+ radius?: ProgressVariants["radius"] | undefined;
43
+ /**
44
+ * The size of the progressbar.
45
+ *
46
+ * @default "md"
47
+ */
48
+ size?: ProgressVariants["size"] | undefined;
49
+ }
50
+ export type ProgressProps = HuiComponentProps<ComponentProps<"div"> & ProgressOwnProps, ProgressSlots>;
51
+ export declare function Progress(rawProps: ProgressProps): VNode;
52
+ //#endregion
53
+ export {};
54
+ //# sourceMappingURL=progress.d.ts.map
@@ -0,0 +1,57 @@
1
+ import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
2
+ import { CSS_VARS, cc, progressControl, progressRecipe, toStrbool } from "@hebium-ui/core";
3
+ import { useId } from "preact/hooks";
4
+ import { jsx, jsxs } from "preact/jsx-runtime";
5
+ //#region src/components/progress/progress.tsx
6
+ function Progress(rawProps) {
7
+ const { min, max, value, valueText, label, color, radius, size, classNames, styles, nonce, children: _children, ...restProps } = useHuiProps("Progress", rawProps);
8
+ const progressId = useId();
9
+ const progress = progressControl.resolve({
10
+ progressId,
11
+ hasLabel: Boolean(label),
12
+ min,
13
+ max,
14
+ value,
15
+ valueText
16
+ });
17
+ const recipe = progressRecipe({
18
+ color,
19
+ indeterminate: toStrbool(progress.isIndeterminate),
20
+ radius,
21
+ size
22
+ });
23
+ const cls = useHuiClassNames("Progress", recipe, classNames);
24
+ const sls = useHuiStyles("Progress", styles);
25
+ const labelAttrs = progressControl.getLabelAttributes(progress);
26
+ const barAttrs = progressControl.getBarAttributes(progress);
27
+ const valueAttrs = progressControl.getValueAttributes();
28
+ const valueClassName = `progress-value-${progress.progressId}`;
29
+ return /* @__PURE__ */ jsxs("div", {
30
+ className: cls.root,
31
+ style: sls.root,
32
+ children: [label && /* @__PURE__ */ jsx("div", {
33
+ className: cls.label,
34
+ style: sls.label,
35
+ ...labelAttrs,
36
+ children: label
37
+ }), /* @__PURE__ */ jsxs("div", {
38
+ className: cls.bar,
39
+ style: sls.bar,
40
+ ...barAttrs,
41
+ ...restProps,
42
+ children: [/* @__PURE__ */ jsx("style", {
43
+ nonce,
44
+ children: `.${valueClassName} {${CSS_VARS.arbitraryWidth}: ${progress.width}}`
45
+ }), /* @__PURE__ */ jsx("div", {
46
+ className: cc(cls.value, valueClassName),
47
+ style: sls.value,
48
+ ...valueAttrs,
49
+ children: progress.isIndeterminate ? void 0 : valueText
50
+ })]
51
+ })]
52
+ });
53
+ }
54
+ //#endregion
55
+ export { Progress };
56
+
57
+ //# sourceMappingURL=progress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"progress.js","names":[],"sources":["../../../src/components/progress/progress.tsx"],"sourcesContent":["import {\n cc,\n CSS_VARS,\n progressControl,\n progressRecipe,\n type ProgressSlots,\n type ProgressVariants,\n toStrbool,\n} from \"@hebium-ui/core\";\nimport { type 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"}
@@ -0,0 +1,2 @@
1
+ import { Tabs, TabsListProps, TabsPanelProps, TabsProps, TabsTabProps } from "./tabs.js";
2
+ export { Tabs, TabsListProps, TabsPanelProps, TabsProps, TabsTabProps };
@@ -0,0 +1,4 @@
1
+ //#region src/components/tabs/tabs.context.d.ts
2
+ export type ActivationMode = "manual" | "auto";
3
+ //#endregion
4
+ //# sourceMappingURL=tabs.context.d.ts.map
@@ -0,0 +1,13 @@
1
+ import { useContext } from "preact/hooks";
2
+ import { createContext } from "preact";
3
+ //#region src/components/tabs/tabs.context.ts
4
+ const TabsContext = createContext(null);
5
+ function useTabsContext() {
6
+ const context = useContext(TabsContext);
7
+ if (!context) throw new Error("[Hebium UI] Tabs compound components must be used within <Tabs>");
8
+ return context;
9
+ }
10
+ //#endregion
11
+ export { TabsContext, useTabsContext };
12
+
13
+ //# sourceMappingURL=tabs.context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tabs.context.js","names":[],"sources":["../../../src/components/tabs/tabs.context.ts"],"sourcesContent":["import { createContext } from \"preact\";\nimport { useContext } from \"preact/hooks\";\n\nexport type ActivationMode = \"manual\" | \"auto\";\n\nexport interface TabsContextValue {\n rootId: string;\n selectedValue: string | undefined;\n onSelect: (value: string) => void;\n activation: ActivationMode;\n}\n\nexport const TabsContext = createContext<TabsContextValue | null>(null);\n\nexport function useTabsContext(): TabsContextValue {\n const context = useContext(TabsContext);\n if (!context) {\n throw new Error(\"[Hebium UI] Tabs compound components must be used within <Tabs>\");\n }\n return context;\n}\n"],"mappings":";;;AAYA,MAAa,cAAc,cAAuC,IAAI;AAEtE,SAAgB,iBAAmC;CACjD,MAAM,UAAU,WAAW,WAAW;CACtC,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,iEAAiE;CAEnF,OAAO;AACT"}
@@ -0,0 +1,60 @@
1
+ import { HuiPolymorphicProps } from "../../types/polymorphic.js";
2
+ import "../../types/index.js";
3
+ import { ActivationMode } from "./tabs.context.js";
4
+ import { TabSlots, TablistSlots, TabpanelSlots, TabrootSlots } from "@hebium-ui/core";
5
+ import { JSX, VNode } from "preact";
6
+ //#region src/components/tabs/tabs.d.ts
7
+ interface TabsOwnProps<V extends string> {
8
+ /**
9
+ * The list of allowed tab values.
10
+ */
11
+ values: V[];
12
+ /**
13
+ * The currently selected tab value.
14
+ */
15
+ value?: V | undefined;
16
+ /**
17
+ * The initially selected tab value for uncontrolled tabs.
18
+ */
19
+ defaultValue?: V | undefined;
20
+ /**
21
+ * Called when the selected tab value changes.
22
+ */
23
+ onChange?: ((value: V) => void) | undefined;
24
+ /**
25
+ * The activation mode used when focus moves between tabs.
26
+ *
27
+ * @default "manual"
28
+ * @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}
29
+ */
30
+ activation?: ActivationMode;
31
+ }
32
+ export type TabsProps<V extends string, E extends JSX.ElementType = "div"> = HuiPolymorphicProps<E, TabsOwnProps<V>, TabrootSlots>;
33
+ declare function TabsRoot<V extends string, E extends JSX.ElementType = "div">(rawProps: TabsProps<V, E>): VNode;
34
+ interface TabsListOwnProps {}
35
+ export type TabsListProps<E extends JSX.ElementType = "div"> = HuiPolymorphicProps<E, TabsListOwnProps, TablistSlots>;
36
+ declare function List<E extends JSX.ElementType = "div">(rawProps: TabsListProps<E>): VNode;
37
+ interface TabsTabOwnProps {
38
+ /**
39
+ * The value represented by this tab.
40
+ */
41
+ value: string;
42
+ }
43
+ export type TabsTabProps<E extends JSX.ElementType = "button"> = HuiPolymorphicProps<E, TabsTabOwnProps, TabSlots>;
44
+ declare function Tab<E extends JSX.ElementType = "button">(rawProps: TabsTabProps<E>): VNode;
45
+ interface TabsPanelOwnProps {
46
+ /**
47
+ * The tab value associated with this panel.
48
+ */
49
+ value: string;
50
+ }
51
+ export type TabsPanelProps<E extends JSX.ElementType = "div"> = HuiPolymorphicProps<E, TabsPanelOwnProps, TabpanelSlots>;
52
+ declare function Panel<E extends JSX.ElementType = "div">(rawProps: TabsPanelProps<E>): VNode;
53
+ export declare const Tabs: typeof TabsRoot & {
54
+ List: typeof List;
55
+ Tab: typeof Tab;
56
+ Panel: typeof Panel;
57
+ };
58
+ //#endregion
59
+ export {};
60
+ //# sourceMappingURL=tabs.d.ts.map
@@ -0,0 +1,157 @@
1
+ import { useHuiClassNames, useHuiProps, useHuiStyles } from "../../provider/hui-provider.context.js";
2
+ import { TabsContext, useTabsContext } from "./tabs.context.js";
3
+ import { tabRecipe, tablistRecipe, tabpanelRecipe, tabrootRecipe, tabsControl } from "@hebium-ui/core";
4
+ import { useCallback, useId, useMemo, useState } from "preact/hooks";
5
+ import { jsx } from "preact/jsx-runtime";
6
+ //#region src/components/tabs/tabs.tsx
7
+ function TabsRoot(rawProps) {
8
+ const { as, id, values, value, defaultValue, onChange, className, style, children, activation = "manual", ...restProps } = useHuiProps("Tabs", rawProps);
9
+ const Component = as ?? "div";
10
+ const tmpId = useId();
11
+ const rootId = id || tmpId;
12
+ const [uncontrolledValue, setUncontrolledValue] = useState(() => value ?? defaultValue ?? values[0]);
13
+ const selectedValue = value ?? uncontrolledValue;
14
+ const recipe = tabrootRecipe({});
15
+ const cls = useHuiClassNames("Tabs", recipe, { root: className });
16
+ const sls = useHuiStyles("Tabs", { root: style });
17
+ const onSelect = useCallback((nextValue) => {
18
+ if (!values.includes(nextValue)) throw new Error(`[Hebium UI] Unexpected Tab value: ${nextValue}`);
19
+ const v = nextValue;
20
+ setUncontrolledValue(v);
21
+ onChange?.(v);
22
+ }, [onChange, values]);
23
+ const contextValue = useMemo(() => ({
24
+ rootId,
25
+ selectedValue,
26
+ onSelect,
27
+ activation
28
+ }), [
29
+ rootId,
30
+ selectedValue,
31
+ onSelect,
32
+ activation
33
+ ]);
34
+ const attrs = tabsControl.getRootAttributes({
35
+ rootId,
36
+ selectedValue
37
+ });
38
+ return /* @__PURE__ */ jsx(TabsContext.Provider, {
39
+ value: contextValue,
40
+ children: /* @__PURE__ */ jsx(Component, {
41
+ className: cls.root,
42
+ style: sls.root,
43
+ ...attrs,
44
+ ...restProps,
45
+ children
46
+ })
47
+ });
48
+ }
49
+ function List(rawProps) {
50
+ const { as, className, style, children, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...restProps } = useHuiProps("TabsList", rawProps);
51
+ const Component = as ?? "div";
52
+ const recipe = tablistRecipe({});
53
+ const cls = useHuiClassNames("TabsList", recipe, { root: className });
54
+ const sls = useHuiStyles("TabsList", { root: style });
55
+ const { rootId, selectedValue } = useTabsContext();
56
+ const attrs = tabsControl.getListAttributes({
57
+ rootId,
58
+ selectedValue
59
+ }, {
60
+ ariaLabel,
61
+ ariaLabelledBy
62
+ });
63
+ return /* @__PURE__ */ jsx(Component, {
64
+ className: cls.root,
65
+ style: sls.root,
66
+ ...attrs,
67
+ ...restProps,
68
+ children
69
+ });
70
+ }
71
+ function Tab(rawProps) {
72
+ const { as, value, className, style, children, onClick, onKeyDown, onFocus, ...restProps } = useHuiProps("TabsTab", rawProps);
73
+ const Component = as ?? "button";
74
+ const { rootId, selectedValue, onSelect, activation } = useTabsContext();
75
+ const recipe = tabRecipe({});
76
+ const cls = useHuiClassNames("TabsTab", recipe, { root: className });
77
+ const sls = useHuiStyles("TabsTab", { root: style });
78
+ const attrs = tabsControl.getTabAttributes({
79
+ rootId,
80
+ selectedValue
81
+ }, value, { isButtonElement: as === void 0 });
82
+ const handleClick = useCallback((e) => {
83
+ onClick?.(e);
84
+ if (e.defaultPrevented) return;
85
+ onSelect(value);
86
+ }, [
87
+ onClick,
88
+ onSelect,
89
+ value
90
+ ]);
91
+ const handleKeyDown = useCallback((e) => {
92
+ onKeyDown?.(e);
93
+ if (e.defaultPrevented) return;
94
+ switch (tabsControl.handleTabKeydown(e)) {
95
+ case "activate":
96
+ onSelect(value);
97
+ return;
98
+ case "focus-move":
99
+ tabsControl.moveFocus(e, rootId);
100
+ return;
101
+ case "none": return;
102
+ }
103
+ }, [
104
+ onKeyDown,
105
+ onSelect,
106
+ rootId,
107
+ value
108
+ ]);
109
+ const handleFocus = useCallback((e) => {
110
+ onFocus?.(e);
111
+ if (e.defaultPrevented) return;
112
+ if (activation === "auto") onSelect(value);
113
+ }, [
114
+ onFocus,
115
+ onSelect,
116
+ activation,
117
+ value
118
+ ]);
119
+ return /* @__PURE__ */ jsx(Component, {
120
+ className: cls.root,
121
+ style: sls.root,
122
+ ...attrs,
123
+ onClick: handleClick,
124
+ onKeyDown: handleKeyDown,
125
+ onFocus: handleFocus,
126
+ ...restProps,
127
+ children
128
+ });
129
+ }
130
+ function Panel(rawProps) {
131
+ const { as, value, className, style, children, ...restProps } = useHuiProps("TabsPanel", rawProps);
132
+ const Component = as ?? "div";
133
+ const { rootId, selectedValue } = useTabsContext();
134
+ const recipe = tabpanelRecipe({});
135
+ const cls = useHuiClassNames("TabsPanel", recipe, { root: className });
136
+ const sls = useHuiStyles("TabsPanel", { root: style });
137
+ const attrs = tabsControl.getPanelAttributes({
138
+ rootId,
139
+ selectedValue
140
+ }, value);
141
+ return /* @__PURE__ */ jsx(Component, {
142
+ className: cls.root,
143
+ style: sls.root,
144
+ ...attrs,
145
+ ...restProps,
146
+ children
147
+ });
148
+ }
149
+ const Tabs = Object.assign(TabsRoot, {
150
+ List,
151
+ Tab,
152
+ Panel
153
+ });
154
+ //#endregion
155
+ export { Tabs };
156
+
157
+ //# sourceMappingURL=tabs.js.map
@@ -0,0 +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,IAAI,MAAM,qCAAqC,WAAW;EAGlE,MAAM,IAAI;EACV,qBAAqB,CAAC;EACtB,WAAW,CAAC;CACd,GACA,CAAC,UAAU,MAAM,CACnB;CAEA,MAAM,eAAe,eACZ;EACL;EACA;EACA;EACA;CACF,IACA;EACE;EACA;EACA;EACA;CACF,CACF;CACA,MAAM,QAAQ,YAAY,kBAAkB;EAAE;EAAQ;CAAc,CAAC;CAErE,OACE,oBAAC,YAAY,UAAb;EAAsB,OAAO;EAC3B,UAAA,oBAAC,WAAD;GACE,WAAW,IAAI;GACf,OAAO,IAAI;GACX,GAAI;GACJ,GAAI;GAEH;EACQ,CAAA;CACS,CAAA;AAE1B;AASA,SAAS,KAAwC,UAAmC;CAClF,MAAM,EACJ,IACA,WACA,OACA,UACA,cAAc,WACd,mBAAmB,gBACnB,GAAG,cACD,YAAY,YAAY,QAAQ;CAEpC,MAAM,YAAY,MAAM;CAExB,MAAM,SAAS,cAAc,CAAC,CAAC;CAC/B,MAAM,MAAM,iBAAiB,YAAY,QAAQ,EAAE,MAAM,UAAU,CAAC;CACpE,MAAM,MAAM,aAAa,YAAY,EAAE,MAAM,MAAM,CAAC;CACpD,MAAM,EAAE,QAAQ,kBAAkB,eAAe;CACjD,MAAM,QAAQ,YAAY,kBACxB;EAAE;EAAQ;CAAc,GACxB;EAAE;EAAW;CAAe,CAC9B;CAEA,OACE,oBAAC,WAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EACJ,GAAI;EAEH;CACQ,CAAA;AAEf;AAcA,SAAS,IAA0C,UAAkC;CACnF,MAAM,EACJ,IACA,OACA,WACA,OACA,UACA,SACA,WACA,SACA,GAAG,cACD,YAAY,WAAW,QAAQ;CAEnC,MAAM,YAAY,MAAM;CAExB,MAAM,EAAE,QAAQ,eAAe,UAAU,eAAe,eAAe;CACvE,MAAM,SAAS,UAAU,CAAC,CAAC;CAC3B,MAAM,MAAM,iBAAiB,WAAW,QAAQ,EAAE,MAAM,UAAU,CAAC;CACnE,MAAM,MAAM,aAAa,WAAW,EAAE,MAAM,MAAM,CAAC;CACnD,MAAM,QAAQ,YAAY,iBACxB;EAAE;EAAQ;CAAc,GACxB,OACA,EAAE,iBAAiB,OAAO,KAAA,EAAU,CACtC;CAEA,MAAM,cAAc,aACjB,MAAmD;EAClD,UAAU,CAAC;EACX,IAAI,EAAE,kBAAkB;EACxB,SAAS,KAAK;CAChB,GACA;EAAC;EAAS;EAAU;CAAK,CAC3B;CAEA,MAAM,gBAAgB,aACnB,MAAsD;EACrD,YAAY,CAAC;EACb,IAAI,EAAE,kBAAkB;EAGxB,QADe,YAAY,iBAAiB,CAC/B,GAAb;GACE,KAAK;IACH,SAAS,KAAK;IACd;GACF,KAAK;IACH,YAAY,UAAU,GAAG,MAAM;IAC/B;GACF,KAAK,QACH;EACJ;CACF,GACA;EAAC;EAAW;EAAU;EAAQ;CAAK,CACrC;CAEA,MAAM,cAAc,aAAa,MAA6C;EAC5E,UAAU,CAAC;EACX,IAAI,EAAE,kBAAkB;EAExB,IAAI,eAAe,QACjB,SAAS,KAAK;CAElB,GAAG;EAAC;EAAS;EAAU;EAAY;CAAK,CAAC;CAEzC,OACE,oBAAC,WAAD;EACE,WAAW,IAAI;EACf,OAAO,IAAI;EACX,GAAI;EACJ,SAAS;EACT,WAAW;EACX,SAAS;EACT,GAAI;EAEH;CACQ,CAAA;AAEf;AAcA,SAAS,MAAyC,UAAoC;CACpF,MAAM,EACJ,IACA,OACA,WACA,OACA,UACA,GAAG,cACD,YAAY,aAAa,QAAQ;CAErC,MAAM,YAAY,MAAM;CAExB,MAAM,EAAE,QAAQ,kBAAkB,eAAe;CACjD,MAAM,SAAS,eAAe,CAAC,CAAC;CAChC,MAAM,MAAM,iBAAiB,aAAa,QAAQ,EAAE,MAAM,UAAU,CAAC;CACrE,MAAM,MAAM,aAAa,aAAa,EAAE,MAAM,MAAM,CAAC;CACrD,MAAM,QAAQ,YAAY,mBAAmB;EAAE;EAAQ;CAAc,GAAG,KAAK;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"}
@@ -0,0 +1,12 @@
1
+ import { Alert, AlertProps } from "./components/alert/alert.js";
2
+ import { Anchor, AnchorProps } from "./components/anchor/anchor.js";
3
+ import { Avatar, AvatarProps } from "./components/avatar/avatar.js";
4
+ import { Blockquote, BlockquoteProps } from "./components/blockquote/blockquote.js";
5
+ import { Button, ButtonProps } from "./components/button/button.js";
6
+ import { Progress, ProgressProps } from "./components/progress/progress.js";
7
+ import { Tabs, TabsListProps, TabsPanelProps, TabsProps, TabsTabProps } from "./components/tabs/tabs.js";
8
+ import "./components/index.js";
9
+ import { HuiComponentPropsMap, HuiProviderContext, HuiProviderContextValue, useHuiClassNames, useHuiProps, useHuiProviderContext, useHuiStyles } from "./provider/hui-provider.context.js";
10
+ import { HuiProvider } from "./provider/hui-provider.js";
11
+ 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 };
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ import { HuiProviderContext, useHuiClassNames, useHuiProps, useHuiProviderContext, useHuiStyles } from "./provider/hui-provider.context.js";
2
+ import { HuiProvider } from "./provider/hui-provider.js";
3
+ import { Alert } from "./components/alert/alert.js";
4
+ import { Anchor } from "./components/anchor/anchor.js";
5
+ import { Avatar } from "./components/avatar/avatar.js";
6
+ import { Blockquote } from "./components/blockquote/blockquote.js";
7
+ import { Button } from "./components/button/button.js";
8
+ import { Progress } from "./components/progress/progress.js";
9
+ import { Tabs } from "./components/tabs/tabs.js";
10
+ export { Alert, Anchor, Avatar, Blockquote, Button, HuiProvider, HuiProviderContext, Progress, Tabs, useHuiClassNames, useHuiProps, useHuiProviderContext, useHuiStyles };
@@ -0,0 +1,35 @@
1
+ import { AlertProps } from "../components/alert/alert.js";
2
+ import { AnchorProps } from "../components/anchor/anchor.js";
3
+ import { AvatarProps } from "../components/avatar/avatar.js";
4
+ import { BlockquoteProps } from "../components/blockquote/blockquote.js";
5
+ import { ButtonProps } from "../components/button/button.js";
6
+ import { ProgressProps } from "../components/progress/progress.js";
7
+ 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
11
+ export interface HuiComponentPropsMap {
12
+ Alert: Partial<AlertProps>;
13
+ Anchor: Partial<AnchorProps>;
14
+ Avatar: Partial<AvatarProps>;
15
+ Blockquote: Partial<BlockquoteProps>;
16
+ Button: Partial<ButtonProps>;
17
+ Progress: Partial<ProgressProps>;
18
+ Tabs: Partial<TabsProps<string>>;
19
+ TabsList: Partial<TabsListProps>;
20
+ TabsTab: Partial<TabsTabProps>;
21
+ TabsPanel: Partial<TabsPanelProps>;
22
+ }
23
+ type HuiComponentName = keyof HuiComponentPropsMap;
24
+ type HuiDefaultProps = Partial<HuiComponentPropsMap>;
25
+ export interface HuiProviderContextValue {
26
+ defaultProps: HuiDefaultProps;
27
+ }
28
+ export declare const HuiProviderContext: import("preact").Context<HuiProviderContextValue | null>;
29
+ 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
@@ -0,0 +1,37 @@
1
+ import { mergeProps } from "./merge-props.js";
2
+ import { ccAll, msAll } from "@hebium-ui/core";
3
+ import { useContext, useMemo } from "preact/hooks";
4
+ import { createContext } from "preact";
5
+ //#region src/provider/hui-provider.context.ts
6
+ const HuiProviderContext = createContext(null);
7
+ function useHuiProviderContext() {
8
+ return useContext(HuiProviderContext) ?? { defaultProps: {} };
9
+ }
10
+ function useHuiDefaultProps(key) {
11
+ return useHuiProviderContext().defaultProps[key];
12
+ }
13
+ function useHuiProps(key, rawProps) {
14
+ const defaultProps = useHuiDefaultProps(key);
15
+ return useMemo(() => {
16
+ if (typeof defaultProps === "undefined") return rawProps;
17
+ return mergeProps(defaultProps, rawProps);
18
+ }, [defaultProps, rawProps]);
19
+ }
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);
26
+ }
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 ?? {};
33
+ }
34
+ //#endregion
35
+ export { HuiProviderContext, useHuiClassNames, useHuiProps, useHuiProviderContext, useHuiStyles };
36
+
37
+ //# sourceMappingURL=hui-provider.context.js.map
@@ -0,0 +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"}
@@ -0,0 +1,10 @@
1
+ import { HuiProviderContextValue } from "./hui-provider.context.js";
2
+ import { ComponentChildren, VNode } from "preact";
3
+ //#region src/provider/hui-provider.d.ts
4
+ interface HuiProviderProps extends Partial<HuiProviderContextValue> {
5
+ children: ComponentChildren;
6
+ }
7
+ export declare function HuiProvider({ defaultProps, children }: HuiProviderProps): VNode;
8
+ //#endregion
9
+ export {};
10
+ //# sourceMappingURL=hui-provider.d.ts.map
@@ -0,0 +1,17 @@
1
+ import { HuiProviderContext } from "./hui-provider.context.js";
2
+ import { useMemo } from "preact/hooks";
3
+ import { jsx } from "preact/jsx-runtime";
4
+ //#region src/provider/hui-provider.tsx
5
+ function HuiProvider({ defaultProps, children }) {
6
+ const context = useMemo(() => {
7
+ return { defaultProps: defaultProps ?? {} };
8
+ }, [defaultProps]);
9
+ return /* @__PURE__ */ jsx(HuiProviderContext, {
10
+ value: context,
11
+ children
12
+ });
13
+ }
14
+ //#endregion
15
+ export { HuiProvider };
16
+
17
+ //# sourceMappingURL=hui-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hui-provider.js","names":[],"sources":["../../src/provider/hui-provider.tsx"],"sourcesContent":["import { type ComponentChildren, type VNode } from \"preact\";\nimport { useMemo } from \"preact/hooks\";\nimport { HuiProviderContext, type HuiProviderContextValue } from \"./hui-provider.context\";\n\ninterface HuiProviderProps extends Partial<HuiProviderContextValue> {\n children: ComponentChildren;\n}\n\nexport function HuiProvider({ defaultProps, children }: HuiProviderProps): VNode {\n const context = useMemo<HuiProviderContextValue>(() => {\n return { defaultProps: defaultProps ?? {} };\n }, [defaultProps]);\n\n return (\n <HuiProviderContext value={context}>\n {children}\n </HuiProviderContext>\n );\n}\n"],"mappings":";;;;AAQA,SAAgB,YAAY,EAAE,cAAc,YAAqC;CAC/E,MAAM,UAAU,cAAuC;EACrD,OAAO,EAAE,cAAc,gBAAgB,CAAC,EAAE;CAC5C,GAAG,CAAC,YAAY,CAAC;CAEjB,OACE,oBAAC,oBAAD;EAAoB,OAAO;EACxB;CACiB,CAAA;AAExB"}
@@ -0,0 +1,3 @@
1
+ import { HuiComponentPropsMap, HuiProviderContext, HuiProviderContextValue, useHuiClassNames, useHuiProps, useHuiProviderContext, useHuiStyles } from "./hui-provider.context.js";
2
+ import { HuiProvider } from "./hui-provider.js";
3
+ export { HuiComponentPropsMap, HuiProvider, HuiProviderContext, HuiProviderContextValue, useHuiClassNames, useHuiProps, useHuiProviderContext, useHuiStyles };
@@ -0,0 +1,16 @@
1
+ //#region src/provider/merge-props.ts
2
+ function mergeProps(defaultProps, rawProps) {
3
+ const filteredProps = {};
4
+ for (const key of Object.keys(rawProps)) {
5
+ const value = rawProps[key];
6
+ if (typeof value !== "undefined") filteredProps[key] = value;
7
+ }
8
+ return {
9
+ ...defaultProps,
10
+ ...filteredProps
11
+ };
12
+ }
13
+ //#endregion
14
+ export { mergeProps };
15
+
16
+ //# sourceMappingURL=merge-props.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-props.js","names":[],"sources":["../../src/provider/merge-props.ts"],"sourcesContent":["export function mergeProps<P extends object>(\n defaultProps: Partial<P>,\n rawProps: P,\n): P {\n const filteredProps: Partial<P> = {};\n\n for (const key of Object.keys(rawProps) as Array<keyof P>) {\n const value = rawProps[key];\n if (typeof value !== \"undefined\") {\n filteredProps[key] = value;\n }\n }\n\n return {\n ...defaultProps,\n ...filteredProps,\n } as P;\n}\n"],"mappings":";AAAA,SAAgB,WACd,cACA,UACG;CACH,MAAM,gBAA4B,CAAC;CAEnC,KAAK,MAAM,OAAO,OAAO,KAAK,QAAQ,GAAqB;EACzD,MAAM,QAAQ,SAAS;EACvB,IAAI,OAAO,UAAU,aACnB,cAAc,OAAO;CAEzB;CAEA,OAAO;EACL,GAAG;EACH,GAAG;CACL;AACF"}
@@ -0,0 +1,10 @@
1
+ import { CSSProperties } from "preact";
2
+ //#region src/types/hui-component.d.ts
3
+ 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
9
+ export {};
10
+ //# sourceMappingURL=hui-component.d.ts.map
@@ -0,0 +1,3 @@
1
+ import { HuiComponentProps } from "./hui-component.js";
2
+ import { HuiPolymorphicProps, PolymorphicComponentProps } from "./polymorphic.js";
3
+ export { HuiComponentProps, HuiPolymorphicProps, PolymorphicComponentProps };
@@ -0,0 +1,13 @@
1
+ import { CSSProperties, ComponentProps, JSX } from "preact";
2
+ //#region src/types/polymorphic.d.ts
3
+ export type PolymorphicComponentProps<E extends JSX.ElementType, OwnProps extends object> = OwnProps & {
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
13
+ //# sourceMappingURL=polymorphic.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,53 @@
1
1
  {
2
2
  "name": "@hebium-ui/preact",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0-alpha.0",
4
+ "description": "Experimental Preact bindings for the Hebium UI core components.",
5
+ "type": "module",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "default": "./dist/index.js"
13
+ },
14
+ "./package.json": "./package.json"
15
+ },
16
+ "sideEffects": false,
17
+ "keywords": [],
18
+ "author": "wancup",
19
+ "license": "MIT",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/wancup/hebium-ui.git",
23
+ "directory": "packages/preact"
24
+ },
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "devDependencies": {
29
+ "@vitest/browser-playwright": "5.0.4",
30
+ "axe-core": "4.14.0",
31
+ "oxlint": "1.87.0",
32
+ "playwright": "1.64.0",
33
+ "preact": "11.0.1",
34
+ "tsdown": "0.23.1",
35
+ "typescript": "6.0.3",
36
+ "vite": "8.3.4",
37
+ "vitest": "5.0.4",
38
+ "vitest-browser-preact": "1.1.0"
39
+ },
40
+ "peerDependencies": {
41
+ "@hebium-ui/core": "0.1.0-alpha.0",
42
+ "preact": "^11.0.0"
43
+ },
44
+ "scripts": {
45
+ "dev": "tsdown --watch",
46
+ "build": "tsdown",
47
+ "typecheck": "tsc --noEmit --skipLibCheck",
48
+ "lint:check": "oxlint --deny-warnings",
49
+ "lint:fix": "oxlint --fix",
50
+ "test": "vitest",
51
+ "test:with-ui": "vitest --browser.headless=false"
52
+ }
6
53
  }