@cerberus-design/react 0.14.2 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/build/legacy/_tsup-dts-rollup.d.cts +374 -80
  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 +129 -272
  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/Dialog.cjs +86 -0
  22. package/build/legacy/components/Dialog.cjs.map +1 -0
  23. package/build/legacy/components/Dialog.client.cjs +95 -0
  24. package/build/legacy/components/Dialog.client.cjs.map +1 -0
  25. package/build/legacy/components/FileStatus.cjs +62 -212
  26. package/build/legacy/components/FileStatus.cjs.map +1 -1
  27. package/build/legacy/components/FileUploader.cjs +29 -180
  28. package/build/legacy/components/FileUploader.cjs.map +1 -1
  29. package/build/legacy/components/Input.cjs +20 -172
  30. package/build/legacy/components/Input.cjs.map +1 -1
  31. package/build/legacy/components/Modal.cjs.map +1 -1
  32. package/build/legacy/components/ModalDescription.cjs.map +1 -1
  33. package/build/legacy/components/ModalHeader.cjs.map +1 -1
  34. package/build/legacy/components/ModalHeading.cjs.map +1 -1
  35. package/build/legacy/components/Notification.cjs +26 -176
  36. package/build/legacy/components/Notification.cjs.map +1 -1
  37. package/build/legacy/components/Select.cjs +26 -178
  38. package/build/legacy/components/Select.cjs.map +1 -1
  39. package/build/legacy/components/Tag.cjs +16 -167
  40. package/build/legacy/components/Tag.cjs.map +1 -1
  41. package/build/legacy/components/Toggle.cjs +20 -172
  42. package/build/legacy/components/Toggle.cjs.map +1 -1
  43. package/build/legacy/config/defineIcons.cjs +3 -39
  44. package/build/legacy/config/defineIcons.cjs.map +1 -1
  45. package/build/legacy/config/{cerbIcons.cjs → index.cjs} +22 -29
  46. package/build/legacy/config/index.cjs.map +1 -0
  47. package/build/legacy/config/types.cjs +19 -0
  48. package/build/legacy/config/types.cjs.map +1 -0
  49. package/build/legacy/context/cerberus.cjs +46 -0
  50. package/build/legacy/context/cerberus.cjs.map +1 -0
  51. package/build/legacy/context/confirm-modal.cjs +105 -321
  52. package/build/legacy/context/confirm-modal.cjs.map +1 -1
  53. package/build/legacy/context/cta-modal.cjs +137 -336
  54. package/build/legacy/context/cta-modal.cjs.map +1 -1
  55. package/build/legacy/context/notification-center/store.cjs +66 -0
  56. package/build/legacy/context/notification-center/store.cjs.map +1 -0
  57. package/build/legacy/context/notification-center/types.cjs +19 -0
  58. package/build/legacy/context/notification-center/types.cjs.map +1 -0
  59. package/build/legacy/context/notification-center.cjs +142 -249
  60. package/build/legacy/context/notification-center.cjs.map +1 -1
  61. package/build/legacy/context/prompt-modal.cjs +185 -388
  62. package/build/legacy/context/prompt-modal.cjs.map +1 -1
  63. package/build/legacy/index.cjs +1577 -1456
  64. package/build/legacy/index.cjs.map +1 -1
  65. package/build/modern/_tsup-dts-rollup.d.ts +374 -80
  66. package/build/modern/{chunk-BVCXVZAF.js → chunk-25HMVHLT.js} +6 -5
  67. package/build/modern/chunk-25HMVHLT.js.map +1 -0
  68. package/build/modern/chunk-36N4527B.js +1 -0
  69. package/build/modern/chunk-5EWCH7AI.js +82 -0
  70. package/build/modern/chunk-5EWCH7AI.js.map +1 -0
  71. package/build/modern/chunk-5SNLQZYP.js +25 -0
  72. package/build/modern/chunk-5SNLQZYP.js.map +1 -0
  73. package/build/modern/chunk-6BN3XKQF.js +42 -0
  74. package/build/modern/chunk-6BN3XKQF.js.map +1 -0
  75. package/build/modern/{chunk-2UXE5PDG.js → chunk-7NN3SJ7W.js} +1 -1
  76. package/build/modern/chunk-7NN3SJ7W.js.map +1 -0
  77. package/build/modern/{chunk-KWJ5FKX7.js → chunk-BAWZBF5Q.js} +5 -3
  78. package/build/modern/chunk-BAWZBF5Q.js.map +1 -0
  79. package/build/modern/{chunk-6BH5J5GF.js → chunk-BHB56M7S.js} +31 -46
  80. package/build/modern/chunk-BHB56M7S.js.map +1 -0
  81. package/build/modern/{chunk-HKJMLWVP.js → chunk-EDARV2EI.js} +5 -4
  82. package/build/modern/chunk-EDARV2EI.js.map +1 -0
  83. package/build/modern/{chunk-5OVH3INN.js → chunk-FGCO27TC.js} +25 -53
  84. package/build/modern/chunk-FGCO27TC.js.map +1 -0
  85. package/build/modern/{chunk-PVIMOXSO.js → chunk-GCQMH4QA.js} +5 -4
  86. package/build/modern/chunk-GCQMH4QA.js.map +1 -0
  87. package/build/modern/chunk-GITT5645.js +20 -0
  88. package/build/modern/chunk-GITT5645.js.map +1 -0
  89. package/build/modern/{chunk-TJCFYL5W.js → chunk-IGHMP4WA.js} +1 -20
  90. package/build/modern/chunk-IGHMP4WA.js.map +1 -0
  91. package/build/modern/chunk-ISCJ542I.js +82 -0
  92. package/build/modern/chunk-ISCJ542I.js.map +1 -0
  93. package/build/modern/{chunk-HVKM54BA.js → chunk-IW3LIRDG.js} +1 -1
  94. package/build/modern/chunk-IW3LIRDG.js.map +1 -0
  95. package/build/modern/chunk-JAROS4Q3.js +180 -0
  96. package/build/modern/chunk-JAROS4Q3.js.map +1 -0
  97. package/build/modern/{chunk-BE4EOU2P.js → chunk-JIRW4XOJ.js} +1 -1
  98. package/build/modern/chunk-JIRW4XOJ.js.map +1 -0
  99. package/build/modern/chunk-KDDPAJMR.js +9 -0
  100. package/build/modern/chunk-KDDPAJMR.js.map +1 -0
  101. package/build/modern/{chunk-XOROL3JY.js → chunk-KKHL3ZO4.js} +5 -4
  102. package/build/modern/chunk-KKHL3ZO4.js.map +1 -0
  103. package/build/modern/{chunk-U36UZJGZ.js → chunk-MZ3UCDUL.js} +5 -4
  104. package/build/modern/chunk-MZ3UCDUL.js.map +1 -0
  105. package/build/modern/{chunk-T2JOPPGL.js → chunk-N24COMHJ.js} +11 -4
  106. package/build/modern/chunk-N24COMHJ.js.map +1 -0
  107. package/build/modern/chunk-NJSETNRL.js +68 -0
  108. package/build/modern/chunk-NJSETNRL.js.map +1 -0
  109. package/build/modern/{chunk-XY6WL55R.js → chunk-NUMM4TNC.js} +1 -1
  110. package/build/modern/chunk-NUMM4TNC.js.map +1 -0
  111. package/build/modern/{chunk-FXLLRVAM.js → chunk-O6LFWUHI.js} +8 -6
  112. package/build/modern/chunk-O6LFWUHI.js.map +1 -0
  113. package/build/modern/{chunk-JJZQGR7A.js → chunk-RDRD6ACD.js} +9 -6
  114. package/build/modern/chunk-RDRD6ACD.js.map +1 -0
  115. package/build/modern/{chunk-XXWR7UGH.js → chunk-SD3OVTHT.js} +75 -103
  116. package/build/modern/chunk-SD3OVTHT.js.map +1 -0
  117. package/build/modern/chunk-TFL56AYR.js +56 -0
  118. package/build/modern/chunk-TFL56AYR.js.map +1 -0
  119. package/build/modern/chunk-V3M3ZOQI.js +38 -0
  120. package/build/modern/chunk-V3M3ZOQI.js.map +1 -0
  121. package/build/modern/{chunk-QK7R2XJM.js → chunk-XQICKZH4.js} +6 -5
  122. package/build/modern/chunk-XQICKZH4.js.map +1 -0
  123. package/build/modern/chunk-XZGXRRSQ.js +31 -0
  124. package/build/modern/chunk-XZGXRRSQ.js.map +1 -0
  125. package/build/modern/{chunk-KPUYKHLW.js → chunk-YKKNWILF.js} +71 -15
  126. package/build/modern/chunk-YKKNWILF.js.map +1 -0
  127. package/build/modern/{chunk-Q7BRMIBR.js → chunk-ZL6ZITLA.js} +1 -1
  128. package/build/modern/chunk-ZL6ZITLA.js.map +1 -0
  129. package/build/modern/components/Accordion.client.js +9 -0
  130. package/build/modern/components/Accordion.client.js.map +1 -0
  131. package/build/modern/components/Accordion.js +1 -7
  132. package/build/modern/components/AccordionItemGroup.js +4 -6
  133. package/build/modern/components/Admonition.client.js +11 -0
  134. package/build/modern/components/Admonition.client.js.map +1 -0
  135. package/build/modern/components/Admonition.js +4 -6
  136. package/build/modern/components/AnimatingUploadIcon.js +1 -1
  137. package/build/modern/components/Avatar.js +3 -5
  138. package/build/modern/components/Checkbox.js +2 -5
  139. package/build/modern/components/DatePicker.client.js +8 -7
  140. package/build/modern/components/DatePicker.server.js +3 -13
  141. package/build/modern/components/Dialog.client.js +10 -0
  142. package/build/modern/components/Dialog.client.js.map +1 -0
  143. package/build/modern/components/Dialog.js +24 -0
  144. package/build/modern/components/Dialog.js.map +1 -0
  145. package/build/modern/components/FileStatus.js +3 -6
  146. package/build/modern/components/FileUploader.js +3 -6
  147. package/build/modern/components/Input.js +2 -5
  148. package/build/modern/components/Modal.js +1 -1
  149. package/build/modern/components/ModalDescription.js +1 -1
  150. package/build/modern/components/ModalHeader.js +1 -1
  151. package/build/modern/components/ModalHeading.js +1 -1
  152. package/build/modern/components/Notification.js +2 -5
  153. package/build/modern/components/Select.js +2 -5
  154. package/build/modern/components/Tag.js +3 -5
  155. package/build/modern/components/Toggle.js +2 -5
  156. package/build/modern/config/defineIcons.js +2 -5
  157. package/build/modern/config/index.js +14 -0
  158. package/build/modern/config/index.js.map +1 -0
  159. package/build/modern/config/types.js +2 -0
  160. package/build/modern/config/types.js.map +1 -0
  161. package/build/modern/context/cerberus.js +10 -0
  162. package/build/modern/context/cerberus.js.map +1 -0
  163. package/build/modern/context/confirm-modal.js +5 -13
  164. package/build/modern/context/cta-modal.js +7 -14
  165. package/build/modern/context/notification-center/store.js +15 -0
  166. package/build/modern/context/notification-center/store.js.map +1 -0
  167. package/build/modern/context/notification-center/types.js +1 -0
  168. package/build/modern/context/notification-center/types.js.map +1 -0
  169. package/build/modern/context/notification-center.js +5 -7
  170. package/build/modern/context/prompt-modal.js +8 -15
  171. package/build/modern/index.js +111 -75
  172. package/build/modern/index.js.map +1 -1
  173. package/package.json +4 -8
  174. package/src/components/Accordion.client.tsx +46 -0
  175. package/src/components/Accordion.tsx +0 -37
  176. package/src/components/AccordionItemGroup.tsx +1 -1
  177. package/src/components/Admonition.client.tsx +73 -0
  178. package/src/components/Admonition.tsx +1 -70
  179. package/src/components/AnimatingUploadIcon.tsx +3 -3
  180. package/src/components/Avatar.tsx +5 -2
  181. package/src/components/Checkbox.tsx +10 -3
  182. package/src/components/DatePicker.client.tsx +111 -15
  183. package/src/components/DatePicker.server.tsx +2 -75
  184. package/src/components/Dialog.client.tsx +39 -0
  185. package/src/components/Dialog.tsx +165 -0
  186. package/src/components/FileStatus.tsx +5 -3
  187. package/src/components/FileUploader.tsx +3 -2
  188. package/src/components/Input.tsx +4 -2
  189. package/src/components/Modal.tsx +1 -16
  190. package/src/components/ModalDescription.tsx +1 -8
  191. package/src/components/ModalHeader.tsx +1 -10
  192. package/src/components/ModalHeading.tsx +1 -8
  193. package/src/components/Notification.tsx +9 -4
  194. package/src/components/Select.tsx +5 -2
  195. package/src/components/Tag.tsx +5 -2
  196. package/src/components/Toggle.tsx +4 -3
  197. package/src/config/defineIcons.ts +28 -16
  198. package/src/config/index.ts +28 -0
  199. package/src/config/types.ts +42 -0
  200. package/src/context/cerberus.tsx +44 -0
  201. package/src/context/confirm-modal.tsx +44 -42
  202. package/src/context/cta-modal.tsx +25 -38
  203. package/src/context/notification-center/store.ts +88 -0
  204. package/src/context/notification-center/types.ts +28 -0
  205. package/src/context/notification-center.tsx +81 -46
  206. package/src/context/prompt-modal.tsx +101 -103
  207. package/src/index.ts +15 -8
  208. package/build/legacy/config/cerbIcons.cjs.map +0 -1
  209. package/build/modern/chunk-2UXE5PDG.js.map +0 -1
  210. package/build/modern/chunk-5OVH3INN.js.map +0 -1
  211. package/build/modern/chunk-6BH5J5GF.js.map +0 -1
  212. package/build/modern/chunk-BC5SZDYY.js +0 -132
  213. package/build/modern/chunk-BC5SZDYY.js.map +0 -1
  214. package/build/modern/chunk-BE4EOU2P.js.map +0 -1
  215. package/build/modern/chunk-BVCXVZAF.js.map +0 -1
  216. package/build/modern/chunk-CRII2HNX.js +0 -55
  217. package/build/modern/chunk-CRII2HNX.js.map +0 -1
  218. package/build/modern/chunk-CVTON5DQ.js +0 -162
  219. package/build/modern/chunk-CVTON5DQ.js.map +0 -1
  220. package/build/modern/chunk-FXLLRVAM.js.map +0 -1
  221. package/build/modern/chunk-HKJMLWVP.js.map +0 -1
  222. package/build/modern/chunk-HVKM54BA.js.map +0 -1
  223. package/build/modern/chunk-JJZQGR7A.js.map +0 -1
  224. package/build/modern/chunk-KPUYKHLW.js.map +0 -1
  225. package/build/modern/chunk-KWJ5FKX7.js.map +0 -1
  226. package/build/modern/chunk-PVIMOXSO.js.map +0 -1
  227. package/build/modern/chunk-Q7BRMIBR.js.map +0 -1
  228. package/build/modern/chunk-QK7R2XJM.js.map +0 -1
  229. package/build/modern/chunk-QMF5ZNDG.js +0 -27
  230. package/build/modern/chunk-QMF5ZNDG.js.map +0 -1
  231. package/build/modern/chunk-QQOWWMZ3.js +0 -138
  232. package/build/modern/chunk-QQOWWMZ3.js.map +0 -1
  233. package/build/modern/chunk-T2JOPPGL.js.map +0 -1
  234. package/build/modern/chunk-TJCFYL5W.js.map +0 -1
  235. package/build/modern/chunk-U36UZJGZ.js.map +0 -1
  236. package/build/modern/chunk-XOROL3JY.js.map +0 -1
  237. package/build/modern/chunk-XXWR7UGH.js.map +0 -1
  238. package/build/modern/chunk-XY6WL55R.js.map +0 -1
  239. package/build/modern/config/cerbIcons.js +0 -9
  240. package/src/config/cerbIcons.ts +0 -73
  241. /package/build/modern/{config/cerbIcons.js.map → chunk-36N4527B.js.map} +0 -0
