@ccs-ui/rc-pro 2.3.6-alpha-31 → 2.3.6-alpha-33
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/package.json +6 -27
- package/LICENSE +0 -21
- package/README.md +0 -37
- package/es/aj-captcha/index.d.ts +0 -34
- package/es/aj-captcha/index.js +0 -302
- package/es/aj-captcha/index.less +0 -89
- package/es/auth/index.d.ts +0 -15
- package/es/auth/index.js +0 -38
- package/es/breadcrumb.d.ts +0 -8
- package/es/breadcrumb.js +0 -40
- package/es/button/dropdown.d.ts +0 -6
- package/es/button/dropdown.js +0 -72
- package/es/button/group.d.ts +0 -2
- package/es/button/group.js +0 -176
- package/es/button/index.d.ts +0 -65
- package/es/button/index.js +0 -133
- package/es/cascader/index.d.ts +0 -33
- package/es/cascader/index.js +0 -120
- package/es/ccs.d.ts +0 -131
- package/es/ccs.js +0 -1
- package/es/color-picker/index.d.ts +0 -7
- package/es/color-picker/index.js +0 -142
- package/es/color-picker/index.less +0 -8
- package/es/config.d.ts +0 -6
- package/es/config.js +0 -126
- package/es/context/index.d.ts +0 -115
- package/es/context/index.js +0 -6
- package/es/date-picker/index.d.ts +0 -19
- package/es/date-picker/index.js +0 -72
- package/es/dialog/HookDrawer.d.ts +0 -9
- package/es/dialog/HookDrawer.js +0 -156
- package/es/dialog/HookModal.d.ts +0 -10
- package/es/dialog/HookModal.js +0 -213
- package/es/dialog/button.d.ts +0 -24
- package/es/dialog/button.js +0 -256
- package/es/dialog/context.d.ts +0 -25
- package/es/dialog/context.js +0 -13
- package/es/dialog/drawer-footer.d.ts +0 -16
- package/es/dialog/drawer-footer.js +0 -43
- package/es/dialog/form.d.ts +0 -16
- package/es/dialog/form.js +0 -53
- package/es/dialog/hook.d.ts +0 -80
- package/es/dialog/hook.js +0 -234
- package/es/dialog/index.d.ts +0 -19
- package/es/dialog/index.js +0 -14
- package/es/dialog/usePatchElement.d.ts +0 -5
- package/es/dialog/usePatchElement.js +0 -35
- package/es/editor/index.d.ts +0 -22
- package/es/editor/index.js +0 -18
- package/es/editor/index.less +0 -19
- package/es/editor/javascript.d.ts +0 -2
- package/es/editor/javascript.js +0 -56
- package/es/editor/json.d.ts +0 -7
- package/es/editor/json.js +0 -82
- package/es/editor/sql.d.ts +0 -2
- package/es/editor/sql.js +0 -54
- package/es/ellipsis/index.d.ts +0 -22
- package/es/ellipsis/index.js +0 -129
- package/es/ellipsis/index.less +0 -5
- package/es/ellipsis/useMeasure.d.ts +0 -9
- package/es/ellipsis/useMeasure.js +0 -142
- package/es/ellipsis/useResizeEffect.d.ts +0 -2
- package/es/ellipsis/useResizeEffect.js +0 -14
- package/es/ellipsis/withStopPropagation.d.ts +0 -4
- package/es/ellipsis/withStopPropagation.js +0 -38
- package/es/full-screen/index.d.ts +0 -3
- package/es/full-screen/index.js +0 -49
- package/es/group-form-item/index.d.ts +0 -11
- package/es/group-form-item/index.js +0 -124
- package/es/hooks/use-app.d.ts +0 -25
- package/es/hooks/use-app.js +0 -52
- package/es/hooks/use-event.d.ts +0 -10
- package/es/hooks/use-event.js +0 -69
- package/es/hooks/use-once-event.d.ts +0 -2
- package/es/hooks/use-once-event.js +0 -16
- package/es/hooks/use-page.d.ts +0 -10
- package/es/hooks/use-page.js +0 -10
- package/es/hooks/use-selection.d.ts +0 -17
- package/es/hooks/use-selection.js +0 -172
- package/es/hooks/use-tabs.d.ts +0 -2
- package/es/hooks/use-tabs.js +0 -10
- package/es/hooks/use-window.d.ts +0 -8
- package/es/hooks/use-window.js +0 -15
- package/es/index.d.ts +0 -37
- package/es/index.js +0 -37
- package/es/interval-button/index.d.ts +0 -14
- package/es/interval-button/index.js +0 -128
- package/es/layout-keep-alive/index.d.ts +0 -29
- package/es/layout-keep-alive/index.js +0 -400
- package/es/layout-keep-alive/index.less +0 -79
- package/es/layout-keep-alive/page.d.ts +0 -14
- package/es/layout-keep-alive/page.js +0 -53
- package/es/layout-single-page/index.d.ts +0 -14
- package/es/layout-single-page/index.js +0 -71
- package/es/layout-single-page/index.less +0 -15
- package/es/layout-single-page/page.d.ts +0 -13
- package/es/layout-single-page/page.js +0 -41
- package/es/loading/index.d.ts +0 -14
- package/es/loading/index.js +0 -43
- package/es/pro-grid/index.d.ts +0 -15
- package/es/pro-grid/index.js +0 -58
- package/es/pro-table/_utils.d.ts +0 -12
- package/es/pro-table/_utils.js +0 -94
- package/es/pro-table/form-item.d.ts +0 -9
- package/es/pro-table/form-item.js +0 -44
- package/es/pro-table/head.d.ts +0 -16
- package/es/pro-table/head.js +0 -225
- package/es/pro-table/index.d.ts +0 -23
- package/es/pro-table/index.js +0 -37
- package/es/pro-table/index.less +0 -82
- package/es/pro-table/operation.d.ts +0 -14
- package/es/pro-table/operation.js +0 -194
- package/es/pro-table/selection-alert.d.ts +0 -20
- package/es/pro-table/selection-alert.js +0 -64
- package/es/pro-table/size.d.ts +0 -10
- package/es/pro-table/size.js +0 -17
- package/es/pro-table/summary.d.ts +0 -8
- package/es/pro-table/summary.js +0 -32
- package/es/pro-table/table.d.ts +0 -104
- package/es/pro-table/table.js +0 -712
- package/es/pro-table/tree.d.ts +0 -24
- package/es/pro-table/tree.js +0 -197
- package/es/pro-tabs/index.d.ts +0 -9
- package/es/pro-tabs/index.js +0 -174
- package/es/resize-observer.d.ts +0 -15
- package/es/resize-observer.js +0 -37
- package/es/result/icon.d.ts +0 -3
- package/es/result/icon.js +0 -3
- package/es/result/index.d.ts +0 -12
- package/es/result/index.js +0 -68
- package/es/select/ modal.d.ts +0 -10
- package/es/select/ modal.js +0 -141
- package/es/select/api.d.ts +0 -25
- package/es/select/api.js +0 -67
- package/es/select/customize.d.ts +0 -25
- package/es/select/customize.js +0 -139
- package/es/select/index.d.ts +0 -31
- package/es/select/index.js +0 -108
- package/es/status-tag/index.d.ts +0 -13
- package/es/status-tag/index.js +0 -31
- package/es/table/index.d.ts +0 -19
- package/es/table/index.js +0 -253
- package/es/table/index.less +0 -29
- package/es/theme-dialog.d.ts +0 -28
- package/es/theme-dialog.js +0 -81
- package/es/time-picker/index.d.ts +0 -15
- package/es/time-picker/index.js +0 -49
- package/es/trigger/index.d.ts +0 -43
- package/es/trigger/index.js +0 -298
- package/es/trigger/index.less +0 -42
- package/es/types.d.ts +0 -0
- package/es/types.js +0 -0
- package/es/upload/index.d.ts +0 -42
- package/es/upload/index.js +0 -167
- package/es/upload/upload-image.d.ts +0 -6
- package/es/upload/upload-image.js +0 -205
- package/es/virtual-list/index.d.ts +0 -51
- package/es/virtual-list/index.js +0 -132
- package/es/water-mark/index.d.ts +0 -65
- package/es/water-mark/index.js +0 -141
- package/es/water-mark/relative.d.ts +0 -62
- package/es/water-mark/relative.js +0 -130
package/es/trigger/index.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { SizeType } from 'antd/es/config-provider/SizeContext';
|
|
2
|
-
import { PropsWithCss, PropsWithElementChildren } from '../ccs';
|
|
3
|
-
import './index.less';
|
|
4
|
-
export type CcsTriggerProps = PropsWithCss & PropsWithElementChildren & {
|
|
5
|
-
/** 下拉框宽度 */
|
|
6
|
-
width?: number;
|
|
7
|
-
/** 下拉框高度 */
|
|
8
|
-
height?: number;
|
|
9
|
-
/**
|
|
10
|
-
* @description input size:'small' | 'middle' | 'large'
|
|
11
|
-
* @default 'middle'
|
|
12
|
-
*/
|
|
13
|
-
size?: SizeType;
|
|
14
|
-
/**
|
|
15
|
-
* @description 禁用选择
|
|
16
|
-
* @default false
|
|
17
|
-
*/
|
|
18
|
-
disabled?: boolean;
|
|
19
|
-
/** Form.Item value */
|
|
20
|
-
value?: any;
|
|
21
|
-
/** input placeholder */
|
|
22
|
-
placeholder?: string;
|
|
23
|
-
/**
|
|
24
|
-
* 是否在首次显示前渲染弹出内容
|
|
25
|
-
* @default false
|
|
26
|
-
*/
|
|
27
|
-
forceRender?: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* @description popup挂载的html节点,默认:document.body、true:当前dom
|
|
30
|
-
* @default document.body
|
|
31
|
-
*/
|
|
32
|
-
popupContainer?: boolean;
|
|
33
|
-
/** Form.Item onChange */
|
|
34
|
-
onChange?: (value?: any) => void;
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* 适用于Form.Item中的 trigger组件,其内容自行定义,遵循ant form 自定义组件规范
|
|
38
|
-
* @deprecated
|
|
39
|
-
* @param CcsTriggerPropsType
|
|
40
|
-
* @returns
|
|
41
|
-
*/
|
|
42
|
-
declare const TriggerComponent: (props: CcsTriggerProps) => import("react/jsx-runtime").JSX.Element;
|
|
43
|
-
export default TriggerComponent;
|
package/es/trigger/index.js
DELETED
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
var _excluded = ["size", "style", "value", "width", "height", "disabled", "children", "className", "forceRender", "placeholder", "popupContainer", "onChange"];
|
|
3
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
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(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
|
-
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."); }
|
|
10
|
-
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); }
|
|
11
|
-
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; }
|
|
12
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
13
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
|
-
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; }
|
|
15
|
-
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; }
|
|
16
|
-
import { CloseCircleFilled, DownOutlined } from '@ant-design/icons';
|
|
17
|
-
import { useDebounceFn, useEventListener, useUpdate } from 'ahooks';
|
|
18
|
-
import { ConfigProvider, Input, Spin } from 'antd';
|
|
19
|
-
import zhCN from 'antd/locale/zh_CN';
|
|
20
|
-
import _isNil from 'lodash.isnil';
|
|
21
|
-
import Trigger from 'rc-trigger';
|
|
22
|
-
import { cloneElement, useEffect, useMemo, useRef, useState } from 'react';
|
|
23
|
-
import "./index.less";
|
|
24
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
25
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
26
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
27
|
-
var zIndex = 2000;
|
|
28
|
-
var classPrefix = 'ccs-trigger';
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* 适用于Form.Item中的 trigger组件,其内容自行定义,遵循ant form 自定义组件规范
|
|
32
|
-
* @deprecated
|
|
33
|
-
* @param CcsTriggerPropsType
|
|
34
|
-
* @returns
|
|
35
|
-
*/
|
|
36
|
-
var TriggerComponent = function TriggerComponent(props) {
|
|
37
|
-
var _ref$current2;
|
|
38
|
-
var size = props.size,
|
|
39
|
-
style = props.style,
|
|
40
|
-
value = props.value,
|
|
41
|
-
width = props.width,
|
|
42
|
-
height = props.height,
|
|
43
|
-
disabled = props.disabled,
|
|
44
|
-
children = props.children,
|
|
45
|
-
className = props.className,
|
|
46
|
-
forceRender = props.forceRender,
|
|
47
|
-
placeholder = props.placeholder,
|
|
48
|
-
popupContainer = props.popupContainer,
|
|
49
|
-
onChange = props.onChange,
|
|
50
|
-
restProps = _objectWithoutProperties(props, _excluded);
|
|
51
|
-
var inputRef = useRef(null);
|
|
52
|
-
var ref = useRef(null);
|
|
53
|
-
var containerRef = useRef(null);
|
|
54
|
-
var closeRef = useRef(null);
|
|
55
|
-
var downRef = useRef(null);
|
|
56
|
-
var alignRef = useRef({
|
|
57
|
-
points: ['tl', 'bl'],
|
|
58
|
-
offset: [0, 3],
|
|
59
|
-
size: {
|
|
60
|
-
width: width,
|
|
61
|
-
height: height
|
|
62
|
-
},
|
|
63
|
-
maxSize: {
|
|
64
|
-
width: width,
|
|
65
|
-
height: height
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
var _useState = useState(null),
|
|
69
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
70
|
-
visible = _useState2[0],
|
|
71
|
-
setVisible = _useState2[1];
|
|
72
|
-
var update = useUpdate();
|
|
73
|
-
var _useState3 = useState(false),
|
|
74
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
75
|
-
loading = _useState4[0],
|
|
76
|
-
setLoading = _useState4[1];
|
|
77
|
-
|
|
78
|
-
// 显示下拉图标
|
|
79
|
-
var onMouseLeave = function onMouseLeave() {
|
|
80
|
-
var _closeRef$current, _downRef$current;
|
|
81
|
-
(_closeRef$current = closeRef.current) === null || _closeRef$current === void 0 || _closeRef$current.classList.replace('ccs-trigger-show', 'ccs-trigger-hidden');
|
|
82
|
-
(_downRef$current = downRef.current) === null || _downRef$current === void 0 || _downRef$current.classList.replace('ccs-trigger-hidden', 'ccs-trigger-show');
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
// 显示清除数据图标
|
|
86
|
-
var onMouseEnter = function onMouseEnter() {
|
|
87
|
-
if (!_isNil(value)) {
|
|
88
|
-
var _downRef$current2, _closeRef$current2;
|
|
89
|
-
(_downRef$current2 = downRef.current) === null || _downRef$current2 === void 0 || _downRef$current2.classList.replace('ccs-trigger-show', 'ccs-trigger-hidden');
|
|
90
|
-
(_closeRef$current2 = closeRef.current) === null || _closeRef$current2 === void 0 || _closeRef$current2.classList.replace('ccs-trigger-hidden', 'ccs-trigger-show');
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
// 获取对齐方式、默认右下侧展开
|
|
95
|
-
var getAlignMode = function getAlignMode() {
|
|
96
|
-
var _ref$current;
|
|
97
|
-
var rect = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.getBoundingClientRect();
|
|
98
|
-
if (!rect) return;
|
|
99
|
-
var top = rect.top,
|
|
100
|
-
left = rect.left,
|
|
101
|
-
right = rect.right,
|
|
102
|
-
bottom = rect.bottom;
|
|
103
|
-
var _document$body = document.body,
|
|
104
|
-
offsetWidth = _document$body.offsetWidth,
|
|
105
|
-
offsetHeight = _document$body.offsetHeight;
|
|
106
|
-
var rightWidth = offsetWidth - left; // 右侧宽度
|
|
107
|
-
var bottomHeight = offsetHeight - bottom; // 下侧高度
|
|
108
|
-
|
|
109
|
-
// 元素 上右下左弹出框空间 top rightWidth bottomHeight right
|
|
110
|
-
var x = 'right';
|
|
111
|
-
var y = 'bottom';
|
|
112
|
-
if (width) {
|
|
113
|
-
if (rightWidth >= width) {
|
|
114
|
-
// 右侧宽度足够
|
|
115
|
-
} else if (right >= width) {
|
|
116
|
-
// 左侧宽度足够
|
|
117
|
-
x = 'left';
|
|
118
|
-
} else {
|
|
119
|
-
// 两侧宽度都不够,取最大
|
|
120
|
-
x = rightWidth > right ? 'right' : 'left';
|
|
121
|
-
// 弹出框最大宽度
|
|
122
|
-
alignRef.current.size.width = Math.max(right, rightWidth) - 10;
|
|
123
|
-
}
|
|
124
|
-
} else {
|
|
125
|
-
// 没有传入宽度、取最大值
|
|
126
|
-
x = rightWidth > right ? 'right' : 'left';
|
|
127
|
-
alignRef.current.maxSize.width = Math.max(right, rightWidth) - 10;
|
|
128
|
-
}
|
|
129
|
-
if (height) {
|
|
130
|
-
if (bottomHeight >= height) {
|
|
131
|
-
// 底部高度足够
|
|
132
|
-
} else if (top >= height) {
|
|
133
|
-
// 顶部高度足够
|
|
134
|
-
y = 'top';
|
|
135
|
-
} else {
|
|
136
|
-
// 上下高度都不够取最大
|
|
137
|
-
y = bottomHeight > top ? 'bottom' : 'top';
|
|
138
|
-
// 弹出框最大高度
|
|
139
|
-
alignRef.current.size.height = Math.max(top, bottomHeight) - 10;
|
|
140
|
-
}
|
|
141
|
-
} else {
|
|
142
|
-
// 没有传入高度、取最大值
|
|
143
|
-
y = bottomHeight > top ? 'bottom' : 'top';
|
|
144
|
-
alignRef.current.maxSize.height = Math.max(top, bottomHeight) - 10;
|
|
145
|
-
}
|
|
146
|
-
var point0 = 'tl'; // 弹出框对齐点
|
|
147
|
-
var point1 = 'bl'; // 目标对齐点
|
|
148
|
-
var offsetX = 0; // x偏移量
|
|
149
|
-
var offsetY = 3; // y偏移量
|
|
150
|
-
|
|
151
|
-
// 弹出框四个方位展开
|
|
152
|
-
if (x === 'right' && y === 'bottom') {
|
|
153
|
-
// 右下空间足够、默认右下展开
|
|
154
|
-
} else if (x === 'left' && y === 'bottom') {
|
|
155
|
-
// 右边宽度不够、高度足够、左下侧展开
|
|
156
|
-
point1 = 'br';
|
|
157
|
-
point0 = 'tr';
|
|
158
|
-
} else if (x === 'right' && y === 'top') {
|
|
159
|
-
// 右边宽度足够、高度不够、右上侧展开
|
|
160
|
-
point1 = 'tl';
|
|
161
|
-
point0 = 'bl';
|
|
162
|
-
offsetY = -3;
|
|
163
|
-
} else {
|
|
164
|
-
// 右边宽度不够、高度不够、左上侧展开
|
|
165
|
-
point1 = 'tr';
|
|
166
|
-
point0 = 'br';
|
|
167
|
-
offsetY = -3;
|
|
168
|
-
}
|
|
169
|
-
alignRef.current = _objectSpread(_objectSpread({}, alignRef.current), {}, {
|
|
170
|
-
points: [point0, point1],
|
|
171
|
-
offset: [offsetX, offsetY]
|
|
172
|
-
});
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
// resize 防抖
|
|
176
|
-
var _useDebounceFn = useDebounceFn(function (e) {
|
|
177
|
-
if (!alignRef.current.timeStamp && visible) {
|
|
178
|
-
// 防抖开始、关闭已打开的弹出框
|
|
179
|
-
alignRef.current.timeStamp = e.timeStamp;
|
|
180
|
-
setVisible(false);
|
|
181
|
-
} else {
|
|
182
|
-
// 防抖结束
|
|
183
|
-
getAlignMode();
|
|
184
|
-
update();
|
|
185
|
-
alignRef.current.timeStamp = undefined;
|
|
186
|
-
}
|
|
187
|
-
}, {
|
|
188
|
-
wait: 500,
|
|
189
|
-
leading: true
|
|
190
|
-
}),
|
|
191
|
-
run = _useDebounceFn.run;
|
|
192
|
-
var onChangeLabel = function onChangeLabel(text) {
|
|
193
|
-
inputRef.current = text;
|
|
194
|
-
update();
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
// 监听窗口变化
|
|
198
|
-
useEventListener('resize', run, {
|
|
199
|
-
target: window
|
|
200
|
-
});
|
|
201
|
-
var _useState5 = useState(zIndex),
|
|
202
|
-
_useState6 = _slicedToArray(_useState5, 1),
|
|
203
|
-
triggerIndex = _useState6[0];
|
|
204
|
-
useEffect(function () {
|
|
205
|
-
setTimeout(function () {
|
|
206
|
-
getAlignMode();
|
|
207
|
-
}, 10);
|
|
208
|
-
zIndex += 1;
|
|
209
|
-
}, []);
|
|
210
|
-
var _alignRef$current$siz = alignRef.current.size,
|
|
211
|
-
ppWidth = _alignRef$current$siz.width,
|
|
212
|
-
ppHeight = _alignRef$current$siz.height;
|
|
213
|
-
var _alignRef$current$max = alignRef.current.maxSize,
|
|
214
|
-
maxWidth = _alignRef$current$max.width,
|
|
215
|
-
maxHeight = _alignRef$current$max.height;
|
|
216
|
-
|
|
217
|
-
// 如果有初始值则渲染子组件
|
|
218
|
-
var isForceRender = useMemo(function () {
|
|
219
|
-
if (forceRender) return true;
|
|
220
|
-
return !!value;
|
|
221
|
-
}, []);
|
|
222
|
-
return /*#__PURE__*/_jsx(ConfigProvider, {
|
|
223
|
-
locale: zhCN,
|
|
224
|
-
children: /*#__PURE__*/_jsx(Trigger, {
|
|
225
|
-
mask: true,
|
|
226
|
-
action: ['click'],
|
|
227
|
-
forceRender: isForceRender,
|
|
228
|
-
prefixCls: classPrefix,
|
|
229
|
-
popup: /*#__PURE__*/_jsx("div", {
|
|
230
|
-
className: "".concat(classPrefix, "-container"),
|
|
231
|
-
ref: containerRef,
|
|
232
|
-
style: {
|
|
233
|
-
width: ppWidth || 'auto',
|
|
234
|
-
minWidth: (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.clientWidth,
|
|
235
|
-
maxHeight: ppHeight || maxHeight,
|
|
236
|
-
maxWidth: maxWidth
|
|
237
|
-
},
|
|
238
|
-
children: children && /*#__PURE__*/cloneElement(children, _objectSpread({
|
|
239
|
-
value: value,
|
|
240
|
-
onChange: onChange,
|
|
241
|
-
onChangeLabel: onChangeLabel,
|
|
242
|
-
onVisible: setVisible,
|
|
243
|
-
onLoading: setLoading,
|
|
244
|
-
width: ppWidth,
|
|
245
|
-
height: ppHeight
|
|
246
|
-
}, restProps))
|
|
247
|
-
}),
|
|
248
|
-
popupVisible: visible,
|
|
249
|
-
onPopupVisibleChange: function onPopupVisibleChange(e) {
|
|
250
|
-
if (!disabled) setVisible(e);
|
|
251
|
-
},
|
|
252
|
-
showAction: ['click'],
|
|
253
|
-
hideAction: ['click'],
|
|
254
|
-
popupAlign: alignRef.current,
|
|
255
|
-
popupStyle: {
|
|
256
|
-
position: 'absolute'
|
|
257
|
-
},
|
|
258
|
-
getPopupContainer: popupContainer ? function () {
|
|
259
|
-
return ref.current;
|
|
260
|
-
} : undefined,
|
|
261
|
-
zIndex: triggerIndex,
|
|
262
|
-
children: /*#__PURE__*/_jsx("div", {
|
|
263
|
-
ref: ref,
|
|
264
|
-
className: className,
|
|
265
|
-
style: style,
|
|
266
|
-
onMouseEnter: onMouseEnter,
|
|
267
|
-
onMouseLeave: onMouseLeave,
|
|
268
|
-
children: /*#__PURE__*/_jsx(Spin, {
|
|
269
|
-
spinning: loading,
|
|
270
|
-
children: /*#__PURE__*/_jsx(Input, {
|
|
271
|
-
readOnly: true,
|
|
272
|
-
disabled: disabled,
|
|
273
|
-
value: inputRef.current,
|
|
274
|
-
placeholder: placeholder || '请选择',
|
|
275
|
-
size: size || 'middle',
|
|
276
|
-
suffix: !disabled ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
277
|
-
children: [/*#__PURE__*/_jsx(CloseCircleFilled, {
|
|
278
|
-
ref: closeRef,
|
|
279
|
-
onClick: function onClick() {
|
|
280
|
-
if (onChange) {
|
|
281
|
-
onChange(undefined);
|
|
282
|
-
onChangeLabel(undefined);
|
|
283
|
-
onMouseLeave();
|
|
284
|
-
}
|
|
285
|
-
},
|
|
286
|
-
className: "".concat(classPrefix, "-icon ").concat(classPrefix, "-hidden")
|
|
287
|
-
}), /*#__PURE__*/_jsx(DownOutlined, {
|
|
288
|
-
className: "".concat(classPrefix, "-icon ").concat(classPrefix, "-show"),
|
|
289
|
-
ref: downRef
|
|
290
|
-
})]
|
|
291
|
-
}) : null
|
|
292
|
-
})
|
|
293
|
-
})
|
|
294
|
-
})
|
|
295
|
-
})
|
|
296
|
-
});
|
|
297
|
-
};
|
|
298
|
-
export default TriggerComponent;
|
package/es/trigger/index.less
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// ccs trigger
|
|
2
|
-
.ccs-trigger {
|
|
3
|
-
&-hidden {
|
|
4
|
-
display: none !important;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
&-show {
|
|
8
|
-
display: block !important;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
&-icon {
|
|
12
|
-
color: rgb(0 0 0 / 25%) !important;
|
|
13
|
-
font-size: 12px;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
&-container {
|
|
17
|
-
overflow: auto;
|
|
18
|
-
background: #fff;
|
|
19
|
-
border-radius: 2px;
|
|
20
|
-
box-shadow: 0 3px 6px -4px rgb(0 0 0 / 12%), 0 6px 16px 0 rgb(0 0 0 / 8%),
|
|
21
|
-
0 9px 28px 8px rgb(0 0 0 / 5%);
|
|
22
|
-
transition: margin 0.3s;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
&-mask {
|
|
26
|
-
position: fixed;
|
|
27
|
-
top: 0;
|
|
28
|
-
right: 0;
|
|
29
|
-
bottom: 0;
|
|
30
|
-
left: 0;
|
|
31
|
-
height: 100%;
|
|
32
|
-
opacity: 1;
|
|
33
|
-
|
|
34
|
-
&-hidden {
|
|
35
|
-
display: none;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.rc-trigger-popup-hidden {
|
|
41
|
-
display: none;
|
|
42
|
-
}
|
package/es/types.d.ts
DELETED
|
File without changes
|
package/es/types.js
DELETED
|
File without changes
|
package/es/upload/index.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { UploadProps } from 'antd';
|
|
2
|
-
import { UploadChangeParam } from 'antd/es/upload';
|
|
3
|
-
import { RecordType } from '../ccs';
|
|
4
|
-
import { ImageUpload } from './upload-image';
|
|
5
|
-
type FileValue = {
|
|
6
|
-
/** 文件ID */
|
|
7
|
-
fileId: string;
|
|
8
|
-
/** 文件名称 */
|
|
9
|
-
name: string;
|
|
10
|
-
};
|
|
11
|
-
export type CcsUploadProps = Pick<UploadProps, 'maxCount' | 'data' | 'multiple' | 'accept' | 'name' | 'headers'> & {
|
|
12
|
-
/** 最大文件数 */
|
|
13
|
-
maxFileSize?: number;
|
|
14
|
-
/** 上传按钮文本 */
|
|
15
|
-
uploadText?: string;
|
|
16
|
-
/** 图片下载地址 */
|
|
17
|
-
fileDownloadUrl?: string;
|
|
18
|
-
/** 文件id */
|
|
19
|
-
value?: string | string[] | FileValue[];
|
|
20
|
-
/** 上传change事件 */
|
|
21
|
-
onChange?: (value: any) => void;
|
|
22
|
-
/** 上传请求 */
|
|
23
|
-
uploadRequest: (file: File, options?: RecordType) => Promise<{
|
|
24
|
-
/** 成功标识 */
|
|
25
|
-
success: boolean;
|
|
26
|
-
/** 返回文件id */
|
|
27
|
-
data: string;
|
|
28
|
-
/** 异常消息 */
|
|
29
|
-
msg?: string;
|
|
30
|
-
}>;
|
|
31
|
-
};
|
|
32
|
-
export type FileUploadList = UploadChangeParam['fileList'][0] & {
|
|
33
|
-
fileId?: string;
|
|
34
|
-
};
|
|
35
|
-
/** 生成图片默认值 */
|
|
36
|
-
export declare function uploadDefaultFlies(value: CcsUploadProps['value'], fileDownloadUrl: string): FileUploadList[];
|
|
37
|
-
declare function CustomUpload({ value, uploadText, maxCount, maxFileSize, fileDownloadUrl, uploadRequest, onChange, ...otherProps }: CcsUploadProps): import("react/jsx-runtime").JSX.Element;
|
|
38
|
-
declare namespace CustomUpload {
|
|
39
|
-
var Image: typeof ImageUpload;
|
|
40
|
-
var displayName: string;
|
|
41
|
-
}
|
|
42
|
-
export default CustomUpload;
|
package/es/upload/index.js
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
var _excluded = ["value", "uploadText", "maxCount", "maxFileSize", "fileDownloadUrl", "uploadRequest", "onChange"];
|
|
2
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
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(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
8
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
9
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
10
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
11
|
-
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."); }
|
|
12
|
-
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); }
|
|
13
|
-
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; }
|
|
14
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
15
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
16
|
-
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; }
|
|
17
|
-
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; }
|
|
18
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
19
|
-
import { UploadOutlined } from '@ant-design/icons';
|
|
20
|
-
import { Button, Upload, message } from 'antd';
|
|
21
|
-
import { useState } from 'react';
|
|
22
|
-
import CcsDialog from "../dialog";
|
|
23
|
-
import { ImageUpload } from "./upload-image";
|
|
24
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
25
|
-
/** 生成图片默认值 */
|
|
26
|
-
export function uploadDefaultFlies(value, fileDownloadUrl) {
|
|
27
|
-
if (Array.isArray(value)) {
|
|
28
|
-
return value.map(function (v) {
|
|
29
|
-
if (typeof v === 'string') {
|
|
30
|
-
return {
|
|
31
|
-
uid: v,
|
|
32
|
-
name: v,
|
|
33
|
-
url: "".concat(fileDownloadUrl).concat(v),
|
|
34
|
-
fileId: v
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// 文件列表
|
|
39
|
-
if (_typeof(v) === 'object') {
|
|
40
|
-
return {
|
|
41
|
-
uid: v.fileId,
|
|
42
|
-
name: v.name,
|
|
43
|
-
url: "".concat(fileDownloadUrl).concat(v.fileId),
|
|
44
|
-
fileId: v.fileId
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
return undefined;
|
|
48
|
-
}).filter(function (f) {
|
|
49
|
-
return f;
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
if (typeof value === 'string') {
|
|
53
|
-
return [{
|
|
54
|
-
uid: value,
|
|
55
|
-
name: value,
|
|
56
|
-
url: "".concat(fileDownloadUrl).concat(value),
|
|
57
|
-
fileId: value
|
|
58
|
-
}];
|
|
59
|
-
}
|
|
60
|
-
return [];
|
|
61
|
-
}
|
|
62
|
-
function CustomUpload(_ref) {
|
|
63
|
-
var value = _ref.value,
|
|
64
|
-
uploadText = _ref.uploadText,
|
|
65
|
-
_ref$maxCount = _ref.maxCount,
|
|
66
|
-
maxCount = _ref$maxCount === void 0 ? 1 : _ref$maxCount,
|
|
67
|
-
_ref$maxFileSize = _ref.maxFileSize,
|
|
68
|
-
maxFileSize = _ref$maxFileSize === void 0 ? 10 : _ref$maxFileSize,
|
|
69
|
-
_ref$fileDownloadUrl = _ref.fileDownloadUrl,
|
|
70
|
-
fileDownloadUrl = _ref$fileDownloadUrl === void 0 ? '' : _ref$fileDownloadUrl,
|
|
71
|
-
uploadRequest = _ref.uploadRequest,
|
|
72
|
-
onChange = _ref.onChange,
|
|
73
|
-
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
74
|
-
var _useState = useState(function () {
|
|
75
|
-
return uploadDefaultFlies(value, fileDownloadUrl);
|
|
76
|
-
}),
|
|
77
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
78
|
-
files = _useState2[0],
|
|
79
|
-
setFiles = _useState2[1];
|
|
80
|
-
var handleOnChange = function handleOnChange(_ref2) {
|
|
81
|
-
var fileList = _ref2.fileList;
|
|
82
|
-
setFiles(fileList);
|
|
83
|
-
if (!onChange) return;
|
|
84
|
-
|
|
85
|
-
// 文件上传中,不更新结果
|
|
86
|
-
if (fileList.find(function (f) {
|
|
87
|
-
return f.status === 'uploading';
|
|
88
|
-
})) return;
|
|
89
|
-
if (maxCount === 1) {
|
|
90
|
-
var _fileList$, _fileList$2;
|
|
91
|
-
// 只能上传一个文件
|
|
92
|
-
onChange(((_fileList$ = fileList[0]) === null || _fileList$ === void 0 || (_fileList$ = _fileList$.response) === null || _fileList$ === void 0 ? void 0 : _fileList$.data) || ((_fileList$2 = fileList[0]) === null || _fileList$2 === void 0 ? void 0 : _fileList$2.fileId));
|
|
93
|
-
} else {
|
|
94
|
-
// 上传完成的文件,返回上传结果集
|
|
95
|
-
onChange(fileList.map(function (f) {
|
|
96
|
-
var _f$response;
|
|
97
|
-
return ((_f$response = f.response) === null || _f$response === void 0 ? void 0 : _f$response.data) || f.fileId;
|
|
98
|
-
}).filter(function (s) {
|
|
99
|
-
return s !== undefined;
|
|
100
|
-
}));
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
// 上传大小检查
|
|
105
|
-
var beforeUpload = function beforeUpload(file) {
|
|
106
|
-
var isLt2M = file.size / 1024 / 1024 < maxFileSize;
|
|
107
|
-
if (!isLt2M) {
|
|
108
|
-
message.error("\u6587\u4EF6\u4E0D\u80FD\u5927\u4E8E".concat(maxFileSize, "MB!"));
|
|
109
|
-
}
|
|
110
|
-
return isLt2M;
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
// 自定义上传
|
|
114
|
-
var onCustomRequest = /*#__PURE__*/function () {
|
|
115
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref3) {
|
|
116
|
-
var file, onSuccess, onError, result;
|
|
117
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
118
|
-
while (1) switch (_context.prev = _context.next) {
|
|
119
|
-
case 0:
|
|
120
|
-
file = _ref3.file, onSuccess = _ref3.onSuccess, onError = _ref3.onError;
|
|
121
|
-
_context.next = 3;
|
|
122
|
-
return uploadRequest(file);
|
|
123
|
-
case 3:
|
|
124
|
-
result = _context.sent;
|
|
125
|
-
// 上传成功
|
|
126
|
-
if (result.success && onSuccess) {
|
|
127
|
-
onSuccess(result);
|
|
128
|
-
}
|
|
129
|
-
// 上传失败
|
|
130
|
-
if (!result.success && onError) {
|
|
131
|
-
CcsDialog.message.error(result.msg || '上传失败');
|
|
132
|
-
onError({
|
|
133
|
-
status: 500,
|
|
134
|
-
name: '出错了',
|
|
135
|
-
message: result.msg || '上传失败'
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
case 6:
|
|
139
|
-
case "end":
|
|
140
|
-
return _context.stop();
|
|
141
|
-
}
|
|
142
|
-
}, _callee);
|
|
143
|
-
}));
|
|
144
|
-
return function onCustomRequest(_x) {
|
|
145
|
-
return _ref4.apply(this, arguments);
|
|
146
|
-
};
|
|
147
|
-
}();
|
|
148
|
-
return /*#__PURE__*/_jsx(Upload, _objectSpread(_objectSpread({
|
|
149
|
-
customRequest: onCustomRequest,
|
|
150
|
-
name: "fileName",
|
|
151
|
-
onChange: handleOnChange,
|
|
152
|
-
beforeUpload: beforeUpload,
|
|
153
|
-
fileList: files,
|
|
154
|
-
maxCount: maxCount
|
|
155
|
-
}, otherProps), {}, {
|
|
156
|
-
children: /*#__PURE__*/_jsx(Button, {
|
|
157
|
-
icon: /*#__PURE__*/_jsx(UploadOutlined, {}),
|
|
158
|
-
disabled: files.length >= maxCount,
|
|
159
|
-
children: uploadText
|
|
160
|
-
})
|
|
161
|
-
}));
|
|
162
|
-
}
|
|
163
|
-
CustomUpload.Image = ImageUpload;
|
|
164
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
165
|
-
CustomUpload.displayName = 'CcsUpload';
|
|
166
|
-
}
|
|
167
|
-
export default CustomUpload;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { CcsUploadProps } from './index';
|
|
2
|
-
type CcsImageUploadProps = CcsUploadProps & {
|
|
3
|
-
crop?: boolean;
|
|
4
|
-
};
|
|
5
|
-
export declare function ImageUpload({ uploadText, maxCount, maxFileSize, crop, value, fileDownloadUrl, uploadRequest, onChange, ...otherProps }: CcsImageUploadProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
-
export {};
|