@pisell/materials 1.0.295 → 1.0.296

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.
Files changed (64) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/index.js +1 -1
  5. package/build/lowcode/meta.js +2 -2
  6. package/build/lowcode/preview.js +8 -8
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +10 -10
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +8 -8
  11. package/dist/umd/materials.min.css +1 -0
  12. package/dist/umd/materials.min.js +1 -0
  13. package/dist/umd/static/DotsSix.57d66266.svg +1 -0
  14. package/dist/umd/static/arrow-left.e542294f.svg +1 -0
  15. package/dist/umd/static/arrow-right.763f03e0.svg +1 -0
  16. package/dist/umd/static/filter-lines.04a54ae9.svg +1 -0
  17. package/dist/umd/static/help-circle.31c9be40.svg +1 -0
  18. package/dist/umd/static/switch-vertical-01.7ebe3ba8.svg +1 -0
  19. package/es/components/batch-editor/fields/Image/index.d.ts +7 -0
  20. package/es/components/batch-editor/fields/Image/index.js +14 -0
  21. package/es/components/batch-editor/fields/Image/index.less +6 -0
  22. package/es/components/batch-editor/fields/Price/index.d.ts +6 -0
  23. package/es/components/batch-editor/fields/Price/index.js +19 -0
  24. package/es/components/batch-editor/fields/Text/index.d.ts +6 -0
  25. package/es/components/batch-editor/fields/Text/index.js +8 -0
  26. package/es/components/batch-editor/fields/index.d.ts +7 -0
  27. package/es/components/batch-editor/fields/index.js +8 -0
  28. package/es/components/batch-editor/index.d.ts +11 -0
  29. package/es/components/batch-editor/index.js +446 -0
  30. package/es/components/batch-editor/index.less +48 -0
  31. package/es/components/table/hooks/useTransDataSource.js +1 -0
  32. package/es/components/table/index.js +11 -15
  33. package/es/index.d.ts +1 -0
  34. package/es/index.js +2 -1
  35. package/es/locales/en-US.d.ts +11 -0
  36. package/es/locales/en-US.js +16 -1
  37. package/es/locales/zh-CN.d.ts +11 -0
  38. package/es/locales/zh-CN.js +16 -1
  39. package/es/locales/zh-TW.d.ts +11 -0
  40. package/es/locales/zh-TW.js +16 -1
  41. package/lib/components/batch-editor/fields/Image/index.d.ts +7 -0
  42. package/lib/components/batch-editor/fields/Image/index.js +48 -0
  43. package/lib/components/batch-editor/fields/Image/index.less +6 -0
  44. package/lib/components/batch-editor/fields/Price/index.d.ts +6 -0
  45. package/lib/components/batch-editor/fields/Price/index.js +54 -0
  46. package/lib/components/batch-editor/fields/Text/index.d.ts +6 -0
  47. package/lib/components/batch-editor/fields/Text/index.js +40 -0
  48. package/lib/components/batch-editor/fields/index.d.ts +7 -0
  49. package/lib/components/batch-editor/fields/index.js +42 -0
  50. package/lib/components/batch-editor/index.d.ts +11 -0
  51. package/lib/components/batch-editor/index.js +357 -0
  52. package/lib/components/batch-editor/index.less +48 -0
  53. package/lib/components/table/hooks/useTransDataSource.js +1 -0
  54. package/lib/components/table/index.js +16 -4
  55. package/lib/index.d.ts +1 -0
  56. package/lib/index.js +3 -0
  57. package/lib/locales/en-US.d.ts +11 -0
  58. package/lib/locales/en-US.js +12 -1
  59. package/lib/locales/zh-CN.d.ts +11 -0
  60. package/lib/locales/zh-CN.js +12 -1
  61. package/lib/locales/zh-TW.d.ts +11 -0
  62. package/lib/locales/zh-TW.js +12 -1
  63. package/lowcode/batch-editor/meta.ts +93 -0
  64. package/package.json +3 -3
