@pisell/materials 1.0.277 → 1.0.279

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.
@@ -46,7 +46,7 @@ var Filter = function Filter(_ref) {
46
46
  getPopupContainer: function getPopupContainer() {
47
47
  return ref.current;
48
48
  },
49
- mouseEnterDelay: 0,
49
+ mouseEnterDelay: 0.1,
50
50
  transitionName: "test"
51
51
  }, /*#__PURE__*/React.createElement(Button, {
52
52
  icon: /*#__PURE__*/React.createElement(FilterLines, null),
@@ -72,7 +72,10 @@ export declare const setTableSettingToLocalStorage: ({ tableId, tableSettingObj,
72
72
  }>;
73
73
  currentViewMode: ModeType;
74
74
  currentSettingHash: string;
75
- }) => void;
75
+ }) => {
76
+ key: string;
77
+ value: Record<string, any>;
78
+ } | undefined;
76
79
  export declare const clearTableSettingToLocalStorage: (tableId?: string) => void;
77
80
  /**
78
81
  * 从本地存储中获取表格设置, 全部配置
@@ -103,7 +106,16 @@ export declare const setFormValuesToLocalStorage: ({ tableId, allValues, keys, c
103
106
  keys?: string[] | undefined;
104
107
  currentViewMode: ModeType;
105
108
  currentSettingHash: string;
106
- }) => void;
109
+ }) => {
110
+ key: string;
111
+ value: Record<string, any>;
112
+ } | undefined;
113
+ /**
114
+ * 获取表格键值
115
+ * @param tableId 表格ID
116
+ * @returns 返回格式化后的表格键值
117
+ */
118
+ export declare const getTableKey: (tableId: string) => string;
107
119
  /**
108
120
  * 合并筛选设置
109
121
  * @param list 列表数据
@@ -267,6 +267,10 @@ export var setTableSettingToLocalStorage = function setTableSettingToLocalStorag
267
267
  currentSettingHash: currentSettingHash
268
268
  }, currentViewMode, _objectSpread(_objectSpread({}, newData[currentViewMode] || {}), itemSetting)));
269
269
  localStorage.setItem(getTableKey(tableId), JSON.stringify(newData));
270
+ return {
271
+ key: getTableKey(tableId),
272
+ value: newData
273
+ };
270
274
  };
271
275
  export var clearTableSettingToLocalStorage = function clearTableSettingToLocalStorage(tableId) {
272
276
  if (!tableId) return;
@@ -323,7 +327,7 @@ export var setFormValuesToLocalStorage = function setFormValuesToLocalStorage(_r
323
327
  keys === null || keys === void 0 ? void 0 : keys.forEach(function (key) {
324
328
  obj[key] = allValues === null || allValues === void 0 ? void 0 : allValues[key];
325
329
  });
326
- setTableSettingToLocalStorage({
330
+ return setTableSettingToLocalStorage({
327
331
  tableId: tableId,
328
332
  tableSettingObj: obj,
329
333
  currentViewMode: currentViewMode,
@@ -336,7 +340,7 @@ export var setFormValuesToLocalStorage = function setFormValuesToLocalStorage(_r
336
340
  * @param tableId 表格ID
337
341
  * @returns 返回格式化后的表格键值
338
342
  */
