@byline/admin 2.5.1 → 2.6.0

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 (260) hide show
  1. package/dist/fields/array/array-field.d.ts +14 -0
  2. package/dist/fields/array/array-field.js +177 -0
  3. package/dist/fields/array/array-field.module.js +11 -0
  4. package/dist/fields/array/array-field_module.css +32 -0
  5. package/dist/fields/blocks/blocks-field.d.ts +13 -0
  6. package/dist/fields/blocks/blocks-field.js +245 -0
  7. package/dist/fields/blocks/blocks-field.module.js +26 -0
  8. package/dist/fields/blocks/blocks-field_module.css +107 -0
  9. package/dist/fields/checkbox/checkbox-field.d.ts +16 -0
  10. package/dist/fields/checkbox/checkbox-field.js +28 -0
  11. package/dist/fields/checkbox/checkbox-field.module.js +6 -0
  12. package/dist/fields/checkbox/checkbox-field_module.css +4 -0
  13. package/dist/fields/column-formatter.d.ts +20 -0
  14. package/dist/fields/column-formatter.js +15 -0
  15. package/dist/fields/date-time-formatter.d.ts +16 -0
  16. package/dist/fields/date-time-formatter.js +8 -0
  17. package/dist/fields/datetime/datetime-field.d.ts +16 -0
  18. package/dist/fields/datetime/datetime-field.js +37 -0
  19. package/dist/fields/datetime/datetime-field.module.js +5 -0
  20. package/dist/fields/datetime/datetime-field_module.css +4 -0
  21. package/dist/fields/draggable-context-menu.d.ts +6 -0
  22. package/dist/fields/draggable-context-menu.js +85 -0
  23. package/dist/fields/draggable-context-menu.module.js +15 -0
  24. package/dist/fields/draggable-context-menu_module.css +91 -0
  25. package/dist/fields/field-helpers.d.ts +26 -0
  26. package/dist/fields/field-helpers.js +50 -0
  27. package/dist/fields/field-renderer.d.ts +37 -0
  28. package/dist/fields/field-renderer.js +206 -0
  29. package/dist/fields/field-renderer.module.js +8 -0
  30. package/dist/fields/field-renderer_module.css +11 -0
  31. package/dist/fields/field-services-context.d.ts +16 -0
  32. package/dist/fields/field-services-context.js +13 -0
  33. package/dist/fields/field-services-types.d.ts +63 -0
  34. package/dist/fields/field-services-types.js +1 -0
  35. package/dist/fields/file/file-field.d.ts +19 -0
  36. package/dist/fields/file/file-field.js +225 -0
  37. package/dist/fields/file/file-field.module.js +18 -0
  38. package/dist/fields/file/file-field_module.css +131 -0
  39. package/dist/fields/file/file-upload-field.d.ts +21 -0
  40. package/dist/fields/file/file-upload-field.js +130 -0
  41. package/dist/fields/file/file-upload-field.module.js +15 -0
  42. package/dist/fields/file/file-upload-field_module.css +74 -0
  43. package/dist/fields/group/group-field.d.ts +15 -0
  44. package/dist/fields/group/group-field.js +59 -0
  45. package/dist/fields/group/group-field.module.js +9 -0
  46. package/dist/fields/group/group-field_module.css +27 -0
  47. package/dist/fields/image/image-field.d.ts +19 -0
  48. package/dist/fields/image/image-field.js +241 -0
  49. package/dist/fields/image/image-field.module.js +22 -0
  50. package/dist/fields/image/image-field_module.css +121 -0
  51. package/dist/fields/image/image-upload-field.d.ts +21 -0
  52. package/dist/fields/image/image-upload-field.js +190 -0
  53. package/dist/fields/image/image-upload-field.module.js +19 -0
  54. package/dist/fields/image/image-upload-field_module.css +92 -0
  55. package/dist/fields/local-date-time.d.ts +27 -0
  56. package/dist/fields/local-date-time.js +49 -0
  57. package/dist/fields/locale-badge.d.ts +18 -0
  58. package/dist/fields/locale-badge.js +10 -0
  59. package/dist/fields/locale-badge.module.js +5 -0
  60. package/dist/fields/locale-badge_module.css +27 -0
  61. package/dist/fields/numerical/numerical-field.d.ts +18 -0
  62. package/dist/fields/numerical/numerical-field.js +74 -0
  63. package/dist/fields/relation/relation-display.d.ts +40 -0
  64. package/dist/fields/relation/relation-display.js +58 -0
  65. package/dist/fields/relation/relation-display.module.js +9 -0
  66. package/dist/fields/relation/relation-display_module.css +21 -0
  67. package/dist/fields/relation/relation-field.d.ts +18 -0
  68. package/dist/fields/relation/relation-field.js +138 -0
  69. package/dist/fields/relation/relation-field.module.js +13 -0
  70. package/dist/fields/relation/relation-field_module.css +62 -0
  71. package/dist/fields/relation/relation-picker.d.ts +49 -0
  72. package/dist/fields/relation/relation-picker.js +236 -0
  73. package/dist/fields/relation/relation-picker.module.js +26 -0
  74. package/dist/fields/relation/relation-picker_module.css +124 -0
  75. package/dist/fields/relation/relation-summary.d.ts +31 -0
  76. package/dist/fields/relation/relation-summary.js +50 -0
  77. package/dist/fields/relation/relation-summary.module.js +11 -0
  78. package/dist/fields/relation/relation-summary_module.css +37 -0
  79. package/dist/fields/select/select-field.d.ts +16 -0
  80. package/dist/fields/select/select-field.js +50 -0
  81. package/dist/fields/select/select-field.module.js +5 -0
  82. package/dist/fields/select/select-field_module.css +4 -0
  83. package/dist/fields/sortable-item.d.ts +15 -0
  84. package/dist/fields/sortable-item.js +81 -0
  85. package/dist/fields/sortable-item.module.js +22 -0
  86. package/dist/fields/sortable-item_module.css +124 -0
  87. package/dist/fields/text/text-field.d.ts +20 -0
  88. package/dist/fields/text/text-field.js +104 -0
  89. package/dist/fields/text/text-field.module.js +6 -0
  90. package/dist/fields/text/text-field_module.css +5 -0
  91. package/dist/fields/text-area/text-area-field.d.ts +20 -0
  92. package/dist/fields/text-area/text-area-field.js +105 -0
  93. package/dist/fields/text-area/text-area-field.module.js +6 -0
  94. package/dist/fields/text-area/text-area-field_module.css +5 -0
  95. package/dist/fields/use-field-change-handler.d.ts +23 -0
  96. package/dist/fields/use-field-change-handler.js +52 -0
  97. package/dist/forms/document-actions.d.ts +48 -0
  98. package/dist/forms/document-actions.js +475 -0
  99. package/dist/forms/document-actions.module.js +34 -0
  100. package/dist/forms/document-actions_module.css +118 -0
  101. package/dist/forms/form-context.d.ts +89 -0
  102. package/dist/forms/form-context.js +466 -0
  103. package/dist/forms/form-renderer.d.ts +98 -0
  104. package/dist/forms/form-renderer.js +597 -0
  105. package/dist/forms/form-renderer.module.js +46 -0
  106. package/dist/forms/form-renderer_module.css +245 -0
  107. package/dist/forms/navigation-guard.d.ts +54 -0
  108. package/dist/forms/navigation-guard.js +22 -0
  109. package/dist/forms/path-widget.d.ts +36 -0
  110. package/dist/forms/path-widget.js +116 -0
  111. package/dist/forms/path-widget.module.js +8 -0
  112. package/dist/forms/path-widget_module.css +29 -0
  113. package/dist/forms/upload-executor.d.ts +57 -0
  114. package/dist/forms/upload-executor.js +94 -0
  115. package/dist/lib/translate-validation-error.d.ts +36 -0
  116. package/dist/lib/translate-validation-error.js +11 -0
  117. package/dist/modules/admin-account/commands.d.ts +2 -1
  118. package/dist/modules/admin-account/commands.js +13 -2
  119. package/dist/modules/admin-account/components/change-password.js +45 -36
  120. package/dist/modules/admin-account/components/container.js +185 -134
  121. package/dist/modules/admin-account/components/preferences.d.ts +8 -0
  122. package/dist/modules/admin-account/components/preferences.js +152 -0
  123. package/dist/modules/admin-account/components/preferences.module.js +11 -0
  124. package/dist/modules/admin-account/components/preferences_module.css +41 -0
  125. package/dist/modules/admin-account/components/update.js +50 -31
  126. package/dist/modules/admin-account/index.d.ts +3 -3
  127. package/dist/modules/admin-account/index.js +2 -2
  128. package/dist/modules/admin-account/schemas.d.ts +4 -0
  129. package/dist/modules/admin-account/schemas.js +4 -1
  130. package/dist/modules/admin-account/service.d.ts +1 -0
  131. package/dist/modules/admin-account/service.js +8 -0
  132. package/dist/modules/admin-permissions/components/inspector.js +31 -41
  133. package/dist/modules/admin-roles/components/create.js +43 -26
  134. package/dist/modules/admin-roles/components/permissions.js +26 -35
  135. package/dist/modules/admin-roles/components/update.js +26 -16
  136. package/dist/modules/admin-users/components/create.js +60 -40
  137. package/dist/modules/admin-users/components/roles.js +9 -15
  138. package/dist/modules/admin-users/components/set-password.js +30 -31
  139. package/dist/modules/admin-users/components/update.js +58 -39
  140. package/dist/modules/admin-users/dto.js +1 -0
  141. package/dist/modules/admin-users/repository.d.ts +17 -0
  142. package/dist/modules/admin-users/schemas.d.ts +4 -0
  143. package/dist/modules/admin-users/schemas.js +6 -2
  144. package/dist/modules/auth/components/sign-in-form.js +10 -8
  145. package/dist/presentation/group.d.ts +27 -0
  146. package/dist/presentation/group.js +14 -0
  147. package/dist/presentation/group.module.js +6 -0
  148. package/dist/presentation/group_module.css +19 -0
  149. package/dist/presentation/row.d.ts +25 -0
  150. package/dist/presentation/row.js +8 -0
  151. package/dist/presentation/row.module.js +5 -0
  152. package/dist/presentation/row_module.css +18 -0
  153. package/dist/presentation/tabs.d.ts +25 -0
  154. package/dist/presentation/tabs.js +39 -0
  155. package/dist/presentation/tabs.module.js +10 -0
  156. package/dist/presentation/tabs_module.css +68 -0
  157. package/dist/react.d.ts +66 -0
  158. package/dist/react.js +36 -0
  159. package/dist/services/admin-services-types.d.ts +16 -0
  160. package/dist/widgets/diff-viewer/diff-modal.d.ts +22 -0
  161. package/dist/widgets/diff-viewer/diff-modal.js +149 -0
  162. package/dist/widgets/diff-viewer/diff-modal.module.js +14 -0
  163. package/dist/widgets/diff-viewer/diff-modal_module.css +56 -0
  164. package/dist/widgets/status-badge/status-badge.d.ts +25 -0
  165. package/dist/widgets/status-badge/status-badge.js +37 -0
  166. package/dist/widgets/status-badge/status-badge.module.js +7 -0
  167. package/dist/widgets/status-badge/status-badge_module.css +20 -0
  168. package/package.json +14 -4
  169. package/src/fields/array/array-field.module.css +48 -0
  170. package/src/fields/array/array-field.tsx +267 -0
  171. package/src/fields/blocks/blocks-field.module.css +148 -0
  172. package/src/fields/blocks/blocks-field.tsx +323 -0
  173. package/src/fields/checkbox/checkbox-field.module.css +4 -0
  174. package/src/fields/checkbox/checkbox-field.tsx +54 -0
  175. package/src/fields/column-formatter.tsx +31 -0
  176. package/src/fields/date-time-formatter.tsx +22 -0
  177. package/src/fields/datetime/datetime-field.module.css +13 -0
  178. package/src/fields/datetime/datetime-field.tsx +54 -0
  179. package/src/fields/draggable-context-menu.module.css +127 -0
  180. package/src/fields/draggable-context-menu.tsx +87 -0
  181. package/src/fields/field-helpers.ts +69 -0
  182. package/src/fields/field-renderer.module.css +22 -0
  183. package/src/fields/field-renderer.tsx +288 -0
  184. package/src/fields/field-services-context.tsx +35 -0
  185. package/src/fields/field-services-types.ts +68 -0
  186. package/src/fields/file/file-field.module.css +153 -0
  187. package/src/fields/file/file-field.tsx +286 -0
  188. package/src/fields/file/file-upload-field.module.css +101 -0
  189. package/src/fields/file/file-upload-field.tsx +187 -0
  190. package/src/fields/group/group-field.module.css +43 -0
  191. package/src/fields/group/group-field.tsx +84 -0
  192. package/src/fields/image/image-field.module.css +155 -0
  193. package/src/fields/image/image-field.tsx +306 -0
  194. package/src/fields/image/image-upload-field.module.css +123 -0
  195. package/src/fields/image/image-upload-field.tsx +276 -0
  196. package/src/fields/local-date-time.tsx +88 -0
  197. package/src/fields/locale-badge.module.css +37 -0
  198. package/src/fields/locale-badge.tsx +32 -0
  199. package/src/fields/numerical/numerical-field.tsx +114 -0
  200. package/src/fields/relation/relation-display.module.css +36 -0
  201. package/src/fields/relation/relation-display.tsx +130 -0
  202. package/src/fields/relation/relation-field.module.css +83 -0
  203. package/src/fields/relation/relation-field.tsx +211 -0
  204. package/src/fields/relation/relation-picker.module.css +168 -0
  205. package/src/fields/relation/relation-picker.tsx +326 -0
  206. package/src/fields/relation/relation-summary.module.css +55 -0
  207. package/src/fields/relation/relation-summary.tsx +123 -0
  208. package/src/fields/select/select-field.module.css +13 -0
  209. package/src/fields/select/select-field.tsx +61 -0
  210. package/src/fields/sortable-item.module.css +167 -0
  211. package/src/fields/sortable-item.tsx +106 -0
  212. package/src/fields/text/text-field.module.css +13 -0
  213. package/src/fields/text/text-field.tsx +146 -0
  214. package/src/fields/text-area/text-area-field.module.css +13 -0
  215. package/src/fields/text-area/text-area-field.tsx +147 -0
  216. package/src/fields/use-field-change-handler.ts +112 -0
  217. package/src/forms/document-actions.module.css +160 -0
  218. package/src/forms/document-actions.tsx +482 -0
  219. package/src/forms/form-context.tsx +704 -0
  220. package/src/forms/form-renderer.module.css +321 -0
  221. package/src/forms/form-renderer.tsx +891 -0
  222. package/src/forms/navigation-guard.tsx +98 -0
  223. package/src/forms/path-widget.module.css +41 -0
  224. package/src/forms/path-widget.test.tsx +217 -0
  225. package/src/forms/path-widget.tsx +183 -0
  226. package/src/forms/upload-executor.ts +192 -0
  227. package/src/lib/translate-validation-error.ts +56 -0
  228. package/src/modules/admin-account/commands.ts +13 -0
  229. package/src/modules/admin-account/components/change-password.tsx +46 -31
  230. package/src/modules/admin-account/components/container.tsx +83 -38
  231. package/src/modules/admin-account/components/preferences.module.css +60 -0
  232. package/src/modules/admin-account/components/preferences.tsx +203 -0
  233. package/src/modules/admin-account/components/update.tsx +53 -27
  234. package/src/modules/admin-account/index.ts +3 -0
  235. package/src/modules/admin-account/schemas.ts +13 -0
  236. package/src/modules/admin-account/service.ts +12 -0
  237. package/src/modules/admin-permissions/components/inspector.tsx +22 -14
  238. package/src/modules/admin-roles/components/create.tsx +51 -23
  239. package/src/modules/admin-roles/components/permissions.tsx +25 -21
  240. package/src/modules/admin-roles/components/update.tsx +37 -19
  241. package/src/modules/admin-users/components/create.tsx +63 -34
  242. package/src/modules/admin-users/components/roles.tsx +9 -8
  243. package/src/modules/admin-users/components/set-password.tsx +34 -28
  244. package/src/modules/admin-users/components/update.tsx +58 -36
  245. package/src/modules/admin-users/dto.ts +1 -0
  246. package/src/modules/admin-users/repository.ts +17 -0
  247. package/src/modules/admin-users/schemas.ts +12 -0
  248. package/src/modules/auth/components/sign-in-form.tsx +14 -8
  249. package/src/presentation/group.module.css +41 -0
  250. package/src/presentation/group.tsx +40 -0
  251. package/src/presentation/row.module.css +32 -0
  252. package/src/presentation/row.tsx +33 -0
  253. package/src/presentation/tabs.module.css +107 -0
  254. package/src/presentation/tabs.tsx +84 -0
  255. package/src/react.ts +84 -0
  256. package/src/services/admin-services-types.ts +18 -0
  257. package/src/widgets/diff-viewer/diff-modal.module.css +79 -0
  258. package/src/widgets/diff-viewer/diff-modal.tsx +186 -0
  259. package/src/widgets/status-badge/status-badge.module.css +31 -0
  260. package/src/widgets/status-badge/status-badge.tsx +71 -0
