@sudobility/entity_pages 0.0.122 → 0.0.124

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 +78 -73
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { jsxs as t, Fragment as k, jsx as e } from "react/jsx-runtime";
2
2
  import * as z from "react";
3
3
  import { useState as x } from "react";
4
- import { createPortal as S } from "react-dom";
4
+ import { createPortal as j } from "react-dom";
5
5
  import { ContentLayout as E } from "@sudobility/components";
6
- import { EntityList as D, MemberList as j, InvitationForm as A, InvitationList as P } from "@sudobility/entity-components";
7
- import { useEntities as T, useCreateEntity as O, useEntityMembers as $, useUpdateMemberRole as W, useRemoveMember as K, useCreateInvitation as Y, useMyInvitations as q, useAcceptInvitation as U, useDeclineInvitation as B } from "@sudobility/entity_client";
8
- function G({
6
+ import { EntityList as I, MemberList as A, InvitationForm as P, InvitationList as T } from "@sudobility/entity-components";
7
+ import { useEntities as O, useCreateEntity as $, useEntityMembers as W, useUpdateMemberRole as K, useRemoveMember as Y, useCreateInvitation as q, useMyInvitations as U, useAcceptInvitation as B, useDeclineInvitation as G } from "@sudobility/entity_client";
8
+ function H({
9
9
  title: r,
10
- titleId: i,
10
+ titleId: a,
11
11
  ...o
12
12
  }, n) {
13
13
  return /* @__PURE__ */ z.createElement("svg", Object.assign({
@@ -19,22 +19,27 @@ function G({
19
19
  "aria-hidden": "true",
20
20
  "data-slot": "icon",
21
21
  ref: n,
22
- "aria-labelledby": i
22
+ "aria-labelledby": a
23
23
  }, o), r ? /* @__PURE__ */ z.createElement("title", {
24
- id: i
24
+ id: a
25
25
  }, r) : null, /* @__PURE__ */ z.createElement("path", {
26
26
  strokeLinecap: "round",
27
27
  strokeLinejoin: "round",
28
28
  d: "M12 4.5v15m7.5-7.5h-15"
29
29
  }));
30
30
  }
31
- const I = /* @__PURE__ */ z.forwardRef(G), R = {
32
- // Background utilities
33
- background: {
34
- overlay: "bg-black/50 dark:bg-black/70"
31
+ const L = /* @__PURE__ */ z.forwardRef(H), R = (r, a) => a, D = {
32
+ // Background utilities (theme-aware getter)
33
+ get background() {
34
+ return {
35
+ surface: R("bg-card", "bg-white dark:bg-gray-800"),
36
+ subtle: R("bg-muted", "bg-gray-50 dark:bg-gray-900"),
37
+ muted: R("bg-muted", "bg-gray-100 dark:bg-gray-700"),
38
+ overlay: "bg-black/50 dark:bg-black/70"
39
+ };
35
40
  }
36
41
  };
37
- function H() {
42
+ function J() {
38
43
  return /* @__PURE__ */ t("div", { className: "space-y-3", role: "status", "aria-label": "Loading workspaces", children: [
39
44
  [1, 2, 3].map((r) => /* @__PURE__ */ e(
40
45
  "div",
@@ -48,7 +53,7 @@ function H() {
48
53
  }
49
54
  function ie({
50
55
  client: r,
51
- onSelectEntity: i
56
+ onSelectEntity: a
52
57
  }) {
53
58
  const [o, n] = x(!1), [s, l] = x({
54
59
  displayName: "",
@@ -59,10 +64,10 @@ function ie({
59
64
  isError: b,
60
65
  error: N,
61
66
  refetch: w
62
- } = T(r), h = O(r), y = u.filter((a) => a.entityType === "personal"), c = u.filter(
63
- (a) => a.entityType === "organization"
64
- ), v = async (a) => {
65
- if (a.preventDefault(), d(null), !s.displayName.trim()) {
67
+ } = O(r), h = $(r), y = u.filter((i) => i.entityType === "personal"), c = u.filter(
68
+ (i) => i.entityType === "organization"
69
+ ), v = async (i) => {
70
+ if (i.preventDefault(), d(null), !s.displayName.trim()) {
66
71
  d("Display name is required");
67
72
  return;
68
73
  }
@@ -76,19 +81,19 @@ function ie({
76
81
  }
77
82
  };
78
83
  return /* @__PURE__ */ t(k, { children: [
79
- o && S(
84
+ o && j(
80
85
  /* @__PURE__ */ e(
81
86
  "div",
82
87
  {
83
- className: `fixed inset-0 z-50 flex items-center justify-center ${R.background.overlay} p-4`,
88
+ className: `fixed inset-0 z-50 flex items-center justify-center ${D.background.overlay} p-4`,
84
89
  role: "dialog",
85
90
  "aria-modal": "true",
86
91
  "aria-label": "Create organization",
87
- onClick: (a) => {
88
- a.target === a.currentTarget && (n(!1), l({ displayName: "", description: "" }), d(null));
92
+ onClick: (i) => {
93
+ i.target === i.currentTarget && (n(!1), l({ displayName: "", description: "" }), d(null));
89
94
  },
90
- onKeyDown: (a) => {
91
- a.key === "Escape" && (n(!1), l({ displayName: "", description: "" }), d(null));
95
+ onKeyDown: (i) => {
96
+ i.key === "Escape" && (n(!1), l({ displayName: "", description: "" }), d(null));
92
97
  },
93
98
  children: /* @__PURE__ */ t("div", { className: "w-full max-w-md rounded-lg bg-background p-4 sm:p-6 shadow-lg", children: [
94
99
  /* @__PURE__ */ e("h2", { className: "text-lg font-semibold mb-4", children: "Create Organization" }),
@@ -114,9 +119,9 @@ function ie({
114
119
  id: "create-org-name",
115
120
  type: "text",
116
121
  value: s.displayName,
117
- onChange: (a) => l((f) => ({
122
+ onChange: (i) => l((f) => ({
118
123
  ...f,
119
- displayName: a.target.value
124
+ displayName: i.target.value
120
125
  })),
121
126
  placeholder: "My Organization",
122
127
  "aria-required": "true",
@@ -139,9 +144,9 @@ function ie({
139
144
  {
140
145
  id: "create-org-description",
141
146
  value: s.description,
142
- onChange: (a) => l((f) => ({
147
+ onChange: (i) => l((f) => ({
143
148
  ...f,
144
- description: a.target.value
149
+ description: i.target.value
145
150
  })),
146
151
  placeholder: "What is this organization for?",
147
152
  rows: 3,
@@ -208,7 +213,7 @@ function ie({
208
213
  "aria-label": "Create new organization",
209
214
  className: "flex flex-shrink-0 items-center justify-center gap-2 px-3 py-2 rounded-lg bg-primary text-primary-foreground text-sm font-medium hover:bg-primary/90 transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2",
210
215
  children: [
211
- /* @__PURE__ */ e(I, { className: "h-4 w-4", "aria-hidden": "true" }),
216
+ /* @__PURE__ */ e(L, { className: "h-4 w-4", "aria-hidden": "true" }),
212
217
  /* @__PURE__ */ e("span", { children: "New Organization" })
213
218
  ]
214
219
  }
@@ -237,7 +242,7 @@ function ie({
237
242
  ]
238
243
  }
239
244
  ),
240
- m && /* @__PURE__ */ e(H, {}),
245
+ m && /* @__PURE__ */ e(J, {}),
241
246
  !m && !b && /* @__PURE__ */ t(k, { children: [
242
247
  y.length > 0 && /* @__PURE__ */ t(
243
248
  "section",
@@ -247,10 +252,10 @@ function ie({
247
252
  children: [
248
253
  /* @__PURE__ */ e("h2", { className: "text-base sm:text-lg font-semibold mb-3", children: "Personal Workspace" }),
249
254
  /* @__PURE__ */ e(
250
- D,
255
+ I,
251
256
  {
252
257
  entities: y,
253
- onSelect: i,
258
+ onSelect: a,
254
259
  isLoading: m
255
260
  }
256
261
  )
@@ -279,10 +284,10 @@ function ie({
279
284
  ]
280
285
  }
281
286
  ) : /* @__PURE__ */ e(
282
- D,
287
+ I,
283
288
  {
284
289
  entities: c,
285
- onSelect: i,
290
+ onSelect: a,
286
291
  isLoading: m
287
292
  }
288
293
  )
@@ -304,7 +309,7 @@ function ie({
304
309
  )
305
310
  ] });
306
311
  }
307
- function J() {
312
+ function Q() {
308
313
  return /* @__PURE__ */ t("div", { className: "space-y-3", role: "status", "aria-label": "Loading members", children: [
309
314
  [1, 2, 3].map((r) => /* @__PURE__ */ e(
310
315
  "div",
@@ -316,9 +321,9 @@ function J() {
316
321
  /* @__PURE__ */ e("span", { className: "sr-only", children: "Loading members..." })
317
322
  ] });
318
323
  }
319
- function Q({
324
+ function V({
320
325
  title: r,
321
- message: i,
326
+ message: a,
322
327
  confirmLabel: o,
323
328
  onConfirm: n,
324
329
  onCancel: s
@@ -326,7 +331,7 @@ function Q({
326
331
  return /* @__PURE__ */ e(
327
332
  "div",
328
333
  {
329
- className: `fixed inset-0 z-50 flex items-center justify-center ${R.background.overlay} p-4`,
334
+ className: `fixed inset-0 z-50 flex items-center justify-center ${D.background.overlay} p-4`,
330
335
  role: "dialog",
331
336
  "aria-modal": "true",
332
337
  "aria-label": r,
@@ -338,7 +343,7 @@ function Q({
338
343
  },
339
344
  children: /* @__PURE__ */ t("div", { className: "w-full max-w-sm rounded-lg bg-background p-4 sm:p-6 shadow-lg", children: [
340
345
  /* @__PURE__ */ e("h3", { className: "text-lg font-semibold mb-2", children: r }),
341
- /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground mb-4", children: i }),
346
+ /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground mb-4", children: a }),
342
347
  /* @__PURE__ */ t("div", { className: "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", children: [
343
348
  /* @__PURE__ */ e(
344
349
  "button",
@@ -363,35 +368,35 @@ function Q({
363
368
  }
364
369
  );
365
370
  }
366
- function ae({
371
+ function oe({
367
372
  client: r,
368
- entity: i,
373
+ entity: a,
369
374
  currentUserId: o
370
375
  }) {
371
- const n = i.userRole === "owner", [s, l] = x(!1), [g, d] = x(null), {
376
+ const n = a.userRole === "owner", [s, l] = x(!1), [g, d] = x(null), {
372
377
  data: u = [],
373
378
  isLoading: m,
374
379
  isError: b,
375
380
  error: N,
376
381
  refetch: w
377
- } = $(r, i.entitySlug), h = W(r), y = K(r), c = Y(r), v = async (p, C) => {
382
+ } = W(r, a.entitySlug), h = K(r), y = Y(r), c = q(r), v = async (p, C) => {
378
383
  try {
379
384
  await h.mutateAsync({
380
- entitySlug: i.entitySlug,
385
+ entitySlug: a.entitySlug,
381
386
  memberId: p,
382
387
  role: C
383
388
  });
384
389
  } catch (M) {
385
390
  console.error("Failed to update role:", M);
386
391
  }
387
- }, a = (p) => {
388
- const C = u.find((F) => F.id === p), M = C?.user?.displayName || C?.user?.email || "this member";
392
+ }, i = (p) => {
393
+ const C = u.find((S) => S.id === p), M = C?.user?.displayName || C?.user?.email || "this member";
389
394
  d({ id: p, label: M });
390
395
  }, f = async () => {
391
396
  if (g) {
392
397
  try {
393
398
  await y.mutateAsync({
394
- entitySlug: i.entitySlug,
399
+ entitySlug: a.entitySlug,
395
400
  memberId: g.id
396
401
  });
397
402
  } catch (p) {
@@ -399,13 +404,13 @@ function ae({
399
404
  }
400
405
  d(null);
401
406
  }
402
- }, L = async (p) => {
407
+ }, F = async (p) => {
403
408
  await c.mutateAsync({
404
- entitySlug: i.entitySlug,
409
+ entitySlug: a.entitySlug,
405
410
  request: p
406
411
  }), l(!1);
407
412
  };
408
- return i.entityType === "personal" ? /* @__PURE__ */ e(
413
+ return a.entityType === "personal" ? /* @__PURE__ */ e(
409
414
  E,
410
415
  {
411
416
  header: /* @__PURE__ */ e("div", { className: "border-b bg-background px-4 py-3", children: /* @__PURE__ */ e("h1", { className: "text-lg sm:text-xl font-bold text-foreground", children: "Members" }) }),
@@ -424,7 +429,7 @@ function ae({
424
429
  }
425
430
  ) : /* @__PURE__ */ t(k, { children: [
426
431
  g && /* @__PURE__ */ e(
427
- Q,
432
+ V,
428
433
  {
429
434
  title: "Remove Member",
430
435
  message: `Are you sure you want to remove ${g.label}? They will lose access to this organization.`,
@@ -446,7 +451,7 @@ function ae({
446
451
  u.length === 1 ? "" : "s",
447
452
  " in",
448
453
  " ",
449
- i.displayName
454
+ a.displayName
450
455
  ] })
451
456
  ] }),
452
457
  n && /* @__PURE__ */ t(
@@ -458,7 +463,7 @@ function ae({
458
463
  "aria-controls": "invite-member-panel",
459
464
  className: "flex flex-shrink-0 items-center gap-2 px-3 py-2 rounded-lg bg-primary text-primary-foreground text-sm font-medium hover:bg-primary/90 transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2",
460
465
  children: [
461
- /* @__PURE__ */ e(I, { className: "h-4 w-4", "aria-hidden": "true" }),
466
+ /* @__PURE__ */ e(L, { className: "h-4 w-4", "aria-hidden": "true" }),
462
467
  /* @__PURE__ */ e("span", { children: "Invite" })
463
468
  ]
464
469
  }
@@ -473,9 +478,9 @@ function ae({
473
478
  children: /* @__PURE__ */ e("div", { className: "overflow-hidden", children: /* @__PURE__ */ t("div", { className: "border-t px-4 py-3 sm:py-4", children: [
474
479
  /* @__PURE__ */ e("h2", { className: "text-sm font-semibold mb-3", children: "Invite Member" }),
475
480
  /* @__PURE__ */ e(
476
- A,
481
+ P,
477
482
  {
478
- onSubmit: L,
483
+ onSubmit: F,
479
484
  isSubmitting: c.isPending
480
485
  }
481
486
  )
@@ -504,7 +509,7 @@ function ae({
504
509
  )
505
510
  ]
506
511
  }
507
- ) : m ? /* @__PURE__ */ e(J, {}) : u.length === 0 ? /* @__PURE__ */ t(
512
+ ) : m ? /* @__PURE__ */ e(Q, {}) : u.length === 0 ? /* @__PURE__ */ t(
508
513
  "div",
509
514
  {
510
515
  className: "text-center py-8 sm:py-12 text-muted-foreground border border-dashed rounded-lg",
@@ -515,13 +520,13 @@ function ae({
515
520
  ]
516
521
  }
517
522
  ) : /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ e(
518
- j,
523
+ A,
519
524
  {
520
525
  members: u,
521
526
  currentUserId: o,
522
527
  canManage: n,
523
528
  onRoleChange: v,
524
- onRemove: a,
529
+ onRemove: i,
525
530
  isLoading: m
526
531
  }
527
532
  ) }) })
@@ -529,7 +534,7 @@ function ae({
529
534
  )
530
535
  ] });
531
536
  }
532
- function V() {
537
+ function X() {
533
538
  return /* @__PURE__ */ t("div", { className: "space-y-3", role: "status", "aria-label": "Loading invitations", children: [
534
539
  [1, 2].map((r) => /* @__PURE__ */ e(
535
540
  "div",
@@ -541,15 +546,15 @@ function V() {
541
546
  /* @__PURE__ */ e("span", { className: "sr-only", children: "Loading invitations..." })
542
547
  ] });
543
548
  }
544
- function X({
549
+ function Z({
545
550
  entityName: r,
546
- onConfirm: i,
551
+ onConfirm: a,
547
552
  onCancel: o
548
553
  }) {
549
554
  return /* @__PURE__ */ e(
550
555
  "div",
551
556
  {
552
- className: `fixed inset-0 z-50 flex items-center justify-center ${R.background.overlay} p-4`,
557
+ className: `fixed inset-0 z-50 flex items-center justify-center ${D.background.overlay} p-4`,
553
558
  role: "dialog",
554
559
  "aria-modal": "true",
555
560
  "aria-label": "Decline invitation",
@@ -581,7 +586,7 @@ function X({
581
586
  "button",
582
587
  {
583
588
  type: "button",
584
- onClick: i,
589
+ onClick: a,
585
590
  className: "px-4 py-2 rounded-lg bg-destructive text-destructive-foreground font-medium hover:bg-destructive/90 transition-colors focus:outline-none focus:ring-2 focus:ring-destructive focus:ring-offset-2 w-full sm:w-auto",
586
591
  children: "Decline"
587
592
  }
@@ -591,9 +596,9 @@ function X({
591
596
  }
592
597
  );
593
598
  }
594
- function oe({
599
+ function se({
595
600
  client: r,
596
- onInvitationAccepted: i
601
+ onInvitationAccepted: a
597
602
  }) {
598
603
  const {
599
604
  data: o = [],
@@ -601,15 +606,15 @@ function oe({
601
606
  isError: s,
602
607
  error: l,
603
608
  refetch: g
604
- } = q(r), d = U(r), u = B(r), [m, b] = x(null), N = async (c) => {
609
+ } = U(r), d = B(r), u = G(r), [m, b] = x(null), N = async (c) => {
605
610
  try {
606
- await d.mutateAsync(c), i?.();
611
+ await d.mutateAsync(c), a?.();
607
612
  } catch (v) {
608
613
  console.error("Failed to accept invitation:", v);
609
614
  }
610
615
  }, w = (c) => {
611
- const a = o.find((f) => f.token === c)?.entity?.displayName || "this organization";
612
- b({ token: c, entityName: a });
616
+ const i = o.find((f) => f.token === c)?.entity?.displayName || "this organization";
617
+ b({ token: c, entityName: i });
613
618
  }, h = async () => {
614
619
  if (m) {
615
620
  try {
@@ -624,7 +629,7 @@ function oe({
624
629
  ).length;
625
630
  return /* @__PURE__ */ t(k, { children: [
626
631
  m && /* @__PURE__ */ e(
627
- X,
632
+ Z,
628
633
  {
629
634
  entityName: m.entityName,
630
635
  onConfirm: h,
@@ -661,7 +666,7 @@ function oe({
661
666
  ]
662
667
  }
663
668
  ),
664
- n && /* @__PURE__ */ e(V, {}),
669
+ n && /* @__PURE__ */ e(X, {}),
665
670
  !n && !s && /* @__PURE__ */ e(k, { children: o.length === 0 ? /* @__PURE__ */ t(
666
671
  "div",
667
672
  {
@@ -673,7 +678,7 @@ function oe({
673
678
  ]
674
679
  }
675
680
  ) : /* @__PURE__ */ e("section", { "aria-label": "Invitation list", children: /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ e(
676
- P,
681
+ T,
677
682
  {
678
683
  invitations: o,
679
684
  mode: "user",
@@ -690,6 +695,6 @@ function oe({
690
695
  }
691
696
  export {
692
697
  ie as EntityListPage,
693
- oe as InvitationsPage,
694
- ae as MembersManagementPage
698
+ se as InvitationsPage,
699
+ oe as MembersManagementPage
695
700
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sudobility/entity_pages",
3
- "version": "0.0.122",
3
+ "version": "0.0.124",
4
4
  "description": "Page containers for entity/organization management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -40,18 +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.82",
43
+ "@sudobility/components": "^5.0.83",
44
44
  "@sudobility/entity_client": "^0.0.36",
45
45
  "@sudobility/entity-components": "^1.0.13",
46
46
  "@heroicons/react": "^2.2.0",
47
47
  "@sudobility/types": "^1.9.62",
48
- "@sudobility/design": "^1.1.32"
48
+ "@sudobility/design": "^1.1.34"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@eslint/js": "^9.38.0",
52
52
  "@heroicons/react": "^2.2.0",
53
- "@sudobility/components": "^5.0.82",
54
- "@sudobility/design": "^1.1.32",
53
+ "@sudobility/components": "^5.0.83",
54
+ "@sudobility/design": "^1.1.34",
55
55
  "@sudobility/entity-components": "^1.0.13",
56
56
  "@sudobility/entity_client": "^0.0.36",
57
57
  "@sudobility/types": "^1.9.62",