@pisell/materials 1.0.237 → 1.0.239

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.
@@ -148,4 +148,5 @@ export declare const getSettingKeyArrByMode: ({ filter, columnSetting, dataSourc
148
148
  currentViewMode: ModeType;
149
149
  }) => ("filter_setting" | "column_setting" | "gallery_setting" | "view_mode" | "group_by" | "order_by")[];
150
150
  export declare const omit: (obj: Record<string, any>, keys: string[]) => Record<string, any>;
151
+ export declare const stringify: (obj: Record<string, any>) => string;
151
152
  export {};
@@ -503,4 +503,12 @@ export var omit = function omit(obj, keys) {
503
503
  delete shallowCopy[key];
504
504
  }
505
505
  return shallowCopy;
506
+ };
507
+ export var stringify = function stringify(obj) {
508
+ return JSON.stringify(obj, function (key, value) {
509
+ if (isFunction(value)) {
510
+ return value.toString();
511
+ }
512
+ return value;
513
+ });
506
514
  };
@@ -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 } from "./Table/utils";
28
+ import { clearTableSettingToLocalStorage, getCurrentViewModeFromLocalStorage, getHash, 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";
@@ -180,7 +180,7 @@ var GridView = Provider( /*#__PURE__*/forwardRef(function (props, ref) {
180
180
  setTimeout(function () {
181
181
  document.body.id = "body";
182
182
  }, 200);
183
- }, [filter]);
183
+ }, []);
184
184
  var filterDefaultValues = useMemo(function () {
185
185
  var _other$pagination3, _other$pagination4;
186
186
  var defaultValues = ((filter === null || filter === void 0 ? void 0 : filter.list) || []).reduce(function (p, c) {
@@ -211,8 +211,11 @@ var GridView = Provider( /*#__PURE__*/forwardRef(function (props, ref) {
211
211
  }, [currentViewMode]);
212
212
  useEffect(function () {
213
213
  // 虚拟表columns由接口获取 columns变更时只重新设置tableSetting
214
- form.setFieldsValue(tableSettingRef.current);
215
- }, [JSON.stringify(columns)]);
214
+ // 直接设置column_setting对象时useWatch监听数据有误,先设置{}后再设置useWatch可以监听到变更数据
215
+ form.setFieldValue("column_setting", {});
216
+ form.setFieldValue("column_setting", tableSettingRef.current.column_setting);
217
+ // JSON.stringify会丢失 render函数变更的监听 使用自定义stringify处理
218
+ }, [stringify(columns)]);
216
219
  useEffect(function () {
217
220
  form.setFieldsValue(initialValuesRef.current);
218
221
  // ArraySetter在面板state变更时指针改变
@@ -2,7 +2,7 @@ import { isMobile as isMobileUtils } from "@pisell/utils";
2
2
  import { isBrowser } from "./index";
3
3
  export var isMobile = function isMobile() {
4
4
  if (isBrowser) {
5
- return window.innerWidth <= 768 || isMobileUtils();
5
+ return window.innerWidth <= 768 && isMobileUtils();
6
6
  }
7
7
  return isMobileUtils();
8
8
  };
@@ -148,4 +148,5 @@ export declare const getSettingKeyArrByMode: ({ filter, columnSetting, dataSourc
148
148
  currentViewMode: ModeType;
149
149
  }) => ("filter_setting" | "column_setting" | "gallery_setting" | "view_mode" | "group_by" | "order_by")[];
150
150
  export declare const omit: (obj: Record<string, any>, keys: string[]) => Record<string, any>;
151
+ export declare const stringify: (obj: Record<string, any>) => string;
151
152
  export {};
@@ -44,7 +44,8 @@ __export(utils_exports, {
44
44
  omit: () => omit,
45
45
  setFormValuesToLocalStorage: () => setFormValuesToLocalStorage,
46
46
  setTableSettingToLocalStorage: () => setTableSettingToLocalStorage,
47
- sortDataSource: () => sortDataSource
47
+ sortDataSource: () => sortDataSource,
48
+ stringify: () => stringify
48
49
  });
49
50
  module.exports = __toCommonJS(utils_exports);
50
51
  var import_dayjs = __toESM(require("dayjs"));
@@ -439,6 +440,14 @@ var omit = (obj, keys) => {
439
440
  }
440
441
  return shallowCopy;
441
442
  };
443
+ var stringify = (obj) => {
444
+ return JSON.stringify(obj, (key, value) => {
445
+ if ((0, import_utils.isFunction)(value)) {
446
+ return value.toString();
447
+ }
448
+ return value;
449
+ });
450
+ };
442
451
  // Annotate the CommonJS export names for ESM import in node:
443
452
  0 && (module.exports = {
444
453
  calcFilterSort,
@@ -456,5 +465,6 @@ var omit = (obj, keys) => {
456
465
  omit,
457
466
  setFormValuesToLocalStorage,
458
467
  setTableSettingToLocalStorage,
459
- sortDataSource
468
+ sortDataSource,
469
+ stringify
460
470
  });
@@ -187,7 +187,7 @@ var GridView = (0, import_model.Provider)(
187
187
  setTimeout(() => {
188
188
  document.body.id = "body";
189
189
  }, 200);
190
- }, [filter]);
190
+ }, []);
191
191
  const filterDefaultValues = (0, import_react.useMemo)(() => {
192
192
  var _a2, _b2;
193
193
  const defaultValues = ((filter == null ? void 0 : filter.list) || []).reduce(
@@ -227,8 +227,9 @@ var GridView = (0, import_model.Provider)(
227
227
  form.setFieldsValue(initialValuesRef.current);
228
228
  }, [currentViewMode]);
229
229
  (0, import_react.useEffect)(() => {
230
- form.setFieldsValue(tableSettingRef.current);
231
- }, [JSON.stringify(columns)]);
230
+ form.setFieldValue("column_setting", {});
231
+ form.setFieldValue("column_setting", tableSettingRef.current.column_setting);
232
+ }, [(0, import_utils.stringify)(columns)]);
232
233
  (0, import_react.useEffect)(() => {
233
234
  form.setFieldsValue(initialValuesRef.current);
234
235
  }, [JSON.stringify(propsFilter)]);
@@ -26,7 +26,7 @@ var import_utils = require("@pisell/utils");
26
26
  var import_index = require("./index");
27
27
  var isMobile = () => {
28
28
  if (import_index.isBrowser) {
29
- return window.innerWidth <= 768 || (0, import_utils.isMobile)();
29
+ return window.innerWidth <= 768 && (0, import_utils.isMobile)();
30
30
  }
31
31
  return (0, import_utils.isMobile)();
32
32
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/materials",
3
- "version": "1.0.237",
3
+ "version": "1.0.239",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",