@clerk/react 5.54.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +71 -0
  3. package/dist/chunk-KLK6ZMZX.mjs +1011 -0
  4. package/dist/chunk-KLK6ZMZX.mjs.map +1 -0
  5. package/dist/chunk-MB46WFKC.mjs +28 -0
  6. package/dist/chunk-MB46WFKC.mjs.map +1 -0
  7. package/dist/chunk-OANWQR3B.mjs +16 -0
  8. package/dist/chunk-OANWQR3B.mjs.map +1 -0
  9. package/dist/chunk-PS5BRRRD.mjs +282 -0
  10. package/dist/chunk-PS5BRRRD.mjs.map +1 -0
  11. package/dist/chunk-Z2DSM5QN.mjs +171 -0
  12. package/dist/chunk-Z2DSM5QN.mjs.map +1 -0
  13. package/dist/errors.d.mts +1 -0
  14. package/dist/errors.d.ts +1 -0
  15. package/dist/errors.js +45 -0
  16. package/dist/errors.js.map +1 -0
  17. package/dist/errors.mjs +24 -0
  18. package/dist/errors.mjs.map +1 -0
  19. package/dist/experimental.d.mts +125 -0
  20. package/dist/experimental.d.ts +125 -0
  21. package/dist/experimental.js +1301 -0
  22. package/dist/experimental.js.map +1 -0
  23. package/dist/experimental.mjs +164 -0
  24. package/dist/experimental.mjs.map +1 -0
  25. package/dist/index.d.mts +217 -0
  26. package/dist/index.d.ts +217 -0
  27. package/dist/index.js +3304 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/index.mjs +1940 -0
  30. package/dist/index.mjs.map +1 -0
  31. package/dist/internal.d.mts +18 -0
  32. package/dist/internal.d.ts +18 -0
  33. package/dist/internal.js +260 -0
  34. package/dist/internal.js.map +1 -0
  35. package/dist/internal.mjs +58 -0
  36. package/dist/internal.mjs.map +1 -0
  37. package/dist/legacy.d.mts +95 -0
  38. package/dist/legacy.d.ts +95 -0
  39. package/dist/legacy.js +90 -0
  40. package/dist/legacy.js.map +1 -0
  41. package/dist/legacy.mjs +48 -0
  42. package/dist/legacy.mjs.map +1 -0
  43. package/dist/types-BS-xjOf_.d.mts +77 -0
  44. package/dist/types-BS-xjOf_.d.ts +77 -0
  45. package/dist/useAuth-CibrZ7p3.d.mts +182 -0
  46. package/dist/useAuth-yh0dHssU.d.ts +182 -0
  47. package/package.json +116 -0
