@mtes-mct/monitor-ui 10.8.0 → 10.9.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/index.js CHANGED
@@ -2,7 +2,7 @@ import styled, { createGlobalStyle, ThemeProvider as ThemeProvider$1, css } from
2
2
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
3
  import * as t from 'react';
4
4
  import t__default, { useMemo, PureComponent, forwardRef, useEffect, useReducer, useState, useRef, isValidElement, cloneElement, useLayoutEffect, useCallback, useImperativeHandle, createContext, useContext } from 'react';
5
- import { Dropdown as Dropdown$1, AutoComplete, Checkbox as Checkbox$1, DatePicker as DatePicker$1, DateRangePicker as DateRangePicker$1, TagPicker, Radio, Input, SelectPicker } from 'rsuite';
5
+ import { Dropdown as Dropdown$1, AutoComplete, Checkbox as Checkbox$1, CheckPicker as CheckPicker$1, DatePicker as DatePicker$1, DateRangePicker as DateRangePicker$1, TagPicker, Radio, Input, SelectPicker } from 'rsuite';
6
6
  import { useField, useFormikContext } from 'formik';
7
7
  import { captureMessage } from '@sentry/react';
8
8
 
@@ -2300,7 +2300,7 @@ function stopMouseEventPropagation(event) {
2300
2300
 
2301
2301
  function RawDialog({ children, className, isAbsolute = false, ...nativeProps }) {
2302
2302
  const controlledClassName = classnames('Component-Dialog', className);
2303
- return /*#__PURE__*/ jsxs(Box$i, {
2303
+ return /*#__PURE__*/ jsxs(Box$j, {
2304
2304
  $isAbsolute: isAbsolute,
2305
2305
  className: controlledClassName,
2306
2306
  onClick: stopMouseEventPropagation,
@@ -2316,7 +2316,7 @@ function RawDialog({ children, className, isAbsolute = false, ...nativeProps })
2316
2316
  ]
2317
2317
  });
2318
2318
  }
2319
- const Box$i = styled.div`
2319
+ const Box$j = styled.div`
2320
2320
  position: ${(p)=>p.$isAbsolute ? 'absolute' : 'fixed'};
2321
2321
  top: 0;
2322
2322
  bottom: 0;
@@ -38051,7 +38051,7 @@ function SingleTag({ accent = Accent.PRIMARY, children, className, onDelete, ...
38051
38051
  ]);
38052
38052
  switch(accent){
38053
38053
  case Accent.SECONDARY:
38054
- return /*#__PURE__*/ jsxs(Box$h, {
38054
+ return /*#__PURE__*/ jsxs(Box$i, {
38055
38055
  className: controlledClassName,
38056
38056
  ...nativeProps,
38057
38057
  children: [
@@ -38067,7 +38067,7 @@ function SingleTag({ accent = Accent.PRIMARY, children, className, onDelete, ...
38067
38067
  ]
38068
38068
  });
38069
38069
  default:
38070
- return /*#__PURE__*/ jsxs(Box$h, {
38070
+ return /*#__PURE__*/ jsxs(Box$i, {
38071
38071
  className: controlledClassName,
38072
38072
  ...nativeProps,
38073
38073
  children: [
@@ -38084,7 +38084,7 @@ function SingleTag({ accent = Accent.PRIMARY, children, className, onDelete, ...
38084
38084
  });
38085
38085
  }
38086
38086
  }
38087
- const Box$h = styled.div`
38087
+ const Box$i = styled.div`
38088
38088
  align-items: center;
38089
38089
  display: inline-flex;
38090
38090
  max-width: 100%;
@@ -38219,7 +38219,7 @@ const ExclamationPoint = styled.span`
38219
38219
  function Message({ children, level = Level.WARNING, ...nativeProps }) {
38220
38220
  switch(level){
38221
38221
  case Level.WARNING:
38222
- return /*#__PURE__*/ jsxs(Box$g, {
38222
+ return /*#__PURE__*/ jsxs(Box$h, {
38223
38223
  backgroundColor: THEME.color.goldenPoppy25,
38224
38224
  color: THEME.color.slateGray,
38225
38225
  ...nativeProps,
@@ -38234,7 +38234,7 @@ function Message({ children, level = Level.WARNING, ...nativeProps }) {
38234
38234
  ]
38235
38235
  });
38236
38236
  default:
38237
- return /*#__PURE__*/ jsxs(Box$g, {
38237
+ return /*#__PURE__*/ jsxs(Box$h, {
38238
38238
  backgroundColor: THEME.color.goldenPoppy25,
38239
38239
  color: THEME.color.slateGray,
38240
38240
  ...nativeProps,
@@ -38253,7 +38253,7 @@ function Message({ children, level = Level.WARNING, ...nativeProps }) {
38253
38253
  const Text = styled.div`
38254
38254
  margin-left: 8px;
38255
38255
  `;
38256
- const Box$g = styled.span`
38256
+ const Box$h = styled.span`
38257
38257
  background: ${(p)=>p.backgroundColor || p.theme.color.goldenPoppy25};
38258
38258
  color: ${(p)=>p.color || p.theme.color.slateGray};
38259
38259
  padding: 8px 16px 16px 8px;
@@ -38289,7 +38289,7 @@ function Fieldset({ children, className, hasBorder = false, hasError = false, is
38289
38289
  const hasLegend = useMemo(()=>Boolean(legend), [
38290
38290
  legend
38291
38291
  ]);
38292
- return /*#__PURE__*/ jsxs(Box$f, {
38292
+ return /*#__PURE__*/ jsxs(Box$g, {
38293
38293
  className: classnames('Element-Fieldset', className),
38294
38294
  ...nativeProps,
38295
38295
  children: [
@@ -38308,7 +38308,7 @@ function Fieldset({ children, className, hasBorder = false, hasError = false, is
38308
38308
  ]
38309
38309
  });
38310
38310
  }
38311
- const Box$f = styled.fieldset`
38311
+ const Box$g = styled.fieldset`
38312
38312
  align-items: flex-start;
38313
38313
  border: 0;
38314
38314
  display: flex;
@@ -38405,7 +38405,7 @@ function Tag({ accent, backgroundColor, borderColor, bullet, bulletColor, childr
38405
38405
  ...commonProps
38406
38406
  });
38407
38407
  default:
38408
- return /*#__PURE__*/ jsx(Box$e, {
38408
+ return /*#__PURE__*/ jsx(Box$f, {
38409
38409
  $backgroundColor: backgroundColor,
38410
38410
  $borderColor: borderColor,
38411
38411
  $color: color,
@@ -38413,7 +38413,7 @@ function Tag({ accent, backgroundColor, borderColor, bullet, bulletColor, childr
38413
38413
  });
38414
38414
  }
38415
38415
  }
38416
- const Box$e = styled.span`
38416
+ const Box$f = styled.span`
38417
38417
  align-items: end;
38418
38418
  align-self: flex-start;
38419
38419
  background-color: ${(p)=>{
@@ -38442,16 +38442,16 @@ const Box$e = styled.span`
38442
38442
  margin-right: 4px;
38443
38443
  }
38444
38444
  `;
38445
- const PrimaryTag = styled(Box$e)`
38445
+ const PrimaryTag = styled(Box$f)`
38446
38446
  background-color: ${(p)=>p.$isLight ? p.theme.color.white : p.theme.color.gainsboro};
38447
38447
  color: ${(p)=>p.theme.color.gunMetal};
38448
38448
  `;
38449
38449
  // TODO Fix this color.
38450
- const SecondaryTag = styled(Box$e)`
38450
+ const SecondaryTag = styled(Box$f)`
38451
38451
  background-color: ${(p)=>p.$isLight ? p.theme.color.goldenPoppy : p.theme.color.goldenPoppy};
38452
38452
  color: ${(p)=>p.theme.color.gunMetal};
38453
38453
  `;
38454
- const TertiaryTag = styled(Box$e)`
38454
+ const TertiaryTag = styled(Box$f)`
38455
38455
  background-color: ${(p)=>p.$isLight ? p.theme.color.charcoal : p.theme.color.charcoal};
38456
38456
  color: ${(p)=>p.theme.color.white};
38457
38457
  `;
@@ -55879,7 +55879,7 @@ function Search({ baseContainer, className, customSearch = undefined, customSear
55879
55879
  isHidden: isLabelHidden,
55880
55880
  children: label
55881
55881
  }),
55882
- /*#__PURE__*/ jsxs(Box$d, {
55882
+ /*#__PURE__*/ jsxs(Box$e, {
55883
55883
  ref: boxRef,
55884
55884
  isLight: isLight,
55885
55885
  children: [
@@ -55970,7 +55970,7 @@ const StyledAutoComplete = styled(AutoComplete)`
55970
55970
  }
55971
55971
  }
55972
55972
  `;
55973
- const Box$d = styled.div`
55973
+ const Box$e = styled.div`
55974
55974
  background-color: ${(p)=>p.isLight ? p.theme.color.white : p.theme.color.gainsboro};
55975
55975
  position: relative;
55976
55976
  width: 100%;
@@ -56045,6 +56045,207 @@ const StyledCheckbox = styled(Checkbox$1)`
56045
56045
  }
56046
56046
  `;
56047
56047
 
56048
+ function getRsuiteValuesFromOptionValues(optionValues, optionValueKey) {
56049
+ if (!optionValues || optionValues.length === 0) {
56050
+ return [];
56051
+ }
56052
+ return optionValues.filter((optionValue)=>optionValue !== undefined).map((optionValue)=>String(optionValueKey ? optionValue[optionValueKey] : optionValue));
56053
+ }
56054
+
56055
+ function CheckPicker({ className, customSearch, customSearchMinQueryLength = 1, disabled = false, error, isErrorMessageHidden = false, isLabelHidden = false, isLight = false, isUndefinedWhenDisabled = false, label, onChange, options, optionValueKey, searchable = false, style, value, ...originalProps }) {
56056
+ // eslint-disable-next-line no-null/no-null
56057
+ const boxRef = useRef(null);
56058
+ /** Instance of `CustomSearch` */ const customSearchRef = useRef(customSearch);
56059
+ const controlledClassName = useMemo(()=>classnames('Field-CheckPicker', className), [
56060
+ className
56061
+ ]);
56062
+ const controlledError = useMemo(()=>normalizeString(error), [
56063
+ error
56064
+ ]);
56065
+ const rsuiteData = useMemo(()=>getRsuiteDataFromOptions(options, optionValueKey), [
56066
+ options,
56067
+ optionValueKey
56068
+ ]);
56069
+ const hasError = useMemo(()=>Boolean(controlledError), [
56070
+ controlledError
56071
+ ]);
56072
+ const key = useKey([
56073
+ disabled,
56074
+ originalProps.name
56075
+ ]);
56076
+ const selectedRsuiteValue = useMemo(()=>getRsuiteValuesFromOptionValues(value, optionValueKey), [
56077
+ optionValueKey,
56078
+ value
56079
+ ]);
56080
+ const { forceUpdate } = useForceUpdate();
56081
+ // Only used when `customSearch` prop is set
56082
+ const [controlledRsuiteData, setControlledRsuiteData] = useState(customSearch ? rsuiteData : undefined);
56083
+ const getOptionValuesFromRsuiteDataValues = useCallback((rsuiteValues)=>rsuiteData.reduce((optionsValues, rsuiteDataItem)=>{
56084
+ if (!rsuiteValues.includes(rsuiteDataItem.value)) {
56085
+ return optionsValues;
56086
+ }
56087
+ return [
56088
+ ...optionsValues,
56089
+ rsuiteDataItem.optionValue
56090
+ ];
56091
+ }, []), [
56092
+ rsuiteData
56093
+ ]);
56094
+ const handleChange = useCallback((nextOptionRsuiteValues)=>{
56095
+ if (!onChange) {
56096
+ return;
56097
+ }
56098
+ const nextValue = nextOptionRsuiteValues ? getOptionValuesFromRsuiteDataValues(nextOptionRsuiteValues) : [];
56099
+ const normalizedNextValue = nextValue.length > 0 ? nextValue : undefined;
56100
+ setControlledRsuiteData(rsuiteData);
56101
+ onChange(normalizedNextValue);
56102
+ }, [
56103
+ getOptionValuesFromRsuiteDataValues,
56104
+ onChange,
56105
+ rsuiteData
56106
+ ]);
56107
+ const handleSearch = useCallback((nextQuery)=>{
56108
+ if (!customSearchRef.current || nextQuery.trim().length < customSearchMinQueryLength) {
56109
+ return;
56110
+ }
56111
+ const nextControlledRsuiteData = nextQuery.trim().length >= customSearchMinQueryLength ? getRsuiteDataFromOptions(customSearchRef.current.find(nextQuery), optionValueKey) : rsuiteData;
56112
+ setControlledRsuiteData(nextControlledRsuiteData);
56113
+ }, [
56114
+ customSearchMinQueryLength,
56115
+ optionValueKey,
56116
+ rsuiteData
56117
+ ]);
56118
+ const renderMenuItem = useCallback((node)=>/*#__PURE__*/ jsx("span", {
56119
+ title: String(node),
56120
+ children: String(node)
56121
+ }), []);
56122
+ useFieldUndefineEffect(isUndefinedWhenDisabled && disabled, onChange);
56123
+ useEffect(()=>{
56124
+ forceUpdate();
56125
+ }, [
56126
+ forceUpdate
56127
+ ]);
56128
+ return /*#__PURE__*/ jsxs(Field$2, {
56129
+ className: controlledClassName,
56130
+ style: style,
56131
+ children: [
56132
+ /*#__PURE__*/ jsx(Label, {
56133
+ disabled: disabled,
56134
+ hasError: hasError,
56135
+ htmlFor: originalProps.name,
56136
+ isHidden: isLabelHidden,
56137
+ children: label
56138
+ }),
56139
+ /*#__PURE__*/ jsx(Box$d, {
56140
+ ref: boxRef,
56141
+ $hasError: hasError,
56142
+ $isLight: isLight,
56143
+ children: boxRef.current && /*#__PURE__*/ jsx(CheckPicker$1, {
56144
+ container: boxRef.current,
56145
+ // When we use a custom search, we use `controlledRsuiteData` to provide the matching options (data),
56146
+ // when we don't, we don't need to control that and just pass the non-internally-controlled `rsuiteData`
56147
+ data: controlledRsuiteData || rsuiteData,
56148
+ disabled: disabled,
56149
+ id: originalProps.name,
56150
+ onChange: handleChange,
56151
+ onSearch: handleSearch,
56152
+ renderMenuItem: renderMenuItem,
56153
+ searchable: !!customSearch || searchable,
56154
+ // When we use a custom search, we use `controlledRsuiteData` to provide the matching options (data),
56155
+ // that's why we send this "always true" filter to disable Rsuite CheckPicker internal search filtering
56156
+ searchBy: customSearch ? ()=>true : undefined,
56157
+ size: originalProps.size || 'sm',
56158
+ value: selectedRsuiteValue,
56159
+ ...originalProps
56160
+ }, key)
56161
+ }),
56162
+ !isErrorMessageHidden && hasError && /*#__PURE__*/ jsx(FieldError, {
56163
+ children: controlledError
56164
+ })
56165
+ ]
56166
+ });
56167
+ }
56168
+ const Box$d = styled.div`
56169
+ position: relative;
56170
+ user-select: none;
56171
+ width: 100%;
56172
+
56173
+ > .rs-picker {
56174
+ background-color: ${(p)=>p.$isLight ? p.theme.color.white : p.theme.color.gainsboro} !important;
56175
+ cursor: pointer;
56176
+ width: 100%;
56177
+ height: 30px;
56178
+
56179
+ > .rs-picker-toggle {
56180
+ background-color: ${(p)=>p.$isLight ? p.theme.color.white : p.theme.color.gainsboro} !important;
56181
+ border: solid 1px ${(p)=>p.$hasError ? p.theme.color.maximumRed : p.theme.color.gainsboro} !important;
56182
+ cursor: inherit;
56183
+ font-size: 13px;
56184
+ height: 100%;
56185
+ display: flex;
56186
+ align-items: center;
56187
+ justify-content: space-between;
56188
+
56189
+ :hover {
56190
+ border: solid 1px ${(p)=>p.$hasError ? p.theme.color.maximumRed : p.theme.color.slateGray} !important;
56191
+ }
56192
+
56193
+ :active,
56194
+ :focus {
56195
+ border: solid 1px ${(p)=>p.$hasError ? p.theme.color.maximumRed : p.theme.color.blueGray} !important;
56196
+ }
56197
+
56198
+ > .rs-stack {
56199
+ > .rs-stack-item {
56200
+ > .rs-picker-toggle-placeholder {
56201
+ font-size: 13px;
56202
+ line-height: 1;
56203
+ vertical-align: 1px;
56204
+ }
56205
+ .rs-picker-value-count {
56206
+ background-color: ${(p)=>p.theme.color.charcoal} !important;
56207
+ line-height: 18px !important;
56208
+ }
56209
+
56210
+ .rs-picker-toggle-caret {
56211
+ right: 10px;
56212
+ }
56213
+ .rs-picker-toggle-clean,
56214
+ .rs-picker-toggle-caret {
56215
+ top: 5px;
56216
+ }
56217
+ }
56218
+ }
56219
+ }
56220
+ }
56221
+ > .rs-picker-menu {
56222
+ max-width: 100%;
56223
+ > .rs-picker-check-menu {
56224
+ padding-top: 6px;
56225
+ margin: 0;
56226
+
56227
+ > div[role='option'] {
56228
+ > .rs-check-item {
56229
+ > .rs-checkbox-checker {
56230
+ > label {
56231
+ font-size: 13px;
56232
+ line-height: 1.3846;
56233
+ overflow: hidden;
56234
+ padding: 8px 12px 8px 38px;
56235
+ text-overflow: ellipsis;
56236
+ white-space: nowrap;
56237
+ > .rs-checkbox-wrapper {
56238
+ left: 12px;
56239
+ top: 10px !important;
56240
+ }
56241
+ }
56242
+ }
56243
+ }
56244
+ }
56245
+ }
56246
+ }
56247
+ `;
56248
+
56048
56249
  var dayjs_min = {exports: {}};
56049
56250
 
56050
56251
  var hasRequiredDayjs_min;
@@ -58183,6 +58384,9 @@ function MultiSelect({ baseContainer, className, customSearch, customSearchMinQu
58183
58384
  children: String(node)
58184
58385
  }), []);
58185
58386
  const toggle = useCallback((event)=>{
58387
+ if (disabled) {
58388
+ return;
58389
+ }
58186
58390
  let targetElement = event.target;
58187
58391
  if (targetElement.tagName === 'path') {
58188
58392
  if (targetElement.parentElement) {
@@ -58193,7 +58397,8 @@ function MultiSelect({ baseContainer, className, customSearch, customSearchMinQu
58193
58397
  setIsOpen(!isOpen);
58194
58398
  }
58195
58399
  }, [
58196
- isOpen
58400
+ isOpen,
58401
+ disabled
58197
58402
  ]);
58198
58403
  useFieldUndefineEffect(isUndefinedWhenDisabled && disabled, onChange);
58199
58404
  useClickOutsideEffect(boxRef, close, baseContainer);
@@ -69652,6 +69857,9 @@ function Select({ baseContainer, className, customSearch, customSearchMinQueryLe
69652
69857
  children: String(node)
69653
69858
  }), []);
69654
69859
  const toggle = useCallback((event)=>{
69860
+ if (disabled) {
69861
+ return;
69862
+ }
69655
69863
  let targetElement = event.target;
69656
69864
  if (targetElement.tagName === 'path') {
69657
69865
  if (targetElement.parentElement) {
@@ -69662,7 +69870,8 @@ function Select({ baseContainer, className, customSearch, customSearchMinQueryLe
69662
69870
  setIsOpen(!isOpen);
69663
69871
  }
69664
69872
  }, [
69665
- isOpen
69873
+ isOpen,
69874
+ disabled
69666
69875
  ]);
69667
69876
  useFieldUndefineEffect(isUndefinedWhenDisabled && disabled, onChange);
69668
69877
  useClickOutsideEffect(boxRef, close, baseContainer);
@@ -78408,5 +78617,5 @@ const undefineObjectPropPair = ([key, value])=>[
78408
78617
  return value;
78409
78618
  }
78410
78619
 
78411
- export { Accent, Button$1 as Button, Checkbox, CoordinatesFormat, CoordinatesInput, CustomSearch, DataTable, DatePicker, DateRangePicker, Dialog, Dropdown, ExclamationPoint, Field$2 as Field, FieldError, Fieldset, FormikCheckbox, FormikCoordinatesInput, FormikDatePicker, FormikDateRangePicker, FormikEffect, FormikMultiCheckbox, FormikMultiRadio, FormikMultiSelect, FormikNumberInput, FormikSearch, FormikSelect, FormikTextInput, FormikTextarea, GlobalStyle, index as Icon, IconButton, Label, Legend, Level, MapMenuDialog, Message, MultiCheckbox, MultiRadio, MultiSelect, MultiZoneEditor, NewWindow, NewWindowContext, NotificationEvent, Notifier, NumberInput, OPENLAYERS_PROJECTION, OnlyFontGlobalStyle, Search, Select, SideMenu, SimpleTable, SingleTag, Size, THEME, TableWithSelectableRows, Tag, TagBullet, TagGroup, TextInput, Textarea, ThemeProvider, WSG84_PROJECTION, cleanString, coordinatesAreDistinct, customDayjs, getCoordinates, getHashFromCollection, getLocalizedDayjs, getOptionsFromIdAndName, getOptionsFromLabelledEnum, getPseudoRandomString, getUtcizedDayjs, isArray, isDefined, isNumeric, isObject, logSoftError, normalizeString, nullify, pluralize, stopMouseEventPropagation, undefine, useClickOutsideEffect, useFieldControl, useForceUpdate, useKey, useNewWindow, usePrevious };
78620
+ export { Accent, Button$1 as Button, CheckPicker, Checkbox, CoordinatesFormat, CoordinatesInput, CustomSearch, DataTable, DatePicker, DateRangePicker, Dialog, Dropdown, ExclamationPoint, Field$2 as Field, FieldError, Fieldset, FormikCheckbox, FormikCoordinatesInput, FormikDatePicker, FormikDateRangePicker, FormikEffect, FormikMultiCheckbox, FormikMultiRadio, FormikMultiSelect, FormikNumberInput, FormikSearch, FormikSelect, FormikTextInput, FormikTextarea, GlobalStyle, index as Icon, IconButton, Label, Legend, Level, MapMenuDialog, Message, MultiCheckbox, MultiRadio, MultiSelect, MultiZoneEditor, NewWindow, NewWindowContext, NotificationEvent, Notifier, NumberInput, OPENLAYERS_PROJECTION, OnlyFontGlobalStyle, Search, Select, SideMenu, SimpleTable, SingleTag, Size, THEME, TableWithSelectableRows, Tag, TagBullet, TagGroup, TextInput, Textarea, ThemeProvider, WSG84_PROJECTION, cleanString, coordinatesAreDistinct, customDayjs, getCoordinates, getHashFromCollection, getLocalizedDayjs, getOptionsFromIdAndName, getOptionsFromLabelledEnum, getPseudoRandomString, getUtcizedDayjs, isArray, isDefined, isNumeric, isObject, logSoftError, normalizeString, nullify, pluralize, stopMouseEventPropagation, undefine, useClickOutsideEffect, useFieldControl, useForceUpdate, useKey, useNewWindow, usePrevious };
78412
78621
  //# sourceMappingURL=index.js.map