@luomus/laji-form 15.1.90 → 15.1.93
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.
- package/dist/laji-form.js +1 -1
- package/lib/components/LajiForm.d.ts +256 -3
- package/lib/components/LajiForm.js +3 -127
- package/lib/components/fields/MultiAnyToBooleanField.d.ts +6 -0
- package/lib/components/fields/MultiAnyToBooleanField.js +29 -23
- package/lib/components/fields/TaxonSetPopulatorField.d.ts +50 -0
- package/lib/components/fields/TaxonSetPopulatorField.js +206 -0
- package/lib/components/fields/index.d.ts +76 -0
- package/lib/components/fields/index.js +160 -0
- package/lib/components/templates/index.d.ts +8 -0
- package/lib/components/templates/index.js +22 -0
- package/lib/components/widgets/index.d.ts +20 -0
- package/lib/components/widgets/index.js +46 -0
- package/package.json +1 -1
|
@@ -19,6 +19,9 @@ import RootInstanceService from "../services/root-instance-service";
|
|
|
19
19
|
import SingletonMapService from "../services/singleton-map-service";
|
|
20
20
|
import { FieldProps, HasMaybeChildren, Lang } from "../types";
|
|
21
21
|
import MultiActiveArrayService from "../services/multi-active-array-service";
|
|
22
|
+
import * as fields from "./fields";
|
|
23
|
+
import * as widgets from "./widgets";
|
|
24
|
+
import * as templates from "./templates";
|
|
22
25
|
export interface LajiFormProps extends HasMaybeChildren {
|
|
23
26
|
apiClient?: ApiClientImplementation;
|
|
24
27
|
lang?: Lang;
|
|
@@ -191,17 +194,267 @@ export default class LajiForm extends React.Component<LajiFormProps, LajiFormSta
|
|
|
191
194
|
getFields: (_fields?: {
|
|
192
195
|
[name: string]: Field;
|
|
193
196
|
}) => {
|
|
194
|
-
|
|
197
|
+
SchemaField: typeof fields.SchemaField;
|
|
198
|
+
ArrayField: typeof fields.ArrayField;
|
|
199
|
+
ObjectField: (props: any) => JSX.Element;
|
|
200
|
+
NestField: typeof fields.NestField;
|
|
201
|
+
ArrayBulkField: typeof fields.ArrayBulkField;
|
|
202
|
+
ArrayPropertySumField: typeof fields.ArrayPropertySumField;
|
|
203
|
+
ScopeField: typeof fields.ScopeField;
|
|
204
|
+
SelectTreeField: typeof fields.SelectTreeField;
|
|
205
|
+
GridLayoutField: {
|
|
206
|
+
(props: any): JSX.Element;
|
|
207
|
+
propTypes: {
|
|
208
|
+
uiSchema: PropTypes.Requireable<PropTypes.InferProps<{
|
|
209
|
+
"ui:grid": PropTypes.Requireable<PropTypes.InferProps<{
|
|
210
|
+
lg: PropTypes.Requireable<NonNullable<number | object | null | undefined>>;
|
|
211
|
+
md: PropTypes.Requireable<NonNullable<number | object | null | undefined>>;
|
|
212
|
+
sm: PropTypes.Requireable<NonNullable<number | object | null | undefined>>;
|
|
213
|
+
xs: PropTypes.Requireable<NonNullable<number | object | null | undefined>>;
|
|
214
|
+
}>>;
|
|
215
|
+
}>>;
|
|
216
|
+
schema: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
217
|
+
type: PropTypes.Requireable<string>;
|
|
218
|
+
}>>>;
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
TableField: typeof fields.TableField;
|
|
222
|
+
InjectField: typeof fields.InjectField;
|
|
223
|
+
InjectDefaultValueField: typeof fields.InjectDefaultValueField;
|
|
224
|
+
ArrayCombinerField: typeof fields.ArrayCombinerField;
|
|
225
|
+
DependentBooleanField: typeof fields.DependentBooleanField;
|
|
226
|
+
DependentDisableField: typeof fields.DependentDisableField;
|
|
227
|
+
MapArrayField: typeof fields.MapArrayField;
|
|
228
|
+
AutoArrayField: typeof fields.AutoArrayField;
|
|
229
|
+
AutosuggestField: typeof fields.AutosuggestField;
|
|
230
|
+
HiddenField: {
|
|
231
|
+
(): JSX.Element;
|
|
232
|
+
propTypes: {
|
|
233
|
+
schema: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
234
|
+
type: PropTypes.Requireable<string>;
|
|
235
|
+
}>>>;
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
HiddenWithTextField: {
|
|
239
|
+
(props: FieldProps<import("../types").JSONSchemaArray<import("../types").JSONSchemaString>>): JSX.Element;
|
|
240
|
+
propTypes: {
|
|
241
|
+
uiSchema: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
242
|
+
"ui:options": PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
243
|
+
altText: PropTypes.Validator<string>;
|
|
244
|
+
}>>>;
|
|
245
|
+
uiSchema: PropTypes.Requireable<object>;
|
|
246
|
+
}>>>;
|
|
247
|
+
schema: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
248
|
+
type: PropTypes.Requireable<string>;
|
|
249
|
+
}>>>;
|
|
250
|
+
};
|
|
251
|
+
};
|
|
252
|
+
InitiallyHiddenField: typeof fields.InitiallyHiddenField;
|
|
253
|
+
ContextInjectionField: typeof fields.ContextInjectionField;
|
|
254
|
+
ImageArrayField: typeof fields.ImageArrayField;
|
|
255
|
+
SplitField: typeof fields.SplitField;
|
|
256
|
+
FlatField: typeof fields.FlatField;
|
|
257
|
+
SingleActiveArrayField: typeof fields.SingleActiveArrayField;
|
|
258
|
+
SingleItemArrayField: typeof fields.SingleItemArrayField;
|
|
259
|
+
UnitShorthandField: typeof fields.UnitShorthandField;
|
|
260
|
+
CombinedValueDisplayField: typeof fields.CombinedValueDisplayField;
|
|
261
|
+
UiFieldMapperArrayField: typeof fields.UiFieldMapperArrayField;
|
|
262
|
+
ExtraLabelRowField: typeof fields.ExtraLabelRowField;
|
|
263
|
+
SumField: typeof fields.SumField;
|
|
264
|
+
NamedPlaceChooserField: typeof fields.NamedPlaceChooserField;
|
|
265
|
+
NamedPlaceSaverField: typeof fields.NamedPlaceSaverField;
|
|
266
|
+
MapField: typeof fields.MapField;
|
|
267
|
+
GeocoderField: typeof fields.GeocoderField;
|
|
268
|
+
TagArrayField: typeof fields.TagArrayField;
|
|
269
|
+
StringToArrayField: typeof fields.StringToArrayField;
|
|
270
|
+
ConditionalOnChangeField: typeof fields.ConditionalOnChangeField;
|
|
271
|
+
ConditionalUiSchemaField: typeof fields.ConditionalUiSchemaField;
|
|
272
|
+
AnnotationField: typeof fields.AnnotationField;
|
|
273
|
+
PrefillingArrayField: typeof fields.PrefillingArrayField;
|
|
274
|
+
AnyToBooleanField: {
|
|
275
|
+
(props: any): JSX.Element;
|
|
276
|
+
propTypes: {
|
|
277
|
+
uiSchema: PropTypes.Requireable<PropTypes.InferProps<{
|
|
278
|
+
"ui:options": PropTypes.Requireable<PropTypes.InferProps<{
|
|
279
|
+
trueValue: PropTypes.Validator<object>;
|
|
280
|
+
falseValue: PropTypes.Requireable<object>;
|
|
281
|
+
allowUndefined: PropTypes.Requireable<boolean>;
|
|
282
|
+
}>>;
|
|
283
|
+
}>>;
|
|
284
|
+
schema: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
285
|
+
type: PropTypes.Requireable<string>;
|
|
286
|
+
}>>>;
|
|
287
|
+
formData: PropTypes.Requireable<object>;
|
|
288
|
+
};
|
|
289
|
+
};
|
|
290
|
+
EnumRangeArrayField: typeof fields.EnumRangeArrayField;
|
|
291
|
+
UnitListShorthandArrayField: typeof fields.UnitListShorthandArrayField;
|
|
292
|
+
LocationChooserField: typeof fields.LocationChooserField;
|
|
293
|
+
DataLeakerField: typeof fields.DataLeakerField;
|
|
294
|
+
LocalityField: typeof fields.LocalityField;
|
|
295
|
+
ImageDisplayField: typeof fields.ImageDisplayField;
|
|
296
|
+
FakePropertyField: typeof fields.FakePropertyField;
|
|
297
|
+
SectionArrayField: typeof fields.SectionArrayField;
|
|
298
|
+
MultiArrayField: typeof fields.MultiArrayField;
|
|
299
|
+
AudioArrayField: typeof fields.AudioArrayField;
|
|
300
|
+
FilterArrayField: typeof fields.FilterArrayField;
|
|
301
|
+
MultiAnyToBooleanField: typeof fields.MultiAnyToBooleanField;
|
|
302
|
+
UnitCountShorthandField: typeof fields.UnitCountShorthandField;
|
|
303
|
+
ToggleAdditionalArrayFieldsField: typeof fields.ToggleAdditionalArrayFieldsField;
|
|
304
|
+
DefaultValueArrayField: typeof fields.DefaultValueArrayField;
|
|
305
|
+
UiFieldApplierField: typeof fields.UiFieldApplierField;
|
|
306
|
+
MultiLanguageField: typeof fields.MultiLanguageField;
|
|
307
|
+
SortArrayField: typeof fields.SortArrayField;
|
|
308
|
+
InputWithDefaultValueButtonField: typeof fields.InputWithDefaultValueButtonField;
|
|
309
|
+
MultiTagArrayField: typeof fields.MultiTagArrayField;
|
|
310
|
+
PdfArrayField: typeof fields.PdfArrayField;
|
|
311
|
+
AsArrayField: typeof fields.AsArrayField;
|
|
312
|
+
CondensedObjectField: typeof fields.CondensedObjectField;
|
|
313
|
+
MultiActiveArrayField: typeof fields.MultiActiveArrayField;
|
|
314
|
+
PrefixArrayField: typeof fields.PrefixArrayField;
|
|
315
|
+
FillDateRangeField: typeof fields.FillDateRangeField;
|
|
316
|
+
TaxonSetPopulatorField: typeof fields.TaxonSetPopulatorField;
|
|
317
|
+
ScientificNameTaxonAutosuggestField: typeof fields.ScientificNameTaxonAutosuggestField;
|
|
318
|
+
ArraySchemaField: typeof fields.SchemaField;
|
|
319
|
+
InputTransformerField: typeof fields.ConditionalOnChangeField;
|
|
320
|
+
ConditionalField: typeof fields.ConditionalUiSchemaField;
|
|
321
|
+
UnitRapidField: typeof fields.UnitShorthandField;
|
|
322
|
+
AccordionArrayField: typeof fields.SingleActiveArrayField;
|
|
195
323
|
};
|
|
196
324
|
getWidgets: (_widgets?: {
|
|
197
325
|
[name: string]: Widget;
|
|
198
326
|
}) => {
|
|
199
|
-
|
|
327
|
+
CheckboxWidget: typeof widgets.CheckboxWidget;
|
|
328
|
+
SelectWidget: <T extends string | number>(props: (Omit<import("../types").WidgetProps<import("../types").JSONSchemaEnum>, "value" | "onChange"> & {
|
|
329
|
+
value?: T | undefined;
|
|
330
|
+
onChange: (value?: T | undefined) => void;
|
|
331
|
+
} & {
|
|
332
|
+
includeEmpty?: boolean;
|
|
333
|
+
getEnumOptionsAsync?: (() => Promise<(Omit<import("@rjsf/utils").EnumOptionsType, "value"> & {
|
|
334
|
+
value: T;
|
|
335
|
+
})[]>) | undefined;
|
|
336
|
+
}) | (Omit<import("../types").WidgetProps<import("../types").JSONSchemaArray<import("../types").JSONSchemaEnumOneOf>>, "value" | "onChange"> & {
|
|
337
|
+
value?: T[] | undefined;
|
|
338
|
+
onChange: (value?: T[] | undefined) => void;
|
|
339
|
+
} & {
|
|
340
|
+
includeEmpty?: boolean;
|
|
341
|
+
getEnumOptionsAsync?: (() => Promise<(Omit<import("@rjsf/utils").EnumOptionsType, "value"> & {
|
|
342
|
+
value: T;
|
|
343
|
+
})[]>) | undefined;
|
|
344
|
+
})) => JSX.Element;
|
|
345
|
+
TextareaWidget: typeof widgets.TextareaWidget;
|
|
346
|
+
DateTimeWidget: typeof widgets.DateTimeWidget;
|
|
347
|
+
DateWidget: {
|
|
348
|
+
(props: any): JSX.Element;
|
|
349
|
+
propTypes: {
|
|
350
|
+
uiSchema: PropTypes.Requireable<PropTypes.InferProps<{
|
|
351
|
+
"ui:options": PropTypes.Requireable<PropTypes.InferProps<{
|
|
352
|
+
showButtons: PropTypes.Requireable<NonNullable<boolean | PropTypes.InferProps<{
|
|
353
|
+
today: PropTypes.Requireable<boolean>;
|
|
354
|
+
yesterday: PropTypes.Requireable<boolean>;
|
|
355
|
+
same: PropTypes.Requireable<NonNullable<boolean | PropTypes.InferProps<{
|
|
356
|
+
path: PropTypes.Requireable<string>;
|
|
357
|
+
}> | null | undefined>>;
|
|
358
|
+
plusSixMonths: PropTypes.Requireable<NonNullable<boolean | PropTypes.InferProps<{
|
|
359
|
+
path: PropTypes.Requireable<string>;
|
|
360
|
+
}> | null | undefined>>;
|
|
361
|
+
plusSixYear: PropTypes.Requireable<NonNullable<boolean | PropTypes.InferProps<{
|
|
362
|
+
path: PropTypes.Requireable<string>;
|
|
363
|
+
}> | null | undefined>>;
|
|
364
|
+
}> | null | undefined>>;
|
|
365
|
+
allowOnlyYear: PropTypes.Requireable<boolean>;
|
|
366
|
+
}>>;
|
|
367
|
+
}>>;
|
|
368
|
+
schema: PropTypes.Requireable<PropTypes.InferProps<{
|
|
369
|
+
type: PropTypes.Requireable<string>;
|
|
370
|
+
}>>;
|
|
371
|
+
value: PropTypes.Requireable<string>;
|
|
372
|
+
};
|
|
373
|
+
};
|
|
374
|
+
TimeWidget: {
|
|
375
|
+
(props: any): JSX.Element;
|
|
376
|
+
propTypes: {
|
|
377
|
+
schema: PropTypes.Requireable<PropTypes.InferProps<{
|
|
378
|
+
type: PropTypes.Requireable<string>;
|
|
379
|
+
}>>;
|
|
380
|
+
value: PropTypes.Requireable<string>;
|
|
381
|
+
};
|
|
382
|
+
};
|
|
383
|
+
SeparatedDateTimeWidget: typeof widgets.SeparatedDateTimeWidget;
|
|
384
|
+
AutosuggestWidget: typeof widgets.AutosuggestWidget;
|
|
385
|
+
HiddenWidget: typeof widgets.HiddenWidget;
|
|
386
|
+
PlainTextWidget: typeof widgets.PlainTextWidget;
|
|
387
|
+
TextSelectWidget: typeof widgets.TextSelectWidget;
|
|
388
|
+
ImageSelectWidget: typeof widgets.ImageSelectWidget;
|
|
389
|
+
AnyToBooleanWidget: {
|
|
390
|
+
(props: any): JSX.Element;
|
|
391
|
+
propTypes: {
|
|
392
|
+
uiSchema: PropTypes.Requireable<PropTypes.InferProps<{
|
|
393
|
+
"ui:options": PropTypes.Requireable<PropTypes.InferProps<{
|
|
394
|
+
trueValue: PropTypes.Validator<NonNullable<NonNullable<string | number | boolean | null | undefined>>>;
|
|
395
|
+
falseValue: PropTypes.Requireable<NonNullable<string | number | boolean | null | undefined>>;
|
|
396
|
+
allowUndefined: PropTypes.Requireable<boolean>;
|
|
397
|
+
}>>;
|
|
398
|
+
}>>;
|
|
399
|
+
schema: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
400
|
+
type: PropTypes.Requireable<string>;
|
|
401
|
+
}>>>;
|
|
402
|
+
formData: PropTypes.Requireable<NonNullable<string | number | boolean | null | undefined>>;
|
|
403
|
+
};
|
|
404
|
+
};
|
|
405
|
+
URLWidget: {
|
|
406
|
+
({ value, options }: {
|
|
407
|
+
value: any;
|
|
408
|
+
options?: {} | undefined;
|
|
409
|
+
}): JSX.Element;
|
|
410
|
+
propTypes: {
|
|
411
|
+
schema: PropTypes.Requireable<PropTypes.InferProps<{
|
|
412
|
+
type: PropTypes.Requireable<string>;
|
|
413
|
+
}>>;
|
|
414
|
+
value: PropTypes.Requireable<string>;
|
|
415
|
+
};
|
|
416
|
+
};
|
|
417
|
+
InformalTaxonGroupChooserWidget: typeof widgets.InformalTaxonGroupChooserWidget;
|
|
418
|
+
TaxonImageWidget: typeof widgets.TaxonImageWidget;
|
|
419
|
+
UpperCaseWidget: typeof widgets.UpperCaseWidget;
|
|
420
|
+
NumberWidget: typeof widgets.NumberWidget;
|
|
421
|
+
InputGroupWidget: typeof widgets.InputGroupWidget;
|
|
422
|
+
InputWithDefaultValueButtonWidget: typeof widgets.InputWithDefaultValueButtonWidget;
|
|
200
423
|
};
|
|
201
424
|
getTemplates: (_templates?: {
|
|
202
425
|
[name: string]: TemplatesType;
|
|
203
426
|
}) => {
|
|
204
|
-
|
|
427
|
+
BaseInputTemplate: typeof templates.BaseInputTemplate;
|
|
428
|
+
DescriptionField: typeof templates.DescriptionField;
|
|
429
|
+
FieldTemplate: typeof templates.FieldTemplate;
|
|
430
|
+
ArrayFieldTemplate: {
|
|
431
|
+
new (): {
|
|
432
|
+
[x: string]: any;
|
|
433
|
+
componentDidMount(): void;
|
|
434
|
+
componentDidUpdate(prevProps: any, prevState: any): void;
|
|
435
|
+
componentWillUnmount(): void;
|
|
436
|
+
addKeyHandlers(): void;
|
|
437
|
+
arrayKeyFunctions: any;
|
|
438
|
+
removeKeyHandlers(props: any): void;
|
|
439
|
+
getKeyHandlers(props: any): any[];
|
|
440
|
+
addChildKeyHandlers(props: any): void;
|
|
441
|
+
childKeyHandlers: any;
|
|
442
|
+
removeChildKeyHandlers(): void;
|
|
443
|
+
getChildKeyHandlers(props: any): any;
|
|
444
|
+
onFocus: (target: any) => void;
|
|
445
|
+
onCopy: (options?: {}) => void;
|
|
446
|
+
getCustomEventListeners(): (string | ((target: any) => void))[][];
|
|
447
|
+
addCustomEventListeners(props: any): void;
|
|
448
|
+
customEventListeners: any;
|
|
449
|
+
removeCustomEventListeners(props: any): void;
|
|
450
|
+
};
|
|
451
|
+
[x: string]: any;
|
|
452
|
+
displayName: string;
|
|
453
|
+
};
|
|
454
|
+
ErrorListTemplate: typeof templates.ErrorListTemplate;
|
|
455
|
+
ObjectFieldTemplate: typeof templates.ObjectFieldTemplate;
|
|
456
|
+
TitleFieldTemplate: (props: any) => JSX.Element | null;
|
|
457
|
+
DescriptionFieldTemplate: typeof templates.DescriptionField;
|
|
205
458
|
};
|
|
206
459
|
getContext: (props: LajiFormProps, context: ContextProps) => ContextProps;
|
|
207
460
|
render(): JSX.Element | null;
|
|
@@ -74,133 +74,9 @@ const id_service_1 = __importDefault(require("../services/id-service"));
|
|
|
74
74
|
const root_instance_service_1 = __importDefault(require("../services/root-instance-service"));
|
|
75
75
|
const singleton_map_service_1 = __importDefault(require("../services/singleton-map-service"));
|
|
76
76
|
const multi_active_array_service_1 = __importDefault(require("../services/multi-active-array-service"));
|
|
77
|
-
const fields =
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
"ArrayField",
|
|
81
|
-
"ObjectField",
|
|
82
|
-
"NestField",
|
|
83
|
-
"ArrayBulkField",
|
|
84
|
-
"ArrayBulkField",
|
|
85
|
-
"ArrayPropertySumField",
|
|
86
|
-
"ScopeField",
|
|
87
|
-
"SelectTreeField",
|
|
88
|
-
"GridLayoutField",
|
|
89
|
-
"TableField",
|
|
90
|
-
"InjectField",
|
|
91
|
-
"InjectDefaultValueField",
|
|
92
|
-
"ArrayCombinerField",
|
|
93
|
-
"DependentBooleanField",
|
|
94
|
-
"DependentDisableField",
|
|
95
|
-
"MapArrayField",
|
|
96
|
-
"AutoArrayField",
|
|
97
|
-
"AutosuggestField",
|
|
98
|
-
"HiddenField",
|
|
99
|
-
"HiddenWithTextField",
|
|
100
|
-
"InitiallyHiddenField",
|
|
101
|
-
"ContextInjectionField",
|
|
102
|
-
"ImageArrayField",
|
|
103
|
-
"SplitField",
|
|
104
|
-
"FlatField",
|
|
105
|
-
"SingleActiveArrayField",
|
|
106
|
-
"SingleItemArrayField",
|
|
107
|
-
"UnitShorthandField",
|
|
108
|
-
"CombinedValueDisplayField",
|
|
109
|
-
"UiFieldMapperArrayField",
|
|
110
|
-
"ExtraLabelRowField",
|
|
111
|
-
"SumField",
|
|
112
|
-
"NamedPlaceChooserField",
|
|
113
|
-
"NamedPlaceSaverField",
|
|
114
|
-
"MapField",
|
|
115
|
-
"GeocoderField",
|
|
116
|
-
"TagArrayField",
|
|
117
|
-
"StringToArrayField",
|
|
118
|
-
"ConditionalOnChangeField",
|
|
119
|
-
"ConditionalUiSchemaField",
|
|
120
|
-
"AnnotationField",
|
|
121
|
-
"PrefillingArrayField",
|
|
122
|
-
"AnyToBooleanField",
|
|
123
|
-
"EnumRangeArrayField",
|
|
124
|
-
"UnitListShorthandArrayField",
|
|
125
|
-
"LocationChooserField",
|
|
126
|
-
"DataLeakerField",
|
|
127
|
-
"LocalityField",
|
|
128
|
-
"ImageDisplayField",
|
|
129
|
-
"FakePropertyField",
|
|
130
|
-
"SectionArrayField",
|
|
131
|
-
"MultiArrayField",
|
|
132
|
-
"AudioArrayField",
|
|
133
|
-
"FilterArrayField",
|
|
134
|
-
"MultiAnyToBooleanField",
|
|
135
|
-
"UnitCountShorthandField",
|
|
136
|
-
"ToggleAdditionalArrayFieldsField",
|
|
137
|
-
"DefaultValueArrayField",
|
|
138
|
-
"UiFieldApplierField",
|
|
139
|
-
"MultiLanguageField",
|
|
140
|
-
"SortArrayField",
|
|
141
|
-
"InputWithDefaultValueButtonField",
|
|
142
|
-
"MultiTagArrayField",
|
|
143
|
-
"PdfArrayField",
|
|
144
|
-
"AsArrayField",
|
|
145
|
-
"CondensedObjectField",
|
|
146
|
-
"MultiActiveArrayField",
|
|
147
|
-
"PrefixArrayField",
|
|
148
|
-
"FillDateRangeField",
|
|
149
|
-
"ScientificNameTaxonAutosuggestField",
|
|
150
|
-
{ "InputTransformerField": "ConditionalOnChangeField" }, // Alias for backward compatibility.
|
|
151
|
-
{ "ConditionalField": "ConditionalUiSchemaField" }, // Alias for backward compatibility.
|
|
152
|
-
{ "UnitRapidField": "UnitShorthandField" }, // Alias for backward compatibility.
|
|
153
|
-
{ "AccordionArrayField": "SingleActiveArrayField" } // Alias for backward compatibility.
|
|
154
|
-
]);
|
|
155
|
-
const widgets = importLocalComponents("widgets", [
|
|
156
|
-
"CheckboxWidget",
|
|
157
|
-
"SelectWidget",
|
|
158
|
-
"TextareaWidget",
|
|
159
|
-
"DateTimeWidget",
|
|
160
|
-
"DateWidget",
|
|
161
|
-
"TimeWidget",
|
|
162
|
-
"SeparatedDateTimeWidget",
|
|
163
|
-
"AutosuggestWidget",
|
|
164
|
-
"HiddenWidget",
|
|
165
|
-
"PlainTextWidget",
|
|
166
|
-
"TextSelectWidget",
|
|
167
|
-
"ImageSelectWidget",
|
|
168
|
-
"AnyToBooleanWidget",
|
|
169
|
-
"URLWidget",
|
|
170
|
-
"InformalTaxonGroupChooserWidget",
|
|
171
|
-
"TaxonImageWidget",
|
|
172
|
-
"UpperCaseWidget",
|
|
173
|
-
"NumberWidget",
|
|
174
|
-
"InputGroupWidget",
|
|
175
|
-
"InputWithDefaultValueButtonWidget"
|
|
176
|
-
]);
|
|
177
|
-
const templates = importLocalComponents("templates", [
|
|
178
|
-
"BaseInputTemplate",
|
|
179
|
-
"DescriptionField",
|
|
180
|
-
{ "TitleFieldTemplate": "TitleField" },
|
|
181
|
-
{ "DescriptionFieldTemplate": "DescriptionField" },
|
|
182
|
-
"FieldTemplate",
|
|
183
|
-
"ArrayFieldTemplate",
|
|
184
|
-
"ErrorListTemplate",
|
|
185
|
-
"ObjectFieldTemplate"
|
|
186
|
-
]);
|
|
187
|
-
function importLocalComponents(dir, fieldNames) {
|
|
188
|
-
return fieldNames.reduce((fields, field) => {
|
|
189
|
-
if (typeof field === "string") {
|
|
190
|
-
fields[field] = require(`./${dir}/${field}`).default;
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
const fieldName = Object.keys(field)[0];
|
|
194
|
-
if (typeof field[fieldName] === "string") {
|
|
195
|
-
fields[fieldName] = require(`./${dir}/${field[fieldName]}`).default;
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
fields[fieldName] = field[fieldName];
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
return fields;
|
|
202
|
-
}, {});
|
|
203
|
-
}
|
|
77
|
+
const fields = __importStar(require("./fields"));
|
|
78
|
+
const widgets = __importStar(require("./widgets"));
|
|
79
|
+
const templates = __importStar(require("./templates"));
|
|
204
80
|
// Each form should have a unique id to keep Context private.
|
|
205
81
|
let id = 0;
|
|
206
82
|
function getNewId() {
|
|
@@ -22,6 +22,12 @@ export default class MultiAnyToBooleanField extends React.Component<any, any, an
|
|
|
22
22
|
getInitialState(props: any): {
|
|
23
23
|
groupsFormData: any[];
|
|
24
24
|
};
|
|
25
|
+
getStateFromProps(props: any): {
|
|
26
|
+
groupsFormData: any[];
|
|
27
|
+
};
|
|
28
|
+
initializeGroups: (props: any) => {
|
|
29
|
+
groupsFormData: any[];
|
|
30
|
+
};
|
|
25
31
|
onChange: (index: any) => (value: any) => void;
|
|
26
32
|
render(): JSX.Element;
|
|
27
33
|
}
|
|
@@ -62,6 +62,31 @@ const utils_2 = require("@rjsf/utils");
|
|
|
62
62
|
let MultiAnyToBooleanField = class MultiAnyToBooleanField extends React.Component {
|
|
63
63
|
constructor(props) {
|
|
64
64
|
super(props);
|
|
65
|
+
this.initializeGroups = (props) => {
|
|
66
|
+
let { groups } = (0, utils_1.getUiOptions)(props.uiSchema) || [];
|
|
67
|
+
const { formData } = props;
|
|
68
|
+
const trueValues = groups.map(group => group.trueValue);
|
|
69
|
+
const falseValues = groups.map(group => group.falseValue);
|
|
70
|
+
const groupsFormData = [];
|
|
71
|
+
if (formData) {
|
|
72
|
+
formData.forEach(value => {
|
|
73
|
+
if (value === undefined) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const trueIndex = trueValues.findIndex(trueValue => props.formContext.utils.formDataEquals(value, trueValue, props.idSchema.$id));
|
|
77
|
+
if (trueIndex !== -1) {
|
|
78
|
+
groupsFormData[trueIndex] = value;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
const falseIndex = falseValues.findIndex(falseValue => props.formContext.utils.formDataEquals(value, falseValue, props.idSchema.$id));
|
|
82
|
+
if (falseIndex !== -1) {
|
|
83
|
+
groupsFormData[falseIndex] = value;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return { groupsFormData: groupsFormData };
|
|
89
|
+
};
|
|
65
90
|
this.onChange = (index) => (value) => {
|
|
66
91
|
const groupsFormData = this.state.groupsFormData;
|
|
67
92
|
groupsFormData[index] = value;
|
|
@@ -77,29 +102,10 @@ let MultiAnyToBooleanField = class MultiAnyToBooleanField extends React.Componen
|
|
|
77
102
|
this.state = this.getInitialState(props);
|
|
78
103
|
}
|
|
79
104
|
getInitialState(props) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const groupsFormData = [];
|
|
85
|
-
if (formData) {
|
|
86
|
-
formData.forEach(value => {
|
|
87
|
-
if (value === undefined) {
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
const trueIndex = trueValues.findIndex(trueValue => props.formContext.utils.formDataEquals(value, trueValue, props.idSchema.$id));
|
|
91
|
-
if (trueIndex !== -1) {
|
|
92
|
-
groupsFormData[trueIndex] = value;
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
const falseIndex = falseValues.findIndex(falseValue => props.formContext.utils.formDataEquals(value, falseValue, props.idSchema.$id));
|
|
96
|
-
if (falseIndex !== -1) {
|
|
97
|
-
groupsFormData[falseIndex] = value;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
return { groupsFormData: groupsFormData };
|
|
105
|
+
return this.initializeGroups(props);
|
|
106
|
+
}
|
|
107
|
+
getStateFromProps(props) {
|
|
108
|
+
return this.initializeGroups(props);
|
|
103
109
|
}
|
|
104
110
|
render() {
|
|
105
111
|
const TitleFieldTemplate = (0, utils_2.getTemplate)("TitleFieldTemplate", this.props.registry, (0, utils_1.getUiOptions)(this.props.uiSchema));
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as PropTypes from "prop-types";
|
|
3
|
+
import { FieldProps } from "../../types";
|
|
4
|
+
/**
|
|
5
|
+
* Watches a specified field which contains taxon set IDs.
|
|
6
|
+
*
|
|
7
|
+
* When taxon set IDs are added, it fetches the taxa in those sets from the API and adds them to the units in formData.
|
|
8
|
+
*
|
|
9
|
+
* When taxon set IDs are removed, it removes any taxa belonging to those sets from the units in formData.
|
|
10
|
+
*
|
|
11
|
+
* uiSchema = {
|
|
12
|
+
* "ui:field": "TaxonSetPopulatorField",
|
|
13
|
+
* "ui:options": {
|
|
14
|
+
* "props": {
|
|
15
|
+
* "from": "taxonCensus", // Source object containing taxon set IDs
|
|
16
|
+
* "fromArrayKey": "censusTaxonSetID", // Field within source object containing the taxon set IDs
|
|
17
|
+
* "joinArray": true, // Join array of IDs into comma-separated string
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
*/
|
|
22
|
+
export default class TaxonSetPopulatorField extends React.Component<FieldProps> {
|
|
23
|
+
static propTypes: {
|
|
24
|
+
uiSchema: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
25
|
+
"ui:options": PropTypes.Requireable<PropTypes.InferProps<{
|
|
26
|
+
props: PropTypes.Requireable<NonNullable<PropTypes.InferProps<{
|
|
27
|
+
from: PropTypes.Validator<string>;
|
|
28
|
+
fromArrayKey: PropTypes.Requireable<string>;
|
|
29
|
+
joinArray: PropTypes.Requireable<boolean>;
|
|
30
|
+
}> | (PropTypes.InferProps<{
|
|
31
|
+
from: PropTypes.Validator<string>;
|
|
32
|
+
fromArrayKey: PropTypes.Requireable<string>;
|
|
33
|
+
joinArray: PropTypes.Requireable<boolean>;
|
|
34
|
+
}> | null | undefined)[] | null | undefined>>;
|
|
35
|
+
}>>;
|
|
36
|
+
uiSchema: PropTypes.Requireable<object>;
|
|
37
|
+
}>>>;
|
|
38
|
+
schema: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
39
|
+
type: PropTypes.Requireable<string>;
|
|
40
|
+
}>>>;
|
|
41
|
+
formData: PropTypes.Validator<object>;
|
|
42
|
+
};
|
|
43
|
+
static getName(): string;
|
|
44
|
+
taxonSets: any[];
|
|
45
|
+
getStateFromProps(): {
|
|
46
|
+
onChange: (formData: any) => Promise<void>;
|
|
47
|
+
};
|
|
48
|
+
onChange: (formData: any) => Promise<void>;
|
|
49
|
+
private fetchTaxaFromSet;
|
|
50
|
+
}
|