@cerberus-design/react 0.5.2-next-f5feb6d → 0.5.2-next-94987e7

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 (39) hide show
  1. package/build/legacy/_tsup-dts-rollup.d.ts +15 -0
  2. package/build/legacy/{chunk-PEWG443T.js → chunk-AAKHV2IO.js} +8 -5
  3. package/build/legacy/chunk-AAKHV2IO.js.map +1 -0
  4. package/build/legacy/chunk-LQD23PG3.js +24 -0
  5. package/build/legacy/chunk-LQD23PG3.js.map +1 -0
  6. package/build/legacy/chunk-RK5HK6UU.js +10 -0
  7. package/build/legacy/chunk-RK5HK6UU.js.map +1 -0
  8. package/build/legacy/{chunk-CINUA3C7.js → chunk-V4SA6GNO.js} +4 -4
  9. package/build/legacy/components/Input.js +4 -2
  10. package/build/legacy/components/Label.js +2 -2
  11. package/build/legacy/config/cerbIcons.js +7 -0
  12. package/build/legacy/config/cerbIcons.js.map +1 -0
  13. package/build/legacy/config/defineIcons.js +10 -0
  14. package/build/legacy/config/defineIcons.js.map +1 -0
  15. package/build/legacy/index.js +25 -18
  16. package/build/modern/_tsup-dts-rollup.d.ts +15 -0
  17. package/build/modern/{chunk-PEWG443T.js → chunk-AAKHV2IO.js} +8 -5
  18. package/build/modern/chunk-AAKHV2IO.js.map +1 -0
  19. package/build/modern/chunk-LQD23PG3.js +24 -0
  20. package/build/modern/chunk-LQD23PG3.js.map +1 -0
  21. package/build/modern/chunk-RK5HK6UU.js +10 -0
  22. package/build/modern/chunk-RK5HK6UU.js.map +1 -0
  23. package/build/modern/{chunk-CINUA3C7.js → chunk-V4SA6GNO.js} +4 -4
  24. package/build/modern/components/Input.js +4 -2
  25. package/build/modern/components/Label.js +2 -2
  26. package/build/modern/config/cerbIcons.js +7 -0
  27. package/build/modern/config/cerbIcons.js.map +1 -0
  28. package/build/modern/config/defineIcons.js +10 -0
  29. package/build/modern/config/defineIcons.js.map +1 -0
  30. package/build/modern/index.js +25 -18
  31. package/package.json +2 -2
  32. package/src/components/Input.tsx +3 -2
  33. package/src/config/cerbIcons.ts +10 -0
  34. package/src/config/defineIcons.ts +19 -0
  35. package/src/index.ts +4 -0
  36. package/build/legacy/chunk-PEWG443T.js.map +0 -1
  37. package/build/modern/chunk-PEWG443T.js.map +0 -1
  38. /package/build/legacy/{chunk-CINUA3C7.js.map → chunk-V4SA6GNO.js.map} +0 -0
  39. /package/build/modern/{chunk-CINUA3C7.js.map → chunk-V4SA6GNO.js.map} +0 -0
@@ -1,6 +1,7 @@
1
1
  import type { AnchorHTMLAttributes } from 'react';
2
2
  import { button } from '@cerberus/styled-system/recipes';
3
3
  import { ButtonHTMLAttributes } from 'react';
4
+ import { CarbonIconType } from '@cerberus/icons';
4
5
  import { Context } from 'react';
5
6
  import { ElementType } from 'react';
6
7
  import { fieldMessage } from '@cerberus/styled-system/recipes';
@@ -19,6 +20,10 @@ import { RefObject } from 'react';
19
20
  import { tag } from '@cerberus/styled-system/recipes';
20
21
  import type { TextareaHTMLAttributes } from 'react';
21
22
 
23
+ declare let $cerberusIcons: DefinedIcons;
24
+ export { $cerberusIcons }
25
+ export { $cerberusIcons as $cerberusIcons_alias_1 }
26
+
22
27
  /**
23
28
  * A component that allows the user to perform actions
24
29
  * @description https://github.com/omnifed/cerberus/blob/main/packages/react/src/components/Button.tsx
@@ -57,10 +62,20 @@ declare type CustomThemes<K extends string = DefaultThemes> = 'cerberus' | K;
57
62
  export { CustomThemes }
58
63
  export { CustomThemes as CustomThemes_alias_1 }
59
64
 
65
+ export declare const defaultIcons: DefinedIcons;
66
+
60
67
  declare type DefaultThemes = 'cerberus';
61
68
  export { DefaultThemes }
62
69
  export { DefaultThemes as DefaultThemes_alias_1 }
63
70
 
71
+ export declare interface DefinedIcons {
72
+ invalid: CarbonIconType | ElementType;
73
+ }
74
+
75
+ declare function defineIcons(icons: DefinedIcons): DefinedIcons;
76
+ export { defineIcons }
77
+ export { defineIcons as defineIcons_alias_1 }
78
+
64
79
  declare function Field(props: PropsWithChildren<FieldContextValue>): JSX.Element;
65
80
  export { Field }
66
81
  export { Field as Field_alias_1 }
@@ -1,12 +1,14 @@
1
+ import {
2
+ useFieldContext
3
+ } from "./chunk-ZAU4JVLL.js";
1
4
  import {
2
5
  Show
3
6
  } from "./chunk-4O4QFF4S.js";
4
7
  import {
5
- useFieldContext
6
- } from "./chunk-ZAU4JVLL.js";
8
+ $cerberusIcons
9
+ } from "./chunk-LQD23PG3.js";
7
10
 
8
11
  // src/components/Input.tsx
9
- import { WarningFilled } from "@cerberus/icons";
10
12
  import { input } from "@cerberus/styled-system/recipes";
11
13
  import { cx } from "@cerberus/styled-system/css";
12
14
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -15,6 +17,7 @@ function Input(props) {
15
17
  const inputStyles = input({ size });
16
18
  const { invalid, ...fieldStates } = useFieldContext();
17
19
  const hasEndIcon = Boolean(endIcon);
20
+ const { invalid: InvalidIcon } = $cerberusIcons;
18
21
  return /* @__PURE__ */ jsxs("div", { className: inputStyles.root, children: [
19
22
  /* @__PURE__ */ jsx(Show, { when: Boolean(startIcon), children: /* @__PURE__ */ jsx("span", { className: inputStyles.startIcon, children: startIcon }) }),
20
23
  /* @__PURE__ */ jsx(
@@ -28,7 +31,7 @@ function Input(props) {
28
31
  className: cx("peer", nativeProps.className, inputStyles.input)
29
32
  }
30
33
  ),
31
- /* @__PURE__ */ jsx(Show, { when: invalid, children: /* @__PURE__ */ jsx(WarningFilled, { className: inputStyles.icon }) }),
34
+ /* @__PURE__ */ jsx(Show, { when: invalid, children: /* @__PURE__ */ jsx(InvalidIcon, { className: inputStyles.icon }) }),
32
35
  /* @__PURE__ */ jsx(Show, { when: hasEndIcon && !invalid, children: /* @__PURE__ */ jsx("span", { className: inputStyles.icon, children: endIcon }) })
33
36
  ] });
