@arco-design/mobile-react 2.28.2 → 2.29.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.en-US.md +2 -2
  3. package/README.md +2 -2
  4. package/cjs/grid/style/css/index.css +4 -0
  5. package/cjs/grid/style/index.less +6 -0
  6. package/cjs/index.d.ts +1 -0
  7. package/cjs/index.js +5 -1
  8. package/cjs/input/hooks.js +33 -40
  9. package/cjs/input/props.d.ts +1 -1
  10. package/cjs/skeleton/demo/style/css/mobile.css +7 -0
  11. package/cjs/skeleton/demo/style/mobile.less +13 -0
  12. package/cjs/skeleton/elements.d.ts +7 -0
  13. package/cjs/skeleton/elements.js +302 -0
  14. package/cjs/skeleton/index.d.ts +18 -0
  15. package/cjs/skeleton/index.js +100 -0
  16. package/cjs/skeleton/skeleton-context.d.ts +3 -0
  17. package/cjs/skeleton/skeleton-context.js +15 -0
  18. package/cjs/skeleton/style/css/index.css +180 -0
  19. package/cjs/skeleton/style/css/index.d.ts +3 -0
  20. package/cjs/skeleton/style/css/index.js +7 -0
  21. package/cjs/skeleton/style/index.d.ts +3 -0
  22. package/cjs/skeleton/style/index.js +7 -0
  23. package/cjs/skeleton/style/index.less +147 -0
  24. package/cjs/skeleton/type.d.ts +104 -0
  25. package/cjs/skeleton/type.js +3 -0
  26. package/cjs/style.d.ts +1 -0
  27. package/cjs/style.js +2 -0
  28. package/dist/index.js +423 -76
  29. package/dist/index.min.js +5 -5
  30. package/dist/style.css +123 -0
  31. package/dist/style.min.css +1 -1
  32. package/esm/grid/style/css/index.css +4 -0
  33. package/esm/grid/style/index.less +6 -0
  34. package/esm/index.d.ts +1 -0
  35. package/esm/index.js +1 -0
  36. package/esm/input/hooks.js +32 -40
  37. package/esm/input/props.d.ts +1 -1
  38. package/esm/skeleton/demo/style/css/mobile.css +7 -0
  39. package/esm/skeleton/demo/style/mobile.less +13 -0
  40. package/esm/skeleton/elements.d.ts +7 -0
  41. package/esm/skeleton/elements.js +281 -0
  42. package/esm/skeleton/index.d.ts +18 -0
  43. package/esm/skeleton/index.js +82 -0
  44. package/esm/skeleton/skeleton-context.d.ts +3 -0
  45. package/esm/skeleton/skeleton-context.js +5 -0
  46. package/esm/skeleton/style/css/index.css +180 -0
  47. package/esm/skeleton/style/css/index.d.ts +3 -0
  48. package/esm/skeleton/style/css/index.js +3 -0
  49. package/esm/skeleton/style/index.d.ts +3 -0
  50. package/esm/skeleton/style/index.js +3 -0
  51. package/esm/skeleton/style/index.less +147 -0
  52. package/esm/skeleton/type.d.ts +104 -0
  53. package/esm/skeleton/type.js +1 -0
  54. package/esm/style.d.ts +1 -0
  55. package/esm/style.js +1 -0
  56. package/package.json +3 -3
  57. package/tokens/app/arcodesign/default/css-variables.less +16 -0
  58. package/tokens/app/arcodesign/default/index.d.ts +16 -0
  59. package/tokens/app/arcodesign/default/index.js +17 -1
  60. package/tokens/app/arcodesign/default/index.json +190 -0
  61. package/tokens/app/arcodesign/default/index.less +16 -0
  62. package/umd/grid/style/css/index.css +4 -0
  63. package/umd/grid/style/index.less +6 -0
  64. package/umd/index.d.ts +1 -0
  65. package/umd/index.js +7 -5
  66. package/umd/input/hooks.js +36 -44
  67. package/umd/input/props.d.ts +1 -1
  68. package/umd/skeleton/demo/style/css/mobile.css +7 -0
  69. package/umd/skeleton/demo/style/mobile.less +13 -0
  70. package/umd/skeleton/elements.d.ts +7 -0
  71. package/umd/skeleton/elements.js +306 -0
  72. package/umd/skeleton/index.d.ts +18 -0
  73. package/umd/skeleton/index.js +104 -0
  74. package/umd/skeleton/skeleton-context.d.ts +3 -0
  75. package/umd/skeleton/skeleton-context.js +28 -0
  76. package/umd/skeleton/style/css/index.css +180 -0
  77. package/umd/skeleton/style/css/index.d.ts +3 -0
  78. package/umd/skeleton/style/css/index.js +15 -0
  79. package/umd/skeleton/style/index.d.ts +3 -0
  80. package/umd/skeleton/style/index.js +15 -0
  81. package/umd/skeleton/style/index.less +147 -0
  82. package/umd/skeleton/type.d.ts +104 -0
  83. package/umd/skeleton/type.js +17 -0
  84. package/umd/style.d.ts +1 -0
  85. package/umd/style.js +4 -4
