@mtes-mct/monitor-ui 24.14.1 → 24.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,10 @@
1
+ ## [24.14.1](https://github.com/MTES-MCT/monitor-ui/compare/v24.14.0...v24.14.1) (2025-03-03)
2
+
3
+ ### Buid System & Dependencies
4
+
5
+ * **dev-deps:** bump the all-non-major-dependencies group ([41f36e4](https://github.com/MTES-MCT/monitor-ui/commit/41f36e48ee0e195ab5eb448f24ce042aeaa4f147))
6
+ * **dev-deps:** bump the non-major-dev-dependencies group with 23 updates ([e251f0f](https://github.com/MTES-MCT/monitor-ui/commit/e251f0f6c3f9bdb97c838436a536b4db2756a0d9))
7
+
1
8
  ## [24.14.0](https://github.com/MTES-MCT/monitor-ui/compare/v24.13.0...v24.14.0) (2025-02-24)
2
9
 
3
10
  ### Features
@@ -1 +1 @@
1
- {"version":3,"file":"CheckPicker.d.ts","sourceRoot":"","sources":["../../src/fields/CheckPicker.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAoC,KAAK,gBAAgB,IAAI,sBAAsB,EAAE,MAAM,QAAQ,CAAA;AAQ1G,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAK3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAErD,MAAM,MAAM,gBAAgB,CAAC,WAAW,SAAS,eAAe,GAAG,MAAM,IAAI,IAAI,CAC/E,sBAAsB,CAAC,MAAM,CAAC,EAC9B,IAAI,GAAG,WAAW,GAAG,MAAM,GAAG,cAAc,GAAG,IAAI,GAAG,UAAU,GAAG,gBAAgB,GAAG,OAAO,GAAG,UAAU,CAC3G,GACC,UAAU,CAAC,WAAW,CAAC,CAAA;AAEzB,wBAAgB,WAAW,CAAC,WAAW,SAAS,eAAe,GAAG,MAAM,EAAE,EACxE,SAAS,EACT,YAAY,EACZ,0BAA8B,EAC9B,QAAgB,EAChB,KAAK,EACL,oBAA4B,EAC5B,aAAqB,EACrB,OAAe,EACf,UAAkB,EAClB,aAAqB,EACrB,uBAA+B,EAC/B,KAAK,EACL,QAAQ,EACR,OAAO,EACP,cAAc,EACd,UAAU,EACV,QAAgB,EAChB,UAAkB,EAClB,KAAK,EACL,KAAK,EACL,GAAG,aAAa,EACjB,EAAE,gBAAgB,CAAC,WAAW,CAAC,2CAwG/B"}
1
+ {"version":3,"file":"CheckPicker.d.ts","sourceRoot":"","sources":["../../src/fields/CheckPicker.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAoC,KAAK,gBAAgB,IAAI,sBAAsB,EAAE,MAAM,QAAQ,CAAA;AAI1G,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAM3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAErD,MAAM,MAAM,gBAAgB,CAAC,WAAW,SAAS,eAAe,GAAG,MAAM,IAAI,IAAI,CAC/E,sBAAsB,CAAC,MAAM,CAAC,EAC9B,IAAI,GAAG,WAAW,GAAG,MAAM,GAAG,cAAc,GAAG,IAAI,GAAG,UAAU,GAAG,gBAAgB,GAAG,OAAO,GAAG,UAAU,CAC3G,GACC,UAAU,CAAC,WAAW,CAAC,CAAA;AAEzB,wBAAgB,WAAW,CAAC,WAAW,SAAS,eAAe,GAAG,MAAM,EAAE,EACxE,SAAS,EACT,YAAY,EACZ,0BAA8B,EAC9B,QAAgB,EAChB,KAAK,EACL,oBAA4B,EAC5B,aAAqB,EACrB,OAAe,EACf,UAAkB,EAClB,aAAqB,EACrB,uBAA+B,EAC/B,KAAK,EACL,QAAQ,EACR,OAAO,EACP,cAAc,EACd,UAAU,EACV,QAAgB,EAChB,UAAkB,EAClB,KAAK,EACL,KAAK,EACL,GAAG,aAAa,EACjB,EAAE,gBAAgB,CAAC,WAAW,CAAC,2CAyG/B"}
@@ -0,0 +1,20 @@
1
+ import { type CheckTreePickerProps as RsuiteCheckTreePickerProps } from 'rsuite';
2
+ import type { TreeOption } from './types';
3
+ import type { Promisable } from 'type-fest';
4
+ export type CheckTreePickerProps<TreeOptionValue extends TreeOption[]> = Omit<RsuiteCheckTreePickerProps, 'as' | 'container' | 'data' | 'defaultValue' | 'id' | 'onChange' | 'renderMenuItem' | 'value'> & {
5
+ error?: string | undefined;
6
+ isErrorMessageHidden?: boolean | undefined;
7
+ isLabelHidden?: boolean | undefined;
8
+ isLight?: boolean | undefined;
9
+ isRequired?: boolean | undefined;
10
+ isTransparent?: boolean | undefined;
11
+ isUndefinedWhenDisabled?: boolean | undefined;
12
+ label: string;
13
+ name: string;
14
+ onChange?: (nextValue: TreeOptionValue | undefined) => Promisable<void>;
15
+ options: TreeOptionValue;
16
+ popupWidth?: number | undefined;
17
+ value?: TreeOptionValue | undefined;
18
+ };
19
+ export declare function CheckTreePicker({ className, disabled, error, isErrorMessageHidden, isLabelHidden, isLight, isRequired, isTransparent, isUndefinedWhenDisabled, label, onChange, options, popupWidth, readOnly, style, value, ...originalProps }: CheckTreePickerProps<TreeOption[]>): import("react/jsx-runtime").JSX.Element;
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/CheckTreePicker/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,oBAAoB,IAAI,0BAA0B,EACxD,MAAM,QAAQ,CAAA;AAOf,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAE3C,MAAM,MAAM,oBAAoB,CAAC,eAAe,SAAS,UAAU,EAAE,IAAI,IAAI,CAC3E,0BAA0B,EAC1B,IAAI,GAAG,WAAW,GAAG,MAAM,GAAG,cAAc,GAAG,IAAI,GAAG,UAAU,GAAG,gBAAgB,GAAG,OAAO,CAC9F,GAAG;IACF,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,oBAAoB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC1C,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IACnC,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC7B,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAChC,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IACnC,uBAAuB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC7C,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,eAAe,GAAG,SAAS,KAAK,UAAU,CAAC,IAAI,CAAC,CAAA;IACvE,OAAO,EAAE,eAAe,CAAA;IACxB,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,KAAK,CAAC,EAAE,eAAe,GAAG,SAAS,CAAA;CACpC,CAAA;AAED,wBAAgB,eAAe,CAAC,EAC9B,SAAS,EACT,QAAgB,EAChB,KAAK,EACL,oBAA4B,EAC5B,aAAqB,EACrB,OAAe,EACf,UAAkB,EAClB,aAAqB,EACrB,uBAA+B,EAC/B,KAAK,EACL,QAAQ,EACR,OAAO,EACP,UAAU,EACV,QAAgB,EAChB,KAAK,EACL,KAAK,EACL,GAAG,aAAa,EACjB,EAAE,oBAAoB,CAAC,UAAU,EAAE,CAAC,2CA8EpC"}
@@ -0,0 +1,6 @@
1
+ export interface TreeOption {
2
+ children?: TreeOption[];
3
+ label: string;
4
+ value: string | number;
5
+ }
6
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/fields/CheckTreePicker/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,UAAU,EAAE,CAAA;IACvB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CACvB"}
@@ -0,0 +1,9 @@
1
+ import type { TreeOption } from './types';
2
+ import type { ValueType } from 'rsuite/esm/CheckTreePicker';
3
+ export declare function fromRsuiteValue(selectedValues: ValueType, allOptions: TreeOption[], previousSelectedValues?: ValueType): TreeOption[] | undefined;
4
+ export declare const findItemByValue: (options: TreeOption[], value: string | number) => {
5
+ item: TreeOption;
6
+ parent: TreeOption | undefined;
7
+ } | undefined;
8
+ export declare function toRsuiteValue(uiValues: TreeOption[] | undefined): ValueType | undefined;
9
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/fields/CheckTreePicker/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAE3D,wBAAgB,eAAe,CAC7B,cAAc,EAAE,SAAS,EACzB,UAAU,EAAE,UAAU,EAAE,EACxB,sBAAsB,CAAC,EAAE,SAAS,GACjC,UAAU,EAAE,GAAG,SAAS,CAqB1B;AACD,eAAO,MAAM,eAAe,GAC1B,SAAS,UAAU,EAAE,EACrB,OAAO,MAAM,GAAG,MAAM,KACrB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,UAAU,GAAG,SAAS,CAAA;CAAE,GAAG,SAoBzD,CAAA;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,UAAU,EAAE,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CASvF"}
@@ -3,7 +3,7 @@ type DDCoordinatesInputProps = {
3
3
  coordinates: Coordinates | undefined;
4
4
  disabled: boolean;
5
5
  name: string;
6
- onChange: (nextCoordinates: Coordinates, coordinates: Coordinates | undefined) => void;
6
+ onChange: (nextCoordinates: Coordinates | undefined) => void;
7
7
  readOnly: boolean;
8
8
  };
9
9
  export declare function DDCoordinatesInput({ coordinates, disabled, name, onChange, readOnly }: DDCoordinatesInputProps): import("react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"DDCoordinatesInput.d.ts","sourceRoot":"","sources":["../../../src/fields/CoordinatesInput/DDCoordinatesInput.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAI1D,KAAK,uBAAuB,GAAG;IAC7B,WAAW,EAAE,WAAW,GAAG,SAAS,CAAA;IACpC,QAAQ,EAAE,OAAO,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,CAAC,eAAe,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,GAAG,SAAS,KAAK,IAAI,CAAA;IACtF,QAAQ,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,wBAAgB,kBAAkB,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,uBAAuB,2CAmF9G"}
1
+ {"version":3,"file":"DDCoordinatesInput.d.ts","sourceRoot":"","sources":["../../../src/fields/CoordinatesInput/DDCoordinatesInput.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAI1D,KAAK,uBAAuB,GAAG;IAC7B,WAAW,EAAE,WAAW,GAAG,SAAS,CAAA;IACpC,QAAQ,EAAE,OAAO,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,CAAC,eAAe,EAAE,WAAW,GAAG,SAAS,KAAK,IAAI,CAAA;IAC5D,QAAQ,EAAE,OAAO,CAAA;CAClB,CAAA;AAOD,wBAAgB,kBAAkB,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,uBAAuB,2CAsH9G"}
@@ -0,0 +1,21 @@
1
+ interface CheckPickerBoxProps {
2
+ boxRef: React.RefObject<HTMLDivElement> | undefined;
3
+ children?: React.ReactNode;
4
+ className: string | undefined;
5
+ disabled: boolean;
6
+ error: string | undefined;
7
+ hasError: boolean;
8
+ isErrorMessageHidden: boolean;
9
+ isLabelHidden?: boolean;
10
+ isLight: boolean;
11
+ isRequired?: boolean;
12
+ isTransparent: boolean;
13
+ label: string;
14
+ name: string;
15
+ popupWidth: number | undefined;
16
+ readOnly: boolean;
17
+ style: React.CSSProperties | undefined;
18
+ }
19
+ export declare function CheckPickerBox({ boxRef, children, className, disabled, error, hasError, isErrorMessageHidden, isLabelHidden, isLight, isRequired, isTransparent, label, name, popupWidth, readOnly, style }: CheckPickerBoxProps): import("react/jsx-runtime").JSX.Element;
20
+ export {};
21
+ //# sourceMappingURL=CheckPickerBox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CheckPickerBox.d.ts","sourceRoot":"","sources":["../../../src/fields/shared/CheckPickerBox.tsx"],"names":[],"mappings":"AAMA,UAAU,mBAAmB;IAC3B,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,SAAS,CAAA;IACnD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B,QAAQ,EAAE,OAAO,CAAA;IACjB,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,QAAQ,EAAE,OAAO,CAAA;IACjB,oBAAoB,EAAE,OAAO,CAAA;IAC7B,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,OAAO,EAAE,OAAO,CAAA;IAChB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,aAAa,EAAE,OAAO,CAAA;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,QAAQ,EAAE,OAAO,CAAA;IACjB,KAAK,EAAE,KAAK,CAAC,aAAa,GAAG,SAAS,CAAA;CACvC;AAED,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,oBAAoB,EACpB,aAAa,EACb,OAAO,EACP,UAAU,EACV,aAAa,EACb,KAAK,EACL,IAAI,EACJ,UAAU,EACV,QAAQ,EACR,KAAK,EACN,EAAE,mBAAmB,2CAqBrB"}
@@ -1 +1 @@
1
- {"version":3,"file":"StyledRsuitePickerBox.d.ts","sourceRoot":"","sources":["../../../src/fields/shared/StyledRsuitePickerBox.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAA;AAE1D,eAAO,MAAM,qBAAqB,gQA+TjC,CAAA"}
1
+ {"version":3,"file":"StyledRsuitePickerBox.d.ts","sourceRoot":"","sources":["../../../src/fields/shared/StyledRsuitePickerBox.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAA;AAE1D,eAAO,MAAM,qBAAqB,gQA2djC,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { type CheckTreePickerProps } from '@fields/CheckTreePicker';
2
+ import type { TreeOption } from '@fields/CheckTreePicker/types';
3
+ export type FormikCheckTreePickerProps<TreeOptionValue extends TreeOption[]> = Omit<CheckTreePickerProps<TreeOptionValue>, 'error' | 'onChange' | 'value'>;
4
+ export declare function FormikCheckTreePicker<TreeOptionValue extends TreeOption[]>({ name, ...originalProps }: FormikCheckTreePickerProps<TreeOptionValue>): import("react/jsx-runtime").JSX.Element;
5
+ //# sourceMappingURL=FormikCheckTreePicker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormikCheckTreePicker.d.ts","sourceRoot":"","sources":["../../src/formiks/FormikCheckTreePicker.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAIpF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAA;AAE/D,MAAM,MAAM,0BAA0B,CAAC,eAAe,SAAS,UAAU,EAAE,IAAI,IAAI,CACjF,oBAAoB,CAAC,eAAe,CAAC,EACrC,OAAO,GAAG,UAAU,GAAG,OAAO,CAC/B,CAAA;AACD,wBAAgB,qBAAqB,CAAC,eAAe,SAAS,UAAU,EAAE,EAAE,EAC1E,IAAI,EACJ,GAAG,aAAa,EACjB,EAAE,0BAA0B,CAAC,eAAe,CAAC,2CAgB7C"}
@@ -1,6 +1,4 @@
1
1
  import type { CoordinatesInputProps } from '../fields/CoordinatesInput';
2
- export type FormikCoordinatesInputProps = Omit<CoordinatesInputProps, 'defaultValue' | 'error' | 'onChange'> & {
3
- name: string;
4
- };
2
+ export type FormikCoordinatesInputProps = Omit<CoordinatesInputProps, 'error' | 'onChange'>;
5
3
  export declare function FormikCoordinatesInput({ name, ...originalProps }: FormikCoordinatesInputProps): import("react/jsx-runtime").JSX.Element;
6
4
  //# sourceMappingURL=FormikCoordinatesInput.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FormikCoordinatesInput.d.ts","sourceRoot":"","sources":["../../src/formiks/FormikCoordinatesInput.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAGvE,MAAM,MAAM,2BAA2B,GAAG,IAAI,CAAC,qBAAqB,EAAE,cAAc,GAAG,OAAO,GAAG,UAAU,CAAC,GAAG;IAC7G,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AACD,wBAAgB,sBAAsB,CAAC,EAAE,IAAI,EAAE,GAAG,aAAa,EAAE,EAAE,2BAA2B,2CAsB7F"}
1
+ {"version":3,"file":"FormikCoordinatesInput.d.ts","sourceRoot":"","sources":["../../src/formiks/FormikCoordinatesInput.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAGvE,MAAM,MAAM,2BAA2B,GAAG,IAAI,CAAC,qBAAqB,EAAE,OAAO,GAAG,UAAU,CAAC,CAAA;AAE3F,wBAAgB,sBAAsB,CAAC,EAAE,IAAI,EAAE,GAAG,aAAa,EAAE,EAAE,2BAA2B,2CAgB7F"}
package/index.js CHANGED
@@ -55346,6 +55346,68 @@ const StyledRsuiteCheckbox = styled(Checkbox$1)`
55346
55346
  }, []);
55347
55347
  }
55348
55348
 
55349
+ /**
55350
+ * Force component re-rendering
55351
+ *
55352
+ * @see https://reactjs.org/docs/hooks-faq.html#is-there-something-like-forceupdate
55353
+ */ function useForceUpdate() {
55354
+ const [, forceUpdate] = useReducer((x)=>x + 1, 0);
55355
+ const forceDebouncedUpdate = useMemo(()=>lodashExports.throttle(forceUpdate, 500), [
55356
+ forceUpdate
55357
+ ]);
55358
+ return {
55359
+ forceDebouncedUpdate,
55360
+ forceUpdate
55361
+ };
55362
+ }
55363
+
55364
+ /**
55365
+ * @internal
55366
+ */ function getRsuiteDataItemValueFromOptionValue(optionValue, optionValueKey) {
55367
+ if (optionValueKey) {
55368
+ if (typeof optionValue[optionValueKey] !== 'number' && typeof optionValue[optionValueKey] !== 'string') {
55369
+ throw new Error([
55370
+ `You must provide a valid option value key when using objects as option values.`,
55371
+ `The property value must exist and be a unique number or a string.`,
55372
+ `OptionValue: \`${JSON.stringify(optionValue)}\`.`,
55373
+ `OptionValueKey: \`${String(optionValueKey)}\`.`
55374
+ ].join(' '));
55375
+ }
55376
+ return String(optionValue[optionValueKey]);
55377
+ }
55378
+ if (typeof optionValue !== 'boolean' && typeof optionValue !== 'number' && typeof optionValue !== 'string') {
55379
+ throw new Error([
55380
+ `You must provide an option value key when using objects as option values.`,
55381
+ `OptionValue: \`${JSON.stringify(optionValue)}\`.`
55382
+ ].join(' '));
55383
+ }
55384
+ return String(optionValue);
55385
+ }
55386
+
55387
+ /**
55388
+ * @internal
55389
+ */ function getRsuiteDataItemsFromOptions(options, optionValueKey) {
55390
+ return options.map((option)=>{
55391
+ const { value: optionValue, ...rest } = option;
55392
+ const rsuiteItemDataValue = getRsuiteDataItemValueFromOptionValue(optionValue, optionValueKey);
55393
+ return {
55394
+ ...rest,
55395
+ optionValue,
55396
+ value: rsuiteItemDataValue
55397
+ };
55398
+ });
55399
+ }
55400
+
55401
+ /**
55402
+ * @see {@link getRsuiteDataItemValueFromOptionValue}
55403
+ * @internal
55404
+ */ function getRsuiteDataItemValuesFromOptionValues(optionValues, optionValueKey) {
55405
+ if (!optionValues || optionValues.length === 0) {
55406
+ return [];
55407
+ }
55408
+ return optionValues.map((optionValue)=>getRsuiteDataItemValueFromOptionValue(optionValue, optionValueKey));
55409
+ }
55410
+
55349
55411
  const StyledRsuitePickerBox = styled.div`
55350
55412
  font-size: 13px !important;
55351
55413
  position: relative;
@@ -55661,69 +55723,192 @@ const StyledRsuitePickerBox = styled.div`
55661
55723
  }
55662
55724
  }
55663
55725
  }
55664
- }
55665
- `;
55726
+ /** CheckTreePicker **/
55727
+ > .rs-check-tree {
55728
+ padding: 0;
55729
+ margin: 0;
55730
+ .rs-check-tree-node-icon {
55731
+ margin-top: 4px;
55732
+ &.rs-check-tree-node-expanded {
55733
+ margin-top: -2px;
55734
+ }
55735
+ }
55736
+ [role='treeitem'] {
55737
+ display: flex;
55738
+ align-items: center;
55739
+ .rs-check-item {
55740
+ width: 100%;
55741
+ color: ${(p)=>p.theme.color.gunMetal};
55742
+ line-height: 1;
55743
+ overflow: hidden;
55744
+ text-overflow: ellipsis;
55745
+ white-space: nowrap;
55746
+ .rs-check-item-focus {
55747
+ background-color: none;
55748
+ }
55666
55749
 
55667
- /**
55668
- * Force component re-rendering
55669
- *
55670
- * @see https://reactjs.org/docs/hooks-faq.html#is-there-something-like-forceupdate
55671
- */ function useForceUpdate() {
55672
- const [, forceUpdate] = useReducer((x)=>x + 1, 0);
55673
- const forceDebouncedUpdate = useMemo(()=>lodashExports.throttle(forceUpdate, 500), [
55674
- forceUpdate
55675
- ]);
55676
- return {
55677
- forceDebouncedUpdate,
55678
- forceUpdate
55679
- };
55680
- }
55750
+ &:hover {
55751
+ background-color: ${(p)=>p.theme.color.blueYonder25} !important;
55752
+ color: ${(p)=>p.theme.color.blueYonder} !important;
55753
+ }
55681
55754
 
55682
- /**
55683
- * @internal
55684
- */ function getRsuiteDataItemValueFromOptionValue(optionValue, optionValueKey) {
55685
- if (optionValueKey) {
55686
- if (typeof optionValue[optionValueKey] !== 'number' && typeof optionValue[optionValueKey] !== 'string') {
55687
- throw new Error([
55688
- `You must provide a valid option value key when using objects as option values.`,
55689
- `The property value must exist and be a unique number or a string.`,
55690
- `OptionValue: \`${JSON.stringify(optionValue)}\`.`,
55691
- `OptionValueKey: \`${String(optionValueKey)}\`.`
55692
- ].join(' '));
55755
+ &.rs-picker-select-menu-item-active {
55756
+ background-color: transparent;
55757
+ font-weight: 500;
55758
+
55759
+ &:hover {
55760
+ background-color: ${(p)=>p.theme.color.blueYonder25};
55761
+ }
55762
+ }
55763
+
55764
+ &.rs-picker-select-menu-item-disabled {
55765
+ background-color: transparent;
55766
+ color: ${(p)=>p.theme.color.lightGray};
55767
+ }
55693
55768
  }
