@cerberus-design/react 0.14.2-next-a928afd → 0.14.2-next-0052cda

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 (188) hide show
  1. package/build/legacy/_tsup-dts-rollup.d.cts +111 -34
  2. package/build/legacy/components/Accordion.cjs +4 -187
  3. package/build/legacy/components/Accordion.cjs.map +1 -1
  4. package/build/legacy/components/Accordion.client.cjs +64 -0
  5. package/build/legacy/components/Accordion.client.cjs.map +1 -0
  6. package/build/legacy/components/AccordionItemGroup.cjs +41 -185
  7. package/build/legacy/components/AccordionItemGroup.cjs.map +1 -1
  8. package/build/legacy/components/Admonition.cjs +89 -239
  9. package/build/legacy/components/Admonition.cjs.map +1 -1
  10. package/build/legacy/components/Admonition.client.cjs +219 -0
  11. package/build/legacy/components/Admonition.client.cjs.map +1 -0
  12. package/build/legacy/components/AnimatingUploadIcon.cjs.map +1 -1
  13. package/build/legacy/components/Avatar.cjs +23 -174
  14. package/build/legacy/components/Avatar.cjs.map +1 -1
  15. package/build/legacy/components/Checkbox.cjs +22 -168
  16. package/build/legacy/components/Checkbox.cjs.map +1 -1
  17. package/build/legacy/components/DatePicker.client.cjs +119 -268
  18. package/build/legacy/components/DatePicker.client.cjs.map +1 -1
  19. package/build/legacy/components/DatePicker.server.cjs +17 -271
  20. package/build/legacy/components/DatePicker.server.cjs.map +1 -1
  21. package/build/legacy/components/FileStatus.cjs +62 -212
  22. package/build/legacy/components/FileStatus.cjs.map +1 -1
  23. package/build/legacy/components/FileUploader.cjs +29 -180
  24. package/build/legacy/components/FileUploader.cjs.map +1 -1
  25. package/build/legacy/components/Input.cjs +20 -172
  26. package/build/legacy/components/Input.cjs.map +1 -1
  27. package/build/legacy/components/Notification.cjs +25 -176
  28. package/build/legacy/components/Notification.cjs.map +1 -1
  29. package/build/legacy/components/Select.cjs +26 -178
  30. package/build/legacy/components/Select.cjs.map +1 -1
  31. package/build/legacy/components/Tag.cjs +16 -167
  32. package/build/legacy/components/Tag.cjs.map +1 -1
  33. package/build/legacy/components/Toggle.cjs +20 -172
  34. package/build/legacy/components/Toggle.cjs.map +1 -1
  35. package/build/legacy/config/defineIcons.cjs +3 -39
  36. package/build/legacy/config/defineIcons.cjs.map +1 -1
  37. package/build/legacy/config/{cerbIcons.cjs → index.cjs} +22 -29
  38. package/build/legacy/config/index.cjs.map +1 -0
  39. package/build/legacy/config/types.cjs +19 -0
  40. package/build/legacy/config/types.cjs.map +1 -0
  41. package/build/legacy/context/cerberus.cjs +46 -0
  42. package/build/legacy/context/cerberus.cjs.map +1 -0
  43. package/build/legacy/context/confirm-modal.cjs +58 -207
  44. package/build/legacy/context/confirm-modal.cjs.map +1 -1
  45. package/build/legacy/context/cta-modal.cjs +57 -209
  46. package/build/legacy/context/cta-modal.cjs.map +1 -1
  47. package/build/legacy/context/notification-center.cjs +55 -206
  48. package/build/legacy/context/notification-center.cjs.map +1 -1
  49. package/build/legacy/context/prompt-modal.cjs +83 -233
  50. package/build/legacy/context/prompt-modal.cjs.map +1 -1
  51. package/build/legacy/index.cjs +950 -930
  52. package/build/legacy/index.cjs.map +1 -1
  53. package/build/modern/_tsup-dts-rollup.d.ts +111 -34
  54. package/build/modern/{chunk-BVCXVZAF.js → chunk-25HMVHLT.js} +6 -5
  55. package/build/modern/chunk-25HMVHLT.js.map +1 -0
  56. package/build/modern/chunk-36N4527B.js +1 -0
  57. package/build/modern/chunk-5EWCH7AI.js +82 -0
  58. package/build/modern/chunk-5EWCH7AI.js.map +1 -0
  59. package/build/modern/chunk-5SNLQZYP.js +25 -0
  60. package/build/modern/chunk-5SNLQZYP.js.map +1 -0
  61. package/build/modern/{chunk-6BH5J5GF.js → chunk-CCTLGF5U.js} +18 -17
  62. package/build/modern/chunk-CCTLGF5U.js.map +1 -0
  63. package/build/modern/{chunk-HKJMLWVP.js → chunk-EDARV2EI.js} +5 -4
  64. package/build/modern/chunk-EDARV2EI.js.map +1 -0
  65. package/build/modern/{chunk-FXLLRVAM.js → chunk-EMNBMH7Z.js} +13 -11
  66. package/build/modern/chunk-EMNBMH7Z.js.map +1 -0
  67. package/build/modern/{chunk-PVIMOXSO.js → chunk-GCQMH4QA.js} +5 -4
  68. package/build/modern/chunk-GCQMH4QA.js.map +1 -0
  69. package/build/modern/chunk-GITT5645.js +20 -0
  70. package/build/modern/chunk-GITT5645.js.map +1 -0
  71. package/build/modern/{chunk-TJCFYL5W.js → chunk-IGHMP4WA.js} +1 -20
  72. package/build/modern/chunk-IGHMP4WA.js.map +1 -0
  73. package/build/modern/chunk-ISCJ542I.js +82 -0
  74. package/build/modern/chunk-ISCJ542I.js.map +1 -0
  75. package/build/modern/{chunk-HVKM54BA.js → chunk-IW3LIRDG.js} +1 -1
  76. package/build/modern/chunk-IW3LIRDG.js.map +1 -0
  77. package/build/modern/{chunk-KWJ5FKX7.js → chunk-JQCRDZNI.js} +8 -6
  78. package/build/modern/chunk-JQCRDZNI.js.map +1 -0
  79. package/build/modern/chunk-KDDPAJMR.js +9 -0
  80. package/build/modern/chunk-KDDPAJMR.js.map +1 -0
  81. package/build/modern/{chunk-JJZQGR7A.js → chunk-KF35CYT4.js} +8 -6
  82. package/build/modern/chunk-KF35CYT4.js.map +1 -0
  83. package/build/modern/{chunk-XOROL3JY.js → chunk-KKHL3ZO4.js} +5 -4
  84. package/build/modern/chunk-KKHL3ZO4.js.map +1 -0
  85. package/build/modern/{chunk-U36UZJGZ.js → chunk-MZ3UCDUL.js} +5 -4
  86. package/build/modern/chunk-MZ3UCDUL.js.map +1 -0
  87. package/build/modern/{chunk-T2JOPPGL.js → chunk-N24COMHJ.js} +11 -4
  88. package/build/modern/chunk-N24COMHJ.js.map +1 -0
  89. package/build/modern/{chunk-CVTON5DQ.js → chunk-N3L3PEMF.js} +2 -2
  90. package/build/modern/chunk-NJSETNRL.js +68 -0
  91. package/build/modern/chunk-NJSETNRL.js.map +1 -0
  92. package/build/modern/{chunk-XXWR7UGH.js → chunk-QKZZHZL4.js} +22 -21
  93. package/build/modern/chunk-QKZZHZL4.js.map +1 -0
  94. package/build/modern/{chunk-KPUYKHLW.js → chunk-UMF2TWZN.js} +59 -9
  95. package/build/modern/chunk-UMF2TWZN.js.map +1 -0
  96. package/build/modern/{chunk-QK7R2XJM.js → chunk-XQICKZH4.js} +6 -5
  97. package/build/modern/chunk-XQICKZH4.js.map +1 -0
  98. package/build/modern/chunk-XZGXRRSQ.js +31 -0
  99. package/build/modern/chunk-XZGXRRSQ.js.map +1 -0
  100. package/build/modern/{chunk-5OVH3INN.js → chunk-Z64YZ5IH.js} +18 -18
  101. package/build/modern/chunk-Z64YZ5IH.js.map +1 -0
  102. package/build/modern/components/Accordion.client.js +9 -0
  103. package/build/modern/components/Accordion.client.js.map +1 -0
  104. package/build/modern/components/Accordion.js +1 -7
  105. package/build/modern/components/AccordionItemGroup.js +4 -6
  106. package/build/modern/components/Admonition.client.js +11 -0
  107. package/build/modern/components/Admonition.client.js.map +1 -0
  108. package/build/modern/components/Admonition.js +4 -6
  109. package/build/modern/components/AnimatingUploadIcon.js +1 -1
  110. package/build/modern/components/Avatar.js +3 -5
  111. package/build/modern/components/Checkbox.js +2 -5
  112. package/build/modern/components/DatePicker.client.js +8 -7
  113. package/build/modern/components/DatePicker.server.js +3 -13
  114. package/build/modern/components/FileStatus.js +4 -7
  115. package/build/modern/components/FileUploader.js +3 -6
  116. package/build/modern/components/Input.js +2 -5
  117. package/build/modern/components/Notification.js +2 -5
  118. package/build/modern/components/Select.js +2 -5
  119. package/build/modern/components/Tag.js +3 -5
  120. package/build/modern/components/Toggle.js +2 -5
  121. package/build/modern/config/defineIcons.js +2 -5
  122. package/build/modern/config/index.js +14 -0
  123. package/build/modern/config/index.js.map +1 -0
  124. package/build/modern/config/types.js +2 -0
  125. package/build/modern/config/types.js.map +1 -0
  126. package/build/modern/context/cerberus.js +10 -0
  127. package/build/modern/context/cerberus.js.map +1 -0
  128. package/build/modern/context/confirm-modal.js +6 -9
  129. package/build/modern/context/cta-modal.js +6 -9
  130. package/build/modern/context/notification-center.js +3 -6
  131. package/build/modern/context/prompt-modal.js +8 -11
  132. package/build/modern/index.js +105 -94
  133. package/build/modern/index.js.map +1 -1
  134. package/package.json +4 -8
  135. package/src/components/Accordion.client.tsx +46 -0
  136. package/src/components/Accordion.tsx +0 -37
  137. package/src/components/AccordionItemGroup.tsx +1 -1
  138. package/src/components/Admonition.client.tsx +73 -0
  139. package/src/components/Admonition.tsx +1 -70
  140. package/src/components/AnimatingUploadIcon.tsx +3 -3
  141. package/src/components/Avatar.tsx +5 -2
  142. package/src/components/Checkbox.tsx +10 -3
  143. package/src/components/DatePicker.client.tsx +79 -7
  144. package/src/components/DatePicker.server.tsx +2 -75
  145. package/src/components/FileStatus.tsx +5 -3
  146. package/src/components/FileUploader.tsx +3 -2
  147. package/src/components/Input.tsx +4 -2
  148. package/src/components/Notification.tsx +7 -4
  149. package/src/components/Select.tsx +5 -2
  150. package/src/components/Tag.tsx +5 -2
  151. package/src/components/Toggle.tsx +4 -3
  152. package/src/config/defineIcons.ts +28 -16
  153. package/src/config/index.ts +28 -0
  154. package/src/config/types.ts +42 -0
  155. package/src/context/cerberus.tsx +44 -0
  156. package/src/context/confirm-modal.tsx +4 -2
  157. package/src/context/cta-modal.tsx +5 -4
  158. package/src/context/prompt-modal.tsx +4 -2
  159. package/src/index.ts +3 -1
  160. package/build/legacy/config/cerbIcons.cjs.map +0 -1
  161. package/build/modern/chunk-5OVH3INN.js.map +0 -1
  162. package/build/modern/chunk-6BH5J5GF.js.map +0 -1
  163. package/build/modern/chunk-BC5SZDYY.js +0 -132
  164. package/build/modern/chunk-BC5SZDYY.js.map +0 -1
  165. package/build/modern/chunk-BVCXVZAF.js.map +0 -1
  166. package/build/modern/chunk-CRII2HNX.js +0 -55
  167. package/build/modern/chunk-CRII2HNX.js.map +0 -1
  168. package/build/modern/chunk-FXLLRVAM.js.map +0 -1
  169. package/build/modern/chunk-HKJMLWVP.js.map +0 -1
  170. package/build/modern/chunk-HVKM54BA.js.map +0 -1
  171. package/build/modern/chunk-JJZQGR7A.js.map +0 -1
  172. package/build/modern/chunk-KPUYKHLW.js.map +0 -1
  173. package/build/modern/chunk-KWJ5FKX7.js.map +0 -1
  174. package/build/modern/chunk-PVIMOXSO.js.map +0 -1
  175. package/build/modern/chunk-QK7R2XJM.js.map +0 -1
  176. package/build/modern/chunk-QMF5ZNDG.js +0 -27
  177. package/build/modern/chunk-QMF5ZNDG.js.map +0 -1
  178. package/build/modern/chunk-QQOWWMZ3.js +0 -138
  179. package/build/modern/chunk-QQOWWMZ3.js.map +0 -1
  180. package/build/modern/chunk-T2JOPPGL.js.map +0 -1
  181. package/build/modern/chunk-TJCFYL5W.js.map +0 -1
  182. package/build/modern/chunk-U36UZJGZ.js.map +0 -1
  183. package/build/modern/chunk-XOROL3JY.js.map +0 -1
  184. package/build/modern/chunk-XXWR7UGH.js.map +0 -1
  185. package/build/modern/config/cerbIcons.js +0 -9
  186. package/src/config/cerbIcons.ts +0 -73
  187. /package/build/modern/{config/cerbIcons.js.map → chunk-36N4527B.js.map} +0 -0
  188. /package/build/modern/{chunk-CVTON5DQ.js.map → chunk-N3L3PEMF.js.map} +0 -0
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ "use client";
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -39,181 +40,29 @@ function Show(props) {
39
40
  var import_css = require("@cerberus/styled-system/css");
40
41
  var import_recipes = require("@cerberus/styled-system/recipes");
41
42
 
42
- // src/config/cerbIcons.ts
43
- var import_icons = require("@cerberus/icons");
44
-
45
- // src/config/icons/checkbox.icons.tsx
43
+ // src/context/cerberus.tsx
44
+ var import_react2 = require("react");
46
45
  var import_jsx_runtime = require("react/jsx-runtime");
47
- function CheckmarkIcon(props) {
48
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
49
- "svg",
50
- {
51
- "aria-hidden": "true",
52
- xmlns: "http://www.w3.org/2000/svg",
53
- fill: "none",
54
- role: "img",
55
- viewBox: "0 0 24 24",
56
- ...props,
57
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
58
- "path",
59
- {
60
- fill: "currentColor",
61
- d: "M9.714 18 4 12.335l1.818-1.764 3.896 3.824L18.181 6 20 7.803 9.714 18Z"
62
- }
63
- )
64
- }
65
- );
66
- }
67
- function IndeterminateIcon(props) {
68
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
69
- "svg",
70
- {
71
- "aria-hidden": "true",
72
- xmlns: "http://www.w3.org/2000/svg",
73
- role: "img",
74
- fill: "none",
75
- viewBox: "0 0 24 24",
76
- ...props,
77
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { fill: "currentColor", d: "M4 11h16v2.667H4z" })
78
- }
79
- );
80
- }
81
-
82
- // src/components/AnimatingUploadIcon.tsx
83
- var import_jsx_runtime2 = require("react/jsx-runtime");
84
- function AnimatingUploadIcon(props) {
85
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
86
- "svg",
87
- {
88
- "aria-hidden": "true",
89
- xmlns: "http://www.w3.org/2000/svg",
90
- width: props.size ?? "1em",
91
- height: props.size ?? "1em",
92
- viewBox: "0 0 24 24",
93
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
94
- "g",
95
- {
96
- fill: "none",
97
- stroke: "currentColor",
98
- strokeLinecap: "square",
99
- strokeLinejoin: "round",
100
- strokeWidth: 1.5,
101
- children: [
102
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
103
- "path",
104
- {
105
- "data-name": "animating-trail",
106
- strokeDasharray: "2 4",
107
- strokeDashoffset: 6,
108
- d: "M12 21c-4.97 0 -9 -4.03 -9 -9c0 -4.97 4.03 -9 9 -9",
109
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
110
- "animate",
111
- {
112
- attributeName: "stroke-dashoffset",
113
- dur: "0.45s",
114
- repeatCount: "indefinite",
115
- values: "6;0"
116
- }
117
- )
118
- }
119
- ),
120
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
121
- "path",
122
- {
123
- "data-name": "half-circle",
124
- strokeDasharray: 32,
125
- strokeDashoffset: 32,
126
- d: "M12 3c4.97 0 9 4.03 9 9c0 4.97 -4.03 9 -9 9",
127
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
128
- "animate",
129
- {
130
- fill: "freeze",
131
- attributeName: "stroke-dashoffset",
132
- begin: "0.075s",
133
- dur: "0.3s",
134
- values: "32;0"
135
- }
136
- )
137
- }
138
- ),
139
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
140
- "svg",
141
- {
142
- "aria-hidden": "true",
143
- xmlns: "http://www.w3.org/2000/svg",
144
- width: "0.8em",
145
- height: "0.8em",
146
- x: "27%",
147
- y: "27%",
148
- viewBox: "0 0 24 24",
149
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
150
- "polygon",
151
- {
152
- fill: "currentColor",
153
- stroke: "currentColor",
154
- strokeWidth: 0.8,
155
- opacity: "1",
156
- points: "3.7,6.7 7.5,2.9 7.5,15 8.5,15 8.5,2.9 12.3,6.7 13,6 8,1 3,6 ",
157
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
158
- "animate",
159
- {
160
- fill: "freeze",
161
- attributeName: "opacity",
162
- values: "1;0;1",
163
- dur: "2s",
164
- repeatCount: "indefinite"
165
- }
166
- )
167
- }
168
- )
169
- }
170
- )
171
- ]
172
- }
173
- )
174
- }
175
- );
46
+ var CerberusContext = (0, import_react2.createContext)(null);
47
+ function useCerberusContext() {
48
+ const context = (0, import_react2.useContext)(CerberusContext);
49
+ if (!context) {
50
+ throw new Error("useCerberus must be used within a CerberusProvider");
51
+ }
52
+ return context;
176
53
  }
