@mtes-mct/monitor-ui 2.0.0 → 2.1.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 +12 -0
- package/elements/Fieldset.d.ts +5 -3
- package/fields/DatePicker/index.d.ts +2 -1
- package/fields/DateRangePicker/DateInput.d.ts +2 -0
- package/fields/DateRangePicker/TimeInput.d.ts +2 -0
- package/fields/DateRangePicker/index.d.ts +2 -1
- package/fields/MultiCheckbox.d.ts +2 -1
- package/fields/MultiRadio.d.ts +2 -1
- package/fields/MultiZoneEditor/index.d.ts +15 -0
- package/index.d.ts +2 -0
- package/index.js +344 -254
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1145,6 +1145,35 @@ _curry2(function reject(pred, filterable) {
|
|
|
1145
1145
|
return filter(_complement(pred), filterable);
|
|
1146
1146
|
});
|
|
1147
1147
|
|
|
1148
|
+
/**
|
|
1149
|
+
* Removes the sub-list of `list` starting at index `start` and containing
|
|
1150
|
+
* `count` elements. _Note that this is not destructive_: it returns a copy of
|
|
1151
|
+
* the list with the changes.
|
|
1152
|
+
* <small>No lists have been harmed in the application of this function.</small>
|
|
1153
|
+
*
|
|
1154
|
+
* @func
|
|
1155
|
+
* @memberOf R
|
|
1156
|
+
* @since v0.2.2
|
|
1157
|
+
* @category List
|
|
1158
|
+
* @sig Number -> Number -> [a] -> [a]
|
|
1159
|
+
* @param {Number} start The position to start removing elements
|
|
1160
|
+
* @param {Number} count The number of elements to remove
|
|
1161
|
+
* @param {Array} list The list to remove from
|
|
1162
|
+
* @return {Array} A new Array with `count` elements from `start` removed.
|
|
1163
|
+
* @see R.without
|
|
1164
|
+
* @example
|
|
1165
|
+
*
|
|
1166
|
+
* R.remove(2, 3, [1,2,3,4,5,6,7,8]); //=> [1,2,6,7,8]
|
|
1167
|
+
*/
|
|
1168
|
+
|
|
1169
|
+
var remove =
|
|
1170
|
+
/*#__PURE__*/
|
|
1171
|
+
_curry3(function remove(start, count, list) {
|
|
1172
|
+
var result = Array.prototype.slice.call(list, 0);
|
|
1173
|
+
result.splice(start, count);
|
|
1174
|
+
return result;
|
|
1175
|
+
});
|
|
1176
|
+
|
|
1148
1177
|
/**
|
|
1149
1178
|
* Creates a new object with the own properties of the two provided objects. If
|
|
1150
1179
|
* a key exists in both objects, the provided function is applied to the key
|
|
@@ -1511,15 +1540,38 @@ const Field$2 = styled.div `
|
|
|
1511
1540
|
flex-direction: column;
|
|
1512
1541
|
`;
|
|
1513
1542
|
|
|
1514
|
-
|
|
1515
|
-
|
|
1543
|
+
const Label = styled.label `
|
|
1544
|
+
color: ${p => p.theme.color.slateGray};
|
|
1545
|
+
display: ${p => (p.isHidden ? 'none' : 'table')};
|
|
1546
|
+
font-size: 13px;
|
|
1547
|
+
line-height: 1.4;
|
|
1548
|
+
margin-bottom: 8px;
|
|
1549
|
+
`;
|
|
1550
|
+
|
|
1551
|
+
function Legend({ isHidden = false, ...nativeProps }) {
|
|
1552
|
+
return jsx(StyledLabel, { as: "legend", isHidden: isHidden, ...nativeProps });
|
|
1516
1553
|
}
|
|
1517
|
-
const
|
|
1518
|
-
|
|
1554
|
+
const StyledLabel = styled(Label) `
|
|
1555
|
+
padding: 0;
|
|
1556
|
+
`;
|
|
1519
1557
|
|
|
1558
|
+
function Fieldset({ children, hasBorder = false, isHidden = false, isLight = false, legend, ...nativeProps }) {
|
|
1559
|
+
const hasLegend = useMemo(() => Boolean(legend), [legend]);
|
|
1560
|
+
return (jsxs(StyledField, { as: "fieldset", ...nativeProps, children: [legend && jsx(Legend, { isHidden: isHidden, children: legend }), jsx(Box$8, { "$hasBorder": hasBorder, "$hasLegend": hasLegend, "$isLight": isLight, children: children })] }));
|
|
1561
|
+
}
|
|
1562
|
+
const StyledField = styled(Field$2) `
|
|
1520
1563
|
border: 0;
|
|
1521
1564
|
margin: 0;
|
|
1522
|
-
padding:
|
|
1565
|
+
padding: 0;
|
|
1566
|
+
`;
|
|
1567
|
+
const Box$8 = styled.div `
|
|
1568
|
+
background-color: ${p => (p.$isLight ? p.theme.color.white : 'transparent')};
|
|
1569
|
+
padding: ${p => (p.$hasBorder || p.$isLight ? '16px' : 0)};
|
|
1570
|
+
|
|
1571
|
+
${p => p.$hasBorder &&
|
|
1572
|
+
css `
|
|
1573
|
+
border: solid 1px ${p.$isLight ? p.theme.color.white : p.theme.color.gainsboro};
|
|
1574
|
+
`}
|
|
1523
1575
|
`;
|
|
1524
1576
|
|
|
1525
1577
|
const ICON_SIZE_IN_PX = {
|
|
@@ -1582,21 +1634,6 @@ const TertiaryButton = styled.button `
|
|
|
1582
1634
|
}
|
|
1583
1635
|
`;
|
|
1584
1636
|
|
|
1585
|
-
const Label = styled.label `
|
|
1586
|
-
color: ${p => p.theme.color.slateGray};
|
|
1587
|
-
display: ${p => (p.isHidden ? 'none' : 'table')};
|
|
1588
|
-
font-size: 13px;
|
|
1589
|
-
line-height: 1.4;
|
|
1590
|
-
margin-bottom: 8px;
|
|
1591
|
-
`;
|
|
1592
|
-
|
|
1593
|
-
function Legend({ isHidden = false, ...nativeProps }) {
|
|
1594
|
-
return jsx(StyledLabel, { as: "legend", isHidden: isHidden, ...nativeProps });
|
|
1595
|
-
}
|
|
1596
|
-
const StyledLabel = styled(Label) `
|
|
1597
|
-
padding: 0;
|
|
1598
|
-
`;
|
|
1599
|
-
|
|
1600
1637
|
var TagBullet;
|
|
1601
1638
|
(function (TagBullet) {
|
|
1602
1639
|
TagBullet["DISK"] = "DISK";
|
|
@@ -2249,11 +2286,11 @@ const StyledCheckbox = styled(Checkbox$1) `
|
|
|
2249
2286
|
> .rs-checkbox-checker {
|
|
2250
2287
|
min-height: 0;
|
|
2251
2288
|
padding-left: 28px;
|
|
2252
|
-
padding-top:
|
|
2289
|
+
padding-top: 0;
|
|
2253
2290
|
|
|
2254
2291
|
.rs-checkbox-wrapper {
|
|
2255
2292
|
left: 2px;
|
|
2256
|
-
top:
|
|
2293
|
+
top: 2px !important;
|
|
2257
2294
|
}
|
|
2258
2295
|
}
|
|
2259
2296
|
`;
|
|
@@ -2841,7 +2878,7 @@ function NumberInputWithRef({ defaultValue, max, min, onBack, onClick, onFilled,
|
|
|
2841
2878
|
onBack();
|
|
2842
2879
|
}
|
|
2843
2880
|
}, [onBack, onNext, onPrevious]);
|
|
2844
|
-
return (jsx(StyledNumberInput, { ref: inputRef, defaultValue: defaultValue, maxLength: size, onClick: handleClick, onFocus: handleFocus, onInput: handleInput, onKeyDown: handleKeyDown, pattern: "\\d*", placeholder: placeholder,
|
|
2881
|
+
return (jsx(StyledNumberInput, { ref: inputRef, "$size": size, defaultValue: defaultValue, maxLength: size, onClick: handleClick, onFocus: handleFocus, onInput: handleInput, onKeyDown: handleKeyDown, pattern: "\\d*", placeholder: placeholder, type: "text", ...nativeProps }, String(defaultValue)));
|
|
2845
2882
|
}
|
|
2846
2883
|
const NumberInput = forwardRef(NumberInputWithRef);
|
|
2847
2884
|
const StyledNumberInput = styled.input `
|
|
@@ -2852,7 +2889,7 @@ const StyledNumberInput = styled.input `
|
|
|
2852
2889
|
padding: 0;
|
|
2853
2890
|
text-align: center;
|
|
2854
2891
|
/* 1 digit = 8px */
|
|
2855
|
-
width: ${p => p
|
|
2892
|
+
width: ${p => p.$size * 0.5}rem;
|
|
2856
2893
|
|
|
2857
2894
|
::placeholder {
|
|
2858
2895
|
color: ${p => p.theme.color.slateGray};
|
|
@@ -2927,7 +2964,7 @@ function getTimeTupleFromDate(date) {
|
|
|
2927
2964
|
return [formatNumberAsDoubleDigit(date.getHours()), formatNumberAsDoubleDigit(date.getMinutes())];
|
|
2928
2965
|
}
|
|
2929
2966
|
|
|
2930
|
-
function DateInputWithRef({ defaultValue, isEndDate = false, isForcedFocused, isStartDate = false, onBack, onChange, onClick, onNext, onPrevious }, ref) {
|
|
2967
|
+
function DateInputWithRef({ defaultValue, isEndDate = false, isForcedFocused, isLight, isStartDate = false, onBack, onChange, onClick, onNext, onPrevious }, ref) {
|
|
2931
2968
|
const boxSpanRef = useRef();
|
|
2932
2969
|
const dayInputRef = useRef();
|
|
2933
2970
|
const monthInputRef = useRef();
|
|
@@ -2983,13 +3020,13 @@ function DateInputWithRef({ defaultValue, isEndDate = false, isForcedFocused, is
|
|
|
2983
3020
|
];
|
|
2984
3021
|
onChange(nextDateTuple);
|
|
2985
3022
|
}, [onChange]);
|
|
2986
|
-
return (jsxs(Box$6, { ref: boxSpanRef, hasError: hasFormatError || hasValidationError, isFocused: isForcedFocused || isFocused, children: [isStartDate && 'Du ', isEndDate && 'Au ', jsx(NumberInput, { ref: dayInputRef, "data-cy": `date-range-picker-${isStartDate ? 'start' : 'end'}-day`, defaultValue: defaultValue && formatNumberAsDoubleDigit(defaultValue[2]), 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, { ref: monthInputRef, "data-cy": `date-range-picker-${isStartDate ? 'start' : 'end'}-month`, defaultValue: defaultValue && formatNumberAsDoubleDigit(defaultValue[1]), 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, { ref: yearInputRef, "data-cy": `date-range-picker-${isStartDate ? 'start' : 'end'}-year`, defaultValue: defaultValue && defaultValue[0], max: currentUtcYear, min: 2020, onBack: () => monthInputRef.current.focus(), onBlur: handleBlur, onClick: onClick, onFilled: submit, onFocus: handleFocus, onFormatError: handleFormatError, onNext: onNext, onPrevious: () => monthInputRef.current.focus(), size: 4 })] }));
|
|
3023
|
+
return (jsxs(Box$6, { ref: boxSpanRef, "$hasError": hasFormatError || hasValidationError, "$isFocused": isForcedFocused || isFocused, "$isLight": isLight, children: [isStartDate && 'Du ', isEndDate && 'Au ', jsx(NumberInput, { ref: dayInputRef, "data-cy": `date-range-picker-${isStartDate ? 'start' : 'end'}-day`, defaultValue: defaultValue && formatNumberAsDoubleDigit(defaultValue[2]), 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, { ref: monthInputRef, "data-cy": `date-range-picker-${isStartDate ? 'start' : 'end'}-month`, defaultValue: defaultValue && formatNumberAsDoubleDigit(defaultValue[1]), 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, { ref: yearInputRef, "data-cy": `date-range-picker-${isStartDate ? 'start' : 'end'}-year`, defaultValue: defaultValue && defaultValue[0], max: currentUtcYear, min: 2020, onBack: () => monthInputRef.current.focus(), onBlur: handleBlur, onClick: onClick, onFilled: submit, onFocus: handleFocus, onFormatError: handleFormatError, onNext: onNext, onPrevious: () => monthInputRef.current.focus(), size: 4 })] }));
|
|
2987
3024
|
}
|
|
2988
3025
|
const DateInput = forwardRef(DateInputWithRef);
|
|
2989
3026
|
const Box$6 = styled.span `
|
|
2990
|
-
background-color: ${p => p.theme.color.gainsboro};
|
|
2991
|
-
box-shadow: ${p => p
|
|
2992
|
-
? `inset 0px 0px 0px 1px ${p
|
|
3027
|
+
background-color: ${p => (p.$isLight ? p.theme.color.white : p.theme.color.gainsboro)};
|
|
3028
|
+
box-shadow: ${p => p.$hasError || p.$isFocused
|
|
3029
|
+
? `inset 0px 0px 0px 1px ${p.$hasError ? p.theme.color.maximumRed : p.theme.color.blueGray[100]}`
|
|
2993
3030
|
: 'none'};
|
|
2994
3031
|
color: ${p => p.theme.color.slateGray};
|
|
2995
3032
|
display: inline-block;
|
|
@@ -3719,7 +3756,7 @@ const Option = styled.div `
|
|
|
3719
3756
|
}
|
|
3720
3757
|
`;
|
|
3721
3758
|
|
|
3722
|
-
function TimeInputWithRef({ defaultValue, isStartDate = false, minutesRange = 15, onBack, onChange, onFocus, onNext, onPrevious }, ref) {
|
|
3759
|
+
function TimeInputWithRef({ defaultValue, isLight, isStartDate = false, minutesRange = 15, onBack, onChange, onFocus, onNext, onPrevious }, ref) {
|
|
3723
3760
|
const boxSpanRef = useRef();
|
|
3724
3761
|
const hourInputRef = useRef();
|
|
3725
3762
|
const minuteInputRef = useRef();
|
|
@@ -3806,13 +3843,13 @@ function TimeInputWithRef({ defaultValue, isStartDate = false, minutesRange = 15
|
|
|
3806
3843
|
const nextTimeTuple = [hourInputRef.current.value, minuteInputRef.current.value];
|
|
3807
3844
|
onChange(nextTimeTuple);
|
|
3808
3845
|
}, [closeRangedTimePicker, onChange]);
|
|
3809
|
-
return (jsxs(Box$3, { ref: boxSpanRef, hasError: hasFormatError || hasValidationError, isFocused: isFocused, children: [jsxs(Fragment, { children: [jsx(NumberInput, { ref: hourInputRef, "data-cy": `date-range-picker-${isStartDate ? 'start' : 'end'}-hour`, defaultValue: controlledDefaultValue && controlledDefaultValue[0], 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, { ref: minuteInputRef, "data-cy": `date-range-picker-${isStartDate ? 'start' : 'end'}-minute`, defaultValue: controlledDefaultValue && controlledDefaultValue[1], 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 })] }), isRangedTimePickerOpenRef.current && (jsx(RangedTimePicker, { filter: rangedTimePickerFilter, minutesRange: minutesRange, onChange: handleRangedTimePickedChange }))] }));
|
|
3846
|
+
return (jsxs(Box$3, { ref: boxSpanRef, "$hasError": hasFormatError || hasValidationError, "$isFocused": isFocused, "$isLight": isLight, children: [jsxs(Fragment, { children: [jsx(NumberInput, { ref: hourInputRef, "data-cy": `date-range-picker-${isStartDate ? 'start' : 'end'}-hour`, defaultValue: controlledDefaultValue && controlledDefaultValue[0], 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, { ref: minuteInputRef, "data-cy": `date-range-picker-${isStartDate ? 'start' : 'end'}-minute`, defaultValue: controlledDefaultValue && controlledDefaultValue[1], 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 })] }), isRangedTimePickerOpenRef.current && (jsx(RangedTimePicker, { filter: rangedTimePickerFilter, minutesRange: minutesRange, onChange: handleRangedTimePickedChange }))] }));
|
|
3810
3847
|
}
|
|
3811
3848
|
const TimeInput = forwardRef(TimeInputWithRef);
|
|
3812
3849
|
const Box$3 = styled.span `
|
|
3813
|
-
background-color: ${p => p.theme.color.gainsboro};
|
|
3814
|
-
box-shadow: ${p => p
|
|
3815
|
-
? `inset 0px 0px 0px 1px ${p
|
|
3850
|
+
background-color: ${p => (p.$isLight ? p.theme.color.white : p.theme.color.gainsboro)};
|
|
3851
|
+
box-shadow: ${p => p.$hasError || p.$isFocused
|
|
3852
|
+
? `inset 0px 0px 0px 1px ${p.$hasError ? p.theme.color.maximumRed : p.theme.color.blueGray[100]}`
|
|
3816
3853
|
: 'none'};
|
|
3817
3854
|
color: ${p => p.theme.color.slateGray};
|
|
3818
3855
|
display: inline-block;
|
|
@@ -3832,7 +3869,7 @@ var DateRangePosition;
|
|
|
3832
3869
|
DateRangePosition["START"] = "START";
|
|
3833
3870
|
})(DateRangePosition || (DateRangePosition = {}));
|
|
3834
3871
|
|
|
3835
|
-
function DateRangePicker({ defaultValue, isHistorical = false, isLabelHidden = false, label, minutesRange = 15, onChange, withTime = false }) {
|
|
3872
|
+
function DateRangePicker({ defaultValue, isHistorical = false, isLabelHidden = false, isLight = false, label, minutesRange = 15, onChange, withTime = false }) {
|
|
3836
3873
|
const startDateInputRef = useRef();
|
|
3837
3874
|
const startTimeInputRef = useRef();
|
|
3838
3875
|
const endDateInputRef = useRef();
|
|
@@ -3981,7 +4018,7 @@ function DateRangePicker({ defaultValue, isHistorical = false, isLabelHidden = f
|
|
|
3981
4018
|
window.document.removeEventListener('click', handleClickOutside);
|
|
3982
4019
|
};
|
|
3983
4020
|
}, [handleClickOutside]);
|
|
3984
|
-
return (jsxs(Fieldset, { className: "DateRangePicker", children: [jsx(Legend, { isHidden: isLabelHidden, children: label }), jsxs(Box$2, { children: [jsx(Field$1, { children: jsx(DateInput, { ref: startDateInputRef, defaultValue: selectedStartDateTupleRef.current, isForcedFocused: isRangeCalendarPickerOpenRef.current, isStartDate: true, onChange: nextDateTuple => handleDateInputFilled(DateRangePosition.START, nextDateTuple), onClick: openRangeCalendarPicker, onNext: handleStartDateInputNext }) }), withTime && (jsx(Field$1, { isTimeField: true, children: jsx(TimeInput, { ref: startTimeInputRef, defaultValue: selectedStartTimeTupleRef.current, 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$1, { isEndDateField: true, children: jsx(DateInput, { ref: endDateInputRef, defaultValue: selectedEndDateTupleRef.current, isEndDate: true, isForcedFocused: isRangeCalendarPickerOpenRef.current, onBack: handleEndDateInputPrevious, onChange: nextDateTuple => handleDateInputFilled(DateRangePosition.END, nextDateTuple), onClick: openRangeCalendarPicker, onNext: handleEndDateInputNext, onPrevious: handleEndDateInputPrevious }) }), withTime && (jsx(Field$1, { isTimeField: true, children: jsx(TimeInput, { ref: endTimeInputRef, defaultValue: selectedEndTimeTupleRef.current, minutesRange: minutesRange, onBack: () => endDateInputRef.current.focus(true), onChange: nextTimeTuple => handleTimeInputFilled(DateRangePosition.END, nextTimeTuple), onFocus: closeRangeCalendarPicker, onPrevious: () => endDateInputRef.current.focus(true) }) }))] }), isRangeCalendarPickerOpenRef.current && (jsx(RangeCalendarPicker, { defaultValue: rangeCalendarPickerDefaultValue, isHistorical: isHistorical, onChange: handleRangeCalendarPickerChange }))] }));
|
|
4021
|
+
return (jsxs(Fieldset, { className: "DateRangePicker", children: [jsx(Legend, { isHidden: isLabelHidden, children: label }), jsxs(Box$2, { children: [jsx(Field$1, { children: jsx(DateInput, { ref: startDateInputRef, defaultValue: selectedStartDateTupleRef.current, isForcedFocused: isRangeCalendarPickerOpenRef.current, isLight: isLight, isStartDate: true, onChange: nextDateTuple => handleDateInputFilled(DateRangePosition.START, nextDateTuple), onClick: openRangeCalendarPicker, onNext: handleStartDateInputNext }) }), withTime && (jsx(Field$1, { isTimeField: true, children: jsx(TimeInput, { ref: startTimeInputRef, defaultValue: selectedStartTimeTupleRef.current, 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$1, { isEndDateField: true, children: jsx(DateInput, { ref: endDateInputRef, defaultValue: selectedEndDateTupleRef.current, isEndDate: true, isForcedFocused: isRangeCalendarPickerOpenRef.current, isLight: isLight, onBack: handleEndDateInputPrevious, onChange: nextDateTuple => handleDateInputFilled(DateRangePosition.END, nextDateTuple), onClick: openRangeCalendarPicker, onNext: handleEndDateInputNext, onPrevious: handleEndDateInputPrevious }) }), withTime && (jsx(Field$1, { isTimeField: true, children: jsx(TimeInput, { ref: endTimeInputRef, defaultValue: selectedEndTimeTupleRef.current, isLight: isLight, minutesRange: minutesRange, onBack: () => endDateInputRef.current.focus(true), onChange: nextTimeTuple => handleTimeInputFilled(DateRangePosition.END, nextTimeTuple), onFocus: closeRangeCalendarPicker, onPrevious: () => endDateInputRef.current.focus(true) }) }))] }), isRangeCalendarPickerOpenRef.current && (jsx(RangeCalendarPicker, { defaultValue: rangeCalendarPickerDefaultValue, isHistorical: isHistorical, onChange: handleRangeCalendarPickerChange }))] }));
|
|
3985
4022
|
}
|
|
3986
4023
|
const Box$2 = styled.div `
|
|
3987
4024
|
* {
|
|
@@ -4129,7 +4166,7 @@ const Box$1 = styled.div `
|
|
|
4129
4166
|
}
|
|
4130
4167
|
`;
|
|
4131
4168
|
|
|
4132
|
-
function DatePicker({ defaultValue, isHistorical = false, isLabelHidden = false, label, minutesRange = 15, onChange, withTime = false }) {
|
|
4169
|
+
function DatePicker({ defaultValue, isHistorical = false, isLabelHidden = false, isLight = false, label, minutesRange = 15, onChange, withTime = false }) {
|
|
4133
4170
|
const dateInputRef = useRef();
|
|
4134
4171
|
const timeInputRef = useRef();
|
|
4135
4172
|
const isCalendarPickerOpenRef = useRef(false);
|
|
@@ -4218,7 +4255,7 @@ function DatePicker({ defaultValue, isHistorical = false, isLabelHidden = false,
|
|
|
4218
4255
|
window.document.removeEventListener('click', handleClickOutside);
|
|
4219
4256
|
};
|
|
4220
4257
|
}, [handleClickOutside]);
|
|
4221
|
-
return (jsxs(Fieldset, { className: "DateRangePicker", children: [jsx(Legend, { isHidden: isLabelHidden, children: label }), jsxs(Box, { children: [jsx(Field, { children: jsx(DateInput, { ref: dateInputRef, defaultValue: selectedDateTupleRef.current, isForcedFocused: isCalendarPickerOpenRef.current, onChange: handleDateInputFilled, onClick: openCalendarPicker, onNext: handleDateInputNext }) }), withTime && (jsx(Field, { isTimeField: true, children: jsx(TimeInput, { ref: timeInputRef, defaultValue: selectedTimeTupleRef.current, minutesRange: minutesRange, onBack: () => dateInputRef.current.focus(true), onChange: handleTimeInputFilled, onFocus: closeCalendarPicker, onPrevious: () => dateInputRef.current.focus(true) }) }))] }), isCalendarPickerOpenRef.current && (jsx(CalendarPicker, { defaultValue: rangeCalendarPickerDefaultValue, isHistorical: isHistorical, onChange: handleCalendarPickerChange }))] }));
|
|
4258
|
+
return (jsxs(Fieldset, { className: "DateRangePicker", children: [jsx(Legend, { isHidden: isLabelHidden, children: label }), jsxs(Box, { children: [jsx(Field, { children: jsx(DateInput, { ref: dateInputRef, defaultValue: selectedDateTupleRef.current, isForcedFocused: isCalendarPickerOpenRef.current, isLight: isLight, onChange: handleDateInputFilled, onClick: openCalendarPicker, onNext: handleDateInputNext }) }), withTime && (jsx(Field, { "$isTimeField": true, children: jsx(TimeInput, { ref: timeInputRef, defaultValue: selectedTimeTupleRef.current, isLight: isLight, minutesRange: minutesRange, onBack: () => dateInputRef.current.focus(true), onChange: handleTimeInputFilled, onFocus: closeCalendarPicker, onPrevious: () => dateInputRef.current.focus(true) }) }))] }), isCalendarPickerOpenRef.current && (jsx(CalendarPicker, { defaultValue: rangeCalendarPickerDefaultValue, isHistorical: isHistorical, onChange: handleCalendarPickerChange }))] }));
|
|
4222
4259
|
}
|
|
4223
4260
|
const Box = styled.div `
|
|
4224
4261
|
* {
|
|
@@ -4232,15 +4269,10 @@ const Box = styled.div `
|
|
|
4232
4269
|
`;
|
|
4233
4270
|
const Field = styled.span `
|
|
4234
4271
|
font-size: inherit;
|
|
4235
|
-
margin-left: ${p =>
|
|
4236
|
-
if (p.isEndDateField) {
|
|
4237
|
-
return '10px';
|
|
4238
|
-
}
|
|
4239
|
-
return p.isTimeField ? '2px' : 0;
|
|
4240
|
-
}};
|
|
4272
|
+
margin-left: ${p => (p.$isTimeField ? '2px' : 0)};
|
|
4241
4273
|
`;
|
|
4242
4274
|
|
|
4243
|
-
function MultiCheckbox({ defaultValue = [], isInline = false, isLabelHidden = false, label, name, onChange, options }) {
|
|
4275
|
+
function MultiCheckbox({ defaultValue = [], isInline = false, isLabelHidden = false, isLight = false, label, name, onChange, options }) {
|
|
4244
4276
|
const checkedOptionValues = useRef(defaultValue);
|
|
4245
4277
|
const key = useMemo(() => `${name}-${JSON.stringify(defaultValue)}`, [defaultValue, name]);
|
|
4246
4278
|
const handleChange = useCallback((nextOptionValue, isChecked) => {
|
|
@@ -4253,9 +4285,9 @@ function MultiCheckbox({ defaultValue = [], isInline = false, isLabelHidden = fa
|
|
|
4253
4285
|
onChange(normalizedNextValue);
|
|
4254
4286
|
}
|
|
4255
4287
|
}, [onChange]);
|
|
4256
|
-
return (
|
|
4257
|
-
|
|
4258
|
-
|
|
4288
|
+
return (jsx(Fieldset, { isHidden: isLabelHidden, isLight: isLight, legend: label, children: jsx(ChecboxesBox$1, { "$isInline": isInline, children: options.map((option, index) => (jsx(Checkbox
|
|
4289
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
4290
|
+
, { defaultChecked: defaultValue.includes(option.value), label: option.label, name: `${name}${index}`, onChange: (isChecked) => handleChange(option.value, isChecked) }, `${name}-${index}`))) }) }, key));
|
|
4259
4291
|
}
|
|
4260
4292
|
const ChecboxesBox$1 = styled.div `
|
|
4261
4293
|
color: ${p => p.theme.color.gunMetal};
|
|
@@ -4303,7 +4335,7 @@ const StyledTagPicker = styled(TagPicker) `
|
|
|
4303
4335
|
}
|
|
4304
4336
|
`;
|
|
4305
4337
|
|
|
4306
|
-
function MultiRadio({ defaultValue, isInline = false, isLabelHidden = false, label, name, onChange, options }) {
|
|
4338
|
+
function MultiRadio({ defaultValue, isInline = false, isLabelHidden = false, isLight = false, label, name, onChange, options }) {
|
|
4307
4339
|
const [checkedOptionValue, setCheckedOptionValue] = useState(undefined);
|
|
4308
4340
|
const key = useMemo(() => `${name}-${String(checkedOptionValue)}}`, [checkedOptionValue, name]);
|
|
4309
4341
|
const handleChange = useCallback((nextOptionValue, isChecked) => {
|
|
@@ -4320,9 +4352,9 @@ function MultiRadio({ defaultValue, isInline = false, isLabelHidden = false, lab
|
|
|
4320
4352
|
useEffect(() => {
|
|
4321
4353
|
setCheckedOptionValue(defaultValue);
|
|
4322
4354
|
}, [defaultValue]);
|
|
4323
|
-
return (
|
|
4324
|
-
|
|
4325
|
-
|
|
4355
|
+
return (jsx(Fieldset, { isHidden: isLabelHidden, isLight: isLight, legend: label, children: jsx(ChecboxesBox, { "$isInline": isInline, children: options.map((option, index) => (jsx(Radio
|
|
4356
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
4357
|
+
, { defaultChecked: option.value === checkedOptionValue, name: name, onChange: (_, isChecked) => handleChange(option.value, isChecked), children: option.label }, `${name}-${index}`))) }) }, key));
|
|
4326
4358
|
}
|
|
4327
4359
|
const ChecboxesBox = styled.div `
|
|
4328
4360
|
color: ${p => p.theme.color.gunMetal};
|
|
@@ -4333,7 +4365,7 @@ const ChecboxesBox = styled.div `
|
|
|
4333
4365
|
> .rs-radio {
|
|
4334
4366
|
> .rs-radio-checker {
|
|
4335
4367
|
min-height: 0;
|
|
4336
|
-
padding:
|
|
4368
|
+
padding: 0 0 0 28px;
|
|
4337
4369
|
|
|
4338
4370
|
.rs-radio-wrapper {
|
|
4339
4371
|
left: 2px;
|
|
@@ -4357,206 +4389,6 @@ const ChecboxesBox = styled.div `
|
|
|
4357
4389
|
`}
|
|
4358
4390
|
`;
|
|
4359
4391
|
|
|
4360
|
-
function Select({ isLabelHidden = false, isLight = false, label, onChange, options,
|
|
4361
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
4362
|
-
searchable = false, ...originalProps }) {
|
|
4363
|
-
const key = useMemo(() => `${originalProps.name}-${JSON.stringify(originalProps.defaultValue)}`, [originalProps.defaultValue, originalProps.name]);
|
|
4364
|
-
const handleChange = useCallback((nextValue) => {
|
|
4365
|
-
if (!onChange) {
|
|
4366
|
-
return;
|
|
4367
|
-
}
|
|
4368
|
-
const normalizedNextValue = nextValue ?? undefined;
|
|
4369
|
-
onChange(normalizedNextValue);
|
|
4370
|
-
}, [onChange]);
|
|
4371
|
-
return (jsxs(Field$2, { children: [jsx(Label, { htmlFor: originalProps.name, isHidden: isLabelHidden, children: label }), jsx(StyledSelectPicker, { "$isLight": isLight, data: options, id: originalProps.name,
|
|
4372
|
-
// The `unknown` type from Rsuite library is wrong. It should be inferred from `data` prop type.
|
|
4373
|
-
// `onChange: ((value: unknown, event: React.SyntheticEvent<Element, Event>) => void) | undefined`
|
|
4374
|
-
onChange: handleChange, searchable: searchable, ...originalProps }, key)] }));
|
|
4375
|
-
}
|
|
4376
|
-
const StyledSelectPicker = styled(SelectPicker) `
|
|
4377
|
-
> .rs-picker-toggle {
|
|
4378
|
-
background-color: ${p => (p.$isLight ? p.theme.color.white : p.theme.color.gainsboro)} !important;
|
|
4379
|
-
border: 0;
|
|
4380
|
-
}
|
|
4381
|
-
`;
|
|
4382
|
-
|
|
4383
|
-
function Textarea({ isLabelHidden = false, isLight = false, label, onChange, rows = 3, ...originalProps }) {
|
|
4384
|
-
const inputRef = useRef();
|
|
4385
|
-
const key = useMemo(() => `${originalProps.name}-${JSON.stringify(originalProps.defaultValue)}`, [originalProps.defaultValue, originalProps.name]);
|
|
4386
|
-
const handleChange = useCallback(() => {
|
|
4387
|
-
if (!onChange) {
|
|
4388
|
-
return;
|
|
4389
|
-
}
|
|
4390
|
-
const nextValue = inputRef.current.value.trim();
|
|
4391
|
-
const normalizedNextValue = nextValue.length ? nextValue : undefined;
|
|
4392
|
-
onChange(normalizedNextValue);
|
|
4393
|
-
}, [onChange]);
|
|
4394
|
-
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)] }));
|
|
4395
|
-
}
|
|
4396
|
-
const StyledInput$1 = styled(Input) `
|
|
4397
|
-
background-color: ${p => (p.$isLight ? p.theme.color.white : p.theme.color.gainsboro)};
|
|
4398
|
-
border: 0;
|
|
4399
|
-
font-size: 13px;
|
|
4400
|
-
padding: 7px 11px;
|
|
4401
|
-
width: 100%;
|
|
4402
|
-
`;
|
|
4403
|
-
|
|
4404
|
-
function TextInput({ isLabelHidden = false, isLight = false, label, onChange, ...originalProps }) {
|
|
4405
|
-
const key = useMemo(() => `${originalProps.name}-${JSON.stringify(originalProps.defaultValue)}`, [originalProps.defaultValue, originalProps.name]);
|
|
4406
|
-
const handleChange = useCallback((nextValue) => {
|
|
4407
|
-
if (!onChange) {
|
|
4408
|
-
return;
|
|
4409
|
-
}
|
|
4410
|
-
const normalizedNextValue = nextValue && nextValue.trim().length ? nextValue : undefined;
|
|
4411
|
-
onChange(normalizedNextValue);
|
|
4412
|
-
}, [onChange]);
|
|
4413
|
-
return (jsxs(Field$2, { children: [jsx(Label, { htmlFor: originalProps.name, isHidden: isLabelHidden, children: label }), jsx(StyledInput, { "$isLight": isLight, id: originalProps.name, onChange: handleChange, ...originalProps }, key)] }));
|
|
4414
|
-
}
|
|
4415
|
-
const StyledInput = styled(Input) `
|
|
4416
|
-
background-color: ${p => (p.$isLight ? p.theme.color.white : p.theme.color.gainsboro)};
|
|
4417
|
-
border: 0;
|
|
4418
|
-
font-size: 13px;
|
|
4419
|
-
width: 100%;
|
|
4420
|
-
`;
|
|
4421
|
-
|
|
4422
|
-
function FormikAutoComplete({ name, ...originalProps }) {
|
|
4423
|
-
const [field, , helpers] = useField(name);
|
|
4424
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps, @typescript-eslint/naming-convention
|
|
4425
|
-
const defaultValue = useMemo(() => field.value, []);
|
|
4426
|
-
const handleChange = useCallback((nextValue) => {
|
|
4427
|
-
helpers.setValue(nextValue);
|
|
4428
|
-
},
|
|
4429
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4430
|
-
[]);
|
|
4431
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4432
|
-
useEffect(() => () => helpers.setValue(undefined), []);
|
|
4433
|
-
return jsx(AutoComplete, { defaultValue: defaultValue, name: name, onChange: handleChange, ...originalProps });
|
|
4434
|
-
}
|
|
4435
|
-
|
|
4436
|
-
function FormikCheckbox({ name, ...originalProps }) {
|
|
4437
|
-
const [field, , helpers] = useField(name);
|
|
4438
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps, @typescript-eslint/naming-convention
|
|
4439
|
-
const defaultChecked = useMemo(() => Boolean(field.value), []);
|
|
4440
|
-
const handleChange = useCallback((isChecked) => {
|
|
4441
|
-
helpers.setValue(isChecked);
|
|
4442
|
-
},
|
|
4443
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4444
|
-
[]);
|
|
4445
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4446
|
-
useEffect(() => () => helpers.setValue(undefined), []);
|
|
4447
|
-
return jsx(Checkbox, { defaultChecked: defaultChecked, name: name, onChange: handleChange, ...originalProps });
|
|
4448
|
-
}
|
|
4449
|
-
|
|
4450
|
-
function FormikDatePicker({ name, ...originalProps }) {
|
|
4451
|
-
const [field, , helpers] = useField(name);
|
|
4452
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4453
|
-
const defaultValue = useMemo(() => field.value, []);
|
|
4454
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4455
|
-
useEffect(() => () => helpers.setValue(undefined), []);
|
|
4456
|
-
return jsx(DatePicker, { defaultValue: defaultValue, onChange: helpers.setValue, ...originalProps });
|
|
4457
|
-
}
|
|
4458
|
-
|
|
4459
|
-
function FormikDateRangePicker({ name, ...originalProps }) {
|
|
4460
|
-
const [field, , helpers] = useField(name);
|
|
4461
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4462
|
-
const defaultValue = useMemo(() => field.value, []);
|
|
4463
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4464
|
-
useEffect(() => () => helpers.setValue(undefined), []);
|
|
4465
|
-
return jsx(DateRangePicker, { defaultValue: defaultValue, onChange: helpers.setValue, ...originalProps });
|
|
4466
|
-
}
|
|
4467
|
-
|
|
4468
|
-
function FormikEffect({ onChange }) {
|
|
4469
|
-
const { values } = useFormikContext();
|
|
4470
|
-
useEffect(() => {
|
|
4471
|
-
onChange(values);
|
|
4472
|
-
}, [onChange, values]);
|
|
4473
|
-
return jsx(Fragment, {});
|
|
4474
|
-
}
|
|
4475
|
-
|
|
4476
|
-
function FormikMultiCheckbox({ name, ...originalProps }) {
|
|
4477
|
-
const [field, , helpers] = useField(name);
|
|
4478
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4479
|
-
const defaultValue = useMemo(() => field.value, []);
|
|
4480
|
-
const handleChange = useCallback((nextValue) => {
|
|
4481
|
-
helpers.setValue(nextValue);
|
|
4482
|
-
},
|
|
4483
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4484
|
-
[]);
|
|
4485
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4486
|
-
useEffect(() => () => helpers.setValue(undefined), []);
|
|
4487
|
-
return jsx(MultiCheckbox, { defaultValue: defaultValue, name: name, onChange: handleChange, ...originalProps });
|
|
4488
|
-
}
|
|
4489
|
-
|
|
4490
|
-
function FormikMultiSelect({ name, ...originalProps }) {
|
|
4491
|
-
const [field, , helpers] = useField(name);
|
|
4492
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4493
|
-
const defaultValue = useMemo(() => field.value, []);
|
|
4494
|
-
const handleChange = useCallback((nextValue) => {
|
|
4495
|
-
helpers.setValue(nextValue);
|
|
4496
|
-
},
|
|
4497
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4498
|
-
[]);
|
|
4499
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4500
|
-
useEffect(() => () => helpers.setValue(undefined), []);
|
|
4501
|
-
return jsx(MultiSelect, { defaultValue: defaultValue, name: name, onChange: handleChange, ...originalProps });
|
|
4502
|
-
}
|
|
4503
|
-
|
|
4504
|
-
function FormikMultiRadio({ name, ...originalProps }) {
|
|
4505
|
-
const [field, , helpers] = useField(name);
|
|
4506
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4507
|
-
const defaultValue = useMemo(() => field.value, []);
|
|
4508
|
-
const handleChange = useCallback((nextValue) => {
|
|
4509
|
-
helpers.setValue(nextValue);
|
|
4510
|
-
},
|
|
4511
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4512
|
-
[]);
|
|
4513
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4514
|
-
useEffect(() => () => helpers.setValue(undefined), []);
|
|
4515
|
-
return jsx(MultiRadio, { defaultValue: defaultValue, name: name, onChange: handleChange, ...originalProps });
|
|
4516
|
-
}
|
|
4517
|
-
|
|
4518
|
-
function FormikSelect({ name, ...originalProps }) {
|
|
4519
|
-
const [field, , helpers] = useField(name);
|
|
4520
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4521
|
-
const defaultValue = useMemo(() => field.value, []);
|
|
4522
|
-
const handleChange = useCallback((nextValue) => {
|
|
4523
|
-
helpers.setValue(nextValue);
|
|
4524
|
-
},
|
|
4525
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4526
|
-
[]);
|
|
4527
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4528
|
-
useEffect(() => () => helpers.setValue(undefined), []);
|
|
4529
|
-
return jsx(Select, { defaultValue: defaultValue, name: name, onChange: handleChange, ...originalProps });
|
|
4530
|
-
}
|
|
4531
|
-
|
|
4532
|
-
function FormikTextarea({ name, ...originalProps }) {
|
|
4533
|
-
const [field, , helpers] = useField(name);
|
|
4534
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4535
|
-
const defaultValue = useMemo(() => field.value, []);
|
|
4536
|
-
const handleChange = useCallback((nextValue) => {
|
|
4537
|
-
helpers.setValue(nextValue);
|
|
4538
|
-
},
|
|
4539
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4540
|
-
[]);
|
|
4541
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4542
|
-
useEffect(() => () => helpers.setValue(undefined), []);
|
|
4543
|
-
return jsx(Textarea, { defaultValue: defaultValue, name: name, onChange: handleChange, ...originalProps });
|
|
4544
|
-
}
|
|
4545
|
-
|
|
4546
|
-
function FormikTextInput({ name, ...originalProps }) {
|
|
4547
|
-
const [field, , helpers] = useField(name);
|
|
4548
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4549
|
-
const defaultValue = useMemo(() => field.value, []);
|
|
4550
|
-
const handleChange = useCallback((nextValue) => {
|
|
4551
|
-
helpers.setValue(nextValue);
|
|
4552
|
-
},
|
|
4553
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4554
|
-
[]);
|
|
4555
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4556
|
-
useEffect(() => () => helpers.setValue(undefined), []);
|
|
4557
|
-
return jsx(TextInput, { defaultValue: defaultValue, name: name, onChange: handleChange, ...originalProps });
|
|
4558
|
-
}
|
|
4559
|
-
|
|
4560
4392
|
/**
|
|
4561
4393
|
* Internal component used to wrap SVG icon components
|
|
4562
4394
|
*/
|
|
@@ -4895,5 +4727,263 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
4895
4727
|
ViewOnMap: ViewOnMap
|
|
4896
4728
|
});
|
|
4897
4729
|
|
|
4898
|
-
|
|
4730
|
+
function MultiZoneEditor({ addButtonLabel, defaultValue = [], initialZone, isLabelHidden = false, isLight = false, label, labelPropName, onAdd, onCenter, onDelete, onEdit }) {
|
|
4731
|
+
const prevDefaultValueRef = useRef(defaultValue);
|
|
4732
|
+
const [zones, setZones] = useState(defaultValue);
|
|
4733
|
+
const addZone = useCallback(() => {
|
|
4734
|
+
const nextZones = [...zones, initialZone];
|
|
4735
|
+
if (onAdd) {
|
|
4736
|
+
onAdd(nextZones, nextZones.length);
|
|
4737
|
+
}
|
|
4738
|
+
setZones(nextZones);
|
|
4739
|
+
}, [initialZone, onAdd, zones]);
|
|
4740
|
+
const centerZone = useCallback((zone) => {
|
|
4741
|
+
if (onCenter) {
|
|
4742
|
+
onCenter(zone);
|
|
4743
|
+
}
|
|
4744
|
+
}, [onCenter]);
|
|
4745
|
+
const deleteZone = useCallback((index) => {
|
|
4746
|
+
const nextZones = remove(index, 1, zones);
|
|
4747
|
+
setZones(nextZones);
|
|
4748
|
+
if (onDelete) {
|
|
4749
|
+
onDelete(nextZones);
|
|
4750
|
+
}
|
|
4751
|
+
}, [onDelete, zones]);
|
|
4752
|
+
const editZone = useCallback((index, zone) => {
|
|
4753
|
+
if (onEdit) {
|
|
4754
|
+
onEdit(zone, index);
|
|
4755
|
+
}
|
|
4756
|
+
}, [onEdit]);
|
|
4757
|
+
useEffect(() => {
|
|
4758
|
+
if (equals(defaultValue, prevDefaultValueRef.current)) {
|
|
4759
|
+
return;
|
|
4760
|
+
}
|
|
4761
|
+
setZones(defaultValue);
|
|
4762
|
+
}, [defaultValue]);
|
|
4763
|
+
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) => (
|
|
4764
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
4765
|
+
jsxs(Row, { children: [jsxs(ZoneWrapper, { children: [zone[labelPropName], jsxs("a", { onClick: () => centerZone(zone), style: {
|
|
4766
|
+
cursor: 'pointer'
|
|
4767
|
+
}, children: [jsx(SelectRectangle, {}), " 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}`))) })] }));
|
|
4768
|
+
}
|
|
4769
|
+
const Row = styled.div `
|
|
4770
|
+
align-items: center;
|
|
4771
|
+
display: flex;
|
|
4772
|
+
margin: 8px 0 0;
|
|
4773
|
+
|
|
4774
|
+
> button {
|
|
4775
|
+
margin: 0 0 0 8px;
|
|
4776
|
+
}
|
|
4777
|
+
`;
|
|
4778
|
+
const ZoneWrapper = styled.div `
|
|
4779
|
+
background-color: ${p => p.theme.color.gainsboro};
|
|
4780
|
+
display: flex;
|
|
4781
|
+
flex-grow: 1;
|
|
4782
|
+
font-size: 13px;
|
|
4783
|
+
line-height: 1.5;
|
|
4784
|
+
justify-content: space-between;
|
|
4785
|
+
padding: 6px 12px 6px;
|
|
4786
|
+
`;
|
|
4787
|
+
|
|
4788
|
+
function Select({ isLabelHidden = false, isLight = false, label, onChange, options,
|
|
4789
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
4790
|
+
searchable = false, ...originalProps }) {
|
|
4791
|
+
const key = useMemo(() => `${originalProps.name}-${JSON.stringify(originalProps.defaultValue)}`, [originalProps.defaultValue, originalProps.name]);
|
|
4792
|
+
const handleChange = useCallback((nextValue) => {
|
|
4793
|
+
if (!onChange) {
|
|
4794
|
+
return;
|
|
4795
|
+
}
|
|
4796
|
+
const normalizedNextValue = nextValue ?? undefined;
|
|
4797
|
+
onChange(normalizedNextValue);
|
|
4798
|
+
}, [onChange]);
|
|
4799
|
+
return (jsxs(Field$2, { children: [jsx(Label, { htmlFor: originalProps.name, isHidden: isLabelHidden, children: label }), jsx(StyledSelectPicker, { "$isLight": isLight, data: options, id: originalProps.name,
|
|
4800
|
+
// The `unknown` type from Rsuite library is wrong. It should be inferred from `data` prop type.
|
|
4801
|
+
// `onChange: ((value: unknown, event: React.SyntheticEvent<Element, Event>) => void) | undefined`
|
|
4802
|
+
onChange: handleChange, searchable: searchable, ...originalProps }, key)] }));
|
|
4803
|
+
}
|
|
4804
|
+
const StyledSelectPicker = styled(SelectPicker) `
|
|
4805
|
+
> .rs-picker-toggle {
|
|
4806
|
+
background-color: ${p => (p.$isLight ? p.theme.color.white : p.theme.color.gainsboro)} !important;
|
|
4807
|
+
border: 0;
|
|
4808
|
+
}
|
|
4809
|
+
`;
|
|
4810
|
+
|
|
4811
|
+
function Textarea({ isLabelHidden = false, isLight = false, label, onChange, rows = 3, ...originalProps }) {
|
|
4812
|
+
const inputRef = useRef();
|
|
4813
|
+
const key = useMemo(() => `${originalProps.name}-${JSON.stringify(originalProps.defaultValue)}`, [originalProps.defaultValue, originalProps.name]);
|
|
4814
|
+
const handleChange = useCallback(() => {
|
|
4815
|
+
if (!onChange) {
|
|
4816
|
+
return;
|
|
4817
|
+
}
|
|
4818
|
+
const nextValue = inputRef.current.value.trim();
|
|
4819
|
+
const normalizedNextValue = nextValue.length ? nextValue : undefined;
|
|
4820
|
+
onChange(normalizedNextValue);
|
|
4821
|
+
}, [onChange]);
|
|
4822
|
+
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)] }));
|
|
4823
|
+
}
|
|
4824
|
+
const StyledInput$1 = styled(Input) `
|
|
4825
|
+
background-color: ${p => (p.$isLight ? p.theme.color.white : p.theme.color.gainsboro)};
|
|
4826
|
+
border: 0;
|
|
4827
|
+
font-size: 13px;
|
|
4828
|
+
padding: 7px 11px;
|
|
4829
|
+
width: 100%;
|
|
4830
|
+
`;
|
|
4831
|
+
|
|
4832
|
+
function TextInput({ isLabelHidden = false, isLight = false, label, onChange, ...originalProps }) {
|
|
4833
|
+
const key = useMemo(() => `${originalProps.name}-${JSON.stringify(originalProps.defaultValue)}`, [originalProps.defaultValue, originalProps.name]);
|
|
4834
|
+
const handleChange = useCallback((nextValue) => {
|
|
4835
|
+
if (!onChange) {
|
|
4836
|
+
return;
|
|
4837
|
+
}
|
|
4838
|
+
const normalizedNextValue = nextValue && nextValue.trim().length ? nextValue : undefined;
|
|
4839
|
+
onChange(normalizedNextValue);
|
|
4840
|
+
}, [onChange]);
|
|
4841
|
+
return (jsxs(Field$2, { children: [jsx(Label, { htmlFor: originalProps.name, isHidden: isLabelHidden, children: label }), jsx(StyledInput, { "$isLight": isLight, id: originalProps.name, onChange: handleChange, ...originalProps }, key)] }));
|
|
4842
|
+
}
|
|
4843
|
+
const StyledInput = styled(Input) `
|
|
4844
|
+
background-color: ${p => (p.$isLight ? p.theme.color.white : p.theme.color.gainsboro)};
|
|
4845
|
+
border: 0;
|
|
4846
|
+
font-size: 13px;
|
|
4847
|
+
width: 100%;
|
|
4848
|
+
`;
|
|
4849
|
+
|
|
4850
|
+
function FormikAutoComplete({ name, ...originalProps }) {
|
|
4851
|
+
const [field, , helpers] = useField(name);
|
|
4852
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps, @typescript-eslint/naming-convention
|
|
4853
|
+
const defaultValue = useMemo(() => field.value, []);
|
|
4854
|
+
const handleChange = useCallback((nextValue) => {
|
|
4855
|
+
helpers.setValue(nextValue);
|
|
4856
|
+
},
|
|
4857
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4858
|
+
[]);
|
|
4859
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4860
|
+
useEffect(() => () => helpers.setValue(undefined), []);
|
|
4861
|
+
return jsx(AutoComplete, { defaultValue: defaultValue, name: name, onChange: handleChange, ...originalProps });
|
|
4862
|
+
}
|
|
4863
|
+
|
|
4864
|
+
function FormikCheckbox({ name, ...originalProps }) {
|
|
4865
|
+
const [field, , helpers] = useField(name);
|
|
4866
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps, @typescript-eslint/naming-convention
|
|
4867
|
+
const defaultChecked = useMemo(() => Boolean(field.value), []);
|
|
4868
|
+
const handleChange = useCallback((isChecked) => {
|
|
4869
|
+
helpers.setValue(isChecked);
|
|
4870
|
+
},
|
|
4871
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4872
|
+
[]);
|
|
4873
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4874
|
+
useEffect(() => () => helpers.setValue(undefined), []);
|
|
4875
|
+
return jsx(Checkbox, { defaultChecked: defaultChecked, name: name, onChange: handleChange, ...originalProps });
|
|
4876
|
+
}
|
|
4877
|
+
|
|
4878
|
+
function FormikDatePicker({ name, ...originalProps }) {
|
|
4879
|
+
const [field, , helpers] = useField(name);
|
|
4880
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4881
|
+
const defaultValue = useMemo(() => field.value, []);
|
|
4882
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4883
|
+
useEffect(() => () => helpers.setValue(undefined), []);
|
|
4884
|
+
return jsx(DatePicker, { defaultValue: defaultValue, onChange: helpers.setValue, ...originalProps });
|
|
4885
|
+
}
|
|
4886
|
+
|
|
4887
|
+
function FormikDateRangePicker({ name, ...originalProps }) {
|
|
4888
|
+
const [field, , helpers] = useField(name);
|
|
4889
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4890
|
+
const defaultValue = useMemo(() => field.value, []);
|
|
4891
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4892
|
+
useEffect(() => () => helpers.setValue(undefined), []);
|
|
4893
|
+
return jsx(DateRangePicker, { defaultValue: defaultValue, onChange: helpers.setValue, ...originalProps });
|
|
4894
|
+
}
|
|
4895
|
+
|
|
4896
|
+
function FormikEffect({ onChange }) {
|
|
4897
|
+
const { values } = useFormikContext();
|
|
4898
|
+
useEffect(() => {
|
|
4899
|
+
onChange(values);
|
|
4900
|
+
}, [onChange, values]);
|
|
4901
|
+
return jsx(Fragment, {});
|
|
4902
|
+
}
|
|
4903
|
+
|
|
4904
|
+
function FormikMultiCheckbox({ name, ...originalProps }) {
|
|
4905
|
+
const [field, , helpers] = useField(name);
|
|
4906
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4907
|
+
const defaultValue = useMemo(() => field.value, []);
|
|
4908
|
+
const handleChange = useCallback((nextValue) => {
|
|
4909
|
+
helpers.setValue(nextValue);
|
|
4910
|
+
},
|
|
4911
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4912
|
+
[]);
|
|
4913
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4914
|
+
useEffect(() => () => helpers.setValue(undefined), []);
|
|
4915
|
+
return jsx(MultiCheckbox, { defaultValue: defaultValue, name: name, onChange: handleChange, ...originalProps });
|
|
4916
|
+
}
|
|
4917
|
+
|
|
4918
|
+
function FormikMultiSelect({ name, ...originalProps }) {
|
|
4919
|
+
const [field, , helpers] = useField(name);
|
|
4920
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4921
|
+
const defaultValue = useMemo(() => field.value, []);
|
|
4922
|
+
const handleChange = useCallback((nextValue) => {
|
|
4923
|
+
helpers.setValue(nextValue);
|
|
4924
|
+
},
|
|
4925
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4926
|
+
[]);
|
|
4927
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4928
|
+
useEffect(() => () => helpers.setValue(undefined), []);
|
|
4929
|
+
return jsx(MultiSelect, { defaultValue: defaultValue, name: name, onChange: handleChange, ...originalProps });
|
|
4930
|
+
}
|
|
4931
|
+
|
|
4932
|
+
function FormikMultiRadio({ name, ...originalProps }) {
|
|
4933
|
+
const [field, , helpers] = useField(name);
|
|
4934
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4935
|
+
const defaultValue = useMemo(() => field.value, []);
|
|
4936
|
+
const handleChange = useCallback((nextValue) => {
|
|
4937
|
+
helpers.setValue(nextValue);
|
|
4938
|
+
},
|
|
4939
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4940
|
+
[]);
|
|
4941
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4942
|
+
useEffect(() => () => helpers.setValue(undefined), []);
|
|
4943
|
+
return jsx(MultiRadio, { defaultValue: defaultValue, name: name, onChange: handleChange, ...originalProps });
|
|
4944
|
+
}
|
|
4945
|
+
|
|
4946
|
+
function FormikSelect({ name, ...originalProps }) {
|
|
4947
|
+
const [field, , helpers] = useField(name);
|
|
4948
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4949
|
+
const defaultValue = useMemo(() => field.value, []);
|
|
4950
|
+
const handleChange = useCallback((nextValue) => {
|
|
4951
|
+
helpers.setValue(nextValue);
|
|
4952
|
+
},
|
|
4953
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4954
|
+
[]);
|
|
4955
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4956
|
+
useEffect(() => () => helpers.setValue(undefined), []);
|
|
4957
|
+
return jsx(Select, { defaultValue: defaultValue, name: name, onChange: handleChange, ...originalProps });
|
|
4958
|
+
}
|
|
4959
|
+
|
|
4960
|
+
function FormikTextarea({ name, ...originalProps }) {
|
|
4961
|
+
const [field, , helpers] = useField(name);
|
|
4962
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4963
|
+
const defaultValue = useMemo(() => field.value, []);
|
|
4964
|
+
const handleChange = useCallback((nextValue) => {
|
|
4965
|
+
helpers.setValue(nextValue);
|
|
4966
|
+
},
|
|
4967
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4968
|
+
[]);
|
|
4969
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4970
|
+
useEffect(() => () => helpers.setValue(undefined), []);
|
|
4971
|
+
return jsx(Textarea, { defaultValue: defaultValue, name: name, onChange: handleChange, ...originalProps });
|
|
4972
|
+
}
|
|
4973
|
+
|
|
4974
|
+
function FormikTextInput({ name, ...originalProps }) {
|
|
4975
|
+
const [field, , helpers] = useField(name);
|
|
4976
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4977
|
+
const defaultValue = useMemo(() => field.value, []);
|
|
4978
|
+
const handleChange = useCallback((nextValue) => {
|
|
4979
|
+
helpers.setValue(nextValue);
|
|
4980
|
+
},
|
|
4981
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4982
|
+
[]);
|
|
4983
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4984
|
+
useEffect(() => () => helpers.setValue(undefined), []);
|
|
4985
|
+
return jsx(TextInput, { defaultValue: defaultValue, name: name, onChange: handleChange, ...originalProps });
|
|
4986
|
+
}
|
|
4987
|
+
|
|
4988
|
+
export { Accent, AutoComplete, Button, Checkbox, DatePicker, DateRangePicker, Dropdown, Field$2 as Field, Fieldset, FormikAutoComplete, FormikCheckbox, FormikDatePicker, FormikDateRangePicker, FormikEffect, FormikMultiCheckbox, FormikMultiRadio, FormikMultiSelect, FormikSelect, FormikTextInput, FormikTextarea, GlobalStyle, index as Icon, IconButton, Label, Legend, MultiCheckbox, MultiRadio, MultiSelect, MultiZoneEditor, Select, Size, THEME, Tag$1 as Tag, TextInput, Textarea, ThemeProvider };
|
|
4899
4989
|
//# sourceMappingURL=index.js.map
|