@@ -51,179 +51,33 @@ function useFieldContext() {
51
51
  return context;
52
52
  }
53
53
 
54
- // src/config/cerbIcons.ts
55
- var import_icons = require("@cerberus/icons");
56
-
57
- // src/config/icons/checkbox.icons.tsx
54
+ // src/context/cerberus.tsx
55
+ var import_react3 = require("react");
58
56
  var import_jsx_runtime2 = require("react/jsx-runtime");
59
- function CheckmarkIcon(props) {
60
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
61
- "svg",
62
- {
63
- "aria-hidden": "true",
64
- xmlns: "http://www.w3.org/2000/svg",
65
- fill: "none",
66
- role: "img",
67
- viewBox: "0 0 24 24",
68
- ...props,
69
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
70
- "path",
71
- {
72
- fill: "currentColor",
73
- d: "M9.714 18 4 12.335l1.818-1.764 3.896 3.824L18.181 6 20 7.803 9.714 18Z"
74
- }
75
- )
76
- }
77
- );
78
- }
79
- function IndeterminateIcon(props) {
80
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
81
- "svg",
82
- {
83
- "aria-hidden": "true",
84
- xmlns: "http://www.w3.org/2000/svg",
85
- role: "img",
86
- fill: "none",
87
- viewBox: "0 0 24 24",
88
- ...props,
89
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { fill: "currentColor", d: "M4 11h16v2.667H4z" })
90
- }
91
- );
92
- }
93
-
94
- // src/components/AnimatingUploadIcon.tsx
95
- var import_jsx_runtime3 = require("react/jsx-runtime");
96
- function AnimatingUploadIcon(props) {
97
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
98
- "svg",
99
- {
100
- "aria-hidden": "true",
101
- xmlns: "http://www.w3.org/2000/svg",
102
- width: props.size ?? "1em",
103
- height: props.size ?? "1em",
104
- viewBox: "0 0 24 24",
105
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
106
- "g",
107
- {
108
- fill: "none",
109
- stroke: "currentColor",
110
- strokeLinecap: "square",
111
- strokeLinejoin: "round",
112
- strokeWidth: 1.5,
113
- children: [
114
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
115
- "path",
116
- {
117
- "data-name": "animating-trail",
118
- strokeDasharray: "2 4",
119
- strokeDashoffset: 6,
120
- d: "M12 21c-4.97 0 -9 -4.03 -9 -9c0 -4.97 4.03 -9 9 -9",
121
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
122
- "animate",
123
- {
124
- attributeName: "stroke-dashoffset",
125
- dur: "0.45s",
126
- repeatCount: "indefinite",
127
- values: "6;0"
128
- }
129
- )
130
- }
131
- ),
132
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
133
- "path",
134
- {
135
- "data-name": "half-circle",
136
- strokeDasharray: 32,
137
- strokeDashoffset: 32,
138
- d: "M12 3c4.97 0 9 4.03 9 9c0 4.97 -4.03 9 -9 9",
139
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
140
- "animate",
141
- {
142
- fill: "freeze",
143
- attributeName: "stroke-dashoffset",
144
- begin: "0.075s",
145
- dur: "0.3s",
146
- values: "32;0"
147
- }
148
- )
149
- }
150
- ),
151
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
152
- "svg",
153
- {
154
- "aria-hidden": "true",
155
- xmlns: "http://www.w3.org/2000/svg",
156
- width: "0.8em",
157
- height: "0.8em",
158
- x: "27%",
159
- y: "27%",
160
- viewBox: "0 0 24 24",
161
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
162
- "polygon",
163
- {
164
- fill: "currentColor",
165
- stroke: "currentColor",
166
- strokeWidth: 0.8,
167
- opacity: "1",
168
- 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 ",
169
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
170
- "animate",
171
- {
172
- fill: "freeze",
173
- attributeName: "opacity",
174
- values: "1;0;1",
175
- dur: "2s",
176
- repeatCount: "indefinite"
177
- }
178
- )
179
- }
180
- )
181
- }
182
- )
183
- ]
184
- }
185
- )
186
- }
187
- );
57
+ var CerberusContext = (0, import_react3.createContext)(null);
58
+ function useCerberusContext() {
59
+ const context = (0, import_react3.useContext)(CerberusContext);
60
+ if (!context) {
61
+ throw new Error("useCerberus must be used within a CerberusProvider");
62
+ }
63
+ return context;
188
64
  }