177
54
 
178
- // src/config/cerbIcons.ts
179
- var defaultIcons = {
180
- accordionIndicator: import_icons.ChevronDown,
181
- avatar: import_icons.UserFilled,
182
- calendar: import_icons.Calendar,
183
- calendarPrev: import_icons.ChevronLeft,
184
- calendarNext: import_icons.ChevronRight,
185
- checkbox: CheckmarkIcon,
186
- close: import_icons.Close,
187
- confirmModal: import_icons.Information,
188
- delete: import_icons.TrashCan,
189
- promptModal: import_icons.Information,
190
- waitingFileUploader: import_icons.CloudUpload,
191
- fileUploader: AnimatingUploadIcon,
192
- indeterminate: IndeterminateIcon,
193
- infoNotification: import_icons.Information,
194
- successNotification: import_icons.CheckmarkOutline,
195
- warningNotification: import_icons.WarningAlt,
196
- dangerNotification: import_icons.WarningFilled,
197
- invalid: import_icons.WarningFilled,
198
- invalidAlt: import_icons.Warning,
199
- redo: import_icons.Restart,
200
- selectArrow: import_icons.ChevronDown,
201
- toggleChecked: import_icons.Checkmark
202
- };
203
-
204
- // src/config/defineIcons.ts
205
- var $cerberusIcons = defaultIcons;
206
-
207
55
  // src/components/Tag.tsx
