@byline/ui 2.4.0 → 2.4.1

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 (95) hide show
  1. package/dist/react.d.ts +10 -18
  2. package/dist/react.js +2 -15
  3. package/dist/{admin/components/collections → widgets/diff-viewer}/diff-modal.d.ts +8 -1
  4. package/dist/{admin/components/collections → widgets/diff-viewer}/diff-modal.js +4 -6
  5. package/dist/widgets/diff-viewer/diff-modal.module.js +14 -0
  6. package/dist/{admin/components/collections → widgets/diff-viewer}/diff-modal_module.css +9 -9
  7. package/dist/{admin/components/collections → widgets/status-badge}/status-badge.js +1 -1
  8. package/dist/{admin/components/collections → widgets/status-badge}/status-badge.module.js +3 -3
  9. package/dist/{admin/components/collections → widgets/status-badge}/status-badge_module.css +3 -3
  10. package/package.json +2 -4
  11. package/src/react.ts +12 -34
  12. package/src/{admin/components/collections → widgets/diff-viewer}/diff-modal.tsx +16 -5
  13. package/src/{admin/components/collections → widgets/status-badge}/status-badge.tsx +1 -1
  14. package/dist/admin/components/admin-account/change-password.d.ts +0 -8
  15. package/dist/admin/components/admin-account/change-password.js +0 -192
  16. package/dist/admin/components/admin-account/change-password.module.js +0 -8
  17. package/dist/admin/components/admin-account/change-password_module.css +0 -27
  18. package/dist/admin/components/admin-account/container.d.ts +0 -29
  19. package/dist/admin/components/admin-account/container.js +0 -299
  20. package/dist/admin/components/admin-account/container.module.js +0 -28
  21. package/dist/admin/components/admin-account/container_module.css +0 -106
  22. package/dist/admin/components/admin-account/update.d.ts +0 -8
  23. package/dist/admin/components/admin-account/update.js +0 -207
  24. package/dist/admin/components/admin-account/update.module.js +0 -8
  25. package/dist/admin/components/admin-account/update_module.css +0 -27
  26. package/dist/admin/components/admin-permissions/inspector.d.ts +0 -4
  27. package/dist/admin/components/admin-permissions/inspector.js +0 -284
  28. package/dist/admin/components/admin-permissions/inspector.module.js +0 -56
  29. package/dist/admin/components/admin-permissions/inspector_module.css +0 -238
  30. package/dist/admin/components/admin-roles/create.d.ts +0 -7
  31. package/dist/admin/components/admin-roles/create.js +0 -177
  32. package/dist/admin/components/admin-roles/create.module.js +0 -8
  33. package/dist/admin/components/admin-roles/create_module.css +0 -27
  34. package/dist/admin/components/admin-roles/permissions.d.ts +0 -10
  35. package/dist/admin/components/admin-roles/permissions.js +0 -303
  36. package/dist/admin/components/admin-roles/permissions.module.js +0 -44
  37. package/dist/admin/components/admin-roles/permissions_module.css +0 -192
  38. package/dist/admin/components/admin-roles/update.d.ts +0 -8
  39. package/dist/admin/components/admin-roles/update.js +0 -166
  40. package/dist/admin/components/admin-roles/update.module.js +0 -8
  41. package/dist/admin/components/admin-roles/update_module.css +0 -27
  42. package/dist/admin/components/admin-users/create.d.ts +0 -8
  43. package/dist/admin/components/admin-users/create.js +0 -268
  44. package/dist/admin/components/admin-users/create.module.js +0 -10
  45. package/dist/admin/components/admin-users/create_module.css +0 -45
  46. package/dist/admin/components/admin-users/roles.d.ts +0 -11
  47. package/dist/admin/components/admin-users/roles.js +0 -148
  48. package/dist/admin/components/admin-users/roles.module.js +0 -18
  49. package/dist/admin/components/admin-users/roles_module.css +0 -75
  50. package/dist/admin/components/admin-users/set-password.d.ts +0 -8
  51. package/dist/admin/components/admin-users/set-password.js +0 -170
  52. package/dist/admin/components/admin-users/set-password.module.js +0 -9
  53. package/dist/admin/components/admin-users/set-password_module.css +0 -31
  54. package/dist/admin/components/admin-users/update.d.ts +0 -8
  55. package/dist/admin/components/admin-users/update.js +0 -254
  56. package/dist/admin/components/admin-users/update.module.js +0 -9
  57. package/dist/admin/components/admin-users/update_module.css +0 -34
  58. package/dist/admin/components/auth/sign-in-form.d.ts +0 -12
  59. package/dist/admin/components/auth/sign-in-form.js +0 -115
  60. package/dist/admin/components/auth/sign-in-form.module.js +0 -12
  61. package/dist/admin/components/auth/sign-in-form_module.css +0 -41
  62. package/dist/admin/components/collections/diff-modal.module.js +0 -14
  63. package/dist/services/admin-services-context.d.ts +0 -16
  64. package/dist/services/admin-services-context.js +0 -13
  65. package/dist/services/admin-services-types.d.ts +0 -129
  66. package/dist/services/admin-services-types.js +0 -1
  67. package/src/admin/components/admin-account/change-password.module.css +0 -40
  68. package/src/admin/components/admin-account/change-password.tsx +0 -232
  69. package/src/admin/components/admin-account/container.module.css +0 -158
  70. package/src/admin/components/admin-account/container.tsx +0 -230
  71. package/src/admin/components/admin-account/update.module.css +0 -40
  72. package/src/admin/components/admin-account/update.tsx +0 -263
  73. package/src/admin/components/admin-permissions/inspector.module.css +0 -326
  74. package/src/admin/components/admin-permissions/inspector.tsx +0 -298
  75. package/src/admin/components/admin-roles/create.module.css +0 -40
  76. package/src/admin/components/admin-roles/create.tsx +0 -218
  77. package/src/admin/components/admin-roles/permissions.module.css +0 -279
  78. package/src/admin/components/admin-roles/permissions.tsx +0 -396
  79. package/src/admin/components/admin-roles/update.module.css +0 -40
  80. package/src/admin/components/admin-roles/update.tsx +0 -218
  81. package/src/admin/components/admin-users/create.module.css +0 -63
  82. package/src/admin/components/admin-users/create.tsx +0 -323
  83. package/src/admin/components/admin-users/roles.module.css +0 -119
  84. package/src/admin/components/admin-users/roles.tsx +0 -172
  85. package/src/admin/components/admin-users/set-password.module.css +0 -46
  86. package/src/admin/components/admin-users/set-password.tsx +0 -199
  87. package/src/admin/components/admin-users/update.module.css +0 -49
  88. package/src/admin/components/admin-users/update.tsx +0 -328
  89. package/src/admin/components/auth/sign-in-form.module.css +0 -62
  90. package/src/admin/components/auth/sign-in-form.tsx +0 -132
  91. package/src/services/admin-services-context.tsx +0 -35
  92. package/src/services/admin-services-types.ts +0 -177
  93. /package/dist/{admin/components/collections → widgets/status-badge}/status-badge.d.ts +0 -0
  94. /package/src/{admin/components/collections → widgets/diff-viewer}/diff-modal.module.css +0 -0
  95. /package/src/{admin/components/collections → widgets/status-badge}/status-badge.module.css +0 -0
