@pisell/common 0.0.1

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 (183) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +40 -0
  3. package/es/business-components/colorInput/index.d.ts +21 -0
  4. package/es/business-components/colorInput/index.js +43 -0
  5. package/es/business-components/colorInput/index.less +10 -0
  6. package/es/business-components/index.d.ts +11 -0
  7. package/es/business-components/index.js +7 -0
  8. package/es/business-components/rechargeOption/index.d.ts +36 -0
  9. package/es/business-components/rechargeOption/index.js +136 -0
  10. package/es/business-components/rechargeOption/index.less +0 -0
  11. package/es/business-components/selectTag/index.d.ts +25 -0
  12. package/es/business-components/selectTag/index.js +180 -0
  13. package/es/business-components/selectTag/index.less +22 -0
  14. package/es/business-components/sortModal/index.d.ts +30 -0
  15. package/es/business-components/sortModal/index.js +85 -0
  16. package/es/business-components/sortModal/index.less +29 -0
  17. package/es/business-components/statistics/index.d.ts +12 -0
  18. package/es/business-components/statistics/index.js +38 -0
  19. package/es/business-components/statistics/index.less +64 -0
  20. package/es/business-components/tagModal/index.d.ts +17 -0
  21. package/es/business-components/tagModal/index.js +59 -0
  22. package/es/business-hooks/index.d.ts +2 -0
  23. package/es/business-hooks/index.js +2 -0
  24. package/es/business-hooks/useModal/index.d.ts +31 -0
  25. package/es/business-hooks/useModal/index.js +91 -0
  26. package/es/business-hooks/useModal/index.less +0 -0
  27. package/es/business-hooks/useTagModal/index.d.ts +17 -0
  28. package/es/business-hooks/useTagModal/index.js +47 -0
  29. package/es/components/ColorPicker/index.d.ts +22 -0
  30. package/es/components/ColorPicker/index.js +51 -0
  31. package/es/components/ColorPicker/index.less +17 -0
  32. package/es/components/DragSort/index.d.ts +2 -0
  33. package/es/components/DragSort/index.js +68 -0
  34. package/es/components/Iconfont/index.d.ts +6 -0
  35. package/es/components/Iconfont/index.js +28 -0
  36. package/es/components/Iconfont/index.less +0 -0
  37. package/es/components/card/index.d.ts +5 -0
  38. package/es/components/card/index.js +16 -0
  39. package/es/components/card/index.less +9 -0
  40. package/es/components/index.d.ts +4 -0
  41. package/es/components/index.js +4 -0
  42. package/es/config/index.d.ts +16 -0
  43. package/es/config/index.js +18 -0
  44. package/es/config/utils.d.ts +0 -0
  45. package/es/config/utils.js +0 -0
  46. package/es/hooks/index.d.ts +8 -0
  47. package/es/hooks/index.js +8 -0
  48. package/es/hooks/useCountDown/index.d.ts +10 -0
  49. package/es/hooks/useCountDown/index.js +48 -0
  50. package/es/hooks/useDocumentScroll/index.d.ts +8 -0
  51. package/es/hooks/useDocumentScroll/index.js +41 -0
  52. package/es/hooks/useDocumentScroll/index.less +0 -0
  53. package/es/hooks/useMousemove/index.d.ts +8 -0
  54. package/es/hooks/useMousemove/index.js +61 -0
  55. package/es/hooks/useResponsive/index.d.ts +2 -0
  56. package/es/hooks/useResponsive/index.js +29 -0
  57. package/es/hooks/useResponsive/index.less +0 -0
  58. package/es/hooks/useSize/index.d.ts +2 -0
  59. package/es/hooks/useSize/index.js +27 -0
  60. package/es/hooks/useSize/index.less +0 -0
  61. package/es/hooks/useStateMulti/index.d.ts +2 -0
  62. package/es/hooks/useStateMulti/index.js +29 -0
  63. package/es/hooks/useStateWithCb/index.d.ts +2 -0
  64. package/es/hooks/useStateWithCb/index.js +42 -0
  65. package/es/hooks/useTable/index.d.ts +12 -0
  66. package/es/hooks/useTable/index.js +74 -0
  67. package/es/hooks/useTable/index.less +0 -0
  68. package/es/hooks/useTableModal/index.d.ts +12 -0
  69. package/es/hooks/useTableModal/index.js +25 -0
  70. package/es/hooks/useTableModal/index.less +0 -0
  71. package/es/hooks/useUrlState/index.d.ts +2 -0
  72. package/es/hooks/useUrlState/index.js +56 -0
  73. package/es/hooks/useWebSocket/index.d.ts +13 -0
  74. package/es/hooks/useWebSocket/index.js +121 -0
  75. package/es/index.d.ts +4 -0
  76. package/es/index.js +4 -0
  77. package/es/locales/en-US.d.ts +11 -0
  78. package/es/locales/en-US.js +10 -0
  79. package/es/locales/index.d.ts +1 -0
  80. package/es/locales/index.js +23 -0
  81. package/es/locales/zh-CN.d.ts +11 -0
  82. package/es/locales/zh-CN.js +10 -0
  83. package/es/locales/zh-TW.d.ts +11 -0
  84. package/es/locales/zh-TW.js +10 -0
  85. package/es/utils/index.d.ts +3 -0
  86. package/es/utils/index.js +3 -0
  87. package/es/utils/otherUtils.d.ts +8 -0
  88. package/es/utils/otherUtils.js +12 -0
  89. package/es/utils/storage.d.ts +30 -0
  90. package/es/utils/storage.js +70 -0
  91. package/es/utils/typeUtils.d.ts +42 -0
  92. package/es/utils/typeUtils.js +86 -0
  93. package/lib/business-components/colorInput/index.d.ts +21 -0
  94. package/lib/business-components/colorInput/index.js +70 -0
  95. package/lib/business-components/colorInput/index.less +10 -0
  96. package/lib/business-components/index.d.ts +11 -0
  97. package/lib/business-components/index.js +54 -0
  98. package/lib/business-components/rechargeOption/index.d.ts +36 -0
  99. package/lib/business-components/rechargeOption/index.js +133 -0
  100. package/lib/business-components/rechargeOption/index.less +0 -0
  101. package/lib/business-components/selectTag/index.d.ts +25 -0
  102. package/lib/business-components/selectTag/index.js +181 -0
  103. package/lib/business-components/selectTag/index.less +22 -0
  104. package/lib/business-components/sortModal/index.d.ts +30 -0
  105. package/lib/business-components/sortModal/index.js +100 -0
  106. package/lib/business-components/sortModal/index.less +29 -0
  107. package/lib/business-components/statistics/index.d.ts +12 -0
  108. package/lib/business-components/statistics/index.js +63 -0
  109. package/lib/business-components/statistics/index.less +64 -0
  110. package/lib/business-components/tagModal/index.d.ts +17 -0
  111. package/lib/business-components/tagModal/index.js +66 -0
  112. package/lib/business-hooks/index.d.ts +2 -0
  113. package/lib/business-hooks/index.js +42 -0
  114. package/lib/business-hooks/useModal/index.d.ts +31 -0
  115. package/lib/business-hooks/useModal/index.js +68 -0
  116. package/lib/business-hooks/useModal/index.less +0 -0
  117. package/lib/business-hooks/useTagModal/index.d.ts +17 -0
  118. package/lib/business-hooks/useTagModal/index.js +61 -0
  119. package/lib/components/ColorPicker/index.d.ts +22 -0
  120. package/lib/components/ColorPicker/index.js +80 -0
  121. package/lib/components/ColorPicker/index.less +17 -0
  122. package/lib/components/DragSort/index.d.ts +2 -0
  123. package/lib/components/DragSort/index.js +101 -0
  124. package/lib/components/Iconfont/index.d.ts +6 -0
  125. package/lib/components/Iconfont/index.js +47 -0
  126. package/lib/components/Iconfont/index.less +0 -0
  127. package/lib/components/card/index.d.ts +5 -0
  128. package/lib/components/card/index.js +42 -0
  129. package/lib/components/card/index.less +9 -0
  130. package/lib/components/index.d.ts +4 -0
  131. package/lib/components/index.js +48 -0
  132. package/lib/config/index.d.ts +16 -0
  133. package/lib/config/index.js +39 -0
  134. package/lib/config/utils.d.ts +0 -0
  135. package/lib/config/utils.js +0 -0
  136. package/lib/hooks/index.d.ts +8 -0
  137. package/lib/hooks/index.js +57 -0
  138. package/lib/hooks/useCountDown/index.d.ts +10 -0
  139. package/lib/hooks/useCountDown/index.js +57 -0
  140. package/lib/hooks/useDocumentScroll/index.d.ts +8 -0
  141. package/lib/hooks/useDocumentScroll/index.js +54 -0
  142. package/lib/hooks/useDocumentScroll/index.less +0 -0
  143. package/lib/hooks/useMousemove/index.d.ts +8 -0
  144. package/lib/hooks/useMousemove/index.js +70 -0
  145. package/lib/hooks/useResponsive/index.d.ts +2 -0
  146. package/lib/hooks/useResponsive/index.js +47 -0
  147. package/lib/hooks/useResponsive/index.less +0 -0
  148. package/lib/hooks/useSize/index.d.ts +2 -0
  149. package/lib/hooks/useSize/index.js +45 -0
  150. package/lib/hooks/useSize/index.less +0 -0
  151. package/lib/hooks/useStateMulti/index.d.ts +2 -0
  152. package/lib/hooks/useStateMulti/index.js +43 -0
  153. package/lib/hooks/useStateWithCb/index.d.ts +2 -0
  154. package/lib/hooks/useStateWithCb/index.js +53 -0
  155. package/lib/hooks/useTable/index.d.ts +12 -0
  156. package/lib/hooks/useTable/index.js +75 -0
  157. package/lib/hooks/useTable/index.less +0 -0
  158. package/lib/hooks/useTableModal/index.d.ts +12 -0
  159. package/lib/hooks/useTableModal/index.js +43 -0
  160. package/lib/hooks/useTableModal/index.less +0 -0
  161. package/lib/hooks/useUrlState/index.d.ts +2 -0
  162. package/lib/hooks/useUrlState/index.js +59 -0
  163. package/lib/hooks/useWebSocket/index.d.ts +13 -0
  164. package/lib/hooks/useWebSocket/index.js +91 -0
  165. package/lib/index.d.ts +4 -0
  166. package/lib/index.js +22 -0
  167. package/lib/locales/en-US.d.ts +11 -0
  168. package/lib/locales/en-US.js +36 -0
  169. package/lib/locales/index.d.ts +1 -0
  170. package/lib/locales/index.js +59 -0
  171. package/lib/locales/zh-CN.d.ts +11 -0
  172. package/lib/locales/zh-CN.js +36 -0
  173. package/lib/locales/zh-TW.d.ts +11 -0
  174. package/lib/locales/zh-TW.js +36 -0
  175. package/lib/utils/index.d.ts +3 -0
  176. package/lib/utils/index.js +21 -0
  177. package/lib/utils/otherUtils.d.ts +8 -0
  178. package/lib/utils/otherUtils.js +31 -0
  179. package/lib/utils/storage.d.ts +30 -0
  180. package/lib/utils/storage.js +63 -0
  181. package/lib/utils/typeUtils.d.ts +42 -0
  182. package/lib/utils/typeUtils.js +75 -0
  183. package/package.json +101 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # @pisell/common
