@trackunit/filters-filter-bar 1.16.11 → 1.16.15

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.
Files changed (3) hide show
  1. package/index.cjs.js +6 -16
  2. package/index.esm.js +6 -16
  3. package/package.json +12 -12
package/index.cjs.js CHANGED
@@ -580,9 +580,7 @@ const EmptyResults = ({ loading }) => {
580
580
  * @param {DefaultFilterProps<string[]>} props - The properties required for the `DefaultCheckboxFilter` component.
581
581
  */
582
582
  const DefaultCheckboxFilter = ({ filterDefinition, filterBarActions, options, loading, setValue, filterName, customSearch, showRequestMoreUseSearch = false, showUndefinedOptionWithCountAtBottom = true, }) => {
583
- const [undefinedCount, setUndefinedCount] = react.useState(null);
584
583
  const { logEvent } = reactCoreHooks.useAnalytics(FilterEvents);
585
- const [hasSelectedAll, setHasSelectedAll] = react.useState(false);
586
584
  const { t } = useTranslation();
587
585
  const handleSetValue = (value) => {
588
586
  logEvent("Filters Applied - V2", {
@@ -635,34 +633,26 @@ const DefaultCheckboxFilter = ({ filterDefinition, filterBarActions, options, lo
635
633
  }
636
634
  return result;
637
635
  }, [customSearch, options, filteredOptions, showUndefinedOptionWithCountAtBottom]);
638
- react.useEffect(() => {
636
+ const undefinedCount = react.useMemo(() => {
639
637
  const index = results.findIndex(option => option.key === "UNDEFINED");
640
638
  if (index !== -1) {
641
- setUndefinedCount({ count: results[index]?.count, index });
639
+ return { count: results[index]?.count, index };
642
640
  }
641
+ return null;
643
642
  }, [results]);
644
- react.useEffect(() => {
643
+ const hasSelectedAll = react.useMemo(() => {
645
644
  const values = filterBarActions.getValuesByKey(filterDefinition.filterKey);
646
645
  if (Array.isArray(values)) {
647
646
  const optionsLength = undefinedCount ? options.length - 1 : options.length;
648
- if (values.length === optionsLength) {
649
- setHasSelectedAll(true);
650
- }
651
- else {
652
- setHasSelectedAll(false);
653
- }
654
- }
655
- else {
656
- setHasSelectedAll(true);
647
+ return values.length === optionsLength;
657
648
  }
649
+ return true;
658
650
  }, [filterBarActions, filterDefinition.filterKey, options.length, undefinedCount]);
659
651
  const handleSelectAll = () => {
660
652
  if (hasSelectedAll) {
661
653
  setMultipleValues([]);
662
- setHasSelectedAll(false);
663
654
  }
664
655
  else {
665
- setHasSelectedAll(true);
666
656
  let selectValues = options;
667
657
  if (undefinedCount) {
668
658
  selectValues = selectValues.slice(0, undefinedCount.index);
package/index.esm.js CHANGED
@@ -578,9 +578,7 @@ const EmptyResults = ({ loading }) => {
578
578
  * @param {DefaultFilterProps<string[]>} props - The properties required for the `DefaultCheckboxFilter` component.
579
579
  */
580
580
  const DefaultCheckboxFilter = ({ filterDefinition, filterBarActions, options, loading, setValue, filterName, customSearch, showRequestMoreUseSearch = false, showUndefinedOptionWithCountAtBottom = true, }) => {
581
- const [undefinedCount, setUndefinedCount] = useState(null);
582
581
  const { logEvent } = useAnalytics(FilterEvents);
583
- const [hasSelectedAll, setHasSelectedAll] = useState(false);
584
582
  const { t } = useTranslation();
585
583
  const handleSetValue = (value) => {
586
584
  logEvent("Filters Applied - V2", {
@@ -633,34 +631,26 @@ const DefaultCheckboxFilter = ({ filterDefinition, filterBarActions, options, lo
633
631
  }
634
632
  return result;
635
633
  }, [customSearch, options, filteredOptions, showUndefinedOptionWithCountAtBottom]);
636
- useEffect(() => {
634
+ const undefinedCount = useMemo(() => {
637
635
  const index = results.findIndex(option => option.key === "UNDEFINED");
638
636
  if (index !== -1) {
639
- setUndefinedCount({ count: results[index]?.count, index });
637
+ return { count: results[index]?.count, index };
640
638
  }
639
+ return null;
641
640
  }, [results]);
642
- useEffect(() => {
641
+ const hasSelectedAll = useMemo(() => {
643
642
  const values = filterBarActions.getValuesByKey(filterDefinition.filterKey);
644
643
  if (Array.isArray(values)) {
645
644
  const optionsLength = undefinedCount ? options.length - 1 : options.length;
646
- if (values.length === optionsLength) {
647
- setHasSelectedAll(true);
648
- }
649
- else {
650
- setHasSelectedAll(false);
651
- }
652
- }
653
- else {
654
- setHasSelectedAll(true);
645
+ return values.length === optionsLength;
655
646
  }
647
+ return true;
656
648
  }, [filterBarActions, filterDefinition.filterKey, options.length, undefinedCount]);
657
649
  const handleSelectAll = () => {
658
650
  if (hasSelectedAll) {
659
651
  setMultipleValues([]);
660
- setHasSelectedAll(false);
661
652
  }
662
653
  else {
663
- setHasSelectedAll(true);
664
654
  let selectValues = options;
665
655
  if (undefinedCount) {
666
656
  selectValues = selectValues.slice(0, undefinedCount.index);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/filters-filter-bar",
3
- "version": "1.16.11",
3
+ "version": "1.16.15",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -12,17 +12,17 @@
12
12
  "tailwind-merge": "^2.0.0",
13
13
  "string-ts": "^2.0.0",
14
14
  "zod": "^3.23.8",
15
- "@trackunit/iris-app-api": "1.15.5",
16
- "@trackunit/react-core-hooks": "1.12.67",
17
- "@trackunit/react-filter-components": "1.15.11",
18
- "@trackunit/react-date-and-time-components": "1.18.11",
19
- "@trackunit/shared-utils": "1.13.74",
20
- "@trackunit/react-form-components": "1.16.11",
21
- "@trackunit/iris-app-runtime-core-api": "1.12.57",
22
- "@trackunit/geo-json-utils": "1.11.75",
23
- "@trackunit/i18n-library-translation": "1.13.10",
24
- "@trackunit/css-class-variance-utilities": "1.11.74",
25
- "@trackunit/react-components": "1.18.20",
15
+ "@trackunit/iris-app-api": "1.15.7",
16
+ "@trackunit/react-core-hooks": "1.12.69",
17
+ "@trackunit/react-filter-components": "1.15.15",
18
+ "@trackunit/react-date-and-time-components": "1.18.15",
19
+ "@trackunit/shared-utils": "1.13.75",
20
+ "@trackunit/react-form-components": "1.16.15",
21
+ "@trackunit/iris-app-runtime-core-api": "1.12.58",
22
+ "@trackunit/geo-json-utils": "1.11.76",
23
+ "@trackunit/i18n-library-translation": "1.13.13",
24
+ "@trackunit/css-class-variance-utilities": "1.11.75",
25
+ "@trackunit/react-components": "1.18.22",
26
26
  "@tanstack/react-router": "1.114.29"
27
27
  },
28
28
  "module": "./index.esm.js",