189
65
 
190
- // src/config/cerbIcons.ts
191
- var defaultIcons = {
192
- accordionIndicator: import_icons.ChevronDown,
193
- avatar: import_icons.UserFilled,
194
- calendar: import_icons.Calendar,
195
- calendarPrev: import_icons.ChevronLeft,
196
- calendarNext: import_icons.ChevronRight,
197
- checkbox: CheckmarkIcon,
198
- close: import_icons.Close,
199
- confirmModal: import_icons.Information,
200
- delete: import_icons.TrashCan,
201
- promptModal: import_icons.Information,
202
- waitingFileUploader: import_icons.CloudUpload,
203
- fileUploader: AnimatingUploadIcon,
204
- indeterminate: IndeterminateIcon,
205
- infoNotification: import_icons.Information,
206
- successNotification: import_icons.CheckmarkOutline,
207
- warningNotification: import_icons.WarningAlt,
208
- dangerNotification: import_icons.WarningFilled,
209
- invalid: import_icons.WarningFilled,
210
- invalidAlt: import_icons.Warning,
211
- redo: import_icons.Restart,
212
- selectArrow: import_icons.ChevronDown,
213
- toggleChecked: import_icons.Checkmark
214
- };
215
-
216
- // src/config/defineIcons.ts
217
- var $cerberusIcons = defaultIcons;
218
-
219
66
  // src/components/Checkbox.tsx
