@limetech/lime-elements 39.13.3 → 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 (180) hide show
  1. package/CHANGELOG.md +7 -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 +13 -478
  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/esm/{_assignValue-DkGAX8ec.js → _assignValue-DOEO9byf.js} +24 -2
  60. package/dist/esm/{_baseForOwn-CfpQNnvA.js → _baseEach-CL_-rBMy.js} +42 -2
  61. package/dist/esm/{_baseIsEqual-BvHnKRmD.js → _baseIsEqual-BfXMsuGh.js} +2 -2
  62. package/dist/esm/{_baseIteratee-DFBCJcMA.js → _baseIteratee-kS1-0_xD.js} +3 -3
  63. package/dist/esm/_commonjsHelpers-B85MJLTf.js +5 -0
  64. package/dist/esm/_getAllKeysIn-BKpeslPJ.js +113 -0
  65. package/dist/esm/_isIterateeCall-CTcCv8Mb.js +69 -0
  66. package/dist/esm/cloneDeep-BXAw5H-1.js +609 -0
  67. package/dist/esm/{isArrayLikeObject-D7yRwRv4.js → difference-DMAjHh-t.js} +91 -7
  68. package/dist/esm/{focus-trigger-element-6aEStEKM.js → focus-trigger-element-DubROLkE.js} +1 -1
  69. package/dist/esm/{format-BMPGHLQ8.js → format-hTrthuPP.js} +1 -1
  70. package/dist/esm/{index-DJJymEnS.js → index-t4DgGbWS.js} +1 -1
  71. package/dist/esm/{isArrayLike-bWHU4ebg.js → isArrayLike-D1QkaJU2.js} +1 -1
  72. package/dist/esm/{isEmpty-tfwtR2ai.js → isEmpty-DrFXbHWO.js} +2 -2
  73. package/dist/esm/{isEqual-BkQ4Z_9r.js → isEqual-CpaoJ_AF.js} +1 -1
  74. package/dist/esm/lime-elements.js +1 -1
  75. package/dist/esm/limel-badge.entry.js +2 -2
  76. package/dist/esm/limel-breadcrumbs_7.entry.js +2 -3
  77. package/dist/esm/limel-chip_2.entry.js +4 -4
  78. package/dist/esm/limel-circular-progress.entry.js +2 -2
  79. package/dist/esm/limel-code-editor.entry.js +1 -1
  80. package/dist/esm/limel-date-picker.entry.js +3 -3
  81. package/dist/esm/limel-dialog.entry.js +3 -3
  82. package/dist/esm/limel-file-dropzone_2.entry.js +4 -43
  83. package/dist/esm/limel-file-viewer.entry.js +2 -2
  84. package/dist/esm/limel-flatpickr-adapter.entry.js +8 -70
  85. package/dist/esm/limel-form.entry.js +38553 -50307
  86. package/dist/esm/limel-markdown.entry.js +3 -3
  87. package/dist/esm/limel-popover_2.entry.js +2 -3
  88. package/dist/esm/limel-prosemirror-adapter.entry.js +12 -477
  89. package/dist/esm/limel-tab-bar.entry.js +4 -83
  90. package/dist/esm/limel-table.entry.js +11 -266
  91. package/dist/esm/loader.js +1 -1
  92. package/dist/esm/{markdown-parser-CXYHPPe2.js → markdown-parser-D7vLKElE.js} +2 -2
  93. package/dist/esm/{moment-DhvPC9Jt.js → moment-DQRNe8qq.js} +1 -1
  94. package/dist/esm/pickBy-BEA90LIZ.js +195 -0
  95. package/dist/esm/{sv-84mf7Xsv.js → sv-CY-6-yEp.js} +1 -1
  96. package/dist/lime-elements/lime-elements.esm.js +1 -1
  97. package/dist/lime-elements/p-1cb2d781.entry.js +13 -0
  98. package/dist/lime-elements/{p-00d6ccd6.entry.js → p-25ae3a55.entry.js} +5 -5
  99. package/dist/lime-elements/{p-be0cbddb.entry.js → p-374ec191.entry.js} +1 -1
  100. package/dist/lime-elements/p-3a662d7e.entry.js +1 -0
  101. package/dist/lime-elements/{p-f0f5eda1.entry.js → p-41be4893.entry.js} +1 -1
  102. package/dist/lime-elements/{p-c84911e6.entry.js → p-4ad193a2.entry.js} +1 -1
  103. package/dist/lime-elements/{p-dd7a2361.entry.js → p-4ce682cf.entry.js} +3 -3
  104. package/dist/lime-elements/{p-eeae0ef6.entry.js → p-5ee484a7.entry.js} +4 -4
  105. package/dist/lime-elements/{p-b1d6553c.entry.js → p-77abb595.entry.js} +1 -1
  106. package/dist/lime-elements/p-8065425a.entry.js +1 -0
  107. package/dist/lime-elements/{p-77ba0f66.entry.js → p-8299af78.entry.js} +1 -1
  108. package/dist/lime-elements/{p-87c5e951.entry.js → p-8c7a7003.entry.js} +1 -1
  109. package/dist/lime-elements/{p-ce20d720.entry.js → p-97c401f1.entry.js} +1 -1
  110. package/dist/lime-elements/p-9a378cf0.entry.js +1 -0
  111. package/dist/lime-elements/p-B3zCFNAw.js +1 -0
  112. package/dist/lime-elements/p-B6bNnxRu.js +1 -0
  113. package/dist/lime-elements/p-B85MJLTf.js +1 -0
  114. package/dist/lime-elements/p-BCMRfUKp.js +1 -0
  115. package/dist/lime-elements/p-BbU4FGNT.js +1 -0
  116. package/dist/lime-elements/p-Bp0tNo1s.js +1 -0
  117. package/dist/lime-elements/{p-DpyWBa_Z.js → p-Bt64o80S.js} +1 -1
  118. package/dist/lime-elements/{p-BqiDn_Sf.js → p-BvDmWgCs.js} +1 -1
  119. package/dist/lime-elements/p-CMjGNANG.js +1 -0
  120. package/dist/lime-elements/p-DFWcgJ_i.js +1 -0
  121. package/dist/lime-elements/{p-B4YDb6f3.js → p-DJvGLFul.js} +1 -1
  122. package/dist/lime-elements/p-DTXIk0fN.js +1 -0
  123. package/dist/lime-elements/{p-BgPHaiMH.js → p-D_uMnX5g.js} +1 -1
  124. package/dist/lime-elements/{p-g3InYy9F.js → p-DdYOzHlg.js} +1 -1
  125. package/dist/lime-elements/{p-ndpPJpml.js → p-DsDkl4Sy.js} +1 -1
  126. package/dist/lime-elements/p-UGKt6Ywx.js +1 -0
  127. package/dist/lime-elements/p-afcf580c.entry.js +16 -0
  128. package/dist/lime-elements/p-b57b08b6.entry.js +1 -0
  129. package/dist/lime-elements/p-v6b303K5.js +1 -0
  130. package/dist/lime-elements/p-xQsJdKrq.js +1 -0
  131. package/dist/lime-elements/{p-BYx8mudw.js → p-zo6O9LC9.js} +2 -2
  132. package/dist/types/components/form/adapters/widget-adapter.d.ts +3 -2
  133. package/dist/types/components/form/fields/array-field.d.ts +11 -19
  134. package/dist/types/components/form/fields/object-field.d.ts +2 -2
  135. package/dist/types/components/form/fields/schema-field.d.ts +5 -18
  136. package/dist/types/components/form/form.d.ts +4 -8
  137. package/dist/types/components/form/form.test-schemas.d.ts +30 -0
  138. package/dist/types/components/form/row/row-context.d.ts +2 -0
  139. package/dist/types/components/form/templates/array-context.d.ts +7 -0
  140. package/dist/types/components/form/templates/array-field-collapsible-item.d.ts +7 -11
  141. package/dist/types/components/form/templates/array-field-item.d.ts +6 -0
  142. package/dist/types/components/form/templates/array-field-simple-item.d.ts +7 -9
  143. package/dist/types/components/form/templates/array-field.d.ts +7 -8
  144. package/dist/types/components/form/templates/index.d.ts +1 -0
  145. package/dist/types/components/form/templates/object-field.d.ts +6 -1
  146. package/dist/types/components/form/templates/types.d.ts +2 -4
  147. package/dist/types/components/form/validation-display.d.ts +60 -0
  148. package/dist/types/components/form/validator.d.ts +6 -0
  149. package/dist/types/components/form/widgets/code-editor.d.ts +1 -1
  150. package/dist/types/components/form/widgets/types.d.ts +1 -1
  151. package/package.json +4 -2
  152. package/dist/cjs/_baseAssignValue-BJgt6T7z.js +0 -27
  153. package/dist/cjs/_commonjsHelpers-BJu3ubxk.js +0 -10
  154. package/dist/cjs/_getPrototype-BK9cL-57.js +0 -8
  155. package/dist/cjs/negate-Bg3SqQh6.js +0 -42
  156. package/dist/collection/components/form/fields/types.js +0 -1
  157. package/dist/collection/components/form/schema-cache.js +0 -66
  158. package/dist/esm/_baseAssignValue-C8Uwn8zr.js +0 -25
  159. package/dist/esm/_commonjsHelpers-BFTU3MAI.js +0 -7
  160. package/dist/esm/_getPrototype-jV9gkkJy.js +0 -6
  161. package/dist/esm/negate-ooVD-6_a.js +0 -40
  162. package/dist/lime-elements/p-45dfcaf3.entry.js +0 -1
  163. package/dist/lime-elements/p-5db2d069.entry.js +0 -1
  164. package/dist/lime-elements/p-9728aa4a.entry.js +0 -1
  165. package/dist/lime-elements/p-BFTU3MAI.js +0 -1
  166. package/dist/lime-elements/p-BlJd1RC5.js +0 -1
  167. package/dist/lime-elements/p-C6SEjICu.js +0 -1
  168. package/dist/lime-elements/p-CqEHNkif.js +0 -1
  169. package/dist/lime-elements/p-Cs5T63LB.js +0 -1
  170. package/dist/lime-elements/p-Cw1B5fXE.js +0 -1
  171. package/dist/lime-elements/p-DKxusNKT.js +0 -1
  172. package/dist/lime-elements/p-DrjUjEz3.js +0 -1
  173. package/dist/lime-elements/p-DzlmgobW.js +0 -1
  174. package/dist/lime-elements/p-ZcW3uvZL.js +0 -1
  175. package/dist/lime-elements/p-a4a09ce9.entry.js +0 -7
  176. package/dist/lime-elements/p-c4e2885d.entry.js +0 -16
  177. package/dist/lime-elements/p-ee80a6f2.entry.js +0 -1
  178. package/dist/lime-elements/p-ooVD-6_a.js +0 -1
  179. package/dist/types/components/form/fields/types.d.ts +0 -41
  180. package/dist/types/components/form/schema-cache.d.ts +0 -17
