@pointcloud/pcloud-components 0.1.21 → 0.1.23

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 (60) hide show
  1. package/README.md +1 -1
  2. package/dist/esm/AdvancedFilter/FormFilter.js +3 -3
  3. package/dist/esm/AdvancedFilter/interface.d.ts +3 -3
  4. package/dist/esm/AdvancedFilter/styles/index.less +146 -146
  5. package/dist/esm/ColorPicker/index.js +1 -1
  6. package/dist/esm/ColorPicker/index.less +18 -18
  7. package/dist/esm/ColorPicker/interface.d.ts +3 -3
  8. package/dist/esm/ConfigProvider/interface.d.ts +1 -1
  9. package/dist/esm/DCascader/index.js +6 -6
  10. package/dist/esm/DCascader/index.less +24 -24
  11. package/dist/esm/DForm/DItem/itemsRender.js +2 -0
  12. package/dist/esm/DForm/helper.js +6 -6
  13. package/dist/esm/DForm/index.js +1 -1
  14. package/dist/esm/DForm/index.less +45 -45
  15. package/dist/esm/DInput/index.js +14 -14
  16. package/dist/esm/DModal/interface.d.ts +2 -2
  17. package/dist/esm/DModal/styles/index.less +27 -27
  18. package/dist/esm/DSelect/index.js +39 -45
  19. package/dist/esm/DTable/index.js +6 -6
  20. package/dist/esm/DTable/index.less +71 -71
  21. package/dist/esm/DTreeSelect/index.less +11 -11
  22. package/dist/esm/DUpload/helper.js +47 -47
  23. package/dist/esm/DUpload/index.d.ts +1 -1
  24. package/dist/esm/DUpload/index.js +6 -6
  25. package/dist/esm/DUpload/index.less +19 -19
  26. package/dist/esm/ErrorBoundary/index.less +44 -44
  27. package/dist/esm/IPAddress/index.d.ts +23 -0
  28. package/dist/esm/IPAddress/index.js +243 -0
  29. package/dist/esm/IPAddress/index.less +63 -0
  30. package/dist/esm/IconFont/index.d.ts +17 -0
  31. package/dist/esm/IconFont/index.js +27 -0
  32. package/dist/esm/InfiniteScrollList/styles/index.less +22 -22
  33. package/dist/esm/LabelValue/interface.d.ts +1 -1
  34. package/dist/esm/LabelValue/styles/index.less +23 -23
  35. package/dist/esm/Loading/hooks/useLoading.d.ts +6 -0
  36. package/dist/esm/Loading/hooks/useLoading.js +35 -0
  37. package/dist/esm/Loading/index.d.ts +5 -4
  38. package/dist/esm/Loading/index.js +9 -9
  39. package/dist/esm/Loading/interface.d.ts +6 -3
  40. package/dist/esm/Loading/loading.d.ts +2 -4
  41. package/dist/esm/Loading/loading.js +5 -3
  42. package/dist/esm/Loading/styles/index.less +25 -25
  43. package/dist/esm/NoData/styles/index.less +24 -24
  44. package/dist/esm/PictureCard/index.d.ts +1 -1
  45. package/dist/esm/PictureCard/index.less +28 -28
  46. package/dist/esm/RCropper/handler.d.ts +16 -0
  47. package/dist/esm/RCropper/handler.js +146 -0
  48. package/dist/esm/RCropper/index.d.ts +4 -0
  49. package/dist/esm/RCropper/index.js +183 -0
  50. package/dist/esm/RCropper/interface.d.ts +70 -0
  51. package/dist/esm/RCropper/interface.js +1 -0
  52. package/dist/esm/RCropper/styles/toolbar.less +25 -0
  53. package/dist/esm/RCropper/toolbar.d.ts +5 -0
  54. package/dist/esm/RCropper/toolbar.js +74 -0
  55. package/dist/esm/commonStyle/index.less +1 -1
  56. package/dist/esm/index.d.ts +7 -1
  57. package/dist/esm/index.js +5 -2
  58. package/dist/umd/pcloud-components.min.css +1 -1
  59. package/dist/umd/pcloud-components.min.js +1 -1
  60. package/package.json +108 -106