55694
- return String(optionValue[optionValueKey]);
55695
- }
55696
- if (typeof optionValue !== 'boolean' && typeof optionValue !== 'number' && typeof optionValue !== 'string') {
55697
- throw new Error([
55698
- `You must provide an option value key when using objects as option values.`,
55699
- `OptionValue: \`${JSON.stringify(optionValue)}\`.`
55700
- ].join(' '));
55701
- }
55702
- return String(optionValue);
55703
- }
55704
55769
 
55705
- /**
55706
- * @internal
55707
- */ function getRsuiteDataItemsFromOptions(options, optionValueKey) {
55708
- return options.map((option)=>{
55709
- const { value: optionValue, ...rest } = option;
55710
- const rsuiteItemDataValue = getRsuiteDataItemValueFromOptionValue(optionValue, optionValueKey);
55711
- return {
55712
- ...rest,
55713
- optionValue,
55714
- value: rsuiteItemDataValue
55715
- };
55716
- });
55717
- }
55770
+ > .rs-check-item {
55771
+ > .rs-checkbox-checker {
55772
+ min-height: auto;
55718
55773
 
55719
- /**
55720
- * @see {@link getRsuiteDataItemValueFromOptionValue}
55721
- * @internal
55722
- */ function getRsuiteDataItemValuesFromOptionValues(optionValues, optionValueKey) {
55723
- if (!optionValues || optionValues.length === 0) {
55724
- return [];
55774
+ > label {
55775
+ color: ${(p)=>p.theme.color.gunMetal};
55776
+ font-size: 13px !important;
55777
+ line-height: 1;
55778
+ overflow: hidden;
55779
+ text-overflow: ellipsis;
55780
+ white-space: nowrap;
55781
+ padding: 1px 0;
55782
+
55783
+ > .rs-check-tree-node-label-content {
55784
+ margin-left: 32px;
55785
+ background-color: initial;
55786
+ color: initial;
55787
+ }
55788
+
55789
+ > .rs-checkbox-wrapper {
55790
+ height: auto;
55791
+ left: 8px;
55792
+ top: 7px !important;
55793
+ margin-left: 8px;
55794
+
55795
+ > .rs-checkbox-inner {
55796
+ &:before {
55797
+ background-color: ${(p)=>p.theme.color.gainsboro};
55798
+ border: solid 2px ${(p)=>p.theme.color.lightGray};
55799
+ border-radius: 0;
55800
+ margin-right: 8px;
55801
+ }
55802
+ }
55803
+ }
55804
+ }
55805
+ }
55806
+
55807
+ &:hover {
55808
+ background-color: ${(p)=>p.theme.color.blueYonder25};
55809
+
55810
+ > .rs-checkbox-checker {
55811
+ > label {
55812
+ color: ${(p)=>p.theme.color.blueYonder};
55813
+
55814
+ > .rs-checkbox-wrapper {
55815
+ > .rs-checkbox-inner {
55816
+ &:before {
55817
+ background-color: ${(p)=>p.theme.color.blueYonder25};
55818
+ border: solid 2px ${(p)=>p.theme.color.blueYonder};
55819
+ }
55820
+ }
55821
+ }
55822
+ }
55823
+ }
55824
+ }
55825
+
55826
+ &.rs-check-item-focus {
55827
+ background-color: ${(p)=>p.theme.color.blueYonder25} !important;
55828
+
55829
+ > .rs-checkbox-checker {
55830
+ > label {
55831
+ font-weight: 400;
55832
+ }
55833
+ }
55834
+ }
55835
+
55836
+ &.rs-checkbox-checked {
55837
+ background-color: transparent;
55838
+
55839
+ &.rs-check-item-focus {
55840
+ background-color: ${(p)=>p.theme.color.blueYonder25} !important;
55841
+ }
55842
+
55843
+ > .rs-checkbox-checker {
55844
+ > label {
55845
+ color: ${(p)=>p.theme.color.gunMetal};
55846
+ font-weight: 500;
55847
+
55848
+ > .rs-checkbox-wrapper {
55849
+ > .rs-checkbox-inner {
55850
+ &:before {
55851
+ background-color: ${(p)=>p.theme.color.charcoal};
55852
+ border: solid 2px ${(p)=>p.theme.color.charcoal};
55853
+ }
55854
+ }
55855
+ }
55856
+ }
55857
+ }
55858
+
55859
+ &:hover,
55860
+ &._hover {
55861
+ background-color: ${(p)=>p.theme.color.blueYonder25};
55862
+
55863
+ > .rs-checkbox-checker {
55864
+ > label {
55865
+ color: ${(p)=>p.theme.color.blueYonder};
55866
+
55867
+ > .rs-checkbox-wrapper {
55868
+ > .rs-checkbox-inner {
55869
+ &:before {
55870
+ background-color: ${(p)=>p.theme.color.blueYonder};
55871
+ border: solid 2px ${(p)=>p.theme.color.blueYonder};
55872
+ }
55873
+ }
55874
+ }
55875
+ }
55876
+ }
55877
+ }
55878
+ }
55879
+ }
55880
+ }
55725
55881
  }
