@pisell/utils 1.0.61 → 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.
@@ -24,6 +24,13 @@ export declare function clearColumnSettingFromLocal(componentId?: string): void;
24
24
  export declare function saveColumnVisibilityToLocal(params: {
25
25
  componentId: string;
26
26
  columnVisibility: Record<string, boolean>;
27
+ /** 列 key 顺序,用于列设置弹层拖拽排序后持久化 */
28
+ columnOrder?: string[];
27
29
  }): void;
28
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;
29
36
  export declare function clearColumnVisibilityFromLocal(componentId?: string): void;
@@ -1,4 +1,9 @@
1
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); }
2
7
  /**
3
8
  * 组件级 localStorage 存储:列设置、列显隐等。
4
9
  * 供 pisellDataSourceContainer、pisellRecordBoard 等复用,key 含 pathname 与 memory_key 以区分页面。
@@ -80,14 +85,18 @@ export function clearColumnSettingFromLocal(componentId) {
80
85
  var RECORD_BOARD_VISIBILITY_PREFIX = 'record-board-column-visibility';
81
86
  export function saveColumnVisibilityToLocal(params) {
82
87
  var componentId = params.componentId,
83
- columnVisibility = params.columnVisibility;
88
+ columnVisibility = params.columnVisibility,
89
+ columnOrder = params.columnOrder;
84
90
  if (!componentId) return;
85
91
  if (typeof window === 'undefined' || !window.localStorage) return;
86
92
  var storageKey = getComponentStorageKey(componentId, RECORD_BOARD_VISIBILITY_PREFIX);
87
- var data = {
88
- column_visibility: columnVisibility,
93
+ var data = _objectSpread(_objectSpread({
94
+ column_visibility: columnVisibility
95
+ }, columnOrder != null && {
96
+ column_order: columnOrder
97
+ }), {}, {
89
98
  updatedAt: Date.now()
90
- };
99
+ });
91
100
  try {
92
101
  window.localStorage.setItem(storageKey, JSON.stringify(data));
93
102
  } catch (_unused3) {
@@ -106,6 +115,25 @@ export function getColumnVisibilityFromLocal(componentId) {
106
115
  }
107
116
  return null;
108
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
+ }
109
137
  export function clearColumnVisibilityFromLocal(componentId) {
110
138
  if (!componentId) return;
111
139
  if (typeof window === 'undefined' || !window.localStorage) return;
package/es/locales.d.ts CHANGED
@@ -1,6 +1,7 @@
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
7
  localeMaps: any;
package/es/locales.js CHANGED
@@ -69,9 +69,15 @@ var getText = function getText(id) {
69
69
  var _localeMaps2;
70
70
  return localeMap[id] || ((_localeMaps2 = localeMaps) === null || _localeMaps2 === void 0 || (_localeMaps2 = _localeMaps2['en']) === null || _localeMaps2 === void 0 ? void 0 : _localeMaps2[id]) || id;
71
71
  };
72
+
73
+ /** 获取当前语言(与 getText 同源,供 datetime 等组件与 getText 语言一致) */
74
+ var getLocale = function getLocale() {
75
+ return locale;
76
+ };
72
77
  export var locales = {
73
78
  init: init,
74
79
  getText: getText,
80
+ getLocale: getLocale,
75
81
  locale: locale,
76
82
  localeMap: localeMap,
77
83
  localeMaps: localeMaps,
@@ -24,6 +24,13 @@ export declare function clearColumnSettingFromLocal(componentId?: string): void;
24
24
  export declare function saveColumnVisibilityToLocal(params: {
25
25
  componentId: string;
26
26
  columnVisibility: Record<string, boolean>;
27
+ /** 列 key 顺序,用于列设置弹层拖拽排序后持久化 */
28
+ columnOrder?: string[];
27
29
  }): void;
28
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;
29
36
  export declare function clearColumnVisibilityFromLocal(componentId?: string): void;
@@ -24,6 +24,7 @@ __export(componentStorage_exports, {
24
24
  getColumnSettingFromLocal: () => getColumnSettingFromLocal,
25
25
  getColumnVisibilityFromLocal: () => getColumnVisibilityFromLocal,
26
26
  getComponentStorageKey: () => getComponentStorageKey,
27
+ getRecordBoardColumnSettingFromLocal: () => getRecordBoardColumnSettingFromLocal,
27
28
  getStorageKeySuffix: () => getStorageKeySuffix,
28
29
  saveColumnSettingToLocal: () => saveColumnSettingToLocal,
29
30
  saveColumnVisibilityToLocal: () => saveColumnVisibilityToLocal
@@ -83,11 +84,15 @@ function clearColumnSettingFromLocal(componentId) {
83
84
  }
84
85
  var RECORD_BOARD_VISIBILITY_PREFIX = "record-board-column-visibility";
85
86
  function saveColumnVisibilityToLocal(params) {
86
- const { componentId, columnVisibility } = params;
87
+ const { componentId, columnVisibility, columnOrder } = params;
87
88
  if (!componentId) return;
88
89
  if (typeof window === "undefined" || !window.localStorage) return;
89
90
  const storageKey = getComponentStorageKey(componentId, RECORD_BOARD_VISIBILITY_PREFIX);
90
- const data = { column_visibility: columnVisibility, updatedAt: Date.now() };
91
+ const data = {
92
+ column_visibility: columnVisibility,
93
+ ...columnOrder != null && { column_order: columnOrder },
94
+ updatedAt: Date.now()
95
+ };
91
96
  try {
92
97
  window.localStorage.setItem(storageKey, JSON.stringify(data));
93
98
  } catch {
@@ -105,6 +110,20 @@ function getColumnVisibilityFromLocal(componentId) {
105
110
  }
106
111
  return null;
107
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
+ }
108
127
  function clearColumnVisibilityFromLocal(componentId) {
109
128
  if (!componentId) return;
110
129
  if (typeof window === "undefined" || !window.localStorage) return;
@@ -118,6 +137,7 @@ function clearColumnVisibilityFromLocal(componentId) {
118
137
  getColumnSettingFromLocal,
119
138
  getColumnVisibilityFromLocal,
120
139
  getComponentStorageKey,
140
+ getRecordBoardColumnSettingFromLocal,
121
141
  getStorageKeySuffix,
122
142
  saveColumnSettingToLocal,
123
143
  saveColumnVisibilityToLocal
package/lib/locales.d.ts CHANGED
@@ -1,6 +1,7 @@
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
7
  localeMaps: any;
package/lib/locales.js CHANGED
@@ -59,9 +59,13 @@ var getText = (id) => {
59
59
  var _a;
60
60
  return localeMap[id] || ((_a = localeMaps == null ? void 0 : localeMaps["en"]) == null ? void 0 : _a[id]) || id;
61
61
  };
62
+ var getLocale = () => {
63
+ return locale;
64
+ };
62
65
  var locales = {
63
66
  init,
64
67
  getText,
68
+ getLocale,
65
69
  locale,
66
70
  localeMap,
67
71
  localeMaps,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/utils",
3
- "version": "1.0.61",
3
+ "version": "1.0.62",
4
4
  "sideEffects": false,
5
5
  "main": "./lib/index.js",
6
6
  "module": "./es/index.js",