@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,74 @@
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: 二次封装useTable
15
+ * @Describe: 传入 isCaChe 则缓存请求的参数, 防止刷新页面参数重置
16
+ * @Author: Wzw
17
+ * @Date: 2021-04-07 14:42:28
18
+ * @LastEditors: wanghan 1556042996@qq.com
19
+ * @LastEditTime: 2022-07-30 17:58
20
+ */
21
+ import { useEffect } from 'react';
22
+ import { useAntdTable } from 'ahooks';
23
+ import useUrlState from "../useUrlState";
24
+ var useTable = function useTable(service, options) {
25
+ var _useUrlState = useUrlState({}),
26
+ _useUrlState2 = _slicedToArray(_useUrlState, 2),
27
+ urlParams = _useUrlState2[0],
28
+ setUrlParams = _useUrlState2[1];
29
+ var table = useAntdTable(service, _objectSpread(_objectSpread({
30
+ throwOnError: true
31
+ }, options), {}, {
32
+ onSuccess: function onSuccess(data, params) {
33
+ //如果传入isCaChe, 则缓存参数
34
+ if (options.isCaChe) {
35
+ setParams(params);
36
+ }
37
+ if (typeof options.onSuccess === 'function') {
38
+ options.onSuccess(data, params, urlParams);
39
+ }
40
+ }
41
+ }));
42
+
43
+ /**
44
+ * @Title: 储存url参数
45
+ * @Describe:
46
+ * @Author: Wzw
47
+ * @param {any} params
48
+ */
49
+ var setParams = function setParams(params) {
50
+ //翻页参数
51
+ var _pagination = params[0];
52
+ //form参数
53
+ var _formData = params[1];
54
+ var _newParams = {
55
+ skip: (_pagination === null || _pagination === void 0 ? void 0 : _pagination.current) || 1,
56
+ num: (_pagination === null || _pagination === void 0 ? void 0 : _pagination.pageSize) || 10
57
+ };
58
+ for (var _i2 = 0, _Object$entries = Object.entries(_formData); _i2 < _Object$entries.length; _i2++) {
59
+ var item = _Object$entries[_i2];
60
+ if (item[1] !== undefined) {
61
+ _newParams[item[0]] = item[1];
62
+ }
63
+ }
64
+ setUrlParams(_objectSpread({}, _newParams));
65
+ };
66
+ useEffect(function () {
67
+ //组件卸载时取消请求
68
+ return function () {
69
+ table.cancel();
70
+ };
71
+ }, []);
72
+ return table;
73
+ };
74
+ export default useTable;
File without changes
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ /**
3
+ * @Title: 传入参数
4
+ * @Describe: 其余参数与Modal一致
5
+ * @Author: Wzw
6
+ */
7
+ interface useModalProps {
8
+ children: React.ReactNode;
9
+ title: React.ReactNode;
10
+ }
11
+ declare const useTableModal: (props: Partial<useModalProps>) => JSX.Element;
12
+ export default useTableModal;
@@ -0,0 +1,25 @@
1
+ /*
2
+ * @Title: useModal hooks
3
+ * @Describe: 基于Modal 封装 visible 以及Modal创建, 只需传入children
4
+ * @Author: Wzw
5
+ * @Date: 2021-03-30 15:21:58
6
+ * @LastEditors: zhiwei.wang 445595671@qq.com
7
+ * @LastEditTime: 2023-02-21 10:29
8
+ */
9
+ import React from 'react';
10
+ import useModal from "../../business-hooks/useModal";
11
+ /**
12
+ * @Title: 传入参数
13
+ * @Describe: 其余参数与Modal一致
14
+ * @Author: Wzw
15
+ */
16
+ import { Fragment as _Fragment } from "react/jsx-runtime";
17
+ import { jsx as _jsx } from "react/jsx-runtime";
18
+ var useTableModal = function useTableModal(props) {
19
+ var _useModal = useModal({}),
20
+ content = _useModal.content;
21
+ return /*#__PURE__*/_jsx(_Fragment, {
22
+ children: content
23
+ });
24
+ };
25
+ export default useTableModal;
File without changes
@@ -0,0 +1,2 @@
1
+ declare const useUrlState: <T extends object>(defaultState: T) => readonly [T, (states: any) => void];
2
+ export default useUrlState;
@@ -0,0 +1,56 @@
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: 将state参数push到路径中
15
+ * @Describe:
16
+ * @Author: Wzw
17
+ * @Date: 2021-04-30 09:16:38
18
+ * @LastEditors: Wzw
19
+ * @LastEditTime: 2021-08-02 17:44:01
20
+ */
21
+
22
+ import { history } from 'umi';
23
+ import { useCallback, useEffect, useState } from 'react';
24
+ import { usePersistFn } from 'ahooks';
25
+ var useUrlState = function useUrlState(defaultState) {
26
+ var mergeQueryAndDefault = usePersistFn(function (query) {
27
+ var tempState = {};
28
+ Object.keys(defaultState).forEach(function (k) {
29
+ if (k in query) {
30
+ tempState[k] = query[k];
31
+ } else {
32
+ //@ts-ignore
33
+ tempState[k] = defaultState[k];
34
+ }
35
+ });
36
+ return tempState;
37
+ });
38
+ var _useState = useState(function () {
39
+ return mergeQueryAndDefault(history.location.query);
40
+ }),
41
+ _useState2 = _slicedToArray(_useState, 2),
42
+ state = _useState2[0],
43
+ setState = _useState2[1];
44
+ useEffect(function () {
45
+ return history.listen(function (location) {
46
+ setState(mergeQueryAndDefault(location.query));
47
+ });
48
+ }, [mergeQueryAndDefault]);
49
+ var setUrlState = useCallback(function (states) {
50
+ history.replace({
51
+ query: _objectSpread({}, states)
52
+ });
53
+ }, []);
54
+ return [state, setUrlState];
55
+ };
56
+ export default useUrlState;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @Description: WebSocket hooks
3
+ * @Author: wzw
4
+ * @Date: 2020-11-26 14:00:23
5
+ * @param {*}
6
+ * @return {*}
7
+ */
8
+ declare const useWebSocket: ({ onopen, onerror, onmessage, onclose }: any) => {
9
+ createWebSocket: () => void;
10
+ closeWebSocket: () => void;
11
+ websocket: any;
12
+ };
13
+ export default useWebSocket;
@@ -0,0 +1,121 @@
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 { useRef, useState } from 'react';
8
+ import { getConfig } from "../../config";
9
+
10
+ /**
11
+ * @Description: WebSocket hooks
12
+ * @Author: wzw
13
+ * @Date: 2020-11-26 14:00:23
14
+ * @param {*}
15
+ * @return {*}
16
+ */
17
+ var useWebSocket = function useWebSocket(_ref) {
18
+ var onopen = _ref.onopen,
19
+ onerror = _ref.onerror,
20
+ onmessage = _ref.onmessage,
21
+ onclose = _ref.onclose;
22
+ var websocket = useRef();
23
+ var time = useRef();
24
+ var _useState = useState(3),
25
+ _useState2 = _slicedToArray(_useState, 2),
26
+ reconnectNum = _useState2[0],
27
+ setReconnectNum = _useState2[1];
28
+ /**
29
+ * @Description: 创建一个socket
30
+ * @Author: wzw
31
+ * @Date: 2020-12-07 09:06:39
32
+ * @param {*}
33
+ * @return {*}
34
+ */
35
+ var createWebSocket = function createWebSocket() {
36
+ websocket.current = new WebSocket(getConfig().ENV.socket);
37
+ websocket.current.onopen = function (e) {
38
+ console.log('open');
39
+ if (typeof onopen === 'function') {
40
+ onopen(e);
41
+ }
42
+ socketTimeOut();
43
+ };
44
+ websocket.current.onerror = function (e) {
45
+ console.log('error');
46
+ reconnect();
47
+ if (typeof onerror === 'function') {
48
+ onerror(e);
49
+ }
50
+ };
51
+ websocket.current.onmessage = function (e) {
52
+ console.log('message', e);
53
+ if (typeof onmessage === 'function') {
54
+ onmessage(e);
55
+ }
56
+ };
57
+ websocket.current.onclose = function (e) {
58
+ console.log('close');
59
+ if (typeof onclose === 'function') {
60
+ onclose(e);
61
+ }
62
+ };
63
+ };
64
+ /**
65
+ * @Description: 失败重连
66
+ * @Author: wzw
67
+ * @Date: 2020-12-07 09:06:53
68
+ * @param {*}
69
+ * @return {*}
70
+ */
71
+ var reconnect = function reconnect() {
72
+ if (reconnectNum === 0) {
73
+ return;
74
+ }
75
+ setReconnectNum(reconnectNum - 1);
76
+ createWebSocket();
77
+ };
78
+ /**
79
+ * @Description: 心跳
80
+ * @Author: wzw
81
+ * @Date: 2020-12-07 09:07:00
82
+ * @param {*}
83
+ * @return {*}
84
+ */
85
+ var socketTimeOut = function socketTimeOut() {
86
+ clearTimeout(time.current);
87
+ if (websocket.current && websocket.current.readyState === 1) {
88
+ // 每30s 发送一条信息
89
+ time.current = setTimeout(function () {
90
+ console.log('ping');
91
+ websocket.current.send(JSON.stringify({
92
+ type: 'ping'
93
+ }));
94
+ socketTimeOut();
95
+ }, 30000);
96
+ }
97
+ };
98
+ var closeWebSocket = function closeWebSocket() {
99
+ _reset();
100
+ };
101
+ /**
102
+ * @Description: 关闭socket
103
+ * @Author: wzw
104
+ * @Date: 2020-12-07 09:08:10
105
+ * @param {*}
106
+ * @return {*}
107
+ */
108
+ var _reset = function _reset() {
109
+ if (websocket.current) {
110
+ websocket.current.close();
111
+ }
112
+ setReconnectNum(3);
113
+ clearTimeout(time.current);
114
+ };
115
+ return {
116
+ createWebSocket: createWebSocket,
117
+ closeWebSocket: closeWebSocket,
118
+ websocket: websocket.current
119
+ };
120
+ };
121
+ export default useWebSocket;
package/es/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from './business-components';
2
+ export * from './business-hooks';
3
+ export * from './components';
4
+ export * from './hooks';
package/es/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export * from "./business-components";
2
+ export * from "./business-hooks";
3
+ export * from "./components";
4
+ export * from "./hooks";
@@ -0,0 +1,11 @@
1
+ declare const _default: {
2
+ 'pisell-design.multi-select.apply': string;
3
+ 'pisell-design.multi-select.apply.no-data': string;
4
+ 'pisell-design.paginator.previous': string;
5
+ 'pisell-design.paginator.next': string;
6
+ 'pisell-design.search.search': string;
7
+ 'pisell-design.recharge.option.button.edit': string;
8
+ 'pisell-design.recharge.option.button.add': string;
9
+ 'pisell-design.select.tag.modal.title': string;
10
+ };
11
+ export default _default;
@@ -0,0 +1,10 @@
1
+ export default {
2
+ 'pisell-design.multi-select.apply': 'Apply',
3
+ 'pisell-design.multi-select.apply.no-data': 'Sorry, no products matched your selection',
4
+ 'pisell-design.paginator.previous': 'Previous',
5
+ 'pisell-design.paginator.next': 'Next',
6
+ 'pisell-design.search.search': 'Search',
7
+ 'pisell-design.recharge.option.button.edit': 'Edit',
8
+ 'pisell-design.recharge.option.button.add': 'Add recharge item',
9
+ 'pisell-design.select.tag.modal.title': 'Select tag'
10
+ };
@@ -0,0 +1 @@
1
+ export declare const getText: (id: string) => any;
@@ -0,0 +1,23 @@
1
+ import zhCN from "../locales/zh-CN";
2
+ import zhTW from "../locales/zh-TW";
3
+ import enUS from "../locales/en-US";
4
+ import { getStorage } from "../utils/storage";
5
+ var langMap = {
6
+ 'zh-CN': zhCN,
7
+ 'en-US': enUS,
8
+ 'zh-TW': zhTW
9
+ };
10
+ export var getText = function getText(id) {
11
+ if (!id) {
12
+ return '';
13
+ }
14
+ var locale = 'en-US';
15
+ var oldLocale = getStorage('umi_locale');
16
+ if (oldLocale) {
17
+ locale = oldLocale;
18
+ }
19
+ console.log('locale', getStorage('umi_locale'));
20
+
21
+ //@ts-ignore
22
+ return langMap[locale] ? langMap[locale][id] || id : id;
23
+ };
@@ -0,0 +1,11 @@
1
+ declare const _default: {
2
+ 'pisell-design.multi-select.apply': string;
3
+ 'pisell-design.multi-select.apply.no-data': string;
4
+ 'pisell-design.paginator.previous': string;
5
+ 'pisell-design.paginator.next': string;
6
+ 'pisell-design.search.search': string;
7
+ 'pisell-design.recharge.option.button.edit': string;
8
+ 'pisell-design.recharge.option.button.add': string;
9
+ 'pisell-design.select.tag.modal.title': string;
10
+ };
11
+ export default _default;
@@ -0,0 +1,10 @@
1
+ export default {
2
+ 'pisell-design.multi-select.apply': '应用',
3
+ 'pisell-design.multi-select.apply.no-data': '对不起,没有符合您选择的产品',
4
+ 'pisell-design.paginator.previous': '上一页',
5
+ 'pisell-design.paginator.next': '下一页',
6
+ 'pisell-design.search.search': '搜索',
7
+ 'pisell-design.recharge.option.button.edit': '编辑',
8
+ 'pisell-design.recharge.option.button.add': '添加充值项',
9
+ 'pisell-design.select.tag.modal.title': '选择标签'
10
+ };
@@ -0,0 +1,11 @@
1
+ declare const _default: {
2
+ 'pisell-design.multi-select.apply': string;
3
+ 'pisell-design.multi-select.apply.no-data': string;
4
+ 'pisell-design.paginator.previous': string;
5
+ 'pisell-design.paginator.next': string;
6
+ 'pisell-design.search.search': string;
7
+ 'pisell-design.recharge.option.button.edit': string;
8
+ 'pisell-design.recharge.option.button.add': string;
9
+ 'pisell-design.select.tag.modal.title': string;
10
+ };
11
+ export default _default;
@@ -0,0 +1,10 @@
1
+ export default {
2
+ 'pisell-design.multi-select.apply': '應用',
3
+ 'pisell-design.multi-select.apply.no-data': '對不起,沒有符合您選擇的產品',
4
+ 'pisell-design.paginator.previous': '上一頁',
5
+ 'pisell-design.paginator.next': '下一頁',
6
+ 'pisell-design.search.search': '搜索',
7
+ 'pisell-design.recharge.option.button.edit': '編輯',
8
+ 'pisell-design.recharge.option.button.add': '添加充值項',
9
+ 'pisell-design.select.tag.modal.title': '選擇標籤'
10
+ };
@@ -0,0 +1,3 @@
1
+ export * from './otherUtils';
2
+ export * from './storage';
3
+ export * from './typeUtils';
@@ -0,0 +1,3 @@
1
+ export * from "./otherUtils";
2
+ export * from "./storage";
3
+ export * from "./typeUtils";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @Description: 生成唯一id
3
+ * @Author: wzw
4
+ * @Date: 2020-12-01 14:20:29
5
+ * @param {*}
6
+ * @return {*}
7
+ */
8
+ export declare const getUniqueId: (prefix?: string, maxLength?: number) => string;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @Description: 生成唯一id
3
+ * @Author: wzw
4
+ * @Date: 2020-12-01 14:20:29
5
+ * @param {*}
6
+ * @return {*}
7
+ */
8
+ export var getUniqueId = function getUniqueId() {
9
+ var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
10
+ var maxLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 11;
11
+ return prefix + (Math.random() + '').replace(/\D/g, '').substring(0, maxLength);
12
+ };
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @title: 设置storage
3
+ * @description:
4
+ * @param {*} T
5
+ * @param {*} param2
6
+ * @return {*}
7
+ * @Author: Wzw
8
+ * @Date: 2022-02-21 10:30
9
+ */
10
+ export declare const setStorage: (key: string, value: any, type?: 'local' | 'session', prefix?: string) => any;
11
+ /**
12
+ * @title: 获取storage
13
+ * @description:
14
+ * @param {string} key
15
+ * @param {string} prefix
16
+ * @return {*}
17
+ * @Author: Wzw
18
+ * @Date: 2022-02-21 10:30
19
+ */
20
+ export declare const getStorage: (key: string, prefix?: string, type?: 'local' | 'session') => any;
21
+ /**
22
+ * @title: 删除storage
23
+ * @description:
24
+ * @param {string} key
25
+ * @param {string} prefix
26
+ * @return {*}
27
+ * @Author: Wzw
28
+ * @Date: 2022-02-21 10:30
29
+ */
30
+ export declare const removeStorage: (key: string, prefix?: string, type?: 'local' | 'session') => void;
@@ -0,0 +1,70 @@
1
+ var default_prefix = 'shop_';
2
+ /**
3
+ * @title: 设置storage
4
+ * @description:
5
+ * @param {*} T
6
+ * @param {*} param2
7
+ * @return {*}
8
+ * @Author: Wzw
9
+ * @Date: 2022-02-21 10:30
10
+ */
11
+ export var setStorage = function setStorage(key, value, type, prefix) {
12
+ var _value = value;
13
+
14
+ // 增加前缀, 防止与其他项目混合
15
+ var _key = (prefix || default_prefix) + key;
16
+
17
+ // 区分是 local 还是 session
18
+ if (type === undefined || type === 'local') {
19
+ localStorage.setItem(_key, _value);
20
+ } else {
21
+ sessionStorage.setItem(_key, _value);
22
+ }
23
+ };
24
+
25
+ /**
26
+ * @title: 获取storage
27
+ * @description:
28
+ * @param {string} key
29
+ * @param {string} prefix
30
+ * @return {*}
31
+ * @Author: Wzw
32
+ * @Date: 2022-02-21 10:30
33
+ */
34
+ export var getStorage = function getStorage(key, prefix, type) {
35
+ // 增加前缀, 防止与其他项目混合
36
+ var _key = (prefix || default_prefix) + key;
37
+ if (key === 'umi_locale') {
38
+ _key = key;
39
+ }
40
+
41
+ // 区分是 local 还是 session
42
+ if (type === undefined || type === 'local') {
43
+ var _localValue = localStorage.getItem(_key) || '';
44
+ return _localValue;
45
+ } else {
46
+ var _sessionValue = sessionStorage.getItem(_key) || '';
47
+ return _sessionValue;
48
+ }
49
+ };
50
+
51
+ /**
52
+ * @title: 删除storage
53
+ * @description:
54
+ * @param {string} key
55
+ * @param {string} prefix
56
+ * @return {*}
57
+ * @Author: Wzw
58
+ * @Date: 2022-02-21 10:30
59
+ */
60
+ export var removeStorage = function removeStorage(key, prefix, type) {
61
+ // 增加前缀, 防止与其他项目混合
62
+ var _key = (prefix || default_prefix) + key;
63
+
64
+ // 区分是 local 还是 session
65
+ if (type === undefined || type === 'local') {
66
+ localStorage.removeItem(_key);
67
+ } else {
68
+ sessionStorage.removeItem(_key);
69
+ }
70
+ };
@@ -0,0 +1,42 @@
1
+ /**
2
+ * 判断是否是函数
3
+ * @param obj
4
+ */
5
+ export declare const isFunction: (obj: any) => obj is Function;
6
+ /**
7
+ * 判断是否是数组
8
+ * @param obj
9
+ */
10
+ export declare const isArr: (obj: any) => obj is any[];
11
+ /**
12
+ * 判断是否是字符串
13
+ * @param obj
14
+ */
15
+ export declare const isString: (obj: any) => obj is string;
16
+ /**
17
+ * 判断是否是数字
18
+ * @param obj
19
+ */
20
+ export declare const isNumber: (obj: any) => obj is number;
21
+ /**
22
+ * 判断是否是undefined
23
+ * @param obj
24
+ */
25
+ export declare const isUndefined: (obj: any) => obj is undefined;
26
+ /**
27
+ * 判断是否是boolean
28
+ * @param obj
29
+ */
30
+ export declare const isBoolean: (obj: any) => obj is boolean;
31
+ /**
32
+ * 判断是否是json字符串
33
+ * @param v
34
+ */
35
+ export declare const isJson: (v: any) => boolean;
36
+ /**
37
+ * @Title: 判断是否为对象
38
+ * @Describe:
39
+ * @Author: Wzw
40
+ * @param {any} obj
41
+ */
42
+ export declare const isPlainObject: (obj: any) => boolean;