@dialpad/dialtone-vue 4.5.0 → 4.6.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.
Files changed (103) hide show
  1. package/dist/{RichTextEditor-DaOHmXD_.js → RichTextEditor-D8DfONFm.js} +7 -7
  2. package/dist/{RichTextEditor-DaOHmXD_.js.map → RichTextEditor-D8DfONFm.js.map} +1 -1
  3. package/dist/{RichTextEditor-7eY8gy9u.cjs → RichTextEditor-DMUDJKVn.cjs} +2 -2
  4. package/dist/{RichTextEditor-7eY8gy9u.cjs.map → RichTextEditor-DMUDJKVn.cjs.map} +1 -1
  5. package/dist/common/sr_only_close_button.vue.d.ts +18 -1
  6. package/dist/component-documentation.json +1 -1
  7. package/dist/components/Avatar/Avatar.vue.d.ts +12 -8
  8. package/dist/components/Avatar/Avatar.vue.d.ts.map +1 -1
  9. package/dist/components/Badge/Badge.vue.d.ts +1 -2
  10. package/dist/components/Banner/Banner.vue.d.ts +36 -2
  11. package/dist/components/Banner/Banner.vue.d.ts.map +1 -1
  12. package/dist/components/Button/Button.vue.d.ts +18 -1
  13. package/dist/components/Button/Button.vue.d.ts.map +1 -1
  14. package/dist/components/Chip/Chip.vue.d.ts +18 -1
  15. package/dist/components/Chip/Chip.vue.d.ts.map +1 -1
  16. package/dist/components/Collapsible/Collapsible.vue.d.ts +18 -1
  17. package/dist/components/Collapsible/Collapsible.vue.d.ts.map +1 -1
  18. package/dist/components/ComboboxWithPopover/ComboboxWithPopover.vue.d.ts +36 -2
  19. package/dist/components/ComboboxWithPopover/ComboboxWithPopover.vue.d.ts.map +1 -1
  20. package/dist/components/Dropdown/Dropdown.vue.d.ts +36 -2
  21. package/dist/components/Dropdown/Dropdown.vue.d.ts.map +1 -1
  22. package/dist/components/FilterPill/FilterPill.vue.d.ts +90 -5
  23. package/dist/components/FilterPill/FilterPill.vue.d.ts.map +1 -1
  24. package/dist/components/Hovercard/Hovercard.vue.d.ts +72 -4
  25. package/dist/components/Hovercard/Hovercard.vue.d.ts.map +1 -1
  26. package/dist/components/ImageViewer/ImageViewer.vue.d.ts +36 -2
  27. package/dist/components/ImageViewer/ImageViewer.vue.d.ts.map +1 -1
  28. package/dist/components/Loader/Loader.vue.d.ts +18 -1
  29. package/dist/components/Loader/Loader.vue.d.ts.map +1 -1
  30. package/dist/components/Loader/LoaderConstants.d.ts +5 -0
  31. package/dist/components/Loader/LoaderConstants.d.ts.map +1 -0
  32. package/dist/components/Loader/index.d.ts +1 -0
  33. package/dist/components/Modal/Modal.vue.d.ts +37 -3
  34. package/dist/components/Modal/Modal.vue.d.ts.map +1 -1
  35. package/dist/components/Notice/Notice.vue.d.ts +36 -2
  36. package/dist/components/Notice/Notice.vue.d.ts.map +1 -1
  37. package/dist/components/Notice/NoticeAction.vue.d.ts +36 -2
  38. package/dist/components/Notice/NoticeAction.vue.d.ts.map +1 -1
  39. package/dist/components/Pagination/Pagination.vue.d.ts +18 -1
  40. package/dist/components/Pagination/Pagination.vue.d.ts.map +1 -1
  41. package/dist/components/Popover/Popover.vue.d.ts +36 -2
  42. package/dist/components/Popover/Popover.vue.d.ts.map +1 -1
  43. package/dist/components/Popover/PopoverHeaderFooter.vue.d.ts +18 -1
  44. package/dist/components/Popover/PopoverHeaderFooter.vue.d.ts.map +1 -1
  45. package/dist/components/RichTextEditor/Extensions/Mentions/MentionSuggestion.vue.d.ts +12 -8
  46. package/dist/components/RichTextEditor/Extensions/Variable/VariableComponent.vue.d.ts +55 -5
  47. package/dist/components/RichTextEditor/Extensions/Variable/VariableComponent.vue.d.ts.map +1 -1
  48. package/dist/components/SegmentedControl/SegmentedControlItem.vue.d.ts.map +1 -1
  49. package/dist/components/SplitButton/SplitButton.vue.d.ts +72 -4
  50. package/dist/components/SplitButton/SplitButton.vue.d.ts.map +1 -1
  51. package/dist/components/SplitButton/SplitButtonEnd.vue.d.ts +18 -1
  52. package/dist/components/SplitButton/SplitButtonEnd.vue.d.ts.map +1 -1
  53. package/dist/components/SplitButton/SplitButtonStart.vue.d.ts +18 -1
  54. package/dist/components/Tab/Tab.vue.d.ts +18 -1
  55. package/dist/components/Toast/Layouts/ToastLayoutAlternate.vue.d.ts +36 -2
  56. package/dist/components/Toast/Layouts/ToastLayoutAlternate.vue.d.ts.map +1 -1
  57. package/dist/components/Toast/Layouts/ToastLayoutDefault.vue.d.ts +36 -2
  58. package/dist/components/Toast/Layouts/ToastLayoutDefault.vue.d.ts.map +1 -1
  59. package/dist/components/Toast/Toast.vue.d.ts +144 -8
  60. package/dist/components/Toast/Toast.vue.d.ts.map +1 -1
  61. package/dist/dialtone-vue.cjs +1 -1
  62. package/dist/dialtone-vue.js +116 -115
  63. package/dist/lib/avatar/avatar.cjs +1 -1
  64. package/dist/lib/avatar/avatar.cjs.map +1 -1
  65. package/dist/lib/avatar/avatar.js +50 -47
  66. package/dist/lib/avatar/avatar.js.map +1 -1
  67. package/dist/lib/badge/badge.cjs +1 -1
  68. package/dist/lib/badge/badge.cjs.map +1 -1
  69. package/dist/lib/badge/badge.js +12 -14
  70. package/dist/lib/badge/badge.js.map +1 -1
  71. package/dist/lib/button/button.cjs +1 -1
  72. package/dist/lib/button/button.js +21 -21
  73. package/dist/lib/dropdown/dropdown.cjs.map +1 -1
  74. package/dist/lib/dropdown/dropdown.js.map +1 -1
  75. package/dist/lib/filter-pill/filter-pill.cjs +1 -1
  76. package/dist/lib/filter-pill/filter-pill.js +5 -5
  77. package/dist/lib/loader/index.cjs +1 -1
  78. package/dist/lib/loader/index.js +3 -2
  79. package/dist/lib/loader/loader-constants.cjs +2 -0
  80. package/dist/lib/loader/loader-constants.cjs.map +1 -0
  81. package/dist/lib/loader/loader-constants.js +9 -0
  82. package/dist/lib/loader/loader-constants.js.map +1 -0
  83. package/dist/lib/loader/loader.cjs +21 -21
  84. package/dist/lib/loader/loader.cjs.map +1 -1
  85. package/dist/lib/loader/loader.js +77 -14
  86. package/dist/lib/loader/loader.js.map +1 -1
  87. package/dist/lib/modal/modal.cjs +1 -1
  88. package/dist/lib/modal/modal.cjs.map +1 -1
  89. package/dist/lib/modal/modal.js +6 -5
  90. package/dist/lib/modal/modal.js.map +1 -1
  91. package/dist/lib/rich-text-editor/index.cjs +1 -1
  92. package/dist/lib/rich-text-editor/index.js +1 -1
  93. package/dist/lib/rich-text-editor/rich-text-editor.cjs +1 -1
  94. package/dist/lib/rich-text-editor/rich-text-editor.js +1 -1
  95. package/dist/lib/segmented-control/segmented-control-item.cjs.map +1 -1
  96. package/dist/lib/segmented-control/segmented-control-item.js.map +1 -1
  97. package/dist/lib/text/text.cjs.map +1 -1
  98. package/dist/lib/text/text.js.map +1 -1
  99. package/dist/localization/index.cjs +1 -1
  100. package/dist/localization/index.cjs.map +1 -1
  101. package/dist/localization/index.js +50 -33
  102. package/dist/localization/index.js.map +1 -1
  103. package/package.json +5 -5
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);const e=require(`./en-US.cjs`),t=require(`./zh-CN.cjs`),n=require(`./nl-NL.cjs`),r=require(`./fr-FR.cjs`),i=require(`./de-DE.cjs`),a=require(`./it-IT.cjs`),o=require(`./ja-JP.cjs`),s=require(`./ko-KR.cjs`),c=require(`./pt-BR.cjs`),l=require(`./ru-RU.cjs`),u=require(`./es-LA.cjs`),d=require(`./sv-SE.cjs`);let f=require(`@dialpad/i18n`);var p=`dialtone`,m={ENGLISH:`en-US`,CHINESE:`zh-CN`,DUTCH:`nl-NL`,FRENCH:`fr-FR`,GERMAN:`de-DE`,ITALIAN:`it-IT`,JAPANESE:`ja-JP`,KOREAN:`ko-KR`,PORTUGUESE:`pt-BR`,RUSSIAN:`ru-RU`,SPANISH:`es-LA`,SWEDISH:`sv-SE`},h=`en-US`,g=`user-locale`,_=class _{constructor(v=null){if(typeof _.instance==`object`)return _.instance;this._locale=v||_.getPreferredLocale();let y=new f.LocaleManager({bundleSource:new f.RawBundleSource({resources:f.RawBundleSource.builtResources([[`en-US`,p,e.default],[`zh-CN`,p,t.default],[`nl-NL`,p,n.default],[`fr-FR`,p,r.default],[`de-DE`,p,i.default],[`it-IT`,p,a.default],[`ja-JP`,p,o.default],[`ko-KR`,p,s.default],[`pt-BR`,p,c.default],[`ru-RU`,p,l.default],[`es-LA`,p,u.default],[`sv-SE`,p,d.default]])}),allowedLocales:Object.values(m),fallbackLocale:h,preferredLocale:this._locale,namespaces:[p]});return _.instance=this,this.i18n=y.useI18N(p),typeof window<`u`&&(window.onstorage=e=>{e.key===g&&(this.currentLocale=e.newValue)}),this}static getPreferredLocale(){if(typeof window>`u`||!window.localStorage)return h;let e=window.localStorage.getItem(g),t=Object.values(m).includes(e)?e:null,n=Object.values(m).find(e=>e.startsWith(navigator.language.slice(0,2)));return t||n||h}static getAllowedLocales(){return m}$t(...e){return this.i18n.$t(...e)}$ta(...e){return this.i18n.$ta(...e)}get currentLocale(){return this._locale}set currentLocale(e){if(e!==this._locale){if(!Object.values(m).includes(e))throw Error(`Locale ${e} is not allowed, please use one of the following: ${Object.values(m).join(`, `)}`);this._locale=e,this.i18n.setI18N({preferredLocale:e},p)}}};exports.DialtoneLocalization=_;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);const e=require(`./en-US.cjs`),t=require(`./zh-CN.cjs`),n=require(`./nl-NL.cjs`),r=require(`./fr-FR.cjs`),i=require(`./de-DE.cjs`),a=require(`./it-IT.cjs`),o=require(`./ja-JP.cjs`),s=require(`./ko-KR.cjs`),c=require(`./pt-BR.cjs`),l=require(`./ru-RU.cjs`),u=require(`./es-LA.cjs`),d=require(`./sv-SE.cjs`);let f=require(`@dialpad/i18n`);var p=`dialtone`,m={ENGLISH:`en-US`,CHINESE:`zh-CN`,DUTCH:`nl-NL`,FRENCH:`fr-FR`,GERMAN:`de-DE`,ITALIAN:`it-IT`,JAPANESE:`ja-JP`,KOREAN:`ko-KR`,PORTUGUESE:`pt-BR`,RUSSIAN:`ru-RU`,SPANISH:`es-LA`,SWEDISH:`sv-SE`},h=`en-US`,g=`user-locale`,_=class _{constructor(v=null){if(typeof _.instance==`object`)return _.instance;this._locale=v||_.getPreferredLocale();let y={bundleSource:new f.RawBundleSource({resources:f.RawBundleSource.builtResources([[`en-US`,p,e.default],[`zh-CN`,p,t.default],[`nl-NL`,p,n.default],[`fr-FR`,p,r.default],[`de-DE`,p,i.default],[`it-IT`,p,a.default],[`ja-JP`,p,o.default],[`ko-KR`,p,s.default],[`pt-BR`,p,c.default],[`ru-RU`,p,l.default],[`es-LA`,p,u.default],[`sv-SE`,p,d.default]])}),allowedLocales:Object.values(m),fallbackLocale:h,preferredLocale:this._locale,namespaces:[p]},b;try{b=new f.LocaleManager(y)}catch(e){if(e.name!==`SecurityError`)throw e;b=new f.LocaleManager({...y,storageWrapper:new f.MemoryStorageWrapper})}return _.instance=this,this.i18n=b.useI18N(p),typeof window<`u`&&window.addEventListener(`storage`,e=>{e.key===g&&(this.currentLocale=e.newValue)}),this}static getPreferredLocale(){if(typeof window>`u`)return h;let e;try{let t=window.localStorage;if(!t)return h;e=t.getItem(g)}catch{return h}let t=Object.values(m).includes(e)?e:null,n=Object.values(m).find(e=>e.startsWith(navigator.language.slice(0,2)));return t||n||h}static getAllowedLocales(){return m}$t(...e){return this.i18n.$t(...e)}$ta(...e){return this.i18n.$ta(...e)}get currentLocale(){return this._locale}set currentLocale(e){if(e!==this._locale){if(!Object.values(m).includes(e))throw Error(`Locale ${e} is not allowed, please use one of the following: ${Object.values(m).join(`, `)}`);this._locale=e,this.i18n.setI18N({preferredLocale:e},p)}}};exports.DialtoneLocalization=_;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["LocaleManager","RawBundleSource","enUS","zhCN","nlNL","frFR","deDE","itIT","jaJP","koKR","ptBR","ruRU","esLA","svSE"],"sources":["../../localization/index.js"],"sourcesContent":["import { LocaleManager, RawBundleSource } from '@dialpad/i18n';\n\nimport enUS from './en-US.ftl?raw';\nimport zhCN from './zh-CN.ftl?raw';\nimport nlNL from './nl-NL.ftl?raw';\nimport frFR from './fr-FR.ftl?raw';\nimport deDE from './de-DE.ftl?raw';\nimport itIT from './it-IT.ftl?raw';\nimport jaJP from './ja-JP.ftl?raw';\nimport koKR from './ko-KR.ftl?raw';\nimport ptBR from './pt-BR.ftl?raw';\nimport ruRU from './ru-RU.ftl?raw';\nimport esLA from './es-LA.ftl?raw';\nimport svSE from './sv-SE.ftl?raw';\n\nconst dialtoneNamespace = 'dialtone';\nconst allowedLocales = {\n ENGLISH: 'en-US',\n CHINESE: 'zh-CN',\n DUTCH: 'nl-NL',\n FRENCH: 'fr-FR',\n GERMAN: 'de-DE',\n ITALIAN: 'it-IT',\n JAPANESE: 'ja-JP',\n KOREAN: 'ko-KR',\n PORTUGUESE: 'pt-BR',\n RUSSIAN: 'ru-RU',\n SPANISH: 'es-LA',\n SWEDISH: 'sv-SE',\n};\nconst fallbackLocale = 'en-US';\n/**\n * Default key name used by the LocaleManager to store the user's preferred locale in localStorage\n */\nconst localeManagerStorageKey = 'user-locale';\n\n/**\n * Dialtone localization class, follows the singleton pattern to make sure only one instance of the class is created.\n * Initializes the localeManager and looks for changes on the browser storage to update the current locale.\n * https://github.com/dialpad/goblin-client-tools/tree/main/packages/i18n#i18n-vue-3-compatible\n */\nexport class DialtoneLocalization {\n /**\n * @prop {import('@dialpad/i18n').UseI18N} i18n\n * @private\n */\n constructor (locale = null) {\n if (typeof DialtoneLocalization.instance === 'object') {\n return DialtoneLocalization.instance;\n }\n\n this._locale = locale || DialtoneLocalization.getPreferredLocale();\n\n const bundleSource = new RawBundleSource({\n resources: RawBundleSource.builtResources([\n ['en-US', dialtoneNamespace, enUS],\n ['zh-CN', dialtoneNamespace, zhCN],\n ['nl-NL', dialtoneNamespace, nlNL],\n ['fr-FR', dialtoneNamespace, frFR],\n ['de-DE', dialtoneNamespace, deDE],\n ['it-IT', dialtoneNamespace, itIT],\n ['ja-JP', dialtoneNamespace, jaJP],\n ['ko-KR', dialtoneNamespace, koKR],\n ['pt-BR', dialtoneNamespace, ptBR],\n ['ru-RU', dialtoneNamespace, ruRU],\n ['es-LA', dialtoneNamespace, esLA],\n ['sv-SE', dialtoneNamespace, svSE],\n ]),\n });\n\n const localeManager = new LocaleManager({\n bundleSource,\n allowedLocales: Object.values(allowedLocales),\n fallbackLocale,\n preferredLocale: this._locale,\n namespaces: [dialtoneNamespace],\n });\n\n DialtoneLocalization.instance = this;\n this.i18n = localeManager.useI18N(dialtoneNamespace);\n\n if (typeof window !== 'undefined') {\n /**\n * @description\n * When the browser storage changes, update the current locale\n * @param event\n */\n window.onstorage = (event) => {\n if (event.key === localeManagerStorageKey) {\n this.currentLocale = event.newValue;\n }\n };\n }\n\n return this;\n }\n\n /**\n * Gets the preferred locale from user's locale stored in localStorage or the browser language\n * @returns { string }\n */\n static getPreferredLocale () {\n /**\n * Early return if we're not in the browser or if localStorage is not available\n */\n if (typeof window === 'undefined' || !window.localStorage) {\n return fallbackLocale;\n }\n\n // Only trust the stored locale if it's one Dialtone actually ships a bundle for.\n // Callers (e.g. UC/UV) may allow locales Dialtone doesn't support, which would\n // otherwise crash the LocaleManager during render.\n const storedLanguage = window.localStorage.getItem(localeManagerStorageKey);\n const localStorageLanguage = Object.values(allowedLocales).includes(storedLanguage)\n ? storedLanguage\n : null;\n\n // Get the first two letters of the navigator language and check if it's in the allowed locales\n const navigatorLanguage = Object.values(allowedLocales)\n .find(locale => locale.startsWith(navigator.language.slice(0, 2)));\n\n return localStorageLanguage || navigatorLanguage || fallbackLocale;\n }\n\n static getAllowedLocales () {\n return allowedLocales;\n }\n\n /**\n * Passthrough function to the i18n $t function including the dialtone namespace\n * Returns a translated string based on a key and optional variables.\n * It’s used for simple text translations.\n * https://github.com/dialpad/goblin-client-tools/tree/main/packages/i18n#t\n */\n $t (...args) {\n return this.i18n.$t(...args);\n }\n\n /**\n * Passthrough function to the i18n $ta function including the dialtone namespace\n * Returns an object containing translated attributes to pass directly as props to components, it can contain\n * aria-label, title, etc, rather than just a plain text. It’s useful for handling element attributes in the UI.\n * https://github.com/dialpad/goblin-client-tools/tree/main/packages/i18n#ta\n */\n $ta (...args) {\n return this.i18n.$ta(...args);\n }\n\n get currentLocale () {\n return this._locale;\n }\n\n set currentLocale (newLocale) {\n if (newLocale === this._locale) return;\n if (!Object.values(allowedLocales).includes(newLocale)) {\n throw new Error(`Locale ${newLocale} is not allowed, please use one of the following: ${Object.values(allowedLocales).join(', ')}`);\n }\n\n this._locale = newLocale;\n this.i18n.setI18N({ preferredLocale: newLocale }, dialtoneNamespace);\n }\n}\n"],"mappings":"qbAeA,IAAM,EAAoB,WACpB,EAAiB,CACrB,QAAS,QACT,QAAS,QACT,MAAO,QACP,OAAQ,QACR,OAAQ,QACR,QAAS,QACT,SAAU,QACV,OAAQ,QACR,WAAY,QACZ,QAAS,QACT,QAAS,QACT,QAAS,QACV,CACK,EAAiB,QAIjB,EAA0B,cAOnB,EAAb,MAAa,CAAqB,CAKhC,YAAa,EAAS,KAAM,CAC1B,GAAI,OAAO,EAAqB,UAAa,SAC3C,OAAO,EAAqB,SAG9B,KAAK,QAAU,GAAU,EAAqB,oBAAoB,CAmBlE,IAAM,EAAgB,IAAIA,EAAAA,cAAc,CACtC,aAlBmB,IAAIC,EAAAA,gBAAgB,CACvC,UAAWA,EAAAA,gBAAgB,eAAe,CACxC,CAAC,QAAS,EAAmBC,EAAAA,QAAK,CAClC,CAAC,QAAS,EAAmBC,EAAAA,QAAK,CAClC,CAAC,QAAS,EAAmBC,EAAAA,QAAK,CAClC,CAAC,QAAS,EAAmBC,EAAAA,QAAK,CAClC,CAAC,QAAS,EAAmBC,EAAAA,QAAK,CAClC,CAAC,QAAS,EAAmBC,EAAAA,QAAK,CAClC,CAAC,QAAS,EAAmBC,EAAAA,QAAK,CAClC,CAAC,QAAS,EAAmBC,EAAAA,QAAK,CAClC,CAAC,QAAS,EAAmBC,EAAAA,QAAK,C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R","deDE","itIT","jaJP","koKR","ptBR","ruRU","esLA","svSE","LocaleManager","MemoryStorageWrapper"],"sources":["../../localization/index.js"],"sourcesContent":["import { LocaleManager, RawBundleSource, MemoryStorageWrapper } from '@dialpad/i18n';\n\nimport enUS from './en-US.ftl?raw';\nimport zhCN from './zh-CN.ftl?raw';\nimport nlNL from './nl-NL.ftl?raw';\nimport frFR from './fr-FR.ftl?raw';\nimport deDE from './de-DE.ftl?raw';\nimport itIT from './it-IT.ftl?raw';\nimport jaJP from './ja-JP.ftl?raw';\nimport koKR from './ko-KR.ftl?raw';\nimport ptBR from './pt-BR.ftl?raw';\nimport ruRU from './ru-RU.ftl?raw';\nimport esLA from './es-LA.ftl?raw';\nimport svSE from './sv-SE.ftl?raw';\n\nconst dialtoneNamespace = 'dialtone';\nconst allowedLocales = {\n ENGLISH: 'en-US',\n CHINESE: 'zh-CN',\n DUTCH: 'nl-NL',\n FRENCH: 'fr-FR',\n GERMAN: 'de-DE',\n ITALIAN: 'it-IT',\n JAPANESE: 'ja-JP',\n KOREAN: 'ko-KR',\n PORTUGUESE: 'pt-BR',\n RUSSIAN: 'ru-RU',\n SPANISH: 'es-LA',\n SWEDISH: 'sv-SE',\n};\nconst fallbackLocale = 'en-US';\n/**\n * Default key name used by the LocaleManager to store the user's preferred locale in localStorage\n */\nconst localeManagerStorageKey = 'user-locale';\n\n/**\n * Dialtone localization class, follows the singleton pattern to make sure only one instance of the class is created.\n * Initializes the localeManager and looks for changes on the browser storage to update the current locale.\n * https://github.com/dialpad/goblin-client-tools/tree/main/packages/i18n#i18n-vue-3-compatible\n */\nexport class DialtoneLocalization {\n /**\n * @prop {import('@dialpad/i18n').UseI18N} i18n\n * @private\n */\n constructor (locale = null) {\n if (typeof DialtoneLocalization.instance === 'object') {\n return DialtoneLocalization.instance;\n }\n\n this._locale = locale || DialtoneLocalization.getPreferredLocale();\n\n const bundleSource = new RawBundleSource({\n resources: RawBundleSource.builtResources([\n ['en-US', dialtoneNamespace, enUS],\n ['zh-CN', dialtoneNamespace, zhCN],\n ['nl-NL', dialtoneNamespace, nlNL],\n ['fr-FR', dialtoneNamespace, frFR],\n ['de-DE', dialtoneNamespace, deDE],\n ['it-IT', dialtoneNamespace, itIT],\n ['ja-JP', dialtoneNamespace, jaJP],\n ['ko-KR', dialtoneNamespace, koKR],\n ['pt-BR', dialtoneNamespace, ptBR],\n ['ru-RU', dialtoneNamespace, ruRU],\n ['es-LA', dialtoneNamespace, esLA],\n ['sv-SE', dialtoneNamespace, svSE],\n ]),\n });\n\n const localeOptions = {\n bundleSource,\n allowedLocales: Object.values(allowedLocales),\n fallbackLocale,\n preferredLocale: this._locale,\n namespaces: [dialtoneNamespace],\n };\n let localeManager;\n try {\n localeManager = new LocaleManager(localeOptions);\n } catch (error) {\n if (error.name !== 'SecurityError') throw error;\n localeManager = new LocaleManager({ ...localeOptions, storageWrapper: new MemoryStorageWrapper() });\n }\n\n DialtoneLocalization.instance = this;\n this.i18n = localeManager.useI18N(dialtoneNamespace);\n\n if (typeof window !== 'undefined') {\n /**\n * @description\n * When the browser storage changes, update the current locale\n * @param event\n */\n window.addEventListener('storage', (event) => {\n if (event.key === localeManagerStorageKey) {\n this.currentLocale = event.newValue;\n }\n });\n }\n\n return this;\n }\n\n /**\n * Gets the preferred locale from user's locale stored in localStorage or the browser language\n * @returns { string }\n */\n static getPreferredLocale () {\n /**\n * Early return if we're not in the browser or if localStorage is not available\n */\n if (typeof window === 'undefined') {\n return fallbackLocale;\n }\n\n let storedLanguage;\n try {\n const storage = window.localStorage;\n if (!storage) return fallbackLocale;\n storedLanguage = storage.getItem(localeManagerStorageKey);\n } catch {\n return fallbackLocale;\n }\n\n // Only trust the stored locale if it's one Dialtone actually ships a bundle for.\n // Callers (e.g. UC/UV) may allow locales Dialtone doesn't support, which would\n // otherwise crash the LocaleManager during render.\n const localStorageLanguage = Object.values(allowedLocales).includes(storedLanguage)\n ? storedLanguage\n : null;\n\n // Get the first two letters of the navigator language and check if it's in the allowed locales\n const navigatorLanguage = Object.values(allowedLocales)\n .find(locale => locale.startsWith(navigator.language.slice(0, 2)));\n\n return localStorageLanguage || navigatorLanguage || fallbackLocale;\n }\n\n static getAllowedLocales () {\n return allowedLocales;\n }\n\n /**\n * Passthrough function to the i18n $t function including the dialtone namespace\n * Returns a translated string based on a key and optional variables.\n * It’s used for simple text translations.\n * https://github.com/dialpad/goblin-client-tools/tree/main/packages/i18n#t\n */\n $t (...args) {\n return this.i18n.$t(...args);\n }\n\n /**\n * Passthrough function to the i18n $ta function including the dialtone namespace\n * Returns an object containing translated attributes to pass directly as props to components, it can contain\n * aria-label, title, etc, rather than just a plain text. It’s useful for handling element attributes in the UI.\n * https://github.com/dialpad/goblin-client-tools/tree/main/packages/i18n#ta\n */\n $ta (...args) {\n return this.i18n.$ta(...args);\n }\n\n get currentLocale () {\n return this._locale;\n }\n\n set currentLocale (newLocale) {\n if (newLocale === this._locale) return;\n if (!Object.values(allowedLocales).includes(newLocale)) {\n throw new Error(`Locale ${newLocale} is not allowed, please use one of the following: ${Object.values(allowedLocales).join(', ')}`);\n }\n\n this._locale = newLocale;\n this.i18n.setI18N({ preferredLocale: newLocale }, dialtoneNamespace);\n }\n}\n"],"mappings":"qbAeA,IAAM,EAAoB,WACpB,EAAiB,CACrB,QAAS,QACT,QAAS,QACT,MAAO,QACP,OAAQ,QACR,OAAQ,QACR,QAAS,QACT,SAAU,QACV,OAAQ,QACR,WAAY,QACZ,QAAS,QACT,QAAS,QACT,QAAS,QACV,CACK,EAAiB,QAIjB,EAA0B,cAOnB,EAAb,MAAa,CAAqB,CAKhC,YAAa,EAAS,KAAM,CAC1B,GAAI,OAAO,EAAqB,UAAa,SAC3C,OAAO,EAAqB,SAG9B,KAAK,QAAU,GAAU,EAAqB,oBAAoB,CAmBlE,IAAM,EAAgB,CACpB,aAlBmB,IAAIA,EAAAA,gBAAgB,CACvC,UAAWA,EAAAA,gBAAgB,eAAe,CACxC,CAAC,QAAS,EAAmBC,EAAAA,QAAK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WAAW,UAAU,SAAS,MAAM,EAAG,EAAE,CAAC,CAAC,CAEpE,OAAO,GAAwB,GAAqB,EAGtD,OAAO,mBAAqB,CAC1B,OAAO,EAST,GAAI,GAAG,EAAM,CACX,OAAO,KAAK,KAAK,GAAG,GAAG,EAAK,CAS9B,IAAK,GAAG,EAAM,CACZ,OAAO,KAAK,KAAK,IAAI,GAAG,EAAK,CAG/B,IAAI,eAAiB,CACnB,OAAO,KAAK,QAGd,IAAI,cAAe,EAAW,CACxB,OAAc,KAAK,QACvB,IAAI,CAAC,OAAO,OAAO,EAAe,CAAC,SAAS,EAAU,CACpD,MAAU,MAAM,UAAU,EAAU,oDAAoD,OAAO,OAAO,EAAe,CAAC,KAAK,KAAK,GAAG,CAGrI,KAAK,QAAU,EACf,KAAK,KAAK,QAAQ,CAAE,gBAAiB,EAAW,CAAE,EAAkB"}
@@ -10,9 +10,9 @@ import c from "./pt-BR.js";
10
10
  import l from "./ru-RU.js";
