@mtes-mct/monitor-ui 2.5.1 → 2.6.0
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 +7 -0
- package/index.js +262 -108
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/NewWindow/index.d.ts +14 -0
- package/src/elements/FieldError.d.ts +7 -0
- package/src/elements/Label.d.ts +2 -0
- package/src/fields/AutoComplete.d.ts +3 -2
- package/src/fields/MultiSelect.d.ts +3 -2
- package/src/fields/Select.d.ts +3 -2
- package/src/utils/cleanString.d.ts +4 -0
- package/src/utils/normalizeString.d.ts +4 -0
- package/src/utils/cleanInputString.d.ts +0 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [2.5.1](https://github.com/MTES-MCT/monitor-ui/compare/v2.5.0...v2.5.1) (2023-01-06)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **fields:** force width for DateRangePicker calendar container ([2c3bab7](https://github.com/MTES-MCT/monitor-ui/commit/2c3bab7a1f6ab5a70ad2e679045eef8822f310d5))
|
|
7
|
+
|
|
1
8
|
# [2.5.0](https://github.com/MTES-MCT/monitor-ui/compare/v2.4.1...v2.5.0) (2023-01-06)
|
|
2
9
|
|
|
3
10
|
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import styled, { createGlobalStyle, ThemeProvider as ThemeProvider$1, css } from 'styled-components';
|
|
2
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
|
-
import { useMemo, useRef, useState, useCallback, useEffect,
|
|
3
|
+
import { useMemo, useReducer, useRef, useState, useCallback, useEffect, forwardRef, useImperativeHandle } from 'react';
|
|
4
4
|
import { Dropdown as Dropdown$1, AutoComplete as AutoComplete$1, Checkbox as Checkbox$1, DatePicker as DatePicker$1, DateRangePicker as DateRangePicker$1, TagPicker, Radio, Input, SelectPicker } from 'rsuite';
|
|
5
5
|
import { useField, useFormikContext } from 'formik';
|
|
6
6
|
|
|
@@ -89,7 +89,7 @@ const GlobalStyle = createGlobalStyle `
|
|
|
89
89
|
body {
|
|
90
90
|
font-family: Marianne, sans-serif;
|
|
91
91
|
font-size: 16px;
|
|
92
|
-
line-height: 1.
|
|
92
|
+
line-height: 1.3846;
|
|
93
93
|
}
|
|
94
94
|
`;
|
|
95
95
|
|
|
@@ -1599,10 +1599,12 @@ const Field$2 = styled.div `
|
|
|
1599
1599
|
`;
|
|
1600
1600
|
|
|
1601
1601
|
const Label = styled.label `
|
|
1602
|
-
color: ${p =>
|
|
1603
|
-
|
|
1602
|
+
color: ${p =>
|
|
1603
|
+
// eslint-disable-next-line no-nested-ternary
|
|
1604
|
+
p.isDisabled ? p.theme.color.lightGray : p.hasError ? p.theme.color.maximumRed : p.theme.color.slateGray};
|
|
1605
|
+
display: ${p => (p.isHidden ? 'none' : 'block')};
|
|
1604
1606
|
font-size: 13px;
|
|
1605
|
-
line-height: 1.
|
|
1607
|
+
line-height: 1.3846;
|
|
1606
1608
|
margin-bottom: 4px;
|
|
1607
1609
|
`;
|
|
1608
1610
|
|
|
@@ -1615,14 +1617,14 @@ const StyledLabel = styled(Label) `
|
|
|
1615
1617
|
|
|
1616
1618
|
function Fieldset({ children, hasBorder = false, isHidden = false, isLight = false, legend, ...nativeProps }) {
|
|
1617
1619
|
const hasLegend = useMemo(() => Boolean(legend), [legend]);
|
|
1618
|
-
return (jsxs(StyledField, { as: "fieldset", ...nativeProps, children: [legend && jsx(Legend, { isHidden: isHidden, children: legend }), jsx(Box$
|
|
1620
|
+
return (jsxs(StyledField, { as: "fieldset", ...nativeProps, children: [legend && jsx(Legend, { isHidden: isHidden, children: legend }), jsx(Box$b, { "$hasBorder": hasBorder, "$hasLegend": hasLegend, "$isLight": isLight, children: children })] }));
|
|
1619
1621
|
}
|
|
1620
1622
|
const StyledField = styled(Field$2) `
|
|
1621
1623
|
border: 0;
|
|
1622
1624
|
margin: 0;
|
|
1623
1625
|
padding: 0;
|
|
1624
1626
|
`;
|
|
1625
|
-
const Box$
|
|
1627
|
+
const Box$b = styled.div `
|
|
1626
1628
|
background-color: ${p => (p.$isLight ? p.theme.color.white : 'transparent')};
|
|
1627
1629
|
padding: ${p => (p.$hasBorder || p.$isLight ? '16px' : 0)};
|
|
1628
1630
|
|
|
@@ -1727,17 +1729,17 @@ function Tag$1({ accent, bullet, children, color, Icon, isLight = false, ...nati
|
|
|
1727
1729
|
case Accent.TERTIARY:
|
|
1728
1730
|
return jsx(TertiaryTag, { ...commonProps });
|
|
1729
1731
|
default:
|
|
1730
|
-
return jsx(Box$
|
|
1732
|
+
return jsx(Box$a, { "$color": color, ...commonProps });
|
|
1731
1733
|
}
|
|
1732
1734
|
}
|
|
1733
|
-
const Box$
|
|
1735
|
+
const Box$a = styled.span `
|
|
1734
1736
|
align-items: center;
|
|
1735
1737
|
background-color: ${p => (p.$isLight ? p.theme.color.white : 'transparent')};
|
|
1736
1738
|
border-radius: 11px;
|
|
1737
1739
|
color: ${p => (p.$color ? p.$color : p.theme.color.gunMetal)};
|
|
1738
1740
|
display: inline-flex;
|
|
1739
1741
|
font-size: 13px;
|
|
1740
|
-
line-height: 1.
|
|
1742
|
+
line-height: 1.3846;
|
|
1741
1743
|
padding: 1px 8px 3px 8px;
|
|
1742
1744
|
|
|
1743
1745
|
/* Bullet components are a span */
|
|
@@ -1752,16 +1754,16 @@ const Box$7 = styled.span `
|
|
|
1752
1754
|
margin-right: 4px;
|
|
1753
1755
|
}
|
|
1754
1756
|
`;
|
|
1755
|
-
const PrimaryTag = styled(Box$
|
|
1757
|
+
const PrimaryTag = styled(Box$a) `
|
|
1756
1758
|
background-color: ${p => (p.$isLight ? p.theme.color.white : p.theme.color.gainsboro)};
|
|
1757
1759
|
color: ${p => p.theme.color.gunMetal};
|
|
1758
1760
|
`;
|
|
1759
1761
|
// TODO Fix this color.
|
|
1760
|
-
const SecondaryTag = styled(Box$
|
|
1762
|
+
const SecondaryTag = styled(Box$a) `
|
|
1761
1763
|
background-color: ${p => (p.$isLight ? '#f6d012' : '#f6d012')};
|
|
1762
1764
|
color: ${p => p.theme.color.gunMetal};
|
|
1763
1765
|
`;
|
|
1764
|
-
const TertiaryTag = styled(Box$
|
|
1766
|
+
const TertiaryTag = styled(Box$a) `
|
|
1765
1767
|
background-color: ${p => (p.$isLight ? p.theme.color.charcoal : p.theme.color.charcoal)};
|
|
1766
1768
|
color: ${p => p.theme.color.white};
|
|
1767
1769
|
`;
|
|
@@ -2288,77 +2290,13 @@ const createInstance = (defaults) => {
|
|
|
2288
2290
|
const ky = createInstance();
|
|
2289
2291
|
var ky$1 = ky;
|
|
2290
2292
|
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
const [autoGeneratedOptions, setAutoGeneratedOptions] = useState([]);
|
|
2295
|
-
const controlledOptions = useMemo(() => options ?? autoGeneratedOptions, [autoGeneratedOptions, options]);
|
|
2296
|
-
const controlledValueAsLabel = useMemo(() => {
|
|
2297
|
-
const foundOption = controlledOptions.find(propEq('value', controlledDefaultValue));
|
|
2298
|
-
return foundOption ? foundOption.label : undefined;
|
|
2299
|
-
}, [controlledDefaultValue, controlledOptions]);
|
|
2300
|
-
const key = useMemo(() => `${originalProps.name}-${JSON.stringify(controlledDefaultValue)}`, [controlledDefaultValue, originalProps.name]);
|
|
2301
|
-
const handleChange = useCallback(async (nextQuery) => {
|
|
2302
|
-
if (queryUrl && queryMap) {
|
|
2303
|
-
const url = queryUrl.replace('%s', nextQuery);
|
|
2304
|
-
const rawData = await ky$1.get(url).json();
|
|
2305
|
-
const nextData = rawData.map(queryMap);
|
|
2306
|
-
setAutoGeneratedOptions(nextData);
|
|
2307
|
-
}
|
|
2308
|
-
const normalizedNextQuery = nextQuery && nextQuery.trim().length ? nextQuery : undefined;
|
|
2309
|
-
if (onChange && !normalizedNextQuery) {
|
|
2310
|
-
onChange(undefined);
|
|
2311
|
-
}
|
|
2312
|
-
if (onQuery) {
|
|
2313
|
-
onQuery(normalizedNextQuery);
|
|
2314
|
-
}
|
|
2315
|
-
}, [onChange, onQuery, queryMap, queryUrl]);
|
|
2316
|
-
const handleSelect = useCallback((nextValue) => {
|
|
2317
|
-
if (onChange) {
|
|
2318
|
-
onChange(nextValue);
|
|
2319
|
-
}
|
|
2320
|
-
setDefaultControlledValue(nextValue);
|
|
2321
|
-
}, [onChange]);
|
|
2322
|
-
useEffect(() => {
|
|
2323
|
-
if (defaultValue === prevDefaultValuePropRef.current) {
|
|
2324
|
-
return;
|
|
2325
|
-
}
|
|
2326
|
-
setDefaultControlledValue(defaultValue);
|
|
2327
|
-
}, [defaultValue]);
|
|
2328
|
-
return (jsxs(Field$2, { children: [jsx(Label, { htmlFor: originalProps.name, isHidden: isLabelHidden, children: label }), jsx(StyledAutoComplete, { "$isLight": isLight, data: controlledOptions, defaultValue: controlledValueAsLabel, id: originalProps.name, onChange: handleChange, onSelect: handleSelect, ...originalProps }, key)] }));
|
|
2329
|
-
}
|
|
2330
|
-
const StyledAutoComplete = styled(AutoComplete$1) `
|
|
2293
|
+
const FieldError = styled.p `
|
|
2294
|
+
color: ${p => p.theme.color.maximumRed};
|
|
2295
|
+
display: ${p => (p.isDisabled ? 'none' : 'block')};
|
|
2331
2296
|
font-size: 13px;
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
border: 0;
|
|
2336
|
-
font-size: 13px;
|
|
2337
|
-
width: 100%;
|
|
2338
|
-
}
|
|
2339
|
-
`;
|
|
2340
|
-
|
|
2341
|
-
function Checkbox({ label, onChange, ...originalProps }) {
|
|
2342
|
-
const key = useMemo(() => `${originalProps.name}-${String(originalProps.defaultChecked)}`, [originalProps.defaultChecked, originalProps.name]);
|
|
2343
|
-
const handleChange = useCallback((_, isChecked) => {
|
|
2344
|
-
if (!onChange) {
|
|
2345
|
-
return;
|
|
2346
|
-
}
|
|
2347
|
-
onChange(isChecked);
|
|
2348
|
-
}, [onChange]);
|
|
2349
|
-
return (jsx(StyledCheckbox, { id: originalProps.name, onChange: handleChange, ...originalProps, children: label }, key));
|
|
2350
|
-
}
|
|
2351
|
-
const StyledCheckbox = styled(Checkbox$1) `
|
|
2352
|
-
> .rs-checkbox-checker {
|
|
2353
|
-
min-height: 0;
|
|
2354
|
-
padding-left: 28px;
|
|
2355
|
-
padding-top: 0;
|
|
2356
|
-
|
|
2357
|
-
.rs-checkbox-wrapper {
|
|
2358
|
-
left: 2px;
|
|
2359
|
-
top: 2px !important;
|
|
2360
|
-
}
|
|
2361
|
-
}
|
|
2297
|
+
font-weight: 700;
|
|
2298
|
+
line-height: 1.3846;
|
|
2299
|
+
margin-top: 4px;
|
|
2362
2300
|
`;
|
|
2363
2301
|
|
|
2364
2302
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
@@ -2815,6 +2753,122 @@ function useForceUpdate() {
|
|
|
2815
2753
|
return { forceDebouncedUpdate, forceUpdate };
|
|
2816
2754
|
}
|
|
2817
2755
|
|
|
2756
|
+
/**
|
|
2757
|
+
* Trim and single-space a string
|
|
2758
|
+
*/
|
|
2759
|
+
function cleanString(text) {
|
|
2760
|
+
return text.replace(/\s+/g, ' ').trim();
|
|
2761
|
+
}
|
|
2762
|
+
|
|
2763
|
+
/**
|
|
2764
|
+
* Normalize a string, making them undefined if empty-ish
|
|
2765
|
+
*/
|
|
2766
|
+
function normalizeString(text) {
|
|
2767
|
+
if (!text) {
|
|
2768
|
+
return undefined;
|
|
2769
|
+
}
|
|
2770
|
+
const cleanText = cleanString(text);
|
|
2771
|
+
return cleanText.length > 0 ? cleanText : undefined;
|
|
2772
|
+
}
|
|
2773
|
+
|
|
2774
|
+
function AutoComplete({ defaultValue, error, isLabelHidden, isLight = false, label, onChange, onQuery, options, queryMap, queryUrl, ...originalProps }) {
|
|
2775
|
+
// eslint-disable-next-line no-null/no-null
|
|
2776
|
+
const boxRef = useRef(null);
|
|
2777
|
+
const prevDefaultValuePropRef = useRef(defaultValue);
|
|
2778
|
+
const [controlledDefaultValue, setDefaultControlledValue] = useState(defaultValue);
|
|
2779
|
+
const [autoGeneratedOptions, setAutoGeneratedOptions] = useState([]);
|
|
2780
|
+
const { forceUpdate } = useForceUpdate();
|
|
2781
|
+
const controlledError = useMemo(() => normalizeString(error), [error]);
|
|
2782
|
+
const controlledOptions = useMemo(() => options ?? autoGeneratedOptions, [autoGeneratedOptions, options]);
|
|
2783
|
+
const controlledValueAsLabel = useMemo(() => {
|
|
2784
|
+
const foundOption = controlledOptions.find(propEq('value', controlledDefaultValue));
|
|
2785
|
+
return foundOption ? foundOption.label : undefined;
|
|
2786
|
+
}, [controlledDefaultValue, controlledOptions]);
|
|
2787
|
+
const hasError = useMemo(() => Boolean(controlledError), [controlledError]);
|
|
2788
|
+
const key = useMemo(() => `${originalProps.name}-${JSON.stringify(controlledDefaultValue)}`, [controlledDefaultValue, originalProps.name]);
|
|
2789
|
+
const handleChange = useCallback(async (nextQuery) => {
|
|
2790
|
+
if (queryUrl && queryMap) {
|
|
2791
|
+
const url = queryUrl.replace('%s', nextQuery);
|
|
2792
|
+
const rawData = await ky$1.get(url).json();
|
|
2793
|
+
const nextData = rawData.map(queryMap);
|
|
2794
|
+
setAutoGeneratedOptions(nextData);
|
|
2795
|
+
}
|
|
2796
|
+
const normalizedNextQuery = nextQuery && nextQuery.trim().length ? nextQuery : undefined;
|
|
2797
|
+
if (onChange && !normalizedNextQuery) {
|
|
2798
|
+
onChange(undefined);
|
|
2799
|
+
}
|
|
2800
|
+
if (onQuery) {
|
|
2801
|
+
onQuery(normalizedNextQuery);
|
|
2802
|
+
}
|
|
2803
|
+
}, [onChange, onQuery, queryMap, queryUrl]);
|
|
2804
|
+
const handleSelect = useCallback((nextValue) => {
|
|
2805
|
+
if (onChange) {
|
|
2806
|
+
onChange(nextValue);
|
|
2807
|
+
}
|
|
2808
|
+
setDefaultControlledValue(nextValue);
|
|
2809
|
+
}, [onChange]);
|
|
2810
|
+
useEffect(() => {
|
|
2811
|
+
if (defaultValue === prevDefaultValuePropRef.current) {
|
|
2812
|
+
return;
|
|
2813
|
+
}
|
|
2814
|
+
setDefaultControlledValue(defaultValue);
|
|
2815
|
+
}, [defaultValue]);
|
|
2816
|
+
useEffect(() => {
|
|
2817
|
+
forceUpdate();
|
|
2818
|
+
}, [forceUpdate]);
|
|
2819
|
+
return (jsxs(Field$2, { children: [jsx(Label, { hasError: hasError, htmlFor: originalProps.name, isHidden: isLabelHidden, children: label }), jsx(Box$9, { ref: boxRef, children: boxRef.current && (jsx(StyledAutoComplete, { "$isLight": isLight, container: boxRef.current, data: controlledOptions, defaultValue: controlledValueAsLabel, id: originalProps.name, onChange: handleChange, onSelect: handleSelect, ...originalProps }, key)) }), hasError && jsx(FieldError, { children: controlledError })] }));
|
|
2820
|
+
}
|
|
2821
|
+
const StyledAutoComplete = styled(AutoComplete$1) `
|
|
2822
|
+
font-size: 13px;
|
|
2823
|
+
|
|
2824
|
+
> input {
|
|
2825
|
+
background-color: ${p => (p.$isLight ? p.theme.color.white : p.theme.color.gainsboro)};
|
|
2826
|
+
border: 0;
|
|
2827
|
+
font-size: 13px;
|
|
2828
|
+
width: 100%;
|
|
2829
|
+
}
|
|
2830
|
+
`;
|
|
2831
|
+
const Box$9 = styled.div `
|
|
2832
|
+
position: relative;
|
|
2833
|
+
|
|
2834
|
+
> .rs-picker-select {
|
|
2835
|
+
> .rs-picker-toggle {
|
|
2836
|
+
font-size: 13px;
|
|
2837
|
+
|
|
2838
|
+
> .rs-stack {
|
|
2839
|
+
> .rs-stack-item {
|
|
2840
|
+
> .rs-picker-toggle-placeholder {
|
|
2841
|
+
font-size: 13px;
|
|
2842
|
+
}
|
|
2843
|
+
}
|
|
2844
|
+
}
|
|
2845
|
+
}
|
|
2846
|
+
}
|
|
2847
|
+
`;
|
|
2848
|
+
|
|
2849
|
+
function Checkbox({ label, onChange, ...originalProps }) {
|
|
2850
|
+
const key = useMemo(() => `${originalProps.name}-${String(originalProps.defaultChecked)}`, [originalProps.defaultChecked, originalProps.name]);
|
|
2851
|
+
const handleChange = useCallback((_, isChecked) => {
|
|
2852
|
+
if (!onChange) {
|
|
2853
|
+
return;
|
|
2854
|
+
}
|
|
2855
|
+
onChange(isChecked);
|
|
2856
|
+
}, [onChange]);
|
|
2857
|
+
return (jsx(StyledCheckbox, { id: originalProps.name, onChange: handleChange, ...originalProps, children: label }, key));
|
|
2858
|
+
}
|
|
2859
|
+
const StyledCheckbox = styled(Checkbox$1) `
|
|
2860
|
+
> .rs-checkbox-checker {
|
|
2861
|
+
min-height: 0;
|
|
2862
|
+
padding-left: 28px;
|
|
2863
|
+
padding-top: 0;
|
|
2864
|
+
|
|
2865
|
+
.rs-checkbox-wrapper {
|
|
2866
|
+
left: 2px;
|
|
2867
|
+
top: 2px !important;
|
|
2868
|
+
}
|
|
2869
|
+
}
|
|
2870
|
+
`;
|
|
2871
|
+
|
|
2818
2872
|
var dayjs_min = {exports: {}};
|
|
2819
2873
|
|
|
2820
2874
|
var hasRequiredDayjs_min;
|
|
@@ -3437,10 +3491,10 @@ disabled = false, isCompact, isEndDate = false, isForcedFocused, isLight, isStar
|
|
|
3437
3491
|
];
|
|
3438
3492
|
onChange(nextDateTuple, isFilled);
|
|
3439
3493
|
}, [onChange]);
|
|
3440
|
-
return (jsxs(Box$
|
|
3494
|
+
return (jsxs(Box$8, { ref: boxRef, "$hasError": hasFormatError || hasValidationError, "$isCompact": isCompact, "$isDisabled": disabled, "$isFocused": isForcedFocused || isFocused, "$isLight": isLight, children: [jsxs("div", { children: [isStartDate && jsx("span", { children: "Du " }), isEndDate && jsx("span", { children: "Au " }), jsx(NumberInput$1, { ref: dayInputRef, "aria-label": `Jour${isStartDate ? ' de début' : ''}${isEndDate ? ' de fin' : ''}`, defaultValue: defaultValue && formatNumberAsDoubleDigit(defaultValue[2]), disabled: disabled, isLight: isLight, max: 31, min: 1, onBack: onBack, onBlur: handleBlur, onClick: onClick, onFilled: submit, onFocus: handleFocus, onFormatError: handleFormatError, onNext: () => monthInputRef.current.focus(), onPrevious: onPrevious, size: 2 }), "/", jsx(NumberInput$1, { ref: monthInputRef, "aria-label": `Mois${isStartDate ? ' de début' : ''}${isEndDate ? ' de fin' : ''}`, defaultValue: defaultValue && formatNumberAsDoubleDigit(defaultValue[1]), disabled: disabled, isLight: isLight, max: 12, min: 1, onBack: () => dayInputRef.current.focus(), onBlur: handleBlur, onClick: onClick, onFilled: submit, onFocus: handleFocus, onFormatError: handleFormatError, onNext: () => yearInputRef.current.focus(), onPrevious: () => dayInputRef.current.focus(), size: 2 }), "/", jsx(NumberInput$1, { ref: yearInputRef, "aria-label": `Année${isStartDate ? ' de début' : ''}${isEndDate ? ' de fin' : ''}`, defaultValue: defaultValue && defaultValue[0], disabled: disabled, isLight: isLight, max: 2030, min: 2020, onBack: () => monthInputRef.current.focus(), onBlur: handleBlur, onClick: onClick, onFilled: submit, onFocus: handleFocus, onFormatError: handleFormatError, onNext: onNext, onPrevious: () => monthInputRef.current.focus(), size: 4 })] }), !isCompact && jsx(Calendar, {})] }));
|
|
3441
3495
|
}
|
|
3442
3496
|
const DateInput = forwardRef(DateInputWithRef);
|
|
3443
|
-
const Box$
|
|
3497
|
+
const Box$8 = styled.div `
|
|
3444
3498
|
align-items: center;
|
|
3445
3499
|
background-color: ${p => (p.$isLight ? p.theme.color.white : p.theme.color.gainsboro)};
|
|
3446
3500
|
box-shadow: ${p => p.$hasError || p.$isFocused
|
|
@@ -3517,9 +3571,9 @@ function RangedTimePicker({ filter, minutesRange, onChange }) {
|
|
|
3517
3571
|
if (!filteredRangedTimeOptions.length) {
|
|
3518
3572
|
return jsx(Fragment, {});
|
|
3519
3573
|
}
|
|
3520
|
-
return (jsx(Box$
|
|
3574
|
+
return (jsx(Box$7, { onClick: stopMouseEventPropagation, role: "listbox", children: filteredRangedTimeOptions.map(({ label, value }, index) => (jsx(Option, { "aria-selected": false, className: "js-ranged-time-picker-option", isSelected: index === selectedOptionIndex, onClick: () => onChange(value), role: "option", tabIndex: -1, children: spannedLabels[index] }, label))) }));
|
|
3521
3575
|
}
|
|
3522
|
-
const Box$
|
|
3576
|
+
const Box$7 = styled.div `
|
|
3523
3577
|
background-color: ${p => p.theme.color.white};
|
|
3524
3578
|
box-shadow: inset 0px 0px 0px 1px ${p => p.theme.color.lightGray};
|
|
3525
3579
|
display: flex;
|
|
@@ -3656,10 +3710,10 @@ disabled = false, isCompact, isEndDate = false, isLight, isStartDate = false, mi
|
|
|
3656
3710
|
const nextTimeTuple = [hourInputRef.current.value, minuteInputRef.current.value];
|
|
3657
3711
|
onChange(nextTimeTuple);
|
|
3658
3712
|
}, [closeRangedTimePicker, onChange]);
|
|
3659
|
-
return (jsxs(Box$
|
|
3713
|
+
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 }))] }));
|
|
3660
3714
|
}
|
|
3661
3715
|
const TimeInput = forwardRef(TimeInputWithRef);
|
|
3662
|
-
const Box$
|
|
3716
|
+
const Box$6 = styled.div `
|
|
3663
3717
|
background-color: ${p => (p.$isLight ? p.theme.color.white : p.theme.color.gainsboro)};
|
|
3664
3718
|
box-shadow: ${p => p.$hasError || p.$isFocused
|
|
3665
3719
|
? `inset 0px 0px 0px 1px ${p.$hasError ? p.theme.color.maximumRed : p.theme.color.blueGray[100]}`
|
|
@@ -3738,11 +3792,11 @@ function CalendarPicker({ defaultValue, isHistorical, isOpen, onChange }) {
|
|
|
3738
3792
|
// and can be used as a container for <RsuiteDatePicker />
|
|
3739
3793
|
forceUpdate();
|
|
3740
3794
|
}, [forceUpdate]);
|
|
3741
|
-
return (jsx(Box$
|
|
3795
|
+
return (jsx(Box$5, { ref: boxRef, onClick: stopMouseEventPropagation, children: boxRef.current && (jsx(DatePicker$1, { container: boxRef.current, disabledDate: disabledDate, format: "yyyy-MM-dd", locale: RSUITE_CALENDAR_LOCALE, oneTap: true, onSelect: handleSelect, open: isOpen,
|
|
3742
3796
|
// `defaultValue` seems to be immediatly cancelled so we come down to using a controlled `value`
|
|
3743
3797
|
ranges: [], value: defaultValue })) }));
|
|
3744
3798
|
}
|
|
3745
|
-
const Box$
|
|
3799
|
+
const Box$5 = styled.div `
|
|
3746
3800
|
height: 0;
|
|
3747
3801
|
position: relative;
|
|
3748
3802
|
user-select: none;
|
|
@@ -3780,7 +3834,7 @@ const Box$3 = styled.div `
|
|
|
3780
3834
|
border: 0;
|
|
3781
3835
|
font-size: 13px;
|
|
3782
3836
|
height: auto !important;
|
|
3783
|
-
line-height: 1.
|
|
3837
|
+
line-height: 1.3846;
|
|
3784
3838
|
padding: 0;
|
|
3785
3839
|
|
|
3786
3840
|
> .rs-calendar-header {
|
|
@@ -3994,9 +4048,9 @@ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false
|
|
|
3994
4048
|
window.document.removeEventListener('click', handleClickOutside);
|
|
3995
4049
|
};
|
|
3996
4050
|
}, [handleClickOutside]);
|
|
3997
|
-
return (jsxs(Fieldset, { disabled: disabled, ...nativeProps, children: [jsx(Legend, { isDisabled: disabled, isHidden: isLabelHidden, children: label }), jsxs(Box$
|
|
4051
|
+
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: selectedDateTupleRef.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, defaultValue: selectedTimeTupleRef.current, disabled: disabled, isCompact: isCompact, isLight: isLight, minutesRange: minutesRange, onBack: () => dateInputRef.current.focus(true), onChange: handleTimeInputFilled, onFocus: closeCalendarPicker, onPrevious: () => dateInputRef.current.focus(true) }) }))] }), jsx(CalendarPicker, { defaultValue: rangeCalendarPickerDefaultValue, isHistorical: isHistorical, isOpen: isCalendarPickerOpenRef.current, onChange: handleCalendarPickerChange })] }));
|
|
3998
4052
|
}
|
|
3999
|
-
const Box$
|
|
4053
|
+
const Box$4 = styled.div `
|
|
4000
4054
|
* {
|
|
4001
4055
|
font-weight: 500;
|
|
4002
4056
|
line-height: 1;
|
|
@@ -4042,11 +4096,11 @@ function RangeCalendarPicker({ defaultValue, isHistorical, isOpen, onChange }) {
|
|
|
4042
4096
|
// and can be used as a container for <RsuiteDateRangePicker />
|
|
4043
4097
|
forceUpdate();
|
|
4044
4098
|
}, [forceUpdate]);
|
|
4045
|
-
return (jsx(Box$
|
|
4099
|
+
return (jsx(Box$3, { ref: boxRef, onClick: stopMouseEventPropagation, children: boxRef.current && (jsx(DateRangePicker$1, { container: boxRef.current, disabledDate: disabledDate, format: "yyyy-MM-dd", locale: RSUITE_CALENDAR_LOCALE, onSelect: handleSelect, open: isOpen, ranges: [],
|
|
4046
4100
|
// `defaultValue` seems to be immediatly cancelled so we come down to using a controlled `value`
|
|
4047
4101
|
value: controlledValue })) }));
|
|
4048
4102
|
}
|
|
4049
|
-
const Box$
|
|
4103
|
+
const Box$3 = styled.div `
|
|
4050
4104
|
height: 0;
|
|
4051
4105
|
position: relative;
|
|
4052
4106
|
user-select: none;
|
|
@@ -4087,7 +4141,7 @@ const Box$1 = styled.div `
|
|
|
4087
4141
|
> .rs-calendar {
|
|
4088
4142
|
font-size: 13px;
|
|
4089
4143
|
height: auto !important;
|
|
4090
|
-
line-height: 1.
|
|
4144
|
+
line-height: 1.3846;
|
|
4091
4145
|
padding: 0;
|
|
4092
4146
|
|
|
4093
4147
|
&:first-child {
|
|
@@ -4370,9 +4424,9 @@ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false
|
|
|
4370
4424
|
window.document.removeEventListener('click', handleClickOutside);
|
|
4371
4425
|
};
|
|
4372
4426
|
}, [handleClickOutside]);
|
|
4373
|
-
return (jsxs(Fieldset, { ...nativeProps, children: [jsx(Legend, { isDisabled: disabled, isHidden: isLabelHidden, children: label }), jsxs(Box, { isDisabled: disabled, children: [jsx(Field, { children: jsx(DateInput, { ref: startDateInputRef, defaultValue: selectedStartDateTupleRef.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, defaultValue: selectedStartTimeTupleRef.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: selectedEndDateTupleRef.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, defaultValue: selectedEndTimeTupleRef.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) }) }))] }), jsx(RangeCalendarPicker, { defaultValue: rangeCalendarPickerDefaultValue, isHistorical: isHistorical, isOpen: isRangeCalendarPickerOpenRef.current, onChange: handleRangeCalendarPickerChange })] }));
|
|
4427
|
+
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: selectedStartDateTupleRef.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, defaultValue: selectedStartTimeTupleRef.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: selectedEndDateTupleRef.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, defaultValue: selectedEndTimeTupleRef.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) }) }))] }), jsx(RangeCalendarPicker, { defaultValue: rangeCalendarPickerDefaultValue, isHistorical: isHistorical, isOpen: isRangeCalendarPickerOpenRef.current, onChange: handleRangeCalendarPickerChange })] }));
|
|
4374
4428
|
}
|
|
4375
|
-
const Box = styled.div `
|
|
4429
|
+
const Box$2 = styled.div `
|
|
4376
4430
|
* {
|
|
4377
4431
|
font-weight: 500;
|
|
4378
4432
|
line-height: 1;
|
|
@@ -4438,9 +4492,14 @@ const ChecboxesBox$1 = styled.div `
|
|
|
4438
4492
|
`}
|
|
4439
4493
|
`;
|
|
4440
4494
|
|
|
4441
|
-
function MultiSelect({ fixedWidth = 5, isLabelHidden = false, isLight = false, label, onChange, options,
|
|
4495
|
+
function MultiSelect({ error, fixedWidth = 5, isLabelHidden = false, isLight = false, label, onChange, options,
|
|
4442
4496
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
4443
4497
|
searchable = false, ...originalProps }) {
|
|
4498
|
+
// eslint-disable-next-line no-null/no-null
|
|
4499
|
+
const boxRef = useRef(null);
|
|
4500
|
+
const { forceUpdate } = useForceUpdate();
|
|
4501
|
+
const controlledError = useMemo(() => normalizeString(error), [error]);
|
|
4502
|
+
const hasError = useMemo(() => Boolean(controlledError), [controlledError]);
|
|
4444
4503
|
const key = useMemo(() => `${originalProps.name}-${JSON.stringify(originalProps.defaultValue)}`, [originalProps.defaultValue, originalProps.name]);
|
|
4445
4504
|
const handleChange = useCallback((nextValue) => {
|
|
4446
4505
|
if (!onChange) {
|
|
@@ -4449,7 +4508,10 @@ searchable = false, ...originalProps }) {
|
|
|
4449
4508
|
const normalizedNextValue = !nextValue || !nextValue.length ? undefined : nextValue;
|
|
4450
4509
|
onChange(normalizedNextValue);
|
|
4451
4510
|
}, [onChange]);
|
|
4452
|
-
|
|
4511
|
+
useEffect(() => {
|
|
4512
|
+
forceUpdate();
|
|
4513
|
+
}, [forceUpdate]);
|
|
4514
|
+
return (jsxs(Field$2, { children: [jsx(Label, { hasError: hasError, htmlFor: originalProps.name, isHidden: isLabelHidden, children: label }), jsx(Box$1, { ref: boxRef, children: boxRef.current && (jsx(StyledTagPicker, { "$fixedWidth": fixedWidth, "$isLight": isLight, container: boxRef.current, data: options, id: originalProps.name, onChange: handleChange, searchable: searchable, ...originalProps }, key)) }), hasError && jsx(FieldError, { children: controlledError })] }));
|
|
4453
4515
|
}
|
|
4454
4516
|
// TODO A width seems to be mandatory in rsuite which is a very dirty behavior.
|
|
4455
4517
|
// We should hack that.
|
|
@@ -4463,6 +4525,54 @@ const StyledTagPicker = styled(TagPicker) `
|
|
|
4463
4525
|
cursor: inherit;
|
|
4464
4526
|
}
|
|
4465
4527
|
`;
|
|
4528
|
+
const Box$1 = styled.div `
|
|
4529
|
+
position: relative;
|
|
4530
|
+
|
|
4531
|
+
> .rs-picker-input {
|
|
4532
|
+
> .rs-picker-toggle {
|
|
4533
|
+
border: solid 1px ${p => p.theme.color.gainsboro} !important;
|
|
4534
|
+
font-size: 13px;
|
|
4535
|
+
line-height: 1.3846;
|
|
4536
|
+
padding: 5px 40px 5px 8px !important;
|
|
4537
|
+
|
|
4538
|
+
:hover {
|
|
4539
|
+
border: solid 1px ${p => p.theme.color.blueYonder[100]} !important;
|
|
4540
|
+
}
|
|
4541
|
+
|
|
4542
|
+
:active,
|
|
4543
|
+
:focus {
|
|
4544
|
+
border: solid 1px ${p => p.theme.color.blueGray[100]} !important;
|
|
4545
|
+
}
|
|
4546
|
+
|
|
4547
|
+
> .rs-stack {
|
|
4548
|
+
> .rs-stack-item {
|
|
4549
|
+
> .rs-picker-toggle-placeholder {
|
|
4550
|
+
font-size: 13px;
|
|
4551
|
+
line-height: 1.3846;
|
|
4552
|
+
}
|
|
4553
|
+
|
|
4554
|
+
> svg {
|
|
4555
|
+
height: 18px;
|
|
4556
|
+
/* margin-top: -2px; */
|
|
4557
|
+
}
|
|
4558
|
+
}
|
|
4559
|
+
}
|
|
4560
|
+
}
|
|
4561
|
+
|
|
4562
|
+
> .rs-picker-tag-wrapper {
|
|
4563
|
+
.rs-picker-search {
|
|
4564
|
+
.rs-picker-search-input {
|
|
4565
|
+
padding: 0 8px !important;
|
|
4566
|
+
|
|
4567
|
+
input {
|
|
4568
|
+
font-size: 13px;
|
|
4569
|
+
line-height: 1.3846;
|
|
4570
|
+
}
|
|
4571
|
+
}
|
|
4572
|
+
}
|
|
4573
|
+
}
|
|
4574
|
+
}
|
|
4575
|
+
`;
|
|
4466
4576
|
|
|
4467
4577
|
function MultiRadio({ defaultValue, isInline = false, isLabelHidden = false, isLight = false, label, name, onChange, options }) {
|
|
4468
4578
|
const [checkedOptionValue, setCheckedOptionValue] = useState(undefined);
|
|
@@ -4596,9 +4706,14 @@ const StyledInput$2 = styled(Input) `
|
|
|
4596
4706
|
width: 100%;
|
|
4597
4707
|
`;
|
|
4598
4708
|
|
|
4599
|
-
function Select({ isLabelHidden = false, isLight = false, label, onChange, options,
|
|
4709
|
+
function Select({ error, isLabelHidden = false, isLight = false, label, onChange, options,
|
|
4600
4710
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
4601
4711
|
searchable = false, ...originalProps }) {
|
|
4712
|
+
// eslint-disable-next-line no-null/no-null
|
|
4713
|
+
const boxRef = useRef(null);
|
|
4714
|
+
const { forceUpdate } = useForceUpdate();
|
|
4715
|
+
const controlledError = useMemo(() => normalizeString(error), [error]);
|
|
4716
|
+
const hasError = useMemo(() => Boolean(controlledError), [controlledError]);
|
|
4602
4717
|
const key = useMemo(() => `${originalProps.name}-${JSON.stringify(originalProps.defaultValue)}`, [originalProps.defaultValue, originalProps.name]);
|
|
4603
4718
|
const handleChange = useCallback((nextValue) => {
|
|
4604
4719
|
if (!onChange) {
|
|
@@ -4607,10 +4722,13 @@ searchable = false, ...originalProps }) {
|
|
|
4607
4722
|
const normalizedNextValue = nextValue ?? undefined;
|
|
4608
4723
|
onChange(normalizedNextValue);
|
|
4609
4724
|
}, [onChange]);
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4725
|
+
useEffect(() => {
|
|
4726
|
+
forceUpdate();
|
|
4727
|
+
}, [forceUpdate]);
|
|
4728
|
+
return (jsxs(Field$2, { children: [jsx(Label, { hasError: hasError, htmlFor: originalProps.name, isHidden: isLabelHidden, children: label }), jsx(Box, { ref: boxRef, children: boxRef.current && (jsx(StyledSelectPicker, { "$isLight": isLight, container: boxRef.current, data: options, id: originalProps.name,
|
|
4729
|
+
// The `unknown` type from Rsuite library is wrong. It should be inferred from `data` prop type.
|
|
4730
|
+
// `onChange: ((value: unknown, event: React.SyntheticEvent<Element, Event>) => void) | undefined`
|
|
4731
|
+
onChange: handleChange, searchable: searchable, ...originalProps }, key)) }), hasError && jsx(FieldError, { children: controlledError })] }));
|
|
4614
4732
|
}
|
|
4615
4733
|
const StyledSelectPicker = styled(SelectPicker) `
|
|
4616
4734
|
> .rs-picker-toggle {
|
|
@@ -4618,6 +4736,41 @@ const StyledSelectPicker = styled(SelectPicker) `
|
|
|
4618
4736
|
border: 0;
|
|
4619
4737
|
}
|
|
4620
4738
|
`;
|
|
4739
|
+
const Box = styled.div `
|
|
4740
|
+
position: relative;
|
|
4741
|
+
|
|
4742
|
+
> .rs-picker-select {
|
|
4743
|
+
> .rs-picker-toggle {
|
|
4744
|
+
border: solid 1px ${p => p.theme.color.gainsboro} !important;
|
|
4745
|
+
font-size: 13px;
|
|
4746
|
+
line-height: 1.3846;
|
|
4747
|
+
padding: 4px 40px 6px 8px;
|
|
4748
|
+
|
|
4749
|
+
:hover {
|
|
4750
|
+
border: solid 1px ${p => p.theme.color.blueYonder[100]} !important;
|
|
4751
|
+
}
|
|
4752
|
+
|
|
4753
|
+
:active,
|
|
4754
|
+
:focus {
|
|
4755
|
+
border: solid 1px ${p => p.theme.color.blueGray[100]} !important;
|
|
4756
|
+
}
|
|
4757
|
+
|
|
4758
|
+
> .rs-stack {
|
|
4759
|
+
> .rs-stack-item {
|
|
4760
|
+
> .rs-picker-toggle-placeholder {
|
|
4761
|
+
font-size: 13px;
|
|
4762
|
+
line-height: 1.3846;
|
|
4763
|
+
}
|
|
4764
|
+
|
|
4765
|
+
> svg {
|
|
4766
|
+
height: 18px;
|
|
4767
|
+
margin-top: -2px;
|
|
4768
|
+
}
|
|
4769
|
+
}
|
|
4770
|
+
}
|
|
4771
|
+
}
|
|
4772
|
+
}
|
|
4773
|
+
`;
|
|
4621
4774
|
|
|
4622
4775
|
function Textarea({ isLabelHidden = false, isLight = false, label, onChange, rows = 3, ...originalProps }) {
|
|
4623
4776
|
const inputRef = useRef();
|
|
@@ -4731,10 +4884,11 @@ function FormikNumberInput({ name, ...originalProps }) {
|
|
|
4731
4884
|
}
|
|
4732
4885
|
|
|
4733
4886
|
function FormikSelect({ name, ...originalProps }) {
|
|
4734
|
-
const [field, , helpers] = useField(name);
|
|
4887
|
+
const [field, meta, helpers] = useField(name);
|
|
4735
4888
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4736
4889
|
const defaultValue = useMemo(() => field.value, []);
|
|
4737
|
-
|
|
4890
|
+
const error = useMemo(() => (meta.initialTouched ? meta.error : undefined), [meta.error, meta.initialTouched]);
|
|
4891
|
+
return jsx(Select, { defaultValue: defaultValue, error: error, name: name, onChange: helpers.setValue, ...originalProps });
|
|
4738
4892
|
}
|
|
4739
4893
|
|
|
4740
4894
|
function FormikTextarea({ name, ...originalProps }) {
|