@opentiny/vue-search-box 0.1.2 → 0.1.4

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.
@@ -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 { default as default2 } from "./utils/en_US.es.js";
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 default3 } from "./components/first-level-panel.vue.es2.js";
10
- import { default as default4 } from "./components/second-level-panel.vue.es2.js";
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, _f, _g;
18
- const array = key.split(".");
19
- return ((_b = (_a = apps == null ? void 0 : apps.config) == null ? void 0 : _a.globalProperties) == null ? void 0 : _b.$t) ? (_d = (_c = apps == null ? void 0 : apps.config) == null ? void 0 : _c.globalProperties) == null ? void 0 : _d.$t(key) : (_g = (_f = (_e = zhCN) == null ? void 0 : _e[array == null ? void 0 : array[0]]) == null ? void 0 : _f[array == null ? void 0 : array[1]]) == null ? void 0 : _g[array == null ? void 0 : array[2]];
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
- default3 as TinySearchBoxFirstLevelPanel,
23
- default4 as TinySearchBoxSecondLevelPanel,
39
+ default2 as TinySearchBoxFirstLevelPanel,
40
+ default3 as TinySearchBoxSecondLevelPanel,
24
41
  _sfc_main as default,
25
- default2 as enUS,
42
+ enUS,
26
43
  t,
27
44
  zhCN
28
45
  };
@@ -1,4 +1,4 @@
1
- const en_US = {
1
+ const enUS = {
2
2
  tvp: {
3
3
  tvpSearchbox: {
4
4
  defaultPlaceholder: "Select attribute filtering or enter keywords",
@@ -35,10 +35,11 @@ const en_US = {
35
35
  equal: "Equal",
36
36
  notEqual: "Not equal",
37
37
  contain: "Contain",
38
- notContain: "Does not contain"
38
+ notContain: "Does not contain",
39
+ initUse: "Search"
39
40
  }
40
41
  }
41
42
  };
42
43
  export {
43
- en_US as default
44
+ enUS as default
44
45
  };
@@ -35,7 +35,8 @@ const zhCN = {
35
35
  equal: "等于",
36
36
  notEqual: "不等于",
37
37
  contain: "包含",
38
- notContain: "不包含"
38
+ notContain: "不包含",
39
+ initUse: "搜索"
39
40
  }
40
41
  }
41
42
  };
@@ -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, _f, _g;
20
- const array = key.split(".");
21
- return ((_b = (_a = apps == null ? void 0 : apps.config) == null ? void 0 : _a.globalProperties) == null ? void 0 : _b.$t) ? (_d = (_c = apps == null ? void 0 : apps.config) == null ? void 0 : _c.globalProperties) == null ? void 0 : _d.$t(key) : (_g = (_f = (_e = zh_CN.default) == null ? void 0 : _e[array == null ? void 0 : array[0]]) == null ? void 0 : _f[array == null ? void 0 : array[1]]) == null ? void 0 : _g[array == null ? void 0 : array[2]];
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 en_US = {
3
+ const enUS = {
4
4
  tvp: {
5
5
  tvpSearchbox: {
6
6
  defaultPlaceholder: "Select attribute filtering or enter keywords",
@@ -37,8 +37,9 @@ const en_US = {
37
37
  equal: "Equal",
38
38
  notEqual: "Not equal",
39
39
  contain: "Contain",
40
- notContain: "Does not contain"
40
+ notContain: "Does not contain",
41
+ initUse: "Search"
41
42
  }
42
43
  }
43
44
  };
44
- exports.default = en_US;
45
+ exports.default = enUS;
@@ -37,7 +37,8 @@ const zhCN = {
37
37
  equal: "等于",
38
38
  notEqual: "不等于",
39
39
  contain: "包含",
40
- notContain: "不包含"
40
+ notContain: "不包含",
41
+ initUse: "搜索"
41
42
  }
42
43
  }
43
44
  };
@@ -36,6 +36,7 @@ declare const _default: {
36
36
  notEqual: string;
37
37
  contain: string;
38
38
  notContain: string;
39
+ initUse: string;
39
40
  };
40
41
  };
41
42
  };
@@ -36,6 +36,7 @@ declare const _default: {
36
36
  notEqual: string;
37
37
  contain: string;
38
38
  notContain: string;
39
+ initUse: string;
39
40
  };
40
41
  };
41
42
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentiny/vue-search-box",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "",
5
5
  "homepage": "https://github.com/opentiny/tiny-search-box#readme",
6
6
  "bugs": {