@mtes-mct/monitor-ui 2.11.0 → 2.12.1
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/CHANGELOG.md +15 -0
- package/index.js +139 -102
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/src/fields/Checkbox.d.ts +2 -1
- package/src/fields/DatePicker/index.d.ts +1 -0
- package/src/fields/DateRangePicker/index.d.ts +1 -0
- package/src/fields/MultiCheckbox.d.ts +3 -1
- package/src/fields/MultiRadio.d.ts +3 -1
- package/src/fields/MultiZoneEditor/index.d.ts +2 -1
- package/src/fields/NumberInput.d.ts +2 -1
- package/src/fields/TextInput.d.ts +2 -1
- package/src/fields/Textarea.d.ts +2 -1
- package/src/formiks/FormikAutoComplete.d.ts +1 -1
- package/src/formiks/FormikCheckbox.d.ts +1 -1
- package/src/formiks/FormikDatePicker.d.ts +2 -2
- package/src/formiks/FormikDateRangePicker.d.ts +2 -2
- package/src/formiks/FormikMultiCheckbox.d.ts +1 -1
- package/src/formiks/FormikMultiRadio.d.ts +1 -1
- package/src/formiks/FormikMultiSelect.d.ts +1 -1
- package/src/formiks/FormikNumberInput.d.ts +1 -1
- package/src/formiks/FormikSelect.d.ts +1 -1
- package/src/formiks/FormikTextInput.d.ts +1 -1
- package/src/formiks/FormikTextarea.d.ts +1 -1
- package/src/hooks/useClickOutsideEffect.d.ts +3 -0
- package/src/hooks/useFieldUndefineEffect.d.ts +2 -0
- package/src/index.d.ts +2 -2
- package/src/types.d.ts +10 -0
- package/src/hooks/useClickOutside.d.ts +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
# [2.12.0](https://github.com/MTES-MCT/monitor-ui/compare/v2.11.0...v2.12.0) (2023-02-07)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **fields:** add error prop ([26d7494](https://github.com/MTES-MCT/monitor-ui/commit/26d7494157528d853da4a26077f4d63012bd2bd0))
|
|
7
|
+
* **fields:** set onChange value to undefined on disabled ([323ef7a](https://github.com/MTES-MCT/monitor-ui/commit/323ef7ace51acdc117187118bc2a3a8b7ac59ed6))
|
|
8
|
+
|
|
9
|
+
# [2.11.0](https://github.com/MTES-MCT/monitor-ui/compare/v2.10.0...v2.11.0) (2023-02-07)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* **formiks:** set value to undefined on destroy ([8d810ad](https://github.com/MTES-MCT/monitor-ui/commit/8d810ad5dae3990628b3a63744adcc5fb339a3ad))
|
|
15
|
+
|
|
1
16
|
# [2.10.0](https://github.com/MTES-MCT/monitor-ui/compare/v2.9.5...v2.10.0) (2023-01-31)
|
|
2
17
|
|
|
3
18
|
|
package/index.js
CHANGED
|
@@ -2794,7 +2794,7 @@ const FieldError = styled.p `
|
|
|
2794
2794
|
margin-top: 4px;
|
|
2795
2795
|
`;
|
|
2796
2796
|
|
|
2797
|
-
const
|
|
2797
|
+
const useClickOutsideEffect = (zoneRefOrzoneRefs, action, baseContainer) => {
|
|
2798
2798
|
const handleClickOutside = useCallback((event) => {
|
|
2799
2799
|
const eventTarget = event.target;
|
|
2800
2800
|
const zoneRefs = Array.isArray(zoneRefOrzoneRefs) ? zoneRefOrzoneRefs : [zoneRefOrzoneRefs];
|
|
@@ -2813,6 +2813,21 @@ const useClickOutside = (zoneRefOrzoneRefs, action, baseContainer) => {
|
|
|
2813
2813
|
}, [baseContainer, handleClickOutside]);
|
|
2814
2814
|
};
|
|
2815
2815
|
|
|
2816
|
+
function useFieldUndefineEffect(
|
|
2817
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2818
|
+
disabled, onChange) {
|
|
2819
|
+
useEffect(() => {
|
|
2820
|
+
if (disabled && onChange) {
|
|
2821
|
+
onChange(undefined);
|
|
2822
|
+
}
|
|
2823
|
+
return () => {
|
|
2824
|
+
if (onChange) {
|
|
2825
|
+
onChange(undefined);
|
|
2826
|
+
}
|
|
2827
|
+
};
|
|
2828
|
+
}, [disabled, onChange]);
|
|
2829
|
+
}
|
|
2830
|
+
|
|
2816
2831
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
2817
2832
|
|
|
2818
2833
|
function getDefaultExportFromCjs (x) {
|
|
@@ -3343,7 +3358,8 @@ function AutoComplete({ baseContainer, defaultValue, error, isLabelHidden, isLig
|
|
|
3343
3358
|
}
|
|
3344
3359
|
setDefaultControlledValue(defaultValue);
|
|
3345
3360
|
}, [defaultValue]);
|
|
3346
|
-
|
|
3361
|
+
useFieldUndefineEffect(originalProps.disabled, onChange);
|
|
3362
|
+
useClickOutsideEffect(boxRef, close, baseContainer);
|
|
3347
3363
|
useEffect(() => {
|
|
3348
3364
|
forceUpdate();
|
|
3349
3365
|
}, [forceUpdate]);
|
|
@@ -3377,7 +3393,9 @@ const Box$9 = styled.div `
|
|
|
3377
3393
|
}
|
|
3378
3394
|
`;
|
|
3379
3395
|
|
|
3380
|
-
function Checkbox({ label, onChange, ...originalProps }) {
|
|
3396
|
+
function Checkbox({ error, label, onChange, ...originalProps }) {
|
|
3397
|
+
const controlledError = useMemo(() => normalizeString(error), [error]);
|
|
3398
|
+
const hasError = useMemo(() => Boolean(controlledError), [controlledError]);
|
|
3381
3399
|
const key = useMemo(() => `${originalProps.name}-${String(originalProps.defaultChecked)}`, [originalProps.defaultChecked, originalProps.name]);
|
|
3382
3400
|
const handleChange = useCallback((_, isChecked) => {
|
|
3383
3401
|
if (!onChange) {
|
|
@@ -3385,7 +3403,8 @@ function Checkbox({ label, onChange, ...originalProps }) {
|
|
|
3385
3403
|
}
|
|
3386
3404
|
onChange(isChecked);
|
|
3387
3405
|
}, [onChange]);
|
|
3388
|
-
|
|
3406
|
+
useFieldUndefineEffect(originalProps.disabled, onChange);
|
|
3407
|
+
return (jsxs(Field$2, { children: [jsx(StyledCheckbox, { id: originalProps.name, onChange: handleChange, ...originalProps, children: label }, key), hasError && jsx(FieldError, { children: controlledError })] }));
|
|
3389
3408
|
}
|
|
3390
3409
|
const StyledCheckbox = styled(Checkbox$1) `
|
|
3391
3410
|
> .rs-checkbox-checker {
|
|
@@ -4246,7 +4265,7 @@ disabled = false, isCompact, isEndDate = false, isLight, isStartDate = false, mi
|
|
|
4246
4265
|
const nextTimeTuple = [hourInputRef.current.value, minuteInputRef.current.value];
|
|
4247
4266
|
onChange(nextTimeTuple);
|
|
4248
4267
|
}, [closeRangedTimePicker, onChange]);
|
|
4249
|
-
|
|
4268
|
+
useClickOutsideEffect(boxRef, closeRangedTimePicker, baseContainer);
|
|
4250
4269
|
return (jsxs(Box$6, { ref: boxRef, "$hasError": hasFormatError || hasValidationError, "$isCompact": isCompact, "$isDisabled": disabled, "$isFocused": isFocused, "$isLight": isLight, children: [jsxs(InputGroup, { children: [jsxs("div", { children: [jsx(NumberInput$1, { ref: hourInputRef, "aria-label": `Heure${isStartDate ? ' de début' : ''}${isEndDate ? ' de fin' : ''}`, defaultValue: controlledDefaultValue && controlledDefaultValue[0], disabled: disabled, isLight: isLight, max: 23, min: 0, onBack: handleBack, onBlur: handleBlur, onClick: openRangedTimePicker, onFilled: submit, onFocus: handleFocus, onFormatError: handleFormatError, onInput: handleHourInput, onNext: () => minuteInputRef.current.focus(), onPrevious: onPrevious, size: 2 }), ":", jsx(NumberInput$1, { ref: minuteInputRef, "aria-label": `Minute${isStartDate ? ' de début' : ''}${isEndDate ? ' de fin' : ''}`, defaultValue: controlledDefaultValue && controlledDefaultValue[1], disabled: disabled, isLight: isLight, max: 59, min: 0, onBack: () => hourInputRef.current.focus(), onBlur: handleBlur, onClick: openRangedTimePicker, onFilled: submit, onFocus: handleFocus, onFormatError: handleFormatError, onNext: onNext, onPrevious: () => hourInputRef.current.focus(), size: 2 })] }), !isCompact && jsx(Clock, {})] }), isRangedTimePickerOpenRef.current && (jsx(RangedTimePicker, { filter: rangedTimePickerFilter, minutesRange: minutesRange, onChange: handleRangedTimePickedChange }))] }));
|
|
4251
4270
|
}
|
|
4252
4271
|
const TimeInput = forwardRef(TimeInputWithRef);
|
|
@@ -4492,7 +4511,7 @@ const Box$5 = styled.div `
|
|
|
4492
4511
|
|
|
4493
4512
|
function DatePicker({ baseContainer, defaultValue,
|
|
4494
4513
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
4495
|
-
disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false, isLight = false, isStringDate = false, label, minutesRange = 15, onChange, withTime = false, ...nativeProps }) {
|
|
4514
|
+
disabled = false, error, isCompact = false, isHistorical = false, isLabelHidden = false, isLight = false, isStringDate = false, label, minutesRange = 15, onChange, withTime = false, ...nativeProps }) {
|
|
4496
4515
|
const boxRef = useRef();
|
|
4497
4516
|
const dateInputRef = useRef();
|
|
4498
4517
|
const timeInputRef = useRef();
|
|
@@ -4501,6 +4520,8 @@ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false
|
|
|
4501
4520
|
const selectedLocalizedDateTupleRef = useRef(getDateTupleFromDate(selectedLocalizedDateRef.current));
|
|
4502
4521
|
const selectedLocalizedTimeTupleRef = useRef(getTimeTupleFromDate(selectedLocalizedDateRef.current));
|
|
4503
4522
|
const { forceUpdate } = useForceUpdate();
|
|
4523
|
+
const controlledError = useMemo(() => normalizeString(error), [error]);
|
|
4524
|
+
const hasError = useMemo(() => Boolean(controlledError), [controlledError]);
|
|
4504
4525
|
const rangeCalendarPickerDefaultValue = useMemo(() => selectedLocalizedDateTupleRef.current
|
|
4505
4526
|
? getDateFromDateAndTimeTuple(selectedLocalizedDateTupleRef.current, ['00', '00'])
|
|
4506
4527
|
: undefined,
|
|
@@ -4579,8 +4600,9 @@ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false
|
|
|
4579
4600
|
isCalendarPickerOpenRef.current = true;
|
|
4580
4601
|
forceUpdate();
|
|
4581
4602
|
}, [forceUpdate]);
|
|
4582
|
-
|
|
4583
|
-
|
|
4603
|
+
useFieldUndefineEffect(disabled, onChange);
|
|
4604
|
+
useClickOutsideEffect(boxRef, closeCalendarPicker, baseContainer);
|
|
4605
|
+
return (jsxs(Fieldset, { disabled: disabled, ...nativeProps, children: [jsx(Legend, { isDisabled: disabled, isHidden: isLabelHidden, children: label }), jsxs(Box$4, { ref: boxRef, children: [jsx(Field$1, { children: jsx(DateInput, { ref: dateInputRef, defaultValue: selectedLocalizedDateTupleRef.current, disabled: disabled, isCompact: isCompact, isForcedFocused: isCalendarPickerOpenRef.current, isLight: isLight, onChange: handleDateInputChange, onClick: openCalendarPicker, onNext: handleDateInputNext }) }), withTime && (jsx(Field$1, { "$isTimeField": true, children: jsx(TimeInput, { ref: timeInputRef, baseContainer: baseContainer, defaultValue: selectedLocalizedTimeTupleRef.current, disabled: disabled, isCompact: isCompact, isLight: isLight, minutesRange: minutesRange, onBack: () => dateInputRef.current.focus(true), onChange: handleTimeInputFilled, onFocus: closeCalendarPicker, onPrevious: () => dateInputRef.current.focus(true) }) }))] }), hasError && jsx(FieldError, { children: controlledError }), jsx(CalendarPicker, { defaultValue: rangeCalendarPickerDefaultValue, isHistorical: isHistorical, isOpen: isCalendarPickerOpenRef.current, onChange: handleCalendarPickerChange })] }));
|
|
4584
4606
|
}
|
|
4585
4607
|
const Box$4 = styled.div `
|
|
4586
4608
|
* {
|
|
@@ -4807,7 +4829,7 @@ var DateRangePosition;
|
|
|
4807
4829
|
|
|
4808
4830
|
function DateRangePicker({ baseContainer, defaultValue,
|
|
4809
4831
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
4810
|
-
disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false, isLight = false, isStringDate = false, label, minutesRange = 15, onChange, withTime = false, ...nativeProps }) {
|
|
4832
|
+
disabled = false, error, isCompact = false, isHistorical = false, isLabelHidden = false, isLight = false, isStringDate = false, label, minutesRange = 15, onChange, withTime = false, ...nativeProps }) {
|
|
4811
4833
|
const startDateInputRef = useRef();
|
|
4812
4834
|
const startTimeInputRef = useRef();
|
|
4813
4835
|
const endDateInputRef = useRef();
|
|
@@ -4820,6 +4842,8 @@ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false
|
|
|
4820
4842
|
const selectedLocalizedStartTimeTupleRef = useRef(getTimeTupleFromDate(selectedLocalizedStartDateRef.current));
|
|
4821
4843
|
const selectedLocalizedEndTimeTupleRef = useRef(getTimeTupleFromDate(selectedLocalizedEndDateRef.current));
|
|
4822
4844
|
const { forceUpdate } = useForceUpdate();
|
|
4845
|
+
const controlledError = useMemo(() => normalizeString(error), [error]);
|
|
4846
|
+
const hasError = useMemo(() => Boolean(controlledError), [controlledError]);
|
|
4823
4847
|
const rangeCalendarPickerDefaultValue = useMemo(() => selectedLocalizedStartDateTupleRef.current && selectedLocalizedEndDateTupleRef.current
|
|
4824
4848
|
? [
|
|
4825
4849
|
getDateFromDateAndTimeTuple(selectedLocalizedStartDateTupleRef.current, ['00', '00']),
|
|
@@ -4954,8 +4978,9 @@ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false
|
|
|
4954
4978
|
isRangeCalendarPickerOpenRef.current = true;
|
|
4955
4979
|
forceUpdate();
|
|
4956
4980
|
}, [forceUpdate]);
|
|
4957
|
-
|
|
4958
|
-
|
|
4981
|
+
useFieldUndefineEffect(disabled, onChange);
|
|
4982
|
+
useClickOutsideEffect([endDateInputRef, startDateInputRef], closeRangeCalendarPicker, baseContainer);
|
|
4983
|
+
return (jsxs(Fieldset, { ...nativeProps, children: [jsx(Legend, { isDisabled: disabled, isHidden: isLabelHidden, children: label }), jsxs(Box$2, { isDisabled: disabled, children: [jsx(Field, { children: jsx(DateInput, { ref: startDateInputRef, defaultValue: selectedLocalizedStartDateTupleRef.current, disabled: disabled, isCompact: isCompact, isForcedFocused: isRangeCalendarPickerOpenRef.current, isLight: isLight, isStartDate: true, onChange: (nextDateTuple, isFilled) => handleDateInputChange(DateRangePosition.START, nextDateTuple, isFilled), onClick: openRangeCalendarPicker, onNext: handleStartDateInputNext }) }), withTime && (jsx(Field, { isTimeField: true, children: jsx(TimeInput, { ref: startTimeInputRef, baseContainer: baseContainer, defaultValue: selectedLocalizedStartTimeTupleRef.current, disabled: disabled, isCompact: isCompact, isLight: isLight, isStartDate: true, minutesRange: minutesRange, onBack: () => startDateInputRef.current.focus(true), onChange: nextTimeTuple => handleTimeInputFilled(DateRangePosition.START, nextTimeTuple), onFocus: closeRangeCalendarPicker, onNext: () => endDateInputRef.current.focus(), onPrevious: () => startDateInputRef.current.focus(true) }) })), jsx(Field, { isEndDateField: true, children: jsx(DateInput, { ref: endDateInputRef, defaultValue: selectedLocalizedEndDateTupleRef.current, disabled: disabled, isCompact: isCompact, isEndDate: true, isForcedFocused: isRangeCalendarPickerOpenRef.current, isLight: isLight, onBack: handleEndDateInputPrevious, onChange: (nextDateTuple, isFilled) => handleDateInputChange(DateRangePosition.END, nextDateTuple, isFilled), onClick: openRangeCalendarPicker, onNext: handleEndDateInputNext, onPrevious: handleEndDateInputPrevious }) }), withTime && (jsx(Field, { isTimeField: true, children: jsx(TimeInput, { ref: endTimeInputRef, baseContainer: baseContainer, defaultValue: selectedLocalizedEndTimeTupleRef.current, disabled: disabled, isCompact: isCompact, isEndDate: true, isLight: isLight, minutesRange: minutesRange, onBack: () => endDateInputRef.current.focus(true), onChange: nextTimeTuple => handleTimeInputFilled(DateRangePosition.END, nextTimeTuple), onFocus: closeRangeCalendarPicker, onPrevious: () => endDateInputRef.current.focus(true) }) }))] }), hasError && jsx(FieldError, { children: controlledError }), jsx(RangeCalendarPicker, { defaultValue: rangeCalendarPickerDefaultValue, isHistorical: isHistorical, isOpen: isRangeCalendarPickerOpenRef.current, onChange: handleRangeCalendarPickerChange })] }));
|
|
4959
4984
|
}
|
|
4960
4985
|
const Box$2 = styled.div `
|
|
4961
4986
|
* {
|
|
@@ -4986,8 +5011,12 @@ const Field = styled.span `
|
|
|
4986
5011
|
}};
|
|
4987
5012
|
`;
|
|
4988
5013
|
|
|
4989
|
-
function MultiCheckbox({ defaultValue = [],
|
|
5014
|
+
function MultiCheckbox({ defaultValue = [],
|
|
5015
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
5016
|
+
disabled = false, error, isInline = false, isLabelHidden = false, isLight = false, label, name, onChange, options }) {
|
|
4990
5017
|
const checkedOptionValues = useRef(defaultValue);
|
|
5018
|
+
const controlledError = useMemo(() => normalizeString(error), [error]);
|
|
5019
|
+
const hasError = useMemo(() => Boolean(controlledError), [controlledError]);
|
|
4991
5020
|
const key = useMemo(() => `${name}-${JSON.stringify(defaultValue)}`, [defaultValue, name]);
|
|
4992
5021
|
const handleChange = useCallback((nextOptionValue, isChecked) => {
|
|
4993
5022
|
const nextCheckedOptionValues = isChecked
|
|
@@ -4999,26 +5028,38 @@ function MultiCheckbox({ defaultValue = [], isInline = false, isLabelHidden = fa
|
|
|
4999
5028
|
onChange(normalizedNextValue);
|
|
5000
5029
|
}
|
|
5001
5030
|
}, [onChange]);
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5031
|
+
useFieldUndefineEffect(disabled, onChange);
|
|
5032
|
+
const checkboxesElement = useMemo(() => (jsx(Fragment, { children: options.map((option, index) => (jsx(Checkbox, { defaultChecked: defaultValue.includes(option.value), disabled: disabled, label: option.label, name: `${name}${index}`, onChange: (isChecked) => handleChange(option.value, isChecked) }, option.value))) })),
|
|
5033
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5034
|
+
[disabled, handleChange, name, options]);
|
|
5035
|
+
return (jsxs(Fieldset, { isHidden: isLabelHidden, isLight: isLight, legend: label, children: [jsx(ChecboxesBox$1, { "$isInline": isInline, children: checkboxesElement }), hasError && jsx(FieldError, { children: controlledError })] }, key));
|
|
5005
5036
|
}
|
|
5006
5037
|
const ChecboxesBox$1 = styled.div `
|
|
5007
5038
|
color: ${p => p.theme.color.gunMetal};
|
|
5008
5039
|
display: flex;
|
|
5009
5040
|
flex-direction: ${p => (p.$isInline ? 'row' : 'column')};
|
|
5010
5041
|
|
|
5042
|
+
> div {
|
|
5043
|
+
> .rs-checkbox {
|
|
5044
|
+
user-select: none;
|
|
5045
|
+
}
|
|
5046
|
+
}
|
|
5047
|
+
|
|
5011
5048
|
${p => !p.$isInline &&
|
|
5012
5049
|
css `
|
|
5013
|
-
>
|
|
5014
|
-
|
|
5050
|
+
> div:not(:first-child) {
|
|
5051
|
+
> .rs-checkbox {
|
|
5052
|
+
margin-top: 8px;
|
|
5053
|
+
}
|
|
5015
5054
|
}
|
|
5016
5055
|
`}
|
|
5017
5056
|
|
|
5018
5057
|
${p => p.$isInline &&
|
|
5019
5058
|
css `
|
|
5020
|
-
>
|
|
5021
|
-
|
|
5059
|
+
> div:not(:first-child) {
|
|
5060
|
+
.rs-checkbox {
|
|
5061
|
+
margin-left: 12px;
|
|
5062
|
+
}
|
|
5022
5063
|
}
|
|
5023
5064
|
`}
|
|
5024
5065
|
`;
|
|
@@ -5056,7 +5097,8 @@ searchable = false, ...originalProps }) {
|
|
|
5056
5097
|
setIsOpen(!isOpen);
|
|
5057
5098
|
}
|
|
5058
5099
|
}, [isOpen]);
|
|
5059
|
-
|
|
5100
|
+
useFieldUndefineEffect(originalProps.disabled, onChange);
|
|
5101
|
+
useClickOutsideEffect(boxRef, close, baseContainer);
|
|
5060
5102
|
useEffect(() => {
|
|
5061
5103
|
forceUpdate();
|
|
5062
5104
|
}, [forceUpdate]);
|
|
@@ -5140,8 +5182,12 @@ const Box$1 = styled.div `
|
|
|
5140
5182
|
}
|
|
5141
5183
|
`;
|
|
5142
5184
|
|
|
5143
|
-
function MultiRadio({ defaultValue,
|
|
5185
|
+
function MultiRadio({ defaultValue,
|
|
5186
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
5187
|
+
disabled = false, error, isInline = false, isLabelHidden = false, isLight = false, label, name, onChange, options }) {
|
|
5144
5188
|
const [checkedOptionValue, setCheckedOptionValue] = useState(undefined);
|
|
5189
|
+
const controlledError = useMemo(() => normalizeString(error), [error]);
|
|
5190
|
+
const hasError = useMemo(() => Boolean(controlledError), [controlledError]);
|
|
5145
5191
|
const key = useMemo(() => `${name}-${String(checkedOptionValue)}}`, [checkedOptionValue, name]);
|
|
5146
5192
|
const handleChange = useCallback((nextOptionValue, isChecked) => {
|
|
5147
5193
|
const nextCheckedOptionValue = isChecked ? nextOptionValue : undefined;
|
|
@@ -5150,6 +5196,7 @@ function MultiRadio({ defaultValue, isInline = false, isLabelHidden = false, isL
|
|
|
5150
5196
|
onChange(nextCheckedOptionValue);
|
|
5151
5197
|
}
|
|
5152
5198
|
}, [onChange]);
|
|
5199
|
+
useFieldUndefineEffect(disabled, onChange);
|
|
5153
5200
|
// TODO There may be a better solution.
|
|
5154
5201
|
// A key change is not enough to force radio checked check changes
|
|
5155
5202
|
// on `defaultValue` property update (even when appending `defaultValue` to `key`),
|
|
@@ -5157,9 +5204,9 @@ function MultiRadio({ defaultValue, isInline = false, isLabelHidden = false, isL
|
|
|
5157
5204
|
useEffect(() => {
|
|
5158
5205
|
setCheckedOptionValue(defaultValue);
|
|
5159
5206
|
}, [defaultValue]);
|
|
5160
|
-
return (
|
|
5161
|
-
|
|
5162
|
-
|
|
5207
|
+
return (jsxs(Fieldset, { isHidden: isLabelHidden, isLight: isLight, legend: label, children: [jsx(ChecboxesBox, { "$isInline": isInline, children: options.map((option, index) => (jsx(Radio
|
|
5208
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
5209
|
+
, { defaultChecked: option.value === checkedOptionValue, disabled: disabled, name: name, onChange: (_, isChecked) => handleChange(option.value, isChecked), children: option.label }, `${name}-${index}`))) }), hasError && jsx(FieldError, { children: controlledError })] }, key));
|
|
5163
5210
|
}
|
|
5164
5211
|
const ChecboxesBox = styled.div `
|
|
5165
5212
|
color: ${p => p.theme.color.gunMetal};
|
|
@@ -5171,6 +5218,7 @@ const ChecboxesBox = styled.div `
|
|
|
5171
5218
|
> .rs-radio-checker {
|
|
5172
5219
|
min-height: 0;
|
|
5173
5220
|
padding: 0 0 0 28px;
|
|
5221
|
+
user-select: none;
|
|
5174
5222
|
|
|
5175
5223
|
.rs-radio-wrapper {
|
|
5176
5224
|
left: 2px;
|
|
@@ -5194,9 +5242,11 @@ const ChecboxesBox = styled.div `
|
|
|
5194
5242
|
`}
|
|
5195
5243
|
`;
|
|
5196
5244
|
|
|
5197
|
-
function MultiZoneEditor({ addButtonLabel, defaultValue = [], initialZone, isLabelHidden = false, isLight = false, label, labelPropName, onAdd, onCenter, onDelete, onEdit }) {
|
|
5245
|
+
function MultiZoneEditor({ addButtonLabel, defaultValue = [], error, initialZone, isLabelHidden = false, isLight = false, label, labelPropName, onAdd, onCenter, onDelete, onEdit }) {
|
|
5198
5246
|
const prevDefaultValueRef = useRef(defaultValue);
|
|
5199
5247
|
const [zones, setZones] = useState(defaultValue);
|
|
5248
|
+
const controlledError = useMemo(() => normalizeString(error), [error]);
|
|
5249
|
+
const hasError = useMemo(() => Boolean(controlledError), [controlledError]);
|
|
5200
5250
|
const addZone = useCallback(() => {
|
|
5201
5251
|
const nextZones = [...zones, initialZone];
|
|
5202
5252
|
if (onAdd) {
|
|
@@ -5229,7 +5279,7 @@ function MultiZoneEditor({ addButtonLabel, defaultValue = [], initialZone, isLab
|
|
|
5229
5279
|
}, [defaultValue]);
|
|
5230
5280
|
return (jsxs(Fieldset, { isHidden: isLabelHidden, isLight: isLight, legend: label, children: [jsx(Button, { accent: Accent.SECONDARY, Icon: Plus, isFullWidth: true, onClick: addZone, children: addButtonLabel }), jsx(Fragment, { children: zones.map((zone, index) => (
|
|
5231
5281
|
// eslint-disable-next-line react/no-array-index-key
|
|
5232
|
-
jsxs(Row, { children: [jsxs(ZoneWrapper, { children: [zone[labelPropName], jsxs(Link, { onClick: () => centerZone(zone), children: [jsx(SelectRectangle, {}), jsx("span", { children: "Centrer sur la carte" })] })] }), jsx(IconButton, { accent: Accent.SECONDARY, Icon: Edit, onClick: () => editZone(index, zone) }), jsx(IconButton, { accent: Accent.SECONDARY, "aria-label": "Supprimer cette zone", Icon: Delete, onClick: () => deleteZone(index) })] }, `zone-${index}`))) })] }));
|
|
5282
|
+
jsxs(Row, { children: [jsxs(ZoneWrapper, { children: [zone[labelPropName], jsxs(Link, { onClick: () => centerZone(zone), children: [jsx(SelectRectangle, {}), jsx("span", { children: "Centrer sur la carte" })] })] }), jsx(IconButton, { accent: Accent.SECONDARY, Icon: Edit, onClick: () => editZone(index, zone) }), jsx(IconButton, { accent: Accent.SECONDARY, "aria-label": "Supprimer cette zone", Icon: Delete, onClick: () => deleteZone(index) })] }, `zone-${index}`))) }), hasError && jsx(FieldError, { children: controlledError })] }));
|
|
5233
5283
|
}
|
|
5234
5284
|
const Row = styled.div `
|
|
5235
5285
|
align-items: center;
|
|
@@ -5260,7 +5310,9 @@ const Link = styled.a `
|
|
|
5260
5310
|
}
|
|
5261
5311
|
`;
|
|
5262
5312
|
|
|
5263
|
-
function NumberInput({ isLabelHidden = false, isLight = false, label, onChange, ...originalProps }) {
|
|
5313
|
+
function NumberInput({ error, isLabelHidden = false, isLight = false, label, onChange, ...originalProps }) {
|
|
5314
|
+
const controlledError = useMemo(() => normalizeString(error), [error]);
|
|
5315
|
+
const hasError = useMemo(() => Boolean(controlledError), [controlledError]);
|
|
5264
5316
|
const key = useMemo(() => `${originalProps.name}-${JSON.stringify(originalProps.defaultValue)}`, [originalProps.defaultValue, originalProps.name]);
|
|
5265
5317
|
const handleChange = useCallback((nextValue) => {
|
|
5266
5318
|
if (!onChange) {
|
|
@@ -5271,7 +5323,8 @@ function NumberInput({ isLabelHidden = false, isLight = false, label, onChange,
|
|
|
5271
5323
|
const normalizedNextValue = !Number.isNaN(nextValueAsNumber) ? nextValueAsNumber : undefined;
|
|
5272
5324
|
onChange(normalizedNextValue);
|
|
5273
5325
|
}, [onChange]);
|
|
5274
|
-
|
|
5326
|
+
useFieldUndefineEffect(originalProps.disabled, onChange);
|
|
5327
|
+
return (jsxs(Field$2, { children: [jsx(Label, { htmlFor: originalProps.name, isHidden: isLabelHidden, children: label }), jsx(StyledInput$2, { "$isLight": isLight, id: originalProps.name, onChange: handleChange, type: "number", ...originalProps }, key), hasError && jsx(FieldError, { children: controlledError })] }));
|
|
5275
5328
|
}
|
|
5276
5329
|
const StyledInput$2 = styled(Input) `
|
|
5277
5330
|
background-color: ${p => (p.$isLight ? p.theme.color.white : p.theme.color.gainsboro)};
|
|
@@ -5314,7 +5367,8 @@ searchable = false, ...originalProps }) {
|
|
|
5314
5367
|
setIsOpen(!isOpen);
|
|
5315
5368
|
}
|
|
5316
5369
|
}, [isOpen]);
|
|
5317
|
-
|
|
5370
|
+
useFieldUndefineEffect(originalProps.disabled, onChange);
|
|
5371
|
+
useClickOutsideEffect(boxRef, close, baseContainer);
|
|
5318
5372
|
useEffect(() => {
|
|
5319
5373
|
forceUpdate();
|
|
5320
5374
|
}, [forceUpdate]);
|
|
@@ -5368,8 +5422,10 @@ const Box = styled.div `
|
|
|
5368
5422
|
}
|
|
5369
5423
|
`;
|
|
5370
5424
|
|
|
5371
|
-
function Textarea({ isLabelHidden = false, isLight = false, label, onChange, rows = 3, ...originalProps }) {
|
|
5425
|
+
function Textarea({ error, isLabelHidden = false, isLight = false, label, onChange, rows = 3, ...originalProps }) {
|
|
5372
5426
|
const inputRef = useRef();
|
|
5427
|
+
const controlledError = useMemo(() => normalizeString(error), [error]);
|
|
5428
|
+
const hasError = useMemo(() => Boolean(controlledError), [controlledError]);
|
|
5373
5429
|
const key = useMemo(() => `${originalProps.name}-${JSON.stringify(originalProps.defaultValue)}`, [originalProps.defaultValue, originalProps.name]);
|
|
5374
5430
|
const handleChange = useCallback(() => {
|
|
5375
5431
|
if (!onChange) {
|
|
@@ -5379,7 +5435,8 @@ function Textarea({ isLabelHidden = false, isLight = false, label, onChange, row
|
|
|
5379
5435
|
const normalizedNextValue = nextValue.length ? nextValue : undefined;
|
|
5380
5436
|
onChange(normalizedNextValue);
|
|
5381
5437
|
}, [onChange]);
|
|
5382
|
-
|
|
5438
|
+
useFieldUndefineEffect(originalProps.disabled, onChange);
|
|
5439
|
+
return (jsxs(Field$2, { children: [jsx(Label, { htmlFor: originalProps.name, isHidden: isLabelHidden, children: label }), jsx(StyledInput$1, { ref: inputRef, "$isLight": isLight, as: "textarea", id: originalProps.name, onChange: handleChange, rows: rows, ...originalProps }, key), hasError && jsx(FieldError, { children: controlledError })] }));
|
|
5383
5440
|
}
|
|
5384
5441
|
const StyledInput$1 = styled(Input) `
|
|
5385
5442
|
background-color: ${p => (p.$isLight ? p.theme.color.white : p.theme.color.gainsboro)};
|
|
@@ -5393,7 +5450,9 @@ const StyledInput$1 = styled(Input) `
|
|
|
5393
5450
|
}
|
|
5394
5451
|
`;
|
|
5395
5452
|
|
|
5396
|
-
function TextInput({ isLabelHidden = false, isLight = false, label, onChange, ...originalProps }) {
|
|
5453
|
+
function TextInput({ error, isLabelHidden = false, isLight = false, label, onChange, ...originalProps }) {
|
|
5454
|
+
const controlledError = useMemo(() => normalizeString(error), [error]);
|
|
5455
|
+
const hasError = useMemo(() => Boolean(controlledError), [controlledError]);
|
|
5397
5456
|
const key = useMemo(() => `${originalProps.name}-${JSON.stringify(originalProps.defaultValue)}`, [originalProps.defaultValue, originalProps.name]);
|
|
5398
5457
|
const handleChange = useCallback((nextValue) => {
|
|
5399
5458
|
if (!onChange) {
|
|
@@ -5402,7 +5461,8 @@ function TextInput({ isLabelHidden = false, isLight = false, label, onChange, ..
|
|
|
5402
5461
|
const normalizedNextValue = nextValue && nextValue.trim().length ? nextValue : undefined;
|
|
5403
5462
|
onChange(normalizedNextValue);
|
|
5404
5463
|
}, [onChange]);
|
|
5405
|
-
|
|
5464
|
+
useFieldUndefineEffect(originalProps.disabled, onChange);
|
|
5465
|
+
return (jsxs(Field$2, { children: [jsx(Label, { htmlFor: originalProps.name, isHidden: isLabelHidden, children: label }), jsx(StyledInput, { "$isLight": isLight, id: originalProps.name, onChange: handleChange, type: "text", ...originalProps }, key), hasError && jsx(FieldError, { children: controlledError })] }));
|
|
5406
5466
|
}
|
|
5407
5467
|
const StyledInput = styled(Input) `
|
|
5408
5468
|
background-color: ${p => (p.$isLight ? p.theme.color.white : p.theme.color.gainsboro)};
|
|
@@ -5416,56 +5476,48 @@ const StyledInput = styled(Input) `
|
|
|
5416
5476
|
`;
|
|
5417
5477
|
|
|
5418
5478
|
function FormikAutoComplete({ name, ...originalProps }) {
|
|
5419
|
-
const [field, , helpers] = useField(name);
|
|
5420
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5479
|
+
const [field, meta, helpers] = useField(name);
|
|
5480
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5421
5481
|
const defaultValue = useMemo(() => field.value, []);
|
|
5422
|
-
|
|
5423
|
-
helpers.setValue(undefined);
|
|
5424
|
-
},
|
|
5482
|
+
const error = useMemo(() => (meta.initialTouched ? meta.error : undefined), [meta.error, meta.initialTouched]);
|
|
5425
5483
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5426
|
-
[]);
|
|
5484
|
+
const handleChange = useMemo(() => helpers.setValue, []);
|
|
5427
5485
|
if (!defaultValue) {
|
|
5428
5486
|
return jsx(AutoComplete, { name: name, onChange: helpers.setValue, ...originalProps });
|
|
5429
5487
|
}
|
|
5430
|
-
return jsx(AutoComplete, { defaultValue: defaultValue, name: name, onChange:
|
|
5488
|
+
return (jsx(AutoComplete, { defaultValue: defaultValue, error: error, name: name, onChange: handleChange, ...originalProps }));
|
|
5431
5489
|
}
|
|
5432
5490
|
|
|
5433
5491
|
function FormikCheckbox({ name, ...originalProps }) {
|
|
5434
|
-
const [field, , helpers] = useField(name);
|
|
5435
|
-
|
|
5436
|
-
|
|
5437
|
-
|
|
5438
|
-
helpers.setValue(undefined);
|
|
5439
|
-
},
|
|
5492
|
+
const [field, meta, helpers] = useField(name);
|
|
5493
|
+
const error = useMemo(() => (meta.initialTouched ? meta.error : undefined), [meta.error, meta.initialTouched]);
|
|
5494
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5495
|
+
const handleChange = useMemo(() => helpers.setValue, []);
|
|
5440
5496
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5441
|
-
[]);
|
|
5442
|
-
return jsx(Checkbox, { defaultChecked:
|
|
5497
|
+
const isDefaultChecked = useMemo(() => Boolean(field.value), []);
|
|
5498
|
+
return (jsx(Checkbox, { defaultChecked: isDefaultChecked, error: error, name: name, onChange: handleChange, ...originalProps }));
|
|
5443
5499
|
}
|
|
5444
5500
|
|
|
5445
5501
|
const UntypedDatePicker = DatePicker;
|
|
5446
5502
|
function FormikDatePicker({ name, ...originalProps }) {
|
|
5447
|
-
const [field, , helpers] = useField(name);
|
|
5503
|
+
const [field, meta, helpers] = useField(name);
|
|
5448
5504
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5449
5505
|
const defaultValue = useMemo(() => field.value, []);
|
|
5450
|
-
|
|
5451
|
-
helpers.setValue(undefined);
|
|
5452
|
-
},
|
|
5506
|
+
const error = useMemo(() => (meta.initialTouched ? meta.error : undefined), [meta.error, meta.initialTouched]);
|
|
5453
5507
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5454
|
-
[]);
|
|
5455
|
-
return jsx(UntypedDatePicker, { defaultValue: defaultValue, onChange:
|
|
5508
|
+
const handleChange = useMemo(() => helpers.setValue, []);
|
|
5509
|
+
return jsx(UntypedDatePicker, { defaultValue: defaultValue, error: error, onChange: handleChange, ...originalProps });
|
|
5456
5510
|
}
|
|
5457
5511
|
|
|
5458
5512
|
const UntypedDateRangePicker = DateRangePicker;
|
|
5459
5513
|
function FormikDateRangePicker({ name, ...originalProps }) {
|
|
5460
|
-
const [field, , helpers] = useField(name);
|
|
5514
|
+
const [field, meta, helpers] = useField(name);
|
|
5461
5515
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5462
5516
|
const defaultValue = useMemo(() => field.value, []);
|
|
5463
|
-
|
|
5464
|
-
helpers.setValue(undefined);
|
|
5465
|
-
},
|
|
5517
|
+
const error = useMemo(() => (meta.initialTouched ? meta.error : undefined), [meta.error, meta.initialTouched]);
|
|
5466
5518
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5467
|
-
[]);
|
|
5468
|
-
return jsx(UntypedDateRangePicker, { defaultValue: defaultValue, onChange:
|
|
5519
|
+
const handleChange = useMemo(() => helpers.setValue, []);
|
|
5520
|
+
return jsx(UntypedDateRangePicker, { defaultValue: defaultValue, error: error, onChange: handleChange, ...originalProps });
|
|
5469
5521
|
}
|
|
5470
5522
|
|
|
5471
5523
|
function FormikEffect({ onChange }) {
|
|
@@ -5477,51 +5529,43 @@ function FormikEffect({ onChange }) {
|
|
|
5477
5529
|
}
|
|
5478
5530
|
|
|
5479
5531
|
function FormikMultiCheckbox({ name, ...originalProps }) {
|
|
5480
|
-
const [field, , helpers] = useField(name);
|
|
5532
|
+
const [field, meta, helpers] = useField(name);
|
|
5481
5533
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5482
5534
|
const defaultValue = useMemo(() => field.value, []);
|
|
5483
|
-
|
|
5484
|
-
helpers.setValue(undefined);
|
|
5485
|
-
},
|
|
5535
|
+
const error = useMemo(() => (meta.initialTouched ? meta.error : undefined), [meta.error, meta.initialTouched]);
|
|
5486
5536
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5487
|
-
[]);
|
|
5488
|
-
return jsx(MultiCheckbox, { defaultValue: defaultValue, name: name, onChange:
|
|
5537
|
+
const handleChange = useMemo(() => helpers.setValue, []);
|
|
5538
|
+
return (jsx(MultiCheckbox, { defaultValue: defaultValue, error: error, name: name, onChange: handleChange, ...originalProps }));
|
|
5489
5539
|
}
|
|
5490
5540
|
|
|
5491
5541
|
function FormikMultiSelect({ name, ...originalProps }) {
|
|
5492
|
-
const [field, , helpers] = useField(name);
|
|
5542
|
+
const [field, meta, helpers] = useField(name);
|
|
5493
5543
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5494
5544
|
const defaultValue = useMemo(() => field.value, []);
|
|
5495
|
-
|
|
5496
|
-
helpers.setValue(undefined);
|
|
5497
|
-
},
|
|
5545
|
+
const error = useMemo(() => (meta.initialTouched ? meta.error : undefined), [meta.error, meta.initialTouched]);
|
|
5498
5546
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5499
|
-
[]);
|
|
5500
|
-
return jsx(MultiSelect, { defaultValue: defaultValue, name: name, onChange:
|
|
5547
|
+
const handleChange = useMemo(() => helpers.setValue, []);
|
|
5548
|
+
return (jsx(MultiSelect, { defaultValue: defaultValue, error: error, name: name, onChange: handleChange, ...originalProps }));
|
|
5501
5549
|
}
|
|
5502
5550
|
|
|
5503
5551
|
function FormikMultiRadio({ name, ...originalProps }) {
|
|
5504
|
-
const [field, , helpers] = useField(name);
|
|
5552
|
+
const [field, meta, helpers] = useField(name);
|
|
5505
5553
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5506
5554
|
const defaultValue = useMemo(() => field.value, []);
|
|
5507
|
-
|
|
5508
|
-
helpers.setValue(undefined);
|
|
5509
|
-
},
|
|
5555
|
+
const error = useMemo(() => (meta.initialTouched ? meta.error : undefined), [meta.error, meta.initialTouched]);
|
|
5510
5556
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5511
|
-
[]);
|
|
5512
|
-
return jsx(MultiRadio, { defaultValue: defaultValue, name: name, onChange:
|
|
5557
|
+
const handleChange = useMemo(() => helpers.setValue, []);
|
|
5558
|
+
return jsx(MultiRadio, { defaultValue: defaultValue, error: error, name: name, onChange: handleChange, ...originalProps });
|
|
5513
5559
|
}
|
|
5514
5560
|
|
|
5515
5561
|
function FormikNumberInput({ name, ...originalProps }) {
|
|
5516
|
-
const [field, , helpers] = useField(name);
|
|
5562
|
+
const [field, meta, helpers] = useField(name);
|
|
5517
5563
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5518
5564
|
const defaultValue = useMemo(() => field.value, []);
|
|
5519
|
-
|
|
5520
|
-
helpers.setValue(undefined);
|
|
5521
|
-
},
|
|
5565
|
+
const error = useMemo(() => (meta.initialTouched ? meta.error : undefined), [meta.error, meta.initialTouched]);
|
|
5522
5566
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5523
|
-
[]);
|
|
5524
|
-
return jsx(NumberInput, { defaultValue: defaultValue, name: name, onChange:
|
|
5567
|
+
const handleChange = useMemo(() => helpers.setValue, []);
|
|
5568
|
+
return (jsx(NumberInput, { defaultValue: defaultValue, error: error, name: name, onChange: handleChange, ...originalProps }));
|
|
5525
5569
|
}
|
|
5526
5570
|
|
|
5527
5571
|
function FormikSelect({ name, ...originalProps }) {
|
|
@@ -5529,39 +5573,32 @@ function FormikSelect({ name, ...originalProps }) {
|
|
|
5529
5573
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5530
5574
|
const defaultValue = useMemo(() => field.value, []);
|
|
5531
5575
|
const error = useMemo(() => (meta.initialTouched ? meta.error : undefined), [meta.error, meta.initialTouched]);
|
|
5532
|
-
useEffect(() => () => {
|
|
5533
|
-
helpers.setValue(undefined);
|
|
5534
|
-
},
|
|
5535
5576
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5536
|
-
[]);
|
|
5537
|
-
return jsx(Select, { defaultValue: defaultValue, error: error, name: name, onChange:
|
|
5577
|
+
const handleChange = useMemo(() => helpers.setValue, []);
|
|
5578
|
+
return jsx(Select, { defaultValue: defaultValue, error: error, name: name, onChange: handleChange, ...originalProps });
|
|
5538
5579
|
}
|
|
5539
5580
|
|
|
5540
5581
|
function FormikTextarea({ name, ...originalProps }) {
|
|
5541
|
-
const [field, , helpers] = useField(name);
|
|
5582
|
+
const [field, meta, helpers] = useField(name);
|
|
5542
5583
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5543
5584
|
const defaultValue = useMemo(() => field.value, []);
|
|
5544
|
-
|
|
5545
|
-
helpers.setValue(undefined);
|
|
5546
|
-
},
|
|
5585
|
+
const error = useMemo(() => (meta.initialTouched ? meta.error : undefined), [meta.error, meta.initialTouched]);
|
|
5547
5586
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5548
|
-
[]);
|
|
5549
|
-
return jsx(Textarea, { defaultValue: defaultValue, name: name, onChange:
|
|
5587
|
+
const handleChange = useMemo(() => helpers.setValue, []);
|
|
5588
|
+
return jsx(Textarea, { defaultValue: defaultValue, error: error, name: name, onChange: handleChange, ...originalProps });
|
|
5550
5589
|
}
|
|
5551
5590
|
|
|
5552
5591
|
function FormikTextInput({ name, ...originalProps }) {
|
|
5553
|
-
const [field, , helpers] = useField(name);
|
|
5592
|
+
const [field, meta, helpers] = useField(name);
|
|
5554
5593
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5555
5594
|
const defaultValue = useMemo(() => field.value, []);
|
|
5556
|
-
|
|
5557
|
-
helpers.setValue(undefined);
|
|
5558
|
-
},
|
|
5595
|
+
const error = useMemo(() => (meta.initialTouched ? meta.error : undefined), [meta.error, meta.initialTouched]);
|
|
5559
5596
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5560
|
-
[]);
|
|
5561
|
-
return jsx(TextInput, { defaultValue: defaultValue, name: name, onChange:
|
|
5597
|
+
const handleChange = useMemo(() => helpers.setValue, []);
|
|
5598
|
+
return jsx(TextInput, { defaultValue: defaultValue, error: error, name: name, onChange: handleChange, ...originalProps });
|
|
5562
5599
|
}
|
|
5563
5600
|
|
|
5564
5601
|
const noop = () => { };
|
|
5565
5602
|
|
|
5566
|
-
export { Accent, AutoComplete, Button, Checkbox, DatePicker, DateRangePicker, Dropdown, Field$2 as Field, Fieldset, FormikAutoComplete, FormikCheckbox, FormikDatePicker, FormikDateRangePicker, FormikEffect, FormikMultiCheckbox, FormikMultiRadio, FormikMultiSelect, FormikNumberInput, FormikSelect, FormikTextInput, FormikTextarea, GlobalStyle, index as Icon, IconButton, Label, Legend, MultiCheckbox, MultiRadio, MultiSelect, MultiZoneEditor, NumberInput, OnlyFontGlobalStyle, Select, Size, THEME, Tag$1 as Tag, TagGroup, TextInput, Textarea, ThemeProvider, dayjs, getLocalizedDayjs, getUtcizedDayjs, noop, stopMouseEventPropagation,
|
|
5603
|
+
export { Accent, AutoComplete, Button, Checkbox, DatePicker, DateRangePicker, Dropdown, Field$2 as Field, Fieldset, FormikAutoComplete, FormikCheckbox, FormikDatePicker, FormikDateRangePicker, FormikEffect, FormikMultiCheckbox, FormikMultiRadio, FormikMultiSelect, FormikNumberInput, FormikSelect, FormikTextInput, FormikTextarea, GlobalStyle, index as Icon, IconButton, Label, Legend, MultiCheckbox, MultiRadio, MultiSelect, MultiZoneEditor, NumberInput, OnlyFontGlobalStyle, Select, Size, THEME, Tag$1 as Tag, TagGroup, TextInput, Textarea, ThemeProvider, dayjs, getLocalizedDayjs, getUtcizedDayjs, noop, stopMouseEventPropagation, useClickOutsideEffect, useForceUpdate };
|
|
5567
5604
|
//# sourceMappingURL=index.js.map
|