@descope/sdk-mixins 0.30.0 → 0.30.1
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/dist/cjs/mixins/localeMixin/localeMixin.js +1 -1
- package/dist/cjs/mixins/localeMixin/localeMixin.js.map +1 -1
- package/dist/esm/mixins/localeMixin/localeMixin.js +1 -1
- package/dist/esm/mixins/localeMixin/localeMixin.js.map +1 -1
- package/dist/index.d.ts +318 -318
- package/dist/types/mixins/localeMixin/localeMixin.d.ts +1 -1
- package/package.json +3 -3
|
@@ -9,7 +9,7 @@ var sdkHelpers = require('@descope/sdk-helpers');
|
|
|
9
9
|
* theme/styleId), so callers can pass it straight to setAttribute without emitting "undefined".
|
|
10
10
|
* - `localeCandidates` returns the lowercased locales to try, most-specific first: the resolved
|
|
11
11
|
* locale and then its language-only fallback (e.g. 'en-us' then 'en'), matching the
|
|
12
|
-
* web-component
|
|
12
|
+
* order of getUserLocale (also used by the web-component). Falls back to navigator.language.
|
|
13
13
|
* - `firstAvailableLocale(availableLocales)` returns the most-specific candidate that the consumer
|
|
14
14
|
* actually publishes (e.g. a widget's config.json targetLocales), or '' when none match.
|
|
15
15
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localeMixin.js","sources":["../../../../src/mixins/localeMixin/localeMixin.ts"],"sourcesContent":["import { createSingletonMixin, getUserLocale } from '@descope/sdk-helpers';\n\n/**\n * Exposes the widget's locale to mixins that need it (HTML fetching, flow propagation).\n * Mirrors web-component's BaseDescopeWc locale handling:\n * - `locale` getter returns the raw attribute value, defaulting to '' when unset (like themeMixin's\n * theme/styleId), so callers can pass it straight to setAttribute without emitting \"undefined\".\n * - `localeCandidates` returns the lowercased locales to try, most-specific first: the resolved\n * locale and then its language-only fallback (e.g. 'en-us' then 'en'), matching the\n * web-component
|
|
1
|
+
{"version":3,"file":"localeMixin.js","sources":["../../../../src/mixins/localeMixin/localeMixin.ts"],"sourcesContent":["import { createSingletonMixin, getUserLocale } from '@descope/sdk-helpers';\n\n/**\n * Exposes the widget's locale to mixins that need it (HTML fetching, flow propagation).\n * Mirrors web-component's BaseDescopeWc locale handling:\n * - `locale` getter returns the raw attribute value, defaulting to '' when unset (like themeMixin's\n * theme/styleId), so callers can pass it straight to setAttribute without emitting \"undefined\".\n * - `localeCandidates` returns the lowercased locales to try, most-specific first: the resolved\n * locale and then its language-only fallback (e.g. 'en-us' then 'en'), matching the\n * order of getUserLocale (also used by the web-component). Falls back to navigator.language.\n * - `firstAvailableLocale(availableLocales)` returns the most-specific candidate that the consumer\n * actually publishes (e.g. a widget's config.json targetLocales), or '' when none match.\n */\nexport const localeMixin = createSingletonMixin(\n <T extends CustomElementConstructor>(superclass: T) =>\n class LocaleMixinClass extends superclass {\n get locale(): string {\n return this.getAttribute('locale') || '';\n }\n\n get localeCandidates(): string[] {\n const { locale, fallback } = getUserLocale(this.locale);\n return [...new Set([locale, fallback].filter(Boolean))];\n }\n\n firstAvailableLocale(availableLocales: string[]): string {\n const available = (availableLocales ?? []).map((l) => l.toLowerCase());\n // localeCandidates are already lowercased, most-specific first.\n return this.localeCandidates.find((c) => available.includes(c)) ?? '';\n }\n },\n);\n"],"names":["createSingletonMixin","getUserLocale"],"mappings":";;;;AAEA;;;;;;;;;;AAUG;AACI,MAAM,WAAW,GAAGA,+BAAoB,CAC7C,CAAqC,UAAa,KAChD,MAAM,gBAAiB,SAAQ,UAAU,CAAA;AACvC,IAAA,IAAI,MAAM,GAAA;QACR,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,EAAE;IAC1C;AAEA,IAAA,IAAI,gBAAgB,GAAA;AAClB,QAAA,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAGC,wBAAa,CAAC,IAAI,CAAC,MAAM,CAAC;AACvD,QAAA,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IACzD;AAEA,IAAA,oBAAoB,CAAC,gBAA0B,EAAA;;QAC7C,MAAM,SAAS,GAAG,CAAC,gBAAgB,KAAA,IAAA,IAAhB,gBAAgB,KAAA,MAAA,GAAhB,gBAAgB,GAAI,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;;QAEtE,OAAO,CAAA,EAAA,GAAA,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAA,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,EAAA,GAAI,EAAE;IACvE;AACD,CAAA;;;;"}
|
|
@@ -7,7 +7,7 @@ import { createSingletonMixin, getUserLocale } from '@descope/sdk-helpers';
|
|
|
7
7
|
* theme/styleId), so callers can pass it straight to setAttribute without emitting "undefined".
|
|
8
8
|
* - `localeCandidates` returns the lowercased locales to try, most-specific first: the resolved
|
|
9
9
|
* locale and then its language-only fallback (e.g. 'en-us' then 'en'), matching the
|
|
10
|
-
* web-component
|
|
10
|
+
* order of getUserLocale (also used by the web-component). Falls back to navigator.language.
|
|
11
11
|
* - `firstAvailableLocale(availableLocales)` returns the most-specific candidate that the consumer
|
|
12
12
|
* actually publishes (e.g. a widget's config.json targetLocales), or '' when none match.
|
|
13
13
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localeMixin.js","sources":["../../../../src/mixins/localeMixin/localeMixin.ts"],"sourcesContent":["import { createSingletonMixin, getUserLocale } from '@descope/sdk-helpers';\n\n/**\n * Exposes the widget's locale to mixins that need it (HTML fetching, flow propagation).\n * Mirrors web-component's BaseDescopeWc locale handling:\n * - `locale` getter returns the raw attribute value, defaulting to '' when unset (like themeMixin's\n * theme/styleId), so callers can pass it straight to setAttribute without emitting \"undefined\".\n * - `localeCandidates` returns the lowercased locales to try, most-specific first: the resolved\n * locale and then its language-only fallback (e.g. 'en-us' then 'en'), matching the\n * web-component
|
|
1
|
+
{"version":3,"file":"localeMixin.js","sources":["../../../../src/mixins/localeMixin/localeMixin.ts"],"sourcesContent":["import { createSingletonMixin, getUserLocale } from '@descope/sdk-helpers';\n\n/**\n * Exposes the widget's locale to mixins that need it (HTML fetching, flow propagation).\n * Mirrors web-component's BaseDescopeWc locale handling:\n * - `locale` getter returns the raw attribute value, defaulting to '' when unset (like themeMixin's\n * theme/styleId), so callers can pass it straight to setAttribute without emitting \"undefined\".\n * - `localeCandidates` returns the lowercased locales to try, most-specific first: the resolved\n * locale and then its language-only fallback (e.g. 'en-us' then 'en'), matching the\n * order of getUserLocale (also used by the web-component). Falls back to navigator.language.\n * - `firstAvailableLocale(availableLocales)` returns the most-specific candidate that the consumer\n * actually publishes (e.g. a widget's config.json targetLocales), or '' when none match.\n */\nexport const localeMixin = createSingletonMixin(\n <T extends CustomElementConstructor>(superclass: T) =>\n class LocaleMixinClass extends superclass {\n get locale(): string {\n return this.getAttribute('locale') || '';\n }\n\n get localeCandidates(): string[] {\n const { locale, fallback } = getUserLocale(this.locale);\n return [...new Set([locale, fallback].filter(Boolean))];\n }\n\n firstAvailableLocale(availableLocales: string[]): string {\n const available = (availableLocales ?? []).map((l) => l.toLowerCase());\n // localeCandidates are already lowercased, most-specific first.\n return this.localeCandidates.find((c) => available.includes(c)) ?? '';\n }\n },\n);\n"],"names":[],"mappings":";;AAEA;;;;;;;;;;AAUG;AACI,MAAM,WAAW,GAAG,oBAAoB,CAC7C,CAAqC,UAAa,KAChD,MAAM,gBAAiB,SAAQ,UAAU,CAAA;AACvC,IAAA,IAAI,MAAM,GAAA;QACR,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,EAAE;IAC1C;AAEA,IAAA,IAAI,gBAAgB,GAAA;AAClB,QAAA,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC;AACvD,QAAA,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IACzD;AAEA,IAAA,oBAAoB,CAAC,gBAA0B,EAAA;;QAC7C,MAAM,SAAS,GAAG,CAAC,gBAAgB,KAAA,IAAA,IAAhB,gBAAgB,KAAA,MAAA,GAAhB,gBAAgB,GAAI,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;;QAEtE,OAAO,CAAA,EAAA,GAAA,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAA,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,EAAA,GAAI,EAAE;IACvE;AACD,CAAA;;;;"}
|