@workday/canvas-kit-react 8.0.4 → 8.0.6

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.
@@ -2,6 +2,22 @@ import React from 'react';
2
2
 
3
3
  type Modality = 'mouse' | 'touch' | 'pen';
4
4
 
5
+ function safeLocalStorageGet(key: string): string | null {
6
+ try {
7
+ return localStorage.get(key);
8
+ } catch (_) {
9
+ return null;
10
+ }
11
+ }
12
+
13
+ function safeLocalStorageSet(key: string, value: string): void {
14
+ try {
15
+ localStorage.set(key, value);
16
+ } catch (_) {
17
+ // Do nothing
18
+ }
19
+ }
20
+
5
21
  // Use this shared global value to reduce calls to localStorage which is a synchronous API to a
6
22
  // drive which could be slow (spinning disks could be hundreds of ms). We read only once this way.
7
23
  // The following initialization is very difficult to test via automation. Don't mess with it unless
@@ -12,7 +28,7 @@ type Modality = 'mouse' | 'touch' | 'pen';
12
28
  // b. if < 768, default to 'touch'
13
29
  // c. else default to 'mouse'
14
30
  let localStorageValue = ((typeof localStorage !== 'undefined'
15
- ? localStorage.getItem('modality')
31
+ ? safeLocalStorageGet('modality')
16
32
  : '') ||
17
33
  (typeof document !== 'undefined'
18
34
  ? document.documentElement.clientWidth < 768
@@ -26,7 +42,7 @@ let localStorageValue = ((typeof localStorage !== 'undefined'
26
42
  // drives
27
43
  const updateLocalStorage = (value: Modality) => {
28
44
  if (localStorageValue !== value) {
29
- localStorage.setItem('modality', value);
45
+ safeLocalStorageSet('modality', value);
30
46
  }
31
47
  localStorageValue = value;
32
48
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useModalityType.d.ts","sourceRoot":"","sources":["../../../../../common/lib/utils/useModalityType.ts"],"names":[],"mappings":"AAEA,aAAK,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,CAAC;AA+B1C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,QAAO,QAkBlC,CAAC"}
1
+ {"version":3,"file":"useModalityType.d.ts","sourceRoot":"","sources":["../../../../../common/lib/utils/useModalityType.ts"],"names":[],"mappings":"AAEA,aAAK,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,CAAC;AA+C1C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,QAAO,QAkBlC,CAAC"}
@@ -5,6 +5,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.useModalityType = void 0;
7
7
  var react_1 = __importDefault(require("react"));
8
+ function safeLocalStorageGet(key) {
9
+ try {
10
+ return localStorage.get(key);
11
+ }
12
+ catch (_) {
13
+ return null;
14
+ }
15
+ }
16
+ function safeLocalStorageSet(key, value) {
17
+ try {
18
+ localStorage.set(key, value);
19
+ }
20
+ catch (_) {
21
+ // Do nothing
22
+ }
23
+ }
8
24
  // Use this shared global value to reduce calls to localStorage which is a synchronous API to a
9
25
  // drive which could be slow (spinning disks could be hundreds of ms). We read only once this way.
10
26
  // The following initialization is very difficult to test via automation. Don't mess with it unless
@@ -15,7 +31,7 @@ var react_1 = __importDefault(require("react"));
15
31
  // b. if < 768, default to 'touch'
16
32
  // c. else default to 'mouse'
17
33
  var localStorageValue = ((typeof localStorage !== 'undefined'
18
- ? localStorage.getItem('modality')
34
+ ? safeLocalStorageGet('modality')
19
35
  : '') ||
20
36
  (typeof document !== 'undefined'
21
37
  ? document.documentElement.clientWidth < 768
@@ -28,7 +44,7 @@ var localStorageValue = ((typeof localStorage !== 'undefined'
28
44
  // drives
29
45
  var updateLocalStorage = function (value) {
30
46
  if (localStorageValue !== value) {
31
- localStorage.setItem('modality', value);
47
+ safeLocalStorageSet('modality', value);
32
48
  }
33
49
  localStorageValue = value;
34
50
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useModalityType.d.ts","sourceRoot":"","sources":["../../../../../common/lib/utils/useModalityType.ts"],"names":[],"mappings":"AAEA,aAAK,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,CAAC;AA+B1C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,QAAO,QAkBlC,CAAC"}
1
+ {"version":3,"file":"useModalityType.d.ts","sourceRoot":"","sources":["../../../../../common/lib/utils/useModalityType.ts"],"names":[],"mappings":"AAEA,aAAK,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,CAAC;AA+C1C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,QAAO,QAkBlC,CAAC"}
@@ -1,4 +1,20 @@
1
1
  import React from 'react';
2
+ function safeLocalStorageGet(key) {
3
+ try {
4
+ return localStorage.get(key);
5
+ }
6
+ catch (_) {
7
+ return null;
8
+ }
9
+ }
10
+ function safeLocalStorageSet(key, value) {
11
+ try {
12
+ localStorage.set(key, value);
13
+ }
14
+ catch (_) {
15
+ // Do nothing
16
+ }
17
+ }
2
18
  // Use this shared global value to reduce calls to localStorage which is a synchronous API to a
3
19
  // drive which could be slow (spinning disks could be hundreds of ms). We read only once this way.
4
20
  // The following initialization is very difficult to test via automation. Don't mess with it unless
@@ -9,7 +25,7 @@ import React from 'react';
9
25
  // b. if < 768, default to 'touch'
10
26
  // c. else default to 'mouse'
11
27
  var localStorageValue = ((typeof localStorage !== 'undefined'
12
- ? localStorage.getItem('modality')
28
+ ? safeLocalStorageGet('modality')
13
29
  : '') ||
14
30
  (typeof document !== 'undefined'
15
31
  ? document.documentElement.clientWidth < 768
@@ -22,7 +38,7 @@ var localStorageValue = ((typeof localStorage !== 'undefined'
22
38
  // drives
23
39
  var updateLocalStorage = function (value) {
24
40
  if (localStorageValue !== value) {
25
- localStorage.setItem('modality', value);
41
+ safeLocalStorageSet('modality', value);
26
42
  }
27
43
  localStorageValue = value;
28
44
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-react",
3
- "version": "8.0.4",
3
+ "version": "8.0.6",
4
4
  "description": "The parent module that contains all Workday Canvas Kit React components",
5
5
  "author": "Workday, Inc. (https://www.workday.com)",
6
6
  "license": "Apache-2.0",
@@ -49,7 +49,7 @@
49
49
  "@emotion/styled": "^11.6.0",
50
50
  "@popperjs/core": "^2.5.4",
51
51
  "@workday/canvas-colors-web": "^2.0.0",
52
- "@workday/canvas-kit-popup-stack": "^8.0.4",
52
+ "@workday/canvas-kit-popup-stack": "^8.0.6",
53
53
  "@workday/canvas-system-icons-web": "^3.0.0",
54
54
  "@workday/design-assets-types": "^0.2.8",
55
55
  "chroma-js": "^2.1.0",
@@ -67,5 +67,5 @@
67
67
  "@workday/canvas-accent-icons-web": "^3.0.0",
68
68
  "@workday/canvas-applet-icons-web": "^2.0.0"
69
69
  },
70
- "gitHead": "d18afa4048fa7beea381e287abe5f84b1f303c45"
70
+ "gitHead": "73dda0c2a368063f0030a523b31c5771a899fe27"
71
71
  }