@arco-design/mobile-react 2.28.1 → 2.29.0
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/CHANGELOG.md +29 -0
- package/README.en-US.md +2 -2
- package/README.md +2 -2
- package/cjs/_helpers/hooks.d.ts +7 -1
- package/cjs/_helpers/hooks.js +9 -5
- package/cjs/form/form-item.js +109 -108
- package/cjs/grid/style/css/index.css +4 -0
- package/cjs/grid/style/index.less +6 -0
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +5 -1
- package/cjs/nav-bar/index.d.ts +3 -3
- package/cjs/picker-view/components/picker-cell.js +20 -6
- package/cjs/skeleton/demo/style/css/mobile.css +7 -0
- package/cjs/skeleton/demo/style/mobile.less +13 -0
- package/cjs/skeleton/elements.d.ts +7 -0
- package/cjs/skeleton/elements.js +302 -0
- package/cjs/skeleton/index.d.ts +18 -0
- package/cjs/skeleton/index.js +100 -0
- package/cjs/skeleton/skeleton-context.d.ts +3 -0
- package/cjs/skeleton/skeleton-context.js +15 -0
- package/cjs/skeleton/style/css/index.css +180 -0
- package/cjs/skeleton/style/css/index.d.ts +3 -0
- package/cjs/skeleton/style/css/index.js +7 -0
- package/cjs/skeleton/style/index.d.ts +3 -0
- package/cjs/skeleton/style/index.js +7 -0
- package/cjs/skeleton/style/index.less +147 -0
- package/cjs/skeleton/type.d.ts +104 -0
- package/cjs/skeleton/type.js +3 -0
- package/cjs/style.d.ts +1 -0
- package/cjs/style.js +2 -0
- package/cjs/tabs/index.js +8 -2
- package/dist/index.js +532 -147
- package/dist/index.min.js +5 -5
- package/dist/style.css +123 -0
- package/dist/style.min.css +1 -1
- package/esm/_helpers/hooks.d.ts +7 -1
- package/esm/_helpers/hooks.js +8 -2
- package/esm/form/form-item.js +109 -108
- package/esm/grid/style/css/index.css +4 -0
- package/esm/grid/style/index.less +6 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/esm/nav-bar/index.d.ts +3 -3
- package/esm/picker-view/components/picker-cell.js +20 -6
- package/esm/skeleton/demo/style/css/mobile.css +7 -0
- package/esm/skeleton/demo/style/mobile.less +13 -0
- package/esm/skeleton/elements.d.ts +7 -0
- package/esm/skeleton/elements.js +281 -0
- package/esm/skeleton/index.d.ts +18 -0
- package/esm/skeleton/index.js +82 -0
- package/esm/skeleton/skeleton-context.d.ts +3 -0
- package/esm/skeleton/skeleton-context.js +5 -0
- package/esm/skeleton/style/css/index.css +180 -0
- package/esm/skeleton/style/css/index.d.ts +3 -0
- package/esm/skeleton/style/css/index.js +3 -0
- package/esm/skeleton/style/index.d.ts +3 -0
- package/esm/skeleton/style/index.js +3 -0
- package/esm/skeleton/style/index.less +147 -0
- package/esm/skeleton/type.d.ts +104 -0
- package/esm/skeleton/type.js +1 -0
- package/esm/style.d.ts +1 -0
- package/esm/style.js +1 -0
- package/esm/tabs/index.js +9 -3
- package/package.json +3 -3
- package/tokens/app/arcodesign/default/css-variables.less +16 -0
- package/tokens/app/arcodesign/default/index.d.ts +16 -0
- package/tokens/app/arcodesign/default/index.js +17 -1
- package/tokens/app/arcodesign/default/index.json +190 -0
- package/tokens/app/arcodesign/default/index.less +16 -0
- package/umd/_helpers/hooks.d.ts +7 -1
- package/umd/_helpers/hooks.js +9 -5
- package/umd/form/form-item.js +109 -108
- package/umd/grid/style/css/index.css +4 -0
- package/umd/grid/style/index.less +6 -0
- package/umd/index.d.ts +1 -0
- package/umd/index.js +7 -5
- package/umd/nav-bar/index.d.ts +3 -3
- package/umd/picker-view/components/picker-cell.js +20 -6
- package/umd/skeleton/demo/style/css/mobile.css +7 -0
- package/umd/skeleton/demo/style/mobile.less +13 -0
- package/umd/skeleton/elements.d.ts +7 -0
- package/umd/skeleton/elements.js +306 -0
- package/umd/skeleton/index.d.ts +18 -0
- package/umd/skeleton/index.js +104 -0
- package/umd/skeleton/skeleton-context.d.ts +3 -0
- package/umd/skeleton/skeleton-context.js +28 -0
- package/umd/skeleton/style/css/index.css +180 -0
- package/umd/skeleton/style/css/index.d.ts +3 -0
- package/umd/skeleton/style/css/index.js +15 -0
- package/umd/skeleton/style/index.d.ts +3 -0
- package/umd/skeleton/style/index.js +15 -0
- package/umd/skeleton/style/index.less +147 -0
- package/umd/skeleton/type.d.ts +104 -0
- package/umd/skeleton/type.js +17 -0
- package/umd/style.d.ts +1 -0
- package/umd/style.js +4 -4
- package/umd/tabs/index.js +8 -2
package/esm/form/form-item.js
CHANGED
@@ -24,15 +24,96 @@ var FormItemInner = /*#__PURE__*/function (_PureComponent) {
|
|
24
24
|
_this._errors = [];
|
25
25
|
_this._touched = false;
|
26
26
|
|
27
|
+
_this.onValueChange = function (preStore, curStore) {
|
28
|
+
_this._touched = true;
|
29
|
+
var shouldUpdate = _this.props.shouldUpdate;
|
30
|
+
|
31
|
+
if (typeof shouldUpdate === 'function') {
|
32
|
+
shouldUpdate({
|
33
|
+
preStore: preStore,
|
34
|
+
curStore: curStore
|
35
|
+
}) && _this.forceUpdate();
|
36
|
+
return;
|
37
|
+
}
|
38
|
+
|
39
|
+
_this.forceUpdate();
|
40
|
+
};
|
41
|
+
|
42
|
+
_this.getFieldError = function () {
|
43
|
+
return _this._errors;
|
44
|
+
};
|
45
|
+
|
46
|
+
_this.isFieldTouched = function () {
|
47
|
+
return _this._touched;
|
48
|
+
};
|
49
|
+
|
50
|
+
_this.validateField = function () {
|
51
|
+
var validateMessages = _this.context.validateMessages;
|
52
|
+
var getFieldValue = _this.context.form.getFieldValue;
|
53
|
+
var _this$props = _this.props,
|
54
|
+
field = _this$props.field,
|
55
|
+
rules = _this$props.rules,
|
56
|
+
onValidateStatusChange = _this$props.onValidateStatusChange;
|
57
|
+
var value = getFieldValue(field);
|
58
|
+
|
59
|
+
if (rules != null && rules.length && field) {
|
60
|
+
var _Validator;
|
61
|
+
|
62
|
+
var fieldDom = _this.props.getFormItemRef();
|
63
|
+
|
64
|
+
var fieldValidator = new Validator((_Validator = {}, _Validator[field] = rules, _Validator), {
|
65
|
+
validateMessages: validateMessages
|
66
|
+
});
|
67
|
+
return new Promise(function (resolve) {
|
68
|
+
var _fieldValidator$valid;
|
69
|
+
|
70
|
+
fieldValidator.validate((_fieldValidator$valid = {}, _fieldValidator$valid[field] = value, _fieldValidator$valid), function (errorsMap) {
|
71
|
+
var _getErrorAndWarnings = getErrorAndWarnings((errorsMap == null ? void 0 : errorsMap[field]) || []),
|
72
|
+
errors = _getErrorAndWarnings.errors,
|
73
|
+
warnings = _getErrorAndWarnings.warnings;
|
74
|
+
|
75
|
+
_this._errors = errors;
|
76
|
+
onValidateStatusChange({
|
77
|
+
errors: _this._errors,
|
78
|
+
warnings: warnings
|
79
|
+
});
|
80
|
+
return resolve({
|
81
|
+
errors: _this._errors,
|
82
|
+
warnings: warnings,
|
83
|
+
value: value,
|
84
|
+
field: field,
|
85
|
+
dom: fieldDom
|
86
|
+
});
|
87
|
+
});
|
88
|
+
});
|
89
|
+
}
|
90
|
+
|
91
|
+
return Promise.resolve({
|
92
|
+
errors: [],
|
93
|
+
warnings: [],
|
94
|
+
value: value,
|
95
|
+
field: field,
|
96
|
+
dom: null
|
97
|
+
});
|
98
|
+
};
|
99
|
+
|
100
|
+
_this.setFieldData = function (value) {
|
101
|
+
var field = _this.props.field;
|
102
|
+
var setFieldValue = _this.context.form.setFieldValue;
|
103
|
+
setFieldValue(field, value);
|
104
|
+
|
105
|
+
_this.validateField();
|
106
|
+
};
|
107
|
+
|
27
108
|
_this.innerTriggerFunction = function (_, value) {
|
28
109
|
var _children$props;
|
29
110
|
|
30
111
|
_this.setFieldData(value);
|
31
112
|
|
32
|
-
var _this$
|
33
|
-
children = _this$
|
34
|
-
_this$
|
35
|
-
trigger = _this$
|
113
|
+
var _this$props2 = _this.props,
|
114
|
+
children = _this$props2.children,
|
115
|
+
_this$props2$trigger = _this$props2.trigger,
|
116
|
+
trigger = _this$props2$trigger === void 0 ? 'onChange' : _this$props2$trigger;
|
36
117
|
|
37
118
|
if (trigger && (_children$props = children.props) != null && _children$props[trigger]) {
|
38
119
|
var _children$props2;
|
@@ -50,10 +131,10 @@ var FormItemInner = /*#__PURE__*/function (_PureComponent) {
|
|
50
131
|
|
51
132
|
_this.setFieldData(value);
|
52
133
|
|
53
|
-
var _this$
|
54
|
-
children = _this$
|
55
|
-
_this$
|
56
|
-
trigger = _this$
|
134
|
+
var _this$props3 = _this.props,
|
135
|
+
children = _this$props3.children,
|
136
|
+
_this$props3$trigger = _this$props3.trigger,
|
137
|
+
trigger = _this$props3$trigger === void 0 ? 'onChange' : _this$props3$trigger;
|
57
138
|
|
58
139
|
if (trigger && (_children$props3 = children.props) != null && _children$props3[trigger]) {
|
59
140
|
var _children$props4;
|
@@ -66,6 +147,24 @@ var FormItemInner = /*#__PURE__*/function (_PureComponent) {
|
|
66
147
|
}
|
67
148
|
};
|
68
149
|
|
150
|
+
_this.innerClearFunction = function () {
|
151
|
+
var _children$props5;
|
152
|
+
|
153
|
+
var children = _this.props.children;
|
154
|
+
|
155
|
+
_this.setFieldData('');
|
156
|
+
|
157
|
+
if ((_children$props5 = children.props) != null && _children$props5.onClear) {
|
158
|
+
var _children$props6;
|
159
|
+
|
160
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
161
|
+
args[_key3] = arguments[_key3];
|
162
|
+
}
|
163
|
+
|
164
|
+
(_children$props6 = children.props) == null ? void 0 : _children$props6.onClear.apply(_children$props6, args);
|
165
|
+
}
|
166
|
+
};
|
167
|
+
|
69
168
|
_this.destroyField = function () {};
|
70
169
|
|
71
170
|
if (props != null && props.initialValue && props.field) {
|
@@ -93,108 +192,10 @@ var FormItemInner = /*#__PURE__*/function (_PureComponent) {
|
|
93
192
|
this.destroyField();
|
94
193
|
};
|
95
194
|
|
96
|
-
_proto.onValueChange = function onValueChange(preStore, curStore) {
|
97
|
-
this._touched = true;
|
98
|
-
var shouldUpdate = this.props.shouldUpdate;
|
99
|
-
|
100
|
-
if (typeof shouldUpdate === 'function') {
|
101
|
-
shouldUpdate({
|
102
|
-
preStore: preStore,
|
103
|
-
curStore: curStore
|
104
|
-
}) && this.forceUpdate();
|
105
|
-
return;
|
106
|
-
}
|
107
|
-
|
108
|
-
this.forceUpdate();
|
109
|
-
};
|
110
|
-
|
111
|
-
_proto.getFieldError = function getFieldError() {
|
112
|
-
return this._errors;
|
113
|
-
};
|
114
|
-
|
115
|
-
_proto.isFieldTouched = function isFieldTouched() {
|
116
|
-
return this._touched;
|
117
|
-
};
|
118
|
-
|
119
|
-
_proto.validateField = function validateField() {
|
120
|
-
var _this2 = this;
|
121
|
-
|
122
|
-
var validateMessages = this.context.validateMessages;
|
123
|
-
var getFieldValue = this.context.form.getFieldValue;
|
124
|
-
var _this$props3 = this.props,
|
125
|
-
field = _this$props3.field,
|
126
|
-
rules = _this$props3.rules,
|
127
|
-
onValidateStatusChange = _this$props3.onValidateStatusChange;
|
128
|
-
var value = getFieldValue(field);
|
129
|
-
|
130
|
-
if (rules != null && rules.length && field) {
|
131
|
-
var _Validator;
|
132
|
-
|
133
|
-
var fieldDom = this.props.getFormItemRef();
|
134
|
-
var fieldValidator = new Validator((_Validator = {}, _Validator[field] = rules, _Validator), {
|
135
|
-
validateMessages: validateMessages
|
136
|
-
});
|
137
|
-
return new Promise(function (resolve) {
|
138
|
-
var _fieldValidator$valid;
|
139
|
-
|
140
|
-
fieldValidator.validate((_fieldValidator$valid = {}, _fieldValidator$valid[field] = value, _fieldValidator$valid), function (errorsMap) {
|
141
|
-
var _getErrorAndWarnings = getErrorAndWarnings((errorsMap == null ? void 0 : errorsMap[field]) || []),
|
142
|
-
errors = _getErrorAndWarnings.errors,
|
143
|
-
warnings = _getErrorAndWarnings.warnings;
|
144
|
-
|
145
|
-
_this2._errors = errors;
|
146
|
-
onValidateStatusChange({
|
147
|
-
errors: _this2._errors,
|
148
|
-
warnings: warnings
|
149
|
-
});
|
150
|
-
return resolve({
|
151
|
-
errors: _this2._errors,
|
152
|
-
warnings: warnings,
|
153
|
-
value: value,
|
154
|
-
field: field,
|
155
|
-
dom: fieldDom
|
156
|
-
});
|
157
|
-
});
|
158
|
-
});
|
159
|
-
}
|
160
|
-
|
161
|
-
return Promise.resolve({
|
162
|
-
errors: [],
|
163
|
-
warnings: [],
|
164
|
-
value: value,
|
165
|
-
field: field,
|
166
|
-
dom: null
|
167
|
-
});
|
168
|
-
};
|
169
|
-
|
170
|
-
_proto.setFieldData = function setFieldData(value) {
|
171
|
-
var field = this.props.field;
|
172
|
-
var setFieldValue = this.context.form.setFieldValue;
|
173
|
-
setFieldValue(field, value);
|
174
|
-
this.validateField();
|
175
|
-
};
|
176
|
-
|
177
|
-
_proto.innerClearFunction = function innerClearFunction() {
|
178
|
-
var _children$props5;
|
179
|
-
|
180
|
-
var children = this.props.children;
|
181
|
-
this.setFieldData('');
|
182
|
-
|
183
|
-
if ((_children$props5 = children.props) != null && _children$props5.onClear) {
|
184
|
-
var _children$props6;
|
185
|
-
|
186
|
-
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
187
|
-
args[_key3] = arguments[_key3];
|
188
|
-
}
|
189
|
-
|
190
|
-
(_children$props6 = children.props) == null ? void 0 : _children$props6.onClear.apply(_children$props6, args);
|
191
|
-
}
|
192
|
-
};
|
193
|
-
|
194
195
|
_proto.renderChildren = function renderChildren() {
|
195
196
|
var _props,
|
196
197
|
_children$type,
|
197
|
-
|
198
|
+
_this2 = this;
|
198
199
|
|
199
200
|
var _this$props4 = this.props,
|
200
201
|
children = _this$props4.children,
|
@@ -269,7 +270,7 @@ var FormItemInner = /*#__PURE__*/function (_PureComponent) {
|
|
269
270
|
props.error = this._errors;
|
270
271
|
|
271
272
|
props[trigger] = function (newValue) {
|
272
|
-
|
273
|
+
_this2.setFieldData(newValue);
|
273
274
|
|
274
275
|
for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
275
276
|
args[_key4 - 1] = arguments[_key4];
|
package/esm/index.d.ts
CHANGED
@@ -43,6 +43,7 @@ export { default as PullRefresh } from './pull-refresh';
|
|
43
43
|
export { default as Radio } from './radio';
|
44
44
|
export { default as Rate } from './rate';
|
45
45
|
export { default as SearchBar } from './search-bar';
|
46
|
+
export { default as Skeleton } from './skeleton';
|
46
47
|
export { default as ShowMonitor } from './show-monitor';
|
47
48
|
export { default as Slider } from './slider';
|
48
49
|
export { default as Stepper } from './stepper';
|
package/esm/index.js
CHANGED
@@ -43,6 +43,7 @@ export { default as PullRefresh } from './pull-refresh';
|
|
43
43
|
export { default as Radio } from './radio';
|
44
44
|
export { default as Rate } from './rate';
|
45
45
|
export { default as SearchBar } from './search-bar';
|
46
|
+
export { default as Skeleton } from './skeleton';
|
46
47
|
export { default as ShowMonitor } from './show-monitor';
|
47
48
|
export { default as Slider } from './slider';
|
48
49
|
export { default as Stepper } from './stepper';
|
package/esm/nav-bar/index.d.ts
CHANGED
@@ -32,13 +32,13 @@ export interface NavBarProps {
|
|
32
32
|
*/
|
33
33
|
rightContent?: React.ReactNode;
|
34
34
|
/**
|
35
|
-
*
|
35
|
+
* 自定义样式,最外层元素的背景文字颜色可在此定义
|
36
36
|
* @en Custom stylesheet, background and text colors can be defined here
|
37
37
|
*/
|
38
38
|
style?: React.CSSProperties;
|
39
39
|
/**
|
40
|
-
*
|
41
|
-
* @en
|
40
|
+
* 内层自定义类名
|
41
|
+
* @en Inner custom classname
|
42
42
|
*/
|
43
43
|
className?: string;
|
44
44
|
/**
|
@@ -53,6 +53,7 @@ var PickerCell = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
53
53
|
var rowCount = Math.max(rows % 2 === 0 ? rows + 1 : rows, 3);
|
54
54
|
var isTouchMoveRef = useRef(false);
|
55
55
|
var isTouchStopped = useRef(false);
|
56
|
+
var unmountCallbackRef = useRef();
|
56
57
|
var timeRef = useRef(null);
|
57
58
|
var colStyle = useMemo(function () {
|
58
59
|
return getStyleWithVendor(_extends({
|
@@ -94,20 +95,24 @@ var PickerCell = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
94
95
|
}
|
95
96
|
|
96
97
|
setTransitionDuration(transDuration ? transDuration + "ms" : '');
|
97
|
-
setTransformY(transY); //
|
98
|
-
// @en handle the case of continuous sliding:
|
99
|
-
// 如果上一次callback还未执行,先cancel掉上一次回调,只执行最近的一次回调
|
100
|
-
// @en If the last callback has not been executed, cancel the last callback first, and only execute the latest callback
|
98
|
+
setTransformY(transY); // 处理连续滑动的情况:如果上一次callback还未执行,先cancel掉上一次回调
|
99
|
+
// @en handle the case of continuous sliding: If the last callback has not been executed, cancel the last callback first
|
101
100
|
|
102
101
|
if (latestCallbackTimer.current) {
|
103
102
|
clearTimeout(latestCallbackTimer.current);
|
104
103
|
}
|
105
104
|
|
106
|
-
|
105
|
+
var setNormalStatus = function setNormalStatus() {
|
106
|
+
// 如果timer顺利执行,则在unmount时不再重复执行
|
107
|
+
// @en If the timer is successfully executed, it will not be repeated when unmounting
|
108
|
+
unmountCallbackRef.current = undefined;
|
107
109
|
movingStatusRef.current = 'normal';
|
108
110
|
setTransitionDuration('');
|
109
111
|
callback();
|
110
|
-
}
|
112
|
+
};
|
113
|
+
|
114
|
+
unmountCallbackRef.current = setNormalStatus;
|
115
|
+
latestCallbackTimer.current = window.setTimeout(setNormalStatus, transDuration);
|
111
116
|
}
|
112
117
|
|
113
118
|
function _scrollToIndex(itemIndex, transDuration, callback) {
|
@@ -305,6 +310,15 @@ var PickerCell = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
305
310
|
_scrollToIndexWithChange(itemIndex, 200);
|
306
311
|
}
|
307
312
|
|
313
|
+
useEffect(function () {
|
314
|
+
return function () {
|
315
|
+
// 卸载组件时,如果timer中还有未执行的onchange操作,则立刻执行该操作并移除timer
|
316
|
+
// @en When unloading the component, if there is an unexecuted onchange operation in the timer, execute it immediately and remove the timer
|
317
|
+
var timerId = latestCallbackTimer.current;
|
318
|
+
unmountCallbackRef.current == null ? void 0 : unmountCallbackRef.current();
|
319
|
+
timerId && clearTimeout(timerId);
|
320
|
+
};
|
321
|
+
}, []);
|
308
322
|
useEffect(function () {
|
309
323
|
if (wrapRef.current) {
|
310
324
|
wrapRef.current.addEventListener('touchstart', _handleColumnTouchStart);
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { SkeletonAvatarProps, SkeletonGridProps, SkeletonNodeProps, SkeletonParagraphProps, SkeletonRef, SkeletonTitleProps } from './type';
|
3
|
+
export declare const SkeletonNode: React.ForwardRefExoticComponent<SkeletonNodeProps & React.RefAttributes<SkeletonRef>>;
|
4
|
+
export declare const SkeletonTitle: React.ForwardRefExoticComponent<SkeletonTitleProps & React.RefAttributes<SkeletonRef>>;
|
5
|
+
export declare const SkeletonParagraph: React.ForwardRefExoticComponent<SkeletonParagraphProps & React.RefAttributes<SkeletonRef>>;
|
6
|
+
export declare const SkeletonAvatar: React.ForwardRefExoticComponent<SkeletonAvatarProps & React.RefAttributes<SkeletonRef>>;
|
7
|
+
export declare const SkeletonGrid: React.ForwardRefExoticComponent<SkeletonGridProps & React.RefAttributes<SkeletonRef>>;
|
@@ -0,0 +1,281 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import React, { forwardRef, useContext, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
3
|
+
import { cls, isArray, nextTick } from '@arco-design/mobile-utils';
|
4
|
+
import { useListenResize } from '../_helpers';
|
5
|
+
import { GlobalContext } from '../context-provider';
|
6
|
+
import { SkeletonContext } from './skeleton-context';
|
7
|
+
|
8
|
+
var calcOffset = function calcOffset(dom, useRtl) {
|
9
|
+
if (!dom) {
|
10
|
+
return 0;
|
11
|
+
}
|
12
|
+
|
13
|
+
if (useRtl) {
|
14
|
+
return dom.offsetLeft - dom.offsetTop;
|
15
|
+
}
|
16
|
+
|
17
|
+
return dom.offsetLeft + dom.offsetTop;
|
18
|
+
};
|
19
|
+
|
20
|
+
function useOffset(dom, useRtl) {
|
21
|
+
var _useState = useState(),
|
22
|
+
offset = _useState[0],
|
23
|
+
setOffset = _useState[1];
|
24
|
+
|
25
|
+
var calcLayout = function calcLayout() {
|
26
|
+
var isList = Array.isArray(dom);
|
27
|
+
|
28
|
+
if (!(isList ? dom.length > 0 : dom == null ? void 0 : dom.current)) {
|
29
|
+
return;
|
30
|
+
}
|
31
|
+
|
32
|
+
setOffset(isList ? dom.map(function (item) {
|
33
|
+
return calcOffset(item, useRtl);
|
34
|
+
}) : calcOffset(dom.current, useRtl));
|
35
|
+
};
|
36
|
+
|
37
|
+
useEffect(function () {
|
38
|
+
nextTick(function () {
|
39
|
+
calcLayout();
|
40
|
+
});
|
41
|
+
}, [dom, useRtl]);
|
42
|
+
useListenResize(calcLayout);
|
43
|
+
return offset;
|
44
|
+
}
|
45
|
+
|
46
|
+
export var SkeletonNode = /*#__PURE__*/forwardRef(function (props, ref) {
|
47
|
+
var _props$className = props.className,
|
48
|
+
className = _props$className === void 0 ? '' : _props$className,
|
49
|
+
style = props.style,
|
50
|
+
children = props.children;
|
51
|
+
|
52
|
+
var _useContext = useContext(GlobalContext),
|
53
|
+
useRtl = _useContext.useRtl,
|
54
|
+
prefixCls = _useContext.prefixCls;
|
55
|
+
|
56
|
+
var _useContext2 = useContext(SkeletonContext),
|
57
|
+
backgroundColor = _useContext2.backgroundColor,
|
58
|
+
showAnimation = _useContext2.showAnimation,
|
59
|
+
animation = _useContext2.animation;
|
60
|
+
|
61
|
+
var domRef = useRef(null);
|
62
|
+
var isGradientAnimation = showAnimation && animation === 'gradient';
|
63
|
+
var offset = useOffset(isGradientAnimation ? domRef : undefined, useRtl);
|
64
|
+
useImperativeHandle(ref, function () {
|
65
|
+
return {
|
66
|
+
dom: domRef.current
|
67
|
+
};
|
68
|
+
});
|
69
|
+
return /*#__PURE__*/React.createElement("div", {
|
70
|
+
className: cls(prefixCls + "-skeleton-item", prefixCls + "-skeleton-node", showAnimation && prefixCls + "-skeleton-animation-" + animation, className),
|
71
|
+
style: _extends({
|
72
|
+
backgroundColor: backgroundColor
|
73
|
+
}, style),
|
74
|
+
ref: domRef
|
75
|
+
}, children, isGradientAnimation && offset !== undefined && /*#__PURE__*/React.createElement("div", {
|
76
|
+
className: prefixCls + "-skeleton-animation-item",
|
77
|
+
style: {
|
78
|
+
left: 0 - offset
|
79
|
+
}
|
80
|
+
}));
|
81
|
+
});
|
82
|
+
export var SkeletonTitle = /*#__PURE__*/forwardRef(function (props, ref) {
|
83
|
+
var _props$className2 = props.className,
|
84
|
+
className = _props$className2 === void 0 ? '' : _props$className2,
|
85
|
+
style = props.style,
|
86
|
+
_props$width = props.width,
|
87
|
+
width = _props$width === void 0 ? '40%' : _props$width;
|
88
|
+
|
89
|
+
var _useContext3 = useContext(GlobalContext),
|
90
|
+
useRtl = _useContext3.useRtl,
|
91
|
+
prefixCls = _useContext3.prefixCls;
|
92
|
+
|
93
|
+
var _useContext4 = useContext(SkeletonContext),
|
94
|
+
backgroundColor = _useContext4.backgroundColor,
|
95
|
+
showAnimation = _useContext4.showAnimation,
|
96
|
+
animation = _useContext4.animation;
|
97
|
+
|
98
|
+
var domRef = useRef(null);
|
99
|
+
var isGradientAnimation = showAnimation && animation === 'gradient';
|
100
|
+
var offset = useOffset(isGradientAnimation ? domRef : undefined, useRtl);
|
101
|
+
useImperativeHandle(ref, function () {
|
102
|
+
return {
|
103
|
+
dom: domRef.current
|
104
|
+
};
|
105
|
+
});
|
106
|
+
return /*#__PURE__*/React.createElement("div", {
|
107
|
+
className: cls(prefixCls + "-skeleton-item", prefixCls + "-skeleton-title", showAnimation && prefixCls + "-skeleton-animation-" + animation, className),
|
108
|
+
style: _extends({
|
109
|
+
width: width,
|
110
|
+
backgroundColor: backgroundColor
|
111
|
+
}, style),
|
112
|
+
ref: domRef
|
113
|
+
}, isGradientAnimation && offset !== undefined && /*#__PURE__*/React.createElement("div", {
|
114
|
+
className: prefixCls + "-skeleton-animation-item",
|
115
|
+
style: {
|
116
|
+
left: 0 - offset
|
117
|
+
}
|
118
|
+
}));
|
119
|
+
});
|
120
|
+
export var SkeletonParagraph = /*#__PURE__*/forwardRef(function (props, ref) {
|
121
|
+
var _props$className3 = props.className,
|
122
|
+
className = _props$className3 === void 0 ? '' : _props$className3,
|
123
|
+
style = props.style,
|
124
|
+
_props$rows = props.rows,
|
125
|
+
rows = _props$rows === void 0 ? 3 : _props$rows,
|
126
|
+
_props$width2 = props.width,
|
127
|
+
width = _props$width2 === void 0 ? '60%' : _props$width2;
|
128
|
+
|
129
|
+
var _useContext5 = useContext(GlobalContext),
|
130
|
+
useRtl = _useContext5.useRtl,
|
131
|
+
prefixCls = _useContext5.prefixCls;
|
132
|
+
|
133
|
+
var _useContext6 = useContext(SkeletonContext),
|
134
|
+
backgroundColor = _useContext6.backgroundColor,
|
135
|
+
showAnimation = _useContext6.showAnimation,
|
136
|
+
animation = _useContext6.animation;
|
137
|
+
|
138
|
+
var domRef = useRef(null);
|
139
|
+
var lineDomRefs = useRef([]);
|
140
|
+
var isGradientAnimation = showAnimation && animation === 'gradient';
|
141
|
+
var offsets = useOffset(isGradientAnimation ? lineDomRefs.current : undefined, useRtl);
|
142
|
+
useImperativeHandle(ref, function () {
|
143
|
+
return {
|
144
|
+
dom: domRef.current
|
145
|
+
};
|
146
|
+
});
|
147
|
+
|
148
|
+
var getWidth = function getWidth(idx) {
|
149
|
+
if (isArray(width)) {
|
150
|
+
return width[idx];
|
151
|
+
}
|
152
|
+
|
153
|
+
if (rows - 1 === idx) {
|
154
|
+
return width;
|
155
|
+
}
|
156
|
+
|
157
|
+
return undefined;
|
158
|
+
};
|
159
|
+
|
160
|
+
return /*#__PURE__*/React.createElement("div", {
|
161
|
+
className: cls(prefixCls + "-skeleton-paragraph", className),
|
162
|
+
style: style,
|
163
|
+
ref: domRef
|
164
|
+
}, Array.from(new Array(rows)).map(function (_, idx) {
|
165
|
+
return /*#__PURE__*/React.createElement("div", {
|
166
|
+
key: idx,
|
167
|
+
className: cls(prefixCls + "-skeleton-item", prefixCls + "-skeleton-paragraph-line", showAnimation && prefixCls + "-skeleton-animation-" + animation),
|
168
|
+
style: {
|
169
|
+
width: getWidth(idx),
|
170
|
+
backgroundColor: backgroundColor
|
171
|
+
},
|
172
|
+
ref: function ref(el) {
|
173
|
+
return el && (lineDomRefs.current[idx] = el);
|
174
|
+
}
|
175
|
+
}, isGradientAnimation && offsets !== undefined && /*#__PURE__*/React.createElement("div", {
|
176
|
+
className: prefixCls + "-skeleton-animation-item",
|
177
|
+
style: {
|
178
|
+
left: 0 - (offsets[idx] || 0)
|
179
|
+
}
|
180
|
+
}));
|
181
|
+
}));
|
182
|
+
});
|
183
|
+
export var SkeletonAvatar = /*#__PURE__*/forwardRef(function (props, ref) {
|
184
|
+
var _props$className4 = props.className,
|
185
|
+
className = _props$className4 === void 0 ? '' : _props$className4,
|
186
|
+
style = props.style;
|
187
|
+
|
188
|
+
var _useContext7 = useContext(GlobalContext),
|
189
|
+
useRtl = _useContext7.useRtl,
|
190
|
+
prefixCls = _useContext7.prefixCls;
|
191
|
+
|
192
|
+
var _useContext8 = useContext(SkeletonContext),
|
193
|
+
backgroundColor = _useContext8.backgroundColor,
|
194
|
+
showAnimation = _useContext8.showAnimation,
|
195
|
+
animation = _useContext8.animation;
|
196
|
+
|
197
|
+
var domRef = useRef(null);
|
198
|
+
var isGradientAnimation = showAnimation && animation === 'gradient';
|
199
|
+
var offset = useOffset(isGradientAnimation ? domRef : undefined, useRtl);
|
200
|
+
useImperativeHandle(ref, function () {
|
201
|
+
return {
|
202
|
+
dom: domRef.current
|
203
|
+
};
|
204
|
+
});
|
205
|
+
return /*#__PURE__*/React.createElement("div", {
|
206
|
+
className: cls(prefixCls + "-skeleton-item", prefixCls + "-skeleton-avatar", showAnimation && prefixCls + "-skeleton-animation-" + animation, className),
|
207
|
+
style: _extends({
|
208
|
+
backgroundColor: backgroundColor
|
209
|
+
}, style),
|
210
|
+
ref: domRef
|
211
|
+
}, isGradientAnimation && offset !== undefined && /*#__PURE__*/React.createElement("div", {
|
212
|
+
className: prefixCls + "-skeleton-animation-item",
|
213
|
+
style: {
|
214
|
+
left: 0 - offset
|
215
|
+
}
|
216
|
+
}));
|
217
|
+
});
|
218
|
+
export var SkeletonGrid = /*#__PURE__*/forwardRef(function (props, ref) {
|
219
|
+
var _props$className5 = props.className,
|
220
|
+
className = _props$className5 === void 0 ? '' : _props$className5,
|
221
|
+
style = props.style,
|
222
|
+
_props$columns = props.columns,
|
223
|
+
columns = _props$columns === void 0 ? 4 : _props$columns;
|
224
|
+
|
225
|
+
var _useContext9 = useContext(GlobalContext),
|
226
|
+
useRtl = _useContext9.useRtl,
|
227
|
+
prefixCls = _useContext9.prefixCls;
|
228
|
+
|
229
|
+
var _useContext10 = useContext(SkeletonContext),
|
230
|
+
backgroundColor = _useContext10.backgroundColor,
|
231
|
+
showAnimation = _useContext10.showAnimation,
|
232
|
+
animation = _useContext10.animation;
|
233
|
+
|
234
|
+
var domRef = useRef(null);
|
235
|
+
var iconDomRefs = useRef([]);
|
236
|
+
var textDomRefs = useRef([]);
|
237
|
+
var isGradientAnimation = showAnimation && animation === 'gradient';
|
238
|
+
var iconOffsets = useOffset(isGradientAnimation ? iconDomRefs.current : undefined, useRtl);
|
239
|
+
var textOffsets = useOffset(isGradientAnimation ? textDomRefs.current : undefined, useRtl);
|
240
|
+
useImperativeHandle(ref, function () {
|
241
|
+
return {
|
242
|
+
dom: domRef.current
|
243
|
+
};
|
244
|
+
});
|
245
|
+
return /*#__PURE__*/React.createElement("div", {
|
246
|
+
className: cls(prefixCls + "-skeleton-grid", className),
|
247
|
+
style: style,
|
248
|
+
ref: domRef
|
249
|
+
}, Array.from(new Array(columns)).map(function (_, idx) {
|
250
|
+
return /*#__PURE__*/React.createElement("div", {
|
251
|
+
key: idx,
|
252
|
+
className: cls(prefixCls + "-skeleton-grid-item")
|
253
|
+
}, /*#__PURE__*/React.createElement("div", {
|
254
|
+
className: cls(prefixCls + "-skeleton-item", prefixCls + "-skeleton-grid-icon", showAnimation && prefixCls + "-skeleton-animation-" + animation),
|
255
|
+
style: {
|
256
|
+
backgroundColor: backgroundColor
|
257
|
+
},
|
258
|
+
ref: function ref(el) {
|
259
|
+
return el && (iconDomRefs.current[idx] = el);
|
260
|
+
}
|
261
|
+
}, isGradientAnimation && iconOffsets !== undefined && /*#__PURE__*/React.createElement("div", {
|
262
|
+
className: prefixCls + "-skeleton-animation-item",
|
263
|
+
style: {
|
264
|
+
left: 0 - ((iconOffsets == null ? void 0 : iconOffsets[idx]) || 0)
|
265
|
+
}
|
266
|
+
})), /*#__PURE__*/React.createElement("div", {
|
267
|
+
className: cls(prefixCls + "-skeleton-item", prefixCls + "-skeleton-grid-text", showAnimation && prefixCls + "-skeleton-animation-" + animation),
|
268
|
+
style: {
|
269
|
+
backgroundColor: backgroundColor
|
270
|
+
},
|
271
|
+
ref: function ref(el) {
|
272
|
+
return el && (textDomRefs.current[idx] = el);
|
273
|
+
}
|
274
|
+
}, isGradientAnimation && textOffsets !== undefined && /*#__PURE__*/React.createElement("div", {
|
275
|
+
className: prefixCls + "-skeleton-animation-item",
|
276
|
+
style: {
|
277
|
+
left: 0 - ((textOffsets == null ? void 0 : textOffsets[idx]) || 0)
|
278
|
+
}
|
279
|
+
})));
|
280
|
+
}));
|
281
|
+
});
|