@itcase/forms 1.0.63 → 1.0.65
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/css/form/Field/Chips/Chips.css +27 -0
- package/dist/css/form/FormField/FormField.css +10 -1
- package/dist/itcase-forms.cjs.js +287 -172
- package/dist/itcase-forms.esm.js +287 -173
- package/package.json +28 -22
package/dist/itcase-forms.cjs.js
CHANGED
|
@@ -33,6 +33,7 @@ var Select = require('@itcase/ui/components/Select');
|
|
|
33
33
|
var Switch = require('@itcase/ui/components/Switch');
|
|
34
34
|
var Textarea = require('@itcase/ui/components/Textarea');
|
|
35
35
|
var reactImask = require('react-imask');
|
|
36
|
+
var Chips = require('@itcase/ui/components/Chips');
|
|
36
37
|
var Button = require('@itcase/ui/components/Button');
|
|
37
38
|
var Group$1 = require('@itcase/ui/components/Group');
|
|
38
39
|
var Notification = require('@itcase/ui/components/Notification');
|
|
@@ -154,9 +155,11 @@ function FieldWrapperBase(props) {
|
|
|
154
155
|
labelHidden,
|
|
155
156
|
labelTextColor,
|
|
156
157
|
labelTextSize,
|
|
158
|
+
labelTextSizeMobile,
|
|
157
159
|
labelTextWeight,
|
|
158
160
|
helpText,
|
|
159
161
|
helpTextSize,
|
|
162
|
+
helpTextSizeMobile,
|
|
160
163
|
helpTextWeight,
|
|
161
164
|
helpTextColor,
|
|
162
165
|
isErrorState,
|
|
@@ -223,6 +226,7 @@ function FieldWrapperBase(props) {
|
|
|
223
226
|
htmlFor: id
|
|
224
227
|
}, /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
225
228
|
size: labelTextSize,
|
|
229
|
+
sizeMobile: labelTextSizeMobile,
|
|
226
230
|
textColor: labelTextColor,
|
|
227
231
|
textWeight: labelTextWeight
|
|
228
232
|
}, label, labelHidden && '\u00A0')), desc && /*#__PURE__*/React__default.default.createElement("div", {
|
|
@@ -256,6 +260,7 @@ function FieldWrapperBase(props) {
|
|
|
256
260
|
className: "form-field__message-item form-field__message-item_type_help-text",
|
|
257
261
|
dataTestId: `${inputName}FieldMessageHelpText`,
|
|
258
262
|
size: helpTextSize,
|
|
263
|
+
sizeMobile: helpTextSizeMobile,
|
|
259
264
|
textColor: helpTextColor,
|
|
260
265
|
textWeight: helpTextWeight
|
|
261
266
|
}, helpText), (!isErrorState && !helpText || isErrorState && !helpText && !errorMessage) && /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
@@ -2371,120 +2376,112 @@ MaskedInputField.propTypes = {
|
|
|
2371
2376
|
unmasked: PropTypes__default.default.string
|
|
2372
2377
|
};
|
|
2373
2378
|
|
|
2374
|
-
|
|
2375
|
-
const
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
if (!errorFieldElement && errorsList.length) {
|
|
2391
|
-
let errorElement;
|
|
2392
|
-
try {
|
|
2393
|
-
const fieldName = errorsList[0];
|
|
2394
|
-
if (fieldName === finalForm.FORM_ERROR) {
|
|
2395
|
-
errorElement = document.querySelector('notification__item_status_error');
|
|
2396
|
-
} else {
|
|
2397
|
-
errorElement = document.querySelector(`#${fieldName}-error`);
|
|
2398
|
-
if (!errorElement) {
|
|
2399
|
-
errorElement = document.querySelector(`#id_${fieldName}`);
|
|
2400
|
-
}
|
|
2401
|
-
}
|
|
2402
|
-
} catch (err) {
|
|
2403
|
-
console.warn(err);
|
|
2404
|
-
}
|
|
2405
|
-
if (errorElement) {
|
|
2406
|
-
errorElement.scrollIntoView({
|
|
2407
|
-
block: 'center'
|
|
2408
|
-
}); // , behavior: 'smooth'
|
|
2409
|
-
}
|
|
2410
|
-
}
|
|
2379
|
+
function ChipsField(props) {
|
|
2380
|
+
const {
|
|
2381
|
+
classNameGroupItem,
|
|
2382
|
+
fieldProps,
|
|
2383
|
+
initialValue,
|
|
2384
|
+
inputProps,
|
|
2385
|
+
isDisabled,
|
|
2386
|
+
isRequired,
|
|
2387
|
+
name,
|
|
2388
|
+
options,
|
|
2389
|
+
showMessage,
|
|
2390
|
+
onChange
|
|
2391
|
+
} = props;
|
|
2392
|
+
const {
|
|
2393
|
+
change
|
|
2394
|
+
} = reactFinalForm.useForm();
|
|
2411
2395
|
|
|
2412
|
-
//
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2396
|
+
// Callback for value changes
|
|
2397
|
+
const onChangeSomeInput = React.useCallback((inputValue, newOptionValue) => {
|
|
2398
|
+
const updatedValues = inputValue.includes(newOptionValue) ? inputValue.filter(selectedValue => selectedValue !== newOptionValue) : [...inputValue, newOptionValue];
|
|
2399
|
+
change(name, updatedValues);
|
|
2400
|
+
onChange && onChange(updatedValues);
|
|
2401
|
+
}, [change, name, onChange]);
|
|
2402
|
+
React.useEffect(() => {
|
|
2403
|
+
initialValue && change(name, initialValue);
|
|
2404
|
+
// update the form value only when the initialValue changes, so use disable eslint to ignore the warning
|
|
2405
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2406
|
+
}, [initialValue]);
|
|
2407
|
+
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
2408
|
+
initialValue: initialValue,
|
|
2409
|
+
name: name
|
|
2410
|
+
}, function Render({
|
|
2411
|
+
input,
|
|
2412
|
+
meta
|
|
2413
|
+
}) {
|
|
2414
|
+
const {
|
|
2415
|
+
isErrorState,
|
|
2416
|
+
isValidState,
|
|
2417
|
+
errorKey,
|
|
2418
|
+
errorMessage
|
|
2419
|
+
} = useFieldValidationState({
|
|
2420
|
+
fieldProps: fieldProps,
|
|
2421
|
+
input: input,
|
|
2422
|
+
meta: meta
|
|
2417
2423
|
});
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
const focusOnErrorDecorator = createDecorator__default.default(null, focusOnError);
|
|
2422
|
-
const setErrorsMutator = (args, state) => {
|
|
2423
|
-
const [fieldName, data] = args;
|
|
2424
|
-
const submitError = data.submitError;
|
|
2425
|
-
const fieldError = data.error;
|
|
2426
|
-
if (fieldName === 'non_field_errors') {
|
|
2427
|
-
// state.formState.invalid = true
|
|
2428
|
-
// state.formState.valid = false
|
|
2429
|
-
state.formState.error = fieldError;
|
|
2430
|
-
state.formState.submitError = submitError;
|
|
2431
|
-
} else if (fieldName in state.fields) {
|
|
2432
|
-
if (fieldError) {
|
|
2433
|
-
const errorsState = Object.assign({}, state.formState.errors, {
|
|
2434
|
-
[fieldName]: fieldError
|
|
2435
|
-
});
|
|
2436
|
-
state.fields[fieldName].touched = true;
|
|
2437
|
-
state.fields[fieldName].error = fieldError;
|
|
2438
|
-
state.formState.errors = errorsState;
|
|
2439
|
-
}
|
|
2440
|
-
if (submitError) {
|
|
2441
|
-
const submitErrorsState = Object.assign({}, state.formState.submitErrors, {
|
|
2442
|
-
[fieldName]: submitError
|
|
2443
|
-
});
|
|
2444
|
-
|
|
2445
|
-
// state.fields[fieldName].submitFailed = true
|
|
2446
|
-
// state.fields[fieldName].submitSucceeded = false
|
|
2447
|
-
state.fields[fieldName].submitError = submitError;
|
|
2448
|
-
state.formState.submitErrors = submitErrorsState;
|
|
2449
|
-
state.formState.submitFailed = true;
|
|
2450
|
-
state.formState.submitSucceeded = false;
|
|
2451
|
-
state.formState.lastSubmittedValues = state.formState.values;
|
|
2452
|
-
}
|
|
2453
|
-
}
|
|
2454
|
-
};
|
|
2455
|
-
const sendFormDataToServer = async (url, data) => {
|
|
2456
|
-
try {
|
|
2457
|
-
const response = await axios__default.default({
|
|
2458
|
-
url: url,
|
|
2459
|
-
method: 'POST',
|
|
2460
|
-
data: data
|
|
2424
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
2425
|
+
validationStateKey: isErrorState ? errorKey : 'success',
|
|
2426
|
+
inputProps: inputProps
|
|
2461
2427
|
});
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2428
|
+
const activeOptionsList = React.useMemo(() => {
|
|
2429
|
+
const emptyOptionsList = [{
|
|
2430
|
+
value: null,
|
|
2431
|
+
label: null
|
|
2432
|
+
}];
|
|
2433
|
+
if (input?.value) {
|
|
2434
|
+
const currentOptions = options.filter(option => input.value?.includes(option.value));
|
|
2435
|
+
return currentOptions || emptyOptionsList;
|
|
2436
|
+
}
|
|
2437
|
+
return emptyOptionsList;
|
|
2438
|
+
}, [input.value]);
|
|
2439
|
+
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
2440
|
+
className: clsx__default.default('form-field_type_chips', 'form__item_type_chips', classNameGroupItem),
|
|
2441
|
+
errorKey: errorKey,
|
|
2442
|
+
errorMessage: errorMessage,
|
|
2443
|
+
fieldClassName: 'form-chips',
|
|
2444
|
+
inputName: input.name,
|
|
2445
|
+
inputValue: input.value,
|
|
2446
|
+
isDisabled: isDisabled,
|
|
2447
|
+
isErrorState: isErrorState,
|
|
2448
|
+
isRequired: isRequired,
|
|
2449
|
+
isValidState: isValidState,
|
|
2450
|
+
metaActive: meta.active,
|
|
2451
|
+
metaError: meta.error,
|
|
2452
|
+
showMessage: showMessage
|
|
2453
|
+
}, fieldProps), options.map(option => /*#__PURE__*/React__default.default.createElement(Chips.Chips, Object.assign({
|
|
2454
|
+
isActive: activeOptionsList.includes(option),
|
|
2455
|
+
className: clsx__default.default(meta.active && 'form-chips_state_focus', meta.error && meta.touched && `form-chips_state_${errorKey}`),
|
|
2456
|
+
key: option.value,
|
|
2457
|
+
label: option.label,
|
|
2458
|
+
value: option.value,
|
|
2459
|
+
onClick: () => onChangeSomeInput(input.value, option.value)
|
|
2460
|
+
}, updatedInputProps))));
|
|
2461
|
+
});
|
|
2462
|
+
}
|
|
2463
|
+
ChipsField.propTypes = {
|
|
2464
|
+
classNameGroupItem: PropTypes__default.default.string,
|
|
2465
|
+
fieldProps: PropTypes__default.default.object,
|
|
2466
|
+
initialValue: PropTypes__default.default.array,
|
|
2467
|
+
input: PropTypes__default.default.object,
|
|
2468
|
+
inputProps: PropTypes__default.default.object,
|
|
2469
|
+
isDisabled: PropTypes__default.default.bool,
|
|
2470
|
+
isRequired: PropTypes__default.default.bool,
|
|
2471
|
+
name: PropTypes__default.default.string,
|
|
2472
|
+
options: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
|
|
2473
|
+
value: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.number, PropTypes__default.default.bool]),
|
|
2474
|
+
label: PropTypes__default.default.string
|
|
2475
|
+
})),
|
|
2476
|
+
showMessage: PropTypes__default.default.bool,
|
|
2477
|
+
onChange: PropTypes__default.default.func
|
|
2482
2478
|
};
|
|
2483
2479
|
|
|
2484
2480
|
const formTypes = {
|
|
2485
2481
|
checkbox: 'checkbox',
|
|
2486
2482
|
custom: 'custom',
|
|
2487
2483
|
choice: 'choice',
|
|
2484
|
+
chips: 'chips',
|
|
2488
2485
|
code: 'code',
|
|
2489
2486
|
datePicker: 'datePicker',
|
|
2490
2487
|
dateRangePicker: 'dateRangePicker',
|
|
@@ -2512,6 +2509,12 @@ function generateField(field, config, props) {
|
|
|
2512
2509
|
key: config.key
|
|
2513
2510
|
}, field, props));
|
|
2514
2511
|
}
|
|
2512
|
+
case formTypes.chips:
|
|
2513
|
+
{
|
|
2514
|
+
return /*#__PURE__*/React__default.default.createElement(ChipsField, Object.assign({
|
|
2515
|
+
key: config.key
|
|
2516
|
+
}, field, props));
|
|
2517
|
+
}
|
|
2515
2518
|
case formTypes.code:
|
|
2516
2519
|
{
|
|
2517
2520
|
return /*#__PURE__*/React__default.default.createElement(CodeField, Object.assign({
|
|
@@ -2596,8 +2599,119 @@ function generateField(field, config, props) {
|
|
|
2596
2599
|
}
|
|
2597
2600
|
}
|
|
2598
2601
|
|
|
2602
|
+
const focusOnError = (formElementsList, errors) => {
|
|
2603
|
+
const selectsIds = Object.keys(errors).map(fieldName => {
|
|
2604
|
+
if (fieldName === finalForm.FORM_ERROR) {
|
|
2605
|
+
// TODO: get from somewhere
|
|
2606
|
+
return 'notification__item_status_error';
|
|
2607
|
+
}
|
|
2608
|
+
return `react-select-id_${fieldName}-input`;
|
|
2609
|
+
});
|
|
2610
|
+
const errorFieldElement = formElementsList.find(element => {
|
|
2611
|
+
if (element.name) {
|
|
2612
|
+
return finalForm.getIn(errors, element.name);
|
|
2613
|
+
} else {
|
|
2614
|
+
return selectsIds.includes(element.id);
|
|
2615
|
+
}
|
|
2616
|
+
});
|
|
2617
|
+
const errorsList = Object.keys(errors);
|
|
2618
|
+
if (!errorFieldElement && errorsList.length) {
|
|
2619
|
+
let errorElement;
|
|
2620
|
+
try {
|
|
2621
|
+
const fieldName = errorsList[0];
|
|
2622
|
+
if (fieldName === finalForm.FORM_ERROR) {
|
|
2623
|
+
errorElement = document.querySelector('notification__item_status_error');
|
|
2624
|
+
} else {
|
|
2625
|
+
errorElement = document.querySelector(`#${fieldName}-error`);
|
|
2626
|
+
if (!errorElement) {
|
|
2627
|
+
errorElement = document.querySelector(`#id_${fieldName}`);
|
|
2628
|
+
}
|
|
2629
|
+
}
|
|
2630
|
+
} catch (err) {
|
|
2631
|
+
console.warn(err);
|
|
2632
|
+
}
|
|
2633
|
+
if (errorElement) {
|
|
2634
|
+
errorElement.scrollIntoView({
|
|
2635
|
+
block: 'center'
|
|
2636
|
+
}); // , behavior: 'smooth'
|
|
2637
|
+
}
|
|
2638
|
+
}
|
|
2639
|
+
|
|
2640
|
+
// The field is covered by the header because header is "sticky",
|
|
2641
|
+
// that's we scroll manually so that the field falls into the center of the visible area
|
|
2642
|
+
if (errorFieldElement) {
|
|
2643
|
+
errorFieldElement.scrollIntoView({
|
|
2644
|
+
block: 'center'
|
|
2645
|
+
});
|
|
2646
|
+
}
|
|
2647
|
+
return null;
|
|
2648
|
+
};
|
|
2649
|
+
const focusOnErrorDecorator = createDecorator__default.default(null, focusOnError);
|
|
2650
|
+
const setErrorsMutator = (args, state) => {
|
|
2651
|
+
const [fieldName, data] = args;
|
|
2652
|
+
const submitError = data.submitError;
|
|
2653
|
+
const fieldError = data.error;
|
|
2654
|
+
if (fieldName === 'non_field_errors') {
|
|
2655
|
+
// state.formState.invalid = true
|
|
2656
|
+
// state.formState.valid = false
|
|
2657
|
+
state.formState.error = fieldError;
|
|
2658
|
+
state.formState.submitError = submitError;
|
|
2659
|
+
} else if (fieldName in state.fields) {
|
|
2660
|
+
if (fieldError) {
|
|
2661
|
+
const errorsState = Object.assign({}, state.formState.errors, {
|
|
2662
|
+
[fieldName]: fieldError
|
|
2663
|
+
});
|
|
2664
|
+
state.fields[fieldName].touched = true;
|
|
2665
|
+
state.fields[fieldName].error = fieldError;
|
|
2666
|
+
state.formState.errors = errorsState;
|
|
2667
|
+
}
|
|
2668
|
+
if (submitError) {
|
|
2669
|
+
const submitErrorsState = Object.assign({}, state.formState.submitErrors, {
|
|
2670
|
+
[fieldName]: submitError
|
|
2671
|
+
});
|
|
2672
|
+
|
|
2673
|
+
// state.fields[fieldName].submitFailed = true
|
|
2674
|
+
// state.fields[fieldName].submitSucceeded = false
|
|
2675
|
+
state.fields[fieldName].submitError = submitError;
|
|
2676
|
+
state.formState.submitErrors = submitErrorsState;
|
|
2677
|
+
state.formState.submitFailed = true;
|
|
2678
|
+
state.formState.submitSucceeded = false;
|
|
2679
|
+
state.formState.lastSubmittedValues = state.formState.values;
|
|
2680
|
+
}
|
|
2681
|
+
}
|
|
2682
|
+
};
|
|
2683
|
+
const sendFormDataToServer = async (url, data) => {
|
|
2684
|
+
try {
|
|
2685
|
+
const response = await axios__default.default({
|
|
2686
|
+
url: url,
|
|
2687
|
+
method: 'POST',
|
|
2688
|
+
data: data
|
|
2689
|
+
});
|
|
2690
|
+
return {
|
|
2691
|
+
success: true,
|
|
2692
|
+
response
|
|
2693
|
+
};
|
|
2694
|
+
} catch (error) {
|
|
2695
|
+
const formErrors = {};
|
|
2696
|
+
if (typeof error.response?.data === 'string') {
|
|
2697
|
+
formErrors[finalForm.FORM_ERROR] = 'Something went wrong';
|
|
2698
|
+
}
|
|
2699
|
+
if (typeof error.response?.data === 'object') {
|
|
2700
|
+
Object.entries(error.response.data).forEach(([fieldName, errorsList]) => {
|
|
2701
|
+
formErrors[fieldName] = errorsList[0];
|
|
2702
|
+
});
|
|
2703
|
+
}
|
|
2704
|
+
return {
|
|
2705
|
+
success: false,
|
|
2706
|
+
formErrors,
|
|
2707
|
+
error
|
|
2708
|
+
};
|
|
2709
|
+
}
|
|
2710
|
+
};
|
|
2711
|
+
|
|
2599
2712
|
const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalForm(props, ref) {
|
|
2600
2713
|
const {
|
|
2714
|
+
isLoading,
|
|
2601
2715
|
additionalProps,
|
|
2602
2716
|
after,
|
|
2603
2717
|
before,
|
|
@@ -2608,13 +2722,13 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
|
|
|
2608
2722
|
buttonPadding,
|
|
2609
2723
|
className,
|
|
2610
2724
|
config,
|
|
2611
|
-
dataTour,
|
|
2612
2725
|
dataTestId,
|
|
2613
|
-
dataTourButtons,
|
|
2614
2726
|
dataTestIdButtons,
|
|
2615
2727
|
dataTestIdPrimaryButton,
|
|
2616
2728
|
dataTestIdSecondaryButton,
|
|
2617
2729
|
dataTestIdTertiaryButton,
|
|
2730
|
+
dataTour,
|
|
2731
|
+
dataTourButtons,
|
|
2618
2732
|
dataTourPrimaryButton,
|
|
2619
2733
|
dataTourSecondaryButton,
|
|
2620
2734
|
dataTourTertiaryButton,
|
|
@@ -2628,7 +2742,6 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
|
|
|
2628
2742
|
groupGap,
|
|
2629
2743
|
initialValues,
|
|
2630
2744
|
initialValuesEqual,
|
|
2631
|
-
isLoading,
|
|
2632
2745
|
language,
|
|
2633
2746
|
loader,
|
|
2634
2747
|
loaderFill,
|
|
@@ -2638,10 +2751,6 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
|
|
|
2638
2751
|
mutators,
|
|
2639
2752
|
notificationCloseButton,
|
|
2640
2753
|
notificationType,
|
|
2641
|
-
onChangeFormValues,
|
|
2642
|
-
onClickSecondaryButton,
|
|
2643
|
-
onClickTertiaryButton,
|
|
2644
|
-
onSubmit,
|
|
2645
2754
|
primaryButton,
|
|
2646
2755
|
primaryButtonFill,
|
|
2647
2756
|
primaryButtonFillHover,
|
|
@@ -2650,6 +2759,7 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
|
|
|
2650
2759
|
primaryButtonLabelTextColor,
|
|
2651
2760
|
primaryButtonLabelTextWeight,
|
|
2652
2761
|
primaryButtonSize,
|
|
2762
|
+
renderFieldsWrapper = wrapperChildren => wrapperChildren,
|
|
2653
2763
|
secondaryButton,
|
|
2654
2764
|
secondaryButtonFill,
|
|
2655
2765
|
secondaryButtonFillHover,
|
|
@@ -2672,7 +2782,11 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
|
|
|
2672
2782
|
titleTextSize,
|
|
2673
2783
|
titleTextWeight,
|
|
2674
2784
|
type,
|
|
2675
|
-
validationSchema
|
|
2785
|
+
validationSchema,
|
|
2786
|
+
onChangeFormValues,
|
|
2787
|
+
onClickSecondaryButton,
|
|
2788
|
+
onClickTertiaryButton,
|
|
2789
|
+
onSubmit
|
|
2676
2790
|
} = props;
|
|
2677
2791
|
const validate = useYupValidationSchema(validationSchema, language);
|
|
2678
2792
|
const onRefFormInstance = React.useCallback(formInstance => {
|
|
@@ -2704,26 +2818,27 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
|
|
|
2704
2818
|
initialValues: initialValues,
|
|
2705
2819
|
initialValuesEqual: initialValuesEqual,
|
|
2706
2820
|
mutators: mutators,
|
|
2821
|
+
validate: validate,
|
|
2707
2822
|
render: ({
|
|
2823
|
+
form,
|
|
2708
2824
|
handleSubmit,
|
|
2709
|
-
submitError,
|
|
2710
2825
|
modifiedSinceLastSubmit,
|
|
2711
|
-
|
|
2826
|
+
submitError
|
|
2712
2827
|
}) => {
|
|
2713
2828
|
return /*#__PURE__*/React__default.default.createElement("form", {
|
|
2714
|
-
|
|
2715
|
-
className: clsx__default.default(className, 'form', set && `form_set_${set}`, type && `form_type_${type}`, directionClass, fillClass, shapeClass, elevationClass),
|
|
2716
|
-
name: formName,
|
|
2717
|
-
"data-tour": dataTour,
|
|
2718
|
-
"data-test-id": dataTestId
|
|
2829
|
+
className: clsx__default.default(className, 'form', set && `form_set_${set}`, type && `form_type_${type}`, directionClass, fillClass, shapeClass, elevationClass)
|
|
2719
2830
|
// We no need set reference to html element, we need reference to "final-form" instance
|
|
2720
2831
|
,
|
|
2721
2832
|
ref: () => onRefFormInstance(form),
|
|
2722
|
-
|
|
2833
|
+
name: formName,
|
|
2834
|
+
autoCapitalize: disableFieldsAutoComplete ? 'off' : undefined,
|
|
2723
2835
|
autoComplete: disableFieldsAutoComplete ? 'off' : undefined,
|
|
2724
2836
|
autoCorrect: disableFieldsAutoComplete ? 'off' : undefined,
|
|
2725
|
-
|
|
2726
|
-
|
|
2837
|
+
"data-test-id": dataTestId,
|
|
2838
|
+
"data-tour": dataTour,
|
|
2839
|
+
spellCheck: disableFieldsAutoComplete ? 'false' : undefined,
|
|
2840
|
+
style: formStyles,
|
|
2841
|
+
onSubmit: handleSubmit
|
|
2727
2842
|
}, before, title && /*#__PURE__*/React__default.default.createElement(Title.Title, {
|
|
2728
2843
|
className: "form__title",
|
|
2729
2844
|
size: titleTextSize,
|
|
@@ -2738,88 +2853,88 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
|
|
|
2738
2853
|
className: clsx__default.default('notification', 'form-notification', notificationType ? `form-notification_type_${notificationType}` : 'form-notification_type_global')
|
|
2739
2854
|
}, /*#__PURE__*/React__default.default.createElement(Notification.NotificationItem, {
|
|
2740
2855
|
className: "form-notification__item",
|
|
2741
|
-
titleTextSize: "h6",
|
|
2742
2856
|
closeButton: notificationCloseButton,
|
|
2857
|
+
status: "error",
|
|
2743
2858
|
title: form.getState().submitError,
|
|
2744
|
-
|
|
2745
|
-
|
|
2859
|
+
titleTextSize: "h6",
|
|
2860
|
+
set: "form"
|
|
2746
2861
|
})), onChangeFormValues && /*#__PURE__*/React__default.default.createElement(reactFinalForm.FormSpy, {
|
|
2747
2862
|
subscription: {
|
|
2748
2863
|
values: true
|
|
2749
2864
|
},
|
|
2750
2865
|
onChange: onChangeFormValues
|
|
2751
|
-
}), Boolean(Object.keys(config).length) && /*#__PURE__*/React__default.default.createElement(Group$1.Group, {
|
|
2866
|
+
}), Boolean(Object.keys(config).length) && /*#__PURE__*/React__default.default.createElement(React__default.default.Fragment, null, renderFieldsWrapper( /*#__PURE__*/React__default.default.createElement(Group$1.Group, {
|
|
2867
|
+
className: "form__wrapper",
|
|
2752
2868
|
direction: "vertical",
|
|
2753
|
-
gap: fieldsGap || groupGap
|
|
2754
|
-
className: "form__wrapper"
|
|
2869
|
+
gap: fieldsGap || groupGap
|
|
2755
2870
|
}, Object.keys(config).map(key => generateField(config[key], {
|
|
2756
2871
|
key
|
|
2757
2872
|
}, additionalProps[config[key].name])), isLoading && (loader || /*#__PURE__*/React__default.default.createElement(Loader.Loader, {
|
|
2758
2873
|
className: "form__loader",
|
|
2759
|
-
set: loaderSet,
|
|
2760
2874
|
fill: loaderFill,
|
|
2761
2875
|
itemFill: loaderItemFill,
|
|
2762
|
-
text: loaderText
|
|
2763
|
-
|
|
2876
|
+
text: loaderText,
|
|
2877
|
+
set: loaderSet
|
|
2878
|
+
}))))), (primaryButtonLabel || primaryButton || secondaryButtonLabel || secondaryButton || tertiaryButton || tertiaryButtonLabel) && /*#__PURE__*/React__default.default.createElement(Group$1.Group, {
|
|
2879
|
+
className: "form__button",
|
|
2764
2880
|
fill: buttonFill,
|
|
2765
|
-
justifyContent: buttonJustifyContent,
|
|
2766
|
-
direction: buttonDirection,
|
|
2767
2881
|
padding: buttonPadding,
|
|
2768
|
-
|
|
2769
|
-
className: "form__button",
|
|
2882
|
+
dataTestId: dataTestIdButtons,
|
|
2770
2883
|
dataTour: dataTourButtons,
|
|
2771
|
-
|
|
2884
|
+
direction: buttonDirection,
|
|
2885
|
+
gap: buttonGap,
|
|
2886
|
+
justifyContent: buttonJustifyContent
|
|
2772
2887
|
}, primaryButtonLabel ? /*#__PURE__*/React__default.default.createElement(Button.Button, {
|
|
2773
|
-
width: "fill",
|
|
2774
2888
|
className: "form__button-item",
|
|
2889
|
+
width: "fill",
|
|
2890
|
+
labelTextColor: primaryButtonLabelTextColor,
|
|
2891
|
+
labelTextSize: primaryButtonLabelSize,
|
|
2775
2892
|
fill: primaryButtonFill,
|
|
2776
2893
|
fillHover: primaryButtonFillHover,
|
|
2777
|
-
|
|
2778
|
-
labelTextColor: primaryButtonLabelTextColor,
|
|
2779
|
-
labelSize: primaryButtonLabelSize,
|
|
2780
|
-
labelTextWeight: primaryButtonLabelTextWeight,
|
|
2781
|
-
label: primaryButtonLabel,
|
|
2894
|
+
dataTestId: dataTestIdPrimaryButton,
|
|
2782
2895
|
dataTour: dataTourPrimaryButton,
|
|
2783
|
-
|
|
2896
|
+
label: primaryButtonLabel,
|
|
2897
|
+
labelTextWeight: primaryButtonLabelTextWeight,
|
|
2898
|
+
size: primaryButtonSize
|
|
2784
2899
|
}) : primaryButton, secondaryButtonLabel ? /*#__PURE__*/React__default.default.createElement(Button.Button, {
|
|
2785
|
-
width: "fill",
|
|
2786
2900
|
className: "form__button-item",
|
|
2901
|
+
width: "fill",
|
|
2902
|
+
labelTextColor: secondaryButtonLabelTextColor,
|
|
2903
|
+
labelTextSize: secondaryButtonLabelSize,
|
|
2787
2904
|
fill: secondaryButtonFill,
|
|
2788
2905
|
fillHover: secondaryButtonFillHover,
|
|
2789
|
-
|
|
2790
|
-
labelTextColor: secondaryButtonLabelTextColor,
|
|
2791
|
-
labelSize: secondaryButtonLabelSize,
|
|
2792
|
-
labelTextWeight: secondaryButtonLabelTextWeight,
|
|
2793
|
-
label: secondaryButtonLabel,
|
|
2794
|
-
onClick: onClickSecondaryButton,
|
|
2906
|
+
dataTestId: dataTestIdSecondaryButton,
|
|
2795
2907
|
dataTour: dataTourSecondaryButton,
|
|
2796
|
-
|
|
2908
|
+
label: secondaryButtonLabel,
|
|
2909
|
+
labelTextWeight: secondaryButtonLabelTextWeight,
|
|
2910
|
+
size: secondaryButtonSize,
|
|
2911
|
+
onClick: onClickSecondaryButton
|
|
2797
2912
|
}) : secondaryButton, tertiaryButtonLabel ? /*#__PURE__*/React__default.default.createElement(Button.Button, {
|
|
2798
|
-
width: "fill",
|
|
2799
2913
|
className: "form__button-item",
|
|
2914
|
+
width: "fill",
|
|
2915
|
+
labelTextColor: tertiaryButtonLabelTextColor,
|
|
2916
|
+
labelTextSize: tertiaryButtonLabelSize,
|
|
2800
2917
|
fill: tertiaryButtonFill,
|
|
2801
2918
|
fillHover: tertiaryButtonFillHover,
|
|
2802
|
-
|
|
2803
|
-
labelTextColor: tertiaryButtonLabelTextColor,
|
|
2804
|
-
labelSize: tertiaryButtonLabelSize,
|
|
2805
|
-
labelTextWeight: tertiaryButtonLabelTextWeight,
|
|
2806
|
-
label: tertiaryButtonLabel,
|
|
2807
|
-
onClick: onClickTertiaryButton,
|
|
2919
|
+
dataTestId: dataTestIdTertiaryButton,
|
|
2808
2920
|
dataTour: dataTourTertiaryButton,
|
|
2809
|
-
|
|
2921
|
+
label: tertiaryButtonLabel,
|
|
2922
|
+
labelTextWeight: tertiaryButtonLabelTextWeight,
|
|
2923
|
+
size: tertiaryButtonSize,
|
|
2924
|
+
onClick: onClickTertiaryButton
|
|
2810
2925
|
}) : tertiaryButton), after);
|
|
2811
2926
|
},
|
|
2812
2927
|
subscription: {
|
|
2813
|
-
submitting: true,
|
|
2814
|
-
pristine: true,
|
|
2815
2928
|
modifiedSinceLastSubmit: true,
|
|
2816
|
-
|
|
2929
|
+
pristine: true,
|
|
2930
|
+
submitError: true,
|
|
2931
|
+
submitting: true
|
|
2817
2932
|
},
|
|
2818
|
-
validate: validate,
|
|
2819
2933
|
onSubmit: onSubmit
|
|
2820
2934
|
});
|
|
2821
2935
|
});
|
|
2822
2936
|
FinalForm.propTypes = {
|
|
2937
|
+
isLoading: PropTypes__default.default.bool,
|
|
2823
2938
|
additionalProps: PropTypes__default.default.object,
|
|
2824
2939
|
after: PropTypes__default.default.any,
|
|
2825
2940
|
before: PropTypes__default.default.any,
|
|
@@ -2845,7 +2960,6 @@ FinalForm.propTypes = {
|
|
|
2845
2960
|
groupGap: PropTypes__default.default.string,
|
|
2846
2961
|
initialValues: PropTypes__default.default.any,
|
|
2847
2962
|
initialValuesEqual: PropTypes__default.default.any,
|
|
2848
|
-
isLoading: PropTypes__default.default.bool,
|
|
2849
2963
|
language: PropTypes__default.default.string,
|
|
2850
2964
|
loader: PropTypes__default.default.element,
|
|
2851
2965
|
loaderFill: PropTypes__default.default.string,
|
|
@@ -2893,16 +3007,16 @@ FinalForm.propTypes = {
|
|
|
2893
3007
|
onSubmit: PropTypes__default.default.func
|
|
2894
3008
|
};
|
|
2895
3009
|
FinalForm.defaultProps = {
|
|
2896
|
-
|
|
3010
|
+
direction: 'vertical',
|
|
2897
3011
|
isLoading: false,
|
|
2898
|
-
|
|
3012
|
+
additionalProps: {},
|
|
3013
|
+
buttonDirection: 'vertical',
|
|
3014
|
+
disableFieldsAutoComplete: false,
|
|
3015
|
+
language: 'en',
|
|
2899
3016
|
loaderFill: 'surfacePrimary',
|
|
2900
3017
|
loaderItemFill: 'surfaceItemAccent',
|
|
2901
|
-
|
|
2902
|
-
titleSize: 'h1'
|
|
2903
|
-
buttonDirection: 'vertical',
|
|
2904
|
-
direction: 'vertical',
|
|
2905
|
-
disableFieldsAutoComplete: false
|
|
3018
|
+
loaderSet: 'simple',
|
|
3019
|
+
titleSize: 'h1'
|
|
2906
3020
|
};
|
|
2907
3021
|
|
|
2908
3022
|
const DEFAULT_MESSAGES_FIELDS = {
|
|
@@ -3030,6 +3144,7 @@ Object.defineProperty(exports, "useFormState", {
|
|
|
3030
3144
|
get: function () { return reactFinalForm.useFormState; }
|
|
3031
3145
|
});
|
|
3032
3146
|
exports.Checkbox = CheckboxField;
|
|
3147
|
+
exports.ChipsField = ChipsField;
|
|
3033
3148
|
exports.ChoiceField = ChoiceField;
|
|
3034
3149
|
exports.CodeField = CodeField;
|
|
3035
3150
|
exports.CustomField = CustomField;
|