@trionesdev/antd-mobile-base-react 0.0.2-beta.15 → 0.0.2-beta.17

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 (115) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +23 -23
  3. package/dist/Alert/style.scss +69 -69
  4. package/dist/Avatar/avatar.d.ts +2 -2
  5. package/dist/Avatar/avatar.js +1 -1
  6. package/dist/Avatar/style.scss +17 -17
  7. package/dist/Badge/style.scss +100 -100
  8. package/dist/Card/style.scss +35 -35
  9. package/dist/CascaderView/style.scss +22 -22
  10. package/dist/Cell/CellGroup.js +25 -8
  11. package/dist/Cell/cell.js +20 -37
  12. package/dist/Cell/context.d.ts +4 -2
  13. package/dist/Cell/styles.scss +81 -52
  14. package/dist/Cell/types.d.ts +6 -4
  15. package/dist/Checkbox/checkbox-group.js +1 -2
  16. package/dist/Checkbox/index.scss +165 -165
  17. package/dist/ConfigProvider/config-provider.d.ts +1 -0
  18. package/dist/DemoBlock/index.scss +20 -20
  19. package/dist/DemoDescription/index.scss +3 -3
  20. package/dist/Descriptions/style.scss +65 -65
  21. package/dist/Divider/divider.d.ts +1 -1
  22. package/dist/Divider/divider.js +5 -3
  23. package/dist/Divider/style.scss +62 -62
  24. package/dist/Ellipsis/style.scss +13 -13
  25. package/dist/Empty/style.scss +29 -29
  26. package/dist/ErrorBlock/demo/base.js +2 -2
  27. package/dist/ErrorBlock/style.scss +62 -62
  28. package/dist/Footer/style.scss +55 -55
  29. package/dist/Form/ErrorList.d.ts +4 -0
  30. package/dist/Form/ErrorList.js +9 -0
  31. package/dist/Form/context.d.ts +4 -2
  32. package/dist/Form/context.js +2 -1
  33. package/dist/Form/form.d.ts +24 -6
  34. package/dist/Form/form.js +22 -11
  35. package/dist/Form/hooks/useForm.js +1 -8
  36. package/dist/Form/hooks/useFormContext.js +1 -2
  37. package/dist/Form/index.d.ts +6 -3
  38. package/dist/Form/index.js +4 -1
  39. package/dist/Form/styles.scss +11 -0
  40. package/dist/Form/types.d.ts +2 -1
  41. package/dist/FormCell/FormCell.d.ts +21 -0
  42. package/dist/FormCell/FormCell.js +56 -0
  43. package/dist/FormCell/index.d.ts +4 -0
  44. package/dist/FormCell/index.js +3 -0
  45. package/dist/FormCell/styles.scss +103 -0
  46. package/dist/Grid/style.scss +17 -17
  47. package/dist/Icon/demo/base.js +2 -2
  48. package/dist/InputNumber/input-number.d.ts +2 -4
  49. package/dist/InputNumber/input-number.js +46 -28
  50. package/dist/InputNumber/style.scss +100 -63
  51. package/dist/Loading/DotLoading.d.ts +8 -0
  52. package/dist/Loading/DotLoading.js +33 -0
  53. package/dist/Loading/SpinLoading.js +70 -0
  54. package/dist/Loading/dot-loading.scss +72 -0
  55. package/dist/Loading/index.d.ts +5 -0
  56. package/dist/Loading/index.js +3 -0
  57. package/dist/{SpinLoading → Loading}/spin-loading.scss +39 -40
  58. package/dist/NavBar/style.scss +64 -64
  59. package/dist/NoticeBar/style.scss +130 -130
  60. package/dist/PageIndicator/style.scss +59 -59
  61. package/dist/Progress/Progress.js +1 -1
  62. package/dist/Progress/ProgressCircle.js +5 -2
  63. package/dist/Progress/ProgressLine.js +2 -2
  64. package/dist/Progress/style.scss +33 -33
  65. package/dist/Progress/types.d.ts +2 -2
  66. package/dist/Radio/style.scss +154 -141
  67. package/dist/Rate/style.scss +37 -37
  68. package/dist/Result/demo/base.js +2 -2
  69. package/dist/Result/style.scss +73 -73
  70. package/dist/SafeArea/style.scss +20 -20
  71. package/dist/Scaffold/style.scss +17 -17
  72. package/dist/Segmented/style.scss +75 -75
  73. package/dist/Skeleton/Skeleton.d.ts +80 -21
  74. package/dist/Skeleton/Skeleton.js +248 -57
  75. package/dist/Skeleton/index.d.ts +3 -1
  76. package/dist/Skeleton/index.js +2 -1
  77. package/dist/Skeleton/style.scss +215 -48
  78. package/dist/Space/space.js +12 -9
  79. package/dist/Space/style.scss +101 -80
  80. package/dist/Stepper/index.d.ts +3 -0
  81. package/dist/Stepper/index.js +2 -0
  82. package/dist/Stepper/stepper.d.ts +14 -0
  83. package/dist/Stepper/stepper.js +92 -0
  84. package/dist/Stepper/style.scss +100 -0
  85. package/dist/Steps/HorizontalSteps.js +5 -2
  86. package/dist/Steps/VerticalSteps.js +5 -2
  87. package/dist/Steps/style.scss +153 -153
  88. package/dist/Steps/types.d.ts +2 -0
  89. package/dist/Switch/style.scss +127 -128
  90. package/dist/Switch/switch.d.ts +2 -0
  91. package/dist/Switch/switch.js +6 -5
  92. package/dist/TabBar/demo/base.js +2 -2
  93. package/dist/TabBar/index.scss +37 -37
  94. package/dist/Tabs/style.scss +108 -108
  95. package/dist/Tag/style.scss +110 -109
  96. package/dist/Tag/tag.d.ts +1 -1
  97. package/dist/Tag/tag.js +1 -1
  98. package/dist/WaterMark/style.scss +17 -17
  99. package/dist/index.d.ts +11 -4
  100. package/dist/index.js +5 -2
  101. package/dist/style/css-variable.scss +6 -6
  102. package/dist/style/style.scss +52 -52
  103. package/dist/style/theme-dark.scss +24 -24
  104. package/dist/style/theme-default.scss +54 -54
  105. package/dist/style/variable.scss +180 -173
  106. package/dist/types.d.ts +6 -1
  107. package/dist/utils/type.js +36 -36
  108. package/dist/utils/with-default-props.js +4 -4
  109. package/package.json +4 -7
  110. package/dist/SpinLoading/index.d.ts +0 -3
  111. package/dist/SpinLoading/index.js +0 -2
  112. package/dist/SpinLoading/spin-loading.js +0 -59
  113. package/dist/Tabs/demo/base.d.ts +0 -3
  114. package/dist/Tabs/demo/base.js +0 -59
  115. /package/dist/{SpinLoading/spin-loading.d.ts → Loading/SpinLoading.d.ts} +0 -0