11
11
  import u from "./es-LA.js";
12
12
  import d from "./sv-SE.js";
13
- import { LocaleManager as f, RawBundleSource as p } from "@dialpad/i18n";
13
+ import { LocaleManager as f, MemoryStorageWrapper as p, RawBundleSource as m } from "@dialpad/i18n";
14
14
  //#region localization/index.js
15
- var m = "dialtone", h = {
15
+ var h = "dialtone", g = {
16
16
  ENGLISH: "en-US",
17
17
  CHINESE: "zh-CN",
18
18
  DUTCH: "nl-NL",
@@ -25,89 +25,106 @@ var m = "dialtone", h = {
25
25
  RUSSIAN: "ru-RU",
26
26
  SPANISH: "es-LA",
27
27
  SWEDISH: "sv-SE"
28
- }, g = "en-US", _ = "user-locale", v = class v {
29
- constructor(y = null) {
30
- if (typeof v.instance == "object") return v.instance;
31
- this._locale = y || v.getPreferredLocale();
32
- let b = new f({
33
- bundleSource: new p({ resources: p.builtResources([
28
+ }, _ = "en-US", v = "user-locale", y = class y {
29
+ constructor(b = null) {
30
+ if (typeof y.instance == "object") return y.instance;
31
+ this._locale = b || y.getPreferredLocale();
32
+ let x = {
33
+ bundleSource: new m({ resources: m.builtResources([
34
34
  [
35
35
  "en-US",
36
- m,
36
+ h,
37
37
  e
38
38
  ],
39
39
  [
40
40
  "zh-CN",
41
- m,
41
+ h,
42
42
  t
43
43
  ],
44
44
  [
45
45
  "nl-NL",
46
- m,
46
+ h,
47
47
  n
48
48
  ],
49
49
  [
50
50
  "fr-FR",
51
- m,
51
+ h,
52
52
  r
53
53
  ],
54
54
  [
55
55
  "de-DE",
56
- m,
56
+ h,
57
57
  i
58
58
  ],
59
59
  [
60
60
  "it-IT",
61
- m,
61
+ h,
62
62
  a
63
63
  ],
64
64
  [
65
65
  "ja-JP",
66
- m,
66
+ h,
67
67
  o
68
68
  ],
69
69
  [
70
70
  "ko-KR",
71
- m,
71
+ h,
72
72
  s
73
73
  ],
74
74
  [
75
75
  "pt-BR",
76
- m,
76
+ h,
77
77
  c
78
78
  ],
79
79
  [
80
80
  "ru-RU",
81
- m,
81
+ h,
82
82
  l
83
83
  ],
84
84
  [
85
85
  "es-LA",
86
- m,
86
+ h,
87
87
  u
88
88
  ],
89
89
  [
90
90
  "sv-SE",
91
- m,
91
+ h,
92
92
  d
93
93
  ]
94
94
  ]) }),
95
- allowedLocales: Object.values(h),
96
- fallbackLocale: g,
95
+ allowedLocales: Object.values(g),
96
+ fallbackLocale: _,
97
97
  preferredLocale: this._locale,
98
- namespaces: [m]
99
- });
100
- return v.instance = this, this.i18n = b.useI18N(m), typeof window < "u" && (window.onstorage = (e) => {
101
- e.key === _ && (this.currentLocale = e.newValue);
98
+ namespaces: [h]
99
+ }, S;
100
+ try {
101
+ S = new f(x);
102
+ } catch (e) {
103
+ if (e.name !== "SecurityError") throw e;
104
+ S = new f({
105
+ ...x,
106
+ storageWrapper: new p()
107
+ });
108
+ }
109
+ return y.instance = this, this.i18n = S.useI18N(h), typeof window < "u" && window.addEventListener("storage", (e) => {
110
+ e.key === v && (this.currentLocale = e.newValue);
102
111
  }), this;
103
112
  }
104
113
  static getPreferredLocale() {
105
- if (typeof window > "u" || !window.localStorage) return g;
106
- let e = window.localStorage.getItem(_), t = Object.values(h).includes(e) ? e : null, n = Object.values(h).find((e) => e.startsWith(navigator.language.slice(0, 2)));
107
- return t || n || g;
114
+ if (typeof window > "u") return _;
115
+ let e;
116
+ try {
117
+ let t = window.localStorage;
118
+ if (!t) return _;
119
+ e = t.getItem(v);
120
+ } catch {
121
+ return _;
122
+ }
123
+ let t = Object.values(g).includes(e) ? e : null, n = Object.values(g).find((e) => e.startsWith(navigator.language.slice(0, 2)));
124
+ return t || n || _;
108
125
  }
109
126
  static getAllowedLocales() {
110
- return h;
127
+ return g;
111
128
  }
112
129
  $t(...e) {
113
130
  return this.i18n.$t(...e);
@@ -120,12 +137,12 @@ var m = "dialtone", h = {
120
137
  }
121
138
  set currentLocale(e) {
122
139
  if (e !== this._locale) {
123
- if (!Object.values(h).includes(e)) throw Error(`Locale ${e} is not allowed, please use one of the following: ${Object.values(h).join(", ")}`);
124
- this._locale = e, this.i18n.setI18N({ preferredLocale: e }, m);
140
+ if (!Object.values(g).includes(e)) throw Error(`Locale ${e} is not allowed, please use one of the following: ${Object.values(g).join(", ")}`);
141
+ this._locale = e, this.i18n.setI18N({ preferredLocale: e }, h);
125
142
  }
126
143
  }
127
144
  };
128
145
  //#endregion
129
- export { v as DialtoneLocalization };
146
+ export { y as DialtoneLocalization };
130
147
 
131
148
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["enUS","zhCN","nlNL","frFR","deDE","itIT","jaJP","koKR","ptBR","ruRU","esLA","svSE"],"sources":["../../localization/index.js"],"sourcesContent":["import { LocaleManager, RawBundleSource } from '@dialpad/i18n';\n\nimport enUS from './en-US.ftl?raw';\nimport zhCN from './zh-CN.ftl?raw';\nimport nlNL from './nl-NL.ftl?raw';\nimport frFR from './fr-FR.ftl?raw';\nimport deDE from './de-DE.ftl?raw';\nimport itIT from './it-IT.ftl?raw';\nimport jaJP from './ja-JP.ftl?raw';\nimport koKR from './ko-KR.ftl?raw';\nimport ptBR from './pt-BR.ftl?raw';\nimport ruRU from './ru-RU.ftl?raw';\nimport esLA from './es-LA.ftl?raw';\nimport svSE from './sv-SE.ftl?raw';\n\nconst dialtoneNamespace = 'dialtone';\nconst allowedLocales = {\n ENGLISH: 'en-US',\n CHINESE: 'zh-CN',\n DUTCH: 'nl-NL',\n FRENCH: 'fr-FR',\n GERMAN: 'de-DE',\n ITALIAN: 'it-IT',\n JAPANESE: 'ja-JP',\n KOREAN: 'ko-KR',\n PORTUGUESE: 'pt-BR',\n RUSSIAN: 'ru-RU',\n SPANISH: 'es-LA',\n SWEDISH: 'sv-SE',\n};\nconst fallbackLocale = 'en-US';\n/**\n * Default key name used by the LocaleManager to store the user's preferred locale in localStorage\n */\nconst localeManagerStorageKey = 'user-locale';\n\n/**\n * Dialtone localization class, follows the singleton pattern to make sure only one instance of the class is created.\n * Initializes the localeManager and looks for changes on the browser storage to update the current locale.\n * https://github.com/dialpad/goblin-client-tools/tree/main/packages/i18n#i18n-vue-3-compatible\n */\nexport class DialtoneLocalization {\n /**\n * @prop {import('@dialpad/i18n').UseI18N} i18n\n * @private\n */\n constructor (locale = null) {\n if (typeof DialtoneLocalization.instance === 'object') {\n return DialtoneLocalization.instance;\n }\n\n this._locale = locale || DialtoneLocalization.getPreferredLocale();\n\n const bundleSource = new RawBundleSource({\n resources: RawBundleSource.builtResources([\n ['en-US', dialtoneNamespace, enUS],\n ['zh-CN', dialtoneNamespace, zhCN],\n ['nl-NL', dialtoneNamespace, nlNL],\n ['fr-FR', dialtoneNamespace, frFR],\n ['de-DE', dialtoneNamespace, deDE],\n ['it-IT', dialtoneNamespace, itIT],\n ['ja-JP', dialtoneNamespace, jaJP],\n ['ko-KR', dialtoneNamespace, koKR],\n ['pt-BR', dialtoneNamespace, ptBR],\n ['ru-RU', dialtoneNamespace, ruRU],\n ['es-LA', dialtoneNamespace, esLA],\n ['sv-SE', dialtoneNamespace, svSE],\n ]),\n });\n\n const localeManager = new LocaleManager({\n bundleSource,\n allowedLocales: Object.values(allowedLocales),\n fallbackLocale,\n preferredLocale: this._locale,\n namespaces: [dialtoneNamespace],\n });\n\n DialtoneLocalization.instance = this;\n this.i18n = localeManager.useI18N(dialtoneNamespace);\n\n if (typeof window !== 'undefined') {\n /**\n * @description\n * When the browser storage changes, update the current locale\n * @param event\n */\n window.onstorage = (event) => {\n if (event.key === localeManagerStorageKey) {\n this.currentLocale = event.newValue;\n }\n };\n }\n\n return this;\n }\n\n /**\n * Gets the preferred locale from user's locale stored in localStorage or the browser language\n * @returns { string }\n */\n static getPreferredLocale () {\n /**\n * Early return if we're not in the browser or if localStorage is not available\n */\n if (typeof window === 'undefined' || !window.localStorage) {\n return fallbackLocale;\n }\n\n // Only trust the stored locale if it's one Dialtone actually ships a bundle for.\n // Callers (e.g. UC/UV) may allow locales Dialtone doesn't support, which would\n // otherwise crash the LocaleManager during render.\n const storedLanguage = window.localStorage.getItem(localeManagerStorageKey);\n const localStorageLanguage = Object.values(allowedLocales).includes(storedLanguage)\n ? storedLanguage\n : null;\n\n // Get the first two letters of the navigator language and check if it's in the allowed locales\n const navigatorLanguage = Object.values(allowedLocales)\n .find(locale => locale.startsWith(navigator.language.slice(0, 2)));\n\n return localStorageLanguage || navigatorLanguage || fallbackLocale;\n }\n\n static getAllowedLocales () {\n return allowedLocales;\n }\n\n /**\n * Passthrough function to the i18n $t function including the dialtone namespace\n * Returns a translated string based on a key and optional variables.\n * It’s used for simple text translations.\n * https://github.com/dialpad/goblin-client-tools/tree/main/packages/i18n#t\n */\n $t (...args) {\n return this.i18n.$t(...args);\n }\n\n /**\n * Passthrough function to the i18n $ta function including the dialtone namespace\n * Returns an object containing translated attributes to pass directly as props to components, it can contain\n * aria-label, title, etc, rather than just a plain text. It’s useful for handling element attributes in the UI.\n * https://github.com/dialpad/goblin-client-tools/tree/main/packages/i18n#ta\n */\n $ta (...args) {\n return this.i18n.$ta(...args);\n }\n\n get currentLocale () {\n return this._locale;\n }\n\n set currentLocale (newLocale) {\n if (newLocale === this._locale) return;\n if (!Object.values(allowedLocales).includes(newLocale)) {\n throw new Error(`Locale ${newLocale} is not allowed, please use one of the following: ${Object.values(allowedLocales).join(', ')}`);\n }\n\n this._locale = newLocale;\n this.i18n.setI18N({ preferredLocale: newLocale }, dialtoneNamespace);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,IAAM,IAAoB,YACpB,IAAiB;CACrB,SAAS;CACT,SAAS;CACT,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,UAAU;CACV,QAAQ;CACR,YAAY;CACZ,SAAS;CACT,SAAS;CACT,SAAS;CACV,EACK,IAAiB,SAIjB,IAA0B,eAOnB,IAAb,MAAa,EAAqB;CAKhC,YAAa,IAAS,MAAM;AAC1B,MAAI,OAAO,EAAqB,YAAa,SAC3C,QAAO,EAAqB;AAG9B,OAAK,UAAU,KAAU,EAAqB,oBAAoB;EAmBlE,IAAM,IAAgB,IAAI,EAAc;GACtC,cAlBmB,IAAI,EAAgB,EACvC,WAAW,EAAgB,eAAe;IACxC;KAAC;KAAS;KAAmBA;KAAK;IAClC;KAAC;KAAS;KAAmBC;KAAK;IAClC;KAAC;KAAS;KAAmBC;KAAK;IAClC;KAAC;KAAS;KAAmBC;KAAK;IAClC;KAAC;KAAS;KAAmBC;KAAK;IAClC;KAAC;KAAS;KAAmBC;KAAK;IAClC;KAAC;KAAS;KAAmBC;KAAK;IAClC;KAAC;KAAS;KAAmBC;KAAK;IAClC;KAAC;KAAS;KAAmBC;KAAK;IAClC;KAAC;KAAS;KAAmBC;KAAK;IAClC;KAAC;KAAS;KAAmBC;KAAK;IAClC;KAAC;KAAS;KAAmBC;KAAK;IACnC,CAAC,EACH,CAAC;GAIA,gBAAgB,OAAO,OAAO,EAAe;GAC7C;GACA,iBAAiB,KAAK;GACtB,YAAY,CAAC,EAAkB;GAChC,CAAC;AAkBF,SAhBA,EAAqB,WAAW,MAChC,KAAK,OAAO,EAAc,QAAQ,EAAkB,EAEhD,OAAO,SAAW,QAMpB,OAAO,aAAa,MAAU;AAC5B,GAAI,EAAM,QAAQ,MAChB,KAAK,gBAAgB,EAAM;MAK1B;;CAOT,OAAO,qBAAsB;AAI3B,MAAI,OAAO,SAAW,OAAe,CAAC,OAAO,aAC3C,QAAO;EAMT,IAAM,IAAiB,OAAO,aAAa,QAAQ,EAAwB,EACrE,IAAuB,OAAO,OAAO,EAAe,CAAC,SAAS,EAAe,GAC/E,IACA,MAGE,IAAoB,OAAO,OAAO,EAAe,CACpD,MAAK,MAAU,EAAO,WAAW,UAAU,SAAS,MAAM,GAAG,EAAE,CAAC,CAAC;AAEpE,SAAO,KAAwB,KAAqB;;CAGtD,OAAO,oBAAqB;AAC1B,SAAO;;CAST,GAAI,GAAG,GAAM;AACX,SAAO,KAAK,KAAK,GAAG,GAAG,EAAK;;CAS9B,IAAK,GAAG,GAAM;AACZ,SAAO,KAAK,KAAK,IAAI,GAAG,EAAK;;CAG/B,IAAI,gBAAiB;AACnB,SAAO,KAAK;;CAGd,IAAI,cAAe,GAAW;AACxB,YAAc,KAAK,SACvB;OAAI,CAAC,OAAO,OAAO,EAAe,CAAC,SAAS,EAAU,CACpD,OAAU,MAAM,UAAU,EAAU,oDAAoD,OAAO,OAAO,EAAe,CAAC,KAAK,KAAK,GAAG;AAIrI,GADA,KAAK,UAAU,GACf,KAAK,KAAK,QAAQ,EAAE,iBAAiB,GAAW,EAAE,EAAkB"}
1
+ {"version":3,"file":"index.js","names":["enUS","zhCN","nlNL","frFR","deDE","itIT","jaJP","koKR","ptBR","ruRU","esLA","svSE"],"sources":["../../localization/index.js"],"sourcesContent":["import { LocaleManager, RawBundleSource, MemoryStorageWrapper } from '@dialpad/i18n';\n\nimport enUS from './en-US.ftl?raw';\nimport zhCN from './zh-CN.ftl?raw';\nimport nlNL from './nl-NL.ftl?raw';\nimport frFR from './fr-FR.ftl?raw';\nimport deDE from './de-DE.ftl?raw';\nimport itIT from './it-IT.ftl?raw';\nimport jaJP from './ja-JP.ftl?raw';\nimport koKR from './ko-KR.ftl?raw';\nimport ptBR from './pt-BR.ftl?raw';\nimport ruRU from './ru-RU.ftl?raw';\nimport esLA from './es-LA.ftl?raw';\nimport svSE from './sv-SE.ftl?raw';\n\nconst dialtoneNamespace = 'dialtone';\nconst allowedLocales = {\n ENGLISH: 'en-US',\n CHINESE: 'zh-CN',\n DUTCH: 'nl-NL',\n FRENCH: 'fr-FR',\n GERMAN: 'de-DE',\n ITALIAN: 'it-IT',\n JAPANESE: 'ja-JP',\n KOREAN: 'ko-KR',\n PORTUGUESE: 'pt-BR',\n RUSSIAN: 'ru-RU',\n SPANISH: 'es-LA',\n SWEDISH: 'sv-SE',\n};\nconst fallbackLocale = 'en-US';\n/**\n * Default key name used by the LocaleManager to store the user's preferred locale in localStorage\n */\nconst localeManagerStorageKey = 'user-locale';\n\n/**\n * Dialtone localization class, follows the singleton pattern to make sure only one instance of the class is created.\n * Initializes the localeManager and looks for changes on the browser storage to update the current locale.\n * https://github.com/dialpad/goblin-client-tools/tree/main/packages/i18n#i18n-vue-3-compatible\n */\nexport class DialtoneLocalization {\n /**\n * @prop {import('@dialpad/i18n').UseI18N} i18n\n * @private\n */\n constructor (locale = null) {\n if (typeof DialtoneLocalization.instance === 'object') {\n return DialtoneLocalization.instance;\n }\n\n this._locale = locale || DialtoneLocalization.getPreferredLocale();\n\n const bundleSource = new RawBundleSource({\n resources: RawBundleSource.builtResources([\n ['en-US', dialtoneNamespace, enUS],\n ['zh-CN', dialtoneNamespace, zhCN],\n ['nl-NL', dialtoneNamespace, nlNL],\n ['fr-FR', dialtoneNamespace, frFR],\n ['de-DE', dialtoneNamespace, deDE],\n ['it-IT', dialtoneNamespace, itIT],\n ['ja-JP', dialtoneNamespace, jaJP],\n ['ko-KR', dialtoneNamespace, koKR],\n ['pt-BR', dialtoneNamespace, ptBR],\n ['ru-RU', dialtoneNamespace, ruRU],\n ['es-LA', dialtoneNamespace, esLA],\n ['sv-SE', dialtoneNamespace, svSE],\n ]),\n });\n\n const localeOptions = {\n bundleSource,\n allowedLocales: Object.values(allowedLocales),\n fallbackLocale,\n preferredLocale: this._locale,\n namespaces: [dialtoneNamespace],\n };\n let localeManager;\n try {\n localeManager = new LocaleManager(localeOptions);\n } catch (error) {\n if (error.name !== 'SecurityError') throw error;\n localeManager = new LocaleManager({ ...localeOptions, storageWrapper: new MemoryStorageWrapper() });\n }\n\n DialtoneLocalization.instance = this;\n this.i18n = localeManager.useI18N(dialtoneNamespace);\n\n if (typeof window !== 'undefined') {\n /**\n * @description\n * When the browser storage changes, update the current locale\n * @param event\n */\n window.addEventListener('storage', (event) => {\n if (event.key === localeManagerStorageKey) {\n this.currentLocale = event.newValue;\n }\n });\n }\n\n return this;\n }\n\n /**\n * Gets the preferred locale from user's locale stored in localStorage or the browser language\n * @returns { string }\n */\n static getPreferredLocale () {\n /**\n * Early return if we're not in the browser or if localStorage is not available\n */\n if (typeof window === 'undefined') {\n return fallbackLocale;\n }\n\n let storedLanguage;\n try {\n const storage = window.localStorage;\n if (!storage) return fallbackLocale;\n storedLanguage = storage.getItem(localeManagerStorageKey);\n } catch {\n return fallbackLocale;\n }\n\n // Only trust the stored locale if it's one Dialtone actually ships a bundle for.\n // Callers (e.g. UC/UV) may allow locales Dialtone doesn't support, which would\n // otherwise crash the LocaleManager during render.\n const localStorageLanguage = Object.values(allowedLocales).includes(storedLanguage)\n ? storedLanguage\n : null;\n\n // Get the first two letters of the navigator language and check if it's in the allowed locales\n const navigatorLanguage = Object.values(allowedLocales)\n .find(locale => locale.startsWith(navigator.language.slice(0, 2)));\n\n return localStorageLanguage || navigatorLanguage || fallbackLocale;\n }\n\n static getAllowedLocales () {\n return allowedLocales;\n }\n\n /**\n * Passthrough function to the i18n $t function including the dialtone namespace\n * Returns a translated string based on a key and optional variables.\n * It’s used for simple text translations.\n * https://github.com/dialpad/goblin-client-tools/tree/main/packages/i18n#t\n */\n $t (...args) {\n return this.i18n.$t(...args);\n }\n\n /**\n * Passthrough function to the i18n $ta function including the dialtone namespace\n * Returns an object containing translated attributes to pass directly as props to components, it can contain\n * aria-label, title, etc, rather than just a plain text. It’s useful for handling element attributes in the UI.\n * https://github.com/dialpad/goblin-client-tools/tree/main/packages/i18n#ta\n */\n $ta (...args) {\n return this.i18n.$ta(...args);\n }\n\n get currentLocale () {\n return this._locale;\n }\n\n set currentLocale (newLocale) {\n if (newLocale === this._locale) return;\n if (!Object.values(allowedLocales).includes(newLocale)) {\n throw new Error(`Locale ${newLocale} is not allowed, please use one of the following: ${Object.values(allowedLocales).join(', ')}`);\n }\n\n this._locale = newLocale;\n this.i18n.setI18N({ preferredLocale: newLocale }, dialtoneNamespace);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,IAAM,IAAoB,YACpB,IAAiB;CACrB,SAAS;CACT,SAAS;CACT,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,UAAU;CACV,QAAQ;CACR,YAAY;CACZ,SAAS;CACT,SAAS;CACT,SAAS;CACV,EACK,IAAiB,SAIjB,IAA0B,eAOnB,IAAb,MAAa,EAAqB;CAKhC,YAAa,IAAS,MAAM;AAC1B,MAAI,OAAO,EAAqB,YAAa,SAC3C,QAAO,EAAqB;AAG9B,OAAK,UAAU,KAAU,EAAqB,oBAAoB;EAmBlE,IAAM,IAAgB;GACpB,cAlBmB,IAAI,EAAgB,EACvC,WAAW,EAAgB,eAAe;IACxC;KAAC;KAAS;KAAmBA;KAAK;IAClC;KAAC;KAAS;KAAmBC;KAAK;IAClC;KAAC;KAAS;KAAmBC;KAAK;IAClC;KAAC;KAAS;KAAmBC;KAAK;IAClC;KAAC;KAAS;KAAmBC;KAAK;IAClC;KAAC;KAAS;KAAmBC;KAAK;IAClC;KAAC;KAAS;KAAmBC;KAAK;IAClC;KAAC;KAAS;KAAmBC;KAAK;IAClC;KAAC;KAAS;KAAmBC;KAAK;IAClC;KAAC;KAAS;KAAmBC;KAAK;IAClC;KAAC;KAAS;KA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,UAAU,EAAU,oDAAoD,OAAO,OAAO,EAAe,CAAC,KAAK,KAAK,GAAG;AAIrI,GADA,KAAK,UAAU,GACf,KAAK,KAAK,QAAQ,EAAE,iBAAiB,GAAW,EAAE,EAAkB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dialpad/dialtone-vue",
3
- "version": "4.5.0",
3
+ "version": "4.6.1",
4
4
  "description": "Vue component library for Dialpad's design system Dialtone",
5
5
  "files": [
6
6
  "dist"
@@ -47,7 +47,7 @@
47
47
  "regex-combined-emojis": "1.6.0",
48
48
  "tippy.js": "6.3.7",
49
49
  "@dialpad/dialtone-emojis": "1.3.1",
50
- "@dialpad/dialtone-icons": "5.4.0"
50
+ "@dialpad/dialtone-icons": "5.5.0"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@storybook/addon-a11y": "10.3.0",
@@ -61,12 +61,12 @@
61
61
  "react": "19.2.4",
62
62
  "storybook": "10.3.0",
63
63
  "vue": "^3.3.4",
64
- "@dialpad/dialtone-css": "9.2.0",
65
- "@dialpad/generator-dialtone": "0.1.0"
64
+ "@dialpad/generator-dialtone": "0.1.0",
65
+ "@dialpad/dialtone-css": "9.4.0"
66
66
  },
67
67
  "peerDependencies": {
68
68
  "vue": ">=3.2",
69
- "@dialpad/dialtone-css": "^9.2.0"
69
+ "@dialpad/dialtone-css": "^9.4.0"
70
70
  },
71
71
  "bugs": {
72
72
  "email": "dialtone@dialpad.com"