@etsoo/shared 1.0.83 → 1.0.84

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/README.md CHANGED
@@ -95,8 +95,6 @@ DOM/window related utilities
95
95
  |isJSONContentType|Is JSON content type|
96
96
  |mergeFormData|Merge form data to primary one|
97
97
  |mergeURLSearchParams|Merge URL search parameters|
98
- |saveCountry|Save country name|
99
- |saveCulture|Save culture name|
100
98
  |setFocus|Set HTML element focus by name|
101
99
 
102
100
  ## ExtendUtils
@@ -8,11 +8,11 @@ export declare namespace DomUtils {
8
8
  /**
9
9
  * Language cache parameter name
10
10
  */
11
- const Culture = "culture";
11
+ const CultureField = "EtsooCulture";
12
12
  /**
13
13
  * Country cache parameter name
14
14
  */
15
- const Country = "country";
15
+ const CountryField = "EtsooCountry";
16
16
  /**
17
17
  * Clear form data
18
18
  * @param data Form data
@@ -94,16 +94,6 @@ export declare namespace DomUtils {
94
94
  * @param data New simple object data to merge
95
95
  */
96
96
  function mergeURLSearchParams(base: URLSearchParams, data: DataTypes.SimpleObject): URLSearchParams;
97
- /**
98
- * Save country name
99
- * @param country Country name
100
- */
101
- function saveCountry(country: string): void;
102
- /**
103
- * Save culture name
104
- * @param culture Culture name
105
- */
106
- function saveCulture(culture: string): void;
107
97
  /**
108
98
  * Set HTML element focus by name
109
99
  * @param name Element name or first collection item
@@ -16,11 +16,11 @@ var DomUtils;
16
16
  /**
17
17
  * Language cache parameter name
18
18
  */
19
- DomUtils.Culture = 'culture';
19
+ DomUtils.CultureField = 'EtsooCulture';
20
20
  /**
21
21
  * Country cache parameter name
22
22
  */
23
- DomUtils.Country = 'country';
23
+ DomUtils.CountryField = 'EtsooCountry';
24
24
  /**
25
25
  * Clear form data
26
26
  * @param data Form data
@@ -156,12 +156,12 @@ var DomUtils;
156
156
  * Current detected country
157
157
  */
158
158
  DomUtils.detectedCountry = (() => {
159
+ var _a, _b;
159
160
  // URL first, then local storage
160
161
  let country;
161
162
  try {
162
163
  country =
163
- new URL(location.href).searchParams.get(DomUtils.Country) ||
164
- localStorage.getItem(DomUtils.Country);
164
+ (_b = (_a = new URL(location.href).searchParams.get(DomUtils.CountryField)) !== null && _a !== void 0 ? _a : sessionStorage.getItem(DomUtils.CountryField)) !== null && _b !== void 0 ? _b : localStorage.getItem(DomUtils.CountryField);
165
165
  }
166
166
  catch {
167
167
  country = null;
@@ -173,12 +173,12 @@ var DomUtils;
173
173
  * Current detected culture
174
174
  */
175
175
  DomUtils.detectedCulture = (() => {
176
+ var _a, _b;
176
177
  // URL first, then local storage
177
178
  let culture;
178
179
  try {
179
180
  culture =
180
- new URL(location.href).searchParams.get(DomUtils.Culture) ||
181
- localStorage.getItem(DomUtils.Culture);
181
+ (_b = (_a = new URL(location.href).searchParams.get(DomUtils.CultureField)) !== null && _a !== void 0 ? _a : sessionStorage.getItem(DomUtils.CultureField)) !== null && _b !== void 0 ? _b : localStorage.getItem(DomUtils.CultureField);
182
182
  }
183
183
  catch {
184
184
  culture = null;
@@ -342,22 +342,6 @@ var DomUtils;
342
342
  return base;
343
343
  }
344
344
  DomUtils.mergeURLSearchParams = mergeURLSearchParams;
345
- /**
346
- * Save country name
347
- * @param country Country name
348
- */
349
- function saveCountry(country) {
350
- localStorage.setItem(DomUtils.Country, country);
351
- }
352
- DomUtils.saveCountry = saveCountry;
353
- /**
354
- * Save culture name
355
- * @param culture Culture name
356
- */
357
- function saveCulture(culture) {
358
- localStorage.setItem(DomUtils.Culture, culture);
359
- }
360
- DomUtils.saveCulture = saveCulture;
361
345
  /**
362
346
  * Set HTML element focus by name
363
347
  * @param name Element name or first collection item
@@ -17,6 +17,7 @@ class WindowStorage {
17
17
  if (globalFields.length == 0)
18
18
  return;
19
19
  // Copy global fields to session storage where first item does not exist
20
+ // Duplicate browser tab would copy the session storage
20
21
  const firsItem = sessionStorage.getItem(globalFields[0]);
21
22
  if (firsItem)
22
23
  return;
@@ -8,11 +8,11 @@ export declare namespace DomUtils {
8
8
  /**
9
9
  * Language cache parameter name
10
10
  */
11
- const Culture = "culture";
11
+ const CultureField = "EtsooCulture";
12
12
  /**
13
13
  * Country cache parameter name
14
14
  */
15
- const Country = "country";
15
+ const CountryField = "EtsooCountry";
16
16
  /**
17
17
  * Clear form data
18
18
  * @param data Form data
@@ -94,16 +94,6 @@ export declare namespace DomUtils {
94
94
  * @param data New simple object data to merge
95
95
  */
96
96
  function mergeURLSearchParams(base: URLSearchParams, data: DataTypes.SimpleObject): URLSearchParams;
97
- /**
98
- * Save country name
99
- * @param country Country name
100
- */
101
- function saveCountry(country: string): void;
102
- /**
103
- * Save culture name
104
- * @param culture Culture name
105
- */
106
- function saveCulture(culture: string): void;
107
97
  /**
108
98
  * Set HTML element focus by name
109
99
  * @param name Element name or first collection item
@@ -13,11 +13,11 @@ export var DomUtils;
13
13
  /**
14
14
  * Language cache parameter name
15
15
  */
16
- DomUtils.Culture = 'culture';
16
+ DomUtils.CultureField = 'EtsooCulture';
17
17
  /**
18
18
  * Country cache parameter name
19
19
  */
20
- DomUtils.Country = 'country';
20
+ DomUtils.CountryField = 'EtsooCountry';
21
21
  /**
22
22
  * Clear form data
23
23
  * @param data Form data
@@ -153,12 +153,12 @@ export var DomUtils;
153
153
  * Current detected country
154
154
  */
155
155
  DomUtils.detectedCountry = (() => {
156
+ var _a, _b;
156
157
  // URL first, then local storage
157
158
  let country;
158
159
  try {
159
160
  country =
160
- new URL(location.href).searchParams.get(DomUtils.Country) ||
161
- localStorage.getItem(DomUtils.Country);
161
+ (_b = (_a = new URL(location.href).searchParams.get(DomUtils.CountryField)) !== null && _a !== void 0 ? _a : sessionStorage.getItem(DomUtils.CountryField)) !== null && _b !== void 0 ? _b : localStorage.getItem(DomUtils.CountryField);
162
162
  }
163
163
  catch {
164
164
  country = null;
@@ -170,12 +170,12 @@ export var DomUtils;
170
170
  * Current detected culture
171
171
  */
172
172
  DomUtils.detectedCulture = (() => {
173
+ var _a, _b;
173
174
  // URL first, then local storage
174
175
  let culture;
175
176
  try {
176
177
  culture =
177
- new URL(location.href).searchParams.get(DomUtils.Culture) ||
178
- localStorage.getItem(DomUtils.Culture);
178
+ (_b = (_a = new URL(location.href).searchParams.get(DomUtils.CultureField)) !== null && _a !== void 0 ? _a : sessionStorage.getItem(DomUtils.CultureField)) !== null && _b !== void 0 ? _b : localStorage.getItem(DomUtils.CultureField);
179
179
  }
180
180
  catch {
181
181
  culture = null;
@@ -339,22 +339,6 @@ export var DomUtils;
339
339
  return base;
340
340
  }
341
341
  DomUtils.mergeURLSearchParams = mergeURLSearchParams;
342
- /**
343
- * Save country name
344
- * @param country Country name
345
- */
346
- function saveCountry(country) {
347
- localStorage.setItem(DomUtils.Country, country);
348
- }
349
- DomUtils.saveCountry = saveCountry;
350
- /**
351
- * Save culture name
352
- * @param culture Culture name
353
- */
354
- function saveCulture(culture) {
355
- localStorage.setItem(DomUtils.Culture, culture);
356
- }
357
- DomUtils.saveCulture = saveCulture;
358
342
  /**
359
343
  * Set HTML element focus by name
360
344
  * @param name Element name or first collection item
@@ -14,6 +14,7 @@ export class WindowStorage {
14
14
  if (globalFields.length == 0)
15
15
  return;
16
16
  // Copy global fields to session storage where first item does not exist
17
+ // Duplicate browser tab would copy the session storage
17
18
  const firsItem = sessionStorage.getItem(globalFields[0]);
18
19
  if (firsItem)
19
20
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/shared",
3
- "version": "1.0.83",
3
+ "version": "1.0.84",
4
4
  "description": "TypeScript shared utilities and functions",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
package/src/DomUtils.ts CHANGED
@@ -15,12 +15,12 @@ export namespace DomUtils {
15
15
  /**
16
16
  * Language cache parameter name
17
17
  */
18
- export const Culture = 'culture';
18
+ export const CultureField = 'EtsooCulture';
19
19
 
20
20
  /**
21
21
  * Country cache parameter name
22
22
  */
23
- export const Country = 'country';
23
+ export const CountryField = 'EtsooCountry';
24
24
 
25
25
  /**
26
26
  * Clear form data
@@ -198,8 +198,9 @@ export namespace DomUtils {
198
198
  let country: string | null;
199
199
  try {
200
200
  country =
201
- new URL(location.href).searchParams.get(Country) ||
202
- localStorage.getItem(Country);
201
+ new URL(location.href).searchParams.get(CountryField) ??
202
+ sessionStorage.getItem(CountryField) ??
203
+ localStorage.getItem(CountryField);
203
204
  } catch {
204
205
  country = null;
205
206
  }
@@ -216,8 +217,9 @@ export namespace DomUtils {
216
217
  let culture: string | null;
217
218
  try {
218
219
  culture =
219
- new URL(location.href).searchParams.get(Culture) ||
220
- localStorage.getItem(Culture);
220
+ new URL(location.href).searchParams.get(CultureField) ??
221
+ sessionStorage.getItem(CultureField) ??
222
+ localStorage.getItem(CultureField);
221
223
  } catch {
222
224
  culture = null;
223
225
  }
@@ -415,22 +417,6 @@ export namespace DomUtils {
415
417
  return base;
416
418
  }
417
419
 
418
- /**
419
- * Save country name
420
- * @param country Country name
421
- */
422
- export function saveCountry(country: string) {
423
- localStorage.setItem(Country, country);
424
- }
425
-
426
- /**
427
- * Save culture name
428
- * @param culture Culture name
429
- */
430
- export function saveCulture(culture: string) {
431
- localStorage.setItem(Culture, culture);
432
- }
433
-
434
420
  /**
435
421
  * Set HTML element focus by name
436
422
  * @param name Element name or first collection item
@@ -15,6 +15,7 @@ export class WindowStorage implements IStorage {
15
15
  if (globalFields.length == 0) return;
16
16
 
17
17
  // Copy global fields to session storage where first item does not exist
18
+ // Duplicate browser tab would copy the session storage
18
19
  const firsItem = sessionStorage.getItem(globalFields[0]);
19
20
  if (firsItem) return;
20
21