220
- var import_jsx_runtime4 = require("react/jsx-runtime");
67
+ var import_jsx_runtime3 = require("react/jsx-runtime");
221
68
  function Checkbox(props) {
222
69
  const { describedBy, size, checked, mixed, ...nativeProps } = props;
223
70
  const { invalid, ...fieldStates } = useFieldContext();
224
71
  const styles = (0, import_recipes.checkbox)({ size });
225
- const { checkbox: CheckIcon, indeterminate: IndeterminateIcon2 } = $cerberusIcons;
226
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
72
+ const { icons } = useCerberusContext();
73
+ const { checkbox: CheckIcon, indeterminate: IndeterminateIcon } = icons;
74
+ if (!CheckIcon) {
75
+ throw new Error("The CerberusProvider is missing the checkbox icon.");
76
+ }
77
+ if (!IndeterminateIcon) {
78
+ throw new Error("The CerberusProvider is missing the indeterminate icon.");
79
+ }
80
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
227
81
  "div",
228
82
  {
229
83
  className: (0, import_css.cx)(
@@ -234,7 +88,7 @@ function Checkbox(props) {
234
88
  })
235
89
  ),
236
90
  children: [
237
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
91
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
238
92
  "input",
239
93
  {
240
94
  ...nativeProps,
@@ -246,8 +100,8 @@ function Checkbox(props) {
246
100
  type: "checkbox"
247
101
  }
248
102
  ),
249
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Show, { when: checked && !mixed, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: styles.icon, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CheckIcon, {}) }) }),
250
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Show, { when: mixed, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: styles.icon, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(IndeterminateIcon2, {}) }) })
103
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Show, { when: checked && !mixed, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: styles.icon, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CheckIcon, {}) }) }),
104
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Show, { when: mixed, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: styles.icon, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(IndeterminateIcon, {}) }) })
251
105
  ]