2
+
3
+ [![NPM version](https://img.shields.io/npm/v/@pisell/common.svg?style=flat)](https://npmjs.org/package/@pisell/common)
4
+ [![NPM downloads](http://img.shields.io/npm/dm/@pisell/common.svg?style=flat)](https://npmjs.org/package/@pisell/common)
5
+
6
+ pisell
7
+
8
+ ## Usage
9
+
10
+ TODO
11
+
12
+ ## Options
13
+
14
+ TODO
15
+
16
+ ## Development
17
+
18
+ ```bash
19
+ # install dependencies
20
+ $ cnpm install
21
+
22
+ # develop library by docs demo
23
+ $ cnpm start
24
+
25
+ # build library source code
26
+ $ cnpm run build
27
+
28
+ # build library source code in watch mode
29
+ $ cnpm run build:watch
30
+
31
+ # build docs
32
+ $ cnpm run docs:build
33
+
34
+ # check your project for potential problems
35
+ $ cnpm run doctor
36
+ ```
37
+
38
+ ## LICENSE
39
+
40
+ MIT
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ export interface ColorInputProps {
4
+ /**
5
+ * @description 颜色值
6
+ * @default ""
7
+ */
8
+ value: string;
9
+ /**
10
+ * @description 当颜色值改变触发
11
+ * @default () => void
12
+ */
13
+ onChange: (val: string) => void;
14
+ /**
15
+ * @description 色块大小
16
+ * @default 30
17
+ */
18
+ colorBlockSize?: number;
19
+ }
20
+ declare const ColorInput: React.FC<ColorInputProps>;
21
+ export default ColorInput;
@@ -0,0 +1,43 @@
1
+ import { Input } from 'antd';
2
+ import React from 'react';
3
+ import { ColorPicker } from "../../components";
4
+ import "./index.less";
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ import { jsxs as _jsxs } from "react/jsx-runtime";
7
+ var prefix = 'pisell-';
8
+ var ColorInput = function ColorInput(props) {
9
+ var _props$value = props.value,
10
+ value = _props$value === void 0 ? '' : _props$value,
11
+ _onChange = props.onChange,
12
+ _props$colorBlockSize = props.colorBlockSize,
13
+ colorBlockSize = _props$colorBlockSize === void 0 ? 30 : _props$colorBlockSize;
14
+ return /*#__PURE__*/_jsxs("div", {
15
+ className: "".concat(prefix, "color-input-wrap"),
16
+ children: [/*#__PURE__*/_jsx(ColorPicker, {
17
+ onChange: _onChange,
18
+ value: value,
19
+ children: /*#__PURE__*/_jsx("div", {
20
+ style: {
21
+ backgroundColor: value,
22
+ width: colorBlockSize,
23
+ height: colorBlockSize
24
+ },
25
+ className: "".concat(prefix, "color-block")
26
+ })
27
+ }), /*#__PURE__*/_jsx(Input, {
28
+ value: value.replace('#', ''),
29
+ prefix: '#',
30
+ style: {
31
+ width: 120
32
+ },
33
+ onChange: function onChange(e) {
34
+ var reg = /^([0-9a-fA-F]{0,6})$/;
35
+ if (!reg.test(e.target.value)) {
36
+ return;
37
+ }
38
+ _onChange("#".concat(e.target.value));
39
+ }
40
+ })]
41
+ });
42
+ };
43
+ export default ColorInput;
@@ -0,0 +1,10 @@
1
+ .pisell-color-input-wrap {
2
+ display: flex;
3
+ align-items: center;
4
+ .pisell-color-block {
5
+ width: 30px;
6
+ height: 30px;
7
+ margin-right: 10px;
8
+ border-radius: 4px;
9
+ }
10
+ }
@@ -0,0 +1,11 @@
1
+ export { default as ColorInput } from './colorInput';
2
+ export type { ColorInputProps } from './colorInput';
3
+ export { default as RechargeOption } from './rechargeOption';
4
+ export type { RechargeOptionProps } from './rechargeOption';
5
+ export { default as SelectTag } from './selectTag';
6
+ export type { SelectTagProps } from './selectTag';
7
+ export { default as SortModal } from './sortModal';
8
+ export type { SortModalProps } from './sortModal';
9
+ export { default as Statistics } from './statistics';
10
+ export { default as TagModal } from './tagModal';
11
+ export type { TagModalProps } from './tagModal';
@@ -0,0 +1,7 @@
1
+ // export { default as Address } from './address';
2
+ export { default as ColorInput } from "./colorInput";
3
+ export { default as RechargeOption } from "./rechargeOption";
4
+ export { default as SelectTag } from "./selectTag";
5
+ export { default as SortModal } from "./sortModal";
6
+ export { default as Statistics } from "./statistics";
7
+ export { default as TagModal } from "./tagModal";
@@ -0,0 +1,36 @@
1
+ import React from 'react';
2
+ import type { ColProps } from 'antd/lib/col';
3
+ import type { FormListFieldData, FormListProps } from 'antd/lib/form/FormList';
4
+ import type { FormItemProps } from 'antd/lib/form/FormItem';
5
+ import type { SortModalProps } from '../sortModal';
6
+ import type { FormInstance } from 'antd/es/form/hooks/useForm';
7
+ export interface RechargeOptionProps {
8
+ name: FormListProps['name'];
9
+ /** 是否展示编辑按钮 */
10
+ isShowEditButton?: boolean;
11
+ /** 添加按钮文案 */
12
+ addBtnText?: string;
13
+ /** 编辑按钮文案 */
14
+ editBtnText?: string;
15
+ /** 列配置 */
16
+ columnOption: {
17
+ label: string;
18
+ span: ColProps['span'];
19
+ field: string;
20
+ rules: FormItemProps['rules'];
21
+ }[];
22
+ /** 编辑按钮事件 */
23
+ onEditClick?: (bundle: FormListFieldData) => void;
24
+ rechargeOptionRef?: React.MutableRefObject<{
25
+ openSortModal: () => void;
26
+ } | undefined>;
27
+ sortModalProps?: Partial<Omit<SortModalProps<Record<string, any>>, 'ref'>>;
28
+ form: FormInstance;
29
+ }
30
+ /**
31
+ * 类充值选项组件
32
+ * @param props
33
+ * @constructor
34
+ */
35
+ declare const RechargeOption: React.FC<RechargeOptionProps>;
36
+ export default RechargeOption;
@@ -0,0 +1,136 @@
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 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; }
3
+ 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; }
4
+ 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; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ 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); }
7
+ import React, { useCallback, useImperativeHandle, useMemo, useRef } from 'react';
8
+ import { Button, Col, Form, Input, Row } from 'antd';
9
+ import { getUniqueId, isFunction } from "../../utils";
10
+ import { DeleteOutlined } from '@ant-design/icons';
11
+ import SortModal from "../sortModal";
12
+ import { getText } from "../../locales";
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { jsxs as _jsxs } from "react/jsx-runtime";
15
+ import { Fragment as _Fragment } from "react/jsx-runtime";
16
+ /**
17
+ * 类充值选项组件
18
+ * @param props
19
+ * @constructor
20
+ */
21
+ var RechargeOption = function RechargeOption(props) {
22
+ var name = props.name,
23
+ _props$isShowEditButt = props.isShowEditButton,
24
+ isShowEditButton = _props$isShowEditButt === void 0 ? false : _props$isShowEditButt,
25
+ columnOption = props.columnOption,
26
+ addBtnText = props.addBtnText,
27
+ editBtnText = props.editBtnText,
28
+ onEditClick = props.onEditClick,
29
+ rechargeOptionRef = props.rechargeOptionRef,
30
+ sortModalProps = props.sortModalProps,
31
+ form = props.form;
32
+ var sortModalRef = useRef(null);
33
+ var genDefaultData = useCallback(function (others) {
34
+ return columnOption.reduce(function (acc, cur) {
35
+ return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, cur.field, ''));
36
+ }, _objectSpread({
37
+ key: getUniqueId()
38
+ }, others));
39
+ }, [columnOption]);
40
+ var initValue = useMemo(function () {
41
+ return genDefaultData({
42
+ id: 0
43
+ });
44
+ }, [columnOption]);
45
+ useImperativeHandle(rechargeOptionRef, function () {
46
+ return {
47
+ openSortModal: function openSortModal() {
48
+ var _sortModalRef$current;
49
+ (_sortModalRef$current = sortModalRef.current) === null || _sortModalRef$current === void 0 ? void 0 : _sortModalRef$current.showModal();
50
+ }
51
+ };
52
+ });
53
+ var handleSortModalOk = useCallback(function (list) {
54
+ var _sortModalRef$current2;
55
+ form.setFieldsValue(_defineProperty({}, name, list));
56
+ (_sortModalRef$current2 = sortModalRef.current) === null || _sortModalRef$current2 === void 0 ? void 0 : _sortModalRef$current2.hideModal();
57
+ }, [name]);
58
+ return /*#__PURE__*/_jsxs("div", {
59
+ children: [/*#__PURE__*/_jsxs("div", {
60
+ children: [/*#__PURE__*/_jsx(Row, {
61
+ gutter: 10,
62
+ style: {
63
+ marginBottom: '10px'
64
+ },
65
+ children: columnOption.map(function (item) {
66
+ return /*#__PURE__*/_jsx(Col, {
67
+ span: item.span,
68
+ children: item.label
69
+ }, item.label);
70
+ })
71
+ }), /*#__PURE__*/_jsx(Form.List, {
72
+ name: name,
73
+ initialValue: [initValue],
74
+ children: function children(fields, _ref) {
75
+ var add = _ref.add,
76
+ remove = _ref.remove;
77
+ return /*#__PURE__*/_jsxs(_Fragment, {
78
+ children: [fields.map(function (bundle, i) {
79
+ return /*#__PURE__*/_jsx(Form.Item, {
80
+ noStyle: true,
81
+ children: /*#__PURE__*/_jsxs(Row, {
82
+ gutter: 10,
83
+ children: [columnOption.map(function (item) {
84
+ return /*#__PURE__*/_jsx(Col, {
85
+ span: item.span,
86
+ children: /*#__PURE__*/_jsx(Form.Item, {
87
+ name: [bundle.name, item.field],
88
+ rules: item.rules,
89
+ children: /*#__PURE__*/_jsx(Input, {
90
+ style: {
91
+ width: '100%'
92
+ }
93
+ })
94
+ })
95
+ }, item.label);
96
+ }), isShowEditButton && /*#__PURE__*/_jsx(Col, {
97
+ span: 3,
98
+ children: /*#__PURE__*/_jsx(Button, {
99
+ onClick: function onClick() {
100
+ isFunction(onEditClick) && onEditClick(bundle);
101
+ },
102
+ children: editBtnText || getText('pisell-design.recharge.option.button.edit')
103
+ })
104
+ }), /*#__PURE__*/_jsx(Col, {
105
+ span: 2,
106
+ children: i !== 0 && /*#__PURE__*/_jsx(Button, {
107
+ icon: /*#__PURE__*/_jsx(DeleteOutlined, {}),
108
+ onClick: function onClick() {
109
+ remove(bundle.name);
110
+ }
111
+ })
112
+ })]
113
+ })
114
+ }, bundle.key);
115
+ }), /*#__PURE__*/_jsx(Button, {
116
+ onClick: function onClick() {
117
+ add(genDefaultData({
118
+ id: fields.length + 1
119
+ }));
120
+ },
121
+ children: addBtnText || getText('pisell-design.recharge.option.button.add')
122
+ })]
123
+ });
124
+ }
125
+ })]
126
+ }), /*#__PURE__*/_jsx(SortModal, {
127
+ isShowIndex: false,
128
+ field: sortModalProps === null || sortModalProps === void 0 ? void 0 : sortModalProps.field,
129
+ title: sortModalProps === null || sortModalProps === void 0 ? void 0 : sortModalProps.title,
130
+ items: form.getFieldValue(name) || [],
131
+ sortModalRef: sortModalRef,
132
+ onOk: handleSortModalOk
133
+ })]
134
+ });
135
+ };
136
+ export default RechargeOption;
@@ -0,0 +1,25 @@
1
+ import type { SelectProps } from 'antd';
2
+ import React from 'react';
3
+ import './index.less';
4
+ declare type BaseValue = string | number;
5
+ declare type ColorValue = {
6
+ color: string;
7
+ value: BaseValue;
8
+ label: string;
9
+ };
10
+ declare type Value = BaseValue | ColorValue;
11
+ export interface SelectTagProps<T> extends Omit<SelectProps, 'options'> {
12
+ selectTagRef?: React.MutableRefObject<{
13
+ showModal: () => void;
14
+ hideModal: () => void;
15
+ }>;
16
+ value?: T[];
17
+ onChange?: (value: T[]) => void;
18
+ isColorSelect?: boolean;
19
+ options: {
20
+ value: BaseValue;
21
+ label: string;
22
+ }[];
23
+ }
24
+ declare const SelectTag: <T extends Value>(props: SelectTagProps<T>) => JSX.Element;
25
+ export default SelectTag;
@@ -0,0 +1,180 @@
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 _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); }
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 _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; }
8
+ 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; }
9
+ 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; }
10
+ 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; }
11
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
12
+ 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); }
13
+ import { Select, Tag } from 'antd';
14
+ import React, { useCallback, useImperativeHandle, useMemo } from 'react';
15
+ import { useTagModal } from "../../business-hooks";
16
+ import DragSort from "../../components/DragSort";
17
+ import IconFont from "../../components/Iconfont";
18
+ import { getText } from "../../locales";
19
+ import { isArr, isFunction, isNumber, isString } from "../../utils";
20
+ import ColorInput from "../colorInput";
21
+ import "./index.less";
22
+ import { jsx as _jsx } from "react/jsx-runtime";
23
+ import { jsxs as _jsxs } from "react/jsx-runtime";
24
+ import { Fragment as _Fragment } from "react/jsx-runtime";
25
+ var defaultColor = '#000';
26
+ var prefix = 'pisell-';
27
+ var SelectTag = function SelectTag(props) {
28
+ var selectTagRef = props.selectTagRef,
29
+ value = props.value,
30
+ _onChange = props.onChange,
31
+ options = props.options,
32
+ isColorSelect = props.isColorSelect;
33
+ var tagValue = useMemo(function () {
34
+ if (!isArr(value)) {
35
+ return [];
36
+ }
37
+ if (value.every(function (item) {
38
+ return isString(item) || isNumber(item);
39
+ })) {
40
+ return value;
41
+ }
42
+ return value.map(function (item) {
43
+ return item.value;
44
+ });
45
+ }, [value]);
46
+ var valueColorMap = useMemo(function () {
47
+ if (!isColorSelect || !isArr(value)) {
48
+ return {};
49
+ }
50
+ return value.reduce(function (pre, cur) {
51
+ return _objectSpread(_objectSpread({}, pre), {}, _defineProperty({}, cur.value, cur.color));
52
+ }, {});
53
+ }, [value, options]);
54
+ var valueLabelMap = useMemo(function () {
55
+ return options.reduce(function (pre, cur) {
56
+ return _objectSpread(_objectSpread({}, pre), {}, _defineProperty({}, cur.value, cur.label));
57
+ }, {});
58
+ }, [options]);
59
+ var handleTagChange = useCallback(function (val) {
60
+ if (isColorSelect) {
61
+ var _value = val.map(function (item) {
62
+ return {
63
+ color: valueColorMap[item] || defaultColor,
64
+ value: item
65
+ };
66
+ });
67
+ isFunction(_onChange) && _onChange(_value);
68
+ return;
69
+ }
70
+ isFunction(_onChange) && _onChange(val);
71
+ }, [isColorSelect, _onChange, valueColorMap]);
72
+ var _useTagModal = useTagModal({
73
+ value: tagValue,
74
+ onChange: handleTagChange,
75
+ data: options,
76
+ onOk: function onOk() {
77
+ hideModal();
78
+ },
79
+ title: getText('pisell-design.select.tag.modal.title'),
80
+ onCancel: function onCancel() {
81
+ hideModal();
82
+ }
83
+ }),
84
+ content = _useTagModal.content,
85
+ hideModal = _useTagModal.hideModal,
86
+ visible = _useTagModal.visible,
87
+ showModal = _useTagModal.showModal;
88
+ useImperativeHandle(selectTagRef, function () {
89
+ return {
90
+ showModal: showModal,
91
+ hideModal: hideModal
92
+ };
93
+ });
94
+ var tagRender = function tagRender(props) {
95
+ var label = props.label,
96
+ value = props.value,
97
+ closable = props.closable,
98
+ onClose = props.onClose;
99
+ var onPreventMouseDown = function onPreventMouseDown(event) {
100
+ event.preventDefault();
101
+ event.stopPropagation();
102
+ };
103
+ return /*#__PURE__*/_jsx(Tag, {
104
+ onMouseDown: onPreventMouseDown,
105
+ closable: closable,
106
+ onClose: onClose,
107
+ className: "".concat(prefix, "select-tag"),
108
+ style: {
109
+ color: valueColorMap[value] || defaultColor
110
+ },
111
+ children: label
112
+ });
113
+ };
114
+ var handleSelectChange = useCallback(function (val) {
115
+ var newVal = val;
116
+ if (isColorSelect) {
117
+ newVal = val.map(function (item) {
118
+ return {
119
+ value: item,
120
+ color: valueColorMap[item] || defaultColor
121
+ };
122
+ });
123
+ }
124
+ isFunction(_onChange) && _onChange(newVal);
125
+ }, [isColorSelect, valueColorMap]);
126
+ var selectValue = useMemo(function () {
127
+ if (!isArr(value)) {
128
+ return [];
129
+ }
130
+ if (value.every(function (item) {
131
+ return isString(item) || isNumber(item);
132
+ })) {
133
+ return value;
134
+ }
135
+ if (isColorSelect) {
136
+ return value.map(function (item) {
137
+ return item.value;
138
+ });
139
+ }
140
+ }, [value, isColorSelect]);
141
+ return /*#__PURE__*/_jsxs(_Fragment, {
142
+ children: [/*#__PURE__*/_jsx(Select, _objectSpread(_objectSpread({}, props), {}, {
143
+ value: selectValue,
144
+ mode: "tags",
145
+ options: options,
146
+ onChange: handleSelectChange,
147
+ tagRender: tagRender
148
+ })), isColorSelect && /*#__PURE__*/_jsx(DragSort, {
149
+ list: value || [],
150
+ droppableId: "addressSort",
151
+ draggableIdKey: "value",
152
+ onChange: function onChange(_list) {
153
+ isFunction(_onChange) && _onChange(_list);
154
+ },
155
+ children: function children(item, index) {
156
+ return /*#__PURE__*/_jsxs("div", {
157
+ className: "".concat(prefix, "sort-item"),
158
+ children: [/*#__PURE__*/_jsx(IconFont, {
159
+ type: "icon-drag",
160
+ className: "".concat(prefix, "icon")
161
+ }), /*#__PURE__*/_jsx("span", {
162
+ className: "".concat(prefix, "sort-content"),
163
+ children: /*#__PURE__*/_jsx("span", {
164
+ className: "".concat(prefix, "tag-content"),
165
+ children: valueLabelMap[item.value]
166
+ })
167
+ }), /*#__PURE__*/_jsx(ColorInput, {
168
+ value: item.color,
169
+ onChange: function onChange(val) {
170
+ var _value = value ? _toConsumableArray(value) : [];
171
+ _value[index].color = val;
172
+ isFunction(_onChange) && _onChange(_value);
173
+ }
174
+ })]
175
+ }, item.value);
176
+ }
177
+ }), content]
178
+ });
179
+ };
180
+ export default SelectTag;
@@ -0,0 +1,22 @@
1
+ .pisell-sort-item {
2
+ display: flex;
3
+ align-items: center;
4
+ height: 50px;
5
+ margin-top: 12px;
6
+ line-height: 40px;
7
+ background-color: #f0f0f0;
8
+ .pisell-sort-content {
9
+ margin-right: 10px;
10
+ }
11
+ .pisell-icon {
12
+ color: #999;
13
+ font-size: 20px;
14
+ }
15
+ }
16
+
17
+ .pisell-select-tag {
18
+ margin: 0 3px 3px 0;
19
+ padding: 2px 8px;
20
+ font-size: 14px;
21
+ border-radius: 6px;
22
+ }
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import type { useModalProps } from '../../business-hooks/useModal';
3
+ import './index.less';
4
+ export interface SortModalProps<T> {
5
+ /** 排序数据 */
6
+ items: T[];
7
+ /** 弹窗标题 */
8
+ title: useModalProps['title'];
9
+ /** 自定义渲染内容 */
10
+ renderContent?: (items: T[], content: React.ReactNode) => React.ReactNode;
11
+ /** 自定义渲染排序项 */
12
+ renderSortItem?: (item: T, index: number) => React.ReactNode;
13
+ /** 是否展示序号 */
14
+ isShowIndex?: boolean;
15
+ /** 字段展示配置 */
16
+ field: {
17
+ id: keyof T;
18
+ name: keyof T;
19
+ key: keyof T;
20
+ };
21
+ /** 确认事件 返回调整后的顺序 */
22
+ onOk?: (list: T[]) => void;
23
+ /** 弹窗ref 可外部唤起弹窗 */
24
+ sortModalRef?: React.Ref<{
25
+ showModal: () => void;
26
+ hideModal: () => void;
27
+ }>;
28
+ }
29
+ declare const SortModal: <T extends Record<string, any>>(props: SortModalProps<T>) => JSX.Element;
30
+ export default SortModal;