@byline/ui 2.5.2 → 2.6.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 (218) hide show
  1. package/dist/components/shimmer/shimmer.d.ts +13 -1
  2. package/dist/components/shimmer/shimmer.js +29 -20
  3. package/dist/components/shimmer/shimmer_module.css +4 -4
  4. package/dist/dnd/draggable-sortable/demo/draggable-list-demo.js +1 -1
  5. package/dist/react.d.ts +18 -54
  6. package/dist/react.js +0 -35
  7. package/dist/styles/styles.css +3 -0
  8. package/dist/uikit.d.ts +1 -0
  9. package/dist/uikit.js +1 -0
  10. package/package.json +2 -8
  11. package/src/components/shimmer/shimmer.module.css +8 -4
  12. package/src/components/shimmer/shimmer.tsx +34 -9
  13. package/src/dnd/draggable-sortable/demo/draggable-list-demo.tsx +1 -1
  14. package/src/react.ts +20 -68
  15. package/src/styles/functional/surfaces.css +13 -1
  16. package/src/uikit.ts +1 -0
  17. package/dist/admin/group.d.ts +0 -27
  18. package/dist/admin/group.js +0 -14
  19. package/dist/admin/group.module.js +0 -6
  20. package/dist/admin/group_module.css +0 -19
  21. package/dist/admin/row.d.ts +0 -25
  22. package/dist/admin/row.js +0 -8
  23. package/dist/admin/row.module.js +0 -5
  24. package/dist/admin/row_module.css +0 -18
  25. package/dist/admin/tabs.d.ts +0 -25
  26. package/dist/admin/tabs.js +0 -35
  27. package/dist/admin/tabs.module.js +0 -10
  28. package/dist/admin/tabs_module.css +0 -68
  29. package/dist/fields/array/array-field.d.ts +0 -14
  30. package/dist/fields/array/array-field.js +0 -176
  31. package/dist/fields/array/array-field.module.js +0 -11
  32. package/dist/fields/array/array-field_module.css +0 -32
  33. package/dist/fields/blocks/blocks-field.d.ts +0 -13
  34. package/dist/fields/blocks/blocks-field.js +0 -244
  35. package/dist/fields/blocks/blocks-field.module.js +0 -26
  36. package/dist/fields/blocks/blocks-field_module.css +0 -107
  37. package/dist/fields/checkbox/checkbox-field.d.ts +0 -16
  38. package/dist/fields/checkbox/checkbox-field.js +0 -28
  39. package/dist/fields/checkbox/checkbox-field.module.js +0 -6
  40. package/dist/fields/checkbox/checkbox-field_module.css +0 -4
  41. package/dist/fields/column-formatter.d.ts +0 -20
  42. package/dist/fields/column-formatter.js +0 -15
  43. package/dist/fields/date-time-formatter.d.ts +0 -16
  44. package/dist/fields/date-time-formatter.js +0 -8
  45. package/dist/fields/datetime/datetime-field.d.ts +0 -16
  46. package/dist/fields/datetime/datetime-field.js +0 -37
  47. package/dist/fields/datetime/datetime-field.module.js +0 -5
  48. package/dist/fields/datetime/datetime-field_module.css +0 -4
  49. package/dist/fields/draggable-context-menu.d.ts +0 -6
  50. package/dist/fields/draggable-context-menu.js +0 -83
  51. package/dist/fields/draggable-context-menu.module.js +0 -15
  52. package/dist/fields/draggable-context-menu_module.css +0 -91
  53. package/dist/fields/field-helpers.d.ts +0 -26
  54. package/dist/fields/field-helpers.js +0 -50
  55. package/dist/fields/field-renderer.d.ts +0 -37
  56. package/dist/fields/field-renderer.js +0 -206
  57. package/dist/fields/field-renderer.module.js +0 -8
  58. package/dist/fields/field-renderer_module.css +0 -11
  59. package/dist/fields/file/file-field.d.ts +0 -19
  60. package/dist/fields/file/file-field.js +0 -226
  61. package/dist/fields/file/file-field.module.js +0 -18
  62. package/dist/fields/file/file-field_module.css +0 -131
  63. package/dist/fields/file/file-upload-field.d.ts +0 -21
  64. package/dist/fields/file/file-upload-field.js +0 -128
  65. package/dist/fields/file/file-upload-field.module.js +0 -15
  66. package/dist/fields/file/file-upload-field_module.css +0 -74
  67. package/dist/fields/group/group-field.d.ts +0 -15
  68. package/dist/fields/group/group-field.js +0 -59
  69. package/dist/fields/group/group-field.module.js +0 -9
  70. package/dist/fields/group/group-field_module.css +0 -27
  71. package/dist/fields/image/image-field.d.ts +0 -19
  72. package/dist/fields/image/image-field.js +0 -242
  73. package/dist/fields/image/image-field.module.js +0 -22
  74. package/dist/fields/image/image-field_module.css +0 -121
  75. package/dist/fields/image/image-upload-field.d.ts +0 -21
  76. package/dist/fields/image/image-upload-field.js +0 -187
  77. package/dist/fields/image/image-upload-field.module.js +0 -19
  78. package/dist/fields/image/image-upload-field_module.css +0 -92
  79. package/dist/fields/local-date-time.d.ts +0 -27
  80. package/dist/fields/local-date-time.js +0 -49
  81. package/dist/fields/locale-badge.d.ts +0 -18
  82. package/dist/fields/locale-badge.js +0 -10
  83. package/dist/fields/locale-badge.module.js +0 -5
  84. package/dist/fields/locale-badge_module.css +0 -27
  85. package/dist/fields/numerical/numerical-field.d.ts +0 -18
  86. package/dist/fields/numerical/numerical-field.js +0 -74
  87. package/dist/fields/relation/relation-display.d.ts +0 -40
  88. package/dist/fields/relation/relation-display.js +0 -58
  89. package/dist/fields/relation/relation-display.module.js +0 -9
  90. package/dist/fields/relation/relation-display_module.css +0 -21
  91. package/dist/fields/relation/relation-field.d.ts +0 -18
  92. package/dist/fields/relation/relation-field.js +0 -146
  93. package/dist/fields/relation/relation-field.module.js +0 -13
  94. package/dist/fields/relation/relation-field_module.css +0 -62
  95. package/dist/fields/relation/relation-picker.d.ts +0 -49
  96. package/dist/fields/relation/relation-picker.js +0 -233
  97. package/dist/fields/relation/relation-picker.module.js +0 -26
  98. package/dist/fields/relation/relation-picker_module.css +0 -124
  99. package/dist/fields/relation/relation-summary.d.ts +0 -31
  100. package/dist/fields/relation/relation-summary.js +0 -50
  101. package/dist/fields/relation/relation-summary.module.js +0 -11
  102. package/dist/fields/relation/relation-summary_module.css +0 -37
  103. package/dist/fields/select/select-field.d.ts +0 -16
  104. package/dist/fields/select/select-field.js +0 -50
  105. package/dist/fields/select/select-field.module.js +0 -5
  106. package/dist/fields/select/select-field_module.css +0 -4
  107. package/dist/fields/sortable-item.d.ts +0 -15
  108. package/dist/fields/sortable-item.js +0 -80
  109. package/dist/fields/sortable-item.module.js +0 -22
  110. package/dist/fields/sortable-item_module.css +0 -124
  111. package/dist/fields/text/text-field.d.ts +0 -20
  112. package/dist/fields/text/text-field.js +0 -104
  113. package/dist/fields/text/text-field.module.js +0 -6
  114. package/dist/fields/text/text-field_module.css +0 -5
  115. package/dist/fields/text-area/text-area-field.d.ts +0 -20
  116. package/dist/fields/text-area/text-area-field.js +0 -105
  117. package/dist/fields/text-area/text-area-field.module.js +0 -6
  118. package/dist/fields/text-area/text-area-field_module.css +0 -5
  119. package/dist/fields/use-field-change-handler.d.ts +0 -23
  120. package/dist/fields/use-field-change-handler.js +0 -52
  121. package/dist/forms/document-actions.d.ts +0 -48
  122. package/dist/forms/document-actions.js +0 -469
  123. package/dist/forms/document-actions.module.js +0 -34
  124. package/dist/forms/document-actions_module.css +0 -118
  125. package/dist/forms/form-context.d.ts +0 -89
  126. package/dist/forms/form-context.js +0 -466
  127. package/dist/forms/form-renderer.d.ts +0 -98
  128. package/dist/forms/form-renderer.js +0 -591
  129. package/dist/forms/form-renderer.module.js +0 -46
  130. package/dist/forms/form-renderer_module.css +0 -245
  131. package/dist/forms/navigation-guard.d.ts +0 -54
  132. package/dist/forms/navigation-guard.js +0 -22
  133. package/dist/forms/path-widget.d.ts +0 -36
  134. package/dist/forms/path-widget.js +0 -107
  135. package/dist/forms/path-widget.module.js +0 -8
  136. package/dist/forms/path-widget_module.css +0 -29
  137. package/dist/forms/upload-executor.d.ts +0 -57
  138. package/dist/forms/upload-executor.js +0 -92
  139. package/dist/services/field-services-context.d.ts +0 -16
  140. package/dist/services/field-services-context.js +0 -13
  141. package/dist/services/field-services-types.d.ts +0 -63
  142. package/dist/services/field-services-types.js +0 -1
  143. package/dist/widgets/diff-viewer/diff-modal.d.ts +0 -22
  144. package/dist/widgets/diff-viewer/diff-modal.js +0 -146
  145. package/dist/widgets/diff-viewer/diff-modal.module.js +0 -14
  146. package/dist/widgets/diff-viewer/diff-modal_module.css +0 -56
  147. package/dist/widgets/status-badge/status-badge.d.ts +0 -25
  148. package/dist/widgets/status-badge/status-badge.js +0 -35
  149. package/dist/widgets/status-badge/status-badge.module.js +0 -7
  150. package/dist/widgets/status-badge/status-badge_module.css +0 -20
  151. package/src/admin/group.module.css +0 -41
  152. package/src/admin/group.tsx +0 -40
  153. package/src/admin/row.module.css +0 -32
  154. package/src/admin/row.tsx +0 -33
  155. package/src/admin/tabs.module.css +0 -107
  156. package/src/admin/tabs.tsx +0 -82
  157. package/src/fields/array/array-field.module.css +0 -48
  158. package/src/fields/array/array-field.tsx +0 -266
  159. package/src/fields/blocks/blocks-field.module.css +0 -148
  160. package/src/fields/blocks/blocks-field.tsx +0 -312
  161. package/src/fields/checkbox/checkbox-field.module.css +0 -4
  162. package/src/fields/checkbox/checkbox-field.tsx +0 -54
  163. package/src/fields/column-formatter.tsx +0 -31
  164. package/src/fields/date-time-formatter.tsx +0 -22
  165. package/src/fields/datetime/datetime-field.module.css +0 -13
  166. package/src/fields/datetime/datetime-field.tsx +0 -54
  167. package/src/fields/draggable-context-menu.module.css +0 -127
  168. package/src/fields/draggable-context-menu.tsx +0 -85
  169. package/src/fields/field-helpers.ts +0 -69
  170. package/src/fields/field-renderer.module.css +0 -22
  171. package/src/fields/field-renderer.tsx +0 -288
  172. package/src/fields/file/file-field.module.css +0 -153
  173. package/src/fields/file/file-field.tsx +0 -271
  174. package/src/fields/file/file-upload-field.module.css +0 -101
  175. package/src/fields/file/file-upload-field.tsx +0 -183
  176. package/src/fields/group/group-field.module.css +0 -43
  177. package/src/fields/group/group-field.tsx +0 -84
  178. package/src/fields/image/image-field.module.css +0 -155
  179. package/src/fields/image/image-field.tsx +0 -291
  180. package/src/fields/image/image-upload-field.module.css +0 -123
  181. package/src/fields/image/image-upload-field.tsx +0 -270
  182. package/src/fields/local-date-time.tsx +0 -88
  183. package/src/fields/locale-badge.module.css +0 -37
  184. package/src/fields/locale-badge.tsx +0 -32
  185. package/src/fields/numerical/numerical-field.tsx +0 -114
  186. package/src/fields/relation/relation-display.module.css +0 -36
  187. package/src/fields/relation/relation-display.tsx +0 -130
  188. package/src/fields/relation/relation-field.module.css +0 -83
  189. package/src/fields/relation/relation-field.tsx +0 -206
  190. package/src/fields/relation/relation-picker.module.css +0 -168
  191. package/src/fields/relation/relation-picker.tsx +0 -325
  192. package/src/fields/relation/relation-summary.module.css +0 -55
  193. package/src/fields/relation/relation-summary.tsx +0 -123
  194. package/src/fields/select/select-field.module.css +0 -13
  195. package/src/fields/select/select-field.tsx +0 -61
  196. package/src/fields/sortable-item.module.css +0 -167
  197. package/src/fields/sortable-item.tsx +0 -101
  198. package/src/fields/text/text-field.module.css +0 -13
  199. package/src/fields/text/text-field.tsx +0 -146
  200. package/src/fields/text-area/text-area-field.module.css +0 -13
  201. package/src/fields/text-area/text-area-field.tsx +0 -147
  202. package/src/fields/use-field-change-handler.ts +0 -112
  203. package/src/forms/document-actions.module.css +0 -160
  204. package/src/forms/document-actions.tsx +0 -487
  205. package/src/forms/form-context.tsx +0 -704
  206. package/src/forms/form-renderer.module.css +0 -321
  207. package/src/forms/form-renderer.tsx +0 -888
  208. package/src/forms/navigation-guard.tsx +0 -98
  209. package/src/forms/path-widget.module.css +0 -41
  210. package/src/forms/path-widget.test.tsx +0 -217
  211. package/src/forms/path-widget.tsx +0 -181
  212. package/src/forms/upload-executor.ts +0 -190
  213. package/src/services/field-services-context.tsx +0 -35
  214. package/src/services/field-services-types.ts +0 -68
  215. package/src/widgets/diff-viewer/diff-modal.module.css +0 -79
  216. package/src/widgets/diff-viewer/diff-modal.tsx +0 -184
  217. package/src/widgets/status-badge/status-badge.module.css +0 -31
  218. package/src/widgets/status-badge/status-badge.tsx +0 -69