@@ -1,44 +1,44 @@
1
- @import '../commonStyle/index.less';
2
-
3
- .@{prefix}-error-boundary {
4
- display: flex;
5
- flex-direction: column;
6
- align-items: center;
7
- justify-content: center;
8
- width: auto;
9
- margin: 20px;
10
- padding: 15px;
11
- background-color: rgb(221, 127, 127);
12
- border-radius: 10px;
13
-
14
- .error-text {
15
- margin-top: 20px;
16
- }
17
-
18
- .error-refresh {
19
- width: 140px;
20
- height: 40px;
21
- color: white;
22
- font-weight: bold;
23
- line-height: 40px;
24
- text-align: center;
25
- background-color: #4593ef;
26
- border-radius: 5px;
27
- cursor: pointer;
28
- }
29
-
30
- .errorDetiles {
31
- .detilesLink {
32
- color: blue;
33
- }
34
-
35
- .errordetails {
36
- padding: 10px;
37
- color: #777;
38
- font-size: 80%;
39
- background-color: rgb(204, 198, 190);
40
- border: 1px solid #777;
41
- border-radius: 5px;
42
- }
43
- }
44
- }
1
+ @import '../commonStyle/index.less';
2
+
3
+ .@{prefix}-error-boundary {
4
+ display: flex;
5
+ flex-direction: column;
6
+ align-items: center;
7
+ justify-content: center;
8
+ width: auto;
9
+ margin: 20px;
10
+ padding: 15px;
11
+ background-color: rgb(221, 127, 127);
12
+ border-radius: 10px;
13
+
14
+ .error-text {
15
+ margin-top: 20px;
16
+ }
17
+
18
+ .error-refresh {
19
+ width: 140px;
20
+ height: 40px;
21
+ color: white;
22
+ font-weight: bold;
23
+ line-height: 40px;
24
+ text-align: center;
25
+ background-color: #4593ef;
26
+ border-radius: 5px;
27
+ cursor: pointer;
28
+ }
29
+
30
+ .errorDetiles {
31
+ .detilesLink {
32
+ color: blue;
33
+ }
34
+
35
+ .errordetails {
36
+ padding: 10px;
37
+ color: #777;
38
+ font-size: 80%;
39
+ background-color: rgb(204, 198, 190);
40
+ border: 1px solid #777;
41
+ border-radius: 5px;
42
+ }
43
+ }
44
+ }
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ export interface IPAddressProps {
4
+ className?: string;
5
+ value?: string;
6
+ onChange?: (_value: string) => void;
7
+ onFocus?: (_value: string, _index: number) => void;
8
+ onBlur?: (_value: string, _index: number) => void;
9
+ type?: 'IPv4' | 'IPv6';
10
+ delimiter?: React.ReactNode;
11
+ readOnly?: boolean;
12
+ disabled?: boolean;
13
+ size?: 'small' | 'middle' | 'large';
14
+ style?: React.CSSProperties;
15
+ inputProps?: {
16
+ style?: React.CSSProperties;
17
+ [key: string]: any;
18
+ };
19
+ autoComplete?: boolean;
20
+ normalize?: boolean;
21
+ }
22
+ declare const IPAddress: React.FC<IPAddressProps>;
23
+ export default IPAddress;
@@ -0,0 +1,243 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
5
+ import React, { useState, useEffect, useRef, useCallback, useContext } from 'react';
6
+ import classNames from 'classnames';
7
+ import { ConfigContext } from "../ConfigProvider";
8
+ import "./index.less";
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ import { jsxs as _jsxs } from "react/jsx-runtime";
11
+ // IPv6 规范化函数
12
+ var normalizeIPv6 = function normalizeIPv6(ipv6) {
13
+ if (!ipv6) return '';
14
+ if (ipv6 === '::') return '0000:0000:0000:0000:0000:0000:0000:0000';
15
+ // 处理开头/结尾的 ::
16
+ var normalized = ipv6;
17
+ if (normalized.startsWith('::')) normalized = '0' + normalized;
18
+ if (normalized.endsWith('::')) normalized = normalized + '0';
19
+ var parts = normalized.split('::');
20
+ var leftParts = parts[0].split(':').filter(Boolean);
21
+ var rightParts = parts.length > 1 ? parts[1].split(':').filter(Boolean) : [];
22
+ var zeroSegmentsNeeded = 8 - leftParts.length - rightParts.length;
23
+ var zeroSegments = Array(zeroSegmentsNeeded).fill('0000');
24
+ return [].concat(_toConsumableArray(leftParts), _toConsumableArray(zeroSegments), _toConsumableArray(rightParts)).map(function (segment) {
25
+ return segment.padStart(4, '0');
26
+ }).join(':');
27
+ };
28
+ var getInitialAddress = function getInitialAddress(type, value) {
29
+ if (!value) {
30
+ var len = type === 'IPv6' ? 8 : 4;
31
+ return Array.from({
32
+ length: len
33
+ }, function () {
34
+ return {
35
+ value: ''
36
+ };
37
+ });
38
+ }
39
+ if (type === 'IPv6') {
40
+ var normalized = normalizeIPv6(value);
41
+ return normalized.split(':').map(function (i) {
42
+ return {
43
+ value: i
44
+ };
45
+ });
46
+ } else {
47
+ var parts = value.split('.').map(function (i) {
48
+ return {
49
+ value: i
50
+ };
51
+ });
52
+ while (parts.length < 4) parts.push({
53
+ value: ''
54
+ });
55
+ return parts.slice(0, 4);
56
+ }
57
+ };
58
+ var IPAddress = function IPAddress(props) {
59
+ var _props$className = props.className,
60
+ className = _props$className === void 0 ? '' : _props$className,
61
+ value = props.value,
62
+ _props$type = props.type,
63
+ type = _props$type === void 0 ? 'IPv4' : _props$type,
64
+ delimiter = props.delimiter,
65
+ readOnly = props.readOnly,
66
+ disabled = props.disabled,
67
+ _props$size = props.size,
68
+ size = _props$size === void 0 ? 'middle' : _props$size,
69
+ style = props.style,
70
+ inputProps = props.inputProps,
71
+ _props$autoComplete = props.autoComplete,
72
+ autoComplete = _props$autoComplete === void 0 ? true : _props$autoComplete,
73
+ _props$normalize = props.normalize,
74
+ normalize = _props$normalize === void 0 ? true : _props$normalize,
75
+ onChange = props.onChange,
76
+ onFocus = props.onFocus,
77
+ onBlur = props.onBlur;
78
+ var _useContext = useContext(ConfigContext),
79
+ prefixCls = _useContext.prefixCls,
80
+ getPrefixCls = _useContext.getPrefixCls;
81
+ var classname = getPrefixCls('ip-address');
82
+ var wrapperClass = classNames(_defineProperty({}, "".concat(prefixCls, "-ip-address"), !!prefixCls), classname);
83
+ var _useState = useState(function () {
84
+ return getInitialAddress(type, value);
85
+ }),
86
+ _useState2 = _slicedToArray(_useState, 2),
87
+ address = _useState2[0],
88
+ setAddress = _useState2[1];
89
+ var refs = useRef([]);
90
+ useEffect(function () {
91
+ setAddress(getInitialAddress(type, value));
92
+ }, [value, type]);
93
+ var getValue = useCallback(function (addr) {
94
+ var vals = addr.map(function (item) {
95
+ return item.value || '0';
96
+ });
97
+ var splitSymbol = type === 'IPv6' ? ':' : '.';
98
+ if (type !== 'IPv6') return vals.join(splitSymbol);
99
+ if (normalize) return normalizeIPv6(vals.join(splitSymbol));
100
+
101
+ // 1. 去除前导零但保留至少一个0
102
+ var simplifiedSegments = vals.map(function (seg) {
103
+ if (seg === '0') return '0';
104
+ var trimmed = seg.replace(/^0+/, '');
105
+ return trimmed === '' ? '0' : trimmed;
106
+ });
107
+
108
+ // 2. 查找最长连续0段用于压缩
109
+ var bestZeroRange = {
110
+ start: -1,
111
+ length: 0
112
+ };
113
+ var currentZeroStart = -1;
114
+ simplifiedSegments.forEach(function (seg, i) {
115
+ if (seg === '0') {
116
+ if (currentZeroStart === -1) currentZeroStart = i;
117
+ var currentLength = i - currentZeroStart + 1;
118
+ if (currentLength > bestZeroRange.length) {
119
+ bestZeroRange = {
120
+ start: currentZeroStart,
121
+ length: currentLength
122
+ };
123
+ }
124
+ } else {
125
+ currentZeroStart = -1;
126
+ }
127
+ });
128
+
129
+ // 3. 生成压缩后的地址
130
+ if (bestZeroRange.length >= 2) {
131
+ var before = simplifiedSegments.slice(0, bestZeroRange.start);
132
+ var after = simplifiedSegments.slice(bestZeroRange.start + bestZeroRange.length);
133
+ var beforeStr = before.join(':');
134
+ var afterStr = after.join(':');
135
+
136
+ // 处理边界情况
137
+ if (before.length === 0 && after.length === 0) return '::'; // 全零情况
138
+ if (before.length === 0) return '::' + afterStr; // 开头压缩
139
+ if (after.length === 0) return beforeStr + '::'; // 结尾压缩
140
+
141
+ return beforeStr + '::' + afterStr;
142
+ }
143
+ return simplifiedSegments.join(':');
144
+ }, [type, normalize]);
145
+ var handleInput = useCallback(function (idx, v) {
146
+ var nv = v;
147
+ var maxLen = type === 'IPv6' ? 4 : 3;
148
+ if (type === 'IPv6') {
149
+ nv = v.replace(/[^a-fA-F0-9]/g, '').toLowerCase();
150
+ } else {
151
+ nv = v.replace(/\D/g, '');
152
+ if (nv && parseInt(nv, 10) > 255) {
153
+ nv = '255';
154
+ }
155
+ }
156
+ if (nv.length > maxLen) nv = nv.slice(0, maxLen);
157
+
158
+ // 自动聚焦下一个输入框
159
+ if (autoComplete && type === 'IPv6' && nv.length === maxLen && idx < (type === 'IPv6' ? 7 : 3)) {
160
+ var _refs$current;
161
+ (_refs$current = refs.current[idx + 1]) === null || _refs$current === void 0 || _refs$current.focus();
162
+ }
163
+ var next = address.map(function (item, i) {
164
+ return i === idx ? {
165
+ value: nv
166
+ } : item;
167
+ });
168
+ setAddress(next);
169
+ if (onChange) {
170
+ onChange(getValue(next));
171
+ }
172
+ }, [address, autoComplete, getValue, onChange, type]);
173
+ var handleKeyUp = useCallback(function (idx, value) {
174
+ if (autoComplete && (type === 'IPv4' && value.length === 3 && idx < 3 || type === 'IPv6' && value.length === 4 && idx < 7)) {
175
+ var _refs$current2;
176
+ (_refs$current2 = refs.current[idx + 1]) === null || _refs$current2 === void 0 || _refs$current2.focus();
177
+ }
178
+ }, [type, autoComplete]);
179
+ var handleFocus = function handleFocus(idx, value) {
180
+ onFocus === null || onFocus === void 0 || onFocus(value, idx);
181
+ };
182
+ var handleBlur = function handleBlur(idx, value) {
183
+ onBlur === null || onBlur === void 0 || onBlur(value, idx);
184
+ };
185
+ var renderDelimiter = function renderDelimiter() {
186
+ if (delimiter) return /*#__PURE__*/_jsx("span", {
187
+ children: delimiter
188
+ });
189
+ return type === 'IPv6' ? /*#__PURE__*/_jsx("span", {
190
+ style: {
191
+ margin: '0 2px',
192
+ color: '#00000040'
193
+ },
194
+ children: ":"
195
+ }) : /*#__PURE__*/_jsx("span", {
196
+ style: {
197
+ margin: '0 2px',
198
+ color: '#00000040'
199
+ },
200
+ children: "\xB7"
201
+ });
202
+ };
203
+ return /*#__PURE__*/_jsx("div", {
204
+ className: "".concat(wrapperClass, " ").concat(className, " ").concat(size, " ").concat(disabled ? 'disabled' : '', " ").concat(readOnly ? 'readonly' : ''),
205
+ style: _objectSpread({
206
+ display: 'inline-block',
207
+ alignItems: 'center'
208
+ }, style),
209
+ children: address.map(function (item, idx) {
210
+ return /*#__PURE__*/_jsxs(React.Fragment, {
211
+ children: [/*#__PURE__*/_jsx("input", _objectSpread({
212
+ ref: function ref(el) {
213
+ return refs.current[idx] = el;
214
+ },
215
+ type: "text",
216
+ value: item.value,
217
+ readOnly: readOnly,
218
+ disabled: disabled,
219
+ maxLength: type === 'IPv6' ? 4 : 3,
220
+ style: _objectSpread({
221
+ width: type === 'IPv6' ? '4em' : '3em',
222
+ textAlign: 'center',
223
+ letterSpacing: type === 'IPv6' ? '0.1em' : undefined,
224
+ marginRight: idx < address.length - 1 ? 0 : undefined
225
+ }, inputProps === null || inputProps === void 0 ? void 0 : inputProps.style),
226
+ onChange: function onChange(e) {
227
+ return handleInput(idx, e.target.value);
228
+ },
229
+ onKeyUp: function onKeyUp(e) {
230
+ return handleKeyUp(idx, e.target.value);
231
+ },
232
+ onFocus: function onFocus(e) {
233
+ return handleFocus(idx, e.target.value);
234
+ },
235
+ onBlur: function onBlur(e) {
236
+ return handleBlur(idx, e.target.value);
237
+ }
238
+ }, inputProps)), idx < address.length - 1 && renderDelimiter()]
239
+ }, idx);
240
+ })
241
+ });
242
+ };
243
+ export default IPAddress;
@@ -0,0 +1,63 @@
1
+ @import '../commonStyle/index.less';
2
+
3
+ .@{prefix}-ip-address {
4
+ border: 1px solid #d9d9d9;
5
+ border-radius: 2px;
6
+ transition: all 0.3s;
7
+
8
+ &.small {
9
+ height: 24px;
10
+ }
11
+
12
+ &.large {
13
+ padding: 6.5px 10px;
14
+ }
15
+
16
+ &.middle {
17
+ padding: 4px 10px;
18
+ }
19
+
20
+ &.disabled {
21
+ color: rgba(0, 0, 0, 25%);
22
+ background-color: #f5f5f5;
23
+ border-color: #d9d9d9;
24
+ box-shadow: none;
25
+ cursor: not-allowed;
26
+ opacity: 1;
27
+
28
+ &:hover {
29
+ border-color: #d9d9d9;
30
+ }
31
+ }
32
+
33
+ &:hover {
34
+ border-color: #4d90ff;
35
+ }
36
+
37
+ &:focus-within {
38
+ border-color: #40a9ff;
39
+ box-shadow: 0 0 0 2px rgba(24, 144, 255, 20%);
40
+ }
41
+
42
+ input {
43
+ border: none;
44
+ background: none;
45
+ text-align: center;
46
+ outline: 0;
47
+ padding: 0;
48
+ margin: 0;
49
+ box-sizing: border-box;
50
+ font-variant: tabular-nums;
51
+ font-feature-settings: 'tnum';
52
+ position: relative;
53
+ display: inline-block;
54
+ color: #000000d9;
55
+ font-size: 14px;
56
+ line-height: 1.5715;
57
+ }
58
+
59
+ input[disabled] {
60
+ cursor: not-allowed;
61
+ color: inherit;
62
+ }
63
+ }
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { getTwoToneColor, setTwoToneColor } from '@ant-design/icons';
3
+ declare const setIconfontScriptUrl: (urls: string | string[]) => void;
4
+ export interface IconFontProps {
5
+ type: string;
6
+ scriptUrl?: string | string[];
7
+ className?: string;
8
+ style?: React.CSSProperties;
9
+ onClick?: React.MouseEventHandler<HTMLElement>;
10
+ }
11
+ interface IconFontType extends React.FC<IconFontProps> {
12
+ setIconfontScriptUrl: typeof setIconfontScriptUrl;
13
+ getTWoToneColor: typeof getTwoToneColor;
14
+ setTwoToneColor: typeof setTwoToneColor;
15
+ }
16
+ declare const IconFont: IconFontType;
17
+ export default IconFont;
@@ -0,0 +1,27 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ var _excluded = ["scriptUrl"];
4
+ import React from 'react';
5
+ import { createFromIconfontCN, getTwoToneColor, setTwoToneColor } from '@ant-design/icons';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ var scriptUrls = [];
8
+ var setIconfontScriptUrl = function setIconfontScriptUrl(urls) {
9
+ scriptUrls = Array.isArray(urls) ? urls : [urls];
10
+ };
11
+ var IconFont = function IconFont(_ref) {
12
+ var propScriptUrl = _ref.scriptUrl,
13
+ restProps = _objectWithoutProperties(_ref, _excluded);
14
+ var finalScriptUrls = propScriptUrl ? Array.isArray(propScriptUrl) ? propScriptUrl : [propScriptUrl] : scriptUrls;
15
+ if (!finalScriptUrls.length) {
16
+ console.error('IconFont 组件需要配置 scriptUrl,请在项目入口处先调用 setIconfontScriptUrl() 或在组件 props 中传入 scriptUrl');
17
+ return null;
18
+ }
19
+ var IconComponent = createFromIconfontCN({
20
+ scriptUrl: finalScriptUrls
21
+ });
22
+ return /*#__PURE__*/_jsx(IconComponent, _objectSpread({}, restProps));
23
+ };
24
+ IconFont.setIconfontScriptUrl = setIconfontScriptUrl;
25
+ IconFont.getTWoToneColor = getTwoToneColor;
26
+ IconFont.setTwoToneColor = setTwoToneColor;
27
+ export default IconFont;
@@ -1,22 +1,22 @@
1
- @import '../../commonStyle/index.less';
2
-
3
- .@{prefix}-infinite-scroll-wrapper {
4
- .ant-list .ant-row {
5
- margin-right: 0 !important;
6
- }
7
- }
8
-
9
- .scroll-container {
10
- position: relative;
11
-
12
- .backtop {
13
- right: 50px;
14
- }
15
-
16
- .up {
17
- background: #007aff;
18
- color: #fff;
19
- text-align: center;
20
- border-radius: 3px;
21
- }
22
- }
1
+ @import '../../commonStyle/index.less';
2
+
3
+ .@{prefix}-infinite-scroll-wrapper {
4
+ .ant-list .ant-row {
5
+ margin-right: 0 !important;
6
+ }
7
+ }
8
+
9
+ .scroll-container {
10
+ position: relative;
11
+
12
+ .backtop {
13
+ right: 50px;
14
+ }
15
+
16
+ .up {
17
+ background: #007aff;
18
+ color: #fff;
19
+ text-align: center;
20
+ border-radius: 3px;
21
+ }
22
+ }
@@ -11,7 +11,7 @@ export interface ILabelValueProps {
11
11
  /**
12
12
  * @description 格式化value值
13
13
  */
14
- formatter?: (v?: any) => string | React.ReactNode;
14
+ formatter?: (_v?: string | React.ReactNode) => string | React.ReactNode;
15
15
  /**
16
16
  * @description 文字标签值为空时的值
17
17
  * @default -
@@ -1,23 +1,23 @@
1
- @import '../../commonStyle/index.less';
2
-
3
- .@{prefix}-label-value {
4
- display: inline-flex;
5
-
6
- span {
7
- &:first-child {
8
- max-width: 120px;
9
- padding-right: 4px;
10
- white-space: nowrap;
11
- }
12
-
13
- &:last-child {
14
- flex: 1;
15
-
16
- &.no-wrap {
17
- overflow: hidden;
18
- white-space: nowrap;
19
- text-overflow: ellipsis;
20
- }
21
- }
22
- }
23
- }
1
+ @import '../../commonStyle/index.less';
2
+
3
+ .@{prefix}-label-value {
4
+ display: inline-flex;
5
+
6
+ span {
7
+ &:first-child {
8
+ max-width: 120px;
9
+ padding-right: 4px;
10
+ white-space: nowrap;
11
+ }
12
+
13
+ &:last-child {
14
+ flex: 1;
15
+
16
+ &.no-wrap {
17
+ overflow: hidden;
18
+ white-space: nowrap;
19
+ text-overflow: ellipsis;
20
+ }
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,6 @@
1
+ import type { ILoadingInstance, LoadingInstanceProps } from '../interface';
2
+ export declare const useLoading: (initialState?: boolean) => {
3
+ isLoading: boolean;
4
+ openLoading: (params?: LoadingInstanceProps) => ILoadingInstance;
5
+ closeLoading: () => void;
6
+ };
@@ -0,0 +1,35 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import { useState, useEffect, useRef } from 'react';
3
+ import loading from "../index";
4
+ export var useLoading = function useLoading() {
5
+ var initialState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
6
+ var _useState = useState(initialState),
7
+ _useState2 = _slicedToArray(_useState, 2),
8
+ isLoading = _useState2[0],
9
+ setIsLoading = _useState2[1];
10
+ var loadingRef = useRef(null);
11
+ useEffect(function () {
12
+ return function () {
13
+ if (loadingRef.current) {
14
+ loading.close();
15
+ }
16
+ };
17
+ }, []);
18
+ var openLoading = function openLoading(params) {
19
+ setIsLoading(true);
20
+ loadingRef.current = loading.open(params);
21
+ return loadingRef.current;
22
+ };
23
+ var closeLoading = function closeLoading() {
24
+ setIsLoading(false);
25
+ if (loadingRef.current) {
26
+ loading.close();
27
+ loadingRef.current = null;
28
+ }
29
+ };
30
+ return {
31
+ isLoading: isLoading,
32
+ openLoading: openLoading,
33
+ closeLoading: closeLoading
34
+ };
35
+ };
@@ -1,9 +1,10 @@
1
1
  import Loading from './loading';
2
- import { ILoadingProps, LoadingInstanceProps } from './interface';
2
+ import { LoadingInstanceProps, ILoadingInstance } from './interface';
3
+ import { useLoading } from './hooks/useLoading';
3
4
  declare const _default: {
4
- open(params?: LoadingInstanceProps): ILoadingProps;
5
+ open(params?: LoadingInstanceProps): ILoadingInstance;
5
6
  close(): void;
6
- getInstance(): ILoadingProps;
7
+ getInstance(): ILoadingInstance | null;
7
8
  };
8
9
  export default _default;
9
- export { Loading };
10
+ export { Loading, useLoading };
@@ -1,22 +1,22 @@
1
1
  import Loading from "./loading";
2
+ import { useLoading } from "./hooks/useLoading";
2
3
  var loadingInstance = null;
3
- var getLoadingInstance = function getLoadingInstance(params) {
4
- loadingInstance = loadingInstance || Loading.newInstance(params);
5
- return loadingInstance;
6
- };
7
4
  export default {
8
5
  open: function open(params) {
9
- return getLoadingInstance(params);
6
+ if (!loadingInstance) {
7
+ loadingInstance = Loading.newInstance(params);
8
+ }
9
+ return loadingInstance;
10
10
  },
11
11
  close: function close() {
12
12
  if (loadingInstance) {
13
- var _loadingInstance;
14
- (_loadingInstance = loadingInstance) === null || _loadingInstance === void 0 || _loadingInstance.destroy();
15
- loadingInstance = null;
13
+ var currentInstance = loadingInstance;
14
+ loadingInstance = null; // 先清空引用
15
+ currentInstance.destroy(); // 再销毁
16
16
  }
17
17
  },
18
18
  getInstance: function getInstance() {
19
19
  return loadingInstance;
20
20
  }
21
21
  };
22
- export { Loading };
22
+ export { Loading, useLoading };
@@ -1,5 +1,5 @@
1
1
  import { SpinProps } from 'antd';
2
- import React, { ReactInstance } from 'react';
2
+ import { ReactInstance } from 'react';
3
3
  export interface LoadingInstanceProps extends Omit<SpinProps, 'delay'> {
4
4
  /**
5
5
  * @description 加载框容器
@@ -12,9 +12,12 @@ export interface LoadingInstanceProps extends Omit<SpinProps, 'delay'> {
12
12
  */
13
13
  delay?: number;
14
14
  }
15
+ export interface ILoadingInstance {
16
+ destroy: () => void;
17
+ }
15
18
  export interface ILoadingProps {
16
- open: (_param: LoadingInstanceProps) => React.ReactNode;
19
+ open: (_params: LoadingInstanceProps) => ILoadingInstance;
20
+ getInstance: () => ILoadingInstance | null;
17
21
  close: () => void;
18
- getInstance: () => React.ReactNode;
19
22
  }
20
23
  export declare type LoadingProps = ILoadingProps;