@limetech/lime-elements 39.13.3 → 39.14.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 (184) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/{_assignValue-D2D1zedG.js → _assignValue-DpsLUlF4.js} +25 -2
  3. package/dist/cjs/{_baseForOwn-QM0kHQT5.js → _baseEach-C570gT5Y.js} +43 -1
  4. package/dist/cjs/{_baseIsEqual-D6hrjmx4.js → _baseIsEqual-aOPReRWl.js} +1 -0
  5. package/dist/cjs/{_baseIteratee-iGEZ9pZY.js → _baseIteratee-DggA4e7a.js} +3 -1
  6. package/dist/cjs/_commonjsHelpers-CFO10eej.js +7 -0
  7. package/dist/cjs/_getAllKeysIn-BQIV8aw7.js +118 -0
  8. package/dist/cjs/_isIterateeCall-CPWXFS_s.js +72 -0
  9. package/dist/cjs/cloneDeep-CxFNKF1Y.js +619 -0
  10. package/dist/cjs/{isArrayLikeObject-CTP6Ak01.js → difference-Bfsq4sXB.js} +93 -5
  11. package/dist/cjs/{focus-trigger-element-NnpJ5nTp.js → focus-trigger-element-Brw8VubX.js} +1 -1
  12. package/dist/cjs/{format-D04vDIBj.js → format-D4jZb7Ls.js} +1 -1
  13. package/dist/cjs/{index-mbfaT7TB.js → index-BgFEL6FF.js} +1 -1
  14. package/dist/cjs/{isEmpty-DCC_l2Xp.js → isEmpty-EBCFxX1S.js} +1 -1
  15. package/dist/cjs/{isEqual-BsHLqE-x.js → isEqual-bXyw7kXo.js} +1 -1
  16. package/dist/cjs/lime-elements.cjs.js +1 -1
  17. package/dist/cjs/limel-badge.cjs.entry.js +2 -2
  18. package/dist/cjs/limel-breadcrumbs_7.cjs.entry.js +2 -3
  19. package/dist/cjs/limel-chip_2.cjs.entry.js +3 -3
  20. package/dist/cjs/limel-circular-progress.cjs.entry.js +2 -2
  21. package/dist/cjs/limel-code-editor.cjs.entry.js +1 -1
  22. package/dist/cjs/limel-date-picker.cjs.entry.js +3 -3
  23. package/dist/cjs/limel-dialog.cjs.entry.js +2 -2
  24. package/dist/cjs/limel-file-dropzone_2.cjs.entry.js +5 -44
  25. package/dist/cjs/limel-file-viewer.cjs.entry.js +2 -2
  26. package/dist/cjs/limel-flatpickr-adapter.cjs.entry.js +12 -74
  27. package/dist/cjs/limel-form.cjs.entry.js +38541 -50295
  28. package/dist/cjs/limel-markdown.cjs.entry.js +3 -3
  29. package/dist/cjs/limel-popover_2.cjs.entry.js +2 -3
  30. package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js +23 -481
  31. package/dist/cjs/limel-tab-bar.cjs.entry.js +4 -83
  32. package/dist/cjs/limel-table.cjs.entry.js +14 -269
  33. package/dist/cjs/loader.cjs.js +1 -1
  34. package/dist/cjs/{markdown-parser-DCnW9yak.js → markdown-parser-BIa99LAc.js} +2 -2
  35. package/dist/cjs/{moment-DCqC7BZP.js → moment-CqRdiK10.js} +1 -1
  36. package/dist/cjs/pickBy-kLjYLoam.js +201 -0
  37. package/dist/cjs/{sv-jO-ewmqh.js → sv-BSR4W58y.js} +1 -1
  38. package/dist/collection/components/form/adapters/widget-adapter.js +23 -30
  39. package/dist/collection/components/form/fields/array-field.js +39 -6
  40. package/dist/collection/components/form/fields/field-helpers.js +4 -4
  41. package/dist/collection/components/form/fields/object-field.js +4 -2
  42. package/dist/collection/components/form/fields/schema-field.js +33 -70
  43. package/dist/collection/components/form/form.css +19 -19
  44. package/dist/collection/components/form/form.js +40 -72
  45. package/dist/collection/components/form/form.test-schemas.js +308 -0
  46. package/dist/collection/components/form/row/row-context.js +2 -0
  47. package/dist/collection/components/form/row/row.js +2 -2
  48. package/dist/collection/components/form/templates/array-context.js +2 -0
  49. package/dist/collection/components/form/templates/array-field-collapsible-item.js +4 -4
  50. package/dist/collection/components/form/templates/array-field-item.js +47 -0
  51. package/dist/collection/components/form/templates/array-field-simple-item.js +6 -7
  52. package/dist/collection/components/form/templates/array-field.js +38 -94
  53. package/dist/collection/components/form/templates/index.js +1 -0
  54. package/dist/collection/components/form/templates/object-field.js +15 -11
  55. package/dist/collection/components/form/validation-display.js +75 -0
  56. package/dist/collection/components/form/validator.js +10 -0
  57. package/dist/collection/components/form/widgets/code-editor.js +1 -1
  58. package/dist/collection/components/form/widgets/select.js +2 -1
  59. package/dist/collection/components/text-editor/prosemirror-adapter/plugins/trigger/create-html-inserter.js +2 -2
  60. package/dist/collection/components/text-editor/prosemirror-adapter/plugins/trigger/factory-helpers/append-transaction-handler.js +7 -0
  61. package/dist/collection/components/text-editor/prosemirror-adapter/plugins/trigger/inserter.js +1 -1
  62. package/dist/esm/{_assignValue-DkGAX8ec.js → _assignValue-DOEO9byf.js} +24 -2
  63. package/dist/esm/{_baseForOwn-CfpQNnvA.js → _baseEach-CL_-rBMy.js} +42 -2
  64. package/dist/esm/{_baseIsEqual-BvHnKRmD.js → _baseIsEqual-BfXMsuGh.js} +2 -2
  65. package/dist/esm/{_baseIteratee-DFBCJcMA.js → _baseIteratee-kS1-0_xD.js} +3 -3
  66. package/dist/esm/_commonjsHelpers-B85MJLTf.js +5 -0
  67. package/dist/esm/_getAllKeysIn-BKpeslPJ.js +113 -0
  68. package/dist/esm/_isIterateeCall-CTcCv8Mb.js +69 -0
  69. package/dist/esm/cloneDeep-BXAw5H-1.js +609 -0
  70. package/dist/esm/{isArrayLikeObject-D7yRwRv4.js → difference-DMAjHh-t.js} +91 -7
  71. package/dist/esm/{focus-trigger-element-6aEStEKM.js → focus-trigger-element-DubROLkE.js} +1 -1
  72. package/dist/esm/{format-BMPGHLQ8.js → format-hTrthuPP.js} +1 -1
  73. package/dist/esm/{index-DJJymEnS.js → index-t4DgGbWS.js} +1 -1
  74. package/dist/esm/{isArrayLike-bWHU4ebg.js → isArrayLike-D1QkaJU2.js} +1 -1
  75. package/dist/esm/{isEmpty-tfwtR2ai.js → isEmpty-DrFXbHWO.js} +2 -2
  76. package/dist/esm/{isEqual-BkQ4Z_9r.js → isEqual-CpaoJ_AF.js} +1 -1
  77. package/dist/esm/lime-elements.js +1 -1
  78. package/dist/esm/limel-badge.entry.js +2 -2
  79. package/dist/esm/limel-breadcrumbs_7.entry.js +2 -3
  80. package/dist/esm/limel-chip_2.entry.js +4 -4
  81. package/dist/esm/limel-circular-progress.entry.js +2 -2
  82. package/dist/esm/limel-code-editor.entry.js +1 -1
  83. package/dist/esm/limel-date-picker.entry.js +3 -3
  84. package/dist/esm/limel-dialog.entry.js +3 -3
  85. package/dist/esm/limel-file-dropzone_2.entry.js +4 -43
  86. package/dist/esm/limel-file-viewer.entry.js +2 -2
  87. package/dist/esm/limel-flatpickr-adapter.entry.js +8 -70
  88. package/dist/esm/limel-form.entry.js +38553 -50307
  89. package/dist/esm/limel-markdown.entry.js +3 -3
  90. package/dist/esm/limel-popover_2.entry.js +2 -3
  91. package/dist/esm/limel-prosemirror-adapter.entry.js +22 -480
  92. package/dist/esm/limel-tab-bar.entry.js +4 -83
  93. package/dist/esm/limel-table.entry.js +11 -266
  94. package/dist/esm/loader.js +1 -1
  95. package/dist/esm/{markdown-parser-CXYHPPe2.js → markdown-parser-D7vLKElE.js} +2 -2
  96. package/dist/esm/{moment-DhvPC9Jt.js → moment-DQRNe8qq.js} +1 -1
  97. package/dist/esm/pickBy-BEA90LIZ.js +195 -0
  98. package/dist/esm/{sv-84mf7Xsv.js → sv-CY-6-yEp.js} +1 -1
  99. package/dist/lime-elements/lime-elements.esm.js +1 -1
  100. package/dist/lime-elements/p-1cb2d781.entry.js +13 -0
  101. package/dist/lime-elements/{p-00d6ccd6.entry.js → p-25ae3a55.entry.js} +5 -5
  102. package/dist/lime-elements/{p-be0cbddb.entry.js → p-374ec191.entry.js} +1 -1
  103. package/dist/lime-elements/p-3a662d7e.entry.js +1 -0
  104. package/dist/lime-elements/{p-f0f5eda1.entry.js → p-41be4893.entry.js} +1 -1
  105. package/dist/lime-elements/{p-c84911e6.entry.js → p-4ad193a2.entry.js} +1 -1
  106. package/dist/lime-elements/{p-dd7a2361.entry.js → p-4ce682cf.entry.js} +3 -3
  107. package/dist/lime-elements/{p-eeae0ef6.entry.js → p-5ee484a7.entry.js} +4 -4
  108. package/dist/lime-elements/{p-b1d6553c.entry.js → p-77abb595.entry.js} +1 -1
  109. package/dist/lime-elements/p-8065425a.entry.js +1 -0
  110. package/dist/lime-elements/{p-77ba0f66.entry.js → p-8299af78.entry.js} +1 -1
  111. package/dist/lime-elements/{p-87c5e951.entry.js → p-8c7a7003.entry.js} +1 -1
  112. package/dist/lime-elements/{p-ce20d720.entry.js → p-97c401f1.entry.js} +1 -1
  113. package/dist/lime-elements/p-9a378cf0.entry.js +1 -0
  114. package/dist/lime-elements/p-B3zCFNAw.js +1 -0
  115. package/dist/lime-elements/p-B6bNnxRu.js +1 -0
  116. package/dist/lime-elements/p-B85MJLTf.js +1 -0
  117. package/dist/lime-elements/p-BCMRfUKp.js +1 -0
  118. package/dist/lime-elements/p-BbU4FGNT.js +1 -0
  119. package/dist/lime-elements/p-Bp0tNo1s.js +1 -0
  120. package/dist/lime-elements/{p-DpyWBa_Z.js → p-Bt64o80S.js} +1 -1
  121. package/dist/lime-elements/{p-BqiDn_Sf.js → p-BvDmWgCs.js} +1 -1
  122. package/dist/lime-elements/p-CMjGNANG.js +1 -0
  123. package/dist/lime-elements/p-DFWcgJ_i.js +1 -0
  124. package/dist/lime-elements/{p-B4YDb6f3.js → p-DJvGLFul.js} +1 -1
  125. package/dist/lime-elements/p-DTXIk0fN.js +1 -0
  126. package/dist/lime-elements/{p-BgPHaiMH.js → p-D_uMnX5g.js} +1 -1
  127. package/dist/lime-elements/{p-g3InYy9F.js → p-DdYOzHlg.js} +1 -1
  128. package/dist/lime-elements/{p-ndpPJpml.js → p-DsDkl4Sy.js} +1 -1
  129. package/dist/lime-elements/p-UGKt6Ywx.js +1 -0
  130. package/dist/lime-elements/p-afcf580c.entry.js +16 -0
  131. package/dist/lime-elements/p-f6c3f49b.entry.js +1 -0
  132. package/dist/lime-elements/p-v6b303K5.js +1 -0
  133. package/dist/lime-elements/p-xQsJdKrq.js +1 -0
  134. package/dist/lime-elements/{p-BYx8mudw.js → p-zo6O9LC9.js} +2 -2
  135. package/dist/types/components/form/adapters/widget-adapter.d.ts +3 -2
  136. package/dist/types/components/form/fields/array-field.d.ts +11 -19
  137. package/dist/types/components/form/fields/object-field.d.ts +2 -2
  138. package/dist/types/components/form/fields/schema-field.d.ts +5 -18
  139. package/dist/types/components/form/form.d.ts +4 -8
  140. package/dist/types/components/form/form.test-schemas.d.ts +30 -0
  141. package/dist/types/components/form/row/row-context.d.ts +2 -0
  142. package/dist/types/components/form/templates/array-context.d.ts +7 -0
  143. package/dist/types/components/form/templates/array-field-collapsible-item.d.ts +7 -11
  144. package/dist/types/components/form/templates/array-field-item.d.ts +6 -0
  145. package/dist/types/components/form/templates/array-field-simple-item.d.ts +7 -9
  146. package/dist/types/components/form/templates/array-field.d.ts +7 -8
  147. package/dist/types/components/form/templates/index.d.ts +1 -0
  148. package/dist/types/components/form/templates/object-field.d.ts +6 -1
  149. package/dist/types/components/form/templates/types.d.ts +2 -4
  150. package/dist/types/components/form/validation-display.d.ts +60 -0
  151. package/dist/types/components/form/validator.d.ts +6 -0
  152. package/dist/types/components/form/widgets/code-editor.d.ts +1 -1
  153. package/dist/types/components/form/widgets/types.d.ts +1 -1
  154. package/dist/types/components/text-editor/prosemirror-adapter/plugins/trigger/create-html-inserter.d.ts +2 -1
  155. package/package.json +4 -2
  156. package/dist/cjs/_baseAssignValue-BJgt6T7z.js +0 -27
  157. package/dist/cjs/_commonjsHelpers-BJu3ubxk.js +0 -10
  158. package/dist/cjs/_getPrototype-BK9cL-57.js +0 -8
  159. package/dist/cjs/negate-Bg3SqQh6.js +0 -42
  160. package/dist/collection/components/form/fields/types.js +0 -1
  161. package/dist/collection/components/form/schema-cache.js +0 -66
  162. package/dist/esm/_baseAssignValue-C8Uwn8zr.js +0 -25
  163. package/dist/esm/_commonjsHelpers-BFTU3MAI.js +0 -7
  164. package/dist/esm/_getPrototype-jV9gkkJy.js +0 -6
  165. package/dist/esm/negate-ooVD-6_a.js +0 -40
  166. package/dist/lime-elements/p-45dfcaf3.entry.js +0 -1
  167. package/dist/lime-elements/p-5db2d069.entry.js +0 -1
  168. package/dist/lime-elements/p-9728aa4a.entry.js +0 -1
  169. package/dist/lime-elements/p-BFTU3MAI.js +0 -1
  170. package/dist/lime-elements/p-BlJd1RC5.js +0 -1
  171. package/dist/lime-elements/p-C6SEjICu.js +0 -1
  172. package/dist/lime-elements/p-CqEHNkif.js +0 -1
  173. package/dist/lime-elements/p-Cs5T63LB.js +0 -1
  174. package/dist/lime-elements/p-Cw1B5fXE.js +0 -1
  175. package/dist/lime-elements/p-DKxusNKT.js +0 -1
  176. package/dist/lime-elements/p-DrjUjEz3.js +0 -1
  177. package/dist/lime-elements/p-DzlmgobW.js +0 -1
  178. package/dist/lime-elements/p-ZcW3uvZL.js +0 -1
  179. package/dist/lime-elements/p-a4a09ce9.entry.js +0 -7
  180. package/dist/lime-elements/p-c4e2885d.entry.js +0 -16
  181. package/dist/lime-elements/p-ee80a6f2.entry.js +0 -1
  182. package/dist/lime-elements/p-ooVD-6_a.js +0 -1
  183. package/dist/types/components/form/fields/types.d.ts +0 -41
  184. package/dist/types/components/form/schema-cache.d.ts +0 -17
