@mtes-mct/monitor-ui 6.3.0 → 6.3.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 CHANGED
@@ -1,3 +1,17 @@
1
+ # [6.3.0](https://github.com/MTES-MCT/monitor-ui/compare/v6.2.2...v6.3.0) (2023-05-24)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **fields:** fix multiple performance issues in Select & MultiSelect ([771e33e](https://github.com/MTES-MCT/monitor-ui/commit/771e33e9fcad59f2dbbea1aeb7ef9efeba85d840))
7
+
8
+
9
+ ### Features
10
+
11
+ * **fields:** add customSearch prop to Select & MultiSelect ([217bd58](https://github.com/MTES-MCT/monitor-ui/commit/217bd58142898e8fff89fd7ea748ba3bf7d42144))
12
+ * **libs:** add CustomSearch ([6dfe696](https://github.com/MTES-MCT/monitor-ui/commit/6dfe696d7b11b941ba257da20d59b7ceabb7a7be))
13
+ * **libs:** add isStrict & threshold options to CustomSearch ([c059a57](https://github.com/MTES-MCT/monitor-ui/commit/c059a57ffbfa052bbf3fb7d83e145421dd2c5a57))
14
+
1
15
  ## [6.2.2](https://github.com/MTES-MCT/monitor-ui/compare/v6.2.1...v6.2.2) (2023-05-21)
2
16
 
3
17
 
package/index.js CHANGED
@@ -24522,7 +24522,7 @@ class CustomSearch {
24522
24522
  * @returns A list of matching items
24523
24523
  */
24524
24524
  find(query, limit) {
24525
- const normalizedQuery = this.#isDiacriticSensitive ? query : diacritics.remove(query);
24525
+ const normalizedQuery = (this.#isDiacriticSensitive ? query : diacritics.remove(query)).trim();
24526
24526
  // Here we use Fuse.js `useExtendedSearch` option to avoid fuzziness
24527
24527
  // when `CustomSearch` `isStrict` option is set to `true`.
24528
24528
  // In that case we want each space-separated `query` keywords to be strict
@@ -24611,7 +24611,7 @@ function MultiSelect({ baseContainer, customSearch, disabled = false, error, isE
24611
24611
  // and we use the `customSearchLabelMatches` ref-stored results, in the form of option labels,
24612
24612
  // to check if the current option label is part of these results.
24613
24613
  // Note that options label are expected to be unique in order for this pattern to work.
24614
- boxRef.current && customSearchRef.current
24614
+ customSearchRef.current
24615
24615
  ? (query, _label, item) => {
24616
24616
  if (!customSearchRef.current) {
24617
24617
  throw new Error('`customSearchRef.current` is undefined.');
@@ -24621,6 +24621,7 @@ function MultiSelect({ baseContainer, customSearch, disabled = false, error, isE
24621
24621
  if (query !== previousSearchQueryRef.current) {
24622
24622
  const nextCustomSearchLabelMatches = query.trim().length > 0 ? customSearchRef.current.find(query).map(option => option.label) : undefined;
24623
24623
  customSearchLabelMatchesRef.current = nextCustomSearchLabelMatches;
24624
+ previousSearchQueryRef.current = query;
24624
24625
  }
24625
24626
  return customSearchLabelMatchesRef.current ? customSearchLabelMatchesRef.current.includes(item.label) : true;
24626
24627
  }
@@ -24662,7 +24663,7 @@ function MultiSelect({ baseContainer, customSearch, disabled = false, error, isE
24662
24663
  useEffect(() => {
24663
24664
  forceUpdate();
24664
24665
  }, [forceUpdate]);
24665
- return (jsxs(Field$2, { className: "Field-MultiSelect", children: [jsx(Label, { disabled: disabled, hasError: hasError, htmlFor: originalProps.name, isHidden: isLabelHidden, children: label }), jsx(Box$4, { ref: boxRef, "$hasError": hasError, "$isActive": isOpen, "$isLight": isLight, onClick: toggle, children: boxRef.current && (jsx(TagPicker, { container: boxRef.current, data: rsuiteData, disabled: disabled, id: originalProps.name, onChange: handleChange, onClick: toggle, open: isOpen, renderMenuItem: renderMenuItem, searchable: searchable, searchBy: searchBy, value: selectedRsuiteValue, ...originalProps }, key)) }), !isErrorMessageHidden && hasError && jsx(FieldError, { children: controlledError })] }));
24666
+ return (jsxs(Field$2, { className: "Field-MultiSelect", children: [jsx(Label, { disabled: disabled, hasError: hasError, htmlFor: originalProps.name, isHidden: isLabelHidden, children: label }), jsx(Box$4, { ref: boxRef, "$hasError": hasError, "$isActive": isOpen, "$isLight": isLight, onClick: toggle, children: boxRef.current && (jsx(TagPicker, { container: boxRef.current, data: rsuiteData, disabled: disabled, id: originalProps.name, onChange: handleChange, onClick: toggle, open: isOpen, renderMenuItem: renderMenuItem, searchable: !!customSearch || searchable, searchBy: searchBy, value: selectedRsuiteValue, ...originalProps }, key)) }), !isErrorMessageHidden && hasError && jsx(FieldError, { children: controlledError })] }));
24666
24667
  }
24667
24668
  const Box$4 = styled.div `
24668
24669
  position: relative;
@@ -33873,7 +33874,7 @@ function Select({ baseContainer, customSearch, disabled = false, error, isCleana
33873
33874
  // and we use the `customSearchLabelMatches` ref-stored results, in the form of option labels,
33874
33875
  // to check if the current option label is part of these results.
33875
33876
  // Note that options label are expected to be unique in order for this pattern to work.
33876
- boxRef.current && customSearchRef.current
33877
+ customSearchRef.current
33877
33878
  ? (query, _label, item) => {
33878
33879
  if (!customSearchRef.current) {
33879
33880
  throw new Error('`customSearchRef.current` is undefined.');
@@ -33883,6 +33884,7 @@ function Select({ baseContainer, customSearch, disabled = false, error, isCleana
33883
33884
  if (query !== previousSearchQueryRef.current) {
33884
33885
  const nextCustomSearchLabelMatches = query.trim().length > 0 ? customSearchRef.current.find(query).map(option => option.label) : undefined;
33885
33886
  customSearchLabelMatchesRef.current = nextCustomSearchLabelMatches;
33887
+ previousSearchQueryRef.current = query;
33886
33888
  }
33887
33889
  return customSearchLabelMatchesRef.current ? customSearchLabelMatchesRef.current.includes(item.label) : true;
33888
33890
  }