@workos-inc/widgets 0.0.0-pre.3 → 0.0.0-pre.4
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/cjs/lib/delete-user-dialog.d.ts +1 -1
- package/dist/cjs/lib/delete-user-dialog.d.ts.map +1 -1
- package/dist/cjs/lib/delete-user-dialog.js +3 -4
- package/dist/cjs/lib/delete-user-dialog.js.map +1 -1
- package/dist/cjs/lib/edit-user-details-dialog.d.ts +1 -1
- package/dist/cjs/lib/edit-user-details-dialog.d.ts.map +1 -1
- package/dist/cjs/lib/edit-user-details-dialog.js +4 -5
- package/dist/cjs/lib/edit-user-details-dialog.js.map +1 -1
- package/dist/cjs/lib/elements.d.ts +5 -3
- package/dist/cjs/lib/elements.d.ts.map +1 -1
- package/dist/cjs/lib/elements.js +31 -20
- package/dist/cjs/lib/elements.js.map +1 -1
- package/dist/cjs/lib/invite-user-dialog.d.ts +1 -1
- package/dist/cjs/lib/invite-user-dialog.d.ts.map +1 -1
- package/dist/cjs/lib/invite-user-dialog.js +14 -18
- package/dist/cjs/lib/invite-user-dialog.js.map +1 -1
- package/dist/cjs/lib/resend-invite-dialog.d.ts +1 -1
- package/dist/cjs/lib/resend-invite-dialog.d.ts.map +1 -1
- package/dist/cjs/lib/resend-invite-dialog.js +3 -4
- package/dist/cjs/lib/resend-invite-dialog.js.map +1 -1
- package/dist/cjs/lib/revoke-invite-dialog.d.ts +1 -1
- package/dist/cjs/lib/revoke-invite-dialog.d.ts.map +1 -1
- package/dist/cjs/lib/revoke-invite-dialog.js +3 -4
- package/dist/cjs/lib/revoke-invite-dialog.js.map +1 -1
- package/dist/cjs/lib/users-management.d.ts.map +1 -1
- package/dist/cjs/lib/users-management.js +1 -1
- package/dist/cjs/lib/users-management.js.map +1 -1
- package/dist/cjs/lib/users-search.d.ts.map +1 -1
- package/dist/cjs/lib/users-search.js +5 -1
- package/dist/cjs/lib/users-search.js.map +1 -1
- package/dist/cjs/lib/utils.d.ts +2 -2
- package/dist/cjs/lib/utils.d.ts.map +1 -1
- package/dist/cjs/lib/utils.js +5 -16
- package/dist/cjs/lib/utils.js.map +1 -1
- package/dist/cjs/workos-widgets.client.d.ts.map +1 -1
- package/dist/cjs/workos-widgets.client.js +5 -1
- package/dist/cjs/workos-widgets.client.js.map +1 -1
- package/dist/esm/lib/delete-user-dialog.d.ts +1 -1
- package/dist/esm/lib/delete-user-dialog.d.ts.map +1 -1
- package/dist/esm/lib/delete-user-dialog.js +2 -2
- package/dist/esm/lib/delete-user-dialog.js.map +1 -1
- package/dist/esm/lib/edit-user-details-dialog.d.ts +1 -1
- package/dist/esm/lib/edit-user-details-dialog.d.ts.map +1 -1
- package/dist/esm/lib/edit-user-details-dialog.js +4 -4
- package/dist/esm/lib/edit-user-details-dialog.js.map +1 -1
- package/dist/esm/lib/elements.d.ts +5 -3
- package/dist/esm/lib/elements.d.ts.map +1 -1
- package/dist/esm/lib/elements.js +29 -21
- package/dist/esm/lib/elements.js.map +1 -1
- package/dist/esm/lib/invite-user-dialog.d.ts +1 -1
- package/dist/esm/lib/invite-user-dialog.d.ts.map +1 -1
- package/dist/esm/lib/invite-user-dialog.js +13 -16
- package/dist/esm/lib/invite-user-dialog.js.map +1 -1
- package/dist/esm/lib/resend-invite-dialog.d.ts +1 -1
- package/dist/esm/lib/resend-invite-dialog.d.ts.map +1 -1
- package/dist/esm/lib/resend-invite-dialog.js +2 -2
- package/dist/esm/lib/resend-invite-dialog.js.map +1 -1
- package/dist/esm/lib/revoke-invite-dialog.d.ts +1 -1
- package/dist/esm/lib/revoke-invite-dialog.d.ts.map +1 -1
- package/dist/esm/lib/revoke-invite-dialog.js +2 -2
- package/dist/esm/lib/revoke-invite-dialog.js.map +1 -1
- package/dist/esm/lib/users-management.d.ts.map +1 -1
- package/dist/esm/lib/users-management.js +2 -2
- package/dist/esm/lib/users-management.js.map +1 -1
- package/dist/esm/lib/users-search.d.ts.map +1 -1
- package/dist/esm/lib/users-search.js +3 -2
- package/dist/esm/lib/users-search.js.map +1 -1
- package/dist/esm/lib/utils.d.ts +2 -2
- package/dist/esm/lib/utils.d.ts.map +1 -1
- package/dist/esm/lib/utils.js +4 -11
- package/dist/esm/lib/utils.js.map +1 -1
- package/dist/esm/workos-widgets.client.d.ts.map +1 -1
- package/dist/esm/workos-widgets.client.js +3 -2
- package/dist/esm/workos-widgets.client.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/delete-user-dialog.tsx +3 -3
- package/src/lib/edit-user-details-dialog.tsx +4 -4
- package/src/lib/elements.tsx +62 -26
- package/src/lib/invite-user-dialog.tsx +80 -86
- package/src/lib/resend-invite-dialog.tsx +3 -3
- package/src/lib/revoke-invite-dialog.tsx +3 -3
- package/src/lib/users-management.tsx +1 -1
- package/src/lib/users-search.tsx +3 -2
- package/src/lib/utils.ts +6 -18
- package/src/workos-widgets.client.tsx +3 -2
package/src/lib/elements.tsx
CHANGED
|
@@ -2,20 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
DropdownMenu as RadixDropdownMenu,
|
|
5
|
+
AlertDialog as RadixAlertDialog,
|
|
7
6
|
Avatar as RadixAvatar,
|
|
8
7
|
AvatarProps as RadixAvatarProps,
|
|
9
|
-
AlertDialog as RadixAlertDialog,
|
|
10
|
-
Dialog as RadixDialog,
|
|
11
8
|
Badge as RadixBadge,
|
|
9
|
+
Button as RadixButton,
|
|
10
|
+
Dialog as RadixDialog,
|
|
11
|
+
DropdownMenu as RadixDropdownMenu,
|
|
12
12
|
IconButton as RadixIconButton,
|
|
13
13
|
Select as RadixSelect,
|
|
14
|
-
|
|
14
|
+
Skeleton as RadixSkeleton,
|
|
15
15
|
Text,
|
|
16
|
+
TextField as RadixTextField,
|
|
16
17
|
type BadgeProps,
|
|
17
18
|
type ButtonProps,
|
|
18
19
|
type IconButtonProps,
|
|
20
|
+
type SkeletonProps,
|
|
19
21
|
type TextProps,
|
|
20
22
|
} from "@radix-ui/themes";
|
|
21
23
|
import type {
|
|
@@ -30,10 +32,12 @@ import type {
|
|
|
30
32
|
textPropDefs,
|
|
31
33
|
textFieldRootPropDefs,
|
|
32
34
|
selectTriggerPropDefs,
|
|
35
|
+
skeletonPropDefs,
|
|
33
36
|
} from "@radix-ui/themes/props";
|
|
34
37
|
import { useComposedRefs } from "@radix-ui/react-compose-refs";
|
|
38
|
+
import cx from "clsx";
|
|
35
39
|
import { useElement } from "./widgets-context";
|
|
36
|
-
import {
|
|
40
|
+
import { namespaceClassNames } from "./utils";
|
|
37
41
|
import { useLayoutEffect } from "./use-layout-effect";
|
|
38
42
|
|
|
39
43
|
export const PrimaryButton = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
@@ -42,7 +46,10 @@ export const PrimaryButton = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
42
46
|
return (
|
|
43
47
|
<RadixButton
|
|
44
48
|
ref={ref}
|
|
45
|
-
className={cx(
|
|
49
|
+
className={cx(
|
|
50
|
+
namespaceClassNames("button", "button--primary"),
|
|
51
|
+
className,
|
|
52
|
+
)}
|
|
46
53
|
variant="solid"
|
|
47
54
|
{...props}
|
|
48
55
|
{...element}
|
|
@@ -57,7 +64,10 @@ export const SecondaryButton = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
57
64
|
return (
|
|
58
65
|
<RadixButton
|
|
59
66
|
ref={ref}
|
|
60
|
-
className={cx(
|
|
67
|
+
className={cx(
|
|
68
|
+
namespaceClassNames("button", "button--secondary"),
|
|
69
|
+
className,
|
|
70
|
+
)}
|
|
61
71
|
variant="surface"
|
|
62
72
|
color="gray"
|
|
63
73
|
{...props}
|
|
@@ -75,7 +85,10 @@ export const DestructiveButton = React.forwardRef<
|
|
|
75
85
|
return (
|
|
76
86
|
<RadixButton
|
|
77
87
|
ref={ref}
|
|
78
|
-
className={cx(
|
|
88
|
+
className={cx(
|
|
89
|
+
namespaceClassNames("button", "button--destructive"),
|
|
90
|
+
className,
|
|
91
|
+
)}
|
|
79
92
|
variant="solid"
|
|
80
93
|
color="red"
|
|
81
94
|
{...props}
|
|
@@ -90,7 +103,7 @@ export const IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(
|
|
|
90
103
|
return (
|
|
91
104
|
<RadixIconButton
|
|
92
105
|
ref={ref}
|
|
93
|
-
className={cx(
|
|
106
|
+
className={cx(namespaceClassNames("button", "icon-button"), className)}
|
|
94
107
|
variant="ghost"
|
|
95
108
|
color="gray"
|
|
96
109
|
{...props}
|
|
@@ -100,6 +113,20 @@ export const IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(
|
|
|
100
113
|
},
|
|
101
114
|
);
|
|
102
115
|
|
|
116
|
+
export const Skeleton = React.forwardRef<HTMLSpanElement, SkeletonProps>(
|
|
117
|
+
function Skeleton({ className, ...props }, ref) {
|
|
118
|
+
const element = useElement("skeleton");
|
|
119
|
+
return (
|
|
120
|
+
<RadixSkeleton
|
|
121
|
+
ref={ref}
|
|
122
|
+
className={cx(namespaceClassNames("skeleton"), className)}
|
|
123
|
+
{...props}
|
|
124
|
+
{...element}
|
|
125
|
+
/>
|
|
126
|
+
);
|
|
127
|
+
},
|
|
128
|
+
);
|
|
129
|
+
|
|
103
130
|
export const SelectTrigger = React.forwardRef<
|
|
104
131
|
HTMLButtonElement,
|
|
105
132
|
RadixSelect.TriggerProps
|
|
@@ -108,7 +135,7 @@ export const SelectTrigger = React.forwardRef<
|
|
|
108
135
|
return (
|
|
109
136
|
<RadixSelect.Trigger
|
|
110
137
|
ref={ref}
|
|
111
|
-
className={cx("select", className)}
|
|
138
|
+
className={cx(namespaceClassNames("select"), className)}
|
|
112
139
|
{...props}
|
|
113
140
|
{...element}
|
|
114
141
|
/>
|
|
@@ -123,7 +150,10 @@ export const SelectContent = React.forwardRef<
|
|
|
123
150
|
return (
|
|
124
151
|
<RadixSelect.Content
|
|
125
152
|
ref={ref}
|
|
126
|
-
className={cx(
|
|
153
|
+
className={cx(
|
|
154
|
+
namespaceClassNames("dropdown", "select-dropdown"),
|
|
155
|
+
className,
|
|
156
|
+
)}
|
|
127
157
|
{...props}
|
|
128
158
|
{...element}
|
|
129
159
|
/>
|
|
@@ -138,7 +168,7 @@ export const SelectItem = React.forwardRef<
|
|
|
138
168
|
return (
|
|
139
169
|
<RadixSelect.Item
|
|
140
170
|
ref={ref}
|
|
141
|
-
className={cx(
|
|
171
|
+
className={cx(namespaceClassNames("menu-item", "select-item"), className)}
|
|
142
172
|
{...props}
|
|
143
173
|
{...element}
|
|
144
174
|
/>
|
|
@@ -149,12 +179,14 @@ export const Label = React.forwardRef<HTMLLabelElement, TextProps>(
|
|
|
149
179
|
function Label({ children, className, ...props }, ref) {
|
|
150
180
|
const element = useElement("label");
|
|
151
181
|
return (
|
|
182
|
+
// @ts-expect-error: Text props are a complex union type depending on the
|
|
183
|
+
// `as` prop value, which breaks down when spreading in `element`
|
|
152
184
|
<Text
|
|
153
185
|
as="label"
|
|
154
186
|
ref={ref}
|
|
155
187
|
weight="bold"
|
|
156
188
|
size="2"
|
|
157
|
-
className={cx("label", className)}
|
|
189
|
+
className={cx(namespaceClassNames("label"), className)}
|
|
158
190
|
{...props}
|
|
159
191
|
{...element}
|
|
160
192
|
>
|
|
@@ -173,7 +205,7 @@ export const TextField = React.forwardRef<
|
|
|
173
205
|
<RadixTextField.Root
|
|
174
206
|
ref={ref}
|
|
175
207
|
variant="surface"
|
|
176
|
-
className={cx("text-field", className)}
|
|
208
|
+
className={cx(namespaceClassNames("text-field"), className)}
|
|
177
209
|
{...props}
|
|
178
210
|
{...element}
|
|
179
211
|
/>
|
|
@@ -187,7 +219,7 @@ export const TextFieldSlot = React.forwardRef<
|
|
|
187
219
|
return (
|
|
188
220
|
<RadixTextField.Slot
|
|
189
221
|
ref={ref}
|
|
190
|
-
className={cx("text-field-slot", className)}
|
|
222
|
+
className={cx(namespaceClassNames("text-field-slot"), className)}
|
|
191
223
|
{...props}
|
|
192
224
|
/>
|
|
193
225
|
);
|
|
@@ -199,7 +231,7 @@ export const Badge = React.forwardRef<HTMLSpanElement, BadgeProps>(
|
|
|
199
231
|
return (
|
|
200
232
|
<RadixBadge
|
|
201
233
|
ref={ref}
|
|
202
|
-
className={cx("badge", className)}
|
|
234
|
+
className={cx(namespaceClassNames("badge"), className)}
|
|
203
235
|
{...element}
|
|
204
236
|
{...props}
|
|
205
237
|
/>
|
|
@@ -215,7 +247,7 @@ export const DropdownMenuContent = React.forwardRef<
|
|
|
215
247
|
return (
|
|
216
248
|
<RadixDropdownMenu.Content
|
|
217
249
|
ref={ref}
|
|
218
|
-
className={cx("dropdown", className)}
|
|
250
|
+
className={cx(namespaceClassNames("dropdown"), className)}
|
|
219
251
|
{...props}
|
|
220
252
|
{...element}
|
|
221
253
|
/>
|
|
@@ -230,7 +262,7 @@ export const PrimaryMenuItem = React.forwardRef<
|
|
|
230
262
|
return (
|
|
231
263
|
<RadixDropdownMenu.Item
|
|
232
264
|
ref={ref}
|
|
233
|
-
className={cx("menu-item", className)}
|
|
265
|
+
className={cx(namespaceClassNames("menu-item"), className)}
|
|
234
266
|
{...props}
|
|
235
267
|
{...element}
|
|
236
268
|
/>
|
|
@@ -245,7 +277,10 @@ export const DestructiveMenuItem = React.forwardRef<
|
|
|
245
277
|
return (
|
|
246
278
|
<RadixDropdownMenu.Item
|
|
247
279
|
ref={ref}
|
|
248
|
-
className={cx(
|
|
280
|
+
className={cx(
|
|
281
|
+
namespaceClassNames("menu-item", "menu-item--destructive"),
|
|
282
|
+
className,
|
|
283
|
+
)}
|
|
249
284
|
color="red"
|
|
250
285
|
{...props}
|
|
251
286
|
{...element}
|
|
@@ -264,7 +299,7 @@ export const Avatar = React.forwardRef<HTMLImageElement, AvatarProps>(
|
|
|
264
299
|
<RadixAvatar
|
|
265
300
|
ref={ref}
|
|
266
301
|
color="gray"
|
|
267
|
-
className={cx("avatar", className)}
|
|
302
|
+
className={cx(namespaceClassNames("avatar"), className)}
|
|
268
303
|
{...props}
|
|
269
304
|
{...element}
|
|
270
305
|
// TODO: use CSS var instead of hard-coded value for opacity
|
|
@@ -282,13 +317,13 @@ export const DialogContent = React.forwardRef<
|
|
|
282
317
|
const [node, setNode] = React.useState<HTMLDivElement | null>(null);
|
|
283
318
|
const ref = useComposedRefs(forwardedRef, setNode as any);
|
|
284
319
|
useDialogOverlayHack(node, {
|
|
285
|
-
className:
|
|
320
|
+
className: namespaceClassNames("dialog-overlay"),
|
|
286
321
|
selector: ".rt-DialogOverlay",
|
|
287
322
|
});
|
|
288
323
|
return (
|
|
289
324
|
<RadixDialog.Content
|
|
290
325
|
ref={ref}
|
|
291
|
-
className={cx("dialog", className)}
|
|
326
|
+
className={cx(namespaceClassNames("dialog"), className)}
|
|
292
327
|
{...props}
|
|
293
328
|
{...element}
|
|
294
329
|
/>
|
|
@@ -303,14 +338,14 @@ export const AlertDialogContent = React.forwardRef<
|
|
|
303
338
|
const [node, setNode] = React.useState<HTMLDivElement | null>(null);
|
|
304
339
|
const ref = useComposedRefs(forwardedRef, setNode as any);
|
|
305
340
|
useDialogOverlayHack(node, {
|
|
306
|
-
className:
|
|
341
|
+
className: namespaceClassNames("dialog-overlay"),
|
|
307
342
|
selector: ".rt-AlertDialogOverlay",
|
|
308
343
|
});
|
|
309
344
|
|
|
310
345
|
return (
|
|
311
346
|
<RadixAlertDialog.Content
|
|
312
347
|
ref={ref}
|
|
313
|
-
className={cx("dialog", className)}
|
|
348
|
+
className={cx(namespaceClassNames("dialog"), className)}
|
|
314
349
|
{...props}
|
|
315
350
|
{...element}
|
|
316
351
|
/>
|
|
@@ -355,5 +390,6 @@ export type Elements = OmitAsChild<{
|
|
|
355
390
|
primaryMenuItem?: GetPropDefTypes<typeof dropdownMenuItemPropDefs>;
|
|
356
391
|
destructiveMenuItem?: GetPropDefTypes<typeof dropdownMenuItemPropDefs>;
|
|
357
392
|
avatar?: Omit<GetPropDefTypes<typeof avatarPropDefs>, "fallback">;
|
|
358
|
-
label?:
|
|
393
|
+
label?: GetPropDefTypes<typeof textPropDefs>;
|
|
394
|
+
skeleton?: GetPropDefTypes<typeof skeletonPropDefs>;
|
|
359
395
|
}>;
|
|
@@ -35,14 +35,7 @@ interface InviteUserDialogProps {
|
|
|
35
35
|
children?: React.ReactNode;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
dialogId: string;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const DialogFormContext = React.createContext<DialogFormContextValue>(null!);
|
|
43
|
-
DialogFormContext.displayName = "DialogFormContext";
|
|
44
|
-
|
|
45
|
-
export const InviteUserDialog = ({ children }: InviteUserDialogProps) => {
|
|
38
|
+
export function InviteUserDialog({ children }: InviteUserDialogProps) {
|
|
46
39
|
const [open, setOpen] = React.useState(false);
|
|
47
40
|
const dialogId = toId("invite-user", React.useId());
|
|
48
41
|
const formId = toId(dialogId, "form");
|
|
@@ -88,81 +81,81 @@ export const InviteUserDialog = ({ children }: InviteUserDialogProps) => {
|
|
|
88
81
|
An invitation will be sent to this email address with a link to
|
|
89
82
|
complete their account.
|
|
90
83
|
</Dialog.Description>
|
|
91
|
-
<
|
|
92
|
-
<
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
84
|
+
<Flex direction="column" gap="4" mt="5" asChild>
|
|
85
|
+
<form
|
|
86
|
+
id={formId}
|
|
87
|
+
onSubmit={async (event) => {
|
|
88
|
+
event.preventDefault();
|
|
89
|
+
onSubmitForm({
|
|
90
|
+
email: event.currentTarget.email.value,
|
|
91
|
+
role: selectedRole,
|
|
92
|
+
});
|
|
93
|
+
}}
|
|
94
|
+
>
|
|
95
|
+
<FormField
|
|
96
|
+
rootId={dialogId}
|
|
97
|
+
name="email"
|
|
98
|
+
label="Email address"
|
|
99
|
+
error={formErrors.fields.email}
|
|
100
|
+
required
|
|
101
|
+
control={(props) => (
|
|
102
|
+
<TextField
|
|
103
|
+
{...props}
|
|
104
|
+
data-1p-ignore="true"
|
|
105
|
+
data-lpignore="true"
|
|
106
|
+
type="email"
|
|
107
|
+
autoComplete="off"
|
|
108
|
+
placeholder="Enter an email address"
|
|
109
|
+
/>
|
|
110
|
+
)}
|
|
111
|
+
/>
|
|
119
112
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
113
|
+
<FormField
|
|
114
|
+
rootId={dialogId}
|
|
115
|
+
name="role"
|
|
116
|
+
label="Role"
|
|
117
|
+
error={formErrors.fields.role}
|
|
118
|
+
disabled={rolesQuery.isPending || roles.length <= 1}
|
|
119
|
+
info={
|
|
120
|
+
roles.length === 1 ? (
|
|
121
|
+
<>
|
|
122
|
+
New users will be invited with the{" "}
|
|
123
|
+
<Text weight="bold">{roles[0].name}</Text> role, as it is
|
|
124
|
+
the only one available.
|
|
125
|
+
</>
|
|
126
|
+
) : undefined
|
|
127
|
+
}
|
|
128
|
+
control={({
|
|
129
|
+
id,
|
|
130
|
+
"aria-invalid": ariaInvalid,
|
|
131
|
+
"aria-describedby": ariaDescribedBy,
|
|
132
|
+
...props
|
|
133
|
+
}) => (
|
|
134
|
+
<Select.Root
|
|
135
|
+
{...props}
|
|
136
|
+
value={selectedRole}
|
|
137
|
+
onValueChange={setSelectedRole}
|
|
138
|
+
>
|
|
139
|
+
<SelectTrigger
|
|
140
|
+
id={id}
|
|
141
|
+
aria-invalid={ariaInvalid}
|
|
142
|
+
aria-describedby={ariaDescribedBy}
|
|
143
|
+
/>
|
|
144
|
+
<SelectContent>
|
|
145
|
+
<SelectItem value={PLACEHOLDER_ROLE} disabled>
|
|
146
|
+
Select a role
|
|
147
|
+
</SelectItem>
|
|
148
|
+
{roles.map((role) => (
|
|
149
|
+
<SelectItem key={role.slug} value={role.slug}>
|
|
150
|
+
{role.name}
|
|
153
151
|
</SelectItem>
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
)}
|
|
162
|
-
/>
|
|
163
|
-
</form>
|
|
164
|
-
</Flex>
|
|
165
|
-
</DialogFormContext.Provider>
|
|
152
|
+
))}
|
|
153
|
+
</SelectContent>
|
|
154
|
+
</Select.Root>
|
|
155
|
+
)}
|
|
156
|
+
/>
|
|
157
|
+
</form>
|
|
158
|
+
</Flex>
|
|
166
159
|
|
|
167
160
|
{formErrors.form ? (
|
|
168
161
|
<Callout.Root color="red" mt="4" mb="-2">
|
|
@@ -191,7 +184,7 @@ export const InviteUserDialog = ({ children }: InviteUserDialogProps) => {
|
|
|
191
184
|
</DialogContent>
|
|
192
185
|
</Dialog.Root>
|
|
193
186
|
);
|
|
194
|
-
}
|
|
187
|
+
}
|
|
195
188
|
|
|
196
189
|
interface FormControlRenderProps {
|
|
197
190
|
id: string;
|
|
@@ -203,6 +196,7 @@ interface FormControlRenderProps {
|
|
|
203
196
|
}
|
|
204
197
|
|
|
205
198
|
function FormField({
|
|
199
|
+
rootId,
|
|
206
200
|
name,
|
|
207
201
|
label,
|
|
208
202
|
error,
|
|
@@ -211,6 +205,7 @@ function FormField({
|
|
|
211
205
|
required,
|
|
212
206
|
disabled,
|
|
213
207
|
}: {
|
|
208
|
+
rootId: string;
|
|
214
209
|
name: string;
|
|
215
210
|
label: string;
|
|
216
211
|
error?: React.ReactNode;
|
|
@@ -219,10 +214,9 @@ function FormField({
|
|
|
219
214
|
required?: boolean;
|
|
220
215
|
disabled?: boolean;
|
|
221
216
|
}) {
|
|
222
|
-
const
|
|
223
|
-
const
|
|
224
|
-
const
|
|
225
|
-
const infoId = toId(dialogId, name, "info");
|
|
217
|
+
const fieldId = toId(rootId, name);
|
|
218
|
+
const errorId = toId(rootId, name, "error");
|
|
219
|
+
const infoId = toId(rootId, name, "info");
|
|
226
220
|
return (
|
|
227
221
|
<Flex direction="column" gap="1">
|
|
228
222
|
<Label htmlFor={fieldId}>{label}</Label>
|
|
@@ -24,11 +24,11 @@ interface ResendInviteDialogProps extends AlertDialog.RootProps {
|
|
|
24
24
|
children?: React.ReactNode;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export
|
|
27
|
+
export function ResendInviteDialog({
|
|
28
28
|
children,
|
|
29
29
|
user,
|
|
30
30
|
...props
|
|
31
|
-
}: ResendInviteDialogProps)
|
|
31
|
+
}: ResendInviteDialogProps) {
|
|
32
32
|
const resendInvite = useResendUserInvite();
|
|
33
33
|
const cancelButtonRef = React.useRef<HTMLButtonElement>(null);
|
|
34
34
|
const successButtonRef = React.useRef<HTMLButtonElement>(null);
|
|
@@ -131,7 +131,7 @@ export const ResendInviteDialog = ({
|
|
|
131
131
|
</Dialog.Root>
|
|
132
132
|
</>
|
|
133
133
|
);
|
|
134
|
-
}
|
|
134
|
+
}
|
|
135
135
|
|
|
136
136
|
function getMutationErrorMessage(error: unknown) {
|
|
137
137
|
if (!error) {
|
|
@@ -21,11 +21,11 @@ interface RevokeInviteDialogProps extends AlertDialog.RootProps {
|
|
|
21
21
|
children?: ReactNode;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export
|
|
24
|
+
export function RevokeInviteDialog({
|
|
25
25
|
children,
|
|
26
26
|
user,
|
|
27
27
|
...props
|
|
28
|
-
}: RevokeInviteDialogProps)
|
|
28
|
+
}: RevokeInviteDialogProps) {
|
|
29
29
|
const revokeInvite = useRevokeUserInvite();
|
|
30
30
|
const cancelButtonRef = useRef<HTMLButtonElement>(null);
|
|
31
31
|
|
|
@@ -97,7 +97,7 @@ export const RevokeInviteDialog = ({
|
|
|
97
97
|
</VisuallyHidden>
|
|
98
98
|
</AlertDialog.Root>
|
|
99
99
|
);
|
|
100
|
-
}
|
|
100
|
+
}
|
|
101
101
|
|
|
102
102
|
function getMutationErrorMessage(error: unknown) {
|
|
103
103
|
if (!error) {
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
Grid,
|
|
8
8
|
Heading,
|
|
9
9
|
Select,
|
|
10
|
-
Skeleton,
|
|
11
10
|
Table,
|
|
12
11
|
Text,
|
|
13
12
|
type TextProps,
|
|
@@ -24,6 +23,7 @@ import {
|
|
|
24
23
|
SelectContent,
|
|
25
24
|
SelectItem,
|
|
26
25
|
SelectTrigger,
|
|
26
|
+
Skeleton,
|
|
27
27
|
TextField,
|
|
28
28
|
} from "./elements";
|
|
29
29
|
import { InviteUserDialog } from "./invite-user-dialog";
|
package/src/lib/users-search.tsx
CHANGED
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
import { useComposedRefs } from "@radix-ui/react-compose-refs";
|
|
4
4
|
import { Cross2Icon, MagnifyingGlassIcon } from "@radix-ui/react-icons";
|
|
5
5
|
import { IconButton } from "@radix-ui/themes";
|
|
6
|
+
import cx from "clsx";
|
|
6
7
|
import * as React from "react";
|
|
7
8
|
import { useDebouncedCallback } from "use-debounce";
|
|
8
9
|
import { TextField, TextFieldSlot } from "./elements";
|
|
9
10
|
import { useSearchContext } from "./search-provider";
|
|
10
11
|
import { useUsersManagementContext } from "./users-management-context";
|
|
11
|
-
import {
|
|
12
|
+
import { namespaceClassNames } from "./utils";
|
|
12
13
|
|
|
13
14
|
type UsersSearchProps = React.ComponentPropsWithoutRef<typeof TextField>;
|
|
14
15
|
|
|
@@ -30,7 +31,7 @@ export const UsersSearch = React.forwardRef<HTMLInputElement, UsersSearchProps>(
|
|
|
30
31
|
return (
|
|
31
32
|
<TextField
|
|
32
33
|
ref={useComposedRefs(inputRef, ref)}
|
|
33
|
-
className={cx(
|
|
34
|
+
className={cx(namespaceClassNames("users-search"), className)}
|
|
34
35
|
autoComplete="off"
|
|
35
36
|
placeholder="Search by name or e-mail"
|
|
36
37
|
value={searchValue}
|
package/src/lib/utils.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import clsx from "clsx";
|
|
2
1
|
import type { User } from "./api/user";
|
|
3
2
|
import { WIDGETS_CLASS_NAMESPACE } from "./constants";
|
|
4
3
|
|
|
@@ -95,21 +94,10 @@ export async function parseErrorResponse(
|
|
|
95
94
|
}
|
|
96
95
|
}
|
|
97
96
|
|
|
98
|
-
export function
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
...classes: (string | false | null | undefined)[]
|
|
105
|
-
): string {
|
|
106
|
-
if (baseClass) {
|
|
107
|
-
return clsx(
|
|
108
|
-
typeof baseClass === "string"
|
|
109
|
-
? namespaceClassName(baseClass)
|
|
110
|
-
: baseClass.map(namespaceClassName),
|
|
111
|
-
...classes,
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
return clsx(...classes);
|
|
97
|
+
export function namespaceClassNames(className: string): string;
|
|
98
|
+
export function namespaceClassNames(...classNames: string[]): string;
|
|
99
|
+
export function namespaceClassNames(...classNames: string[]): string {
|
|
100
|
+
return classNames
|
|
101
|
+
.map((className) => `${WIDGETS_CLASS_NAMESPACE}-${className}`)
|
|
102
|
+
.join(" ");
|
|
115
103
|
}
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
import { Theme as RadixThemes } from "@radix-ui/themes";
|
|
4
4
|
import type { GetPropDefTypes, themePropDefs } from "@radix-ui/themes/props";
|
|
5
5
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
6
|
+
import cx from "clsx";
|
|
6
7
|
import * as React from "react";
|
|
7
|
-
import {
|
|
8
|
+
import { namespaceClassNames } from "./lib/utils";
|
|
8
9
|
import { DEFAULT_API_HOSTNAME } from "./lib/api/config";
|
|
9
10
|
import type { Elements } from "./lib/elements";
|
|
10
11
|
import { WidgetsContext } from "./lib/widgets-context";
|
|
@@ -63,7 +64,7 @@ export const WorkOsWidgets: React.FC<WorkOsWidgetsProps> = ({
|
|
|
63
64
|
<RadixThemes
|
|
64
65
|
{...radixThemesProps}
|
|
65
66
|
style={customStyle}
|
|
66
|
-
className={cx("root", className)}
|
|
67
|
+
className={cx(namespaceClassNames("root"), className)}
|
|
67
68
|
>
|
|
68
69
|
<WidgetsContext.Provider value={{ elements, apiBaseUrl }}>
|
|
69
70
|
{children}
|