34
37
  }
@@ -36,4 +39,4 @@ function Input(props) {
36
39
  export {
37
40
  Input
38
41
  };
39
- //# sourceMappingURL=chunk-PEWG443T.js.map
42
+ //# sourceMappingURL=chunk-AAKHV2IO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/Input.tsx"],"sourcesContent":["'use client'\n\nimport type { InputHTMLAttributes, ReactNode } from 'react'\nimport { input } from '@cerberus/styled-system/recipes'\nimport { cx, type RecipeVariantProps } from '@cerberus/styled-system/css'\nimport { useFieldContext } from '../context/field'\nimport { $cerberusIcons } from '../config/defineIcons'\nimport { Show } from './Show'\n\nexport type InputRecipeProps = RecipeVariantProps<typeof input>\nexport interface InputBaseProps\n extends Omit<InputHTMLAttributes<HTMLInputElement>, 'id' | 'size'> {\n describedBy?: string\n id: string\n startIcon?: ReactNode\n endIcon?: ReactNode\n}\nexport type InputProps = InputBaseProps & InputRecipeProps\n\nexport function Input(props: InputProps) {\n const { describedBy, size, startIcon, endIcon, ...nativeProps } = props\n const inputStyles = input({ size })\n const { invalid, ...fieldStates } = useFieldContext()\n const hasEndIcon = Boolean(endIcon)\n const { invalid: InvalidIcon } = $cerberusIcons\n\n return (\n <div className={inputStyles.root}>\n <Show when={Boolean(startIcon)}>\n <span className={inputStyles.startIcon}>{startIcon}</span>\n </Show>\n\n <input\n {...nativeProps}\n {...fieldStates}\n {...(describedBy && { 'aria-describedby': describedBy })}\n {...(invalid && { 'aria-invalid': true })}\n data-start-icon={Boolean(startIcon)}\n className={cx('peer', nativeProps.className, inputStyles.input)}\n />\n\n <Show when={invalid}>\n <InvalidIcon className={inputStyles.icon} />\n </Show>\n <Show when={hasEndIcon && !invalid}>\n <span className={inputStyles.icon}>{endIcon}</span>\n </Show>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;AAGA,SAAS,aAAa;AACtB,SAAS,UAAmC;AAuBxC,SAEI,KAFJ;AARG,SAAS,MAAM,OAAmB;AACvC,QAAM,EAAE,aAAa,MAAM,WAAW,SAAS,GAAG,YAAY,IAAI;AAClE,QAAM,cAAc,MAAM,EAAE,KAAK,CAAC;AAClC,QAAM,EAAE,SAAS,GAAG,YAAY,IAAI,gBAAgB;AACpD,QAAM,aAAa,QAAQ,OAAO;AAClC,QAAM,EAAE,SAAS,YAAY,IAAI;AAEjC,SACE,qBAAC,SAAI,WAAW,YAAY,MAC1B;AAAA,wBAAC,QAAK,MAAM,QAAQ,SAAS,GAC3B,8BAAC,UAAK,WAAW,YAAY,WAAY,qBAAU,GACrD;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACH,GAAG;AAAA,QACH,GAAI,eAAe,EAAE,oBAAoB,YAAY;AAAA,QACrD,GAAI,WAAW,EAAE,gBAAgB,KAAK;AAAA,QACvC,mBAAiB,QAAQ,SAAS;AAAA,QAClC,WAAW,GAAG,QAAQ,YAAY,WAAW,YAAY,KAAK;AAAA;AAAA,IAChE;AAAA,IAEA,oBAAC,QAAK,MAAM,SACV,8BAAC,eAAY,WAAW,YAAY,MAAM,GAC5C;AAAA,IACA,oBAAC,QAAK,MAAM,cAAc,CAAC,SACzB,8BAAC,UAAK,WAAW,YAAY,MAAO,mBAAQ,GAC9C;AAAA,KACF;AAEJ;","names":[]}
@@ -0,0 +1,24 @@
1
+ import {
2
+ defaultIcons
3
+ } from "./chunk-RK5HK6UU.js";
4
+
5
+ // src/config/defineIcons.ts
6
+ function _validateIconsProperties(icons) {
7
+ if (!icons.invalid) {
8
+ throw new Error(
9
+ "The an invalid property must be defined in your custom icons library."
10
+ );
11
+ }
12
+ }
13
+ function defineIcons(icons) {
14
+ _validateIconsProperties(icons);
15
+ $cerberusIcons = icons;
16
+ return $cerberusIcons;
17
+ }
18
+ var $cerberusIcons = defaultIcons;
19
+
20
+ export {
21
+ defineIcons,
22
+ $cerberusIcons
23
+ };
24
+ //# sourceMappingURL=chunk-LQD23PG3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/config/defineIcons.ts"],"sourcesContent":["import { defaultIcons, type DefinedIcons } from './cerbIcons'\n\nfunction _validateIconsProperties(icons: DefinedIcons) {\n if (!icons.invalid) {\n throw new Error(\n 'The an invalid property must be defined in your custom icons library.',\n )\n }\n}\n\nexport function defineIcons(icons: DefinedIcons): DefinedIcons {\n _validateIconsProperties(icons)\n $cerberusIcons = icons\n return $cerberusIcons\n}\n\n// Default icons\n\nexport let $cerberusIcons: DefinedIcons = defaultIcons\n"],"mappings":";;;;;AAEA,SAAS,yBAAyB,OAAqB;AACrD,MAAI,CAAC,MAAM,SAAS;AAClB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACF;AAEO,SAAS,YAAY,OAAmC;AAC7D,2BAAyB,KAAK;AAC9B,mBAAiB;AACjB,SAAO;AACT;AAIO,IAAI,iBAA+B;","names":[]}
@@ -0,0 +1,10 @@
1
+ // src/config/cerbIcons.ts
2
+ import { WarningFilled } from "@cerberus/icons";
3
+ var defaultIcons = {
4
+ invalid: WarningFilled
5
+ };
6
+
7
+ export {
8
+ defaultIcons
9
+ };
10
+ //# sourceMappingURL=chunk-RK5HK6UU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/config/cerbIcons.ts"],"sourcesContent":["import { WarningFilled, type CarbonIconType } from '@cerberus/icons'\nimport type { ElementType } from 'react'\n\nexport interface DefinedIcons {\n invalid: CarbonIconType | ElementType\n}\n\nexport const defaultIcons: DefinedIcons = {\n invalid: WarningFilled,\n}\n"],"mappings":";AAAA,SAAS,qBAA0C;AAO5C,IAAM,eAA6B;AAAA,EACxC,SAAS;AACX;","names":[]}
@@ -1,9 +1,9 @@
1
- import {
2
- Show
3
- } from "./chunk-4O4QFF4S.js";
4
1
  import {
5
2
  useFieldContext
6
3
  } from "./chunk-ZAU4JVLL.js";
4
+ import {
5
+ Show
6
+ } from "./chunk-4O4QFF4S.js";
7
7
 
8
8
  // src/components/Label.tsx
9
9
  import { label } from "@cerberus/styled-system/recipes";
@@ -45,4 +45,4 @@ function Label(props) {
45
45
  export {
46
46
  Label
47
47
  };
48
- //# sourceMappingURL=chunk-CINUA3C7.js.map
48
+ //# sourceMappingURL=chunk-V4SA6GNO.js.map
@@ -1,9 +1,11 @@
1
1
  "use client";
2
2
  import {
3
3
  Input
4
- } from "../chunk-PEWG443T.js";
5
- import "../chunk-4O4QFF4S.js";
4
+ } from "../chunk-AAKHV2IO.js";
6
5
  import "../chunk-ZAU4JVLL.js";
6
+ import "../chunk-4O4QFF4S.js";
7
+ import "../chunk-LQD23PG3.js";
8
+ import "../chunk-RK5HK6UU.js";
7
9
  export {
8
10
  Input
9
11
  };
@@ -1,9 +1,9 @@
1
1
  "use client";
2
2
  import {
3
3
  Label
4
- } from "../chunk-CINUA3C7.js";
5
- import "../chunk-4O4QFF4S.js";
4
+ } from "../chunk-V4SA6GNO.js";
6
5
  import "../chunk-ZAU4JVLL.js";
