@pisell/utils 1.0.60 → 1.0.62

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.
@@ -0,0 +1,36 @@
1
+ /** 生成存储 key 的路径后缀:pathname 或 pathname#memory_key(来自 URL memory_key 参数) */
2
+ export declare function getStorageKeySuffix(): string;
3
+ /**
4
+ * 生成组件实例的存储 key。
5
+ * @param componentId 组件实例 id(如 __id)
6
+ * @param prefix 前缀,如 'table-setting'、'record-board-column-visibility'
7
+ */
8
+ export declare function getComponentStorageKey(componentId: string, prefix: string): string;
9
+ export interface ColumnSettingStorageItem {
10
+ key: string;
11
+ dataIndex: string;
12
+ title?: unknown;
13
+ titleString?: string;
14
+ isShow: boolean;
15
+ sortIndex?: number;
16
+ fixed?: 'left' | 'right' | boolean;
17
+ }
18
+ export declare function saveColumnSettingToLocal(params: {
19
+ componentId: string;
20
+ columnSetting: ColumnSettingStorageItem[];
21
+ }): void;
22
+ export declare function getColumnSettingFromLocal(componentId?: string): ColumnSettingStorageItem[] | null;
23
+ export declare function clearColumnSettingFromLocal(componentId?: string): void;
24
+ export declare function saveColumnVisibilityToLocal(params: {
25
+ componentId: string;
26
+ columnVisibility: Record<string, boolean>;
27
+ /** 列 key 顺序,用于列设置弹层拖拽排序后持久化 */
28
+ columnOrder?: string[];
29
+ }): void;
30
+ export declare function getColumnVisibilityFromLocal(componentId?: string): Record<string, boolean> | null;
31
+ /** RecordBoard 列设置(显隐 + 顺序)从 localStorage 读取,用于列设置弹层拖拽排序与显隐持久化 */
32
+ export declare function getRecordBoardColumnSettingFromLocal(componentId?: string): {
33
+ columnVisibility: Record<string, boolean>;
34
+ columnOrder: string[] | null;
35
+ } | null;
36
+ export declare function clearColumnVisibilityFromLocal(componentId?: string): void;
@@ -0,0 +1,142 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ /**
8
+ * 组件级 localStorage 存储:列设置、列显隐等。
9
+ * 供 pisellDataSourceContainer、pisellRecordBoard 等复用,key 含 pathname 与 memory_key 以区分页面。
10
+ */
11
+ import { isJson } from "./typeUtils";
12
+
13
+ /** 生成存储 key 的路径后缀:pathname 或 pathname#memory_key(来自 URL memory_key 参数) */
14
+ export function getStorageKeySuffix() {
15
+ if (typeof window === 'undefined' || typeof window.location === 'undefined') {
16
+ return '/';
17
+ }
18
+ var _window$location = window.location,
19
+ pathname = _window$location.pathname,
20
+ search = _window$location.search;
21
+ var appendPath = pathname || '/';
22
+ var memoryKey = '';
23
+ try {
24
+ var params = new URLSearchParams(search || '');
25
+ var mk = params.get('memory_key');
26
+ if (mk && mk.trim() !== '') memoryKey = mk.trim();
27
+ } catch (_unused) {
28
+ // ignore
29
+ }
30
+ return memoryKey ? "".concat(appendPath, "#").concat(memoryKey) : appendPath;
31
+ }
32
+
33
+ /**
34
+ * 生成组件实例的存储 key。
35
+ * @param componentId 组件实例 id(如 __id)
36
+ * @param prefix 前缀,如 'table-setting'、'record-board-column-visibility'
37
+ */
38
+ export function getComponentStorageKey(componentId, prefix) {
39
+ if (typeof window === 'undefined' || typeof window.location === 'undefined') {
40
+ return "".concat(prefix, "-").concat(componentId);
41
+ }
42
+ var suffix = getStorageKeySuffix();
43
+ return "".concat(prefix, "-").concat(componentId, "-").concat(suffix);
44
+ }
45
+
46
+ // ---------- 列设置(DataSourceContainer Table 列显隐+排序等,数组格式) ----------
47
+
48
+ export function saveColumnSettingToLocal(params) {
49
+ var componentId = params.componentId,
50
+ columnSetting = params.columnSetting;
51
+ if (!componentId) return;
52
+ if (typeof window === 'undefined' || !window.localStorage) return;
53
+ var storageKey = getComponentStorageKey(componentId, 'table-setting');
54
+ var data = {
55
+ column_setting: columnSetting,
56
+ updatedAt: Date.now()
57
+ };
58
+ try {
59
+ window.localStorage.setItem(storageKey, JSON.stringify(data));
60
+ } catch (_unused2) {
61
+ // ignore
62
+ }
63
+ }
64
+ export function getColumnSettingFromLocal(componentId) {
65
+ if (!componentId) return null;
66
+ if (typeof window === 'undefined' || !window.localStorage) return null;
67
+ var storageKey = getComponentStorageKey(componentId, 'table-setting');
68
+ var raw = window.localStorage.getItem(storageKey);
69
+ if (raw && isJson(raw)) {
70
+ var data = JSON.parse(raw);
71
+ var arr = data === null || data === void 0 ? void 0 : data.column_setting;
72
+ return Array.isArray(arr) ? arr : null;
73
+ }
74
+ return null;
75
+ }
76
+ export function clearColumnSettingFromLocal(componentId) {
77
+ if (!componentId) return;
78
+ if (typeof window === 'undefined' || !window.localStorage) return;
79
+ var storageKey = getComponentStorageKey(componentId, 'table-setting');
80
+ window.localStorage.removeItem(storageKey);
81
+ }
82
+
83
+ // ---------- 列显隐(RecordBoard,Record<列 key, boolean> 格式) ----------
84
+
85
+ var RECORD_BOARD_VISIBILITY_PREFIX = 'record-board-column-visibility';
86
+ export function saveColumnVisibilityToLocal(params) {
87
+ var componentId = params.componentId,
88
+ columnVisibility = params.columnVisibility,
89
+ columnOrder = params.columnOrder;
90
+ if (!componentId) return;
91
+ if (typeof window === 'undefined' || !window.localStorage) return;
92
+ var storageKey = getComponentStorageKey(componentId, RECORD_BOARD_VISIBILITY_PREFIX);
93
+ var data = _objectSpread(_objectSpread({
94
+ column_visibility: columnVisibility
95
+ }, columnOrder != null && {
96
+ column_order: columnOrder
97
+ }), {}, {
98
+ updatedAt: Date.now()
99
+ });
100
+ try {
101
+ window.localStorage.setItem(storageKey, JSON.stringify(data));
102
+ } catch (_unused3) {
103
+ // ignore
104
+ }
105
+ }
106
+ export function getColumnVisibilityFromLocal(componentId) {
107
+ if (!componentId) return null;
108
+ if (typeof window === 'undefined' || !window.localStorage) return null;
109
+ var storageKey = getComponentStorageKey(componentId, RECORD_BOARD_VISIBILITY_PREFIX);
110
+ var raw = window.localStorage.getItem(storageKey);
111
+ if (raw && isJson(raw)) {
112
+ var data = JSON.parse(raw);
113
+ var vis = data === null || data === void 0 ? void 0 : data.column_visibility;
114
+ return vis && _typeof(vis) === 'object' && vis !== null ? vis : null;
115
+ }
116
+ return null;
117
+ }
118
+
119
+ /** RecordBoard 列设置(显隐 + 顺序)从 localStorage 读取,用于列设置弹层拖拽排序与显隐持久化 */
120
+ export function getRecordBoardColumnSettingFromLocal(componentId) {
121
+ if (!componentId) return null;
122
+ if (typeof window === 'undefined' || !window.localStorage) return null;
123
+ var storageKey = getComponentStorageKey(componentId, RECORD_BOARD_VISIBILITY_PREFIX);
124
+ var raw = window.localStorage.getItem(storageKey);
125
+ if (raw && isJson(raw)) {
126
+ var data = JSON.parse(raw);
127
+ var vis = data === null || data === void 0 ? void 0 : data.column_visibility;
128
+ var columnVisibility = vis && _typeof(vis) === 'object' && vis !== null ? vis : {};
129
+ var columnOrder = Array.isArray(data === null || data === void 0 ? void 0 : data.column_order) ? data.column_order : null;
130
+ return {
131
+ columnVisibility: columnVisibility,
132
+ columnOrder: columnOrder
133
+ };
134
+ }
135
+ return null;
136
+ }
137
+ export function clearColumnVisibilityFromLocal(componentId) {
138
+ if (!componentId) return;
139
+ if (typeof window === 'undefined' || !window.localStorage) return;
140
+ var storageKey = getComponentStorageKey(componentId, RECORD_BOARD_VISIBILITY_PREFIX);
141
+ window.localStorage.removeItem(storageKey);
142
+ }
package/es/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './otherUtils';
2
2
  export * from './typeUtils';