@@ -1,75 +1,75 @@
1
- @use "../style/variable" as variable;
2
-
3
- $class-prefix-segmented: 'triones-antm-segmented';
4
-
5
- .#{$class-prefix-segmented} {
6
- display: inline-flex;
7
- flex-direction: row;
8
- align-items: stretch;
9
- box-sizing: border-box;
10
- padding: 2Px;
11
- border-radius: variable.$trionesBorderRadius;
12
- background: variable.$trionesColorFillTertiary;
13
- gap: 0;
14
-
15
- &-block {
16
- display: flex;
17
- width: 100%;
18
- }
19
-
20
- &-disabled {
21
- opacity: 0.45;
22
- pointer-events: none;
23
- }
24
-
25
- &-item {
26
- position: relative;
27
- z-index: 0;
28
- display: inline-flex;
29
- flex: 0 1 auto;
30
- align-items: center;
31
- justify-content: center;
32
- min-height: 10Px;
33
- padding: 0Px 11Px;
34
- font-size: variable.$trionesFontSize;
35
- line-height: variable.$trionesLineHeightSm;
36
- color: variable.$trionesColorTextSecondary;
37
- border-radius: variable.$trionesBorderRadiusXs;
38
- cursor: pointer;
39
- user-select: none;
40
- transition:
41
- color 0.2s,
42
- background-color 0.2s,
43
- box-shadow 0.2s;
44
-
45
- &-icon {
46
- display: inline-flex;
47
- margin-inline-end: 4Px;
48
- font-size: variable.$trionesFontSizeIcon;
49
- line-height: 1;
50
- }
51
-
52
- &-label {
53
- display: inline-flex;
54
- align-items: center;
55
- line-height: 28Px;
56
- }
57
-
58
- &-active {
59
- z-index: 1;
60
- color: variable.$trionesColorTextHeading;
61
- background: variable.$trionesColorBgBase;
62
- box-shadow: 0 1Px 2Px rgba(0, 0, 0, 0.06);
63
- }
64
-
65
- &-disabled {
66
- cursor: not-allowed;
67
- color: variable.$trionesColorTextDisabled;
68
- }
69
- }
70
-
71
- &-block &-item {
72
- flex: 1 1 0;
73
- min-width: 0;
74
- }
75
- }
1
+ @use "../style/variable" as variable;
2
+
3
+ $class-prefix-segmented: 'triones-antm-segmented';
4
+
5
+ .#{$class-prefix-segmented} {
6
+ display: inline-flex;
7
+ flex-direction: row;
8
+ align-items: stretch;
9
+ box-sizing: border-box;
10
+ padding: 2Px;
11
+ border-radius: variable.$trionesBorderRadius;
12
+ background: variable.$trionesColorFillTertiary;
13
+ gap: 0;
14
+
15
+ &-block {
16
+ display: flex;
17
+ width: 100%;
18
+ }
19
+
20
+ &-disabled {
21
+ opacity: 0.45;
22
+ pointer-events: none;
23
+ }
24
+
25
+ &-item {
26
+ position: relative;
27
+ z-index: 0;
28
+ display: inline-flex;
29
+ flex: 0 1 auto;
30
+ align-items: center;
31
+ justify-content: center;
32
+ min-height: 10Px;
33
+ padding: 0Px 11Px;
34
+ font-size: variable.$trionesFontSize;
35
+ line-height: variable.$trionesLineHeightSm;
36
+ color: variable.$trionesColorTextSecondary;
37
+ border-radius: variable.$trionesBorderRadiusXs;
38
+ cursor: pointer;
39
+ user-select: none;
40
+ transition:
41
+ color 0.2s,
42
+ background-color 0.2s,
43
+ box-shadow 0.2s;
44
+
45
+ &-icon {
46
+ display: inline-flex;
47
+ margin-inline-end: 4Px;
48
+ font-size: variable.$trionesFontSizeIcon;
49
+ line-height: 1;
50
+ }
51
+
52
+ &-label {
53
+ display: inline-flex;
54
+ align-items: center;
55
+ line-height: 28Px;
56
+ }
57
+
58
+ &-active {
59
+ z-index: 1;
60
+ color: variable.$trionesColorTextHeading;
61
+ background: variable.$trionesColorBgBase;
62
+ box-shadow: 0 1Px 2Px rgba(0, 0, 0, 0.06);
63
+ }
64
+
65
+ &-disabled {
66
+ cursor: not-allowed;
67
+ color: variable.$trionesColorTextDisabled;
68
+ }
69
+ }
70
+
71
+ &-block &-item {
72
+ flex: 1 1 0;
73
+ min-width: 0;
74
+ }
75
+ }
@@ -1,27 +1,86 @@
1
- import React from 'react';
1
+ import type { CSSProperties, FC, ReactNode } from 'react';
2
2
  import './style.scss';