208
- var import_jsx_runtime3 = require("react/jsx-runtime");
56
+ var import_jsx_runtime2 = require("react/jsx-runtime");
209
57
  function Tag(props) {
210
58
  const { shape: initShape, gradient, onClick, usage, ...nativeProps } = props;
211
59
  const palette = (props == null ? void 0 : props.palette) ?? "page";
212
60
  const isClosable = Boolean(onClick);
213
61
  const shape = isClosable ? "pill" : initShape;
214
62
  const closableStyles = isClosable ? closableCss : "";
215
- const { close: Close2 } = $cerberusIcons;
216
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
63
+ const { icons } = useCerberusContext();
64
+ const { close: Close } = icons;
65
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
217
66
  "span",
218
67
  {
219
68
  ...nativeProps,
@@ -229,7 +78,7 @@ function Tag(props) {
229
78
  ),
230
79
  children: [
231
80
  props.children,
232
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Show, { when: isClosable, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
81
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Show, { when: isClosable, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
233
82
  "button",
234
83
  {
235
84
  "aria-label": "Close",
@@ -239,7 +88,7 @@ function Tag(props) {
239
88
  size: "sm"
240
89
  }),
241
90
  onClick,
242
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Close2, {})
91
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Close, {})
243
92
  }
244
93
  ) })