@@ -1,3 +1,4 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  import React, { useState, useEffect, useRef } from 'react';
2
3
  import { cls, nextTick } from '@arco-design/mobile-utils';
3
4
  import IconClear from '../icon/IconClear';
@@ -47,23 +48,6 @@ export function useInputLogic(props, inputRef) {
47
48
  toggleClear = _useState2[1];
48
49
 
49
50
  var compositingRef = useRef(false);
50
- /**
51
- * clear相关问题背景
52
- * 如果点击clear按钮之前已经是focusing状态了,那么在点完clear按钮之后会手动聚焦一下
53
- * 该行为将导致onClear事件触发时,也会触发一次onBlur和onFocus事件,可能影响一些组件外的代码逻辑
54
- *
55
- * e.g. 假设input按钮右侧有一个按钮仅在聚焦时展示
56
- * 实现代码大致是:onBlur设置其visible为false,onFocus设置其visible为true
57
- * 那么这个按钮就会因为clear的点击造成一瞬的闪烁
58
- *
59
- * 解决思路
60
- * 先来看一下,在输入框已激活的状态时,点击清除按钮后,组件的一些事件的触发顺序
61
- * handleBlur -> handleClear -> handleFocus -> onBlur(外部回调) -> onFocus(外部回调)
62
- * 可以看到外部的onBlur和onFocus回调都是在handleClear函数之后被调用
63
- * 因此可以在handleClear中设置一个shouldPreventEvent的boolean标志
64
- * 如果这个标志为true,则跳过调用外部的onBlur和onFocus,并在最后再将标志置回false
65
- *
66
- */
67
51
 
68
52
  var _useState3 = useState(false),
69
53
  isFocusing = _useState3[0],
@@ -163,28 +147,24 @@ export function useInputLogic(props, inputRef) {
163
147
  }
164
148
 
165
149
  function handleFocus(e) {
166
- nextTick(function () {
167
- if (preventEventWhenClearing && shouldPreventEvent.current) {
168
- shouldPreventEvent.current = false;
169
- return;
170
- }
150
+ if (preventEventWhenClearing && shouldPreventEvent.current) {
151
+ shouldPreventEvent.current = false;
152
+ return;
153
+ }
171
154
 
172
- setIsFocusing(true);
173
- clearShowType === 'focus' && toggleClear(true);
174
- onFocus && onFocus(e);
175
- });
155
+ setIsFocusing(true);
156
+ clearShowType === 'focus' && toggleClear(true);
157
+ onFocus && onFocus(e);
176
158
  }
177
159
 
178
160
  function handleBlur(e) {
179
- nextTick(function () {
180
- if (preventEventWhenClearing && shouldPreventEvent.current) {
181
- return;
182
- }
161
+ if (preventEventWhenClearing && shouldPreventEvent.current) {
162
+ return;
163
+ }
183
164
 
184
- setIsFocusing(false);
185
- clearShowType === 'focus' && toggleClear(false);
186
- onBlur && onBlur(e);
187
- });
165
+ setIsFocusing(false);
166
+ clearShowType === 'focus' && toggleClear(false);
167
+ onBlur && onBlur(e);
188
168
  }
189
169
 
190
170
  function handleClick(e) {
@@ -215,10 +195,17 @@ export function useInputLogic(props, inputRef) {
215
195
 
216
196
  if (isFocusing) {
217
197
  if (preventEventWhenClearing) {
218
- shouldPreventEvent.current = true;
198
+ shouldPreventEvent.current = true; // 一段时间未执行blur或focus则重置,避免对下次事件循环造成影响
199
+ // @en If blur or focus is not executed for a period of time, it will be reset to avoid affecting the next event loop
200
+
201
+ setTimeout(function () {
202
+ shouldPreventEvent.current = false;
203
+ }, 200);
219
204
  }
220
205
 
221
- inputRef.current && inputRef.current.focus();
206
+ nextTick(function () {
207
+ inputRef.current && inputRef.current.focus();
208
+ });
222
209
  }
223
210
  });
224
211
  }