@@ -0,0 +1 @@
1
+ <svg width="24" height="24" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="M8 13a1 1 0 1 0 0-2 1 1 0 0 0 0 2ZM8 6a1 1 0 1 0 0-2 1 1 0 0 0 0 2ZM8 20a1 1 0 1 0 0-2 1 1 0 0 0 0 2ZM16 13a1 1 0 1 0 0-2 1 1 0 0 0 0 2ZM16 6a1 1 0 1 0 0-2 1 1 0 0 0 0 2ZM16 20a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>
@@ -0,0 +1 @@
1
+ <svg width="24" height="24" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M12.707 4.293a1 1 0 0 1 0 1.414L7.414 11H19a1 1 0 1 1 0 2H7.414l5.293 5.293a1 1 0 0 1-1.414 1.414l-7-7a1 1 0 0 1 0-1.414l7-7a1 1 0 0 1 1.414 0Z"/></svg>
@@ -0,0 +1 @@
1
+ <svg width="24" height="24" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M11.293 4.293a1 1 0 0 1 1.414 0l7 7a1 1 0 0 1 0 1.414l-7 7a1 1 0 0 1-1.414-1.414L16.586 13H5a1 1 0 1 1 0-2h11.586l-5.293-5.293a1 1 0 0 1 0-1.414Z"/></svg>
@@ -0,0 +1 @@
1
+ <svg width="24" height="24" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M2 6a1 1 0 0 1 1-1h18a1 1 0 1 1 0 2H3a1 1 0 0 1-1-1Zm3 6a1 1 0 0 1 1-1h12a1 1 0 1 1 0 2H6a1 1 0 0 1-1-1Zm3 6a1 1 0 0 1 1-1h6a1 1 0 1 1 0 2H9a1 1 0 0 1-1-1Z"/></svg>
@@ -0,0 +1 @@
1
+ <svg width="24" height="24" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18ZM1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11.258-3.976a2 2 0 0 0-2.225 1.308 1 1 0 1 1-1.886-.664 4 4 0 0 1 7.773 1.333c0 1.53-1.135 2.54-1.945 3.081a8.044 8.044 0 0 1-1.686.848l-.035.013-.011.003-.004.002h-.002L11.92 13l.316.949a1 1 0 0 1-.633-1.897l.016-.006.074-.027a6.051 6.051 0 0 0 1.172-.6c.69-.46 1.055-.95 1.055-1.419v-.001a2 2 0 0 0-1.662-1.975ZM11 17a1 1 0 0 1 1-1h.01a1 1 0 1 1 0 2H12a1 1 0 0 1-1-1Z"/></svg>
@@ -0,0 +1 @@
1
+ <svg width="24" height="24" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M6.293 3.293a1 1 0 0 1 1.414 0l4 4a1 1 0 0 1-1.414 1.414L8 6.414V20a1 1 0 1 1-2 0V6.414L3.707 8.707a1 1 0 0 1-1.414-1.414l4-4ZM16 17.586V4a1 1 0 1 1 2 0v13.586l2.293-2.293a1 1 0 0 1 1.414 1.414l-4 4a1 1 0 0 1-1.414 0l-4-4a1 1 0 0 1 1.414-1.414L16 17.586Z"/></svg>
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ export interface ImageProps extends React.ComponentPropsWithoutRef<"img"> {
3
+ value?: string;
4
+ }
5
+ import "./index.less";
6
+ declare const Image: (props: ImageProps) => React.JSX.Element | null;
7
+ export default Image;
@@ -0,0 +1,14 @@
1
+ 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); }
2
+ import React from "react";
3
+ import "./index.less";
4
+ var Image = function Image(props) {
5
+ return props.value ? /*#__PURE__*/React.createElement("img", _extends({}, props, {
6
+ className: "batch-editor-fields-image",
7
+ src: props.value,
8
+ style: {
9
+ width: "50px",
10
+ height: "50px"
11
+ }
12
+ })) : null;
13
+ };
14
+ export default Image;
@@ -0,0 +1,6 @@
1
+ .batch-editor-fields-image {
2
+ width: 48px;
3
+ height: 48px;
4
+ border-radius: 8px;
5
+ object-fit: cover;
6
+ }
@@ -0,0 +1,6 @@
1
+ import React from "react";
2
+ import { InputNumberProps } from "antd";
3
+ export interface PriceProps extends InputNumberProps {
4
+ }
5
+ declare const Price: React.FC<PriceProps>;
6
+ export default Price;
@@ -0,0 +1,19 @@
1
+ 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); }
2
+ import React from "react";
3
+ import { InputNumber } from "antd";
4
+ var Price = function Price(props) {
5
+ return /*#__PURE__*/React.createElement(InputNumber, _extends({
6
+ keyboard: false,
7
+ style: {
8
+ width: "100%"
9
+ },
10
+ placeholder: "0.00",
11
+ min: 0,
12
+ prefix: "$",
13
+ max: 999999,
14
+ precision: 2,
15
+ size: "large",
16
+ controls: false
17
+ }, props));
18
+ };
19
+ export default Price;
@@ -0,0 +1,6 @@
1
+ import React from "react";
2
+ export interface TextProps extends React.HTMLAttributes<HTMLDivElement> {
3
+ children: React.ReactNode;
4
+ }
5
+ declare const Text: (props: TextProps) => React.JSX.Element;
6
+ export default Text;
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import { Tooltip } from "antd";
3
+ var Text = function Text(props) {
4
+ return /*#__PURE__*/React.createElement(Tooltip, {
5
+ overlay: props.children
6
+ }, /*#__PURE__*/React.createElement("div", props, props.children));
7
+ };
8
+ export default Text;
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ declare const _default: {
3
+ price: import("react").FC<import("./Price").PriceProps>;
4
+ image: (props: import("./Image").ImageProps) => import("react").JSX.Element | null;
5
+ text: (props: import("./Text").TextProps) => import("react").JSX.Element;
6
+ };
7
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import Price from "./Price";
2
+ import Image from "./Image";
3
+ import Text from "./Text";
4
+ export default {
5
+ price: Price,
6
+ image: Image,
7
+ text: Text
8
+ };
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ import "./index.less";
3
+ interface BatchEditorProps {
4
+ columns: any[];
5
+ dataSource: any[];
6
+ onChange: (value: any) => void;
7
+ rowKey: string;
8
+ otherTableProps: any;
9
+ }
10
+ declare const BatchEditor: (props: BatchEditorProps) => React.JSX.Element;
11
+ export default BatchEditor;
@@ -0,0 +1,446 @@
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
+ 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); }
3
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
+ 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; }
8
+ 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; }
9
+ 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; }
10
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
11
+ 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); }
12
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
13
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
14
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
15
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
16
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
17
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
18
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
19
+ import React, { useMemo, useState, useCallback } from "react";
20
+ import { Popover, Tooltip, Button, Modal, Form, Select } from "antd";
21
+ import { useDebounceFn } from "ahooks";
22
+ import Table from "../table";
23
+ import fields from "./fields";
24
+ import Price from "./fields/Price";
25
+ import { getText } from "../../locales/index";
26
+ import "./index.less";
27
+ var BatchEditor = function BatchEditor(props) {
28
+ var _otherTableProps$filt;
29
+ var columns = props.columns,
30
+ _props$dataSource = props.dataSource,
31
+ dataSource = _props$dataSource === void 0 ? [] : _props$dataSource,
32
+ onChange = props.onChange,
33
+ rowKey = props.rowKey,
34
+ otherTableProps = props.otherTableProps;
35
+ var _Form$useForm = Form.useForm(),
36
+ _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
37
+ form = _Form$useForm2[0];
38
+ var _useState = useState(false),
39
+ _useState2 = _slicedToArray(_useState, 2),
40
+ openModal = _useState2[0],
41
+ setOpenModal = _useState2[1];
42
+ var _useState3 = useState([]),
43
+ _useState4 = _slicedToArray(_useState3, 2),
44
+ selectList = _useState4[0],
45
+ setSelectList = _useState4[1];
46
+
47
+ /**
48
+ * @title: 渲染column
49
+ * @description:
50
+ * @return {*}
51
+ * @Author: zhiwei.Wang
52
+ * @Date: 2024-06-17 13:21
53
+ */
54
+ var renderColumnItem = useCallback(function (_item) {
55
+ return function (text, record) {
56
+ // 没有type 按文本渲染
57
+ if (!_item.type) {
58
+ var _Com = fields["text"];
59
+ return /*#__PURE__*/React.createElement("div", {
60
+ className: "editor-item"
61
+ }, /*#__PURE__*/React.createElement(_Com, null, text));
62
+ }
63
+
64
+ // 如果当前record单独禁止编辑某些字段
65
+ if ((record.disabledList || []).includes(_item.dataIndex)) {
66
+ return /*#__PURE__*/React.createElement("div", {
67
+ className: "editor-item",
68
+ style: {
69
+ padding: "0 11px"
70
+ }
71
+ }, /*#__PURE__*/React.createElement(Tooltip, {
72
+ overlay: record !== null && record !== void 0 && record.disabledTexts ?
73
+ //@ts-ignore
74
+ (record === null || record === void 0 ? void 0 : record.disabledTexts[_item.dataIndex]) || text : text
75
+ }, /*#__PURE__*/React.createElement("div", {
76
+ className: "name"
77
+ }, record !== null && record !== void 0 && record.disabledTexts ?
78
+ //@ts-ignore
79
+ (record === null || record === void 0 ? void 0 : record.disabledTexts[_item.dataIndex]) || text : text)));
80
+ }
81
+ var Com = fields[_item.type];
82
+ if (Com) {
83
+ return /*#__PURE__*/React.createElement("div", {
84
+ className: "editor-item"
85
+ }, /*#__PURE__*/React.createElement(Com, {
86
+ status: record.status,
87
+ value: text,
88
+ onChange: function onChange(e) {
89
+ handleChange(e, _item.dataIndex, record[rowKey]);
90
+ }
91
+ }));
92
+ }
93
+ return /*#__PURE__*/React.createElement("div", {
94
+ className: "editor-item"
95
+ }, "-");
96
+ };
97
+ }, [dataSource, rowKey, columns]);
98
+
99
+ /**
100
+ * dataSource 的返回事件
101
+ * @param newDataSource
102
+ */
103
+ var _onChange = function _onChange(newDataSource) {
104
+ onChange === null || onChange === void 0 ? void 0 : onChange(newDataSource);
105
+ };
106
+
107
+ /**
108
+ * @title: 编辑某个字段
109
+ * @description:
110
+ * @return {*}
111
+ * @Author: zhiwei.Wang
112
+ * @Date: 2024-06-17 13:22
113
+ */
114
+ var handleChange = function handleChange(val, key, id) {
115
+ var _dataSource = JSON.parse(JSON.stringify(dataSource));
116
+ var fn = function fn(_list) {
117
+ var _iterator = _createForOfIteratorHelper(_list),
118
+ _step;
119
+ try {
120
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
121
+ var d = _step.value;
122
+ if (d[rowKey] === id) {
123
+ d[key] = val;
124
+ break;
125
+ }
126
+ if (d.children && d.children.length) {
127
+ fn(d.children);
128
+ }
129
+ }
130
+ } catch (err) {
131
+ _iterator.e(err);
132
+ } finally {
133
+ _iterator.f();
134
+ }
135
+ };
136
+ fn(_dataSource || []);
137
+ _onChange(_dataSource);
138
+ };
139
+
140
+ /**
141
+ * @title: 批量编辑
142
+ * @description:
143
+ * @param {any} val
144
+ * @param {any} key
145
+ * @return {*}
146
+ * @Author: zhiwei.Wang
147
+ * @Date: 2024-06-17 13:22
148
+ */
149
+ var handleBatchEditChange = function handleBatchEditChange(val, key) {
150
+ var _dataSource = JSON.parse(JSON.stringify(dataSource));
151
+ var fn = function fn(_list) {
152
+ var _iterator2 = _createForOfIteratorHelper(_list),
153
+ _step2;
154
+ try {
155
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
156
+ var d = _step2.value;
157
+ if (selectList.includes(d[rowKey]) && !(d.disabledList || []).includes(key)) {
158
+ d[key] = val;
159
+ }
160
+ if (d.children && d.children.length) {
161
+ fn(d.children);
162
+ }
163
+ }
164
+ } catch (err) {
165
+ _iterator2.e(err);
166
+ } finally {
167
+ _iterator2.f();
168
+ }
169
+ };
170
+ fn(_dataSource || []);
171
+ _onChange(_dataSource);
172
+ };
173
+
174
+ /**
175
+ * @title: 删除record
176
+ * @description:
177
+ * @param {any} ids
178
+ * @return {*}
179
+ * @Author: zhiwei.Wang
180
+ * @Date: 2024-06-17 13:22
181
+ */
182
+ var handleRemove = function handleRemove(ids) {
183
+ var _dataSource = JSON.parse(JSON.stringify(dataSource));
184
+ if (_dataSource.some(function (d) {
185
+ return ids.includes(d[rowKey]);
186
+ })) {
187
+ _dataSource = _dataSource.filter(function (d) {
188
+ return !ids.includes(d[rowKey]);
189
+ });
190
+ } else {
191
+ _dataSource.forEach(function (d) {
192
+ if (d.children) {
193
+ d.children = d.children.filter(function (d) {
194
+ return !ids.includes(d[rowKey]);
195
+ });
196
+ }
197
+ });
198
+ }
199
+ _onChange(_dataSource);
200
+ };
201
+ var setDebounceValue = useDebounceFn(function (_dataSource) {
202
+ _onChange(_dataSource);
203
+ }, {
204
+ wait: 300
205
+ });
206
+
207
+ // 渲染弹窗内容
208
+ var renderPopoverContent = useCallback(function (_item) {
209
+ var Com = fields[_item.type];
210
+ var val;
211
+ return /*#__PURE__*/React.createElement("div", {
212
+ className: "batch-popover-content"
213
+ }, /*#__PURE__*/React.createElement("div", {
214
+ className: "editor-item"
215
+ }, /*#__PURE__*/React.createElement(Com, {
216
+ onBlur: function onBlur() {
217
+ if (val !== undefined) {
218
+ handleBatchEditChange(val, _item.dataIndex);
219
+ }
220
+ },
221
+ onChange: function onChange(e) {
222
+ val = e;
223
+ }
224
+ })));
225
+ }, [dataSource, selectList]);
226
+
227
+ /**
228
+ * @title: 渲染表格列标题
229
+ * @description:
230
+ * @return {*}
231
+ * @Author: zhiwei.Wang
232
+ * @Date: 2024-06-17 13:23
233
+ */
234
+ var renderColumnTitle = useCallback(function (item) {
235
+ return /*#__PURE__*/React.createElement("div", {
236
+ className: "column-title"
237
+ }, /*#__PURE__*/React.createElement("span", null, item.title), selectList.length && item.batchEdit ? /*#__PURE__*/React.createElement(Popover, {
238
+ destroyTooltipOnHide: true,
239
+ trigger: ["click"],
240
+ placement: "bottom",
241
+ title: "".concat(getText("batch-editor-batch-edit"), ": ").concat(item.title),
242
+ content: renderPopoverContent(item)
243
+ }, /*#__PURE__*/React.createElement("a", null, getText("batch-editor-batch-edit"))) : null);
244
+ }, [dataSource, rowKey, selectList]);
245
+
246
+ /**
247
+ * @title: 表格列
248
+ * @description:
249
+ * @param {*} useMemo
250
+ * @return {*}
251
+ * @Author: zhiwei.Wang
252
+ * @Date: 2024-06-17 13:23
253
+ */
254
+ var _columns = useMemo(function () {
255
+ return columns.filter(function (d) {
256
+ return !d.hide;
257
+ }).map(function (d) {
258
+ return _objectSpread(_objectSpread({}, d), {}, {
259
+ titleStr: d.title,
260
+ title: renderColumnTitle(d),
261
+ render: renderColumnItem(d)
262
+ });
263
+ }).concat([{
264
+ title: getText("batch-editor-actions"),
265
+ dataIndex: rowKey,
266
+ key: "actions",
267
+ align: "center",
268
+ fixed: "right",
269
+ width: 100,
270
+ dataSource: dataSource,
271
+ selectList: selectList,
272
+ render: function render(text, record) {
273
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Button, {
274
+ onClick: function onClick() {
275
+ handleRemove([text]);
276
+ }
277
+ }, getText("batch-editor-remove")));
278
+ }
279
+ }]);
280
+ }, [renderColumnItem, rowKey, dataSource, selectList]);
281
+ var selectOptions = useMemo(function () {
282
+ return _columns.filter(function (d) {
283
+ return d.batchEdit;
284
+ }).map(function (d) {
285
+ return {
286
+ label: d.titleStr,
287
+ value: d.dataIndex
288
+ };
289
+ });
290
+ }, [_columns]);
291
+ var onFinish = function onFinish(values) {
292
+ handleBatchEditChange(values.value, values.key);
293
+ onCancel();
294
+ setSelectList([]);
295
+ };
296
+ var onCancel = function onCancel() {
297
+ form.resetFields();
298
+ setOpenModal(false);
299
+ };
300
+ var onOpenMOdal = function onOpenMOdal() {
301
+ setOpenModal(true);
302
+ form.setFieldsValue({
303
+ key: selectOptions[0].value
304
+ });
305
+ };
306
+ var modalTitle = useMemo(function () {
307
+ var str = "";
308
+ var selectItems = [];
309
+ selectList.forEach(function (item) {
310
+ var productItem = dataSource.find(function (d) {
311
+ return d[rowKey] === item;
312
+ });
313
+ if (productItem) {
314
+ selectItems.push(productItem);
315
+ } else {
316
+ dataSource.forEach(function (d) {
317
+ if (d.children) {
318
+ var childProductItem = d.children.find(function (t) {
319
+ return t[rowKey] === item;
320
+ });
321
+ if (childProductItem) {
322
+ selectItems.push(childProductItem);
323
+ }
324
+ }
325
+ });
326
+ }
327
+ });
328
+ str = "";
329
+ if (selectItems.length > 1) {
330
+ var _selectItems$;
331
+ str = getText("batch-editor-quick-edit-title")((_selectItems$ = selectItems[0]) === null || _selectItems$ === void 0 ? void 0 : _selectItems$.title, selectItems.length);
332
+ } else {
333
+ var _selectItems$2;
334
+ str = getText("batch-editor-quick-edit-title-2")((_selectItems$2 = selectItems[0]) === null || _selectItems$2 === void 0 ? void 0 : _selectItems$2.title);
335
+ }
336
+ return str;
337
+ }, [selectList, dataSource]);
338
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Table, _extends({
339
+ actionButtons: !!selectList.length && [{
340
+ title: getText("batch-editor-batch-remove"),
341
+ size: "large",
342
+ onClick: function onClick() {
343
+ handleRemove(selectList);
344
+ setSelectList([]);
345
+ }
346
+ }, {
347
+ title: getText("batch-editor-batch-edit"),
348
+ onClick: onOpenMOdal,
349
+ size: "large",
350
+ type: "primary"
351
+ }],
352
+ bordered: true,
353
+ dataSource: dataSource,
354
+ columns: _columns,
355
+ size: "small",
356
+ className: "batch-editor-table",
357
+ rowKey: rowKey,
358
+ rowSelection: {
359
+ type: "checkbox",
360
+ selectedRowKeys: selectList,
361
+ onChange: function onChange(keys) {
362
+ setSelectList(keys);
363
+ }
364
+ },
365
+ scroll: {
366
+ x: _columns.length * 200
367
+ },
368
+ pagination: {
369
+ localPagination: true
370
+ }
371
+ }, otherTableProps, {
372
+ onValuesChange: function onValuesChange(values) {
373
+ var _otherTableProps$onVa;
374
+ setSelectList([]);
375
+ otherTableProps === null || otherTableProps === void 0 ? void 0 : (_otherTableProps$onVa = otherTableProps.onValuesChange) === null || _otherTableProps$onVa === void 0 ? void 0 : _otherTableProps$onVa.call(otherTableProps, values);
376
+ },
377
+ filter: _objectSpread(_objectSpread({
378
+ show: true,
379
+ sortButtonShow: false,
380
+ quickFilterMaxLength: 3,
381
+ storageMode: "localStorage"
382
+ }, otherTableProps === null || otherTableProps === void 0 ? void 0 : otherTableProps.filter), {}, {
383
+ list: [{
384
+ type: "search",
385
+ name: "keywords",
386
+ key: "keywords",
387
+ localFilter: true,
388
+ other: {
389
+ trigger: ["onChange"],
390
+ size: "large",
391
+ onChange: function onChange() {
392
+ setSelectList([]);
393
+ }
394
+ }
395
+ }].concat(_toConsumableArray(otherTableProps === null || otherTableProps === void 0 ? void 0 : (_otherTableProps$filt = otherTableProps.filter) === null || _otherTableProps$filt === void 0 ? void 0 : _otherTableProps$filt.list))
396
+ })
397
+ })), /*#__PURE__*/React.createElement(Modal, {
398
+ title: getText("batch-editor-quick-edit"),
399
+ open: openModal,
400
+ footer: null,
401
+ onCancel: function onCancel() {
402
+ setOpenModal(false);
403
+ }
404
+ }, /*#__PURE__*/React.createElement("div", {
405
+ className: "title",
406
+ style: {
407
+ marginBottom: 20
408
+ }
409
+ }, modalTitle), /*#__PURE__*/React.createElement(Form, {
410
+ layout: "vertical",
411
+ form: form,
412
+ onFinish: onFinish
413
+ }, /*#__PURE__*/React.createElement(Form.Item, {
414
+ label: getText("batch-editor-what-price"),
415
+ name: "key"
416
+ }, /*#__PURE__*/React.createElement(Select, {
417
+ size: "large",
418
+ options: selectOptions
419
+ })), /*#__PURE__*/React.createElement(Form.Item, {
420
+ label: getText("batch-editor-price"),
421
+ name: "value"
422
+ }, /*#__PURE__*/React.createElement(Price, null))), /*#__PURE__*/React.createElement("div", {
423
+ className: "",
424
+ style: {
425
+ display: "flex",
426
+ gap: 20,
427
+ width: "100%"
428
+ }
429
+ }, /*#__PURE__*/React.createElement(Button, {
430
+ size: "large",
431
+ style: {
432
+ flex: 1
433
+ },
434
+ onClick: onCancel
435
+ }, getText("batch-editor-cancel")), /*#__PURE__*/React.createElement(Button, {
436
+ size: "large",
437
+ type: "primary",
438
+ onClick: function onClick() {
439
+ form.submit();
440
+ },
441
+ style: {
442
+ flex: 1
443
+ }
444
+ }, getText("batch-editor-confirm")))));
445
+ };
446
+ export default BatchEditor;
@@ -0,0 +1,48 @@
1
+ .batch-editor-table {
2
+
3
+ :global {
4
+
5
+ // .ant-table-tbody .ant-table-cell {
6
+ // display: flex;
7
+ // align-items: center;
8
+ // }
9
+ .ant-table-cell-with-append {
10
+ display: flex;
11
+ align-items: center;
12
+ height: 95px;
13
+ }
14
+ }
15
+
16
+ .column-title {
17
+ display: flex;
18
+ align-items: center;
19
+ justify-content: space-between;
20
+ word-wrap: normal !important;
21
+ word-break: normal !important;
22
+
23
+ .icon {
24
+ cursor: pointer;
25
+ }
26
+ }
27
+
28
+ .editor-item {
29
+ flex: 1;
30
+ cursor: pointer;
31
+ min-height: 40px;
32
+
33
+ .name {
34
+ overflow: hidden;
35
+ text-overflow: ellipsis;
36
+ white-space: nowrap;
37
+
38
+ max-width: 240px;
39
+ }
40
+ }
41
+
42
+ :global {
43
+ .batch-popover-content {
44
+ width: 250px;
45
+ height: 50px;
46
+ }
47
+ }
48
+ }
@@ -86,6 +86,7 @@ var useTransDataSource = function useTransDataSource(params) {
86
86
  }
87
87
  return newDataSource;
88
88
  }, [pDataSource, localPagination, sortObj, groupDetail, filterLocalArr, filters]);
89
+ console.log('dataSourcedataSource', dataSource);
89
90
  return dataSource;
90
91
  };
91
92
  export default useTransDataSource;