@@ -0,0 +1,1011 @@
1
+ import {
2
+ customLinkWrongProps,
3
+ customMenuItemsIgnoredComponent,
4
+ customPageWrongProps,
5
+ customPagesIgnoredComponent,
6
+ multipleChildrenInButtonComponent,
7
+ organizationProfileLinkRenderedError,
8
+ organizationProfilePageRenderedError,
9
+ userButtonIgnoredComponent,
10
+ userButtonMenuActionRenderedError,
11
+ userButtonMenuItemLinkWrongProps,
12
+ userButtonMenuItemsActionWrongsProps,
13
+ userButtonMenuItemsRenderedError,
14
+ userButtonMenuLinkRenderedError,
15
+ userProfileLinkRenderedError,
16
+ userProfilePageRenderedError,
17
+ withClerk
18
+ } from "./chunk-PS5BRRRD.mjs";
19
+ import {
20
+ errorThrower
21
+ } from "./chunk-MB46WFKC.mjs";
22
+
23
+ // src/components/uiComponents.tsx
24
+ import { logErrorInDevMode as logErrorInDevMode3 } from "@clerk/shared/utils";
25
+ import React7, { createContext, createElement, useContext } from "react";
26
+
27
+ // src/utils/childrenUtils.tsx
28
+ import React from "react";
29
+ var assertSingleChild = (children) => (name) => {
30
+ try {
31
+ return React.Children.only(children);
32
+ } catch {
33
+ return errorThrower.throw(multipleChildrenInButtonComponent(name));
34
+ }
35
+ };
36
+ var normalizeWithDefaultValue = (children, defaultText) => {
37
+ if (!children) {
38
+ children = defaultText;
39
+ }
40
+ if (typeof children === "string") {
41
+ children = /* @__PURE__ */ React.createElement("button", null, children);
42
+ }
43
+ return children;
44
+ };
45
+ var safeExecute = (cb) => (...args) => {
46
+ if (cb && typeof cb === "function") {
47
+ return cb(...args);
48
+ }
49
+ };
50
+
51
+ // src/utils/isConstructor.ts
52
+ function isConstructor(f) {
53
+ return typeof f === "function";
54
+ }
55
+
56
+ // src/utils/useMaxAllowedInstancesGuard.tsx
57
+ import React2 from "react";
58
+ var counts = /* @__PURE__ */ new Map();
59
+ function useMaxAllowedInstancesGuard(name, error, maxCount = 1) {
60
+ React2.useEffect(() => {
61
+ const count = counts.get(name) || 0;
62
+ if (count == maxCount) {
63
+ return errorThrower.throw(error);
64
+ }
65
+ counts.set(name, count + 1);
66
+ return () => {
67
+ counts.set(name, (counts.get(name) || 1) - 1);
68
+ };
69
+ }, []);
70
+ }
71
+ function withMaxAllowedInstancesGuard(WrappedComponent, name, error) {
72
+ const displayName = WrappedComponent.displayName || WrappedComponent.name || name || "Component";
73
+ const Hoc = (props) => {
74
+ useMaxAllowedInstancesGuard(name, error);
75
+ return /* @__PURE__ */ React2.createElement(WrappedComponent, { ...props });
76
+ };
77
+ Hoc.displayName = `withMaxAllowedInstancesGuard(${displayName})`;
78
+ return Hoc;
79
+ }
80
+
81
+ // src/utils/useCustomElementPortal.tsx
82
+ import { useState } from "react";
83
+ import { createPortal } from "react-dom";
84
+ var useCustomElementPortal = (elements) => {
85
+ const [nodeMap, setNodeMap] = useState(/* @__PURE__ */ new Map());
86
+ return elements.map((el) => ({
87
+ id: el.id,
88
+ mount: (node) => setNodeMap((prev) => new Map(prev).set(String(el.id), node)),
89
+ unmount: () => setNodeMap((prev) => {
90
+ const newMap = new Map(prev);
91
+ newMap.set(String(el.id), null);
92
+ return newMap;
93
+ }),
94
+ portal: () => {
95
+ const node = nodeMap.get(String(el.id));
96
+ return node ? createPortal(el.component, node) : null;
97
+ }
98
+ }));
99
+ };
100
+
101
+ // src/utils/useCustomPages.tsx
102
+ import { logErrorInDevMode } from "@clerk/shared/utils";
103
+ import React4 from "react";
104
+
105
+ // src/utils/componentValidation.ts
106
+ import React3 from "react";
107
+ var isThatComponent = (v, component) => {
108
+ return !!v && React3.isValidElement(v) && (v == null ? void 0 : v.type) === component;
109
+ };
110
+
111
+ // src/utils/useCustomPages.tsx
112
+ var useUserProfileCustomPages = (children, options) => {
113
+ const reorderItemsLabels = ["account", "security"];
114
+ return useCustomPages(
115
+ {
116
+ children,
117
+ reorderItemsLabels,
118
+ LinkComponent: UserProfileLink,
119
+ PageComponent: UserProfilePage,
120
+ MenuItemsComponent: MenuItems,
121
+ componentName: "UserProfile"
122
+ },
123
+ options
124
+ );
125
+ };
126
+ var useOrganizationProfileCustomPages = (children, options) => {
127
+ const reorderItemsLabels = ["general", "members"];
128
+ return useCustomPages(
129
+ {
130
+ children,
131
+ reorderItemsLabels,
132
+ LinkComponent: OrganizationProfileLink,
133
+ PageComponent: OrganizationProfilePage,
134
+ componentName: "OrganizationProfile"
135
+ },
136
+ options
137
+ );
138
+ };
139
+ var useSanitizedChildren = (children) => {
140
+ const sanitizedChildren = [];
141
+ const excludedComponents = [
142
+ OrganizationProfileLink,
143
+ OrganizationProfilePage,
144
+ MenuItems,
145
+ UserProfilePage,
146
+ UserProfileLink
147
+ ];
148
+ React4.Children.forEach(children, (child) => {
149
+ if (!excludedComponents.some((component) => isThatComponent(child, component))) {
150
+ sanitizedChildren.push(child);
151
+ }
152
+ });
153
+ return sanitizedChildren;
154
+ };
155
+ var useCustomPages = (params, options) => {
156
+ const { children, LinkComponent, PageComponent, MenuItemsComponent, reorderItemsLabels, componentName } = params;
157
+ const { allowForAnyChildren = false } = options || {};
158
+ const validChildren = [];
159
+ React4.Children.forEach(children, (child) => {
160
+ if (!isThatComponent(child, PageComponent) && !isThatComponent(child, LinkComponent) && !isThatComponent(child, MenuItemsComponent)) {
161
+ if (child && !allowForAnyChildren) {
162
+ logErrorInDevMode(customPagesIgnoredComponent(componentName));
163
+ }
164
+ return;
165
+ }
166
+ const { props } = child;
167
+ const { children: children2, label, url, labelIcon } = props;
168
+ if (isThatComponent(child, PageComponent)) {
169
+ if (isReorderItem(props, reorderItemsLabels)) {
170
+ validChildren.push({ label });
171
+ } else if (isCustomPage(props)) {
172
+ validChildren.push({ label, labelIcon, children: children2, url });
173
+ } else {
174
+ logErrorInDevMode(customPageWrongProps(componentName));
175
+ return;
176
+ }
177
+ }
178
+ if (isThatComponent(child, LinkComponent)) {
179
+ if (isExternalLink(props)) {
180
+ validChildren.push({ label, labelIcon, url });
181
+ } else {
182
+ logErrorInDevMode(customLinkWrongProps(componentName));
183
+ return;
184
+ }
185
+ }
186
+ });
187
+ const customPageContents = [];
188
+ const customPageLabelIcons = [];
189
+ const customLinkLabelIcons = [];
190
+ validChildren.forEach((cp, index) => {
191
+ if (isCustomPage(cp)) {
192
+ customPageContents.push({ component: cp.children, id: index });
193
+ customPageLabelIcons.push({ component: cp.labelIcon, id: index });
194
+ return;
195
+ }
196
+ if (isExternalLink(cp)) {
197
+ customLinkLabelIcons.push({ component: cp.labelIcon, id: index });
198
+ }
199
+ });
200
+ const customPageContentsPortals = useCustomElementPortal(customPageContents);
201
+ const customPageLabelIconsPortals = useCustomElementPortal(customPageLabelIcons);
202
+ const customLinkLabelIconsPortals = useCustomElementPortal(customLinkLabelIcons);
203
+ const customPages = [];
204
+ const customPagesPortals = [];
205
+ validChildren.forEach((cp, index) => {
206
+ if (isReorderItem(cp, reorderItemsLabels)) {
207
+ customPages.push({ label: cp.label });
208
+ return;
209
+ }
210
+ if (isCustomPage(cp)) {
211
+ const {
212
+ portal: contentPortal,
213
+ mount,
214
+ unmount
215
+ } = customPageContentsPortals.find((p) => p.id === index);
216
+ const {
217
+ portal: labelPortal,
218
+ mount: mountIcon,
219
+ unmount: unmountIcon
220
+ } = customPageLabelIconsPortals.find((p) => p.id === index);
221
+ customPages.push({ label: cp.label, url: cp.url, mount, unmount, mountIcon, unmountIcon });
222
+ customPagesPortals.push(contentPortal);
223
+ customPagesPortals.push(labelPortal);
224
+ return;
225
+ }
226
+ if (isExternalLink(cp)) {
227
+ const {
228
+ portal: labelPortal,
229
+ mount: mountIcon,
230
+ unmount: unmountIcon
231
+ } = customLinkLabelIconsPortals.find((p) => p.id === index);
232
+ customPages.push({ label: cp.label, url: cp.url, mountIcon, unmountIcon });
233
+ customPagesPortals.push(labelPortal);
234
+ return;
235
+ }
236
+ });
237
+ return { customPages, customPagesPortals };
238
+ };
239
+ var isReorderItem = (childProps, validItems) => {
240
+ const { children, label, url, labelIcon } = childProps;
241
+ return !children && !url && !labelIcon && validItems.some((v) => v === label);
242
+ };
243
+ var isCustomPage = (childProps) => {
244
+ const { children, label, url, labelIcon } = childProps;
245
+ return !!children && !!url && !!labelIcon && !!label;
246
+ };
247
+ var isExternalLink = (childProps) => {
248
+ const { children, label, url, labelIcon } = childProps;
249
+ return !children && !!url && !!labelIcon && !!label;
250
+ };
251
+
252
+ // src/utils/useCustomMenuItems.tsx
253
+ import { logErrorInDevMode as logErrorInDevMode2 } from "@clerk/shared/utils";
254
+ import React5 from "react";
255
+ var useUserButtonCustomMenuItems = (children, options) => {
256
+ var _a;
257
+ const reorderItemsLabels = ["manageAccount", "signOut"];
258
+ return useCustomMenuItems({
259
+ children,
260
+ reorderItemsLabels,
261
+ MenuItemsComponent: MenuItems,
262
+ MenuActionComponent: MenuAction,
263
+ MenuLinkComponent: MenuLink,
264
+ UserProfileLinkComponent: UserProfileLink,
265
+ UserProfilePageComponent: UserProfilePage,
266
+ allowForAnyChildren: (_a = options == null ? void 0 : options.allowForAnyChildren) != null ? _a : false
267
+ });
268
+ };
269
+ var useCustomMenuItems = ({
270
+ children,
271
+ MenuItemsComponent,
272
+ MenuActionComponent,
273
+ MenuLinkComponent,
274
+ UserProfileLinkComponent,
275
+ UserProfilePageComponent,
276
+ reorderItemsLabels,
277
+ allowForAnyChildren = false
278
+ }) => {
279
+ const validChildren = [];
280
+ const customMenuItems = [];
281
+ const customMenuItemsPortals = [];
282
+ React5.Children.forEach(children, (child) => {
283
+ if (!isThatComponent(child, MenuItemsComponent) && !isThatComponent(child, UserProfileLinkComponent) && !isThatComponent(child, UserProfilePageComponent)) {
284
+ if (child && !allowForAnyChildren) {
285
+ logErrorInDevMode2(userButtonIgnoredComponent);
286
+ }
287
+ return;
288
+ }
289
+ if (isThatComponent(child, UserProfileLinkComponent) || isThatComponent(child, UserProfilePageComponent)) {
290
+ return;
291
+ }
292
+ const { props } = child;
293
+ React5.Children.forEach(props.children, (child2) => {
294
+ if (!isThatComponent(child2, MenuActionComponent) && !isThatComponent(child2, MenuLinkComponent)) {
295
+ if (child2) {
296
+ logErrorInDevMode2(customMenuItemsIgnoredComponent);
297
+ }
298
+ return;
299
+ }
300
+ const { props: props2 } = child2;
301
+ const { label, labelIcon, href, onClick, open } = props2;
302
+ if (isThatComponent(child2, MenuActionComponent)) {
303
+ if (isReorderItem2(props2, reorderItemsLabels)) {
304
+ validChildren.push({ label });
305
+ } else if (isCustomMenuItem(props2)) {
306
+ const baseItem = {
307
+ label,
308
+ labelIcon
309
+ };
310
+ if (onClick !== void 0) {
311
+ validChildren.push({
312
+ ...baseItem,
313
+ onClick
314
+ });
315
+ } else if (open !== void 0) {
316
+ validChildren.push({
317
+ ...baseItem,
318
+ open: open.startsWith("/") ? open : `/${open}`
319
+ });
320
+ } else {
321
+ logErrorInDevMode2("Custom menu item must have either onClick or open property");
322
+ return;
323
+ }
324
+ } else {
325
+ logErrorInDevMode2(userButtonMenuItemsActionWrongsProps);
326
+ return;
327
+ }
328
+ }
329
+ if (isThatComponent(child2, MenuLinkComponent)) {
330
+ if (isExternalLink2(props2)) {
331
+ validChildren.push({ label, labelIcon, href });
332
+ } else {
333
+ logErrorInDevMode2(userButtonMenuItemLinkWrongProps);
334
+ return;
335
+ }
336
+ }
337
+ });
338
+ });
339
+ const customMenuItemLabelIcons = [];
340
+ const customLinkLabelIcons = [];
341
+ validChildren.forEach((mi, index) => {
342
+ if (isCustomMenuItem(mi)) {
343
+ customMenuItemLabelIcons.push({ component: mi.labelIcon, id: index });
344
+ }
345
+ if (isExternalLink2(mi)) {
346
+ customLinkLabelIcons.push({ component: mi.labelIcon, id: index });
347
+ }
348
+ });
349
+ const customMenuItemLabelIconsPortals = useCustomElementPortal(customMenuItemLabelIcons);
350
+ const customLinkLabelIconsPortals = useCustomElementPortal(customLinkLabelIcons);
351
+ validChildren.forEach((mi, index) => {
352
+ if (isReorderItem2(mi, reorderItemsLabels)) {
353
+ customMenuItems.push({
354
+ label: mi.label
355
+ });
356
+ }
357
+ if (isCustomMenuItem(mi)) {
358
+ const {
359
+ portal: iconPortal,
360
+ mount: mountIcon,
361
+ unmount: unmountIcon
362
+ } = customMenuItemLabelIconsPortals.find((p) => p.id === index);
363
+ const menuItem = {
364
+ label: mi.label,
365
+ mountIcon,
366
+ unmountIcon
367
+ };
368
+ if ("onClick" in mi) {
369
+ menuItem.onClick = mi.onClick;
370
+ } else if ("open" in mi) {
371
+ menuItem.open = mi.open;
372
+ }
373
+ customMenuItems.push(menuItem);
374
+ customMenuItemsPortals.push(iconPortal);
375
+ }
376
+ if (isExternalLink2(mi)) {
377
+ const {
378
+ portal: iconPortal,
379
+ mount: mountIcon,
380
+ unmount: unmountIcon
381
+ } = customLinkLabelIconsPortals.find((p) => p.id === index);
382
+ customMenuItems.push({
383
+ label: mi.label,
384
+ href: mi.href,
385
+ mountIcon,
386
+ unmountIcon
387
+ });
388
+ customMenuItemsPortals.push(iconPortal);
389
+ }
390
+ });
391
+ return { customMenuItems, customMenuItemsPortals };
392
+ };
393
+ var isReorderItem2 = (childProps, validItems) => {
394
+ const { children, label, onClick, labelIcon } = childProps;
395
+ return !children && !onClick && !labelIcon && validItems.some((v) => v === label);
396
+ };
397
+ var isCustomMenuItem = (childProps) => {
398
+ const { label, labelIcon, onClick, open } = childProps;
399
+ return !!labelIcon && !!label && (typeof onClick === "function" || typeof open === "string");
400
+ };
401
+ var isExternalLink2 = (childProps) => {
402
+ const { label, href, labelIcon } = childProps;
403
+ return !!href && !!labelIcon && !!label;
404
+ };
405
+
406
+ // src/utils/useWaitForComponentMount.ts
407
+ import { useEffect, useRef, useState as useState2 } from "react";
408
+ var createAwaitableMutationObserver = (globalOptions) => {
409
+ const isReady = globalOptions == null ? void 0 : globalOptions.isReady;
410
+ return (options) => new Promise((resolve, reject) => {
411
+ const { root = document == null ? void 0 : document.body, selector, timeout = 0 } = options;
412
+ if (!root) {
413
+ reject(new Error("No root element provided"));
414
+ return;
415
+ }
416
+ let elementToWatch = root;
417
+ if (selector) {
418
+ elementToWatch = root == null ? void 0 : root.querySelector(selector);
419
+ }
420
+ if (isReady(elementToWatch, selector)) {
421
+ resolve();
422
+ return;
423
+ }
424
+ const observer = new MutationObserver((mutationsList) => {
425
+ for (const mutation of mutationsList) {
426
+ if (!elementToWatch && selector) {
427
+ elementToWatch = root == null ? void 0 : root.querySelector(selector);
428
+ }
429
+ if (globalOptions.childList && mutation.type === "childList" || globalOptions.attributes && mutation.type === "attributes") {
430
+ if (isReady(elementToWatch, selector)) {
431
+ observer.disconnect();
432
+ resolve();
433
+ return;
434
+ }
435
+ }
436
+ }
437
+ });
438
+ observer.observe(root, globalOptions);
439
+ if (timeout > 0) {
440
+ setTimeout(() => {
441
+ observer.disconnect();
442
+ reject(new Error(`Timeout waiting for ${selector}`));
443
+ }, timeout);
444
+ }
445
+ });
446
+ };
447
+ var waitForElementChildren = createAwaitableMutationObserver({
448
+ childList: true,
449
+ subtree: true,
450
+ isReady: (el, selector) => {
451
+ var _a;
452
+ return !!(el == null ? void 0 : el.childElementCount) && ((_a = el == null ? void 0 : el.matches) == null ? void 0 : _a.call(el, selector)) && el.childElementCount > 0;
453
+ }
454
+ });
455
+ function useWaitForComponentMount(component, options) {
456
+ const watcherRef = useRef();
457
+ const [status, setStatus] = useState2("rendering");
458
+ useEffect(() => {
459
+ if (!component) {
460
+ throw new Error("Clerk: no component name provided, unable to detect mount.");
461
+ }
462
+ if (typeof window !== "undefined" && !watcherRef.current) {
463
+ const defaultSelector = `[data-clerk-component="${component}"]`;
464
+ const selector = options == null ? void 0 : options.selector;
465
+ watcherRef.current = waitForElementChildren({
466
+ selector: selector ? (
467
+ // Allows for `[data-clerk-component="xxxx"][data-some-attribute="123"] .my-class`
468
+ defaultSelector + selector
469
+ ) : defaultSelector
470
+ }).then(() => {
471
+ setStatus("rendered");
472
+ }).catch(() => {
473
+ setStatus("error");
474
+ });
475
+ }
476
+ }, [component, options == null ? void 0 : options.selector]);
477
+ return status;
478
+ }
479
+
480
+ // src/components/ClerkHostRenderer.tsx
481
+ import { without } from "@clerk/shared/object";
482
+ import { isDeeplyEqual } from "@clerk/shared/react";
483
+ import React6 from "react";
484
+ var isMountProps = (props) => {
485
+ return "mount" in props;
486
+ };
487
+ var isOpenProps = (props) => {
488
+ return "open" in props;
489
+ };
490
+ var stripMenuItemIconHandlers = (menuItems) => {
491
+ return menuItems == null ? void 0 : menuItems.map(({ mountIcon, unmountIcon, ...rest }) => rest);
492
+ };
493
+ var ClerkHostRenderer = class extends React6.PureComponent {
494
+ constructor() {
495
+ super(...arguments);
496
+ this.rootRef = React6.createRef();
497
+ }
498
+ componentDidUpdate(_prevProps) {
499
+ var _a, _b, _c, _d;
500
+ if (!isMountProps(_prevProps) || !isMountProps(this.props)) {
501
+ return;
502
+ }
503
+ const prevProps = without(_prevProps.props, "customPages", "customMenuItems", "children");
504
+ const newProps = without(this.props.props, "customPages", "customMenuItems", "children");
505
+ const customPagesChanged = ((_a = prevProps.customPages) == null ? void 0 : _a.length) !== ((_b = newProps.customPages) == null ? void 0 : _b.length);
506
+ const customMenuItemsChanged = ((_c = prevProps.customMenuItems) == null ? void 0 : _c.length) !== ((_d = newProps.customMenuItems) == null ? void 0 : _d.length);
507
+ const prevMenuItemsWithoutHandlers = stripMenuItemIconHandlers(_prevProps.props.customMenuItems);
508
+ const newMenuItemsWithoutHandlers = stripMenuItemIconHandlers(this.props.props.customMenuItems);
509
+ if (!isDeeplyEqual(prevProps, newProps) || !isDeeplyEqual(prevMenuItemsWithoutHandlers, newMenuItemsWithoutHandlers) || customPagesChanged || customMenuItemsChanged) {
510
+ if (this.rootRef.current) {
511
+ this.props.updateProps({ node: this.rootRef.current, props: this.props.props });
512
+ }
513
+ }
514
+ }
515
+ componentDidMount() {
516
+ if (this.rootRef.current) {
517
+ if (isMountProps(this.props)) {
518
+ this.props.mount(this.rootRef.current, this.props.props);
519
+ }
520
+ if (isOpenProps(this.props)) {
521
+ this.props.open(this.props.props);
522
+ }
523
+ }
524
+ }
525
+ componentWillUnmount() {
526
+ if (this.rootRef.current) {
527
+ if (isMountProps(this.props)) {
528
+ this.props.unmount(this.rootRef.current);
529
+ }
530
+ if (isOpenProps(this.props)) {
531
+ this.props.close();
532
+ }
533
+ }
534
+ }
535
+ render() {
536
+ const { hideRootHtmlElement = false } = this.props;
537
+ const rootAttributes = {
538
+ ref: this.rootRef,
539
+ ...this.props.rootProps,
540
+ ...this.props.component && { "data-clerk-component": this.props.component }
541
+ };
542
+ return /* @__PURE__ */ React6.createElement(React6.Fragment, null, !hideRootHtmlElement && /* @__PURE__ */ React6.createElement("div", { ...rootAttributes }), this.props.children);
543
+ }
544
+ };
545
+
546
+ // src/components/uiComponents.tsx
547
+ var CustomPortalsRenderer = (props) => {
548
+ var _a, _b;
549
+ return /* @__PURE__ */ React7.createElement(React7.Fragment, null, (_a = props == null ? void 0 : props.customPagesPortals) == null ? void 0 : _a.map((portal, index) => createElement(portal, { key: index })), (_b = props == null ? void 0 : props.customMenuItemsPortals) == null ? void 0 : _b.map((portal, index) => createElement(portal, { key: index })));
550
+ };
551
+ var SignIn = withClerk(
552
+ ({ clerk, component, fallback, ...props }) => {
553
+ const mountingStatus = useWaitForComponentMount(component);
554
+ const shouldShowFallback = mountingStatus === "rendering" || !clerk.loaded;
555
+ const rendererRootProps = {
556
+ ...shouldShowFallback && fallback && { style: { display: "none" } }
557
+ };
558
+ return /* @__PURE__ */ React7.createElement(React7.Fragment, null, shouldShowFallback && fallback, clerk.loaded && /* @__PURE__ */ React7.createElement(
559
+ ClerkHostRenderer,
560
+ {
561
+ component,
562
+ mount: clerk.mountSignIn,
563
+ unmount: clerk.unmountSignIn,
564
+ updateProps: clerk.__unstable__updateProps,
565
+ props,
566
+ rootProps: rendererRootProps
567
+ }
568
+ ));
569
+ },
570
+ { component: "SignIn", renderWhileLoading: true }
571
+ );
572
+ var SignUp = withClerk(
573
+ ({ clerk, component, fallback, ...props }) => {
574
+ const mountingStatus = useWaitForComponentMount(component);
575
+ const shouldShowFallback = mountingStatus === "rendering" || !clerk.loaded;
576
+ const rendererRootProps = {
577
+ ...shouldShowFallback && fallback && { style: { display: "none" } }
578
+ };
579
+ return /* @__PURE__ */ React7.createElement(React7.Fragment, null, shouldShowFallback && fallback, clerk.loaded && /* @__PURE__ */ React7.createElement(
580
+ ClerkHostRenderer,
581
+ {
582
+ component,
583
+ mount: clerk.mountSignUp,
584
+ unmount: clerk.unmountSignUp,
585
+ updateProps: clerk.__unstable__updateProps,
586
+ props,
587
+ rootProps: rendererRootProps
588
+ }
589
+ ));
590
+ },
591
+ { component: "SignUp", renderWhileLoading: true }
592
+ );
593
+ function UserProfilePage({ children }) {
594
+ logErrorInDevMode3(userProfilePageRenderedError);
595
+ return /* @__PURE__ */ React7.createElement(React7.Fragment, null, children);
596
+ }
597
+ function UserProfileLink({ children }) {
598
+ logErrorInDevMode3(userProfileLinkRenderedError);
599
+ return /* @__PURE__ */ React7.createElement(React7.Fragment, null, children);
600
+ }
601
+ var _UserProfile = withClerk(
602
+ ({
603
+ clerk,
604
+ component,
605
+ fallback,
606
+ ...props
607
+ }) => {
608
+ const mountingStatus = useWaitForComponentMount(component);
609
+ const shouldShowFallback = mountingStatus === "rendering" || !clerk.loaded;
610
+ const rendererRootProps = {
611
+ ...shouldShowFallback && fallback && { style: { display: "none" } }
612
+ };
613
+ const { customPages, customPagesPortals } = useUserProfileCustomPages(props.children);
614
+ return /* @__PURE__ */ React7.createElement(React7.Fragment, null, shouldShowFallback && fallback, /* @__PURE__ */ React7.createElement(
615
+ ClerkHostRenderer,
616
+ {
617
+ component,
618
+ mount: clerk.mountUserProfile,
619
+ unmount: clerk.unmountUserProfile,
620
+ updateProps: clerk.__unstable__updateProps,
621
+ props: { ...props, customPages },
622
+ rootProps: rendererRootProps
623
+ },
624
+ /* @__PURE__ */ React7.createElement(CustomPortalsRenderer, { customPagesPortals })
625
+ ));
626
+ },
627
+ { component: "UserProfile", renderWhileLoading: true }
628
+ );
629
+ var UserProfile = Object.assign(_UserProfile, {
630
+ Page: UserProfilePage,
631
+ Link: UserProfileLink
632
+ });
633
+ var UserButtonContext = createContext({
634
+ mount: () => {
635
+ },
636
+ unmount: () => {
637
+ },
638
+ updateProps: () => {
639
+ }
640
+ });
641
+ var _UserButton = withClerk(
642
+ ({
643
+ clerk,
644
+ component,
645
+ fallback,
646
+ ...props
647
+ }) => {
648
+ const mountingStatus = useWaitForComponentMount(component);
649
+ const shouldShowFallback = mountingStatus === "rendering" || !clerk.loaded;
650
+ const rendererRootProps = {
651
+ ...shouldShowFallback && fallback && { style: { display: "none" } }
652
+ };
653
+ const { customPages, customPagesPortals } = useUserProfileCustomPages(props.children, {
654
+ allowForAnyChildren: !!props.__experimental_asProvider
655
+ });
656
+ const userProfileProps = Object.assign(props.userProfileProps || {}, { customPages });
657
+ const { customMenuItems, customMenuItemsPortals } = useUserButtonCustomMenuItems(props.children, {
658
+ allowForAnyChildren: !!props.__experimental_asProvider
659
+ });
660
+ const sanitizedChildren = useSanitizedChildren(props.children);
661
+ const passableProps = {
662
+ mount: clerk.mountUserButton,
663
+ unmount: clerk.unmountUserButton,
664
+ updateProps: clerk.__unstable__updateProps,
665
+ props: { ...props, userProfileProps, customMenuItems }
666
+ };
667
+ const portalProps = {
668
+ customPagesPortals,
669
+ customMenuItemsPortals
670
+ };
671
+ return /* @__PURE__ */ React7.createElement(UserButtonContext.Provider, { value: passableProps }, shouldShowFallback && fallback, clerk.loaded && /* @__PURE__ */ React7.createElement(
672
+ ClerkHostRenderer,
673
+ {
674
+ component,
675
+ ...passableProps,
676
+ hideRootHtmlElement: !!props.__experimental_asProvider,
677
+ rootProps: rendererRootProps
678
+ },
679
+ props.__experimental_asProvider ? sanitizedChildren : null,
680
+ /* @__PURE__ */ React7.createElement(CustomPortalsRenderer, { ...portalProps })
681
+ ));
682
+ },
683
+ { component: "UserButton", renderWhileLoading: true }
684
+ );
685
+ function MenuItems({ children }) {
686
+ logErrorInDevMode3(userButtonMenuItemsRenderedError);
687
+ return /* @__PURE__ */ React7.createElement(React7.Fragment, null, children);
688
+ }
689
+ function MenuAction({ children }) {
690
+ logErrorInDevMode3(userButtonMenuActionRenderedError);
691
+ return /* @__PURE__ */ React7.createElement(React7.Fragment, null, children);
692
+ }
693
+ function MenuLink({ children }) {
694
+ logErrorInDevMode3(userButtonMenuLinkRenderedError);
695
+ return /* @__PURE__ */ React7.createElement(React7.Fragment, null, children);
696
+ }
697
+ function UserButtonOutlet(outletProps) {
698
+ const providerProps = useContext(UserButtonContext);
699
+ const portalProps = {
700
+ ...providerProps,
701
+ props: {
702
+ ...providerProps.props,
703
+ ...outletProps
704
+ }
705
+ };
706
+ return /* @__PURE__ */ React7.createElement(ClerkHostRenderer, { ...portalProps });
707
+ }
708
+ var UserButton = Object.assign(_UserButton, {
709
+ UserProfilePage,
710
+ UserProfileLink,
711
+ MenuItems,
712
+ Action: MenuAction,
713
+ Link: MenuLink,
714
+ __experimental_Outlet: UserButtonOutlet
715
+ });
716
+ function OrganizationProfilePage({ children }) {
717
+ logErrorInDevMode3(organizationProfilePageRenderedError);
718
+ return /* @__PURE__ */ React7.createElement(React7.Fragment, null, children);
719
+ }
720
+ function OrganizationProfileLink({ children }) {
721
+ logErrorInDevMode3(organizationProfileLinkRenderedError);
722
+ return /* @__PURE__ */ React7.createElement(React7.Fragment, null, children);
723
+ }
724
+ var _OrganizationProfile = withClerk(
725
+ ({
726
+ clerk,
727
+ component,
728
+ fallback,
729
+ ...props
730
+ }) => {
731
+ const mountingStatus = useWaitForComponentMount(component);
732
+ const shouldShowFallback = mountingStatus === "rendering" || !clerk.loaded;
733
+ const rendererRootProps = {
734
+ ...shouldShowFallback && fallback && { style: { display: "none" } }
735
+ };
736
+ const { customPages, customPagesPortals } = useOrganizationProfileCustomPages(props.children);
737
+ return /* @__PURE__ */ React7.createElement(React7.Fragment, null, shouldShowFallback && fallback, clerk.loaded && /* @__PURE__ */ React7.createElement(
738
+ ClerkHostRenderer,
739
+ {
740
+ component,
741
+ mount: clerk.mountOrganizationProfile,
742
+ unmount: clerk.unmountOrganizationProfile,
743
+ updateProps: clerk.__unstable__updateProps,
744
+ props: { ...props, customPages },
745
+ rootProps: rendererRootProps
746
+ },
747
+ /* @__PURE__ */ React7.createElement(CustomPortalsRenderer, { customPagesPortals })
748
+ ));
749
+ },
750
+ { component: "OrganizationProfile", renderWhileLoading: true }
751
+ );
752
+ var OrganizationProfile = Object.assign(_OrganizationProfile, {
753
+ Page: OrganizationProfilePage,
754
+ Link: OrganizationProfileLink
755
+ });
756
+ var CreateOrganization = withClerk(
757
+ ({ clerk, component, fallback, ...props }) => {
758
+ const mountingStatus = useWaitForComponentMount(component);
759
+ const shouldShowFallback = mountingStatus === "rendering" || !clerk.loaded;
760
+ const rendererRootProps = {
761
+ ...shouldShowFallback && fallback && { style: { display: "none" } }
762
+ };
763
+ return /* @__PURE__ */ React7.createElement(React7.Fragment, null, shouldShowFallback && fallback, clerk.loaded && /* @__PURE__ */ React7.createElement(
764
+ ClerkHostRenderer,
765
+ {
766
+ component,
767
+ mount: clerk.mountCreateOrganization,
768
+ unmount: clerk.unmountCreateOrganization,
769
+ updateProps: clerk.__unstable__updateProps,
770
+ props,
771
+ rootProps: rendererRootProps
772
+ }
773
+ ));
774
+ },
775
+ { component: "CreateOrganization", renderWhileLoading: true }
776
+ );
777
+ var OrganizationSwitcherContext = createContext({
778
+ mount: () => {
779
+ },
780
+ unmount: () => {
781
+ },
782
+ updateProps: () => {
783
+ }
784
+ });
785
+ var _OrganizationSwitcher = withClerk(
786
+ ({
787
+ clerk,
788
+ component,
789
+ fallback,
790
+ ...props
791
+ }) => {
792
+ const mountingStatus = useWaitForComponentMount(component);
793
+ const shouldShowFallback = mountingStatus === "rendering" || !clerk.loaded;
794
+ const rendererRootProps = {
795
+ ...shouldShowFallback && fallback && { style: { display: "none" } }
796
+ };
797
+ const { customPages, customPagesPortals } = useOrganizationProfileCustomPages(props.children, {
798
+ allowForAnyChildren: !!props.__experimental_asProvider
799
+ });
800
+ const organizationProfileProps = Object.assign(props.organizationProfileProps || {}, { customPages });
801
+ const sanitizedChildren = useSanitizedChildren(props.children);
802
+ const passableProps = {
803
+ mount: clerk.mountOrganizationSwitcher,
804
+ unmount: clerk.unmountOrganizationSwitcher,
805
+ updateProps: clerk.__unstable__updateProps,
806
+ props: { ...props, organizationProfileProps },
807
+ rootProps: rendererRootProps,
808
+ component
809
+ };
810
+ clerk.__experimental_prefetchOrganizationSwitcher();
811
+ return /* @__PURE__ */ React7.createElement(OrganizationSwitcherContext.Provider, { value: passableProps }, /* @__PURE__ */ React7.createElement(React7.Fragment, null, shouldShowFallback && fallback, clerk.loaded && /* @__PURE__ */ React7.createElement(
812
+ ClerkHostRenderer,
813
+ {
814
+ ...passableProps,
815
+ hideRootHtmlElement: !!props.__experimental_asProvider
816
+ },
817
+ props.__experimental_asProvider ? sanitizedChildren : null,
818
+ /* @__PURE__ */ React7.createElement(CustomPortalsRenderer, { customPagesPortals })
819
+ )));
820
+ },
821
+ { component: "OrganizationSwitcher", renderWhileLoading: true }
822
+ );
823
+ function OrganizationSwitcherOutlet(outletProps) {
824
+ const providerProps = useContext(OrganizationSwitcherContext);
825
+ const portalProps = {
826
+ ...providerProps,
827
+ props: {
828
+ ...providerProps.props,
829
+ ...outletProps
830
+ }
831
+ };
832
+ return /* @__PURE__ */ React7.createElement(ClerkHostRenderer, { ...portalProps });
833
+ }
834
+ var OrganizationSwitcher = Object.assign(_OrganizationSwitcher, {
835
+ OrganizationProfilePage,
836
+ OrganizationProfileLink,
837
+ __experimental_Outlet: OrganizationSwitcherOutlet
838
+ });
839
+ var OrganizationList = withClerk(
840
+ ({ clerk, component, fallback, ...props }) => {
841
+ const mountingStatus = useWaitForComponentMount(component);
842
+ const shouldShowFallback = mountingStatus === "rendering" || !clerk.loaded;
843
+ const rendererRootProps = {
844
+ ...shouldShowFallback && fallback && { style: { display: "none" } }
845
+ };
846
+ return /* @__PURE__ */ React7.createElement(React7.Fragment, null, shouldShowFallback && fallback, clerk.loaded && /* @__PURE__ */ React7.createElement(
847
+ ClerkHostRenderer,
848
+ {
849
+ component,
850
+ mount: clerk.mountOrganizationList,
851
+ unmount: clerk.unmountOrganizationList,
852
+ updateProps: clerk.__unstable__updateProps,
853
+ props,
854
+ rootProps: rendererRootProps
855
+ }
856
+ ));
857
+ },
858
+ { component: "OrganizationList", renderWhileLoading: true }
859
+ );
860
+ var GoogleOneTap = withClerk(
861
+ ({ clerk, component, fallback, ...props }) => {
862
+ const mountingStatus = useWaitForComponentMount(component);
863
+ const shouldShowFallback = mountingStatus === "rendering" || !clerk.loaded;
864
+ const rendererRootProps = {
865
+ ...shouldShowFallback && fallback && { style: { display: "none" } }
866
+ };
867
+ return /* @__PURE__ */ React7.createElement(React7.Fragment, null, shouldShowFallback && fallback, clerk.loaded && /* @__PURE__ */ React7.createElement(
868
+ ClerkHostRenderer,
869
+ {
870
+ component,
871
+ open: clerk.openGoogleOneTap,
872
+ close: clerk.closeGoogleOneTap,
873
+ updateProps: clerk.__unstable__updateProps,
874
+ props,
875
+ rootProps: rendererRootProps
876
+ }
877
+ ));
878
+ },
879
+ { component: "GoogleOneTap", renderWhileLoading: true }
880
+ );
881
+ var Waitlist = withClerk(
882
+ ({ clerk, component, fallback, ...props }) => {
883
+ const mountingStatus = useWaitForComponentMount(component);
884
+ const shouldShowFallback = mountingStatus === "rendering" || !clerk.loaded;
885
+ const rendererRootProps = {
886
+ ...shouldShowFallback && fallback && { style: { display: "none" } }
887
+ };
888
+ return /* @__PURE__ */ React7.createElement(React7.Fragment, null, shouldShowFallback && fallback, clerk.loaded && /* @__PURE__ */ React7.createElement(
889
+ ClerkHostRenderer,
890
+ {
891
+ component,
892
+ mount: clerk.mountWaitlist,
893
+ unmount: clerk.unmountWaitlist,
894
+ updateProps: clerk.__unstable__updateProps,
895
+ props,
896
+ rootProps: rendererRootProps
897
+ }
898
+ ));
899
+ },
900
+ { component: "Waitlist", renderWhileLoading: true }
901
+ );
902
+ var PricingTable = withClerk(
903
+ ({ clerk, component, fallback, ...props }) => {
904
+ const mountingStatus = useWaitForComponentMount(component, {
905
+ // This attribute is added to the PricingTable root element after we've successfully fetched the plans asynchronously.
906
+ selector: '[data-component-status="ready"]'
907
+ });
908
+ const shouldShowFallback = mountingStatus === "rendering" || !clerk.loaded;
909
+ const rendererRootProps = {
910
+ ...shouldShowFallback && fallback && { style: { display: "none" } }
911
+ };
912
+ return /* @__PURE__ */ React7.createElement(React7.Fragment, null, shouldShowFallback && fallback, clerk.loaded && /* @__PURE__ */ React7.createElement(
913
+ ClerkHostRenderer,
914
+ {
915
+ component,
916
+ mount: clerk.mountPricingTable,
917
+ unmount: clerk.unmountPricingTable,
918
+ updateProps: clerk.__unstable__updateProps,
919
+ props,
920
+ rootProps: rendererRootProps
921
+ }
922
+ ));
923
+ },
924
+ { component: "PricingTable", renderWhileLoading: true }
925
+ );
926
+ var APIKeys = withClerk(
927
+ ({ clerk, component, fallback, ...props }) => {
928
+ const mountingStatus = useWaitForComponentMount(component);
929
+ const shouldShowFallback = mountingStatus === "rendering" || !clerk.loaded;
930
+ const rendererRootProps = {
931
+ ...shouldShowFallback && fallback && { style: { display: "none" } }
932
+ };
933
+ return /* @__PURE__ */ React7.createElement(React7.Fragment, null, shouldShowFallback && fallback, clerk.loaded && /* @__PURE__ */ React7.createElement(
934
+ ClerkHostRenderer,
935
+ {
936
+ component,
937
+ mount: clerk.mountApiKeys,
938
+ unmount: clerk.unmountApiKeys,
939
+ updateProps: clerk.__unstable__updateProps,
940
+ props,
941
+ rootProps: rendererRootProps
942
+ }
943
+ ));
944
+ },
945
+ { component: "ApiKeys", renderWhileLoading: true }
946
+ );
947
+ var UserAvatar = withClerk(
948
+ ({ clerk, component, fallback, ...props }) => {
949
+ const mountingStatus = useWaitForComponentMount(component);
950
+ const shouldShowFallback = mountingStatus === "rendering" || !clerk.loaded;
951
+ const rendererRootProps = {
952
+ ...shouldShowFallback && fallback && { style: { display: "none" } }
953
+ };
954
+ return /* @__PURE__ */ React7.createElement(React7.Fragment, null, shouldShowFallback && fallback, clerk.loaded && /* @__PURE__ */ React7.createElement(
955
+ ClerkHostRenderer,
956
+ {
957
+ component,
958
+ mount: clerk.mountUserAvatar,
959
+ unmount: clerk.unmountUserAvatar,
960
+ updateProps: clerk.__unstable__updateProps,
961
+ props,
962
+ rootProps: rendererRootProps
963
+ }
964
+ ));
965
+ },
966
+ { component: "UserAvatar", renderWhileLoading: true }
967
+ );
968
+ var TaskChooseOrganization = withClerk(
969
+ ({ clerk, component, fallback, ...props }) => {
970
+ const mountingStatus = useWaitForComponentMount(component);
971
+ const shouldShowFallback = mountingStatus === "rendering" || !clerk.loaded;
972
+ const rendererRootProps = {
973
+ ...shouldShowFallback && fallback && { style: { display: "none" } }
974
+ };
975
+ return /* @__PURE__ */ React7.createElement(React7.Fragment, null, shouldShowFallback && fallback, clerk.loaded && /* @__PURE__ */ React7.createElement(
976
+ ClerkHostRenderer,
977
+ {
978
+ component,
979
+ mount: clerk.mountTaskChooseOrganization,
980
+ unmount: clerk.unmountTaskChooseOrganization,
981
+ updateProps: clerk.__unstable__updateProps,
982
+ props,
983
+ rootProps: rendererRootProps
984
+ }
985
+ ));
986
+ },
987
+ { component: "TaskChooseOrganization", renderWhileLoading: true }
988
+ );
989
+
990
+ export {
991
+ assertSingleChild,
992
+ normalizeWithDefaultValue,
993
+ safeExecute,
994
+ isConstructor,
995
+ withMaxAllowedInstancesGuard,
996
+ SignIn,
997
+ SignUp,
998
+ UserProfile,
999
+ UserButton,
1000
+ OrganizationProfile,
1001
+ CreateOrganization,
1002
+ OrganizationSwitcher,
1003
+ OrganizationList,
1004
+ GoogleOneTap,
1005
+ Waitlist,
1006
+ PricingTable,
1007
+ APIKeys,
1008
+ UserAvatar,
1009
+ TaskChooseOrganization
1010
+ };
1011
+ //# sourceMappingURL=chunk-KLK6ZMZX.mjs.map