3
+ export * from './componentStorage';
3
4
  export * from './document';
4
5
  export * from './date';
5
6
  export * from './platform';
package/es/index.js CHANGED
@@ -6,6 +6,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
6
6
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
7
  export * from "./otherUtils";
8
8
  export * from "./typeUtils";
9
+ export * from "./componentStorage";
9
10
  export * from "./document";
10
11
  export * from "./date";
11
12
  export * from "./platform";
package/es/locales.d.ts CHANGED
@@ -1,12 +1,9 @@
1
1
  export declare const locales: {
2
2
  init: (_localeMaps: any, _locale: string) => void;
3
3
  getText: (id: string) => any;
4
+ getLocale: () => string;
4
5
  locale: string;
5
6
  localeMap: any;
6
- localeMaps: {
7
- en: {};
8
- 'zh-CN': {};
9
- 'zh-HK': {};
10
- };
7
+ localeMaps: any;
11
8
  formatLocale: (_locale: string) => string;
12
9
  };
package/es/locales.js CHANGED
@@ -8,7 +8,9 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
8
8
  var localeMaps = {
9
9
  en: {},
10
10
  'zh-CN': {},
11
- 'zh-HK': {}
11
+ 'zh-HK': {},
12
+ 'ja': {},
13
+ 'pt': {}
12
14
  };
