@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.
- package/build/legacy/_tsup-dts-rollup.d.cts +374 -80
- package/build/legacy/components/Accordion.cjs +4 -187
- package/build/legacy/components/Accordion.cjs.map +1 -1
- package/build/legacy/components/Accordion.client.cjs +64 -0
- package/build/legacy/components/Accordion.client.cjs.map +1 -0
- package/build/legacy/components/AccordionItemGroup.cjs +41 -185
- package/build/legacy/components/AccordionItemGroup.cjs.map +1 -1
- package/build/legacy/components/Admonition.cjs +89 -239
- package/build/legacy/components/Admonition.cjs.map +1 -1
- package/build/legacy/components/Admonition.client.cjs +219 -0
- package/build/legacy/components/Admonition.client.cjs.map +1 -0
- package/build/legacy/components/AnimatingUploadIcon.cjs.map +1 -1
- package/build/legacy/components/Avatar.cjs +23 -174
- package/build/legacy/components/Avatar.cjs.map +1 -1
- package/build/legacy/components/Checkbox.cjs +22 -168
- package/build/legacy/components/Checkbox.cjs.map +1 -1
- package/build/legacy/components/DatePicker.client.cjs +129 -272
- package/build/legacy/components/DatePicker.client.cjs.map +1 -1
- package/build/legacy/components/DatePicker.server.cjs +17 -271
- package/build/legacy/components/DatePicker.server.cjs.map +1 -1
- package/build/legacy/components/Dialog.cjs +86 -0
- package/build/legacy/components/Dialog.cjs.map +1 -0
- package/build/legacy/components/Dialog.client.cjs +95 -0
- package/build/legacy/components/Dialog.client.cjs.map +1 -0
- package/build/legacy/components/FileStatus.cjs +62 -212
- package/build/legacy/components/FileStatus.cjs.map +1 -1
- package/build/legacy/components/FileUploader.cjs +29 -180
- package/build/legacy/components/FileUploader.cjs.map +1 -1
- package/build/legacy/components/Input.cjs +20 -172
- package/build/legacy/components/Input.cjs.map +1 -1
- package/build/legacy/components/Modal.cjs.map +1 -1
- package/build/legacy/components/ModalDescription.cjs.map +1 -1
- package/build/legacy/components/ModalHeader.cjs.map +1 -1
- package/build/legacy/components/ModalHeading.cjs.map +1 -1
- package/build/legacy/components/Notification.cjs +26 -176
- package/build/legacy/components/Notification.cjs.map +1 -1
- package/build/legacy/components/Select.cjs +26 -178
- package/build/legacy/components/Select.cjs.map +1 -1
- package/build/legacy/components/Tag.cjs +16 -167
- package/build/legacy/components/Tag.cjs.map +1 -1
- package/build/legacy/components/Toggle.cjs +20 -172
- package/build/legacy/components/Toggle.cjs.map +1 -1
- package/build/legacy/config/defineIcons.cjs +3 -39
- package/build/legacy/config/defineIcons.cjs.map +1 -1
- package/build/legacy/config/{cerbIcons.cjs → index.cjs} +22 -29
- package/build/legacy/config/index.cjs.map +1 -0
- package/build/legacy/config/types.cjs +19 -0
- package/build/legacy/config/types.cjs.map +1 -0
- package/build/legacy/context/cerberus.cjs +46 -0
- package/build/legacy/context/cerberus.cjs.map +1 -0
- package/build/legacy/context/confirm-modal.cjs +105 -321
- package/build/legacy/context/confirm-modal.cjs.map +1 -1
- package/build/legacy/context/cta-modal.cjs +137 -336
- package/build/legacy/context/cta-modal.cjs.map +1 -1
- package/build/legacy/context/notification-center/store.cjs +66 -0
- package/build/legacy/context/notification-center/store.cjs.map +1 -0
- package/build/legacy/context/notification-center/types.cjs +19 -0
- package/build/legacy/context/notification-center/types.cjs.map +1 -0
- package/build/legacy/context/notification-center.cjs +142 -249
- package/build/legacy/context/notification-center.cjs.map +1 -1
- package/build/legacy/context/prompt-modal.cjs +185 -388
- package/build/legacy/context/prompt-modal.cjs.map +1 -1
- package/build/legacy/index.cjs +1577 -1456
- package/build/legacy/index.cjs.map +1 -1
- package/build/modern/_tsup-dts-rollup.d.ts +374 -80
- package/build/modern/{chunk-BVCXVZAF.js → chunk-25HMVHLT.js} +6 -5
- package/build/modern/chunk-25HMVHLT.js.map +1 -0
- package/build/modern/chunk-36N4527B.js +1 -0
- package/build/modern/chunk-5EWCH7AI.js +82 -0
- package/build/modern/chunk-5EWCH7AI.js.map +1 -0
- package/build/modern/chunk-5SNLQZYP.js +25 -0
- package/build/modern/chunk-5SNLQZYP.js.map +1 -0
- package/build/modern/chunk-6BN3XKQF.js +42 -0
- package/build/modern/chunk-6BN3XKQF.js.map +1 -0
- package/build/modern/{chunk-2UXE5PDG.js → chunk-7NN3SJ7W.js} +1 -1
- package/build/modern/chunk-7NN3SJ7W.js.map +1 -0
- package/build/modern/{chunk-KWJ5FKX7.js → chunk-BAWZBF5Q.js} +5 -3
- package/build/modern/chunk-BAWZBF5Q.js.map +1 -0
- package/build/modern/{chunk-6BH5J5GF.js → chunk-BHB56M7S.js} +31 -46
- package/build/modern/chunk-BHB56M7S.js.map +1 -0
- package/build/modern/{chunk-HKJMLWVP.js → chunk-EDARV2EI.js} +5 -4
- package/build/modern/chunk-EDARV2EI.js.map +1 -0
- package/build/modern/{chunk-5OVH3INN.js → chunk-FGCO27TC.js} +25 -53
- package/build/modern/chunk-FGCO27TC.js.map +1 -0
- package/build/modern/{chunk-PVIMOXSO.js → chunk-GCQMH4QA.js} +5 -4
- package/build/modern/chunk-GCQMH4QA.js.map +1 -0
- package/build/modern/chunk-GITT5645.js +20 -0
- package/build/modern/chunk-GITT5645.js.map +1 -0
- package/build/modern/{chunk-TJCFYL5W.js → chunk-IGHMP4WA.js} +1 -20
- package/build/modern/chunk-IGHMP4WA.js.map +1 -0
- package/build/modern/chunk-ISCJ542I.js +82 -0
- package/build/modern/chunk-ISCJ542I.js.map +1 -0
- package/build/modern/{chunk-HVKM54BA.js → chunk-IW3LIRDG.js} +1 -1
- package/build/modern/chunk-IW3LIRDG.js.map +1 -0
- package/build/modern/chunk-JAROS4Q3.js +180 -0
- package/build/modern/chunk-JAROS4Q3.js.map +1 -0
- package/build/modern/{chunk-BE4EOU2P.js → chunk-JIRW4XOJ.js} +1 -1
- package/build/modern/chunk-JIRW4XOJ.js.map +1 -0
- package/build/modern/chunk-KDDPAJMR.js +9 -0
- package/build/modern/chunk-KDDPAJMR.js.map +1 -0
- package/build/modern/{chunk-XOROL3JY.js → chunk-KKHL3ZO4.js} +5 -4
- package/build/modern/chunk-KKHL3ZO4.js.map +1 -0
- package/build/modern/{chunk-U36UZJGZ.js → chunk-MZ3UCDUL.js} +5 -4
- package/build/modern/chunk-MZ3UCDUL.js.map +1 -0
- package/build/modern/{chunk-T2JOPPGL.js → chunk-N24COMHJ.js} +11 -4
- package/build/modern/chunk-N24COMHJ.js.map +1 -0
- package/build/modern/chunk-NJSETNRL.js +68 -0
- package/build/modern/chunk-NJSETNRL.js.map +1 -0
- package/build/modern/{chunk-XY6WL55R.js → chunk-NUMM4TNC.js} +1 -1
- package/build/modern/chunk-NUMM4TNC.js.map +1 -0
- package/build/modern/{chunk-FXLLRVAM.js → chunk-O6LFWUHI.js} +8 -6
- package/build/modern/chunk-O6LFWUHI.js.map +1 -0
- package/build/modern/{chunk-JJZQGR7A.js → chunk-RDRD6ACD.js} +9 -6
- package/build/modern/chunk-RDRD6ACD.js.map +1 -0
- package/build/modern/{chunk-XXWR7UGH.js → chunk-SD3OVTHT.js} +75 -103
- package/build/modern/chunk-SD3OVTHT.js.map +1 -0
- package/build/modern/chunk-TFL56AYR.js +56 -0
- package/build/modern/chunk-TFL56AYR.js.map +1 -0
- package/build/modern/chunk-V3M3ZOQI.js +38 -0
- package/build/modern/chunk-V3M3ZOQI.js.map +1 -0
- package/build/modern/{chunk-QK7R2XJM.js → chunk-XQICKZH4.js} +6 -5
- package/build/modern/chunk-XQICKZH4.js.map +1 -0
- package/build/modern/chunk-XZGXRRSQ.js +31 -0
- package/build/modern/chunk-XZGXRRSQ.js.map +1 -0
- package/build/modern/{chunk-KPUYKHLW.js → chunk-YKKNWILF.js} +71 -15
- package/build/modern/chunk-YKKNWILF.js.map +1 -0
- package/build/modern/{chunk-Q7BRMIBR.js → chunk-ZL6ZITLA.js} +1 -1
- package/build/modern/chunk-ZL6ZITLA.js.map +1 -0
- package/build/modern/components/Accordion.client.js +9 -0
- package/build/modern/components/Accordion.client.js.map +1 -0
- package/build/modern/components/Accordion.js +1 -7
- package/build/modern/components/AccordionItemGroup.js +4 -6
- package/build/modern/components/Admonition.client.js +11 -0
- package/build/modern/components/Admonition.client.js.map +1 -0
- package/build/modern/components/Admonition.js +4 -6
- package/build/modern/components/AnimatingUploadIcon.js +1 -1
- package/build/modern/components/Avatar.js +3 -5
- package/build/modern/components/Checkbox.js +2 -5
- package/build/modern/components/DatePicker.client.js +8 -7
- package/build/modern/components/DatePicker.server.js +3 -13
- package/build/modern/components/Dialog.client.js +10 -0
- package/build/modern/components/Dialog.client.js.map +1 -0
- package/build/modern/components/Dialog.js +24 -0
- package/build/modern/components/Dialog.js.map +1 -0
- package/build/modern/components/FileStatus.js +3 -6
- package/build/modern/components/FileUploader.js +3 -6
- package/build/modern/components/Input.js +2 -5
- package/build/modern/components/Modal.js +1 -1
- package/build/modern/components/ModalDescription.js +1 -1
- package/build/modern/components/ModalHeader.js +1 -1
- package/build/modern/components/ModalHeading.js +1 -1
- package/build/modern/components/Notification.js +2 -5
- package/build/modern/components/Select.js +2 -5
- package/build/modern/components/Tag.js +3 -5
- package/build/modern/components/Toggle.js +2 -5
- package/build/modern/config/defineIcons.js +2 -5
- package/build/modern/config/index.js +14 -0
- package/build/modern/config/index.js.map +1 -0
- package/build/modern/config/types.js +2 -0
- package/build/modern/config/types.js.map +1 -0
- package/build/modern/context/cerberus.js +10 -0
- package/build/modern/context/cerberus.js.map +1 -0
- package/build/modern/context/confirm-modal.js +5 -13
- package/build/modern/context/cta-modal.js +7 -14
- package/build/modern/context/notification-center/store.js +15 -0
- package/build/modern/context/notification-center/store.js.map +1 -0
- package/build/modern/context/notification-center/types.js +1 -0
- package/build/modern/context/notification-center/types.js.map +1 -0
- package/build/modern/context/notification-center.js +5 -7
- package/build/modern/context/prompt-modal.js +8 -15
- package/build/modern/index.js +111 -75
- package/build/modern/index.js.map +1 -1
- package/package.json +4 -8
- package/src/components/Accordion.client.tsx +46 -0
- package/src/components/Accordion.tsx +0 -37
- package/src/components/AccordionItemGroup.tsx +1 -1
- package/src/components/Admonition.client.tsx +73 -0
- package/src/components/Admonition.tsx +1 -70
- package/src/components/AnimatingUploadIcon.tsx +3 -3
- package/src/components/Avatar.tsx +5 -2
- package/src/components/Checkbox.tsx +10 -3
- package/src/components/DatePicker.client.tsx +111 -15
- package/src/components/DatePicker.server.tsx +2 -75
- package/src/components/Dialog.client.tsx +39 -0
- package/src/components/Dialog.tsx +165 -0
- package/src/components/FileStatus.tsx +5 -3
- package/src/components/FileUploader.tsx +3 -2
- package/src/components/Input.tsx +4 -2
- package/src/components/Modal.tsx +1 -16
- package/src/components/ModalDescription.tsx +1 -8
- package/src/components/ModalHeader.tsx +1 -10
- package/src/components/ModalHeading.tsx +1 -8
- package/src/components/Notification.tsx +9 -4
- package/src/components/Select.tsx +5 -2
- package/src/components/Tag.tsx +5 -2
- package/src/components/Toggle.tsx +4 -3
- package/src/config/defineIcons.ts +28 -16
- package/src/config/index.ts +28 -0
- package/src/config/types.ts +42 -0
- package/src/context/cerberus.tsx +44 -0
- package/src/context/confirm-modal.tsx +44 -42
- package/src/context/cta-modal.tsx +25 -38
- package/src/context/notification-center/store.ts +88 -0
- package/src/context/notification-center/types.ts +28 -0
- package/src/context/notification-center.tsx +81 -46
- package/src/context/prompt-modal.tsx +101 -103
- package/src/index.ts +15 -8
- package/build/legacy/config/cerbIcons.cjs.map +0 -1
- package/build/modern/chunk-2UXE5PDG.js.map +0 -1
- package/build/modern/chunk-5OVH3INN.js.map +0 -1
- package/build/modern/chunk-6BH5J5GF.js.map +0 -1
- package/build/modern/chunk-BC5SZDYY.js +0 -132
- package/build/modern/chunk-BC5SZDYY.js.map +0 -1
- package/build/modern/chunk-BE4EOU2P.js.map +0 -1
- package/build/modern/chunk-BVCXVZAF.js.map +0 -1
- package/build/modern/chunk-CRII2HNX.js +0 -55
- package/build/modern/chunk-CRII2HNX.js.map +0 -1
- package/build/modern/chunk-CVTON5DQ.js +0 -162
- package/build/modern/chunk-CVTON5DQ.js.map +0 -1
- package/build/modern/chunk-FXLLRVAM.js.map +0 -1
- package/build/modern/chunk-HKJMLWVP.js.map +0 -1
- package/build/modern/chunk-HVKM54BA.js.map +0 -1
- package/build/modern/chunk-JJZQGR7A.js.map +0 -1
- package/build/modern/chunk-KPUYKHLW.js.map +0 -1
- package/build/modern/chunk-KWJ5FKX7.js.map +0 -1
- package/build/modern/chunk-PVIMOXSO.js.map +0 -1
- package/build/modern/chunk-Q7BRMIBR.js.map +0 -1
- package/build/modern/chunk-QK7R2XJM.js.map +0 -1
- package/build/modern/chunk-QMF5ZNDG.js +0 -27
- package/build/modern/chunk-QMF5ZNDG.js.map +0 -1
- package/build/modern/chunk-QQOWWMZ3.js +0 -138
- package/build/modern/chunk-QQOWWMZ3.js.map +0 -1
- package/build/modern/chunk-T2JOPPGL.js.map +0 -1
- package/build/modern/chunk-TJCFYL5W.js.map +0 -1
- package/build/modern/chunk-U36UZJGZ.js.map +0 -1
- package/build/modern/chunk-XOROL3JY.js.map +0 -1
- package/build/modern/chunk-XXWR7UGH.js.map +0 -1
- package/build/modern/chunk-XY6WL55R.js.map +0 -1
- package/build/modern/config/cerbIcons.js +0 -9
- package/src/config/cerbIcons.ts +0 -73
- /package/build/modern/{config/cerbIcons.js.map → chunk-36N4527B.js.map} +0 -0
|
@@ -41,176 +41,23 @@ function Show(props) {
|
|
|
41
41
|
// src/components/FileUploader.tsx
|
|
42
42
|
var import_recipes2 = require("@cerberus/styled-system/recipes");
|
|
43
43
|
|
|
44
|
-
// src/
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
// src/config/icons/checkbox.icons.tsx
|
|
44
|
+
// src/context/cerberus.tsx
|
|
45
|
+
var import_react2 = require("react");
|
|
48
46
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
role: "img",
|
|
57
|
-
viewBox: "0 0 24 24",
|
|
58
|
-
...props,
|
|
59
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
60
|
-
"path",
|
|
61
|
-
{
|
|
62
|
-
fill: "currentColor",
|
|
63
|
-
d: "M9.714 18 4 12.335l1.818-1.764 3.896 3.824L18.181 6 20 7.803 9.714 18Z"
|
|
64
|
-
}
|
|
65
|
-
)
|
|
66
|
-
}
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
function IndeterminateIcon(props) {
|
|
70
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
71
|
-
"svg",
|
|
72
|
-
{
|
|
73
|
-
"aria-hidden": "true",
|
|
74
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
75
|
-
role: "img",
|
|
76
|
-
fill: "none",
|
|
77
|
-
viewBox: "0 0 24 24",
|
|
78
|
-
...props,
|
|
79
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { fill: "currentColor", d: "M4 11h16v2.667H4z" })
|
|
80
|
-
}
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// src/components/AnimatingUploadIcon.tsx
|
|
85
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
86
|
-
function AnimatingUploadIcon(props) {
|
|
87
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
88
|
-
"svg",
|
|
89
|
-
{
|
|
90
|
-
"aria-hidden": "true",
|
|
91
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
92
|
-
width: props.size ?? "1em",
|
|
93
|
-
height: props.size ?? "1em",
|
|
94
|
-
viewBox: "0 0 24 24",
|
|
95
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
96
|
-
"g",
|
|
97
|
-
{
|
|
98
|
-
fill: "none",
|
|
99
|
-
stroke: "currentColor",
|
|
100
|
-
strokeLinecap: "square",
|
|
101
|
-
strokeLinejoin: "round",
|
|
102
|
-
strokeWidth: 1.5,
|
|
103
|
-
children: [
|
|
104
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
105
|
-
"path",
|
|
106
|
-
{
|
|
107
|
-
"data-name": "animating-trail",
|
|
108
|
-
strokeDasharray: "2 4",
|
|
109
|
-
strokeDashoffset: 6,
|
|
110
|
-
d: "M12 21c-4.97 0 -9 -4.03 -9 -9c0 -4.97 4.03 -9 9 -9",
|
|
111
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
112
|
-
"animate",
|
|
113
|
-
{
|
|
114
|
-
attributeName: "stroke-dashoffset",
|
|
115
|
-
dur: "0.45s",
|
|
116
|
-
repeatCount: "indefinite",
|
|
117
|
-
values: "6;0"
|
|
118
|
-
}
|
|
119
|
-
)
|
|
120
|
-
}
|
|
121
|
-
),
|
|
122
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
123
|
-
"path",
|
|
124
|
-
{
|
|
125
|
-
"data-name": "half-circle",
|
|
126
|
-
strokeDasharray: 32,
|
|
127
|
-
strokeDashoffset: 32,
|
|
128
|
-
d: "M12 3c4.97 0 9 4.03 9 9c0 4.97 -4.03 9 -9 9",
|
|
129
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
130
|
-
"animate",
|
|
131
|
-
{
|
|
132
|
-
fill: "freeze",
|
|
133
|
-
attributeName: "stroke-dashoffset",
|
|
134
|
-
begin: "0.075s",
|
|
135
|
-
dur: "0.3s",
|
|
136
|
-
values: "32;0"
|
|
137
|
-
}
|
|
138
|
-
)
|
|
139
|
-
}
|
|
140
|
-
),
|
|
141
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
142
|
-
"svg",
|
|
143
|
-
{
|
|
144
|
-
"aria-hidden": "true",
|
|
145
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
146
|
-
width: "0.8em",
|
|
147
|
-
height: "0.8em",
|
|
148
|
-
x: "27%",
|
|
149
|
-
y: "27%",
|
|
150
|
-
viewBox: "0 0 24 24",
|
|
151
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
152
|
-
"polygon",
|
|
153
|
-
{
|
|
154
|
-
fill: "currentColor",
|
|
155
|
-
stroke: "currentColor",
|
|
156
|
-
strokeWidth: 0.8,
|
|
157
|
-
opacity: "1",
|
|
158
|
-
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 ",
|
|
159
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
160
|
-
"animate",
|
|
161
|
-
{
|
|
162
|
-
fill: "freeze",
|
|
163
|
-
attributeName: "opacity",
|
|
164
|
-
values: "1;0;1",
|
|
165
|
-
dur: "2s",
|
|
166
|
-
repeatCount: "indefinite"
|
|
167
|
-
}
|
|
168
|
-
)
|
|
169
|
-
}
|
|
170
|
-
)
|
|
171
|
-
}
|
|
172
|
-
)
|
|
173
|
-
]
|
|
174
|
-
}
|
|
175
|
-
)
|
|
176
|
-
}
|
|
177
|
-
);
|
|
47
|
+
var CerberusContext = (0, import_react2.createContext)(null);
|
|
48
|
+
function useCerberusContext() {
|
|
49
|
+
const context = (0, import_react2.useContext)(CerberusContext);
|
|
50
|
+
if (!context) {
|
|
51
|
+
throw new Error("useCerberus must be used within a CerberusProvider");
|
|
52
|
+
}
|
|
53
|
+
return context;
|
|
178
54
|
}
|
|
179
55
|
|
|
180
|
-
// src/config/cerbIcons.ts
|
|
181
|
-
var defaultIcons = {
|
|
182
|
-
accordionIndicator: import_icons.ChevronDown,
|
|
183
|
-
avatar: import_icons.UserFilled,
|
|
184
|
-
calendar: import_icons.Calendar,
|
|
185
|
-
calendarPrev: import_icons.ChevronLeft,
|
|
186
|
-
calendarNext: import_icons.ChevronRight,
|
|
187
|
-
checkbox: CheckmarkIcon,
|
|
188
|
-
close: import_icons.Close,
|
|
189
|
-
confirmModal: import_icons.Information,
|
|
190
|
-
delete: import_icons.TrashCan,
|
|
191
|
-
promptModal: import_icons.Information,
|
|
192
|
-
waitingFileUploader: import_icons.CloudUpload,
|
|
193
|
-
fileUploader: AnimatingUploadIcon,
|
|
194
|
-
indeterminate: IndeterminateIcon,
|
|
195
|
-
infoNotification: import_icons.Information,
|
|
196
|
-
successNotification: import_icons.CheckmarkOutline,
|
|
197
|
-
warningNotification: import_icons.WarningAlt,
|
|
198
|
-
dangerNotification: import_icons.WarningFilled,
|
|
199
|
-
invalid: import_icons.WarningFilled,
|
|
200
|
-
invalidAlt: import_icons.Warning,
|
|
201
|
-
redo: import_icons.Restart,
|
|
202
|
-
selectArrow: import_icons.ChevronDown,
|
|
203
|
-
toggleChecked: import_icons.Checkmark
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
// src/config/defineIcons.ts
|
|
207
|
-
var $cerberusIcons = defaultIcons;
|
|
208
|
-
|
|
209
56
|
// src/components/Avatar.tsx
|
|
210
57
|
var import_css = require("@cerberus/styled-system/css");
|
|
211
58
|
var import_patterns = require("@cerberus/styled-system/patterns");
|
|
212
59
|
var import_recipes = require("@cerberus/styled-system/recipes");
|
|
213
|
-
var
|
|
60
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
214
61
|
function Avatar(props) {
|
|
215
62
|
const {
|
|
216
63
|
ariaLabel,
|
|
@@ -223,9 +70,10 @@ function Avatar(props) {
|
|
|
223
70
|
icon,
|
|
224
71
|
...nativeProps
|
|
225
72
|
} = props;
|
|
226
|
-
const {
|
|
73
|
+
const { icons } = useCerberusContext();
|
|
74
|
+
const { avatar: AvatarIcon } = icons;
|
|
227
75
|
const initials = (ariaLabel || "").split(" ").map((word) => word[0]).join("").slice(0, 2);
|
|
228
|
-
return /* @__PURE__ */ (0,
|
|
76
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
229
77
|
"div",
|
|
230
78
|
{
|
|
231
79
|
...nativeProps,
|
|
@@ -234,19 +82,19 @@ function Avatar(props) {
|
|
|
234
82
|
(0, import_recipes.avatar)({ gradient, size }),
|
|
235
83
|
(0, import_patterns.circle)()
|
|
236
84
|
),
|
|
237
|
-
children: /* @__PURE__ */ (0,
|
|
85
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
238
86
|
Show,
|
|
239
87
|
{
|
|
240
88
|
when: Boolean(src) || Boolean(as),
|
|
241
|
-
fallback: /* @__PURE__ */ (0,
|
|
89
|
+
fallback: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
242
90
|
Show,
|
|
243
91
|
{
|
|
244
92
|
when: Boolean(initials),
|
|
245
|
-
fallback: /* @__PURE__ */ (0,
|
|
93
|
+
fallback: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
246
94
|
Show,
|
|
247
95
|
{
|
|
248
96
|
when: Boolean(icon),
|
|
249
|
-
fallback: /* @__PURE__ */ (0,
|
|
97
|
+
fallback: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
250
98
|
AvatarIcon,
|
|
251
99
|
{
|
|
252
100
|
size: iconSizeMap[size]
|
|
@@ -258,11 +106,11 @@ function Avatar(props) {
|
|
|
258
106
|
children: initials
|
|
259
107
|
}
|
|
260
108
|
),
|
|
261
|
-
children: /* @__PURE__ */ (0,
|
|
109
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
262
110
|
Show,
|
|
263
111
|
{
|
|
264
112
|
when: Boolean(as),
|
|
265
|
-
fallback: /* @__PURE__ */ (0,
|
|
113
|
+
fallback: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
266
114
|
"img",
|
|
267
115
|
{
|
|
268
116
|
alt: props.ariaLabel,
|
|
@@ -298,12 +146,13 @@ var iconSizeMap = {
|
|
|
298
146
|
};
|
|
299
147
|
|
|
300
148
|
// src/components/FileUploader.tsx
|
|
301
|
-
var
|
|
149
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
302
150
|
function FileUploader(props) {
|
|
303
151
|
var _a;
|
|
152
|
+
const { icons } = useCerberusContext();
|
|
304
153
|
const styles = (0, import_recipes2.fileUploader)();
|
|
305
|
-
const { waitingFileUploader: Icon } =
|
|
306
|
-
return /* @__PURE__ */ (0,
|
|
154
|
+
const { waitingFileUploader: Icon } = icons;
|
|
155
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
307
156
|
"div",
|
|
308
157
|
{
|
|
309
158
|
...props.disabled ? { "aria-disabled": true } : {},
|
|
@@ -314,17 +163,17 @@ function FileUploader(props) {
|
|
|
314
163
|
styles.container
|
|
315
164
|
),
|
|
316
165
|
children: [
|
|
317
|
-
/* @__PURE__ */ (0,
|
|
166
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: styles.icon, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
318
167
|
Avatar,
|
|
319
168
|
{
|
|
320
169
|
gradient: "charon-light",
|
|
321
170
|
ariaLabel: "",
|
|
322
|
-
icon: /* @__PURE__ */ (0,
|
|
171
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon, {}),
|
|
323
172
|
size: "md",
|
|
324
173
|
src: ""
|
|
325
174
|
}
|
|
326
175
|
) }),
|
|
327
|
-
/* @__PURE__ */ (0,
|
|
176
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
328
177
|
"label",
|
|
329
178
|
{
|
|
330
179
|
className: (0, import_css2.cx)(
|
|
@@ -335,12 +184,12 @@ function FileUploader(props) {
|
|
|
335
184
|
),
|
|
336
185
|
htmlFor: props.name,
|
|
337
186
|
children: [
|
|
338
|
-
/* @__PURE__ */ (0,
|
|
187
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Show, { when: Boolean(props.heading), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: styles.heading, children: props.heading }) }),
|
|
339
188
|
"Import ",
|
|
340
189
|
(_a = props.accept) == null ? void 0 : _a.replace(",", ", "),
|
|
341
190
|
" files",
|
|
342
|
-
/* @__PURE__ */ (0,
|
|
343
|
-
/* @__PURE__ */ (0,
|
|
191
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: styles.description, children: "Click to select files" }),
|
|
192
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
344
193
|
"input",
|
|
345
194
|
{
|
|
346
195
|
...props,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/FileUploader.tsx","../../../src/components/Show.tsx","../../../src/config/cerbIcons.ts","../../../src/config/icons/checkbox.icons.tsx","../../../src/components/AnimatingUploadIcon.tsx","../../../src/config/defineIcons.ts","../../../src/components/Avatar.tsx"],"sourcesContent":["'use client'\n\nimport { cx } from '@cerberus/styled-system/css'\nimport { vstack } from '@cerberus/styled-system/patterns'\nimport { type InputHTMLAttributes } from 'react'\nimport { Show } from './Show'\nimport { fileUploader } from '@cerberus/styled-system/recipes'\nimport { $cerberusIcons } from '../config/defineIcons'\nimport { Avatar } from './Avatar'\n\nexport interface FileUploaderProps\n extends InputHTMLAttributes<HTMLInputElement> {\n /**\n * The optional heading to display in the FileUploader component.\n */\n heading?: string\n /**\n * The name of the file input element.\n */\n name: string\n /**\n * Disable the FileUploader component. Good for single-use file uploads.\n */\n disabled?: boolean\n}\n\n/**\n * A component that allows the user to upload files.\n * @see https://cerberus.digitalu.design/react/file-uploader\n */\nexport function FileUploader(props: FileUploaderProps) {\n const styles = fileUploader()\n const { waitingFileUploader: Icon } = $cerberusIcons\n\n return (\n <div\n {...(props.disabled ? { 'aria-disabled': true } : {})}\n className={cx(\n vstack({\n justify: 'center',\n }),\n styles.container,\n )}\n >\n <div className={styles.icon}>\n <Avatar\n gradient=\"charon-light\"\n ariaLabel=\"\"\n icon={<Icon />}\n size=\"md\"\n src=\"\"\n />\n </div>\n\n <label\n className={cx(\n vstack({\n justify: 'center',\n }),\n styles.label,\n )}\n htmlFor={props.name}\n >\n <Show when={Boolean(props.heading)}>\n <p className={styles.heading}>{props.heading}</p>\n </Show>\n Import {props.accept?.replace(',', ', ')} files\n <p className={styles.description}>Click to select files</p>\n <input\n {...props}\n className={cx(props.className, styles.input)}\n type=\"file\"\n />\n </label>\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","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","import { css, cx } from '@cerberus/styled-system/css'\nimport { circle } from '@cerberus/styled-system/patterns'\nimport {\n avatar,\n type AvatarVariantProps,\n} from '@cerberus/styled-system/recipes'\nimport { $cerberusIcons } from '../config/defineIcons'\nimport type { HtmlHTMLAttributes, ReactNode } from 'react'\nimport { Show } from './Show'\n\n/**\n * This module contains the Avatar component.\n * @module\n */\n\nexport type SharedAvatarProps = {\n /**\n * An optional icon to show when no src or ariaLabel is provided.\n */\n icon?: ReactNode\n /**\n * The size of the avatar.\n */\n width?: number\n /**\n * The size of the avatar.\n */\n height?: number\n}\nexport type AvatarImageProps = HtmlHTMLAttributes<HTMLImageElement> &\n SharedAvatarProps & {\n /**\n * The aria-label for the avatar needed for accessibility.\n */\n ariaLabel: string\n /**\n * An optional element to replace the image. Recommended for Next.js Image component.\n */\n as?: never\n /**\n * The source of the image.\n */\n src: string\n }\nexport type AvatarAsProps = SharedAvatarProps & {\n /**\n * An optional element to replace the image. Recommended for Next.js Image component.\n */\n as: ReactNode\n /**\n * The aria-label for the avatar needed for accessibility.\n */\n ariaLabel?: never\n /**\n * The source of the image.\n */\n src?: never\n}\n\nexport type AvatarProps = (HtmlHTMLAttributes<HTMLDivElement> &\n AvatarVariantProps) &\n (AvatarImageProps | AvatarAsProps)\n\n/**\n * The Avatar component is used to represent a user or entity. It will show an image if src provided, otherwise it will show the ariaLabel of the ariaLabel. If the ariaLabel is empty, it will show a `defineIcons().avatar` icon.\n * @see https://cerberus.digitalu.design/react/avatar\n * @example\n * ```tsx\n * <Avatar\n * ariaLabel=\"Protector Cerberus\"\n * src=\"https://cerberus.digitalu.design/logo.svg\"\n * />\n * ```\n */\nexport function Avatar(props: AvatarProps) {\n const {\n ariaLabel,\n as,\n gradient,\n size,\n src,\n width,\n height,\n icon,\n ...nativeProps\n } = props\n const { avatar: AvatarIcon } = $cerberusIcons\n const initials = (ariaLabel || '')\n .split(' ')\n .map((word) => word[0])\n .join('')\n .slice(0, 2)\n\n return (\n <div\n {...nativeProps}\n className={cx(\n nativeProps.className,\n avatar({ gradient, size }),\n circle(),\n )}\n >\n <Show\n when={Boolean(src) || Boolean(as)}\n fallback={\n <Show\n when={Boolean(initials)}\n fallback={\n <Show\n when={Boolean(icon)}\n fallback={\n <AvatarIcon\n size={iconSizeMap[size as keyof typeof iconSizeMap]}\n />\n }\n >\n {icon}\n </Show>\n }\n >\n {initials}\n </Show>\n }\n >\n <Show\n when={Boolean(as)}\n fallback={\n <img\n alt={props.ariaLabel}\n className={css({\n h: 'full',\n objectFit: 'cover',\n w: 'full',\n })}\n decoding=\"async\"\n loading=\"lazy\"\n src={src}\n height={height}\n width={width}\n />\n }\n >\n {as}\n </Show>\n </Show>\n </div>\n )\n}\n\nconst iconSizeMap = {\n xs: 16,\n sm: 16,\n md: 20,\n lg: 34,\n xl: 32,\n '2xl': 32,\n '3xl': 32,\n '4xl': 32,\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAAA,cAAmB;AACnB,IAAAC,mBAAuB;;;ACDvB,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,IAAAC,kBAA6B;;;AEN7B,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,SAA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C5B,QAAM,EAAE,qBAAqB,KAAK,IAAI;AAEtC,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAI,MAAM,WAAW,EAAE,iBAAiB,KAAK,IAAI,CAAC;AAAA,MACnD,eAAW;AAAA,YACT,yBAAO;AAAA,UACL,SAAS;AAAA,QACX,CAAC;AAAA,QACD,OAAO;AAAA,MACT;AAAA,MAEA;AAAA,qDAAC,SAAI,WAAW,OAAO,MACrB;AAAA,UAAC;AAAA;AAAA,YACC,UAAS;AAAA,YACT,WAAU;AAAA,YACV,MAAM,6CAAC,QAAK;AAAA,YACZ,MAAK;AAAA,YACL,KAAI;AAAA;AAAA,QACN,GACF;AAAA,QAEA;AAAA,UAAC;AAAA;AAAA,YACC,eAAW;AAAA,kBACT,yBAAO;AAAA,gBACL,SAAS;AAAA,cACX,CAAC;AAAA,cACD,OAAO;AAAA,YACT;AAAA,YACA,SAAS,MAAM;AAAA,YAEf;AAAA,2DAAC,QAAK,MAAM,QAAQ,MAAM,OAAO,GAC/B,uDAAC,OAAE,WAAW,OAAO,SAAU,gBAAM,SAAQ,GAC/C;AAAA,cAAO;AAAA,eACC,WAAM,WAAN,mBAAc,QAAQ,KAAK;AAAA,cAAM;AAAA,cACzC,6CAAC,OAAE,WAAW,OAAO,aAAa,mCAAqB;AAAA,cACvD;AAAA,gBAAC;AAAA;AAAA,kBACE,GAAG;AAAA,kBACJ,eAAW,gBAAG,MAAM,WAAW,OAAO,KAAK;AAAA,kBAC3C,MAAK;AAAA;AAAA,cACP;AAAA;AAAA;AAAA,QACF;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["import_css","import_patterns","import_recipes","import_jsx_runtime","import_jsx_runtime","import_jsx_runtime"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/FileUploader.tsx","../../../src/components/Show.tsx","../../../src/context/cerberus.tsx","../../../src/components/Avatar.tsx"],"sourcesContent":["'use client'\n\nimport { cx } from '@cerberus/styled-system/css'\nimport { vstack } from '@cerberus/styled-system/patterns'\nimport { type InputHTMLAttributes } from 'react'\nimport { Show } from './Show'\nimport { fileUploader } from '@cerberus/styled-system/recipes'\nimport { useCerberusContext } from '../context/cerberus'\nimport { Avatar } from './Avatar'\n\nexport interface FileUploaderProps\n extends InputHTMLAttributes<HTMLInputElement> {\n /**\n * The optional heading to display in the FileUploader component.\n */\n heading?: string\n /**\n * The name of the file input element.\n */\n name: string\n /**\n * Disable the FileUploader component. Good for single-use file uploads.\n */\n disabled?: boolean\n}\n\n/**\n * A component that allows the user to upload files.\n * @see https://cerberus.digitalu.design/react/file-uploader\n */\nexport function FileUploader(props: FileUploaderProps) {\n const { icons } = useCerberusContext()\n const styles = fileUploader()\n const { waitingFileUploader: Icon } = icons\n\n return (\n <div\n {...(props.disabled ? { 'aria-disabled': true } : {})}\n className={cx(\n vstack({\n justify: 'center',\n }),\n styles.container,\n )}\n >\n <div className={styles.icon}>\n <Avatar\n gradient=\"charon-light\"\n ariaLabel=\"\"\n icon={<Icon />}\n size=\"md\"\n src=\"\"\n />\n </div>\n\n <label\n className={cx(\n vstack({\n justify: 'center',\n }),\n styles.label,\n )}\n htmlFor={props.name}\n >\n <Show when={Boolean(props.heading)}>\n <p className={styles.heading}>{props.heading}</p>\n </Show>\n Import {props.accept?.replace(',', ', ')} files\n <p className={styles.description}>Click to select files</p>\n <input\n {...props}\n className={cx(props.className, styles.input)}\n type=\"file\"\n />\n </label>\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 { 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","'use client'\n\nimport { css, cx } from '@cerberus/styled-system/css'\nimport { circle } from '@cerberus/styled-system/patterns'\nimport {\n avatar,\n type AvatarVariantProps,\n} from '@cerberus/styled-system/recipes'\nimport type { HtmlHTMLAttributes, ReactNode } from 'react'\nimport { Show } from './Show'\nimport { useCerberusContext } from '../context/cerberus'\n\n/**\n * This module contains the Avatar component.\n * @module\n */\n\nexport type SharedAvatarProps = {\n /**\n * An optional icon to show when no src or ariaLabel is provided.\n */\n icon?: ReactNode\n /**\n * The size of the avatar.\n */\n width?: number\n /**\n * The size of the avatar.\n */\n height?: number\n}\nexport type AvatarImageProps = HtmlHTMLAttributes<HTMLImageElement> &\n SharedAvatarProps & {\n /**\n * The aria-label for the avatar needed for accessibility.\n */\n ariaLabel: string\n /**\n * An optional element to replace the image. Recommended for Next.js Image component.\n */\n as?: never\n /**\n * The source of the image.\n */\n src: string\n }\nexport type AvatarAsProps = SharedAvatarProps & {\n /**\n * An optional element to replace the image. Recommended for Next.js Image component.\n */\n as: ReactNode\n /**\n * The aria-label for the avatar needed for accessibility.\n */\n ariaLabel?: never\n /**\n * The source of the image.\n */\n src?: never\n}\n\nexport type AvatarProps = (HtmlHTMLAttributes<HTMLDivElement> &\n AvatarVariantProps) &\n (AvatarImageProps | AvatarAsProps)\n\n/**\n * The Avatar component is used to represent a user or entity. It will show an image if src provided, otherwise it will show the ariaLabel of the ariaLabel. If the ariaLabel is empty, it will show a `defineIcons().avatar` icon.\n * @see https://cerberus.digitalu.design/react/avatar\n * @example\n * ```tsx\n * <Avatar\n * ariaLabel=\"Protector Cerberus\"\n * src=\"https://cerberus.digitalu.design/logo.svg\"\n * />\n * ```\n */\nexport function Avatar(props: AvatarProps) {\n const {\n ariaLabel,\n as,\n gradient,\n size,\n src,\n width,\n height,\n icon,\n ...nativeProps\n } = props\n const { icons } = useCerberusContext()\n const { avatar: AvatarIcon } = icons\n const initials = (ariaLabel || '')\n .split(' ')\n .map((word) => word[0])\n .join('')\n .slice(0, 2)\n\n return (\n <div\n {...nativeProps}\n className={cx(\n nativeProps.className,\n avatar({ gradient, size }),\n circle(),\n )}\n >\n <Show\n when={Boolean(src) || Boolean(as)}\n fallback={\n <Show\n when={Boolean(initials)}\n fallback={\n <Show\n when={Boolean(icon)}\n fallback={\n <AvatarIcon\n size={iconSizeMap[size as keyof typeof iconSizeMap]}\n />\n }\n >\n {icon}\n </Show>\n }\n >\n {initials}\n </Show>\n }\n >\n <Show\n when={Boolean(as)}\n fallback={\n <img\n alt={props.ariaLabel}\n className={css({\n h: 'full',\n objectFit: 'cover',\n w: 'full',\n })}\n decoding=\"async\"\n loading=\"lazy\"\n src={src}\n height={height}\n width={width}\n />\n }\n >\n {as}\n </Show>\n </Show>\n </div>\n )\n}\n\nconst iconSizeMap = {\n xs: 16,\n sm: 16,\n md: 20,\n lg: 34,\n xl: 32,\n '2xl': 32,\n '3xl': 32,\n '4xl': 32,\n}\n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MAEA;AAAA,qDAAC,SAAI,WAAW,OAAO,MACrB;AAAA,UAAC;AAAA;AAAA,YACC,UAAS;AAAA,YACT,WAAU;AAAA,YACV,MAAM,6CAAC,QAAK;AAAA,YACZ,MAAK;AAAA,YACL,KAAI;AAAA;AAAA,QACN,GACF;AAAA,QAEA;AAAA,UAAC;AAAA;AAAA,YACC,eAAW;AAAA,kBACT,yBAAO;AAAA,gBACL,SAAS;AAAA,cACX,CAAC;AAAA,cACD,OAAO;AAAA,YACT;AAAA,YACA,SAAS,MAAM;AAAA,YAEf;AAAA,2DAAC,QAAK,MAAM,QAAQ,MAAM,OAAO,GAC/B,uDAAC,OAAE,WAAW,OAAO,SAAU,gBAAM,SAAQ,GAC/C;AAAA,cAAO;AAAA,eACC,WAAM,WAAN,mBAAc,QAAQ,KAAK;AAAA,cAAM;AAAA,cACzC,6CAAC,OAAE,WAAW,OAAO,aAAa,mCAAqB;AAAA,cACvD;AAAA,gBAAC;AAAA;AAAA,kBACE,GAAG;AAAA,kBACJ,eAAW,gBAAG,MAAM,WAAW,OAAO,KAAK;AAAA,kBAC3C,MAAK;AAAA;AAAA,cACP;AAAA;AAAA;AAAA,QACF;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["import_css","import_patterns","import_recipes","import_react","import_jsx_runtime","import_jsx_runtime"]}
|
|
@@ -39,193 +39,41 @@ function useFieldContext() {
|
|
|
39
39
|
return context;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
// src/
|
|
43
|
-
var
|
|
44
|
-
|
|
45
|
-
// src/config/icons/checkbox.icons.tsx
|
|
42
|
+
// src/context/cerberus.tsx
|
|
43
|
+
var import_react2 = require("react");
|
|
46
44
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
role: "img",
|
|
55
|
-
viewBox: "0 0 24 24",
|
|
56
|
-
...props,
|
|
57
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime2.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_runtime2.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_runtime2.jsx)("path", { fill: "currentColor", d: "M4 11h16v2.667H4z" })
|
|
78
|
-
}
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// src/components/AnimatingUploadIcon.tsx
|
|
83
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
84
|
-
function AnimatingUploadIcon(props) {
|
|
85
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.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_runtime3.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_runtime3.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_runtime3.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_runtime3.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_runtime3.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_runtime3.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_runtime3.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_runtime3.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
|
-
);
|
|
45
|
+
var CerberusContext = (0, import_react2.createContext)(null);
|
|
46
|
+
function useCerberusContext() {
|
|
47
|
+
const context = (0, import_react2.useContext)(CerberusContext);
|
|
48
|
+
if (!context) {
|
|
49
|
+
throw new Error("useCerberus must be used within a CerberusProvider");
|
|
50
|
+
}
|
|
51
|
+
return context;
|
|
176
52
|
}
|
|
177
53
|
|
|
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
54
|
// src/components/Show.tsx
|
|
208
|
-
var
|
|
55
|
+
var import_react3 = require("react");
|
|
209
56
|
function Show(props) {
|
|
210
57
|
const { when, children, fallback } = props;
|
|
211
|
-
const condition = (0,
|
|
212
|
-
return (0,
|
|
58
|
+
const condition = (0, import_react3.useMemo)(() => when ?? false, [when]);
|
|
59
|
+
return (0, import_react3.useMemo)(() => {
|
|
213
60
|
if (condition) return children;
|
|
214
61
|
return fallback ?? null;
|
|
215
62
|
}, [condition, children, fallback]);
|
|
216
63
|
}
|
|
217
64
|
|
|
218
65
|
// src/components/Input.tsx
|
|
219
|
-
var
|
|
66
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
220
67
|
function Input(props) {
|
|
221
68
|
const { describedBy, size, startIcon, endIcon, ...nativeProps } = props;
|
|
222
69
|
const inputStyles = (0, import_recipes.input)({ size });
|
|
223
70
|
const { invalid, ...fieldStates } = useFieldContext();
|
|
224
71
|
const hasEndIcon = Boolean(endIcon);
|
|
225
|
-
const {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
/* @__PURE__ */ (0,
|
|
72
|
+
const { icons } = useCerberusContext();
|
|
73
|
+
const { invalid: InvalidIcon } = icons;
|
|
74
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: inputStyles.root, children: [
|
|
75
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Show, { when: Boolean(startIcon), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: inputStyles.startIcon, children: startIcon }) }),
|
|
76
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
229
77
|
"input",
|
|
230
78
|
{
|
|
231
79
|
...nativeProps,
|
|
@@ -236,8 +84,8 @@ function Input(props) {
|
|
|
236
84
|
className: (0, import_css.cx)("peer", nativeProps.className, inputStyles.input)
|
|
237
85
|
}
|
|
238
86
|
),
|
|
239
|
-
/* @__PURE__ */ (0,
|
|
240
|
-
/* @__PURE__ */ (0,
|
|
87
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Show, { when: invalid, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(InvalidIcon, { className: inputStyles.icon }) }),
|
|
88
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Show, { when: hasEndIcon && !invalid, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: inputStyles.icon, children: endIcon }) })
|
|
241
89
|
] });
|
|
242
90
|
}
|
|
243
91
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Input.tsx","../../../src/context/field.tsx","../../../src/config/cerbIcons.ts","../../../src/config/icons/checkbox.icons.tsx","../../../src/components/AnimatingUploadIcon.tsx","../../../src/config/defineIcons.ts","../../../src/components/Show.tsx"],"sourcesContent":["'use client'\n\nimport type { InputHTMLAttributes, ReactNode } from 'react'\nimport { input, type InputVariantProps } from '@cerberus/styled-system/recipes'\nimport { cx } from '@cerberus/styled-system/css'\nimport { useFieldContext } from '../context/field'\nimport { $cerberusIcons } from '../config/defineIcons'\nimport { Show } from './Show'\n\nexport interface InputBaseProps\n extends Omit<InputHTMLAttributes<HTMLInputElement>, 'id' | 'size'> {\n /**\n * The id of the FieldMessage component used to describe the input. Required for accessibility.\n */\n describedBy?: string\n /**\n * The unique identifier for the input element. Required for accessibility.\n */\n id: string\n /**\n * An optional icon to display at the start of the input.\n */\n startIcon?: ReactNode\n /**\n * An optional icon to display at the end of the input.\n */\n endIcon?: ReactNode\n}\nexport type InputProps = InputBaseProps & InputVariantProps\n\n/**\n * A component that allows the user to input text. Must be wrapped in a Field\n * component to keep track of the state for entire group of elements related to\n * the field.\n * @see https://cerberus.digitalu.design/react/input\n */\nexport function Input(props: InputProps) {\n const { describedBy, size, startIcon, endIcon, ...nativeProps } = props\n const inputStyles = input({ size })\n const { invalid, ...fieldStates } = useFieldContext()\n const hasEndIcon = Boolean(endIcon)\n const { invalid: InvalidIcon } = $cerberusIcons\n\n return (\n <div className={inputStyles.root}>\n <Show when={Boolean(startIcon)}>\n <span className={inputStyles.startIcon}>{startIcon}</span>\n </Show>\n\n <input\n {...nativeProps}\n {...fieldStates}\n {...(describedBy && { 'aria-describedby': describedBy })}\n {...(invalid && { 'aria-invalid': true })}\n data-start-icon={Boolean(startIcon)}\n className={cx('peer', nativeProps.className, inputStyles.input)}\n />\n\n <Show when={invalid}>\n <InvalidIcon className={inputStyles.icon} />\n </Show>\n <Show when={hasEndIcon && !invalid}>\n <span className={inputStyles.icon}>{endIcon}</span>\n </Show>\n </div>\n )\n}\n","'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","'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"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA8C;AAC9C,iBAAmB;;;ACFnB,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;;;ACtEA,mBAiBO;;;ACKD,IAAAA,sBAAA;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,EACF;AAEJ;AAOO,SAAS,kBAAkB,OAA+B;AAC/D,SACE;AAAA,IAAC;AAAA;AAAA,MACC,eAAY;AAAA,MACZ,OAAM;AAAA,MACN,MAAK;AAAA,MACL,MAAK;AAAA,MACL,SAAQ;AAAA,MACP,GAAG;AAAA,M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AAA,iDAAC,QAAK,MAAM,QAAQ,SAAS,GAC3B,uDAAC,UAAK,WAAW,YAAY,WAAY,qBAAU,GACrD;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACH,GAAG;AAAA,QACH,GAAI,eAAe,EAAE,oBAAoB,YAAY;AAAA,QACrD,GAAI,WAAW,EAAE,gBAAgB,KAAK;AAAA,QACvC,mBAAiB,QAAQ,SAAS;AAAA,QAClC,eAAW,eAAG,QAAQ,YAAY,WAAW,YAAY,KAAK;AAAA;AAAA,IAChE;AAAA,IAEA,6CAAC,QAAK,MAAM,SACV,uDAAC,eAAY,WAAW,YAAY,MAAM,GAC5C;AAAA,IACA,6CAAC,QAAK,MAAM,cAAc,CAAC,SACzB,uDAAC,UAAK,WAAW,YAAY,MAAO,mBAAQ,GAC9C;AAAA,KACF;AAEJ;","names":["import_jsx_runtime","import_jsx_runtime","import_react","import_jsx_runtime"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Input.tsx","../../../src/context/field.tsx","../../../src/context/cerberus.tsx","../../../src/components/Show.tsx"],"sourcesContent":["'use client'\n\nimport type { InputHTMLAttributes, ReactNode } from 'react'\nimport { input, type InputVariantProps } from '@cerberus/styled-system/recipes'\nimport { cx } from '@cerberus/styled-system/css'\nimport { useFieldContext } from '../context/field'\nimport { useCerberusContext } from '../context/cerberus'\nimport { Show } from './Show'\n\nexport interface InputBaseProps\n extends Omit<InputHTMLAttributes<HTMLInputElement>, 'id' | 'size'> {\n /**\n * The id of the FieldMessage component used to describe the input. Required for accessibility.\n */\n describedBy?: string\n /**\n * The unique identifier for the input element. Required for accessibility.\n */\n id: string\n /**\n * An optional icon to display at the start of the input.\n */\n startIcon?: ReactNode\n /**\n * An optional icon to display at the end of the input.\n */\n endIcon?: ReactNode\n}\nexport type InputProps = InputBaseProps & InputVariantProps\n\n/**\n * A component that allows the user to input text. Must be wrapped in a Field\n * component to keep track of the state for entire group of elements related to\n * the field.\n * @see https://cerberus.digitalu.design/react/input\n */\nexport function Input(props: InputProps) {\n const { describedBy, size, startIcon, endIcon, ...nativeProps } = props\n const inputStyles = input({ size })\n const { invalid, ...fieldStates } = useFieldContext()\n const hasEndIcon = Boolean(endIcon)\n\n const { icons } = useCerberusContext()\n const { invalid: InvalidIcon } = icons\n\n return (\n <div className={inputStyles.root}>\n <Show when={Boolean(startIcon)}>\n <span className={inputStyles.startIcon}>{startIcon}</span>\n </Show>\n\n <input\n {...nativeProps}\n {...fieldStates}\n {...(describedBy && { 'aria-describedby': describedBy })}\n {...(invalid && { 'aria-invalid': true })}\n data-start-icon={Boolean(startIcon)}\n className={cx('peer', nativeProps.className, inputStyles.input)}\n />\n\n <Show when={invalid}>\n <InvalidIcon className={inputStyles.icon} />\n </Show>\n <Show when={hasEndIcon && !invalid}>\n <span className={inputStyles.icon}>{endIcon}</span>\n </Show>\n </div>\n )\n}\n","'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","'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"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA8C;AAC9C,iBAAmB;;;ACFnB,mBAKO;AA+CH;A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