@mtes-mct/monitor-ui 2.14.4 → 2.15.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 CHANGED
@@ -1,3 +1,17 @@
1
+ ## [2.14.5](https://github.com/MTES-MCT/monitor-ui/compare/v2.14.4...v2.14.5) (2023-02-09)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **fields:** add css selector for toggle event ([2c61e67](https://github.com/MTES-MCT/monitor-ui/commit/2c61e672fc979d92b43e3912b382754bfcc40eef))
7
+
8
+ ## [2.14.4](https://github.com/MTES-MCT/monitor-ui/compare/v2.14.3...v2.14.4) (2023-02-09)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **formiks:** initialize FormikCheckbox form value on mount ([741505f](https://github.com/MTES-MCT/monitor-ui/commit/741505f7a6705cec2fa439284dff04de43fce962))
14
+
1
15
  ## [2.14.3](https://github.com/MTES-MCT/monitor-ui/compare/v2.14.2...v2.14.3) (2023-02-09)
2
16
 
3
17
 
@@ -0,0 +1,2 @@
1
+ declare const _default: Cypress.ConfigOptions<any>;
2
+ export default _default;
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') {
@@ -5551,6 +5571,7 @@ searchable = false, ...originalProps }) {
5551
5571
  }
5552
5572
  }
5553
5573
  if (targetElement.classList.contains('rs-picker-toggle') ||
5574
+ targetElement.classList.contains('rs-picker-toggle-value') ||
5554
5575
  targetElement.classList.contains('rs-stack-item') ||
5555
5576
  targetElement.classList.contains('rs-picker-toggle-caret') ||
5556
5577
  targetElement.classList.contains('rs-picker-toggle-placeholder')) {
@@ -5565,7 +5586,7 @@ searchable = false, ...originalProps }) {
5565
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,
5566
5587
  // The `unknown` type from Rsuite library is wrong. It should be inferred from `data` prop type.
5567
5588
  // `onChange: ((value: unknown, event: React.SyntheticEvent<Element, Event>) => void) | undefined`
5568
- 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 })] }));
5569
5590
  }
5570
5591
  const StyledSelectPicker = styled(SelectPicker) `
5571
5592
  > .rs-picker-toggle {
@@ -5602,6 +5623,10 @@ const Box = styled.div `
5602
5623
  line-height: 1.3846;
5603
5624
  }
5604
5625
 
5626
+ > .rs-picker-toggle-clean.rs-btn-close {
5627
+ top: 4px !important;
5628
+ }
5629
+
5605
5630
  > svg {
5606
5631
  height: 18px;
5607
5632
  margin-top: -2px;
@@ -5610,6 +5635,38 @@ const Box = styled.div `
5610
5635
  }
5611
5636
  }
5612
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
+ }
5613
5670
  `;
5614
5671
 
5615
5672
  function Textarea({ defaultValue, error, isLabelHidden = false, isLight = false, label, onChange, rows = 3, ...originalProps }) {