245
94
  ]
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Tag.tsx","../../../src/components/Show.tsx","../../../src/config/cerbIcons.ts","../../../src/config/icons/checkbox.icons.tsx","../../../src/components/AnimatingUploadIcon.tsx","../../../src/config/defineIcons.ts"],"sourcesContent":["import type {\n HTMLAttributes,\n MouseEventHandler,\n PropsWithChildren,\n} from 'react'\nimport { Show } from './Show'\nimport { css, cx } from '@cerberus/styled-system/css'\nimport {\n iconButton,\n tag,\n type TagVariantProps,\n} from '@cerberus/styled-system/recipes'\nimport { $cerberusIcons } from '../config/defineIcons'\n\n/**\n * This module contains the tag component.\n * @module\n */\n\nexport type StaticTagProps = HTMLAttributes<HTMLSpanElement> &\n TagVariantProps & {\n /**\n * The action to be performed when the tag is clicked. Not available when\n * the palette or gradient props are provided.\n */\n onClick?: never\n }\n\nexport type ClickableTagProps = HTMLAttributes<HTMLSpanElement> & {\n /**\n * The gradient to apply to the tag. Not available when the onClick prop is\n * provided.\n */\n gradient?: never\n /**\n * The palette to use for the tag. Not available when the onClick prop is\n * provided.\n */\n palette?: never\n /**\n * The action to be performed when the tag is clicked.\n */\n onClick: MouseEventHandler<HTMLSpanElement>\n /**\n * The shape of the tag. Not available when the onClick prop is provided.\n * @type 'pill' | 'rounded'\n * @default 'pill'\n */\n shape?: never\n /**\n * The usage of the tag. Not available when the onClick prop is provided.\n * @type 'filled' | 'outlined'\n * @default 'filled'\n */\n usage?: never\n}\n\nexport type TagProps = StaticTagProps | ClickableTagProps\n\n/**\n * The Tag component is used to display a meta descriptions.\n * @see https://cerberus.digitalu.design/react/tag\n * @example\n * ```tsx\n * <Tag>Tag</Tag>\n * ```\n */\nexport function Tag(props: PropsWithChildren<TagProps>): JSX.Element {\n const { shape: initShape, gradient, onClick, usage, ...nativeProps } = props\n const palette = props?.palette ?? 'page'\n const isClosable = Boolean(onClick)\n const shape = isClosable ? 'pill' : initShape\n const closableStyles = isClosable ? closableCss : ''\n const { close: Close } = $cerberusIcons\n\n return (\n <span\n {...nativeProps}\n className={cx(\n nativeProps.className,\n tag({\n gradient,\n palette,\n shape,\n usage,\n }),\n closableStyles,\n )}\n >\n {props.children}\n\n <Show when={isClosable}>\n <button\n aria-label=\"Close\"\n className={iconButton({\n palette: 'action',\n usage: 'filled',\n size: 'sm',\n })}\n onClick={onClick}\n >\n <Close />\n </button>\n </Show>\n </span>\n )\n}\n\nconst closableCss = css({\n bgColor: 'action.bg.active',\n color: 'action.text.initial',\n paddingInlineEnd: '0',\n})\n","'use client'\n\nimport { useMemo, type PropsWithChildren, type ReactNode } from 'react'\n\n/**\n * This module contains the Show component.\n * @module\n */\n\nexport interface ShowProps {\n /**\n * The condition to render memoized children or the fallback content.\n */\n when: boolean | null | undefined\n /**\n * The children to render when the condition is false.\n */\n fallback?: ReactNode\n}\n\n/**\n * Conditionally render a memoized version of the children or optional fallback\n * content.\n * @see https://cerberus.digitalu.design/react/show\n * @example\n * ```tsx\n * <Show when={isLoggedIn} fallback={<Navigate to=\"/login\" />}>\n * <Dashboard />\n * </Show>\n */\nexport function Show(props: PropsWithChildren<ShowProps>): ReactNode {\n const { when, children, fallback } = props\n const condition = useMemo(() => when ?? false, [when])\n\n return useMemo(() => {\n if (condition) return children\n return fallback ?? null\n }, [condition, children, fallback])\n}\n","import {\n Calendar,\n Checkmark,\n CheckmarkOutline,\n ChevronDown,\n ChevronLeft,\n ChevronRight,\n Close,\n CloudUpload,\n Information,\n Restart,\n TrashCan,\n UserFilled,\n Warning,\n WarningAlt,\n WarningFilled,\n type CarbonIconType,\n} from '@cerberus/icons'\nimport type { ElementType } from 'react'\nimport { CheckmarkIcon, IndeterminateIcon } from './icons/checkbox.icons'\nimport { AnimatingUploadIcon } from '../components/AnimatingUploadIcon'\n\nexport type IconType = CarbonIconType | ElementType\n\nexport interface DefinedIcons {\n accordionIndicator?: IconType\n avatar?: IconType\n calendar?: IconType\n calendarPrev?: IconType\n calendarNext?: IconType\n checkbox?: IconType\n close?: IconType\n confirmModal?: IconType\n delete?: IconType\n promptModal?: IconType\n waitingFileUploader?: IconType\n fileUploader?: IconType\n indeterminate?: IconType\n infoNotification?: IconType\n successNotification?: IconType\n warningNotification?: IconType\n dangerNotification?: IconType\n invalid: IconType\n invalidAlt?: IconType\n redo?: IconType\n selectArrow?: IconType\n toggleChecked?: IconType\n}\n\nexport const defaultIcons: DefinedIcons = {\n accordionIndicator: ChevronDown,\n avatar: UserFilled,\n calendar: Calendar,\n calendarPrev: ChevronLeft,\n calendarNext: ChevronRight,\n checkbox: CheckmarkIcon,\n close: Close,\n confirmModal: Information,\n delete: TrashCan,\n promptModal: Information,\n waitingFileUploader: CloudUpload,\n fileUploader: AnimatingUploadIcon,\n indeterminate: IndeterminateIcon,\n infoNotification: Information,\n successNotification: CheckmarkOutline,\n warningNotification: WarningAlt,\n dangerNotification: WarningFilled,\n invalid: WarningFilled,\n invalidAlt: Warning,\n redo: Restart,\n selectArrow: ChevronDown,\n toggleChecked: Checkmark,\n}\n","import type { SVGProps } from 'react'\n\n/**\n * This module contains substitute icons for the Checkbox component.\n * @module\n */\n\nexport type CheckboxIconProps = SVGProps<SVGSVGElement>\n\n/**\n * Checkmark icon for Checkbox component\n */\nexport function CheckmarkIcon(props: CheckboxIconProps) {\n return (\n <svg\n aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n role=\"img\"\n viewBox=\"0 0 24 24\"\n {...props}\n >\n <path\n fill=\"currentColor\"\n d=\"M9.714 18 4 12.335l1.818-1.764 3.896 3.824L18.181 6 20 7.803 9.714 18Z\"\n />\n </svg>\n )\n}\n\nexport type IndeterminateIconProps = SVGProps<SVGSVGElement>\n\n/**\n * Indeterminate icon for Checkbox component\n */\nexport function IndeterminateIcon(props: IndeterminateIconProps) {\n return (\n <svg\n aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/2000/svg\"\n role=\"img\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n {...props}\n >\n <path fill=\"currentColor\" d=\"M4 11h16v2.667H4z\" />\n </svg>\n )\n}\n","import { type CarbonIconProps } from '@cerberus/icons'\n\n/**\n * This module contains an animating icon to use for the FileStatus component.\n * @module\n */\n\nexport type AnimatingUploadIconProps = CarbonIconProps\n\nexport function AnimatingUploadIcon(props: AnimatingUploadIconProps) {\n return (\n <svg\n aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width={props.size ?? '1em'}\n height={props.size ?? '1em'}\n viewBox=\"0 0 24 24\"\n >\n <g\n fill=\"none\"\n stroke=\"currentColor\"\n strokeLinecap=\"square\"\n strokeLinejoin=\"round\"\n strokeWidth={1.5}\n >\n <path\n data-name=\"animating-trail\"\n strokeDasharray=\"2 4\"\n strokeDashoffset={6}\n d=\"M12 21c-4.97 0 -9 -4.03 -9 -9c0 -4.97 4.03 -9 9 -9\"\n >\n <animate\n attributeName=\"stroke-dashoffset\"\n dur=\"0.45s\"\n repeatCount=\"indefinite\"\n values=\"6;0\"\n ></animate>\n </path>\n\n <path\n data-name=\"half-circle\"\n strokeDasharray={32}\n strokeDashoffset={32}\n d=\"M12 3c4.97 0 9 4.03 9 9c0 4.97 -4.03 9 -9 9\"\n >\n <animate\n fill=\"freeze\"\n attributeName=\"stroke-dashoffset\"\n begin=\"0.075s\"\n dur=\"0.3s\"\n values=\"32;0\"\n ></animate>\n </path>\n\n <svg\n aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"0.8em\"\n height=\"0.8em\"\n x=\"27%\"\n y=\"27%\"\n viewBox=\"0 0 24 24\"\n >\n <polygon\n fill=\"currentColor\"\n stroke=\"currentColor\"\n strokeWidth={0.8}\n opacity=\"1\"\n points=\"3.7,6.7 7.5,2.9 7.5,15 8.5,15 8.5,2.9 12.3,6.7 13,6 8,1 3,6 \"\n >\n <animate\n fill=\"freeze\"\n attributeName=\"opacity\"\n values=\"1;0;1\"\n dur=\"2s\"\n repeatCount=\"indefinite\"\n ></animate>\n </polygon>\n </svg>\n </g>\n </svg>\n )\n}\n","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): Required<DefinedIcons> {\n _validateIconsProperties(icons)\n $cerberusIcons = {\n ...defaultIcons,\n ...icons,\n } as Required<DefinedIcons>\n return $cerberusIcons\n}\n\n// Default icons\n\nexport let $cerberusIcons = defaultIcons as Required<DefinedIcons>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,mBAAgE;AA4BzD,SAAS,KAAK,OAAgD;AACnE,QAAM,EAAE,MAAM,UAAU,SAAS,IAAI;AACrC,QAAM,gBAAY,sBAAQ,MAAM,QAAQ,OAAO,CAAC,IAAI,CAAC;AAErD,aAAO,sBAAQ,MAAM;AACnB,QAAI,UAAW,QAAO;AACtB,WAAO,YAAY;AAAA,EACrB,GAAG,CAAC,WAAW,UAAU,QAAQ,CAAC;AACpC;;;ADhCA,iBAAwB;AACxB,qBAIO;;;AEXP,mBAiBO;;;ACKD;AAVC,SAAS,cAAc,OAA0B;AACtD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,eAAY;AAAA,MACZ,OAAM;AAAA,MACN,MAAK;AAAA,MACL,MAAK;AAAA,MACL,SAAQ;AAAA,MACP,GAAG;AAAA,MAEJ;AAAA,QAAC;AAAA;AAAA,UACC,MAAK;AAAA,UACL,GAAE;AAAA;AAAA,MACJ;AAAA;AAAA,EAC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;AAAA,QACF,CAAC;AAAA,QACD;AAAA,MACF;AAAA,MAEC;AAAA,cAAM;AAAA,QAEP,6CAAC,QAAK,MAAM,YACV;AAAA,UAAC;AAAA;AAAA,YACC,cAAW;AAAA,YACX,eAAW,2BAAW;AAAA,cACpB,SAAS;AAAA,cACT,OAAO;AAAA,cACP,MAAM;AAAA,YACR,CAAC;AAAA,YACD;AAAA,YAEA,uDAACA,QAAA,EAAM;AAAA;AAAA,QACT,GACF;AAAA;AAAA;AAAA,EACF;AAEJ;AAEA,IAAM,kBAAc,gBAAI;AAAA,EACtB,SAAS;AAAA,EACT,OAAO;AAAA,EACP,kBAAkB;AACpB,CAAC;","names":["import_jsx_runtime","import_jsx_runtime","Close"]}
1
+ {"version":3,"sources":["../../../src/components/Tag.tsx","../../../src/components/Show.tsx","../../../src/context/cerberus.tsx"],"sourcesContent":["'use client'\n\nimport type {\n HTMLAttributes,\n MouseEventHandler,\n PropsWithChildren,\n} from 'react'\nimport { Show } from './Show'\nimport { css, cx } from '@cerberus/styled-system/css'\nimport {\n iconButton,\n tag,\n type TagVariantProps,\n} from '@cerberus/styled-system/recipes'\nimport { useCerberusContext } from '../context/cerberus'\n\n/**\n * This module contains the tag component.\n * @module\n */\n\nexport type StaticTagProps = HTMLAttributes<HTMLSpanElement> &\n TagVariantProps & {\n /**\n * The action to be performed when the tag is clicked. Not available when\n * the palette or gradient props are provided.\n */\n onClick?: never\n }\n\nexport type ClickableTagProps = HTMLAttributes<HTMLSpanElement> & {\n /**\n * The gradient to apply to the tag. Not available when the onClick prop is\n * provided.\n */\n gradient?: never\n /**\n * The palette to use for the tag. Not available when the onClick prop is\n * provided.\n */\n palette?: never\n /**\n * The action to be performed when the tag is clicked.\n */\n onClick: MouseEventHandler<HTMLSpanElement>\n /**\n * The shape of the tag. Not available when the onClick prop is provided.\n * @type 'pill' | 'rounded'\n * @default 'pill'\n */\n shape?: never\n /**\n * The usage of the tag. Not available when the onClick prop is provided.\n * @type 'filled' | 'outlined'\n * @default 'filled'\n */\n usage?: never\n}\n\nexport type TagProps = StaticTagProps | ClickableTagProps\n\n/**\n * The Tag component is used to display a meta descriptions.\n * @see https://cerberus.digitalu.design/react/tag\n * @example\n * ```tsx\n * <Tag>Tag</Tag>\n * ```\n */\nexport function Tag(props: PropsWithChildren<TagProps>): JSX.Element {\n const { shape: initShape, gradient, onClick, usage, ...nativeProps } = props\n const palette = props?.palette ?? 'page'\n const isClosable = Boolean(onClick)\n const shape = isClosable ? 'pill' : initShape\n const closableStyles = isClosable ? closableCss : ''\n const { icons } = useCerberusContext()\n const { close: Close } = icons\n\n return (\n <span\n {...nativeProps}\n className={cx(\n nativeProps.className,\n tag({\n gradient,\n palette,\n shape,\n usage,\n }),\n closableStyles,\n )}\n >\n {props.children}\n\n <Show when={isClosable}>\n <button\n aria-label=\"Close\"\n className={iconButton({\n palette: 'action',\n usage: 'filled',\n size: 'sm',\n })}\n onClick={onClick}\n >\n <Close />\n </button>\n </Show>\n </span>\n )\n}\n\nconst closableCss = css({\n bgColor: 'action.bg.active',\n color: 'action.text.initial',\n paddingInlineEnd: '0',\n})\n","'use client'\n\nimport { useMemo, type PropsWithChildren, type ReactNode } from 'react'\n\n/**\n * This module contains the Show component.\n * @module\n */\n\nexport interface ShowProps {\n /**\n * The condition to render memoized children or the fallback content.\n */\n when: boolean | null | undefined\n /**\n * The children to render when the condition is false.\n */\n fallback?: ReactNode\n}\n\n/**\n * Conditionally render a memoized version of the children or optional fallback\n * content.\n * @see https://cerberus.digitalu.design/react/show\n * @example\n * ```tsx\n * <Show when={isLoggedIn} fallback={<Navigate to=\"/login\" />}>\n * <Dashboard />\n * </Show>\n */\nexport function Show(props: PropsWithChildren<ShowProps>): ReactNode {\n const { when, children, fallback } = props\n const condition = useMemo(() => when ?? false, [when])\n\n return useMemo(() => {\n if (condition) return children\n return fallback ?? null\n }, [condition, children, fallback])\n}\n","'use client'\n\nimport { createContext, useContext, type PropsWithChildren } from 'react'\nimport type { SystemConfig } from '../config'\n\n/**\n * This module contains the Cerberus configuration context and helpers.\n * @module context/cerberus\n */\n\ntype CerberusContextValue = SystemConfig\n\nconst CerberusContext = createContext<CerberusContextValue | null>(null)\n\ninterface CerberusProviderProps {\n config: SystemConfig\n}\n\n/**\n * Cerberus configuration provider.\n * @param props.config The Cerberus configuration created with\n * `makeSystemConfig` helper.\n */\nexport function CerberusProvider(\n props: PropsWithChildren<CerberusProviderProps>,\n) {\n return (\n <CerberusContext.Provider value={props.config}>\n {props.children}\n </CerberusContext.Provider>\n )\n}\n\n/**\n * Returns the Cerberus configuration context.\n * @returns The Cerberus configuration context.\n */\nexport function useCerberusContext() {\n const context = useContext(CerberusContext)\n if (!context) {\n throw new Error('useCerberus must be used within a CerberusProvider')\n }\n return context\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,mBAAgE;AA4BzD,SAAS,KAAK,OAAgD;AACnE,QAAM,EAAE,MAAM,UAAU,SAAS,IAAI;AACrC,QAAM,gBAAY,sBAAQ,MAAM,QAAQ,OAAO,CAAC,IAAI,CAAC;AAErD,aAAO,sBAAQ,MAAM;AACnB,QAAI,UAAW,QAAO;AACtB,WAAO,YAAY;AAAA,EACrB,GAAG,CAAC,WAAW,UAAU,QAAQ,CAAC;AACpC;;;AD9BA,iBAAwB;AACxB,qBAIO;;;AEXP,IAAAA,gBAAkE;AAyB9D;AAfJ,IAAM,sBAAkB,6BAA2C,IAAI;AAyBhE,SAAS,qBAAqB;AACnC,QAAM,cAAU,0BAAW,eAAe;AAC1C,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,oDAAoD;AAAA,EACtE;AACA,SAAO;AACT;;;AFoCI,IAAAC,sBAAA;AAVG,SAAS,IAAI,OAAiD;AACnE,QAAM,EAAE,OAAO,WAAW,UAAU,SAAS,OAAO,GAAG,YAAY,IAAI;AACvE,QAAM,WAAU,+BAAO,YAAW;AAClC,QAAM,aAAa,QAAQ,OAAO;AAClC,QAAM,QAAQ,aAAa,SAAS;AACpC,QAAM,iBAAiB,aAAa,cAAc;AAClD,QAAM,EAAE,MAAM,IAAI,mBAAmB;AACrC,QAAM,EAAE,OAAO,MAAM,IAAI;AAEzB,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,eAAW;AAAA,QACT,YAAY;AAAA,YACZ,oBAAI;AAAA,UACF;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF,CAAC;AAAA,QACD;AAAA,MACF;AAAA,MAEC;AAAA,cAAM;AAAA,QAEP,6CAAC,QAAK,MAAM,YACV;AAAA,UAAC;AAAA;AAAA,YACC,cAAW;AAAA,YACX,eAAW,2BAAW;AAAA,cACpB,SAAS;AAAA,cACT,OAAO;AAAA,cACP,MAAM;AAAA,YACR,CAAC;AAAA,YACD;AAAA,YAEA,uDAAC,SAAM;AAAA;AAAA,QACT,GACF;AAAA;AAAA;AAAA,EACF;AAEJ;AAEA,IAAM,kBAAc,gBAAI;AAAA,EACtB,SAAS;AAAA,EACT,OAAO;AAAA,EACP,kBAAkB;AACpB,CAAC;","names":["import_react","import_jsx_runtime"]}
@@ -28,174 +28,9 @@ var import_css = require("@cerberus/styled-system/css");
28
28
  var import_patterns = require("@cerberus/styled-system/patterns");
29
29
  var import_recipes = require("@cerberus/styled-system/recipes");
30
30
 
31
- // src/config/cerbIcons.ts
32
- var import_icons = require("@cerberus/icons");
33
-
34
- // src/config/icons/checkbox.icons.tsx
35
- var import_jsx_runtime = require("react/jsx-runtime");
36
- function CheckmarkIcon(props) {
37
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
38
- "svg",
39
- {
40
- "aria-hidden": "true",
41
- xmlns: "http://www.w3.org/2000/svg",
42
- fill: "none",
43
- role: "img",
44
- viewBox: "0 0 24 24",
45
- ...props,
46
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
47
- "path",
48
- {
49
- fill: "currentColor",
50
- d: "M9.714 18 4 12.335l1.818-1.764 3.896 3.824L18.181 6 20 7.803 9.714 18Z"
51
- }
52
- )
53
- }
54
- );
55
- }
56
- function IndeterminateIcon(props) {
57
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
58
- "svg",
59
- {
60
- "aria-hidden": "true",
61
- xmlns: "http://www.w3.org/2000/svg",
62
- role: "img",
63
- fill: "none",
64
- viewBox: "0 0 24 24",
65
- ...props,
66
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { fill: "currentColor", d: "M4 11h16v2.667H4z" })
67
- }
68
- );
69
- }
70
-
71
- // src/components/AnimatingUploadIcon.tsx
72
- var import_jsx_runtime2 = require("react/jsx-runtime");
73
- function AnimatingUploadIcon(props) {
74
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
75
- "svg",
76
- {
77
- "aria-hidden": "true",
78
- xmlns: "http://www.w3.org/2000/svg",
79
- width: props.size ?? "1em",
80
- height: props.size ?? "1em",
81
- viewBox: "0 0 24 24",
82
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
83
- "g",
84
- {
85
- fill: "none",
86
- stroke: "currentColor",
87
- strokeLinecap: "square",
88
- strokeLinejoin: "round",
89
- strokeWidth: 1.5,
90
- children: [
91
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
92
- "path",
93
- {
94
- "data-name": "animating-trail",
95
- strokeDasharray: "2 4",
96
- strokeDashoffset: 6,
97
- d: "M12 21c-4.97 0 -9 -4.03 -9 -9c0 -4.97 4.03 -9 9 -9",
98
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
99
- "animate",
100
- {
101
- attributeName: "stroke-dashoffset",
102
- dur: "0.45s",
103
- repeatCount: "indefinite",
104
- values: "6;0"
105
- }
106
- )
107
- }
108
- ),
109
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
110
- "path",
111
- {
112
- "data-name": "half-circle",
113
- strokeDasharray: 32,
114
- strokeDashoffset: 32,
115
- d: "M12 3c4.97 0 9 4.03 9 9c0 4.97 -4.03 9 -9 9",
116
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
117
- "animate",
118
- {
119
- fill: "freeze",
120
- attributeName: "stroke-dashoffset",
121
- begin: "0.075s",
122
- dur: "0.3s",
123
- values: "32;0"
124
- }
125
- )
126
- }
127
- ),
128
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
129
- "svg",
130
- {
131
- "aria-hidden": "true",
132
- xmlns: "http://www.w3.org/2000/svg",
133
- width: "0.8em",
134
- height: "0.8em",
135
- x: "27%",
136
- y: "27%",
137
- viewBox: "0 0 24 24",
138
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
139
- "polygon",
140
- {
141
- fill: "currentColor",
142
- stroke: "currentColor",
143
- strokeWidth: 0.8,
144
- opacity: "1",
145
- points: "3.7,6.7 7.5,2.9 7.5,15 8.5,15 8.5,2.9 12.3,6.7 13,6 8,1 3,6 ",
146
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
147
- "animate",
148
- {
149
- fill: "freeze",
150
- attributeName: "opacity",
151
- values: "1;0;1",
152
- dur: "2s",
153
- repeatCount: "indefinite"
154
- }
155
- )
156
- }
157
- )
158
- }
159
- )
160
- ]
161
- }
162
- )
163
- }
164
- );
165
- }
166
-
167
- // src/config/cerbIcons.ts
168
- var defaultIcons = {
169
- accordionIndicator: import_icons.ChevronDown,
170
- avatar: import_icons.UserFilled,
171
- calendar: import_icons.Calendar,
172
- calendarPrev: import_icons.ChevronLeft,
173
- calendarNext: import_icons.ChevronRight,
174
- checkbox: CheckmarkIcon,
175
- close: import_icons.Close,
176
- confirmModal: import_icons.Information,
177
- delete: import_icons.TrashCan,
178
- promptModal: import_icons.Information,
179
- waitingFileUploader: import_icons.CloudUpload,
180
- fileUploader: AnimatingUploadIcon,
181
- indeterminate: IndeterminateIcon,
182
- infoNotification: import_icons.Information,
183
- successNotification: import_icons.CheckmarkOutline,
184
- warningNotification: import_icons.WarningAlt,
185
- dangerNotification: import_icons.WarningFilled,
186
- invalid: import_icons.WarningFilled,
187
- invalidAlt: import_icons.Warning,
188
- redo: import_icons.Restart,
189
- selectArrow: import_icons.ChevronDown,
190
- toggleChecked: import_icons.Checkmark
191
- };
192
-
193
- // src/config/defineIcons.ts
194
- var $cerberusIcons = defaultIcons;
195
-
196
31
  // src/context/field.tsx
