@clerk/ui 0.1.9 → 0.1.10

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/dist/contexts.js CHANGED
@@ -1,8 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  var react = require('@clerk/shared/react');
4
- var React = require('react');
4
+ require('@clerk/elements/common');
5
+ var React5 = require('react');
6
+ var cva = require('cva');
5
7
  var jsxRuntime = require('react/jsx-runtime');
8
+ var types = require('@clerk/types');
6
9
 
7
10
  function _interopNamespace(e) {
8
11
  if (e && e.__esModule) return e;
@@ -22,9 +25,377 @@ function _interopNamespace(e) {
22
25
  return Object.freeze(n);
23
26
  }
24
27
 
25
- var React__namespace = /*#__PURE__*/_interopNamespace(React);
28
+ var React5__namespace = /*#__PURE__*/_interopNamespace(React5);
26
29
 
27
30
  // src/contexts/AppearanceContext.tsx
31
+
32
+ // ../../node_modules/clsx/dist/clsx.mjs
33
+ function r(e) {
34
+ var t, f, n = "";
35
+ if ("string" == typeof e || "number" == typeof e) n += e;
36
+ else if ("object" == typeof e) if (Array.isArray(e)) {
37
+ var o = e.length;
38
+ for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
39
+ } else for (f in e) e[f] && (n && (n += " "), n += f);
40
+ return n;
41
+ }
42
+ function clsx() {
43
+ for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
44
+ return n;
45
+ }
46
+ var clsx_default = clsx;
47
+
48
+ // src/utils/dva.ts
49
+ var falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
50
+ var defineConfig = (options) => {
51
+ const cx4 = (...inputs) => {
52
+ var _a, _b;
53
+ if (typeof ((_a = void 0 ) == null ? void 0 : _a["cx:done"]) !== "undefined") {
54
+ return void 0 ;
55
+ }
56
+ if (typeof ((_b = void 0 ) == null ? void 0 : _b.onComplete) !== "undefined") {
57
+ return void 0 ;
58
+ }
59
+ return clsx(inputs);
60
+ };
61
+ const dva2 = (config) => (props) => {
62
+ var _a;
63
+ if ((config == null ? void 0 : config.variants) == null) {
64
+ return cx4(config == null ? void 0 : config.base, props == null ? void 0 : props.descriptor);
65
+ }
66
+ const { variants, defaultVariants } = config;
67
+ const getVariantClassNames = Object.keys(variants).map((variant) => {
68
+ const variantProp = props == null ? void 0 : props[variant];
69
+ const defaultVariantProp = defaultVariants == null ? void 0 : defaultVariants[variant];
70
+ const variantKey = falsyToString(variantProp) || falsyToString(defaultVariantProp);
71
+ return variants[variant][variantKey];
72
+ });
73
+ const defaultsAndProps = {
74
+ ...defaultVariants,
75
+ // remove `undefined` props
76
+ ...props && Object.entries(props).reduce(
77
+ (acc, [key, value]) => typeof value === "undefined" ? acc : { ...acc, [key]: value },
78
+ {}
79
+ )
80
+ };
81
+ const getCompoundVariantClassNames = (_a = config == null ? void 0 : config.compoundVariants) == null ? void 0 : _a.reduce(
82
+ (acc, { descriptor, ...cvConfig }) => Object.entries(cvConfig).every(([cvKey, cvSelector]) => {
83
+ const selector = defaultsAndProps[cvKey];
84
+ return Array.isArray(cvSelector) ? cvSelector.includes(selector) : selector === cvSelector;
85
+ }) ? [...acc, descriptor] : acc,
86
+ []
87
+ );
88
+ return cx4(config == null ? void 0 : config.base, getVariantClassNames, getCompoundVariantClassNames, props == null ? void 0 : props.descriptor);
89
+ };
90
+ const compose2 = (...components) => (props) => {
91
+ const propsWithoutDescriptor = Object.fromEntries(
92
+ Object.entries(props || {}).filter(([key]) => !["descriptor"].includes(key))
93
+ );
94
+ return cx4(components.map((component) => component(propsWithoutDescriptor)), props == null ? void 0 : props.descriptor);
95
+ };
96
+ return {
97
+ compose: compose2,
98
+ dva: dva2,
99
+ cx: cx4
100
+ };
101
+ };
102
+ var { compose, dva, cx } = defineConfig();
103
+ function getDescriptors(elements, descriptorList) {
104
+ const descriptors = descriptorList.split(" ");
105
+ return descriptors.map((d) => {
106
+ const value = elements[d];
107
+ if (!value) {
108
+ console.warn(`Clerk: unable to access style configuration for descriptor: ${d}`);
109
+ }
110
+ return value;
111
+ });
112
+ }
113
+ function applyDescriptors(elements, descriptorList) {
114
+ const descriptors = getDescriptors(elements, descriptorList);
115
+ return mergeDescriptors(...descriptors);
116
+ }
117
+ var SIZE = 16;
118
+ var layoutStyle = {
119
+ spinner: {
120
+ className: "cl-26207fa4"
121
+ }
122
+ };
123
+ var visualStyle = {
124
+ spinner: {
125
+ className: "cl-9feebad9"
126
+ }
127
+ };
128
+ var spinner = dva({
129
+ base: "spinner"
130
+ });
131
+ var Spinner = React5.forwardRef(function Spinner2({
132
+ children,
133
+ descriptor
134
+ }, ref) {
135
+ const { elements } = useAppearance().parsedAppearance;
136
+ return /* @__PURE__ */ jsxRuntime.jsxs(
137
+ "span",
138
+ {
139
+ ref,
140
+ ...applyDescriptors(elements, spinner({ descriptor })),
141
+ children: [
142
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "cl-32fb0905", children }),
143
+ /* @__PURE__ */ jsxRuntime.jsxs(
144
+ "svg",
145
+ {
146
+ viewBox: [0, 0, SIZE, SIZE].join(" "),
147
+ fill: "none",
148
+ xmlns: "http://www.w3.org/2000/svg",
149
+ className: "cl-4f43603c",
150
+ style: {
151
+ ["--spinner-origin"]: Array.from({ length: 2 }).fill(`${16 / SIZE / 2}rem`).join(" ")
152
+ },
153
+ "aria-hidden": true,
154
+ children: [
155
+ /* @__PURE__ */ jsxRuntime.jsxs(
156
+ "g",
157
+ {
158
+ className: cva.cx(
159
+ "cl-bfbc36b1",
160
+ "cl-22c1b7ea",
161
+ "cl-45bbc6bf",
162
+ "cl-e5d7b81e",
163
+ "cl-4bd15f3b"
164
+ ),
165
+ fill: "currentColor",
166
+ opacity: 0.5,
167
+ children: [
168
+ "(",
169
+ /* @__PURE__ */ jsxRuntime.jsx(
170
+ "circle",
171
+ {
172
+ cx: "8",
173
+ cy: "2.75",
174
+ r: "0.75"
175
+ }
176
+ ),
177
+ /* @__PURE__ */ jsxRuntime.jsx(
178
+ "circle",
179
+ {
180
+ cx: "13.25",
181
+ cy: "8",
182
+ r: "0.75"
183
+ }
184
+ ),
185
+ /* @__PURE__ */ jsxRuntime.jsx(
186
+ "circle",
187
+ {
188
+ cx: "2.75",
189
+ cy: "8",
190
+ r: "0.75"
191
+ }
192
+ ),
193
+ /* @__PURE__ */ jsxRuntime.jsx(
194
+ "circle",
195
+ {
196
+ cx: "4.29999",
197
+ cy: "4.29001",
198
+ r: "0.75"
199
+ }
200
+ ),
201
+ /* @__PURE__ */ jsxRuntime.jsx(
202
+ "circle",
203
+ {
204
+ cx: "11.7",
205
+ cy: "4.29001",
206
+ r: "0.75"
207
+ }
208
+ ),
209
+ /* @__PURE__ */ jsxRuntime.jsx(
210
+ "circle",
211
+ {
212
+ cx: "4.29999",
213
+ cy: "11.72",
214
+ r: "0.75"
215
+ }
216
+ ),
217
+ /* @__PURE__ */ jsxRuntime.jsx(
218
+ "circle",
219
+ {
220
+ cx: "11.7",
221
+ cy: "11.72",
222
+ r: "0.75"
223
+ }
224
+ ),
225
+ /* @__PURE__ */ jsxRuntime.jsx(
226
+ "circle",
227
+ {
228
+ cx: "8",
229
+ cy: "13.25",
230
+ r: "0.75"
231
+ }
232
+ ),
233
+ ")"
234
+ ]
235
+ }
236
+ ),
237
+ /* @__PURE__ */ jsxRuntime.jsx(
238
+ "circle",
239
+ {
240
+ className: cva.cx(
241
+ "cl-4f43603c",
242
+ "cl-bfbc36b1",
243
+ "cl-22c1b7ea",
244
+ "cl-45bbc6bf",
245
+ "cl-3ba7917c"
246
+ ),
247
+ cx: "8",
248
+ cy: "8",
249
+ r: "5.25",
250
+ pathLength: 360,
251
+ stroke: "currentColor",
252
+ strokeLinecap: "round",
253
+ strokeLinejoin: "round",
254
+ strokeDashoffset: 100,
255
+ strokeDasharray: "90 270",
256
+ strokeWidth: 1.5
257
+ }
258
+ )
259
+ ]
260
+ }
261
+ )
262
+ ]
263
+ }
264
+ );
265
+ });
266
+ var layoutStyle2 = {
267
+ button: {
268
+ className: [
269
+ "cl-16a914bc",
270
+ // 16px
271
+ "cl-da41fb98",
272
+ "cl-f5aee1d0",
273
+ "cl-c8dc0199",
274
+ "cl-ff9d26a5",
275
+ "cl-ce4a8aff",
276
+ "cl-8a3782da"
277
+ ].join(" ")
278
+ },
279
+ buttonIcon: {
280
+ className: "cl-27ead27a"
281
+ },
282
+ buttonSpinner: {
283
+ className: "cl-27ead27a"
284
+ }
285
+ };
286
+ var visualStyle2 = {
287
+ button: {
288
+ className: ["cl-b55f0528", "cl-d9cf47b8", "cl-b30fc560"].join(" ")
289
+ },
290
+ buttonPrimary: {
291
+ className: [
292
+ "cl-a98b2d0f",
293
+ "cl-e7b4a4f3",
294
+ "cl-93e9de3b",
295
+ "cl-cb1d8f85",
296
+ "cl-2b39a966",
297
+ "cl-5d812cb6"
298
+ ].join(" ")
299
+ },
300
+ buttonSecondary: {
301
+ className: [
302
+ "cl-947a937d",
303
+ "cl-2031c7be",
304
+ "cl-97c9b979",
305
+ "cl-aa729509"
306
+ ].join(" ")
307
+ },
308
+ buttonConnection: {
309
+ className: [
310
+ "cl-947a937d",
311
+ "cl-2031c7be",
312
+ "cl-97c9b979",
313
+ "cl-aa729509"
314
+ ].join(" ")
315
+ },
316
+ buttonPrimaryDefault: {
317
+ className: "cl-dd1ec9c5"
318
+ },
319
+ buttonSecondaryDefault: {
320
+ className: "cl-9b31bb43"
321
+ },
322
+ buttonConnectionDefault: {
323
+ className: "cl-9b31bb43"
324
+ },
325
+ buttonDisabled: {
326
+ className: "cl-d4e2e313"
327
+ },
328
+ buttonBusy: {
329
+ className: "cl-d6edf6f5"
330
+ },
331
+ buttonText: {
332
+ className: "cl-63a1f595"
333
+ },
334
+ buttonTextVisuallyHidden: {
335
+ className: "cl-32fb0905"
336
+ },
337
+ buttonIcon: {
338
+ className: "cl-2e5aed0f"
339
+ },
340
+ buttonSpinner: {
341
+ className: "cl-291bc932"
342
+ }
343
+ };
344
+ var button = dva({
345
+ base: "button",
346
+ variants: {
347
+ intent: {
348
+ primary: "buttonPrimary",
349
+ secondary: "buttonSecondary",
350
+ connection: "buttonConnection"
351
+ },
352
+ busy: {
353
+ false: null,
354
+ true: null
355
+ },
356
+ disabled: {
357
+ false: null,
358
+ true: null
359
+ }
360
+ },
361
+ compoundVariants: [
362
+ { busy: false, disabled: false, intent: "primary", descriptor: "buttonPrimaryDefault" },
363
+ { busy: false, disabled: false, intent: "secondary", descriptor: "buttonSecondaryDefault" },
364
+ { busy: false, disabled: false, intent: "connection", descriptor: "buttonConnectionDefault" },
365
+ { busy: false, disabled: true, descriptor: "buttonDisabled" },
366
+ { busy: true, disabled: false, descriptor: "buttonBusy" }
367
+ ]
368
+ });
369
+ React5__namespace.forwardRef(function Button2({
370
+ busy = false,
371
+ children,
372
+ descriptor,
373
+ disabled = false,
374
+ iconStart,
375
+ iconEnd,
376
+ intent = "primary",
377
+ type = "button",
378
+ textVisuallyHidden,
379
+ ...props
380
+ }, forwardedRef) {
381
+ const { elements } = useAppearance().parsedAppearance;
382
+ const spinner2 = /* @__PURE__ */ jsxRuntime.jsx(Spinner, { descriptor: "buttonSpinner", children: "Loading\u2026" });
383
+ return /* @__PURE__ */ jsxRuntime.jsx(
384
+ "button",
385
+ {
386
+ ref: forwardedRef,
387
+ ...applyDescriptors(elements, button({ busy, disabled, intent, descriptor })),
388
+ disabled: busy || disabled,
389
+ type,
390
+ ...props,
391
+ children: busy && intent === "primary" ? spinner2 : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
392
+ iconStart ? busy && intent === "connection" ? spinner2 : /* @__PURE__ */ jsxRuntime.jsx("span", { ...applyDescriptors(elements, "buttonIcon buttonIconStart"), children: iconStart }) : null,
393
+ children ? /* @__PURE__ */ jsxRuntime.jsx("span", { ...mergeDescriptors(elements.buttonText, !!textVisuallyHidden && elements.buttonTextVisuallyHidden), children }) : null,
394
+ iconEnd ? /* @__PURE__ */ jsxRuntime.jsx("span", { ...applyDescriptors(elements, "buttonIcon buttonIconEnd"), children: iconEnd }) : null
395
+ ] })
396
+ }
397
+ );
398
+ });
28
399
  var $bdb11010cef70236$var$idsUpdaterMap = /* @__PURE__ */ new Map();