6
+ import "../chunk-4O4QFF4S.js";
7
7
  export {
8
8
  Label
9
9
  };
@@ -0,0 +1,7 @@
1
+ import {
2
+ defaultIcons
3
+ } from "../chunk-RK5HK6UU.js";
4
+ export {
5
+ defaultIcons
6
+ };
7
+ //# sourceMappingURL=cerbIcons.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,10 @@
1
+ import {
2
+ $cerberusIcons,
3
+ defineIcons
4
+ } from "../chunk-LQD23PG3.js";
5
+ import "../chunk-RK5HK6UU.js";
6
+ export {
7
+ $cerberusIcons,
8
+ defineIcons
9
+ };
10
+ //# sourceMappingURL=defineIcons.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,3 +1,9 @@
1
+ import {
2
+ Tab
3
+ } from "./chunk-YA2UV2AB.js";
4
+ import {
5
+ TabList
6
+ } from "./chunk-5GSXIYD3.js";
1
7
  import {
2
8
  TabPanel
3
9
  } from "./chunk-YJCWUN33.js";
@@ -7,12 +13,22 @@ import {
7
13
  import {
8
14
  Textarea
9
15
  } from "./chunk-TCO46FK7.js";
16
+ import {
17
+ FieldMessage
18
+ } from "./chunk-VGHVH2T3.js";
19
+ import {
20
+ IconButton
21
+ } from "./chunk-SLHX5K6I.js";
10
22
  import {
11
23
  Input
12
- } from "./chunk-PEWG443T.js";
24
+ } from "./chunk-AAKHV2IO.js";
13
25
  import {
14
26
  Label
15
- } from "./chunk-CINUA3C7.js";
27
+ } from "./chunk-V4SA6GNO.js";
28
+ import {
29
+ Field,
30
+ useFieldContext
31
+ } from "./chunk-ZAU4JVLL.js";
16
32
  import {
17
33
  NavMenuLink
18
34
  } from "./chunk-6DIGPXAD.js";
