@pisell/materials 3.0.13 → 3.0.15

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 (115) 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 +142 -142
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +20 -20
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +20 -20
  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 +7 -0
  23. package/es/components/batch-editor/fields/Price/index.js +26 -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 +465 -0
  30. package/es/components/batch-editor/index.less +50 -0
  31. package/es/components/page/index.js +12 -9
  32. package/es/components/select-time/RightPanel/index.d.ts +9 -0
  33. package/es/components/select-time/RightPanel/index.js +45 -0
  34. package/es/components/select-time/RightPanel/index.less +22 -0
  35. package/es/components/select-time/index.d.ts +14 -0
  36. package/es/components/select-time/index.js +115 -0
  37. package/es/components/select-time/index.less +16 -0
  38. package/es/components/select-time/utils.d.ts +9 -0
  39. package/es/components/select-time/utils.js +42 -0
  40. package/es/components/table/Table/fields/select/filterUtil/index.js +11 -1
  41. package/es/components/table/hooks/useTransDataSource.js +1 -0
  42. package/es/components/table/index.js +11 -3
  43. package/es/components/table/index.less +47 -2
  44. package/es/components/virtual-keyboard/Keyboard/index.d.ts +18 -0
  45. package/es/components/virtual-keyboard/Keyboard/index.js +51 -0
  46. package/es/components/virtual-keyboard/Keyboard/index.less +32 -0
  47. package/es/components/virtual-keyboard/Time/index.d.ts +13 -0
  48. package/es/components/virtual-keyboard/Time/index.js +124 -0
  49. package/es/components/virtual-keyboard/Time/index.less +0 -0
  50. package/es/components/virtual-keyboard/Time/utils.d.ts +10 -0
  51. package/es/components/virtual-keyboard/Time/utils.js +153 -0
  52. package/es/components/virtual-keyboard/VirtualKeyInput/index.d.ts +9 -0
  53. package/es/components/virtual-keyboard/VirtualKeyInput/index.js +76 -0
  54. package/es/components/virtual-keyboard/VirtualKeyInput/index.less +52 -0
  55. package/es/components/virtual-keyboard/index.d.ts +14 -0
  56. package/es/components/virtual-keyboard/index.js +85 -0
  57. package/es/components/virtual-keyboard/index.less +17 -0
  58. package/es/index.d.ts +4 -0
  59. package/es/index.js +5 -1
  60. package/es/locales/en-US.d.ts +14 -0
  61. package/es/locales/en-US.js +19 -1
  62. package/es/locales/zh-CN.d.ts +14 -0
  63. package/es/locales/zh-CN.js +19 -1
  64. package/es/locales/zh-TW.d.ts +14 -0
  65. package/es/locales/zh-TW.js +19 -1
  66. package/lib/components/batch-editor/fields/Image/index.d.ts +7 -0
  67. package/lib/components/batch-editor/fields/Image/index.js +48 -0
  68. package/lib/components/batch-editor/fields/Image/index.less +6 -0
  69. package/lib/components/batch-editor/fields/Price/index.d.ts +7 -0
  70. package/lib/components/batch-editor/fields/Price/index.js +55 -0
  71. package/lib/components/batch-editor/fields/Text/index.d.ts +6 -0
  72. package/lib/components/batch-editor/fields/Text/index.js +40 -0
  73. package/lib/components/batch-editor/fields/index.d.ts +7 -0
  74. package/lib/components/batch-editor/fields/index.js +42 -0
  75. package/lib/components/batch-editor/index.d.ts +11 -0
  76. package/lib/components/batch-editor/index.js +370 -0
  77. package/lib/components/batch-editor/index.less +50 -0
  78. package/lib/components/page/index.js +6 -7
  79. package/lib/components/select-time/RightPanel/index.d.ts +9 -0
  80. package/lib/components/select-time/RightPanel/index.js +78 -0
  81. package/lib/components/select-time/RightPanel/index.less +22 -0
  82. package/lib/components/select-time/index.d.ts +14 -0
  83. package/lib/components/select-time/index.js +145 -0
  84. package/lib/components/select-time/index.less +16 -0
  85. package/lib/components/select-time/utils.d.ts +9 -0
  86. package/lib/components/select-time/utils.js +71 -0
  87. package/lib/components/table/Table/fields/select/filterUtil/index.js +7 -1
  88. package/lib/components/table/hooks/useTransDataSource.js +1 -0
  89. package/lib/components/table/index.js +16 -4
  90. package/lib/components/table/index.less +47 -2
  91. package/lib/components/virtual-keyboard/Keyboard/index.d.ts +18 -0
  92. package/lib/components/virtual-keyboard/Keyboard/index.js +81 -0
  93. package/lib/components/virtual-keyboard/Keyboard/index.less +32 -0
  94. package/lib/components/virtual-keyboard/Time/index.d.ts +13 -0
  95. package/lib/components/virtual-keyboard/Time/index.js +166 -0
  96. package/lib/components/virtual-keyboard/Time/index.less +0 -0
  97. package/lib/components/virtual-keyboard/Time/utils.d.ts +10 -0
  98. package/lib/components/virtual-keyboard/Time/utils.js +162 -0
  99. package/lib/components/virtual-keyboard/VirtualKeyInput/index.d.ts +9 -0
  100. package/lib/components/virtual-keyboard/VirtualKeyInput/index.js +90 -0
  101. package/lib/components/virtual-keyboard/VirtualKeyInput/index.less +52 -0
  102. package/lib/components/virtual-keyboard/index.d.ts +14 -0
  103. package/lib/components/virtual-keyboard/index.js +131 -0
  104. package/lib/components/virtual-keyboard/index.less +17 -0
  105. package/lib/index.d.ts +4 -0
  106. package/lib/index.js +12 -0
  107. package/lib/locales/en-US.d.ts +14 -0
  108. package/lib/locales/en-US.js +15 -1
  109. package/lib/locales/zh-CN.d.ts +14 -0
  110. package/lib/locales/zh-CN.js +15 -1
  111. package/lib/locales/zh-TW.d.ts +14 -0
  112. package/lib/locales/zh-TW.js +15 -1
  113. package/lowcode/batch-editor/meta.ts +93 -0
  114. package/lowcode/select-time/meta.ts +8 -8
  115. package/package.json +1 -1
