@rjsf/core 6.1.1 → 6.2.3
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/core.umd.js +65 -44
- package/dist/index.cjs +65 -44
- package/dist/index.cjs.map +3 -3
- package/dist/index.esm.js +68 -47
- package/dist/index.esm.js.map +3 -3
- package/lib/components/Form.d.ts +17 -5
- package/lib/components/Form.d.ts.map +1 -1
- package/lib/components/Form.js +35 -49
- package/lib/components/fields/LayoutMultiSchemaField.d.ts.map +1 -1
- package/lib/components/fields/LayoutMultiSchemaField.js +1 -1
- package/lib/components/fields/SchemaField.d.ts.map +1 -1
- package/lib/components/fields/SchemaField.js +1 -0
- package/lib/components/templates/BaseInputTemplate.d.ts.map +1 -1
- package/lib/components/templates/BaseInputTemplate.js +7 -1
- package/lib/components/templates/ButtonTemplates/IconButton.d.ts +1 -0
- package/lib/components/templates/ButtonTemplates/IconButton.d.ts.map +1 -1
- package/lib/components/templates/ButtonTemplates/IconButton.js +4 -0
- package/lib/components/templates/ButtonTemplates/index.d.ts.map +1 -1
- package/lib/components/templates/ButtonTemplates/index.js +2 -1
- package/lib/components/templates/ObjectFieldTemplate.d.ts +1 -1
- package/lib/components/templates/ObjectFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/ObjectFieldTemplate.js +6 -0
- package/lib/components/widgets/TextareaWidget.d.ts +0 -6
- package/lib/components/widgets/TextareaWidget.d.ts.map +1 -1
- package/lib/components/widgets/TextareaWidget.js +0 -4
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -10
- package/src/components/Form.tsx +53 -62
- package/src/components/fields/LayoutMultiSchemaField.tsx +1 -0
- package/src/components/fields/SchemaField.tsx +1 -0
- package/src/components/templates/BaseInputTemplate.tsx +13 -1
- package/src/components/templates/ButtonTemplates/IconButton.tsx +24 -0
- package/src/components/templates/ButtonTemplates/index.ts +2 -1
- package/src/components/templates/ObjectFieldTemplate.tsx +9 -0
- package/src/components/widgets/TextareaWidget.tsx +0 -5
package/lib/components/Form.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { Component, ElementType, FormEvent, ReactNode, Ref, RefObject } from 'react';
|
|
2
2
|
import { CustomValidator, ErrorSchema, ErrorSchemaBuilder, ErrorTransformer, FieldPathId, FieldPathList, FormContextType, PathSchema, StrictRJSFSchema, Registry, RegistryFieldsType, RegistryWidgetsType, RJSFSchema, RJSFValidationError, SchemaUtilsType, TemplatesType, UiSchema, ValidationData, ValidatorType, Experimental_DefaultFormStateBehavior, Experimental_CustomMergeAllOf, NameGeneratorFunction } from '@rjsf/utils';
|
|
3
|
+
/** Represents a boolean option that is deprecated.
|
|
4
|
+
* @deprecated - In a future major release, this type will be removed
|
|
5
|
+
*/
|
|
6
|
+
type DeprecatedBooleanOption = boolean;
|
|
3
7
|
/** The properties that are passed to the `Form` */
|
|
4
8
|
export interface FormProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> {
|
|
5
9
|
/** The JSON schema object for the form */
|
|
@@ -124,9 +128,9 @@ export interface FormProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F e
|
|
|
124
128
|
* is provided, then live validation will be performed when a field that was updated is blurred (as a performance
|
|
125
129
|
* optimization).
|
|
126
130
|
*
|
|
127
|
-
*
|
|
131
|
+
* NOTE: In a future major release, the `boolean` options for this flag will be removed
|
|
128
132
|
*/
|
|
129
|
-
liveValidate?:
|
|
133
|
+
liveValidate?: 'onChange' | 'onBlur' | DeprecatedBooleanOption;
|
|
130
134
|
/** Flag that describes when live omit will be performed. Live omit happens only when `omitExtraData` is also set to
|
|
131
135
|
* to `true` and the form's data is updated by the user.
|
|
132
136
|
*
|
|
@@ -135,9 +139,9 @@ export interface FormProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F e
|
|
|
135
139
|
* is provided, then live omit will be performed when a field that was updated is blurred (as a performance
|
|
136
140
|
* optimization).
|
|
137
141
|
*
|
|
138
|
-
*
|
|
142
|
+
* NOTE: In a future major release, the `boolean` options for this flag will be removed
|
|
139
143
|
*/
|
|
140
|
-
liveOmit?:
|
|
144
|
+
liveOmit?: 'onChange' | 'onBlur' | DeprecatedBooleanOption;
|
|
141
145
|
/** If set to true, then extra form data values that are not in any form field will be removed whenever `onSubmit` is
|
|
142
146
|
* called. Set to `false` by default.
|
|
143
147
|
*/
|
|
@@ -268,6 +272,10 @@ export default class Form<T = any, S extends StrictRJSFSchema = RJSFSchema, F ex
|
|
|
268
272
|
/** The list of pending changes
|
|
269
273
|
*/
|
|
270
274
|
pendingChanges: PendingChange<T>[];
|
|
275
|
+
/** Flag to track when we're processing a user-initiated field change.
|
|
276
|
+
* This prevents componentDidUpdate from reverting oneOf/anyOf option switches.
|
|
277
|
+
*/
|
|
278
|
+
private _isProcessingUserChange;
|
|
271
279
|
/** Constructs the `Form` from the `props`. Will setup the initial state from the props. It will also call the
|
|
272
280
|
* `onChange` handler if the initially provided `formData` is modified to add missing default values as part of the
|
|
273
281
|
* state construction.
|
|
@@ -376,18 +384,22 @@ export default class Form<T = any, S extends StrictRJSFSchema = RJSFSchema, F ex
|
|
|
376
384
|
*
|
|
377
385
|
* @param formData - The data for the `Form`
|
|
378
386
|
* @param fields - The fields to keep while filtering
|
|
387
|
+
* @deprecated - To be removed as an exported `Form` function in a future release; there isn't a planned replacement
|
|
379
388
|
*/
|
|
380
|
-
getUsedFormData: (formData: T | undefined, fields: string[]
|
|
389
|
+
getUsedFormData: (formData: T | undefined, fields: string[]) => T | undefined;
|
|
381
390
|
/** Returns the list of field names from inspecting the `pathSchema` as well as using the `formData`
|
|
382
391
|
*
|
|
383
392
|
* @param pathSchema - The `PathSchema` object for the form
|
|
384
393
|
* @param [formData] - The form data to use while checking for empty objects/arrays
|
|
394
|
+
* @deprecated - To be removed as an exported `Form` function in a future release; there isn't a planned replacement
|
|
385
395
|
*/
|
|
386
396
|
getFieldNames: (pathSchema: PathSchema<T>, formData?: T) => string[][];
|
|
387
397
|
/** Returns the `formData` after filtering to remove any extra data not in a form field
|
|
388
398
|
*
|
|
389
399
|
* @param formData - The data for the `Form`
|
|
390
400
|
* @returns The `formData` after omitting extra data
|
|
401
|
+
* @deprecated - To be removed as an exported `Form` function in a future release, use `SchemaUtils.omitExtraData`
|
|
402
|
+
* instead.
|
|
391
403
|
*/
|
|
392
404
|
omitExtraData: (formData?: T) => T | undefined;
|
|
393
405
|
/** Allows a user to set a value for the provided `fieldPath`, which must be either a dotted path to the field OR a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../src/components/Form.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AAChG,OAAO,EAEL,eAAe,EAEf,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,eAAe,
|
|
1
|
+
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../src/components/Form.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AAChG,OAAO,EAEL,eAAe,EAEf,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,eAAe,EAMf,UAAU,EACV,gBAAgB,EAChB,QAAQ,EACR,kBAAkB,EAClB,mBAAmB,EACnB,UAAU,EACV,mBAAmB,EACnB,eAAe,EAGf,aAAa,EAGb,QAAQ,EAGR,cAAc,EAEd,aAAa,EACb,qCAAqC,EACrC,6BAA6B,EAM7B,qBAAqB,EAGtB,MAAM,aAAa,CAAC;AAYrB;;GAEG;AACH,KAAK,uBAAuB,GAAG,OAAO,CAAC;AAEvC,mDAAmD;AACnD,MAAM,WAAW,SAAS,CAAC,CAAC,GAAG,GAAG,EAAE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;;;;;OAKG;IACH,wBAAwB,GAAI,WAAW,CAAC,KAAG,OAAO,CA8ChD;IAEF;;;;;OAKG;IACH,YAAY;IASZ;;OAEG;IACH,MAAM;CAwEP"}
|
package/lib/components/Form.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Component, createRef } from 'react';
|
|
3
|
-
import { createSchemaUtils, deepEquals, ErrorSchemaBuilder, getChangedFields, getTemplate, getUiOptions, isObject, mergeObjects,
|
|
3
|
+
import { createSchemaUtils, deepEquals, ErrorSchemaBuilder, getChangedFields, getTemplate, getUiOptions, isObject, mergeObjects, shouldRender, SUBMIT_BTN_OPTIONS_KEY, toErrorList, toFieldPathId, UI_GLOBAL_OPTIONS_KEY, UI_OPTIONS_KEY, validationDataMerge, DEFAULT_ID_SEPARATOR, DEFAULT_ID_PREFIX, ERRORS_KEY, ID_KEY, getUsedFormData, getFieldNames, } from '@rjsf/utils';
|
|
4
4
|
import _cloneDeep from 'lodash-es/cloneDeep.js';
|
|
5
5
|
import _get from 'lodash-es/get.js';
|
|
6
6
|
import _isEmpty from 'lodash-es/isEmpty.js';
|
|
@@ -31,6 +31,10 @@ export default class Form extends Component {
|
|
|
31
31
|
/** The list of pending changes
|
|
32
32
|
*/
|
|
33
33
|
pendingChanges = [];
|
|
34
|
+
/** Flag to track when we're processing a user-initiated field change.
|
|
35
|
+
* This prevents componentDidUpdate from reverting oneOf/anyOf option switches.
|
|
36
|
+
*/
|
|
37
|
+
_isProcessingUserChange = false;
|
|
34
38
|
/** Constructs the `Form` from the `props`. Will setup the initial state from the props. It will also call the
|
|
35
39
|
* `onChange` handler if the initially provided `formData` is modified to add missing default values as part of the
|
|
36
40
|
* state construction.
|
|
@@ -107,9 +111,16 @@ export default class Form extends Component {
|
|
|
107
111
|
componentDidUpdate(_, prevState, snapshot) {
|
|
108
112
|
if (snapshot.shouldUpdate) {
|
|
109
113
|
const { nextState } = snapshot;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
114
|
+
// Prevent oneOf/anyOf option switches from reverting when getStateFromProps
|
|
115
|
+
// re-evaluates and produces stale formData.
|
|
116
|
+
const nextStateDiffersFromProps = !deepEquals(nextState.formData, this.props.formData);
|
|
117
|
+
const wasProcessingUserChange = this._isProcessingUserChange;
|
|
118
|
+
this._isProcessingUserChange = false;
|
|
119
|
+
if (wasProcessingUserChange && nextStateDiffersFromProps) {
|
|
120
|
+
// Skip - the user's option switch is already applied via processPendingChange
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (nextStateDiffersFromProps && !deepEquals(nextState.formData, prevState.formData) && this.props.onChange) {
|
|
113
124
|
this.props.onChange(toIChangeEvent(nextState));
|
|
114
125
|
}
|
|
115
126
|
this.setState(nextState);
|
|
@@ -319,67 +330,30 @@ export default class Form extends Component {
|
|
|
319
330
|
*
|
|
320
331
|
* @param formData - The data for the `Form`
|
|
321
332
|
* @param fields - The fields to keep while filtering
|
|
333
|
+
* @deprecated - To be removed as an exported `Form` function in a future release; there isn't a planned replacement
|
|
322
334
|
*/
|
|
323
335
|
getUsedFormData = (formData, fields) => {
|
|
324
|
-
|
|
325
|
-
if (fields.length === 0 && typeof formData !== 'object') {
|
|
326
|
-
return formData;
|
|
327
|
-
}
|
|
328
|
-
// _pick has incorrect type definition, it works with string[][], because lodash/hasIn supports it
|
|
329
|
-
const data = _pick(formData, fields);
|
|
330
|
-
if (Array.isArray(formData)) {
|
|
331
|
-
return Object.keys(data).map((key) => data[key]);
|
|
332
|
-
}
|
|
333
|
-
return data;
|
|
336
|
+
return getUsedFormData(formData, fields);
|
|
334
337
|
};
|
|
335
338
|
/** Returns the list of field names from inspecting the `pathSchema` as well as using the `formData`
|
|
336
339
|
*
|
|
337
340
|
* @param pathSchema - The `PathSchema` object for the form
|
|
338
341
|
* @param [formData] - The form data to use while checking for empty objects/arrays
|
|
342
|
+
* @deprecated - To be removed as an exported `Form` function in a future release; there isn't a planned replacement
|
|
339
343
|
*/
|
|
340
344
|
getFieldNames = (pathSchema, formData) => {
|
|
341
|
-
|
|
342
|
-
const getAllPaths = (_obj, acc = [], paths = [[]]) => {
|
|
343
|
-
const objKeys = Object.keys(_obj);
|
|
344
|
-
objKeys.forEach((key) => {
|
|
345
|
-
const data = _obj[key];
|
|
346
|
-
if (typeof data === 'object') {
|
|
347
|
-
const newPaths = paths.map((path) => [...path, key]);
|
|
348
|
-
// If an object is marked with additionalProperties, all its keys are valid
|
|
349
|
-
if (data[RJSF_ADDITIONAL_PROPERTIES_FLAG] && data[NAME_KEY] !== '') {
|
|
350
|
-
acc.push(data[NAME_KEY]);
|
|
351
|
-
}
|
|
352
|
-
else {
|
|
353
|
-
getAllPaths(data, acc, newPaths);
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
else if (key === NAME_KEY && data !== '') {
|
|
357
|
-
paths.forEach((path) => {
|
|
358
|
-
const formValue = _get(formData, path);
|
|
359
|
-
const isLeaf = objKeys.length === 1;
|
|
360
|
-
// adds path to fieldNames if it points to a value or an empty object/array which is not a leaf
|
|
361
|
-
if (formValueHasData(formValue, isLeaf) ||
|
|
362
|
-
(Array.isArray(formValue) && formValue.every((val) => formValueHasData(val, isLeaf)))) {
|
|
363
|
-
acc.push(path);
|
|
364
|
-
}
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
});
|
|
368
|
-
return acc;
|
|
369
|
-
};
|
|
370
|
-
return getAllPaths(pathSchema);
|
|
345
|
+
return getFieldNames(pathSchema, formData);
|
|
371
346
|
};
|
|
372
347
|
/** Returns the `formData` after filtering to remove any extra data not in a form field
|
|
373
348
|
*
|
|
374
349
|
* @param formData - The data for the `Form`
|
|
375
350
|
* @returns The `formData` after omitting extra data
|
|
351
|
+
* @deprecated - To be removed as an exported `Form` function in a future release, use `SchemaUtils.omitExtraData`
|
|
352
|
+
* instead.
|
|
376
353
|
*/
|
|
377
354
|
omitExtraData = (formData) => {
|
|
378
355
|
const { schema, schemaUtils } = this.state;
|
|
379
|
-
|
|
380
|
-
const pathSchema = schemaUtils.toPathSchema(retrievedSchema, '', formData);
|
|
381
|
-
const fieldNames = this.getFieldNames(pathSchema, formData);
|
|
382
|
-
return this.getUsedFormData(formData, fieldNames);
|
|
356
|
+
return schemaUtils.omitExtraData(schema, formData);
|
|
383
357
|
};
|
|
384
358
|
/** Allows a user to set a value for the provided `fieldPath`, which must be either a dotted path to the field OR a
|
|
385
359
|
* `FieldPathList`. To set the root element, used either `''` or `[]` for the path. Passing undefined will clear the
|
|
@@ -421,6 +395,9 @@ export default class Form extends Component {
|
|
|
421
395
|
if (this.pendingChanges.length === 0) {
|
|
422
396
|
return;
|
|
423
397
|
}
|
|
398
|
+
// Mark that we're processing a user-initiated change.
|
|
399
|
+
// This prevents componentDidUpdate from reverting oneOf/anyOf option switches.
|
|
400
|
+
this._isProcessingUserChange = true;
|
|
424
401
|
const { newValue, path, id } = this.pendingChanges[0];
|
|
425
402
|
const { newErrorSchema } = this.pendingChanges[0];
|
|
426
403
|
const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange } = this.props;
|
|
@@ -430,6 +407,15 @@ export default class Form extends Component {
|
|
|
430
407
|
const isRootPath = !path || path.length === 0 || (path.length === 1 && path[0] === rootPathId);
|
|
431
408
|
let retrievedSchema = this.state.retrievedSchema;
|
|
432
409
|
let formData = isRootPath ? newValue : _cloneDeep(oldFormData);
|
|
410
|
+
// When switching from null to an object option in oneOf, MultiSchemaField sends
|
|
411
|
+
// an object with property names but undefined values (e.g., {types: undefined, content: undefined}).
|
|
412
|
+
// In this case, pass undefined to getStateFromProps to trigger fresh default computation.
|
|
413
|
+
// Only do this when the previous formData was null/undefined (switching FROM null).
|
|
414
|
+
const hasOnlyUndefinedValues = isObject(formData) &&
|
|
415
|
+
Object.keys(formData).length > 0 &&
|
|
416
|
+
Object.values(formData).every((v) => v === undefined);
|
|
417
|
+
const wasPreviouslyNull = oldFormData === null || oldFormData === undefined;
|
|
418
|
+
const inputForDefaults = hasOnlyUndefinedValues && wasPreviouslyNull ? undefined : formData;
|
|
433
419
|
if (isObject(formData) || Array.isArray(formData)) {
|
|
434
420
|
if (newValue === ADDITIONAL_PROPERTY_KEY_REMOVE) {
|
|
435
421
|
// For additional properties, we were given the special remove this key value, so unset it
|
|
@@ -440,7 +426,7 @@ export default class Form extends Component {
|
|
|
440
426
|
_set(formData, path, newValue);
|
|
441
427
|
}
|
|
442
428
|
// Pass true to skip live validation in `getStateFromProps()` since we will do it a bit later
|
|
443
|
-
const newState = this.getStateFromProps(this.props,
|
|
429
|
+
const newState = this.getStateFromProps(this.props, inputForDefaults, undefined, undefined, undefined, true);
|
|
444
430
|
formData = newState.formData;
|
|
445
431
|
retrievedSchema = newState.retrievedSchema;
|
|
446
432
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LayoutMultiSchemaField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/LayoutMultiSchemaField.tsx"],"names":[],"mappings":"AACA,OAAO,EAIL,eAAe,EAEf,UAAU,EACV,eAAe,EAOf,UAAU,EAIV,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACT,MAAM,aAAa,CAAC;AAQrB;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvE,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,EAC7B,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,OAAO,GACb,CAAC,GAAG,SAAS,CAQf;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EAClH,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,CAAC,EAAE,EACZ,WAAW,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACrC,QAAQ,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,UAAU,sBAAsB,CAC5C,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAuI3B"}
|
|
@@ -110,5 +110,5 @@ export default function LayoutMultiSchemaField(props) {
|
|
|
110
110
|
// filtering the options based on the type of widget because `selectField` does not recognize the `convertOther` prop
|
|
111
111
|
const widgetOptions = { enumOptions, ...uiOptions };
|
|
112
112
|
const errors = !hideFieldError && rawErrors.length > 0 ? (_jsx(FieldErrorTemplate, { fieldPathId: fieldPathId, schema: schema, errors: rawErrors, registry: registry })) : undefined;
|
|
113
|
-
return (_jsx(FieldTemplate, { id: id, schema: schema, label: (title || schema.title) ?? '', disabled: disabled || (Array.isArray(enumOptions) && isEmpty(enumOptions)), uiSchema: uiSchema, required: required, readonly: !!readonly, registry: registry, displayLabel: displayLabel, errors: errors, onChange: onChange, onKeyRename: noop, onKeyRenameBlur: noop, onRemoveProperty: noop, children: _jsx(Widget, { id: id, name: name, schema: schema, label: (title || schema.title) ?? '', disabled: disabled || (Array.isArray(enumOptions) && isEmpty(enumOptions)), uiSchema: uiSchema, autofocus: autofocus, readonly: readonly, required: required, registry: registry, multiple: false, rawErrors: rawErrors, hideError: hideFieldError, hideLabel: !displayLabel, errorSchema: fieldErrorSchema, placeholder: placeholder, onChange: onOptionChange, onBlur: onBlur, onFocus: onFocus, value: selectedOption, options: widgetOptions, htmlName: fieldPathId.name }) }));
|
|
113
|
+
return (_jsx(FieldTemplate, { fieldPathId: fieldPathId, id: id, schema: schema, label: (title || schema.title) ?? '', disabled: disabled || (Array.isArray(enumOptions) && isEmpty(enumOptions)), uiSchema: uiSchema, required: required, readonly: !!readonly, registry: registry, displayLabel: displayLabel, errors: errors, onChange: onChange, onKeyRename: noop, onKeyRenameBlur: noop, onRemoveProperty: noop, children: _jsx(Widget, { id: id, name: name, schema: schema, label: (title || schema.title) ?? '', disabled: disabled || (Array.isArray(enumOptions) && isEmpty(enumOptions)), uiSchema: uiSchema, autofocus: autofocus, readonly: readonly, required: required, registry: registry, multiple: false, rawErrors: rawErrors, hideError: hideFieldError, hideLabel: !displayLabel, errorSchema: fieldErrorSchema, placeholder: placeholder, onChange: onOptionChange, onBlur: onBlur, onFocus: onFocus, value: selectedOption, options: widgetOptions, htmlName: fieldPathId.name }) }));
|
|
114
114
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/SchemaField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,SAAS,EAAiB,MAAM,OAAO,CAAC;AAC9D,OAAO,EAQL,UAAU,EAEV,eAAe,EAQf,UAAU,EAGV,gBAAgB,EAIjB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"SchemaField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/SchemaField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,SAAS,EAAiB,MAAM,OAAO,CAAC;AAC9D,OAAO,EAQL,UAAU,EAEV,eAAe,EAQf,UAAU,EAGV,gBAAgB,EAIjB,MAAM,aAAa,CAAC;AAiSrB;;GAEG;AACH,cAAM,WAAW,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,CAAE,SAAQ,SAAS,CACpH,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CACpB;IACC,qBAAqB,CAAC,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAS9D,MAAM;CAGP;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseInputTemplate.d.ts","sourceRoot":"","sources":["../../../src/components/templates/BaseInputTemplate.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,sBAAsB,EAGtB,eAAe,EACf,UAAU,EACV,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAErB;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,KAAK,EAAE,sBAAsB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"BaseInputTemplate.d.ts","sourceRoot":"","sources":["../../../src/components/templates/BaseInputTemplate.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,sBAAsB,EAGtB,eAAe,EACf,UAAU,EACV,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAErB;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,KAAK,EAAE,sBAAsB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CA+FvC"}
|
|
@@ -12,6 +12,7 @@ export default function BaseInputTemplate(props) {
|
|
|
12
12
|
htmlName, value, readonly, disabled, autofocus, onBlur, onFocus, onChange, onChangeOverride, options, schema, uiSchema, registry, rawErrors, type, hideLabel, // remove this from ...rest
|
|
13
13
|
hideError, // remove this from ...rest
|
|
14
14
|
...rest } = props;
|
|
15
|
+
const { ClearButton } = registry.templates.ButtonTemplates;
|
|
15
16
|
// Note: since React 15.2.0 we can't forward unknown element attributes, so we
|
|
16
17
|
// exclude the "options" and "schema" ones here.
|
|
17
18
|
if (!id) {
|
|
@@ -32,7 +33,12 @@ export default function BaseInputTemplate(props) {
|
|
|
32
33
|
const _onChange = useCallback(({ target: { value } }) => onChange(value === '' ? options.emptyValue : value), [onChange, options]);
|
|
33
34
|
const _onBlur = useCallback(({ target }) => onBlur(id, target && target.value), [onBlur, id]);
|
|
34
35
|
const _onFocus = useCallback(({ target }) => onFocus(id, target && target.value), [onFocus, id]);
|
|
35
|
-
|
|
36
|
+
const _onClear = useCallback((e) => {
|
|
37
|
+
e.preventDefault();
|
|
38
|
+
e.stopPropagation();
|
|
39
|
+
onChange(options.emptyValue ?? '');
|
|
40
|
+
}, [onChange, options.emptyValue]);
|
|
41
|
+
return (_jsxs(_Fragment, { children: [_jsx("input", { id: id, name: htmlName || id, className: 'form-control', readOnly: readonly, disabled: disabled, autoFocus: autofocus, value: inputValue, ...inputProps, list: schema.examples ? examplesId(id) : undefined, onChange: onChangeOverride || _onChange, onBlur: _onBlur, onFocus: _onFocus, "aria-describedby": ariaDescribedByIds(id, !!schema.examples) }), options.allowClearTextInputs && !readonly && !disabled && inputValue && (_jsx(ClearButton, { registry: registry, onClick: _onClear })), Array.isArray(schema.examples) && (_jsx("datalist", { id: examplesId(id), children: schema.examples
|
|
36
42
|
.concat(schema.default && !schema.examples.includes(schema.default) ? [schema.default] : [])
|
|
37
43
|
.map((example) => {
|
|
38
44
|
return _jsx("option", { value: example }, example);
|
|
@@ -4,4 +4,5 @@ export declare function CopyButton<T = any, S extends StrictRJSFSchema = RJSFSch
|
|
|
4
4
|
export declare function MoveDownButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: IconButtonProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
export declare function MoveUpButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: IconButtonProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
export declare function RemoveButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: IconButtonProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function ClearButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({ id, className, onClick, disabled, registry, ...props }: IconButtonProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
|
|
7
8
|
//# sourceMappingURL=IconButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconButton.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/ButtonTemplates/IconButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAsB,MAAM,aAAa,CAAC;AAEjH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EAClH,KAAK,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAQhC;AAED,wBAAgB,UAAU,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EAC1G,KAAK,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAMhC;AAED,wBAAgB,cAAc,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EAC9G,KAAK,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAMhC;AAED,wBAAgB,YAAY,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EAC5G,KAAK,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAMhC;AAED,wBAAgB,YAAY,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EAC5G,KAAK,EAAE,eAAe,CAAC,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B,WAAW,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EAAE,EAC7G,EAAE,EACF,SAAS,EACT,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAe1B"}
|
|
@@ -20,3 +20,7 @@ export function RemoveButton(props) {
|
|
|
20
20
|
const { registry: { translateString }, } = props;
|
|
21
21
|
return (_jsx(IconButton, { title: translateString(TranslatableString.RemoveButton), ...props, iconType: 'danger', icon: 'remove' }));
|
|
22
22
|
}
|
|
23
|
+
export function ClearButton({ id, className, onClick, disabled, registry, ...props }) {
|
|
24
|
+
const { translateString } = registry;
|
|
25
|
+
return (_jsx(IconButton, { id: id, iconType: 'default', icon: 'remove', className: 'btn-clear col-xs-12', title: translateString(TranslatableString.ClearButton), onClick: onClick, disabled: disabled, registry: registry, ...props }));
|
|
26
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/ButtonTemplates/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAM3F,iBAAS,eAAe,CACtB,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,KAC5B,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/ButtonTemplates/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAM3F,iBAAS,eAAe,CACtB,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,KAC5B,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAU7C;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import SubmitButton from './SubmitButton.js';
|
|
2
2
|
import AddButton from './AddButton.js';
|
|
3
|
-
import { CopyButton, MoveDownButton, MoveUpButton, RemoveButton } from './IconButton.js';
|
|
3
|
+
import { CopyButton, MoveDownButton, MoveUpButton, RemoveButton, ClearButton } from './IconButton.js';
|
|
4
4
|
function buttonTemplates() {
|
|
5
5
|
return {
|
|
6
6
|
SubmitButton,
|
|
@@ -9,6 +9,7 @@ function buttonTemplates() {
|
|
|
9
9
|
MoveDownButton,
|
|
10
10
|
MoveUpButton,
|
|
11
11
|
RemoveButton,
|
|
12
|
+
ClearButton,
|
|
12
13
|
};
|
|
13
14
|
}
|
|
14
15
|
export default buttonTemplates;
|
|
@@ -5,5 +5,5 @@ import { FormContextType, ObjectFieldTemplateProps, RJSFSchema, StrictRJSFSchema
|
|
|
5
5
|
*
|
|
6
6
|
* @param props - The `ObjectFieldTemplateProps` for this component
|
|
7
7
|
*/
|
|
8
|
-
export default function ObjectFieldTemplate<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: ObjectFieldTemplateProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export default function ObjectFieldTemplate<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: ObjectFieldTemplateProps<T, S, F>): import("react/jsx-runtime").JSX.Element | null;
|
|
9
9
|
//# sourceMappingURL=ObjectFieldTemplate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectFieldTemplate.d.ts","sourceRoot":"","sources":["../../../src/components/templates/ObjectFieldTemplate.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAEf,wBAAwB,EACxB,UAAU,EACV,gBAAgB,EAOjB,MAAM,aAAa,CAAC;AAErB;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CACzC,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,KAAK,EAAE,wBAAwB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"ObjectFieldTemplate.d.ts","sourceRoot":"","sources":["../../../src/components/templates/ObjectFieldTemplate.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAEf,wBAAwB,EACxB,UAAU,EACV,gBAAgB,EAOjB,MAAM,aAAa,CAAC;AAErB;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CACzC,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,KAAK,EAAE,wBAAwB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,kDA0EzC"}
|
|
@@ -11,6 +11,12 @@ export default function ObjectFieldTemplate(props) {
|
|
|
11
11
|
const options = getUiOptions(uiSchema);
|
|
12
12
|
const TitleFieldTemplate = getTemplate('TitleFieldTemplate', registry, options);
|
|
13
13
|
const DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, options);
|
|
14
|
+
// For "pure union" schemas (oneOf/anyOf without properties), skip rendering the empty fieldset wrapper.
|
|
15
|
+
// The AnyOfField/OneOfField will handle rendering the union selector and selected variant's content directly.
|
|
16
|
+
const isPureUnionSchema = (schema.oneOf || schema.anyOf) && !schema.properties && properties.length === 0;
|
|
17
|
+
if (isPureUnionSchema) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
14
20
|
const showOptionalDataControlInTitle = !readonly && !disabled;
|
|
15
21
|
// Button templates are not overridden in the uiSchema
|
|
16
22
|
const { ButtonTemplates: { AddButton }, } = registry.templates;
|
|
@@ -4,11 +4,5 @@ import { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjs
|
|
|
4
4
|
* @param props - The `WidgetProps` for this component
|
|
5
5
|
*/
|
|
6
6
|
declare function TextareaWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({ id, options, placeholder, value, required, disabled, readonly, autofocus, onChange, onBlur, onFocus, htmlName, }: WidgetProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
declare namespace TextareaWidget {
|
|
8
|
-
var defaultProps: {
|
|
9
|
-
autofocus: boolean;
|
|
10
|
-
options: {};
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
7
|
export default TextareaWidget;
|
|
14
8
|
//# sourceMappingURL=TextareaWidget.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextareaWidget.d.ts","sourceRoot":"","sources":["../../../src/components/widgets/TextareaWidget.tsx"],"names":[],"mappings":"AACA,OAAO,EAAsB,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE7G;;;GAGG;AACH,iBAAS,cAAc,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EAAE,EACzG,EAAE,EACF,OAAY,EACZ,WAAW,EACX,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,SAAiB,EACjB,QAAQ,EACR,MAAM,EACN,OAAO,EACP,QAAQ,GACT,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAkCtB;
|
|
1
|
+
{"version":3,"file":"TextareaWidget.d.ts","sourceRoot":"","sources":["../../../src/components/widgets/TextareaWidget.tsx"],"names":[],"mappings":"AACA,OAAO,EAAsB,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE7G;;;GAGG;AACH,iBAAS,cAAc,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EAAE,EACzG,EAAE,EACF,OAAY,EACZ,WAAW,EACX,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,SAAiB,EACjB,QAAQ,EACR,MAAM,EACN,OAAO,EACP,QAAQ,GACT,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAkCtB;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -11,8 +11,4 @@ function TextareaWidget({ id, options = {}, placeholder, value, required, disabl
|
|
|
11
11
|
const handleFocus = useCallback(({ target }) => onFocus(id, target && target.value), [id, onFocus]);
|
|
12
12
|
return (_jsx("textarea", { id: id, name: htmlName || id, className: 'form-control', value: value ? value : '', placeholder: placeholder, required: required, disabled: disabled, readOnly: readonly, autoFocus: autofocus, rows: options.rows, onBlur: handleBlur, onFocus: handleFocus, onChange: handleChange, "aria-describedby": ariaDescribedByIds(id) }));
|
|
13
13
|
}
|
|
14
|
-
TextareaWidget.defaultProps = {
|
|
15
|
-
autofocus: false,
|
|
16
|
-
options: {},
|
|
17
|
-
};
|
|
18
14
|
export default TextareaWidget;
|