197
32
  var import_react = require("react");
198
- var import_jsx_runtime3 = require("react/jsx-runtime");
33
+ var import_jsx_runtime = require("react/jsx-runtime");
199
34
  var FieldContext = (0, import_react.createContext)(null);
200
35
  function useFieldContext() {
201
36
  const context = (0, import_react.useContext)(FieldContext);
@@ -205,20 +40,33 @@ function useFieldContext() {
205
40
  return context;
206
41
  }
207
42
 
43
+ // src/context/cerberus.tsx
44
+ var import_react2 = require("react");
45
+ var import_jsx_runtime2 = require("react/jsx-runtime");
46
+ var CerberusContext = (0, import_react2.createContext)(null);
47
+ function useCerberusContext() {
48
+ const context = (0, import_react2.useContext)(CerberusContext);
49
+ if (!context) {
50
+ throw new Error("useCerberus must be used within a CerberusProvider");
51
+ }
52
+ return context;
53
+ }
54
+
208
55
  // src/components/Toggle.tsx
209
- var import_jsx_runtime4 = require("react/jsx-runtime");
56
+ var import_jsx_runtime3 = require("react/jsx-runtime");
210
57
  function Toggle(props) {
211
58
  const { size, describedBy, ...nativeProps } = props;
212
59
  const styles = (0, import_recipes.toggle)({ size });
213
60
  const { invalid, ...state } = useFieldContext();
214
- const Icon = $cerberusIcons.toggleChecked;
215
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
61
+ const { icons } = useCerberusContext();
62
+ const CheckedIcon = icons.toggleChecked;
63
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
216
64
  "span",
217
65
  {
218
66
  className: (0, import_css.cx)("group", styles.track, (0, import_patterns.hstack)()),
219
67
  "data-checked": props.checked || props.defaultChecked,
220
68
  children: [
221
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
69
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
222
70
  "input",
223
71
  {
224
72
  ...nativeProps,
@@ -230,7 +78,7 @@ function Toggle(props) {
230
78
  type: "checkbox"
231
79
  }
232
80
  ),
233
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
81
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
234
82
  "span",
235
83
  {
236
84
  className: (0, import_css.cx)(
@@ -239,7 +87,7 @@ function Toggle(props) {
239
87
  justify: "center"
240
88
  })
241
89
  ),
242
- children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, {})
90
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CheckedIcon, {})
243
91
  }
244
92
  )