@@ -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,7 @@
1
+ import React from "react";
2
+ import { InputNumberProps } from "antd";
3
+ export interface PriceProps extends InputNumberProps {
4
+ symbol: string;
5
+ }
6
+ declare const Price: React.FC<PriceProps>;
7
+ export default Price;
@@ -0,0 +1,26 @@
1
+ var _excluded = ["symbol"];
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 _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; }
4
+ 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; }
5
+ import React from "react";
6
+ import { InputNumber } from "antd";
7
+ var Price = function Price(props) {
8
+ var symbol = props.symbol,
9
+ rest = _objectWithoutProperties(props, _excluded);
10
+ // return <div>{}</div>
11
+ return /*#__PURE__*/React.createElement(InputNumber, _extends({
12
+ keyboard: false,
13
+ style: {
14
+ width: "100%"
15
+ },
16
+ min: 0,
17
+ prefix: symbol || "$",
18
+ max: 999999,
19
+ precision: 2,
20
+ size: "large",
21
+ controls: false
22
+ }, rest, {
23
+ placeholder: rest.placeholder || "0.00"
24
+ }));
25
+ };
26
+ 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,465 @@
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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
+ 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."); }
4
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
+ 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; }
7
+ 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; }
8
+ 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; }
9
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
10
+ 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); }
11
+ 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; } } }; }
12
+ 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); }
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 useEngineContext from "../../hooks/useEngineContext";
26
+ import { getText } from "../../locales/index";
27
+ import "./index.less";
28
+ var BatchEditor = function BatchEditor(props) {
29
+ var _context$appHelper, _store$getState, _store$getState$call, _store$getState$call$, _otherTableProps$filt;
30
+ var columns = props.columns,
31
+ _props$dataSource = props.dataSource,
32
+ dataSource = _props$dataSource === void 0 ? [] : _props$dataSource,
33
+ onChange = props.onChange,
34
+ rowKey = props.rowKey,
35
+ otherTableProps = props.otherTableProps;
36
+ var _Form$useForm = Form.useForm(),
37
+ _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
38
+ form = _Form$useForm2[0];
39
+ var _useState = useState(false),
40
+ _useState2 = _slicedToArray(_useState, 2),
41
+ openModal = _useState2[0],
42
+ setOpenModal = _useState2[1];
43
+ var _useState3 = useState([]),
44
+ _useState4 = _slicedToArray(_useState3, 2),
45
+ selectList = _useState4[0],
46
+ setSelectList = _useState4[1];
47
+ var context = useEngineContext();
48
+ var _ref = ((_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.utils) || {},
49
+ store = _ref.store;
50
+ var symbol = (store === null || store === void 0 ? void 0 : (_store$getState = store.getState) === null || _store$getState === void 0 ? void 0 : (_store$getState$call = _store$getState.call(store)) === null || _store$getState$call === void 0 ? void 0 : (_store$getState$call$ = _store$getState$call.global) === null || _store$getState$call$ === void 0 ? void 0 : _store$getState$call$.symbol) || "$";
51
+
52
+ /**
53
+ * @title: 渲染column
54
+ * @description:
55
+ * @return {*}
56
+ * @Author: zhiwei.Wang
57
+ * @Date: 2024-06-17 13:21
58
+ */
59
+ var renderColumnItem = useCallback(function (_item) {
60
+ return function (text, record) {
61
+ // 没有type 按文本渲染
62
+ if (!_item.type) {
63
+ var _Com = fields["text"];
64
+ return /*#__PURE__*/React.createElement("div", {
65
+ className: "editor-item"
66
+ }, /*#__PURE__*/React.createElement(_Com, null, text));
67
+ }
68
+
69
+ // 如果当前record单独禁止编辑某些字段
70
+ if ((record.disabledList || []).includes(_item.dataIndex)) {
71
+ return /*#__PURE__*/React.createElement("div", {
72
+ className: "editor-item",
73
+ style: {
74
+ padding: "0 11px"
75
+ }
76
+ }, /*#__PURE__*/React.createElement(Tooltip, {
77
+ overlay: 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
+ }, /*#__PURE__*/React.createElement("div", {
81
+ className: "name"
82
+ }, record !== null && record !== void 0 && record.disabledTexts ?
83
+ //@ts-ignore
84
+ (record === null || record === void 0 ? void 0 : record.disabledTexts[_item.dataIndex]) || text : text)));
85
+ }
86
+ var Com = fields[_item.type];
87
+ if (Com) {
88
+ return /*#__PURE__*/React.createElement("div", {
89
+ className: "editor-item"
90
+ }, /*#__PURE__*/React.createElement(Com, _extends({
91
+ status: record.status,
92
+ value: text
93
+ // 为了应对每个字段需要设置不同的 placeholder
94
+ }, _item.componentProps, {
95
+ placeholder: _item.placeholder || record[_item.dataIndex + "placeholder"],
96
+ symbol: symbol,
97
+ onChange: function onChange(e) {
98
+ handleChange(e, _item.dataIndex, record[rowKey]);
99
+ }
100
+ })));
101
+ }
102
+ return /*#__PURE__*/React.createElement("div", {
103
+ className: "editor-item"
104
+ }, "-");
105
+ };
106
+ }, [dataSource, rowKey, columns]);
107
+
108
+ /**
109
+ * dataSource 的返回事件
110
+ * @param newDataSource
111
+ */
112
+ var _onChange = function _onChange(newDataSource) {
113
+ onChange === null || onChange === void 0 ? void 0 : onChange(newDataSource);
114
+ };
115
+
116
+ /**
117
+ * @title: 编辑某个字段
118
+ * @description:
119
+ * @return {*}
120
+ * @Author: zhiwei.Wang
121
+ * @Date: 2024-06-17 13:22
122
+ */
123
+ var handleChange = function handleChange(val, key, id) {
124
+ var _dataSource = JSON.parse(JSON.stringify(dataSource));
125
+ var fn = function fn(_list) {
126
+ var _iterator = _createForOfIteratorHelper(_list),
127
+ _step;
128
+ try {
129
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
130
+ var d = _step.value;
131
+ if (d[rowKey] === id) {
132
+ d[key] = val;
133
+ break;
134
+ }
135
+ if (d.children && d.children.length) {
136
+ fn(d.children);
137
+ }
138
+ }
139
+ } catch (err) {
140
+ _iterator.e(err);
141
+ } finally {
142
+ _iterator.f();
143
+ }
144
+ };
145
+ fn(_dataSource || []);
146
+ _onChange(_dataSource);
147
+ };
148
+
149
+ /**
150
+ * @title: 批量编辑
151
+ * @description:
152
+ * @param {any} val
153
+ * @param {any} key
154
+ * @return {*}
155
+ * @Author: zhiwei.Wang
156
+ * @Date: 2024-06-17 13:22
157
+ */
158
+ var handleBatchEditChange = function handleBatchEditChange(val, key) {
159
+ var _dataSource = JSON.parse(JSON.stringify(dataSource));
160
+ var fn = function fn(_list) {
161
+ var _iterator2 = _createForOfIteratorHelper(_list),
162
+ _step2;
163
+ try {
164
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
165
+ var d = _step2.value;
166
+ if (selectList.includes(d[rowKey]) && !(d.disabledList || []).includes(key)) {
167
+ d[key] = val;
168
+ }
169
+ if (d.children && d.children.length) {
170
+ fn(d.children);
171
+ }
172
+ }
173
+ } catch (err) {
174
+ _iterator2.e(err);
175
+ } finally {
176
+ _iterator2.f();
177
+ }
178
+ };
179
+ fn(_dataSource || []);
180
+ _onChange(_dataSource);
181
+ };
182
+
183
+ /**
184
+ * @title: 删除record
185
+ * @description:
186
+ * @param {any} ids
187
+ * @return {*}
188
+ * @Author: zhiwei.Wang
189
+ * @Date: 2024-06-17 13:22
190
+ */
191
+ var handleRemove = function handleRemove(ids) {
192
+ var _dataSource = JSON.parse(JSON.stringify(dataSource));
193
+ if (_dataSource.some(function (d) {
194
+ return ids.includes(d[rowKey]);
195
+ })) {
196
+ _dataSource = _dataSource.filter(function (d) {
197
+ return !ids.includes(d[rowKey]);
198
+ });
199
+ } else {
200
+ _dataSource.forEach(function (d) {
201
+ if (d.children) {
202
+ d.children = d.children.filter(function (d) {
203
+ return !ids.includes(d[rowKey]);
204
+ });
205
+ }
206
+ });
207
+ }
208
+ _onChange(_dataSource);
209
+ };
210
+ var setDebounceValue = useDebounceFn(function (_dataSource) {
211
+ _onChange(_dataSource);
212
+ }, {
213
+ wait: 300
214
+ });
215
+
216
+ // 渲染弹窗内容
217
+ var renderPopoverContent = useCallback(function (_item) {
218
+ var Com = fields[_item.type];
219
+ var val;
220
+ return /*#__PURE__*/React.createElement("div", {
221
+ className: "batch-popover-content"
222
+ }, /*#__PURE__*/React.createElement("div", {
223
+ className: "editor-item"
224
+ }, /*#__PURE__*/React.createElement(Com, {
225
+ symbol: symbol,
226
+ onBlur: function onBlur() {
227
+ if (val !== undefined) {
228
+ handleBatchEditChange(val, _item.dataIndex);
229
+ }
230
+ },
231
+ onChange: function onChange(e) {
232
+ val = e;
233
+ }
234
+ })));
235
+ }, [dataSource, selectList]);
236
+
237
+ /**
238
+ * @title: 渲染表格列标题
239
+ * @description:
240
+ * @return {*}
241
+ * @Author: zhiwei.Wang
242
+ * @Date: 2024-06-17 13:23
243
+ */
244
+ var renderColumnTitle = useCallback(function (item) {
245
+ return /*#__PURE__*/React.createElement("div", {
246
+ className: "column-title"
247
+ }, /*#__PURE__*/React.createElement("span", null, item.title), selectList.length && item.batchEdit ? /*#__PURE__*/React.createElement(Popover, {
248
+ destroyTooltipOnHide: true,
249
+ trigger: ["click"],
250
+ placement: "bottom",
251
+ title: "".concat(getText("batch-editor-batch-edit"), ": ").concat(item.title),
252
+ content: renderPopoverContent(item)
253
+ }, /*#__PURE__*/React.createElement("a", {
254
+ style: {
255
+ marginLeft: 4
256
+ }
257
+ }, getText("batch-editor-batch-edit"))) : null);
258
+ }, [dataSource, rowKey, selectList]);
259
+
260
+ /**
261
+ * @title: 表格列
262
+ * @description:
263
+ * @param {*} useMemo
264
+ * @return {*}
265
+ * @Author: zhiwei.Wang
266
+ * @Date: 2024-06-17 13:23
267
+ */
268
+ var _columns = useMemo(function () {
269
+ return columns.filter(function (d) {
270
+ return !d.hide;
271
+ }).map(function (d) {
272
+ return _objectSpread(_objectSpread({}, d), {}, {
273
+ titleStr: d.title,
274
+ title: renderColumnTitle(d),
275
+ render: renderColumnItem(d)
276
+ });
277
+ }).concat([{
278
+ title: getText("batch-editor-actions"),
279
+ dataIndex: rowKey,
280
+ key: "actions",
281
+ align: "center",
282
+ fixed: "right",
283
+ width: 100,
284
+ dataSource: dataSource,
285
+ selectList: selectList,
286
+ render: function render(text, record) {
287
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Button, {
288
+ onClick: function onClick() {
289
+ handleRemove([text]);
290
+ }
291
+ }, getText("batch-editor-remove")));
292
+ }
293
+ }]);
294
+ }, [renderColumnItem, rowKey, dataSource, selectList]);
295
+ var selectOptions = useMemo(function () {
296
+ return _columns.filter(function (d) {
297
+ return d.batchEdit;
298
+ }).map(function (d) {
299
+ return {
300
+ label: d.titleStr,
301
+ value: d.dataIndex
302
+ };
303
+ });
304
+ }, [_columns]);
305
+ var onFinish = function onFinish(values) {
306
+ handleBatchEditChange(values.value, values.key);
307
+ onCancel();
308
+ setSelectList([]);
309
+ };
310
+ var onCancel = function onCancel() {
311
+ form.resetFields();
312
+ setOpenModal(false);
313
+ };
314
+ var onOpenMOdal = function onOpenMOdal() {
315
+ setOpenModal(true);
316
+ form.setFieldsValue({
317
+ key: selectOptions[0].value
318
+ });
319
+ };
320
+ var modalTitle = useMemo(function () {
321
+ var str = "";
322
+ var selectItems = [];
323
+ selectList.forEach(function (item) {
324
+ var productItem = dataSource.find(function (d) {
325
+ return d[rowKey] === item;
326
+ });
327
+ if (productItem) {
328
+ selectItems.push(productItem);
329
+ } else {
330
+ dataSource.forEach(function (d) {
331
+ if (d.children) {
332
+ var childProductItem = d.children.find(function (t) {
333
+ return t[rowKey] === item;
334
+ });
335
+ if (childProductItem) {
336
+ selectItems.push(childProductItem);
337
+ }
338
+ }
339
+ });
340
+ }
341
+ });
342
+ str = "";
343
+ if (selectItems.length > 1) {
344
+ var _selectItems$;
345
+ str = getText("batch-editor-quick-edit-title")((_selectItems$ = selectItems[0]) === null || _selectItems$ === void 0 ? void 0 : _selectItems$.title, selectItems.length);
346
+ } else {
347
+ var _selectItems$2;
348
+ str = getText("batch-editor-quick-edit-title-2")((_selectItems$2 = selectItems[0]) === null || _selectItems$2 === void 0 ? void 0 : _selectItems$2.title);
349
+ }
350
+ return str;
351
+ }, [selectList, dataSource]);
352
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Table, _extends({
353
+ actionButtons: !!selectList.length && [{
354
+ title: getText("batch-editor-batch-remove"),
355
+ size: "large",
356
+ onClick: function onClick() {
357
+ handleRemove(selectList);
358
+ setSelectList([]);
359
+ }
360
+ }, {
361
+ title: getText("batch-editor-batch-edit"),
362
+ onClick: onOpenMOdal,
363
+ size: "large",
364
+ type: "primary"
365
+ }],
366
+ bordered: true,
367
+ dataSource: dataSource,
368
+ columns: _columns,
369
+ className: "batch-editor-table",
370
+ rowKey: rowKey,
371
+ rowSelection: {
372
+ type: "checkbox",
373
+ selectedRowKeys: selectList,
374
+ onChange: function onChange(keys) {
375
+ setSelectList(keys);
376
+ }
377
+ },
378
+ scroll: {
379
+ autoCalc: true
380
+ },
381
+ pagination: {
382
+ localPagination: true,
383
+ showSizeChanger: true,
384
+ size: "default"
385
+ }
386
+ }, otherTableProps, {
387
+ onValuesChange: function onValuesChange(values) {
388
+ var _otherTableProps$onVa;
389
+ setSelectList([]);
390
+ otherTableProps === null || otherTableProps === void 0 ? void 0 : (_otherTableProps$onVa = otherTableProps.onValuesChange) === null || _otherTableProps$onVa === void 0 ? void 0 : _otherTableProps$onVa.call(otherTableProps, values);
391
+ },
392
+ filter: _objectSpread(_objectSpread({
393
+ show: true,
394
+ sortButtonShow: false,
395
+ quickFilterMaxLength: 3,
396
+ storageMode: "localStorage"
397
+ }, (otherTableProps === null || otherTableProps === void 0 ? void 0 : otherTableProps.filter) || {}), {}, {
398
+ list: [{
399
+ type: "search",
400
+ name: "keywords",
401
+ key: "keywords",
402
+ localFilter: true,
403
+ other: {
404
+ trigger: ["onChange"],
405
+ allowClear: true,
406
+ size: "large",
407
+ placeholder: getText("batch-editor-search"),
408
+ onChange: function onChange() {
409
+ setSelectList([]);
410
+ }
411
+ }
412
+ }].concat(_toConsumableArray((otherTableProps === null || otherTableProps === void 0 ? void 0 : (_otherTableProps$filt = otherTableProps.filter) === null || _otherTableProps$filt === void 0 ? void 0 : _otherTableProps$filt.list) || []))
413
+ })
414
+ })), /*#__PURE__*/React.createElement(Modal, {
415
+ title: getText("batch-editor-quick-edit"),
416
+ open: openModal,
417
+ footer: null,
418
+ onCancel: function onCancel() {
419
+ setOpenModal(false);
420
+ }
421
+ }, /*#__PURE__*/React.createElement("div", {
422
+ className: "title",
423
+ style: {
424
+ marginBottom: 20
425
+ }
426
+ }, modalTitle), /*#__PURE__*/React.createElement(Form, {
427
+ layout: "vertical",
428
+ form: form,
429
+ onFinish: onFinish
430
+ }, /*#__PURE__*/React.createElement(Form.Item, {
431
+ label: getText("batch-editor-what-price"),
432
+ name: "key"
433
+ }, /*#__PURE__*/React.createElement(Select, {
434
+ size: "large",
435
+ options: selectOptions
436
+ })), /*#__PURE__*/React.createElement(Form.Item, {
437
+ label: getText("batch-editor-price"),
438
+ name: "value"
439
+ }, /*#__PURE__*/React.createElement(Price, {
440
+ symbol: symbol
441
+ }))), /*#__PURE__*/React.createElement("div", {
442
+ className: "",
443
+ style: {
444
+ display: "flex",
445
+ gap: 20,
446
+ width: "100%"
447
+ }
448
+ }, /*#__PURE__*/React.createElement(Button, {
449
+ size: "large",
450
+ style: {
451
+ flex: 1
452
+ },
453
+ onClick: onCancel
454
+ }, getText("batch-editor-cancel")), /*#__PURE__*/React.createElement(Button, {
455
+ size: "large",
456
+ type: "primary",
457
+ onClick: function onClick() {
458
+ form.submit();
459
+ },
460
+ style: {
461
+ flex: 1
462
+ }
463
+ }, getText("batch-editor-confirm")))));
464
+ };
465
+ export default BatchEditor;
@@ -0,0 +1,50 @@
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 !important;
18
+ align-items: center;
19
+ justify-content: space-between;
20
+ word-wrap: normal !important;
21
+ word-break: normal !important;
22
+ white-space: wrap !important;
23
+ padding: 4px 8px;
24
+
25
+ .icon {
26
+ cursor: pointer;
27
+ }
28
+ }
29
+
30
+ .editor-item {
31
+ flex: 1;
32
+ cursor: pointer;
33
+ min-height: 40px;
34
+
35
+ .name {
36
+ overflow: hidden;
37
+ text-overflow: ellipsis;
38
+ white-space: nowrap;
39
+
40
+ max-width: 240px;
41
+ }
42
+ }
43
+
44
+ :global {
45
+ .batch-popover-content {
46
+ width: 250px;
47
+ height: 50px;
48
+ }
49
+ }
50
+ }