@itcase/forms 1.0.62 → 1.0.64
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.
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
.form-chips {
|
|
2
|
+
&&_state {
|
|
3
|
+
&_success {
|
|
4
|
+
& .chips {
|
|
5
|
+
/* border: solid 1px var(--choice-success-border); */
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
&_error {
|
|
9
|
+
& .chips {
|
|
10
|
+
/* border: solid 1px var(--choice-error-border); */
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
&_focus {
|
|
14
|
+
/* border: solid 1px var(--choice-focus-border); */
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
.form-field {
|
|
19
|
+
&_type_chips {
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
:root {
|
|
23
|
+
--chips-success-border: var(--color-success-border-primary);
|
|
24
|
+
--chips-success-border-hover: var(--color-surface-border-quaternary);
|
|
25
|
+
--chips-error-border: var(--color-error-border-primary);
|
|
26
|
+
--chips-focus-border: var(--color-surface-border-quaternary);
|
|
27
|
+
}
|
|
@@ -25,6 +25,16 @@
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
.form {
|
|
29
|
+
&-field {
|
|
30
|
+
&_type_code {
|
|
31
|
+
^&__content {
|
|
32
|
+
justify-content: space-between;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
28
38
|
.form {
|
|
29
39
|
&^&-field_type_float {
|
|
30
40
|
position: relative;
|
|
@@ -101,4 +111,3 @@
|
|
|
101
111
|
}
|
|
102
112
|
}
|
|
103
113
|
}
|
|
104
|
-
|
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, {
|
|
@@ -539,7 +544,7 @@ const ChoiceField = /*#__PURE__*/React__default.default.memo(function ChoiceFiel
|
|
|
539
544
|
initialValue,
|
|
540
545
|
inputProps,
|
|
541
546
|
isDisabled,
|
|
542
|
-
|
|
547
|
+
isCheckbox,
|
|
543
548
|
isRequired,
|
|
544
549
|
label,
|
|
545
550
|
messageType,
|
|
@@ -616,8 +621,8 @@ const ChoiceField = /*#__PURE__*/React__default.default.memo(function ChoiceFiel
|
|
|
616
621
|
active: activeOption,
|
|
617
622
|
className: clsx__default.default(meta.active && 'form-choice_state_focus', meta.error && meta.touched && `form-choice_state_${errorKey}`),
|
|
618
623
|
inputValue: input.value || [],
|
|
624
|
+
isCheckbox: isCheckbox,
|
|
619
625
|
isDisabled: isDisabled,
|
|
620
|
-
isMultiple: isMultiple,
|
|
621
626
|
isRequired: isRequired,
|
|
622
627
|
name: input.name,
|
|
623
628
|
options: options,
|
|
@@ -631,12 +636,16 @@ ChoiceField.propTypes = {
|
|
|
631
636
|
fieldProps: PropTypes__default.default.object,
|
|
632
637
|
initialValue: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.number, PropTypes__default.default.bool]),
|
|
633
638
|
inputProps: PropTypes__default.default.object,
|
|
639
|
+
isCheckbox: PropTypes__default.default.bool,
|
|
634
640
|
isDisabled: PropTypes__default.default.bool,
|
|
635
|
-
isMultiple: PropTypes__default.default.bool,
|
|
636
641
|
isRequired: PropTypes__default.default.bool,
|
|
637
642
|
label: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.element]),
|
|
638
643
|
messageType: PropTypes__default.default.string,
|
|
639
644
|
name: PropTypes__default.default.string,
|
|
645
|
+
options: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
|
|
646
|
+
label: PropTypes__default.default.string,
|
|
647
|
+
value: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.number])
|
|
648
|
+
})),
|
|
640
649
|
placeholder: PropTypes__default.default.string,
|
|
641
650
|
showMessage: PropTypes__default.default.bool,
|
|
642
651
|
onChange: PropTypes__default.default.func
|
|
@@ -2367,6 +2376,107 @@ MaskedInputField.propTypes = {
|
|
|
2367
2376
|
unmasked: PropTypes__default.default.string
|
|
2368
2377
|
};
|
|
2369
2378
|
|
|
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();
|
|
2395
|
+
|
|
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
|
|
2423
|
+
});
|
|
2424
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
2425
|
+
validationStateKey: isErrorState ? errorKey : 'success',
|
|
2426
|
+
inputProps: inputProps
|
|
2427
|
+
});
|
|
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
|
|
2478
|
+
};
|
|
2479
|
+
|
|
2370
2480
|
const focusOnError = (formElementsList, errors) => {
|
|
2371
2481
|
const selectsIds = Object.keys(errors).map(fieldName => {
|
|
2372
2482
|
if (fieldName === finalForm.FORM_ERROR) {
|
|
@@ -2481,6 +2591,7 @@ const formTypes = {
|
|
|
2481
2591
|
checkbox: 'checkbox',
|
|
2482
2592
|
custom: 'custom',
|
|
2483
2593
|
choice: 'choice',
|
|
2594
|
+
chips: 'chips',
|
|
2484
2595
|
code: 'code',
|
|
2485
2596
|
datePicker: 'datePicker',
|
|
2486
2597
|
dateRangePicker: 'dateRangePicker',
|
|
@@ -2508,6 +2619,12 @@ function generateField(field, config, props) {
|
|
|
2508
2619
|
key: config.key
|
|
2509
2620
|
}, field, props));
|
|
2510
2621
|
}
|
|
2622
|
+
case formTypes.chips:
|
|
2623
|
+
{
|
|
2624
|
+
return /*#__PURE__*/React__default.default.createElement(ChipsField, Object.assign({
|
|
2625
|
+
key: config.key
|
|
2626
|
+
}, field, props));
|
|
2627
|
+
}
|
|
2511
2628
|
case formTypes.code:
|
|
2512
2629
|
{
|
|
2513
2630
|
return /*#__PURE__*/React__default.default.createElement(CodeField, Object.assign({
|
|
@@ -3026,6 +3143,7 @@ Object.defineProperty(exports, "useFormState", {
|
|
|
3026
3143
|
get: function () { return reactFinalForm.useFormState; }
|
|
3027
3144
|
});
|
|
3028
3145
|
exports.Checkbox = CheckboxField;
|
|
3146
|
+
exports.ChipsField = ChipsField;
|
|
3029
3147
|
exports.ChoiceField = ChoiceField;
|
|
3030
3148
|
exports.CodeField = CodeField;
|
|
3031
3149
|
exports.CustomField = CustomField;
|
package/dist/itcase-forms.esm.js
CHANGED
|
@@ -32,6 +32,7 @@ import { Select } from '@itcase/ui/components/Select';
|
|
|
32
32
|
import { Switch } from '@itcase/ui/components/Switch';
|
|
33
33
|
import { Textarea } from '@itcase/ui/components/Textarea';
|
|
34
34
|
import { useIMask } from 'react-imask';
|
|
35
|
+
import { Chips } from '@itcase/ui/components/Chips';
|
|
35
36
|
import { Button } from '@itcase/ui/components/Button';
|
|
36
37
|
import { Group as Group$1 } from '@itcase/ui/components/Group';
|
|
37
38
|
import { NotificationItem } from '@itcase/ui/components/Notification';
|
|
@@ -140,9 +141,11 @@ function FieldWrapperBase(props) {
|
|
|
140
141
|
labelHidden,
|
|
141
142
|
labelTextColor,
|
|
142
143
|
labelTextSize,
|
|
144
|
+
labelTextSizeMobile,
|
|
143
145
|
labelTextWeight,
|
|
144
146
|
helpText,
|
|
145
147
|
helpTextSize,
|
|
148
|
+
helpTextSizeMobile,
|
|
146
149
|
helpTextWeight,
|
|
147
150
|
helpTextColor,
|
|
148
151
|
isErrorState,
|
|
@@ -209,6 +212,7 @@ function FieldWrapperBase(props) {
|
|
|
209
212
|
htmlFor: id
|
|
210
213
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
211
214
|
size: labelTextSize,
|
|
215
|
+
sizeMobile: labelTextSizeMobile,
|
|
212
216
|
textColor: labelTextColor,
|
|
213
217
|
textWeight: labelTextWeight
|
|
214
218
|
}, label, labelHidden && '\u00A0')), desc && /*#__PURE__*/React.createElement("div", {
|
|
@@ -242,6 +246,7 @@ function FieldWrapperBase(props) {
|
|
|
242
246
|
className: "form-field__message-item form-field__message-item_type_help-text",
|
|
243
247
|
dataTestId: `${inputName}FieldMessageHelpText`,
|
|
244
248
|
size: helpTextSize,
|
|
249
|
+
sizeMobile: helpTextSizeMobile,
|
|
245
250
|
textColor: helpTextColor,
|
|
246
251
|
textWeight: helpTextWeight
|
|
247
252
|
}, helpText), (!isErrorState && !helpText || isErrorState && !helpText && !errorMessage) && /*#__PURE__*/React.createElement(Text, {
|
|
@@ -525,7 +530,7 @@ const ChoiceField = /*#__PURE__*/React.memo(function ChoiceField(props) {
|
|
|
525
530
|
initialValue,
|
|
526
531
|
inputProps,
|
|
527
532
|
isDisabled,
|
|
528
|
-
|
|
533
|
+
isCheckbox,
|
|
529
534
|
isRequired,
|
|
530
535
|
label,
|
|
531
536
|
messageType,
|
|
@@ -602,8 +607,8 @@ const ChoiceField = /*#__PURE__*/React.memo(function ChoiceField(props) {
|
|
|
602
607
|
active: activeOption,
|
|
603
608
|
className: clsx(meta.active && 'form-choice_state_focus', meta.error && meta.touched && `form-choice_state_${errorKey}`),
|
|
604
609
|
inputValue: input.value || [],
|
|
610
|
+
isCheckbox: isCheckbox,
|
|
605
611
|
isDisabled: isDisabled,
|
|
606
|
-
isMultiple: isMultiple,
|
|
607
612
|
isRequired: isRequired,
|
|
608
613
|
name: input.name,
|
|
609
614
|
options: options,
|
|
@@ -617,12 +622,16 @@ ChoiceField.propTypes = {
|
|
|
617
622
|
fieldProps: PropTypes.object,
|
|
618
623
|
initialValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]),
|
|
619
624
|
inputProps: PropTypes.object,
|
|
625
|
+
isCheckbox: PropTypes.bool,
|
|
620
626
|
isDisabled: PropTypes.bool,
|
|
621
|
-
isMultiple: PropTypes.bool,
|
|
622
627
|
isRequired: PropTypes.bool,
|
|
623
628
|
label: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
624
629
|
messageType: PropTypes.string,
|
|
625
630
|
name: PropTypes.string,
|
|
631
|
+
options: PropTypes.arrayOf(PropTypes.shape({
|
|
632
|
+
label: PropTypes.string,
|
|
633
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
634
|
+
})),
|
|
626
635
|
placeholder: PropTypes.string,
|
|
627
636
|
showMessage: PropTypes.bool,
|
|
628
637
|
onChange: PropTypes.func
|
|
@@ -2353,6 +2362,107 @@ MaskedInputField.propTypes = {
|
|
|
2353
2362
|
unmasked: PropTypes.string
|
|
2354
2363
|
};
|
|
2355
2364
|
|
|
2365
|
+
function ChipsField(props) {
|
|
2366
|
+
const {
|
|
2367
|
+
classNameGroupItem,
|
|
2368
|
+
fieldProps,
|
|
2369
|
+
initialValue,
|
|
2370
|
+
inputProps,
|
|
2371
|
+
isDisabled,
|
|
2372
|
+
isRequired,
|
|
2373
|
+
name,
|
|
2374
|
+
options,
|
|
2375
|
+
showMessage,
|
|
2376
|
+
onChange
|
|
2377
|
+
} = props;
|
|
2378
|
+
const {
|
|
2379
|
+
change
|
|
2380
|
+
} = useForm();
|
|
2381
|
+
|
|
2382
|
+
// Callback for value changes
|
|
2383
|
+
const onChangeSomeInput = useCallback((inputValue, newOptionValue) => {
|
|
2384
|
+
const updatedValues = inputValue.includes(newOptionValue) ? inputValue.filter(selectedValue => selectedValue !== newOptionValue) : [...inputValue, newOptionValue];
|
|
2385
|
+
change(name, updatedValues);
|
|
2386
|
+
onChange && onChange(updatedValues);
|
|
2387
|
+
}, [change, name, onChange]);
|
|
2388
|
+
useEffect(() => {
|
|
2389
|
+
initialValue && change(name, initialValue);
|
|
2390
|
+
// update the form value only when the initialValue changes, so use disable eslint to ignore the warning
|
|
2391
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2392
|
+
}, [initialValue]);
|
|
2393
|
+
return /*#__PURE__*/React.createElement(Field, {
|
|
2394
|
+
initialValue: initialValue,
|
|
2395
|
+
name: name
|
|
2396
|
+
}, function Render({
|
|
2397
|
+
input,
|
|
2398
|
+
meta
|
|
2399
|
+
}) {
|
|
2400
|
+
const {
|
|
2401
|
+
isErrorState,
|
|
2402
|
+
isValidState,
|
|
2403
|
+
errorKey,
|
|
2404
|
+
errorMessage
|
|
2405
|
+
} = useFieldValidationState({
|
|
2406
|
+
fieldProps: fieldProps,
|
|
2407
|
+
input: input,
|
|
2408
|
+
meta: meta
|
|
2409
|
+
});
|
|
2410
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
2411
|
+
validationStateKey: isErrorState ? errorKey : 'success',
|
|
2412
|
+
inputProps: inputProps
|
|
2413
|
+
});
|
|
2414
|
+
const activeOptionsList = useMemo(() => {
|
|
2415
|
+
const emptyOptionsList = [{
|
|
2416
|
+
value: null,
|
|
2417
|
+
label: null
|
|
2418
|
+
}];
|
|
2419
|
+
if (input?.value) {
|
|
2420
|
+
const currentOptions = options.filter(option => input.value?.includes(option.value));
|
|
2421
|
+
return currentOptions || emptyOptionsList;
|
|
2422
|
+
}
|
|
2423
|
+
return emptyOptionsList;
|
|
2424
|
+
}, [input.value]);
|
|
2425
|
+
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
2426
|
+
className: clsx('form-field_type_chips', 'form__item_type_chips', classNameGroupItem),
|
|
2427
|
+
errorKey: errorKey,
|
|
2428
|
+
errorMessage: errorMessage,
|
|
2429
|
+
fieldClassName: 'form-chips',
|
|
2430
|
+
inputName: input.name,
|
|
2431
|
+
inputValue: input.value,
|
|
2432
|
+
isDisabled: isDisabled,
|
|
2433
|
+
isErrorState: isErrorState,
|
|
2434
|
+
isRequired: isRequired,
|
|
2435
|
+
isValidState: isValidState,
|
|
2436
|
+
metaActive: meta.active,
|
|
2437
|
+
metaError: meta.error,
|
|
2438
|
+
showMessage: showMessage
|
|
2439
|
+
}, fieldProps), options.map(option => /*#__PURE__*/React.createElement(Chips, Object.assign({
|
|
2440
|
+
isActive: activeOptionsList.includes(option),
|
|
2441
|
+
className: clsx(meta.active && 'form-chips_state_focus', meta.error && meta.touched && `form-chips_state_${errorKey}`),
|
|
2442
|
+
key: option.value,
|
|
2443
|
+
label: option.label,
|
|
2444
|
+
value: option.value,
|
|
2445
|
+
onClick: () => onChangeSomeInput(input.value, option.value)
|
|
2446
|
+
}, updatedInputProps))));
|
|
2447
|
+
});
|
|
2448
|
+
}
|
|
2449
|
+
ChipsField.propTypes = {
|
|
2450
|
+
classNameGroupItem: PropTypes.string,
|
|
2451
|
+
fieldProps: PropTypes.object,
|
|
2452
|
+
initialValue: PropTypes.array,
|
|
2453
|
+
input: PropTypes.object,
|
|
2454
|
+
inputProps: PropTypes.object,
|
|
2455
|
+
isDisabled: PropTypes.bool,
|
|
2456
|
+
isRequired: PropTypes.bool,
|
|
2457
|
+
name: PropTypes.string,
|
|
2458
|
+
options: PropTypes.arrayOf(PropTypes.shape({
|
|
2459
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]),
|
|
2460
|
+
label: PropTypes.string
|
|
2461
|
+
})),
|
|
2462
|
+
showMessage: PropTypes.bool,
|
|
2463
|
+
onChange: PropTypes.func
|
|
2464
|
+
};
|
|
2465
|
+
|
|
2356
2466
|
const focusOnError = (formElementsList, errors) => {
|
|
2357
2467
|
const selectsIds = Object.keys(errors).map(fieldName => {
|
|
2358
2468
|
if (fieldName === FORM_ERROR) {
|
|
@@ -2467,6 +2577,7 @@ const formTypes = {
|
|
|
2467
2577
|
checkbox: 'checkbox',
|
|
2468
2578
|
custom: 'custom',
|
|
2469
2579
|
choice: 'choice',
|
|
2580
|
+
chips: 'chips',
|
|
2470
2581
|
code: 'code',
|
|
2471
2582
|
datePicker: 'datePicker',
|
|
2472
2583
|
dateRangePicker: 'dateRangePicker',
|
|
@@ -2494,6 +2605,12 @@ function generateField(field, config, props) {
|
|
|
2494
2605
|
key: config.key
|
|
2495
2606
|
}, field, props));
|
|
2496
2607
|
}
|
|
2608
|
+
case formTypes.chips:
|
|
2609
|
+
{
|
|
2610
|
+
return /*#__PURE__*/React.createElement(ChipsField, Object.assign({
|
|
2611
|
+
key: config.key
|
|
2612
|
+
}, field, props));
|
|
2613
|
+
}
|
|
2497
2614
|
case formTypes.code:
|
|
2498
2615
|
{
|
|
2499
2616
|
return /*#__PURE__*/React.createElement(CodeField, Object.assign({
|
|
@@ -2999,4 +3116,4 @@ const DEFAULT_MESSAGES_FIELDS = {
|
|
|
2999
3116
|
}
|
|
3000
3117
|
};
|
|
3001
3118
|
|
|
3002
|
-
export { CheckboxField as Checkbox, ChoiceField, CodeField, CustomField, DEFAULT_MESSAGES_FIELDS, DatePickerField, FieldWrapper, FieldWrapperBase, FileInput, FinalForm, Group, InputField, MaskedInputField, RadioGroup, SegmentedField, SelectField, SwitchField as Switch, TextareaField as Textarea, addRequiredFieldsParamToSchema, emailValidation, focusOnError, focusOnErrorDecorator, formTypes, generateField, phoneValidation, sendFormDataToServer, setErrorsMutator, useYupValidationSchema };
|
|
3119
|
+
export { CheckboxField as Checkbox, ChipsField, ChoiceField, CodeField, CustomField, DEFAULT_MESSAGES_FIELDS, DatePickerField, FieldWrapper, FieldWrapperBase, FileInput, FinalForm, Group, InputField, MaskedInputField, RadioGroup, SegmentedField, SelectField, SwitchField as Switch, TextareaField as Textarea, addRequiredFieldsParamToSchema, emailValidation, focusOnError, focusOnErrorDecorator, formTypes, generateField, phoneValidation, sendFormDataToServer, setErrorsMutator, useYupValidationSchema };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itcase/forms",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.64",
|
|
4
4
|
"description": "Forms fields, inputs, etc.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,20 +30,20 @@
|
|
|
30
30
|
"registry": "https://registry.npmjs.org/"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@itcase/common": "^1.2.
|
|
34
|
-
"@itcase/ui": "^1.1.
|
|
35
|
-
"axios": "^1.7.
|
|
33
|
+
"@itcase/common": "^1.2.6",
|
|
34
|
+
"@itcase/ui": "^1.1.21",
|
|
35
|
+
"axios": "^1.7.3",
|
|
36
36
|
"clsx": "^2.1.1",
|
|
37
37
|
"final-form": "^4.20.10",
|
|
38
38
|
"final-form-focus": "^1.1.2",
|
|
39
|
-
"libphonenumber-js": "^1.11.
|
|
39
|
+
"libphonenumber-js": "^1.11.5",
|
|
40
40
|
"lodash": "^4.17.21",
|
|
41
|
-
"luxon": "^3.
|
|
42
|
-
"postcss": "^8.4.
|
|
41
|
+
"luxon": "^3.5.0",
|
|
42
|
+
"postcss": "^8.4.41",
|
|
43
43
|
"prop-types": "^15.8.1",
|
|
44
44
|
"react": "^18.3.1",
|
|
45
45
|
"react-date-range": "^2.0.1",
|
|
46
|
-
"react-datepicker": "^
|
|
46
|
+
"react-datepicker": "^7.3.0",
|
|
47
47
|
"react-dom": "^18.3.1",
|
|
48
48
|
"react-dropzone": "^14.2.3",
|
|
49
49
|
"react-final-form": "^6.5.9",
|
|
@@ -51,38 +51,44 @@
|
|
|
51
51
|
"react-select": "^5.8.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@
|
|
55
|
-
"@babel/
|
|
56
|
-
"@babel/
|
|
57
|
-
"@babel/preset-
|
|
54
|
+
"@itcase/lint": "^1.0.8",
|
|
55
|
+
"@babel/core": "^7.25.2",
|
|
56
|
+
"@babel/eslint-parser": "^7.25.1",
|
|
57
|
+
"@babel/preset-env": "^7.25.3",
|
|
58
|
+
"@babel/preset-react": "^7.24.7",
|
|
58
59
|
"@commitlint/cli": "^19.3.0",
|
|
59
60
|
"@commitlint/config-conventional": "^19.2.2",
|
|
60
|
-
"@eslint/compat": "^1.
|
|
61
|
+
"@eslint/compat": "^1.1.1",
|
|
61
62
|
"@eslint/eslintrc": "^3.1.0",
|
|
62
|
-
"@ianvs/prettier-plugin-sort-imports": "^4.
|
|
63
|
+
"@ianvs/prettier-plugin-sort-imports": "^4.3.1",
|
|
63
64
|
"@rollup/plugin-babel": "^6.0.4",
|
|
64
|
-
"@rollup/plugin-commonjs": "^
|
|
65
|
+
"@rollup/plugin-commonjs": "^26.0.1",
|
|
65
66
|
"@rollup/plugin-json": "^6.1.0",
|
|
66
67
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
67
68
|
"@rollup/plugin-terser": "^0.4.4",
|
|
69
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
68
70
|
"@semantic-release/git": "^10.0.1",
|
|
71
|
+
"@semantic-release/release-notes-generator": "14.0.1",
|
|
72
|
+
"@types/react": "^18",
|
|
73
|
+
"@types/react-dom": "^18.3.0",
|
|
69
74
|
"babel-plugin-inline-react-svg": "^2.0.2",
|
|
70
75
|
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
|
|
71
|
-
"
|
|
76
|
+
"conventional-changelog-conventionalcommits": "^8.0.0",
|
|
77
|
+
"eslint": "9.8.0",
|
|
72
78
|
"eslint-config-prettier": "9.1.0",
|
|
73
79
|
"eslint-config-standard": "17.1.0",
|
|
74
80
|
"eslint-plugin-babel": "5.3.1",
|
|
75
81
|
"eslint-plugin-import": "2.29.1",
|
|
76
|
-
"eslint-plugin-n": "17.
|
|
82
|
+
"eslint-plugin-n": "17.10.2",
|
|
77
83
|
"eslint-plugin-node": "11.1.0",
|
|
78
|
-
"eslint-plugin-prettier": "5.1
|
|
79
|
-
"eslint-plugin-promise": "
|
|
80
|
-
"eslint-plugin-react": "7.
|
|
84
|
+
"eslint-plugin-prettier": "5.2.1",
|
|
85
|
+
"eslint-plugin-promise": "7.0.0",
|
|
86
|
+
"eslint-plugin-react": "7.35.0",
|
|
81
87
|
"eslint-plugin-react-hooks": "4.6.2",
|
|
82
88
|
"eslint-plugin-standard": "5.0.0",
|
|
83
|
-
"husky": "^9.
|
|
84
|
-
"lint-staged": "^15.2.
|
|
85
|
-
"npm": "^10.8.
|
|
89
|
+
"husky": "^9.1.4",
|
|
90
|
+
"lint-staged": "^15.2.8",
|
|
91
|
+
"npm": "^10.8.2",
|
|
86
92
|
"postcss-aspect-ratio-polyfill": "^2.0.0",
|
|
87
93
|
"postcss-cli": "^11.0.0",
|
|
88
94
|
"postcss-combine-duplicated-selectors": "^10.0.3",
|
|
@@ -96,21 +102,22 @@
|
|
|
96
102
|
"postcss-import": "^16.1.0",
|
|
97
103
|
"postcss-import-ext-glob": "^2.1.1",
|
|
98
104
|
"postcss-mixins": "^10.0.1",
|
|
99
|
-
"postcss-nested": "^6.0
|
|
105
|
+
"postcss-nested": "^6.2.0",
|
|
100
106
|
"postcss-nested-ancestors": "^3.0.0",
|
|
101
107
|
"postcss-normalize": "^10.0.1",
|
|
102
108
|
"postcss-prepend-imports": "^1.0.1",
|
|
103
|
-
"postcss-preset-env": "^
|
|
109
|
+
"postcss-preset-env": "^10.0.0",
|
|
104
110
|
"postcss-pxtorem": "^6.1.0",
|
|
105
111
|
"postcss-responsive-type": "github:ITCase/postcss-responsive-type",
|
|
106
112
|
"postcss-sort-media-queries": "^5.2.0",
|
|
107
|
-
"prettier": "3.
|
|
108
|
-
"rollup": "^4.
|
|
113
|
+
"prettier": "3.3.3",
|
|
114
|
+
"rollup": "^4.20.0",
|
|
109
115
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
110
|
-
"semantic-release": "^
|
|
111
|
-
"stylelint": "^16.
|
|
112
|
-
"stylelint-config-standard": "^36.0.
|
|
116
|
+
"semantic-release": "^24.0.0",
|
|
117
|
+
"stylelint": "^16.8.1",
|
|
118
|
+
"stylelint-config-standard": "^36.0.1",
|
|
113
119
|
"stylelint-no-unsupported-browser-features": "^8.0.1",
|
|
114
|
-
"stylelint-order": "^6.0.4"
|
|
120
|
+
"stylelint-order": "^6.0.4",
|
|
121
|
+
"typescript": "^5.5.4"
|
|
115
122
|
}
|
|
116
123
|
}
|