@luomus/laji-form 15.1.70 → 15.1.72
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/dist/styles.css +2 -2
- package/lib/components/LajiForm.d.ts +15 -5
- package/lib/components/LajiForm.js +16 -7
- package/lib/components/fields/CondensedObjectField.js +3 -5
- package/lib/components/fields/ImageArrayField.d.ts +7 -3
- package/lib/components/fields/ImageArrayField.js +22 -11
- package/lib/components/fields/PrefixArrayField.js +3 -3
- package/lib/components/fields/SectionArrayField.js +1 -1
- package/lib/components/fields/SingleActiveArrayField.js +5 -5
- package/lib/components/fields/TableField.js +2 -2
- package/lib/components/templates/ArrayFieldTemplate.js +2 -2
- package/lib/themes/bs5.js +10 -2
- package/package.json +1 -1
package/dist/styles.css
CHANGED
|
@@ -2149,7 +2149,7 @@ body .laji-form {
|
|
|
2149
2149
|
margin-bottom: 6px;
|
|
2150
2150
|
}
|
|
2151
2151
|
|
|
2152
|
-
.laji-form button {
|
|
2152
|
+
.laji-form button, .laji-form .page-link {
|
|
2153
2153
|
line-height: 14px;
|
|
2154
2154
|
white-space: normal;
|
|
2155
2155
|
}
|
|
@@ -2685,7 +2685,7 @@ body .laji-form {
|
|
|
2685
2685
|
padding: 10px 15px;
|
|
2686
2686
|
color: rgb(51, 51, 51);
|
|
2687
2687
|
}
|
|
2688
|
-
.laji-form .laji-form-panel .panel-heading, .laji-form .pager {
|
|
2688
|
+
.laji-form .laji-form-panel .panel-heading, .laji-form .pager, .laji-form .pagination {
|
|
2689
2689
|
padding: 0;
|
|
2690
2690
|
margin: 0;
|
|
2691
2691
|
}
|
|
@@ -5,7 +5,7 @@ import { ReactUtilsType } from "../utils";
|
|
|
5
5
|
import { Theme } from "../themes/theme";
|
|
6
6
|
import { ContextProps } from "../ReactContext";
|
|
7
7
|
import Form from "@rjsf/core";
|
|
8
|
-
import { Field, Widget, TemplatesType } from "@rjsf/utils";
|
|
8
|
+
import { Field, Widget, TemplatesType, ErrorSchema } from "@rjsf/utils";
|
|
9
9
|
import ApiClient, { ApiClientImplementation } from "../ApiClient";
|
|
10
10
|
import KeyHandlerService, { ShortcutKeys } from "../services/key-handler-service";
|
|
11
11
|
import SettingsService, { Settings } from "../services/settings-service";
|
|
@@ -28,7 +28,7 @@ export interface LajiFormProps extends HasMaybeChildren {
|
|
|
28
28
|
topOffset?: number;
|
|
29
29
|
bottomOffset?: number;
|
|
30
30
|
formContext?: any;
|
|
31
|
-
uiSchemaContext?:
|
|
31
|
+
uiSchemaContext?: UiSchemaContext;
|
|
32
32
|
settings?: any;
|
|
33
33
|
id?: string;
|
|
34
34
|
googleApiKey?: string;
|
|
@@ -53,24 +53,26 @@ export interface LajiFormProps extends HasMaybeChildren {
|
|
|
53
53
|
onSubmit?: (data: {
|
|
54
54
|
formData: any;
|
|
55
55
|
}) => void;
|
|
56
|
-
onValidationError?: (extraErrors:
|
|
56
|
+
onValidationError?: (extraErrors: ErrorSchema) => void;
|
|
57
57
|
validators?: any;
|
|
58
58
|
warnings?: any;
|
|
59
59
|
onSettingsChange?: (settings: any, global: boolean) => void;
|
|
60
60
|
mediaMetadata?: MediaMetadata;
|
|
61
61
|
theme?: Theme;
|
|
62
62
|
lajiGeoServerAddress?: string;
|
|
63
|
+
extraErrors: ErrorSchema;
|
|
63
64
|
}
|
|
64
65
|
export interface LajiFormState {
|
|
65
66
|
submitHooks?: SubmitHook[];
|
|
66
67
|
formContext: FormContext;
|
|
67
68
|
formData?: any;
|
|
68
|
-
extraErrors?:
|
|
69
|
+
extraErrors?: ErrorSchema;
|
|
70
|
+
externalErrors?: ErrorSchema;
|
|
69
71
|
error?: boolean;
|
|
70
72
|
runningSubmitHooks?: boolean;
|
|
71
73
|
}
|
|
72
74
|
export interface MediaMetadata {
|
|
73
|
-
capturerVerbatim
|
|
75
|
+
capturerVerbatim?: string | string[];
|
|
74
76
|
intellectualOwner: string;
|
|
75
77
|
intellectualRights: string;
|
|
76
78
|
}
|
|
@@ -118,6 +120,14 @@ export interface FormContext {
|
|
|
118
120
|
multiActiveArray: MultiActiveArrayService;
|
|
119
121
|
};
|
|
120
122
|
}
|
|
123
|
+
export interface UiSchemaContext {
|
|
124
|
+
isAdmin?: boolean;
|
|
125
|
+
isEdit?: boolean;
|
|
126
|
+
creator?: string;
|
|
127
|
+
confirmDelete?: boolean;
|
|
128
|
+
additionalClassNames?: Record<string, string>;
|
|
129
|
+
[key: string]: any;
|
|
130
|
+
}
|
|
121
131
|
export type NotifyMessager = (msg: string) => void;
|
|
122
132
|
export interface Notifier {
|
|
123
133
|
success: NotifyMessager;
|
|
@@ -282,7 +282,8 @@ class LajiForm extends React.Component {
|
|
|
282
282
|
this.validateAndSubmit = (warnings = true, onlySchema = false) => {
|
|
283
283
|
const { formData } = this.state;
|
|
284
284
|
const { onValidationError, onSubmit } = this.props;
|
|
285
|
-
|
|
285
|
+
this.setState({ externalErrors: undefined });
|
|
286
|
+
return this.validate(warnings, true, onlySchema).then(valid => {
|
|
286
287
|
if (formData !== this.state.formData) {
|
|
287
288
|
this.validateAndSubmit(warnings, onlySchema);
|
|
288
289
|
}
|
|
@@ -329,12 +330,15 @@ class LajiForm extends React.Component {
|
|
|
329
330
|
this.cachedNonliveValidations = (0, deepmerge_1.default)(schemaErrors, _validations);
|
|
330
331
|
block && this.memoizedFormContext.services.blocker.pop();
|
|
331
332
|
}
|
|
332
|
-
const
|
|
333
|
+
const mergedInternalErrors = (0, deepmerge_1.default)(_liveValidations, !nonlive
|
|
333
334
|
? (this.cachedNonliveValidations || {})
|
|
334
335
|
: (0, deepmerge_1.default)(_validations, schemaErrors));
|
|
336
|
+
const mergedAll = (0, deepmerge_1.default)(this.state.externalErrors || {}, mergedInternalErrors);
|
|
335
337
|
this.validating = false;
|
|
336
|
-
resolve(!Object.keys(
|
|
337
|
-
!equals((this.state.extraErrors || {}),
|
|
338
|
+
resolve(!Object.keys(mergedAll).length);
|
|
339
|
+
if (!equals((this.state.extraErrors || {}), mergedAll)) {
|
|
340
|
+
this.setState({ extraErrors: mergedAll }, this.popErrorListIfNeeded);
|
|
341
|
+
}
|
|
338
342
|
}).catch((e) => {
|
|
339
343
|
block && this.memoizedFormContext.services.blocker.pop();
|
|
340
344
|
throw e;
|
|
@@ -516,11 +520,16 @@ class LajiForm extends React.Component {
|
|
|
516
520
|
if (this.apiClient && "lang" in props && this.props.lang !== props.lang) {
|
|
517
521
|
this.apiClient.setLang(props.lang);
|
|
518
522
|
}
|
|
519
|
-
this.setState(this.getStateFromProps(props));
|
|
523
|
+
this.setState(this.getStateFromProps(props), this.popErrorListIfNeeded);
|
|
520
524
|
}
|
|
521
525
|
getStateFromProps(props) {
|
|
526
|
+
var _a;
|
|
522
527
|
const state = {
|
|
523
|
-
formContext: this.getMemoizedFormContext(props)
|
|
528
|
+
formContext: this.getMemoizedFormContext(props),
|
|
529
|
+
externalErrors: props.extraErrors,
|
|
530
|
+
extraErrors: ((_a = this.state) === null || _a === void 0 ? void 0 : _a.extraErrors)
|
|
531
|
+
? (0, deepmerge_1.default)(this.state.extraErrors, props.extraErrors || {})
|
|
532
|
+
: props.extraErrors
|
|
524
533
|
};
|
|
525
534
|
if (((!this.state && props.schema && Object.keys(props.schema).length) || (this.state && !("formData" in this.state))) || ("formData" in props && props.formData !== this.props.formData)) {
|
|
526
535
|
state.formData = state.formContext.services.ids.addLajiFormIds((0, utils_1.getDefaultFormState)(props.schema, props.formData, props.schema))[0];
|
|
@@ -632,7 +641,7 @@ class LajiForm extends React.Component {
|
|
|
632
641
|
showShortcutsButton && this.props.showShortcutButton !== false && shortcuts && (React.createElement(components_1.TooltipComponent, { tooltip: this.getShorcutButtonTooltip() },
|
|
633
642
|
React.createElement(components_1.Button, { variant: undefined, onClick: this.toggleHelp }, translations.Shortcuts))),
|
|
634
643
|
React.createElement(components_1.FailedBackgroundJobsPanel, { jobs: this.state.submitHooks, schema: this.props.schema, uiSchema: uiSchema, formContext: this.state.formContext, errorClickHandler: this.memoizedFormContext.services.focus.focus, ref: this.bgJobRef }),
|
|
635
|
-
React.createElement(core_1.default, Object.assign({}, this.props, { formData: this.state.formData, uiSchema: uiSchema, ref: this.formRef, onChange: this.onChange, onSubmit: this.onSubmit, fields: this.getFields(this.props.fields), widgets: this.getWidgets(this.props.widgets), templates: this.getTemplates(this.props.templates), formContext: this.state.formContext, validator: validator_ajv6_1.default, noValidate: true, extraErrors: this.state.extraErrors, noHtml5Validate: true, liveValidate: true, autoComplete: "off", tagName: "div", readonly: readonly, disabled: disabled }), this.props.children),
|
|
644
|
+
React.createElement(core_1.default, Object.assign({}, this.props, { formData: this.state.formData, uiSchema: uiSchema, ref: this.formRef, onChange: this.onChange, onSubmit: this.onSubmit, fields: this.getFields(this.props.fields), widgets: this.getWidgets(this.props.widgets), templates: this.getTemplates(this.props.templates), formContext: this.state.formContext, validator: validator_ajv6_1.default, noValidate: true, extraErrors: this.state.extraErrors || {}, noHtml5Validate: true, liveValidate: true, autoComplete: "off", tagName: "div", readonly: readonly, disabled: disabled }), this.props.children),
|
|
636
645
|
(!this.props.children && this.props.renderSubmit !== false) ? (React.createElement(components_1.Button, { id: "submit", onClick: this.submit, disabled: readonly || disabled }, this.props.submitText || translations.Submit)) : null,
|
|
637
646
|
shortcuts &&
|
|
638
647
|
React.createElement(Panel, { ref: this.shortcutHelpRef, className: "shortcut-help laji-form-popped z-depth-3 hidden", style: { top: (this.props.topOffset || 0) + 5, bottom: (this.props.bottomOffset || 0) + 5 }, variant: "info" },
|
|
@@ -134,10 +134,9 @@ class CondensedObjectField extends React.Component {
|
|
|
134
134
|
return Math.max(...oldIndexes, -1) + 1;
|
|
135
135
|
}
|
|
136
136
|
render() {
|
|
137
|
-
var _a;
|
|
138
137
|
const SchemaField = this.props.registry.fields.SchemaField;
|
|
139
|
-
const { schema, uiSchema, idSchema, errorSchema, formData = {}, required, formContext: { Label, translations } } = this.props;
|
|
140
|
-
const
|
|
138
|
+
const { schema, uiSchema, idSchema, errorSchema, formData = {}, required, disabled, readonly, formContext: { Label, translations, uiSchemaContext } } = this.props;
|
|
139
|
+
const { addFieldPlaceholder = `${translations.AddField}`, confirmDelete = uiSchemaContext.confirmDelete } = (0, utils_1.getUiOptions)(uiSchema);
|
|
141
140
|
const childProps = this.state.selectedFields.map(field => {
|
|
142
141
|
let childSchema = schema.properties[field.name];
|
|
143
142
|
let childUiSchema = uiSchema[field.name] || {};
|
|
@@ -162,14 +161,13 @@ class CondensedObjectField extends React.Component {
|
|
|
162
161
|
value: prop,
|
|
163
162
|
label: schema.properties[prop].title || prop,
|
|
164
163
|
}));
|
|
165
|
-
const addFieldPlaceholder = (_a = uiOptions.addFieldPlaceholder) !== null && _a !== void 0 ? _a : `${translations.AddField}`;
|
|
166
164
|
return (React.createElement(React.Fragment, null,
|
|
167
165
|
React.createElement(Label, { label: this.props.schema.title, required: required || uiSchema["ui:required"], id: this.props.idSchema.$id, uiSchema: this.props.uiSchema }),
|
|
168
166
|
childProps.map((props, idx) => React.createElement("div", { key: idx, className: "laji-form-field-template-item condensed-object-field-item" },
|
|
169
167
|
React.createElement("div", { className: "laji-form-field-template-schema" },
|
|
170
168
|
React.createElement(SchemaField, Object.assign({}, this.props, props, { key: idx, onChange: this.onFieldChange(idx) }))),
|
|
171
169
|
React.createElement("div", { className: "laji-form-field-template-buttons" },
|
|
172
|
-
React.createElement(components_1.DeleteButton, { id: props.idSchema.$id, onClick: this.onFieldDelete(idx), translations: translations })))),
|
|
170
|
+
React.createElement(components_1.DeleteButton, { id: props.idSchema.$id, onClick: this.onFieldDelete(idx), translations: translations, confirm: confirmDelete, disabled: disabled || readonly })))),
|
|
173
171
|
React.createElement(SelectWidget_1.default, { key: childProps.length, options: { enumOptions: selectableFieldEnums, placeholder: addFieldPlaceholder }, onChange: this.onSelectFieldChange, includeEmpty: true, schema: {}, id: `${idSchema.$id}_field_select`, formContext: this.props.formContext, disabled: this.props.disabled, readonly: this.props.readonly })));
|
|
174
172
|
}
|
|
175
173
|
}
|
|
@@ -16,6 +16,10 @@ interface MediaMetadataSchema {
|
|
|
16
16
|
intellectualOwner?: string;
|
|
17
17
|
intellectualRights?: string;
|
|
18
18
|
}
|
|
19
|
+
interface ProcessedExifData {
|
|
20
|
+
formData?: any;
|
|
21
|
+
defaultMediaMetadata?: any;
|
|
22
|
+
}
|
|
19
23
|
export default class ImageArrayField extends React.Component<FieldProps<any, JSONSchemaArray<JSONSchemaObject>>, ImageArrayFieldState> {
|
|
20
24
|
ALLOWED_FILE_TYPES: string[];
|
|
21
25
|
ACCEPT_FILE_TYPES: string[];
|
|
@@ -89,18 +93,18 @@ export declare function MediaArrayField<LFC extends Constructor<React.Component<
|
|
|
89
93
|
onHideMediaAddModal: () => void;
|
|
90
94
|
renderMediaAddModal: () => JSX.Element | null;
|
|
91
95
|
onAlertOk: () => void;
|
|
92
|
-
parseExif: (files: File[]) =>
|
|
96
|
+
parseExif: (files: File[]) => Promise<ProcessedExifData>;
|
|
93
97
|
sideEffects: (formData: any) => void;
|
|
94
98
|
onFileFormChange: (files: File[]) => void;
|
|
95
99
|
getContainerId: () => number | "root";
|
|
96
|
-
saveMedias(files: File[]): Promise<any[] | undefined>;
|
|
100
|
+
saveMedias(files: File[], exifDataPromise: Promise<ProcessedExifData>): Promise<any[] | undefined>;
|
|
97
101
|
addNameToDataURL: (dataURL: string, name: string) => string;
|
|
98
102
|
processFiles: (files: File[]) => Promise<ProcessedFile[]>;
|
|
99
103
|
processFile: (file: File) => Promise<ProcessedFile>;
|
|
100
104
|
onMediaMetadataUpdate: ({ formData }: {
|
|
101
105
|
formData: any;
|
|
102
106
|
}) => Promise<void>;
|
|
103
|
-
getMetadataPromise: () => Promise<MediaMetadataSchema>;
|
|
107
|
+
getMetadataPromise: (exifDataPromise: Promise<ProcessedExifData>) => Promise<MediaMetadataSchema>;
|
|
104
108
|
getMaxFileSizeAsString: () => string;
|
|
105
109
|
getAllowedMediaFormatsTranslationKey: () => "AllowedFileFormat" | "AllowedFileFormats";
|
|
106
110
|
getAllowedMediaFormatsAsString: () => string;
|
|
@@ -260,7 +260,7 @@ function MediaArrayField(ComposedComponent) {
|
|
|
260
260
|
this.parseExif = (files) => {
|
|
261
261
|
const { exifParsers = [] } = (0, utils_1.getUiOptions)(this.props.uiSchema);
|
|
262
262
|
if (!exifParsers)
|
|
263
|
-
return;
|
|
263
|
+
return Promise.resolve({});
|
|
264
264
|
const found = exifParsers.reduce((found, { parse }) => {
|
|
265
265
|
found[parse] = false;
|
|
266
266
|
return found;
|
|
@@ -326,15 +326,19 @@ function MediaArrayField(ComposedComponent) {
|
|
|
326
326
|
const lajiFormInstance = this.props.formContext.services.rootInstance;
|
|
327
327
|
const schema = lajiFormInstance.getSchema();
|
|
328
328
|
let formData = lajiFormInstance.getFormData();
|
|
329
|
+
let defaultMediaMetadata = {};
|
|
329
330
|
exifParsers.filter((f) => f.type === "event" || found[f.parse]).forEach(({ field, parse, type, eventName }) => {
|
|
330
331
|
if (type === "mutate") {
|
|
331
332
|
formData = (0, utils_1.updateFormDataWithJSONPointer)({ formData, schema, registry }, found[parse], field);
|
|
332
333
|
}
|
|
334
|
+
if (type === "mutateMetadata") {
|
|
335
|
+
defaultMediaMetadata = (0, utils_1.updateSafelyWithJSONPointer)(defaultMediaMetadata, found[parse], field);
|
|
336
|
+
}
|
|
333
337
|
if (type === "event") {
|
|
334
338
|
this.props.formContext.services.customEvents.send(`root_${(0, utils_1.JSONPointerToId)(field)}`, eventName, found[parse], undefined, { bubble: false });
|
|
335
339
|
}
|
|
336
340
|
});
|
|
337
|
-
return formData;
|
|
341
|
+
return { formData, defaultMediaMetadata };
|
|
338
342
|
});
|
|
339
343
|
};
|
|
340
344
|
this.sideEffects = (formData) => {
|
|
@@ -364,14 +368,18 @@ function MediaArrayField(ComposedComponent) {
|
|
|
364
368
|
}
|
|
365
369
|
};
|
|
366
370
|
this.onFileFormChange = (files) => {
|
|
367
|
-
var _a;
|
|
368
371
|
if (this.state.addModal) {
|
|
369
372
|
this.setState({ addModal: undefined });
|
|
370
373
|
}
|
|
371
|
-
|
|
374
|
+
const exifDataPromise = this.parseExif(files);
|
|
375
|
+
exifDataPromise.then(data => {
|
|
376
|
+
if (data.formData) {
|
|
377
|
+
this.sideEffects(data.formData);
|
|
378
|
+
}
|
|
379
|
+
});
|
|
372
380
|
const id = this.getContainerId();
|
|
373
381
|
const lajiFormInstance = this.props.formContext.services.rootInstance;
|
|
374
|
-
const saveAndOnChange = () => this.saveMedias(files).then(mediaIds => {
|
|
382
|
+
const saveAndOnChange = () => this.saveMedias(files, exifDataPromise).then(mediaIds => {
|
|
375
383
|
if (!lajiFormInstance.isMounted() || !mediaIds) {
|
|
376
384
|
return;
|
|
377
385
|
}
|
|
@@ -450,15 +458,18 @@ function MediaArrayField(ComposedComponent) {
|
|
|
450
458
|
this.mounted && this.setState({ metadataSaveSuccess: false });
|
|
451
459
|
}
|
|
452
460
|
});
|
|
453
|
-
this.getMetadataPromise = () => {
|
|
461
|
+
this.getMetadataPromise = (exifDataPromise) => {
|
|
454
462
|
let mediaMetadata = this.props.formContext.mediaMetadata
|
|
455
463
|
|| { intellectualRights: "MZ.intellectualRightsARR" };
|
|
456
464
|
const MACode = this.props.formContext.uiSchemaContext.creator;
|
|
457
|
-
|
|
458
|
-
? Promise.resolve(Object.assign(Object.assign({}, mediaMetadata), { capturerVerbatim: [mediaMetadata.capturerVerbatim] }))
|
|
465
|
+
const metadataPromise = ("capturerVerbatim" in mediaMetadata)
|
|
466
|
+
? Promise.resolve(Object.assign(Object.assign({}, mediaMetadata), { capturerVerbatim: Array.isArray(mediaMetadata.capturerVerbatim) ? mediaMetadata.capturerVerbatim : [mediaMetadata.capturerVerbatim] }))
|
|
459
467
|
: MACode
|
|
460
468
|
? this.apiClient.get("/person/by-id/{personId}", { path: { personId: MACode } }).then(({ fullName = MACode }) => (Object.assign(Object.assign({ capturerVerbatim: Array.isArray(fullName) ? fullName : [fullName] }, mediaMetadata), { intellectualOwner: fullName }))).catch(() => Promise.resolve(mediaMetadata))
|
|
461
|
-
: mediaMetadata;
|
|
469
|
+
: Promise.resolve(mediaMetadata);
|
|
470
|
+
return Promise.all([exifDataPromise, metadataPromise]).then(([exifData, metadata]) => {
|
|
471
|
+
return Object.assign(Object.assign({}, exifData.defaultMediaMetadata), metadata);
|
|
472
|
+
});
|
|
462
473
|
};
|
|
463
474
|
this.getMaxFileSizeAsString = () => {
|
|
464
475
|
let maxSize = this.MAX_FILE_SIZE.toString().substring(0, this.MAX_FILE_SIZE.toString().length - 6);
|
|
@@ -571,7 +582,7 @@ function MediaArrayField(ComposedComponent) {
|
|
|
571
582
|
this.renderMetadataModal(),
|
|
572
583
|
this.renderMediaAddModal()))));
|
|
573
584
|
}
|
|
574
|
-
saveMedias(files) {
|
|
585
|
+
saveMedias(files, exifDataPromise) {
|
|
575
586
|
return __awaiter(this, void 0, void 0, function* () {
|
|
576
587
|
const containerId = this.getContainerId();
|
|
577
588
|
let tmpMedias = [];
|
|
@@ -617,7 +628,7 @@ function MediaArrayField(ComposedComponent) {
|
|
|
617
628
|
return;
|
|
618
629
|
}
|
|
619
630
|
const tmpMediaEntities = yield this.apiClient.post(`/${this.ENDPOINT}`, undefined, formData);
|
|
620
|
-
const mediaMetadata = yield this.getMetadataPromise();
|
|
631
|
+
const mediaMetadata = yield this.getMetadataPromise(exifDataPromise);
|
|
621
632
|
const mediaEntities = yield Promise.all(tmpMediaEntities.map((item) => this.apiClient.post(`/${this.ENDPOINT}/{id}`, { path: { id: item.id } }, mediaMetadata)));
|
|
622
633
|
const ids = mediaEntities.map((item) => item ? item.id : undefined).filter(item => item !== undefined);
|
|
623
634
|
tmpMedias.forEach(id => {
|
|
@@ -89,8 +89,8 @@ let PrefixArrayField = class PrefixArrayField extends React.Component {
|
|
|
89
89
|
}
|
|
90
90
|
render() {
|
|
91
91
|
const SchemaField = this.props.registry.fields.SchemaField;
|
|
92
|
-
const { schema, uiSchema, idSchema, errorSchema, required, formContext: { Label, translations } } = this.props;
|
|
93
|
-
const { prefixValues = [], addFieldPlaceholder } = (0, utils_1.getUiOptions)(uiSchema);
|
|
92
|
+
const { schema, uiSchema, idSchema, errorSchema, required, disabled, readonly, formContext: { Label, translations, uiSchemaContext } } = this.props;
|
|
93
|
+
const { prefixValues = [], addFieldPlaceholder, confirmDelete = uiSchemaContext.confirmDelete } = (0, utils_1.getUiOptions)(uiSchema);
|
|
94
94
|
const childProps = this.state.fieldValues.map((value, idx) => {
|
|
95
95
|
return {
|
|
96
96
|
schema: schema.items,
|
|
@@ -114,7 +114,7 @@ let PrefixArrayField = class PrefixArrayField extends React.Component {
|
|
|
114
114
|
React.createElement("div", { className: "laji-form-field-template-schema" },
|
|
115
115
|
React.createElement(SchemaField, Object.assign({}, this.props, props, { key: idx, onChange: this.onFieldChange(idx) }))),
|
|
116
116
|
React.createElement("div", { className: "laji-form-field-template-buttons" },
|
|
117
|
-
React.createElement(components_1.DeleteButton, { id: props.idSchema.$id, onClick: this.onFieldDelete(idx), translations: translations })))),
|
|
117
|
+
React.createElement(components_1.DeleteButton, { id: props.idSchema.$id, onClick: this.onFieldDelete(idx), translations: translations, confirm: confirmDelete, disabled: disabled || readonly })))),
|
|
118
118
|
React.createElement(SelectWidget_1.default, { key: childProps.length, options: { enumOptions: selectableFieldEnums, placeholder: addFieldPlaceholder !== null && addFieldPlaceholder !== void 0 ? addFieldPlaceholder : `${translations.AddField}` }, onChange: this.onSelectFieldChange, includeEmpty: true, schema: {}, id: `${idSchema.$id}_field_select`, formContext: this.props.formContext, disabled: this.props.disabled, readonly: this.props.readonly })));
|
|
119
119
|
}
|
|
120
120
|
};
|
|
@@ -357,7 +357,7 @@ let SectionArrayFieldTemplate = class SectionArrayFieldTemplate extends React.Co
|
|
|
357
357
|
return null;
|
|
358
358
|
}
|
|
359
359
|
const { children, hasRemove, index, disabled, readonly, onDropIndexClick } = this.props.items[idx];
|
|
360
|
-
const del = hasRemove && (React.createElement(components_1.DeleteButton, { id: `${this.props.idSchema.$id}_${index}`, disabled: disabled || readonly, translations: this.props.formContext.translations, onClick: onDropIndexClick(index), className: "horizontally-centered" }));
|
|
360
|
+
const del = hasRemove && (React.createElement(components_1.DeleteButton, { id: `${this.props.idSchema.$id}_${index}`, disabled: disabled || readonly, translations: this.props.formContext.translations, confirm: this.props.formContext.uiSchemaContext.confirmDelete, onClick: onDropIndexClick(index), className: "horizontally-centered" }));
|
|
361
361
|
const sectionLabel = (React.createElement(components_1.Affix, { className: index % 2 ? "background" : " darker", containerRef: this.containerRef, topOffset: this.props.formContext.topOffset, bottomOffset: this.props.formContext.bottomOffset },
|
|
362
362
|
React.createElement("legend", { className: "horizontally-centered" }, (0, utils_1.parseJSONPointer)(this.props.formData[index], sectionField))));
|
|
363
363
|
const [arr, field] = rowValueField.split("/%{row}");
|
|
@@ -471,8 +471,8 @@ let AccordionArrayFieldTemplate = class AccordionArrayFieldTemplate extends Reac
|
|
|
471
471
|
const that = this.props.formContext.this;
|
|
472
472
|
const arrayFieldTemplateProps = this.props;
|
|
473
473
|
const activeIdx = that.state.activeIdx;
|
|
474
|
-
const {
|
|
475
|
-
const {
|
|
474
|
+
const { translations, uiSchemaContext } = this.props.formContext;
|
|
475
|
+
const { confirmDelete = uiSchemaContext.confirmDelete, closeButton, affixed } = (0, utils_1.getUiOptions)(arrayFieldTemplateProps.uiSchema);
|
|
476
476
|
const { disabled, readonly } = arrayFieldTemplateProps;
|
|
477
477
|
const containerRefs = {};
|
|
478
478
|
(0, utils_1.asArray)(activeIdx).forEach(idx => {
|
|
@@ -526,8 +526,8 @@ let PagerArrayFieldTemplate = class PagerArrayFieldTemplate extends React.Compon
|
|
|
526
526
|
render() {
|
|
527
527
|
const that = this.props.formContext.this;
|
|
528
528
|
const arrayTemplateFieldProps = this.props;
|
|
529
|
-
const { translations } = that.props.formContext;
|
|
530
|
-
const { buttons, affixed, headerClassName, confirmDelete } = (0, utils_1.getUiOptions)(arrayTemplateFieldProps.uiSchema);
|
|
529
|
+
const { translations, uiSchemaContext } = that.props.formContext;
|
|
530
|
+
const { buttons, affixed, headerClassName, confirmDelete = uiSchemaContext.confirmDelete } = (0, utils_1.getUiOptions)(arrayTemplateFieldProps.uiSchema);
|
|
531
531
|
const activeIdx = that.state.activeIdx;
|
|
532
532
|
const { Pager } = this.context.theme;
|
|
533
533
|
let header = (React.createElement("div", { className: `laji-form-panel-header laji-form-accordion-header${headerClassName ? ` ${headerClassName}` : ""}`, ref: this.setHeaderRef },
|
|
@@ -800,7 +800,7 @@ let TableArrayFieldTemplate = class TableArrayFieldTemplate extends React.Compon
|
|
|
800
800
|
const that = this.props.formContext.this;
|
|
801
801
|
const { errorSchema } = that.props;
|
|
802
802
|
const activeIdx = that.state.activeIdx;
|
|
803
|
-
const { confirmDelete } = (0, utils_1.getUiOptions)(uiSchema);
|
|
803
|
+
const { confirmDelete = this.props.formContext.uiSchemaContext.confirmDelete } = (0, utils_1.getUiOptions)(uiSchema);
|
|
804
804
|
const getDeleteButtonFor = (idx, item) => {
|
|
805
805
|
return removable && React.createElement(components_1.DeleteButton, { id: `${that.props.idSchema.$id}_${idx}`, disabled: disabled || readonly, ref: this.getDeleteButtonRef(idx), key: (0, utils_1.getUUID)(this.props.formData[item.index]) || item.key, confirm: confirmDelete, translations: this.props.formContext.translations, onClick: that.onDelete(item) });
|
|
806
806
|
};
|
|
@@ -135,7 +135,7 @@ exports.default = TableField;
|
|
|
135
135
|
let TableArrayFieldTemplate = class TableArrayFieldTemplate extends React.Component {
|
|
136
136
|
render() {
|
|
137
137
|
const { props } = this;
|
|
138
|
-
const { schema, uiSchema, formContext: { cols, wrapperCols, schemaPropsArray }, idSchema, readonly, disabled } = props;
|
|
138
|
+
const { schema, uiSchema, formContext: { cols, wrapperCols, schemaPropsArray, uiSchemaContext }, idSchema, readonly, disabled } = props;
|
|
139
139
|
const schemaProps = schema.additionalItems ? schema.additionalItems.properties : schema.items.properties;
|
|
140
140
|
const { Label } = this.props.formContext;
|
|
141
141
|
const { Row, Col } = this.context.theme;
|
|
@@ -146,7 +146,7 @@ let TableArrayFieldTemplate = class TableArrayFieldTemplate extends React.Compon
|
|
|
146
146
|
|| propUiSchema["ui:required"], uiSchema: propUiSchema })));
|
|
147
147
|
});
|
|
148
148
|
const options = (0, utils_1.getUiOptions)(props.uiSchema);
|
|
149
|
-
const { confirmDelete, deleteCorner, removable = true, nonRemovables = [], buttons, "ui:deleteHelp": deleteHelp } = options;
|
|
149
|
+
const { confirmDelete = uiSchemaContext.confirmDelete, deleteCorner, removable = true, nonRemovables = [], buttons, "ui:deleteHelp": deleteHelp } = options;
|
|
150
150
|
if (!this.deleteButtonRefs)
|
|
151
151
|
this.deleteButtonRefs = [];
|
|
152
152
|
const getRefFor = i => elem => { this.deleteButtonRefs[i] = elem; };
|
|
@@ -301,9 +301,9 @@ class ArrayFieldTemplateWithoutKeyHandling extends React.Component {
|
|
|
301
301
|
}
|
|
302
302
|
render() {
|
|
303
303
|
const { props } = this;
|
|
304
|
-
const { confirmDelete, renderTitleAsLabel, deleteCorner, removable = true, orderable, nonRemovables = [], nonOrderables = [], "ui:deleteHelp": deleteHelp, buttons = [] } = (0, utils_1.getUiOptions)(props.uiSchema);
|
|
305
304
|
const { readonly, disabled } = this.props;
|
|
306
|
-
const { Label } = this.props.formContext;
|
|
305
|
+
const { Label, uiSchemaContext } = this.props.formContext;
|
|
306
|
+
const { confirmDelete = uiSchemaContext.confirmDelete, renderTitleAsLabel, deleteCorner, removable = true, orderable, nonRemovables = [], nonOrderables = [], "ui:deleteHelp": deleteHelp, buttons = [] } = (0, utils_1.getUiOptions)(props.uiSchema);
|
|
307
307
|
const Title = renderTitleAsLabel ? Label : (0, utils_2.getTemplate)("TitleFieldTemplate", props.registry, (0, utils_1.getUiOptions)(props.uiSchema));
|
|
308
308
|
const Description = (0, utils_2.getTemplate)("DescriptionFieldTemplate", this.props.registry, (0, utils_1.getUiOptions)(props.uiSchema));
|
|
309
309
|
if (!this.deleteButtonRefs)
|
package/lib/themes/bs5.js
CHANGED
|
@@ -67,7 +67,10 @@ const mapValidationStateToClass = (validationState) => {
|
|
|
67
67
|
}
|
|
68
68
|
return "text-" + (validationState === "error" ? "danger" : validationState);
|
|
69
69
|
};
|
|
70
|
-
const _Card = React.forwardRef((
|
|
70
|
+
const _Card = React.forwardRef((_a, ref) => {
|
|
71
|
+
var { eventKey } = _a, props = __rest(_a, ["eventKey"]);
|
|
72
|
+
return (React.createElement(react_bootstrap_5_1.Card, Object.assign({}, props, { ref: ref })));
|
|
73
|
+
});
|
|
71
74
|
let Panel = _Card;
|
|
72
75
|
Panel.Body = react_bootstrap_5_1.Card.Body;
|
|
73
76
|
Panel.Heading = React.forwardRef((props, ref) => (React.createElement(react_bootstrap_5_1.Card.Header, Object.assign({ className: "panel-heading" }, props, { ref: ref }))));
|
|
@@ -98,6 +101,11 @@ const _Popover = React.forwardRef((_a, ref) => {
|
|
|
98
101
|
props.title ? React.createElement(react_bootstrap_5_1.Popover.Header, null, props.title) : null,
|
|
99
102
|
React.createElement(react_bootstrap_5_1.Popover.Body, null, children)));
|
|
100
103
|
});
|
|
104
|
+
const _Pager = react_bootstrap_5_1.Pagination;
|
|
105
|
+
_Pager.Item = React.forwardRef((_a, ref) => {
|
|
106
|
+
var { previous, next } = _a, props = __rest(_a, ["previous", "next"]);
|
|
107
|
+
return (React.createElement(react_bootstrap_5_1.PageItem, Object.assign({}, props, { ref: ref })));
|
|
108
|
+
});
|
|
101
109
|
const theme = {
|
|
102
110
|
Panel,
|
|
103
111
|
Table: react_bootstrap_5_1.Table,
|
|
@@ -134,7 +142,7 @@ const theme = {
|
|
|
134
142
|
var { variant } = _a, props = __rest(_a, ["variant"]);
|
|
135
143
|
return React.createElement(react_bootstrap_5_1.Alert, Object.assign({ variant: mapVariant(variant) }, props, { ref: ref }));
|
|
136
144
|
}),
|
|
137
|
-
Pager:
|
|
145
|
+
Pager: _Pager,
|
|
138
146
|
Accordion: React.forwardRef((props, ref) => React.createElement(react_bootstrap_5_1.Accordion, Object.assign({}, props, { ref: ref }))),
|
|
139
147
|
Collapse: react_bootstrap_5_1.Collapse,
|
|
140
148
|
Dropdown: _Dropdown,
|