@wix/site-service-locale 1.0.4 → 1.0.5

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
@@ -1,6 +1,6 @@
1
1
  # @wix/site-service-locale
2
2
 
3
- A thin signal-backed service that exposes the current site language, text direction, and regional locale.
3
+ A thin signal-backed service that exposes the current site language, text direction, regional locale, and time zone.
4
4
 
5
5
  ## Install
6
6
 
@@ -22,6 +22,7 @@ const service = servicesManager.getService(LocaleDefinition)
22
22
  service.language
23
23
  service.direction
24
24
  service.locale
25
+ service.timeZone
25
26
  ```
26
27
 
27
28
  ## API
@@ -31,6 +32,7 @@ service.locale
31
32
  | `language` | `Language` | never | Site primary language code (for example `en`, `fr`). |
32
33
  | `direction` | `LanguageDirection` | never | Site text direction (`ltr` or `rtl`). |
33
34
  | `locale` | `string` | never | BCP-47 locale used for regional formatting (for example `en-US`, `de-CH`). |
35
+ | `timeZone` | `string` | never | IANA time zone of the site's business (for example `America/New_York`, `Europe/Zurich`). |
34
36
  | `_updateConfig` | `(Partial<ILocaleServiceConfig>) => void` | never | Private replace-on-write updater for provided fields. |
35
37
 
36
38
  ## Configuration
@@ -42,6 +44,7 @@ type ILocaleServiceConfig = {
42
44
  language: Language
43
45
  direction: LanguageDirection
44
46
  locale: string
47
+ timeZone: string
45
48
  }
46
49
  ```
47
50
 
@@ -4,11 +4,13 @@ export type ILocaleServiceConfig = {
4
4
  language: Language;
5
5
  direction: LanguageDirection;
6
6
  locale: string;
7
+ timeZone: string;
7
8
  };
8
9
  export interface ILocaleService {
9
10
  readonly language: Language;
10
11
  readonly direction: LanguageDirection;
11
12
  readonly locale: string;
13
+ readonly timeZone: string;
12
14
  _updateConfig: (config: Partial<ILocaleServiceConfig>) => void;
13
15
  }
14
16
  export type ILocaleDefinition = ServiceDefinition<ILocaleService, ILocaleServiceConfig>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/definition/index.ts"],"names":[],"mappings":";;;AAAA,oEAAyD;AAmB5C,QAAA,gBAAgB,GAAG,IAAA,oCAAa,EAAuC,0BAA0B,CAAC,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/definition/index.ts"],"names":[],"mappings":";;;AAAA,oEAAyD;AAqB5C,QAAA,gBAAgB,GAAG,IAAA,oCAAa,EAAuC,0BAA0B,CAAC,CAAA"}
