@limetech/lime-elements 39.13.2 → 39.14.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 (186) 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-picker.cjs.entry.js +1 -0
  30. package/dist/cjs/limel-popover_2.cjs.entry.js +2 -3
  31. package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js +13 -478
  32. package/dist/cjs/limel-tab-bar.cjs.entry.js +4 -83
  33. package/dist/cjs/limel-table.cjs.entry.js +17 -272
  34. package/dist/cjs/loader.cjs.js +1 -1
  35. package/dist/cjs/{markdown-parser-DCnW9yak.js → markdown-parser-BIa99LAc.js} +2 -2
  36. package/dist/cjs/{moment-DCqC7BZP.js → moment-CqRdiK10.js} +1 -1
  37. package/dist/cjs/pickBy-kLjYLoam.js +201 -0
  38. package/dist/cjs/{sv-jO-ewmqh.js → sv-BSR4W58y.js} +1 -1
  39. package/dist/collection/components/form/adapters/widget-adapter.js +23 -30
  40. package/dist/collection/components/form/fields/array-field.js +39 -6
  41. package/dist/collection/components/form/fields/field-helpers.js +4 -4
  42. package/dist/collection/components/form/fields/object-field.js +4 -2
  43. package/dist/collection/components/form/fields/schema-field.js +33 -70
  44. package/dist/collection/components/form/form.css +19 -19
  45. package/dist/collection/components/form/form.js +40 -72
  46. package/dist/collection/components/form/form.test-schemas.js +308 -0
  47. package/dist/collection/components/form/row/row-context.js +2 -0
  48. package/dist/collection/components/form/row/row.js +2 -2
  49. package/dist/collection/components/form/templates/array-context.js +2 -0
  50. package/dist/collection/components/form/templates/array-field-collapsible-item.js +4 -4
  51. package/dist/collection/components/form/templates/array-field-item.js +47 -0
  52. package/dist/collection/components/form/templates/array-field-simple-item.js +6 -7
  53. package/dist/collection/components/form/templates/array-field.js +38 -94
  54. package/dist/collection/components/form/templates/index.js +1 -0
  55. package/dist/collection/components/form/templates/object-field.js +15 -11
  56. package/dist/collection/components/form/validation-display.js +75 -0
  57. package/dist/collection/components/form/validator.js +10 -0
  58. package/dist/collection/components/form/widgets/code-editor.js +1 -1
  59. package/dist/collection/components/form/widgets/select.js +2 -1
  60. package/dist/collection/components/picker/picker.js +1 -0
  61. package/dist/collection/components/table/table.js +12 -12
  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-picker.entry.js +1 -0
  91. package/dist/esm/limel-popover_2.entry.js +2 -3
  92. package/dist/esm/limel-prosemirror-adapter.entry.js +12 -477
  93. package/dist/esm/limel-tab-bar.entry.js +4 -83
  94. package/dist/esm/limel-table.entry.js +14 -269
  95. package/dist/esm/loader.js +1 -1
  96. package/dist/esm/{markdown-parser-CXYHPPe2.js → markdown-parser-D7vLKElE.js} +2 -2
  97. package/dist/esm/{moment-DhvPC9Jt.js → moment-DQRNe8qq.js} +1 -1
  98. package/dist/esm/pickBy-BEA90LIZ.js +195 -0
  99. package/dist/esm/{sv-84mf7Xsv.js → sv-CY-6-yEp.js} +1 -1
  100. package/dist/lime-elements/lime-elements.esm.js +1 -1
  101. package/dist/lime-elements/p-1cb2d781.entry.js +13 -0
  102. package/dist/lime-elements/{p-bd77c457.entry.js → p-2160ff6e.entry.js} +1 -1
  103. package/dist/lime-elements/{p-00d6ccd6.entry.js → p-25ae3a55.entry.js} +5 -5
  104. package/dist/lime-elements/{p-be0cbddb.entry.js → p-374ec191.entry.js} +1 -1
  105. package/dist/lime-elements/p-3a662d7e.entry.js +1 -0
  106. package/dist/lime-elements/{p-f0f5eda1.entry.js → p-41be4893.entry.js} +1 -1
  107. package/dist/lime-elements/{p-c84911e6.entry.js → p-4ad193a2.entry.js} +1 -1
  108. package/dist/lime-elements/{p-dd7a2361.entry.js → p-4ce682cf.entry.js} +3 -3
  109. package/dist/lime-elements/{p-eeae0ef6.entry.js → p-5ee484a7.entry.js} +4 -4
  110. package/dist/lime-elements/{p-b1d6553c.entry.js → p-77abb595.entry.js} +1 -1
  111. package/dist/lime-elements/p-8065425a.entry.js +1 -0
  112. package/dist/lime-elements/{p-77ba0f66.entry.js → p-8299af78.entry.js} +1 -1
  113. package/dist/lime-elements/{p-87c5e951.entry.js → p-8c7a7003.entry.js} +1 -1
  114. package/dist/lime-elements/{p-ce20d720.entry.js → p-97c401f1.entry.js} +1 -1
  115. package/dist/lime-elements/p-9a378cf0.entry.js +1 -0
  116. package/dist/lime-elements/p-B3zCFNAw.js +1 -0
  117. package/dist/lime-elements/p-B6bNnxRu.js +1 -0
  118. package/dist/lime-elements/p-B85MJLTf.js +1 -0
  119. package/dist/lime-elements/p-BCMRfUKp.js +1 -0
  120. package/dist/lime-elements/p-BbU4FGNT.js +1 -0
  121. package/dist/lime-elements/p-Bp0tNo1s.js +1 -0
  122. package/dist/lime-elements/{p-DpyWBa_Z.js → p-Bt64o80S.js} +1 -1
  123. package/dist/lime-elements/{p-BqiDn_Sf.js → p-BvDmWgCs.js} +1 -1
  124. package/dist/lime-elements/p-CMjGNANG.js +1 -0
  125. package/dist/lime-elements/p-DFWcgJ_i.js +1 -0
  126. package/dist/lime-elements/{p-B4YDb6f3.js → p-DJvGLFul.js} +1 -1
  127. package/dist/lime-elements/p-DTXIk0fN.js +1 -0
  128. package/dist/lime-elements/{p-BgPHaiMH.js → p-D_uMnX5g.js} +1 -1
  129. package/dist/lime-elements/{p-g3InYy9F.js → p-DdYOzHlg.js} +1 -1
  130. package/dist/lime-elements/{p-ndpPJpml.js → p-DsDkl4Sy.js} +1 -1
  131. package/dist/lime-elements/p-UGKt6Ywx.js +1 -0
  132. package/dist/lime-elements/p-afcf580c.entry.js +16 -0
  133. package/dist/lime-elements/p-b57b08b6.entry.js +1 -0
  134. package/dist/lime-elements/p-v6b303K5.js +1 -0
  135. package/dist/lime-elements/p-xQsJdKrq.js +1 -0
  136. package/dist/lime-elements/{p-BYx8mudw.js → p-zo6O9LC9.js} +2 -2
  137. package/dist/types/components/form/adapters/widget-adapter.d.ts +3 -2
  138. package/dist/types/components/form/fields/array-field.d.ts +11 -19
  139. package/dist/types/components/form/fields/object-field.d.ts +2 -2
  140. package/dist/types/components/form/fields/schema-field.d.ts +5 -18
  141. package/dist/types/components/form/form.d.ts +4 -8
  142. package/dist/types/components/form/form.test-schemas.d.ts +30 -0
  143. package/dist/types/components/form/row/row-context.d.ts +2 -0
  144. package/dist/types/components/form/templates/array-context.d.ts +7 -0
  145. package/dist/types/components/form/templates/array-field-collapsible-item.d.ts +7 -11
  146. package/dist/types/components/form/templates/array-field-item.d.ts +6 -0
  147. package/dist/types/components/form/templates/array-field-simple-item.d.ts +7 -9
  148. package/dist/types/components/form/templates/array-field.d.ts +7 -8
  149. package/dist/types/components/form/templates/index.d.ts +1 -0
  150. package/dist/types/components/form/templates/object-field.d.ts +6 -1
  151. package/dist/types/components/form/templates/types.d.ts +2 -4
  152. package/dist/types/components/form/validation-display.d.ts +60 -0
  153. package/dist/types/components/form/validator.d.ts +6 -0
  154. package/dist/types/components/form/widgets/code-editor.d.ts +1 -1
  155. package/dist/types/components/form/widgets/types.d.ts +1 -1
  156. package/dist/types/components/table/table.d.ts +8 -8
  157. package/package.json +4 -2
  158. package/dist/cjs/_baseAssignValue-BJgt6T7z.js +0 -27
  159. package/dist/cjs/_commonjsHelpers-BJu3ubxk.js +0 -10
  160. package/dist/cjs/_getPrototype-BK9cL-57.js +0 -8
  161. package/dist/cjs/negate-Bg3SqQh6.js +0 -42
  162. package/dist/collection/components/form/fields/types.js +0 -1
  163. package/dist/collection/components/form/schema-cache.js +0 -66
  164. package/dist/esm/_baseAssignValue-C8Uwn8zr.js +0 -25
  165. package/dist/esm/_commonjsHelpers-BFTU3MAI.js +0 -7
  166. package/dist/esm/_getPrototype-jV9gkkJy.js +0 -6
  167. package/dist/esm/negate-ooVD-6_a.js +0 -40
  168. package/dist/lime-elements/p-45dfcaf3.entry.js +0 -1
  169. package/dist/lime-elements/p-5db2d069.entry.js +0 -1
  170. package/dist/lime-elements/p-9728aa4a.entry.js +0 -1
  171. package/dist/lime-elements/p-BFTU3MAI.js +0 -1
  172. package/dist/lime-elements/p-BlJd1RC5.js +0 -1
  173. package/dist/lime-elements/p-C6SEjICu.js +0 -1
  174. package/dist/lime-elements/p-CqEHNkif.js +0 -1
  175. package/dist/lime-elements/p-Cs5T63LB.js +0 -1
  176. package/dist/lime-elements/p-Cw1B5fXE.js +0 -1
  177. package/dist/lime-elements/p-DKxusNKT.js +0 -1
  178. package/dist/lime-elements/p-DrjUjEz3.js +0 -1
  179. package/dist/lime-elements/p-DzlmgobW.js +0 -1
  180. package/dist/lime-elements/p-ZcW3uvZL.js +0 -1
  181. package/dist/lime-elements/p-a4a09ce9.entry.js +0 -7
  182. package/dist/lime-elements/p-ad9cb573.entry.js +0 -1
  183. package/dist/lime-elements/p-c4e2885d.entry.js +0 -16
  184. package/dist/lime-elements/p-ooVD-6_a.js +0 -1
  185. package/dist/types/components/form/fields/types.d.ts +0 -41
  186. package/dist/types/components/form/schema-cache.d.ts +0 -17