252
106
  }
253
107
  );
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Checkbox.tsx","../../../src/components/Show.tsx","../../../src/context/field.tsx","../../../src/config/cerbIcons.ts","../../../src/config/icons/checkbox.icons.tsx","../../../src/components/AnimatingUploadIcon.tsx","../../../src/config/defineIcons.ts"],"sourcesContent":["'use client'\n\nimport {\n checkbox,\n type CheckboxVariantProps,\n} from '@cerberus/styled-system/recipes'\nimport { vstack } from '@cerberus/styled-system/patterns'\nimport { cx } from '@cerberus/styled-system/css'\nimport type { InputHTMLAttributes } from 'react'\nimport { Show } from './Show'\nimport { useFieldContext } from '../context/field'\nimport { $cerberusIcons } from '../config/defineIcons'\n\n/**\n * This module contains the Checkbox component.\n * @module\n */\n\nexport type CheckboxProps = CheckboxVariantProps &\n Omit<InputHTMLAttributes<HTMLInputElement>, 'size' | 'id'> & {\n /**\n * The id of the FieldMessage element describing the Checkbox.\n */\n describedBy?: string\n /**\n * The unique identifier for the checkbox. Required for accessibility.\n */\n id: string\n /**\n * Used to display a mixed checked state.\n * @description [ARIA Mixed State](https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/examples/checkbox-mixed/)\n */\n mixed?: boolean\n }\n\n/**\n * Checkbox component\n * @definition [ARIA Target Size](https://www.w3.org/WAI/WCAG21/Understanding/target-size.html#:~:text=Understanding%20SC%202.5.,%3ATarget%20Size%20(Level%20AAA)&text=The%20size%20of%20the%20target,Equivalent)\n * @definition [ARIA Forms](https://www.a11yproject.com/checklist/#forms)\n * @see https://cerberus.digitalu.design/react/checkbox\n * @example\n * ```tsx\n * <Field>\n * <Checkbox id=\"legal\" checked={checked.legal} onChange={handleChange} />\n * </Field>\n * ```\n */\nexport function Checkbox(props: CheckboxProps) {\n const { describedBy, size, checked, mixed, ...nativeProps } = props\n const { invalid, ...fieldStates } = useFieldContext()\n const styles = checkbox({ size })\n const { checkbox: CheckIcon, indeterminate: IndeterminateIcon } =\n $cerberusIcons\n\n return (\n <div\n className={cx(\n styles.root,\n vstack({\n gap: '0',\n justify: 'center',\n }),\n )}\n >\n <input\n {...nativeProps}\n {...fieldStates}\n {...(describedBy && { 'aria-describedby': describedBy })}\n {...(invalid && { 'aria-invalid': true })}\n {...(mixed && { 'aria-checked': 'mixed' })}\n className={cx('peer', nativeProps.className, styles.input)}\n type=\"checkbox\"\n />\n <Show when={checked && !mixed}>\n <span className={styles.icon}>\n <CheckIcon />\n </span>\n </Show>\n <Show when={mixed}>\n <span className={styles.icon}>\n <IndeterminateIcon />\n </span>\n </Show>\n </div>\n )\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 {\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","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;AAEA,qBAGO;AAC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AAO,MACtB,uDAACA,oBAAA,EAAkB,GACrB,GACF;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["import_react","import_jsx_runtime","import_jsx_runtime","import_jsx_runtime","IndeterminateIcon"]}
1
+ {"version":3,"sources":["../../../src/components/Checkbox.tsx","../../../src/components/Show.tsx","../../../src/context/field.tsx","../../../src/context/cerberus.tsx"],"sourcesContent":["'use client'\n\nimport {\n checkbox,\n type CheckboxVariantProps,\n} from '@cerberus/styled-system/recipes'\nimport { vstack } from '@cerberus/styled-system/patterns'\nimport { cx } from '@cerberus/styled-system/css'\nimport type { InputHTMLAttributes } from 'react'\nimport { Show } from './Show'\nimport { useFieldContext } from '../context/field'\nimport { useCerberusContext } from '../context/cerberus'\n\n/**\n * This module contains the Checkbox component.\n * @module\n */\n\nexport type CheckboxProps = CheckboxVariantProps &\n Omit<InputHTMLAttributes<HTMLInputElement>, 'size' | 'id'> & {\n /**\n * The id of the FieldMessage element describing the Checkbox.\n */\n describedBy?: string\n /**\n * The unique identifier for the checkbox. Required for accessibility.\n */\n id: string\n /**\n * Used to display a mixed checked state.\n * @description [ARIA Mixed State](https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/examples/checkbox-mixed/)\n */\n mixed?: boolean\n }\n\n/**\n * Checkbox component\n * @definition [ARIA Target Size](https://www.w3.org/WAI/WCAG21/Understanding/target-size.html#:~:text=Understanding%20SC%202.5.,%3ATarget%20Size%20(Level%20AAA)&text=The%20size%20of%20the%20target,Equivalent)\n * @definition [ARIA Forms](https://www.a11yproject.com/checklist/#forms)\n * @see https://cerberus.digitalu.design/react/checkbox\n * @example\n * ```tsx\n * <Field>\n * <Checkbox id=\"legal\" checked={checked.legal} onChange={handleChange} />\n * </Field>\n * ```\n */\nexport function Checkbox(props: CheckboxProps) {\n const { describedBy, size, checked, mixed, ...nativeProps } = props\n const { invalid, ...fieldStates } = useFieldContext()\n const styles = checkbox({ size })\n const { icons } = useCerberusContext()\n const { checkbox: CheckIcon, indeterminate: IndeterminateIcon } = icons\n\n if (!CheckIcon) {\n throw new Error('The CerberusProvider is missing the checkbox icon.')\n }\n if (!IndeterminateIcon) {\n throw new Error('The CerberusProvider is missing the indeterminate icon.')\n }\n\n return (\n <div\n className={cx(\n styles.root,\n vstack({\n gap: '0',\n justify: 'center',\n }),\n )}\n >\n <input\n {...nativeProps}\n {...fieldStates}\n {...(describedBy && { 'aria-describedby': describedBy })}\n {...(invalid && { 'aria-invalid': true })}\n {...(mixed && { 'aria-checked': 'mixed' })}\n className={cx('peer', nativeProps.className, styles.input)}\n type=\"checkbox\"\n />\n <Show when={checked && !mixed}>\n <span className={styles.icon}>\n <CheckIcon />\n </span>\n </Show>\n <Show when={mixed}>\n <span className={styles.icon}>\n <IndeterminateIcon />\n </span>\n </Show>\n </div>\n )\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 {\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,qBAGO;AACP,sBAAuB;AACvB,iBAAmB;;;ACLnB,mBAAgE;AA4BzD,SAAS,KAAK,OAAgD;AACnE,QAAM,EAAE,MAAM,UAAU,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