@pisell/materials 1.0.272 → 1.0.274

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.
@@ -14,7 +14,7 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _ty
14
14
  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); }
15
15
  import React, { useLayoutEffect, useMemo } from "react";
16
16
  import { Drawer as OriginalDrawer } from "antd";
17
- import { useControllableValue } from "ahooks";
17
+ import { useControllableValue, useUpdateEffect } from "ahooks";
18
18
  import classNames from "classnames";
19
19
  import { isBoolean, isUndefined } from "@pisell/utils";
20
20
  import XClose from "@pisell/icon/es/XClose";
@@ -57,13 +57,15 @@ var Drawer = function Drawer(props) {
57
57
  _useControllableValue2 = _slicedToArray(_useControllableValue, 2),
58
58
  persistentState = _useControllableValue2[0],
59
59
  setPersistentState = _useControllableValue2[1];
60
+ var currentDrawerId = props.__id;
61
+ var storageKey = "drawer-".concat(currentDrawerId);
60
62
  var innerProps = {};
61
63
  if (props.__designMode === "design") {
62
64
  // 低代码编辑态中强制显示,将控制权交给引擎侧
63
65
  innerProps.open = true;
64
66
  }
65
67
  useLayoutEffect(function () {
66
- if (isBoolean(persistentState) && isUndefined(getContainer)) {
68
+ if (isBoolean(persistentState) && isUndefined(getContainer) && showPin) {
67
69
  document.body.style.transition = 'all 0.3s';
68
70
  document.body.style["padding-".concat(placement)] = persistentState && open ? "".concat(width || 378, "px") : "0";
69
71
  }
@@ -72,6 +74,16 @@ var Drawer = function Drawer(props) {
72
74
  document.body.style.transition = 'none';
73
75
  };
74
76
  }, [persistentState, width, showPin, placement, open]);
77
+ useUpdateEffect(function () {
78
+ if (isBoolean(persistentState) && showPin) {
79
+ localStorage.setItem(storageKey, "".concat(persistentState));
80
+ }
81
+ }, [persistentState, storageKey, showPin]);
82
+ useLayoutEffect(function () {
83
+ if (!isBoolean(persistentState) && showPin) {
84
+ setPersistentState(localStorage.getItem(storageKey) === "true");
85
+ }
86
+ }, [persistentState, storageKey, showPin]);
75
87
  var otherProps = useMemo(function () {
76
88
  if (operateMode === "outside") {
77
89
  return {
@@ -108,16 +108,27 @@ var useTransColumns = function useTransColumns(params) {
108
108
  position = "end";
109
109
  }
110
110
  var groupObj = {};
111
+ if (groupField) {
112
+ groupObj = {
113
+ render: function render(text, record) {
114
+ var _col$render;
115
+ if (record.__is_group) {
116
+ return null;
117
+ }
118
+ return (col === null || col === void 0 ? void 0 : (_col$render = col.render) === null || _col$render === void 0 ? void 0 : _col$render.call(col, text, record)) || text;
119
+ }
120
+ };
121
+ }
111
122
  if (position === "start" && groupField) {
112
123
  groupObj = {
113
124
  fixed: "left",
114
125
  width: 350,
115
126
  render: function render(text, record) {
116
- var _col$render;
127
+ var _col$render2;
117
128
  if (record.__is_group && groupFieldRender) {
118
129
  return groupFieldRender(text, record);
119
130
  }
120
- return (col === null || col === void 0 ? void 0 : (_col$render = col.render) === null || _col$render === void 0 ? void 0 : _col$render.call(col, text, record)) || text;
131
+ return (col === null || col === void 0 ? void 0 : (_col$render2 = col.render) === null || _col$render2 === void 0 ? void 0 : _col$render2.call(col, text, record)) || text;
121
132
  }
122
133
  };
123
134
  }
@@ -80,12 +80,14 @@ var Drawer = (props) => {
80
80
  valuePropName: "persistent"
81
81
  }
82
82
  );
83
+ const currentDrawerId = props.__id;
84
+ const storageKey = `drawer-${currentDrawerId}`;
83
85
  const innerProps = {};
84
86
  if (props.__designMode === "design") {
85
87
  innerProps.open = true;
86
88
  }
87
89
  (0, import_react.useLayoutEffect)(() => {
88
- if ((0, import_utils.isBoolean)(persistentState) && (0, import_utils.isUndefined)(getContainer)) {
90
+ if ((0, import_utils.isBoolean)(persistentState) && (0, import_utils.isUndefined)(getContainer) && showPin) {
89
91
  document.body.style.transition = "all 0.3s";
90
92
  document.body.style[`padding-${placement}`] = persistentState && open ? `${width || 378}px` : "0";
91
93
  }
@@ -94,6 +96,16 @@ var Drawer = (props) => {
94
96
  document.body.style.transition = "none";
95
97
  };
96
98
  }, [persistentState, width, showPin, placement, open]);
99
+ (0, import_ahooks.useUpdateEffect)(() => {
100
+ if ((0, import_utils.isBoolean)(persistentState) && showPin) {
101
+ localStorage.setItem(storageKey, `${persistentState}`);
102
+ }
103
+ }, [persistentState, storageKey, showPin]);
104
+ (0, import_react.useLayoutEffect)(() => {
105
+ if (!(0, import_utils.isBoolean)(persistentState) && showPin) {
106
+ setPersistentState(localStorage.getItem(storageKey) === "true");
107
+ }
108
+ }, [persistentState, storageKey, showPin]);
97
109
  const otherProps = (0, import_react.useMemo)(() => {
98
110
  if (operateMode === "outside") {
99
111
  return {
@@ -130,6 +130,17 @@ var useTransColumns = (params) => {
130
130
  position = "end";
131
131
  }
132
132
  let groupObj = {};
133
+ if (groupField) {
134
+ groupObj = {
135
+ render: (text, record) => {
136
+ var _a4;
137
+ if (record.__is_group) {
138
+ return null;
139
+ }
140
+ return ((_a4 = col == null ? void 0 : col.render) == null ? void 0 : _a4.call(col, text, record)) || text;
141
+ }
142
+ };
143
+ }
133
144
  if (position === "start" && groupField) {
134
145
  groupObj = {
135
146
  fixed: "left",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/materials",
3
- "version": "1.0.272",
3
+ "version": "1.0.274",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",