@@ -1,9 +1,8 @@
1
1
  import React from "react";
2
- import { isObjectType } from "../schema";
3
- import { CollapsibleItemTemplate } from "./array-field-collapsible-item";
4
- import { SimpleItemTemplate } from "./array-field-simple-item";
5
2
  import { renderDescription, renderTitle } from "./common";
6
3
  import Sortable from "sortablejs";
4
+ import { ArrayFieldContext } from "./array-context";
5
+ export const ARRAY_REORDER_EVENT = 'arrayReorder';
7
6
  const DRAG_HANDLE_SELECTOR = '[data-drag-handle]';
8
7
  const DRAGGABLE_ITEM_SELECTOR = '.array-item[data-reorderable="true"]';
9
8
  const DEFAULT_CONTAINER_CLASS = 'has-an-item-which-is-being-dragged';
@@ -13,7 +12,7 @@ const TOUCH_DRAG_DELAY_MS = 200; // Adds a short hold on touch (long-press) so s
13
12
  export class ArrayFieldTemplate extends React.Component {
14
13
  constructor(props) {
15
14
  super(props);
16
- this.itemByIndex = new Map();
15
+ this.cachedContextValue = null;
17
16
  this.handleAddClick = (event) => {
18
17
  event.stopPropagation();
19
18
  this.props.onAddClick(event);
@@ -72,20 +71,10 @@ export class ArrayFieldTemplate extends React.Component {
72
71
  this.scheduleDropElevationRemoval();
73
72
  return;
74
73
  }
75
- const targetItem = ((_a = this.props.items) !== null && _a !== void 0 ? _a : []).find((entry) => {
76
- var _a;
77
- return ((_a = entry.index) !== null && _a !== void 0 ? _a : -1) === draggedItemIndex;
78
- });
79
- if (!targetItem || typeof targetItem.onReorderClick !== 'function') {
80
- this.scheduleDropElevationRemoval();
81
- return;
82
- }
83
- requestAnimationFrame(() => {
84
- const reorder = targetItem.onReorderClick(draggedItemIndex, toPosition);
85
- if (typeof reorder === 'function') {
86
- reorder();
87
- }
88
- });
74
+ (_a = this.container) === null || _a === void 0 ? void 0 : _a.dispatchEvent(new CustomEvent(ARRAY_REORDER_EVENT, {
75
+ bubbles: true,
76
+ detail: { fromIndex: fromPosition, toIndex: toPosition },
77
+ }));
89
78
  this.scheduleDropElevationRemoval();
90
79
  };
91
80
  this.state = {
@@ -118,13 +107,12 @@ export class ArrayFieldTemplate extends React.Component {
118
107
  }
119
108
  }
120
109
  render() {
121
- const controls = this.getItemControls();
122
- const { ordered: orderedItems, byIndex } = this.getOrderedItems();
123
- this.itemByIndex = byIndex;
124
- return React.createElement('div', {}, renderTitle(this.props.title), renderDescription(this.props.schema.description), React.createElement('div', {
110
+ const orderedItems = this.getOrderedItems();
111
+ const contextValue = this.getContextValue();
112
+ return React.createElement(ArrayFieldContext.Provider, { value: contextValue }, React.createElement('div', {}, renderTitle(this.props.title), renderDescription(this.props.schema.description), React.createElement('div', {
125
113
  className: 'array-items',
126
114
  ref: this.setContainer,
127
- }, orderedItems.map((item, index) => this.renderItem(item, index, controls))), this.renderAddButton());
115
+ }, orderedItems), this.renderAddButton()));
128
116
  }
129
117
  renderAddButton() {
130
118
  if (!this.props.canAdd) {
@@ -137,73 +125,40 @@ export class ArrayFieldTemplate extends React.Component {
137
125
  class: 'button-add-new',
138
126
  });
139
127
  }
140
- getItemControls() {
141
- return {
142
- allowItemRemoval: this.canRemoveItems(),
143
- };
144
- }
145
- renderItem(item, index, controls) {
146
- var _a;
147
- const { schema, formData, formContext } = this.props;
148
- const itemIndex = (_a = item.index) !== null && _a !== void 0 ? _a : index;
149
- const allowItemReorder = this.isItemReorderable(item);
150
- if (isObjectType(schema.items)) {
151
- return React.createElement(CollapsibleItemTemplate, {
152
- key: item.key,
153
- item: item,
154
- data: Array.isArray(formData) ? formData[itemIndex] : undefined,
155
- schema: schema,
156
- formSchema: formContext.schema,
157
- index: itemIndex,
158
- allowItemRemoval: controls.allowItemRemoval,
159
- allowItemReorder: allowItemReorder,
160
- });
161
- }
162
- return React.createElement(SimpleItemTemplate, {
163
- key: item.key,
164
- item: item,
165
- index: itemIndex,
166
- dataIndex: itemIndex,
167
- allowItemRemoval: controls.allowItemRemoval,
168
- allowItemReorder: allowItemReorder,
169
- });
170
- }
171
128
  getOrderedItems() {
172
- var _a, _b;
129
+ var _a;
173
130
  const items = (_a = this.props.items) !== null && _a !== void 0 ? _a : [];
174
- const byIndex = new Map();
175
- let entryIndex = 0;
176
- for (const entry of items) {
177
- byIndex.set((_b = entry.index) !== null && _b !== void 0 ? _b : entryIndex, entry);
178
- entryIndex += 1;
131
+ if (items.length === 0) {
132
+ return [];
133
+ }
134
+ const byKey = new Map();
135
+ for (const [index, item] of items.entries()) {
136
+ byKey.set(index, item);
179
137
  }
180
138
  const ordered = [];
181
139
  const used = new Set();
182
140
  for (const index of this.state.order) {
183
- const entry = byIndex.get(index);
141
+ const entry = byKey.get(index);
184
142
  if (!entry) {
185
143
  continue;
186
144
  }
187
145
  ordered.push(entry);
188
146
  used.add(index);
189
147
  }
190
- for (const [index, entry] of byIndex.entries()) {
148
+ for (const [index, entry] of byKey.entries()) {
191
149
  if (!used.has(index)) {
192
150
  ordered.push(entry);
193
151
  }
194
152
  }
195
- return {
196
- ordered,
197
- byIndex,
198
- };
153
+ return ordered;
199
154
  }
200
155
  setupDragController() {
201
156
  if (!this.container || !this.canReorderItems()) {
202
157
  this.teardownDragController();
203
158
  return;
204
159
  }
205
- const reorderableCount = this.getReorderableOrder().length;
206
- if (reorderableCount < 2) {
160
+ const reorderableItems = this.container.querySelectorAll(`:scope > ${DRAGGABLE_ITEM_SELECTOR}`);
161
+ if (reorderableItems.length < 2) {
207
162
  this.teardownDragController();
208
163
  return;
209
164
  }
@@ -249,31 +204,6 @@ export class ArrayFieldTemplate extends React.Component {
249
204
  const limeOptions = (schema === null || schema === void 0 ? void 0 : schema.lime) || {};
250
205
  return limeOptions.allowItemReorder !== false;
251
206
  }
252
- canRemoveItems() {
253
- const schema = this.props.schema;
254
- const limeOptions = (schema === null || schema === void 0 ? void 0 : schema.lime) || {};
255
- return limeOptions.allowItemRemoval !== false;
256
- }
257
- isItemReorderable(item) {
258
- return (this.canReorderItems() &&
259
- Boolean((item === null || item === void 0 ? void 0 : item.hasMoveDown) || (item === null || item === void 0 ? void 0 : item.hasMoveUp)));
260
- }
261
- isIndexReorderable(index) {
262
- const item = this.itemByIndex.get(index);
263
- if (!item) {
264
- return false;
265
- }
266
- return this.isItemReorderable(item);
267
- }
268
- getReorderableOrder(order = this.state.order) {
269
- const result = [];
270
- for (const index of order) {
271
- if (this.isIndexReorderable(index)) {
272
- result.push(index);
273
- }
274
- }
275
- return result;
276
- }
277
207
  readOrderFromDom() {
278
208
  if (!this.container) {
279
209
  return [];
@@ -348,6 +278,20 @@ export class ArrayFieldTemplate extends React.Component {
348
278
  return true;
349
279
  }
350
280
  extractIndices(items = []) {
351
- return (items !== null && items !== void 0 ? items : []).map((item, index) => { var _a; return (_a = item.index) !== null && _a !== void 0 ? _a : index; });
281
+ return (items !== null && items !== void 0 ? items : []).map((_, index) => index);
282
+ }
283
+ getContextValue() {
284
+ var _a;
285
+ const schema = this.props.schema;
286
+ const formData = ((_a = this.props.formData) !== null && _a !== void 0 ? _a : []);
287
+ if (this.cachedContextValue &&
288
+ this.cachedSchema === schema &&
289
+ this.cachedFormData === formData) {
290
+ return this.cachedContextValue;
291
+ }
292
+ this.cachedSchema = schema;
293
+ this.cachedFormData = formData;
294
+ this.cachedContextValue = { arraySchema: schema, formData };
295
+ return this.cachedContextValue;
352
296
  }
353
297
  }
@@ -1,3 +1,4 @@
1
1
  export * from './field';
2
2
  export * from './array-field';
3
+ export * from './array-field-item';
3
4
  export * from './object-field';
@@ -1,17 +1,19 @@
1
- import React from "react";
1
+ import React, { useContext } from "react";
2
2
  import { renderDescription, renderTitle } from "./common";
3
3
  import { GridLayout } from "./grid-layout";
4
4
  import { RowLayout } from "./row-layout";
5
5
  import { getHelpComponent } from "../help";
6
+ import { ArrayFieldContext } from "./array-context";
6
7
  export const ObjectFieldTemplate = (props) => {
7
- const id = props.idSchema.$id;
8
+ const arrayContext = useContext(ArrayFieldContext);
9
+ const id = props.fieldPathId.$id;
10
+ if (arrayContext && id !== 'root') {
11
+ return React.createElement(ArrayFieldContext.Provider, { value: null }, renderProperties(props.properties, props.schema));
12
+ }
8
13
  if (id === 'root' || !isCollapsible(props.schema)) {
9
14
  return renderFieldWithTitle(props);
10
15
  }
11
- if (isCollapsible(props.schema)) {
12
- return renderCollapsibleField(props);
13
- }
14
- return renderProperties(props.properties, props.schema);
16
+ return renderCollapsibleField(props);
15
17
  };
16
18
  function renderFieldWithTitle(props) {
17
19
  return React.createElement(React.Fragment, {}, renderSectionHeader(props), renderDescription(props.description), renderProperties(props.properties, props.schema));
@@ -30,17 +32,19 @@ function renderCollapsibleField(props) {
30
32
  });
31
33
  return React.createElement('limel-collapsible-section', {
32
34
  header: props.title,
33
- id: getSchemaObjectPropertyPath(props.formContext.schema, props.idSchema),
35
+ id: getSchemaObjectPropertyPath(props.registry.formContext.schema, props.fieldPathId),
34
36
  'is-open': defaultOpen,
35
37
  }, helpElement, renderDescription(props.description), renderProperties(props.properties, props.schema));
36
38
  }
37
- function getSchemaObjectPropertyPath(schema, subSchema) {
39
+ function getSchemaObjectPropertyPath(schema, fieldPathId) {
38
40
  var _a, _b;
39
41
  const refPrefixLength = 2;
40
42
  const matchAllForwardSlashes = /\//g;
41
- const rootPath = (_a = schema.$ref) === null || _a === void 0 ? void 0 : _a.replace(matchAllForwardSlashes, '.').slice(refPrefixLength);
42
- const subSchemaPath = (_b = subSchema.$id) === null || _b === void 0 ? void 0 : _b.replace('_', '.properties.');
43
- return subSchemaPath.replace('root', rootPath);
43
+ const rootPath = (_b = (_a = schema.$ref) === null || _a === void 0 ? void 0 : _a.replace(matchAllForwardSlashes, '.').slice(refPrefixLength)) !== null && _b !== void 0 ? _b : '';
44
+ const subSchemaPath = fieldPathId.path
45
+ .map((segment) => `.properties.${segment}`)
46
+ .join('');
47
+ return `${rootPath}${subSchemaPath}`;
44
48
  }
45
49
  function renderProperties(properties, schema) {
46
50
  var _a;
@@ -0,0 +1,75 @@
1
+ import { isEmpty, capitalize } from "lodash-es";
2
+ /**
3
+ * Check whether a form field value is non-empty.
4
+ * Treats `null`, `undefined`, `''`, empty arrays,
5
+ * and empty plain objects as "no value".
6
+ *
7
+ * @param value - the current field value
8
+ * @returns `true` when the field holds meaningful data
9
+ */
10
+ export function hasValue(value) {
11
+ if (value === null || value === undefined || value === '') {
12
+ return false;
13
+ }
14
+ if (Array.isArray(value)) {
15
+ return value.length > 0;
16
+ }
17
+ if (value instanceof Date) {
18
+ return true;
19
+ }
20
+ if (typeof value === 'object') {
21
+ return !isEmpty(value);
22
+ }
23
+ return true;
24
+ }
25
+ /**
26
+ * Determine whether a field should be displayed as invalid.
27
+ *
28
+ * A field with errors is shown as invalid only when the user has
29
+ * interacted with it, it already contains a value, or it is optional.
30
+ * This avoids showing errors on untouched required fields before the
31
+ * user has had a chance to fill them in.
32
+ *
33
+ * @param field - the current field state
34
+ * @param field.hasErrors - whether the field currently has validation errors
35
+ * @param field.modified - whether the user has interacted with the field
36
+ * @param field.hasValue - whether the field holds a non-empty value
37
+ * @param field.required - whether the field is required
38
+ * @returns `true` when the field should render in an invalid state
39
+ */
40
+ export function isFieldInvalid(field) {
41
+ return (field.hasErrors && (field.modified || field.hasValue || !field.required));
42
+ }
43
+ /**
44
+ * Check whether a field should be marked as required.
45
+ *
46
+ * A field is required when the schema marks it as `required` or
47
+ * when it specifies a positive `minItems` constraint.
48
+ *
49
+ * @param field - the current field state
50
+ * @param field.required - the `required` flag from the schema/props
51
+ * @param field.minItems - the `minItems` value from the schema (0 if unset)
52
+ * @returns `true` when the field is required
53
+ */
54
+ export function isFieldRequired(field) {
55
+ return field.required || field.minItems > 0;
56
+ }
57
+ /**
58
+ * Return the helper text to display beneath a field.
59
+ *
60
+ * When validation errors exist the first error message is returned
61
+ * (capitalized). Otherwise falls back to `fallbackText` if provided,
62
+ * then to `description`.
63
+ *
64
+ * @param errors - array of validation error strings (may be `null`)
65
+ * @param description - the schema description for the field
66
+ * @param fallbackText - optional text that takes priority over `description`
67
+ * when there are no errors (e.g. a custom `helperText` prop)
68
+ * @returns the string to show as helper text
69
+ */
70
+ export function getErrorText(errors, description, fallbackText) {
71
+ if ((errors === null || errors === void 0 ? void 0 : errors.length) > 0) {
72
+ return capitalize(errors[0]);
73
+ }
74
+ return fallbackText || description;
75
+ }
@@ -0,0 +1,10 @@
1
+ import { customizeValidator } from "@rjsf/validator-ajv8";
2
+ import { isInteger } from "./validators";
3
+ /**
4
+ * Shared RJSF validator configured with custom formats and ajv options.
5
+ * Use this single instance wherever the RJSF v6 API requires a validator.
6
+ */
7
+ export const rjsfValidator = customizeValidator({
8
+ customFormats: { integer: isInteger },
9
+ ajvOptionsOverrides: { allErrors: true, multipleOfPrecision: 2 },
10
+ });
@@ -62,7 +62,7 @@ export class CodeEditor extends React.Component {
62
62
  this.setState({ validationError, modified: true });
63
63
  return;
64
64
  }
65
- props.onChange(value);
65
+ props.onChange(value, props.fieldPathId.path);
66
66
  this.setState({ validationError: '', modified: true });
67
67
  }
68
68
  }
@@ -48,10 +48,11 @@ export class Select extends React.Component {
48
48
  }
49
49
  }
50
50
  function createOption(item) {
51
+ var _a;
51
52
  return {
52
53
  text: item.label,
53
54
  value: item.value,
54
- disabled: !!item.schema.readOnly,
55
+ disabled: !!((_a = item.schema) === null || _a === void 0 ? void 0 : _a.readOnly),
55
56
  };
56
57
  }
57
58
  function findValue(value, options) {
@@ -1,10 +1,10 @@
1
1
  import { DOMParser } from "prosemirror-model";
2
- export const createHtmlInserter = (view, contentConverter, startPos, dispatchTransaction) => {
2
+ export const createHtmlInserter = (view, contentConverter, trigger, dispatchTransaction) => {
3
3
  const schema = view.state.schema;
4
4
  return async (input) => {
5
5
  const container = document.createElement('span');
6
6
  container.innerHTML = await contentConverter.parseAsHTML(input, schema);
7
7
  const fragment = DOMParser.fromSchema(schema).parse(container).content;
8
- dispatchTransaction(view, startPos, fragment);
8
+ dispatchTransaction(view, trigger.position, fragment);
9
9
  };
10
10
  };
@@ -12,6 +12,13 @@ export const getAppendTransactionHandler = (getCurrentView, getActiveTrigger, re
12
12
  resetActiveTrigger();
13
13
  return;
14
14
  }
15
+ for (const transaction of transactions) {
16
+ if (transaction.docChanged) {
17
+ activeTrigger.position = transaction.mapping.map(activeTrigger.position,
18
+ // eslint-disable-next-line unicorn/no-array-method-this-argument -- ProseMirror Mapping#map(pos, assoc), not Array#map
19
+ -1);
20
+ }
21
+ }
15
22
  monitorTriggeredText(newState.doc, activeTrigger, newState.selection.from, contentConverter, getCurrentView());
16
23
  };
17
24
  };
@@ -2,7 +2,7 @@ import { createHtmlInserter } from "./create-html-inserter";
2
2
  export const inserterFactory = (view, contentConverter, trigger) => {
3
3
  return {
4
4
  insert: createNodeAndTextInserter(view, trigger),
5
- insertHtml: createHtmlInserter(view, contentConverter, trigger.position, dispatchTransaction),
5
+ insertHtml: createHtmlInserter(view, contentConverter, trigger, dispatchTransaction),
6
6
  stopTrigger: () => stopTriggerTransaction(view),
7
7
  };
8
8
  };
@@ -1,6 +1,28 @@
1
- import { b as baseAssignValue } from './_baseAssignValue-C8Uwn8zr.js';
1
+ import { d as defineProperty } from './_defineProperty-yVdnnt__.js';
2
2
  import { e as eq } from './eq-D7VMHFyO.js';
3
3
 
4
+ /**
5
+ * The base implementation of `assignValue` and `assignMergeValue` without
6
+ * value checks.
7
+ *
8
+ * @private
9
+ * @param {Object} object The object to modify.
10
+ * @param {string} key The key of the property to assign.
11
+ * @param {*} value The value to assign.
12
+ */
13
+ function baseAssignValue(object, key, value) {
14
+ if (key == '__proto__' && defineProperty) {
15
+ defineProperty(object, key, {
16
+ 'configurable': true,
17
+ 'enumerable': true,
18
+ 'value': value,
19
+ 'writable': true
20
+ });
21
+ } else {
22
+ object[key] = value;
23
+ }
24
+ }
25
+
4
26
  /** Used for built-in method references. */
5
27
  var objectProto = Object.prototype;
6
28
 
@@ -25,4 +47,4 @@ function assignValue(object, key, value) {
25
47
  }
26
48
  }
27
49
 
28
- export { assignValue as a };
50
+ export { assignValue as a, baseAssignValue as b };
@@ -1,4 +1,5 @@
1
- import { k as keys } from './_baseIsEqual-BvHnKRmD.js';
1
+ import { k as keys } from './_baseIsEqual-BfXMsuGh.js';
2
+ import { i as isArrayLike } from './isArrayLike-D1QkaJU2.js';
2
3
 
3
4
  /**
4
5
  * Creates a base function for methods like `_.forIn` and `_.forOwn`.
@@ -49,4 +50,43 @@ function baseForOwn(object, iteratee) {
49
50
  return object && baseFor(object, iteratee, keys);
50
51
  }
51
52
 
52
- export { baseForOwn as b };
53
+ /**
54
+ * Creates a `baseEach` or `baseEachRight` function.
55
+ *
56
+ * @private
57
+ * @param {Function} eachFunc The function to iterate over a collection.
58
+ * @param {boolean} [fromRight] Specify iterating from right to left.
59
+ * @returns {Function} Returns the new base function.
60
+ */
61
+ function createBaseEach(eachFunc, fromRight) {
62
+ return function(collection, iteratee) {
63
+ if (collection == null) {
64
+ return collection;
65
+ }
66
+ if (!isArrayLike(collection)) {
67
+ return eachFunc(collection, iteratee);
68
+ }
69
+ var length = collection.length,
70
+ index = -1,
71
+ iterable = Object(collection);
72
+
73
+ while ((++index < length)) {
74
+ if (iteratee(iterable[index], index, iterable) === false) {
75
+ break;
76
+ }
77
+ }
78
+ return collection;
79
+ };
80
+ }
81
+
82
+ /**
83
+ * The base implementation of `_.forEach` without support for iteratee shorthands.
84
+ *
85
+ * @private
86
+ * @param {Array|Object} collection The collection to iterate over.
87
+ * @param {Function} iteratee The function invoked per iteration.
88
+ * @returns {Array|Object} Returns `collection`.
89
+ */
90
+ var baseEach = createBaseEach(baseForOwn);
91
+
92
+ export { baseEach as a, baseFor as b, baseForOwn as c };
@@ -3,7 +3,7 @@ import { g as getNative, t as toSource } from './_getNative-aN4R8EiP.js';
3
3
  import { r as root, b as baseGetTag, f as freeGlobal, S as Symbol } from './isObject-BJQylLSL.js';
4
4
  import { i as isArray } from './isArray-B8VKuhvH.js';
5
5
  import { i as isObjectLike } from './isObjectLike-oiMYqRQ0.js';
6
- import { i as isLength, a as isIndex, b as isArrayLike } from './isArrayLike-bWHU4ebg.js';
6
+ import { a as isLength, b as isIndex, i as isArrayLike } from './isArrayLike-D1QkaJU2.js';
7
7
 
8
8
  /* Built-in method references that are verified to be native. */
9
9
  var WeakMap = getNative(root, 'WeakMap');
@@ -1539,4 +1539,4 @@ function baseIsEqual(value, other, bitmask, customizer, stack) {
1539
1539
  return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
1540
1540
  }
1541
1541
 
1542
- export { MapCache as M, Set as S, Uint8Array as U, SetCache as a, baseIsEqual as b, cacheHas as c, isTypedArray as d, isArguments as e, isPrototype as f, getTag as g, baseKeys as h, isBuffer as i, Stack as j, keys as k, arrayPush as l, arrayLikeKeys as m, stubArray as n, overArg as o, getSymbols as p, baseGetAllKeys as q, baseUnary as r, setToArray as s, nodeUtil as t, getAllKeys as u };
1542
+ export { MapCache as M, Stack as S, Uint8Array as U, isTypedArray as a, isArguments as b, SetCache as c, cacheHas as d, baseIsEqual as e, baseTimes as f, Set as g, getTag as h, isBuffer as i, isPrototype as j, keys as k, baseKeys as l, getSymbols as m, baseUnary as n, nodeUtil as o, getAllKeys as p, arrayPush as q, arrayLikeKeys as r, setToArray as s, overArg as t, stubArray as u, baseGetAllKeys as v };
@@ -1,8 +1,8 @@
1
- import { M as MapCache, j as Stack, b as baseIsEqual, k as keys, e as isArguments } from './_baseIsEqual-BvHnKRmD.js';
1
+ import { M as MapCache, S as Stack, e as baseIsEqual, k as keys, b as isArguments } from './_baseIsEqual-BfXMsuGh.js';
2
2
  import { S as Symbol, i as isObject } from './isObject-BJQylLSL.js';
3
3
  import { i as isArray } from './isArray-B8VKuhvH.js';
4
4
  import { i as isSymbol } from './isSymbol-ClAke5ga.js';
5
- import { i as isLength, a as isIndex } from './isArrayLike-bWHU4ebg.js';
5
+ import { a as isLength, b as isIndex } from './isArrayLike-D1QkaJU2.js';
6
6
  import { i as identity } from './identity-CK4jS9_E.js';
7
7
 
8
8
  /**
@@ -596,4 +596,4 @@ function baseIteratee(value) {
596
596
  return property(value);
597
597
  }
598
598
 
599
- export { toKey as a, baseIteratee as b, castPath as c, baseGet as d, arrayMap as e, get as g, hasPath as h, toString as t };
599
+ export { arrayMap as a, baseGet as b, baseIteratee as c, castPath as d, toKey as e, hasPath as f, get as g, hasIn as h, stringToPath as s, toString as t };
@@ -0,0 +1,5 @@
1
+ function getDefaultExportFromCjs (x) {
2
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
3
+ }
4
+
5
+ export { getDefaultExportFromCjs as g };
@@ -0,0 +1,113 @@
1
+ import { j as isPrototype, r as arrayLikeKeys, t as overArg, u as stubArray, q as arrayPush, m as getSymbols, v as baseGetAllKeys } from './_baseIsEqual-BfXMsuGh.js';
2
+ import { i as isObject } from './isObject-BJQylLSL.js';
3
+ import { i as isArrayLike } from './isArrayLike-D1QkaJU2.js';
4
+
5
+ /**
6
+ * This function is like
7
+ * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
8
+ * except that it includes inherited enumerable properties.
9
+ *
10
+ * @private
11
+ * @param {Object} object The object to query.
12
+ * @returns {Array} Returns the array of property names.
13
+ */
14
+ function nativeKeysIn(object) {
15
+ var result = [];
16
+ if (object != null) {
17
+ for (var key in Object(object)) {
18
+ result.push(key);
19
+ }
20
+ }
21
+ return result;
22
+ }
23
+
24
+ /** Used for built-in method references. */
25
+ var objectProto = Object.prototype;
26
+
27
+ /** Used to check objects for own properties. */
28
+ var hasOwnProperty = objectProto.hasOwnProperty;
29
+
30
+ /**
31
+ * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
32
+ *
33
+ * @private
34
+ * @param {Object} object The object to query.
35
+ * @returns {Array} Returns the array of property names.
36
+ */
37
+ function baseKeysIn(object) {
38
+ if (!isObject(object)) {
39
+ return nativeKeysIn(object);
40
+ }
41
+ var isProto = isPrototype(object),
42
+ result = [];
43
+
44
+ for (var key in object) {
45
+ if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
46
+ result.push(key);
47
+ }
48
+ }
49
+ return result;
50
+ }
51
+
52
+ /**
53
+ * Creates an array of the own and inherited enumerable property names of `object`.
54
+ *
55
+ * **Note:** Non-object values are coerced to objects.
56
+ *
57
+ * @static
58
+ * @memberOf _
59
+ * @since 3.0.0
60
+ * @category Object
61
+ * @param {Object} object The object to query.
62
+ * @returns {Array} Returns the array of property names.
63
+ * @example
64
+ *
65
+ * function Foo() {
66
+ * this.a = 1;
67
+ * this.b = 2;
68
+ * }
69
+ *
70
+ * Foo.prototype.c = 3;
71
+ *
72
+ * _.keysIn(new Foo);
73
+ * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
74
+ */
75
+ function keysIn(object) {
76
+ return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
77
+ }
78
+
79
+ /** Built-in value references. */
80
+ var getPrototype = overArg(Object.getPrototypeOf, Object);
81
+
82
+ /* Built-in method references for those with the same name as other `lodash` methods. */
83
+ var nativeGetSymbols = Object.getOwnPropertySymbols;
84
+
85
+ /**
86
+ * Creates an array of the own and inherited enumerable symbols of `object`.
87
+ *
88
+ * @private
89
+ * @param {Object} object The object to query.
90
+ * @returns {Array} Returns the array of symbols.
91
+ */
92
+ var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
93
+ var result = [];
94
+ while (object) {
95
+ arrayPush(result, getSymbols(object));
96
+ object = getPrototype(object);
97
+ }
98
+ return result;
99
+ };
100
+
101
+ /**
102
+ * Creates an array of own and inherited enumerable property names and
103
+ * symbols of `object`.
104
+ *
105
+ * @private
106
+ * @param {Object} object The object to query.
107
+ * @returns {Array} Returns the array of property names and symbols.
108
+ */
109
+ function getAllKeysIn(object) {
110
+ return baseGetAllKeys(object, keysIn, getSymbolsIn);
111
+ }
112
+
113
+ export { getAllKeysIn as a, getSymbolsIn as b, getPrototype as g, keysIn as k };