@pzh-ui/react 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # `@pzh-ui/react`
2
+
3
+ This package contains default components to use in Provincie Zuid-Holland projects.
4
+
5
+ Add the NPM package for the components. The component library can be imported as a whole, or per component.
6
+
7
+ In order to add the entire component library, install [@pzh-ui/react](https://www.npmjs.com/package/@pzh-ui/react) using your favorite package manager.
8
+
9
+ For example, `yarn add @pzh-ui/react`
10
+
11
+ After installing the dependency, you can start using the components as follows:
12
+
13
+ ```jsx
14
+ import { Button } from '@pzh-ui/react'
15
+
16
+ function Page() {
17
+ return <Button label="Click here" />
18
+ }
19
+ ```
@@ -0,0 +1,14 @@
1
+ import { ReactNode } from 'react';
2
+ type NotificationVariant = 'info' | 'warning' | 'positive' | 'negative';
3
+ type NotificationSize = 'm' | 's' | 'xs';
4
+ export interface NotificationProps {
5
+ variant?: NotificationVariant;
6
+ size?: NotificationSize;
7
+ className?: string;
8
+ children?: ReactNode;
9
+ title: ReactNode;
10
+ onClose?: () => void;
11
+ }
12
+ export declare const Notification: ({ variant, size, className, children, title, onClose, }: NotificationProps) => import("react/jsx-runtime").JSX.Element;
13
+ export {};
14
+ //# sourceMappingURL=Notification.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Notification.d.ts","sourceRoot":"","sources":["../../src/Notification/Notification.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAIjC,KAAK,mBAAmB,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,CAAA;AACvE,KAAK,gBAAgB,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,CAAA;AAExC,MAAM,WAAW,iBAAiB;IAC9B,OAAO,CAAC,EAAE,mBAAmB,CAAA;IAC7B,IAAI,CAAC,EAAE,gBAAgB,CAAA;IACvB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,KAAK,EAAE,SAAS,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;CACvB;AAoDD,eAAO,MAAM,YAAY,GAAI,yDAO1B,iBAAiB,4CAoDnB,CAAA"}
@@ -0,0 +1,92 @@
1
+ import { cn as e } from "../utils/cn.js";
2
+ import { Text as t } from "../Text/Text.js";
3
+ import { jsx as n, jsxs as r } from "react/jsx-runtime";
4
+ import { Ban as i, CircleCheckSolid as a, CircleInfoSolid as o, TriangleExclamationSolid as s, XmarkLarge as c } from "@pzh-ui/icons";
5
+ //#region src/Notification/Notification.tsx
6
+ var l = {
7
+ info: {
8
+ icon: o,
9
+ container: "bg-pzh-blue-10 border-pzh-blue-100",
10
+ body: "text-pzh-blue-900"
11
+ },
12
+ warning: {
13
+ icon: s,
14
+ container: "bg-pzh-yellow-10 border-pzh-yellow-100",
15
+ body: "text-pzh-gray-700"
16
+ },
17
+ positive: {
18
+ icon: a,
19
+ container: "bg-pzh-green-10 border-pzh-green-100",
20
+ body: "text-pzh-green-900"
21
+ },
22
+ negative: {
23
+ icon: i,
24
+ container: "bg-pzh-red-10 border-pzh-red-100",
25
+ body: "text-pzh-red-900"
26
+ }
27
+ }, u = {
28
+ m: {
29
+ padding: "p-4",
30
+ iconSize: 18,
31
+ iconClass: "min-w-[18px]",
32
+ iconMargin: "mt-1",
33
+ titleClass: "text-heading-s",
34
+ bodySize: "s"
35
+ },
36
+ s: {
37
+ padding: "pl-4 pr-2 py-2",
38
+ iconSize: 16,
39
+ iconClass: "min-w-4 mt-0.5",
40
+ iconMargin: "mt-0.5",
41
+ titleClass: "text-heading-xs",
42
+ bodySize: "s"
43
+ },
44
+ xs: {
45
+ padding: "pl-2 pr-1 py-1",
46
+ iconSize: 14,
47
+ iconClass: "min-w-3.5 mt-[3px]",
48
+ iconMargin: "mt-[3px]",
49
+ titleClass: "text-s -mt-0.5",
50
+ bodySize: "xs"
51
+ }
52
+ }, d = ({ variant: i = "info", size: a = "m", className: o, children: s, title: d, onClose: f }) => {
53
+ let { icon: p, container: m, body: h } = l[i], { padding: g, iconSize: _, iconClass: v, iconMargin: y, titleClass: b, bodySize: x } = u[a];
54
+ return /* @__PURE__ */ n("div", {
55
+ className: e("inline-block rounded border", m, g, o),
56
+ children: /* @__PURE__ */ r("div", {
57
+ className: "flex items-start justify-between gap-2",
58
+ children: [/* @__PURE__ */ r("div", {
59
+ className: "flex items-start gap-2",
60
+ children: [/* @__PURE__ */ n(p, {
61
+ size: _,
62
+ className: e(v, y, h)
63
+ }), /* @__PURE__ */ r("div", {
64
+ className: e("flex flex-col", { "gap-1": a !== "xs" }),
65
+ children: [/* @__PURE__ */ n(t, {
66
+ as: "span",
67
+ bold: !0,
68
+ className: e("block", b, h),
69
+ children: d
70
+ }), s && /* @__PURE__ */ n(t, {
71
+ size: x,
72
+ className: h,
73
+ children: s
74
+ })]
75
+ })]
76
+ }), f && /* @__PURE__ */ n("button", {
77
+ type: "button",
78
+ "aria-label": "Sluiten",
79
+ onClick: f,
80
+ className: e("cursor-pointer", y, h),
81
+ children: /* @__PURE__ */ n(c, {
82
+ size: 14,
83
+ className: "min-w-6"
84
+ })
85
+ })]
86
+ })
87
+ });
88
+ };
89
+ //#endregion
90
+ export { d as Notification };
91
+
92
+ //# sourceMappingURL=Notification.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Notification.js","names":[],"sources":["../../src/Notification/Notification.tsx"],"sourcesContent":["import {\n Ban,\n CircleCheckSolid,\n CircleInfoSolid,\n TriangleExclamationSolid,\n XmarkLarge,\n} from '@pzh-ui/icons'\nimport { ReactNode } from 'react'\nimport { Text } from '../Text'\nimport { cn } from '../utils'\n\ntype NotificationVariant = 'info' | 'warning' | 'positive' | 'negative'\ntype NotificationSize = 'm' | 's' | 'xs'\n\nexport interface NotificationProps {\n variant?: NotificationVariant\n size?: NotificationSize\n className?: string\n children?: ReactNode\n title: ReactNode\n onClose?: () => void\n}\n\nconst variantConfig = {\n info: {\n icon: CircleInfoSolid,\n container: 'bg-pzh-blue-10 border-pzh-blue-100',\n body: 'text-pzh-blue-900',\n },\n warning: {\n icon: TriangleExclamationSolid,\n container: 'bg-pzh-yellow-10 border-pzh-yellow-100',\n body: 'text-pzh-gray-700',\n },\n positive: {\n icon: CircleCheckSolid,\n container: 'bg-pzh-green-10 border-pzh-green-100',\n body: 'text-pzh-green-900',\n },\n negative: {\n icon: Ban,\n container: 'bg-pzh-red-10 border-pzh-red-100',\n body: 'text-pzh-red-900',\n },\n} satisfies Record<NotificationVariant, unknown>\n\nconst sizeConfig = {\n m: {\n padding: 'p-4',\n iconSize: 18,\n iconClass: 'min-w-[18px]',\n iconMargin: 'mt-1',\n titleClass: 'text-heading-s',\n bodySize: 's',\n },\n s: {\n padding: 'pl-4 pr-2 py-2',\n iconSize: 16,\n iconClass: 'min-w-4 mt-0.5',\n iconMargin: 'mt-0.5',\n titleClass: 'text-heading-xs',\n bodySize: 's',\n },\n xs: {\n padding: 'pl-2 pr-1 py-1',\n iconSize: 14,\n iconClass: 'min-w-3.5 mt-[3px]',\n iconMargin: 'mt-[3px]',\n titleClass: 'text-s -mt-0.5',\n bodySize: 'xs',\n },\n} as const\n\nexport const Notification = ({\n variant = 'info',\n size = 'm',\n className,\n children,\n title,\n onClose,\n}: NotificationProps) => {\n const { icon: Icon, container, body } = variantConfig[variant]\n\n const { padding, iconSize, iconClass, iconMargin, titleClass, bodySize } =\n sizeConfig[size]\n\n return (\n <div\n className={cn(\n 'inline-block rounded border',\n container,\n padding,\n className\n )}>\n <div className=\"flex items-start justify-between gap-2\">\n <div className=\"flex items-start gap-2\">\n <Icon\n size={iconSize}\n className={cn(iconClass, iconMargin, body)}\n />\n\n <div\n className={cn('flex flex-col', {\n 'gap-1': size !== 'xs',\n })}>\n <Text\n as=\"span\"\n bold\n className={cn('block', titleClass, body)}>\n {title}\n </Text>\n\n {children && (\n <Text size={bodySize} className={body}>\n {children}\n </Text>\n )}\n </div>\n </div>\n\n {onClose && (\n <button\n type=\"button\"\n aria-label=\"Sluiten\"\n onClick={onClose}\n className={cn('cursor-pointer', iconMargin, body)}>\n <XmarkLarge size={14} className=\"min-w-6\" />\n </button>\n )}\n </div>\n </div>\n )\n}\n"],"mappings":";;;;;AAuBA,IAAM,IAAgB;CAClB,MAAM;EACF,MAAM;EACN,WAAW;EACX,MAAM;CACV;CACA,SAAS;EACL,MAAM;EACN,WAAW;EACX,MAAM;CACV;CACA,UAAU;EACN,MAAM;EACN,WAAW;EACX,MAAM;CACV;CACA,UAAU;EACN,MAAM;EACN,WAAW;EACX,MAAM;CACV;AACJ,GAEM,IAAa;CACf,GAAG;EACC,SAAS;EACT,UAAU;EACV,WAAW;EACX,YAAY;EACZ,YAAY;EACZ,UAAU;CACd;CACA,GAAG;EACC,SAAS;EACT,UAAU;EACV,WAAW;EACX,YAAY;EACZ,YAAY;EACZ,UAAU;CACd;CACA,IAAI;EACA,SAAS;EACT,UAAU;EACV,WAAW;EACX,YAAY;EACZ,YAAY;EACZ,UAAU;CACd;AACJ,GAEa,KAAgB,EACzB,aAAU,QACV,UAAO,KACP,cACA,aACA,UACA,iBACqB;CACrB,IAAM,EAAE,MAAM,GAAM,cAAW,YAAS,EAAc,IAEhD,EAAE,YAAS,aAAU,cAAW,eAAY,eAAY,gBAC1D,EAAW;CAEf,OACI,kBAAC,OAAD;EACI,WAAW,EACP,+BACA,GACA,GACA,CACJ;YACA,kBAAC,OAAD;GAAK,WAAU;aAAf,CACI,kBAAC,OAAD;IAAK,WAAU;cAAf,CACI,kBAAC,GAAD;KACI,MAAM;KACN,WAAW,EAAG,GAAW,GAAY,CAAI;IAC5C,CAAA,GAED,kBAAC,OAAD;KACI,WAAW,EAAG,iBAAiB,EAC3B,SAAS,MAAS,KACtB,CAAC;eAHL,CAII,kBAAC,GAAD;MACI,IAAG;MACH,MAAA;MACA,WAAW,EAAG,SAAS,GAAY,CAAI;gBACtC;KACC,CAAA,GAEL,KACG,kBAAC,GAAD;MAAM,MAAM;MAAU,WAAW;MAC5B;KACC,CAAA,CAET;MACJ;OAEJ,KACG,kBAAC,UAAD;IACI,MAAK;IACL,cAAW;IACX,SAAS;IACT,WAAW,EAAG,kBAAkB,GAAY,CAAI;cAChD,kBAAC,GAAD;KAAY,MAAM;KAAI,WAAU;IAAW,CAAA;GACvC,CAAA,CAEX;;CACJ,CAAA;AAEb"}
@@ -0,0 +1,2 @@
1
+ export * from './Notification';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Notification/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA"}
@@ -0,0 +1,2 @@
1
+ import { Notification as e } from "./Notification.js";
2
+ export { e as Notification };
@@ -0,0 +1,10 @@
1
+ import { PolymorphicComponentProp } from '../utils/polymorphicComponent';
2
+ type PossibleTypes = 'p' | 'span' | 'b' | 'strong' | 'i' | 'em' | 'mark' | 'small' | 'del' | 'ins' | 'sub' | 'sup' | 'blockquote' | 'code' | 'pre' | 'li' | 'dt' | 'dd' | 'label';
3
+ export interface TextProps {
4
+ size?: 'xs' | 's' | 'm' | 'l';
5
+ color?: `text-${string}`;
6
+ bold?: boolean;
7
+ }
8
+ export declare const Text: <C extends PossibleTypes>({ as, size, color, bold, className, children, ...rest }: PolymorphicComponentProp<C, TextProps>) => import("react/jsx-runtime").JSX.Element;
9
+ export {};
10
+ //# sourceMappingURL=Text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../src/Text/Text.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAA;AAExE,KAAK,aAAa,GACZ,GAAG,GACH,MAAM,GACN,GAAG,GACH,QAAQ,GACR,GAAG,GACH,IAAI,GACJ,MAAM,GACN,OAAO,GACP,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,YAAY,GACZ,MAAM,GACN,KAAK,GACL,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,OAAO,CAAA;AAEb,MAAM,WAAW,SAAS;IACtB,IAAI,CAAC,EAAE,IAAI,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;IAC7B,KAAK,CAAC,EAAE,QAAQ,MAAM,EAAE,CAAA;IACxB,IAAI,CAAC,EAAE,OAAO,CAAA;CACjB;AAED,eAAO,MAAM,IAAI,GAAI,CAAC,SAAS,aAAa,EAAE,yDAQ3C,wBAAwB,CAAC,CAAC,EAAE,SAAS,CAAC,4CAaxC,CAAA"}
@@ -0,0 +1,13 @@
1
+ import { cn as e } from "../utils/cn.js";
2
+ import { getTextStyles as t } from "../utils/getTextStyles.js";
3
+ import { jsx as n } from "react/jsx-runtime";
4
+ //#region src/Text/Text.tsx
5
+ var r = ({ as: r, size: i = "m", color: a = "text-pzh-blue-900", bold: o, className: s, children: c, ...l }) => /* @__PURE__ */ n(r || "p", {
6
+ className: e(a, t(i), s, { "font-bold": o }),
7
+ ...l,
8
+ children: c
9
+ });
10
+ //#endregion
11
+ export { r as Text };
12
+
13
+ //# sourceMappingURL=Text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Text.js","names":[],"sources":["../../src/Text/Text.tsx"],"sourcesContent":["import { ElementType } from 'react'\n\nimport { cn } from '../utils'\nimport { getTextStyles } from '../utils/getTextStyles'\nimport { PolymorphicComponentProp } from '../utils/polymorphicComponent'\n\ntype PossibleTypes =\n | 'p'\n | 'span'\n | 'b'\n | 'strong'\n | 'i'\n | 'em'\n | 'mark'\n | 'small'\n | 'del'\n | 'ins'\n | 'sub'\n | 'sup'\n | 'blockquote'\n | 'code'\n | 'pre'\n | 'li'\n | 'dt'\n | 'dd'\n | 'label'\n\nexport interface TextProps {\n size?: 'xs' | 's' | 'm' | 'l'\n color?: `text-${string}`\n bold?: boolean\n}\n\nexport const Text = <C extends PossibleTypes>({\n as,\n size = 'm',\n color = 'text-pzh-blue-900',\n bold,\n className,\n children,\n ...rest\n}: PolymorphicComponentProp<C, TextProps>) => {\n const Component = as || ('p' as ElementType)\n const styles = getTextStyles(size)\n\n return (\n <Component\n className={cn(color, styles, className, {\n 'font-bold': bold,\n })}\n {...rest}>\n {children}\n </Component>\n )\n}\n"],"mappings":";;;;AAiCA,IAAa,KAAiC,EAC1C,OACA,UAAO,KACP,WAAQ,qBACR,SACA,cACA,aACA,GAAG,QAMC,kBAJc,KAAO,KAIrB;CACI,WAAW,EAAG,GAJP,EAAc,CAIA,GAAQ,GAAW,EACpC,aAAa,EACjB,CAAC;CACD,GAAI;CACH;AACM,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './Text';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Text/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA"}
@@ -0,0 +1,2 @@
1
+ import { Text as e } from "./Text.js";
2
+ export { e as Text };
@@ -0,0 +1,5 @@
1
+ export { Text } from './Text';
2
+ export type { TextProps } from './Text';
3
+ export { Notification } from './Notification';
4
+ export type { NotificationProps } from './Notification';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,YAAY,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAEvC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ import { Text as e } from "./Text/Text.js";
2
+ import { Notification as t } from "./Notification/Notification.js";
3
+ export { t as Notification, e as Text };
@@ -0,0 +1,3 @@
1
+ import { type ClassValue } from 'clsx';
2
+ export declare function cn(...inputs: ClassValue[]): string;
3
+ //# sourceMappingURL=cn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cn.d.ts","sourceRoot":"","sources":["../../src/utils/cn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,MAAM,CAAA;AAwB5C,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC"}
@@ -0,0 +1,23 @@
1
+ import { clsx as e } from "clsx";
2
+ import { extendTailwindMerge as t } from "tailwind-merge";
3
+ //#region src/utils/cn.ts
4
+ var n = t({ override: { classGroups: { "font-size": [
5
+ "text-xs",
6
+ "text-s",
7
+ "text-m",
8
+ "text-l",
9
+ "text-heading-xs",
10
+ "text-heading-s",
11
+ "text-heading-m",
12
+ "text-heading-l",
13
+ "text-heading-xl",
14
+ "text-heading-xxl",
15
+ "text-heading-xxxl"
16
+ ] } } });
17
+ function r(...t) {
18
+ return n(e(t));
19
+ }
20
+ //#endregion
21
+ export { r as cn };
22
+
23
+ //# sourceMappingURL=cn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cn.js","names":[],"sources":["../../src/utils/cn.ts"],"sourcesContent":["import { clsx, type ClassValue } from 'clsx'\nimport { extendTailwindMerge } from 'tailwind-merge'\n\nconst twMerge = extendTailwindMerge({\n // use the `extend` key in case you want to extend instead of override\n override: {\n classGroups: {\n 'font-size': [\n 'text-xs',\n 'text-s',\n 'text-m',\n 'text-l',\n 'text-heading-xs',\n 'text-heading-s',\n 'text-heading-m',\n 'text-heading-l',\n 'text-heading-xl',\n 'text-heading-xxl',\n 'text-heading-xxxl',\n ],\n },\n },\n})\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\n"],"mappings":";;;AAGA,IAAM,IAAU,EAAoB,EAEhC,UAAU,EACN,aAAa,EACT,aAAa;CACT;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ,EACJ,EACJ,EACJ,CAAC;AAED,SAAgB,EAAG,GAAG,GAAsB;CACxC,OAAO,EAAQ,EAAK,CAAM,CAAC;AAC/B"}
@@ -0,0 +1,3 @@
1
+ import { TextProps } from '../Text';
2
+ export declare const getTextStyles: (size: TextProps["size"]) => string;
3
+ //# sourceMappingURL=getTextStyles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTextStyles.d.ts","sourceRoot":"","sources":["../../src/utils/getTextStyles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEnC,eAAO,MAAM,aAAa,GAAI,MAAM,SAAS,CAAC,MAAM,CAAC,KAAG,MAavD,CAAA"}
@@ -0,0 +1,14 @@
1
+ //#region src/utils/getTextStyles.ts
2
+ var e = (e) => {
3
+ switch (e) {
4
+ case "l": return "text-l";
5
+ case "m": return "text-m";
6
+ case "s": return "text-s";
7
+ case "xs": return "text-xs";
8
+ default: return "";
9
+ }
10
+ };
11
+ //#endregion
12
+ export { e as getTextStyles };
13
+
14
+ //# sourceMappingURL=getTextStyles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTextStyles.js","names":[],"sources":["../../src/utils/getTextStyles.ts"],"sourcesContent":["import { TextProps } from '../Text'\n\nexport const getTextStyles = (size: TextProps['size']): string => {\n switch (size) {\n case 'l':\n return 'text-l'\n case 'm':\n return 'text-m'\n case 's':\n return 'text-s'\n case 'xs':\n return 'text-xs'\n default:\n return ''\n }\n}\n"],"mappings":";AAEA,IAAa,KAAiB,MAAoC;CAC9D,QAAQ,GAAR;EACI,KAAK,KACD,OAAO;EACX,KAAK,KACD,OAAO;EACX,KAAK,KACD,OAAO;EACX,KAAK,MACD,OAAO;EACX,SACI,OAAO;CACf;AACJ"}
@@ -0,0 +1,2 @@
1
+ export { cn } from './cn';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAA"}
@@ -0,0 +1,2 @@
1
+ import { cn as e } from "./cn.js";
2
+ export { e as cn };
@@ -0,0 +1,40 @@
1
+ type DataProps = {
2
+ [key: `data-${string}`]: string | number | undefined | boolean;
3
+ };
4
+ type PolymorphicRef<C extends React.ElementType> = React.ComponentPropsWithRef<C>['ref'];
5
+ export type As = React.ElementType;
6
+ type AsProp<Component extends As> = {
7
+ as?: Component;
8
+ };
9
+ type PropsToOmit<Component extends As, Props> = keyof (AsProp<Component> & Props);
10
+ export type PolymorphicComponentProp<Component extends As, Props = object> = React.PropsWithChildren<Props & AsProp<Component>> & Omit<React.ComponentPropsWithoutRef<Component>, PropsToOmit<Component, Props>> & DataProps;
11
+ export type PolymorphicComponentPropWithRef<Component extends As, Props = object> = PolymorphicComponentProp<Component, Props> & {
12
+ ref?: PolymorphicRef<Component>;
13
+ } & DataProps;
14
+ export declare function forwardRef<Props extends object, DefaultAs extends As = 'div'>(component: React.ForwardRefRenderFunction<unknown, React.PropsWithoutRef<PolymorphicComponentProp<DefaultAs, Props>>>): <Component extends As = DefaultAs>(props: PolymorphicComponentPropWithRef<Component, Props>) => React.ReactElement | null;
15
+ export declare const polyComponent: <Props extends object, Component extends As = As>(component: React.FC<PolymorphicComponentProp<Component, Props>>) => import("react").FC<PolymorphicComponentProp<Component, Props>>;
16
+ export {};
17
+ /**
18
+
19
+ Usage with ref:
20
+
21
+ interface TestPropsBase {
22
+ title: string;
23
+ }
24
+
25
+ export type TestProps<Component extends As = "div"> = PolyMorphicComponentPropWithRef<TestPropsBase, Component>;
26
+
27
+ export const Test = forwardRef<TestPropsBase, As = "div">(
28
+ ({ as, title, ...props }, ref) => {
29
+ const Component = as || "button";
30
+
31
+ return (
32
+ <Component ref={ref} {...props}>
33
+ {title}
34
+ </Component>
35
+ )
36
+ }
37
+ );
38
+
39
+ */
40
+ //# sourceMappingURL=polymorphicComponent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"polymorphicComponent.d.ts","sourceRoot":"","sources":["../../src/utils/polymorphicComponent.ts"],"names":[],"mappings":"AAEA,KAAK,SAAS,GAAG;IACb,CAAC,GAAG,EAAE,QAAQ,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAA;CACjE,CAAA;AAED,KAAK,cAAc,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,IAC3C,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;AAEzC,MAAM,MAAM,EAAE,GAAG,KAAK,CAAC,WAAW,CAAA;AAElC,KAAK,MAAM,CAAC,SAAS,SAAS,EAAE,IAAI;IAChC,EAAE,CAAC,EAAE,SAAS,CAAA;CACjB,CAAA;AAED,KAAK,WAAW,CAAC,SAAS,SAAS,EAAE,EAAE,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,GACpE,KAAK,CAAC,CAAA;AAEV,MAAM,MAAM,wBAAwB,CAChC,SAAS,SAAS,EAAE,EACpB,KAAK,GAAG,MAAM,IACd,KAAK,CAAC,iBAAiB,CAAC,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,GAClD,IAAI,CACA,KAAK,CAAC,wBAAwB,CAAC,SAAS,CAAC,EACzC,WAAW,CAAC,SAAS,EAAE,KAAK,CAAC,CAChC,GACD,SAAS,CAAA;AAEb,MAAM,MAAM,+BAA+B,CACvC,SAAS,SAAS,EAAE,EACpB,KAAK,GAAG,MAAM,IACd,wBAAwB,CAAC,SAAS,EAAE,KAAK,CAAC,GAAG;IAC7C,GAAG,CAAC,EAAE,cAAc,CAAC,SAAS,CAAC,CAAA;CAClC,GAAG,SAAS,CAAA;AAEb,wBAAgB,UAAU,CAAC,KAAK,SAAS,MAAM,EAAE,SAAS,SAAS,EAAE,GAAG,KAAK,EACzE,SAAS,EAAE,KAAK,CAAC,wBAAwB,CACrC,OAAO,EACP,KAAK,CAAC,eAAe,CAAC,wBAAwB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CACpE,GAE+C,CAC5C,SAAS,SAAS,EAAE,GAAG,SAAS,EAEhC,KAAK,EAAE,+BAA+B,CAAC,SAAS,EAAE,KAAK,CAAC,KACvD,KAAK,CAAC,YAAY,GAAG,IAAI,CACjC;AAED,eAAO,MAAM,aAAa,GAAI,KAAK,SAAS,MAAM,EAAE,SAAS,SAAS,EAAE,GAAG,EAAE,EACzE,WAAW,KAAK,CAAC,EAAE,CAAC,wBAAwB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,mEAGlE,CAAA;;AAED;;;;;;;;;;;;;;;;;;;;;;EAsBE"}
@@ -0,0 +1,10 @@
1
+ import { forwardRef as e } from "react";
2
+ //#region src/utils/polymorphicComponent.ts
3
+ function t(t) {
4
+ return e(t);
5
+ }
6
+ var n = (e) => e;
7
+ //#endregion
8
+ export { t as forwardRef, n as polyComponent };
9
+
10
+ //# sourceMappingURL=polymorphicComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"polymorphicComponent.js","names":[],"sources":["../../src/utils/polymorphicComponent.ts"],"sourcesContent":["import { forwardRef as forwardRefReact } from 'react'\n\ntype DataProps = {\n [key: `data-${string}`]: string | number | undefined | boolean\n}\n\ntype PolymorphicRef<C extends React.ElementType> =\n React.ComponentPropsWithRef<C>['ref']\n\nexport type As = React.ElementType\n\ntype AsProp<Component extends As> = {\n as?: Component\n}\n\ntype PropsToOmit<Component extends As, Props> = keyof (AsProp<Component> &\n Props)\n\nexport type PolymorphicComponentProp<\n Component extends As,\n Props = object,\n> = React.PropsWithChildren<Props & AsProp<Component>> &\n Omit<\n React.ComponentPropsWithoutRef<Component>,\n PropsToOmit<Component, Props>\n > &\n DataProps\n\nexport type PolymorphicComponentPropWithRef<\n Component extends As,\n Props = object,\n> = PolymorphicComponentProp<Component, Props> & {\n ref?: PolymorphicRef<Component>\n} & DataProps\n\nexport function forwardRef<Props extends object, DefaultAs extends As = 'div'>(\n component: React.ForwardRefRenderFunction<\n unknown,\n React.PropsWithoutRef<PolymorphicComponentProp<DefaultAs, Props>>\n >\n) {\n return forwardRefReact(component) as unknown as <\n Component extends As = DefaultAs,\n >(\n props: PolymorphicComponentPropWithRef<Component, Props>\n ) => React.ReactElement | null\n}\n\nexport const polyComponent = <Props extends object, Component extends As = As>(\n component: React.FC<PolymorphicComponentProp<Component, Props>>\n) => {\n return component\n}\n\n/**\n\nUsage with ref:\n\ninterface TestPropsBase {\n title: string;\n}\n\nexport type TestProps<Component extends As = \"div\"> = PolyMorphicComponentPropWithRef<TestPropsBase, Component>;\n\nexport const Test = forwardRef<TestPropsBase, As = \"div\">(\n ({ as, title, ...props }, ref) => {\n const Component = as || \"button\";\n\n return (\n <Component ref={ref} {...props}>\n {title}\n </Component>\n )\n }\n);\n\n*/\n\n/*\nUsage without ref:\n\ninterface TestProps {\n icon?: IconDefinition;\n}\n\nexport const Test = <C extends React.ElementType>({\n as,\n icon,\n children,\n ...props\n}: PolymorphicComponentProp<C, TestProps>) => {\n const Component = as || \"button\";\n\n return (\n <Component {...props}>\n {icon && (\n <FontAwesomeIcon icon={icon} />\n )}\n\n {children}\n </Component>\n );\n};\n\n*/\n"],"mappings":";;AAmCA,SAAgB,EACZ,GAIF;CACE,OAAO,EAAgB,CAAS;AAKpC;AAEA,IAAa,KACT,MAEO"}
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "@pzh-ui/react",
3
+ "version": "0.0.2",
4
+ "description": "Contains default components to use in Provincie Zuid-Holland projects.",
5
+ "homepage": "https://github.com/Provincie-Zuid-Holland/pzh-ui#readme",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "sideEffects": [
10
+ "**/*.css"
11
+ ],
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "type": "module",
16
+ "types": "./dist/index.d.ts",
17
+ "main": "./dist/index.js",
18
+ "module": "./dist/index.js",
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.ts",
22
+ "import": "./dist/index.js"
23
+ }
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/Provincie-Zuid-Holland/pzh-ui.git"
28
+ },
29
+ "scripts": {
30
+ "test": "vitest",
31
+ "chromatic": "npx chromatic --project-token=chpt_086ce80c51e31f9 --auto-accept-changes --build-script-name=build-storybook",
32
+ "storybook": "storybook dev -p 6006",
33
+ "build-storybook": "storybook build",
34
+ "build": "vite build && tsc -p tsconfig.build.json"
35
+ },
36
+ "bugs": {
37
+ "url": "https://github.com/Provincie-Zuid-Holland/pzh-ui/issues"
38
+ },
39
+ "dependencies": {
40
+ "@pzh-ui/icons": "^0.0.95",
41
+ "clsx": "^2.1.1",
42
+ "react": "^19.2.7",
43
+ "react-dom": "^19.2.7",
44
+ "tailwind-merge": "^3.6.0"
45
+ },
46
+ "devDependencies": {
47
+ "@babel/core": "^7.29.7",
48
+ "@babel/preset-env": "^7.29.7",
49
+ "@babel/preset-react": "^7.29.7",
50
+ "@babel/preset-typescript": "^7.29.7",
51
+ "@storybook/addon-docs": "^10.4.2",
52
+ "@storybook/react-vite": "^10.4.2",
53
+ "@tailwindcss/vite": "^4.3.0",
54
+ "@testing-library/jest-dom": "^6.9.1",
55
+ "@testing-library/react": "^16.3.2",
56
+ "@types/babel__core": "^7",
57
+ "@types/babel__preset-env": "^7",
58
+ "@vitejs/plugin-react": "^6.0.2",
59
+ "babel-loader": "^10.1.1",
60
+ "babel-plugin-import": "^1.13.8",
61
+ "eslint": "^10.4.1",
62
+ "eslint-plugin-storybook": "^10.4.2",
63
+ "glob": "^13.0.6",
64
+ "jsdom": "^29.1.1",
65
+ "rollup-plugin-visualizer": "^7.0.1",
66
+ "storybook": "^10.4.2",
67
+ "typescript": "^6.0.3",
68
+ "typescript-eslint": "^8.60.1",
69
+ "vite": "^8.0.16",
70
+ "vitest": "^4.1.8"
71
+ },
72
+ "eslintConfig": {
73
+ "extends": [
74
+ "plugin:storybook/recommended"
75
+ ]
76
+ },
77
+ "gitHead": "cefc02eca39763001719a8173f0f81747e6098ee"
78
+ }