@@ -2,12 +2,12 @@ import { h, } from "@stencil/core";
2
2
  import React from "react";
3
3
  import { createRoot } from "react-dom/client";
4
4
  import JSONSchemaForm from "@rjsf/core";
5
- import { ArrayFieldTemplate, FieldTemplate, ObjectFieldTemplate, } from "./templates";
5
+ import { ArrayFieldTemplate, ArrayFieldItemTemplate, FieldTemplate, ObjectFieldTemplate, } from "./templates";
6
6
  import { SchemaField as CustomSchemaField } from "./fields/schema-field";
7
7
  import { ArrayField as CustomArrayField } from "./fields/array-field";
8
8
  import { ObjectField as CustomObjectField } from "./fields/object-field";
9
9
  import { widgets } from "./widgets";
10
- import { getValidator, getSchemaId } from "./schema-cache";
10
+ import { rjsfValidator } from "./validator";
11
11
  import { mapValues } from "lodash-es";
12
12
  /**
13
13
  * @exampleComponent limel-example-form
@@ -44,10 +44,6 @@ export class Form {
44
44
  connectedCallback() {
45
45
  this.initialize();
46
46
  }
47
- componentWillLoad() {
48
- this.setSchemaId();
49
- this.createValidator();
50
- }
51
47
  componentDidLoad() {
52
48
  this.initialize();
53
49
  }
@@ -60,11 +56,11 @@ export class Form {
60
56
  }
61
57
  this.initialized = true;
62
58
  this.reactRender();
63
- this.validateForm(this.value);
59
+ this.validateFormData();
64
60
  }
65
61
  componentDidUpdate() {
66
62
  this.reactRender();
67
- this.validateForm(this.value);
63
+ this.validateFormData();
68
64
  }
69
65
  disconnectedCallback() {
70
66
  if (this.root) {
@@ -74,7 +70,7 @@ export class Form {
74
70
  this.initialized = false;
75
71
  }
76
72
  render() {
77
- return h("div", { key: '8e03d70f44885de2f18b20e649cd419e030208fd', class: "root" });
73
+ return h("div", { key: '56c9180ab3e5b4ee3282db2c38b5eaf522e8c60f', class: "root" });
78
74
  }
79
75
  reactRender() {
80
76
  if (!this.root) {
@@ -82,20 +78,24 @@ export class Form {
82
78
  this.root = createRoot(rootElement);
83
79
  }
84
80
  this.root.render(React.createElement(JSONSchemaForm, {
85
- schema: this.modifiedSchema,
81
+ schema: this.schema,
86
82
  formData: this.value,
87
83
  onChange: this.handleChange,
88
84
  widgets: widgets,
89
- liveValidate: true,
85
+ validator: rjsfValidator,
86
+ liveValidate: 'onChange',
90
87
  showErrorList: false,
91
88
  extraErrors: this.getExtraErrors(this.errors),
92
- FieldTemplate: FieldTemplate,
93
- ArrayFieldTemplate: ArrayFieldTemplate,
94
- ObjectFieldTemplate: ObjectFieldTemplate,
89
+ templates: {
90
+ FieldTemplate: FieldTemplate,
91
+ ArrayFieldTemplate: ArrayFieldTemplate,
92
+ ArrayFieldItemTemplate: ArrayFieldItemTemplate,
93
+ ObjectFieldTemplate: ObjectFieldTemplate,
94
+ },
95
95
  disabled: this.disabled,
96
96
  transformErrors: this.getCustomErrorMessages,
97
97
  formContext: {
98
- schema: this.modifiedSchema,
98
+ schema: this.schema,
99
99
  rootValue: this.value,
100
100
  propsFactory: this.propsFactory,
101
101
  },
@@ -109,46 +109,31 @@ export class Form {
109
109
  handleChange(event) {
110
110
  this.change.emit(event.formData);
111
111
  }
112
- validateForm(value) {
113
- const isValid = this.validator(value) === true;
114
- const errors = this.getValidationErrors();
115
- const status = {
116
- valid: isValid,
117
- errors: errors,
118
- };
119
- if (this.isValid !== status.valid || !status.valid) {
120
- this.validate.emit(status);
121
- }
122
- this.isValid = status.valid;
123
- }
124
- setSchema() {
125
- this.setSchemaId();
126
- this.createValidator();
112
+ validateFormData() {
113
+ var _a;
114
+ const { errors } = rjsfValidator.validateFormData((_a = this.value) !== null && _a !== void 0 ? _a : {}, this.schema);
115
+ this.emitValidationStatus(errors);
127
116
  }
128
- setSchemaId() {
129
- // RJSF v2 requires a unique $id per distinct schema to avoid
130
- // validation cache collisions.
131
- // https://github.com/rjsf-team/react-jsonschema-form/issues/1563
132
- const id = getSchemaId(this.schema);
133
- this.modifiedSchema = Object.assign(Object.assign({}, this.schema), { id: id, $id: id });
117
+ hasExtraErrors() {
118
+ return !!this.errors && Object.keys(this.errors).length > 0;
134
119
  }
135
- createValidator() {
136
- this.validator = getValidator(this.schema);
120
+ emitValidationStatus(errors) {
121
+ const valid = (!errors || errors.length === 0) && !this.hasExtraErrors();
122
+ const formErrors = this.mapErrors(errors !== null && errors !== void 0 ? errors : []);
123
+ const status = { valid: valid, errors: formErrors };
124
+ if (this.isValid !== valid || !valid) {
125
+ this.validate.emit(status);
126
+ }
127
+ this.isValid = valid;
137
128
  }
138
- getValidationErrors() {
139
- const errors = [...(this.validator.errors || [])];
140
- return errors.map((error) => {
141
- let property = error.dataPath;
142
- if (error.keyword === 'required') {
143
- property = error.params.missingProperty;
144
- }
145
- return {
146
- name: error.keyword,
147
- property: property,
148
- message: error.message,
149
- schemaPath: error.schemaPath,
150
- };
151
- });
129
+ mapErrors(errors) {
130
+ return errors.map((error) => ({
131
+ name: error.name,
132
+ property: error.property,
133
+ message: error.message,
134
+ schemaPath: error.schemaPath,
135
+ params: error.params,
136
+ }));
152
137
  }
153
138
  getExtraErrors(errors) {
154
139
  if (!errors) {
@@ -165,20 +150,9 @@ export class Form {
165
150
  if (!this.transformErrors) {
166
151
  return originalErrors;
167
152
  }
168
- const errors = originalErrors.map((error) => {
169
- return {
170
- name: error.name,
171
- params: error.params,
172
- property: error.property,
173
- message: error.message,
174
- // For some reason 'schemaPath' is missing from the AjvError type definition:
175
- // https://github.com/rjsf-team/react-jsonschema-form/issues/2140
176
- schemaPath: error['schemaPath'],
177
- };
178
- });
179
- // Use `.call({}, …)` here to bind `this` to an empty object to prevent
180
- // the consumer submitted `transformErrors` from getting access to our
181
- // component's internals. /Ads
153
+ const errors = this.mapErrors(originalErrors);
154
+ // Use `.call({}, …)` to prevent the consumer's `transformErrors`
155
+ // from getting access to our component's internals. /Ads
182
156
  return this.transformErrors
183
157
  .call({}, errors)
184
158
  .map((transformedError) => {
@@ -383,10 +357,4 @@ export class Form {
383
357
  }];
384
358
  }
385
359
  static get elementRef() { return "host"; }
386
- static get watchers() {
387
- return [{
388
- "propName": "schema",
389
- "methodName": "setSchema"
390
- }];
391
- }
392
360
  }
@@ -0,0 +1,308 @@
1
+ export const stringSchema = {
2
+ type: 'object',
3
+ properties: {
4
+ name: { type: 'string', title: 'Name' },
5
+ },
6
+ };
7
+ export const numberSchema = {
8
+ type: 'object',
9
+ properties: {
10
+ age: { type: 'number', title: 'Age' },
11
+ },
12
+ };
13
+ export const booleanSchema = {
14
+ type: 'object',
15
+ properties: {
16
+ active: { type: 'boolean', title: 'Active' },
17
+ },
18
+ };
19
+ export const enumSchema = {
20
+ type: 'object',
21
+ properties: {
22
+ color: {
23
+ type: 'string',
24
+ title: 'Color',
25
+ enum: ['red', 'green', 'blue'],
26
+ },
27
+ },
28
+ };
29
+ export const requiredFieldSchema = {
30
+ type: 'object',
31
+ properties: {
32
+ name: { type: 'string', title: 'Name' },
33
+ },
34
+ required: ['name'],
35
+ };
36
+ export const emailFormatSchema = {
37
+ type: 'object',
38
+ properties: {
39
+ email: { type: 'string', title: 'Email', format: 'email' },
40
+ },
41
+ required: ['email'],
42
+ };
43
+ export const arraySchema = {
44
+ type: 'object',
45
+ properties: {
46
+ tags: {
47
+ type: 'array',
48
+ title: 'Tags',
49
+ items: { type: 'string' },
50
+ },
51
+ },
52
+ };
53
+ export const nestedObjectSchema = {
54
+ type: 'object',
55
+ properties: {
56
+ address: {
57
+ type: 'object',
58
+ title: 'Address',
59
+ properties: {
60
+ street: { type: 'string', title: 'Street' },
61
+ city: { type: 'string', title: 'City' },
62
+ },
63
+ },
64
+ },
65
+ };
66
+ export const arrayOfObjectsSchema = {
67
+ type: 'object',
68
+ properties: {
69
+ heroes: {
70
+ type: 'array',
71
+ title: 'Heroes',
72
+ items: {
73
+ type: 'object',
74
+ title: 'Hero',
75
+ properties: {
76
+ name: { type: 'string', title: 'Name' },
77
+ },
78
+ },
79
+ },
80
+ },
81
+ };
82
+ export const dynamicSchema = {
83
+ type: 'object',
84
+ properties: {
85
+ name: { type: 'string', title: 'Name' },
86
+ },
87
+ };
88
+ export const dynamicSchemaUpdated = {
89
+ type: 'object',
90
+ properties: {
91
+ name: { type: 'string', title: 'Name' },
92
+ email: { type: 'string', title: 'Email' },
93
+ },
94
+ };
95
+ export const helpSchema = {
96
+ type: 'object',
97
+ properties: {
98
+ name: {
99
+ type: 'string',
100
+ title: 'Name',
101
+ lime: {
102
+ help: {
103
+ value: 'Enter your full name',
104
+ },
105
+ },
106
+ },
107
+ },
108
+ };
109
+ export const gridLayoutSchema = {
110
+ type: 'object',
111
+ properties: {
112
+ first: { type: 'string', title: 'First' },
113
+ second: { type: 'string', title: 'Second' },
114
+ },
115
+ lime: {
116
+ layout: {
117
+ type: 'grid',
118
+ columns: 2,
119
+ },
120
+ },
121
+ };
122
+ export const collapsibleSchema = {
123
+ type: 'object',
124
+ properties: {
125
+ details: {
126
+ type: 'object',
127
+ title: 'Details',
128
+ properties: {
129
+ info: { type: 'string', title: 'Info' },
130
+ },
131
+ lime: {
132
+ collapsible: true,
133
+ },
134
+ },
135
+ },
136
+ };
137
+ export const dateSchema = {
138
+ type: 'object',
139
+ properties: {
140
+ birthday: { type: 'string', title: 'Birthday', format: 'date' },
141
+ },
142
+ };
143
+ export const integerSchema = {
144
+ type: 'object',
145
+ properties: {
146
+ count: { type: 'integer', title: 'Count' },
147
+ },
148
+ };
149
+ export const serverErrorsSchema = {
150
+ type: 'object',
151
+ properties: {
152
+ name: { type: 'string', title: 'Name' },
153
+ },
154
+ };
155
+ export const transformErrorsSchema = {
156
+ type: 'object',
157
+ properties: {
158
+ code: { type: 'string', title: 'Code', pattern: '^[A-Z]{3}$' },
159
+ },
160
+ required: ['code'],
161
+ };
162
+ export const customComponentSchema = {
163
+ type: 'object',
164
+ properties: {
165
+ enabled: {
166
+ type: 'boolean',
167
+ title: 'Enabled',
168
+ lime: {
169
+ component: {
170
+ name: 'limel-switch',
171
+ },
172
+ },
173
+ },
174
+ },
175
+ };
176
+ export const undefinedComponentSchema = {
177
+ type: 'object',
178
+ properties: {
179
+ field: {
180
+ type: 'string',
181
+ title: 'Field',
182
+ lime: {
183
+ component: {
184
+ name: 'limel-does-not-exist',
185
+ },
186
+ },
187
+ },
188
+ },
189
+ };
190
+ export const emptySchema = {
191
+ type: 'object',
192
+ properties: {},
193
+ };
194
+ export const hiddenFieldSchema = {
195
+ type: 'object',
196
+ properties: {
197
+ visible: { type: 'string', title: 'Visible' },
198
+ secret: {
199
+ type: 'string',
200
+ title: 'Secret',
201
+ lime: { hidden: true },
202
+ },
203
+ },
204
+ };
205
+ export const readOnlyFieldSchema = {
206
+ type: 'object',
207
+ properties: {
208
+ locked: {
209
+ type: 'string',
210
+ title: 'Locked',
211
+ readOnly: true,
212
+ },
213
+ },
214
+ };
215
+ export const arrayMaxItemsSchema = {
216
+ type: 'object',
217
+ properties: {
218
+ tags: {
219
+ type: 'array',
220
+ title: 'Tags',
221
+ items: { type: 'string' },
222
+ maxItems: 2,
223
+ },
224
+ },
225
+ };
226
+ export const arrayItemControlsSchema = {
227
+ type: 'object',
228
+ properties: {
229
+ items: {
230
+ type: 'array',
231
+ title: 'Items',
232
+ items: { type: 'string' },
233
+ lime: {
234
+ allowItemReorder: false,
235
+ allowItemRemoval: false,
236
+ },
237
+ },
238
+ },
239
+ };
240
+ export const rowLayoutSchema = {
241
+ type: 'object',
242
+ properties: {
243
+ first: {
244
+ type: 'string',
245
+ title: 'First',
246
+ description: 'First field description',
247
+ },
248
+ second: {
249
+ type: 'string',
250
+ title: 'Second',
251
+ description: 'Second field description',
252
+ },
253
+ },
254
+ lime: {
255
+ layout: {
256
+ type: 'row',
257
+ },
258
+ },
259
+ };
260
+ export const rowLayoutWithCustomComponentSchema = {
261
+ type: 'object',
262
+ properties: {
263
+ name: {
264
+ type: 'string',
265
+ title: 'Name',
266
+ description: 'Name description',
267
+ },
268
+ active: {
269
+ type: 'boolean',
270
+ title: 'Active',
271
+ description: 'Active description',
272
+ lime: {
273
+ component: {
274
+ name: 'limel-switch',
275
+ },
276
+ },
277
+ },
278
+ },
279
+ lime: {
280
+ layout: {
281
+ type: 'row',
282
+ },
283
+ },
284
+ };
285
+ export const nestedArrayObjectSchema = {
286
+ type: 'object',
287
+ properties: {
288
+ people: {
289
+ type: 'array',
290
+ title: 'People',
291
+ items: {
292
+ type: 'object',
293
+ title: 'Person',
294
+ properties: {
295
+ name: { type: 'string', title: 'Name' },
296
+ address: {
297
+ type: 'object',
298
+ title: 'Address',
299
+ properties: {
300
+ street: { type: 'string', title: 'Street' },
301
+ city: { type: 'string', title: 'City' },
302
+ },
303
+ },
304
+ },
305
+ },
306
+ },
307
+ },
308
+ };
@@ -0,0 +1,2 @@
1
+ import { createContext } from "react";
2
+ export const RowLayoutContext = createContext(false);
@@ -1,4 +1,5 @@
1
1
  import React from "react";
2
+ import { RowLayoutContext } from "./row-context";
2
3
  export class Row extends React.Component {
3
4
  constructor(props) {
4
5
  super(props);
@@ -37,8 +38,7 @@ export class Row extends React.Component {
37
38
  }
38
39
  }
39
40
  renderChildren() {
40
- const children = this.props.children;
41
- return Object.assign(Object.assign({}, children), { props: Object.assign(Object.assign({}, children.props), { schema: Object.assign(Object.assign({}, children.props.schema), { title: null, description: null }) }) });
41
+ return React.createElement(RowLayoutContext.Provider, { value: true }, this.props.children);
42
42
  }
43
43
  get schema() {
44
44
  return this.props.children.props.schema;
@@ -0,0 +1,2 @@
1
+ import { createContext } from "react";
2
+ export const ArrayFieldContext = createContext(null);
@@ -37,7 +37,7 @@ export class CollapsibleItemTemplate extends React.Component {
37
37
  const { data, schema, formSchema } = this.props;
38
38
  let children;
39
39
  if (this.state.isOpen) {
40
- children = this.props.item.children;
40
+ children = this.props.children;
41
41
  }
42
42
  const dragHandle = this.props.allowItemReorder
43
43
  ? React.createElement('limel-drag-handle', {
@@ -59,14 +59,14 @@ export class CollapsibleItemTemplate extends React.Component {
59
59
  }, dragHandle, children);
60
60
  }
61
61
  setActions(element) {
62
- const { item, index, allowItemRemoval } = this.props;
62
+ const { buttonsProps, allowItemRemoval } = this.props;
63
63
  const actions = [];
64
64
  if (allowItemRemoval) {
65
65
  actions.push({
66
66
  id: 'remove',
67
67
  icon: 'trash',
68
- disabled: !item.hasRemove,
69
- run: item.onDropIndexClick(index),
68
+ disabled: !buttonsProps.hasRemove,
69
+ run: buttonsProps.onRemoveItem,
70
70
  });
71
71
  }
72
72
  element.actions = actions;
@@ -0,0 +1,47 @@
1
+ import React, { useContext } from "react";
2
+ import { isObjectType } from "../schema";
3
+ import { CollapsibleItemTemplate } from "./array-field-collapsible-item";
4
+ import { SimpleItemTemplate } from "./array-field-simple-item";
5
+ import { ArrayFieldContext } from "./array-context";
6
+ export const ArrayFieldItemTemplate = (props) => {
7
+ const arrayContext = useContext(ArrayFieldContext);
8
+ const schema = arrayContext === null || arrayContext === void 0 ? void 0 : arrayContext.arraySchema;
9
+ const formData = arrayContext === null || arrayContext === void 0 ? void 0 : arrayContext.formData;
10
+ const formContext = props.registry.formContext;
11
+ const allowItemReorder = canItemReorder(props, schema);
12
+ const allowItemRemoval = canRemoveItems(schema);
13
+ if (schema && isObjectType(schema.items)) {
14
+ const itemData = Array.isArray(formData)
15
+ ? formData[props.index]
16
+ : undefined;
17
+ return React.createElement(CollapsibleItemTemplate, {
18
+ key: props.itemKey,
19
+ buttonsProps: props.buttonsProps,
20
+ index: props.index,
21
+ data: itemData,
22
+ schema: schema,
23
+ formSchema: formContext === null || formContext === void 0 ? void 0 : formContext.schema,
24
+ allowItemRemoval: allowItemRemoval,
25
+ allowItemReorder: allowItemReorder,
26
+ }, props.children);
27
+ }
28
+ return React.createElement(SimpleItemTemplate, {
29
+ key: props.itemKey,
30
+ buttonsProps: props.buttonsProps,
31
+ index: props.index,
32
+ allowItemRemoval: allowItemRemoval,
33
+ allowItemReorder: allowItemReorder,
34
+ }, props.children);
35
+ };
36
+ function canRemoveItems(schema) {
37
+ const limeOptions = (schema === null || schema === void 0 ? void 0 : schema.lime) || {};
38
+ return limeOptions.allowItemRemoval !== false;
39
+ }
40
+ function canItemReorder(props, schema) {
41
+ const limeOptions = (schema === null || schema === void 0 ? void 0 : schema.lime) || {};
42
+ if (limeOptions.allowItemReorder === false) {
43
+ return false;
44
+ }
45
+ const { buttonsProps } = props;
46
+ return Boolean((buttonsProps === null || buttonsProps === void 0 ? void 0 : buttonsProps.hasMoveDown) || (buttonsProps === null || buttonsProps === void 0 ? void 0 : buttonsProps.hasMoveUp));
47
+ }
@@ -5,8 +5,7 @@ export class SimpleItemTemplate extends React.Component {
5
5
  super(props);
6
6
  this.props = props;
7
7
  this.handleRemove = (event) => {
8
- const { item, index } = this.props;
9
- item.onDropIndexClick(index)(event);
8
+ this.props.buttonsProps.onRemoveItem(event);
10
9
  };
11
10
  this.setRemoveButton = (button) => {
12
11
  if (this.removeButton) {
@@ -22,12 +21,12 @@ export class SimpleItemTemplate extends React.Component {
22
21
  this.setRemoveButton(undefined);
23
22
  }
24
23
  render() {
25
- const { item, allowItemReorder } = this.props;
24
+ const { allowItemReorder } = this.props;
26
25
  return React.createElement('div', {
27
26
  className: 'array-item limel-form-array-item--simple',
28
- 'data-reorder-id': String(this.props.dataIndex),
27
+ 'data-reorder-id': String(this.props.index),
29
28
  'data-reorderable': allowItemReorder ? 'true' : 'false',
30
- }, this.props.item.children, this.renderRemoveButton(item), this.renderDragHandle());
29
+ }, this.props.children, this.renderRemoveButton(), this.renderDragHandle());
31
30
  }
32
31
  renderDragHandle() {
33
32
  if (!this.props.allowItemReorder) {
@@ -37,13 +36,13 @@ export class SimpleItemTemplate extends React.Component {
37
36
  class: 'drag-handle',
38
37
  });
39
38
  }
40
- renderRemoveButton(item) {
39
+ renderRemoveButton() {
41
40
  if (!this.props.allowItemRemoval) {
42
41
  return;
43
42
  }
44
43
  const props = {
45
44
  icon: 'trash',
46
- disabled: !item.hasRemove,
45
+ disabled: !this.props.buttonsProps.hasRemove,
47
46
  ref: this.setRemoveButton,
48
47
  };
49
48
  return React.createElement(LIMEL_ICON_BUTTON, props);