@@ -30,12 +46,6 @@ import {
30
46
  import {
31
47
  Show
32
48
  } from "./chunk-4O4QFF4S.js";
33
- import {
34
- Tab
35
- } from "./chunk-YA2UV2AB.js";
36
- import {
37
- TabList
38
- } from "./chunk-5GSXIYD3.js";
39
49
  import "./chunk-55J6XMHW.js";
40
50
  import {
41
51
  createNavTriggerProps
@@ -48,6 +58,11 @@ import {
48
58
  TabsContext,
49
59
  useTabsContext
50
60
  } from "./chunk-DQOYTLGB.js";
61
+ import {
62
+ $cerberusIcons,
63
+ defineIcons
64
+ } from "./chunk-LQD23PG3.js";
65
+ import "./chunk-RK5HK6UU.js";
51
66
  import {
52
67
  MODE_KEY,
53
68
  THEME_KEY,
@@ -58,17 +73,8 @@ import {
58
73
  import {
59
74
  Button
60
75
  } from "./chunk-2ATICEW3.js";
61
- import {
62
- FieldMessage
63
- } from "./chunk-VGHVH2T3.js";
64
- import {
65
- Field,
66
- useFieldContext
67
- } from "./chunk-ZAU4JVLL.js";
68
- import {
69
- IconButton
70
- } from "./chunk-SLHX5K6I.js";
71
76
  export {
77
+ $cerberusIcons,
72
78
  Button,
73
79
  Field,
74
80
  FieldMessage,
@@ -91,6 +97,7 @@ export {
91
97
  Textarea,
92
98
  ThemeProvider,
93
99
  createNavTriggerProps,
100
+ defineIcons,
94
101
  getPosition,
95
102
  useFieldContext,
96
103
  useNavMenuContext,
@@ -1,6 +1,7 @@
1
1
  import type { AnchorHTMLAttributes } from 'react';
2
2
  import { button } from '@cerberus/styled-system/recipes';
3
3
  import { ButtonHTMLAttributes } from 'react';
4
+ import { CarbonIconType } from '@cerberus/icons';
4
5
  import { Context } from 'react';
5
6
  import { ElementType } from 'react';
6
7
  import { fieldMessage } from '@cerberus/styled-system/recipes';
@@ -19,6 +20,10 @@ import { RefObject } from 'react';
19
20
  import { tag } from '@cerberus/styled-system/recipes';
20
21
  import type { TextareaHTMLAttributes } from 'react';
21
22
 
23
+ declare let $cerberusIcons: DefinedIcons;
24
+ export { $cerberusIcons }
25
+ export { $cerberusIcons as $cerberusIcons_alias_1 }
26
+
22
27
  /**
23
28
  * A component that allows the user to perform actions
24
29
  * @description https://github.com/omnifed/cerberus/blob/main/packages/react/src/components/Button.tsx
@@ -57,10 +62,20 @@ declare type CustomThemes<K extends string = DefaultThemes> = 'cerberus' | K;
57
62
  export { CustomThemes }
58
63
  export { CustomThemes as CustomThemes_alias_1 }
59
64
 
65
+ export declare const defaultIcons: DefinedIcons;
66
+
60
67
  declare type DefaultThemes = 'cerberus';
61
68
  export { DefaultThemes }
62
69
  export { DefaultThemes as DefaultThemes_alias_1 }
63
70
 
71
+ export declare interface DefinedIcons {
72
+ invalid: CarbonIconType | ElementType;
73
+ }
74
+
75
+ declare function defineIcons(icons: DefinedIcons): DefinedIcons;
76
+ export { defineIcons }
77
+ export { defineIcons as defineIcons_alias_1 }
78
+
64
79
  declare function Field(props: PropsWithChildren<FieldContextValue>): JSX.Element;
65
80
  export { Field }
66
81
  export { Field as Field_alias_1 }
@@ -1,12 +1,14 @@
1
+ import {
2
+ useFieldContext
3
+ } from "./chunk-ZAU4JVLL.js";
1
4
  import {
2
5
  Show
3
6
  } from "./chunk-4O4QFF4S.js";
4
7
  import {
5
- useFieldContext
6
- } from "./chunk-ZAU4JVLL.js";
8
+ $cerberusIcons
9
+ } from "./chunk-LQD23PG3.js";
7
10
 
8
11
  // src/components/Input.tsx
9
- import { WarningFilled } from "@cerberus/icons";
10
12
  import { input } from "@cerberus/styled-system/recipes";
11
13
  import { cx } from "@cerberus/styled-system/css";
12
14
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -15,6 +17,7 @@ function Input(props) {
15
17
  const inputStyles = input({ size });
16
18
  const { invalid, ...fieldStates } = useFieldContext();
17
19
  const hasEndIcon = Boolean(endIcon);
20
+ const { invalid: InvalidIcon } = $cerberusIcons;
18
21
  return /* @__PURE__ */ jsxs("div", { className: inputStyles.root, children: [
19
22
  /* @__PURE__ */ jsx(Show, { when: Boolean(startIcon), children: /* @__PURE__ */ jsx("span", { className: inputStyles.startIcon, children: startIcon }) }),
20
23
  /* @__PURE__ */ jsx(
@@ -28,7 +31,7 @@ function Input(props) {
28
31
  className: cx("peer", nativeProps.className, inputStyles.input)
29
32
  }
30
33
  ),
31
- /* @__PURE__ */ jsx(Show, { when: invalid, children: /* @__PURE__ */ jsx(WarningFilled, { className: inputStyles.icon }) }),
34
+ /* @__PURE__ */ jsx(Show, { when: invalid, children: /* @__PURE__ */ jsx(InvalidIcon, { className: inputStyles.icon }) }),
32
35
  /* @__PURE__ */ jsx(Show, { when: hasEndIcon && !invalid, children: /* @__PURE__ */ jsx("span", { className: inputStyles.icon, children: endIcon }) })
33
36
  ] });
34
37
  }
@@ -36,4 +39,4 @@ function Input(props) {
36
39
  export {
37
40
  Input
38
41
  };
39
- //# sourceMappingURL=chunk-PEWG443T.js.map
42
+ //# sourceMappingURL=chunk-AAKHV2IO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/Input.tsx"],"sourcesContent":["'use client'\n\nimport type { InputHTMLAttributes, ReactNode } from 'react'\nimport { input } from '@cerberus/styled-system/recipes'\nimport { cx, type RecipeVariantProps } from '@cerberus/styled-system/css'\nimport { useFieldContext } from '../context/field'\nimport { $cerberusIcons } from '../config/defineIcons'\nimport { Show } from './Show'\n\nexport type InputRecipeProps = RecipeVariantProps<typeof input>\nexport interface InputBaseProps\n extends Omit<InputHTMLAttributes<HTMLInputElement>, 'id' | 'size'> {\n describedBy?: string\n id: string\n startIcon?: ReactNode\n endIcon?: ReactNode\n}\nexport type InputProps = InputBaseProps & InputRecipeProps\n\nexport function Input(props: InputProps) {\n const { describedBy, size, startIcon, endIcon, ...nativeProps } = props\n const inputStyles = input({ size })\n const { invalid, ...fieldStates } = useFieldContext()\n const hasEndIcon = Boolean(endIcon)\n const { invalid: InvalidIcon } = $cerberusIcons\n\n return (\n <div className={inputStyles.root}>\n <Show when={Boolean(startIcon)}>\n <span className={inputStyles.startIcon}>{startIcon}</span>\n </Show>\n\n <input\n {...nativeProps}\n {...fieldStates}\n {...(describedBy && { 'aria-describedby': describedBy })}\n {...(invalid && { 'aria-invalid': true })}\n data-start-icon={Boolean(startIcon)}\n className={cx('peer', nativeProps.className, inputStyles.input)}\n />\n\n <Show when={invalid}>\n <InvalidIcon className={inputStyles.icon} />\n </Show>\n <Show when={hasEndIcon && !invalid}>\n <span className={inputStyles.icon}>{endIcon}</span>\n </Show>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;AAGA,SAAS,aAAa;AACtB,SAAS,UAAmC;AAuBxC,SAEI,KAFJ;AARG,SAAS,MAAM,OAAmB;AACvC,QAAM,EAAE,aAAa,MAAM,WAAW,SAAS,GAAG,YAAY,IAAI;AAClE,QAAM,cAAc,MAAM,EAAE,KAAK,CAAC;AAClC,QAAM,EAAE,SAAS,GAAG,YAAY,IAAI,gBAAgB;AACpD,QAAM,aAAa,QAAQ,OAAO;AAClC,QAAM,EAAE,SAAS,YAAY,IAAI;AAEjC,SACE,qBAAC,SAAI,WAAW,YAAY,MAC1B;AAAA,wBAAC,QAAK,MAAM,QAAQ,SAAS,GAC3B,8BAAC,UAAK,WAAW,YAAY,WAAY,qBAAU,GACrD;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACH,GAAG;AAAA,QACH,GAAI,eAAe,EAAE,oBAAoB,YAAY;AAAA,QACrD,GAAI,WAAW,EAAE,gBAAgB,KAAK;AAAA,QACvC,mBAAiB,QAAQ,SAAS;AAAA,QAClC,WAAW,GAAG,QAAQ,YAAY,WAAW,YAAY,KAAK;AAAA;AAAA,IAChE;AAAA,IAEA,oBAAC,QAAK,MAAM,SACV,8BAAC,eAAY,WAAW,YAAY,MAAM,GAC5C;AAAA,IACA,oBAAC,QAAK,MAAM,cAAc,CAAC,SACzB,8BAAC,UAAK,WAAW,YAAY,MAAO,mBAAQ,GAC9C;AAAA,KACF;AAEJ;","names":[]}
@@ -0,0 +1,24 @@
1
+ import {
2
+ defaultIcons
3
+ } from "./chunk-RK5HK6UU.js";
4
+
5
+ // src/config/defineIcons.ts
6
+ function _validateIconsProperties(icons) {
7
+ if (!icons.invalid) {
8
+ throw new Error(
9
+ "The an invalid property must be defined in your custom icons library."
10
+ );
11
+ }
12
+ }
13
+ function defineIcons(icons) {
14
+ _validateIconsProperties(icons);
15
+ $cerberusIcons = icons;
16
+ return $cerberusIcons;
17
+ }
18
+ var $cerberusIcons = defaultIcons;
19
+
20
+ export {
21
+ defineIcons,
22
+ $cerberusIcons
23
+ };
24
+ //# sourceMappingURL=chunk-LQD23PG3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/config/defineIcons.ts"],"sourcesContent":["import { defaultIcons, type DefinedIcons } from './cerbIcons'\n\nfunction _validateIconsProperties(icons: DefinedIcons) {\n if (!icons.invalid) {\n throw new Error(\n 'The an invalid property must be defined in your custom icons library.',\n )\n }\n}\n\nexport function defineIcons(icons: DefinedIcons): DefinedIcons {\n _validateIconsProperties(icons)\n $cerberusIcons = icons\n return $cerberusIcons\n}\n\n// Default icons\n\nexport let $cerberusIcons: DefinedIcons = defaultIcons\n"],"mappings":";;;;;AAEA,SAAS,yBAAyB,OAAqB;AACrD,MAAI,CAAC,MAAM,SAAS;AAClB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACF;AAEO,SAAS,YAAY,OAAmC;AAC7D,2BAAyB,KAAK;AAC9B,mBAAiB;AACjB,SAAO;AACT;AAIO,IAAI,iBAA+B;","names":[]}
@@ -0,0 +1,10 @@
1
+ // src/config/cerbIcons.ts
2
+ import { WarningFilled } from "@cerberus/icons";
3
+ var defaultIcons = {
4
+ invalid: WarningFilled
5
+ };
6
+
7
+ export {
8
+ defaultIcons
9
+ };
10
+ //# sourceMappingURL=chunk-RK5HK6UU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/config/cerbIcons.ts"],"sourcesContent":["import { WarningFilled, type CarbonIconType } from '@cerberus/icons'\nimport type { ElementType } from 'react'\n\nexport interface DefinedIcons {\n invalid: CarbonIconType | ElementType\n}\n\nexport const defaultIcons: DefinedIcons = {\n invalid: WarningFilled,\n}\n"],"mappings":";AAAA,SAAS,qBAA0C;AAO5C,IAAM,eAA6B;AAAA,EACxC,SAAS;AACX;","names":[]}
@@ -1,9 +1,9 @@
1
- import {
2
- Show
3
- } from "./chunk-4O4QFF4S.js";
4
1
  import {
5
2
  useFieldContext
6
3
  } from "./chunk-ZAU4JVLL.js";
4
+ import {
5
+ Show
6
+ } from "./chunk-4O4QFF4S.js";
7
7
 
8
8
  // src/components/Label.tsx
9
9
  import { label } from "@cerberus/styled-system/recipes";
@@ -45,4 +45,4 @@ function Label(props) {
45
45
  export {
46
46
  Label
47
47
  };
48
- //# sourceMappingURL=chunk-CINUA3C7.js.map
48
+ //# sourceMappingURL=chunk-V4SA6GNO.js.map
@@ -1,9 +1,11 @@
1
1
  "use client";
2
2
  import {
3
3
  Input
4
- } from "../chunk-PEWG443T.js";
5
- import "../chunk-4O4QFF4S.js";
4
+ } from "../chunk-AAKHV2IO.js";
6
5
  import "../chunk-ZAU4JVLL.js";
6
+ import "../chunk-4O4QFF4S.js";
7
+ import "../chunk-LQD23PG3.js";
8
+ import "../chunk-RK5HK6UU.js";
7
9
  export {
8
10
  Input
9
11
  };
@@ -1,9 +1,9 @@
1
1
  "use client";
2
2
  import {
3
3
  Label
4
- } from "../chunk-CINUA3C7.js";
5
- import "../chunk-4O4QFF4S.js";
4
+ } from "../chunk-V4SA6GNO.js";
6
5
  import "../chunk-ZAU4JVLL.js";
6
+ import "../chunk-4O4QFF4S.js";
7
7
  export {
8
8
  Label
9
9
  };
@@ -0,0 +1,7 @@
1
+ import {
2
+ defaultIcons
3
+ } from "../chunk-RK5HK6UU.js";
4
+ export {
5
+ defaultIcons
6
+ };
7
+ //# sourceMappingURL=cerbIcons.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,10 @@
1
+ import {
2
+ $cerberusIcons,
3
+ defineIcons
4
+ } from "../chunk-LQD23PG3.js";
5
+ import "../chunk-RK5HK6UU.js";
6
+ export {
7
+ $cerberusIcons,
8
+ defineIcons
9
+ };
10
+ //# sourceMappingURL=defineIcons.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,3 +1,9 @@
1
+ import {
2
+ Tab
3
+ } from "./chunk-SUP7U42W.js";
4
+ import {
5
+ TabList
6
+ } from "./chunk-5GSXIYD3.js";
1
7
  import {
2
8
  TabPanel
3
9
  } from "./chunk-YJCWUN33.js";
@@ -7,12 +13,22 @@ import {
7
13
  import {
8
14
  Textarea
9
15
  } from "./chunk-TCO46FK7.js";
16
+ import {
17
+ FieldMessage
18
+ } from "./chunk-VGHVH2T3.js";
19
+ import {
20
+ IconButton
21
+ } from "./chunk-SLHX5K6I.js";
10
22
  import {
11
23
  Input
12
- } from "./chunk-PEWG443T.js";
24
+ } from "./chunk-AAKHV2IO.js";
13
25
  import {
14
26
  Label
15
- } from "./chunk-CINUA3C7.js";
27
+ } from "./chunk-V4SA6GNO.js";
28
+ import {
29
+ Field,
30
+ useFieldContext
31
+ } from "./chunk-ZAU4JVLL.js";
16
32
  import {
17
33
  NavMenuLink
18
34
  } from "./chunk-6DIGPXAD.js";
@@ -30,12 +46,6 @@ import {
30
46
  import {
31
47
  Show
32
48
  } from "./chunk-4O4QFF4S.js";
33
- import {
34
- Tab
35
- } from "./chunk-SUP7U42W.js";
36
- import {
37
- TabList
38
- } from "./chunk-5GSXIYD3.js";
39
49
  import "./chunk-55J6XMHW.js";
40
50
  import {
41
51
  createNavTriggerProps
@@ -48,6 +58,11 @@ import {
48
58
  TabsContext,
49
59
  useTabsContext
50
60
  } from "./chunk-DQOYTLGB.js";
61
+ import {
62
+ $cerberusIcons,
63
+ defineIcons
64
+ } from "./chunk-LQD23PG3.js";
65
+ import "./chunk-RK5HK6UU.js";
51
66
  import {
52
67
  MODE_KEY,
53
68
  THEME_KEY,
@@ -58,17 +73,8 @@ import {
58
73
  import {
59
74
  Button
60
75
  } from "./chunk-2ATICEW3.js";
61
- import {
62
- FieldMessage
63
- } from "./chunk-VGHVH2T3.js";
64
- import {
65
- Field,
66
- useFieldContext
67
- } from "./chunk-ZAU4JVLL.js";
68
- import {
69
- IconButton
70
- } from "./chunk-SLHX5K6I.js";
71
76
  export {
77
+ $cerberusIcons,
72
78
  Button,
73
79
  Field,
74
80
  FieldMessage,
@@ -91,6 +97,7 @@ export {
91
97
  Textarea,
92
98
  ThemeProvider,
93
99
  createNavTriggerProps,
100
+ defineIcons,
94
101
  getPosition,
95
102
  useFieldContext,
96
103
  useNavMenuContext,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cerberus-design/react",
3
- "version": "0.5.2-next-f5feb6d",
3
+ "version": "0.5.2-next-94987e7",
4
4
  "description": "The Cerberus Design React component library.",
5
5
  "browserslist": "> 0.25%, not dead",
6
6
  "sideEffects": false,
@@ -22,7 +22,7 @@
22
22
  "react-dom": "^18",
23
23
  "tsup": "^8.1.0",
24
24
  "@cerberus-design/configs": "0.0.0",
25
- "@cerberus-design/styled-system": "0.5.2-next-f5feb6d"
25
+ "@cerberus-design/styled-system": "0.5.2-next-94987e7"
26
26
  },
27
27
  "publishConfig": {
28
28
  "access": "public"
@@ -1,10 +1,10 @@
1
1
  'use client'
2
2
 
3
3
  import type { InputHTMLAttributes, ReactNode } from 'react'
4
- import { WarningFilled } from '@cerberus/icons'
5
4
  import { input } from '@cerberus/styled-system/recipes'
6
5
  import { cx, type RecipeVariantProps } from '@cerberus/styled-system/css'
7
6
  import { useFieldContext } from '../context/field'
7
+ import { $cerberusIcons } from '../config/defineIcons'
8
8
  import { Show } from './Show'
9
9
 
10
10
  export type InputRecipeProps = RecipeVariantProps<typeof input>
@@ -22,6 +22,7 @@ export function Input(props: InputProps) {
22
22
  const inputStyles = input({ size })
23
23
  const { invalid, ...fieldStates } = useFieldContext()
24
24
  const hasEndIcon = Boolean(endIcon)
25
+ const { invalid: InvalidIcon } = $cerberusIcons
25
26
 
26
27
  return (
27
28
  <div className={inputStyles.root}>
@@ -39,7 +40,7 @@ export function Input(props: InputProps) {
39
40
  />
40
41
 
41
42
  <Show when={invalid}>
42
- <WarningFilled className={inputStyles.icon} />
43
+ <InvalidIcon className={inputStyles.icon} />
43
44
  </Show>
44
45
  <Show when={hasEndIcon && !invalid}>
45
46
  <span className={inputStyles.icon}>{endIcon}</span>
@@ -0,0 +1,10 @@
1
+ import { WarningFilled, type CarbonIconType } from '@cerberus/icons'
2
+ import type { ElementType } from 'react'
3
+
4
+ export interface DefinedIcons {
5
+ invalid: CarbonIconType | ElementType
6
+ }
7
+
8
+ export const defaultIcons: DefinedIcons = {
9
+ invalid: WarningFilled,
10
+ }
@@ -0,0 +1,19 @@
1
+ import { defaultIcons, type DefinedIcons } from './cerbIcons'
2
+
3
+ function _validateIconsProperties(icons: DefinedIcons) {
4
+ if (!icons.invalid) {
5
+ throw new Error(
6
+ 'The an invalid property must be defined in your custom icons library.',
7
+ )
8
+ }
9
+ }
10
+
11
+ export function defineIcons(icons: DefinedIcons): DefinedIcons {
12
+ _validateIconsProperties(icons)
13
+ $cerberusIcons = icons
14
+ return $cerberusIcons
15
+ }
16
+
17
+ // Default icons
18
+
19
+ export let $cerberusIcons: DefinedIcons = defaultIcons
package/src/index.ts CHANGED
@@ -36,6 +36,10 @@ export * from './hooks/useTheme'
36
36
  export * from './aria-helpers/nav-menu.aria'
37
37
  export * from './aria-helpers/tabs.aria'
38
38
 
39
+ // utils
40
+
41
+ export * from './config/defineIcons'
42
+
39
43
  // shared types
40
44
 
41
45
  export * from './types'
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/components/Input.tsx"],"sourcesContent":["'use client'\n\nimport type { InputHTMLAttributes, ReactNode } from 'react'\nimport { WarningFilled } from '@cerberus/icons'\nimport { input } from '@cerberus/styled-system/recipes'\nimport { cx, type RecipeVariantProps } from '@cerberus/styled-system/css'\nimport { useFieldContext } from '../context/field'\nimport { Show } from './Show'\n\nexport type InputRecipeProps = RecipeVariantProps<typeof input>\nexport interface InputBaseProps\n extends Omit<InputHTMLAttributes<HTMLInputElement>, 'id' | 'size'> {\n describedBy?: string\n id: string\n startIcon?: ReactNode\n endIcon?: ReactNode\n}\nexport type InputProps = InputBaseProps & InputRecipeProps\n\nexport function Input(props: InputProps) {\n const { describedBy, size, startIcon, endIcon, ...nativeProps } = props\n const inputStyles = input({ size })\n const { invalid, ...fieldStates } = useFieldContext()\n const hasEndIcon = Boolean(endIcon)\n\n return (\n <div className={inputStyles.root}>\n <Show when={Boolean(startIcon)}>\n <span className={inputStyles.startIcon}>{startIcon}</span>\n </Show>\n\n <input\n {...nativeProps}\n {...fieldStates}\n {...(describedBy && { 'aria-describedby': describedBy })}\n {...(invalid && { 'aria-invalid': true })}\n data-start-icon={Boolean(startIcon)}\n className={cx('peer', nativeProps.className, inputStyles.input)}\n />\n\n <Show when={invalid}>\n <WarningFilled className={inputStyles.icon} />\n </Show>\n <Show when={hasEndIcon && !invalid}>\n <span className={inputStyles.icon}>{endIcon}</span>\n </Show>\n </div>\n )\n}\n"],"mappings":";;;;;;;;AAGA,SAAS,qBAAqB;AAC9B,SAAS,aAAa;AACtB,SAAS,UAAmC;AAqBxC,SAEI,KAFJ;AAPG,SAAS,MAAM,OAAmB;AACvC,QAAM,EAAE,aAAa,MAAM,WAAW,SAAS,GAAG,YAAY,IAAI;AAClE,QAAM,cAAc,MAAM,EAAE,KAAK,CAAC;AAClC,QAAM,EAAE,SAAS,GAAG,YAAY,IAAI,gBAAgB;AACpD,QAAM,aAAa,QAAQ,OAAO;AAElC,SACE,qBAAC,SAAI,WAAW,YAAY,MAC1B;AAAA,wBAAC,QAAK,MAAM,QAAQ,SAAS,GAC3B,8BAAC,UAAK,WAAW,YAAY,WAAY,qBAAU,GACrD;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACH,GAAG;AAAA,QACH,GAAI,eAAe,EAAE,oBAAoB,YAAY;AAAA,QACrD,GAAI,WAAW,EAAE,gBAAgB,KAAK;AAAA,QACvC,mBAAiB,QAAQ,SAAS;AAAA,QAClC,WAAW,GAAG,QAAQ,YAAY,WAAW,YAAY,KAAK;AAAA;AAAA,IAChE;AAAA,IAEA,oBAAC,QAAK,MAAM,SACV,8BAAC,iBAAc,WAAW,YAAY,MAAM,GAC9C;AAAA,IACA,oBAAC,QAAK,MAAM,cAAc,CAAC,SACzB,8BAAC,UAAK,WAAW,YAAY,MAAO,mBAAQ,GAC9C;AAAA,KACF;AAEJ;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/components/Input.tsx"],"sourcesContent":["'use client'\n\nimport type { InputHTMLAttributes, ReactNode } from 'react'\nimport { WarningFilled } from '@cerberus/icons'\nimport { input } from '@cerberus/styled-system/recipes'\nimport { cx, type RecipeVariantProps } from '@cerberus/styled-system/css'\nimport { useFieldContext } from '../context/field'\nimport { Show } from './Show'\n\nexport type InputRecipeProps = RecipeVariantProps<typeof input>\nexport interface InputBaseProps\n extends Omit<InputHTMLAttributes<HTMLInputElement>, 'id' | 'size'> {\n describedBy?: string\n id: string\n startIcon?: ReactNode\n endIcon?: ReactNode\n}\nexport type InputProps = InputBaseProps & InputRecipeProps\n\nexport function Input(props: InputProps) {\n const { describedBy, size, startIcon, endIcon, ...nativeProps } = props\n const inputStyles = input({ size })\n const { invalid, ...fieldStates } = useFieldContext()\n const hasEndIcon = Boolean(endIcon)\n\n return (\n <div className={inputStyles.root}>\n <Show when={Boolean(startIcon)}>\n <span className={inputStyles.startIcon}>{startIcon}</span>\n </Show>\n\n <input\n {...nativeProps}\n {...fieldStates}\n {...(describedBy && { 'aria-describedby': describedBy })}\n {...(invalid && { 'aria-invalid': true })}\n data-start-icon={Boolean(startIcon)}\n className={cx('peer', nativeProps.className, inputStyles.input)}\n />\n\n <Show when={invalid}>\n <WarningFilled className={inputStyles.icon} />\n </Show>\n <Show when={hasEndIcon && !invalid}>\n <span className={inputStyles.icon}>{endIcon}</span>\n </Show>\n </div>\n )\n}\n"],"mappings":";;;;;;;;AAGA,SAAS,qBAAqB;AAC9B,SAAS,aAAa;AACtB,SAAS,UAAmC;AAqBxC,SAEI,KAFJ;AAPG,SAAS,MAAM,OAAmB;AACvC,QAAM,EAAE,aAAa,MAAM,WAAW,SAAS,GAAG,YAAY,IAAI;AAClE,QAAM,cAAc,MAAM,EAAE,KAAK,CAAC;AAClC,QAAM,EAAE,SAAS,GAAG,YAAY,IAAI,gBAAgB;AACpD,QAAM,aAAa,QAAQ,OAAO;AAElC,SACE,qBAAC,SAAI,WAAW,YAAY,MAC1B;AAAA,wBAAC,QAAK,MAAM,QAAQ,SAAS,GAC3B,8BAAC,UAAK,WAAW,YAAY,WAAY,qBAAU,GACrD;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACH,GAAG;AAAA,QACH,GAAI,eAAe,EAAE,oBAAoB,YAAY;AAAA,QACrD,GAAI,WAAW,EAAE,gBAAgB,KAAK;AAAA,QACvC,mBAAiB,QAAQ,SAAS;AAAA,QAClC,WAAW,GAAG,QAAQ,YAAY,WAAW,YAAY,KAAK;AAAA;AAAA,IAChE;AAAA,IAEA,oBAAC,QAAK,MAAM,SACV,8BAAC,iBAAc,WAAW,YAAY,MAAM,GAC9C;AAAA,IACA,oBAAC,QAAK,MAAM,cAAc,CAAC,SACzB,8BAAC,UAAK,WAAW,YAAY,MAAO,mBAAQ,GAC9C;AAAA,KACF;AAEJ;","names":[]}