@@ -1,26 +1,21 @@
1
1
  "use client";
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
3
  import { useState } from "react";
4
- import { Button, CloseIcon, Drawer, EditIcon, IconButton, LocalDateTime } from "@byline/ui/react";
4
+ import { LocalDateTime } from "@byline/admin/react";
5
+ import { useTranslation } from "@byline/i18n/react";
6
+ import { Button, CloseIcon, Drawer, EditIcon, IconButton } from "@byline/ui/react";
5
7
  import classnames from "classnames";
6
8
  import { ChangeAccountPassword } from "./change-password.js";
7
9
  import container_module from "./container.module.js";
10
+ import { Preferences } from "./preferences.js";
8
11
  import { UpdateAccount } from "./update.js";
9
- const panels = {
10
- update: {
11
- title: 'Profile',
12
- component: UpdateAccount
13
- },
14
- change_password: {
15
- title: 'Change Password',
16
- component: ChangeAccountPassword
17
- },
18
- empty: {
19
- title: '',
20
- component: ()=>null
21
- }
12
+ const panelComponents = {
13
+ update: UpdateAccount,
14
+ change_password: ChangeAccountPassword,
15
+ preferences: Preferences,
16
+ empty: ()=>null
22
17
  };
23
- function ContainerSection({ title, onEdit, children }) {
18
+ function ContainerSection({ title, onEdit, editAriaLabel, children }) {
24
19
  return /*#__PURE__*/ jsxs("div", {
25
20
  className: classnames('byline-account-section', container_module.section),
26
21
  children: [
@@ -33,7 +28,7 @@ function ContainerSection({ title, onEdit, children }) {
33
28
  onEdit ? /*#__PURE__*/ jsx(IconButton, {
34
29
  variant: "text",
35
30
  onClick: onEdit,
36
- "aria-label": `Edit ${title}`,
31
+ "aria-label": editAriaLabel ?? title,
37
32
  children: /*#__PURE__*/ jsx(EditIcon, {
38
33
  width: "20px",
39
34
  height: "20px"
@@ -48,6 +43,7 @@ function ContainerSection({ title, onEdit, children }) {
48
43
  });
49
44
  }
50
45
  function AccountSelfContainer({ account }) {
46
+ const { t } = useTranslation('byline-admin');
51
47
  const [currentAccount, setCurrentAccount] = useState(account);
52
48
  const [current, setCurrent] = useState('empty');
53
49
  const [isDrawerOpen, setIsDrawerOpen] = useState(false);
@@ -62,149 +58,204 @@ function AccountSelfContainer({ account }) {
62
58
  const handleSuccess = (updated)=>{
63
59
  setCurrentAccount(updated);
64
60
  };
65
- const Panel = panels[current].component;
61
+ const Panel = panelComponents[current];
62
+ const panelTitles = {
63
+ update: t('account.sections.profile'),
64
+ change_password: t('account.sections.password'),
65
+ preferences: t('account.sections.preferences'),
66
+ empty: ''
67
+ };
68
+ const editAriaFor = (section)=>t('account.editAriaLabel', {
69
+ section
70
+ });
66
71
  return /*#__PURE__*/ jsxs(Fragment, {
67
72
  children: [
68
73
  /*#__PURE__*/ jsxs("div", {
69
74
  className: classnames('byline-account-grid', container_module.grid),
70
75
  children: [
71
- /*#__PURE__*/ jsx("div", {
76
+ /*#__PURE__*/ jsxs("div", {
72
77
  className: classnames('byline-account-column', container_module.column),
73
- children: /*#__PURE__*/ jsxs(ContainerSection, {
74
- title: "Profile",
75
- onEdit: openDrawer('update'),
76
- children: [
77
- /*#__PURE__*/ jsxs("p", {
78
- className: classnames('byline-account-line', container_module.line),
79
- children: [
80
- /*#__PURE__*/ jsx("span", {
81
- className: "muted",
82
- children: "Email:"
83
- }),
84
- " ",
85
- currentAccount.email
86
- ]
87
- }),
88
- /*#__PURE__*/ jsxs("p", {
89
- className: classnames('byline-account-line', container_module.line),
90
- children: [
91
- /*#__PURE__*/ jsx("span", {
92
- className: "muted",
93
- children: "Given name:"
94
- }),
95
- ' ',
96
- currentAccount.given_name ?? /*#__PURE__*/ jsx("span", {
97
- className: classnames('muted', 'byline-account-not-set', container_module["not-set"]),
98
- children: "Not set"
99
- })
100
- ]
101
- }),
102
- /*#__PURE__*/ jsxs("p", {
103
- className: classnames('byline-account-line', container_module.line),
104
- children: [
105
- /*#__PURE__*/ jsx("span", {
106
- className: "muted",
107
- children: "Family name:"
108
- }),
109
- ' ',
110
- currentAccount.family_name ?? /*#__PURE__*/ jsx("span", {
111
- className: classnames('muted', 'byline-account-not-set', container_module["not-set"]),
112
- children: "Not set"
113
- })
114
- ]
115
- }),
116
- /*#__PURE__*/ jsxs("p", {
117
- className: classnames('byline-account-cta-line', container_module["cta-line"]),
118
- children: [
119
- /*#__PURE__*/ jsx("span", {
120
- className: "muted",
121
- children: "Username:"
122
- }),
123
- ' ',
124
- currentAccount.username ?? /*#__PURE__*/ jsx("span", {
125
- className: classnames('muted', 'byline-account-not-set', container_module["not-set"]),
126
- children: "Not set"
127
- })
128
- ]
129
- }),
130
- /*#__PURE__*/ jsx(Button, {
131
- size: "sm",
132
- onClick: openDrawer('update'),
133
- children: "Edit Profile"
134
- }),
135
- /*#__PURE__*/ jsxs("div", {
136
- className: classnames('muted', 'byline-account-meta', container_module.meta),
137
- children: [
138
- /*#__PURE__*/ jsxs("p", {
139
- children: [
140
- /*#__PURE__*/ jsx("span", {
141
- className: "font-bold",
142
- children: "Created:\xa0"
143
- }),
144
- /*#__PURE__*/ jsx(LocalDateTime, {
145
- value: currentAccount.created_at
146
- })
147
- ]
148
- }),
149
- /*#__PURE__*/ jsxs("p", {
150
- children: [
151
- /*#__PURE__*/ jsx("span", {
152
- className: "font-bold",
153
- children: "Updated:\xa0"
154
- }),
155
- /*#__PURE__*/ jsx(LocalDateTime, {
156
- value: currentAccount.updated_at
157
- })
158
- ]
159
- }),
160
- /*#__PURE__*/ jsxs("p", {
161
- className: classnames('byline-account-line', container_module.line),
162
- children: [
163
- /*#__PURE__*/ jsx("span", {
164
- className: "font-bold",
165
- children: "Last login:\xa0"
166
- }),
167
- /*#__PURE__*/ jsx(LocalDateTime, {
168
- value: currentAccount.last_login,
169
- fallback: "Never"
170
- })
171
- ]
78
+ children: [
79
+ /*#__PURE__*/ jsxs(ContainerSection, {
80
+ title: t('account.sections.profile'),
81
+ onEdit: openDrawer('update'),
82
+ editAriaLabel: editAriaFor(t('account.sections.profile')),
83
+ children: [
84
+ /*#__PURE__*/ jsxs("p", {
85
+ className: classnames('byline-account-line', container_module.line),
86
+ children: [
87
+ /*#__PURE__*/ jsx("span", {
88
+ className: "muted",
89
+ children: t('account.profile.emailColon')
90
+ }),
91
+ ' ',
92
+ currentAccount.email
93
+ ]
94
+ }),
95
+ /*#__PURE__*/ jsxs("p", {
96
+ className: classnames('byline-account-line', container_module.line),
97
+ children: [
98
+ /*#__PURE__*/ jsx("span", {
99
+ className: "muted",
100
+ children: t('account.profile.givenName')
101
+ }),
102
+ ' ',
103
+ currentAccount.given_name ?? /*#__PURE__*/ jsx("span", {
104
+ className: classnames('muted', 'byline-account-not-set', container_module["not-set"]),
105
+ children: t('common.notSet')
106
+ })
107
+ ]
108
+ }),
109
+ /*#__PURE__*/ jsxs("p", {
110
+ className: classnames('byline-account-line', container_module.line),
111
+ children: [
112
+ /*#__PURE__*/ jsx("span", {
113
+ className: "muted",
114
+ children: t('account.profile.familyName')
115
+ }),
116
+ ' ',
117
+ currentAccount.family_name ?? /*#__PURE__*/ jsx("span", {
118
+ className: classnames('muted', 'byline-account-not-set', container_module["not-set"]),
119
+ children: t('common.notSet')
120
+ })
121
+ ]
122
+ }),
123
+ /*#__PURE__*/ jsxs("p", {
124
+ className: classnames('byline-account-cta-line', container_module["cta-line"]),
125
+ children: [
126
+ /*#__PURE__*/ jsx("span", {
127
+ className: "muted",
128
+ children: t('account.profile.username')
129
+ }),
130
+ ' ',
131
+ currentAccount.username ?? /*#__PURE__*/ jsx("span", {
132
+ className: classnames('muted', 'byline-account-not-set', container_module["not-set"]),
133
+ children: t('common.notSet')
134
+ })
135
+ ]
136
+ }),
137
+ /*#__PURE__*/ jsx(Button, {
138
+ size: "sm",
139
+ onClick: openDrawer('update'),
140
+ children: t('account.profile.editButton')
141
+ }),
142
+ /*#__PURE__*/ jsxs("div", {
143
+ className: classnames('muted', 'byline-account-meta', container_module.meta),
144
+ children: [
145
+ /*#__PURE__*/ jsxs("p", {
146
+ children: [
147
+ /*#__PURE__*/ jsxs("span", {
148
+ className: "font-bold",
149
+ children: [
150
+ t('account.profile.created'),
151
+ "\xa0"
152
+ ]
153
+ }),
154
+ /*#__PURE__*/ jsx(LocalDateTime, {
155
+ value: currentAccount.created_at
156
+ })
157
+ ]
158
+ }),
159
+ /*#__PURE__*/ jsxs("p", {
160
+ children: [
161
+ /*#__PURE__*/ jsxs("span", {
162
+ className: "font-bold",
163
+ children: [
164
+ t('account.profile.updated'),
165
+ "\xa0"
166
+ ]
167
+ }),
168
+ /*#__PURE__*/ jsx(LocalDateTime, {
169
+ value: currentAccount.updated_at
170
+ })
171
+ ]
172
+ }),
173
+ /*#__PURE__*/ jsxs("p", {
174
+ className: classnames('byline-account-line', container_module.line),
175
+ children: [
176
+ /*#__PURE__*/ jsxs("span", {
177
+ className: "font-bold",
178
+ children: [
179
+ t('account.profile.lastLogin'),
180
+ "\xa0"
181
+ ]
182
+ }),
183
+ /*#__PURE__*/ jsx(LocalDateTime, {
184
+ value: currentAccount.last_login,
185
+ fallback: t('common.never')
186
+ })
187
+ ]
188
+ })
189
+ ]
190
+ })
191
+ ]
192
+ }),
193
+ /*#__PURE__*/ jsxs(ContainerSection, {
194
+ title: t('account.sections.preferences'),
195
+ onEdit: openDrawer('preferences'),
196
+ editAriaLabel: editAriaFor(t('account.sections.preferences')),
197
+ children: [
198
+ /*#__PURE__*/ jsxs("p", {
199
+ className: classnames('byline-account-line', container_module.line),
200
+ children: [
201
+ /*#__PURE__*/ jsx("span", {
202
+ className: "muted",
203
+ children: t('account.preferences.interfaceLanguage')
204
+ }),
205
+ ' ',
206
+ currentAccount.preferred_locale ?? /*#__PURE__*/ jsx("span", {
207
+ className: classnames('muted', 'byline-account-not-set', container_module["not-set"]),
208
+ children: t('language.useBrowserDefault')
209
+ })
210
+ ]
211
+ }),
212
+ /*#__PURE__*/ jsx("p", {
213
+ className: classnames('byline-account-cta-line', container_module["cta-line"]),
214
+ children: /*#__PURE__*/ jsx(Button, {
215
+ size: "sm",
216
+ onClick: openDrawer('preferences'),
217
+ children: t('account.preferences.editButton')
172
218
  })
173
- ]
174
- })
175
- ]
176
- })
219
+ }),
220
+ /*#__PURE__*/ jsx("p", {
221
+ className: classnames('muted', 'byline-account-status-help', container_module["status-help"]),
222
+ children: t('account.preferences.help')
223
+ })
224
+ ]
225
+ })
226
+ ]
177
227
  }),
178
228
  /*#__PURE__*/ jsxs("div", {
179
229
  className: classnames('byline-account-column', container_module.column),
180
230
  children: [
181
231
  /*#__PURE__*/ jsxs(ContainerSection, {
182
- title: "Password",
232
+ title: t('account.sections.password'),
183
233
  onEdit: openDrawer('change_password'),
234
+ editAriaLabel: editAriaFor(t('account.sections.password')),
184
235
  children: [
185
236
  /*#__PURE__*/ jsx("p", {
186
237
  className: classnames('byline-account-cta-line', container_module["cta-line"]),
187
- children: "Change the password used to sign in to the admin. You'll need to enter your current password to confirm the change."
238
+ children: t('account.password.intro')
188
239
  }),
189
240
  /*#__PURE__*/ jsx(Button, {
190
241
  size: "sm",
191
242
  onClick: openDrawer('change_password'),
192
- children: "Change Password"
243
+ children: t('account.password.editButton')
193
244
  })
194
245
  ]
195
246
  }),
196
247
  /*#__PURE__*/ jsxs(ContainerSection, {
197
- title: "Account Status",
248
+ title: t('account.sections.status'),
198
249
  children: [
199
250
  /*#__PURE__*/ jsxs("p", {
200
251
  className: classnames('byline-account-line', container_module.line),
201
252
  children: [
202
253
  /*#__PURE__*/ jsx("span", {
203
254
  className: "muted",
204
- children: "Super admin:"
255
+ children: t('account.status.superAdmin')
205
256
  }),
206
257
  ' ',
207
- currentAccount.is_super_admin ? 'Yes' : 'No'
258
+ currentAccount.is_super_admin ? t('common.boolean.yes') : t('common.boolean.no')
208
259
  ]
209
260
  }),
210
261
  /*#__PURE__*/ jsxs("p", {
@@ -212,10 +263,10 @@ function AccountSelfContainer({ account }) {
212
263
  children: [
213
264
  /*#__PURE__*/ jsx("span", {
214
265
  className: "muted",
215
- children: "Email verified:"
266
+ children: t('account.status.emailVerified')
216
267
  }),
217
268
  ' ',
218
- currentAccount.is_email_verified ? 'Yes' : 'No'
269
+ currentAccount.is_email_verified ? t('common.boolean.yes') : t('common.boolean.no')
219
270
  ]
220
271
  }),
221
272
  /*#__PURE__*/ jsxs("p", {
@@ -223,18 +274,18 @@ function AccountSelfContainer({ account }) {
223
274
  children: [
224
275
  /*#__PURE__*/ jsx("span", {
225
276
  className: "muted",
226
- children: "Status:"
277
+ children: t('account.status.status')
227
278
  }),
228
279
  ' ',
229
280
  /*#__PURE__*/ jsx("span", {
230
281
  className: currentAccount.is_enabled ? classnames('byline-account-status-on', container_module["status-on"]) : classnames('byline-account-status-off', container_module["status-off"]),
231
- children: currentAccount.is_enabled ? 'Enabled' : 'Disabled'
282
+ children: currentAccount.is_enabled ? t('account.status.enabled') : t('account.status.disabled')
232
283
  })
233
284
  ]
234
285
  }),
235
286
  /*#__PURE__*/ jsx("p", {
236
287
  className: classnames('muted', 'byline-account-status-help', container_module["status-help"]),
237
- children: "These flags are managed by an admin with the appropriate permissions and are not self-editable."
288
+ children: t('account.status.help')
238
289
  })
239
290
  ]
240
291
  })
@@ -263,7 +314,7 @@ function AccountSelfContainer({ account }) {
263
314
  children: "no action"
264
315
  }),
265
316
  /*#__PURE__*/ jsx(IconButton, {
266
- "aria-label": "Close",
317
+ "aria-label": t('common.actions.close'),
267
318
  size: "sm",
268
319
  onClick: closeDrawer,
269
320
  children: /*#__PURE__*/ jsx(CloseIcon, {
@@ -276,7 +327,7 @@ function AccountSelfContainer({ account }) {
276
327
  }),
277
328
  /*#__PURE__*/ jsx(Drawer.Header, {
278
329
  children: /*#__PURE__*/ jsx("h2", {
279
- children: panels[current].title
330
+ children: panelTitles[current]
280
331
  })
281
332
  }),
282
333
  /*#__PURE__*/ jsx(Drawer.Content, {
@@ -0,0 +1,8 @@
1
+ import type { AccountResponse } from '../index.js';
2
+ interface PreferencesProps {
3
+ account: AccountResponse;
4
+ onClose?: () => void;
5
+ onSuccess?: (account: AccountResponse) => void;
6
+ }
7
+ export declare function Preferences({ account, onClose, onSuccess }: PreferencesProps): import("react").JSX.Element;
8
+ export {};
@@ -0,0 +1,152 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useMemo, useState } from "react";
4
+ import { revalidateLogic, useForm } from "@tanstack/react-form-start";
5
+ import { getClientConfig } from "@byline/core";
6
+ import { Alert, Button, LoaderEllipsis, Select } from "@byline/ui/react";
7
+ import classnames from "classnames";
8
+ import { z } from "zod";
9
+ import { useBylineAdminServices } from "../../../services/admin-services-context.js";
10
+ import preferences_module from "./preferences.module.js";
11
+ const AUTO_VALUE = '__auto__';
12
+ const preferencesSchema = z.object({
13
+ locale: z.string().min(1, {
14
+ message: 'Select a language'
15
+ })
16
+ });
17
+ function defaultsFrom(account) {
18
+ return {
19
+ locale: account.preferred_locale ?? AUTO_VALUE
20
+ };
21
+ }
22
+ function Preferences({ account, onClose, onSuccess }) {
23
+ const { setInterfaceLocale } = useBylineAdminServices();
24
+ const [formError, setFormError] = useState(null);
25
+ const [successMessage, setSuccessMessage] = useState(null);
26
+ const localeItems = useMemo(()=>{
27
+ const { i18n } = getClientConfig();
28
+ const definitionByCode = new Map((i18n.interface.localeDefinitions ?? []).map((d)=>[
29
+ d.code,
30
+ d.nativeName
31
+ ]));
32
+ const items = i18n.interface.locales.map((code)=>({
33
+ value: code,
34
+ label: definitionByCode.get(code) ?? code
35
+ }));
36
+ return [
37
+ {
38
+ value: AUTO_VALUE,
39
+ label: 'Use browser default'
40
+ },
41
+ ...items
42
+ ];
43
+ }, []);
44
+ const form = useForm({
45
+ defaultValues: defaultsFrom(account),
46
+ validationLogic: revalidateLogic({
47
+ mode: 'blur',
48
+ modeAfterSubmission: 'change'
49
+ }),
50
+ validators: {
51
+ onDynamic: preferencesSchema
52
+ },
53
+ onSubmit: async ({ value })=>{
54
+ setFormError(null);
55
+ setSuccessMessage(null);
56
+ const nextLocale = value.locale === AUTO_VALUE ? null : value.locale;
57
+ if (nextLocale === (account.preferred_locale ?? null)) return void setSuccessMessage('No changes to save.');
58
+ try {
59
+ const result = await setInterfaceLocale({
60
+ data: {
61
+ locale: nextLocale
62
+ }
63
+ });
64
+ if (null != result.account) {
65
+ setSuccessMessage('Saved.');
66
+ onSuccess?.(result.account);
67
+ } else setSuccessMessage('Saved.');
68
+ } catch {
69
+ setFormError('Could not save changes. Please try again.');
70
+ }
71
+ }
72
+ });
73
+ return /*#__PURE__*/ jsx("div", {
74
+ className: classnames('byline-account-preferences-wrap', preferences_module.wrap),
75
+ children: /*#__PURE__*/ jsxs("form", {
76
+ noValidate: true,
77
+ onSubmit: (event)=>{
78
+ event.preventDefault();
79
+ event.stopPropagation();
80
+ form.handleSubmit();
81
+ },
82
+ className: classnames('byline-account-preferences-form', preferences_module.form),
83
+ children: [
84
+ formError ? /*#__PURE__*/ jsx(Alert, {
85
+ intent: "danger",
86
+ children: formError
87
+ }) : null,
88
+ successMessage ? /*#__PURE__*/ jsx(Alert, {
89
+ intent: "success",
90
+ children: successMessage
91
+ }) : null,
92
+ /*#__PURE__*/ jsx(form.Field, {
93
+ name: "locale",
94
+ children: (field)=>/*#__PURE__*/ jsxs("div", {
95
+ className: classnames('byline-account-preferences-row', preferences_module.row),
96
+ children: [
97
+ /*#__PURE__*/ jsx("label", {
98
+ htmlFor: "preferences-locale-select",
99
+ className: classnames('byline-account-preferences-label', preferences_module.label),
100
+ children: "Interface language"
101
+ }),
102
+ /*#__PURE__*/ jsx(Select, {
103
+ id: "preferences-locale-select",
104
+ size: "sm",
105
+ ariaLabel: "Interface language",
106
+ value: field.state.value,
107
+ items: localeItems,
108
+ onValueChange: (value)=>{
109
+ if (null != value) field.handleChange(value);
110
+ }
111
+ }),
112
+ /*#__PURE__*/ jsx("p", {
113
+ className: classnames('muted', 'byline-account-preferences-help', preferences_module.help),
114
+ children: 'Choose "Use browser default" to let your browser\'s language settings decide.'
115
+ })
116
+ ]
117
+ })
118
+ }),
119
+ /*#__PURE__*/ jsxs("div", {
120
+ className: classnames('byline-account-preferences-actions', preferences_module.actions),
121
+ children: [
122
+ /*#__PURE__*/ jsx(Button, {
123
+ type: "button",
124
+ intent: "secondary",
125
+ size: "sm",
126
+ onClick: onClose,
127
+ className: classnames('byline-account-preferences-action', preferences_module.action),
128
+ children: successMessage ? 'Close' : 'Cancel'
129
+ }),
130
+ /*#__PURE__*/ jsx(form.Subscribe, {
131
+ selector: (state)=>({
132
+ canSubmit: state.canSubmit,
133
+ isSubmitting: state.isSubmitting
134
+ }),
135
+ children: ({ canSubmit, isSubmitting })=>/*#__PURE__*/ jsx(Button, {
136
+ size: "sm",
137
+ intent: "primary",
138
+ type: "submit",
139
+ disabled: !canSubmit || isSubmitting,
140
+ className: classnames('byline-account-preferences-action', preferences_module.action),
141
+ children: true === isSubmitting ? /*#__PURE__*/ jsx(LoaderEllipsis, {
142
+ size: 42
143
+ }) : 'Save'
144
+ })
145
+ })
146
+ ]
147
+ })
148
+ ]
149
+ })
150
+ });
151
+ }
152
+ export { Preferences };
@@ -0,0 +1,11 @@
1
+ import "./preferences_module.css";
2
+ const preferences_module = {
3
+ wrap: "wrap-Z0_u4U",
4
+ form: "form-vgAqtC",
5
+ row: "row-v7Li8f",
6
+ label: "label-Y07C1f",
7
+ help: "help-pf3pyB",
8
+ actions: "actions-cxaMe0",
9
+ action: "action-k1vCLN"
10
+ };
11
+ export default preferences_module;
@@ -0,0 +1,41 @@
1
+ :is(.wrap-Z0_u4U, .byline-account-preferences-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-vgAqtC, .byline-account-preferences-form) {
10
+ gap: var(--spacing-16);
11
+ padding-top: var(--spacing-8);
12
+ flex-direction: column;
13
+ display: flex;
14
+ }
15
+
16
+ :is(.row-v7Li8f, .byline-account-preferences-row) {
17
+ gap: var(--spacing-4);
18
+ flex-direction: column;
19
+ display: flex;
20
+ }
21
+
22
+ :is(.label-Y07C1f, .byline-account-preferences-label) {
23
+ font-weight: 500;
24
+ }
25
+
26
+ :is(.help-pf3pyB, .byline-account-preferences-help) {
27
+ font-size: .875rem;
28
+ }
29
+
30
+ :is(.actions-cxaMe0, .byline-account-preferences-actions) {
31
+ justify-content: flex-end;
32
+ align-items: center;
33
+ gap: var(--spacing-8);
34
+ margin-top: var(--spacing-16);
35
+ display: flex;
36
+ }
37
+
38
+ :is(.action-k1vCLN, .byline-account-preferences-action) {
39
+ min-width: 4rem;
40
+ }
41
+