@tagplus/components 5.2.6 → 5.2.8

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/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "email": "bruno@tagplus.com.br"
9
9
  }
10
10
  ],
11
- "version": "5.2.6",
11
+ "version": "5.2.8",
12
12
  "main": "./dist/tp.common.js",
13
13
  "directories": {
14
14
  "lib": "src/lib"
@@ -124,45 +124,43 @@ async function setupI18n (options = {}) {
124
124
  * @param {Function} [options.i18nHelper.importLangFile] - A function for asynchronously importing custom language files.
125
125
  * @param {Function} [options.i18nHelper.onLanguageSet] - A function to be called after setting the language.
126
126
  * @param {Object} [options.i18nOptions] - Additional options to be passed to the createI18n function.
127
+ * @param {Function} [postInstall] - A function to be called after the plugin is installed.
127
128
  *
128
129
  * @returns {Object} - An object with an install function for Vue.js plugins.
129
130
  */
130
- export default async (options = {}) => {
131
- // Validar as options
131
+ export default async (options = {}, postInstall = (app, options, i18nHelper) => {}) => {
132
+ // Validating the options
132
133
  const keys = Object.keys(options).filter(key => !['i18nHelper', 'i18nOptions'].includes(key))
133
134
  if (keys.length) {
134
135
  throw new Error(`Invalid options: ${keys.join(', ')}, expected { i18nOptions, i18nHelper }`)
135
136
  }
136
137
 
137
- // Override the importLangFile function if provided in options
138
+ // Overriding the importLangFile function if provided in options
138
139
  if (options.i18nHelper && typeof options.i18nHelper.importLangFile === 'function') {
139
140
  i18nHelper.importLangFile = options.i18nHelper.importLangFile
140
141
  }
141
142
 
142
- // Override the onLanguageSet function if provided in options
143
+ // Overriding the onLanguageSet function if provided in options
143
144
  if (options.i18nHelper && typeof options.i18nHelper.onLanguageSet === 'function') {
144
145
  i18nHelper.onLanguageSet = options.i18nHelper.onLanguageSet
145
146
  }
146
147
 
147
148
  let i18nOptions = {}
148
- // Use provided i18nOptions if available
149
+ // Using provided i18nOptions if available
149
150
  if (options.i18nOptions && typeof options.i18nOptions === 'object') {
150
151
  i18nOptions = options.i18nOptions
151
152
  }
152
153
 
153
- // Initialize the i18n instance with the provided options
154
+ // Initializing the i18n instance with the provided options
154
155
  i18n = await setupI18n(i18nOptions)
155
156
 
156
157
  return {
157
158
  install: (app, opts) => {
158
- // Install the original i18n instance
159
+ // Installing the original i18n instance
159
160
  i18n.install(app, i18nOptions)
160
-
161
- /**
162
- * Override project-specific functions and provide the $i18nHelper
163
- * in the Vue.js app's global properties.
164
- **/
165
- app.config.globalProperties.$i18nHelper = i18nHelper
161
+ if (typeof postInstall === 'function') {
162
+ postInstall(app, options, i18nHelper)
163
+ }
166
164
  }
167
165
  }
168
166
  }