@@ -0,0 +1,201 @@
1
+ 'use strict';
2
+
3
+ var _baseIteratee = require('./_baseIteratee-DggA4e7a.js');
4
+ var _assignValue = require('./_assignValue-DpsLUlF4.js');
5
+ var isArrayLike = require('./isArrayLike-_dR1U5-Y.js');
6
+ var isObject = require('./isObject-B6Osvvqp.js');
7
+ var _getAllKeysIn = require('./_getAllKeysIn-BQIV8aw7.js');
8
+
9
+ /** Used for built-in method references. */
10
+ var objectProto = Object.prototype;
11
+
12
+ /** Used to check objects for own properties. */
13
+ var hasOwnProperty = objectProto.hasOwnProperty;
14
+
15
+ /**
16
+ * The base implementation of `_.has` without support for deep paths.
17
+ *
18
+ * @private
19
+ * @param {Object} [object] The object to query.
20
+ * @param {Array|string} key The key to check.
21
+ * @returns {boolean} Returns `true` if `key` exists, else `false`.
22
+ */
23
+ function baseHas(object, key) {
24
+ return object != null && hasOwnProperty.call(object, key);
25
+ }
26
+
27
+ /**
28
+ * Checks if `path` is a direct property of `object`.
29
+ *
30
+ * @static
31
+ * @since 0.1.0
32
+ * @memberOf _
33
+ * @category Object
34
+ * @param {Object} object The object to query.
35
+ * @param {Array|string} path The path to check.
36
+ * @returns {boolean} Returns `true` if `path` exists, else `false`.
37
+ * @example
38
+ *
39
+ * var object = { 'a': { 'b': 2 } };
40
+ * var other = _.create({ 'a': _.create({ 'b': 2 }) });
41
+ *
42
+ * _.has(object, 'a');
43
+ * // => true
44
+ *
45
+ * _.has(object, 'a.b');
46
+ * // => true
47
+ *
48
+ * _.has(object, ['a', 'b']);
49
+ * // => true
50
+ *
51
+ * _.has(other, 'a');
52
+ * // => false
53
+ */
54
+ function has(object, path) {
55
+ return object != null && _baseIteratee.hasPath(object, path, baseHas);
56
+ }
57
+
58
+ /** Error message constants. */
59
+ var FUNC_ERROR_TEXT = 'Expected a function';
60
+
61
+ /**
62
+ * Creates a function that negates the result of the predicate `func`. The
63
+ * `func` predicate is invoked with the `this` binding and arguments of the
64
+ * created function.
65
+ *
66
+ * @static
67
+ * @memberOf _
68
+ * @since 3.0.0
69
+ * @category Function
70
+ * @param {Function} predicate The predicate to negate.
71
+ * @returns {Function} Returns the new negated function.
72
+ * @example
73
+ *
74
+ * function isEven(n) {
75
+ * return n % 2 == 0;
76
+ * }
77
+ *
78
+ * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
79
+ * // => [1, 3, 5]
80
+ */
81
+ function negate(predicate) {
82
+ if (typeof predicate != 'function') {
83
+ throw new TypeError(FUNC_ERROR_TEXT);
84
+ }
85
+ return function() {
86
+ var args = arguments;
87
+ switch (args.length) {
88
+ case 0: return !predicate.call(this);
89
+ case 1: return !predicate.call(this, args[0]);
90
+ case 2: return !predicate.call(this, args[0], args[1]);
91
+ case 3: return !predicate.call(this, args[0], args[1], args[2]);
92
+ }
93
+ return !predicate.apply(this, args);
94
+ };
95
+ }
96
+
97
+ /**
98
+ * The base implementation of `_.set`.
99
+ *
100
+ * @private
101
+ * @param {Object} object The object to modify.
102
+ * @param {Array|string} path The path of the property to set.
103
+ * @param {*} value The value to set.
104
+ * @param {Function} [customizer] The function to customize path creation.
105
+ * @returns {Object} Returns `object`.
106
+ */
107
+ function baseSet(object, path, value, customizer) {
108
+ if (!isObject.isObject(object)) {
109
+ return object;
110
+ }
111
+ path = _baseIteratee.castPath(path, object);
112
+
113
+ var index = -1,
114
+ length = path.length,
115
+ lastIndex = length - 1,
116
+ nested = object;
117
+
118
+ while (nested != null && ++index < length) {
119
+ var key = _baseIteratee.toKey(path[index]),
120
+ newValue = value;
121
+
122
+ if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
123
+ return object;
124
+ }
125
+
126
+ if (index != lastIndex) {
127
+ var objValue = nested[key];
128
+ newValue = customizer ? customizer(objValue, key, nested) : undefined;
129
+ if (newValue === undefined) {
130
+ newValue = isObject.isObject(objValue)
131
+ ? objValue
132
+ : (isArrayLike.isIndex(path[index + 1]) ? [] : {});
133
+ }
134
+ }
135
+ _assignValue.assignValue(nested, key, newValue);
136
+ nested = nested[key];
137
+ }
138
+ return object;
139
+ }
140
+
141
+ /**
142
+ * The base implementation of `_.pickBy` without support for iteratee shorthands.
143
+ *
144
+ * @private
145
+ * @param {Object} object The source object.
146
+ * @param {string[]} paths The property paths to pick.
147
+ * @param {Function} predicate The function invoked per property.
148
+ * @returns {Object} Returns the new object.
149
+ */
150
+ function basePickBy(object, paths, predicate) {
151
+ var index = -1,
152
+ length = paths.length,
153
+ result = {};
154
+
155
+ while (++index < length) {
156
+ var path = paths[index],
157
+ value = _baseIteratee.baseGet(object, path);
158
+
159
+ if (predicate(value, path)) {
160
+ baseSet(result, _baseIteratee.castPath(path, object), value);
161
+ }
162
+ }
163
+ return result;
164
+ }
165
+
166
+ /**
167
+ * Creates an object composed of the `object` properties `predicate` returns
168
+ * truthy for. The predicate is invoked with two arguments: (value, key).
169
+ *
170
+ * @static
171
+ * @memberOf _
172
+ * @since 4.0.0
173
+ * @category Object
174
+ * @param {Object} object The source object.
175
+ * @param {Function} [predicate=_.identity] The function invoked per property.
176
+ * @returns {Object} Returns the new object.
177
+ * @example
178
+ *
179
+ * var object = { 'a': 1, 'b': '2', 'c': 3 };
180
+ *
181
+ * _.pickBy(object, _.isNumber);
182
+ * // => { 'a': 1, 'c': 3 }
183
+ */
184
+ function pickBy(object, predicate) {
185
+ if (object == null) {
186
+ return {};
187
+ }
188
+ var props = _baseIteratee.arrayMap(_getAllKeysIn.getAllKeysIn(object), function(prop) {
189
+ return [prop];
190
+ });
191
+ predicate = _baseIteratee.baseIteratee(predicate);
192
+ return basePickBy(object, props, function(value, path) {
193
+ return predicate(value, path[0]);
194
+ });
195
+ }
196
+
197
+ exports.basePickBy = basePickBy;
198
+ exports.baseSet = baseSet;
199
+ exports.has = has;
200
+ exports.negate = negate;
201
+ exports.pickBy = pickBy;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var moment = require('./moment-DCqC7BZP.js');
3
+ var moment = require('./moment-CqRdiK10.js');
4
4
 
