@sudobility/entity_pages 0.0.107 → 0.0.109
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/index.js +138 -134
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { jsx as e, jsxs as t, Fragment as S } from "react/jsx-runtime";
|
|
2
2
|
import * as M from "react";
|
|
3
3
|
import { useState as k } from "react";
|
|
4
|
+
import { createPortal as K } from "react-dom";
|
|
4
5
|
import { Section as I } from "@sudobility/components";
|
|
5
|
-
import { EntityList as z, InvitationForm as
|
|
6
|
-
import { useEntities as
|
|
7
|
-
function
|
|
6
|
+
import { EntityList as z, InvitationForm as Y, InvitationList as A, MemberList as q } from "@sudobility/entity-components";
|
|
7
|
+
import { useEntities as U, useCreateEntity as B, useEntityMembers as G, useUpdateMemberRole as H, useRemoveMember as J, useEntityInvitations as Q, useCreateInvitation as V, useCancelInvitation as X, useMyInvitations as Z, useAcceptInvitation as _, useDeclineInvitation as ee } from "@sudobility/entity_client";
|
|
8
|
+
function te({
|
|
8
9
|
title: n,
|
|
9
10
|
titleId: a,
|
|
10
11
|
...l
|
|
@@ -27,13 +28,13 @@ function ee({
|
|
|
27
28
|
d: "M12 4.5v15m7.5-7.5h-15"
|
|
28
29
|
}));
|
|
29
30
|
}
|
|
30
|
-
const
|
|
31
|
+
const ne = /* @__PURE__ */ M.forwardRef(te), L = {
|
|
31
32
|
// Background utilities
|
|
32
33
|
background: {
|
|
33
34
|
overlay: "bg-black/50 dark:bg-black/70"
|
|
34
35
|
}
|
|
35
36
|
};
|
|
36
|
-
function
|
|
37
|
+
function re() {
|
|
37
38
|
return /* @__PURE__ */ t("div", { className: "space-y-3", role: "status", "aria-label": "Loading workspaces", children: [
|
|
38
39
|
[1, 2, 3].map((n) => /* @__PURE__ */ e(
|
|
39
40
|
"div",
|
|
@@ -45,7 +46,7 @@ function ne() {
|
|
|
45
46
|
/* @__PURE__ */ e("span", { className: "sr-only", children: "Loading workspaces..." })
|
|
46
47
|
] });
|
|
47
48
|
}
|
|
48
|
-
function
|
|
49
|
+
function ge({
|
|
49
50
|
client: n,
|
|
50
51
|
onSelectEntity: a
|
|
51
52
|
}) {
|
|
@@ -58,7 +59,7 @@ function me({
|
|
|
58
59
|
isError: y,
|
|
59
60
|
error: N,
|
|
60
61
|
refetch: w
|
|
61
|
-
} =
|
|
62
|
+
} = U(n), p = B(n), b = v.filter((s) => s.entityType === "personal"), c = v.filter(
|
|
62
63
|
(s) => s.entityType === "organization"
|
|
63
64
|
), x = async (s) => {
|
|
64
65
|
if (s.preventDefault(), m(null), !i.displayName.trim()) {
|
|
@@ -88,124 +89,127 @@ function me({
|
|
|
88
89
|
"aria-label": "Create new organization",
|
|
89
90
|
className: "flex items-center justify-center gap-2 px-4 py-2 rounded-lg bg-primary text-primary-foreground font-medium hover:bg-primary/90 transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 w-full sm:w-auto",
|
|
90
91
|
children: [
|
|
91
|
-
/* @__PURE__ */ e(
|
|
92
|
+
/* @__PURE__ */ e(ne, { className: "h-4 w-4", "aria-hidden": "true" }),
|
|
92
93
|
/* @__PURE__ */ e("span", { children: "New Organization" })
|
|
93
94
|
]
|
|
94
95
|
}
|
|
95
96
|
)
|
|
96
97
|
] }),
|
|
97
|
-
l &&
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
/* @__PURE__ */
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
/* @__PURE__ */
|
|
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
|
-
/* @__PURE__ */
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
className: "text-sm text-destructive",
|
|
173
|
-
role: "alert",
|
|
174
|
-
"aria-live": "polite",
|
|
175
|
-
children: g
|
|
176
|
-
}
|
|
177
|
-
),
|
|
178
|
-
/* @__PURE__ */ t("div", { className: "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", children: [
|
|
179
|
-
/* @__PURE__ */ e(
|
|
180
|
-
"button",
|
|
98
|
+
l && K(
|
|
99
|
+
/* @__PURE__ */ e(
|
|
100
|
+
"div",
|
|
101
|
+
{
|
|
102
|
+
className: `fixed inset-0 z-50 flex items-center justify-center ${L.background.overlay} p-4`,
|
|
103
|
+
role: "dialog",
|
|
104
|
+
"aria-modal": "true",
|
|
105
|
+
"aria-label": "Create organization",
|
|
106
|
+
onClick: (s) => {
|
|
107
|
+
s.target === s.currentTarget && (r(!1), o({ displayName: "", description: "" }), m(null));
|
|
108
|
+
},
|
|
109
|
+
onKeyDown: (s) => {
|
|
110
|
+
s.key === "Escape" && (r(!1), o({ displayName: "", description: "" }), m(null));
|
|
111
|
+
},
|
|
112
|
+
children: /* @__PURE__ */ t("div", { className: "w-full max-w-md rounded-lg bg-background p-4 sm:p-6 shadow-lg", children: [
|
|
113
|
+
/* @__PURE__ */ e("h2", { className: "text-lg font-semibold mb-4", children: "Create Organization" }),
|
|
114
|
+
/* @__PURE__ */ t(
|
|
115
|
+
"form",
|
|
116
|
+
{
|
|
117
|
+
onSubmit: x,
|
|
118
|
+
className: "space-y-4",
|
|
119
|
+
"aria-label": "Create organization form",
|
|
120
|
+
children: [
|
|
121
|
+
/* @__PURE__ */ t("div", { children: [
|
|
122
|
+
/* @__PURE__ */ e(
|
|
123
|
+
"label",
|
|
124
|
+
{
|
|
125
|
+
htmlFor: "create-org-name",
|
|
126
|
+
className: "block text-sm font-medium mb-1",
|
|
127
|
+
children: "Display Name"
|
|
128
|
+
}
|
|
129
|
+
),
|
|
130
|
+
/* @__PURE__ */ e(
|
|
131
|
+
"input",
|
|
132
|
+
{
|
|
133
|
+
id: "create-org-name",
|
|
134
|
+
type: "text",
|
|
135
|
+
value: i.displayName,
|
|
136
|
+
onChange: (s) => o((f) => ({
|
|
137
|
+
...f,
|
|
138
|
+
displayName: s.target.value
|
|
139
|
+
})),
|
|
140
|
+
placeholder: "My Organization",
|
|
141
|
+
"aria-required": "true",
|
|
142
|
+
"aria-invalid": g ? "true" : void 0,
|
|
143
|
+
className: "w-full px-3 py-2 rounded-lg border bg-background focus:outline-none focus:ring-2 focus:ring-primary"
|
|
144
|
+
}
|
|
145
|
+
)
|
|
146
|
+
] }),
|
|
147
|
+
/* @__PURE__ */ t("div", { children: [
|
|
148
|
+
/* @__PURE__ */ e(
|
|
149
|
+
"label",
|
|
150
|
+
{
|
|
151
|
+
htmlFor: "create-org-description",
|
|
152
|
+
className: "block text-sm font-medium mb-1",
|
|
153
|
+
children: "Description (optional)"
|
|
154
|
+
}
|
|
155
|
+
),
|
|
156
|
+
/* @__PURE__ */ e(
|
|
157
|
+
"textarea",
|
|
158
|
+
{
|
|
159
|
+
id: "create-org-description",
|
|
160
|
+
value: i.description,
|
|
161
|
+
onChange: (s) => o((f) => ({
|
|
162
|
+
...f,
|
|
163
|
+
description: s.target.value
|
|
164
|
+
})),
|
|
165
|
+
placeholder: "What is this organization for?",
|
|
166
|
+
rows: 3,
|
|
167
|
+
className: "w-full px-3 py-2 rounded-lg border bg-background focus:outline-none focus:ring-2 focus:ring-primary resize-y"
|
|
168
|
+
}
|
|
169
|
+
)
|
|
170
|
+
] }),
|
|
171
|
+
g && /* @__PURE__ */ e(
|
|
172
|
+
"p",
|
|
181
173
|
{
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
description: ""
|
|
187
|
-
}), m(null);
|
|
188
|
-
},
|
|
189
|
-
className: "px-4 py-2 rounded-lg border hover:bg-muted transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 w-full sm:w-auto",
|
|
190
|
-
children: "Cancel"
|
|
174
|
+
className: "text-sm text-destructive",
|
|
175
|
+
role: "alert",
|
|
176
|
+
"aria-live": "polite",
|
|
177
|
+
children: g
|
|
191
178
|
}
|
|
192
179
|
),
|
|
193
|
-
/* @__PURE__ */
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
180
|
+
/* @__PURE__ */ t("div", { className: "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", children: [
|
|
181
|
+
/* @__PURE__ */ e(
|
|
182
|
+
"button",
|
|
183
|
+
{
|
|
184
|
+
type: "button",
|
|
185
|
+
onClick: () => {
|
|
186
|
+
r(!1), o({
|
|
187
|
+
displayName: "",
|
|
188
|
+
description: ""
|
|
189
|
+
}), m(null);
|
|
190
|
+
},
|
|
191
|
+
className: "px-4 py-2 rounded-lg border hover:bg-muted transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 w-full sm:w-auto",
|
|
192
|
+
children: "Cancel"
|
|
193
|
+
}
|
|
194
|
+
),
|
|
195
|
+
/* @__PURE__ */ e(
|
|
196
|
+
"button",
|
|
197
|
+
{
|
|
198
|
+
type: "submit",
|
|
199
|
+
disabled: p.isPending,
|
|
200
|
+
"aria-busy": p.isPending,
|
|
201
|
+
className: "px-4 py-2 rounded-lg bg-primary text-primary-foreground font-medium hover:bg-primary/90 transition-colors disabled:opacity-50 focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 w-full sm:w-auto",
|
|
202
|
+
children: p.isPending ? "Creating..." : "Create"
|
|
203
|
+
}
|
|
204
|
+
)
|
|
205
|
+
] })
|
|
206
|
+
]
|
|
207
|
+
}
|
|
208
|
+
)
|
|
209
|
+
] })
|
|
210
|
+
}
|
|
211
|
+
),
|
|
212
|
+
document.body
|
|
209
213
|
),
|
|
210
214
|
y && /* @__PURE__ */ t(
|
|
211
215
|
"div",
|
|
@@ -229,7 +233,7 @@ function me({
|
|
|
229
233
|
]
|
|
230
234
|
}
|
|
231
235
|
),
|
|
232
|
-
u && /* @__PURE__ */ e(
|
|
236
|
+
u && /* @__PURE__ */ e(re, {}),
|
|
233
237
|
!u && !y && /* @__PURE__ */ t(S, { children: [
|
|
234
238
|
b.length > 0 && /* @__PURE__ */ t("section", { className: "mb-6 sm:mb-8", "aria-label": "Personal workspace", children: [
|
|
235
239
|
/* @__PURE__ */ e("h2", { className: "text-base sm:text-lg font-semibold mb-3", children: "Personal Workspace" }),
|
|
@@ -298,7 +302,7 @@ function R() {
|
|
|
298
302
|
/* @__PURE__ */ e("span", { className: "sr-only", children: "Loading members..." })
|
|
299
303
|
] });
|
|
300
304
|
}
|
|
301
|
-
function
|
|
305
|
+
function ie({
|
|
302
306
|
title: n,
|
|
303
307
|
message: a,
|
|
304
308
|
confirmLabel: l,
|
|
@@ -345,7 +349,7 @@ function re({
|
|
|
345
349
|
}
|
|
346
350
|
);
|
|
347
351
|
}
|
|
348
|
-
function
|
|
352
|
+
function pe({
|
|
349
353
|
client: n,
|
|
350
354
|
entity: a,
|
|
351
355
|
currentUserId: l
|
|
@@ -356,13 +360,13 @@ function ue({
|
|
|
356
360
|
isError: v,
|
|
357
361
|
error: u,
|
|
358
362
|
refetch: y
|
|
359
|
-
} =
|
|
363
|
+
} = G(n, a.entitySlug), N = H(n), w = J(n), {
|
|
360
364
|
data: p = [],
|
|
361
365
|
isLoading: b,
|
|
362
366
|
isError: c,
|
|
363
367
|
error: x,
|
|
364
368
|
refetch: s
|
|
365
|
-
} =
|
|
369
|
+
} = Q(n, r ? a.entitySlug : null), f = V(n), D = X(n), F = async (d, h) => {
|
|
366
370
|
try {
|
|
367
371
|
await N.mutateAsync({
|
|
368
372
|
entitySlug: a.entitySlug,
|
|
@@ -425,7 +429,7 @@ function ue({
|
|
|
425
429
|
}
|
|
426
430
|
) }) : /* @__PURE__ */ e(I, { spacing: "lg", maxWidth: "4xl", children: /* @__PURE__ */ t("div", { role: "main", "aria-label": "Members management", children: [
|
|
427
431
|
i && /* @__PURE__ */ e(
|
|
428
|
-
|
|
432
|
+
ie,
|
|
429
433
|
{
|
|
430
434
|
title: i.type === "removeMember" ? "Remove Member" : "Cancel Invitation",
|
|
431
435
|
message: i.type === "removeMember" ? `Are you sure you want to remove ${i.displayLabel}? They will lose access to this organization.` : `Are you sure you want to cancel the invitation to ${i.displayLabel}?`,
|
|
@@ -449,7 +453,7 @@ function ue({
|
|
|
449
453
|
children: [
|
|
450
454
|
/* @__PURE__ */ e("h2", { className: "text-base sm:text-lg font-semibold mb-3 sm:mb-4", children: "Invite Members" }),
|
|
451
455
|
/* @__PURE__ */ e(
|
|
452
|
-
|
|
456
|
+
Y,
|
|
453
457
|
{
|
|
454
458
|
onSubmit: T,
|
|
455
459
|
isSubmitting: f.isPending
|
|
@@ -537,7 +541,7 @@ function ue({
|
|
|
537
541
|
]
|
|
538
542
|
}
|
|
539
543
|
) : /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ e(
|
|
540
|
-
|
|
544
|
+
q,
|
|
541
545
|
{
|
|
542
546
|
members: g,
|
|
543
547
|
currentUserId: l,
|
|
@@ -550,7 +554,7 @@ function ue({
|
|
|
550
554
|
] })
|
|
551
555
|
] }) });
|
|
552
556
|
}
|
|
553
|
-
function
|
|
557
|
+
function ae() {
|
|
554
558
|
return /* @__PURE__ */ t("div", { className: "space-y-3", role: "status", "aria-label": "Loading invitations", children: [
|
|
555
559
|
[1, 2].map((n) => /* @__PURE__ */ e(
|
|
556
560
|
"div",
|
|
@@ -562,7 +566,7 @@ function ie() {
|
|
|
562
566
|
/* @__PURE__ */ e("span", { className: "sr-only", children: "Loading invitations..." })
|
|
563
567
|
] });
|
|
564
568
|
}
|
|
565
|
-
function
|
|
569
|
+
function oe({
|
|
566
570
|
entityName: n,
|
|
567
571
|
onConfirm: a,
|
|
568
572
|
onCancel: l
|
|
@@ -612,7 +616,7 @@ function ae({
|
|
|
612
616
|
}
|
|
613
617
|
);
|
|
614
618
|
}
|
|
615
|
-
function
|
|
619
|
+
function fe({
|
|
616
620
|
client: n,
|
|
617
621
|
onInvitationAccepted: a
|
|
618
622
|
}) {
|
|
@@ -622,7 +626,7 @@ function ge({
|
|
|
622
626
|
isError: i,
|
|
623
627
|
error: o,
|
|
624
628
|
refetch: g
|
|
625
|
-
} =
|
|
629
|
+
} = Z(n), m = _(n), v = ee(n), [u, y] = k(null), N = async (c) => {
|
|
626
630
|
try {
|
|
627
631
|
await m.mutateAsync(c), a?.();
|
|
628
632
|
} catch (x) {
|
|
@@ -645,7 +649,7 @@ function ge({
|
|
|
645
649
|
).length;
|
|
646
650
|
return /* @__PURE__ */ e(I, { spacing: "lg", maxWidth: "4xl", children: /* @__PURE__ */ t("div", { role: "main", "aria-label": "Invitations", children: [
|
|
647
651
|
u && /* @__PURE__ */ e(
|
|
648
|
-
|
|
652
|
+
oe,
|
|
649
653
|
{
|
|
650
654
|
entityName: u.entityName,
|
|
651
655
|
onConfirm: p,
|
|
@@ -678,7 +682,7 @@ function ge({
|
|
|
678
682
|
]
|
|
679
683
|
}
|
|
680
684
|
),
|
|
681
|
-
r && /* @__PURE__ */ e(
|
|
685
|
+
r && /* @__PURE__ */ e(ae, {}),
|
|
682
686
|
!r && !i && /* @__PURE__ */ e(S, { children: l.length === 0 ? /* @__PURE__ */ t(
|
|
683
687
|
"div",
|
|
684
688
|
{
|
|
@@ -703,7 +707,7 @@ function ge({
|
|
|
703
707
|
] }) });
|
|
704
708
|
}
|
|
705
709
|
export {
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
710
|
+
ge as EntityListPage,
|
|
711
|
+
fe as InvitationsPage,
|
|
712
|
+
pe as MembersManagementPage
|
|
709
713
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sudobility/entity_pages",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.109",
|
|
4
4
|
"description": "Page containers for entity/organization management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"react": "^18.0.0 || ^19.0.0",
|
|
41
41
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
42
42
|
"@tanstack/react-query": "^5.0.0",
|
|
43
|
-
"@sudobility/components": "^5.0.
|
|
43
|
+
"@sudobility/components": "^5.0.68",
|
|
44
44
|
"@sudobility/entity_client": "^0.0.36",
|
|
45
45
|
"@sudobility/entity-components": "^1.0.13",
|
|
46
46
|
"@heroicons/react": "^2.2.0",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@eslint/js": "^9.38.0",
|
|
52
52
|
"@heroicons/react": "^2.2.0",
|
|
53
|
-
"@sudobility/components": "^5.0.
|
|
53
|
+
"@sudobility/components": "^5.0.68",
|
|
54
54
|
"@sudobility/design": "^1.1.30",
|
|
55
55
|
"@sudobility/entity-components": "^1.0.13",
|
|
56
56
|
"@sudobility/entity_client": "^0.0.36",
|