@luomus/laji-form 15.1.4 → 15.1.6

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 (235) hide show
  1. package/lib/ApiClient.d.ts +46 -0
  2. package/lib/ApiClient.js +93 -0
  3. package/lib/Context.d.ts +8 -0
  4. package/lib/Context.js +18 -0
  5. package/lib/ReactContext.d.ts +7 -0
  6. package/lib/ReactContext.js +5 -0
  7. package/lib/components/BaseComponent.d.ts +9 -0
  8. package/lib/components/BaseComponent.js +29 -0
  9. package/lib/components/LajiForm.d.ts +221 -0
  10. package/lib/components/LajiForm.js +616 -0
  11. package/lib/components/VirtualSchemaField.d.ts +42 -0
  12. package/lib/components/VirtualSchemaField.js +74 -0
  13. package/lib/components/components.d.ts +119 -0
  14. package/lib/components/components.js +606 -0
  15. package/lib/components/fields/AnnotationField.d.ts +34 -0
  16. package/lib/components/fields/AnnotationField.js +242 -0
  17. package/lib/components/fields/AnyToBooleanField.d.ts +18 -0
  18. package/lib/components/fields/AnyToBooleanField.js +20 -0
  19. package/lib/components/fields/ArrayBulkField.d.ts +23 -0
  20. package/lib/components/fields/ArrayBulkField.js +82 -0
  21. package/lib/components/fields/ArrayCombinerField.d.ts +36 -0
  22. package/lib/components/fields/ArrayCombinerField.js +138 -0
  23. package/lib/components/fields/ArrayField.d.ts +39 -0
  24. package/lib/components/fields/ArrayField.js +148 -0
  25. package/lib/components/fields/AsArrayField.d.ts +292 -0
  26. package/lib/components/fields/AsArrayField.js +38 -0
  27. package/lib/components/fields/AudioArrayField.d.ts +22 -0
  28. package/lib/components/fields/AudioArrayField.js +100 -0
  29. package/lib/components/fields/AutoArrayField.d.ts +24 -0
  30. package/lib/components/fields/AutoArrayField.js +56 -0
  31. package/lib/components/fields/AutosuggestField.d.ts +69 -0
  32. package/lib/components/fields/AutosuggestField.js +299 -0
  33. package/lib/components/fields/CombinedValueDisplayField.d.ts +41 -0
  34. package/lib/components/fields/CombinedValueDisplayField.js +100 -0
  35. package/lib/components/fields/ConditionalOnChangeField.d.ts +42 -0
  36. package/lib/components/fields/ConditionalOnChangeField.js +107 -0
  37. package/lib/components/fields/ConditionalUiSchemaField.d.ts +123 -0
  38. package/lib/components/fields/ConditionalUiSchemaField.js +143 -0
  39. package/lib/components/fields/ContextInjectionField.d.ts +24 -0
  40. package/lib/components/fields/ContextInjectionField.js +68 -0
  41. package/lib/components/fields/DataLeakerField.d.ts +40 -0
  42. package/lib/components/fields/DataLeakerField.js +68 -0
  43. package/lib/components/fields/DefaultValueArrayField.d.ts +34 -0
  44. package/lib/components/fields/DefaultValueArrayField.js +59 -0
  45. package/lib/components/fields/DependentBooleanField.d.ts +38 -0
  46. package/lib/components/fields/DependentBooleanField.js +87 -0
  47. package/lib/components/fields/DependentDisableField.d.ts +35 -0
  48. package/lib/components/fields/DependentDisableField.js +71 -0
  49. package/lib/components/fields/EnumRangeArrayField.d.ts +27 -0
  50. package/lib/components/fields/EnumRangeArrayField.js +115 -0
  51. package/lib/components/fields/ExtraLabelRowField.d.ts +38 -0
  52. package/lib/components/fields/ExtraLabelRowField.js +100 -0
  53. package/lib/components/fields/FakePropertyField.d.ts +18 -0
  54. package/lib/components/fields/FakePropertyField.js +48 -0
  55. package/lib/components/fields/FilterArrayField.d.ts +73 -0
  56. package/lib/components/fields/FilterArrayField.js +121 -0
  57. package/lib/components/fields/FlatField.d.ts +29 -0
  58. package/lib/components/fields/FlatField.js +171 -0
  59. package/lib/components/fields/GeocoderField.d.ts +47 -0
  60. package/lib/components/fields/GeocoderField.js +372 -0
  61. package/lib/components/fields/GridLayoutField.d.ts +18 -0
  62. package/lib/components/fields/GridLayoutField.js +32 -0
  63. package/lib/components/fields/HiddenField.d.ts +10 -0
  64. package/lib/components/fields/HiddenField.js +11 -0
  65. package/lib/components/fields/ImageArrayField.d.ts +172 -0
  66. package/lib/components/fields/ImageArrayField.js +699 -0
  67. package/lib/components/fields/ImageDisplayField.d.ts +18 -0
  68. package/lib/components/fields/ImageDisplayField.js +44 -0
  69. package/lib/components/fields/InitiallyHiddenField.d.ts +21 -0
  70. package/lib/components/fields/InitiallyHiddenField.js +58 -0
  71. package/lib/components/fields/InjectDefaultValueField.d.ts +37 -0
  72. package/lib/components/fields/InjectDefaultValueField.js +68 -0
  73. package/lib/components/fields/InjectField.d.ts +46 -0
  74. package/lib/components/fields/InjectField.js +88 -0
  75. package/lib/components/fields/InputWithDefaultValueButtonField.d.ts +25 -0
  76. package/lib/components/fields/InputWithDefaultValueButtonField.js +61 -0
  77. package/lib/components/fields/LocalityField.d.ts +22 -0
  78. package/lib/components/fields/LocalityField.js +94 -0
  79. package/lib/components/fields/LocationChooserField.d.ts +27 -0
  80. package/lib/components/fields/LocationChooserField.js +440 -0
  81. package/lib/components/fields/MapArrayField.d.ts +78 -0
  82. package/lib/components/fields/MapArrayField.js +1783 -0
  83. package/lib/components/fields/MapField.d.ts +48 -0
  84. package/lib/components/fields/MapField.js +434 -0
  85. package/lib/components/fields/MultiAnyToBooleanField.d.ts +25 -0
  86. package/lib/components/fields/MultiAnyToBooleanField.js +100 -0
  87. package/lib/components/fields/MultiArrayField.d.ts +53 -0
  88. package/lib/components/fields/MultiArrayField.js +224 -0
  89. package/lib/components/fields/MultiLanguageField.d.ts +13 -0
  90. package/lib/components/fields/MultiLanguageField.js +52 -0
  91. package/lib/components/fields/MultiTagArrayField.d.ts +36 -0
  92. package/lib/components/fields/MultiTagArrayField.js +142 -0
  93. package/lib/components/fields/NamedPlaceChooserField.d.ts +29 -0
  94. package/lib/components/fields/NamedPlaceChooserField.js +380 -0
  95. package/lib/components/fields/NamedPlaceSaverField.d.ts +29 -0
  96. package/lib/components/fields/NamedPlaceSaverField.js +237 -0
  97. package/lib/components/fields/NestField.d.ts +148 -0
  98. package/lib/components/fields/NestField.js +289 -0
  99. package/lib/components/fields/ObjectField.d.ts +2 -0
  100. package/lib/components/fields/ObjectField.js +119 -0
  101. package/lib/components/fields/PdfArrayField.d.ts +21 -0
  102. package/lib/components/fields/PdfArrayField.js +40 -0
  103. package/lib/components/fields/PrefillingArrayField.d.ts +22 -0
  104. package/lib/components/fields/PrefillingArrayField.js +65 -0
  105. package/lib/components/fields/SchemaField.d.ts +7 -0
  106. package/lib/components/fields/SchemaField.js +109 -0
  107. package/lib/components/fields/ScopeField.d.ts +85 -0
  108. package/lib/components/fields/ScopeField.js +521 -0
  109. package/lib/components/fields/SectionArrayField.d.ts +38 -0
  110. package/lib/components/fields/SectionArrayField.js +618 -0
  111. package/lib/components/fields/SelectTreeField.d.ts +39 -0
  112. package/lib/components/fields/SelectTreeField.js +143 -0
  113. package/lib/components/fields/SingleActiveArrayField.d.ts +49 -0
  114. package/lib/components/fields/SingleActiveArrayField.js +974 -0
  115. package/lib/components/fields/SingleItemArrayField.d.ts +15 -0
  116. package/lib/components/fields/SingleItemArrayField.js +60 -0
  117. package/lib/components/fields/SortArrayField.d.ts +73 -0
  118. package/lib/components/fields/SortArrayField.js +351 -0
  119. package/lib/components/fields/SplitField.d.ts +28 -0
  120. package/lib/components/fields/SplitField.js +65 -0
  121. package/lib/components/fields/StringToArrayField.d.ts +24 -0
  122. package/lib/components/fields/StringToArrayField.js +48 -0
  123. package/lib/components/fields/SumField.d.ts +35 -0
  124. package/lib/components/fields/SumField.js +83 -0
  125. package/lib/components/fields/TableField.d.ts +18 -0
  126. package/lib/components/fields/TableField.js +136 -0
  127. package/lib/components/fields/TagArrayField.d.ts +38 -0
  128. package/lib/components/fields/TagArrayField.js +128 -0
  129. package/lib/components/fields/ToggleAdditionalArrayFieldsField.d.ts +26 -0
  130. package/lib/components/fields/ToggleAdditionalArrayFieldsField.js +81 -0
  131. package/lib/components/fields/UiFieldApplierField.d.ts +30 -0
  132. package/lib/components/fields/UiFieldApplierField.js +106 -0
  133. package/lib/components/fields/UiFieldMapperArrayField.d.ts +42 -0
  134. package/lib/components/fields/UiFieldMapperArrayField.js +121 -0
  135. package/lib/components/fields/UnitCountShorthandField.d.ts +22 -0
  136. package/lib/components/fields/UnitCountShorthandField.js +149 -0
  137. package/lib/components/fields/UnitListShorthandArrayField.d.ts +26 -0
  138. package/lib/components/fields/UnitListShorthandArrayField.js +108 -0
  139. package/lib/components/fields/UnitShorthandField.d.ts +32 -0
  140. package/lib/components/fields/UnitShorthandField.js +220 -0
  141. package/lib/components/templates/ArrayFieldTemplate.d.ts +85 -0
  142. package/lib/components/templates/ArrayFieldTemplate.js +416 -0
  143. package/lib/components/templates/BaseInputTemplate.d.ts +11 -0
  144. package/lib/components/templates/BaseInputTemplate.js +80 -0
  145. package/lib/components/templates/DescriptionField.d.ts +1 -0
  146. package/lib/components/templates/DescriptionField.js +37 -0
  147. package/lib/components/templates/ErrorListTemplate.d.ts +9 -0
  148. package/lib/components/templates/ErrorListTemplate.js +95 -0
  149. package/lib/components/templates/FieldTemplate.d.ts +6 -0
  150. package/lib/components/templates/FieldTemplate.js +112 -0
  151. package/lib/components/templates/ObjectFieldTemplate.d.ts +7 -0
  152. package/lib/components/templates/ObjectFieldTemplate.js +66 -0
  153. package/lib/components/templates/TitleField.d.ts +9 -0
  154. package/lib/components/templates/TitleField.js +51 -0
  155. package/lib/components/widgets/AnyToBooleanWidget.d.ts +20 -0
  156. package/lib/components/widgets/AnyToBooleanWidget.js +49 -0
  157. package/lib/components/widgets/AutosuggestWidget.d.ts +66 -0
  158. package/lib/components/widgets/AutosuggestWidget.js +1127 -0
  159. package/lib/components/widgets/CheckboxWidget.d.ts +37 -0
  160. package/lib/components/widgets/CheckboxWidget.js +139 -0
  161. package/lib/components/widgets/DateTimeWidget.d.ts +62 -0
  162. package/lib/components/widgets/DateTimeWidget.js +251 -0
  163. package/lib/components/widgets/DateWidget.d.ts +23 -0
  164. package/lib/components/widgets/DateWidget.js +41 -0
  165. package/lib/components/widgets/HiddenWidget.d.ts +15 -0
  166. package/lib/components/widgets/HiddenWidget.js +19 -0
  167. package/lib/components/widgets/ImageSelectWidget.d.ts +14 -0
  168. package/lib/components/widgets/ImageSelectWidget.js +57 -0
  169. package/lib/components/widgets/InformalTaxonGroupChooserWidget.d.ts +43 -0
  170. package/lib/components/widgets/InformalTaxonGroupChooserWidget.js +237 -0
  171. package/lib/components/widgets/InputGroupWidget.d.ts +21 -0
  172. package/lib/components/widgets/InputGroupWidget.js +36 -0
  173. package/lib/components/widgets/InputWithDefaultValueButtonWidget.d.ts +21 -0
  174. package/lib/components/widgets/InputWithDefaultValueButtonWidget.js +47 -0
  175. package/lib/components/widgets/NumberWidget.d.ts +13 -0
  176. package/lib/components/widgets/NumberWidget.js +21 -0
  177. package/lib/components/widgets/PlainTextWidget.d.ts +12 -0
  178. package/lib/components/widgets/PlainTextWidget.js +24 -0
  179. package/lib/components/widgets/SelectWidget.d.ts +52 -0
  180. package/lib/components/widgets/SelectWidget.js +158 -0
  181. package/lib/components/widgets/SeparatedDateTimeWidget.d.ts +19 -0
  182. package/lib/components/widgets/SeparatedDateTimeWidget.js +59 -0
  183. package/lib/components/widgets/TaxonImageWidget.d.ts +13 -0
  184. package/lib/components/widgets/TaxonImageWidget.js +30 -0
  185. package/lib/components/widgets/TextSelectWidget.d.ts +25 -0
  186. package/lib/components/widgets/TextSelectWidget.js +94 -0
  187. package/lib/components/widgets/TextareaWidget.d.ts +32 -0
  188. package/lib/components/widgets/TextareaWidget.js +87 -0
  189. package/lib/components/widgets/TimeWidget.d.ts +11 -0
  190. package/lib/components/widgets/TimeWidget.js +19 -0
  191. package/lib/components/widgets/URLWidget.d.ts +14 -0
  192. package/lib/components/widgets/URLWidget.js +12 -0
  193. package/lib/components/widgets/UpperCaseWidget.d.ts +13 -0
  194. package/lib/components/widgets/UpperCaseWidget.js +21 -0
  195. package/lib/index.d.ts +20 -0
  196. package/lib/index.js +50 -0
  197. package/lib/services/blocker-service.d.ts +11 -0
  198. package/lib/services/blocker-service.js +55 -0
  199. package/lib/services/custom-event-service.d.ts +17 -0
  200. package/lib/services/custom-event-service.js +35 -0
  201. package/lib/services/dom-id-service.d.ts +8 -0
  202. package/lib/services/dom-id-service.js +30 -0
  203. package/lib/services/focus-service.d.ts +13 -0
  204. package/lib/services/focus-service.js +60 -0
  205. package/lib/services/id-service.d.ts +22 -0
  206. package/lib/services/id-service.js +130 -0
  207. package/lib/services/key-handler-service.d.ts +56 -0
  208. package/lib/services/key-handler-service.js +184 -0
  209. package/lib/services/root-instance-service.d.ts +25 -0
  210. package/lib/services/root-instance-service.js +49 -0
  211. package/lib/services/settings-service.d.ts +34 -0
  212. package/lib/services/settings-service.js +154 -0
  213. package/lib/services/singleton-map-service.d.ts +23 -0
  214. package/lib/services/singleton-map-service.js +44 -0
  215. package/lib/services/submit-hook-service.d.ts +24 -0
  216. package/lib/services/submit-hook-service.js +73 -0
  217. package/lib/styles.d.ts +1 -0
  218. package/lib/styles.js +4 -0
  219. package/lib/themes/bs3.d.ts +3 -0
  220. package/lib/themes/bs3.js +133 -0
  221. package/lib/themes/bs5.d.ts +3 -0
  222. package/lib/themes/bs5.js +111 -0
  223. package/lib/themes/glyphicon-fa-mapping.d.ts +3 -0
  224. package/lib/themes/glyphicon-fa-mapping.js +271 -0
  225. package/lib/themes/stub.d.ts +3 -0
  226. package/lib/themes/stub.js +82 -0
  227. package/lib/themes/theme.d.ts +233 -0
  228. package/lib/themes/theme.js +2 -0
  229. package/lib/translations.json +847 -0
  230. package/lib/utils.d.ts +167 -0
  231. package/lib/utils.js +1185 -0
  232. package/lib/validation.d.ts +7 -0
  233. package/lib/validation.js +141 -0
  234. package/package.json +2 -2
  235. package/patches/protractor++webdriver-manager+12.1.8.patch +0 -20395
