@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.
- package/LICENSE +21 -0
- package/README.md +40 -0
- package/es/business-components/colorInput/index.d.ts +21 -0
- package/es/business-components/colorInput/index.js +43 -0
- package/es/business-components/colorInput/index.less +10 -0
- package/es/business-components/index.d.ts +11 -0
- package/es/business-components/index.js +7 -0
- package/es/business-components/rechargeOption/index.d.ts +36 -0
- package/es/business-components/rechargeOption/index.js +136 -0
- package/es/business-components/rechargeOption/index.less +0 -0
- package/es/business-components/selectTag/index.d.ts +25 -0
- package/es/business-components/selectTag/index.js +180 -0
- package/es/business-components/selectTag/index.less +22 -0
- package/es/business-components/sortModal/index.d.ts +30 -0
- package/es/business-components/sortModal/index.js +85 -0
- package/es/business-components/sortModal/index.less +29 -0
- package/es/business-components/statistics/index.d.ts +12 -0
- package/es/business-components/statistics/index.js +38 -0
- package/es/business-components/statistics/index.less +64 -0
- package/es/business-components/tagModal/index.d.ts +17 -0
- package/es/business-components/tagModal/index.js +59 -0
- package/es/business-hooks/index.d.ts +2 -0
- package/es/business-hooks/index.js +2 -0
- package/es/business-hooks/useModal/index.d.ts +31 -0
- package/es/business-hooks/useModal/index.js +91 -0
- package/es/business-hooks/useModal/index.less +0 -0
- package/es/business-hooks/useTagModal/index.d.ts +17 -0
- package/es/business-hooks/useTagModal/index.js +47 -0
- package/es/components/ColorPicker/index.d.ts +22 -0
- package/es/components/ColorPicker/index.js +51 -0
- package/es/components/ColorPicker/index.less +17 -0
- package/es/components/DragSort/index.d.ts +2 -0
- package/es/components/DragSort/index.js +68 -0
- package/es/components/Iconfont/index.d.ts +6 -0
- package/es/components/Iconfont/index.js +28 -0
- package/es/components/Iconfont/index.less +0 -0
- package/es/components/card/index.d.ts +5 -0
- package/es/components/card/index.js +16 -0
- package/es/components/card/index.less +9 -0
- package/es/components/index.d.ts +4 -0
- package/es/components/index.js +4 -0
- package/es/config/index.d.ts +16 -0
- package/es/config/index.js +18 -0
- package/es/config/utils.d.ts +0 -0
- package/es/config/utils.js +0 -0
- package/es/hooks/index.d.ts +8 -0
- package/es/hooks/index.js +8 -0
- package/es/hooks/useCountDown/index.d.ts +10 -0
- package/es/hooks/useCountDown/index.js +48 -0
- package/es/hooks/useDocumentScroll/index.d.ts +8 -0
- package/es/hooks/useDocumentScroll/index.js +41 -0
- package/es/hooks/useDocumentScroll/index.less +0 -0
- package/es/hooks/useMousemove/index.d.ts +8 -0
- package/es/hooks/useMousemove/index.js +61 -0
- package/es/hooks/useResponsive/index.d.ts +2 -0
- package/es/hooks/useResponsive/index.js +29 -0
- package/es/hooks/useResponsive/index.less +0 -0
- package/es/hooks/useSize/index.d.ts +2 -0
- package/es/hooks/useSize/index.js +27 -0
- package/es/hooks/useSize/index.less +0 -0
- package/es/hooks/useStateMulti/index.d.ts +2 -0
- package/es/hooks/useStateMulti/index.js +29 -0
- package/es/hooks/useStateWithCb/index.d.ts +2 -0
- package/es/hooks/useStateWithCb/index.js +42 -0
- package/es/hooks/useTable/index.d.ts +12 -0
- package/es/hooks/useTable/index.js +74 -0
- package/es/hooks/useTable/index.less +0 -0
- package/es/hooks/useTableModal/index.d.ts +12 -0
- package/es/hooks/useTableModal/index.js +25 -0
- package/es/hooks/useTableModal/index.less +0 -0
- package/es/hooks/useUrlState/index.d.ts +2 -0
- package/es/hooks/useUrlState/index.js +56 -0
- package/es/hooks/useWebSocket/index.d.ts +13 -0
- package/es/hooks/useWebSocket/index.js +121 -0
- package/es/index.d.ts +4 -0
- package/es/index.js +4 -0
- package/es/locales/en-US.d.ts +11 -0
- package/es/locales/en-US.js +10 -0
- package/es/locales/index.d.ts +1 -0
- package/es/locales/index.js +23 -0
- package/es/locales/zh-CN.d.ts +11 -0
- package/es/locales/zh-CN.js +10 -0
- package/es/locales/zh-TW.d.ts +11 -0
- package/es/locales/zh-TW.js +10 -0
- package/es/utils/index.d.ts +3 -0
- package/es/utils/index.js +3 -0
- package/es/utils/otherUtils.d.ts +8 -0
- package/es/utils/otherUtils.js +12 -0
- package/es/utils/storage.d.ts +30 -0
- package/es/utils/storage.js +70 -0
- package/es/utils/typeUtils.d.ts +42 -0
- package/es/utils/typeUtils.js +86 -0
- package/lib/business-components/colorInput/index.d.ts +21 -0
- package/lib/business-components/colorInput/index.js +70 -0
- package/lib/business-components/colorInput/index.less +10 -0
- package/lib/business-components/index.d.ts +11 -0
- package/lib/business-components/index.js +54 -0
- package/lib/business-components/rechargeOption/index.d.ts +36 -0
- package/lib/business-components/rechargeOption/index.js +133 -0
- package/lib/business-components/rechargeOption/index.less +0 -0
- package/lib/business-components/selectTag/index.d.ts +25 -0
- package/lib/business-components/selectTag/index.js +181 -0
- package/lib/business-components/selectTag/index.less +22 -0
- package/lib/business-components/sortModal/index.d.ts +30 -0
- package/lib/business-components/sortModal/index.js +100 -0
- package/lib/business-components/sortModal/index.less +29 -0
- package/lib/business-components/statistics/index.d.ts +12 -0
- package/lib/business-components/statistics/index.js +63 -0
- package/lib/business-components/statistics/index.less +64 -0
- package/lib/business-components/tagModal/index.d.ts +17 -0
- package/lib/business-components/tagModal/index.js +66 -0
- package/lib/business-hooks/index.d.ts +2 -0
- package/lib/business-hooks/index.js +42 -0
- package/lib/business-hooks/useModal/index.d.ts +31 -0
- package/lib/business-hooks/useModal/index.js +68 -0
- package/lib/business-hooks/useModal/index.less +0 -0
- package/lib/business-hooks/useTagModal/index.d.ts +17 -0
- package/lib/business-hooks/useTagModal/index.js +61 -0
- package/lib/components/ColorPicker/index.d.ts +22 -0
- package/lib/components/ColorPicker/index.js +80 -0
- package/lib/components/ColorPicker/index.less +17 -0
- package/lib/components/DragSort/index.d.ts +2 -0
- package/lib/components/DragSort/index.js +101 -0
- package/lib/components/Iconfont/index.d.ts +6 -0
- package/lib/components/Iconfont/index.js +47 -0
- package/lib/components/Iconfont/index.less +0 -0
- package/lib/components/card/index.d.ts +5 -0
- package/lib/components/card/index.js +42 -0
- package/lib/components/card/index.less +9 -0
- package/lib/components/index.d.ts +4 -0
- package/lib/components/index.js +48 -0
- package/lib/config/index.d.ts +16 -0
- package/lib/config/index.js +39 -0
- package/lib/config/utils.d.ts +0 -0
- package/lib/config/utils.js +0 -0
- package/lib/hooks/index.d.ts +8 -0
- package/lib/hooks/index.js +57 -0
- package/lib/hooks/useCountDown/index.d.ts +10 -0
- package/lib/hooks/useCountDown/index.js +57 -0
- package/lib/hooks/useDocumentScroll/index.d.ts +8 -0
- package/lib/hooks/useDocumentScroll/index.js +54 -0
- package/lib/hooks/useDocumentScroll/index.less +0 -0
- package/lib/hooks/useMousemove/index.d.ts +8 -0
- package/lib/hooks/useMousemove/index.js +70 -0
- package/lib/hooks/useResponsive/index.d.ts +2 -0
- package/lib/hooks/useResponsive/index.js +47 -0
- package/lib/hooks/useResponsive/index.less +0 -0
- package/lib/hooks/useSize/index.d.ts +2 -0
- package/lib/hooks/useSize/index.js +45 -0
- package/lib/hooks/useSize/index.less +0 -0
- package/lib/hooks/useStateMulti/index.d.ts +2 -0
- package/lib/hooks/useStateMulti/index.js +43 -0
- package/lib/hooks/useStateWithCb/index.d.ts +2 -0
- package/lib/hooks/useStateWithCb/index.js +53 -0
- package/lib/hooks/useTable/index.d.ts +12 -0
- package/lib/hooks/useTable/index.js +75 -0
- package/lib/hooks/useTable/index.less +0 -0
- package/lib/hooks/useTableModal/index.d.ts +12 -0
- package/lib/hooks/useTableModal/index.js +43 -0
- package/lib/hooks/useTableModal/index.less +0 -0
- package/lib/hooks/useUrlState/index.d.ts +2 -0
- package/lib/hooks/useUrlState/index.js +59 -0
- package/lib/hooks/useWebSocket/index.d.ts +13 -0
- package/lib/hooks/useWebSocket/index.js +91 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +22 -0
- package/lib/locales/en-US.d.ts +11 -0
- package/lib/locales/en-US.js +36 -0
- package/lib/locales/index.d.ts +1 -0
- package/lib/locales/index.js +59 -0
- package/lib/locales/zh-CN.d.ts +11 -0
- package/lib/locales/zh-CN.js +36 -0
- package/lib/locales/zh-TW.d.ts +11 -0
- package/lib/locales/zh-TW.js +36 -0
- package/lib/utils/index.d.ts +3 -0
- package/lib/utils/index.js +21 -0
- package/lib/utils/otherUtils.d.ts +8 -0
- package/lib/utils/otherUtils.js +31 -0
- package/lib/utils/storage.d.ts +30 -0
- package/lib/utils/storage.js +63 -0
- package/lib/utils/typeUtils.d.ts +42 -0
- package/lib/utils/typeUtils.js +75 -0
- package/package.json +101 -0
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
// @ts-ignore
|
|
8
|
+
import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd';
|
|
9
|
+
import arrayMove from 'array-move';
|
|
10
|
+
import classNames from 'classnames';
|
|
11
|
+
import { getUniqueId } from "../../utils";
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
var DragDrop = function DragDrop(_ref) {
|
|
15
|
+
var onChange = _ref.onChange,
|
|
16
|
+
_children = _ref.children,
|
|
17
|
+
list = _ref.list,
|
|
18
|
+
droppableId = _ref.droppableId,
|
|
19
|
+
draggableIdKey = _ref.draggableIdKey,
|
|
20
|
+
droppableClassName = _ref.droppableClassName,
|
|
21
|
+
draggableClassName = _ref.draggableClassName,
|
|
22
|
+
footer = _ref.footer,
|
|
23
|
+
_ref$direction = _ref.direction,
|
|
24
|
+
direction = _ref$direction === void 0 ? 'vertical' : _ref$direction,
|
|
25
|
+
isDragDisabled = _ref.isDragDisabled;
|
|
26
|
+
droppableId = droppableId || getUniqueId('droppableId_');
|
|
27
|
+
var handleDragEnd = function handleDragEnd(result) {
|
|
28
|
+
if (result.destination) {
|
|
29
|
+
onChange && onChange(arrayMove(list, result.source.index, result.destination.index), result);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
var getDraggableId = function getDraggableId(item, index) {
|
|
33
|
+
if (typeof draggableIdKey === 'function') {
|
|
34
|
+
return String(draggableIdKey(item, index));
|
|
35
|
+
} else {
|
|
36
|
+
return draggableIdKey ? String(item[draggableIdKey]) : String(item);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
return /*#__PURE__*/_jsx(DragDropContext, {
|
|
40
|
+
onDragEnd: handleDragEnd,
|
|
41
|
+
children: /*#__PURE__*/_jsx(Droppable, {
|
|
42
|
+
droppableId: droppableId,
|
|
43
|
+
direction: direction,
|
|
44
|
+
children: function children(provided) {
|
|
45
|
+
return /*#__PURE__*/_jsxs("div", _objectSpread(_objectSpread({}, provided.droppableProps), {}, {
|
|
46
|
+
ref: provided.innerRef,
|
|
47
|
+
className: classNames(droppableClassName),
|
|
48
|
+
children: [list.map(function (item, index) {
|
|
49
|
+
return /*#__PURE__*/_jsx(Draggable, {
|
|
50
|
+
draggableId: getDraggableId(item, index),
|
|
51
|
+
index: index,
|
|
52
|
+
isDragDisabled: !!isDragDisabled,
|
|
53
|
+
children: function children(provided) {
|
|
54
|
+
return /*#__PURE__*/_jsx("div", _objectSpread(_objectSpread(_objectSpread({
|
|
55
|
+
className: classNames(typeof draggableClassName === 'function' ? draggableClassName(item, index) : draggableClassName),
|
|
56
|
+
ref: provided.innerRef
|
|
57
|
+
}, provided.draggableProps), provided.dragHandleProps), {}, {
|
|
58
|
+
children: _children(item, index)
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
}, getDraggableId(item, index));
|
|
62
|
+
}), provided.placeholder, footer]
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
export default DragDrop;
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
/*
|
|
8
|
+
* @Title: Iconfont
|
|
9
|
+
* @Describe: 通过不同的className来渲染不同的icon
|
|
10
|
+
* @Author: Wzw
|
|
11
|
+
* @Date: 2021-03-15 13:57:03
|
|
12
|
+
* @LastEditors: wzw 445595671@qq.com
|
|
13
|
+
* @LastEditTime: 2022-07-15 09:09
|
|
14
|
+
*/
|
|
15
|
+
import { createFromIconfontCN } from '@ant-design/icons';
|
|
16
|
+
import React from 'react';
|
|
17
|
+
import { getConfig } from "../../config";
|
|
18
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
|
+
var MyIcon = createFromIconfontCN({
|
|
20
|
+
scriptUrl: getConfig().ENV.static + '/static/fonts/iconfont/iconfont.js?q=' + new Date().getTime() // 在 iconfont.cn 上生成
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
var IconFont = function IconFont(props) {
|
|
24
|
+
return /*#__PURE__*/_jsx(MyIcon, _objectSpread(_objectSpread({}, props), {}, {
|
|
25
|
+
className: props.className
|
|
26
|
+
}));
|
|
27
|
+
};
|
|
28
|
+
export default IconFont;
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
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 classNames from 'classnames';
|
|
8
|
+
import "./index.less";
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
var Card = function Card(props) {
|
|
11
|
+
return /*#__PURE__*/_jsx("div", _objectSpread(_objectSpread({}, props), {}, {
|
|
12
|
+
className: classNames('pisell-card', props.className),
|
|
13
|
+
children: props.children
|
|
14
|
+
}));
|
|
15
|
+
};
|
|
16
|
+
export default Card;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
declare type PisellConfigType = {
|
|
2
|
+
ENV: {
|
|
3
|
+
host: string;
|
|
4
|
+
socket: string;
|
|
5
|
+
helpHost: string;
|
|
6
|
+
boxlocal_h5: string;
|
|
7
|
+
accounts: string;
|
|
8
|
+
domain: string;
|
|
9
|
+
googleMap: string;
|
|
10
|
+
appCenter: string;
|
|
11
|
+
static: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export declare const initConfig: (options: PisellConfigType) => void;
|
|
15
|
+
export declare const getConfig: () => PisellConfigType;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
var PisellConfig = {};
|
|
8
|
+
export var initConfig = function initConfig(options) {
|
|
9
|
+
Object.entries(options).forEach(function (_ref) {
|
|
10
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
11
|
+
key = _ref2[0],
|
|
12
|
+
value = _ref2[1];
|
|
13
|
+
PisellConfig[key] = value;
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
export var getConfig = function getConfig() {
|
|
17
|
+
return PisellConfig;
|
|
18
|
+
};
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import useMousemove from './useMousemove';
|
|
2
|
+
import useResponsive from './useResponsive';
|
|
3
|
+
import useSize from './useSize';
|
|
4
|
+
import useStateMulti from './useStateMulti';
|
|
5
|
+
import useStateWithCb from './useStateWithCb';
|
|
6
|
+
import useTable from './useTable';
|
|
7
|
+
import useUrlState from './useUrlState';
|
|
8
|
+
export { useStateMulti, useStateWithCb, useResponsive, useUrlState, useSize, useMousemove, useTable, };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import useMousemove from "./useMousemove";
|
|
2
|
+
import useResponsive from "./useResponsive";
|
|
3
|
+
import useSize from "./useSize";
|
|
4
|
+
import useStateMulti from "./useStateMulti";
|
|
5
|
+
import useStateWithCb from "./useStateWithCb";
|
|
6
|
+
import useTable from "./useTable";
|
|
7
|
+
import useUrlState from "./useUrlState";
|
|
8
|
+
export { useStateMulti, useStateWithCb, useResponsive, useUrlState, useSize, useMousemove, useTable };
|
|
@@ -0,0 +1,48 @@
|
|
|
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 { useCallback, useState, useRef } from 'react';
|
|
8
|
+
var useCountDown = function useCountDown() {
|
|
9
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
10
|
+
_ref$second = _ref.second,
|
|
11
|
+
second = _ref$second === void 0 ? 60 : _ref$second,
|
|
12
|
+
_ref$running = _ref.running,
|
|
13
|
+
running = _ref$running === void 0 ? false : _ref$running;
|
|
14
|
+
var _useState = useState(running),
|
|
15
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
16
|
+
_running = _useState2[0],
|
|
17
|
+
setRunning = _useState2[1];
|
|
18
|
+
var _useState3 = useState(second),
|
|
19
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
20
|
+
_second = _useState4[0],
|
|
21
|
+
setSecond = _useState4[1];
|
|
22
|
+
var timer = useRef();
|
|
23
|
+
var stop = useCallback(function () {
|
|
24
|
+
setRunning(false);
|
|
25
|
+
clearInterval(timer.current);
|
|
26
|
+
}, []);
|
|
27
|
+
var start = useCallback(function () {
|
|
28
|
+
setSecond(second);
|
|
29
|
+
setRunning(true);
|
|
30
|
+
timer.current = setInterval(function () {
|
|
31
|
+
setSecond(function (s) {
|
|
32
|
+
s = s - 1;
|
|
33
|
+
if (s <= 0) {
|
|
34
|
+
s = 0;
|
|
35
|
+
stop();
|
|
36
|
+
}
|
|
37
|
+
return s;
|
|
38
|
+
});
|
|
39
|
+
}, 1000);
|
|
40
|
+
}, [second, stop]);
|
|
41
|
+
return {
|
|
42
|
+
running: _running,
|
|
43
|
+
second: _second,
|
|
44
|
+
start: start,
|
|
45
|
+
stop: stop
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export default useCountDown;
|
|
@@ -0,0 +1,41 @@
|
|
|
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 { useMemo } from 'react';
|
|
8
|
+
import { useScroll } from 'ahooks';
|
|
9
|
+
var initValue = {
|
|
10
|
+
left: 0,
|
|
11
|
+
top: 0,
|
|
12
|
+
// 窗口高度
|
|
13
|
+
innerHeight: 0,
|
|
14
|
+
// 当前窗口高度
|
|
15
|
+
newInnerHeight: 0
|
|
16
|
+
};
|
|
17
|
+
var useDocumentScroll = function useDocumentScroll() {
|
|
18
|
+
//窗口高度
|
|
19
|
+
var _innerHeight = useMemo(function () {
|
|
20
|
+
return document.documentElement.clientHeight;
|
|
21
|
+
}, []);
|
|
22
|
+
var _scroll = useScroll(document);
|
|
23
|
+
/**
|
|
24
|
+
* @title: 返回结果
|
|
25
|
+
* @description:
|
|
26
|
+
* @param {*} useMemo
|
|
27
|
+
* @return {*}
|
|
28
|
+
* @Author: Wzw
|
|
29
|
+
* @Date: 2022-07-01 15:43
|
|
30
|
+
*/
|
|
31
|
+
var _result = useMemo(function () {
|
|
32
|
+
return _objectSpread(_objectSpread(_objectSpread({}, initValue), _scroll), {}, {
|
|
33
|
+
// 窗口高度
|
|
34
|
+
innerHeight: _innerHeight,
|
|
35
|
+
// 当前窗口高度
|
|
36
|
+
newInnerHeight: window.innerHeight
|
|
37
|
+
});
|
|
38
|
+
}, [_innerHeight, _scroll]);
|
|
39
|
+
return _result;
|
|
40
|
+
};
|
|
41
|
+
export default useDocumentScroll;
|
|
File without changes
|
|
@@ -0,0 +1,61 @@
|
|
|
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 { useState, useEffect } from 'react';
|
|
8
|
+
var count = 0;
|
|
9
|
+
var timer = null;
|
|
10
|
+
var useMousemove = function useMousemove(_ref) {
|
|
11
|
+
var _ref$time = _ref.time,
|
|
12
|
+
time = _ref$time === void 0 ? 60 : _ref$time;
|
|
13
|
+
var _useState = useState(false),
|
|
14
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
15
|
+
isMove = _useState2[0],
|
|
16
|
+
setIsMove = _useState2[1];
|
|
17
|
+
var go = function go() {
|
|
18
|
+
count++;
|
|
19
|
+
if (count >= time) {
|
|
20
|
+
setIsMove(true);
|
|
21
|
+
// 此处处理后续操作
|
|
22
|
+
// count = 0;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
var init = function init() {
|
|
27
|
+
//页面倒计时
|
|
28
|
+
timer = setInterval(go, 1000);
|
|
29
|
+
//监听鼠标
|
|
30
|
+
var x;
|
|
31
|
+
var y;
|
|
32
|
+
document.onmousemove = function (event) {
|
|
33
|
+
var x1 = event.clientX;
|
|
34
|
+
var y1 = event.clientY;
|
|
35
|
+
if (x != x1 || y != y1) {
|
|
36
|
+
count = 0;
|
|
37
|
+
setIsMove(false);
|
|
38
|
+
}
|
|
39
|
+
x = x1;
|
|
40
|
+
y = y1;
|
|
41
|
+
};
|
|
42
|
+
// document.onmouseover
|
|
43
|
+
document.onkeydown = function () {
|
|
44
|
+
count = 0;
|
|
45
|
+
setIsMove(false);
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
useEffect(function () {
|
|
49
|
+
init();
|
|
50
|
+
return function () {
|
|
51
|
+
clearInterval(timer);
|
|
52
|
+
setIsMove(false);
|
|
53
|
+
document.onmousemove = null;
|
|
54
|
+
document.onkeydown = null;
|
|
55
|
+
};
|
|
56
|
+
}, []);
|
|
57
|
+
return {
|
|
58
|
+
isMove: isMove
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
export default useMousemove;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Title: history
|
|
3
|
+
* @Describe:
|
|
4
|
+
* @Author: Wzw
|
|
5
|
+
* @Date: 2021-04-30 09:16:38
|
|
6
|
+
* @LastEditors: wzw 445595671@qq.com
|
|
7
|
+
* @LastEditTime: 2023-01-13 10:47
|
|
8
|
+
*/
|
|
9
|
+
import { useMemo } from 'react';
|
|
10
|
+
import { configResponsive, useResponsive } from 'ahooks';
|
|
11
|
+
configResponsive({
|
|
12
|
+
phone: 0,
|
|
13
|
+
ipad: 700,
|
|
14
|
+
pc: 1080
|
|
15
|
+
});
|
|
16
|
+
var useLmResponsive = function useLmResponsive() {
|
|
17
|
+
var responsive = useResponsive();
|
|
18
|
+
var current = useMemo(function () {
|
|
19
|
+
if (responsive !== null && responsive !== void 0 && responsive.pc) {
|
|
20
|
+
return 'pc';
|
|
21
|
+
}
|
|
22
|
+
if (responsive !== null && responsive !== void 0 && responsive.ipad) {
|
|
23
|
+
return 'ipad';
|
|
24
|
+
}
|
|
25
|
+
return 'phone';
|
|
26
|
+
}, [responsive]);
|
|
27
|
+
return current;
|
|
28
|
+
};
|
|
29
|
+
export default useLmResponsive;
|
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { useCallback, useState } from 'react';
|
|
8
|
+
import { useSize, useDebounceEffect } from 'ahooks';
|
|
9
|
+
export default (function (dom) {
|
|
10
|
+
var _useState = useState({
|
|
11
|
+
width: 0,
|
|
12
|
+
height: 0
|
|
13
|
+
}),
|
|
14
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
15
|
+
size = _useState2[0],
|
|
16
|
+
setSize = _useState2[1];
|
|
17
|
+
var _fn = useCallback(function () {
|
|
18
|
+
return document.querySelector(dom || 'body');
|
|
19
|
+
}, [dom]);
|
|
20
|
+
var _size = useSize(_fn);
|
|
21
|
+
useDebounceEffect(function () {
|
|
22
|
+
setSize(_size);
|
|
23
|
+
}, [_size], {
|
|
24
|
+
wait: 50
|
|
25
|
+
});
|
|
26
|
+
return size;
|
|
27
|
+
});
|
|
File without changes
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
import { useState, useCallback } from 'react';
|
|
14
|
+
import { isPlainObject } from "../../utils";
|
|
15
|
+
var useStateMulti = function useStateMulti(initState) {
|
|
16
|
+
var _useState = useState(initState),
|
|
17
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
18
|
+
state = _useState2[0],
|
|
19
|
+
_setState = _useState2[1];
|
|
20
|
+
var setState = useCallback(function (updatedValues) {
|
|
21
|
+
if (isPlainObject(updatedValues)) {
|
|
22
|
+
_setState(function (prevState) {
|
|
23
|
+
return _objectSpread(_objectSpread({}, prevState), updatedValues);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}, []);
|
|
27
|
+
return [state, setState];
|
|
28
|
+
};
|
|
29
|
+
export default useStateMulti;
|
|
@@ -0,0 +1,42 @@
|
|
|
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 { useState, useRef, useEffect, useCallback } from 'react';
|
|
8
|
+
var useStateWithCb = function useStateWithCb(initialVal) {
|
|
9
|
+
var _useState = useState(function () {
|
|
10
|
+
return initialVal;
|
|
11
|
+
}),
|
|
12
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
13
|
+
state = _useState2[0],
|
|
14
|
+
_setState = _useState2[1];
|
|
15
|
+
var _useState3 = useState(function () {
|
|
16
|
+
return Math.random();
|
|
17
|
+
}),
|
|
18
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
19
|
+
random = _useState4[0],
|
|
20
|
+
setRandom = _useState4[1];
|
|
21
|
+
var cbs = useRef([]);
|
|
22
|
+
var setState = useCallback(function (newState, cb) {
|
|
23
|
+
if (cb) {
|
|
24
|
+
cbs.current.push(cb);
|
|
25
|
+
}
|
|
26
|
+
if (Object.is(state, newState)) {
|
|
27
|
+
setRandom(Math.random());
|
|
28
|
+
}
|
|
29
|
+
_setState(newState);
|
|
30
|
+
}, [state]);
|
|
31
|
+
useEffect(function () {
|
|
32
|
+
if (cbs.current) {
|
|
33
|
+
var _cbs = cbs.current;
|
|
34
|
+
cbs.current = [];
|
|
35
|
+
_cbs.forEach(function (_cb) {
|
|
36
|
+
return _cb();
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}, [state, random]);
|
|
40
|
+
return [state, setState];
|
|
41
|
+
};
|
|
42
|
+
export default useStateWithCb;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseOptions, CombineService, PaginatedFormatReturn, PaginatedParams, Result } from 'ahooks/lib/useAntdTable/index';
|
|
2
|
+
/**
|
|
3
|
+
* @Title: 基于ahooks 增加额外参数
|
|
4
|
+
* @Describe:
|
|
5
|
+
* @Author: Wzw
|
|
6
|
+
*/
|
|
7
|
+
interface useTableOptions<T> extends Omit<BaseOptions<T>, 'onSuccess'> {
|
|
8
|
+
isCaChe?: boolean;
|
|
9
|
+
onSuccess?: (data: any, params?: any, urlParams?: any) => void;
|
|
10
|
+
}
|
|
11
|
+
declare const useTable: <R, Item = any, U extends Item = any>(service: CombineService<PaginatedFormatReturn<Item>, PaginatedParams>, options: useTableOptions<U>) => Result<Item>;
|
|
12
|
+
export default useTable;
|