@cerberus-design/react 0.10.4 → 0.11.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 +244 -2
- package/build/legacy/components/Admonition.cjs +419 -0
- package/build/legacy/components/Admonition.cjs.map +1 -0
- package/build/legacy/components/AnimatingUploadIcon.cjs +124 -0
- package/build/legacy/components/AnimatingUploadIcon.cjs.map +1 -0
- package/build/legacy/components/Avatar.cjs +110 -13
- package/build/legacy/components/Avatar.cjs.map +1 -1
- package/build/legacy/components/Checkbox.cjs +107 -10
- package/build/legacy/components/Checkbox.cjs.map +1 -1
- package/build/legacy/components/CircularProgress.cjs +19 -5
- package/build/legacy/components/CircularProgress.cjs.map +1 -1
- package/build/legacy/components/Fieldset.cjs +66 -0
- package/build/legacy/components/Fieldset.cjs.map +1 -0
- package/build/legacy/components/FieldsetLabel.cjs +49 -0
- package/build/legacy/components/FieldsetLabel.cjs.map +1 -0
- package/build/legacy/components/FileStatus.cjs +138 -39
- package/build/legacy/components/FileStatus.cjs.map +1 -1
- package/build/legacy/components/FileUploader.cjs +120 -22
- package/build/legacy/components/FileUploader.cjs.map +1 -1
- package/build/legacy/components/Input.cjs +108 -11
- package/build/legacy/components/Input.cjs.map +1 -1
- package/build/legacy/components/Label.cjs +1 -1
- package/build/legacy/components/Label.cjs.map +1 -1
- package/build/legacy/components/Legend.cjs +95 -0
- package/build/legacy/components/Legend.cjs.map +1 -0
- package/build/legacy/components/ModalHeader.cjs +2 -2
- package/build/legacy/components/ModalHeader.cjs.map +1 -1
- package/build/legacy/components/Notification.cjs +109 -12
- package/build/legacy/components/Notification.cjs.map +1 -1
- package/build/legacy/components/Radio.cjs +27 -14
- package/build/legacy/components/Radio.cjs.map +1 -1
- package/build/legacy/components/Select.cjs +111 -14
- package/build/legacy/components/Select.cjs.map +1 -1
- package/build/legacy/components/Tag.cjs +106 -9
- package/build/legacy/components/Tag.cjs.map +1 -1
- package/build/legacy/components/Th.cjs +4 -1
- package/build/legacy/components/Th.cjs.map +1 -1
- package/build/legacy/components/Toggle.cjs +108 -11
- package/build/legacy/components/Toggle.cjs.map +1 -1
- package/build/legacy/config/cerbIcons.cjs +102 -5
- package/build/legacy/config/cerbIcons.cjs.map +1 -1
- package/build/legacy/config/defineIcons.cjs +102 -5
- package/build/legacy/config/defineIcons.cjs.map +1 -1
- package/build/legacy/context/confirm-modal.cjs +141 -40
- package/build/legacy/context/confirm-modal.cjs.map +1 -1
- package/build/legacy/context/notification-center.cjs +129 -32
- package/build/legacy/context/notification-center.cjs.map +1 -1
- package/build/legacy/context/prompt-modal.cjs +178 -66
- package/build/legacy/context/prompt-modal.cjs.map +1 -1
- package/build/legacy/hooks/useModal.cjs +6 -2
- package/build/legacy/hooks/useModal.cjs.map +1 -1
- package/build/legacy/index.cjs +793 -442
- package/build/legacy/index.cjs.map +1 -1
- package/build/modern/_tsup-dts-rollup.d.ts +244 -2
- package/build/modern/{chunk-S7XGIQY6.js → chunk-243VUIA6.js} +2 -2
- package/build/modern/{chunk-LKFXUM3Z.js → chunk-3NE6C66J.js} +36 -25
- package/build/modern/{chunk-LKFXUM3Z.js.map → chunk-3NE6C66J.js.map} +1 -1
- package/build/modern/chunk-3ZDFQO25.js +31 -0
- package/build/modern/chunk-3ZDFQO25.js.map +1 -0
- package/build/modern/{chunk-YLPSE5Z2.js → chunk-6QHOKCV3.js} +11 -6
- package/build/modern/chunk-6QHOKCV3.js.map +1 -0
- package/build/modern/chunk-6TTN2JMY.js +54 -0
- package/build/modern/chunk-6TTN2JMY.js.map +1 -0
- package/build/modern/{chunk-OW62FLJ6.js → chunk-7T3JIGM7.js} +8 -4
- package/build/modern/chunk-7T3JIGM7.js.map +1 -0
- package/build/modern/{chunk-7K6PZBHN.js → chunk-CO4BKT7K.js} +5 -2
- package/build/modern/{chunk-7K6PZBHN.js.map → chunk-CO4BKT7K.js.map} +1 -1
- package/build/modern/{chunk-NBG2OSYI.js → chunk-FT7DFRHQ.js} +2 -2
- package/build/modern/chunk-FTPZHG6J.js +46 -0
- package/build/modern/{chunk-LJYCFFX7.js.map → chunk-FTPZHG6J.js.map} +1 -1
- package/build/modern/{chunk-JCGWTIR4.js → chunk-HCB5NQ5J.js} +5 -4
- package/build/modern/chunk-HCB5NQ5J.js.map +1 -0
- package/build/modern/chunk-HVKM54BA.js +100 -0
- package/build/modern/chunk-HVKM54BA.js.map +1 -0
- package/build/modern/{chunk-CMUFJU4S.js → chunk-KLUBAM4U.js} +2 -2
- package/build/modern/{chunk-AUAPBPGW.js → chunk-MDIUFBDX.js} +2 -2
- package/build/modern/{chunk-I35HMGJQ.js → chunk-NMF2HYWO.js} +2 -2
- package/build/modern/{chunk-I35HMGJQ.js.map → chunk-NMF2HYWO.js.map} +1 -1
- package/build/modern/{chunk-O6JYYVO7.js → chunk-PA5EB7EO.js} +2 -2
- package/build/modern/chunk-PZAZKQMO.js +25 -0
- package/build/modern/chunk-PZAZKQMO.js.map +1 -0
- package/build/modern/{chunk-EZNGCXVJ.js → chunk-RDQHHCFR.js} +5 -5
- package/build/modern/{chunk-BDCFYW34.js → chunk-TMR7JGMP.js} +12 -9
- package/build/modern/chunk-TMR7JGMP.js.map +1 -0
- package/build/modern/{chunk-WZOYPFUU.js → chunk-UJKS4DDN.js} +2 -2
- package/build/modern/{chunk-WLEX22KS.js → chunk-ULYQLKWA.js} +3 -3
- package/build/modern/{chunk-WLEX22KS.js.map → chunk-ULYQLKWA.js.map} +1 -1
- package/build/modern/{chunk-6YUB3ITX.js → chunk-X4Y4WTRU.js} +10 -10
- package/build/modern/{chunk-UXHAFEBA.js → chunk-YMJMB6OP.js} +5 -3
- package/build/modern/chunk-YMJMB6OP.js.map +1 -0
- package/build/modern/{chunk-GMG3B34U.js → chunk-YWCTMLLO.js} +2 -2
- package/build/modern/chunk-ZW3FFE37.js +138 -0
- package/build/modern/chunk-ZW3FFE37.js.map +1 -0
- package/build/modern/{chunk-477G5ZEL.js → chunk-ZX6DBC2Z.js} +2 -2
- package/build/modern/components/Admonition.js +17 -0
- package/build/modern/components/Admonition.js.map +1 -0
- package/build/modern/components/AnimatingUploadIcon.js +7 -0
- package/build/modern/components/AnimatingUploadIcon.js.map +1 -0
- package/build/modern/components/Avatar.js +4 -3
- package/build/modern/components/Checkbox.js +4 -3
- package/build/modern/components/CircularProgress.js +2 -1
- package/build/modern/components/Fieldset.js +9 -0
- package/build/modern/components/Fieldset.js.map +1 -0
- package/build/modern/components/FieldsetLabel.js +7 -0
- package/build/modern/components/FieldsetLabel.js.map +1 -0
- package/build/modern/components/FileStatus.js +5 -4
- package/build/modern/components/FileUploader.js +5 -4
- package/build/modern/components/Input.js +4 -3
- package/build/modern/components/Label.js +1 -1
- package/build/modern/components/Legend.js +10 -0
- package/build/modern/components/Legend.js.map +1 -0
- package/build/modern/components/ModalHeader.js +1 -1
- package/build/modern/components/Notification.js +4 -3
- package/build/modern/components/Radio.js +1 -1
- package/build/modern/components/Select.js +4 -3
- package/build/modern/components/Tag.js +4 -3
- package/build/modern/components/Th.js +1 -1
- package/build/modern/components/Toggle.js +4 -3
- package/build/modern/config/cerbIcons.js +2 -1
- package/build/modern/config/defineIcons.js +3 -2
- package/build/modern/context/confirm-modal.js +8 -7
- package/build/modern/context/notification-center.js +6 -5
- package/build/modern/context/prompt-modal.js +10 -9
- package/build/modern/hooks/useModal.js +1 -1
- package/build/modern/index.js +86 -65
- package/build/modern/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/Admonition.tsx +186 -0
- package/src/components/AnimatingUploadIcon.tsx +83 -0
- package/src/components/CircularProgress.tsx +20 -12
- package/src/components/Fieldset.tsx +65 -0
- package/src/components/FieldsetLabel.tsx +59 -0
- package/src/components/FileStatus.tsx +2 -0
- package/src/components/FileUploader.tsx +6 -1
- package/src/components/Label.tsx +1 -1
- package/src/components/Legend.tsx +87 -0
- package/src/components/ModalHeader.tsx +2 -2
- package/src/components/Radio.tsx +10 -1
- package/src/components/Th.tsx +3 -0
- package/src/config/cerbIcons.ts +10 -8
- package/src/context/prompt-modal.tsx +8 -1
- package/src/hooks/useModal.ts +19 -4
- package/src/index.ts +4 -0
- package/build/modern/chunk-BDCFYW34.js.map +0 -1
- package/build/modern/chunk-JCGWTIR4.js.map +0 -1
- package/build/modern/chunk-LJYCFFX7.js +0 -33
- package/build/modern/chunk-OW62FLJ6.js.map +0 -1
- package/build/modern/chunk-UXHAFEBA.js.map +0 -1
- package/build/modern/chunk-YLPSE5Z2.js.map +0 -1
- /package/build/modern/{chunk-S7XGIQY6.js.map → chunk-243VUIA6.js.map} +0 -0
- /package/build/modern/{chunk-NBG2OSYI.js.map → chunk-FT7DFRHQ.js.map} +0 -0
- /package/build/modern/{chunk-CMUFJU4S.js.map → chunk-KLUBAM4U.js.map} +0 -0
- /package/build/modern/{chunk-AUAPBPGW.js.map → chunk-MDIUFBDX.js.map} +0 -0
- /package/build/modern/{chunk-O6JYYVO7.js.map → chunk-PA5EB7EO.js.map} +0 -0
- /package/build/modern/{chunk-EZNGCXVJ.js.map → chunk-RDQHHCFR.js.map} +0 -0
- /package/build/modern/{chunk-WZOYPFUU.js.map → chunk-UJKS4DDN.js.map} +0 -0
- /package/build/modern/{chunk-6YUB3ITX.js.map → chunk-X4Y4WTRU.js.map} +0 -0
- /package/build/modern/{chunk-GMG3B34U.js.map → chunk-YWCTMLLO.js.map} +0 -0
- /package/build/modern/{chunk-477G5ZEL.js.map → chunk-ZX6DBC2Z.js.map} +0 -0
|
@@ -67,6 +67,102 @@ function IndeterminateIcon(props) {
|
|
|
67
67
|
);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
// src/components/AnimatingUploadIcon.tsx
|
|
71
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
72
|
+
function AnimatingUploadIcon(props) {
|
|
73
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
74
|
+
"svg",
|
|
75
|
+
{
|
|
76
|
+
"aria-hidden": "true",
|
|
77
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
78
|
+
width: props.size ?? "1em",
|
|
79
|
+
height: props.size ?? "1em",
|
|
80
|
+
viewBox: "0 0 24 24",
|
|
81
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
82
|
+
"g",
|
|
83
|
+
{
|
|
84
|
+
fill: "none",
|
|
85
|
+
stroke: "currentColor",
|
|
86
|
+
strokeLinecap: "square",
|
|
87
|
+
strokeLinejoin: "round",
|
|
88
|
+
strokeWidth: 1.5,
|
|
89
|
+
children: [
|
|
90
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
91
|
+
"path",
|
|
92
|
+
{
|
|
93
|
+
"data-name": "animating-trail",
|
|
94
|
+
strokeDasharray: "2 4",
|
|
95
|
+
strokeDashoffset: 6,
|
|
96
|
+
d: "M12 21c-4.97 0 -9 -4.03 -9 -9c0 -4.97 4.03 -9 9 -9",
|
|
97
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
98
|
+
"animate",
|
|
99
|
+
{
|
|
100
|
+
attributeName: "stroke-dashoffset",
|
|
101
|
+
dur: "0.45s",
|
|
102
|
+
repeatCount: "indefinite",
|
|
103
|
+
values: "6;0"
|
|
104
|
+
}
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
),
|
|
108
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
109
|
+
"path",
|
|
110
|
+
{
|
|
111
|
+
"data-name": "half-circle",
|
|
112
|
+
strokeDasharray: 32,
|
|
113
|
+
strokeDashoffset: 32,
|
|
114
|
+
d: "M12 3c4.97 0 9 4.03 9 9c0 4.97 -4.03 9 -9 9",
|
|
115
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
116
|
+
"animate",
|
|
117
|
+
{
|
|
118
|
+
fill: "freeze",
|
|
119
|
+
attributeName: "stroke-dashoffset",
|
|
120
|
+
begin: "0.075s",
|
|
121
|
+
dur: "0.3s",
|
|
122
|
+
values: "32;0"
|
|
123
|
+
}
|
|
124
|
+
)
|
|
125
|
+
}
|
|
126
|
+
),
|
|
127
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
128
|
+
"svg",
|
|
129
|
+
{
|
|
130
|
+
"aria-hidden": "true",
|
|
131
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
132
|
+
width: "0.8em",
|
|
133
|
+
height: "0.8em",
|
|
134
|
+
x: "27%",
|
|
135
|
+
y: "27%",
|
|
136
|
+
viewBox: "0 0 24 24",
|
|
137
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
138
|
+
"polygon",
|
|
139
|
+
{
|
|
140
|
+
fill: "currentColor",
|
|
141
|
+
stroke: "currentColor",
|
|
142
|
+
strokeWidth: 0.8,
|
|
143
|
+
opacity: "1",
|
|
144
|
+
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 ",
|
|
145
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
146
|
+
"animate",
|
|
147
|
+
{
|
|
148
|
+
fill: "freeze",
|
|
149
|
+
attributeName: "opacity",
|
|
150
|
+
values: "1;0;1",
|
|
151
|
+
dur: "2s",
|
|
152
|
+
repeatCount: "indefinite"
|
|
153
|
+
}
|
|
154
|
+
)
|
|
155
|
+
}
|
|
156
|
+
)
|
|
157
|
+
}
|
|
158
|
+
)
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
)
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
70
166
|
// src/config/cerbIcons.ts
|
|
71
167
|
var defaultIcons = {
|
|
72
168
|
avatar: import_icons.UserFilled,
|
|
@@ -75,12 +171,13 @@ var defaultIcons = {
|
|
|
75
171
|
confirmModal: import_icons.Information,
|
|
76
172
|
delete: import_icons.TrashCan,
|
|
77
173
|
promptModal: import_icons.Information,
|
|
78
|
-
|
|
174
|
+
waitingFileUploader: import_icons.CloudUpload,
|
|
175
|
+
fileUploader: AnimatingUploadIcon,
|
|
79
176
|
indeterminate: IndeterminateIcon,
|
|
80
|
-
infoNotification: import_icons.
|
|
81
|
-
successNotification: import_icons.
|
|
82
|
-
warningNotification: import_icons.
|
|
83
|
-
dangerNotification: import_icons.
|
|
177
|
+
infoNotification: import_icons.Information,
|
|
178
|
+
successNotification: import_icons.CheckmarkOutline,
|
|
179
|
+
warningNotification: import_icons.WarningAlt,
|
|
180
|
+
dangerNotification: import_icons.WarningFilled,
|
|
84
181
|
invalid: import_icons.WarningFilled,
|
|
85
182
|
invalidAlt: import_icons.Warning,
|
|
86
183
|
redo: import_icons.Restart,
|
|
@@ -103,7 +200,7 @@ function Show(props) {
|
|
|
103
200
|
}
|
|
104
201
|
|
|
105
202
|
// src/components/Avatar.tsx
|
|
106
|
-
var
|
|
203
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
107
204
|
function Avatar(props) {
|
|
108
205
|
const {
|
|
109
206
|
ariaLabel,
|
|
@@ -118,7 +215,7 @@ function Avatar(props) {
|
|
|
118
215
|
} = props;
|
|
119
216
|
const { avatar: AvatarIcon } = $cerberusIcons;
|
|
120
217
|
const initials = (ariaLabel || "").split(" ").map((word) => word[0]).join("").slice(0, 2);
|
|
121
|
-
return /* @__PURE__ */ (0,
|
|
218
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
122
219
|
"div",
|
|
123
220
|
{
|
|
124
221
|
...nativeProps,
|
|
@@ -127,19 +224,19 @@ function Avatar(props) {
|
|
|
127
224
|
(0, import_recipes.avatar)({ gradient, size }),
|
|
128
225
|
(0, import_patterns.circle)()
|
|
129
226
|
),
|
|
130
|
-
children: /* @__PURE__ */ (0,
|
|
227
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
131
228
|
Show,
|
|
132
229
|
{
|
|
133
230
|
when: Boolean(src) || Boolean(as),
|
|
134
|
-
fallback: /* @__PURE__ */ (0,
|
|
231
|
+
fallback: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
135
232
|
Show,
|
|
136
233
|
{
|
|
137
234
|
when: Boolean(initials),
|
|
138
|
-
fallback: /* @__PURE__ */ (0,
|
|
235
|
+
fallback: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
139
236
|
Show,
|
|
140
237
|
{
|
|
141
238
|
when: Boolean(icon),
|
|
142
|
-
fallback: /* @__PURE__ */ (0,
|
|
239
|
+
fallback: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
143
240
|
AvatarIcon,
|
|
144
241
|
{
|
|
145
242
|
size: iconSizeMap[size]
|
|
@@ -151,11 +248,11 @@ function Avatar(props) {
|
|
|
151
248
|
children: initials
|
|
152
249
|
}
|
|
153
250
|
),
|
|
154
|
-
children: /* @__PURE__ */ (0,
|
|
251
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
155
252
|
Show,
|
|
156
253
|
{
|
|
157
254
|
when: Boolean(as),
|
|
158
|
-
fallback: /* @__PURE__ */ (0,
|
|
255
|
+
fallback: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
159
256
|
"img",
|
|
160
257
|
{
|
|
161
258
|
alt: props.ariaLabel,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Avatar.tsx","../../../src/config/cerbIcons.ts","../../../src/config/icons/checkbox.icons.tsx","../../../src/config/defineIcons.ts","../../../src/components/Show.tsx"],"sourcesContent":["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","import {\n Checkmark,\n CheckmarkFilled,\n ChevronDown,\n CloseFilled,\n CloudUpload,\n ErrorFilled,\n Information,\n InformationFilled,\n Restart,\n TrashCan,\n UserFilled,\n Warning,\n WarningFilled,\n type CarbonIconType,\n} from '@cerberus/icons'\nimport type { ElementType } from 'react'\nimport { CheckmarkIcon, IndeterminateIcon } from './icons/checkbox.icons'\n\nexport type IconType = CarbonIconType | ElementType\n\nexport interface DefinedIcons {\n avatar?: IconType\n checkbox?: IconType\n close?: IconType\n confirmModal?: IconType\n delete?: IconType\n promptModal?: 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 avatar: UserFilled,\n checkbox: CheckmarkIcon,\n close: CloseFilled,\n confirmModal: Information,\n delete: TrashCan,\n promptModal: Information,\n fileUploader: CloudUpload,\n indeterminate: IndeterminateIcon,\n infoNotification: InformationFilled,\n successNotification: CheckmarkFilled,\n warningNotification: WarningFilled,\n dangerNotification: ErrorFilled,\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\ninterface CheckboxIconProps extends 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\ninterface IndeterminateIconProps extends 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 { 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;AAAA,iBAAwB;AACxB,sBAAuB;AACvB,qBAGO;;;ACLP,mBAeO;;;ACOD;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,MAEJ,sDAAC,UAAK,MAAK,gBAAe,GAAE,qBAAoB;AAAA;AAAA,EAClD;AAEJ;;;ADPO,IAAM,eAA6B;AAAA,EACxC,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,OAAO;AAAA,EACP,cAAc;AAAA,EACd,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,cAAc;AAAA,EACd,eAAe;AAAA,EACf,kBAAkB;AAAA,EAClB,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EACrB,oBAAoB;AAAA,EACpB,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,aAAa;AAAA,EACb,eAAe;AACjB;;;AEtCO,IAAI,iBAAiB;;;ACnB5B,mBAAgE;AA4BzD,SAAS,KAAK,OAAgD;AACnE,QAAM,EAAE,MAAM,UAAU,SAAS,IAAI;AACrC,QAAM,gBAAY,sBAAQ,MAAM,QAAQ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A,kBACD,UAAS;AAAA,kBACT,SAAQ;AAAA,kBACR;AAAA,kBACA;AAAA,kBACA;AAAA;AAAA,cACF;AAAA,cAGD;AAAA;AAAA,UACH;AAAA;AAAA,MACF;AAAA;AAAA,EACF;AAEJ;AAEA,IAAM,cAAc;AAAA,EAClB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AACT;","names":["import_jsx_runtime"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Avatar.tsx","../../../src/config/cerbIcons.ts","../../../src/config/icons/checkbox.icons.tsx","../../../src/components/AnimatingUploadIcon.tsx","../../../src/config/defineIcons.ts","../../../src/components/Show.tsx"],"sourcesContent":["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","import {\n Checkmark,\n CheckmarkOutline,\n ChevronDown,\n CloseFilled,\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 avatar?: 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 avatar: UserFilled,\n checkbox: CheckmarkIcon,\n close: CloseFilled,\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\ninterface CheckboxIconProps extends 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\ninterface IndeterminateIconProps extends 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;AAAA,iBAAwB;AACxB,sBAAuB;AACvB,qBAGO;;;ACLP,mBAcO;;;ACQD;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,QAA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ACP,OAAO;AAAA,EACP,OAAO;AACT;","names":["import_jsx_runtime","import_jsx_runtime"]}
|
|
@@ -91,6 +91,102 @@ function IndeterminateIcon(props) {
|
|
|
91
91
|
);
|
|
92
92
|
}
|
|
93
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
|
+
);
|
|
188
|
+
}
|
|
189
|
+
|
|
94
190
|
// src/config/cerbIcons.ts
|
|
95
191
|
var defaultIcons = {
|
|
96
192
|
avatar: import_icons.UserFilled,
|
|
@@ -99,12 +195,13 @@ var defaultIcons = {
|
|
|
99
195
|
confirmModal: import_icons.Information,
|
|
100
196
|
delete: import_icons.TrashCan,
|
|
101
197
|
promptModal: import_icons.Information,
|
|
102
|
-
|
|
198
|
+
waitingFileUploader: import_icons.CloudUpload,
|
|
199
|
+
fileUploader: AnimatingUploadIcon,
|
|
103
200
|
indeterminate: IndeterminateIcon,
|
|
104
|
-
infoNotification: import_icons.
|
|
105
|
-
successNotification: import_icons.
|
|
106
|
-
warningNotification: import_icons.
|
|
107
|
-
dangerNotification: import_icons.
|
|
201
|
+
infoNotification: import_icons.Information,
|
|
202
|
+
successNotification: import_icons.CheckmarkOutline,
|
|
203
|
+
warningNotification: import_icons.WarningAlt,
|
|
204
|
+
dangerNotification: import_icons.WarningFilled,
|
|
108
205
|
invalid: import_icons.WarningFilled,
|
|
109
206
|
invalidAlt: import_icons.Warning,
|
|
110
207
|
redo: import_icons.Restart,
|
|
@@ -116,13 +213,13 @@ var defaultIcons = {
|
|
|
116
213
|
var $cerberusIcons = defaultIcons;
|
|
117
214
|
|
|
118
215
|
// src/components/Checkbox.tsx
|
|
119
|
-
var
|
|
216
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
120
217
|
function Checkbox(props) {
|
|
121
218
|
const { describedBy, size, checked, mixed, ...nativeProps } = props;
|
|
122
219
|
const { invalid, ...fieldStates } = useFieldContext();
|
|
123
220
|
const styles = (0, import_recipes.checkbox)({ size });
|
|
124
221
|
const { checkbox: CheckIcon, indeterminate: IndeterminateIcon2 } = $cerberusIcons;
|
|
125
|
-
return /* @__PURE__ */ (0,
|
|
222
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
126
223
|
"div",
|
|
127
224
|
{
|
|
128
225
|
className: (0, import_css.cx)(
|
|
@@ -133,7 +230,7 @@ function Checkbox(props) {
|
|
|
133
230
|
})
|
|
134
231
|
),
|
|
135
232
|
children: [
|
|
136
|
-
/* @__PURE__ */ (0,
|
|
233
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
137
234
|
"input",
|
|
138
235
|
{
|
|
139
236
|
...nativeProps,
|
|
@@ -145,8 +242,8 @@ function Checkbox(props) {
|
|
|
145
242
|
type: "checkbox"
|
|
146
243
|
}
|
|
147
244
|
),
|
|
148
|
-
/* @__PURE__ */ (0,
|
|
149
|
-
/* @__PURE__ */ (0,
|
|
245
|
+
/* @__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, {}) }) }),
|
|
246
|
+
/* @__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, {}) }) })
|
|
150
247
|
]
|
|
151
248
|
}
|
|
152
249
|
);
|
|
@@ -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/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 Checkmark,\n CheckmarkFilled,\n ChevronDown,\n CloseFilled,\n CloudUpload,\n ErrorFilled,\n Information,\n InformationFilled,\n Restart,\n TrashCan,\n UserFilled,\n Warning,\n WarningFilled,\n type CarbonIconType,\n} from '@cerberus/icons'\nimport type { ElementType } from 'react'\nimport { CheckmarkIcon, IndeterminateIcon } from './icons/checkbox.icons'\n\nexport type IconType = CarbonIconType | ElementType\n\nexport interface DefinedIcons {\n avatar?: IconType\n checkbox?: IconType\n close?: IconType\n confirmModal?: IconType\n delete?: IconType\n promptModal?: 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 avatar: UserFilled,\n checkbox: CheckmarkIcon,\n close: CloseFilled,\n confirmModal: Information,\n delete: TrashCan,\n promptModal: Information,\n fileUploader: CloudUpload,\n indeterminate: IndeterminateIcon,\n infoNotification: InformationFilled,\n successNotification: CheckmarkFilled,\n warningNotification: WarningFilled,\n dangerNotification: ErrorFilled,\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\ninterface CheckboxIconProps extends 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\ninterface IndeterminateIconProps extends 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 { 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;AACP,sBAAuB;AACvB,iBAAmB;;;ACLnB,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;;;ACpCA,IAAAA,gBAKO;AA+CH;AApBJ,IAAM,mBAAe,6BAAwC,IAAI;AA8B1D,SAAS,kBAAqC;AACnD,QAAM,cAAU,0BAAW,YAAY;AACvC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,uDAAuD;AAAA,EACzE;AACA,SAAO;AACT;;;ACtEA,mBAeO;;;ACOD,IAAAC,sBAAA;AAVC,SAAS,cAAc,OAA0B;AACtD,SACE;AAAA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A;AAAA;AAAA,UAAC;AAAA;AAAA,YACE,GAAG;AAAA,YACH,GAAG;AAAA,YACH,GAAI,eAAe,EAAE,oBAAoB,YAAY;AAAA,YACrD,GAAI,WAAW,EAAE,gBAAgB,KAAK;AAAA,YACtC,GAAI,SAAS,EAAE,gBAAgB,QAAQ;AAAA,YACxC,eAAW,eAAG,QAAQ,YAAY,WAAW,OAAO,KAAK;AAAA,YACzD,MAAK;AAAA;AAAA,QACP;AAAA,QACA,6CAAC,QAAK,MAAM,WAAW,CAAC,OACtB,uDAAC,UAAK,WAAW,OAAO,MACtB,uDAAC,aAAU,GACb,GACF;AAAA,QACA,6CAAC,QAAK,MAAM,OACV,uDAAC,UAAK,WAAW,OAAO,MACtB,uDAACA,oBAAA,EAAkB,GACrB,GACF;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["import_react","import_jsx_runtime","import_jsx_runtime","IndeterminateIcon"]}
|
|
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 Checkmark,\n CheckmarkOutline,\n ChevronDown,\n CloseFilled,\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 avatar?: 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 avatar: UserFilled,\n checkbox: CheckmarkIcon,\n close: CloseFilled,\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\ninterface CheckboxIconProps extends 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\ninterface IndeterminateIconProps extends 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;AACP,sBAAuB;AACvB,iBAAmB;;;ACLnB,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;;;ACpCA,IAAAA,gBAKO;AA+CH;AApBJ,IAAM,mBAAe,6BAAwC,IAAI;AA8B1D,SAAS,kBAAqC;AACnD,QAAM,cAAU,0BAAW,YAAY;AACvC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,uDAAuD;AAAA,EACzE;AACA,SAAO;AACT;;;ACtEA,mBAcO;;;ACQD,IAAAC,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,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gB,KAAK;AAAA,YACtC,GAAI,SAAS,EAAE,gBAAgB,QAAQ;AAAA,YACxC,eAAW,eAAG,QAAQ,YAAY,WAAW,OAAO,KAAK;AAAA,YACzD,MAAK;AAAA;AAAA,QACP;AAAA,QACA,6CAAC,QAAK,MAAM,WAAW,CAAC,OACtB,uDAAC,UAAK,WAAW,OAAO,MACtB,uDAAC,aAAU,GACb,GACF;AAAA,QACA,6CAAC,QAAK,MAAM,OACV,uDAAC,UAAK,WAAW,OAAO,MACtB,uDAACA,oBAAA,EAAkB,GACrB,GACF;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["import_react","import_jsx_runtime","import_jsx_runtime","import_jsx_runtime","IndeterminateIcon"]}
|
|
@@ -26,12 +26,26 @@ __export(CircularProgress_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(CircularProgress_exports);
|
|
27
27
|
var import_patterns = require("@cerberus/styled-system/patterns");
|
|
28
28
|
var import_css = require("@cerberus/styled-system/css");
|
|
29
|
+
|
|
30
|
+
// src/components/Show.tsx
|
|
31
|
+
var import_react = require("react");
|
|
32
|
+
function Show(props) {
|
|
33
|
+
const { when, children, fallback } = props;
|
|
34
|
+
const condition = (0, import_react.useMemo)(() => when ?? false, [when]);
|
|
35
|
+
return (0, import_react.useMemo)(() => {
|
|
36
|
+
if (condition) return children;
|
|
37
|
+
return fallback ?? null;
|
|
38
|
+
}, [condition, children, fallback]);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// src/components/CircularProgress.tsx
|
|
29
42
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
30
43
|
function CircularProgress(props) {
|
|
31
44
|
const strokeW = 14;
|
|
32
45
|
const radius = `calc(50% * (1 - ${strokeW}/100))`;
|
|
33
46
|
const status = props.syntax ?? "Done";
|
|
34
47
|
const now = props.now >= 100 ? 100 : props.now;
|
|
48
|
+
const bgStyle = props.bgStyle ?? "filled";
|
|
35
49
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
36
50
|
"div",
|
|
37
51
|
{
|
|
@@ -69,18 +83,18 @@ function CircularProgress(props) {
|
|
|
69
83
|
"stop",
|
|
70
84
|
{
|
|
71
85
|
offset: "0%",
|
|
72
|
-
stopColor: "var(--cerberus-colors-
|
|
86
|
+
stopColor: "var(--cerberus-colors-data-viz-progress-start)"
|
|
73
87
|
}
|
|
74
88
|
),
|
|
75
89
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
76
90
|
"stop",
|
|
77
91
|
{
|
|
78
92
|
offset: "100%",
|
|
79
|
-
stopColor: "var(--cerberus-colors-
|
|
93
|
+
stopColor: "var(--cerberus-colors-data-viz-progress-end)"
|
|
80
94
|
}
|
|
81
95
|
)
|
|
82
96
|
] }) }),
|
|
83
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
97
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Show, { when: bgStyle === "filled", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
84
98
|
"circle",
|
|
85
99
|
{
|
|
86
100
|
className: (0, import_css.css)({
|
|
@@ -91,7 +105,7 @@ function CircularProgress(props) {
|
|
|
91
105
|
r: `calc(50% * (1 - ${strokeW}/100))`,
|
|
92
106
|
pathLength: "100"
|
|
93
107
|
}
|
|
94
|
-
),
|
|
108
|
+
) }),
|
|
95
109
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
96
110
|
"circle",
|
|
97
111
|
{
|
|
@@ -111,7 +125,7 @@ function CircularProgress(props) {
|
|
|
111
125
|
className: (0, import_css.css)({
|
|
112
126
|
stroke: "url(#gradient)",
|
|
113
127
|
transition: "stroke-dashoffset, stroke 0.5s ease",
|
|
114
|
-
|
|
128
|
+
_isComplete: {
|
|
115
129
|
stroke: "success.bg.initial"
|
|
116
130
|
}
|
|
117
131
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/CircularProgress.tsx"],"sourcesContent":["'use client'\n\nimport { cq } from '@cerberus/styled-system/patterns'\nimport { css } from '@cerberus/styled-system/css'\nimport type { SVGProps } from 'react'\n\n/**\n * This module contains the CircularProgress component.\n * @module\n */\n\nexport interface CircularProgressProps extends SVGProps<SVGSVGElement> {\n /**\n * A unique identifier for the progress bar. Required for accessibility.\n */\n id: string\n /**\n * A description label for the progress bar. Required for accessibility.\n */\n label: string\n /**\n * The current value of the CircularProgress\n */\n now: number\n /**\n * The title of the CircularProgress for a11y\n */\n title: string\n /**\n * What is shown below the now value (default: 'Done')\n */\n syntax?: string\n}\n\n/**\n * The CircularProgress component is used to display a loading indicator.\n * @param props - SVG element attributes\n * @param props.now - The current value of the CircularProgress\n * @param props.title - The title of the CircularProgress for a11y\n * @param props.label - What is shown below the now value (default: 'Done')\n * @see https://cerberus.digitalu.design/react/progress-indicators\n * @example\n * ```tsx\n * <CircularProgress now={24} title=\"Course completion\" label=\"done\" />\n * ```\n */\nexport function CircularProgress(props: CircularProgressProps) {\n const strokeW: number = 14\n const radius = `calc(50% * (1 - ${strokeW}/100))`\n const status: string = props.syntax ?? 'Done'\n const now: number = props.now >= 100 ? 100 : props.now\n\n return (\n <div\n id={props.id}\n aria-label={props.label}\n aria-valuemin={0}\n aria-valuemax={100}\n aria-valuenow={now}\n className={cq({\n alignSelf: 'stretch',\n flex: 1,\n m: '4px',\n position: 'relative',\n })}\n role=\"progressbar\"\n >\n <svg\n data-complete={now === 100}\n className={css({\n display: 'block',\n rounded: 'full',\n transition: 'all 0.5s ease',\n })}\n fill=\"none\"\n strokeLinecap=\"round\"\n strokeWidth={strokeW}\n viewBox=\"0 0 100 100\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <title>{props.title}</title>\n <desc>{`${now}% ${status}`}</desc>\n <defs>\n <linearGradient id=\"gradient\">\n <stop\n offset=\"0%\"\n stopColor=\"var(--cerberus-colors-
|
|
1
|
+
{"version":3,"sources":["../../../src/components/CircularProgress.tsx","../../../src/components/Show.tsx"],"sourcesContent":["'use client'\n\nimport { cq } from '@cerberus/styled-system/patterns'\nimport { css } from '@cerberus/styled-system/css'\nimport type { SVGProps } from 'react'\nimport { Show } from './Show'\n\n/**\n * This module contains the CircularProgress component.\n * @module\n */\n\nexport interface CircularProgressProps extends SVGProps<SVGSVGElement> {\n /**\n * A unique identifier for the progress bar. Required for accessibility.\n */\n id: string\n /**\n * A description label for the progress bar. Required for accessibility.\n */\n label: string\n /**\n * The current value of the CircularProgress\n */\n now: number\n /**\n * The title of the CircularProgress for a11y\n */\n title: string\n /**\n * What is shown below the now value (default: 'Done')\n */\n syntax?: string\n /**\n * The background style of the CircularProgress\n */\n bgStyle?: 'filled' | 'transparent'\n}\n\n/**\n * The CircularProgress component is used to display a loading indicator.\n * @param props - SVG element attributes\n * @param props.now - The current value of the CircularProgress\n * @param props.title - The title of the CircularProgress for a11y\n * @param props.label - What is shown below the now value (default: 'Done')\n * @see https://cerberus.digitalu.design/react/progress-indicators\n * @example\n * ```tsx\n * <CircularProgress now={24} title=\"Course completion\" label=\"done\" />\n * ```\n */\nexport function CircularProgress(props: CircularProgressProps) {\n const strokeW: number = 14\n const radius = `calc(50% * (1 - ${strokeW}/100))`\n const status: string = props.syntax ?? 'Done'\n const now: number = props.now >= 100 ? 100 : props.now\n const bgStyle: string = props.bgStyle ?? 'filled'\n\n return (\n <div\n id={props.id}\n aria-label={props.label}\n aria-valuemin={0}\n aria-valuemax={100}\n aria-valuenow={now}\n className={cq({\n alignSelf: 'stretch',\n flex: 1,\n m: '4px',\n position: 'relative',\n })}\n role=\"progressbar\"\n >\n <svg\n data-complete={now === 100}\n className={css({\n display: 'block',\n rounded: 'full',\n transition: 'all 0.5s ease',\n })}\n fill=\"none\"\n strokeLinecap=\"round\"\n strokeWidth={strokeW}\n viewBox=\"0 0 100 100\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <title>{props.title}</title>\n <desc>{`${now}% ${status}`}</desc>\n <defs>\n <linearGradient id=\"gradient\">\n <stop\n offset=\"0%\"\n stopColor=\"var(--cerberus-colors-data-viz-progress-start)\"\n />\n <stop\n offset=\"100%\"\n stopColor=\"var(--cerberus-colors-data-viz-progress-end)\"\n />\n </linearGradient>\n </defs>\n\n <Show when={bgStyle === 'filled'}>\n <circle\n className={css({\n fill: 'page.surface.initial',\n })}\n cx=\"50%\"\n cy=\"50%\"\n r={`calc(50% * (1 - ${strokeW}/100))`}\n pathLength=\"100\"\n />\n </Show>\n <circle\n className={css({\n stroke: 'page.bg.100',\n })}\n cx=\"50%\"\n cy=\"50%\"\n r={radius}\n pathLength=\"100\"\n />\n <circle\n data-complete={now === 100}\n className={css({\n stroke: 'url(#gradient)',\n transition: 'stroke-dashoffset, stroke 0.5s ease',\n _isComplete: {\n stroke: 'success.bg.initial',\n },\n })}\n cx=\"50%\"\n cy=\"50%\"\n fill=\"none\"\n r={radius}\n pathLength=\"100\"\n strokeDasharray=\"100\"\n strokeDashoffset={100 - now}\n transform=\"rotate(-90 50 50)\"\n />\n\n <g>\n <text\n className={css({\n fill: 'page.text.initial',\n fontFamily: 'mono',\n textStyle: '1.25rem',\n })}\n x=\"50%\"\n y=\"47%\"\n dominantBaseline=\"middle\"\n textAnchor=\"middle\"\n >\n {now}%\n </text>\n <text\n className={css({\n fill: 'page.text.100',\n fontSize: '0.5rem',\n fontWeight: 600,\n })}\n x=\"50%\"\n y=\"59%\"\n dominantBaseline=\"middle\"\n textAnchor=\"middle\"\n >\n {status}\n </text>\n </g>\n </svg>\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,sBAAmB;AACnB,iBAAoB;;;ACDpB,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;;;ADgDQ;AAnCD,SAAS,iBAAiB,OAA8B;AAC7D,QAAM,UAAkB;AACxB,QAAM,SAAS,mBAAmB,OAAO;AACzC,QAAM,SAAiB,MAAM,UAAU;AACvC,QAAM,MAAc,MAAM,OAAO,MAAM,MAAM,MAAM;AACnD,QAAM,UAAkB,MAAM,WAAW;AAEzC,SACE;AAAA,IAAC;AAAA;AAAA,MACC,IAAI,MAAM;AAAA,MACV,cAAY,MAAM;AAAA,MAClB,iBAAe;AAAA,MACf,iBAAe;AAAA,MACf,iBAAe;AAAA,MACf,eAAW,oBAAG;AAAA,QACZ,WAAW;AAAA,QACX,MAAM;AAAA,QACN,GAAG;AAAA,QACH,UAAU;AAAA,MACZ,CAAC;AAAA,MACD,MAAK;AAAA,MAEL;AAAA,QAAC;AAAA;AAAA,UACC,iBAAe,QAAQ;AAAA,UACvB,eAAW,gBAAI;AAAA,YACb,SAAS;AAAA,YACT,SAAS;AAAA,YACT,YAAY;AAAA,UACd,CAAC;AAAA,UACD,MAAK;AAAA,UACL,eAAc;AAAA,UACd,aAAa;AAAA,UACb,SAAQ;AAAA,UACR,OAAM;AAAA,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AAAA,kBACb,CAAC;AAAA,kBACD,GAAE;AAAA,kBACF,GAAE;AAAA,kBACF,kBAAiB;AAAA,kBACjB,YAAW;AAAA,kBAEV;AAAA;AAAA,oBAAI;AAAA;AAAA;AAAA,cACP;AAAA,cACA;AAAA,gBAAC;AAAA;AAAA,kBACC,eAAW,gBAAI;AAAA,oBACb,MAAM;AAAA,oBACN,UAAU;AAAA,oBACV,YAAY;AAAA,kBACd,CAAC;AAAA,kBACD,GAAE;AAAA,kBACF,GAAE;AAAA,kBACF,kBAAiB;AAAA,kBACjB,YAAW;AAAA,kBAEV;AAAA;AAAA,cACH;AAAA,eACF;AAAA;AAAA;AAAA,MACF;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/components/Fieldset.tsx
|
|
22
|
+
var Fieldset_exports = {};
|
|
23
|
+
__export(Fieldset_exports, {
|
|
24
|
+
Fieldset: () => Fieldset
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(Fieldset_exports);
|
|
27
|
+
var import_css = require("@cerberus/styled-system/css");
|
|
28
|
+
|
|
29
|
+
// src/context/field.tsx
|
|
30
|
+
var import_react = require("react");
|
|
31
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
+
var FieldContext = (0, import_react.createContext)(null);
|
|
33
|
+
function useFieldContext() {
|
|
34
|
+
const context = (0, import_react.useContext)(FieldContext);
|
|
35
|
+
if (!context) {
|
|
36
|
+
throw new Error("useFieldContext must be used within a Field Provider.");
|
|
37
|
+
}
|
|
38
|
+
return context;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// src/components/Fieldset.tsx
|
|
42
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
43
|
+
function Fieldset(props) {
|
|
44
|
+
const { invalid, ...formState } = useFieldContext();
|
|
45
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
46
|
+
"fieldset",
|
|
47
|
+
{
|
|
48
|
+
...props,
|
|
49
|
+
...formState,
|
|
50
|
+
...invalid && { "aria-invalid": true },
|
|
51
|
+
className: (0, import_css.cx)(
|
|
52
|
+
props.className,
|
|
53
|
+
(0, import_css.css)({
|
|
54
|
+
border: "none",
|
|
55
|
+
pt: 2,
|
|
56
|
+
margin: 0
|
|
57
|
+
})
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
+
0 && (module.exports = {
|
|
64
|
+
Fieldset
|
|
65
|
+
});
|
|
66
|
+
//# sourceMappingURL=Fieldset.cjs.map
|