29
400
  function $bdb11010cef70236$export$cd8c9cb68f842629(idA, idB) {
30
401
  if (idA === idB) return idA;
@@ -48,22 +419,6 @@ function $ff5963eb1fccf552$export$e08e3b67e392101e(...callbacks) {
48
419
  };
49
420
  }
50
421
 
51
- // ../../node_modules/clsx/dist/clsx.mjs
52
- function r(e) {
53
- var t, f, n = "";
54
- if ("string" == typeof e || "number" == typeof e) n += e;
55
- else if ("object" == typeof e) if (Array.isArray(e)) {
56
- var o = e.length;
57
- for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
58
- } else for (f in e) e[f] && (n && (n += " "), n += f);
59
- return n;
60
- }
61
- function clsx() {
62
- for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
63
- return n;
64
- }
65
- var clsx_default = clsx;
66
-
67
422
  // ../../node_modules/@react-aria/utils/dist/mergeProps.mjs
68
423
  function $3ef42575df84b30b$export$9d1611c77c2fe928(...args) {
69
424
  let result = {
@@ -87,10 +442,10 @@ function $3ef42575df84b30b$export$9d1611c77c2fe928(...args) {
87
442
  }
88
443
 
89
444
  // src/primitives/icons/icon.tsx
90
- var Icon = React__namespace.forwardRef(
445
+ var Icon = React5__namespace.forwardRef(
91
446
  function Icon2(props, ref) {
92
447
  const { children, "aria-label": ariaLabel, "aria-hidden": ariaHidden, ...restProps } = props;
93
- return React__namespace.cloneElement(children, {
448
+ return React5__namespace.cloneElement(children, {
94
449
  ...$3ef42575df84b30b$export$9d1611c77c2fe928(children.props, restProps),
95
450
  ref,
96
451
  width: "1em",
@@ -103,6 +458,15 @@ var Icon = React__namespace.forwardRef(
103
458
  });
104
459
  }
105
460
  );
461
+ var layoutStyle3 = {
462
+ connectionList: {
463
+ className: "cl-519e344c"
464
+ },
465
+ connectionListItem: {
466
+ className: "cl-b9a44166"
467
+ }
468
+ };
469
+ var visualStyle3 = {};
106
470
  function ExclamationOctagonSm(props) {
107
471
  return /* @__PURE__ */ jsxRuntime.jsx(Icon, { ...props, children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { viewBox: "0 0 16 16", children: [
108
472
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -171,17 +535,15 @@ function ExclamationTriangleSm(props) {
171
535
  )
172
536
  ] }) });
173
537
  }
174
- var layoutStyle = {
538
+ var layoutStyle4 = {
175
539
  alert: {
176
540
  className: "cl-fbddaa7d"
177
541
  },
178
- alert__warning: {},
179
- alert__error: {},
180
542
  alertIcon: {
181
543
  className: "cl-af4e251c"
182
544
  }
183
545
  };
184
- var visualStyle = {
546
+ var visualStyle4 = {
185
547
  alert: {
186
548
  className: "cl-15c02a47"
187
549
  },
@@ -190,10 +552,9 @@ var visualStyle = {
190
552
  },
191
553
  alert__error: {
192
554
  className: "cl-66ef3405"
193
- },
194
- alertIcon: {}
555
+ }
195
556
  };
196
- React__namespace.forwardRef(function Alert2({ children, descriptors, intent = "error", ...props }, forwardedRef) {
557
+ React5__namespace.forwardRef(function Alert2({ children, descriptors, intent = "error", ...props }, forwardedRef) {
197
558
  const { elements } = useAppearance().parsedAppearance;
198
559
  return /* @__PURE__ */ jsxRuntime.jsxs(
199
560
  "div",
@@ -216,17 +577,532 @@ React__namespace.forwardRef(function Alert2({ children, descriptors, intent = "e
216
577
  }
217
578
  );
218
579
  });
219
- var layoutStyle2 = {
580
+ var ClerkLogo = () => /* @__PURE__ */ jsxRuntime.jsxs(
581
+ "svg",
582
+ {
583
+ className: "cl-2a836795",
584
+ fill: "none",
585
+ xmlns: "http://www.w3.org/2000/svg",
586
+ viewBox: "0 0 50 14",
587
+ children: [
588
+ /* @__PURE__ */ jsxRuntime.jsx(
589
+ "ellipse",
590
+ {
591
+ cx: "7.889",
592
+ cy: "7",
593
+ rx: "2.187",
594
+ ry: "2.188",
595
+ fill: "currentColor"
596
+ }
597
+ ),
598
+ /* @__PURE__ */ jsxRuntime.jsx(
599
+ "path",
600
+ {
601
+ d: "M11.83 12.18a.415.415 0 0 1-.05.64A6.967 6.967 0 0 1 7.888 14a6.967 6.967 0 0 1-3.891-1.18.415.415 0 0 1-.051-.64l1.598-1.6a.473.473 0 0 1 .55-.074 3.92 3.92 0 0 0 1.794.431 3.92 3.92 0 0 0 1.792-.43.473.473 0 0 1 .551.074l1.599 1.598Z",
602
+ fill: "currentColor"
603
+ }
604
+ ),
605
+ /* @__PURE__ */ jsxRuntime.jsx(
606
+ "path",
607
+ {
608
+ opacity: "0.5",
609
+ d: "M11.78 1.18a.415.415 0 0 1 .05.64l-1.598 1.6a.473.473 0 0 1-.55.073 3.937 3.937 0 0 0-5.3 5.3.473.473 0 0 1-.074.55L2.71 10.942a.415.415 0 0 1-.641-.051 7 7 0 0 1 9.71-9.71Z",
610
+ fill: "currentColor"
611
+ }
612
+ ),
613
+ /* @__PURE__ */ jsxRuntime.jsx(
614
+ "path",
615
+ {
616
+ fillRule: "evenodd",
617
+ clipRule: "evenodd",
618
+ d: "M23.748 1.422c0-.06.05-.11.11-.11h1.64c.06 0 .11.05.11.11v11.156a.11.11 0 0 1-.11.11h-1.64a.11.11 0 0 1-.11-.11V1.422Zm-2.315 8.9a.112.112 0 0 0-.15.004 2.88 2.88 0 0 1-.884.569c-.36.148-.747.222-1.137.219-.33.01-.658-.047-.965-.166a2.422 2.422 0 0 1-.817-.527c-.424-.432-.668-1.05-.668-1.785 0-1.473.98-2.48 2.45-2.48.394-.005.785.074 1.144.234.325.144.617.35.86.607.04.044.11.049.155.01l1.108-.959a.107.107 0 0 0 .01-.152c-.832-.93-2.138-1.412-3.379-1.412-2.499 0-4.27 1.686-4.27 4.166 0 1.227.44 2.26 1.182 2.99.743.728 1.801 1.157 3.022 1.157 1.53 0 2.763-.587 3.485-1.34a.107.107 0 0 0-.009-.155l-1.137-.98Zm13.212-1.14a.108.108 0 0 1-.107.096H28.79a.106.106 0 0 0-.104.132c.286 1.06 1.138 1.701 2.302 1.701a2.59 2.59 0 0 0 1.136-.236 2.55 2.55 0 0 0 .862-.645.08.08 0 0 1 .112-.01l1.155 1.006c.044.039.05.105.013.15-.698.823-1.828 1.42-3.38 1.42-2.386 0-4.185-1.651-4.185-4.162 0-1.232.424-2.264 1.13-2.994.373-.375.82-.67 1.314-.87a3.968 3.968 0 0 1 1.557-.285c2.419 0 3.983 1.701 3.983 4.05a6.737 6.737 0 0 1-.04.647Zm-5.924-1.524a.104.104 0 0 0 .103.133h3.821c.07 0 .123-.066.103-.134-.26-.901-.921-1.503-1.947-1.503a2.13 2.13 0 0 0-.88.16 2.1 2.1 0 0 0-.733.507 2.242 2.242 0 0 0-.467.837Zm11.651-3.172c.061-.001.11.048.11.109v1.837a.11.11 0 0 1-.117.109 7.17 7.17 0 0 0-.455-.024c-1.43 0-2.27 1.007-2.27 2.329v3.732a.11.11 0 0 1-.11.11h-1.64a.11.11 0 0 1-.11-.11v-7.87c0-.06.049-.109.11-.109h1.64c.06 0 .11.05.11.11v1.104a.011.011 0 0 0 .02.007c.64-.857 1.587-1.333 2.587-1.333l.125-.001Zm4.444 4.81a.035.035 0 0 1 .056.006l2.075 3.334a.11.11 0 0 0 .093.052h1.865a.11.11 0 0 0 .093-.168L46.152 7.93a.11.11 0 0 1 .012-.131l2.742-3.026a.11.11 0 0 0-.081-.183h-1.946a.11.11 0 0 0-.08.036l-3.173 3.458a.11.11 0 0 1-.19-.074V1.422a.11.11 0 0 0-.11-.11h-1.64a.11.11 0 0 0-.11.11v11.156c0 .06.05.11.11.11h1.64a.11.11 0 0 0 .11-.11v-1.755a.11.11 0 0 1 .03-.075l1.35-1.452Z",
619
+ fill: "currentColor"
620
+ }
621
+ )
622
+ ]
623
+ }
624
+ );
625
+
626
+ // src/utils/validators.ts
627
+ function isValidUrl(val) {
628
+ if (!val) {
629
+ return false;
630
+ }
631
+ try {
632
+ new URL(val);
633
+ return true;
634
+ } catch (e) {
635
+ return false;
636
+ }
637
+ }
638
+ function isDataUri(val) {
639
+ if (!isValidUrl(val)) {
640
+ return false;
641
+ }
642
+ return new URL(val).protocol === "data:";
643
+ }
644
+ var CLERK_IMAGE_URL_BASES = ["https://img.clerk.com/", "https://img.clerkstage.dev/", "https://img.lclclerk.com/"];
645
+ var isClerkImage = (src) => {
646
+ return !!CLERK_IMAGE_URL_BASES.some((base) => src == null ? void 0 : src.includes(base));
647
+ };
648
+
649
+ // src/utils/images.ts
650
+ var generateSrcSet = ({ src, width }) => {
651
+ if (!src) {
652
+ return "";
653
+ }
654
+ return generateSrc({ src, width });
655
+ };
656
+ var generateSrc = ({ src, width }) => {
657
+ if (!isValidUrl(src) || isDataUri(src)) {
658
+ return src;
659
+ }
660
+ const newSrc = new URL(src);
661
+ if (width) {
662
+ newSrc.searchParams.append("width", width == null ? void 0 : width.toString());
663
+ }
664
+ return newSrc.href;
665
+ };
666
+ var BASE_IMAGE_WIDTH = 80;
667
+ var Image = React5__namespace.forwardRef(function Image2({
668
+ src,
669
+ size = BASE_IMAGE_WIDTH,
670
+ ...props
671
+ }, forwardedRef) {
672
+ const shouldOptimize = isClerkImage(src);
673
+ return /* @__PURE__ */ jsxRuntime.jsx(
674
+ "img",
675
+ {
676
+ ref: forwardedRef,
677
+ "data-image": "",
678
+ crossOrigin: "anonymous",
679
+ srcSet: shouldOptimize ? generateSrcSet({ src, width: size }) : void 0,
680
+ src: shouldOptimize ? generateSrc({ src, width: size * 2 }) : src,
681
+ alt: props.alt,
682
+ ...props
683
+ }
684
+ );
685
+ });
686
+ var RootDefaultElement = "div";
687
+ var cardRootLayoutStyle = {
688
+ cardRoot: {
689
+ className: [
690
+ "cl-a6922c72",
691
+ "cl-5e44c334",
692
+ "cl-c4324dd6",
693
+ "cl-3fbacce1",
694
+ "cl-89a8e890"
695
+ ].join(" ")
696
+ }
697
+ };
698
+ var cardRootVisualStyle = {
699
+ cardRoot: {
700
+ className: "cl-86f06b43"
701
+ },
702
+ cardRootDefault: {
703
+ className: "cl-bc4a783b"
704
+ },
705
+ cardRootInner: {
706
+ className: "cl-9c68c093"
707
+ }
708
+ };
709
+ React5__namespace.forwardRef(
710
+ function CardRoot({ as, banner, children, ...props }, forwardedRef) {
711
+ const { elements } = useAppearance().parsedAppearance;
712
+ const Element = as || RootDefaultElement;
713
+ const cardRootDescriptors = applyDescriptors(elements, "cardRoot");
714
+ const cardRootDefaultDescriptors = applyDescriptors(elements, "cardRootDefault");
715
+ return /* @__PURE__ */ jsxRuntime.jsxs(
716
+ Element,
717
+ {
718
+ ref: forwardedRef,
719
+ ...props,
720
+ className: cva.cx(
721
+ cardRootDescriptors.className,
722
+ banner ? [
723
+ "cl-a52b4c3f",
724
+ "cl-5af1449f"
725
+ ] : cardRootDefaultDescriptors.className
726
+ ),
727
+ children: [
728
+ banner && /* @__PURE__ */ jsxRuntime.jsx(
729
+ "div",
730
+ {
731
+ className: cva.cx(
732
+ "cl-7817f2f2"
733
+ ),
734
+ children: /* @__PURE__ */ jsxRuntime.jsx(
735
+ "p",
736
+ {
737
+ className: cva.cx(
738
+ "cl-03e68f06"
739
+ ),
740
+ ...props,
741
+ children: banner
742
+ }
743
+ )
744
+ }
745
+ ),
746
+ children && /* @__PURE__ */ jsxRuntime.jsx("div", { ...mergeDescriptors(elements.cardRootInner), children })
747
+ ]
748
+ }
749
+ );
750
+ }
751
+ );
752
+ var cardContentLayoutStyle = {
753
+ cardContent: {
754
+ className: "cl-8baa595e"
755
+ }
756
+ };
757
+ var cardContentVisualStyle = {
758
+ cardContent: {
759
+ className: [
760
+ "cl-c99cd8b4",
761
+ "cl-1c01a9d7"
762
+ ].join(" ")
763
+ }
764
+ };
765
+ React5__namespace.forwardRef(function CardContent({ children, className, ...props }, forwardedRef) {
766
+ const { elements } = useAppearance().parsedAppearance;
767
+ return /* @__PURE__ */ jsxRuntime.jsx(
768
+ "div",
769
+ {
770
+ ref: forwardedRef,
771
+ ...props,
772
+ ...mergeDescriptors(elements.cardContent),
773
+ children
774
+ }
775
+ );
776
+ });
777
+ var cardHeaderLayoutStyle = {
778
+ cardHeader: {
779
+ className: "cl-c757ad0c"
780
+ }
781
+ };
782
+ var cardHeaderVisualStyle = {};
783
+ React5__namespace.forwardRef(function CardHeader({ children, className, ...props }, forwardedRef) {
784
+ const { elements } = useAppearance().parsedAppearance;
785
+ return /* @__PURE__ */ jsxRuntime.jsx(
786
+ "div",
787
+ {
788
+ ref: forwardedRef,
789
+ ...props,
790
+ ...mergeDescriptors(elements.cardHeader),
791
+ children
792
+ }
793
+ );
794
+ });
795
+ var cardLogoLayoutStyle = {
796
+ cardLogoBox: {
797
+ className: "cl-4f5262b8"
798
+ },
799
+ cardLogoLink: {
800
+ className: "cl-33c167b1"
801
+ },
802
+ cardLogoImage: {
803
+ className: "cl-deefc87a"
804
+ }
805
+ };
806
+ var cardLogoVisualStyle = {};
807
+ React5__namespace.forwardRef(function CardLogo({
808
+ href,
809
+ src,
810
+ ...props
811
+ }, forwardedRef) {
812
+ const { elements } = useAppearance().parsedAppearance;
813
+ if (!src) {
814
+ return null;
815
+ }
816
+ const img = /* @__PURE__ */ jsxRuntime.jsx(
817
+ Image,
818
+ {
819
+ ref: forwardedRef,
820
+ src,
821
+ size: 200,
822
+ ...props,
823
+ ...mergeDescriptors(elements.cardLogoImage)
824
+ }
825
+ );
826
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ...mergeDescriptors(elements.cardLogoBox), children: href ? /* @__PURE__ */ jsxRuntime.jsx(
827
+ "a",
828
+ {
829
+ href,
830
+ ...mergeDescriptors(elements.cardLogoLink),
831
+ children: img
832
+ }
833
+ ) : img });
834
+ });
835
+ var cardTitleLayoutStyle = {};
836
+ var cardTitleVisualStyle = {
837
+ cardTitle: {
838
+ className: "cl-f29e36a7"
839
+ }
840
+ };
841
+ React5__namespace.forwardRef(function CardTitle({ children, className, ...props }, forwardedRef) {
842
+ const { elements } = useAppearance().parsedAppearance;
843
+ return /* @__PURE__ */ jsxRuntime.jsx(
844
+ "h2",
845
+ {
846
+ ref: forwardedRef,
847
+ ...props,
848
+ ...mergeDescriptors(elements.cardTitle),
849
+ children
850
+ }
851
+ );
852
+ });
853
+ var cardDescriptionLayoutStyle = {};
854
+ var cardDescriptionVisualStyle = {
855
+ cardDescription: {
856
+ className: "cl-5c413d88"
857
+ }
858
+ };
859
+ React5__namespace.forwardRef(
860
+ function CardDescription({ children, className, ...props }, forwardedRef) {
861
+ const { elements } = useAppearance().parsedAppearance;
862
+ return /* @__PURE__ */ jsxRuntime.jsx(
863
+ "p",
864
+ {
865
+ ref: forwardedRef,
866
+ ...props,
867
+ ...mergeDescriptors(elements.cardDescription),
868
+ children
869
+ }
870
+ );
871
+ }
872
+ );
873
+ var cardBodyLayoutStyle = {
874
+ cardBody: {
875
+ className: "cl-5eebf917"
876
+ }
877
+ };
878
+ var cardBodyVisualStyle = {};
879
+ React5__namespace.forwardRef(function CardBody({ children, className, ...props }, forwardedRef) {
880
+ const { elements } = useAppearance().parsedAppearance;
881
+ return /* @__PURE__ */ jsxRuntime.jsx(
882
+ "div",
883
+ {
884
+ ref: forwardedRef,
885
+ ...props,
886
+ ...mergeDescriptors(elements.cardBody),
887
+ children
888
+ }
889
+ );
890
+ });
891
+ var cardActionsLayoutStyle = {
892
+ cardActions: {
893
+ className: [
894
+ "cl-cc1fa4d3",
895
+ // Note:
896
+ // Prevents underline interractions triggering outside of the link text
897
+ // https://linear.app/clerk/issue/SDKI-192/#comment-ebf943b0
898
+ "cl-04c8fa73"
899
+ ].join(" ")
900
+ }
901
+ };
902
+ var cardActionsVisualStyle = {};
903
+ React5__namespace.forwardRef(function CardActions({ children, className, ...props }, forwardedRef) {
904
+ const { elements } = useAppearance().parsedAppearance;
905
+ return /* @__PURE__ */ jsxRuntime.jsx(
906
+ "div",
907
+ {
908
+ ref: forwardedRef,
909
+ ...props,
910
+ ...mergeDescriptors(elements.cardActions),
911
+ children
912
+ }
913
+ );
914
+ });
915
+ var cardFooterLayoutStyle = {
916
+ cardFooter: {
917
+ className: "cl-0f2a693e"
918
+ },
919
+ cardFooterAction: {
920
+ className: "cl-0c81043e"
921
+ }
922
+ };
923
+ var cardFooterVisualStyle = {
924
+ cardFooterAction: {
925
+ className: "cl-e7659ac7"
926
+ },
927
+ cardFooterActionText: {
928
+ className: "cl-8e9f71ce"
929
+ },
930
+ cardFooterActionLink: {
931
+ className: "cl-812d8d14"
932
+ },
933
+ cardFooterActionButton: {
934
+ className: "cl-812d8d14"
935
+ },
936
+ cardFooterActionPageLink: {
937
+ className: "cl-39faa7ab"
938
+ }
939
+ };
940
+ React5__namespace.forwardRef(function CardFooter({
941
+ branded = true,
942
+ helpPageUrl,
943
+ privacyPageUrl,
944
+ termsPageUrl,
945
+ children,
946
+ className,
947
+ ...props
948
+ }, forwardedRef) {
949
+ const { elements } = useAppearance().parsedAppearance;
950
+ const hasPageLinks = helpPageUrl || privacyPageUrl || termsPageUrl;
951
+ const renderFooter = branded || hasPageLinks || children;
952
+ const renderSubFooter = branded || hasPageLinks;
953
+ const hasBrandingAndPageLinks = branded && hasPageLinks;
954
+ return renderFooter ? /* @__PURE__ */ jsxRuntime.jsxs(
955
+ "div",
956
+ {
957
+ ref: forwardedRef,
958
+ ...props,
959
+ ...mergeDescriptors(elements.cardFooter),
960
+ children: [
961
+ children,
962
+ renderSubFooter ? /* @__PURE__ */ jsxRuntime.jsxs(
963
+ "div",
964
+ {
965
+ className: cva.cx("cl-10ec6412", hasBrandingAndPageLinks ? "cl-32c92bb1" : "cl-a503dd37"),
966
+ children: [
967
+ branded ? /* @__PURE__ */ jsxRuntime.jsxs(
968
+ "p",
969
+ {
970
+ className: "cl-286d6459",
971
+ children: [
972
+ "Secured by",
973
+ " ",
974
+ /* @__PURE__ */ jsxRuntime.jsx(
975
+ "a",
976
+ {
977
+ "aria-label": "Clerk logo",
978
+ href: "https://www.clerk.com?utm_source=clerk&utm_medium=components",
979
+ target: "_blank",
980
+ rel: "noopener",
981
+ className: "cl-e9dc1e80",
982
+ children: /* @__PURE__ */ jsxRuntime.jsx(ClerkLogo, {})
983
+ }
984
+ )
985
+ ]
986
+ }
987
+ ) : null,
988
+ hasPageLinks ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cl-c354e22d", children: [
989
+ helpPageUrl ? /* @__PURE__ */ jsxRuntime.jsx(FooterPageLink, { href: helpPageUrl, children: "Help" }) : null,
990
+ privacyPageUrl ? /* @__PURE__ */ jsxRuntime.jsx(FooterPageLink, { href: privacyPageUrl, children: "Privacy" }) : null,
991
+ termsPageUrl ? /* @__PURE__ */ jsxRuntime.jsx(FooterPageLink, { href: termsPageUrl, children: "Terms" }) : null
992
+ ] }) : null
993
+ ]
994
+ }
995
+ ) : null
996
+ ]
997
+ }
998
+ ) : null;
999
+ });
1000
+ React5__namespace.forwardRef(
1001
+ function CardFooterAction({ children, className, ...props }, forwardedRef) {
1002
+ const { elements } = useAppearance().parsedAppearance;
1003
+ return /* @__PURE__ */ jsxRuntime.jsx(
1004
+ "div",
1005
+ {
1006
+ ref: forwardedRef,
1007
+ ...props,
1008
+ ...mergeDescriptors(elements.cardFooterAction),
1009
+ children
1010
+ }
1011
+ );
1012
+ }
1013
+ );
1014
+ React5__namespace.forwardRef(
1015
+ function CardFooterActionText({ children, className, ...props }, forwardedRef) {
1016
+ const { elements } = useAppearance().parsedAppearance;
1017
+ return /* @__PURE__ */ jsxRuntime.jsx(
1018
+ "p",
1019
+ {
1020
+ ref: forwardedRef,
1021
+ ...props,
1022
+ ...mergeDescriptors(elements.cardFooterActionText),
1023
+ children
1024
+ }
1025
+ );
1026
+ }
1027
+ );
1028
+ React5__namespace.forwardRef(
1029
+ function CardFooterActionButton({ children, className, type = "button", ...props }, forwardedRef) {
1030
+ const { elements } = useAppearance().parsedAppearance;
1031
+ return /* @__PURE__ */ jsxRuntime.jsx(
1032
+ "button",
1033
+ {
1034
+ ref: forwardedRef,
1035
+ type,
1036
+ ...props,
1037
+ ...mergeDescriptors(elements.cardFooterActionButton),
1038
+ children
1039
+ }
1040
+ );
1041
+ }
1042
+ );
1043
+ React5__namespace.forwardRef(
1044
+ function CardFooterActionLink({ children, className, ...props }, forwardedRef) {
1045
+ const { elements } = useAppearance().parsedAppearance;
1046
+ return /* @__PURE__ */ jsxRuntime.jsx(
1047
+ "a",
1048
+ {
1049
+ ref: forwardedRef,
1050
+ ...props,
1051
+ ...mergeDescriptors(elements.cardFooterActionLink),
1052
+ children
1053
+ }
1054
+ );
1055
+ }
1056
+ );
1057
+ var FooterPageLink = React5__namespace.forwardRef(
1058
+ function CardFooterPageLink({ children, className, ...props }, forwardedRef) {
1059
+ const { elements } = useAppearance().parsedAppearance;
1060
+ return /* @__PURE__ */ jsxRuntime.jsx(
1061
+ "a",
1062
+ {
1063
+ ref: forwardedRef,
1064
+ ...props,
1065
+ target: "_blank",
1066
+ rel: "noopener",
1067
+ ...mergeDescriptors(elements.cardFooterActionPageLink),
1068
+ children
1069
+ }
1070
+ );
1071
+ }
1072
+ );
1073
+ var layoutStyle5 = {
1074
+ ...cardRootLayoutStyle,
1075
+ ...cardHeaderLayoutStyle,
1076
+ ...cardContentLayoutStyle,
1077
+ ...cardTitleLayoutStyle,
1078
+ ...cardDescriptionLayoutStyle,
1079
+ ...cardBodyLayoutStyle,
1080
+ ...cardActionsLayoutStyle,
1081
+ ...cardFooterLayoutStyle,
1082
+ ...cardLogoLayoutStyle
1083
+ };
1084
+ var visualStyle5 = {
1085
+ ...cardRootVisualStyle,
1086
+ ...cardHeaderVisualStyle,
1087
+ ...cardContentVisualStyle,
1088
+ ...cardTitleVisualStyle,
1089
+ ...cardDescriptionVisualStyle,
1090
+ ...cardBodyVisualStyle,
1091
+ ...cardActionsVisualStyle,
1092
+ ...cardFooterVisualStyle,
1093
+ ...cardLogoVisualStyle
1094
+ };
1095
+ var layoutStyle6 = {
220
1096
  separator: {
221
1097
  className: "cl-c53048bf"
222
1098
  }
223
1099
  };
224
- var visualStyle2 = {
1100
+ var visualStyle6 = {
225
1101
  separator: {
226
1102
  className: "cl-77b14b2e"
227
1103
  }
228
1104
  };
229
- React__namespace.forwardRef(function Separator2({ children, descriptors, ...props }, forwardedRef) {
1105
+ React5__namespace.forwardRef(function Separator2({ children, descriptors, ...props }, forwardedRef) {
230
1106
  const { elements } = useAppearance().parsedAppearance;
231
1107
  return /* @__PURE__ */ jsxRuntime.jsx(
232
1108
  "div",
@@ -238,18 +1114,81 @@ React__namespace.forwardRef(function Separator2({ children, descriptors, ...prop
238
1114
  }
239
1115
  );
240
1116
  });
1117
+ var DESCRIPTORS = [
1118
+ // Alert
1119
+ "alert",
1120
+ "alert__error",
1121
+ "alert__warning",
1122
+ "alertIcon",
1123
+ // Button
1124
+ "button",
1125
+ "buttonPrimary",
1126
+ "buttonSecondary",
1127
+ "buttonConnection",
1128
+ "buttonPrimaryDefault",
1129
+ "buttonSecondaryDefault",
1130
+ "buttonConnectionDefault",
1131
+ "buttonDisabled",
1132
+ "buttonBusy",
1133
+ "buttonText",
1134
+ "buttonTextVisuallyHidden",
1135
+ "buttonIcon",
1136
+ "buttonIconStart",
1137
+ "buttonIconEnd",
1138
+ "buttonSpinner",
1139
+ ...[...types.OAUTH_PROVIDERS, ...types.WEB3_PROVIDERS].map(({ provider }) => `buttonConnection__${provider}`),
1140
+ // Connection
1141
+ "connectionList",
1142
+ "connectionListItem",
1143
+ // Separator
1144
+ "separator",
1145
+ // Spinner
1146
+ "spinner",
1147
+ // Card
1148
+ "cardRoot",
1149
+ "cardRootDefault",
1150
+ "cardRootInner",
1151
+ "cardHeader",
1152
+ "cardContent",
1153
+ "cardTitle",
1154
+ "cardDescription",
1155
+ "cardBody",
1156
+ "cardActions",
1157
+ "cardFooter",
1158
+ "cardFooterAction",
1159
+ "cardFooterActionText",
1160
+ "cardFooterActionLink",
1161
+ "cardFooterActionButton",
1162
+ "cardFooterActionPageLink",
1163
+ "cardLogoBox",
1164
+ "cardLogoLink",
1165
+ "cardLogoImage"
1166
+ ];
241
1167
 
242
1168
  // src/themes/buildTheme.ts
243
1169
  function buildTheme(p) {
244
1170
  const theme = {};
1171
+ DESCRIPTORS.forEach((descriptor) => {
1172
+ theme[descriptor] = {
1173
+ descriptor: `cl-${descriptor}`,
1174
+ className: "",
1175
+ style: {}
1176
+ };
1177
+ });
245
1178
  for (const descriptor in p) {
246
- if (p[descriptor]) {
247
- const { className, style } = p[descriptor];
248
- theme[descriptor] = {
249
- descriptor: `cl-${descriptor}`,
250
- className: className != null ? className : "",
251
- style: style != null ? style : {}
252
- };
1179
+ const key = descriptor;
1180
+ if (p[key]) {
1181
+ if (!(key in theme)) {
1182
+ console.warn(`Clerk: Unknown descriptor: ${descriptor}`);
1183
+ continue;
1184
+ }
1185
+ const { className, style } = p[key];
1186
+ if (className) {
1187
+ theme[key].className = className;
1188
+ }
1189
+ if (style) {
1190
+ theme[key].style = style;
1191
+ }
253
1192
  }
254
1193
  }
255
1194
  return theme;
@@ -265,10 +1204,24 @@ function mergeTheme(a, b) {
265
1204
  }
266
1205
 
267
1206
  // src/themes/layout.ts
268
- var layoutTheme = buildTheme({ ...layoutStyle, ...layoutStyle2 });
1207
+ var layoutTheme = buildTheme({
1208
+ ...layoutStyle4,
1209
+ ...layoutStyle2,
1210
+ ...layoutStyle5,
1211
+ ...layoutStyle3,
1212
+ ...layoutStyle6,
1213
+ ...layoutStyle
1214
+ });
269
1215
 
270
1216
  // src/themes/full.ts
271
- var visualTheme = buildTheme({ ...visualStyle, ...visualStyle2 });
1217
+ var visualTheme = buildTheme({
1218
+ ...visualStyle4,
1219
+ ...visualStyle2,
1220
+ ...visualStyle5,
1221
+ ...visualStyle3,
1222
+ ...visualStyle6,
1223
+ ...visualStyle
1224
+ });
272
1225
  var fullTheme = mergeTheme(layoutTheme, visualTheme);
273
1226
  function mergeDescriptors(...descriptors) {
274
1227
  return descriptors.reduce(
@@ -303,7 +1256,7 @@ function mergeElementsAppearanceConfig(a, b) {
303
1256
  }
304
1257
  }
305
1258
  if (!result) {
306
- throw new Error(`Unable to merge ElementsAppearanceConfigs: ${a} and ${b}`);
1259
+ throw new Error(`Unable to merge ElementsAppearanceConfigs: ${JSON.stringify(a)} and ${JSON.stringify(b)}`);
307
1260
  }
308
1261
  return result;
309
1262
  }