@mtes-mct/monitor-ui 5.9.2 → 6.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/components/Dialog/index.d.ts +1 -1
- package/components/SingleTag.d.ts +3 -2
- package/elements/Button.d.ts +1 -1
- package/elements/Field.d.ts +1 -1
- package/elements/FieldError.d.ts +2 -2
- package/elements/Fieldset.d.ts +2 -2
- package/elements/IconBox.d.ts +7 -2
- package/elements/IconButton.d.ts +1 -1
- package/elements/Label.d.ts +2 -2
- package/elements/Legend.d.ts +5 -1
- package/elements/Tag/index.d.ts +1 -1
- package/elements/TagGroup.d.ts +1 -1
- package/fields/Search.d.ts +5 -4
- package/index.js +97 -205
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1014,84 +1014,6 @@ _dispatchable(['fantasy-land/map', 'map'], _xmap, function map(fn, functor) {
|
|
|
1014
1014
|
|
|
1015
1015
|
var map$1 = map;
|
|
1016
1016
|
|
|
1017
|
-
/**
|
|
1018
|
-
* Determine if the passed argument is an integer.
|
|
1019
|
-
*
|
|
1020
|
-
* @private
|
|
1021
|
-
* @param {*} n
|
|
1022
|
-
* @category Type
|
|
1023
|
-
* @return {Boolean}
|
|
1024
|
-
*/
|
|
1025
|
-
var _isInteger = Number.isInteger || function _isInteger(n) {
|
|
1026
|
-
return n << 0 === n;
|
|
1027
|
-
};
|
|
1028
|
-
|
|
1029
|
-
/**
|
|
1030
|
-
* Returns the nth element of the given list or string. If n is negative the
|
|
1031
|
-
* element at index length + n is returned.
|
|
1032
|
-
*
|
|
1033
|
-
* @func
|
|
1034
|
-
* @memberOf R
|
|
1035
|
-
* @since v0.1.0
|
|
1036
|
-
* @category List
|
|
1037
|
-
* @sig Number -> [a] -> a | Undefined
|
|
1038
|
-
* @sig Number -> String -> String
|
|
1039
|
-
* @param {Number} offset
|
|
1040
|
-
* @param {*} list
|
|
1041
|
-
* @return {*}
|
|
1042
|
-
* @example
|
|
1043
|
-
*
|
|
1044
|
-
* const list = ['foo', 'bar', 'baz', 'quux'];
|
|
1045
|
-
* R.nth(1, list); //=> 'bar'
|
|
1046
|
-
* R.nth(-1, list); //=> 'quux'
|
|
1047
|
-
* R.nth(-99, list); //=> undefined
|
|
1048
|
-
*
|
|
1049
|
-
* R.nth(2, 'abc'); //=> 'c'
|
|
1050
|
-
* R.nth(3, 'abc'); //=> ''
|
|
1051
|
-
* @symb R.nth(-1, [a, b, c]) = c
|
|
1052
|
-
* @symb R.nth(0, [a, b, c]) = a
|
|
1053
|
-
* @symb R.nth(1, [a, b, c]) = b
|
|
1054
|
-
*/
|
|
1055
|
-
|
|
1056
|
-
var nth =
|
|
1057
|
-
/*#__PURE__*/
|
|
1058
|
-
_curry2(function nth(offset, list) {
|
|
1059
|
-
var idx = offset < 0 ? list.length + offset : offset;
|
|
1060
|
-
return _isString(list) ? list.charAt(idx) : list[idx];
|
|
1061
|
-
});
|
|
1062
|
-
|
|
1063
|
-
/**
|
|
1064
|
-
* Returns a function that when supplied an object returns the indicated
|
|
1065
|
-
* property of that object, if it exists.
|
|
1066
|
-
*
|
|
1067
|
-
* @func
|
|
1068
|
-
* @memberOf R
|
|
1069
|
-
* @since v0.1.0
|
|
1070
|
-
* @category Object
|
|
1071
|
-
* @typedefn Idx = String | Int | Symbol
|
|
1072
|
-
* @sig Idx -> {s: a} -> a | Undefined
|
|
1073
|
-
* @param {String|Number} p The property name or array index
|
|
1074
|
-
* @param {Object} obj The object to query
|
|
1075
|
-
* @return {*} The value at `obj.p`.
|
|
1076
|
-
* @see R.path, R.props, R.pluck, R.project, R.nth
|
|
1077
|
-
* @example
|
|
1078
|
-
*
|
|
1079
|
-
* R.prop('x', {x: 100}); //=> 100
|
|
1080
|
-
* R.prop('x', {}); //=> undefined
|
|
1081
|
-
* R.prop(0, [100]); //=> 100
|
|
1082
|
-
* R.compose(R.inc, R.prop('x'))({ x: 3 }) //=> 4
|
|
1083
|
-
*/
|
|
1084
|
-
|
|
1085
|
-
var prop =
|
|
1086
|
-
/*#__PURE__*/
|
|
1087
|
-
_curry2(function prop(p, obj) {
|
|
1088
|
-
if (obj == null) {
|
|
1089
|
-
return;
|
|
1090
|
-
}
|
|
1091
|
-
|
|
1092
|
-
return _isInteger(p) ? nth(p, obj) : obj[p];
|
|
1093
|
-
});
|
|
1094
|
-
|
|
1095
1017
|
/**
|
|
1096
1018
|
* Returns a single item by iterating through the list, successively calling
|
|
1097
1019
|
* the iterator function and passing it an accumulator value and the current
|
|
@@ -2123,47 +2045,13 @@ _curry2(function mergeDeepRight(lObj, rObj) {
|
|
|
2123
2045
|
|
|
2124
2046
|
var mergeDeepRight$1 = mergeDeepRight;
|
|
2125
2047
|
|
|
2126
|
-
/**
|
|
2127
|
-
* Returns `true` if the specified object property is equal, in
|
|
2128
|
-
* [`R.equals`](#equals) terms, to the given value; `false` otherwise.
|
|
2129
|
-
* You can test multiple properties with [`R.whereEq`](#whereEq).
|
|
2130
|
-
*
|
|
2131
|
-
* @func
|
|
2132
|
-
* @memberOf R
|
|
2133
|
-
* @since v0.1.0
|
|
2134
|
-
* @category Relation
|
|
2135
|
-
* @sig String -> a -> Object -> Boolean
|
|
2136
|
-
* @param {String} name
|
|
2137
|
-
* @param {*} val
|
|
2138
|
-
* @param {*} obj
|
|
2139
|
-
* @return {Boolean}
|
|
2140
|
-
* @see R.whereEq, R.propSatisfies, R.equals
|
|
2141
|
-
* @example
|
|
2142
|
-
*
|
|
2143
|
-
* const abby = {name: 'Abby', age: 7, hair: 'blond'};
|
|
2144
|
-
* const fred = {name: 'Fred', age: 12, hair: 'brown'};
|
|
2145
|
-
* const rusty = {name: 'Rusty', age: 10, hair: 'brown'};
|
|
2146
|
-
* const alois = {name: 'Alois', age: 15, disposition: 'surly'};
|
|
2147
|
-
* const kids = [abby, fred, rusty, alois];
|
|
2148
|
-
* const hasBrownHair = R.propEq('hair', 'brown');
|
|
2149
|
-
* R.filter(hasBrownHair, kids); //=> [fred, rusty]
|
|
2150
|
-
*/
|
|
2151
|
-
|
|
2152
|
-
var propEq =
|
|
2153
|
-
/*#__PURE__*/
|
|
2154
|
-
_curry3(function propEq(name, val, obj) {
|
|
2155
|
-
return equals$1(val, prop(name, obj));
|
|
2156
|
-
});
|
|
2157
|
-
|
|
2158
|
-
var propEq$1 = propEq;
|
|
2159
|
-
|
|
2160
2048
|
const UntypedStyledComponentsThemeProvider = ThemeProvider$1;
|
|
2161
2049
|
function ThemeProvider({ children, theme = {} }) {
|
|
2162
2050
|
const finalTheme = mergeDeepRight$1(THEME, theme);
|
|
2163
2051
|
return jsx(UntypedStyledComponentsThemeProvider, { theme: finalTheme, children: children });
|
|
2164
2052
|
}
|
|
2165
2053
|
|
|
2166
|
-
var classnames = {exports: {}};
|
|
2054
|
+
var classnames$1 = {exports: {}};
|
|
2167
2055
|
|
|
2168
2056
|
/*!
|
|
2169
2057
|
Copyright (c) 2018 Jed Watson.
|
|
@@ -2220,10 +2108,10 @@ var classnames = {exports: {}};
|
|
|
2220
2108
|
window.classNames = classNames;
|
|
2221
2109
|
}
|
|
2222
2110
|
}());
|
|
2223
|
-
} (classnames));
|
|
2111
|
+
} (classnames$1));
|
|
2224
2112
|
|
|
2225
|
-
var classnamesExports = classnames.exports;
|
|
2226
|
-
var
|
|
2113
|
+
var classnamesExports = classnames$1.exports;
|
|
2114
|
+
var classnames = /*@__PURE__*/getDefaultExportFromCjs(classnamesExports);
|
|
2227
2115
|
|
|
2228
2116
|
const Action = styled.div `
|
|
2229
2117
|
background-color: ${p => p.theme.color.white};
|
|
@@ -2285,8 +2173,8 @@ function stopMouseEventPropagation(event) {
|
|
|
2285
2173
|
}
|
|
2286
2174
|
|
|
2287
2175
|
function RawDialog({ children, className, isAbsolute = false, ...nativeProps }) {
|
|
2288
|
-
const controlledClassName =
|
|
2289
|
-
return (jsxs(Box$g, { "$isAbsolute": isAbsolute, className: controlledClassName,
|
|
2176
|
+
const controlledClassName = classnames('Component-Dialog', className);
|
|
2177
|
+
return (jsxs(Box$g, { "$isAbsolute": isAbsolute, className: controlledClassName, onClick: stopMouseEventPropagation, ...nativeProps, children: [jsx(Overlay, { "$isAbsolute": isAbsolute }), jsx(Window, { "$isAbsolute": isAbsolute, children: children })] }));
|
|
2290
2178
|
}
|
|
2291
2179
|
const Box$g = styled.div `
|
|
2292
2180
|
position: ${p => (p.$isAbsolute ? 'absolute' : 'fixed')};
|
|
@@ -2354,10 +2242,11 @@ const StyledDropdownItem = styled(Dropdown$1.Item) `
|
|
|
2354
2242
|
}
|
|
2355
2243
|
`;
|
|
2356
2244
|
|
|
2357
|
-
function RawDropdown({ Icon, ...originalProps }) {
|
|
2245
|
+
function RawDropdown({ className, Icon, ...originalProps }) {
|
|
2246
|
+
const controlledClassName = classnames('Component-Dropdow', className);
|
|
2358
2247
|
const icon = useMemo(() => (Icon ? jsx(Icon, { size: 20 }) : undefined), [Icon]);
|
|
2359
2248
|
const hasIcon = useMemo(() => Boolean(Icon), [Icon]);
|
|
2360
|
-
return jsx(StyledDropdown, { "$hasIcon": hasIcon, icon: icon, ...originalProps });
|
|
2249
|
+
return jsx(StyledDropdown, { "$hasIcon": hasIcon, className: controlledClassName, icon: icon, ...originalProps });
|
|
2361
2250
|
}
|
|
2362
2251
|
// TODO We need to split into multiple styled components as done in `<Button />`.
|
|
2363
2252
|
const StyledDropdown = styled(Dropdown$1) `
|
|
@@ -2709,16 +2598,17 @@ const ICON_SIZE = {
|
|
|
2709
2598
|
[Size.NORMAL]: 20,
|
|
2710
2599
|
[Size.SMALL]: 12
|
|
2711
2600
|
};
|
|
2712
|
-
function Button({ accent = Accent.PRIMARY, children, Icon, isFullWidth = false, size = Size.NORMAL, type = 'button', ...nativeProps }) {
|
|
2601
|
+
function Button({ accent = Accent.PRIMARY, children, className, Icon, isFullWidth = false, size = Size.NORMAL, type = 'button', ...nativeProps }) {
|
|
2713
2602
|
const commonChildren = useMemo(() => (jsxs(Fragment, { children: [Icon && jsx(Icon, { size: ICON_SIZE[size] }), children && jsx(ButtonLabel, { children: children })] })), [children, Icon, size]);
|
|
2714
2603
|
const commonProps = useMemo(() => ({
|
|
2715
2604
|
as: StyledButton$1,
|
|
2716
2605
|
children: commonChildren,
|
|
2606
|
+
className: classnames('Element-Button', className),
|
|
2717
2607
|
isFullWidth,
|
|
2718
2608
|
size,
|
|
2719
2609
|
type,
|
|
2720
2610
|
...nativeProps
|
|
2721
|
-
}), [commonChildren, isFullWidth, nativeProps, size, type]);
|
|
2611
|
+
}), [className, commonChildren, isFullWidth, nativeProps, size, type]);
|
|
2722
2612
|
switch (accent) {
|
|
2723
2613
|
case Accent.SECONDARY:
|
|
2724
2614
|
return jsx(SecondaryButton, { ...commonProps });
|
|
@@ -2844,14 +2734,15 @@ const ICON_SIZE_IN_PX = {
|
|
|
2844
2734
|
[Size.NORMAL]: 20,
|
|
2845
2735
|
[Size.SMALL]: 14
|
|
2846
2736
|
};
|
|
2847
|
-
function IconButton({ accent = Accent.PRIMARY, color, Icon, iconSize, size = Size.NORMAL, type = 'button', ...nativeProps }) {
|
|
2737
|
+
function IconButton({ accent = Accent.PRIMARY, className, color, Icon, iconSize, size = Size.NORMAL, type = 'button', ...nativeProps }) {
|
|
2848
2738
|
const children = useMemo(() => jsx(Icon, { color: color, size: iconSize || ICON_SIZE_IN_PX[size] }), [color, Icon, iconSize, size]);
|
|
2849
2739
|
const commonProps = useMemo(() => ({
|
|
2850
2740
|
children,
|
|
2741
|
+
className: classnames('Element-IconButton', className),
|
|
2851
2742
|
size,
|
|
2852
2743
|
type,
|
|
2853
2744
|
...nativeProps
|
|
2854
|
-
}), [children, nativeProps, size, type]);
|
|
2745
|
+
}), [children, className, nativeProps, size, type]);
|
|
2855
2746
|
switch (accent) {
|
|
2856
2747
|
case Accent.SECONDARY:
|
|
2857
2748
|
return jsx(SecondaryButton, { as: StyledButton, ...commonProps });
|
|
@@ -2902,7 +2793,9 @@ const TertiaryButton = styled.button `
|
|
|
2902
2793
|
/**
|
|
2903
2794
|
* Internal component used to wrap SVG icon components
|
|
2904
2795
|
*/
|
|
2905
|
-
const IconBox = styled.div
|
|
2796
|
+
const IconBox = styled.div.attrs(() => ({
|
|
2797
|
+
className: 'Element-IconBox'
|
|
2798
|
+
})) `
|
|
2906
2799
|
display: inline-block;
|
|
2907
2800
|
color: ${p => p.$color ?? 'inherit'};
|
|
2908
2801
|
|
|
@@ -3257,13 +3150,14 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
3257
3150
|
Vms: Vms
|
|
3258
3151
|
});
|
|
3259
3152
|
|
|
3260
|
-
function SingleTag({ children, onDelete }) {
|
|
3153
|
+
function SingleTag({ children, className, onDelete, ...nativeProps }) {
|
|
3154
|
+
const controlledClassName = classnames('Component-SingleTag', className);
|
|
3261
3155
|
const handleDelete = useCallback(() => {
|
|
3262
3156
|
if (onDelete) {
|
|
3263
3157
|
onDelete();
|
|
3264
3158
|
}
|
|
3265
3159
|
}, [onDelete]);
|
|
3266
|
-
return (
|
|
3160
|
+
return (jsxs(Box$f, { className: controlledClassName, ...nativeProps, children: [jsx(Text, { children: children }), jsx(StyledIconButton, { accent: Accent.TERTIARY, Icon: Close, iconSize: 10, onClick: handleDelete })] }));
|
|
3267
3161
|
}
|
|
3268
3162
|
const Box$f = styled.div `
|
|
3269
3163
|
align-items: center;
|
|
@@ -3298,14 +3192,16 @@ const StyledIconButton = styled(IconButton) `
|
|
|
3298
3192
|
`;
|
|
3299
3193
|
|
|
3300
3194
|
const Field$2 = styled.div.attrs(props => ({
|
|
3301
|
-
className:
|
|
3195
|
+
className: classnames('Element-Field', props.className)
|
|
3302
3196
|
})) `
|
|
3303
3197
|
align-items: flex-start;
|
|
3304
3198
|
display: flex;
|
|
3305
3199
|
flex-direction: column;
|
|
3306
3200
|
`;
|
|
3307
3201
|
|
|
3308
|
-
const
|
|
3202
|
+
const Legend = styled.legend.attrs(props => ({
|
|
3203
|
+
className: classnames('Element-Legend', props.className)
|
|
3204
|
+
})) `
|
|
3309
3205
|
color: ${p =>
|
|
3310
3206
|
// eslint-disable-next-line no-nested-ternary
|
|
3311
3207
|
p.disabled ? p.theme.color.lightGray : p.hasError ? p.theme.color.maximumRed : p.theme.color.slateGray};
|
|
@@ -3313,25 +3209,22 @@ p.disabled ? p.theme.color.lightGray : p.hasError ? p.theme.color.maximumRed : p
|
|
|
3313
3209
|
font-size: 13px;
|
|
3314
3210
|
line-height: 1.3846;
|
|
3315
3211
|
margin-bottom: 4px;
|
|
3316
|
-
`;
|
|
3317
|
-
|
|
3318
|
-
function Legend({ disabled = false, hasError = false, isHidden = false, ...nativeProps }) {
|
|
3319
|
-
return jsx(StyledLabel, { as: "legend", disabled: disabled, hasError: hasError, isHidden: isHidden, ...nativeProps });
|
|
3320
|
-
}
|
|
3321
|
-
const StyledLabel = styled(Label) `
|
|
3322
3212
|
padding: 0;
|
|
3323
3213
|
`;
|
|
3324
3214
|
|
|
3325
|
-
function Fieldset({ children, hasBorder = false, hasError = false, isLegendHidden = false, isLight = false, legend, ...nativeProps }) {
|
|
3215
|
+
function Fieldset({ children, className, hasBorder = false, hasError = false, isLegendHidden = false, isLight = false, legend, ...nativeProps }) {
|
|
3326
3216
|
const hasLegend = useMemo(() => Boolean(legend), [legend]);
|
|
3327
|
-
return (jsxs(
|
|
3217
|
+
return (jsxs(Box$e, { className: classnames('Element-Fieldset', className), ...nativeProps, children: [legend && (jsx(Legend, { disabled: nativeProps.disabled, hasError: hasError, isHidden: isLegendHidden, children: legend })), jsx(InnerBox, { "$hasBorder": hasBorder, "$hasLegend": hasLegend, "$isLight": isLight, children: children })] }));
|
|
3328
3218
|
}
|
|
3329
|
-
const
|
|
3219
|
+
const Box$e = styled.fieldset `
|
|
3220
|
+
align-items: flex-start;
|
|
3330
3221
|
border: 0;
|
|
3222
|
+
display: flex;
|
|
3223
|
+
flex-direction: column;
|
|
3331
3224
|
margin: 0;
|
|
3332
3225
|
padding: 0;
|
|
3333
3226
|
`;
|
|
3334
|
-
const
|
|
3227
|
+
const InnerBox = styled.div `
|
|
3335
3228
|
background-color: ${p => (p.$isLight ? p.theme.color.white : 'transparent')};
|
|
3336
3229
|
padding: ${p => (p.$hasBorder || p.$isLight ? '16px' : 0)};
|
|
3337
3230
|
width: 100%;
|
|
@@ -3342,12 +3235,24 @@ const Box$e = styled.div `
|
|
|
3342
3235
|
`}
|
|
3343
3236
|
`;
|
|
3344
3237
|
|
|
3238
|
+
const Label = styled.label.attrs(props => ({
|
|
3239
|
+
className: classnames('Element-Label', props.className)
|
|
3240
|
+
})) `
|
|
3241
|
+
color: ${p =>
|
|
3242
|
+
// eslint-disable-next-line no-nested-ternary
|
|
3243
|
+
p.disabled ? p.theme.color.lightGray : p.hasError ? p.theme.color.maximumRed : p.theme.color.slateGray};
|
|
3244
|
+
display: ${p => (p.isHidden ? 'none' : 'block')};
|
|
3245
|
+
font-size: 13px;
|
|
3246
|
+
line-height: 1.3846;
|
|
3247
|
+
margin-bottom: 4px;
|
|
3248
|
+
`;
|
|
3249
|
+
|
|
3345
3250
|
const Disk = styled.span `
|
|
3346
3251
|
background-color: ${p => p.$color};
|
|
3347
3252
|
border-radius: 50%;
|
|
3348
3253
|
`;
|
|
3349
3254
|
|
|
3350
|
-
function Tag({ accent, bullet, bulletColor, children, color, Icon, isLight = false, ...nativeProps }) {
|
|
3255
|
+
function Tag({ accent, bullet, bulletColor, children, className, color, Icon, isLight = false, ...nativeProps }) {
|
|
3351
3256
|
const commonChildren = useMemo(() => {
|
|
3352
3257
|
const defaultColor = color || THEME.color.gunMetal;
|
|
3353
3258
|
const controlledBulletColor = bulletColor ||
|
|
@@ -3363,8 +3268,9 @@ function Tag({ accent, bullet, bulletColor, children, color, Icon, isLight = fal
|
|
|
3363
3268
|
const commonProps = useMemo(() => ({
|
|
3364
3269
|
$isLight: isLight,
|
|
3365
3270
|
children: commonChildren,
|
|
3271
|
+
className: classnames('Element-Tag', className),
|
|
3366
3272
|
...nativeProps
|
|
3367
|
-
}), [commonChildren, isLight, nativeProps]);
|
|
3273
|
+
}), [className, commonChildren, isLight, nativeProps]);
|
|
3368
3274
|
switch (accent) {
|
|
3369
3275
|
case Accent.PRIMARY:
|
|
3370
3276
|
return jsx(PrimaryTag, { ...commonProps });
|
|
@@ -3412,7 +3318,9 @@ const TertiaryTag = styled(Box$d) `
|
|
|
3412
3318
|
color: ${p => p.theme.color.white};
|
|
3413
3319
|
`;
|
|
3414
3320
|
|
|
3415
|
-
const TagGroup = styled.div
|
|
3321
|
+
const TagGroup = styled.div.attrs(props => ({
|
|
3322
|
+
className: classnames('Element-TagGroup', props.className)
|
|
3323
|
+
})) `
|
|
3416
3324
|
align-items: center;
|
|
3417
3325
|
display: flex;
|
|
3418
3326
|
flex-wrap: wrap;
|
|
@@ -4010,7 +3918,9 @@ var ky$1 = ky;
|
|
|
4010
3918
|
|
|
4011
3919
|
function c(u,e,c){var i=this,a=useRef(null),o=useRef(0),f=useRef(null),l=useRef([]),m=useRef(),v=useRef(),d=useRef(u),p=useRef(!0);useEffect(function(){d.current=u;},[u]);var g=!e&&0!==e&&"undefined"!=typeof window;if("function"!=typeof u)throw new TypeError("Expected a function");e=+e||0;var w=!!(c=c||{}).leading,s=!("trailing"in c)||!!c.trailing,x="maxWait"in c,y=x?Math.max(+c.maxWait||0,e):null;useEffect(function(){return p.current=!0,function(){p.current=!1;}},[]);var h=useMemo(function(){var r=function(r){var n=l.current,t=m.current;return l.current=m.current=null,o.current=r,v.current=d.current.apply(t,n)},n=function(r,n){g&&cancelAnimationFrame(f.current),f.current=g?requestAnimationFrame(r):setTimeout(r,n);},t=function(r){if(!p.current)return !1;var n=r-a.current;return !a.current||n>=e||n<0||x&&r-o.current>=y},u=function(n){return f.current=null,s&&l.current?r(n):(l.current=m.current=null,v.current)},c=function r(){var c=Date.now();if(t(c))return u(c);if(p.current){var i=e-(c-a.current),f=x?Math.min(i,y-(c-o.current)):i;n(r,f);}},h=function(){var u=Date.now(),d=t(u);if(l.current=[].slice.call(arguments),m.current=i,a.current=u,d){if(!f.current&&p.current)return o.current=a.current,n(c,e),w?r(a.current):v.current;if(x)return n(c,e),r(a.current)}return f.current||n(c,e),v.current};return h.cancel=function(){f.current&&(g?cancelAnimationFrame(f.current):clearTimeout(f.current)),o.current=0,l.current=a.current=m.current=f.current=null;},h.isPending=function(){return !!f.current},h.flush=function(){return f.current?u(Date.now()):v.current},h},[w,x,e,y,s,g]);return h}
|
|
4012
3920
|
|
|
4013
|
-
const FieldError = styled.p
|
|
3921
|
+
const FieldError = styled.p.attrs(props => ({
|
|
3922
|
+
className: classnames('Element-FieldError', props.className)
|
|
3923
|
+
})) `
|
|
4014
3924
|
color: ${p => p.theme.color.maximumRed};
|
|
4015
3925
|
display: ${p => (p.isDisabled ? 'none' : 'block')};
|
|
4016
3926
|
font-size: 13px;
|
|
@@ -21288,6 +21198,18 @@ function useKey(deps) {
|
|
|
21288
21198
|
return keyRef.current;
|
|
21289
21199
|
}
|
|
21290
21200
|
|
|
21201
|
+
function getRsuiteValueFromOptionValue(optionValue, optionValueKey) {
|
|
21202
|
+
return optionValue !== undefined ? String(optionValueKey ? optionValue[optionValueKey] : optionValue) : undefined;
|
|
21203
|
+
}
|
|
21204
|
+
|
|
21205
|
+
function getRsuiteDataFromOptions(options, optionValueKey) {
|
|
21206
|
+
return options.map(({ value, ...rest }) => ({
|
|
21207
|
+
...rest,
|
|
21208
|
+
optionValue: value,
|
|
21209
|
+
value: getRsuiteValueFromOptionValue(value, optionValueKey)
|
|
21210
|
+
}));
|
|
21211
|
+
}
|
|
21212
|
+
|
|
21291
21213
|
/**
|
|
21292
21214
|
* Trim and single-space a string
|
|
21293
21215
|
*/
|
|
@@ -21306,27 +21228,20 @@ function normalizeString(text) {
|
|
|
21306
21228
|
return cleanText.length > 0 ? cleanText : undefined;
|
|
21307
21229
|
}
|
|
21308
21230
|
|
|
21309
|
-
function Search({ baseContainer,
|
|
21231
|
+
function Search({ baseContainer, className, error, isErrorMessageHidden = false, isLabelHidden, isLight = false, isSearchIconVisible = true, label, MenuItem, onChange, onQuery, options = [], optionValueKey, queryMap, queryUrl, throttleDuration = 200, value, ...originalProps }) {
|
|
21310
21232
|
// eslint-disable-next-line no-null/no-null
|
|
21311
21233
|
const boxRef = useRef(null);
|
|
21312
21234
|
const queryRef = useRef(undefined);
|
|
21313
|
-
const
|
|
21314
|
-
const [
|
|
21315
|
-
const [autoGeneratedOptions, setAutoGeneratedOptions] = useState([]);
|
|
21316
|
-
const [controlledDefaultValue, setDefaultControlledValue] = useState(defaultValue);
|
|
21235
|
+
const data = useMemo(() => getRsuiteDataFromOptions(options, optionValueKey), [options, optionValueKey]);
|
|
21236
|
+
const [formattedOptions, setFormattedOptions] = useState(data);
|
|
21317
21237
|
const [isOpen, setIsOpen] = useState(false);
|
|
21318
21238
|
const { forceUpdate } = useForceUpdate();
|
|
21239
|
+
const controlledClassName = useMemo(() => classnames('Field-Search', className), [className]);
|
|
21319
21240
|
const controlledError = useMemo(() => normalizeString(error), [error]);
|
|
21320
|
-
const controlledOptions = useMemo(() => options ?? autoGeneratedOptions, [autoGeneratedOptions, options]);
|
|
21321
|
-
const controlledValueAsLabel = useMemo(() => {
|
|
21322
|
-
if (originalProps.disabled) {
|
|
21323
|
-
return undefined;
|
|
21324
|
-
}
|
|
21325
|
-
const foundOption = controlledOptions.find(propEq$1('value', controlledDefaultValue));
|
|
21326
|
-
return foundOption ? foundOption.label : undefined;
|
|
21327
|
-
}, [controlledDefaultValue, controlledOptions, originalProps.disabled]);
|
|
21328
21241
|
const hasError = useMemo(() => Boolean(controlledError), [controlledError]);
|
|
21329
|
-
const key = useKey([
|
|
21242
|
+
const key = useKey([value, originalProps.disabled, originalProps.name]);
|
|
21243
|
+
const rsuiteValue = useMemo(() => getRsuiteValueFromOptionValue(value, optionValueKey), [value, optionValueKey]);
|
|
21244
|
+
const [inputValue, setInputValue] = useState(rsuiteValue);
|
|
21330
21245
|
const close = useCallback(() => {
|
|
21331
21246
|
setIsOpen(false);
|
|
21332
21247
|
}, []);
|
|
@@ -21339,61 +21254,51 @@ function Search({ baseContainer, defaultValue, error, isErrorMessageHidden = fal
|
|
|
21339
21254
|
const rawData = await ky$1.get(url).json();
|
|
21340
21255
|
return rawData.map(_queryMap);
|
|
21341
21256
|
}, throttleDuration);
|
|
21342
|
-
const handleChange = useCallback(async (nextQuery) => {
|
|
21257
|
+
const handleChange = useCallback(async (nextQuery, event) => {
|
|
21343
21258
|
if (!(typeof nextQuery === 'string')) {
|
|
21344
21259
|
return;
|
|
21345
21260
|
}
|
|
21346
|
-
setInputValue(nextQuery);
|
|
21347
21261
|
queryRef.current = normalizeString(nextQuery);
|
|
21262
|
+
if (event.type === 'change') {
|
|
21263
|
+
setInputValue(nextQuery);
|
|
21264
|
+
setIsOpen(Boolean(queryRef.current));
|
|
21265
|
+
}
|
|
21266
|
+
else {
|
|
21267
|
+
setIsOpen(false);
|
|
21268
|
+
}
|
|
21348
21269
|
if (queryUrl && queryMap && queryRef.current) {
|
|
21349
21270
|
const nextData = (await fetchQueryResponse(queryRef.current, queryUrl, queryMap)) || [];
|
|
21350
|
-
|
|
21271
|
+
setFormattedOptions(getRsuiteDataFromOptions(nextData, optionValueKey));
|
|
21351
21272
|
}
|
|
21352
|
-
setIsOpen(Boolean(queryRef.current));
|
|
21353
21273
|
if (onChange && !queryRef.current) {
|
|
21354
21274
|
onChange(undefined);
|
|
21355
21275
|
}
|
|
21356
21276
|
if (onQuery) {
|
|
21357
21277
|
onQuery(queryRef.current);
|
|
21358
21278
|
}
|
|
21359
|
-
}, [onChange, onQuery, queryMap, queryUrl, fetchQueryResponse]);
|
|
21360
|
-
const handleSelect = useCallback((
|
|
21279
|
+
}, [onChange, onQuery, queryMap, queryUrl, fetchQueryResponse, optionValueKey]);
|
|
21280
|
+
const handleSelect = useCallback((_, item) => {
|
|
21361
21281
|
if (onChange) {
|
|
21362
|
-
onChange(
|
|
21282
|
+
onChange(item.optionValue);
|
|
21363
21283
|
}
|
|
21364
|
-
|
|
21284
|
+
setInputValue(item.label);
|
|
21365
21285
|
}, [onChange]);
|
|
21366
|
-
const open = useCallback(() => {
|
|
21367
|
-
if (!queryRef.current) {
|
|
21368
|
-
return;
|
|
21369
|
-
}
|
|
21370
|
-
setIsOpen(true);
|
|
21371
|
-
}, []);
|
|
21372
|
-
useEffect(() => {
|
|
21373
|
-
if (defaultValue === prevDefaultValuePropRef.current) {
|
|
21374
|
-
return;
|
|
21375
|
-
}
|
|
21376
|
-
setDefaultControlledValue(defaultValue);
|
|
21377
|
-
}, [defaultValue]);
|
|
21378
21286
|
useFieldUndefineEffect(originalProps.disabled, onChange);
|
|
21379
21287
|
useClickOutsideEffect(boxRef, close, baseContainer);
|
|
21380
21288
|
useEffect(() => {
|
|
21381
21289
|
forceUpdate();
|
|
21382
21290
|
}, [forceUpdate]);
|
|
21383
|
-
return (jsxs(Field$2, { className:
|
|
21291
|
+
return (jsxs(Field$2, { className: controlledClassName, children: [jsx(Label, { disabled: originalProps.disabled, hasError: hasError, htmlFor: originalProps.name, isHidden: isLabelHidden, children: label }), jsxs(Box$c, { ref: boxRef, isLight: isLight, children: [boxRef.current && (jsx(StyledAutoComplete, { "$isLight": isLight, container: boxRef.current, data: formattedOptions, id: originalProps.name, onChange: handleChange, onSelect: handleSelect, open: isOpen, renderMenuItem: (itemLabel, item) => MenuItem ? jsx(MenuItem, { item: item.value }) : itemLabel, value: inputValue, ...originalProps }, key)), inputValue && (jsxs(Fragment, { children: [jsx(StyledCloseButton, { accent: Accent.TERTIARY, color: THEME.color.slateGray, Icon: Close, isSearchIconVisible: isSearchIconVisible, onClick: clean, size: Size.SMALL }), isSearchIconVisible && jsx(Separator, { children: "|" })] })), isSearchIconVisible && jsx(StyledIconSearch, { color: THEME.color.slateGray, size: 20 })] }), !isErrorMessageHidden && hasError && jsx(FieldError, { children: controlledError })] }));
|
|
21384
21292
|
}
|
|
21385
21293
|
const StyledCloseButton = styled(IconButton) `
|
|
21386
21294
|
cursor: pointer;
|
|
21387
21295
|
height: 30px;
|
|
21388
|
-
margin: 5px ${p => (p.
|
|
21296
|
+
margin: 5px ${p => (p.isSearchIconVisible ? 0 : 5)}px 5px 5px;
|
|
21389
21297
|
padding: 8px;
|
|
21390
21298
|
width: 30px;
|
|
21391
21299
|
`;
|
|
21392
|
-
const
|
|
21393
|
-
border: unset;
|
|
21394
|
-
cursor: pointer;
|
|
21300
|
+
const StyledIconSearch = styled(Search$1) `
|
|
21395
21301
|
margin: 10px 10px 10px 8px;
|
|
21396
|
-
padding: 0px;
|
|
21397
21302
|
`;
|
|
21398
21303
|
const Separator = styled.div `
|
|
21399
21304
|
height: 40px;
|
|
@@ -21410,6 +21315,7 @@ const StyledAutoComplete = styled(AutoComplete) `
|
|
|
21410
21315
|
background-color: ${p => (p.$isLight ? p.theme.color.white : p.theme.color.gainsboro)};
|
|
21411
21316
|
border-width: 0 0 1px;
|
|
21412
21317
|
border-color: ${p => (p.$isLight ? p.theme.color.white : p.theme.color.gainsboro)};
|
|
21318
|
+
|
|
21413
21319
|
font-size: 13px;
|
|
21414
21320
|
width: 100%;
|
|
21415
21321
|
height: 40px;
|
|
@@ -22308,6 +22214,7 @@ function DatePicker({ baseContainer, className, defaultValue, disabled = false,
|
|
|
22308
22214
|
const selectedUtcTimeTupleRef = useRef(getUtcTimeTupleFromDayjs(selectedUtcDateAsDayjsRef.current));
|
|
22309
22215
|
const previousDefaultValue = usePrevious(defaultValue);
|
|
22310
22216
|
const { forceUpdate } = useForceUpdate();
|
|
22217
|
+
const controlledClassName = useMemo(() => classnames('Field-DatePicker', className), [className]);
|
|
22311
22218
|
const controlledError = useMemo(() => normalizeString(error), [error]);
|
|
22312
22219
|
const defaultTimeTuple = useMemo(() => (isEndDate ? ['23', '59'] : ['00', '00']), [isEndDate]);
|
|
22313
22220
|
const hasError = useMemo(() => Boolean(controlledError), [controlledError]);
|
|
@@ -22433,7 +22340,7 @@ function DatePicker({ baseContainer, className, defaultValue, disabled = false,
|
|
|
22433
22340
|
selectedUtcTimeTupleRef.current = getUtcTimeTupleFromDayjs(selectedUtcDateAsDayjsRef.current);
|
|
22434
22341
|
forceUpdate();
|
|
22435
22342
|
}, [defaultValue, forceUpdate, previousDefaultValue]);
|
|
22436
|
-
return (jsxs(Fieldset, { className:
|
|
22343
|
+
return (jsxs(Fieldset, { className: controlledClassName, disabled: disabled, isLegendHidden: isLabelHidden, legend: label, ...nativeProps, children: [jsxs(Box$7, { ref: boxRef, children: [jsx(Field$1, { children: jsx(DateInput, { ref: dateInputRef, baseContainer: baseContainer || undefined, disabled: disabled, isCompact: isCompact, isEndDate: isEndDate, isForcedFocused: isCalendarPickerOpenRef.current, isLight: isLight, onChange: handleDateInputChange, onClick: openCalendarPicker, onInput: handleDateOrTimeInputInput, onNext: handleDateInputNext, value: selectedUtcDateTupleRef.current }) }), withTime && (jsx(Field$1, { "$isTimeField": true, children: jsx(TimeInput, { ref: timeInputRef, baseContainer: baseContainer || undefined, disabled: disabled, isCompact: isCompact, isLight: isLight, minutesRange: minutesRange, onBack: () => dateInputRef.current?.focus(true), onChange: handleTimeInputFilled, onFocus: closeCalendarPicker, onInput: handleDateOrTimeInputInput, onPrevious: () => dateInputRef.current?.focus(true), value: selectedUtcTimeTupleRef.current }, JSON.stringify(selectedUtcTimeTupleRef.current)) }))] }), !isErrorMessageHidden && hasError && jsx(FieldError, { children: controlledError }), jsx(CalendarPicker, { isHistorical: isHistorical, isOpen: isCalendarPickerOpenRef.current, onChange: handleCalendarPickerChange, value: calendarPickerDefaultValue })] }));
|
|
22437
22344
|
}
|
|
22438
22345
|
const Box$7 = styled.div `
|
|
22439
22346
|
* {
|
|
@@ -22664,7 +22571,7 @@ var DateRangePosition;
|
|
|
22664
22571
|
DateRangePosition["START"] = "START";
|
|
22665
22572
|
})(DateRangePosition || (DateRangePosition = {}));
|
|
22666
22573
|
|
|
22667
|
-
function DateRangePicker({ baseContainer, defaultValue, disabled = false, error, isCompact = false, isErrorMessageHidden = false, isHistorical = false, isLabelHidden = false, isLight = false, isStringDate = false, isUndefinedWhenDisabled = false, label, minutesRange = 15, onChange, withTime = false, ...nativeProps }) {
|
|
22574
|
+
function DateRangePicker({ baseContainer, className, defaultValue, disabled = false, error, isCompact = false, isErrorMessageHidden = false, isHistorical = false, isLabelHidden = false, isLight = false, isStringDate = false, isUndefinedWhenDisabled = false, label, minutesRange = 15, onChange, withTime = false, ...nativeProps }) {
|
|
22668
22575
|
/* eslint-disable no-null/no-null */
|
|
22669
22576
|
const startDateInputRef = useRef(null);
|
|
22670
22577
|
const startTimeInputRef = useRef(null);
|
|
@@ -22681,6 +22588,7 @@ function DateRangePicker({ baseContainer, defaultValue, disabled = false, error,
|
|
|
22681
22588
|
const selectedEndTimeTupleRef = useRef(getUtcTimeTupleFromDayjs(selectedEndDateAsDayjsRef.current));
|
|
22682
22589
|
const previousDefaultValue = usePrevious(defaultValue);
|
|
22683
22590
|
const { forceUpdate } = useForceUpdate();
|
|
22591
|
+
const controlledClassName = useMemo(() => classnames('Field-DateRangePicker', className), [className]);
|
|
22684
22592
|
const controlledError = useMemo(() => normalizeString(error), [error]);
|
|
22685
22593
|
const hasError = useMemo(() => Boolean(controlledError), [controlledError]);
|
|
22686
22594
|
const rangeCalendarPickerDefaultValue = useMemo(() => selectedStartDateTupleRef.current && selectedEndDateTupleRef.current
|
|
@@ -22887,7 +22795,7 @@ function DateRangePicker({ baseContainer, defaultValue, disabled = false, error,
|
|
|
22887
22795
|
selectedEndTimeTupleRef.current = getUtcTimeTupleFromDayjs(selectedEndDateAsDayjsRef.current);
|
|
22888
22796
|
forceUpdate();
|
|
22889
22797
|
}, [defaultValue, forceUpdate, previousDefaultValue]);
|
|
22890
|
-
return (jsxs(Fieldset, { className:
|
|
22798
|
+
return (jsxs(Fieldset, { className: controlledClassName, disabled: disabled, isLegendHidden: isLabelHidden, legend: label, ...nativeProps, children: [jsxs(Box$5, { isDisabled: disabled, children: [jsx(Field, { children: jsx(DateInput, { ref: startDateInputRef, baseContainer: baseContainer || undefined, disabled: disabled, isCompact: isCompact, isForcedFocused: isRangeCalendarPickerOpenRef.current, isLight: isLight, isRange: true, isStartDate: true, onChange: (nextDateTuple, isFilled) => handleDateInputChange(DateRangePosition.START, nextDateTuple, isFilled), onClick: openRangeCalendarPicker, onInput: handleDateOrTimeInputInput, onNext: handleStartDateInputNext, value: selectedStartDateTupleRef.current }) }), withTime && (jsx(Field, { isTimeField: true, children: jsx(TimeInput, { ref: startTimeInputRef, baseContainer: baseContainer || undefined, disabled: disabled, isCompact: isCompact, isLight: isLight, isStartDate: true, minutesRange: minutesRange, onBack: () => startDateInputRef.current?.focus(true), onChange: nextTimeTuple => handleTimeInputFilled(DateRangePosition.START, nextTimeTuple), onFocus: closeRangeCalendarPicker, onInput: handleDateOrTimeInputInput, onNext: () => endDateInputRef.current?.focus(), onPrevious: () => startDateInputRef.current?.focus(true), value: selectedStartTimeTupleRef.current }) })), jsx(Field, { isEndDateField: true, children: jsx(DateInput, { ref: endDateInputRef, baseContainer: baseContainer || undefined, disabled: disabled, isCompact: isCompact, isEndDate: true, isForcedFocused: isRangeCalendarPickerOpenRef.current, isLight: isLight, isRange: true, onBack: handleEndDateInputPrevious, onChange: (nextDateTuple, isFilled) => handleDateInputChange(DateRangePosition.END, nextDateTuple, isFilled), onClick: openRangeCalendarPicker, onInput: handleDateOrTimeInputInput, onNext: handleEndDateInputNext, onPrevious: handleEndDateInputPrevious, value: selectedEndDateTupleRef.current }) }), withTime && (jsx(Field, { isTimeField: true, children: jsx(TimeInput, { ref: endTimeInputRef, baseContainer: baseContainer || undefined, disabled: disabled, isCompact: isCompact, isEndDate: true, isLight: isLight, minutesRange: minutesRange, onBack: () => endDateInputRef.current?.focus(true), onChange: nextTimeTuple => handleTimeInputFilled(DateRangePosition.END, nextTimeTuple), onFocus: closeRangeCalendarPicker, onInput: handleDateOrTimeInputInput, onPrevious: () => endDateInputRef.current?.focus(true), value: selectedEndTimeTupleRef.current }) }))] }), !isErrorMessageHidden && hasError && jsx(FieldError, { children: controlledError }), jsx(RangeCalendarPicker, { defaultValue: rangeCalendarPickerDefaultValue, isHistorical: isHistorical, isOpen: isRangeCalendarPickerOpenRef.current, onChange: handleRangeCalendarPickerChange })] }));
|
|
22891
22799
|
}
|
|
22892
22800
|
const Box$5 = styled.div `
|
|
22893
22801
|
* {
|
|
@@ -22971,18 +22879,6 @@ const ChecboxesBox = styled.div `
|
|
|
22971
22879
|
`}
|
|
22972
22880
|
`;
|
|
22973
22881
|
|
|
22974
|
-
function getRsuiteValueFromOptionValue(optionValue, optionValueKey) {
|
|
22975
|
-
return optionValue !== undefined ? String(optionValueKey ? optionValue[optionValueKey] : optionValue) : undefined;
|
|
22976
|
-
}
|
|
22977
|
-
|
|
22978
|
-
function getRsuiteDataFromOptions(options, optionValueKey) {
|
|
22979
|
-
return options.map(({ value, ...rest }) => ({
|
|
22980
|
-
...rest,
|
|
22981
|
-
optionValue: value,
|
|
22982
|
-
value: getRsuiteValueFromOptionValue(value, optionValueKey)
|
|
22983
|
-
}));
|
|
22984
|
-
}
|
|
22985
|
-
|
|
22986
22882
|
function MultiSelect({ baseContainer, disabled = false, error, isErrorMessageHidden = false, isLabelHidden = false, isLight = false, isUndefinedWhenDisabled = false, label, onChange, options, optionValueKey, searchable = false, value, ...originalProps }) {
|
|
22987
22883
|
// eslint-disable-next-line no-null/no-null
|
|
22988
22884
|
const boxRef = useRef(null);
|
|
@@ -32174,6 +32070,7 @@ const Box$1 = styled.div `
|
|
|
32174
32070
|
const noop = () => { };
|
|
32175
32071
|
|
|
32176
32072
|
function CoordinatesInput({ className, coordinatesFormat, defaultValue, error, isLabelHidden = false, isLight = false, label, onChange = noop, ...nativeProps }) {
|
|
32073
|
+
const controlledClassName = classnames('Field-CoordinatesInput', className);
|
|
32177
32074
|
const controlledError = useMemo(() => normalizeString(error), [error]);
|
|
32178
32075
|
const hasError = useMemo(() => Boolean(controlledError), [controlledError]);
|
|
32179
32076
|
const getCoordinatesInput = useCallback(() => {
|
|
@@ -32190,7 +32087,7 @@ function CoordinatesInput({ className, coordinatesFormat, defaultValue, error, i
|
|
|
32190
32087
|
}, [defaultValue, nativeProps.disabled, onChange, coordinatesFormat]);
|
|
32191
32088
|
// TODO We must add a `handleDisable()` callback here to effectively empty the inputs when disabling this field.
|
|
32192
32089
|
useFieldUndefineEffect(nativeProps.disabled, onChange /* , handleDisable */);
|
|
32193
|
-
return (jsxs(StyledFieldset, { className:
|
|
32090
|
+
return (jsxs(StyledFieldset, { className: controlledClassName, isLegendHidden: isLabelHidden, isLight: isLight, legend: label, ...nativeProps, children: [getCoordinatesInput(), hasError && jsx(FieldError, { children: controlledError })] }));
|
|
32194
32091
|
}
|
|
32195
32092
|
const StyledFieldset = styled(Fieldset) `
|
|
32196
32093
|
input {
|
|
@@ -32390,13 +32287,8 @@ const StyledInput = styled(Input) `
|
|
|
32390
32287
|
function FormikSearch({ name, ...originalProps }) {
|
|
32391
32288
|
const [field, meta, helpers] = useField(name);
|
|
32392
32289
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
32393
|
-
const defaultValue = useMemo(() => field.value, []);
|
|
32394
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
32395
32290
|
const handleChange = useMemo(() => helpers.setValue, []);
|
|
32396
|
-
|
|
32397
|
-
return jsx(Search, { name: name, onChange: helpers.setValue, ...originalProps });
|
|
32398
|
-
}
|
|
32399
|
-
return (jsx(Search, { defaultValue: defaultValue, error: meta.error, name: name, onChange: handleChange, ...originalProps }));
|
|
32291
|
+
return jsx(Search, { error: meta.error, name: name, onChange: handleChange, value: field.value, ...originalProps });
|
|
32400
32292
|
}
|
|
32401
32293
|
|
|
32402
32294
|
function FormikCheckbox({ name, ...originalProps }) {
|