@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.
Files changed (97) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.en-US.md +2 -2
  3. package/README.md +2 -2
  4. package/cjs/_helpers/hooks.d.ts +7 -1
  5. package/cjs/_helpers/hooks.js +9 -5
  6. package/cjs/form/form-item.js +109 -108
  7. package/cjs/grid/style/css/index.css +4 -0
  8. package/cjs/grid/style/index.less +6 -0
  9. package/cjs/index.d.ts +1 -0
  10. package/cjs/index.js +5 -1
  11. package/cjs/nav-bar/index.d.ts +3 -3
  12. package/cjs/picker-view/components/picker-cell.js +20 -6
  13. package/cjs/skeleton/demo/style/css/mobile.css +7 -0
  14. package/cjs/skeleton/demo/style/mobile.less +13 -0
  15. package/cjs/skeleton/elements.d.ts +7 -0
  16. package/cjs/skeleton/elements.js +302 -0
  17. package/cjs/skeleton/index.d.ts +18 -0
  18. package/cjs/skeleton/index.js +100 -0
  19. package/cjs/skeleton/skeleton-context.d.ts +3 -0
  20. package/cjs/skeleton/skeleton-context.js +15 -0
  21. package/cjs/skeleton/style/css/index.css +180 -0
  22. package/cjs/skeleton/style/css/index.d.ts +3 -0
  23. package/cjs/skeleton/style/css/index.js +7 -0
  24. package/cjs/skeleton/style/index.d.ts +3 -0
  25. package/cjs/skeleton/style/index.js +7 -0
  26. package/cjs/skeleton/style/index.less +147 -0
  27. package/cjs/skeleton/type.d.ts +104 -0
  28. package/cjs/skeleton/type.js +3 -0
  29. package/cjs/style.d.ts +1 -0
  30. package/cjs/style.js +2 -0
  31. package/cjs/tabs/index.js +8 -2
  32. package/dist/index.js +532 -147
  33. package/dist/index.min.js +5 -5
  34. package/dist/style.css +123 -0
  35. package/dist/style.min.css +1 -1
  36. package/esm/_helpers/hooks.d.ts +7 -1
  37. package/esm/_helpers/hooks.js +8 -2
  38. package/esm/form/form-item.js +109 -108
  39. package/esm/grid/style/css/index.css +4 -0
  40. package/esm/grid/style/index.less +6 -0
  41. package/esm/index.d.ts +1 -0
  42. package/esm/index.js +1 -0
  43. package/esm/nav-bar/index.d.ts +3 -3
  44. package/esm/picker-view/components/picker-cell.js +20 -6
  45. package/esm/skeleton/demo/style/css/mobile.css +7 -0
  46. package/esm/skeleton/demo/style/mobile.less +13 -0
  47. package/esm/skeleton/elements.d.ts +7 -0
  48. package/esm/skeleton/elements.js +281 -0
  49. package/esm/skeleton/index.d.ts +18 -0
  50. package/esm/skeleton/index.js +82 -0
  51. package/esm/skeleton/skeleton-context.d.ts +3 -0
  52. package/esm/skeleton/skeleton-context.js +5 -0
  53. package/esm/skeleton/style/css/index.css +180 -0
  54. package/esm/skeleton/style/css/index.d.ts +3 -0
  55. package/esm/skeleton/style/css/index.js +3 -0
  56. package/esm/skeleton/style/index.d.ts +3 -0
  57. package/esm/skeleton/style/index.js +3 -0
  58. package/esm/skeleton/style/index.less +147 -0
  59. package/esm/skeleton/type.d.ts +104 -0
  60. package/esm/skeleton/type.js +1 -0
  61. package/esm/style.d.ts +1 -0
  62. package/esm/style.js +1 -0
  63. package/esm/tabs/index.js +9 -3
  64. package/package.json +3 -3
  65. package/tokens/app/arcodesign/default/css-variables.less +16 -0
  66. package/tokens/app/arcodesign/default/index.d.ts +16 -0
  67. package/tokens/app/arcodesign/default/index.js +17 -1
  68. package/tokens/app/arcodesign/default/index.json +190 -0
  69. package/tokens/app/arcodesign/default/index.less +16 -0
  70. package/umd/_helpers/hooks.d.ts +7 -1
  71. package/umd/_helpers/hooks.js +9 -5
  72. package/umd/form/form-item.js +109 -108
  73. package/umd/grid/style/css/index.css +4 -0
  74. package/umd/grid/style/index.less +6 -0
  75. package/umd/index.d.ts +1 -0
  76. package/umd/index.js +7 -5
  77. package/umd/nav-bar/index.d.ts +3 -3
  78. package/umd/picker-view/components/picker-cell.js +20 -6
  79. package/umd/skeleton/demo/style/css/mobile.css +7 -0
  80. package/umd/skeleton/demo/style/mobile.less +13 -0
  81. package/umd/skeleton/elements.d.ts +7 -0
  82. package/umd/skeleton/elements.js +306 -0
  83. package/umd/skeleton/index.d.ts +18 -0
  84. package/umd/skeleton/index.js +104 -0
  85. package/umd/skeleton/skeleton-context.d.ts +3 -0
  86. package/umd/skeleton/skeleton-context.js +28 -0
  87. package/umd/skeleton/style/css/index.css +180 -0
  88. package/umd/skeleton/style/css/index.d.ts +3 -0
  89. package/umd/skeleton/style/css/index.js +15 -0
  90. package/umd/skeleton/style/index.d.ts +3 -0
  91. package/umd/skeleton/style/index.js +15 -0
  92. package/umd/skeleton/style/index.less +147 -0
  93. package/umd/skeleton/type.d.ts +104 -0
  94. package/umd/skeleton/type.js +17 -0
  95. package/umd/style.d.ts +1 -0
  96. package/umd/style.js +4 -4
  97. package/umd/tabs/index.js +8 -2