5
5
  var da$1 = {exports: {}};
6
6
 
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
- import { capitalize } from "lodash-es";
2
+ import { hasValue, isFieldInvalid, isFieldRequired, getErrorText, } from "../validation-display";
3
3
  import { getHelpComponent } from "../help";
4
+ import { RowLayoutContext } from "../row/row-context";
4
5
  /**
5
6
  * A widget is a concept in react-jsonschema-form (rjsf).
6
7
  * It represents a HTML tag for the user to enter data, eg. input, select, etc.
@@ -23,47 +24,35 @@ export class LimeElementsWidgetAdapter extends React.Component {
23
24
  };
24
25
  this.handleBlur = this.handleBlur.bind(this);
25
26
  }
26
- hasValue() {
27
- const value = this.getValue();
28
- if (!value) {
29
- return false;
30
- }
31
- if (Array.isArray(value)) {
32
- return value.length > 0;
33
- }
34
- if (value instanceof Date) {
35
- return true;
36
- }
37
- if (typeof value === 'object') {
38
- return Object.entries(value).length > 0;
39
- }
40
- return true;
41
- }
42
27
  handleBlur() {
43
28
  this.setState({ modified: true });
44
29
  }
45
30
  getLabel() {
46
- const { schema, label } = this.props.widgetProps;
31
+ if (this.context) {
32
+ return '';
33
+ }
34
+ const { schema, label, hideLabel } = this.props.widgetProps;
35
+ if (hideLabel) {
36
+ return '';
37
+ }
47
38
  return label || schema.title;
48
39
  }
49
40
  isInvalid() {
50
41
  const { modified } = this.state;
51
- const { rawErrors } = this.props.widgetProps;
52
- return (!!rawErrors && (modified || this.hasValue() || !this.isRequired()));
53
- }
54
- isRequired() {
55
- const { required, schema } = this.props.widgetProps;
56
- return required || schema.minItems > 0;
42
+ const { rawErrors, required, schema } = this.props.widgetProps;
43
+ return isFieldInvalid({
44
+ hasErrors: !!rawErrors,
45
+ modified: modified,
46
+ hasValue: hasValue(this.getValue()),
47
+ required: isFieldRequired({ required, minItems: schema.minItems }),
48
+ });
57
49
  }
58
50
  getHelperText() {
59
51
  const { rawErrors, schema } = this.props.widgetProps;
60
52
  if (!this.isInvalid()) {
61
- return schema.description;
62
- }
63
- if (rawErrors) {
64
- return capitalize(rawErrors[0]);
53
+ return this.context ? '' : schema.description;
65
54
  }
66
- return schema.description;
55
+ return getErrorText(rawErrors || [], schema.description);
67
56
  }
68
57
  getValue() {
69
58
  const { value } = this.props;
@@ -76,7 +65,10 @@ export class LimeElementsWidgetAdapter extends React.Component {
76
65
  const disabled = this.isDisabled();
77
66
  const value = this.getValue();
78
67
  const readonly = this.isReadOnly();
79
- return React.createElement(React.Fragment, {}, React.createElement(name, Object.assign(Object.assign({ value: value, label: this.getLabel(), disabled: disabled, readonly: readonly, required: this.isRequired(), invalid: this.isInvalid(), 'helper-text': this.getHelperText() }, extraProps), { onChange: this.handleChange, onBlur: this.handleBlur })), getHelpComponent(this.props.widgetProps.schema));
68
+ return React.createElement(React.Fragment, {}, React.createElement(name, Object.assign(Object.assign({ value: value, label: this.getLabel(), disabled: disabled, readonly: readonly, required: isFieldRequired({
69
+ required: this.props.widgetProps.required,
70
+ minItems: this.props.widgetProps.schema.minItems,
71
+ }), invalid: this.isInvalid(), 'helper-text': this.getHelperText() }, extraProps), { onChange: this.handleChange, onBlur: this.handleBlur })), getHelpComponent(this.props.widgetProps.schema));
80
72
  }
81
73
  isDisabled() {
82
74
  var _a, _b;
@@ -91,3 +83,4 @@ export class LimeElementsWidgetAdapter extends React.Component {
91
83
  return widgetProps.readonly;
92
84
  }
93
85
  }
86
+ LimeElementsWidgetAdapter.contextType = RowLayoutContext;
@@ -1,6 +1,9 @@
1
- import JSONArrayField from "@rjsf/core/lib/components/fields/ArrayField";
2
1
  import React from "react";
2
+ import { getDefaultRegistry } from "@rjsf/core";
3
3
  import { resetDependentFields } from "./field-helpers";
4
+ import { ARRAY_REORDER_EVENT } from "../templates/array-field";
5
+ const { fields: defaultFields } = getDefaultRegistry();
6
+ const BaseArrayField = defaultFields.ArrayField;
4
7
  /**
5
8
  * This override field exists to supplement the need to reset dependent fields
6
9
  * in SchemaField. The `resetDependentFields` function requires that the schema that
@@ -14,6 +17,10 @@ import { resetDependentFields } from "./field-helpers";
14
17
  * `resetDependentFields` on the changed list items. This is possible because the ArrayField is also given
15
18
  * the raw schema so it can properly call `resetDependentFields`
16
19
  *
20
+ * This field also handles drag-and-drop reordering. The ArrayFieldTemplate
21
+ * dispatches an `arrayReorder` DOM event when Sortable.js completes a drag.
22
+ * This field listens for that event and reorders the form data via onChange.
23
+ *
17
24
  * This form has to handle several events that can affect the list:
18
25
  *
19
26
  * 1. An on change where no list item changes
@@ -32,20 +39,46 @@ export class ArrayField extends React.Component {
32
39
  constructor(props) {
33
40
  super(props);
34
41
  this.handleChange = this.handleChange.bind(this);
42
+ this.handleReorder = this.handleReorder.bind(this);
43
+ this.setWrapper = this.setWrapper.bind(this);
44
+ }
45
+ componentWillUnmount() {
46
+ this.setWrapper(null);
47
+ }
48
+ setWrapper(element) {
49
+ if (this.wrapper) {
50
+ this.wrapper.removeEventListener(ARRAY_REORDER_EVENT, this.handleReorder);
51
+ }
52
+ this.wrapper = element !== null && element !== void 0 ? element : undefined;
53
+ if (this.wrapper) {
54
+ this.wrapper.addEventListener(ARRAY_REORDER_EVENT, this.handleReorder);
55
+ }
56
+ }
57
+ handleReorder(event) {
58
+ event.stopPropagation();
59
+ const { fromIndex, toIndex } = event.detail;
60
+ const { formData, fieldPathId } = this.props;
61
+ if (!Array.isArray(formData) || !fieldPathId) {
62
+ return;
63
+ }
64
+ const reordered = [...formData];
65
+ const [item] = reordered.splice(fromIndex, 1);
66
+ reordered.splice(toIndex, 0, item);
67
+ this.props.onChange(reordered, fieldPathId.path);
35
68
  }
36
- handleChange(newData, errorSchema) {
69
+ handleChange(newData, path) {
37
70
  const { formData: oldData, schema } = this.props;
38
71
  const { rootSchema } = this.props.registry;
39
72
  // This case handles when the first list item is added. When there are no
40
73
  // items we get undefined instead of []
41
74
  if (!oldData) {
42
- this.props.onChange(newData, errorSchema);
75
+ this.props.onChange(newData, path);
43
76
  return;
44
77
  }
45
78
  // This case happens when we add or remove an item from the list
46
79
  // No need to check for resetting fields unless we change data
47
80
  if (oldData.length !== newData.length) {
48
- this.props.onChange(newData, errorSchema);
81
+ this.props.onChange(newData, path);
49
82
  return;
50
83
  }
51
84
  const nonMatchingIndices = [];
@@ -63,10 +96,10 @@ export class ArrayField extends React.Component {
63
96
  const i = nonMatchingIndices[0];
64
97
  newData[i] = resetDependentFields(oldData[i], newData[i], schema.items, rootSchema);
65
98
  }
66
- this.props.onChange(newData, errorSchema);
99
+ this.props.onChange(newData, path);
67
100
  }
68
101
  render() {
69
102
  const arrayProps = Object.assign(Object.assign({}, this.props), { onChange: this.handleChange });
70
- return React.createElement(JSONArrayField, arrayProps);
103
+ return React.createElement('div', { ref: this.setWrapper }, React.createElement(BaseArrayField, arrayProps));
71
104
  }
72
105
  }
@@ -1,5 +1,6 @@
1
1
  import { union, isEqual, isPlainObject, negate } from "lodash-es";
2
- import { retrieveSchema, ADDITIONAL_PROPERTY_FLAG } from "@rjsf/core/lib/utils";
2
+ import { retrieveSchema, ADDITIONAL_PROPERTY_FLAG } from "@rjsf/utils";
3
+ import { rjsfValidator } from "../validator";
3
4
  /**
4
5
  * Given two objects, get a list of keys for each value that is different between
5
6
  * the two objects. Compares using deep comparison
@@ -35,9 +36,8 @@ export const resetDependentFields = (oldData, newData, schema, rootSchema) => {
35
36
  return newData;
36
37
  }
37
38
  // Get the schema generated by the current data
38
- const currentSchema = retrieveSchema(schema, rootSchema, oldData);
39
- // Get the new schema that is calculated for the new data
40
- const newSchema = retrieveSchema(schema, rootSchema, newData);
39
+ const currentSchema = retrieveSchema(rjsfValidator, schema, rootSchema, oldData);
40
+ const newSchema = retrieveSchema(rjsfValidator, schema, rootSchema, newData);
41
41
  // Get property keys whose schema changed due to the new data.
42
42
  // These properties that have changed are the properties that are dependent on
43
43
  // data that has changed in the current onChange event
@@ -1,12 +1,14 @@
1
- import JSONObjectField from "@rjsf/core/lib/components/fields/ObjectField";
2
1
  import React from "react";
2
+ import { getDefaultRegistry } from "@rjsf/core";
3
3
  import { CodeEditor } from "../widgets/code-editor";
4
4
  import { renderDescription, renderTitle } from "../templates/common";
5
5
  import { isCustomObjectSchema } from "./field-helpers";
6
+ const { fields: defaultFields } = getDefaultRegistry();
7
+ const BaseObjectField = defaultFields.ObjectField;
6
8
  export class ObjectField extends React.Component {
7
9
  render() {
8
10
  if (!isCustomObjectSchema(this.props.schema)) {
9
- return React.createElement(JSONObjectField, this.props);
11
+ return React.createElement(BaseObjectField, this.props);
10
12
  }
11
13
  return React.createElement(React.Fragment, {}, renderTitle(this.props.schema.title), renderDescription(this.props.schema.description), React.createElement(CodeEditor, this.props));
12
14
  }
@@ -1,10 +1,14 @@
1
- import JSONSchemaField from "@rjsf/core/lib/components/fields/SchemaField";
2
1
  import React from "react";
3
- import { isEmpty, capitalize } from "lodash-es";
2
+ import { getDefaultRegistry } from "@rjsf/core";
3
+ import { isEmpty } from "lodash-es";
4
+ import { hasValue, isFieldInvalid, isFieldRequired, getErrorText, } from "../validation-display";
4
5
  import { resetDependentFields } from "./field-helpers";
5
6
  import { FieldTemplate } from "../templates";
6
7
  import { getHelpComponent } from "../help";
7
8
  import { TimePicker } from "../widgets/time-picker";
9
+ import { RowLayoutContext } from "../row/row-context";
10
+ const { fields: defaultFields } = getDefaultRegistry();
11
+ const BaseSchemaField = defaultFields.SchemaField;
8
12
  /**
9
13
  * If given a value and schema, check if the value should be translated
10
14
  * from null to undefined to avoid issues with validation
@@ -48,10 +52,6 @@ const hasCustomComponent = (schema) => {
48
52
  return true;
49
53
  };
50
54
  const verifyCustomComponentIsDefined = (elementName) => {
51
- const supportsCustomElements = 'customElements' in window;
52
- if (!supportsCustomElements) {
53
- throw new Error('Custom form elements are not supported by this browser!');
54
- }
55
55
  if (!customElements.get(elementName)) {
56
56
  throw new Error(`Custom form element '${elementName}' is not defined!`);
57
57
  }
@@ -90,51 +90,23 @@ export class SchemaField extends React.Component {
90
90
  this.handleCustomComponentChange =
91
91
  this.handleCustomComponentChange.bind(this);
92
92
  }
93
- hasValue() {
94
- const value = this.getValue();
95
- if (!value) {
96
- return false;
97
- }
98
- if (Array.isArray(value)) {
99
- return value.length > 0;
100
- }
101
- if (value instanceof Date) {
102
- return true;
103
- }
104
- if (typeof value === 'object') {
105
- return !isEmpty(value);
106
- }
107
- return true;
108
- }
109
- getLabel() {
110
- const { schema } = this.props;
111
- return schema.title;
112
- }
113
93
  isInvalid() {
114
94
  const { modified } = this.state;
115
- const { errorSchema } = this.props;
116
- return ((modified || this.hasValue() || !this.isRequired()) &&
117
- !isEmpty(errorSchema));
118
- }
119
- isRequired() {
120
- const { required, schema } = this.props;
121
- return required || schema.minItems > 0;
95
+ const { errorSchema, required, schema } = this.props;
96
+ return isFieldInvalid({
97
+ hasErrors: !isEmpty(errorSchema),
98
+ modified: modified,
99
+ hasValue: hasValue(this.props.formData),
100
+ required: isFieldRequired({ required, minItems: schema.minItems }),
101
+ });
122
102
  }
123
103
  getHelperText() {
124
104
  var _a, _b, _c;
125
105
  const { errorSchema, schema } = this.props;
126
- if (!this.isInvalid()) {
127
- const helperText = (_c = (_b = (_a = schema.lime) === null || _a === void 0 ? void 0 : _a.component) === null || _b === void 0 ? void 0 : _b.props) === null || _c === void 0 ? void 0 : _c.helperText;
128
- return helperText || schema.description;
129
- }
130
- if (!isEmpty(errorSchema) && '__errors' in errorSchema) {
131
- return capitalize(errorSchema.__errors[0]);
132
- }
133
- return schema.description;
134
- }
135
- getValue() {
136
- const { formData } = this.props;
137
- return formData;
106
+ const hasErrors = !isEmpty(errorSchema) && '__errors' in errorSchema;
107
+ const errors = this.isInvalid() && hasErrors ? errorSchema.__errors : [];
108
+ const fallbackText = (_c = (_b = (_a = schema.lime) === null || _a === void 0 ? void 0 : _a.component) === null || _b === void 0 ? void 0 : _b.props) === null || _c === void 0 ? void 0 : _c.helperText;
109
+ return getErrorText(errors, schema.description, fallbackText);
138
110
  }
139
111
  handleCustomComponentChange(event) {
140
112
  const { schema } = this.props;
@@ -143,35 +115,41 @@ export class SchemaField extends React.Component {
143
115
  if (shouldChangeToUndefined(value, schema)) {
144
116
  value = undefined;
145
117
  }
146
- this.handleChange(value);
118
+ this.handleChange(value, this.props.fieldPathId.path);
147
119
  }
148
- handleChange(data) {
120
+ handleChange(data, path) {
149
121
  const { formData, schema } = this.props;
150
122
  const { rootSchema } = this.props.registry;
151
123
  this.setState({ modified: true });
152
124
  const newData = resetDependentFields(formData, data, schema, rootSchema);
153
- this.props.onChange(newData);
125
+ this.props.onChange(newData, path);
154
126
  }
155
127
  buildCustomComponentProps() {
156
- const { disabled, readonly, name, registry, schema, errorSchema, idSchema, } = this.props;
128
+ const { disabled, readonly, name, registry, schema: rawSchema, errorSchema, fieldPathId, } = this.props;
129
+ const schema = rawSchema;
157
130
  const factoryProps = getFactoryProps(registry.formContext, schema);
158
- return Object.assign(Object.assign({}, factoryProps), { value: this.getValue(), required: this.isRequired(), readonly: readonly || schema.readOnly, disabled: disabled, invalid: this.isInvalid(), label: this.getLabel(), helperText: this.getHelperText(), ref: (element) => {
131
+ return Object.assign(Object.assign({}, factoryProps), { value: this.props.formData, required: isFieldRequired({
132
+ required: this.props.required,
133
+ minItems: schema.minItems,
134
+ }), readonly: readonly || schema.readOnly, disabled: disabled, invalid: this.isInvalid(), label: this.context ? '' : schema.title, helperText: this.context && !this.isInvalid() ? '' : this.getHelperText(), ref: (element) => {
135
+ var _a;
159
136
  element.formInfo = {
160
137
  schema: schema,
161
138
  rootSchema: registry.formContext.schema,
162
139
  errorSchema: errorSchema,
163
140
  rootValue: registry.formContext.rootValue,
164
141
  name: name,
165
- schemaPath: this.getSchemaPath(idSchema === null || idSchema === void 0 ? void 0 : idSchema.$id),
142
+ schemaPath: (_a = fieldPathId === null || fieldPathId === void 0 ? void 0 : fieldPathId.path) === null || _a === void 0 ? void 0 : _a.map(String),
166
143
  };
167
144
  return () => { };
168
145
  } });
169
146
  }
170
147
  renderCustomComponent(props) {
171
- const { name, props: userDefinedComponentProps } = getCustomComponent(props.schema);
148
+ const schema = props.schema;
149
+ const { name, props: userDefinedComponentProps } = getCustomComponent(schema);
172
150
  verifyCustomComponentIsDefined(name);
173
151
  const component = React.createElement(name, Object.assign(Object.assign(Object.assign({}, userDefinedComponentProps), this.buildCustomComponentProps()), { onChange: this.handleCustomComponentChange }));
174
- return React.createElement(FieldTemplate, Object.assign(Object.assign({}, this.props), { classNames: 'form-group field field-custom' }), component, getHelpComponent(props.schema));
152
+ return React.createElement(FieldTemplate, Object.assign(Object.assign({}, this.props), { classNames: 'rjsf-field rjsf-field-custom' }), component, getHelpComponent(schema));
175
153
  }
176
154
  render() {
177
155
  var _a;
@@ -185,22 +163,7 @@ export class SchemaField extends React.Component {
185
163
  if (this.props.schema.format === 'time') {
186
164
  fieldProps.uiSchema = Object.assign({ 'ui:widget': TimePicker }, fieldProps.uiSchema);
187
165
  }
188
- return React.createElement(JSONSchemaField, fieldProps);
189
- }
190
- /**
191
- * Gets the path to the current property within the schema
192
- *
193
- * @param schemaId - the id of the schema
194
- * @returns an array with the schema path for the current property
195
- * @example
196
- * const schemaId = 'root_sections_0_controls_0_name';
197
- * const schemaPath = getSchemaPath(schemaId);
198
- * // ➡ ['sections', '0', 'controls', '0', 'name']
199
- */
200
- getSchemaPath(schemaId) {
201
- if (schemaId === undefined) {
202
- return undefined;
203
- }
204
- return schemaId.replace('root_', '').split('_');
166
+ return React.createElement(BaseSchemaField, fieldProps);
205
167
  }
206
168
  }
169
+ SchemaField.contextType = RowLayoutContext;