@geotab/zenith 1.20.0-beta.4 → 1.20.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.
@@ -36,7 +36,7 @@ const SortableHeaderCell = ({ columnName, isSortedBy, sortDirection, title, tool
36
36
  ? iconFilter3Asc_1.IconFilter3Asc
37
37
  : iconFilter3Desc_1.IconFilter3Desc;
38
38
  }, [sortDirection, isActive]);
39
- const iconButton = ((0, jsx_runtime_1.jsx)(textIconButton_1.TextIconButton, { className: "zen-sortable-column-button__dir-icon zen-caption__post-icon", icon: icon, iconPosition: isMobile ? textIconButton_1.ButtonIconPosition.Start : textIconButton_1.ButtonIconPosition.End, type: buttonType_1.ButtonType.Light, title: iconTitle }));
39
+ const iconButton = ((0, jsx_runtime_1.jsx)(textIconButton_1.TextIconButton, { className: "zen-sortable-column-button__dir-icon zen-caption__post-icon", icon: icon, iconPosition: isMobile ? textIconButton_1.ButtonIconPosition.Start : textIconButton_1.ButtonIconPosition.End, type: buttonType_1.ButtonType.TertiaryBlack, title: iconTitle }));
40
40
  return ((0, jsx_runtime_1.jsx)("div", { className: (0, classNames_1.classNames)([
41
41
  "zen-sortable-column",
42
42
  isSortedBy ? `zen-sortable-column--active` : "",
@@ -21,6 +21,7 @@ const useMobile_1 = require("../commonHelpers/hooks/useMobile");
21
21
  const mobileSheet_1 = require("../mobileSheet/mobileSheet");
22
22
  const footerButtons_1 = require("../footerButtons/footerButtons");
23
23
  const useDriveClassName_1 = require("../utils/theme/useDriveClassName");
24
+ const areMapsEqual_1 = require("./utils/areMapsEqual");
24
25
  const parseLabel = (option, dateFormat, translate, toLacalFn) => {
25
26
  const localeFrom = toLacalFn(option.from);
26
27
  const localeTo = toLacalFn(option.to);
@@ -146,11 +147,16 @@ const DateRange = ({ className, classNamePopup, defaultValue, value, onChange, o
146
147
  const handleMobileBackClick = (0, react_1.useCallback)(() => {
147
148
  setShowMobileCalendar(false);
148
149
  }, []);
150
+ const optionsMapRef = (0, react_1.useRef)(optionsMap);
151
+ const isEqualMaps = (0, react_1.useMemo)(() => (0, areMapsEqual_1.areMapsEqual)(optionsMapRef.current, optionsMap), [optionsMap]);
152
+ if (!isEqualMaps) {
153
+ optionsMapRef.current = optionsMap;
154
+ }
149
155
  (0, react_1.useEffect)(() => {
150
156
  setCustomDate({ from: value === null || value === void 0 ? void 0 : value.from.toISOString(), to: value === null || value === void 0 ? void 0 : value.to.toISOString() });
151
- const currentValue = (0, getRangeOption_1.getSelectedRangeFromValue)(optionsMap, value);
157
+ const currentValue = (0, getRangeOption_1.getSelectedRangeFromValue)(optionsMapRef.current, value);
152
158
  setPrevSelection(currentValue);
153
- }, [optionsMap, value]);
159
+ }, [value, isEqualMaps]);
154
160
  const range = (0, react_1.useMemo)(() => ({ from: customDate.from, to: customDate.to }), [customDate.from, customDate.to]);
155
161
  const component = (0, react_1.useMemo)(() => (0, jsx_runtime_1.jsx)(dateRangeInner_1.DateRangeInner, { id: id || componentId, options: options, onOptionSelect: handleDateRangeSelection, onCalendarSelect: hasCustomOption ? (val) => {
156
162
  setCustomDate({ from: lockStartDate || val.from, to: lockEndDate || (lockStartDate ? val.to || val.from : val.to) });
@@ -0,0 +1,2 @@
1
+ import { IDateRangeOption } from "../dateRangeUtils";
2
+ export declare function areMapsEqual(map1: Map<string, IDateRangeOption>, map2: Map<string, IDateRangeOption>): boolean | undefined;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.areMapsEqual = void 0;
4
+ function areMapsEqual(map1, map2) {
5
+ if (!(map1 instanceof Map) || !(map2 instanceof Map)) {
6
+ return undefined;
7
+ }
8
+ if (map1.size !== map2.size) {
9
+ return false;
10
+ }
11
+ for (const [key1, value1] of map1.entries()) {
12
+ if (!map2.has(key1)) {
13
+ return false;
14
+ }
15
+ const value2 = map2.get(key1);
16
+ if (!value2) {
17
+ return false;
18
+ }
19
+ if (value1.label !== value2.label) {
20
+ return false;
21
+ }
22
+ const range1 = value1.getRange();
23
+ const range2 = value2.getRange();
24
+ if (range1.from.getTime() !== range2.from.getTime() || range1.to.getTime() !== range2.to.getTime()) {
25
+ return false;
26
+ }
27
+ if ((value1.hasSecondaryLabel !== undefined && value2.hasSecondaryLabel !== undefined) && value1.hasSecondaryLabel !== value2.hasSecondaryLabel ||
28
+ (value1.hasSecondaryLabel === undefined && value2.hasSecondaryLabel !== undefined) ||
29
+ (value1.hasSecondaryLabel !== undefined && value2.hasSecondaryLabel === undefined)) {
30
+ return false;
31
+ }
32
+ }
33
+ return true;
34
+ }
35
+ exports.areMapsEqual = areMapsEqual;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geotab/zenith",
3
- "version": "1.20.0-beta.4",
3
+ "version": "1.20.0",
4
4
  "description": "Zenith components library on React",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -93,6 +93,6 @@
93
93
  ]
94
94
  },
95
95
  "publishConfig": {
96
- "access": "public"
97
- }
96
+ "access": "public"
97
+ }
98
98
  }