339
- var getTableKey = function getTableKey(tableId) {
343
+ export var getTableKey = function getTableKey(tableId) {
340
344
  return "".concat(tableKeyPrefix, "-").concat(tableId);
341
345
  };
342
346
 
@@ -6,7 +6,9 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _ty
6
6
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
7
  import { useMemo } from "react";
8
8
  import { getSettingKeyArrByMode, getTableSettingByCurrentViewMode, getTableSettingFromLocalStorage, mergeColumnSetting, mergeFilterSetting, setFormValuesToLocalStorage } from "../Table/utils";
9
+ import useEngineContext from "../../../hooks/useEngineContext";
9
10
  var useTableSetting = function useTableSetting(params) {
11
+ var _context$appHelper;
10
12
  var tableId = params.tableId,
11
13
  filter = params.filter,
12
14
  columnSetting = params.columnSetting,
@@ -17,6 +19,10 @@ var useTableSetting = function useTableSetting(params) {
17
19
  propsColumns = params.columns,
18
20
  gallery = params.gallery,
19
21
  currentSettingHash = params.currentSettingHash;
22
+ var context = useEngineContext();
23
+ var _ref = ((_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.utils) || {},
24
+ isTerminal = _ref.isTerminal,
25
+ interaction = _ref.interaction;
20
26
  var columnsMap = useMemo(function () {
21
27
  return new Map(propsColumns.map(function (item) {
22
28
  return [item.key, item];
@@ -37,10 +43,10 @@ var useTableSetting = function useTableSetting(params) {
37
43
  }
38
44
  return propsColumns;
39
45
  }, [propsColumns, currentViewMode, gallery, columnsMap]);
40
- var _ref = filter || {},
41
- list = _ref.list,
42
- quickFilterMaxLength = _ref.quickFilterMaxLength,
43
- sortButtonShow = _ref.sortButtonShow;
46
+ var _ref2 = filter || {},
47
+ list = _ref2.list,
48
+ quickFilterMaxLength = _ref2.quickFilterMaxLength,
49
+ sortButtonShow = _ref2.sortButtonShow;
44
50
  var defaultGalleryCoverSetting = useMemo(function () {
45
51
  var _gallery$cover, _columns$find;
46
52
  return {
@@ -156,13 +162,24 @@ var useTableSetting = function useTableSetting(params) {
156
162
  * @param values
157
163
  */
158
164
  var setTableSetting = function setTableSetting(values) {
159
- setFormValuesToLocalStorage({
165
+ var result = setFormValuesToLocalStorage({
160
166
  tableId: tableId,
161
167
  allValues: values,
162
168
  keys: localStorageSettingKeyArr,
163
169
  currentViewMode: currentViewMode,
164
170
  currentSettingHash: currentSettingHash
165
171
  });
172
+ if (isTerminal() && result) {
173
+ var _interaction$utils, _interaction$utils$po;
174
+ interaction === null || interaction === void 0 ? void 0 : (_interaction$utils = interaction.utils) === null || _interaction$utils === void 0 ? void 0 : (_interaction$utils$po = _interaction$utils.postMessageToApp) === null || _interaction$utils$po === void 0 ? void 0 : _interaction$utils$po.call(_interaction$utils, {
175
+ module: "global",
176
+ key: "local_storage",
177
+ data: {
178
+ type: "set",
179
+ value: _defineProperty({}, result.key, result.value)
180
+ }
181
+ });
182
+ }
166
183
  };
167
184
  var tableSetting = useMemo(function () {
168
185
  return _objectSpread(_objectSpread({}, tableLocalSetting), defaultTableSetting);
@@ -25,7 +25,7 @@ import { Provider, Context, formatColumn } from "./model";
25
25
  import useEngineContext from "../../hooks/useEngineContext";
26
26
  import useTableSetting from "./hooks/useTableSetting";
27
27
  import useTriggerValuesChange from "./hooks/useTriggerValuesChange";
28
- import { clearTableSettingToLocalStorage, getCurrentViewModeFromLocalStorage, getHash, getTableSettingFromLocalStorage, mergeColumnSetting, omit, stringify } from "./Table/utils";
28
+ import { clearTableSettingToLocalStorage, getCurrentViewModeFromLocalStorage, getHash, getTableKey, getTableSettingFromLocalStorage, mergeColumnSetting, omit, stringify } from "./Table/utils";
29
29
  import useTransSortSetting from "./hooks/useTransSortSetting";
30
30
  import useTransFilterSetting from "./hooks/useTransFilterSetting";
31
31
  import useTransDataSourceGroupSetting from "./hooks/useTransDataSourceGroupSetting";
@@ -109,6 +109,17 @@ var GridView = Provider( /*#__PURE__*/forwardRef(function (props, ref) {
109
109
  var setting = getTableSettingFromLocalStorage(tableId);
110
110
  if (setting.currentSettingHash !== currentSettingHash) {
111
111
  clearTableSettingToLocalStorage(tableId);
112
+ if (utils !== null && utils !== void 0 && utils.isTerminal() && tableId) {
113
+ var _utils$interaction, _utils$interaction$ut, _utils$interaction$ut2;
114
+ utils === null || utils === void 0 ? void 0 : (_utils$interaction = utils.interaction) === null || _utils$interaction === void 0 ? void 0 : (_utils$interaction$ut = _utils$interaction.utils) === null || _utils$interaction$ut === void 0 ? void 0 : (_utils$interaction$ut2 = _utils$interaction$ut.postMessageToApp) === null || _utils$interaction$ut2 === void 0 ? void 0 : _utils$interaction$ut2.call(_utils$interaction$ut, {
115
+ module: "global",
116
+ key: "local_storage",
117
+ data: {
118
+ type: "remove",
119
+ key: getTableKey(tableId)
120
+ }
121
+ });
122
+ }
112
123
  }
113
124
  }, [currentSettingHash, tableId]);
114
125
  var _useTableSetting = useTableSetting({
@@ -73,7 +73,7 @@ var Filter = ({
73
73
  content,
74
74
  arrow: false,
75
75
  getPopupContainer: () => ref.current,
76
- mouseEnterDelay: 0,
76
+ mouseEnterDelay: 0.1,
77
77
  transitionName: "test"
78
78
  },
79
79
  /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { icon: /* @__PURE__ */ import_react.default.createElement(import_FilterLines.default, null), size: "large" }, isMobileBool ? null : (0, import_locales.getText)("table-action-filter-button"))
@@ -72,7 +72,10 @@ export declare const setTableSettingToLocalStorage: ({ tableId, tableSettingObj,
72
72
  }>;
73
73
  currentViewMode: ModeType;
74
74
  currentSettingHash: string;
75
- }) => void;
75
+ }) => {
76
+ key: string;
77
+ value: Record<string, any>;
78
+ } | undefined;
76
79
  export declare const clearTableSettingToLocalStorage: (tableId?: string) => void;
77
80
  /**
78
81
  * 从本地存储中获取表格设置, 全部配置
@@ -103,7 +106,16 @@ export declare const setFormValuesToLocalStorage: ({ tableId, allValues, keys, c
103
106
  keys?: string[] | undefined;
104
107
  currentViewMode: ModeType;
105
108
  currentSettingHash: string;
106
- }) => void;
109
+ }) => {
110
+ key: string;
111
+ value: Record<string, any>;
112
+ } | undefined;
113
+ /**
114
+ * 获取表格键值
115
+ * @param tableId 表格ID
116
+ * @returns 返回格式化后的表格键值
117
+ */
118
+ export declare const getTableKey: (tableId: string) => string;
107
119
  /**
108
120
  * 合并筛选设置
109
121
  * @param list 列表数据
@@ -36,6 +36,7 @@ __export(utils_exports, {
36
36
  getHash: () => getHash,
37
37
  getIdByRowKey: () => getIdByRowKey,
38
38
  getSettingKeyArrByMode: () => getSettingKeyArrByMode,
39
+ getTableKey: () => getTableKey,
39
40
  getTableSettingByCurrentViewMode: () => getTableSettingByCurrentViewMode,
40
41
  getTableSettingFromLocalStorage: () => getTableSettingFromLocalStorage,
41
42
  groupDataSource: () => groupDataSource,
@@ -267,6 +268,10 @@ var setTableSettingToLocalStorage = ({
267
268
  }
268
269
  };
269
270
  localStorage.setItem(getTableKey(tableId), JSON.stringify(newData));
271
+ return {
272
+ key: getTableKey(tableId),
273
+ value: newData
274
+ };
270
275
  };
271
276
  var clearTableSettingToLocalStorage = (tableId) => {
272
277
  if (!tableId)
@@ -303,7 +308,7 @@ var setFormValuesToLocalStorage = ({
303
308
  keys == null ? void 0 : keys.forEach((key) => {
304
309
  obj[key] = allValues == null ? void 0 : allValues[key];
305
310
  });
306
- setTableSettingToLocalStorage({
311
+ return setTableSettingToLocalStorage({
307
312
  tableId,
308
313
  tableSettingObj: obj,
309
314
  currentViewMode,
@@ -457,6 +462,7 @@ var stringify = (obj) => {
457
462
  getHash,
458
463
  getIdByRowKey,
459
464
  getSettingKeyArrByMode,
465
+ getTableKey,
460
466
  getTableSettingByCurrentViewMode,
461
467
  getTableSettingFromLocalStorage,
462
468
  groupDataSource,
@@ -1,6 +1,8 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
4
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
7
  var __export = (target, all) => {
6
8
  for (var name in all)
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
14
16
  }
15
17
  return to;
16
18
  };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
17
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
28
 
19
29
  // src/components/table/hooks/useTableSetting.ts
@@ -24,7 +34,9 @@ __export(useTableSetting_exports, {
24
34
  module.exports = __toCommonJS(useTableSetting_exports);
25
35
  var import_react = require("react");
26
36
  var import_utils = require("../Table/utils");
37
+ var import_useEngineContext = __toESM(require("../../../hooks/useEngineContext"));
27
38
  var useTableSetting = (params) => {
39
+ var _a;
28
40
  const {
29
41
  tableId,
30
42
  filter,
@@ -37,27 +49,29 @@ var useTableSetting = (params) => {
37
49
  gallery,
38
50
  currentSettingHash
39
51
  } = params;
52
+ const context = (0, import_useEngineContext.default)();
53
+ const { isTerminal, interaction } = ((_a = context.appHelper) == null ? void 0 : _a.utils) || {};
40
54
  const columnsMap = (0, import_react.useMemo)(() => {
41
55
  return new Map(propsColumns.map((item) => [item.key, item]));
42
56
  }, [propsColumns]);
43
57
  const columns = (0, import_react.useMemo)(() => {
44
- var _a;
58
+ var _a2;
45
59
  if (currentViewMode === "grid") {
46
60
  return propsColumns;
47
61
  } else if (currentViewMode === "gallery") {
48
- return (((_a = gallery == null ? void 0 : gallery.content) == null ? void 0 : _a.fields) || []).filter((item) => item.show).map((item) => columnsMap.get(item.columnKey)).filter(Boolean);
62
+ return (((_a2 = gallery == null ? void 0 : gallery.content) == null ? void 0 : _a2.fields) || []).filter((item) => item.show).map((item) => columnsMap.get(item.columnKey)).filter(Boolean);
49
63
  }
50
64
  return propsColumns;
51
65
  }, [propsColumns, currentViewMode, gallery, columnsMap]);
52
66
  const { list, quickFilterMaxLength, sortButtonShow } = filter || {};
53
67
  const defaultGalleryCoverSetting = (0, import_react.useMemo)(() => {
54
- var _a, _b;
68
+ var _a2, _b;
55
69
  return {
56
- coverObjectFit: (_a = gallery == null ? void 0 : gallery.cover) == null ? void 0 : _a.objectFit,
70
+ coverObjectFit: (_a2 = gallery == null ? void 0 : gallery.cover) == null ? void 0 : _a2.objectFit,
57
71
  coverField: (_b = columns.find(
58
72
  (column) => {
59
- var _a2, _b2;
60
- return column.key === ((_b2 = (_a2 = gallery == null ? void 0 : gallery.cover) == null ? void 0 : _a2.fields) == null ? void 0 : _b2[0]);
73
+ var _a3, _b2;
74
+ return column.key === ((_b2 = (_a3 = gallery == null ? void 0 : gallery.cover) == null ? void 0 : _a3.fields) == null ? void 0 : _b2[0]);
61
75
  }
62
76
  )) == null ? void 0 : _b.dataIndex,
63
77
  compactMode: "default",
@@ -101,7 +115,7 @@ var useTableSetting = (params) => {
101
115
  );
102
116
  const mergedSetting = { ...allSetting, ...currentViewModeSetting };
103
117
  localStorageSettingKeyArr.forEach((item) => {
104
- var _a, _b, _c, _d;
118
+ var _a2, _b, _c, _d;
105
119
  if (item === "view_mode") {
106
120
  setting[item] = view.multiple ? (mergedSetting == null ? void 0 : mergedSetting[item]) || view.defaultViewMode : view.defaultViewMode;
107
121
  } else if (item === "filter_setting") {
@@ -122,7 +136,7 @@ var useTableSetting = (params) => {
122
136
  setting[item] = {
123
137
  ...mergedSetting == null ? void 0 : mergedSetting[item],
124
138
  // 本地没有默认封面效果时取配置中的
125
- coverObjectFit: ((_a = mergedSetting == null ? void 0 : mergedSetting[item]) == null ? void 0 : _a.coverObjectFit) || defaultGalleryCoverSetting.coverObjectFit,
139
+ coverObjectFit: ((_a2 = mergedSetting == null ? void 0 : mergedSetting[item]) == null ? void 0 : _a2.coverObjectFit) || defaultGalleryCoverSetting.coverObjectFit,
126
140
  coverField: ((_b = mergedSetting == null ? void 0 : mergedSetting[item]) == null ? void 0 : _b.coverField) || defaultGalleryCoverSetting.coverField,
127
141
  compactMode: ((_c = mergedSetting == null ? void 0 : mergedSetting[item]) == null ? void 0 : _c.compactMode) || defaultGalleryCoverSetting.compactMode,
128
142
  isShowLabel: ((_d = mergedSetting == null ? void 0 : mergedSetting[item]) == null ? void 0 : _d.isShowLabel) ?? defaultGalleryCoverSetting.isShowLabel
@@ -185,13 +199,26 @@ var useTableSetting = (params) => {
185
199
  sortButtonShow
186
200
  ]);
187
201
  const setTableSetting = (values) => {
188
- (0, import_utils.setFormValuesToLocalStorage)({
202
+ var _a2, _b;
203
+ const result = (0, import_utils.setFormValuesToLocalStorage)({
189
204
  tableId,
190
205
  allValues: values,
191
206
  keys: localStorageSettingKeyArr,
192
207
  currentViewMode,
193
208
  currentSettingHash
194
209
  });
210
+ if (isTerminal() && result) {
211
+ (_b = (_a2 = interaction == null ? void 0 : interaction.utils) == null ? void 0 : _a2.postMessageToApp) == null ? void 0 : _b.call(_a2, {
212
+ module: "global",
213
+ key: "local_storage",
214
+ data: {
215
+ type: "set",
216
+ value: {
217
+ [result.key]: result.value
218
+ }
219
+ }
220
+ });
221
+ }
195
222
  };
196
223
  const tableSetting = (0, import_react.useMemo)(() => {
197
224
  return {
@@ -121,9 +121,20 @@ var GridView = (0, import_model.Provider)(
121
121
  return currentSettingKey || (0, import_utils.getHash)(columns) || "";
122
122
  }, [currentSettingKey, JSON.stringify(columns)]);
123
123
  (0, import_react.useEffect)(() => {
124
+ var _a2, _b2, _c2;
124
125
  const setting = (0, import_utils.getTableSettingFromLocalStorage)(tableId);
125
126
  if (setting.currentSettingHash !== currentSettingHash) {
126
127
  (0, import_utils.clearTableSettingToLocalStorage)(tableId);
128
+ if ((utils == null ? void 0 : utils.isTerminal()) && tableId) {
129
+ (_c2 = (_b2 = (_a2 = utils == null ? void 0 : utils.interaction) == null ? void 0 : _a2.utils) == null ? void 0 : _b2.postMessageToApp) == null ? void 0 : _c2.call(_b2, {
130
+ module: "global",
131
+ key: "local_storage",
132
+ data: {
133
+ type: "remove",
134
+ key: (0, import_utils.getTableKey)(tableId)
135
+ }
136
+ });
137
+ }
127
138
  }
128
139
  }, [currentSettingHash, tableId]);
129
140
  const { setTableSetting, tableSetting } = (0, import_useTableSetting.default)({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/materials",
3
- "version": "1.0.277",
3
+ "version": "1.0.279",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",