@pisell/materials 2.2.4 → 2.2.5

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.
@@ -1,4 +1,4 @@
1
- import React from "react";
2
- import "./index.less";
1
+ import React from 'react';
2
+ import './index.less';
3
3
  declare const _default: React.ForwardRefExoticComponent<Omit<any, "ref"> & React.RefAttributes<unknown>>;
4
4
  export default _default;
@@ -1,5 +1,5 @@
1
1
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- var _excluded = ["dataSource", "columns", "dispatch", "style", "filter", "sort", "buttons", "actionButtons", "title", "summary", "onValuesChange", "columnSetting", "dataSourceGroup", "view", "gallery", "currentSettingKey", "exportImport"];
2
+ var _excluded = ["dataSource", "columns", "dispatch", "style", "filter", "sort", "buttons", "actionButtons", "title", "summary", "onValuesChange", "columnSetting", "dataSourceGroup", "view", "gallery", "currentSettingKey", "exportImport", "currentComponentId"];
3
3
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
4
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
5
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -14,9 +14,9 @@ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefine
14
14
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
15
15
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
16
16
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
17
- import { useSize } from "ahooks";
18
- import { Form } from "antd";
19
- import React, { forwardRef, useEffect, useImperativeHandle, useMemo, useRef } from "react";
17
+ import { useSize } from 'ahooks';
18
+ import { Form } from 'antd';
19
+ import React, { forwardRef, useEffect, useImperativeHandle, useMemo, useRef } from 'react';
20
20
  import { useSharedState } from "../../hooks";
21
21
  import useEngineContext from "../../hooks/useEngineContext";
22
22
  import Actions from "./Actions";
@@ -32,7 +32,7 @@ import useTriggerValuesChange from "./hooks/useTriggerValuesChange";
32
32
  import { Context, Provider, formatColumn } from "./model";
33
33
  import "./index.less";
34
34
  var defaultView = {
35
- defaultViewMode: "grid",
35
+ defaultViewMode: 'grid',
36
36
  multiple: false,
37
37
  modeList: []
38
38
  };