@@ -75,6 +75,7 @@
75
75
  var rowCount = Math.max(rows % 2 === 0 ? rows + 1 : rows, 3);
76
76
  var isTouchMoveRef = (0, _react.useRef)(false);
77
77
  var isTouchStopped = (0, _react.useRef)(false);
78
+ var unmountCallbackRef = (0, _react.useRef)();
78
79
  var timeRef = (0, _react.useRef)(null);
79
80
  var colStyle = (0, _react.useMemo)(function () {
80
81
  return (0, _helpers.getStyleWithVendor)((0, _extends2.default)({
@@ -116,20 +117,24 @@
116
117
  }
117
118
 
118
119
  setTransitionDuration(transDuration ? transDuration + "ms" : '');
119
- setTransformY(transY); // 处理连续滑动的情况:
120
- // @en handle the case of continuous sliding:
121
- // 如果上一次callback还未执行,先cancel掉上一次回调,只执行最近的一次回调
122
- // @en If the last callback has not been executed, cancel the last callback first, and only execute the latest callback
120
+ setTransformY(transY); // 处理连续滑动的情况:如果上一次callback还未执行,先cancel掉上一次回调
121
+ // @en handle the case of continuous sliding: If the last callback has not been executed, cancel the last callback first
123
122
 
124
123
  if (latestCallbackTimer.current) {
125
124
  clearTimeout(latestCallbackTimer.current);
126
125
  }
127
126
 
128
- latestCallbackTimer.current = window.setTimeout(function () {
127
+ var setNormalStatus = function setNormalStatus() {
128
+ // 如果timer顺利执行,则在unmount时不再重复执行
129
+ // @en If the timer is successfully executed, it will not be repeated when unmounting
130
+ unmountCallbackRef.current = undefined;
129
131
  movingStatusRef.current = 'normal';
130
132
  setTransitionDuration('');
131
133
  callback();
132
- }, transDuration);
134
+ };
135
+
136
+ unmountCallbackRef.current = setNormalStatus;
137
+ latestCallbackTimer.current = window.setTimeout(setNormalStatus, transDuration);
133
138
  }
134
139
 
135
140
  function _scrollToIndex(itemIndex, transDuration, callback) {
@@ -327,6 +332,15 @@
327
332
  _scrollToIndexWithChange(itemIndex, 200);
328
333
  }
329
334
 
335
+ (0, _react.useEffect)(function () {
336
+ return function () {
337
+ // 卸载组件时,如果timer中还有未执行的onchange操作,则立刻执行该操作并移除timer
338
+ // @en When unloading the component, if there is an unexecuted onchange operation in the timer, execute it immediately and remove the timer
339
+ var timerId = latestCallbackTimer.current;
340
+ unmountCallbackRef.current == null ? void 0 : unmountCallbackRef.current();
341
+ timerId && clearTimeout(timerId);
342
+ };
343
+ }, []);
330
344
  (0, _react.useEffect)(function () {
331
345
  if (wrapRef.current) {
332
346
  wrapRef.current.addEventListener('touchstart', _handleColumnTouchStart);
@@ -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,306 @@
1
+ (function (global, factory) {
2
+ if (typeof define === "function" && define.amd) {
3
+ define(["exports", "@babel/runtime/helpers/extends", "react", "@arco-design/mobile-utils", "../_helpers", "../context-provider", "./skeleton-context"], factory);
4
+ } else if (typeof exports !== "undefined") {
5
+ factory(exports, require("@babel/runtime/helpers/extends"), require("react"), require("@arco-design/mobile-utils"), require("../_helpers"), require("../context-provider"), require("./skeleton-context"));
6
+ } else {
7
+ var mod = {
8
+ exports: {}
9
+ };
10
+ factory(mod.exports, global._extends, global.react, global.mobileUtils, global._helpers, global.contextProvider, global.skeletonContext);
11
+ global.elements = mod.exports;
12
+ }
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _extends2, _react, _mobileUtils, _helpers, _contextProvider, _skeletonContext) {
14
+ "use strict";
15
+
16
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
17
+
18
+ _exports.__esModule = true;
19
+ _exports.SkeletonTitle = _exports.SkeletonParagraph = _exports.SkeletonNode = _exports.SkeletonGrid = _exports.SkeletonAvatar = void 0;
20
+ _extends2 = _interopRequireDefault(_extends2);
21
+ _react = _interopRequireWildcard(_react);
22
+
23
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
24
+
25
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
26
+
27
+ var calcOffset = function calcOffset(dom, useRtl) {
28
+ if (!dom) {
29
+ return 0;
30
+ }
31
+
32
+ if (useRtl) {
33
+ return dom.offsetLeft - dom.offsetTop;
34
+ }
35
+
36
+ return dom.offsetLeft + dom.offsetTop;
37
+ };
38
+
39
+ function useOffset(dom, useRtl) {
40
+ var _useState = (0, _react.useState)(),
41
+ offset = _useState[0],
42
+ setOffset = _useState[1];
43
+
44
+ var calcLayout = function calcLayout() {
45
+ var isList = Array.isArray(dom);
46
+
47
+ if (!(isList ? dom.length > 0 : dom == null ? void 0 : dom.current)) {
48
+ return;
49
+ }
50
+
51
+ setOffset(isList ? dom.map(function (item) {
52
+ return calcOffset(item, useRtl);
53
+ }) : calcOffset(dom.current, useRtl));
54
+ };
55
+
56
+ (0, _react.useEffect)(function () {
57
+ (0, _mobileUtils.nextTick)(function () {
58
+ calcLayout();
59
+ });
60
+ }, [dom, useRtl]);
61
+ (0, _helpers.useListenResize)(calcLayout);
62
+ return offset;
63
+ }
64
+
65
+ var SkeletonNode = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
66
+ var _props$className = props.className,
67
+ className = _props$className === void 0 ? '' : _props$className,
68
+ style = props.style,
69
+ children = props.children;
70
+
71
+ var _useContext = (0, _react.useContext)(_contextProvider.GlobalContext),
72
+ useRtl = _useContext.useRtl,
73
+ prefixCls = _useContext.prefixCls;
74
+
75
+ var _useContext2 = (0, _react.useContext)(_skeletonContext.SkeletonContext),
76
+ backgroundColor = _useContext2.backgroundColor,
77
+ showAnimation = _useContext2.showAnimation,
78
+ animation = _useContext2.animation;
79
+
80
+ var domRef = (0, _react.useRef)(null);
81
+ var isGradientAnimation = showAnimation && animation === 'gradient';
82
+ var offset = useOffset(isGradientAnimation ? domRef : undefined, useRtl);
83
+ (0, _react.useImperativeHandle)(ref, function () {
84
+ return {
85
+ dom: domRef.current
86
+ };
87
+ });
88
+ return /*#__PURE__*/_react.default.createElement("div", {
89
+ className: (0, _mobileUtils.cls)(prefixCls + "-skeleton-item", prefixCls + "-skeleton-node", showAnimation && prefixCls + "-skeleton-animation-" + animation, className),
90
+ style: (0, _extends2.default)({
91
+ backgroundColor: backgroundColor
92
+ }, style),
93
+ ref: domRef
94
+ }, children, isGradientAnimation && offset !== undefined && /*#__PURE__*/_react.default.createElement("div", {
95
+ className: prefixCls + "-skeleton-animation-item",
96
+ style: {
97
+ left: 0 - offset
98
+ }
99
+ }));
100
+ });
101
+ _exports.SkeletonNode = SkeletonNode;
102
+ var SkeletonTitle = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
103
+ var _props$className2 = props.className,
104
+ className = _props$className2 === void 0 ? '' : _props$className2,
105
+ style = props.style,
106
+ _props$width = props.width,
107
+ width = _props$width === void 0 ? '40%' : _props$width;
108
+
109
+ var _useContext3 = (0, _react.useContext)(_contextProvider.GlobalContext),
110
+ useRtl = _useContext3.useRtl,
111
+ prefixCls = _useContext3.prefixCls;
112
+
113
+ var _useContext4 = (0, _react.useContext)(_skeletonContext.SkeletonContext),
114
+ backgroundColor = _useContext4.backgroundColor,
115
+ showAnimation = _useContext4.showAnimation,
116
+ animation = _useContext4.animation;
117
+
118
+ var domRef = (0, _react.useRef)(null);
119
+ var isGradientAnimation = showAnimation && animation === 'gradient';
120
+ var offset = useOffset(isGradientAnimation ? domRef : undefined, useRtl);
121
+ (0, _react.useImperativeHandle)(ref, function () {
122
+ return {
123
+ dom: domRef.current
124
+ };
125
+ });
126
+ return /*#__PURE__*/_react.default.createElement("div", {
127
+ className: (0, _mobileUtils.cls)(prefixCls + "-skeleton-item", prefixCls + "-skeleton-title", showAnimation && prefixCls + "-skeleton-animation-" + animation, className),
128
+ style: (0, _extends2.default)({
129
+ width: width,
130
+ backgroundColor: backgroundColor
131
+ }, style),
132
+ ref: domRef
133
+ }, isGradientAnimation && offset !== undefined && /*#__PURE__*/_react.default.createElement("div", {
134
+ className: prefixCls + "-skeleton-animation-item",
135
+ style: {
136
+ left: 0 - offset
137
+ }
138
+ }));
139
+ });
140
+ _exports.SkeletonTitle = SkeletonTitle;
141
+ var SkeletonParagraph = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
142
+ var _props$className3 = props.className,
143
+ className = _props$className3 === void 0 ? '' : _props$className3,
144
+ style = props.style,
145
+ _props$rows = props.rows,
146
+ rows = _props$rows === void 0 ? 3 : _props$rows,
147
+ _props$width2 = props.width,
148
+ width = _props$width2 === void 0 ? '60%' : _props$width2;
149
+
150
+ var _useContext5 = (0, _react.useContext)(_contextProvider.GlobalContext),
151
+ useRtl = _useContext5.useRtl,
152
+ prefixCls = _useContext5.prefixCls;
153
+
154
+ var _useContext6 = (0, _react.useContext)(_skeletonContext.SkeletonContext),
155
+ backgroundColor = _useContext6.backgroundColor,
156
+ showAnimation = _useContext6.showAnimation,
157
+ animation = _useContext6.animation;
158
+
159
+ var domRef = (0, _react.useRef)(null);
160
+ var lineDomRefs = (0, _react.useRef)([]);
161
+ var isGradientAnimation = showAnimation && animation === 'gradient';
162
+ var offsets = useOffset(isGradientAnimation ? lineDomRefs.current : undefined, useRtl);
163
+ (0, _react.useImperativeHandle)(ref, function () {
164
+ return {
165
+ dom: domRef.current
166
+ };
167
+ });
168
+
169
+ var getWidth = function getWidth(idx) {
170
+ if ((0, _mobileUtils.isArray)(width)) {
171
+ return width[idx];
172
+ }
173
+
174
+ if (rows - 1 === idx) {
175
+ return width;
176
+ }
177
+
178
+ return undefined;
179
+ };
180
+
181
+ return /*#__PURE__*/_react.default.createElement("div", {
182
+ className: (0, _mobileUtils.cls)(prefixCls + "-skeleton-paragraph", className),
183
+ style: style,
184
+ ref: domRef
185
+ }, Array.from(new Array(rows)).map(function (_, idx) {
186
+ return /*#__PURE__*/_react.default.createElement("div", {
187
+ key: idx,
188
+ className: (0, _mobileUtils.cls)(prefixCls + "-skeleton-item", prefixCls + "-skeleton-paragraph-line", showAnimation && prefixCls + "-skeleton-animation-" + animation),
189
+ style: {
190
+ width: getWidth(idx),
191
+ backgroundColor: backgroundColor
192
+ },
193
+ ref: function ref(el) {
194
+ return el && (lineDomRefs.current[idx] = el);
195
+ }
196
+ }, isGradientAnimation && offsets !== undefined && /*#__PURE__*/_react.default.createElement("div", {
197
+ className: prefixCls + "-skeleton-animation-item",
198
+ style: {
199
+ left: 0 - (offsets[idx] || 0)
200
+ }
201
+ }));
202
+ }));
203
+ });
204
+ _exports.SkeletonParagraph = SkeletonParagraph;
205
+ var SkeletonAvatar = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
206
+ var _props$className4 = props.className,
207
+ className = _props$className4 === void 0 ? '' : _props$className4,
208
+ style = props.style;
209
+
210
+ var _useContext7 = (0, _react.useContext)(_contextProvider.GlobalContext),
211
+ useRtl = _useContext7.useRtl,
212
+ prefixCls = _useContext7.prefixCls;
213
+
214
+ var _useContext8 = (0, _react.useContext)(_skeletonContext.SkeletonContext),
215
+ backgroundColor = _useContext8.backgroundColor,
216
+ showAnimation = _useContext8.showAnimation,
217
+ animation = _useContext8.animation;
218
+
219
+ var domRef = (0, _react.useRef)(null);
220
+ var isGradientAnimation = showAnimation && animation === 'gradient';
221
+ var offset = useOffset(isGradientAnimation ? domRef : undefined, useRtl);
222
+ (0, _react.useImperativeHandle)(ref, function () {
223
+ return {
224
+ dom: domRef.current
225
+ };
226
+ });
227
+ return /*#__PURE__*/_react.default.createElement("div", {
228
+ className: (0, _mobileUtils.cls)(prefixCls + "-skeleton-item", prefixCls + "-skeleton-avatar", showAnimation && prefixCls + "-skeleton-animation-" + animation, className),
229
+ style: (0, _extends2.default)({
230
+ backgroundColor: backgroundColor
231
+ }, style),
232
+ ref: domRef
233
+ }, isGradientAnimation && offset !== undefined && /*#__PURE__*/_react.default.createElement("div", {
234
+ className: prefixCls + "-skeleton-animation-item",
235
+ style: {
236
+ left: 0 - offset
237
+ }
238
+ }));
239
+ });
240
+ _exports.SkeletonAvatar = SkeletonAvatar;
241
+ var SkeletonGrid = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
242
+ var _props$className5 = props.className,
243
+ className = _props$className5 === void 0 ? '' : _props$className5,
244
+ style = props.style,
245
+ _props$columns = props.columns,
246
+ columns = _props$columns === void 0 ? 4 : _props$columns;
247
+
248
+ var _useContext9 = (0, _react.useContext)(_contextProvider.GlobalContext),
249
+ useRtl = _useContext9.useRtl,
250
+ prefixCls = _useContext9.prefixCls;
251
+
252
+ var _useContext10 = (0, _react.useContext)(_skeletonContext.SkeletonContext),
253
+ backgroundColor = _useContext10.backgroundColor,
254
+ showAnimation = _useContext10.showAnimation,
255
+ animation = _useContext10.animation;
256
+
257
+ var domRef = (0, _react.useRef)(null);
258
+ var iconDomRefs = (0, _react.useRef)([]);
259
+ var textDomRefs = (0, _react.useRef)([]);
260
+ var isGradientAnimation = showAnimation && animation === 'gradient';
261
+ var iconOffsets = useOffset(isGradientAnimation ? iconDomRefs.current : undefined, useRtl);
262
+ var textOffsets = useOffset(isGradientAnimation ? textDomRefs.current : undefined, useRtl);
263
+ (0, _react.useImperativeHandle)(ref, function () {
264
+ return {
265
+ dom: domRef.current
266
+ };
267
+ });
268
+ return /*#__PURE__*/_react.default.createElement("div", {
269
+ className: (0, _mobileUtils.cls)(prefixCls + "-skeleton-grid", className),
270
+ style: style,
271
+ ref: domRef
272
+ }, Array.from(new Array(columns)).map(function (_, idx) {
273
+ return /*#__PURE__*/_react.default.createElement("div", {
274
+ key: idx,
275
+ className: (0, _mobileUtils.cls)(prefixCls + "-skeleton-grid-item")
276
+ }, /*#__PURE__*/_react.default.createElement("div", {
277
+ className: (0, _mobileUtils.cls)(prefixCls + "-skeleton-item", prefixCls + "-skeleton-grid-icon", showAnimation && prefixCls + "-skeleton-animation-" + animation),
278
+ style: {
279
+ backgroundColor: backgroundColor
280
+ },
281
+ ref: function ref(el) {
282
+ return el && (iconDomRefs.current[idx] = el);
283
+ }
284
+ }, isGradientAnimation && iconOffsets !== undefined && /*#__PURE__*/_react.default.createElement("div", {
285
+ className: prefixCls + "-skeleton-animation-item",
286
+ style: {
287
+ left: 0 - ((iconOffsets == null ? void 0 : iconOffsets[idx]) || 0)
288
+ }
289
+ })), /*#__PURE__*/_react.default.createElement("div", {
290
+ className: (0, _mobileUtils.cls)(prefixCls + "-skeleton-item", prefixCls + "-skeleton-grid-text", showAnimation && prefixCls + "-skeleton-animation-" + animation),
291
+ style: {
292
+ backgroundColor: backgroundColor
293
+ },
294
+ ref: function ref(el) {
295
+ return el && (textDomRefs.current[idx] = el);
296
+ }
297
+ }, isGradientAnimation && textOffsets !== undefined && /*#__PURE__*/_react.default.createElement("div", {
298
+ className: prefixCls + "-skeleton-animation-item",
299
+ style: {
300
+ left: 0 - ((textOffsets == null ? void 0 : textOffsets[idx]) || 0)
301
+ }
302
+ })));
303
+ }));
304
+ });
305
+ _exports.SkeletonGrid = SkeletonGrid;
306
+ });
@@ -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,104 @@
1
+ (function (global, factory) {
2
+ if (typeof define === "function" && define.amd) {
3
+ define(["exports", "@babel/runtime/helpers/extends", "react", "@arco-design/mobile-utils", "../context-provider", "./elements", "./skeleton-context"], factory);
4
+ } else if (typeof exports !== "undefined") {
5
+ factory(exports, require("@babel/runtime/helpers/extends"), require("react"), require("@arco-design/mobile-utils"), require("../context-provider"), require("./elements"), require("./skeleton-context"));
6
+ } else {
7
+ var mod = {
8
+ exports: {}
9
+ };
10
+ factory(mod.exports, global._extends, global.react, global.mobileUtils, global.contextProvider, global.elements, global.skeletonContext);
11
+ global.index = mod.exports;
12
+ }
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _extends2, _react, _mobileUtils, _contextProvider, _elements, _skeletonContext) {
14
+ "use strict";
15
+
16
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
17
+
18
+ _exports.__esModule = true;
19
+ _exports.default = void 0;
20
+ _extends2 = _interopRequireDefault(_extends2);
21
+ _react = _interopRequireWildcard(_react);
22
+
23
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
24
+
25
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
26
+
27
+ function getComponentProps(prop) {
28
+ if (prop && typeof prop === 'object') {
29
+ return prop;
30
+ }
31
+
32
+ return {};
33
+ }
34
+
35
+ var Skeleton = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
36
+ var _cls;
37
+
38
+ var _props$className = props.className,
39
+ className = _props$className === void 0 ? '' : _props$className,
40
+ style = props.style,
41
+ children = props.children,
42
+ _props$title = props.title,
43
+ title = _props$title === void 0 ? true : _props$title,
44
+ _props$paragraph = props.paragraph,
45
+ paragraph = _props$paragraph === void 0 ? true : _props$paragraph,
46
+ _props$avatar = props.avatar,
47
+ avatar = _props$avatar === void 0 ? false : _props$avatar,
48
+ grid = props.grid,
49
+ _props$showAnimation = props.showAnimation,
50
+ showAnimation = _props$showAnimation === void 0 ? true : _props$showAnimation,
51
+ _props$animation = props.animation,
52
+ animation = _props$animation === void 0 ? 'gradient' : _props$animation,
53
+ animationGradientColor = props.animationGradientColor,
54
+ backgroundColor = props.backgroundColor;
55
+ var domRef = (0, _react.useRef)(null);
56
+
57
+ var _useContext = (0, _react.useContext)(_contextProvider.GlobalContext),
58
+ prefixCls = _useContext.prefixCls;
59
+
60
+ (0, _react.useImperativeHandle)(ref, function () {
61
+ return {
62
+ dom: domRef.current
63
+ };
64
+ });
65
+ var isGrid = !!grid;
66
+ var hasTitle = !!title;
67
+ var hasParagraph = !!paragraph;
68
+ var hasAvatar = !!avatar;
69
+ var content = isGrid ? /*#__PURE__*/_react.default.createElement(_elements.SkeletonGrid, getComponentProps(grid)) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, hasAvatar && /*#__PURE__*/_react.default.createElement(_elements.SkeletonAvatar, getComponentProps(avatar)), (hasTitle || hasParagraph) && /*#__PURE__*/_react.default.createElement("div", {
70
+ className: prefixCls + "-skeleton-content"
71
+ }, hasTitle && /*#__PURE__*/_react.default.createElement(_elements.SkeletonTitle, getComponentProps(title)), hasParagraph && /*#__PURE__*/_react.default.createElement(_elements.SkeletonParagraph, getComponentProps(paragraph))));
72
+ return /*#__PURE__*/_react.default.createElement("div", {
73
+ className: (0, _mobileUtils.cls)(prefixCls + "-skeleton", (_cls = {}, _cls[prefixCls + "-skeleton-with-avatar"] = hasAvatar, _cls), className),
74
+ style: (0, _extends2.default)({
75
+ color: animationGradientColor
76
+ }, style),
77
+ ref: domRef
78
+ }, /*#__PURE__*/_react.default.createElement(_skeletonContext.SkeletonContext.Provider, {
79
+ value: {
80
+ showAnimation: showAnimation,
81
+ animation: animation,
82
+ backgroundColor: backgroundColor
83
+ }
84
+ }, content, children));
85
+ });
86
+ /**
87
+ * 在内容加载过程中展示一组占位图形。
88
+ * @en Display a set of placeholder graphics during content loading
89
+ * @type 信息展示
90
+ * @type_en Data Display
91
+ * @name 骨架屏
92
+ * @name_en Skeleton
93
+ */
94
+
95
+ var _default = (0, _mobileUtils.componentWrapper)(Skeleton, {
96
+ Node: _elements.SkeletonNode,
97
+ Title: _elements.SkeletonTitle,
98
+ Paragraph: _elements.SkeletonParagraph,
99
+ Avatar: _elements.SkeletonAvatar,
100
+ Grid: _elements.SkeletonGrid
101
+ });
102
+
103
+ _exports.default = _default;
104
+ });
@@ -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,28 @@
1
+ (function (global, factory) {
2
+ if (typeof define === "function" && define.amd) {
3
+ define(["exports", "react"], factory);
4
+ } else if (typeof exports !== "undefined") {
5
+ factory(exports, require("react"));
6
+ } else {
7
+ var mod = {
8
+ exports: {}
9
+ };
10
+ factory(mod.exports, global.react);
11
+ global.skeletonContext = mod.exports;
12
+ }
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _react) {
14
+ "use strict";
15
+
16
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
17
+
18
+ _exports.__esModule = true;
19
+ _exports.SkeletonContext = void 0;
20
+ _react = _interopRequireDefault(_react);
21
+
22
+ var SkeletonContext = /*#__PURE__*/_react.default.createContext({
23
+ showAnimation: true,
24
+ animation: 'gradient'
25
+ });
26
+
27
+ _exports.SkeletonContext = SkeletonContext;
28
+ });