@@ -1,14 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import classnames from "classnames";
3
- import group_module from "./group.module.js";
4
- const AdminGroup = ({ label, children, className })=>/*#__PURE__*/ jsxs("fieldset", {
5
- className: classnames('byline-admin-group', group_module.group, className),
6
- children: [
7
- label && /*#__PURE__*/ jsx("legend", {
8
- className: classnames('byline-admin-group-legend', group_module.legend),
9
- children: label
10
- }),
11
- children
12
- ]
13
- });
14
- export { AdminGroup };
@@ -1,6 +0,0 @@
1
- import "./group_module.css";
2
- const group_module = {
3
- group: "group-pmMFT_",
4
- legend: "legend-oOuePJ"
5
- };
6
- export default group_module;
@@ -1,19 +0,0 @@
1
- :is(.group-pmMFT_, .byline-admin-group) {
2
- gap: var(--spacing-16);
3
- padding: var(--spacing-12);
4
- border: var(--border-width-thin) var(--border-style-solid) var(--gray-200);
5
- border-radius: var(--border-radius-md);
6
- flex-direction: column;
7
- display: flex;
8
- }
9
-
10
- :is(.legend-oOuePJ, .byline-admin-group-legend) {
11
- padding-inline: var(--spacing-4);
12
- font-size: var(--font-size-sm);
13
- font-weight: var(--font-weight-medium);
14
- }
15
-
16
- :is(:is([data-theme="dark"], .dark) .group-pmMFT_, :is([data-theme="dark"], .dark) .byline-admin-group) {
17
- border-color: var(--gray-700);
18
- }
19
-
@@ -1,25 +0,0 @@
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 { ReactNode } from 'react';
9
- interface AdminRowProps {
10
- children: ReactNode;
11
- className?: string;
12
- }
13
- /**
14
- * Horizontal flex-row layout for admin form fields.
15
- *
16
- * Used by `FormRenderer` when a `CollectionAdminConfig` declares a `rows`
17
- * primitive. Members are rendered side-by-side above the `sm` breakpoint
18
- * and stack vertically below it. `flex-1` + `min-width: 0` lets two text
19
- * inputs share the row evenly without overflowing.
20
- *
21
- * The element carries `.byline-admin-row` as a stable global class for
22
- * host overrides (alongside the hashed CSS-modules local).
23
- */
24
- export declare const AdminRow: ({ children, className }: AdminRowProps) => import("react").JSX.Element;
25
- export {};
package/dist/admin/row.js DELETED
@@ -1,8 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import classnames from "classnames";
3
- import row_module from "./row.module.js";
4
- const AdminRow = ({ children, className })=>/*#__PURE__*/ jsx("div", {
5
- className: classnames('byline-admin-row', row_module.row, className),
6
- children: children
7
- });
8
- export { AdminRow };
@@ -1,5 +0,0 @@
1
- import "./row_module.css";
2
- const row_module = {
3
- row: "row-Sq48i8"
4
- };
5
- export default row_module;
@@ -1,18 +0,0 @@
1
- :is(.row-Sq48i8, .byline-admin-row) {
2
- align-items: flex-start;
3
- gap: var(--spacing-16);
4
- flex-direction: column;
5
- display: flex;
6
- }
7
-
8
- :is(.row-Sq48i8 > *, .byline-admin-row > *) {
9
- flex: 1;
10
- min-width: 0;
11
- }
12
-
13
- @media (min-width: 40rem) {
14
- :is(.row-Sq48i8, .byline-admin-row) {
15
- flex-direction: row;
16
- }
17
- }
18
-
@@ -1,25 +0,0 @@
1
- export interface AdminTabItem {
2
- name: string;
3
- label: string;
4
- }
5
- interface AdminTabsProps {
6
- tabs: AdminTabItem[];
7
- activeTab: string;
8
- onChange: (name: string) => void;
9
- /** Error counts keyed by tab name — shows a danger badge when > 0. */
10
- errorCounts?: Record<string, number>;
11
- className?: string;
12
- }
13
- /**
14
- * Tabs navigation bar for admin form layouts.
15
- *
16
- * Used by FormRenderer when a CollectionAdminConfig declares a `tabs` array.
17
- * Each tab is a simple button with a bottom-border active indicator.
18
- * Inactive tabs show a subtle hover state. Fully dark-mode aware.
19
- *
20
- * Stable override handles: `.byline-admin-tabs`, `.byline-admin-tab`,
21
- * `.byline-admin-tab-active`, `.byline-admin-tab-label`,
22
- * `.byline-admin-tab-badge`.
23
- */
24
- export declare const AdminTabs: ({ tabs, activeTab, onChange, errorCounts, className, }: AdminTabsProps) => import("react").JSX.Element;
25
- export {};
@@ -1,35 +0,0 @@
1
- "use client";
2
- import { jsx, jsxs } from "react/jsx-runtime";
3
- import classnames from "classnames";
4
- import { Badge } from "../uikit.js";
5
- import tabs_module from "./tabs.module.js";
6
- const AdminTabs = ({ tabs, activeTab, onChange, errorCounts, className })=>/*#__PURE__*/ jsx("div", {
7
- role: "tablist",
8
- "aria-label": "Form tabs",
9
- className: classnames('byline-admin-tabs', tabs_module.tabs, className),
10
- children: tabs.map((tab)=>{
11
- const isActive = tab.name === activeTab;
12
- return /*#__PURE__*/ jsx("button", {
13
- type: "button",
14
- role: "tab",
15
- "aria-selected": isActive,
16
- onClick: ()=>onChange(tab.name),
17
- className: classnames('byline-admin-tab', tabs_module.tab, isActive && [
18
- 'byline-admin-tab-active',
19
- tabs_module["tab-active"]
20
- ]),
21
- children: /*#__PURE__*/ jsxs("span", {
22
- className: classnames('byline-admin-tab-label', tabs_module.label),
23
- children: [
24
- tab.label,
25
- (errorCounts?.[tab.name] ?? 0) > 0 && /*#__PURE__*/ jsx(Badge, {
26
- intent: "danger",
27
- className: classnames('byline-admin-tab-badge', tabs_module.badge),
28
- children: errorCounts?.[tab.name]
29
- })
30
- ]
31
- })
32
- }, tab.name);
33
- })
34
- });
35
- export { AdminTabs };
@@ -1,10 +0,0 @@
1
- import "./tabs_module.css";
2
- const tabs_module = {
3
- tabs: "tabs-j6CvRO",
4
- tab: "tab-BdAWTm",
5
- "tab-active": "tab-active-bc05XN",
6
- tabActive: "tab-active-bc05XN",
7
- label: "label-Tdf1rn",
8
- badge: "badge-Pq1O6d"
9
- };
10
- export default tabs_module;
@@ -1,68 +0,0 @@
1
- :is(.tabs-j6CvRO, .byline-admin-tabs) {
2
- gap: var(--spacing-16);
3
- border-bottom: var(--border-width-thin) var(--border-style-solid) var(--gray-200);
4
- display: flex;
5
- }
6
-
7
- :is(.tab-BdAWTm, .byline-admin-tab) {
8
- color: var(--gray-500);
9
- font-size: 1.1rem;
10
- font-weight: var(--font-weight-medium);
11
- cursor: pointer;
12
- background: none;
13
- border-bottom: 2px solid #0000;
14
- outline: none;
15
- margin-bottom: -1px;
16
- padding: .625rem 0;
17
- transition: color .15s, border-color .15s;
18
- position: relative;
19
- }
20
-
21
- :is(.tab-BdAWTm:hover, .byline-admin-tab:hover) {
22
- color: var(--gray-800);
23
- border-bottom-color: var(--gray-300);
24
- }
25
-
26
- :is(.tab-BdAWTm:focus-visible, .byline-admin-tab:focus-visible) {
27
- box-shadow: 0 0 0 2px var(--blue-500);
28
- }
29
-
30
- :is(.tab-active-bc05XN, .byline-admin-tab-active), :is(.tab-active-bc05XN:hover, .byline-admin-tab-active:hover) {
31
- color: var(--primary-600);
32
- border-bottom-color: var(--primary-400);
33
- }
34
-
35
- :is(.label-Tdf1rn, .byline-admin-tab-label) {
36
- align-items: center;
37
- gap: .375rem;
38
- display: flex;
39
- }
40
-
41
- :is(.badge-Pq1O6d, .byline-admin-tab-badge) {
42
- justify-content: center;
43
- align-items: center;
44
- min-width: 1.25rem;
45
- height: 1.25rem;
46
- padding: 0 .375rem;
47
- font-size: .7rem;
48
- display: flex;
49
- }
50
-
51
- :is(:is([data-theme="dark"], .dark) .tabs-j6CvRO, :is([data-theme="dark"], .dark) .byline-admin-tabs) {
52
- border-bottom-color: var(--gray-700);
53
- }
54
-
55
- :is(:is([data-theme="dark"], .dark) .tab-BdAWTm, :is([data-theme="dark"], .dark) .byline-admin-tab) {
56
- color: var(--gray-400);
57
- }
58
-
59
- :is(:is([data-theme="dark"], .dark) .tab-BdAWTm:hover, :is([data-theme="dark"], .dark) .byline-admin-tab:hover) {
60
- color: var(--gray-200);
61
- border-bottom-color: var(--gray-600);
62
- }
63
-
64
- :is(:is([data-theme="dark"], .dark) .tab-active-bc05XN, :is([data-theme="dark"], .dark) .byline-admin-tab-active), :is(:is([data-theme="dark"], .dark) .tab-active-bc05XN:hover, :is([data-theme="dark"], .dark) .byline-admin-tab-active:hover) {
65
- color: var(--primary-200);
66
- border-bottom-color: var(--primary-400);
67
- }
68
-
@@ -1,14 +0,0 @@
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 { ArrayField as ArrayFieldType } from '@byline/core';
9
- export declare const ArrayField: ({ field, defaultValue, path, disableSorting, }: {
10
- field: ArrayFieldType;
11
- defaultValue: any;
12
- path: string;
13
- disableSorting?: boolean;
14
- }) => import("react").JSX.Element;
@@ -1,176 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useEffect, useState } from "react";
3
- import classnames from "classnames";
4
- import { DraggableSortable, moveItem } from "../../dnd/draggable-sortable/index.js";
5
- import { defaultScalarForField } from "../field-helpers.js";
6
- import { FieldRenderer } from "../field-renderer.js";
7
- import { SortableItem } from "../sortable-item.js";
8
- import { useFormContext } from "../../forms/form-context.js";
9
- import { IconButton, PlusIcon } from "../../uikit.js";
10
- import array_field_module from "./array-field.module.js";
11
- const ArrayField = ({ field, defaultValue, path, disableSorting = false })=>{
12
- const { appendPatch, getFieldValue, getFieldValues, setFieldStore } = useFormContext();
13
- const [items, setItems] = useState([]);
14
- useEffect(()=>{
15
- Array.isArray(defaultValue) ? setItems(defaultValue.map((item)=>({
16
- id: item && 'object' == typeof item && 'id' in item ? String(item.id) : item && 'object' == typeof item && '_id' in item ? String(item._id) : crypto.randomUUID(),
17
- data: item
18
- }))) : setItems([]);
19
- }, [
20
- defaultValue
21
- ]);
22
- const handleDragEnd = ({ moveFromIndex, moveToIndex })=>{
23
- setItems((prev)=>moveItem(prev, moveFromIndex, moveToIndex));
24
- const currentArray = getFieldValue(path) ?? defaultValue;
25
- if (Array.isArray(currentArray)) {
26
- const clampedFrom = Math.max(0, Math.min(moveFromIndex, currentArray.length - 1));
27
- const clampedTo = Math.max(0, Math.min(moveToIndex, currentArray.length - 1));
28
- if (clampedFrom === clampedTo) return;
29
- const item = currentArray[clampedFrom];
30
- const itemId = item && 'object' == typeof item && 'id' in item ? String(item.id) : String(clampedFrom);
31
- appendPatch({
32
- kind: 'array.move',
33
- path: path,
34
- itemId,
35
- toIndex: clampedTo
36
- });
37
- }
38
- };
39
- const handleAddItem = async (atIndex)=>{
40
- const childFields = field.fields ?? [];
41
- if (0 === childFields.length) return;
42
- const newId = crypto.randomUUID();
43
- const newItem = {};
44
- for (const childField of childFields)if ('group' === childField.type && childField.fields && childField.fields.length > 0) {
45
- const groupObj = {};
46
- for (const innerField of childField.fields)groupObj[innerField.name] = await defaultScalarForField(innerField, getFieldValues);
47
- newItem[childField.name] = groupObj;
48
- } else newItem[childField.name] = await defaultScalarForField(childField, getFieldValues);
49
- const currentArray = getFieldValue(path) ?? defaultValue;
50
- const insertAt = null != atIndex ? atIndex : currentArray ? currentArray.length : 0;
51
- const newItemWrapper = {
52
- id: newId,
53
- data: newItem
54
- };
55
- setItems((prev)=>{
56
- const next = [
57
- ...prev
58
- ];
59
- next.splice(insertAt, 0, newItemWrapper);
60
- return next;
61
- });
62
- appendPatch({
63
- kind: 'array.insert',
64
- path: path,
65
- index: insertAt,
66
- item: newItem
67
- });
68
- const newArrayValue = currentArray ? [
69
- ...currentArray
70
- ] : [];
71
- newArrayValue.splice(insertAt, 0, newItem);
72
- setFieldStore(path, newArrayValue);
73
- };
74
- const handleRemoveItem = (index)=>{
75
- const currentArray = getFieldValue(path) ?? defaultValue;
76
- if (!Array.isArray(currentArray) || index < 0 || index >= currentArray.length) return;
77
- const item = currentArray[index];
78
- const itemId = item && 'object' == typeof item && 'id' in item ? String(item.id) : String(index);
79
- setItems((prev)=>prev.filter((_, i)=>i !== index));
80
- appendPatch({
81
- kind: 'array.remove',
82
- path: path,
83
- itemId
84
- });
85
- const newArrayValue = [
86
- ...currentArray
87
- ];
88
- newArrayValue.splice(index, 1);
89
- setFieldStore(path, newArrayValue);
90
- };
91
- const handleInsertBelow = (index)=>{
92
- handleAddItem(index + 1);
93
- };
94
- const renderItem = (itemWrapper, index)=>{
95
- const item = itemWrapper.data;
96
- const arrayElementPath = `${path}[${index}]`;
97
- if (!item || 'object' != typeof item) return null;
98
- const childFields = field.fields ?? [];
99
- if (0 === childFields.length) return null;
100
- const innerBody = childFields.map((childField)=>{
101
- const initial = item[childField.name];
102
- if ('group' === childField.type && childField.fields && childField.fields.length > 0) {
103
- const groupData = initial && 'object' == typeof initial ? initial : {};
104
- return /*#__PURE__*/ jsxs("div", {
105
- className: classnames('byline-field-array-group-fields', array_field_module["group-fields"]),
106
- children: [
107
- childField.label && /*#__PURE__*/ jsx("h4", {
108
- className: classnames('byline-field-array-group-header', array_field_module["group-header"]),
109
- children: childField.label
110
- }),
111
- childField.fields.map((innerField)=>/*#__PURE__*/ jsx(FieldRenderer, {
112
- field: innerField,
113
- defaultValue: groupData[innerField.name],
114
- basePath: `${arrayElementPath}.${childField.name}`,
115
- disableSorting: true
116
- }, innerField.name))
117
- ]
118
- }, childField.name);
119
- }
120
- return /*#__PURE__*/ jsx(FieldRenderer, {
121
- field: childField,
122
- defaultValue: initial,
123
- basePath: arrayElementPath,
124
- disableSorting: true
125
- }, childField.name);
126
- });
127
- const label = field.label ?? field.name;
128
- if (disableSorting) return /*#__PURE__*/ jsx("div", {
129
- className: classnames('byline-field-array-card', array_field_module.card),
130
- children: /*#__PURE__*/ jsx("div", {
131
- className: classnames('byline-field-array-group-fields', array_field_module["group-fields"]),
132
- children: innerBody
133
- })
134
- }, itemWrapper.id);
135
- return /*#__PURE__*/ jsx(SortableItem, {
136
- id: itemWrapper.id,
137
- label: label,
138
- onAddBelow: ()=>handleInsertBelow(index),
139
- onRemove: ()=>handleRemoveItem(index),
140
- children: /*#__PURE__*/ jsx("div", {
141
- className: classnames('byline-field-array-group-fields', array_field_module["group-fields"]),
142
- children: innerBody
143
- })
144
- }, itemWrapper.id);
145
- };
146
- return /*#__PURE__*/ jsxs("div", {
147
- className: `byline-field-array ${field.name}`,
148
- children: [
149
- !disableSorting && field.label && /*#__PURE__*/ jsx("h3", {
150
- className: classnames('byline-field-array-title', array_field_module.title),
151
- children: field.label
152
- }),
153
- disableSorting ? /*#__PURE__*/ jsx("div", {
154
- className: classnames('byline-field-array-stack', array_field_module.stack),
155
- children: items.map((item, index)=>renderItem(item, index))
156
- }) : /*#__PURE__*/ jsxs(DraggableSortable, {
157
- ids: items.map((i)=>i.id),
158
- onDragEnd: handleDragEnd,
159
- className: classnames('byline-field-array-stack', array_field_module.stack),
160
- children: [
161
- items.map((item, index)=>renderItem(item, index)),
162
- /*#__PURE__*/ jsx("span", {
163
- children: /*#__PURE__*/ jsx(IconButton, {
164
- onClick: ()=>{
165
- handleAddItem();
166
- },
167
- "aria-label": "Add item",
168
- children: /*#__PURE__*/ jsx(PlusIcon, {})
169
- })
170
- })
171
- ]
172
- })
173
- ]
174
- });
175
- };
176
- export { ArrayField };
@@ -1,11 +0,0 @@
1
- import "./array-field_module.css";
2
- const array_field_module = {
3
- title: "title-HMJs1n",
4
- stack: "stack-emBcXW",
5
- card: "card-j_6w_O",
6
- "group-header": "group-header-KJxpIV",
7
- groupHeader: "group-header-KJxpIV",
8
- "group-fields": "group-fields-Bmi_hA",
9
- groupFields: "group-fields-Bmi_hA"
10
- };
11
- export default array_field_module;
@@ -1,32 +0,0 @@
1
- :is(.title-HMJs1n, .byline-field-array-title) {
2
- font-size: 1rem;
3
- font-weight: var(--font-weight-medium);
4
- margin-bottom: .25rem;
5
- }
6
-
7
- :is(.stack-emBcXW, .byline-field-array-stack) {
8
- gap: var(--spacing-16);
9
- flex-direction: column;
10
- display: flex;
11
- }
12
-
13
- :is(.card-j_6w_O, .byline-field-array-card) {
14
- gap: var(--spacing-16);
15
- padding: var(--spacing-16);
16
- border: var(--border-width-thin) dashed var(--gray-600);
17
- border-radius: var(--border-radius-md);
18
- flex-direction: column;
19
- display: flex;
20
- }
21
-
22
- :is(.group-header-KJxpIV, .byline-field-array-group-header) {
23
- font-size: .9rem;
24
- font-weight: var(--font-weight-medium);
25
- }
26
-
27
- :is(.group-fields-Bmi_hA, .byline-field-array-group-fields) {
28
- gap: var(--spacing-16);
29
- flex-direction: column;
30
- display: flex;
31
- }
32
-
@@ -1,13 +0,0 @@
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 { BlocksField as BlocksFieldType } from '@byline/core';
9
- export declare const BlocksField: ({ field, defaultValue, path, }: {
10
- field: BlocksFieldType;
11
- defaultValue: any;
12
- path: string;
13
- }) => import("react").JSX.Element;