@opentiny/vue-search-box 0.1.2 → 0.1.3
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/es/index.es.js +27 -10
- package/dist/es/utils/en_US.es.js +2 -2
- package/dist/lib/index.cjs.js +21 -4
- package/dist/lib/utils/en_US.cjs.js +2 -2
- package/package.json +1 -1
package/dist/es/index.es.js
CHANGED
|
@@ -2,27 +2,44 @@ import "./index.vue.es.js";
|
|
|
2
2
|
import "./components/first-level-panel.vue.es.js";
|
|
3
3
|
import "./components/second-level-panel.vue.es.js";
|
|
4
4
|
import zhCN from "./utils/zh_CN.es.js";
|
|
5
|
-
import
|
|
5
|
+
import enUS from "./utils/en_US.es.js";
|
|
6
6
|
/* empty css */
|
|
7
7
|
import "./index.type.es.js";
|
|
8
8
|
import _sfc_main from "./index.vue.es2.js";
|
|
9
|
-
import { default as
|
|
10
|
-
import { default as
|
|
9
|
+
import { default as default2 } from "./components/first-level-panel.vue.es2.js";
|
|
10
|
+
import { default as default3 } from "./components/second-level-panel.vue.es2.js";
|
|
11
11
|
let apps;
|
|
12
12
|
_sfc_main.install = function(app) {
|
|
13
13
|
apps = app;
|
|
14
14
|
app.component(_sfc_main.name, _sfc_main);
|
|
15
15
|
};
|
|
16
|
-
const t = (key) => {
|
|
17
|
-
var _a, _b, _c, _d, _e
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
const t = (key, params) => {
|
|
17
|
+
var _a, _b, _c, _d, _e;
|
|
18
|
+
if ((_b = (_a = apps == null ? void 0 : apps.config) == null ? void 0 : _a.globalProperties) == null ? void 0 : _b.$t) {
|
|
19
|
+
return apps.config.globalProperties.$t(key, params);
|
|
20
|
+
}
|
|
21
|
+
const lang = ((_e = (_d = (_c = apps == null ? void 0 : apps.config) == null ? void 0 : _c.globalProperties) == null ? void 0 : _d.$i18n) == null ? void 0 : _e.locale) || "zhCN";
|
|
22
|
+
return customTranslate(key, params, lang);
|
|
20
23
|
};
|
|
24
|
+
function customTranslate(key, params, lang = "zhCN") {
|
|
25
|
+
const resources = { zhCN, enUS };
|
|
26
|
+
const i18nResources = resources[lang] || resources["zhCN"];
|
|
27
|
+
const value = key.split(".").reduce((obj, k) => obj && obj[k] !== void 0 ? obj[k] : void 0, i18nResources);
|
|
28
|
+
let template = typeof value === "string" ? value : key;
|
|
29
|
+
if (params && typeof params === "object") {
|
|
30
|
+
Object.keys(params).forEach((k) => {
|
|
31
|
+
const value2 = params[k] ?? "";
|
|
32
|
+
template = template.replaceAll(`{${k}}`, String(value2));
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
template = template.replace(/{{\s*\w+\s*}}/g, "");
|
|
36
|
+
return template;
|
|
37
|
+
}
|
|
21
38
|
export {
|
|
22
|
-
|
|
23
|
-
|
|
39
|
+
default2 as TinySearchBoxFirstLevelPanel,
|
|
40
|
+
default3 as TinySearchBoxSecondLevelPanel,
|
|
24
41
|
_sfc_main as default,
|
|
25
|
-
|
|
42
|
+
enUS,
|
|
26
43
|
t,
|
|
27
44
|
zhCN
|
|
28
45
|
};
|
package/dist/lib/index.cjs.js
CHANGED
|
@@ -15,11 +15,28 @@ index_vue_vue_type_script_setup_true_lang.default.install = function(app) {
|
|
|
15
15
|
apps = app;
|
|
16
16
|
app.component(index_vue_vue_type_script_setup_true_lang.default.name, index_vue_vue_type_script_setup_true_lang.default);
|
|
17
17
|
};
|
|
18
|
-
const t = (key) => {
|
|
19
|
-
var _a, _b, _c, _d, _e
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
const t = (key, params) => {
|
|
19
|
+
var _a, _b, _c, _d, _e;
|
|
20
|
+
if ((_b = (_a = apps == null ? void 0 : apps.config) == null ? void 0 : _a.globalProperties) == null ? void 0 : _b.$t) {
|
|
21
|
+
return apps.config.globalProperties.$t(key, params);
|
|
22
|
+
}
|
|
23
|
+
const lang = ((_e = (_d = (_c = apps == null ? void 0 : apps.config) == null ? void 0 : _c.globalProperties) == null ? void 0 : _d.$i18n) == null ? void 0 : _e.locale) || "zhCN";
|
|
24
|
+
return customTranslate(key, params, lang);
|
|
22
25
|
};
|
|
26
|
+
function customTranslate(key, params, lang = "zhCN") {
|
|
27
|
+
const resources = { zhCN: zh_CN.default, enUS: en_US.default };
|
|
28
|
+
const i18nResources = resources[lang] || resources["zhCN"];
|
|
29
|
+
const value = key.split(".").reduce((obj, k) => obj && obj[k] !== void 0 ? obj[k] : void 0, i18nResources);
|
|
30
|
+
let template = typeof value === "string" ? value : key;
|
|
31
|
+
if (params && typeof params === "object") {
|
|
32
|
+
Object.keys(params).forEach((k) => {
|
|
33
|
+
const value2 = params[k] ?? "";
|
|
34
|
+
template = template.replaceAll(`{${k}}`, String(value2));
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
template = template.replace(/{{\s*\w+\s*}}/g, "");
|
|
38
|
+
return template;
|
|
39
|
+
}
|
|
23
40
|
exports.zhCN = zh_CN.default;
|
|
24
41
|
exports.enUS = en_US.default;
|
|
25
42
|
exports.default = index_vue_vue_type_script_setup_true_lang.default;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const
|
|
3
|
+
const enUS = {
|
|
4
4
|
tvp: {
|
|
5
5
|
tvpSearchbox: {
|
|
6
6
|
defaultPlaceholder: "Select attribute filtering or enter keywords",
|
|
@@ -41,4 +41,4 @@ const en_US = {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
|
-
exports.default =
|
|
44
|
+
exports.default = enUS;
|