@sudobility/entity_pages 0.0.86 → 0.0.87

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 (2) hide show
  1. package/dist/index.js +84 -79
  2. package/package.json +6 -4
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- import { jsx as e, jsxs as t, Fragment as R } from "react/jsx-runtime";
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
4
  import { Section as I } from "@sudobility/components";
5
- import { EntityList as E, InvitationForm as K, InvitationList as S, MemberList as Y } from "@sudobility/entity-components";
6
- import { useEntities as $, useCreateEntity as q, useEntityMembers as U, useUpdateMemberRole as B, useRemoveMember as G, useEntityInvitations as H, useCreateInvitation as J, useCancelInvitation as Q, useMyInvitations as V, useAcceptInvitation as X, useDeclineInvitation as Z } from "@sudobility/entity_client";
7
- function _({
5
+ import { EntityList as z, InvitationForm as K, InvitationList as A, MemberList as Y } from "@sudobility/entity-components";
6
+ import { useEntities as q, useCreateEntity as U, useEntityMembers as B, useUpdateMemberRole as G, useRemoveMember as H, useEntityInvitations as J, useCreateInvitation as Q, useCancelInvitation as V, useMyInvitations as X, useAcceptInvitation as Z, useDeclineInvitation as _ } from "@sudobility/entity_client";
7
+ function ee({
8
8
  title: n,
9
9
  titleId: a,
10
10
  ...l
@@ -27,8 +27,13 @@ function _({
27
27
  d: "M12 4.5v15m7.5-7.5h-15"
28
28
  }));
29
29
  }
30
- const ee = /* @__PURE__ */ M.forwardRef(_);
31
- function te() {
30
+ const te = /* @__PURE__ */ M.forwardRef(ee), L = {
31
+ // Background utilities
32
+ background: {
33
+ overlay: "bg-black/50 dark:bg-black/70"
34
+ }
35
+ };
36
+ function ne() {
32
37
  return /* @__PURE__ */ t("div", { className: "space-y-3", role: "status", "aria-label": "Loading workspaces", children: [
33
38
  [1, 2, 3].map((n) => /* @__PURE__ */ e(
34
39
  "div",
@@ -40,7 +45,7 @@ function te() {
40
45
  /* @__PURE__ */ e("span", { className: "sr-only", children: "Loading workspaces..." })
41
46
  ] });
42
47
  }
43
- function de({
48
+ function me({
44
49
  client: n,
45
50
  onSelectEntity: a
46
51
  }) {
@@ -51,11 +56,24 @@ function de({
51
56
  data: v = [],
52
57
  isLoading: u,
53
58
  isError: y,
54
- error: x,
55
- refetch: N
56
- } = $(n), p = q(n), b = v.filter((s) => s.entityType === "personal"), c = v.filter(
59
+ error: N,
60
+ refetch: w
61
+ } = q(n), p = U(n), b = v.filter((s) => s.entityType === "personal"), c = v.filter(
57
62
  (s) => s.entityType === "organization"
58
- );
63
+ ), x = async (s) => {
64
+ if (s.preventDefault(), m(null), !i.displayName.trim()) {
65
+ m("Display name is required");
66
+ return;
67
+ }
68
+ try {
69
+ await p.mutateAsync({
70
+ displayName: i.displayName.trim(),
71
+ description: i.description.trim() || void 0
72
+ }), r(!1), o({ displayName: "", description: "" });
73
+ } catch (f) {
74
+ m(f.message || "Failed to create organization");
75
+ }
76
+ };
59
77
  return /* @__PURE__ */ e(I, { spacing: "lg", maxWidth: "4xl", children: /* @__PURE__ */ t("div", { role: "main", "aria-label": "Workspaces", children: [
60
78
  /* @__PURE__ */ t("div", { className: "flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between mb-6 sm:mb-8", children: [
61
79
  /* @__PURE__ */ t("div", { children: [
@@ -70,7 +88,7 @@ function de({
70
88
  "aria-label": "Create new organization",
71
89
  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",
72
90
  children: [
73
- /* @__PURE__ */ e(ee, { className: "h-4 w-4", "aria-hidden": "true" }),
91
+ /* @__PURE__ */ e(te, { className: "h-4 w-4", "aria-hidden": "true" }),
74
92
  /* @__PURE__ */ e("span", { children: "New Organization" })
75
93
  ]
76
94
  }
@@ -79,7 +97,7 @@ function de({
79
97
  l && /* @__PURE__ */ e(
80
98
  "div",
81
99
  {
82
- className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",
100
+ className: `fixed inset-0 z-50 flex items-center justify-center ${L.background.overlay} p-4`,
83
101
  role: "dialog",
84
102
  "aria-modal": "true",
85
103
  "aria-label": "Create organization",
@@ -94,20 +112,7 @@ function de({
94
112
  /* @__PURE__ */ t(
95
113
  "form",
96
114
  {
97
- onSubmit: async (s) => {
98
- if (s.preventDefault(), m(null), !i.displayName.trim()) {
99
- m("Display name is required");
100
- return;
101
- }
102
- try {
103
- await p.mutateAsync({
104
- displayName: i.displayName.trim(),
105
- description: i.description.trim() || void 0
106
- }), r(!1), o({ displayName: "", description: "" });
107
- } catch (f) {
108
- m(f.message || "Failed to create organization");
109
- }
110
- },
115
+ onSubmit: x,
111
116
  className: "space-y-4",
112
117
  "aria-label": "Create organization form",
113
118
  children: [
@@ -210,12 +215,12 @@ function de({
210
215
  "aria-live": "polite",
211
216
  children: [
212
217
  /* @__PURE__ */ e("p", { className: "text-destructive font-medium mb-2", children: "Failed to load workspaces" }),
213
- /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground mb-4", children: x?.message || "An unexpected error occurred" }),
218
+ /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground mb-4", children: N?.message || "An unexpected error occurred" }),
214
219
  /* @__PURE__ */ e(
215
220
  "button",
216
221
  {
217
222
  type: "button",
218
- onClick: () => N(),
223
+ onClick: () => w(),
219
224
  "aria-label": "Retry loading workspaces",
220
225
  className: "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",
221
226
  children: "Retry"
@@ -224,12 +229,12 @@ function de({
224
229
  ]
225
230
  }
226
231
  ),
227
- u && /* @__PURE__ */ e(te, {}),
228
- !u && !y && /* @__PURE__ */ t(R, { children: [
232
+ u && /* @__PURE__ */ e(ne, {}),
233
+ !u && !y && /* @__PURE__ */ t(S, { children: [
229
234
  b.length > 0 && /* @__PURE__ */ t("section", { className: "mb-6 sm:mb-8", "aria-label": "Personal workspace", children: [
230
235
  /* @__PURE__ */ e("h2", { className: "text-base sm:text-lg font-semibold mb-3", children: "Personal Workspace" }),
231
236
  /* @__PURE__ */ e(
232
- E,
237
+ z,
233
238
  {
234
239
  entities: b,
235
240
  onSelect: a,
@@ -259,7 +264,7 @@ function de({
259
264
  ]
260
265
  }
261
266
  ) : /* @__PURE__ */ e(
262
- E,
267
+ z,
263
268
  {
264
269
  entities: c,
265
270
  onSelect: a,
@@ -281,7 +286,7 @@ function de({
281
286
  ] })
282
287
  ] }) });
283
288
  }
284
- function z() {
289
+ function R() {
285
290
  return /* @__PURE__ */ t("div", { className: "space-y-3", role: "status", "aria-label": "Loading members", children: [
286
291
  [1, 2, 3].map((n) => /* @__PURE__ */ e(
287
292
  "div",
@@ -293,7 +298,7 @@ function z() {
293
298
  /* @__PURE__ */ e("span", { className: "sr-only", children: "Loading members..." })
294
299
  ] });
295
300
  }
296
- function ne({
301
+ function re({
297
302
  title: n,
298
303
  message: a,
299
304
  confirmLabel: l,
@@ -303,7 +308,7 @@ function ne({
303
308
  return /* @__PURE__ */ e(
304
309
  "div",
305
310
  {
306
- className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",
311
+ className: `fixed inset-0 z-50 flex items-center justify-center ${L.background.overlay} p-4`,
307
312
  role: "dialog",
308
313
  "aria-modal": "true",
309
314
  "aria-label": n,
@@ -340,7 +345,7 @@ function ne({
340
345
  }
341
346
  );
342
347
  }
343
- function me({
348
+ function ue({
344
349
  client: n,
345
350
  entity: a,
346
351
  currentUserId: l
@@ -351,15 +356,15 @@ function me({
351
356
  isError: v,
352
357
  error: u,
353
358
  refetch: y
354
- } = U(n, a.entitySlug), x = B(n), N = G(n), {
359
+ } = B(n, a.entitySlug), N = G(n), w = H(n), {
355
360
  data: p = [],
356
361
  isLoading: b,
357
362
  isError: c,
358
- error: w,
363
+ error: x,
359
364
  refetch: s
360
- } = H(n, r ? a.entitySlug : null), f = J(n), A = Q(n), D = async (d, h) => {
365
+ } = J(n, r ? a.entitySlug : null), f = Q(n), D = V(n), F = async (d, h) => {
361
366
  try {
362
- await x.mutateAsync({
367
+ await N.mutateAsync({
363
368
  entitySlug: a.entitySlug,
364
369
  memberId: d,
365
370
  role: h
@@ -367,45 +372,45 @@ function me({
367
372
  } catch (C) {
368
373
  console.error("Failed to update role:", C);
369
374
  }
370
- }, F = (d) => {
371
- const h = g.find((L) => L.id === d), C = h?.user?.displayName || h?.user?.email || "this member";
375
+ }, j = (d) => {
376
+ const h = g.find((E) => E.id === d), C = h?.user?.displayName || h?.user?.email || "this member";
372
377
  o({
373
378
  type: "removeMember",
374
379
  id: d,
375
380
  displayLabel: C
376
381
  });
377
- }, j = async (d) => {
382
+ }, P = async (d) => {
378
383
  try {
379
- await N.mutateAsync({
384
+ await w.mutateAsync({
380
385
  entitySlug: a.entitySlug,
381
386
  memberId: d
382
387
  });
383
388
  } catch (h) {
384
389
  console.error("Failed to remove member:", h);
385
390
  }
386
- }, P = async (d) => {
391
+ }, T = async (d) => {
387
392
  await f.mutateAsync({
388
393
  entitySlug: a.entitySlug,
389
394
  request: d
390
395
  });
391
- }, T = (d) => {
392
- const C = p.find((L) => L.id === d)?.email || "this invitation";
396
+ }, W = (d) => {
397
+ const C = p.find((E) => E.id === d)?.email || "this invitation";
393
398
  o({
394
399
  type: "cancelInvitation",
395
400
  id: d,
396
401
  displayLabel: C
397
402
  });
398
- }, W = async (d) => {
403
+ }, O = async (d) => {
399
404
  try {
400
- await A.mutateAsync({
405
+ await D.mutateAsync({
401
406
  entitySlug: a.entitySlug,
402
407
  invitationId: d
403
408
  });
404
409
  } catch (h) {
405
410
  console.error("Failed to cancel invitation:", h);
406
411
  }
407
- }, O = async () => {
408
- i && (i.type === "removeMember" ? await j(i.id) : i.type === "cancelInvitation" && await W(i.id), o(null));
412
+ }, $ = async () => {
413
+ i && (i.type === "removeMember" ? await P(i.id) : i.type === "cancelInvitation" && await O(i.id), o(null));
409
414
  };
410
415
  return a.entityType === "personal" ? /* @__PURE__ */ e(I, { spacing: "lg", maxWidth: "4xl", children: /* @__PURE__ */ t(
411
416
  "div",
@@ -420,12 +425,12 @@ function me({
420
425
  }
421
426
  ) }) : /* @__PURE__ */ e(I, { spacing: "lg", maxWidth: "4xl", children: /* @__PURE__ */ t("div", { role: "main", "aria-label": "Members management", children: [
422
427
  i && /* @__PURE__ */ e(
423
- ne,
428
+ re,
424
429
  {
425
430
  title: i.type === "removeMember" ? "Remove Member" : "Cancel Invitation",
426
431
  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}?`,
427
432
  confirmLabel: i.type === "removeMember" ? "Remove" : "Cancel Invitation",
428
- onConfirm: O,
433
+ onConfirm: $,
429
434
  onCancel: () => o(null)
430
435
  }
431
436
  ),
@@ -446,7 +451,7 @@ function me({
446
451
  /* @__PURE__ */ e(
447
452
  K,
448
453
  {
449
- onSubmit: P,
454
+ onSubmit: T,
450
455
  isSubmitting: f.isPending
451
456
  }
452
457
  )
@@ -463,7 +468,7 @@ function me({
463
468
  "aria-live": "polite",
464
469
  children: [
465
470
  /* @__PURE__ */ e("p", { className: "text-destructive font-medium mb-2", children: "Failed to load invitations" }),
466
- /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground mb-3", children: w?.message || "An unexpected error occurred" }),
471
+ /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground mb-3", children: x?.message || "An unexpected error occurred" }),
467
472
  /* @__PURE__ */ e(
468
473
  "button",
469
474
  {
@@ -476,7 +481,7 @@ function me({
476
481
  )
477
482
  ]
478
483
  }
479
- ) : b ? /* @__PURE__ */ e(z, {}) : p.length === 0 ? /* @__PURE__ */ e(
484
+ ) : b ? /* @__PURE__ */ e(R, {}) : p.length === 0 ? /* @__PURE__ */ e(
480
485
  "div",
481
486
  {
482
487
  className: "text-center py-4 sm:py-6 text-muted-foreground border border-dashed rounded-lg",
@@ -484,11 +489,11 @@ function me({
484
489
  children: /* @__PURE__ */ e("p", { children: "No pending invitations" })
485
490
  }
486
491
  ) : /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ e(
487
- S,
492
+ A,
488
493
  {
489
494
  invitations: p,
490
495
  mode: "admin",
491
- onCancel: T,
496
+ onCancel: W,
492
497
  isLoading: b,
493
498
  emptyMessage: "No pending invitations"
494
499
  }
@@ -521,7 +526,7 @@ function me({
521
526
  )
522
527
  ]
523
528
  }
524
- ) : m ? /* @__PURE__ */ e(z, {}) : g.length === 0 ? /* @__PURE__ */ t(
529
+ ) : m ? /* @__PURE__ */ e(R, {}) : g.length === 0 ? /* @__PURE__ */ t(
525
530
  "div",
526
531
  {
527
532
  className: "text-center py-4 sm:py-6 text-muted-foreground border border-dashed rounded-lg",
@@ -537,15 +542,15 @@ function me({
537
542
  members: g,
538
543
  currentUserId: l,
539
544
  canManage: r,
540
- onRoleChange: D,
541
- onRemove: F,
545
+ onRoleChange: F,
546
+ onRemove: j,
542
547
  isLoading: m
543
548
  }
544
549
  ) })
545
550
  ] })
546
551
  ] }) });
547
552
  }
548
- function re() {
553
+ function ie() {
549
554
  return /* @__PURE__ */ t("div", { className: "space-y-3", role: "status", "aria-label": "Loading invitations", children: [
550
555
  [1, 2].map((n) => /* @__PURE__ */ e(
551
556
  "div",
@@ -557,7 +562,7 @@ function re() {
557
562
  /* @__PURE__ */ e("span", { className: "sr-only", children: "Loading invitations..." })
558
563
  ] });
559
564
  }
560
- function ie({
565
+ function ae({
561
566
  entityName: n,
562
567
  onConfirm: a,
563
568
  onCancel: l
@@ -565,7 +570,7 @@ function ie({
565
570
  return /* @__PURE__ */ e(
566
571
  "div",
567
572
  {
568
- className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",
573
+ className: `fixed inset-0 z-50 flex items-center justify-center ${L.background.overlay} p-4`,
569
574
  role: "dialog",
570
575
  "aria-modal": "true",
571
576
  "aria-label": "Decline invitation",
@@ -607,7 +612,7 @@ function ie({
607
612
  }
608
613
  );
609
614
  }
610
- function ue({
615
+ function ge({
611
616
  client: n,
612
617
  onInvitationAccepted: a
613
618
  }) {
@@ -617,13 +622,13 @@ function ue({
617
622
  isError: i,
618
623
  error: o,
619
624
  refetch: g
620
- } = V(n), m = X(n), v = Z(n), [u, y] = k(null), x = async (c) => {
625
+ } = X(n), m = Z(n), v = _(n), [u, y] = k(null), N = async (c) => {
621
626
  try {
622
627
  await m.mutateAsync(c), a?.();
623
- } catch (w) {
624
- console.error("Failed to accept invitation:", w);
628
+ } catch (x) {
629
+ console.error("Failed to accept invitation:", x);
625
630
  }
626
- }, N = (c) => {
631
+ }, w = (c) => {
627
632
  const s = l.find((f) => f.token === c)?.entity?.displayName || "this organization";
628
633
  y({ token: c, entityName: s });
629
634
  }, p = async () => {
@@ -640,7 +645,7 @@ function ue({
640
645
  ).length;
641
646
  return /* @__PURE__ */ e(I, { spacing: "lg", maxWidth: "4xl", children: /* @__PURE__ */ t("div", { role: "main", "aria-label": "Invitations", children: [
642
647
  u && /* @__PURE__ */ e(
643
- ie,
648
+ ae,
644
649
  {
645
650
  entityName: u.entityName,
646
651
  onConfirm: p,
@@ -673,8 +678,8 @@ function ue({
673
678
  ]
674
679
  }
675
680
  ),
676
- r && /* @__PURE__ */ e(re, {}),
677
- !r && !i && /* @__PURE__ */ e(R, { children: l.length === 0 ? /* @__PURE__ */ t(
681
+ r && /* @__PURE__ */ e(ie, {}),
682
+ !r && !i && /* @__PURE__ */ e(S, { children: l.length === 0 ? /* @__PURE__ */ t(
678
683
  "div",
679
684
  {
680
685
  className: "text-center py-6 sm:py-8 text-muted-foreground border border-dashed rounded-lg",
@@ -685,12 +690,12 @@ function ue({
685
690
  ]
686
691
  }
687
692
  ) : /* @__PURE__ */ e("section", { "aria-label": "Invitation list", children: /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ e(
688
- S,
693
+ A,
689
694
  {
690
695
  invitations: l,
691
696
  mode: "user",
692
- onAccept: x,
693
- onDecline: N,
697
+ onAccept: N,
698
+ onDecline: w,
694
699
  isLoading: r,
695
700
  emptyMessage: "You don't have any pending invitations"
696
701
  }
@@ -698,7 +703,7 @@ function ue({
698
703
  ] }) });
699
704
  }
700
705
  export {
701
- de as EntityListPage,
702
- ue as InvitationsPage,
703
- me as MembersManagementPage
706
+ me as EntityListPage,
707
+ ge as InvitationsPage,
708
+ ue as MembersManagementPage
704
709
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sudobility/entity_pages",
3
- "version": "0.0.86",
3
+ "version": "0.0.87",
4
4
  "description": "Page containers for entity/organization management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -40,16 +40,18 @@
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.49",
43
+ "@sudobility/components": "^5.0.50",
44
44
  "@sudobility/entity_client": "^0.0.33",
45
45
  "@sudobility/entity-components": "^1.0.13",
46
46
  "@heroicons/react": "^2.2.0",
47
- "@sudobility/types": "^1.9.61"
47
+ "@sudobility/types": "^1.9.61",
48
+ "@sudobility/design": "^1.1.26"
48
49
  },
49
50
  "devDependencies": {
50
51
  "@eslint/js": "^9.38.0",
51
52
  "@heroicons/react": "^2.2.0",
52
- "@sudobility/components": "^5.0.49",
53
+ "@sudobility/components": "^5.0.50",
54
+ "@sudobility/design": "^1.1.26",
53
55
  "@sudobility/entity-components": "^1.0.13",
54
56
  "@sudobility/entity_client": "^0.0.33",
55
57
  "@sudobility/types": "^1.9.61",