@@ -228,6 +215,12 @@ export function useInputLogic(props, inputRef) {
228
215
  }
229
216
 
230
217
  function renderWrapper(prefixCls, type, children) {
218
+ var _clearEvent;
219
+
220
+ // handleClear必须早于handleBlur执行,pc端仅mousedown事件触发早于blur,移动端touch相关事件均早于blur
221
+ // @en handleClear must be executed earlier than handleBlur
222
+ // @en only the mousedown event on the PC side is triggered earlier than blur, and the touch-related events on the mobile side are all earlier than blur
223
+ var clearEvent = (_clearEvent = {}, _clearEvent[system === 'pc' ? 'onMouseDown' : 'onTouchEnd'] = handleClear, _clearEvent);
231
224
  return /*#__PURE__*/React.createElement("div", {
232
225
  role: "search",
233
226
  className: prefixCls + "-container all-border-box " + (className || ''),
@@ -247,10 +240,9 @@ export function useInputLogic(props, inputRef) {
247
240
  className: cls(prefixCls + "-label", {
248
241
  required: required
249
242
  })
250
- }, label) : prefix) : null, children, clearable && showClear ? /*#__PURE__*/React.createElement("div", {
251
- className: prefixCls + "-clear",
252
- onClick: handleClear
253
- }, clearIcon) : null, suffix ? /*#__PURE__*/React.createElement("div", {
243
+ }, label) : prefix) : null, children, clearable && showClear ? /*#__PURE__*/React.createElement("div", _extends({
244
+ className: prefixCls + "-clear"
245
+ }, clearEvent), clearIcon) : null, suffix ? /*#__PURE__*/React.createElement("div", {
254
246
  className: prefixCls + "-suffix"
255
247
  }, suffix) : null), renderPendNode(append));
256
248
  }