55726
- return optionValues.map((optionValue)=>getRsuiteDataItemValueFromOptionValue(optionValue, optionValueKey));
55882
+ }
55883
+ `;
55884
+
55885
+ function CheckPickerBox({ boxRef, children, className, disabled, error, hasError, isErrorMessageHidden, isLabelHidden, isLight, isRequired, isTransparent, label, name, popupWidth, readOnly, style }) {
55886
+ return /*#__PURE__*/ jsxs(Field$2, {
55887
+ className: className,
55888
+ style: style,
55889
+ children: [
55890
+ /*#__PURE__*/ jsx(Label, {
55891
+ $isDisabled: disabled,
55892
+ $isHidden: isLabelHidden,
55893
+ $isRequired: isRequired,
55894
+ htmlFor: name,
55895
+ children: label
55896
+ }),
55897
+ /*#__PURE__*/ jsx(StyledRsuitePickerBox, {
55898
+ ref: boxRef,
55899
+ $hasError: hasError,
55900
+ $isDisabled: disabled,
55901
+ $isLight: isLight,
55902
+ $isReadOnly: readOnly,
55903
+ $isTransparent: isTransparent,
55904
+ $popupWidth: popupWidth,
55905
+ children: children
55906
+ }),
55907
+ !isErrorMessageHidden && hasError && /*#__PURE__*/ jsx(FieldError, {
55908
+ children: error
55909
+ })
55910
+ ]
55911
+ });
55727
55912
  }
55728
55913
 
55729
55914
  function CheckPicker({ className, customSearch, customSearchMinQueryLength = 1, disabled = false, error, isErrorMessageHidden = false, isLabelHidden = false, isLight = false, isRequired = false, isTransparent = false, isUndefinedWhenDisabled = false, label, onChange, options, optionValueKey, popupWidth, readOnly = false, searchable = false, style, value, ...originalProps }) {
@@ -55782,49 +55967,41 @@ function CheckPicker({ className, customSearch, customSearchMinQueryLength = 1,
55782
55967
  }, [
55783
55968
  forceUpdate
55784
55969
  ]);
55785
- return /*#__PURE__*/ jsxs(Field$2, {
55970
+ return /*#__PURE__*/ jsx(CheckPickerBox, {
55971
+ boxRef: boxRef,
55786
55972
  className: controlledClassName,
55973
+ disabled: disabled,
55974
+ error: controlledError,
55975
+ hasError: hasError,
55976
+ isErrorMessageHidden: isErrorMessageHidden,
55977
+ isLabelHidden: isLabelHidden,
55978
+ isLight: isLight,
55979
+ isRequired: isRequired,
55980
+ isTransparent: isTransparent,
55981
+ label: label,
55982
+ name: originalProps.name,
55983
+ popupWidth: popupWidth,
55984
+ readOnly: readOnly,
55787
55985
  style: style,
55788
- children: [
55789
- /*#__PURE__*/ jsx(Label, {
55790
- $isDisabled: disabled,
55791
- $isHidden: isLabelHidden,
55792
- $isRequired: isRequired,
55793
- htmlFor: originalProps.name,
55794
- children: label
55795
- }),
55796
- /*#__PURE__*/ jsx(StyledRsuitePickerBox, {
55797
- ref: boxRef,
55798
- $hasError: hasError,
55799
- $isDisabled: disabled,
55800
- $isLight: isLight,
55801
- $isReadOnly: readOnly,
55802
- $isTransparent: isTransparent,
55803
- $popupWidth: popupWidth,
55804
- children: boxRef.current && /*#__PURE__*/ jsx(CheckPicker$1, {
55805
- container: boxRef.current,
55806
- // When we use a custom search, we use `controlledRsuiteData` to provide the matching options (data),
55807
- // when we don't, we don't need to control that and just pass the non-internally-controlled `rsuiteData`
55808
- data: controlledRsuiteData ?? rsuiteData,
55809
- disabled: disabled,
55810
- id: originalProps.name,
55811
- onChange: handleChange,
55812
- onSearch: handleSearch,
55813
- readOnly: readOnly,
55814
- renderMenuItem: renderMenuItem,
55815
- searchable: !!customSearch || searchable,
55816
- // When we use a custom search, we use `controlledRsuiteData` to provide the matching options (data),
55817
- // that's why we send this "always true" filter to disable Rsuite CheckPicker internal search filtering
55818
- searchBy: customSearch ? ()=>true : undefined,
55819
- size: originalProps.size ?? 'sm',
55820
- value: selectedRsuiteValue,
55821
- ...originalProps
55822
- })
55823
- }),
55824
- !isErrorMessageHidden && hasError && /*#__PURE__*/ jsx(FieldError, {
55825
- children: controlledError
55826
- })
55827
- ]
55986
+ children: boxRef.current && /*#__PURE__*/ jsx(CheckPicker$1, {
55987
+ container: boxRef.current,
55988
+ // When we use a custom search, we use `controlledRsuiteData` to provide the matching options (data),
55989
+ // when we don't, we don't need to control that and just pass the non-internally-controlled `rsuiteData`
55990
+ data: controlledRsuiteData ?? rsuiteData,
55991
+ disabled: disabled,
55992
+ id: originalProps.name,
55993
+ onChange: handleChange,
55994
+ onSearch: handleSearch,
55995
+ readOnly: readOnly,
55996
+ renderMenuItem: renderMenuItem,
55997
+ searchable: !!customSearch || searchable,
55998
+ // When we use a custom search, we use `controlledRsuiteData` to provide the matching options (data),
55999
+ // that's why we send this "always true" filter to disable Rsuite CheckPicker internal search filtering
56000
+ searchBy: customSearch ? ()=>true : undefined,
56001
+ size: originalProps.size ?? 'sm',
56002
+ value: selectedRsuiteValue,
56003
+ ...originalProps
56004
+ })
55828
56005
  });
55829
56006
  }
55830
56007
 
@@ -55839,74 +56016,103 @@ function isNumeric(val) {
55839
56016
  }
55840
56017
 
55841
56018
  const DECIMAL_PRECISION$1 = 6;
56019
+ function isValueTooLong(value) {
56020
+ return isNumeric(value) && (value?.split('.')?.[1]?.length ?? 0) > DECIMAL_PRECISION$1;
56021
+ }
55842
56022
  // TODO This field should return undefined when cleared (i.e.: Select all & Backspace/Delete)
55843
56023
  function DDCoordinatesInput({ coordinates, disabled, name, onChange, readOnly }) {
55844
- const latitudeInputRef = useRef();
55845
- const longitudeInputRef = useRef();
55846
- const [latitudeError, setLatitudeError] = useState('');
55847
- const [longitudeError, setLongitudeError] = useState('');
55848
- const defaultValue = useMemo(()=>{
55849
- if (!coordinates) {
56024
+ const [latitude, setLatitude] = useState();
56025
+ const [longitude, setLongitude] = useState();
56026
+ const [latitudeError, setLatitudeError] = useState(undefined);
56027
+ const [longitudeError, setLongitudeError] = useState(undefined);
56028
+ const debouncedChange = c((nextLatitude, nextLongitude)=>{
56029
+ if (latitudeError ?? longitudeError) {
56030
+ setLongitudeError(undefined);
56031
+ setLatitudeError(undefined);
56032
+ }
56033
+ if (!isNumeric(latitude) && !!latitude) {
56034
+ setLatitudeError('Champ Latitude incorrect');
55850
56035
  return undefined;
55851
56036
  }
55852
- const [latitude, longitude] = coordinates;
55853
- if (isNumeric(latitude) && isNumeric(longitude)) {
55854
- return {
55855
- latitude: Number(latitude).toFixed(DECIMAL_PRECISION$1),
55856
- longitude: Number(longitude).toFixed(DECIMAL_PRECISION$1)
55857
- };
56037
+ if (!isNumeric(longitude) && !!longitude) {
56038
+ setLongitudeError('Champ Longitude incorrect');
56039
+ return undefined;
55858
56040
  }
55859
- return {
55860
- latitude: undefined,
55861
- longitude: undefined
55862
- };
56041
+ if (!nextLatitude || !nextLongitude) {
56042
+ return onChange(undefined);
56043
+ }
56044
+ return onChange([
56045
+ Number(latitude),
56046
+ Number(longitude)
56047
+ ]);
56048
+ }, 300);
56049
+ useEffect(()=>{
56050
+ debouncedChange(latitude ?? String(coordinates?.[0]), longitude ?? String(coordinates?.[1]));
56051
+ // we don't want to run this effect on every coordinates changes
56052
+ // eslint-disable-next-line react-hooks/exhaustive-deps
55863
56053
  }, [
55864
- coordinates
56054
+ debouncedChange,
56055
+ latitude,
56056
+ longitude
55865
56057
  ]);
55866
- const handleChange = c((nextCoordinates)=>{
55867
- if (!latitudeInputRef.current || !longitudeInputRef.current) {
56058
+ const handleLatitudeChange = (nextValue)=>{
56059
+ const { value } = nextValue.target;
56060
+ if (isValueTooLong(value)) {
55868
56061
  return;
55869
56062
  }
55870
- const latitudeAsString = latitudeInputRef.current.value;
55871
- const longitudeAsString = longitudeInputRef.current.value;
55872
- setLongitudeError('');
55873
- setLatitudeError('');
55874
- if (!isNumeric(latitudeAsString)) {
55875
- setLatitudeError('Champ Latitude incorrect');
56063
+ setLatitude(value);
56064
+ };
56065
+ const handleLongitudeChange = (nextValue)=>{
56066
+ const { value } = nextValue.target;
56067
+ if (isValueTooLong(value)) {
55876
56068
  return;
55877
56069
  }
55878
- if (!isNumeric(longitudeAsString)) {
55879
- setLongitudeError('Champ Longitude incorrect');
55880
- return;
56070
+ setLongitude(value);
56071
+ };
56072
+ const formattedLatitude = (()=>{
56073
+ if (latitude) {
56074
+ return latitude;
56075
+ }
56076
+ const latitudeValue = coordinates?.[0];
56077
+ if (!latitudeValue) {
56078
+ return undefined;
56079
+ }
56080
+ if (isValueTooLong(String(coordinates?.[0]))) {
56081
+ return Number(coordinates?.[0]).toFixed(DECIMAL_PRECISION$1);
56082
+ }
56083
+ return latitudeValue;
56084
+ })();
56085
+ const formattedLongitude = (()=>{
56086
+ if (longitude) {
56087
+ return longitude;
55881
56088
  }
55882
- const latitude = Number(latitudeAsString);
55883
- const longitude = Number(longitudeAsString);
55884
- onChange([
55885
- latitude,
55886
- longitude
55887
- ], nextCoordinates);
55888
- }, 500);
56089
+ if (!coordinates?.[1]) {
56090
+ return undefined;
56091
+ }
56092
+ if (isValueTooLong(String(coordinates?.[1]))) {
56093
+ return Number(coordinates?.[1]).toFixed(DECIMAL_PRECISION$1);
56094
+ }
56095
+ return coordinates?.[1];
56096
+ })();
55889
56097
  return /*#__PURE__*/ jsxs(Box$9, {
55890
56098
  children: [
55891
56099
  /*#__PURE__*/ jsx(DDInput, {
55892
- ref: latitudeInputRef,
55893
56100
  "data-cy": "coordinates-dd-input-lat",
55894
56101
  disabled: disabled,
55895
56102
  name: `${name}-latitude`,
55896
- onChange: ()=>handleChange(coordinates),
56103
+ onChange: handleLatitudeChange,
55897
56104
  placeholder: "Latitude",
55898
56105
  readOnly: readOnly,
55899
- value: defaultValue ? defaultValue.latitude : undefined
56106
+ value: formattedLatitude
55900
56107
  }),
55901
56108
  /*#__PURE__*/ jsx(DDInput, {
55902
- ref: longitudeInputRef,
55903
56109
  "data-cy": "coordinates-dd-input-lon",
55904
56110
  disabled: disabled,
55905
56111
  name: `${name}-longitude`,
55906
- onChange: ()=>handleChange(coordinates),
56112
+ onChange: handleLongitudeChange,
55907
56113
  placeholder: "Longitude",
55908
56114
  readOnly: readOnly,
55909
- value: defaultValue ? defaultValue.longitude : undefined
56115
+ value: formattedLongitude
55910
56116
  }),
55911
56117
  /*#__PURE__*/ jsx(CoordinatesType$2, {
55912
56118
  children: "(DD)"
@@ -66400,7 +66606,7 @@ function CoordinatesInput({ className, coordinatesFormat, defaultValue, disabled
66400
66606
  coordinates: defaultValue,
66401
66607
  disabled: disabled,
66402
66608
  name: name,
66403
- onChange: onChange,
66609
+ onChange: (nextCoordinates)=>onChange(nextCoordinates, defaultValue),
66404
66610
  readOnly: readOnly
66405
66611
  }, key);
66406
66612
  default:
@@ -70663,11 +70869,9 @@ function FormikCheckPicker({ name, ...originalProps }) {
70663
70869
 
70664
70870
  function FormikCoordinatesInput({ name, ...originalProps }) {
70665
70871
  const [field, meta, helpers] = useField(name);
70666
- const handleChange = useMemo(()=>(nextValue)=>{
70667
- helpers.setValue(nextValue);
70668
- }, // We don't want to trigger infinite re-rendering since `helpers.setValue` changes after each rendering
70669
- // eslint-disable-next-line react-hooks/exhaustive-deps
70670
- []);
70872
+ const handleChange = (nextValue)=>{
70873
+ helpers.setValue(nextValue);
70874
+ };
70671
70875
  return /*#__PURE__*/ jsx(CoordinatesInput, {
70672
70876
  ...originalProps,
70673
70877
  defaultValue: field.value,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mtes-mct/monitor-ui",
3
3
  "description": "Common React components, hooks, utilities and CSS stylesheets for MonitorFish, MonitorEnv and RapportNav.",
4
- "version": "24.14.1",
4
+ "version": "24.15.0",
5
5
  "license": "AGPL-3.0",
6
6
  "type": "module",
7
7
  "engines": {