245
93
  ]
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Toggle.tsx","../../../src/config/cerbIcons.ts","../../../src/config/icons/checkbox.icons.tsx","../../../src/components/AnimatingUploadIcon.tsx","../../../src/config/defineIcons.ts","../../../src/context/field.tsx"],"sourcesContent":["'use client'\n\nimport { cx } from '@cerberus/styled-system/css'\nimport { hstack, vstack } from '@cerberus/styled-system/patterns'\nimport {\n toggle,\n type ToggleVariantProps,\n} from '@cerberus/styled-system/recipes'\nimport type { InputHTMLAttributes } from 'react'\nimport { $cerberusIcons } from '../config/defineIcons'\nimport { useFieldContext } from '../context/field'\n\n/**\n * This module provides a toggle component.\n * @module\n */\n\nexport type ToggleBase = Omit<\n InputHTMLAttributes<HTMLInputElement>,\n 'size' | 'id' | 'value'\n> & {\n /**\n * The FieldMessage providing context for the Toggle.\n */\n describedBy?: string\n /**\n * A unique identifier for the Toggle. Required for accessibility.\n */\n id: string\n /**\n * The value of the Toggle.\n */\n value: string\n}\nexport type ToggleProps = ToggleBase & ToggleVariantProps\n\n/**\n * The Toggle component is used to switch between two states. Optionally\n * combine with the `useToggle` hook.\n * @see https://cerberus.digitalu.design/react/toggle\n * @example\n * ```tsx\n * const { checked, handleChange } = useToggle({ checked: 'toggle' })\n *\n * <Hstack justify=\"space-between\" w=\"full\">\n * <Field>\n * <Label htmlFor=\"toggle\">Show notifications</Label>\n * <Toggle\n * checked={checked === 'toggle'}\n * id=\"toggle\"\n * onChange={handleChange}\n * value=\"toggle\"\n * />\n * </Field>\n * </Hstack>\n * ```\n */\nexport function Toggle(props: ToggleProps) {\n const { size, describedBy, ...nativeProps } = props\n const styles = toggle({ size })\n const { invalid, ...state } = useFieldContext()\n const Icon = $cerberusIcons.toggleChecked\n\n return (\n <span\n className={cx('group', styles.track, hstack())}\n data-checked={props.checked || props.defaultChecked}\n >\n <input\n {...nativeProps}\n {...state}\n {...(describedBy && { 'aria-describedby': describedBy })}\n {...(invalid && { 'aria-invalid': true })}\n className={cx('peer', styles.input)}\n role=\"switch\"\n type=\"checkbox\"\n />\n <span\n className={cx(\n styles.thumb,\n vstack({\n justify: 'center',\n }),\n )}\n >\n <Icon />\n </span>\n </span>\n )\n}\n","import {\n Calendar,\n Checkmark,\n CheckmarkOutline,\n ChevronDown,\n ChevronLeft,\n ChevronRight,\n Close,\n CloudUpload,\n Information,\n Restart,\n TrashCan,\n UserFilled,\n Warning,\n WarningAlt,\n WarningFilled,\n type CarbonIconType,\n} from '@cerberus/icons'\nimport type { ElementType } from 'react'\nimport { CheckmarkIcon, IndeterminateIcon } from './icons/checkbox.icons'\nimport { AnimatingUploadIcon } from '../components/AnimatingUploadIcon'\n\nexport type IconType = CarbonIconType | ElementType\n\nexport interface DefinedIcons {\n accordionIndicator?: IconType\n avatar?: IconType\n calendar?: IconType\n calendarPrev?: IconType\n calendarNext?: IconType\n checkbox?: IconType\n close?: IconType\n confirmModal?: IconType\n delete?: IconType\n promptModal?: IconType\n waitingFileUploader?: IconType\n fileUploader?: IconType\n indeterminate?: IconType\n infoNotification?: IconType\n successNotification?: IconType\n warningNotification?: IconType\n dangerNotification?: IconType\n invalid: IconType\n invalidAlt?: IconType\n redo?: IconType\n selectArrow?: IconType\n toggleChecked?: IconType\n}\n\nexport const defaultIcons: DefinedIcons = {\n accordionIndicator: ChevronDown,\n avatar: UserFilled,\n calendar: Calendar,\n calendarPrev: ChevronLeft,\n calendarNext: ChevronRight,\n checkbox: CheckmarkIcon,\n close: Close,\n confirmModal: Information,\n delete: TrashCan,\n promptModal: Information,\n waitingFileUploader: CloudUpload,\n fileUploader: AnimatingUploadIcon,\n indeterminate: IndeterminateIcon,\n infoNotification: Information,\n successNotification: CheckmarkOutline,\n warningNotification: WarningAlt,\n dangerNotification: WarningFilled,\n invalid: WarningFilled,\n invalidAlt: Warning,\n redo: Restart,\n selectArrow: ChevronDown,\n toggleChecked: Checkmark,\n}\n","import type { SVGProps } from 'react'\n\n/**\n * This module contains substitute icons for the Checkbox component.\n * @module\n */\n\nexport type CheckboxIconProps = SVGProps<SVGSVGElement>\n\n/**\n * Checkmark icon for Checkbox component\n */\nexport function CheckmarkIcon(props: CheckboxIconProps) {\n return (\n <svg\n aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n role=\"img\"\n viewBox=\"0 0 24 24\"\n {...props}\n >\n <path\n fill=\"currentColor\"\n d=\"M9.714 18 4 12.335l1.818-1.764 3.896 3.824L18.181 6 20 7.803 9.714 18Z\"\n />\n </svg>\n )\n}\n\nexport type IndeterminateIconProps = SVGProps<SVGSVGElement>\n\n/**\n * Indeterminate icon for Checkbox component\n */\nexport function IndeterminateIcon(props: IndeterminateIconProps) {\n return (\n <svg\n aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/2000/svg\"\n role=\"img\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n {...props}\n >\n <path fill=\"currentColor\" d=\"M4 11h16v2.667H4z\" />\n </svg>\n )\n}\n","import { type CarbonIconProps } from '@cerberus/icons'\n\n/**\n * This module contains an animating icon to use for the FileStatus component.\n * @module\n */\n\nexport type AnimatingUploadIconProps = CarbonIconProps\n\nexport function AnimatingUploadIcon(props: AnimatingUploadIconProps) {\n return (\n <svg\n aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width={props.size ?? '1em'}\n height={props.size ?? '1em'}\n viewBox=\"0 0 24 24\"\n >\n <g\n fill=\"none\"\n stroke=\"currentColor\"\n strokeLinecap=\"square\"\n strokeLinejoin=\"round\"\n strokeWidth={1.5}\n >\n <path\n data-name=\"animating-trail\"\n strokeDasharray=\"2 4\"\n strokeDashoffset={6}\n d=\"M12 21c-4.97 0 -9 -4.03 -9 -9c0 -4.97 4.03 -9 9 -9\"\n >\n <animate\n attributeName=\"stroke-dashoffset\"\n dur=\"0.45s\"\n repeatCount=\"indefinite\"\n values=\"6;0\"\n ></animate>\n </path>\n\n <path\n data-name=\"half-circle\"\n strokeDasharray={32}\n strokeDashoffset={32}\n d=\"M12 3c4.97 0 9 4.03 9 9c0 4.97 -4.03 9 -9 9\"\n >\n <animate\n fill=\"freeze\"\n attributeName=\"stroke-dashoffset\"\n begin=\"0.075s\"\n dur=\"0.3s\"\n values=\"32;0\"\n ></animate>\n </path>\n\n <svg\n aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"0.8em\"\n height=\"0.8em\"\n x=\"27%\"\n y=\"27%\"\n viewBox=\"0 0 24 24\"\n >\n <polygon\n fill=\"currentColor\"\n stroke=\"currentColor\"\n strokeWidth={0.8}\n opacity=\"1\"\n points=\"3.7,6.7 7.5,2.9 7.5,15 8.5,15 8.5,2.9 12.3,6.7 13,6 8,1 3,6 \"\n >\n <animate\n fill=\"freeze\"\n attributeName=\"opacity\"\n values=\"1;0;1\"\n dur=\"2s\"\n repeatCount=\"indefinite\"\n ></animate>\n </polygon>\n </svg>\n </g>\n </svg>\n )\n}\n","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): Required<DefinedIcons> {\n _validateIconsProperties(icons)\n $cerberusIcons = {\n ...defaultIcons,\n ...icons,\n } as Required<DefinedIcons>\n return $cerberusIcons\n}\n\n// Default icons\n\nexport let $cerberusIcons = defaultIcons as Required<DefinedIcons>\n","'use client'\n\nimport {\n createContext,\n useContext,\n useMemo,\n type PropsWithChildren,\n} from 'react'\n\n/**\n * This module provides a context and hook for the field.\n * @module Field\n */\n\nexport interface FieldContextValue {\n /**\n * Whether the field is disabled.\n * @description [Moz Input Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attributes)\n */\n disabled?: boolean\n /**\n * Whether the field is read-only.\n */\n readOnly?: boolean\n /**\n * Whether the field is required.\n */\n required?: boolean\n /**\n * Whether the field is invalid.\n */\n invalid?: boolean\n}\n\nconst FieldContext = createContext<FieldContextValue | null>(null)\n\n/**\n * Provides the field state for a all related components used within a group.\n * @see https://cerberus.digitalu.design/react/input\n */\nexport function Field(\n props: PropsWithChildren<FieldContextValue>,\n): JSX.Element {\n const value = useMemo(\n () => ({\n disabled: props.disabled,\n readOnly: props.readOnly,\n required: props.required,\n invalid: props.invalid,\n }),\n [props.disabled, props.readOnly, props.required, props.invalid],\n )\n\n return (\n <FieldContext.Provider value={value}>\n {props.children}\n </FieldContext.Provider>\n )\n}\n\n/**\n * Used to access the field context.\n * @returns The field context.\n */\nexport function useFieldContext(): FieldContextValue {\n const context = useContext(FieldContext)\n if (!context) {\n throw new Error('useFieldContext must be used within a Field Provider.')\n }\n return context\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAAmB;AACnB,sBAA+B;AAC/B,qBAGO;;;ACPP,mBAiBO;;;ACKD;AAVC,SAAS,cAAc,OAA0B;AACtD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,eAAY;AAAA,MACZ,OAAM;AAAA,MACN,MAAK;AAAA,MACL,MAAK;AAAA,MACL,SAAQ;AAAA,MACP,GAAG;AAAA,MAEJ;AAAA,QAAC;AAAA;AAAA,UACC,MAAK;AAAA,UACL,GAAE;AAAA;AAAA,MAC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;AAC9C,QAAM,OAAO,eAAe;AAE5B,SACE;AAAA,IAAC;AAAA;AAAA,MACC,eAAW,eAAG,SAAS,OAAO,WAAO,wBAAO,CAAC;AAAA,MAC7C,gBAAc,MAAM,WAAW,MAAM;AAAA,MAErC;AAAA;AAAA,UAAC;AAAA;AAAA,YACE,GAAG;AAAA,YACH,GAAG;AAAA,YACH,GAAI,eAAe,EAAE,oBAAoB,YAAY;AAAA,YACrD,GAAI,WAAW,EAAE,gBAAgB,KAAK;AAAA,YACvC,eAAW,eAAG,QAAQ,OAAO,KAAK;AAAA,YAClC,MAAK;AAAA,YACL,MAAK;AAAA;AAAA,QACP;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,eAAW;AAAA,cACT,OAAO;AAAA,kBACP,wBAAO;AAAA,gBACL,SAAS;AAAA,cACX,CAAC;AAAA,YACH;AAAA,YAEA,uDAAC,QAAK;AAAA;AAAA,QACR;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["import_jsx_runtime","import_jsx_runtime","import_jsx_runtime"]}
1
+ {"version":3,"sources":["../../../src/components/Toggle.tsx","../../../src/context/field.tsx","../../../src/context/cerberus.tsx"],"sourcesContent":["'use client'\n\nimport { cx } from '@cerberus/styled-system/css'\nimport { hstack, vstack } from '@cerberus/styled-system/patterns'\nimport {\n toggle,\n type ToggleVariantProps,\n} from '@cerberus/styled-system/recipes'\nimport type { InputHTMLAttributes } from 'react'\nimport { useFieldContext } from '../context/field'\nimport { useCerberusContext } from '../context/cerberus'\n\n/**\n * This module provides a toggle component.\n * @module\n */\n\nexport type ToggleBase = Omit<\n InputHTMLAttributes<HTMLInputElement>,\n 'size' | 'id' | 'value'\n> & {\n /**\n * The FieldMessage providing context for the Toggle.\n */\n describedBy?: string\n /**\n * A unique identifier for the Toggle. Required for accessibility.\n */\n id: string\n /**\n * The value of the Toggle.\n */\n value: string\n}\nexport type ToggleProps = ToggleBase & ToggleVariantProps\n\n/**\n * The Toggle component is used to switch between two states. Optionally\n * combine with the `useToggle` hook.\n * @see https://cerberus.digitalu.design/react/toggle\n * @example\n * ```tsx\n * const { checked, handleChange } = useToggle({ checked: 'toggle' })\n *\n * <Hstack justify=\"space-between\" w=\"full\">\n * <Field>\n * <Label htmlFor=\"toggle\">Show notifications</Label>\n * <Toggle\n * checked={checked === 'toggle'}\n * id=\"toggle\"\n * onChange={handleChange}\n * value=\"toggle\"\n * />\n * </Field>\n * </Hstack>\n * ```\n */\nexport function Toggle(props: ToggleProps) {\n const { size, describedBy, ...nativeProps } = props\n const styles = toggle({ size })\n const { invalid, ...state } = useFieldContext()\n const { icons } = useCerberusContext()\n const CheckedIcon = icons.toggleChecked\n\n return (\n <span\n className={cx('group', styles.track, hstack())}\n data-checked={props.checked || props.defaultChecked}\n >\n <input\n {...nativeProps}\n {...state}\n {...(describedBy && { 'aria-describedby': describedBy })}\n {...(invalid && { 'aria-invalid': true })}\n className={cx('peer', styles.input)}\n role=\"switch\"\n type=\"checkbox\"\n />\n <span\n className={cx(\n styles.thumb,\n vstack({\n justify: 'center',\n }),\n )}\n >\n <CheckedIcon />\n </span>\n </span>\n )\n}\n","'use client'\n\nimport {\n createContext,\n useContext,\n useMemo,\n type PropsWithChildren,\n} from 'react'\n\n/**\n * This module provides a context and hook for the field.\n * @module Field\n */\n\nexport interface FieldContextValue {\n /**\n * Whether the field is disabled.\n * @description [Moz Input Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attributes)\n */\n disabled?: boolean\n /**\n * Whether the field is read-only.\n */\n readOnly?: boolean\n /**\n * Whether the field is required.\n */\n required?: boolean\n /**\n * Whether the field is invalid.\n */\n invalid?: boolean\n}\n\nconst FieldContext = createContext<FieldContextValue | null>(null)\n\n/**\n * Provides the field state for a all related components used within a group.\n * @see https://cerberus.digitalu.design/react/input\n */\nexport function Field(\n props: PropsWithChildren<FieldContextValue>,\n): JSX.Element {\n const value = useMemo(\n () => ({\n disabled: props.disabled,\n readOnly: props.readOnly,\n required: props.required,\n invalid: props.invalid,\n }),\n [props.disabled, props.readOnly, props.required, props.invalid],\n )\n\n return (\n <FieldContext.Provider value={value}>\n {props.children}\n </FieldContext.Provider>\n )\n}\n\n/**\n * Used to access the field context.\n * @returns The field context.\n */\nexport function useFieldContext(): FieldContextValue {\n const context = useContext(FieldContext)\n if (!context) {\n throw new Error('useFieldContext must be used within a Field Provider.')\n }\n return context\n}\n","'use client'\n\nimport { createContext, useContext, type PropsWithChildren } from 'react'\nimport type { SystemConfig } from '../config'\n\n/**\n * This module contains the Cerberus configuration context and helpers.\n * @module context/cerberus\n */\n\ntype CerberusContextValue = SystemConfig\n\nconst CerberusContext = createContext<CerberusContextValue | null>(null)\n\ninterface CerberusProviderProps {\n config: SystemConfig\n}\n\n/**\n * Cerberus configuration provider.\n * @param props.config The Cerberus configuration created with\n * `makeSystemConfig` helper.\n */\nexport function CerberusProvider(\n props: PropsWithChildren<CerberusProviderProps>,\n) {\n return (\n <CerberusContext.Provider value={props.config}>\n {props.children}\n </CerberusContext.Provider>\n )\n}\n\n/**\n * Returns the Cerberus configuration context.\n * @returns The Cerberus configuration context.\n */\nexport function useCerberusContext() {\n const context = useContext(CerberusContext)\n if (!context) {\n throw new Error('useCerberus must be used within a CerberusProvider')\n }\n return context\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAAmB;AACnB,sBAA+B;AAC/B,qBAGO;;;ACLP,mBAKO;AA+CH;AApBJ,IAAM,mBAAe,4BAAwC,IAAI;AA8B1D,SAAS,kBAAqC;AACnD,QAAM,cAAU,yBAAW,YAAY;AACvC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,uDAAuD;AAAA,EACzE;AACA,SAAO;AACT;;;ACpEA,IAAAA,gBAAkE;AAyB9D,IAAAC,sBAAA;AAfJ,IAAM,sBAAkB,6BAA2C,IAAI;AAyBhE,SAAS,qBAAqB;AACnC,QAAM,cAAU,0BAAW,eAAe;AAC1C,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,oDAAoD;AAAA,EACtE;AACA,SAAO;AACT;;;AFsBI,IAAAC,sBAAA;AARG,SAAS,OAAO,OAAoB;AACzC,QAAM,EAAE,MAAM,aAAa,GAAG,YAAY,IAAI;AAC9C,QAAM,aAAS,uBAAO,EAAE,KAAK,CAAC;AAC9B,QAAM,EAAE,SAAS,GAAG,MAAM,IAAI,gBAAgB;AAC9C,QAAM,EAAE,MAAM,IAAI,mBAAmB;AACrC,QAAM,cAAc,MAAM;AAE1B,SACE;AAAA,IAAC;AAAA;AAAA,MACC,eAAW,eAAG,SAAS,OAAO,WAAO,wBAAO,CAAC;AAAA,MAC7C,gBAAc,MAAM,WAAW,MAAM;AAAA,MAErC;AAAA;AAAA,UAAC;AAAA;AAAA,YACE,GAAG;AAAA,YACH,GAAG;AAAA,YACH,GAAI,eAAe,EAAE,oBAAoB,YAAY;AAAA,YACrD,GAAI,WAAW,EAAE,gBAAgB,KAAK;AAAA,YACvC,eAAW,eAAG,QAAQ,OAAO,KAAK;AAAA,YAClC,MAAK;AAAA,YACL,MAAK;AAAA;AAAA,QACP;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,eAAW;AAAA,cACT,OAAO;AAAA,kBACP,wBAAO;AAAA,gBACL,SAAS;AAAA,cACX,CAAC;AAAA,YACH;AAAA,YAEA,uDAAC,eAAY;AAAA;AAAA,QACf;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["import_react","import_jsx_runtime","import_jsx_runtime"]}
@@ -20,14 +20,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/config/defineIcons.ts
21
21
  var defineIcons_exports = {};
22
22
  __export(defineIcons_exports, {
23
- $cerberusIcons: () => $cerberusIcons,
24
23
  defineIcons: () => defineIcons
25
24
  });
26
25
  module.exports = __toCommonJS(defineIcons_exports);
27
26
 
28
- // src/config/cerbIcons.ts
29
- var import_icons = require("@cerberus/icons");
30
-
31
27
  // src/config/icons/checkbox.icons.tsx
32
28
  var import_jsx_runtime = require("react/jsx-runtime");
33
29
  function CheckmarkIcon(props) {
@@ -161,52 +157,20 @@ function AnimatingUploadIcon(props) {
161
157
  );
162
158
  }
163
159
 
164
- // src/config/cerbIcons.ts
160
+ // src/config/defineIcons.ts
165
161
  var defaultIcons = {
166
- accordionIndicator: import_icons.ChevronDown,
167
- avatar: import_icons.UserFilled,
168
- calendar: import_icons.Calendar,
169
- calendarPrev: import_icons.ChevronLeft,
170
- calendarNext: import_icons.ChevronRight,
171
162
  checkbox: CheckmarkIcon,
172
- close: import_icons.Close,
173
- confirmModal: import_icons.Information,
174
- delete: import_icons.TrashCan,
175
- promptModal: import_icons.Information,
176
- waitingFileUploader: import_icons.CloudUpload,
177
163
  fileUploader: AnimatingUploadIcon,
178
- indeterminate: IndeterminateIcon,
179
- infoNotification: import_icons.Information,
180
- successNotification: import_icons.CheckmarkOutline,
181
- warningNotification: import_icons.WarningAlt,
182
- dangerNotification: import_icons.WarningFilled,
183
- invalid: import_icons.WarningFilled,
184
- invalidAlt: import_icons.Warning,
185
- redo: import_icons.Restart,
186
- selectArrow: import_icons.ChevronDown,
187
- toggleChecked: import_icons.Checkmark
164
+ indeterminate: IndeterminateIcon
188
165
  };
189
-
190
- // src/config/defineIcons.ts
191
- function _validateIconsProperties(icons) {
192
- if (!icons.invalid) {
193
- throw new Error(
194
- "The an invalid property must be defined in your custom icons library."
195
- );
196
- }
197
- }
198
166
  function defineIcons(icons) {
199
- _validateIconsProperties(icons);
200
- $cerberusIcons = {
167
+ return {
201
168
  ...defaultIcons,
202
169
  ...icons
203
170
  };
204
- return $cerberusIcons;
205
171
  }
206
- var $cerberusIcons = defaultIcons;
207
172
  // Annotate the CommonJS export names for ESM import in node:
208
173
  0 && (module.exports = {
209
- $cerberusIcons,
210
174
  defineIcons
211
175
  });
212
176
  //# sourceMappingURL=defineIcons.cjs.map