@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
@@ -0,0 +1,85 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ 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."); }
3
+ 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); }
4
+ 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; }
5
+ 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; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import React, { useCallback, useEffect, useImperativeHandle, useMemo, useState } from 'react';
8
+ import { isFunction } from "../../utils";
9
+ import useModal from "../../business-hooks/useModal";
10
+ import { DragSort, IconFont } from "../../components";
11
+ import "./index.less";
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { jsxs as _jsxs } from "react/jsx-runtime";
14
+ var prefix = 'pisell-';
15
+ var SortModal = function SortModal(props) {
16
+ var title = props.title,
17
+ items = props.items,
18
+ renderSortItem = props.renderSortItem,
19
+ field = props.field,
20
+ isShowIndex = props.isShowIndex,
21
+ onOk = props.onOk,
22
+ sortModalRef = props.sortModalRef,
23
+ renderContent = props.renderContent;
24
+ var _useState = useState(items),
25
+ _useState2 = _slicedToArray(_useState, 2),
26
+ sortItems = _useState2[0],
27
+ setSortItems = _useState2[1];
28
+ useEffect(function () {
29
+ setSortItems(items);
30
+ }, [items]);
31
+ var RenderSortItem = useCallback(function (item, index) {
32
+ return /*#__PURE__*/_jsxs("div", {
33
+ className: "".concat(prefix, "sort-item"),
34
+ children: [/*#__PURE__*/_jsx(IconFont, {
35
+ type: "icon-drag",
36
+ className: "".concat(prefix, "item")
37
+ }), /*#__PURE__*/_jsxs("span", {
38
+ className: "".concat(prefix, "sort-content"),
39
+ children: [isShowIndex && index + 1, /*#__PURE__*/_jsx("span", {
40
+ className: "".concat(prefix, "tag-content"),
41
+ children: item[field.name]
42
+ })]
43
+ })]
44
+ }, item[field.key]);
45
+ }, [props]);
46
+ var ModalContent = useMemo(function () {
47
+ var content = /*#__PURE__*/_jsx(DragSort, {
48
+ list: sortItems,
49
+ droppableId: "addressSort",
50
+ draggableIdKey: field.id,
51
+ className: "".concat(prefix, "sort-list"),
52
+ onChange: function onChange(_list) {
53
+ setSortItems(_list);
54
+ },
55
+ children: isFunction(renderSortItem) ? renderSortItem : RenderSortItem
56
+ });
57
+ if (isFunction(renderContent)) {
58
+ return renderContent(sortItems, content);
59
+ }
60
+ if (renderContent) {
61
+ return renderContent;
62
+ }
63
+ return content;
64
+ }, [sortItems, renderSortItem, RenderSortItem, renderContent]);
65
+ var handleOk = useCallback(function () {
66
+ isFunction(onOk) && onOk(sortItems);
67
+ }, [onOk, sortItems]);
68
+ var _useModal = useModal({
69
+ children: ModalContent,
70
+ title: title,
71
+ onOk: handleOk
72
+ }),
73
+ content = _useModal.content,
74
+ hideModal = _useModal.hideModal,
75
+ visible = _useModal.visible,
76
+ showModal = _useModal.showModal;
77
+ useImperativeHandle(sortModalRef, function () {
78
+ return {
79
+ showModal: showModal,
80
+ hideModal: hideModal
81
+ };
82
+ });
83
+ return content;
84
+ };
85
+ export default SortModal;
@@ -0,0 +1,29 @@
1
+ .pisell-sort-list {
2
+ .pisell-sort-item {
3
+ display: flex;
4
+ align-items: center;
5
+ width: 100%;
6
+ min-width: 40px;
7
+ margin-bottom: 10px;
8
+ font-size: 16px;
9
+ text-align: center;
10
+ background: none;
11
+ border: none;
12
+ .pisell-sort-content {
13
+ display: flex;
14
+ width: 100%;
15
+ }
16
+
17
+ .pisell-icon {
18
+ margin-right: 6px;
19
+ font-size: 20px;
20
+ }
21
+
22
+ .pisell-tag-content {
23
+ flex: 1;
24
+ width: 100%;
25
+ text-align: left;
26
+ word-break: break-word;
27
+ }
28
+ }
29
+ }
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ export interface StatisticsOption {
4
+ label: string;
5
+ value: string;
6
+ }
7
+ export interface StatisticsProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> {
8
+ loading: boolean;
9
+ options: StatisticsOption[];
10
+ }
11
+ declare const Statistics: React.FC<Partial<StatisticsProps>>;
12
+ export default Statistics;
@@ -0,0 +1,38 @@
1
+ import React from 'react';
2
+ import { Skeleton } from 'antd';
3
+ import classNames from 'classnames';
4
+ import { useResponsive } from "../../hooks";
5
+ import "./index.less";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ import { jsxs as _jsxs } from "react/jsx-runtime";
8
+ var Statistics = function Statistics(props) {
9
+ var loading = props.loading,
10
+ _props$options = props.options,
11
+ options = _props$options === void 0 ? [] : _props$options;
12
+ var responsive = useResponsive();
13
+ return /*#__PURE__*/_jsx("div", {
14
+ className: classNames('pisell-statistics', 'pisell-scrollbar', props.className, {
15
+ 'phone-wrap': responsive === 'phone'
16
+ }),
17
+ style: props.style,
18
+ children: /*#__PURE__*/_jsx("div", {
19
+ className: 'pisell-statistics-options',
20
+ children: options.map(function (d, i) {
21
+ return /*#__PURE__*/_jsxs("div", {
22
+ className: 'pisell-statistics-item',
23
+ children: [/*#__PURE__*/_jsx("div", {
24
+ className: 'pisell-statistics-label',
25
+ children: d.label
26
+ }), /*#__PURE__*/_jsx("div", {
27
+ className: 'pisell-statistics-value',
28
+ children: loading ? /*#__PURE__*/_jsx(Skeleton.Input, {
29
+ active: true,
30
+ size: 'default'
31
+ }) : d.value
32
+ })]
33
+ }, i);
34
+ })
35
+ })
36
+ });
37
+ };
38
+ export default Statistics;
@@ -0,0 +1,64 @@
1
+ .pisell-statistics {
2
+ width: 100%;
3
+ overflow-y: auto;
4
+
5
+ &.phone-wrap {
6
+ overflow-y: hidden;
7
+
8
+ .pisell-statistics-options {
9
+ min-width: 100%;
10
+ display: block;
11
+
12
+ .pisell-statistics-item {
13
+ padding: 12px;
14
+ width: 100%;
15
+ margin-bottom: 20px;
16
+ border-bottom: 1px solid #ccc;
17
+
18
+ &::after {
19
+ display: none;
20
+ }
21
+ }
22
+ }
23
+ }
24
+
25
+ .pisell-statistics-options {
26
+ width: 100%;
27
+ min-width: 1000px;
28
+ display: flex;
29
+ align-items: flex-start;
30
+ justify-content: center;
31
+
32
+ .pisell-statistics-item {
33
+ flex: 1;
34
+ position: relative;
35
+ text-align: center;
36
+
37
+ &::after {
38
+ content: '';
39
+ position: absolute;
40
+ right: 0;
41
+ top: 50%;
42
+ transform: translate(-50%, -50%);
43
+ height: 40px;
44
+ width: 1px;
45
+ background-color: #ccc;
46
+ }
47
+
48
+ .pisell-statistics-label {
49
+ }
50
+
51
+ .pisell-statistics-value {
52
+ margin-top: 10px;
53
+ font-size: 26px;
54
+ // font-weight: 500;
55
+ }
56
+
57
+ &:last-child {
58
+ &::after {
59
+ display: none;
60
+ }
61
+ }
62
+ }
63
+ }
64
+ }
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import type { useModalProps } from '../../business-hooks/useModal';
3
+ export interface TagDataType<T> {
4
+ value: T;
5
+ label: string;
6
+ }
7
+ export interface TagModalProps<T> extends useModalProps {
8
+ data: TagDataType<T>[];
9
+ value: T[];
10
+ onChange: (value: T[]) => void;
11
+ tagModalRef: React.Ref<{
12
+ showModal: () => void;
13
+ hideModal: () => void;
14
+ }>;
15
+ }
16
+ declare const TagModal: <T extends string | number>(props: TagModalProps<T>) => JSX.Element;
17
+ export default TagModal;
@@ -0,0 +1,59 @@
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
+ var _excluded = ["data", "onChange", "value", "tagModalRef"];
3
+ 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; }
4
+ 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; }
5
+ 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; }
6
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
7
+ 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); }
8
+ 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; }
9
+ 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; }
10
+ import React, { useImperativeHandle, useMemo } from 'react';
11
+ import { Checkbox, Col, Row } from 'antd';
12
+ import useModal from "../../business-hooks/useModal";
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ var TagModal = function TagModal(props) {
15
+ var data = props.data,
16
+ _onChange = props.onChange,
17
+ value = props.value,
18
+ tagModalRef = props.tagModalRef,
19
+ others = _objectWithoutProperties(props, _excluded);
20
+ var Content = useMemo(function () {
21
+ return /*#__PURE__*/_jsx(Checkbox.Group, {
22
+ style: {
23
+ width: '100%'
24
+ },
25
+ onChange: function onChange(val) {
26
+ return _onChange(val);
27
+ },
28
+ value: value,
29
+ children: /*#__PURE__*/_jsx(Row, {
30
+ gutter: 10,
31
+ children: data.map(function (d, i) {
32
+ return /*#__PURE__*/_jsx(Col, {
33
+ span: 8,
34
+ children: /*#__PURE__*/_jsx(Checkbox, {
35
+ value: d.value,
36
+ children: d.label
37
+ })
38
+ }, i);
39
+ })
40
+ })
41
+ });
42
+ }, [data]);
43
+ var _useModal = useModal(_objectSpread(_objectSpread({}, others), {}, {
44
+ children: Content,
45
+ destroyOnClose: true
46
+ })),
47
+ showModal = _useModal.showModal,
48
+ visible = _useModal.visible,
49
+ hideModal = _useModal.hideModal,
50
+ content = _useModal.content;
51
+ useImperativeHandle(tagModalRef, function () {
52
+ return {
53
+ showModal: showModal,
54
+ hideModal: hideModal
55
+ };
56
+ });
57
+ return content;
58
+ };
59
+ export default TagModal;
@@ -0,0 +1,2 @@
1
+ export { default as useModal } from './useModal';
2
+ export { default as useTagModal } from './useTagModal';
@@ -0,0 +1,2 @@
1
+ export { default as useModal } from "./useModal";
2
+ export { default as useTagModal } from "./useTagModal";
@@ -0,0 +1,31 @@
1
+ import { ModalProps } from 'node_modules/antd/lib/modal/Modal.d';
2
+ import React from 'react';
3
+ /**
4
+ * @Title: 传入参数
5
+ * @Describe: 其余参数与Modal一致
6
+ * @Author: Wzw
7
+ */
8
+ export interface useModalProps extends ModalProps {
9
+ /**
10
+ * @description 属性描述
11
+ * @default "默认值"
12
+ */
13
+ children: React.ReactNode;
14
+ /**
15
+ * @description 取消事件,不传则执行关闭事件
16
+ * @default "默认值"
17
+ */
18
+ onCancel: () => void;
19
+ /**
20
+ * @description 确认事件,不传则执行关闭事件
21
+ * @default "默认值"
22
+ */
23
+ onOk: () => void;
24
+ }
25
+ declare const useModal: (props: Partial<useModalProps>) => {
26
+ showModal: () => void;
27
+ hideModal: () => void;
28
+ visible: boolean;
29
+ content: JSX.Element;
30
+ };
31
+ export default useModal;
@@ -0,0 +1,91 @@
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
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
+ 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."); }
9
+ 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); }
10
+ 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; }
11
+ 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; } }
12
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
+ /*
14
+ * @Title: useModal hooks
15
+ * @Describe: 基于Modal 封装 visible 以及Modal创建, 只需传入children
16
+ * @Author: Wzw
17
+ * @Date: 2021-03-30 15:21:58
18
+ * @LastEditors: wzw 445595671@qq.com
19
+ * @LastEditTime: 2022-11-14 09:30
20
+ */
21
+ import { Modal } from 'antd';
22
+ import React, { useState } from 'react';
23
+
24
+ /**
25
+ * @Title: 传入参数
26
+ * @Describe: 其余参数与Modal一致
27
+ * @Author: Wzw
28
+ */
29
+ import { jsx as _jsx } from "react/jsx-runtime";
30
+ var useModal = function useModal(props) {
31
+ var _useState = useState(false),
32
+ _useState2 = _slicedToArray(_useState, 2),
33
+ visible = _useState2[0],
34
+ setVisible = _useState2[1];
35
+
36
+ /**
37
+ * @Title: 打开弹窗
38
+ * @Describe:
39
+ * @Author: Wzw
40
+ */
41
+ var showModal = function showModal() {
42
+ setVisible(true);
43
+ };
44
+
45
+ /**
46
+ * @Title: 关闭弹窗
47
+ * @Describe:
48
+ * @Author: Wzw
49
+ */
50
+ var hideModal = function hideModal() {
51
+ setVisible(false);
52
+ };
53
+ /**
54
+ * @Title: OK事件
55
+ * @Describe:
56
+ * @Author: Wzw
57
+ */
58
+ var _onOk = function _onOk() {
59
+ if (props.onOk) {
60
+ props.onOk();
61
+ } else {
62
+ hideModal();
63
+ }
64
+ };
65
+
66
+ /**
67
+ * @Title: cancel事件
68
+ * @Describe:
69
+ * @Author: Wzw
70
+ */
71
+ var _onCancel = function _onCancel() {
72
+ if (props.onCancel) {
73
+ props.onCancel();
74
+ } else {
75
+ hideModal();
76
+ }
77
+ };
78
+ return {
79
+ showModal: showModal,
80
+ hideModal: hideModal,
81
+ visible: visible,
82
+ content: /*#__PURE__*/_jsx(Modal, _objectSpread(_objectSpread({
83
+ open: visible,
84
+ onOk: _onOk,
85
+ onCancel: _onCancel
86
+ }, props), {}, {
87
+ children: props.children
88
+ }))
89
+ };
90
+ };
91
+ export default useModal;
File without changes
@@ -0,0 +1,17 @@
1
+ import { useModalProps } from '../useModal';
2
+ export interface TagDataType<T> {
3
+ value: T;
4
+ label: string;
5
+ }
6
+ export interface UseTagModalProps<T> extends Omit<useModalProps, 'children'> {
7
+ data: TagDataType<T>[];
8
+ value: T[];
9
+ onChange?: (value: T[]) => void;
10
+ }
11
+ declare const useTagModal: <T extends string | number>(props: UseTagModalProps<T>) => {
12
+ showModal: () => void;
13
+ hideModal: () => void;
14
+ visible: boolean;
15
+ content: JSX.Element;
16
+ };
17
+ export default useTagModal;
@@ -0,0 +1,47 @@
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
+ var _excluded = ["data", "onChange", "value"];
3
+ 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; }
4
+ 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; }
5
+ 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; }
6
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
7
+ 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); }
8
+ 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; }
9
+ 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; }
10
+ import useModal from "../useModal";
11
+ import React, { useMemo } from 'react';
12
+ import { Checkbox, Col, Row } from 'antd';
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ var useTagModal = function useTagModal(props) {
15
+ var data = props.data,
16
+ _onChange = props.onChange,
17
+ value = props.value,
18
+ others = _objectWithoutProperties(props, _excluded);
19
+ var Content = useMemo(function () {
20
+ return /*#__PURE__*/_jsx(Checkbox.Group, {
21
+ style: {
22
+ width: '100%'
23
+ },
24
+ onChange: function onChange(val) {
25
+ return _onChange === null || _onChange === void 0 ? void 0 : _onChange(val);
26
+ },
27
+ value: value,
28
+ children: /*#__PURE__*/_jsx(Row, {
29
+ gutter: 10,
30
+ children: data.map(function (d, i) {
31
+ return /*#__PURE__*/_jsx(Col, {
32
+ span: 8,
33
+ children: /*#__PURE__*/_jsx(Checkbox, {
34
+ value: d.value,
35
+ children: d.label
36
+ })
37
+ }, i);
38
+ })
39
+ })
40
+ });
41
+ }, [data, value]);
42
+ var modalResult = useModal(_objectSpread(_objectSpread({}, others), {}, {
43
+ children: Content
44
+ }));
45
+ return modalResult;
46
+ };
47
+ export default useTagModal;
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ export interface ColorPickerProps {
4
+ keyName?: string;
5
+ /**
6
+ * @description 属性描述
7
+ * @default "默认值"
8
+ */
9
+ value: string;
10
+ /**
11
+ * @description 属性描述
12
+ * @default "默认值"
13
+ */
14
+ onChange: (val: any) => void;
15
+ /**
16
+ * @description 属性描述
17
+ * @default "默认值"
18
+ */
19
+ children?: React.ReactNode;
20
+ }
21
+ declare const ColorPicker: React.FC<ColorPickerProps>;
22
+ export default ColorPicker;
@@ -0,0 +1,51 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ 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."); }
3
+ 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); }
4
+ 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; }
5
+ 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; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import { Popover } from 'antd';
8
+ import React, { useEffect, useState } from 'react';
9
+ //@ts-ignore
10
+ import { SwatchesPicker } from 'react-color';
11
+ import "./index.less";
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ var ColorPicker = function ColorPicker(_ref) {
14
+ var keyName = _ref.keyName,
15
+ value = _ref.value,
16
+ onChange = _ref.onChange,
17
+ children = _ref.children;
18
+ var _useState = useState(value),
19
+ _useState2 = _slicedToArray(_useState, 2),
20
+ val = _useState2[0],
21
+ setVal = _useState2[1];
22
+
23
+ //颜色改变
24
+ var handleChange = function handleChange(e) {
25
+ setVal(e[keyName]);
26
+ };
27
+ //确认颜色
28
+ var handleConfirm = function handleConfirm(e) {
29
+ console.log(2);
30
+ onChange && onChange(e[keyName]);
31
+ };
32
+ useEffect(function () {
33
+ setVal(value);
34
+ }, [value]);
35
+ return /*#__PURE__*/_jsx(Popover, {
36
+ trigger: "click",
37
+ overlayClassName: "colorPickerBtn-Popover",
38
+ placement: "rightTop",
39
+ content: /*#__PURE__*/_jsx(SwatchesPicker, {
40
+ triangle: "hide",
41
+ color: val,
42
+ onChange: handleChange,
43
+ onChangeComplete: handleConfirm
44
+ }),
45
+ children: children
46
+ });
47
+ };
48
+ ColorPicker.defaultProps = {
49
+ keyName: 'hex'
50
+ };
51
+ export default ColorPicker;
@@ -0,0 +1,17 @@
1
+ .colorPickerBtn-Popover {
2
+ .ant-popover-inner-content {
3
+ padding: 0 0 0 0;
4
+ }
5
+
6
+ .ant-popover-arrow {
7
+ display: none;
8
+ }
9
+ }
10
+
11
+ .sketch-picker {
12
+ .flexbox-fix:nth-of-type(3) {
13
+ div:nth-of-type(5) {
14
+ display: none;
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,2 @@
1
+ declare const DragDrop: ({ onChange, children, list, droppableId, draggableIdKey, droppableClassName, draggableClassName, footer, direction, isDragDisabled, }: any) => JSX.Element;
2
+ export default DragDrop;