@@ -124,7 +124,7 @@ export interface BasicInputProps<T = HTMLInputElement> {
124
124
  * 按下清除按钮回调
125
125
  * @en Callback when clear button is pressed
126
126
  */
127
- onClear?: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void;
127
+ onClear?: (e: React.TouchEvent<HTMLElement>) => void;
128
128
  /**
129
129
  * 输入框前置内容,在输入框内部,也可自定义
130
130
  * @en The prefix of the input box, inside the input box, can also be customized
@@ -0,0 +1,7 @@
1
+ #demo-skeleton .arcodesign-mobile-demo-content .arco-cell-group {
2
+ margin-bottom: 0.32rem;
3
+ }
4
+ #demo-skeleton .arcodesign-mobile-demo-content .arco-cell {
5
+ margin-left: 0;
6
+ padding-right: 0;
7
+ }
@@ -0,0 +1,13 @@
1
+ @import '../../../../style/mixin.less';
2
+
3
+ #demo-skeleton {
4
+ .arcodesign-mobile-demo-content {
5
+ .arco-cell-group {
6
+ margin-bottom: 0.32rem;
7
+ }
8
+ .arco-cell {
9
+ margin-left: 0;
10
+ padding-right: 0;
11
+ }
12
+ }
13
+ }
@@ -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
+ });
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { SkeletonProps, SkeletonRef } from './type';
3
+ declare const _default: React.ForwardRefExoticComponent<SkeletonProps & React.RefAttributes<SkeletonRef>> & {
4
+ Node: React.ForwardRefExoticComponent<import("./type").SkeletonNodeProps & React.RefAttributes<SkeletonRef>>;
5
+ Title: React.ForwardRefExoticComponent<import("./type").SkeletonTitleProps & React.RefAttributes<SkeletonRef>>;
6
+ Paragraph: React.ForwardRefExoticComponent<import("./type").SkeletonParagraphProps & React.RefAttributes<SkeletonRef>>;
7
+ Avatar: React.ForwardRefExoticComponent<import("./type").SkeletonAvatarProps & React.RefAttributes<SkeletonRef>>;
8
+ Grid: React.ForwardRefExoticComponent<import("./type").SkeletonGridProps & React.RefAttributes<SkeletonRef>>;
9
+ };
10
+ /**
11
+ * 在内容加载过程中展示一组占位图形。
12
+ * @en Display a set of placeholder graphics during content loading
13
+ * @type 信息展示
14
+ * @type_en Data Display
15
+ * @name 骨架屏
16
+ * @name_en Skeleton
17
+ */
18
+ export default _default;
@@ -0,0 +1,82 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React, { useRef, forwardRef, useImperativeHandle, useContext } from 'react';
3
+ import { cls, componentWrapper } from '@arco-design/mobile-utils';
4
+ import { GlobalContext } from '../context-provider';
5
+ import { SkeletonAvatar as Avatar, SkeletonGrid as Grid, SkeletonNode as Node, SkeletonParagraph as Paragraph, SkeletonTitle as Title } from './elements';
6
+ import { SkeletonContext } from './skeleton-context';
7
+
8
+ function getComponentProps(prop) {
9
+ if (prop && typeof prop === 'object') {
10
+ return prop;
11
+ }
12
+
13
+ return {};
14
+ }
15
+
16
+ var Skeleton = /*#__PURE__*/forwardRef(function (props, ref) {
17
+ var _cls;
18
+
19
+ var _props$className = props.className,
20
+ className = _props$className === void 0 ? '' : _props$className,
21
+ style = props.style,
22
+ children = props.children,
23
+ _props$title = props.title,
24
+ title = _props$title === void 0 ? true : _props$title,
25
+ _props$paragraph = props.paragraph,
26
+ paragraph = _props$paragraph === void 0 ? true : _props$paragraph,
27
+ _props$avatar = props.avatar,
28
+ avatar = _props$avatar === void 0 ? false : _props$avatar,
29
+ grid = props.grid,
30
+ _props$showAnimation = props.showAnimation,
31
+ showAnimation = _props$showAnimation === void 0 ? true : _props$showAnimation,
32
+ _props$animation = props.animation,
33
+ animation = _props$animation === void 0 ? 'gradient' : _props$animation,
34
+ animationGradientColor = props.animationGradientColor,
35
+ backgroundColor = props.backgroundColor;
36
+ var domRef = useRef(null);
37
+
38
+ var _useContext = useContext(GlobalContext),
39
+ prefixCls = _useContext.prefixCls;
40
+
41
+ useImperativeHandle(ref, function () {
42
+ return {
43
+ dom: domRef.current
44
+ };
45
+ });
46
+ var isGrid = !!grid;
47
+ var hasTitle = !!title;
48
+ var hasParagraph = !!paragraph;
49
+ var hasAvatar = !!avatar;
50
+ var content = isGrid ? /*#__PURE__*/React.createElement(Grid, getComponentProps(grid)) : /*#__PURE__*/React.createElement(React.Fragment, null, hasAvatar && /*#__PURE__*/React.createElement(Avatar, getComponentProps(avatar)), (hasTitle || hasParagraph) && /*#__PURE__*/React.createElement("div", {
51
+ className: prefixCls + "-skeleton-content"
52
+ }, hasTitle && /*#__PURE__*/React.createElement(Title, getComponentProps(title)), hasParagraph && /*#__PURE__*/React.createElement(Paragraph, getComponentProps(paragraph))));
53
+ return /*#__PURE__*/React.createElement("div", {
54
+ className: cls(prefixCls + "-skeleton", (_cls = {}, _cls[prefixCls + "-skeleton-with-avatar"] = hasAvatar, _cls), className),
55
+ style: _extends({
56
+ color: animationGradientColor
57
+ }, style),
58
+ ref: domRef
59
+ }, /*#__PURE__*/React.createElement(SkeletonContext.Provider, {
60
+ value: {
61
+ showAnimation: showAnimation,
62
+ animation: animation,
63
+ backgroundColor: backgroundColor
64
+ }
65
+ }, content, children));
66
+ });
67
+ /**
68
+ * 在内容加载过程中展示一组占位图形。
69
+ * @en Display a set of placeholder graphics during content loading
70
+ * @type 信息展示
71
+ * @type_en Data Display
72
+ * @name 骨架屏
73
+ * @name_en Skeleton
74
+ */
75
+
76
+ export default componentWrapper(Skeleton, {
77
+ Node: Node,
78
+ Title: Title,
79
+ Paragraph: Paragraph,
80
+ Avatar: Avatar,
81
+ Grid: Grid
82
+ });
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { SkeletonContextParams } from './type';
3
+ export declare const SkeletonContext: React.Context<SkeletonContextParams>;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export var SkeletonContext = /*#__PURE__*/React.createContext({
3
+ showAnimation: true,
4
+ animation: 'gradient'
5
+ });