@@ -0,0 +1,148 @@
1
+ export function getPropsForFields({ schema, uiSchema, idSchema, errorSchema, formData, onChange }: {
2
+ schema: any;
3
+ uiSchema: any;
4
+ idSchema: any;
5
+ errorSchema: any;
6
+ formData: any;
7
+ onChange: any;
8
+ }, fields: any, title: any): {
9
+ schema: {
10
+ type: string;
11
+ properties: {};
12
+ title: any;
13
+ };
14
+ uiSchema: {};
15
+ idSchema: {
16
+ $id: any;
17
+ };
18
+ errorSchema: {};
19
+ formData: {};
20
+ onChange: ((formData: any) => any) | undefined;
21
+ };
22
+ /**
23
+ * Makes it possible to extract fields from object schema and
24
+ * make them act like a nested schema without touching the form data structure.
25
+ *
26
+ * uiSchema = {
27
+ * title: <string>,
28
+ * ui:options: {
29
+ * nests: {
30
+ * fieldName: {
31
+ * fields: [<string>],
32
+ * title: <string>,
33
+ * }
34
+ * },
35
+ * uiSchema: <uiSchema>
36
+ * }
37
+ * }
38
+ *
39
+ * Example usage:
40
+ *
41
+ * schema = {
42
+ * "type": "object",
43
+ * "properties": {
44
+ * "inner_1" { "type": "string" },
45
+ * "inner_2": { "type": "string" },
46
+ * "innerOfInner_1": { "type": "string" },
47
+ * "innerOfInner_2": { "type": "string" },
48
+ * "secondInner_1" { "type": "string" },
49
+ * "secondInner_2": { "type": "string" },
50
+ * "outer_2": { "type": "string" }
51
+ * }
52
+ *
53
+ * uiSchema = {
54
+ * "ui:field": "nest",
55
+ * "ui:options": {
56
+ * "nests": {
57
+ * "inner": {
58
+ * "fields": ["inner_1", "inner_2"],
59
+ * "title": "title of inner",
60
+ * "uiSchema": {
61
+ * "ui:field": "someField"
62
+ * "inner_1": {
63
+ * "ui:field": "someField2"
64
+ * }
65
+ * }
66
+ * },
67
+ * "secondInner": {
68
+ * "fields": ["secondInner_1", "secondInner_2"],
69
+ * "uiSchema": {
70
+ * "ui:field": "someField3"
71
+ * }
72
+ * }
73
+ * },
74
+ * "uiSchema": {
75
+ * "ui:field": "container"
76
+ * }
77
+ * }
78
+ *
79
+ * would make the schemas look like this:
80
+ *
81
+ * schema = {
82
+ * "type": "object",
83
+ * "properties": {
84
+ * "inner": {
85
+ * "type": "object",
86
+ * "title": "title of inner",
87
+ * "properties": {
88
+ * "inner_1": {
89
+ * "type": "string"
90
+ * },
91
+ * "inner_2": {
92
+ * "type": "string"
93
+ * }
94
+ * }
95
+ * },
96
+ * "inner2": {
97
+ * "type: "object",
98
+ * "properties": {
99
+ * "secondInner_1": {
100
+ * "type": "string"
101
+ * },
102
+ * "secondInner_2": {
103
+ * "type": "string"
104
+ * }
105
+ * }
106
+ * },
107
+ * }
108
+ * }
109
+ *
110
+ * uiSchema = {
111
+ * "ui:field": "container",
112
+ * "inner": {
113
+ * "ui:field": "someField"
114
+ * "inner_1": {
115
+ * "ui:field": "someField2"
116
+ * }
117
+ * },
118
+ * "inner2": {
119
+ * "ui:field": "someField3"
120
+ * }
121
+ * }
122
+ *
123
+ */
124
+ export default class NestField extends React.Component<any, any, any> {
125
+ static propTypes: {
126
+ uiSchema: PropTypes.Validator<PropTypes.InferProps<{
127
+ "ui:options": PropTypes.Requireable<PropTypes.InferProps<PropTypes.ValidationMap<any>>>;
128
+ }>>;
129
+ schema: PropTypes.Validator<PropTypes.InferProps<{
130
+ type: PropTypes.Requireable<string>;
131
+ }>>;
132
+ formData: PropTypes.Requireable<object>;
133
+ };
134
+ static getName(): string;
135
+ constructor(props: any);
136
+ constructor(props: any, context: any);
137
+ getStateFromProps(props: any, origProps: any): {
138
+ schema: any;
139
+ uiSchema: any;
140
+ idSchema: any;
141
+ errorSchema: any;
142
+ formData: any;
143
+ onChange: (formData?: {}) => void;
144
+ };
145
+ onChange: (formData?: {}) => void;
146
+ }
147
+ import * as React from "react";
148
+ import * as PropTypes from "prop-types";
@@ -0,0 +1,289 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.getPropsForFields = void 0;
10
+ const React = require("react");
11
+ const PropTypes = require("prop-types");
12
+ const immutability_helper_1 = require("immutability-helper");
13
+ const utils_1 = require("../../utils");
14
+ const VirtualSchemaField_1 = require("../VirtualSchemaField");
15
+ const deepmerge = require("deepmerge");
16
+ /**
17
+ * Makes it possible to extract fields from object schema and
18
+ * make them act like a nested schema without touching the form data structure.
19
+ *
20
+ * uiSchema = {
21
+ * title: <string>,
22
+ * ui:options: {
23
+ * nests: {
24
+ * fieldName: {
25
+ * fields: [<string>],
26
+ * title: <string>,
27
+ * }
28
+ * },
29
+ * uiSchema: <uiSchema>
30
+ * }
31
+ * }
32
+ *
33
+ * Example usage:
34
+ *
35
+ * schema = {
36
+ * "type": "object",
37
+ * "properties": {
38
+ * "inner_1" { "type": "string" },
39
+ * "inner_2": { "type": "string" },
40
+ * "innerOfInner_1": { "type": "string" },
41
+ * "innerOfInner_2": { "type": "string" },
42
+ * "secondInner_1" { "type": "string" },
43
+ * "secondInner_2": { "type": "string" },
44
+ * "outer_2": { "type": "string" }
45
+ * }
46
+ *
47
+ * uiSchema = {
48
+ * "ui:field": "nest",
49
+ * "ui:options": {
50
+ * "nests": {
51
+ * "inner": {
52
+ * "fields": ["inner_1", "inner_2"],
53
+ * "title": "title of inner",
54
+ * "uiSchema": {
55
+ * "ui:field": "someField"
56
+ * "inner_1": {
57
+ * "ui:field": "someField2"
58
+ * }
59
+ * }
60
+ * },
61
+ * "secondInner": {
62
+ * "fields": ["secondInner_1", "secondInner_2"],
63
+ * "uiSchema": {
64
+ * "ui:field": "someField3"
65
+ * }
66
+ * }
67
+ * },
68
+ * "uiSchema": {
69
+ * "ui:field": "container"
70
+ * }
71
+ * }
72
+ *
73
+ * would make the schemas look like this:
74
+ *
75
+ * schema = {
76
+ * "type": "object",
77
+ * "properties": {
78
+ * "inner": {
79
+ * "type": "object",
80
+ * "title": "title of inner",
81
+ * "properties": {
82
+ * "inner_1": {
83
+ * "type": "string"
84
+ * },
85
+ * "inner_2": {
86
+ * "type": "string"
87
+ * }
88
+ * }
89
+ * },
90
+ * "inner2": {
91
+ * "type: "object",
92
+ * "properties": {
93
+ * "secondInner_1": {
94
+ * "type": "string"
95
+ * },
96
+ * "secondInner_2": {
97
+ * "type": "string"
98
+ * }
99
+ * }
100
+ * },
101
+ * }
102
+ * }
103
+ *
104
+ * uiSchema = {
105
+ * "ui:field": "container",
106
+ * "inner": {
107
+ * "ui:field": "someField"
108
+ * "inner_1": {
109
+ * "ui:field": "someField2"
110
+ * }
111
+ * },
112
+ * "inner2": {
113
+ * "ui:field": "someField3"
114
+ * }
115
+ * }
116
+ *
117
+ */
118
+ let NestField = class NestField extends React.Component {
119
+ constructor() {
120
+ super(...arguments);
121
+ this.onChange = (formData = {}) => {
122
+ const { nests } = this.getUiOptions();
123
+ Object.keys(nests).reverse().forEach(nestName => {
124
+ if (formData[nestName]) {
125
+ Object.keys(formData[nestName]).forEach(prop => {
126
+ if (prop in formData[nestName])
127
+ formData = Object.assign(Object.assign({}, formData), { [prop]: formData[nestName][prop] });
128
+ });
129
+ formData = utils_1.immutableDelete(formData, nestName);
130
+ }
131
+ });
132
+ this.props.onChange(formData);
133
+ };
134
+ }
135
+ static getName() { return "NestField"; }
136
+ getStateFromProps(props, origProps) {
137
+ let { schema, uiSchema, idSchema, errorSchema, formData = {} } = props;
138
+ const { nests, buttonsNest, buttons } = utils_1.getUiOptions(origProps.uiSchema);
139
+ const uiButtons = uiSchema["ui:buttons"];
140
+ const nestedPropsMap = {};
141
+ const nestNames = Object.keys(nests).reduce((names, name) => {
142
+ names[name] = true;
143
+ return names;
144
+ }, {});
145
+ Object.keys(nests).forEach((wrapperFieldName) => {
146
+ const nest = nests[wrapperFieldName];
147
+ const nestedProps = getPropsForFields({ schema, uiSchema, idSchema, errorSchema, formData }, nests[wrapperFieldName].fields, nest.title);
148
+ nestedPropsMap[wrapperFieldName] = nestedProps;
149
+ schema = Object.assign(Object.assign({}, schema), { properties: Object.assign(Object.assign({}, schema.properties), { [wrapperFieldName]: nestedProps.schema }) });
150
+ let nestedIdSchema = nestedProps.idSchema;
151
+ nest.fields.forEach(field => {
152
+ if (nestNames[field]) {
153
+ nestedIdSchema[field] = nestedPropsMap[field].idSchema;
154
+ }
155
+ });
156
+ idSchema = Object.assign(Object.assign({}, idSchema), { [wrapperFieldName]: nestedIdSchema });
157
+ errorSchema = Object.assign(Object.assign({}, errorSchema), { [wrapperFieldName]: nestedProps.errorSchema });
158
+ formData = Object.assign(Object.assign({}, formData), { [wrapperFieldName]: nestedProps.formData });
159
+ uiSchema = Object.assign(Object.assign({}, uiSchema), { [wrapperFieldName]: Object.assign(Object.assign(Object.assign({}, nestedProps.uiSchema), (nests[wrapperFieldName] ? nests[wrapperFieldName].rootUiSchema : {} || {})), (uiSchema[wrapperFieldName] || {})) });
160
+ if (nest.rootUiSchema) {
161
+ uiSchema = Object.assign(Object.assign({}, uiSchema), { [wrapperFieldName]: Object.assign(Object.assign({}, (nest.rootUiSchema || {})), (uiSchema[wrapperFieldName] || {})) });
162
+ }
163
+ nest.fields.forEach(fieldName => {
164
+ if (uiSchema[fieldName]) {
165
+ uiSchema[wrapperFieldName][fieldName] = deepmerge(uiSchema[wrapperFieldName][fieldName] || {}, uiSchema[fieldName], {
166
+ arrayMerge: (a1, a2) => a2
167
+ });
168
+ }
169
+ [schema.properties, errorSchema, idSchema, formData, uiSchema].forEach(container => {
170
+ delete container[fieldName];
171
+ });
172
+ if (schema.required)
173
+ schema.required = schema.required.filter(requiredField => requiredField !== fieldName);
174
+ });
175
+ });
176
+ if (buttonsNest && nests[buttonsNest]) {
177
+ if (uiButtons) {
178
+ uiSchema = {
179
+ "ui:buttons": undefined,
180
+ [buttonsNest]: Object.assign(Object.assign({}, (uiSchema[buttonsNest] || [])), { "ui:buttons": [
181
+ ...uiSchema["ui:buttons"]
182
+ ] })
183
+ };
184
+ }
185
+ if (buttons) {
186
+ let nestOptions = utils_1.getUiOptions(uiSchema[buttonsNest]);
187
+ let _buttons = nestOptions.buttons || [];
188
+ uiSchema = Object.assign(Object.assign({}, uiSchema), { "ui:options": Object.assign(Object.assign({}, uiSchema["ui:options"]), { buttons: undefined }), [buttonsNest]: Object.assign(Object.assign({}, uiSchema[buttonsNest]), { "ui:options": Object.assign(Object.assign({}, nestOptions), { buttons: [..._buttons, ...buttons] }) }) });
189
+ }
190
+ }
191
+ const { "ui:order": order = [] } = uiSchema;
192
+ const dictionarifiedOrder = order.reduce((dict, field, idx) => {
193
+ dict[field] = idx;
194
+ return dict;
195
+ }, {});
196
+ const splices = [];
197
+ if (order) {
198
+ Object.keys(nests).forEach(nestName => {
199
+ const { fields } = nests[nestName];
200
+ fields.forEach(field => {
201
+ const idx = dictionarifiedOrder[field];
202
+ if (idx !== undefined) {
203
+ splices.push([idx, 1]);
204
+ }
205
+ });
206
+ });
207
+ if (splices.length)
208
+ uiSchema = immutability_helper_1.default(uiSchema, { "ui:order": { $splice: splices.sort(([idx], [_idx]) => _idx - idx) } });
209
+ }
210
+ return { schema, uiSchema, idSchema, errorSchema, formData, onChange: this.onChange };
211
+ }
212
+ };
213
+ NestField.propTypes = {
214
+ uiSchema: PropTypes.shape({
215
+ "ui:options": PropTypes.shape({
216
+ "nests": function (props, propName, componentName) {
217
+ for (let optionProp in props["ui:options"]) {
218
+ const prop = props["ui:options"][optionProp];
219
+ if (!prop.fields || !Array.isArray(prop.fields)) {
220
+ return new Error("Required prop '" + propName + "." + optionProp + ".fields' was not specified in '" + componentName + "'");
221
+ }
222
+ }
223
+ }
224
+ }),
225
+ }).isRequired,
226
+ schema: PropTypes.shape({
227
+ type: PropTypes.oneOf(["object"])
228
+ }).isRequired,
229
+ formData: PropTypes.object
230
+ };
231
+ NestField = __decorate([
232
+ VirtualSchemaField_1.default
233
+ ], NestField);
234
+ exports.default = NestField;
235
+ function getPropsForFields({ schema, uiSchema, idSchema, errorSchema, formData, onChange }, fields, title) {
236
+ const newSchema = { type: "object", properties: {}, title };
237
+ const newErrorSchema = {};
238
+ const newFormData = {};
239
+ const newUiSchema = uiSchema
240
+ ? ["ui:classNames", "classNames"].reduce((_uiSchema, prop) => {
241
+ if (prop in uiSchema)
242
+ _uiSchema[prop] = uiSchema[prop];
243
+ return _uiSchema;
244
+ }, {})
245
+ : {};
246
+ const newIdSchema = { $id: idSchema.$id };
247
+ const fieldsDictionarified = {};
248
+ // For keeping field names compatible with idSchema.
249
+ const flattenPointerName = fieldName => fieldName[0] === "/" ? fieldName.replace(/(?!^)\//g, "_").substr(1) : fieldName;
250
+ fields.forEach(fieldName => {
251
+ [
252
+ [schema.properties, newSchema.properties, utils_1.schemaJSONPointer(schema.properties, fieldName)],
253
+ [uiSchema, newUiSchema, utils_1.uiSchemaJSONPointer(schema.properties, fieldName)],
254
+ [errorSchema, newErrorSchema, fieldName],
255
+ [formData, newFormData, fieldName],
256
+ [idSchema, newIdSchema, fieldName]
257
+ ].forEach(([originalPropContainer, newPropContainer, _fieldName]) => {
258
+ if (_fieldName !== undefined && utils_1.checkJSONPointer(originalPropContainer, _fieldName)) {
259
+ newPropContainer[flattenPointerName(fieldName)] = utils_1.parseJSONPointer(originalPropContainer, _fieldName);
260
+ }
261
+ });
262
+ fieldsDictionarified[fieldName] = true;
263
+ });
264
+ // TODO Doesn't work for JSON Pointer fields.
265
+ if (uiSchema["ui:order"])
266
+ newUiSchema["ui:order"] = uiSchema["ui:order"].filter(ord => fieldsDictionarified[ord] || ord === "*");
267
+ if (schema.required)
268
+ newSchema.required = schema.required.filter(req => fieldsDictionarified[req]);
269
+ const newOnChange = formData => {
270
+ let newFormData = fields.reduce((_formData, field) => {
271
+ _formData = utils_1.updateSafelyWithJSONPointer(_formData, _formData[flattenPointerName[field]], field, !!"immutably", (__formData, path) => {
272
+ const _schema = utils_1.parseJSONPointer(schema, utils_1.schemaJSONPointer(schema, path));
273
+ return utils_1.getDefaultFormState(_schema);
274
+ });
275
+ _formData = utils_1.immutableDelete(_formData, flattenPointerName(field));
276
+ return _formData;
277
+ }, formData);
278
+ return onChange(newFormData);
279
+ };
280
+ return {
281
+ schema: newSchema,
282
+ uiSchema: newUiSchema,
283
+ idSchema: newIdSchema,
284
+ errorSchema: newErrorSchema,
285
+ formData: newFormData,
286
+ onChange: onChange ? newOnChange : undefined
287
+ };
288
+ }
289
+ exports.getPropsForFields = getPropsForFields;
@@ -0,0 +1,2 @@
1
+ declare function _default(props: any): JSX.Element;
2
+ export default _default;
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const React = require("react");
4
+ const utils_1 = require("@rjsf/utils");
5
+ const utils_2 = require("../../utils");
6
+ const ArrayFieldTemplate_1 = require("../templates/ArrayFieldTemplate");
7
+ const ReactContext_1 = require("../../ReactContext");
8
+ const core_1 = require("@rjsf/core");
9
+ const ObjectFieldTemplate_1 = require("../templates/ObjectFieldTemplate");
10
+ exports.default = (props) => {
11
+ const id = utils_2.getUUID(props.formData);
12
+ const formContext = id
13
+ ? Object.assign(Object.assign({}, props.formContext), { _parentLajiFormId: id }) : props.formContext;
14
+ const uiSchema = props.uiSchema["ui:grid"] && !props.uiSchema["ui:ObjectFieldTemplate"]
15
+ ? Object.assign(Object.assign({}, props.uiSchema), { "ui:ObjectFieldTemplate": GridTemplate }) : props.uiSchema;
16
+ const { ObjectField } = core_1.getDefaultRegistry().fields;
17
+ return React.createElement(ObjectField, Object.assign({}, props, { uiSchema: uiSchema, registry: Object.assign(Object.assign({}, props.registry), { formContext }), formContext: formContext }));
18
+ };
19
+ function GridTemplate(props) {
20
+ const { schema, uiSchema, idSchema, properties } = props;
21
+ const TitleFieldTemplate = utils_1.getTemplate("TitleFieldTemplate", props.registry, utils_2.getUiOptions(props.uiSchema));
22
+ const gridOptions = props.uiSchema["ui:grid"] || {};
23
+ const { ButtonToolbar, Row, Col } = React.useContext(ReactContext_1.default).theme;
24
+ const rows = [];
25
+ const lastRow = [];
26
+ const colsToRows = {};
27
+ (gridOptions.rows || []).forEach((row, i) => {
28
+ row.forEach(col => {
29
+ colsToRows[col] = i;
30
+ });
31
+ });
32
+ const { rowTitles = [], classNames = {} } = gridOptions;
33
+ const { Label } = props.formContext;
34
+ const addRowTitles = (rows, rowTitles) => {
35
+ for (let i = 0; i < rowTitles.length; i++) {
36
+ rows[i] = [];
37
+ const titleCols = getCols(props, { type: "string" }, uiSchema["rowTitle"], "rowTitle");
38
+ rows[i].push(React.createElement(Col, Object.assign({}, titleCols, { key: "title_" + i, className: classNames["rowTitle"] }),
39
+ React.createElement(Label, { id: idSchema.$id + "_row_" + i, label: rowTitles[i].title, uiSchema: { "ui:help": rowTitles[i].help } })));
40
+ }
41
+ };
42
+ function getRow(col, colsToRows, rows) {
43
+ const colRow = colsToRows[col];
44
+ if (colRow !== undefined) {
45
+ if (!rows[colRow])
46
+ rows[colRow] = [];
47
+ return rows[colRow];
48
+ }
49
+ else {
50
+ return lastRow;
51
+ }
52
+ }
53
+ addRowTitles(rows, rowTitles);
54
+ utils_1.orderProperties(Object.keys(schema.properties), uiSchema["ui:order"]).forEach(propertyName => {
55
+ const property = schema.properties[propertyName];
56
+ if (!property)
57
+ return;
58
+ const uiSchemaProperty = uiSchema[propertyName];
59
+ const cols = getCols(props, property, uiSchemaProperty, propertyName);
60
+ const propertiesByName = properties.reduce((propertiesByName, _prop) => {
61
+ propertiesByName[_prop.name] = _prop;
62
+ return propertiesByName;
63
+ }, {});
64
+ if (!utils_2.isHidden(uiSchema, propertyName))
65
+ getRow(propertyName, colsToRows, rows).push(React.createElement(Col, Object.assign({}, cols, { className: classNames[propertyName], key: propertyName }), propertiesByName[propertyName].content));
66
+ });
67
+ if (lastRow.length > 0)
68
+ rows.push(lastRow);
69
+ const { title } = schema;
70
+ const { "ui:title": _title } = uiSchema;
71
+ let fieldTitle = _title || (title !== undefined ? title : props.name);
72
+ let buttons = ObjectFieldTemplate_1.getGlyphButtons(props);
73
+ const [topButtons, bottomButtons, leftButtons, rightButtons] = ["top", "bottom", "left", "right"].map(pos => {
74
+ const buttons = ArrayFieldTemplate_1.getButtonsForPosition(props, utils_2.getUiOptions(uiSchema).buttons, pos, "no default");
75
+ return buttons
76
+ ? (React.createElement(ButtonToolbar, { key: `buttons-${pos}` }, ArrayFieldTemplate_1.getButtonsForPosition(props, utils_2.getUiOptions(uiSchema).buttons, pos, "no default"))) : null;
77
+ });
78
+ const { containerClassName, schemaClassName, buttonsClassName } = ObjectFieldTemplate_1.getObjectTemplateClassNames(props, buttons);
79
+ buttons = React.createElement("div", { className: buttonsClassName }, buttons);
80
+ const titleUiSchema = Object.assign(Object.assign({}, uiSchema), { "ui:renderedButtons": buttons });
81
+ return (React.createElement("div", { className: containerClassName },
82
+ React.createElement("fieldset", { className: schemaClassName },
83
+ !utils_2.isEmptyString(fieldTitle) ?
84
+ React.createElement(TitleFieldTemplate, { title: fieldTitle, schema: schema, uiSchema: titleUiSchema, registry: props.registry, id: idSchema.$id }) : null,
85
+ topButtons,
86
+ leftButtons && React.createElement("div", { className: "pull-left" }, leftButtons),
87
+ rows.map((row, i) => React.createElement(Row, { key: i }, row)),
88
+ rightButtons && React.createElement("div", { className: "pull-right" }, rightButtons),
89
+ bottomButtons),
90
+ !props.title && buttons ? buttons : null));
91
+ }
92
+ function getCols(props, schema, uiSchema, property) {
93
+ const options = props.uiSchema["ui:grid"];
94
+ const cols = { lg: 12, md: 12, sm: 12, xs: 12 };
95
+ const uiField = uiSchema && uiSchema["ui:field"] ? uiSchema["ui:field"] : undefined;
96
+ Object.keys(cols).forEach(col => {
97
+ const optionCol = options[col];
98
+ if ((!utils_2.isObject(optionCol) || !optionCol[property])
99
+ && schema.type === "array"
100
+ && !(schema.items && schema.items.enum && utils_2.isMultiSelect(schema, uiSchema)
101
+ || uiField === "SingleItemArrayField"
102
+ || (schema.items && schema.items.type === "string" && uiField !== "ImageArrayField" && uiField !== "AudioArrayField"))
103
+ || (schema.type === "string" && uiSchema && utils_2.getNestedUiFieldsList(uiSchema).includes("SelectTreeField"))) {
104
+ return cols;
105
+ }
106
+ if (utils_2.isObject(optionCol)) {
107
+ let selector = undefined;
108
+ if (optionCol[property])
109
+ selector = property;
110
+ else if (optionCol["*"])
111
+ selector = "*";
112
+ cols[col] = parseInt(optionCol[selector]);
113
+ }
114
+ else {
115
+ cols[col] = parseInt(optionCol);
116
+ }
117
+ });
118
+ return cols;
119
+ }
@@ -0,0 +1,21 @@
1
+ import * as React from "react";
2
+ import { FieldProps } from "../LajiForm";
3
+ import { MediaArrayState } from "./ImageArrayField";
4
+ export default class PdfArrayField extends React.Component<FieldProps, MediaArrayState> {
5
+ ALLOWED_FILE_TYPES: string[];
6
+ ACCEPT_FILE_TYPES: string[];
7
+ MAX_FILE_SIZE: number;
8
+ KEY: string;
9
+ ENDPOINT: string;
10
+ GLYPH: string;
11
+ TRANSLATION_TAKE_NEW: string;
12
+ TRANSLATION_SELECT_FILE: string;
13
+ TRANSLATION_NO_MEDIA: string;
14
+ CONTAINER_CLASS: string;
15
+ METADATA_FORM_ID: string;
16
+ renderMedia: (id: string) => JSX.Element;
17
+ renderLoadingMedia: (id: string) => JSX.Element;
18
+ onMediaClick: (i: number) => any;
19
+ renderModalMedia: () => JSX.Element;
20
+ formatValue(value: string[], options: any, props: FieldProps): string | null;
21
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ const React = require("react");
10
+ const ImageArrayField_1 = require("./ImageArrayField");
11
+ let PdfArrayField = class PdfArrayField extends React.Component {
12
+ constructor() {
13
+ super(...arguments);
14
+ this.ALLOWED_FILE_TYPES = ["application/pdf"];
15
+ this.ACCEPT_FILE_TYPES = ["application/pdf"];
16
+ this.MAX_FILE_SIZE = 20000000;
17
+ this.KEY = "PDF";
18
+ this.ENDPOINT = "pdf";
19
+ this.GLYPH = "paperclip";
20
+ this.TRANSLATION_TAKE_NEW = "";
21
+ this.TRANSLATION_SELECT_FILE = "";
22
+ this.TRANSLATION_NO_MEDIA = "";
23
+ this.CONTAINER_CLASS = "pdf-container";
24
+ this.METADATA_FORM_ID = "MHL.1070";
25
+ this.renderMedia = (id) => React.createElement(ImageArrayField_1.Thumbnail, { id: id, apiClient: this.props.formContext.apiClient, apiEndpoint: this.ENDPOINT });
26
+ this.renderLoadingMedia = (id) => React.createElement(ImageArrayField_1.Thumbnail, { dataURL: id, loading: true, apiClient: this.props.formContext.apiClient, apiEndpoint: this.ENDPOINT });
27
+ this.onMediaClick = (i) => this.openModalFor(i);
28
+ this.renderModalMedia = () => React.createElement("img", { src: this.state.modalMediaSrc });
29
+ }
30
+ formatValue(value, options, props) {
31
+ const { translations } = props.formContext;
32
+ return value && value.length
33
+ ? `${value.length} ${translations.HowManyFiles}`
34
+ : null;
35
+ }
36
+ };
37
+ PdfArrayField = __decorate([
38
+ ImageArrayField_1.MediaArrayField
39
+ ], PdfArrayField);
40
+ exports.default = PdfArrayField;
@@ -0,0 +1,22 @@
1
+ export default class PrefillingArrayField extends React.Component<any, any, any> {
2
+ static propTypes: {
3
+ uiSchema: PropTypes.Requireable<PropTypes.InferProps<{
4
+ "ui:options": PropTypes.Requireable<PropTypes.InferProps<{
5
+ field: PropTypes.Requireable<string>;
6
+ uiSchema: PropTypes.Requireable<object>;
7
+ }>>;
8
+ }>>;
9
+ schema: PropTypes.Validator<PropTypes.InferProps<{
10
+ type: PropTypes.Requireable<string>;
11
+ }>>;
12
+ formData: PropTypes.Validator<any[]>;
13
+ };
14
+ static getName(): string;
15
+ constructor(props: any);
16
+ constructor(props: any, context: any);
17
+ getStateFromProps(props: any): any;
18
+ mapFormData: (formData: any) => any;
19
+ onChange: (formData: any) => void;
20
+ }
21
+ import * as React from "react";
22
+ import * as PropTypes from "prop-types";