@@ -56,6 +56,7 @@ var GridView = Provider( /*#__PURE__*/forwardRef(function (props, ref) {
56
56
  gallery = props.gallery,
57
57
  currentSettingKey = props.currentSettingKey,
58
58
  exportImport = props.exportImport,
59
+ currentComponentId = props.currentComponentId,
59
60
  other = _objectWithoutProperties(props, _excluded);
60
61
  var modal = useSharedState(Context);
61
62
  var _Form$useForm = Form.useForm(),
@@ -63,7 +64,7 @@ var GridView = Provider( /*#__PURE__*/forwardRef(function (props, ref) {
63
64
  form = _Form$useForm2[0];
64
65
  var defaultViewMode = view.defaultViewMode,
65
66
  multiple = view.multiple;
66
- var viewMode = Form.useWatch("view_mode", {
67
+ var viewMode = Form.useWatch('view_mode', {
67
68
  form: form,
68
69
  preserve: true
69
70
  });
@@ -76,11 +77,12 @@ var GridView = Provider( /*#__PURE__*/forwardRef(function (props, ref) {
76
77
  width = _ref.width;
77
78
  var utils = context === null || context === void 0 ? void 0 : (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.utils;
78
79
  var tableId = useMemo(function () {
79
- if (props.__designMode === "design") {
80
- return "designMode-mock-table-id";
80
+ console.log(props, 'wh');
81
+ if (props.__designMode === 'design') {
82
+ return 'designMode-mock-table-id';
81
83
  }
82
- return props.__id;
83
- }, [props.__id, props.__designMode]);
84
+ return (props === null || props === void 0 ? void 0 : props.currentComponentId) || props.__id;
85
+ }, [props.__id, props.__designMode, props === null || props === void 0 ? void 0 : props.currentComponentId]);
84
86
  var columns = useMemo(function () {
85
87
  return propsColumns.filter(function (item) {
86
88
  return !item.hidden;
@@ -120,7 +122,7 @@ var GridView = Provider( /*#__PURE__*/forwardRef(function (props, ref) {
120
122
  return _columns;
121
123
  }, [columns]);
122
124
  var currentSettingHash = useMemo(function () {
123
- return currentSettingKey || getHash(removeTitleColumns) || "";
125
+ return currentSettingKey || getHash(removeTitleColumns) || '';
124
126
  }, [currentSettingKey, JSON.stringify(removeTitleColumns)]);
125
127
  useEffect(function () {
126
128
  var setting = getTableSettingFromLocalStorage(tableId);
@@ -131,7 +133,7 @@ var GridView = Provider( /*#__PURE__*/forwardRef(function (props, ref) {
131
133
  useEffect(function () {
132
134
  if (width) {
133
135
  modal.dispatch({
134
- type: "setTableWidth",
136
+ type: 'setTableWidth',
135
137
  payload: width || {}
136
138
  });
137
139
  }
@@ -161,13 +163,13 @@ var GridView = Provider( /*#__PURE__*/forwardRef(function (props, ref) {
161
163
  });
162
164
  useEffect(function () {
163
165
  modal.dispatch({
164
- type: "setUtils",
166
+ type: 'setUtils',
165
167
  payload: utils || {}
166
168
  });
167
169
  }, [utils]);
168
170
  useEffect(function () {
169
171
  modal.dispatch({
170
- type: "setDefaultColumns",
172
+ type: 'setDefaultColumns',
171
173
  payload: mergeColumnSetting({
172
174
  columns: columns,
173
175
  tableId: tableId,
@@ -175,36 +177,36 @@ var GridView = Provider( /*#__PURE__*/forwardRef(function (props, ref) {
175
177
  })
176
178
  });
177
179
  modal.dispatch({
178
- type: "setOriginColumns",
180
+ type: 'setOriginColumns',
179
181
  payload: columns
180
182
  });
181
183
  }, [columns, tableId, currentViewMode]);
182
184
  useEffect(function () {
183
185
  modal.dispatch({
184
- type: "setDataSource",
186
+ type: 'setDataSource',
185
187
  payload: dataSource
186
188
  });
187
189
  modal.dispatch({
188
- type: "setOriginDataSource",
190
+ type: 'setOriginDataSource',
189
191
  payload: dataSource
190
192
  });
191
193
  }, [dataSource]);
192
194
  useEffect(function () {
193
195
  modal.dispatch({
194
- type: "setTableId",
196
+ type: 'setTableId',
195
197
  payload: tableId
196
198
  });
197
199
  }, [tableId]);
198
200
  useEffect(function () {
199
201
  var _other$pagination;
200
202
  modal.dispatch({
201
- type: "setLocalPagination",
203
+ type: 'setLocalPagination',
202
204
  payload: other === null || other === void 0 ? void 0 : (_other$pagination = other.pagination) === null || _other$pagination === void 0 ? void 0 : _other$pagination.localPagination
203
205
  });
204
206
  }, [other === null || other === void 0 ? void 0 : (_other$pagination2 = other.pagination) === null || _other$pagination2 === void 0 ? void 0 : _other$pagination2.localPagination]);
205
207
  useEffect(function () {
206
208
  setTimeout(function () {
207
- document.body.id = "body";
209
+ document.body.id = 'body';
208
210
  }, 200);
209
211
  }, []);
210
212
  var filterDefaultValues = useMemo(function () {
@@ -238,8 +240,8 @@ var GridView = Provider( /*#__PURE__*/forwardRef(function (props, ref) {
238
240
  useEffect(function () {
239
241
  // 虚拟表columns由接口获取 columns变更时只重新设置tableSetting
240
242
  // 直接设置column_setting对象时useWatch监听数据有误,先设置{}后再设置useWatch可以监听到变更数据
241
- form.setFieldValue("column_setting", {});
242
- form.setFieldValue("column_setting", tableSettingRef.current.column_setting);
243
+ form.setFieldValue('column_setting', {});
244
+ form.setFieldValue('column_setting', tableSettingRef.current.column_setting);
243
245
  // JSON.stringify会丢失 render函数变更的监听 使用自定义stringify处理
244
246
  }, [stringify(removeTitleColumns)]);
245
247
  useEffect(function () {
@@ -254,7 +256,7 @@ var GridView = Provider( /*#__PURE__*/forwardRef(function (props, ref) {
254
256
  var _values = _objectSpread(_objectSpread({}, form.getFieldsValue(true)), values.filters || {});
255
257
  var _cur = _objectSpread(_objectSpread({}, cur), cur.filters || {});
256
258
  var currentKey = Object.keys(cur)[0];
257
- if (currentKey !== "pagination") {
259
+ if (currentKey !== 'pagination') {
258
260
  _values.pagination = _objectSpread(_objectSpread({}, _values.pagination), {}, {
259
261
  page: 1
260
262
  });
@@ -277,11 +279,11 @@ var GridView = Provider( /*#__PURE__*/forwardRef(function (props, ref) {
277
279
  if (!getIsTriggerValuesChange(cur, values)) {
278
280
  return;
279
281
  }
280
- _onValuesChange === null || _onValuesChange === void 0 ? void 0 : _onValuesChange(omit(_cur, ["filters"]), _values);
282
+ _onValuesChange === null || _onValuesChange === void 0 ? void 0 : _onValuesChange(omit(_cur, ['filters']), _values);
281
283
  },
282
284
  className: "materials-grid-form-wrap"
283
285
  }, /*#__PURE__*/React.createElement("div", {
284
- className: "materials-grid",
286
+ className: 'materials-grid',
285
287
  style: style,
286
288
  ref: wrapRef
287
289
  }, /*#__PURE__*/React.createElement(Header, {
@@ -212,7 +212,11 @@ export declare type GridViewProps = {
212
212
  /**
213
213
  * 当前本地配置的key 用此hash是否改变用来判断是否清空本地配置 不填默认使用columns数据生成hash
214
214
  */
215
- currentSettingKey?: "";
215
+ currentSettingKey?: string;
216
+ /**
217
+ * 当前本地配置的唯一值, 不填默认使用currentSettingKey
218
+ */
219
+ currentComponentId?: string;
216
220
  /**
217
221
  * 当前表格中数据发生变化事件 包含本地筛选和外部传入数据变化
218
222
  * @param currentDataSource
@@ -1,4 +1,4 @@
1
- import React from "react";
2
- import "./index.less";
1
+ import React from 'react';
2
+ import './index.less';
3
3
  declare const _default: React.ForwardRefExoticComponent<Omit<any, "ref"> & React.RefAttributes<unknown>>;
4
4
  export default _default;
@@ -76,6 +76,7 @@ var GridView = (0, import_model.Provider)(
76
76
  currentSettingKey,
77
77
  // pagination,
78
78
  exportImport,
79
+ currentComponentId,
79
80
  ...other
80
81
  } = props;
81
82
  const modal = (0, import_hooks.useSharedState)(import_model.Context);
@@ -90,11 +91,12 @@ var GridView = (0, import_model.Provider)(
90
91
  const { width } = (0, import_ahooks.useSize)(wrapRef) || {};
91
92
  const utils = (_a = context == null ? void 0 : context.appHelper) == null ? void 0 : _a.utils;
92
93
  const tableId = (0, import_react.useMemo)(() => {
94
+ console.log(props, "wh");
93
95
  if (props.__designMode === "design") {
94
96
  return "designMode-mock-table-id";
95
97
  }
96
- return props.__id;
97
- }, [props.__id, props.__designMode]);
98
+ return (props == null ? void 0 : props.currentComponentId) || props.__id;
99
+ }, [props.__id, props.__designMode, props == null ? void 0 : props.currentComponentId]);
98
100
  const columns = (0, import_react.useMemo)(() => {
99
101
  return propsColumns.filter((item) => !item.hidden);
100
102
  }, [propsColumns]);
@@ -212,7 +212,11 @@ export declare type GridViewProps = {
212
212
  /**
213
213
  * 当前本地配置的key 用此hash是否改变用来判断是否清空本地配置 不填默认使用columns数据生成hash
214
214
  */
215
- currentSettingKey?: "";
215
+ currentSettingKey?: string;
216
+ /**
217
+ * 当前本地配置的唯一值, 不填默认使用currentSettingKey
218
+ */
219
+ currentComponentId?: string;
216
220
  /**
217
221
  * 当前表格中数据发生变化事件 包含本地筛选和外部传入数据变化
218
222
  * @param currentDataSource
@@ -81,6 +81,15 @@ export default {
81
81
  },
82
82
  propType: "string",
83
83
  setter: "StringSetter",
84
+ },
85
+ {
86
+ name: "currentComponentId",
87
+ title: {
88
+ label: "currentComponentId",
89
+ tip: "currentComponentId | 当前本地配置的唯一值 不填默认使用currentSettingKey",
90
+ },
91
+ propType: "string",
92
+ setter: "StringSetter",
84
93
  }
85
94
  ],
86
95
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/materials",
3
- "version": "2.2.4",
3
+ "version": "2.2.5",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",