@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
@@ -0,0 +1,6 @@
1
+ import "./checkbox-field_module.css";
2
+ const checkbox_field_module = {
3
+ "field-checkbox": "field-checkbox-H7UwUd",
4
+ fieldCheckbox: "field-checkbox-H7UwUd"
5
+ };
6
+ export default checkbox_field_module;
@@ -0,0 +1,4 @@
1
+ :is(.byline-field-checkbox, .field-checkbox-H7UwUd) {
2
+ margin: 0;
3
+ }
4
+
@@ -0,0 +1,20 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ import type { ColumnFormatter, FormatterProps } from '@byline/core';
9
+ /**
10
+ * Type guard: returns true when the formatter is a `{ component }` wrapper
11
+ * rather than a plain function.
12
+ */
13
+ export declare function isComponentFormatter<T>(fmt: ColumnFormatter<T>): fmt is {
14
+ component: (props: FormatterProps<T>) => any;
15
+ };
16
+ /**
17
+ * Render a cell value through its column formatter (if any).
18
+ * Handles both plain-function and `{ component }` formatters.
19
+ */
20
+ export declare function renderFormatted(value: any, document: any, formatter: ColumnFormatter): any;
@@ -0,0 +1,15 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ function isComponentFormatter(fmt) {
3
+ return 'object' == typeof fmt && null !== fmt && 'component' in fmt;
4
+ }
5
+ function renderFormatted(value, document, formatter) {
6
+ if (isComponentFormatter(formatter)) {
7
+ const Component = formatter.component;
8
+ return /*#__PURE__*/ jsx(Component, {
9
+ value: value,
10
+ record: document
11
+ });
12
+ }
13
+ return formatter(value, document);
14
+ }
15
+ export { isComponentFormatter, renderFormatted };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ import type { FormatterProps } from '@byline/core';
9
+ /**
10
+ * SSR-safe date-time column formatter for list views.
11
+ *
12
+ * Uses the `LocalDateTime` component which renders a placeholder on the server
13
+ * and formats to the user's locale/timezone after hydration, avoiding
14
+ * server/client mismatches.
15
+ */
16
+ export declare function DateTimeFormatter({ value }: FormatterProps): import("react").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { LocalDateTime } from "./local-date-time.js";
3
+ function DateTimeFormatter({ value }) {
4
+ return /*#__PURE__*/ jsx(LocalDateTime, {
5
+ value: value
6
+ });
7
+ }
8
+ export { DateTimeFormatter };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ import type { DateTimeField as FieldType } from '@byline/core';
9
+ export declare const DateTimeField: ({ field, value, defaultValue, onChange, id, path, }: {
10
+ field: FieldType;
11
+ value?: Date | null;
12
+ defaultValue?: Date | null;
13
+ onChange?: (value: Date | null) => void;
14
+ id?: string;
15
+ path?: string;
16
+ }) => import("react").JSX.Element;
@@ -0,0 +1,37 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { DatePicker, ErrorText } from "@byline/ui/react";
3
+ import classnames from "classnames";
4
+ import { useFieldError, useFieldValue, useIsDirty } from "../../forms/form-context.js";
5
+ import datetime_field_module from "./datetime-field.module.js";
6
+ const DateTimeField = ({ field, value, defaultValue, onChange, id, path })=>{
7
+ const fieldPath = path ?? field.name;
8
+ const fieldError = useFieldError(fieldPath);
9
+ const isDirty = useIsDirty(fieldPath);
10
+ const fieldValue = useFieldValue(fieldPath);
11
+ const incomingValue = value ?? fieldValue ?? defaultValue ?? null;
12
+ return /*#__PURE__*/ jsxs("div", {
13
+ className: `byline-field-datetime ${field.name}`,
14
+ children: [
15
+ /*#__PURE__*/ jsx(DatePicker, {
16
+ id: id ?? fieldPath,
17
+ name: field.name,
18
+ label: field.label,
19
+ required: !field.optional,
20
+ initialValue: incomingValue,
21
+ mode: field.mode || 'datetime',
22
+ yearsInFuture: field.yearsInFuture || 1,
23
+ yearsInPast: field.yearsInPast || 10,
24
+ onDateChange: (date)=>onChange?.(date),
25
+ className: classnames(isDirty && [
26
+ 'byline-field-datetime-dirty',
27
+ datetime_field_module.dirty
28
+ ])
29
+ }),
30
+ fieldError && /*#__PURE__*/ jsx(ErrorText, {
31
+ id: `${field.name}-error`,
32
+ text: fieldError
33
+ })
34
+ ]
35
+ });
36
+ };
37
+ export { DateTimeField };
@@ -0,0 +1,5 @@
1
+ import "./datetime-field_module.css";
2
+ const datetime_field_module = {
3
+ dirty: "dirty-cC4ARG"
4
+ };
5
+ export default datetime_field_module;
@@ -0,0 +1,4 @@
1
+ :is(.dirty-cC4ARG, .byline-field-datetime-dirty) {
2
+ border-color: var(--blue-300);
3
+ }
4
+
@@ -0,0 +1,6 @@
1
+ interface DraggableContextMenuProps {
2
+ onAddBelow?: () => void;
3
+ onRemove?: () => void;
4
+ }
5
+ export declare function DraggableContextMenu({ onAddBelow, onRemove, }: DraggableContextMenuProps): React.JSX.Element;
6
+ export {};
@@ -0,0 +1,85 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useTranslation } from "@byline/i18n/react";
4
+ import { DeleteIcon, Dropdown, EllipsisIcon, IconButton, PlusIcon } from "@byline/ui/react";
5
+ import classnames from "classnames";
6
+ import draggable_context_menu_module from "./draggable-context-menu.module.js";
7
+ function DraggableContextMenu({ onAddBelow, onRemove }) {
8
+ const { t } = useTranslation('byline-admin');
9
+ const itemClass = classnames('byline-draggable-menu-item', draggable_context_menu_module.item);
10
+ const rowClass = classnames('byline-draggable-menu-row', draggable_context_menu_module.row);
11
+ const iconSlotClass = classnames('byline-draggable-menu-icon-slot', draggable_context_menu_module["icon-slot"]);
12
+ const labelClass = classnames('byline-draggable-menu-label', draggable_context_menu_module.label);
13
+ return /*#__PURE__*/ jsxs(Dropdown.Root, {
14
+ modal: false,
15
+ children: [
16
+ /*#__PURE__*/ jsx(Dropdown.Trigger, {
17
+ render: /*#__PURE__*/ jsx(IconButton, {
18
+ variant: "text",
19
+ size: "sm"
20
+ }),
21
+ children: /*#__PURE__*/ jsx(EllipsisIcon, {
22
+ width: "16px",
23
+ height: "16px"
24
+ })
25
+ }),
26
+ /*#__PURE__*/ jsx(Dropdown.Portal, {
27
+ children: /*#__PURE__*/ jsxs(Dropdown.Content, {
28
+ align: "end",
29
+ sideOffset: 0,
30
+ className: classnames('byline-draggable-menu', draggable_context_menu_module.menu),
31
+ children: [
32
+ /*#__PURE__*/ jsx(Dropdown.Item, {
33
+ className: itemClass,
34
+ onClick: onAddBelow,
35
+ children: /*#__PURE__*/ jsxs("div", {
36
+ className: rowClass,
37
+ children: [
38
+ /*#__PURE__*/ jsx("span", {
39
+ className: iconSlotClass,
40
+ children: /*#__PURE__*/ jsx(PlusIcon, {
41
+ width: "18px",
42
+ height: "18px"
43
+ })
44
+ }),
45
+ /*#__PURE__*/ jsx("span", {
46
+ className: labelClass,
47
+ children: t('fields.draggableMenu.addBelow')
48
+ })
49
+ ]
50
+ })
51
+ }),
52
+ /*#__PURE__*/ jsx(Dropdown.Separator, {
53
+ className: classnames('byline-draggable-menu-separator', draggable_context_menu_module.separator)
54
+ }),
55
+ /*#__PURE__*/ jsx(Dropdown.Item, {
56
+ className: itemClass,
57
+ onClick: onRemove,
58
+ children: /*#__PURE__*/ jsx("div", {
59
+ className: rowClass,
60
+ children: /*#__PURE__*/ jsxs("div", {
61
+ className: rowClass,
62
+ children: [
63
+ /*#__PURE__*/ jsx("span", {
64
+ className: iconSlotClass,
65
+ children: /*#__PURE__*/ jsx(DeleteIcon, {
66
+ width: "18px",
67
+ height: "18px",
68
+ svgClassName: classnames('byline-draggable-menu-delete-icon', draggable_context_menu_module["delete-icon"])
69
+ })
70
+ }),
71
+ /*#__PURE__*/ jsx("span", {
72
+ className: classnames('byline-draggable-menu-label byline-draggable-menu-label-danger', draggable_context_menu_module.label, draggable_context_menu_module["label-danger"]),
73
+ children: t('fields.draggableMenu.remove')
74
+ })
75
+ ]
76
+ })
77
+ })
78
+ })
79
+ ]
80
+ })
81
+ })
82
+ ]
83
+ });
84
+ }
85
+ export { DraggableContextMenu };
@@ -0,0 +1,15 @@
1
+ import "./draggable-context-menu_module.css";
2
+ const draggable_context_menu_module = {
3
+ menu: "menu-AK92L8",
4
+ item: "item-cZy6je",
5
+ row: "row-IT7owe",
6
+ "icon-slot": "icon-slot-eFcN9X",
7
+ iconSlot: "icon-slot-eFcN9X",
8
+ label: "label-FpWNo3",
9
+ "label-danger": "label-danger-QfUDsA",
10
+ labelDanger: "label-danger-QfUDsA",
11
+ "delete-icon": "delete-icon-VR2oJo",
12
+ deleteIcon: "delete-icon-VR2oJo",
13
+ separator: "separator-wdzZsH"
14
+ };
15
+ export default draggable_context_menu_module;
@@ -0,0 +1,91 @@
1
+ :is(.menu-AK92L8, .byline-draggable-menu) {
2
+ z-index: 40;
3
+ border: var(--border-width-thin) var(--border-style-solid) var(--gray-200);
4
+ border-radius: var(--border-radius-sm);
5
+ background-color: #fff;
6
+ width: 8.5rem;
7
+ padding: .25rem .375rem;
8
+ box-shadow: 0 4px 6px -1px #0000001a, 0 2px 4px -2px #0000001a;
9
+ }
10
+
11
+ :is(.item-cZy6je, .byline-draggable-menu-item) {
12
+ border-radius: var(--border-radius-sm);
13
+ width: 100%;
14
+ color: var(--gray-600);
15
+ cursor: default;
16
+ -webkit-user-select: none;
17
+ user-select: none;
18
+ outline: none;
19
+ align-items: center;
20
+ gap: .25rem;
21
+ padding: 5px 2px;
22
+ display: flex;
23
+ }
24
+
25
+ @media (min-width: 48rem) {
26
+ :is(.item-cZy6je, .byline-draggable-menu-item) {
27
+ font-size: var(--font-size-sm);
28
+ }
29
+ }
30
+
31
+ :is(.item-cZy6je:hover, .item-cZy6je:focus, .byline-draggable-menu-item:hover, .byline-draggable-menu-item:focus) {
32
+ background-color: oklch(from var(--canvas-50) l c h / .3);
33
+ }
34
+
35
+ :is(.row-IT7owe, .byline-draggable-menu-row) {
36
+ align-items: center;
37
+ gap: .25rem;
38
+ width: 100%;
39
+ display: flex;
40
+ }
41
+
42
+ :is(.icon-slot-eFcN9X, .byline-draggable-menu-icon-slot) {
43
+ width: 22px;
44
+ display: inline-block;
45
+ }
46
+
47
+ :is(.label-FpWNo3, .byline-draggable-menu-label) {
48
+ text-align: left;
49
+ color: #000;
50
+ flex: 1;
51
+ align-self: flex-start;
52
+ width: 100%;
53
+ display: inline-block;
54
+ }
55
+
56
+ :is(.label-danger-QfUDsA, .byline-draggable-menu-label-danger) {
57
+ color: var(--red-600);
58
+ }
59
+
60
+ :is(.delete-icon-VR2oJo, .byline-draggable-menu-delete-icon) {
61
+ stroke: var(--red-600);
62
+ }
63
+
64
+ :is(.separator-wdzZsH, .byline-draggable-menu-separator) {
65
+ border: none;
66
+ border-top: var(--border-width-thin) var(--border-style-solid) var(--gray-200);
67
+ width: 90%;
68
+ margin: .25rem auto;
69
+ }
70
+
71
+ :is(:is([data-theme="dark"], .dark) .menu-AK92L8, :is([data-theme="dark"], .dark) .byline-draggable-menu) {
72
+ background-color: var(--canvas-800);
73
+ border-color: var(--canvas-700);
74
+ }
75
+
76
+ :is(:is([data-theme="dark"], .dark) .item-cZy6je, :is([data-theme="dark"], .dark) .byline-draggable-menu-item) {
77
+ color: var(--gray-300);
78
+ }
79
+
80
+ :is(:is([data-theme="dark"], .dark) .item-cZy6je:hover, :is([data-theme="dark"], .dark) .item-cZy6je:focus, :is([data-theme="dark"], .dark) .byline-draggable-menu-item:hover, :is([data-theme="dark"], .dark) .byline-draggable-menu-item:focus) {
81
+ background-color: var(--canvas-900);
82
+ }
83
+
84
+ :is(:is([data-theme="dark"], .dark) .label-FpWNo3, :is([data-theme="dark"], .dark) .byline-draggable-menu-label) {
85
+ color: var(--gray-300);
86
+ }
87
+
88
+ :is(:is([data-theme="dark"], .dark) .separator-wdzZsH, :is([data-theme="dark"], .dark) .byline-draggable-menu-separator) {
89
+ border-top-color: var(--gray-900);
90
+ }
91
+
@@ -0,0 +1,26 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ import type { Field } from '@byline/core';
9
+ export declare const placeholderStoredFileValue: {
10
+ fileId: `${string}-${string}-${string}-${string}-${string}`;
11
+ filename: string;
12
+ originalFilename: string;
13
+ mimeType: string;
14
+ fileSize: number;
15
+ storageProvider: string;
16
+ storagePath: string;
17
+ storageUrl: null;
18
+ fileHash: null;
19
+ imageWidth: null;
20
+ imageHeight: null;
21
+ imageFormat: null;
22
+ processingStatus: string;
23
+ thumbnailGenerated: boolean;
24
+ };
25
+ export declare const placeholderForField: (f: Field) => any;
26
+ export declare const defaultScalarForField: (f: Field, getFieldValues: () => Record<string, any>) => Promise<any>;
@@ -0,0 +1,50 @@
1
+ import { resolveFieldDefaultValue } from "@byline/core";
2
+ const placeholderStoredFileValue = {
3
+ fileId: crypto.randomUUID(),
4
+ filename: 'placeholder',
5
+ originalFilename: 'placeholder',
6
+ mimeType: 'application/octet-stream',
7
+ fileSize: 0,
8
+ storageProvider: 'placeholder',
9
+ storagePath: 'pending',
10
+ storageUrl: null,
11
+ fileHash: null,
12
+ imageWidth: null,
13
+ imageHeight: null,
14
+ imageFormat: null,
15
+ processingStatus: 'pending',
16
+ thumbnailGenerated: false
17
+ };
18
+ const placeholderForField = (f)=>{
19
+ switch(f.type){
20
+ case 'text':
21
+ case 'textArea':
22
+ return '';
23
+ case 'checkbox':
24
+ return false;
25
+ case 'integer':
26
+ return 0;
27
+ case 'counter':
28
+ return;
29
+ case 'richText':
30
+ case 'datetime':
31
+ return;
32
+ case 'select':
33
+ return '';
34
+ case 'file':
35
+ case 'image':
36
+ return placeholderStoredFileValue;
37
+ default:
38
+ return null;
39
+ }
40
+ };
41
+ const defaultScalarForField = async (f, getFieldValues)=>{
42
+ const schemaDefault = await resolveFieldDefaultValue(f, {
43
+ data: getFieldValues(),
44
+ now: ()=>new Date(),
45
+ uuid: ()=>crypto.randomUUID()
46
+ });
47
+ if (void 0 !== schemaDefault) return schemaDefault;
48
+ return placeholderForField(f);
49
+ };
50
+ export { defaultScalarForField, placeholderForField, placeholderStoredFileValue };
@@ -0,0 +1,37 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ import type { Field, FieldComponentSlots, RichTextEditorComponent } from '@byline/core';
9
+ interface FieldRendererProps {
10
+ field: Field;
11
+ defaultValue?: any;
12
+ basePath?: string;
13
+ disableSorting?: boolean;
14
+ hideLabel?: boolean;
15
+ /** Collection path (e.g. `'media'`) forwarded to upload-capable fields. */
16
+ collectionPath?: string;
17
+ /**
18
+ * The active content locale (e.g. `'en'`, `'fr'`). When provided and
19
+ * `field.localized === true`, a small locale badge is shown so the editor
20
+ * knows they are working on a localised field in the current language.
21
+ */
22
+ contentLocale?: string;
23
+ /**
24
+ * Optional UI component slot overrides from the admin config.
25
+ * Forwarded to value-field widgets that support custom slots.
26
+ */
27
+ components?: FieldComponentSlots;
28
+ /**
29
+ * Per-field rich-text editor component override from the admin config.
30
+ * Takes precedence over the globally registered
31
+ * `ClientConfig.fields.richText.editor` for this single field.
32
+ * Ignored when `field.type !== 'richText'`.
33
+ */
34
+ editor?: RichTextEditorComponent;
35
+ }
36
+ export declare const FieldRenderer: ({ field, defaultValue, basePath, disableSorting, hideLabel, collectionPath, contentLocale, components, editor, }: FieldRendererProps) => import("react").JSX.Element | null;
37
+ export {};
@@ -0,0 +1,206 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { getClientConfig } from "@byline/core";
3
+ import classnames from "classnames";
4
+ import { ArrayField } from "./array/array-field.js";
5
+ import { BlocksField } from "./blocks/blocks-field.js";
6
+ import { CheckboxField } from "./checkbox/checkbox-field.js";
7
+ import { DateTimeField } from "./datetime/datetime-field.js";
8
+ import field_renderer_module from "./field-renderer.module.js";
9
+ import { FileField } from "./file/file-field.js";
10
+ import { GroupField } from "./group/group-field.js";
11
+ import { ImageField } from "./image/image-field.js";
12
+ import { LocaleBadge } from "./locale-badge.js";
13
+ import { NumericalField } from "./numerical/numerical-field.js";
14
+ import { RelationField } from "./relation/relation-field.js";
15
+ import { SelectField } from "./select/select-field.js";
16
+ import { TextField } from "./text/text-field.js";
17
+ import { TextAreaField } from "./text-area/text-area-field.js";
18
+ import { useFieldChangeHandler } from "./use-field-change-handler.js";
19
+ const FieldRenderer = ({ field, defaultValue, basePath, disableSorting, hideLabel, collectionPath, contentLocale, components, editor })=>{
20
+ const path = basePath ? `${basePath}.${field.name}` : field.name;
21
+ const htmlId = path.replace(/[[\].]/g, '-');
22
+ const handleChange = useFieldChangeHandler(field, path);
23
+ const isLocalised = true === field.localized;
24
+ const badge = isLocalised && contentLocale && !hideLabel ? /*#__PURE__*/ jsx(LocaleBadge, {
25
+ locale: contentLocale
26
+ }) : null;
27
+ const renderField = ()=>{
28
+ switch(field.type){
29
+ case 'text':
30
+ return /*#__PURE__*/ jsx(TextField, {
31
+ field: hideLabel ? {
32
+ ...field,
33
+ label: void 0
34
+ } : field,
35
+ defaultValue: defaultValue,
36
+ onChange: handleChange,
37
+ path: path,
38
+ id: htmlId,
39
+ locale: isLocalised ? contentLocale : void 0,
40
+ components: components
41
+ });
42
+ case 'textArea':
43
+ return /*#__PURE__*/ jsx(TextAreaField, {
44
+ field: hideLabel ? {
45
+ ...field,
46
+ label: void 0
47
+ } : field,
48
+ defaultValue: defaultValue,
49
+ onChange: handleChange,
50
+ path: path,
51
+ id: htmlId,
52
+ locale: isLocalised ? contentLocale : void 0,
53
+ components: components
54
+ });
55
+ case 'checkbox':
56
+ return /*#__PURE__*/ jsx(CheckboxField, {
57
+ field: hideLabel ? {
58
+ ...field,
59
+ label: void 0
60
+ } : field,
61
+ defaultValue: defaultValue,
62
+ onChange: handleChange,
63
+ path: path,
64
+ id: htmlId
65
+ });
66
+ case 'select':
67
+ return /*#__PURE__*/ jsx(SelectField, {
68
+ field: hideLabel ? {
69
+ ...field,
70
+ label: void 0
71
+ } : field,
72
+ defaultValue: defaultValue,
73
+ onChange: handleChange,
74
+ path: path,
75
+ id: htmlId
76
+ });
77
+ case 'richText':
78
+ {
79
+ const RichTextEditor = editor ?? getClientConfig().fields?.richText?.editor;
80
+ if (!RichTextEditor) throw new Error("No richText editor registered. Install @byline/richtext-lexical and set `fields.richText.editor` in your admin config.");
81
+ return /*#__PURE__*/ jsx(RichTextEditor, {
82
+ field: hideLabel ? {
83
+ ...field,
84
+ label: void 0
85
+ } : field,
86
+ defaultValue: defaultValue,
87
+ onChange: handleChange,
88
+ path: path,
89
+ instanceKey: htmlId,
90
+ locale: isLocalised ? contentLocale : void 0
91
+ });
92
+ }
93
+ case 'datetime':
94
+ return /*#__PURE__*/ jsx(DateTimeField, {
95
+ field: hideLabel ? {
96
+ ...field,
97
+ label: void 0
98
+ } : field,
99
+ defaultValue: defaultValue,
100
+ onChange: handleChange,
101
+ path: path,
102
+ id: htmlId
103
+ });
104
+ case 'integer':
105
+ return /*#__PURE__*/ jsx(NumericalField, {
106
+ field: hideLabel ? {
107
+ ...field,
108
+ label: void 0
109
+ } : field,
110
+ defaultValue: defaultValue,
111
+ onChange: handleChange,
112
+ path: path,
113
+ id: htmlId,
114
+ components: components
115
+ });
116
+ case 'counter':
117
+ return /*#__PURE__*/ jsx(NumericalField, {
118
+ field: hideLabel ? {
119
+ ...field,
120
+ label: void 0,
121
+ readOnly: true
122
+ } : {
123
+ ...field,
124
+ readOnly: true
125
+ },
126
+ defaultValue: defaultValue,
127
+ onChange: handleChange,
128
+ path: path,
129
+ id: htmlId,
130
+ components: components
131
+ });
132
+ case 'file':
133
+ return /*#__PURE__*/ jsx(FileField, {
134
+ field: hideLabel ? {
135
+ ...field,
136
+ label: void 0
137
+ } : field,
138
+ defaultValue: defaultValue,
139
+ onChange: handleChange,
140
+ path: path,
141
+ collectionPath: collectionPath
142
+ });
143
+ case 'image':
144
+ return /*#__PURE__*/ jsx(ImageField, {
145
+ field: hideLabel ? {
146
+ ...field,
147
+ label: void 0
148
+ } : field,
149
+ defaultValue: defaultValue,
150
+ onChange: handleChange,
151
+ path: path,
152
+ collectionPath: collectionPath
153
+ });
154
+ case 'relation':
155
+ return /*#__PURE__*/ jsx(RelationField, {
156
+ field: hideLabel ? {
157
+ ...field,
158
+ label: void 0
159
+ } : field,
160
+ defaultValue: defaultValue,
161
+ onChange: handleChange,
162
+ path: path,
163
+ id: htmlId
164
+ });
165
+ case 'group':
166
+ return /*#__PURE__*/ jsx(GroupField, {
167
+ field: hideLabel ? {
168
+ ...field,
169
+ label: void 0
170
+ } : field,
171
+ defaultValue: defaultValue,
172
+ path: path
173
+ });
174
+ case 'blocks':
175
+ if (!field.blocks) return null;
176
+ return /*#__PURE__*/ jsx(BlocksField, {
177
+ field: field,
178
+ defaultValue: defaultValue,
179
+ path: path
180
+ });
181
+ case 'array':
182
+ if (!field.fields) return null;
183
+ return /*#__PURE__*/ jsx(ArrayField, {
184
+ field: field,
185
+ defaultValue: defaultValue,
186
+ path: path,
187
+ disableSorting: disableSorting
188
+ });
189
+ default:
190
+ return null;
191
+ }
192
+ };
193
+ const selfBadge = 'text' === field.type || 'textArea' === field.type || 'richText' === field.type;
194
+ if (badge && !selfBadge) return /*#__PURE__*/ jsxs("div", {
195
+ className: classnames('byline-field-localized-wrap', field_renderer_module["localized-wrap"]),
196
+ children: [
197
+ renderField(),
198
+ /*#__PURE__*/ jsx("span", {
199
+ className: classnames('byline-field-localized-badge', field_renderer_module["localized-badge"]),
200
+ children: badge
201
+ })
202
+ ]
203
+ });
204
+ return renderField();
205
+ };
206
+ export { FieldRenderer };