@@ -9,6 +9,7 @@ exports.LocaleService = (0, services_definitions_1.implementService)(definition_
9
9
  const _language = signal(config.language);
10
10
  const _direction = signal(config.direction);
11
11
  const _locale = signal(config.locale);
12
+ const _timeZone = signal(config.timeZone);
12
13
  return {
13
14
  get language() {
14
15
  return _language.get();
@@ -19,7 +20,10 @@ exports.LocaleService = (0, services_definitions_1.implementService)(definition_
19
20
  get locale() {
20
21
  return _locale.get();
21
22
  },
22
- _updateConfig({ language, direction, locale }) {
23
+ get timeZone() {
24
+ return _timeZone.get();
25
+ },
26
+ _updateConfig({ language, direction, locale, timeZone }) {
23
27
  if (language) {
24
28
  _language.set(language);
25
29
  }
@@ -29,6 +33,9 @@ exports.LocaleService = (0, services_definitions_1.implementService)(definition_
29
33
  if (locale) {
30
34
  _locale.set(locale);
31
35
  }
36
+ if (timeZone) {
37
+ _timeZone.set(timeZone);
38
+ }
32
39
  },
33
40
  };
34
41
  });
@@ -1 +1 @@
1
- {"version":3,"file":"localeService.js","sourceRoot":"","sources":["../../../src/implementations/localeService.ts"],"names":[],"mappings":";;;AAAA,oEAA4D;AAE5D,6EAA0F;AAE1F,8CAAgD;AAEnC,QAAA,aAAa,GAAG,IAAA,uCAAgB,EAC5C,6BAAgB,EAChB,CAAC,EAAE,MAAM,EAAE,UAAU,EAA4C,EAAkB,EAAE;IACpF,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,kCAAwB,CAAC,CAAA;IACvD,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IACzC,MA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;IACrC,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IAEzC,OAAO;QACN,IAAI,QAAQ;YACX,OAAO,SAAS,CAAC,GAAG,EAAE,CAAA;QACvB,CAAC;QACD,IAAI,SAAS;YACZ,OAAO,UAAU,CAAC,GAAG,EAAE,CAAA;QACxB,CAAC;QACD,IAAI,MAAM;YACT,OAAO,OAAO,CAAC,GAAG,EAAE,CAAA;QACrB,CAAC;QACD,IAAI,QAAQ;YACX,OAAO,SAAS,CAAC,GAAG,EAAE,CAAA;QACvB,CAAC;QACD,aAAa,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAiC;YACrF,IAAI,QAAQ,EAAE,CAAC;gBACd,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;YACxB,CAAC;YACD,IAAI,SAAS,EAAE,CAAC;gBACf,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;YAC1B,CAAC;YACD,IAAI,MAAM,EAAE,CAAC;gBACZ,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;YACpB,CAAC;YACD,IAAI,QAAQ,EAAE,CAAC;gBACd,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;YACxB,CAAC;QACF,CAAC;KACD,CAAA;AACF,CAAC,CACD,CAAA"}
@@ -4,11 +4,13 @@ export type ILocaleServiceConfig = {
4
4
  language: Language;
5
5
  direction: LanguageDirection;
6
6
  locale: string;
7
+ timeZone: string;
7
8
  };
8
9
  export interface ILocaleService {
9
10
  readonly language: Language;
10
11
  readonly direction: LanguageDirection;
11
12
  readonly locale: string;
13
+ readonly timeZone: string;
12
14
  _updateConfig: (config: Partial<ILocaleServiceConfig>) => void;
13
15
  }
14
16
  export type ILocaleDefinition = ServiceDefinition<ILocaleService, ILocaleServiceConfig>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/definition/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAmBzD,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAuC,0BAA0B,CAAC,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/definition/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAqBzD,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAuC,0BAA0B,CAAC,CAAA"}
@@ -6,6 +6,7 @@ export const LocaleService = implementService(LocaleDefinition, ({ config, getSe
6
6
  const _language = signal(config.language);
7
7
  const _direction = signal(config.direction);
8
8
  const _locale = signal(config.locale);
9
+ const _timeZone = signal(config.timeZone);
9
10
  return {
10
11
  get language() {
11
12
  return _language.get();
@@ -16,7 +17,10 @@ export const LocaleService = implementService(LocaleDefinition, ({ config, getSe
16
17
  get locale() {
17
18
  return _locale.get();
18
19
  },
19
- _updateConfig({ language, direction, locale }) {
20
+ get timeZone() {
21
+ return _timeZone.get();
22
+ },
23
+ _updateConfig({ language, direction, locale, timeZone }) {
20
24
  if (language) {
21
25
  _language.set(language);
22
26
  }
@@ -26,6 +30,9 @@ export const LocaleService = implementService(LocaleDefinition, ({ config, getSe
26
30
  if (locale) {
27
31
  _locale.set(locale);
28
32
  }
33
+ if (timeZone) {
34
+ _timeZone.set(timeZone);
35
+ }
29
36
  },
30
37
  };
31
38
  });
@@ -1 +1 @@
1
- {"version":3,"file":"localeService.js","sourceRoot":"","sources":["../../src/implementations/localeService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAE5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,iDAAiD,CAAA;AAE1F,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAEhD,MAAM,CAAC,MAAM,aAAa,GAAG,gBAAgB,CAC5C,gBAAgB,EAChB,CAAC,EAAE,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
+ "version": "1.0.5",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist",
@@ -58,7 +58,7 @@
58
58
  },
59
59
  "devDependencies": {
60
60
  "typescript": "^5.3.3",
61
- "vitest": "4.1.0"
61
+ "vitest": "4.1.11"
62
62
  },
63
63
  "publishUnscoped": false,
64
64
  "wix": {
@@ -77,5 +77,5 @@
77
77
  ]
78
78
  }
79
79
  },
80
- "falconPackageHash": "a8235e10cebdbc3aaaeb8a4c8e2a35268bf7454ee1b9fdc4e2e5b91f"
80
+ "falconPackageHash": "0e3146b73e95d2cfbdf17daa3388bf2a48a9dc216fe53149516f46b0"
81
81
  }
@@ -6,12 +6,14 @@ export type ILocaleServiceConfig = {
6
6
  language: Language
7
7
  direction: LanguageDirection
8
8
  locale: string
9
+ timeZone: string
9
10
  }
10
11
 
11
12
  export interface ILocaleService {
12
13
  readonly language: Language
13
14
  readonly direction: LanguageDirection
14
15
  readonly locale: string
16
+ readonly timeZone: string
15
17
  _updateConfig: (config: Partial<ILocaleServiceConfig>) => void
16
18
  }
17
19
 
@@ -11,6 +11,7 @@ export const LocaleService = implementService(
11
11
  const _language = signal(config.language)
12
12
  const _direction = signal(config.direction)
13
13
  const _locale = signal(config.locale)
14
+ const _timeZone = signal(config.timeZone)
14
15
 
15
16
  return {
16
17
  get language() {
@@ -22,7 +23,10 @@ export const LocaleService = implementService(
22
23
  get locale() {
23
24
  return _locale.get()
24
25
  },
25
- _updateConfig({ language, direction, locale }: Partial<ILocaleServiceConfig>) {
26
+ get timeZone() {
27
+ return _timeZone.get()
28
+ },
29
+ _updateConfig({ language, direction, locale, timeZone }: Partial<ILocaleServiceConfig>) {
26
30
  if (language) {
27
31
  _language.set(language)
28
32
  }
@@ -32,6 +36,9 @@ export const LocaleService = implementService(
32
36
  if (locale) {
33
37
  _locale.set(locale)
34
38
  }
39
+ if (timeZone) {
40
+ _timeZone.set(timeZone)
41
+ }
35
42
  },
36
43
  }
37
44
  }