13
15
 
14
16
  // 当前语言
@@ -24,7 +26,9 @@ var formatLocale = function formatLocale(_locale) {
24
26
  'zh-CN': 'zh-CN',
25
27
  'zh-HK': 'zh-HK',
26
28
  'zh-TW': 'zh-HK',
27
- 'en-US': 'en'
29
+ 'en-US': 'en',
30
+ 'ja': 'ja',
31
+ 'pt': 'pt'
28
32
  };
29
33
  return obj[_locale] || 'en';
30
34
  };
@@ -62,11 +66,18 @@ var init = function init(_localeMaps, _locale) {
62
66
  * @Date: 2024-01-17 21:39
63
67
  */
64
68
  var getText = function getText(id) {
65
- return localeMap[id] || id;
69
+ var _localeMaps2;
70
+ return localeMap[id] || ((_localeMaps2 = localeMaps) === null || _localeMaps2 === void 0 || (_localeMaps2 = _localeMaps2['en']) === null || _localeMaps2 === void 0 ? void 0 : _localeMaps2[id]) || id;
71
+ };
72
+
73
+ /** 获取当前语言(与 getText 同源,供 datetime 等组件与 getText 语言一致) */
74
+ var getLocale = function getLocale() {
75
+ return locale;
66
76
  };
67
77
  export var locales = {
68
78
  init: init,
69
79
  getText: getText,
80
+ getLocale: getLocale,
70
81
  locale: locale,
71
82
  localeMap: localeMap,
72
83
  localeMaps: localeMaps,
@@ -0,0 +1,36 @@
1
+ /** 生成存储 key 的路径后缀:pathname 或 pathname#memory_key(来自 URL memory_key 参数) */
2
+ export declare function getStorageKeySuffix(): string;
3
+ /**
4
+ * 生成组件实例的存储 key。
5
+ * @param componentId 组件实例 id(如 __id)
6
+ * @param prefix 前缀,如 'table-setting'、'record-board-column-visibility'
7
+ */
8
+ export declare function getComponentStorageKey(componentId: string, prefix: string): string;
9
+ export interface ColumnSettingStorageItem {
10
+ key: string;
11
+ dataIndex: string;
12
+ title?: unknown;
13
+ titleString?: string;
14
+ isShow: boolean;
15
+ sortIndex?: number;
16
+ fixed?: 'left' | 'right' | boolean;
17
+ }
18
+ export declare function saveColumnSettingToLocal(params: {
19
+ componentId: string;
20
+ columnSetting: ColumnSettingStorageItem[];
21
+ }): void;
22
+ export declare function getColumnSettingFromLocal(componentId?: string): ColumnSettingStorageItem[] | null;
23
+ export declare function clearColumnSettingFromLocal(componentId?: string): void;
24
+ export declare function saveColumnVisibilityToLocal(params: {
25
+ componentId: string;
26
+ columnVisibility: Record<string, boolean>;
27
+ /** 列 key 顺序,用于列设置弹层拖拽排序后持久化 */
28
+ columnOrder?: string[];
29
+ }): void;
30
+ export declare function getColumnVisibilityFromLocal(componentId?: string): Record<string, boolean> | null;
31
+ /** RecordBoard 列设置(显隐 + 顺序)从 localStorage 读取,用于列设置弹层拖拽排序与显隐持久化 */
32
+ export declare function getRecordBoardColumnSettingFromLocal(componentId?: string): {
33
+ columnVisibility: Record<string, boolean>;
34
+ columnOrder: string[] | null;
35
+ } | null;
36
+ export declare function clearColumnVisibilityFromLocal(componentId?: string): void;
@@ -0,0 +1,144 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/componentStorage.ts
20
+ var componentStorage_exports = {};
21
+ __export(componentStorage_exports, {
22
+ clearColumnSettingFromLocal: () => clearColumnSettingFromLocal,
23
+ clearColumnVisibilityFromLocal: () => clearColumnVisibilityFromLocal,
24
+ getColumnSettingFromLocal: () => getColumnSettingFromLocal,
25
+ getColumnVisibilityFromLocal: () => getColumnVisibilityFromLocal,
26
+ getComponentStorageKey: () => getComponentStorageKey,
27
+ getRecordBoardColumnSettingFromLocal: () => getRecordBoardColumnSettingFromLocal,
28
+ getStorageKeySuffix: () => getStorageKeySuffix,
29
+ saveColumnSettingToLocal: () => saveColumnSettingToLocal,
30
+ saveColumnVisibilityToLocal: () => saveColumnVisibilityToLocal
31
+ });
32
+ module.exports = __toCommonJS(componentStorage_exports);
33
+ var import_typeUtils = require("./typeUtils");
34
+ function getStorageKeySuffix() {
35
+ if (typeof window === "undefined" || typeof window.location === "undefined") {
36
+ return "/";
37
+ }
38
+ const { pathname, search } = window.location;
39
+ const appendPath = pathname || "/";
40
+ let memoryKey = "";
41
+ try {
42
+ const params = new URLSearchParams(search || "");
43
+ const mk = params.get("memory_key");
44
+ if (mk && mk.trim() !== "") memoryKey = mk.trim();
45
+ } catch {
46
+ }
47
+ return memoryKey ? `${appendPath}#${memoryKey}` : appendPath;
48
+ }
49
+ function getComponentStorageKey(componentId, prefix) {
50
+ if (typeof window === "undefined" || typeof window.location === "undefined") {
51
+ return `${prefix}-${componentId}`;
52
+ }
53
+ const suffix = getStorageKeySuffix();
54
+ return `${prefix}-${componentId}-${suffix}`;
55
+ }
56
+ function saveColumnSettingToLocal(params) {
57
+ const { componentId, columnSetting } = params;
58
+ if (!componentId) return;
59
+ if (typeof window === "undefined" || !window.localStorage) return;
60
+ const storageKey = getComponentStorageKey(componentId, "table-setting");
61
+ const data = { column_setting: columnSetting, updatedAt: Date.now() };
62
+ try {
63
+ window.localStorage.setItem(storageKey, JSON.stringify(data));
64
+ } catch {
65
+ }
66
+ }
67
+ function getColumnSettingFromLocal(componentId) {
68
+ if (!componentId) return null;
69
+ if (typeof window === "undefined" || !window.localStorage) return null;
70
+ const storageKey = getComponentStorageKey(componentId, "table-setting");
71
+ const raw = window.localStorage.getItem(storageKey);
72
+ if (raw && (0, import_typeUtils.isJson)(raw)) {
73
+ const data = JSON.parse(raw);
74
+ const arr = data == null ? void 0 : data.column_setting;
75
+ return Array.isArray(arr) ? arr : null;
76
+ }
77
+ return null;
78
+ }
79
+ function clearColumnSettingFromLocal(componentId) {
80
+ if (!componentId) return;
81
+ if (typeof window === "undefined" || !window.localStorage) return;
82
+ const storageKey = getComponentStorageKey(componentId, "table-setting");
83
+ window.localStorage.removeItem(storageKey);
84
+ }
85
+ var RECORD_BOARD_VISIBILITY_PREFIX = "record-board-column-visibility";
86
+ function saveColumnVisibilityToLocal(params) {
87
+ const { componentId, columnVisibility, columnOrder } = params;
88
+ if (!componentId) return;
89
+ if (typeof window === "undefined" || !window.localStorage) return;
90
+ const storageKey = getComponentStorageKey(componentId, RECORD_BOARD_VISIBILITY_PREFIX);
91
+ const data = {
92
+ column_visibility: columnVisibility,
93
+ ...columnOrder != null && { column_order: columnOrder },
94
+ updatedAt: Date.now()
95
+ };
96
+ try {
97
+ window.localStorage.setItem(storageKey, JSON.stringify(data));
98
+ } catch {
99
+ }
100
+ }
101
+ function getColumnVisibilityFromLocal(componentId) {
102
+ if (!componentId) return null;
103
+ if (typeof window === "undefined" || !window.localStorage) return null;
104
+ const storageKey = getComponentStorageKey(componentId, RECORD_BOARD_VISIBILITY_PREFIX);
105
+ const raw = window.localStorage.getItem(storageKey);
106
+ if (raw && (0, import_typeUtils.isJson)(raw)) {
107
+ const data = JSON.parse(raw);
108
+ const vis = data == null ? void 0 : data.column_visibility;
109
+ return vis && typeof vis === "object" && vis !== null ? vis : null;
110
+ }
111
+ return null;
112
+ }
113
+ function getRecordBoardColumnSettingFromLocal(componentId) {
114
+ if (!componentId) return null;
115
+ if (typeof window === "undefined" || !window.localStorage) return null;
116
+ const storageKey = getComponentStorageKey(componentId, RECORD_BOARD_VISIBILITY_PREFIX);
117
+ const raw = window.localStorage.getItem(storageKey);
118
+ if (raw && (0, import_typeUtils.isJson)(raw)) {
119
+ const data = JSON.parse(raw);
120
+ const vis = data == null ? void 0 : data.column_visibility;
121
+ const columnVisibility = vis && typeof vis === "object" && vis !== null ? vis : {};
122
+ const columnOrder = Array.isArray(data == null ? void 0 : data.column_order) ? data.column_order : null;
123
+ return { columnVisibility, columnOrder };
124
+ }
125
+ return null;
126
+ }
127
+ function clearColumnVisibilityFromLocal(componentId) {
128
+ if (!componentId) return;
129
+ if (typeof window === "undefined" || !window.localStorage) return;
130
+ const storageKey = getComponentStorageKey(componentId, RECORD_BOARD_VISIBILITY_PREFIX);
131
+ window.localStorage.removeItem(storageKey);
132
+ }
133
+ // Annotate the CommonJS export names for ESM import in node:
134
+ 0 && (module.exports = {
135
+ clearColumnSettingFromLocal,
136
+ clearColumnVisibilityFromLocal,
137
+ getColumnSettingFromLocal,
138
+ getColumnVisibilityFromLocal,
139
+ getComponentStorageKey,
140
+ getRecordBoardColumnSettingFromLocal,
141
+ getStorageKeySuffix,
142
+ saveColumnSettingToLocal,
143
+ saveColumnVisibilityToLocal
144
+ });
package/lib/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './otherUtils';
2
2
  export * from './typeUtils';
3
+ export * from './componentStorage';
3
4
  export * from './document';
4
5
  export * from './date';
5
6
  export * from './platform';
package/lib/index.js CHANGED
@@ -26,6 +26,7 @@ __export(src_exports, {
26
26
  module.exports = __toCommonJS(src_exports);
27
27
  __reExport(src_exports, require("./otherUtils"), module.exports);
28
28
  __reExport(src_exports, require("./typeUtils"), module.exports);
29
+ __reExport(src_exports, require("./componentStorage"), module.exports);
29
30
  __reExport(src_exports, require("./document"), module.exports);
30
31
  __reExport(src_exports, require("./date"), module.exports);
31
32
  __reExport(src_exports, require("./platform"), module.exports);
@@ -59,6 +60,7 @@ var getPisellUtilsConfig = () => {
59
60
  setPisellUtilsConfig,
60
61
  ...require("./otherUtils"),
61
62
  ...require("./typeUtils"),
63
+ ...require("./componentStorage"),
62
64
  ...require("./document"),
63
65
  ...require("./date"),
64
66
  ...require("./platform"),
package/lib/locales.d.ts CHANGED
@@ -1,12 +1,9 @@
1
1
  export declare const locales: {
2
2
  init: (_localeMaps: any, _locale: string) => void;
3
3
  getText: (id: string) => any;
4
+ getLocale: () => string;
4
5
  locale: string;
5
6
  localeMap: any;
6
- localeMaps: {
7
- en: {};
8
- 'zh-CN': {};
9
- 'zh-HK': {};
10
- };
7
+ localeMaps: any;
11
8
  formatLocale: (_locale: string) => string;
12
9
  };
package/lib/locales.js CHANGED
@@ -25,7 +25,9 @@ module.exports = __toCommonJS(locales_exports);
25
25
  var localeMaps = {
26
26
  en: {},
27
27
  "zh-CN": {},
28
- "zh-HK": {}
28
+ "zh-HK": {},
29
+ "ja": {},
30
+ "pt": {}
29
31
  };
30
32
  var locale = "en";
31
33
  var localeMap = {};
@@ -35,7 +37,9 @@ var formatLocale = (_locale) => {
35
37
  "zh-CN": "zh-CN",
36
38
  "zh-HK": "zh-HK",
37
39
  "zh-TW": "zh-HK",
38
- "en-US": "en"
40
+ "en-US": "en",
41
+ "ja": "ja",
42
+ "pt": "pt"
39
43
  };
40
44
  return obj[_locale] || "en";
41
45
  };
@@ -52,11 +56,16 @@ var init = (_localeMaps, _locale) => {
52
56
  localeMap = localeMaps[locale];
53
57
  };
54
58
  var getText = (id) => {
55
- return localeMap[id] || id;
59
+ var _a;
60
+ return localeMap[id] || ((_a = localeMaps == null ? void 0 : localeMaps["en"]) == null ? void 0 : _a[id]) || id;
61
+ };
62
+ var getLocale = () => {
63
+ return locale;
56
64
  };
57
65
  var locales = {
58
66
  init,
59
67
  getText,
68
+ getLocale,
60
69
  locale,
61
70
  localeMap,
62
71
  localeMaps,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/utils",
3
- "version": "1.0.60",
3
+ "version": "1.0.62",
4
4
  "sideEffects": false,
5
5
  "main": "./lib/index.js",
6
6
  "module": "./es/index.js",