3
- export interface SkeletonProps {
4
- /** 是否显示骨架屏 */
3
+ export type SkeletonAvatarShape = 'circle' | 'square';
4
+ export type SkeletonAvatarSize = 'small' | 'medium' | 'large';
5
+ export interface SkeletonAvatarProps {
6
+ className?: string;
7
+ style?: CSSProperties;
8
+ shape?: SkeletonAvatarShape;
9
+ size?: SkeletonAvatarSize | number;
10
+ active?: boolean;
11
+ }
12
+ export interface SkeletonTitleProps {
13
+ className?: string;
14
+ style?: CSSProperties;
15
+ width?: number | string;
16
+ active?: boolean;
17
+ }
18
+ export interface SkeletonParagraphProps {
19
+ className?: string;
20
+ style?: CSSProperties;
21
+ rows?: number;
22
+ /** 单行宽度;数组时为每行宽度,与 antd 一致 */
23
+ width?: number | string | Array<number | string>;
24
+ active?: boolean;
25
+ }
26
+ export interface SkeletonInputProps {
27
+ className?: string;
28
+ style?: CSSProperties;
29
+ size?: 'small' | 'medium' | 'large';
30
+ active?: boolean;
31
+ }
32
+ export type SkeletonButtonShape = 'default' | 'square' | 'round' | 'circle';
33
+ export interface SkeletonButtonProps {
34
+ className?: string;
35
+ style?: CSSProperties;
36
+ size?: 'small' | 'medium' | 'large';
37
+ shape?: SkeletonButtonShape;
38
+ block?: boolean;
39
+ active?: boolean;
40
+ }
41
+ /** 简单块模式:与历史 API 兼容 */
42
+ export type SkeletonBlockType = 'text' | 'circle' | 'rect';
43
+ export type SkeletonProps = {
44
+ /** 为 true 时显示骨架,为 false 时渲染子节点 */
5
45
  loading?: boolean;
6
- /** 骨架屏类型:text, circle, rect */
7
- type?: 'text' | 'circle' | 'rect';
8
- /** 宽度 */
46
+ /** 是否展示扫光动画,对应 antd `active` */
47
+ active?: boolean;
48
+ /** `active`,兼容旧属性 */
49
+ animated?: boolean;
50
+ /** 标题占位 */
51
+ title?: boolean | SkeletonTitleProps;
52
+ /** 段落占位 */
53
+ paragraph?: boolean | SkeletonParagraphProps;
54
+ /** 左侧头像占位 */
55
+ avatar?: boolean | SkeletonAvatarProps;
56
+ /** 标题与段落是否使用大圆角 */
57
+ round?: boolean;
58
+ className?: string;
59
+ style?: CSSProperties;
60
+ children?: ReactNode;
61
+ /**
62
+ * `composed`:标题+段落组合(默认,对齐 [antd Skeleton](https://ant.design/components/skeleton-cn));可配合 `avatar`
63
+ * `block`:单行/单块占位(兼容历史 `type` + `rows`)
64
+ */
65
+ mode?: 'composed' | 'block';
66
+ /** 仅在 mode=block 时生效 */
67
+ type?: SkeletonBlockType;
9
68
  width?: string | number;
10
- /** 高度 */
11
69
  height?: string | number;
12
- /** 圆角大小,仅在type为circle时生效 */
13
70
  radius?: string | number;
14
- /** 显示多行文本骨架,仅在type为text时生效 */
15
71
  rows?: number;
16
- /** 是否显示动画效果 */
17
- animated?: boolean;
18
- /** 自定义样式类名 */
19
- className?: string;
20
- /** 自定义内联样式 */
21
- style?: React.CSSProperties;
22
- /** 子元素 */
23
- children?: React.ReactNode;
24
- /** 是否是圆角矩形 */
25
- round?: boolean;
26
- }
27
- export declare const Skeleton: React.FC<SkeletonProps>;
72
+ };
73
+ export declare const SkeletonAvatar: FC<SkeletonAvatarProps>;
74
+ export declare const SkeletonTitle: FC<SkeletonTitleProps>;
75
+ export declare const SkeletonParagraph: FC<SkeletonParagraphProps>;
76
+ export declare const SkeletonInput: FC<SkeletonInputProps>;
77
+ export declare const SkeletonButton: FC<SkeletonButtonProps>;
78
+ type CompoundedSkeleton = FC<SkeletonProps> & {
79
+ Avatar: typeof SkeletonAvatar;
80
+ Title: typeof SkeletonTitle;
81
+ Paragraph: typeof SkeletonParagraph;
82
+ Input: typeof SkeletonInput;
83
+ Button: typeof SkeletonButton;
84
+ };
85
+ export declare const Skeleton: CompoundedSkeleton;
86
+ export {};
@@ -1,72 +1,263 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
1
2
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
5
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
6
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
7
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
+ import classNames from 'classnames';
7
9
  import React from 'react';
