@mtes-mct/monitor-ui 2.14.5 → 2.16.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 +16 -0
- package/config/cypress.config.d.ts +2 -0
- package/index.js +65 -13
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/src/elements/Button.d.ts +1 -1
- package/src/elements/IconButton.d.ts +1 -1
- package/src/fields/MultiSelect.d.ts +1 -1
- package/src/fields/Select.d.ts +1 -1
- package/src/index.d.ts +2 -0
- package/e2e/fields.spec.d.ts +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
# [2.15.0](https://github.com/MTES-MCT/monitor-ui/compare/v2.14.5...v2.15.0) (2023-02-10)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **elements:** stop click event propagation in Button & IconButton ([0796b02](https://github.com/MTES-MCT/monitor-ui/commit/0796b02b12fed5fe170fb9b8ce5734f9b54b8c9b))
|
|
7
|
+
* **fields:** add ellipsis for long options in MultiSelect & Select ([0c14f05](https://github.com/MTES-MCT/monitor-ui/commit/0c14f05582d9b8b5454a57908cb5a614837460dd))
|
|
8
|
+
* **fields:** add title to MultiSelect & Select options label ([0d5bca5](https://github.com/MTES-MCT/monitor-ui/commit/0d5bca51b659564c4bac034290b0609b7f693233))
|
|
9
|
+
|
|
10
|
+
## [2.14.5](https://github.com/MTES-MCT/monitor-ui/compare/v2.14.4...v2.14.5) (2023-02-09)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **fields:** add css selector for toggle event ([2c61e67](https://github.com/MTES-MCT/monitor-ui/commit/2c61e672fc979d92b43e3912b382754bfcc40eef))
|
|
16
|
+
|
|
1
17
|
## [2.14.4](https://github.com/MTES-MCT/monitor-ui/compare/v2.14.3...v2.14.4) (2023-02-09)
|
|
2
18
|
|
|
3
19
|
|
package/index.js
CHANGED
|
@@ -2057,21 +2057,32 @@ const Dropdown = Object.assign(RawDropdown, {
|
|
|
2057
2057
|
Item
|
|
2058
2058
|
});
|
|
2059
2059
|
|
|
2060
|
+
function stopMouseEventPropagation(event) {
|
|
2061
|
+
event.stopPropagation();
|
|
2062
|
+
}
|
|
2063
|
+
|
|
2060
2064
|
const ICON_SIZE = {
|
|
2061
2065
|
[Size.LARGE]: 20,
|
|
2062
2066
|
[Size.NORMAL]: 20,
|
|
2063
2067
|
[Size.SMALL]: 12
|
|
2064
2068
|
};
|
|
2065
|
-
function Button({ accent = Accent.PRIMARY, children, Icon, isFullWidth = false, size = Size.NORMAL, type = 'button', ...nativeProps }) {
|
|
2069
|
+
function Button({ accent = Accent.PRIMARY, children, Icon, isFullWidth = false, onClick, size = Size.NORMAL, type = 'button', ...nativeProps }) {
|
|
2066
2070
|
const commonChildren = useMemo(() => (jsxs(Fragment, { children: [Icon && jsx(Icon, { size: ICON_SIZE[size] }), children] })), [children, Icon, size]);
|
|
2071
|
+
const handleClick = useCallback((event) => {
|
|
2072
|
+
stopMouseEventPropagation(event);
|
|
2073
|
+
if (onClick) {
|
|
2074
|
+
onClick(event);
|
|
2075
|
+
}
|
|
2076
|
+
}, [onClick]);
|
|
2067
2077
|
const commonProps = useMemo(() => ({
|
|
2068
2078
|
as: StyledButton$1,
|
|
2069
2079
|
children: commonChildren,
|
|
2070
2080
|
isFullWidth,
|
|
2081
|
+
onClick: handleClick,
|
|
2071
2082
|
size,
|
|
2072
2083
|
type,
|
|
2073
2084
|
...nativeProps
|
|
2074
|
-
}), [commonChildren, isFullWidth, nativeProps, size, type]);
|
|
2085
|
+
}), [commonChildren, isFullWidth, handleClick, nativeProps, size, type]);
|
|
2075
2086
|
switch (accent) {
|
|
2076
2087
|
case Accent.SECONDARY:
|
|
2077
2088
|
return jsx(SecondaryButton, { ...commonProps });
|
|
@@ -2189,7 +2200,7 @@ const ICON_SIZE_IN_PX = {
|
|
|
2189
2200
|
[Size.NORMAL]: 20,
|
|
2190
2201
|
[Size.SMALL]: 14
|
|
2191
2202
|
};
|
|
2192
|
-
function IconButton({ accent = Accent.PRIMARY, color, Icon, iconSize, size = Size.NORMAL, type = 'button', ...nativeProps }) {
|
|
2203
|
+
function IconButton({ accent = Accent.PRIMARY, color, Icon, iconSize, onClick, size = Size.NORMAL, type = 'button', ...nativeProps }) {
|
|
2193
2204
|
const children = useMemo(() => jsx(Icon, { color: color, size: iconSize || ICON_SIZE_IN_PX[size] }), [color, Icon, iconSize, size]);
|
|
2194
2205
|
const commonProps = useMemo(() => ({
|
|
2195
2206
|
children,
|
|
@@ -2197,13 +2208,19 @@ function IconButton({ accent = Accent.PRIMARY, color, Icon, iconSize, size = Siz
|
|
|
2197
2208
|
type,
|
|
2198
2209
|
...nativeProps
|
|
2199
2210
|
}), [children, nativeProps, size, type]);
|
|
2211
|
+
const handleClick = useCallback((event) => {
|
|
2212
|
+
stopMouseEventPropagation(event);
|
|
2213
|
+
if (onClick) {
|
|
2214
|
+
onClick(event);
|
|
2215
|
+
}
|
|
2216
|
+
}, [onClick]);
|
|
2200
2217
|
switch (accent) {
|
|
2201
2218
|
case Accent.SECONDARY:
|
|
2202
|
-
return jsx(SecondaryButton, { as: StyledButton, ...commonProps });
|
|
2219
|
+
return jsx(SecondaryButton, { as: StyledButton, onClick: handleClick, ...commonProps });
|
|
2203
2220
|
case Accent.TERTIARY:
|
|
2204
|
-
return jsx(TertiaryButton, { as: StyledButton, ...commonProps });
|
|
2221
|
+
return jsx(TertiaryButton, { as: StyledButton, onClick: handleClick, ...commonProps });
|
|
2205
2222
|
default:
|
|
2206
|
-
return jsx(PrimaryButton, { as: StyledButton, ...commonProps });
|
|
2223
|
+
return jsx(PrimaryButton, { as: StyledButton, onClick: handleClick, ...commonProps });
|
|
2207
2224
|
}
|
|
2208
2225
|
}
|
|
2209
2226
|
const PADDING = {
|
|
@@ -4258,10 +4275,6 @@ p.$isDisabled
|
|
|
4258
4275
|
}
|
|
4259
4276
|
`;
|
|
4260
4277
|
|
|
4261
|
-
function stopMouseEventPropagation(event) {
|
|
4262
|
-
event.stopPropagation();
|
|
4263
|
-
}
|
|
4264
|
-
|
|
4265
4278
|
function RangedTimePicker({ filter, minutesRange, onChange }) {
|
|
4266
4279
|
const [selectedOptionIndex, setSelectedOptionIndex] = useState(0);
|
|
4267
4280
|
const rangedTimeOptions = useMemo(() => getRangedTimeOptions(minutesRange), [minutesRange]);
|
|
@@ -5265,6 +5278,7 @@ searchable = false, ...originalProps }) {
|
|
|
5265
5278
|
const normalizedNextValue = !nextValue || !nextValue.length ? undefined : nextValue;
|
|
5266
5279
|
onChange(normalizedNextValue);
|
|
5267
5280
|
}, [onChange]);
|
|
5281
|
+
const renderMenuItem = useCallback((_label) => jsx("span", { title: String(_label), children: _label }), []);
|
|
5268
5282
|
const toggle = useCallback((event) => {
|
|
5269
5283
|
let targetElement = event.target;
|
|
5270
5284
|
if (targetElement.tagName === 'path') {
|
|
@@ -5283,7 +5297,7 @@ searchable = false, ...originalProps }) {
|
|
|
5283
5297
|
useEffect(() => {
|
|
5284
5298
|
forceUpdate();
|
|
5285
5299
|
}, [forceUpdate]);
|
|
5286
|
-
return (jsxs(Field$2, { children: [jsx(Label, { disabled: originalProps.disabled, hasError: hasError, htmlFor: originalProps.name, isHidden: isLabelHidden, children: label }), jsx(Box$1, { ref: boxRef, "$isActive": isOpen, "$isLight": isLight, onClick: toggle, children: boxRef.current && (jsx(TagPicker, { container: boxRef.current, data: options, defaultValue: controlledDefaultValue, id: originalProps.name, onChange: handleChange, onClick: toggle, open: isOpen, searchable: searchable, ...originalProps }, key)) }), hasError && jsx(FieldError, { children: controlledError })] }));
|
|
5300
|
+
return (jsxs(Field$2, { children: [jsx(Label, { disabled: originalProps.disabled, hasError: hasError, htmlFor: originalProps.name, isHidden: isLabelHidden, children: label }), jsx(Box$1, { ref: boxRef, "$isActive": isOpen, "$isLight": isLight, onClick: toggle, children: boxRef.current && (jsx(TagPicker, { container: boxRef.current, data: options, defaultValue: controlledDefaultValue, id: originalProps.name, onChange: handleChange, onClick: toggle, open: isOpen, renderMenuItem: renderMenuItem, searchable: searchable, ...originalProps }, key)) }), hasError && jsx(FieldError, { children: controlledError })] }));
|
|
5287
5301
|
}
|
|
5288
5302
|
const Box$1 = styled.div `
|
|
5289
5303
|
position: relative;
|
|
@@ -5340,6 +5354,8 @@ const Box$1 = styled.div `
|
|
|
5340
5354
|
}
|
|
5341
5355
|
|
|
5342
5356
|
> .rs-picker-menu {
|
|
5357
|
+
max-width: 100%;
|
|
5358
|
+
|
|
5343
5359
|
> .rs-picker-check-menu {
|
|
5344
5360
|
margin: 0;
|
|
5345
5361
|
|
|
@@ -5349,7 +5365,10 @@ const Box$1 = styled.div `
|
|
|
5349
5365
|
> label {
|
|
5350
5366
|
font-size: 13px;
|
|
5351
5367
|
line-height: 1.3846;
|
|
5368
|
+
overflow: hidden;
|
|
5352
5369
|
padding: 8px 12px 8px 38px;
|
|
5370
|
+
text-overflow: ellipsis;
|
|
5371
|
+
white-space: nowrap;
|
|
5353
5372
|
|
|
5354
5373
|
> .rs-checkbox-wrapper {
|
|
5355
5374
|
left: 12px;
|
|
@@ -5543,6 +5562,7 @@ searchable = false, ...originalProps }) {
|
|
|
5543
5562
|
onChange(normalizedNextValue);
|
|
5544
5563
|
}
|
|
5545
5564
|
}, [close, onChange]);
|
|
5565
|
+
const renderMenuItem = useCallback((_label) => jsx("span", { title: String(_label), children: _label }), []);
|
|
5546
5566
|
const toggle = useCallback((event) => {
|
|
5547
5567
|
let targetElement = event.target;
|
|
5548
5568
|
if (targetElement.tagName === 'path') {
|
|
@@ -5566,7 +5586,7 @@ searchable = false, ...originalProps }) {
|
|
|
5566
5586
|
return (jsxs(Field$2, { children: [jsx(Label, { disabled: originalProps.disabled, hasError: hasError, htmlFor: originalProps.name, isHidden: isLabelHidden, children: label }), jsx(Box, { ref: boxRef, onClick: toggle, children: boxRef.current && (jsx(StyledSelectPicker, { "$isLight": isLight, container: boxRef.current, data: options, defaultValue: controlledDefaultValue, id: originalProps.name,
|
|
5567
5587
|
// The `unknown` type from Rsuite library is wrong. It should be inferred from `data` prop type.
|
|
5568
5588
|
// `onChange: ((value: unknown, event: React.SyntheticEvent<Element, Event>) => void) | undefined`
|
|
5569
|
-
onChange: handleChange, open: isOpen, searchable: searchable, ...originalProps }, key)) }), hasError && jsx(FieldError, { children: controlledError })] }));
|
|
5589
|
+
onChange: handleChange, open: isOpen, renderMenuItem: renderMenuItem, searchable: searchable, ...originalProps }, key)) }), hasError && jsx(FieldError, { children: controlledError })] }));
|
|
5570
5590
|
}
|
|
5571
5591
|
const StyledSelectPicker = styled(SelectPicker) `
|
|
5572
5592
|
> .rs-picker-toggle {
|
|
@@ -5615,6 +5635,38 @@ const Box = styled.div `
|
|
|
5615
5635
|
}
|
|
5616
5636
|
}
|
|
5617
5637
|
}
|
|
5638
|
+
|
|
5639
|
+
> .rs-picker-menu {
|
|
5640
|
+
max-width: 100%;
|
|
5641
|
+
|
|
5642
|
+
> .rs-picker-search-bar {
|
|
5643
|
+
> .rs-picker-search-bar-input {
|
|
5644
|
+
background-color: ${p => p.theme.color.white};
|
|
5645
|
+
border: solid 1px ${p => p.theme.color.lightGray};
|
|
5646
|
+
border-radius: 0;
|
|
5647
|
+
font-size: 13px;
|
|
5648
|
+
padding: 4px 8px 6px 8px;
|
|
5649
|
+
}
|
|
5650
|
+
|
|
5651
|
+
> svg {
|
|
5652
|
+
color: ${p => p.theme.color.lightGray};
|
|
5653
|
+
top: 11px;
|
|
5654
|
+
}
|
|
5655
|
+
}
|
|
5656
|
+
|
|
5657
|
+
> .rs-picker-select-menu {
|
|
5658
|
+
> div[role='option'] {
|
|
5659
|
+
> .rs-picker-select-menu-item {
|
|
5660
|
+
font-size: 13px;
|
|
5661
|
+
line-height: 1.3846;
|
|
5662
|
+
overflow: hidden;
|
|
5663
|
+
padding: 6px 12px 10px 12px;
|
|
5664
|
+
text-overflow: ellipsis;
|
|
5665
|
+
white-space: nowrap;
|
|
5666
|
+
}
|
|
5667
|
+
}
|
|
5668
|
+
}
|
|
5669
|
+
}
|
|
5618
5670
|
`;
|
|
5619
5671
|
|
|
5620
5672
|
function Textarea({ defaultValue, error, isLabelHidden = false, isLight = false, label, onChange, rows = 3, ...originalProps }) {
|
|
@@ -5793,5 +5845,5 @@ function FormikTextInput({ name, ...originalProps }) {
|
|
|
5793
5845
|
|
|
5794
5846
|
const noop = () => { };
|
|
5795
5847
|
|
|
5796
|
-
export { Accent, AutoComplete, Button, Checkbox, DatePicker, DateRangePicker, Dropdown, Field$2 as Field, Fieldset, FormikAutoComplete, FormikCheckbox, FormikDatePicker, FormikDateRangePicker, FormikEffect, FormikMultiCheckbox, FormikMultiRadio, FormikMultiSelect, FormikNumberInput, FormikSelect, FormikTextInput, FormikTextarea, GlobalStyle, index as Icon, IconButton, Label, Legend, MultiCheckbox, MultiRadio, MultiSelect, MultiZoneEditor, NumberInput, OnlyFontGlobalStyle, Select, SingleTag, Size, THEME, Tag, TagGroup, TextInput, Textarea, ThemeProvider, dayjs, getLocalizedDayjs, getUtcizedDayjs, noop, stopMouseEventPropagation, useClickOutsideEffect, useForceUpdate };
|
|
5848
|
+
export { Accent, AutoComplete, Button, Checkbox, DatePicker, DateRangePicker, Dropdown, Field$2 as Field, Fieldset, FormikAutoComplete, FormikCheckbox, FormikDatePicker, FormikDateRangePicker, FormikEffect, FormikMultiCheckbox, FormikMultiRadio, FormikMultiSelect, FormikNumberInput, FormikSelect, FormikTextInput, FormikTextarea, GlobalStyle, index as Icon, IconButton, Label, Legend, MultiCheckbox, MultiRadio, MultiSelect, MultiZoneEditor, NumberInput, OnlyFontGlobalStyle, Select, SingleTag, Size, THEME, Tag, TagGroup, TextInput, Textarea, ThemeProvider, dayjs, getLocalizedDayjs, getUtcizedDayjs, noop, stopMouseEventPropagation, useClickOutsideEffect, useForceUpdate, useKey, usePrevious };
|
|
5797
5849
|
//# sourceMappingURL=index.js.map
|