package/dist/react.d.ts CHANGED
@@ -4,8 +4,8 @@
4
4
  *
5
5
  * Single unified entry point for `@byline/ui`. Everything React-side
6
6
  * exports through this barrel — uikit foundations, drag-and-drop
7
- * helpers, the admin module surface, field widgets, form runtime, and
8
- * the framework-neutral service contracts.
7
+ * helpers, presentational admin layout primitives, field widgets, form
8
+ * runtime, and the field-side service contracts.
9
9
  *
10
10
  * Why one barrel: previous releases split this into per-area subpath
11
11
  * exports (`./react/admin`, `./react/fields`, `./react/forms`,
@@ -16,21 +16,13 @@
16
16
  * specifier eliminates the trap structurally. Tree-shaking inside the
17
17
  * single ESM bundle handles unused exports for public-site consumers
18
18
  * (sideEffects is set to CSS only).
19
+ *
20
+ * Admin-domain components (admin users, roles, permissions, account
21
+ * self-service, sign-in form, admin services context) live in
22
+ * `@byline/admin` under per-vertical subpaths — they are no longer
23
+ * exported from here. This package is the kit + form runtime +
24
+ * collection-editor-shared widgets.
19
25
  */
20
- export * from './admin/components/admin-account/change-password.js';
21
- export * from './admin/components/admin-account/container.js';
22
- export * from './admin/components/admin-account/update.js';
23
- export * from './admin/components/admin-permissions/inspector.js';
24
- export * from './admin/components/admin-roles/create.js';
25
- export * from './admin/components/admin-roles/permissions.js';
26
- export * from './admin/components/admin-roles/update.js';
27
- export * from './admin/components/admin-users/create.js';
28
- export * from './admin/components/admin-users/roles.js';
29
- export * from './admin/components/admin-users/set-password.js';
30
- export * from './admin/components/admin-users/update.js';
31
- export * from './admin/components/auth/sign-in-form.js';
32
- export * from './admin/components/collections/diff-modal.js';
33
- export * from './admin/components/collections/status-badge.js';
34
26
  export * from './admin/group.js';
35
27
  export * from './admin/row.js';
36
28
  export * from './admin/tabs.js';
@@ -64,8 +56,8 @@ export * from './forms/form-context.js';
64
56
  export * from './forms/form-renderer.js';
65
57
  export * from './forms/navigation-guard.js';
66
58
  export * from './forms/path-widget.js';
67
- export * from './services/admin-services-context.js';
68
59
  export * from './services/field-services-context.js';
69
60
  export * from './uikit.js';
70
- export type { AdminServiceCall, BylineAdminServices, ChangeAccountPasswordInput, CreateAdminRoleInput, CreateAdminUserInput, SetAdminUserPasswordInput, SetRoleAbilitiesInput, SetUserRolesInput, SignInInput, SignInResult, UpdateAccountInput, UpdateAdminRoleInput, UpdateAdminUserInput, WhoHasAbilityInput, } from './services/admin-services-types.js';
61
+ export * from './widgets/diff-viewer/diff-modal.js';
62
+ export * from './widgets/status-badge/status-badge.js';
71
63
  export type { BylineFieldServices, CollectionListDoc, CollectionListParams, CollectionListResponse, GetCollectionDocumentsFn, UploadedFileResult, UploadFieldFn, } from './services/field-services-types.js';
package/dist/react.js CHANGED
@@ -1,17 +1,3 @@
1
- export * from "./admin/components/admin-account/change-password.js";
2
- export * from "./admin/components/admin-account/container.js";
3
- export * from "./admin/components/admin-account/update.js";
4
- export * from "./admin/components/admin-permissions/inspector.js";
5
- export * from "./admin/components/admin-roles/create.js";
6
- export * from "./admin/components/admin-roles/permissions.js";
7
- export * from "./admin/components/admin-roles/update.js";
8
- export * from "./admin/components/admin-users/create.js";
9
- export * from "./admin/components/admin-users/roles.js";
10
- export * from "./admin/components/admin-users/set-password.js";
11
- export * from "./admin/components/admin-users/update.js";
12
- export * from "./admin/components/auth/sign-in-form.js";
13
- export * from "./admin/components/collections/diff-modal.js";
14
- export * from "./admin/components/collections/status-badge.js";
15
1
  export * from "./admin/group.js";
16
2
  export * from "./admin/row.js";
17
3
  export * from "./admin/tabs.js";
@@ -45,6 +31,7 @@ export * from "./forms/form-context.js";
45
31
  export * from "./forms/form-renderer.js";
46
32
  export * from "./forms/navigation-guard.js";
47
33
  export * from "./forms/path-widget.js";
48
- export * from "./services/admin-services-context.js";
49
34
  export * from "./services/field-services-context.js";
50
35
  export * from "./uikit.js";
36
+ export * from "./widgets/diff-viewer/diff-modal.js";
37
+ export * from "./widgets/status-badge/status-badge.js";
@@ -11,5 +11,12 @@ export interface DiffModalProps {
11
11
  currentDocument: Record<string, unknown>;
12
12
  /** Content locale to compare — undefined / 'all' shows all locales. */
13
13
  locale?: string;
14
+ /**
15
+ * Host-provided loader for a historical document version. The diff
16
+ * modal is framework-neutral; callers wire this to whatever transport
17
+ * they use (e.g. `BylineAdminServices.getCollectionDocumentVersion` in
18
+ * the admin shell).
19
+ */
20
+ loadHistoricalVersion: (collection: string, documentId: string, versionId: string, locale: string | undefined) => Promise<Record<string, unknown>>;
14
21
  }
15
- export declare function DiffModal({ isOpen, onDismiss, collection, documentId, versionId, versionLabel, currentDocument, locale, }: DiffModalProps): import("react").JSX.Element;
22
+ export declare function DiffModal({ isOpen, onDismiss, collection, documentId, versionId, versionLabel, currentDocument, locale, loadHistoricalVersion, }: DiffModalProps): import("react").JSX.Element;
@@ -3,8 +3,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { useEffect, useState } from "react";
4
4
  import classnames from "classnames";
5
5
  import react_diff_viewer_continued, { DiffMethod } from "react-diff-viewer-continued";
6
- import { useBylineAdminServices } from "../../../services/admin-services-context.js";
7
- import { CloseIcon, IconButton, LoaderRing, Modal } from "../../../uikit.js";
6
+ import { CloseIcon, IconButton, LoaderRing, Modal } from "../../uikit.js";
8
7
  import diff_modal_module from "./diff-modal.module.js";
9
8
  const STRIP_KEYS = new Set([
10
9
  'id',
@@ -20,8 +19,7 @@ function stripMeta(doc) {
20
19
  if (doc.fields && 'object' == typeof doc.fields) return doc.fields;
21
20
  return Object.fromEntries(Object.entries(doc).filter(([k])=>!STRIP_KEYS.has(k)));
22
21
  }
23
- function DiffModal({ isOpen, onDismiss, collection, documentId, versionId, versionLabel, currentDocument, locale }) {
24
- const { getCollectionDocumentVersion } = useBylineAdminServices();
22
+ function DiffModal({ isOpen, onDismiss, collection, documentId, versionId, versionLabel, currentDocument, locale, loadHistoricalVersion }) {
25
23
  const [historicalDoc, setHistoricalDoc] = useState(null);
26
24
  const [loading, setLoading] = useState(false);
27
25
  const [error, setError] = useState(null);
@@ -31,7 +29,7 @@ function DiffModal({ isOpen, onDismiss, collection, documentId, versionId, versi
31
29
  setLoading(true);
32
30
  setError(null);
33
31
  setHistoricalDoc(null);
34
- getCollectionDocumentVersion(collection, documentId, versionId, locale).then((doc)=>{
32
+ loadHistoricalVersion(collection, documentId, versionId, locale).then((doc)=>{
35
33
  if (cancelled) return;
36
34
  setHistoricalDoc(doc);
37
35
  }).catch((err)=>{
@@ -49,7 +47,7 @@ function DiffModal({ isOpen, onDismiss, collection, documentId, versionId, versi
49
47
  documentId,
50
48
  versionId,
51
49
  locale,
52
- getCollectionDocumentVersion
50
+ loadHistoricalVersion
53
51
  ]);
54
52
  const currentStr = currentDocument ? JSON.stringify(stripMeta(currentDocument), null, 2) : '';
55
53
  const historicalStr = historicalDoc ? JSON.stringify(stripMeta(historicalDoc), null, 2) : '';
@@ -0,0 +1,14 @@
1
+ import "./diff-modal_module.css";
2
+ const diff_modal_module = {
3
+ header: "header-da1tQG",
4
+ "title-stack": "title-stack-mSxmPG",
5
+ titleStack: "title-stack-mSxmPG",
6
+ title: "title-xO708s",
7
+ subtitle: "subtitle-VnkAjp",
8
+ version: "version-sRziHD",
9
+ content: "content-_KyVkg",
10
+ state: "state-Gg9w8j",
11
+ error: "error-BP4kEV",
12
+ viewer: "viewer-hxDZsJ"
13
+ };
14
+ export default diff_modal_module;
@@ -1,26 +1,26 @@
1
- :is(.header-u6gvtB, .byline-diff-modal-header) {
1
+ :is(.header-da1tQG, .byline-diff-modal-header) {
2
2
  padding-top: var(--spacing-16);
3
3
  margin-bottom: var(--spacing-8);
4
4
  flex-shrink: 0;
5
5
  }
6
6
 
7
- :is(.title-stack-rJ2qgD, .byline-diff-modal-title-stack) {
7
+ :is(.title-stack-mSxmPG, .byline-diff-modal-title-stack) {
8
8
  flex-direction: column;
9
9
  display: flex;
10
10
  }
11
11
 
12
- :is(.title-TdarBi, .byline-diff-modal-title) {
12
+ :is(.title-xO708s, .byline-diff-modal-title) {
13
13
  font-size: var(--font-size-xl);
14
14
  margin: 0;
15
15
  }
16
16
 
17
- :is(.subtitle-QCnXHJ, .byline-diff-modal-subtitle) {
17
+ :is(.subtitle-VnkAjp, .byline-diff-modal-subtitle) {
18
18
  font-size: var(--font-size-sm);
19
19
  color: var(--gray-400);
20
20
  margin: 0;
21
21
  }
22
22
 
23
- :is(.version-bEVRZQ, .byline-diff-modal-version) {
23
+ :is(.version-sRziHD, .byline-diff-modal-version) {
24
24
  font-family: var(--font-family-mono);
25
25
  font-size: var(--font-size-xs);
26
26
  background-color: var(--canvas-700);
@@ -28,14 +28,14 @@
28
28
  border-radius: var(--border-radius-sm);
29
29
  }
30
30
 
31
- :is(.content-aOYGDW, .byline-diff-modal-content) {
31
+ :is(.content-_KyVkg, .byline-diff-modal-content) {
32
32
  flex: 1 1 0;
33
33
  min-height: 0;
34
34
  padding: 0;
35
35
  overflow: auto;
36
36
  }
37
37
 
38
- :is(.state-mE6b8u, .byline-diff-modal-state) {
38
+ :is(.state-Gg9w8j, .byline-diff-modal-state) {
39
39
  justify-content: center;
40
40
  align-items: center;
41
41
  gap: var(--spacing-12);
@@ -44,12 +44,12 @@
44
44
  display: flex;
45
45
  }
46
46
 
47
- :is(.error-Fn4D5K, .byline-diff-modal-error) {
47
+ :is(.error-BP4kEV, .byline-diff-modal-error) {
48
48
  color: var(--red-400);
49
49
  gap: 0;
50
50
  }
51
51
 
52
- :is(.viewer-g0QwS4, .byline-diff-modal-viewer) {
52
+ :is(.viewer-hxDZsJ, .byline-diff-modal-viewer) {
53
53
  font-family: var(--font-family-mono);
54
54
  font-size: var(--font-size-sm);
55
55
  }
@@ -1,7 +1,7 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { WORKFLOW_STATUS_ARCHIVED, WORKFLOW_STATUS_DRAFT, WORKFLOW_STATUS_PUBLISHED } from "@byline/core";
3
3
  import classnames from "classnames";
4
- import { Badge } from "../../../uikit.js";
4
+ import { Badge } from "../../uikit.js";
5
5
  import status_badge_module from "./status-badge.module.js";
6
6
  function statusIntent(status) {
7
7
  switch(status){
@@ -1,7 +1,7 @@
1
1
  import "./status-badge_module.css";
2
2
  const status_badge_module = {
3
- wrap: "wrap-XL9MFe",
4
- dot: "dot-tid_fz",
5
- badge: "badge-AEKILT"
3
+ wrap: "wrap-ZbeRnh",
4
+ dot: "dot-VmpmJH",
5
+ badge: "badge-zXEFyw"
6
6
  };
7
7
  export default status_badge_module;
@@ -1,10 +1,10 @@
1
- :is(.wrap-XL9MFe, .byline-status-badge-wrap) {
1
+ :is(.wrap-ZbeRnh, .byline-status-badge-wrap) {
2
2
  align-items: center;
3
3
  gap: var(--spacing-4);
4
4
  display: inline-flex;
5
5
  }
6
6
 
7
- :is(.dot-tid_fz, .byline-status-badge-dot) {
7
+ :is(.dot-VmpmJH, .byline-status-badge-dot) {
8
8
  border-radius: var(--border-radius-full);
9
9
  background-color: var(--green-500);
10
10
  width: .5rem;
@@ -12,7 +12,7 @@
12
12
  display: inline-block;
13
13
  }
14
14
 
15
- :is(.badge-AEKILT, .byline-status-badge) {
15
+ :is(.badge-zXEFyw, .byline-status-badge) {
16
16
  padding: 0 .375rem;
17
17
  font-size: .65rem;
18
18
  line-height: 1.5;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "private": false,
4
4
  "type": "module",
5
5
  "license": "MPL-2.0",
6
- "version": "2.4.0",
6
+ "version": "2.4.1",
7
7
  "engines": {
8
8
  "node": ">=20.9.0"
9
9
  },
@@ -66,9 +66,7 @@
66
66
  "react-diff-viewer-continued": "^4.2.2",
67
67
  "zod": "^4.4.3",
68
68
  "zod-form-data": "^3.0.1",
69
- "@byline/core": "2.4.0",
70
- "@byline/admin": "2.4.0",
71
- "@byline/client": "2.4.0"
69
+ "@byline/core": "2.4.1"
72
70
  },
73
71
  "peerDependencies": {
74
72
  "react": "^19.0.0",
package/src/react.ts CHANGED
@@ -4,8 +4,8 @@
4
4
  *
5
5
  * Single unified entry point for `@byline/ui`. Everything React-side
6
6
  * exports through this barrel — uikit foundations, drag-and-drop
7
- * helpers, the admin module surface, field widgets, form runtime, and
8
- * the framework-neutral service contracts.
7
+ * helpers, presentational admin layout primitives, field widgets, form
8
+ * runtime, and the field-side service contracts.
9
9
  *
10
10
  * Why one barrel: previous releases split this into per-area subpath
11
11
  * exports (`./react/admin`, `./react/fields`, `./react/forms`,
@@ -16,23 +16,15 @@
16
16
  * specifier eliminates the trap structurally. Tree-shaking inside the
17
17
  * single ESM bundle handles unused exports for public-site consumers
18
18
  * (sideEffects is set to CSS only).
19
+ *
20
+ * Admin-domain components (admin users, roles, permissions, account
21
+ * self-service, sign-in form, admin services context) live in
22
+ * `@byline/admin` under per-vertical subpaths — they are no longer
23
+ * exported from here. This package is the kit + form runtime +
24
+ * collection-editor-shared widgets.
19
25
  */
20
26
 
21
- // Admin module components + admin services context.
22
- export * from './admin/components/admin-account/change-password.js'
23
- export * from './admin/components/admin-account/container.js'
24
- export * from './admin/components/admin-account/update.js'
25
- export * from './admin/components/admin-permissions/inspector.js'
26
- export * from './admin/components/admin-roles/create.js'
27
- export * from './admin/components/admin-roles/permissions.js'
28
- export * from './admin/components/admin-roles/update.js'
29
- export * from './admin/components/admin-users/create.js'
30
- export * from './admin/components/admin-users/roles.js'
31
- export * from './admin/components/admin-users/set-password.js'
32
- export * from './admin/components/admin-users/update.js'
33
- export * from './admin/components/auth/sign-in-form.js'
34
- export * from './admin/components/collections/diff-modal.js'
35
- export * from './admin/components/collections/status-badge.js'
27
+ // Presentational admin layout primitives.
36
28
  export * from './admin/group.js'
37
29
  export * from './admin/row.js'
38
30
  export * from './admin/tabs.js'
@@ -69,28 +61,14 @@ export * from './forms/form-context.js'
69
61
  export * from './forms/form-renderer.js'
70
62
  export * from './forms/navigation-guard.js'
71
63
  export * from './forms/path-widget.js'
72
- export * from './services/admin-services-context.js'
73
64
  // Field-side service contract types + Context provider/hook.
74
65
  export * from './services/field-services-context.js'
75
66
  // Foundational surface — synced from @infonomic/uikit. See
76
67
  // scripts/sync-from-uikit.sh and src/.uikit-sync.json.
77
68
  export * from './uikit.js'
78
- export type {
79
- AdminServiceCall,
80
- BylineAdminServices,
81
- ChangeAccountPasswordInput,
82
- CreateAdminRoleInput,
83
- CreateAdminUserInput,
84
- SetAdminUserPasswordInput,
85
- SetRoleAbilitiesInput,
86
- SetUserRolesInput,
87
- SignInInput,
88
- SignInResult,
89
- UpdateAccountInput,
90
- UpdateAdminRoleInput,
91
- UpdateAdminUserInput,
92
- WhoHasAbilityInput,
93
- } from './services/admin-services-types.js'
69
+ // Collection-editor-shared widgets.
70
+ export * from './widgets/diff-viewer/diff-modal.js'
71
+ export * from './widgets/status-badge/status-badge.js'
94
72
  export type {
95
73
  BylineFieldServices,
96
74
  CollectionListDoc,
@@ -13,8 +13,7 @@ import { useEffect, useState } from 'react'
13
13
  import cx from 'classnames'
14
14
  import ReactDiffViewer, { DiffMethod } from 'react-diff-viewer-continued'
15
15
 
16
- import { useBylineAdminServices } from '../../../services/admin-services-context.js'
17
- import { CloseIcon, IconButton, LoaderRing, Modal } from '../../../uikit.js'
16
+ import { CloseIcon, IconButton, LoaderRing, Modal } from '../../uikit.js'
18
17
  import styles from './diff-modal.module.css'
19
18
 
20
19
  // Keys that are per-version metadata rather than content — strip before diffing
@@ -52,6 +51,18 @@ export interface DiffModalProps {
52
51
  currentDocument: Record<string, unknown>
53
52
  /** Content locale to compare — undefined / 'all' shows all locales. */
54
53
  locale?: string
54
+ /**
55
+ * Host-provided loader for a historical document version. The diff
56
+ * modal is framework-neutral; callers wire this to whatever transport
57
+ * they use (e.g. `BylineAdminServices.getCollectionDocumentVersion` in
58
+ * the admin shell).
59
+ */
60
+ loadHistoricalVersion: (
61
+ collection: string,
62
+ documentId: string,
63
+ versionId: string,
64
+ locale: string | undefined
65
+ ) => Promise<Record<string, unknown>>
55
66
  }
56
67
 
57
68
  export function DiffModal({
@@ -63,8 +74,8 @@ export function DiffModal({
63
74
  versionLabel,
64
75
  currentDocument,
65
76
  locale,
77
+ loadHistoricalVersion,
66
78
  }: DiffModalProps) {
67
- const { getCollectionDocumentVersion } = useBylineAdminServices()
68
79
  const [historicalDoc, setHistoricalDoc] = useState<Record<string, unknown> | null>(null)
69
80
  const [loading, setLoading] = useState(false)
70
81
  const [error, setError] = useState<string | null>(null)
@@ -77,7 +88,7 @@ export function DiffModal({
77
88
  setError(null)
78
89
  setHistoricalDoc(null)
79
90
 
80
- getCollectionDocumentVersion(collection, documentId, versionId, locale)
91
+ loadHistoricalVersion(collection, documentId, versionId, locale)
81
92
  .then((doc) => {
82
93
  if (cancelled) return
83
94
  setHistoricalDoc(doc)
@@ -93,7 +104,7 @@ export function DiffModal({
93
104
  return () => {
94
105
  cancelled = true
95
106
  }
96
- }, [isOpen, collection, documentId, versionId, locale, getCollectionDocumentVersion])
107
+ }, [isOpen, collection, documentId, versionId, locale, loadHistoricalVersion])
97
108
 
98
109
  const currentStr = currentDocument ? JSON.stringify(stripMeta(currentDocument), null, 2) : ''
99
110
 
@@ -14,7 +14,7 @@ import {
14
14
  } from '@byline/core'
15
15
  import cx from 'classnames'
16
16
 
17
- import { Badge } from '../../../uikit.js'
17
+ import { Badge } from '../../uikit.js'
18
18
  import styles from './status-badge.module.css'
19
19
 
20
20
  function statusIntent(status: string): 'success' | 'warning' | 'info' | 'noeffect' {
@@ -1,8 +0,0 @@
1
- import type { AccountResponse } from '@byline/admin/admin-account';
2
- interface ChangePasswordProps {
3
- account: AccountResponse;
4
- onClose?: () => void;
5
- onSuccess?: (account: AccountResponse) => void;
6
- }
7
- export declare function ChangeAccountPassword({ account, onClose, onSuccess }: ChangePasswordProps): import("react").JSX.Element;
8
- export {};
@@ -1,192 +0,0 @@
1
- "use client";
2
- import { jsx, jsxs } from "react/jsx-runtime";
3
- import { useState } from "react";
4
- import { revalidateLogic, useForm } from "@tanstack/react-form-start";
5
- import { passwordSchema } from "@byline/core/validation";
6
- import classnames from "classnames";
7
- import { z } from "zod";
8
- import { useBylineAdminServices } from "../../../services/admin-services-context.js";
9
- import { Alert, Button, InputPassword, LoaderEllipsis } from "../../../uikit.js";
10
- import change_password_module from "./change-password.module.js";
11
- const changePasswordFormSchema = z.object({
12
- currentPassword: z.string().min(1, {
13
- message: 'Please enter your current password'
14
- }),
15
- newPassword: passwordSchema,
16
- confirm: z.string({
17
- message: 'Please confirm the new password'
18
- })
19
- }).refine((v)=>v.newPassword === v.confirm, {
20
- message: 'New passwords do not match',
21
- path: [
22
- 'confirm'
23
- ]
24
- });
25
- function ChangeAccountPassword({ account, onClose, onSuccess }) {
26
- const { changeAccountPassword } = useBylineAdminServices();
27
- const [formError, setFormError] = useState(null);
28
- const [successMessage, setSuccessMessage] = useState(null);
29
- const form = useForm({
30
- defaultValues: {
31
- currentPassword: '',
32
- newPassword: '',
33
- confirm: ''
34
- },
35
- validationLogic: revalidateLogic({
36
- mode: 'blur',
37
- modeAfterSubmission: 'change'
38
- }),
39
- validators: {
40
- onDynamic: changePasswordFormSchema
41
- },
42
- onSubmit: async ({ value })=>{
43
- setFormError(null);
44
- setSuccessMessage(null);
45
- try {
46
- const updated = await changeAccountPassword({
47
- data: {
48
- vid: account.vid,
49
- currentPassword: value.currentPassword,
50
- newPassword: value.newPassword
51
- }
52
- });
53
- setSuccessMessage('Password updated.');
54
- form.reset({
55
- currentPassword: '',
56
- newPassword: '',
57
- confirm: ''
58
- });
59
- onSuccess?.(updated);
60
- } catch (err) {
61
- const code = getErrorCode(err);
62
- if ('admin.account.invalidCurrentPassword' === code) return void form.setFieldMeta('currentPassword', (meta)=>({
63
- ...meta,
64
- errorMap: {
65
- ...meta.errorMap,
66
- onServer: 'Current password is incorrect.'
67
- },
68
- errors: [
69
- 'Current password is incorrect.'
70
- ]
71
- }));
72
- if ('admin.users.versionConflict' === code) return void setFormError('Your account has been modified elsewhere since you opened this form. Reload to refresh and try again.');
73
- if ('admin.account.notFound' === code) return void setFormError('Your admin account could not be found. Please sign in again.');
74
- setFormError('Could not change the password. Please try again.');
75
- }
76
- }
77
- });
78
- return /*#__PURE__*/ jsx("div", {
79
- className: classnames('byline-account-change-password-wrap', change_password_module.wrap),
80
- children: /*#__PURE__*/ jsxs("form", {
81
- noValidate: true,
82
- onSubmit: (event)=>{
83
- event.preventDefault();
84
- event.stopPropagation();
85
- form.handleSubmit();
86
- },
87
- className: classnames('byline-account-change-password-form', change_password_module.form),
88
- children: [
89
- formError ? /*#__PURE__*/ jsx(Alert, {
90
- intent: "danger",
91
- children: formError
92
- }) : null,
93
- successMessage ? /*#__PURE__*/ jsx(Alert, {
94
- intent: "success",
95
- children: successMessage
96
- }) : null,
97
- /*#__PURE__*/ jsx("p", {
98
- className: "muted",
99
- children: "Other active sessions will continue to work until their tokens expire. Sign out elsewhere if you suspect another device has been compromised."
100
- }),
101
- /*#__PURE__*/ jsx(form.Field, {
102
- name: "currentPassword",
103
- children: (field)=>/*#__PURE__*/ jsx(InputPassword, {
104
- label: "Current password",
105
- id: "currentPassword",
106
- name: field.name,
107
- value: field.state.value,
108
- onBlur: field.handleBlur,
109
- onChange: (e)=>field.handleChange(e.currentTarget.value),
110
- error: field.state.meta.errors.length > 0,
111
- errorText: firstError(field.state.meta.errors),
112
- autoComplete: "current-password",
113
- required: true
114
- })
115
- }),
116
- /*#__PURE__*/ jsx(form.Field, {
117
- name: "newPassword",
118
- children: (field)=>/*#__PURE__*/ jsx(InputPassword, {
119
- label: "New password",
120
- id: "newPassword",
121
- name: field.name,
122
- value: field.state.value,
123
- onBlur: field.handleBlur,
124
- onChange: (e)=>field.handleChange(e.currentTarget.value),
125
- error: field.state.meta.errors.length > 0,
126
- errorText: firstError(field.state.meta.errors),
127
- autoComplete: "new-password",
128
- required: true
129
- })
130
- }),
131
- /*#__PURE__*/ jsx(form.Field, {
132
- name: "confirm",
133
- children: (field)=>/*#__PURE__*/ jsx(InputPassword, {
134
- label: "Confirm new password",
135
- id: "confirm",
136
- name: field.name,
137
- value: field.state.value,
138
- onBlur: field.handleBlur,
139
- onChange: (e)=>field.handleChange(e.currentTarget.value),
140
- error: field.state.meta.errors.length > 0,
141
- errorText: firstError(field.state.meta.errors),
142
- autoComplete: "new-password",
143
- required: true
144
- })
145
- }),
146
- /*#__PURE__*/ jsxs("div", {
147
- className: classnames('byline-account-change-password-actions', change_password_module.actions),
148
- children: [
149
- /*#__PURE__*/ jsx(Button, {
150
- type: "button",
151
- intent: "secondary",
152
- size: "sm",
153
- onClick: onClose,
154
- className: classnames('byline-account-change-password-action', change_password_module.action),
155
- children: successMessage ? 'Close' : 'Cancel'
156
- }),
157
- /*#__PURE__*/ jsx(form.Subscribe, {
158
- selector: (state)=>({
159
- canSubmit: state.canSubmit,
160
- isSubmitting: state.isSubmitting,
161
- isDirty: state.isDirty
162
- }),
163
- children: ({ canSubmit, isSubmitting })=>/*#__PURE__*/ jsx(Button, {
164
- size: "sm",
165
- intent: "primary",
166
- type: "submit",
167
- disabled: !canSubmit || isSubmitting,
168
- className: classnames('byline-account-change-password-action', change_password_module.action),
169
- children: true === isSubmitting ? /*#__PURE__*/ jsx(LoaderEllipsis, {
170
- size: 42
171
- }) : 'Save'
172
- })
173
- })
174
- ]
175
- })
176
- ]
177
- })
178
- });
179
- }
180
- function firstError(errors) {
181
- for (const err of errors){
182
- if ('string' == typeof err) return err;
183
- if (err && 'object' == typeof err && 'message' in err) {
184
- const msg = err.message;
185
- if ('string' == typeof msg) return msg;
186
- }
187
- }
188
- }
189
- function getErrorCode(err) {
190
- return 'string' == typeof err?.code ? err.code : null;
191
- }
192
- export { ChangeAccountPassword };
@@ -1,8 +0,0 @@
1
- import "./change-password_module.css";
2
- const change_password_module = {
3
- wrap: "wrap-nR1v0b",
4
- form: "form-ikIPql",
5
- actions: "actions-H6_y6n",
6
- action: "action-lTtcpD"
7
- };
8
- export default change_password_module;
@@ -1,27 +0,0 @@
1
- :is(.wrap-nR1v0b, .byline-account-change-password-wrap) {
2
- gap: var(--spacing-8);
3
- padding: var(--spacing-4);
4
- margin-top: var(--spacing-4);
5
- flex-direction: column;
6
- display: flex;
7
- }
8
-
9
- :is(.form-ikIPql, .byline-account-change-password-form) {
10
- gap: var(--spacing-16);
11
- padding-top: var(--spacing-8);
12
- flex-direction: column;
13
- display: flex;
14
- }
15
-
16
- :is(.actions-H6_y6n, .byline-account-change-password-actions) {
17
- justify-content: flex-end;
18
- align-items: center;
19
- gap: var(--spacing-8);
20
- margin-top: var(--spacing-16);
21
- display: flex;
22
- }
23
-
24
- :is(.action-lTtcpD, .byline-account-change-password-action) {
25
- min-width: 4rem;
26
- }
27
-