8
10
  import "./style.scss";
9
- export var Skeleton = function Skeleton(_ref) {
10
- var _ref$loading = _ref.loading,
11
- loading = _ref$loading === void 0 ? true : _ref$loading,
12
- _ref$type = _ref.type,
13
- type = _ref$type === void 0 ? 'text' : _ref$type,
14
- width = _ref.width,
15
- height = _ref.height,
16
- radius = _ref.radius,
17
- _ref$rows = _ref.rows,
18
- rows = _ref$rows === void 0 ? 1 : _ref$rows,
19
- _ref$animated = _ref.animated,
20
- animated = _ref$animated === void 0 ? true : _ref$animated,
21
- _ref$className = _ref.className,
22
- className = _ref$className === void 0 ? '' : _ref$className,
11
+ var prefixCls = 'triones-antm-skeleton';
12
+
13
+ /** 简单块模式:与历史 API 兼容 */
14
+
15
+ /** 使用 px,保证 H5 / 文档站点可渲染(浏览器不支持 rpx) */
16
+ var sizeToPx = {
17
+ small: 32,
18
+ medium: 44,
19
+ large: 56
20
+ };
21
+ var inputHeightPx = {
22
+ small: 24,
23
+ medium: 32,
24
+ large: 40
25
+ };
26
+ var buttonSizePx = {
27
+ small: 28,
28
+ medium: 32,
29
+ large: 36
30
+ };
31
+ function toCssSize(v) {
32
+ if (v === undefined) return undefined;
33
+ return typeof v === 'number' ? "".concat(v, "px") : v;
34
+ }
35
+ function normalizeActive(active, animated) {
36
+ if (active !== undefined) return active;
37
+ if (animated !== undefined) return animated;
38
+ return true;
39
+ }
40
+ export var SkeletonAvatar = function SkeletonAvatar(_ref) {
41
+ var className = _ref.className,
23
42
  style = _ref.style,
24
- children = _ref.children,
25
- _ref$round = _ref.round,
26
- round = _ref$round === void 0 ? false : _ref$round;
27
- if (!loading || children) {
28
- return /*#__PURE__*/React.createElement(React.Fragment, null, children);
29
- }
30
- var getSkeletonStyle = function getSkeletonStyle() {
31
- var style = {};
32
- if (width !== undefined) {
33
- style.width = typeof width === 'number' ? "".concat(width, "px") : width;
43
+ _ref$shape = _ref.shape,
44
+ shape = _ref$shape === void 0 ? 'circle' : _ref$shape,
45
+ _ref$size = _ref.size,
46
+ size = _ref$size === void 0 ? 'medium' : _ref$size,
47
+ _ref$active = _ref.active,
48
+ active = _ref$active === void 0 ? true : _ref$active;
49
+ var dim = typeof size === 'number' ? "".concat(size, "px") : "".concat(sizeToPx[size], "px");
50
+ return /*#__PURE__*/React.createElement("div", {
51
+ className: classNames("".concat(prefixCls, "-avatar"), "".concat(prefixCls, "-avatar-").concat(shape), _defineProperty({}, "".concat(prefixCls, "-element-active"), active), className),
52
+ style: _objectSpread({
53
+ width: dim,
54
+ height: dim
55
+ }, style)
56
+ });
57
+ };
58
+ export var SkeletonTitle = function SkeletonTitle(_ref2) {
59
+ var className = _ref2.className,
60
+ style = _ref2.style,
61
+ width = _ref2.width,
62
+ _ref2$active = _ref2.active,
63
+ active = _ref2$active === void 0 ? true : _ref2$active;
64
+ return /*#__PURE__*/React.createElement("div", {
65
+ className: classNames("".concat(prefixCls, "-title"), _defineProperty({}, "".concat(prefixCls, "-element-active"), active), className),
66
+ style: _objectSpread({
67
+ width: width !== undefined ? toCssSize(width) : undefined
68
+ }, style)
69
+ });
70
+ };
71
+ export var SkeletonParagraph = function SkeletonParagraph(_ref3) {
72
+ var className = _ref3.className,
73
+ style = _ref3.style,
74
+ _ref3$rows = _ref3.rows,
75
+ rows = _ref3$rows === void 0 ? 3 : _ref3$rows,
76
+ width = _ref3.width,
77
+ _ref3$active = _ref3.active,
78
+ active = _ref3$active === void 0 ? true : _ref3$active;
79
+ var list = Array.from({
80
+ length: rows
81
+ }, function (_, i) {
82
+ var w;
83
+ if (Array.isArray(width)) {
84
+ var _width$i;
85
+ var raw = (_width$i = width[i]) !== null && _width$i !== void 0 ? _width$i : width[width.length - 1];
86
+ w = raw !== undefined ? toCssSize(raw) : undefined;
87
+ } else if (width !== undefined && i === rows - 1) {
88
+ w = toCssSize(width);
34
89
  }
35
- if (height !== undefined) {
36
- style.height = typeof height === 'number' ? "".concat(height, "px") : height;
90
+ if (w === undefined && i === rows - 1) {
91
+ w = '62%';
37
92
  }
38
- if (type === 'circle') {
39
- style.borderRadius = '50%';
40
- if (radius !== undefined) {
41
- style.width = typeof radius === 'number' ? "".concat(radius, "px") : radius;
42
- style.height = typeof radius === 'number' ? "".concat(radius, "px") : radius;
43
- }
44
- } else if (round) {
45
- style.borderRadius = '8px';
46
- } else if (radius !== undefined) {
47
- style.borderRadius = typeof radius === 'number' ? "".concat(radius, "px") : radius;
93
+ return /*#__PURE__*/React.createElement("div", {
94
+ key: i,
95
+ className: classNames("".concat(prefixCls, "-paragraph-line"), _defineProperty({}, "".concat(prefixCls, "-element-active"), active)),
96
+ style: w ? {
97
+ width: w
98
+ } : undefined
99
+ });
100
+ });
101
+ return /*#__PURE__*/React.createElement("div", {
102
+ className: classNames("".concat(prefixCls, "-paragraph"), className),
103
+ style: style
104
+ }, list);
105
+ };
106
+ export var SkeletonInput = function SkeletonInput(_ref4) {
107
+ var className = _ref4.className,
108
+ style = _ref4.style,
109
+ _ref4$size = _ref4.size,
110
+ size = _ref4$size === void 0 ? 'medium' : _ref4$size,
111
+ _ref4$active = _ref4.active,
112
+ active = _ref4$active === void 0 ? true : _ref4$active;
113
+ return /*#__PURE__*/React.createElement("div", {
114
+ className: classNames("".concat(prefixCls, "-input"), _defineProperty({}, "".concat(prefixCls, "-element-active"), active), className),
115
+ style: _objectSpread({
116
+ height: "".concat(inputHeightPx[size], "px")
117
+ }, style)
118
+ });
119
+ };
120
+ export var SkeletonButton = function SkeletonButton(_ref5) {
121
+ var className = _ref5.className,
122
+ style = _ref5.style,
123
+ _ref5$size = _ref5.size,
124
+ size = _ref5$size === void 0 ? 'medium' : _ref5$size,
125
+ _ref5$shape = _ref5.shape,
126
+ shape = _ref5$shape === void 0 ? 'default' : _ref5$shape,
127
+ _ref5$block = _ref5.block,
128
+ block = _ref5$block === void 0 ? false : _ref5$block,
129
+ _ref5$active = _ref5.active,
130
+ active = _ref5$active === void 0 ? true : _ref5$active;
131
+ return /*#__PURE__*/React.createElement("div", {
132
+ className: classNames("".concat(prefixCls, "-button"), "".concat(prefixCls, "-button-").concat(shape), _defineProperty(_defineProperty({}, "".concat(prefixCls, "-button-block"), block), "".concat(prefixCls, "-element-active"), active), className),
133
+ style: _objectSpread({
134
+ width: shape === 'circle' ? "".concat(buttonSizePx[size], "px") : undefined,
135
+ height: "".concat(buttonSizePx[size], "px")
136
+ }, style)
137
+ });
138
+ };
139
+ function renderComposed(props, showActive, round) {
140
+ var _props$avatar = props.avatar,
141
+ avatarProp = _props$avatar === void 0 ? false : _props$avatar,
142
+ _props$title = props.title,
143
+ titleProp = _props$title === void 0 ? true : _props$title,
144
+ _props$paragraph = props.paragraph,
145
+ paragraphProp = _props$paragraph === void 0 ? true : _props$paragraph,
146
+ className = props.className,
147
+ style = props.style;
148
+ var avatarCfg = avatarProp === true ? {} : avatarProp === false ? null : avatarProp;
149
+ var titleCfg = titleProp === true ? {} : titleProp === false ? null : titleProp;
150
+ var paragraphCfg = paragraphProp === true ? {
151
+ rows: 3
152
+ } : paragraphProp === false ? null : paragraphProp;
153
+ var hasAvatar = Boolean(avatarCfg);
154
+ var hasTitle = Boolean(titleCfg);
155
+ var hasParagraph = Boolean(paragraphCfg);
156
+ if (!hasAvatar && !hasTitle && !hasParagraph) {
157
+ return null;
158
+ }
159
+ var titleProps = titleCfg && _typeof(titleCfg) === 'object' ? titleCfg : {};
160
+ var paragraphProps = paragraphCfg && _typeof(paragraphCfg) === 'object' ? paragraphCfg : {};
161
+ var avatarProps = avatarCfg && _typeof(avatarCfg) === 'object' ? avatarCfg : {};
162
+ var titleActive = titleProps.active === false ? false : showActive;
163
+ var paragraphActive = paragraphProps.active === false ? false : showActive;
164
+ var avatarActive = avatarProps.active === false ? false : showActive;
165
+ var section = hasTitle || hasParagraph ? /*#__PURE__*/React.createElement("div", {
166
+ className: "".concat(prefixCls, "-section")
167
+ }, hasTitle && /*#__PURE__*/React.createElement(SkeletonTitle, _extends({}, titleProps, {
168
+ active: titleActive
169
+ })), hasParagraph && /*#__PURE__*/React.createElement(SkeletonParagraph, _extends({}, paragraphProps, {
170
+ active: paragraphActive
171
+ }))) : null;
172
+ if (hasAvatar) {
173
+ return /*#__PURE__*/React.createElement("div", {
174
+ className: classNames("".concat(prefixCls), "".concat(prefixCls, "-with-avatar"), _defineProperty({}, "".concat(prefixCls, "-round"), round), className),
175
+ style: style
176
+ }, /*#__PURE__*/React.createElement("div", {
177
+ className: "".concat(prefixCls, "-header")
178
+ }, /*#__PURE__*/React.createElement(SkeletonAvatar, _extends({}, avatarProps, {
179
+ active: avatarActive
180
+ }))), section);
181
+ }
182
+ return /*#__PURE__*/React.createElement("div", {
183
+ className: classNames(prefixCls, _defineProperty({}, "".concat(prefixCls, "-round"), round), className),
184
+ style: style
185
+ }, section);
186
+ }
187
+ function renderBlock(props, showActive) {
188
+ var _props$type = props.type,
189
+ type = _props$type === void 0 ? 'text' : _props$type,
190
+ width = props.width,
191
+ height = props.height,
192
+ radius = props.radius,
193
+ _props$rows = props.rows,
194
+ rows = _props$rows === void 0 ? 1 : _props$rows,
195
+ round = props.round,
196
+ className = props.className,
197
+ style = props.style;
198
+ var baseStyle = {};
199
+ if (width !== undefined) baseStyle.width = toCssSize(width);
200
+ if (height !== undefined) baseStyle.height = toCssSize(height);
201
+ if (type === 'circle') {
202
+ var d = radius !== undefined ? toCssSize(radius) : undefined;
203
+ if (d) {
204
+ baseStyle.width = d;
205
+ baseStyle.height = d;
48
206
  }
49
- return style;
50
- };
51
- var renderSkeletonItems = function renderSkeletonItems() {
52
- if (type === 'text') {
53
- return Array.from({
54
- length: rows
55
- }).map(function (_, index) {
56
- return /*#__PURE__*/React.createElement("div", {
57
- key: index,
58
- className: "skeleton-item skeleton-text ".concat(animated ? 'skeleton-animated' : '', " ").concat(className),
59
- style: _objectSpread(_objectSpread({}, getSkeletonStyle()), style)
60
- });
61
- });
62
- } else {
207
+ baseStyle.borderRadius = '50%';
208
+ } else if (round) {
209
+ baseStyle.borderRadius = '8px';
210
+ } else if (radius !== undefined) {
211
+ baseStyle.borderRadius = toCssSize(radius);
212
+ }
213
+ if (type === 'text') {
214
+ return /*#__PURE__*/React.createElement("div", {
215
+ className: classNames("".concat(prefixCls, "-block-root"), className),
216
+ style: style
217
+ }, Array.from({
218
+ length: rows
219
+ }).map(function (_, index) {
220
+ var _baseStyle$width;
63
221
  return /*#__PURE__*/React.createElement("div", {
64
- className: "skeleton-item skeleton-".concat(type, " ").concat(animated ? 'skeleton-animated' : '', " ").concat(className),
65
- style: _objectSpread(_objectSpread({}, getSkeletonStyle()), style)
222
+ key: index,
223
+ className: classNames("".concat(prefixCls, "-block"), "".concat(prefixCls, "-block-text"), _defineProperty({}, "".concat(prefixCls, "-element-active"), showActive)),
224
+ style: _objectSpread(_objectSpread({}, baseStyle), index === rows - 1 ? {
225
+ width: (_baseStyle$width = baseStyle.width) !== null && _baseStyle$width !== void 0 ? _baseStyle$width : '70%'
226
+ } : {})
66
227
  });
67
- }
68
- };
228
+ }));
229
+ }
69
230
  return /*#__PURE__*/React.createElement("div", {
70
- className: "skeleton-container"
71
- }, renderSkeletonItems());
72
- };
231
+ className: classNames("".concat(prefixCls, "-block-root"), className),
232
+ style: style
233
+ }, /*#__PURE__*/React.createElement("div", {
234
+ className: classNames("".concat(prefixCls, "-block"), "".concat(prefixCls, "-block-").concat(type), _defineProperty({}, "".concat(prefixCls, "-element-active"), showActive)),
235
+ style: baseStyle
236
+ }));
237
+ }
238
+ var SkeletonImpl = function SkeletonImpl(props) {
239
+ var _props$loading = props.loading,
240
+ loading = _props$loading === void 0 ? true : _props$loading,
241
+ children = props.children,
242
+ _props$mode = props.mode,
243
+ mode = _props$mode === void 0 ? 'composed' : _props$mode,
244
+ _props$round = props.round,
245
+ round = _props$round === void 0 ? false : _props$round,
246
+ active = props.active,
247
+ animated = props.animated;
248
+ if (!loading) {
249
+ return /*#__PURE__*/React.createElement(React.Fragment, null, children);
250
+ }
251
+ var showActive = normalizeActive(active, animated);
252
+ if (mode === 'block') {
253
+ return renderBlock(props, showActive);
254
+ }
255
+ return renderComposed(props, showActive, round);
256
+ };
257
+ export var Skeleton = Object.assign(SkeletonImpl, {
258
+ Avatar: SkeletonAvatar,
259
+ Title: SkeletonTitle,
260
+ Paragraph: SkeletonParagraph,
261
+ Input: SkeletonInput,
262
+ Button: SkeletonButton
263
+ });
@@ -1 +1,3 @@
1
- export { Skeleton } from './Skeleton';
1
+ import { Skeleton } from './Skeleton';
2
+ export type { SkeletonProps, SkeletonAvatarProps, SkeletonTitleProps, SkeletonParagraphProps, SkeletonInputProps, SkeletonButtonProps, SkeletonBlockType, SkeletonAvatarShape, SkeletonAvatarSize, SkeletonButtonShape, } from './Skeleton';
3
+ export default Skeleton;
@@ -1 +1,2 @@
1
- export { Skeleton } from "./Skeleton";
1
+ import { Skeleton } from "./Skeleton";
2
+ export default Skeleton;