antd-mobile 5.20.0 → 5.21.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 (70) hide show
  1. package/2x/bundle/antd-mobile.cjs.js +12 -12
  2. package/2x/bundle/antd-mobile.compatible.umd.js +6882 -6786
  3. package/2x/bundle/antd-mobile.es.js +3779 -3709
  4. package/2x/bundle/antd-mobile.umd.js +12 -12
  5. package/2x/bundle/style.css +131 -0
  6. package/2x/cjs/components/form/form-item.d.ts +1 -1
  7. package/2x/cjs/components/picker-view/wheel.js +2 -0
  8. package/2x/cjs/components/rate/rate.css +3 -0
  9. package/2x/cjs/components/rate/rate.js +15 -14
  10. package/2x/cjs/components/result-page/index.d.ts +7 -0
  11. package/2x/cjs/components/result-page/index.js +20 -0
  12. package/2x/cjs/components/result-page/result-page-card.d.ts +6 -0
  13. package/2x/cjs/components/result-page/result-page-card.js +24 -0
  14. package/2x/cjs/components/result-page/result-page.css +130 -0
  15. package/2x/cjs/components/result-page/result-page.d.ts +23 -0
  16. package/2x/cjs/components/result-page/result-page.js +108 -0
  17. package/2x/cjs/components/swiper/swiper.js +1 -1
  18. package/2x/cjs/index.d.ts +1 -0
  19. package/2x/cjs/index.js +8 -0
  20. package/2x/es/components/form/form-item.d.ts +1 -1
  21. package/2x/es/components/picker-view/wheel.js +2 -0
  22. package/2x/es/components/rate/rate.css +3 -0
  23. package/2x/es/components/rate/rate.js +15 -14
  24. package/2x/es/components/result-page/index.d.ts +7 -0
  25. package/2x/es/components/result-page/index.js +7 -0
  26. package/2x/es/components/result-page/result-page-card.d.ts +6 -0
  27. package/2x/es/components/result-page/result-page-card.js +9 -0
  28. package/2x/es/components/result-page/result-page.css +130 -0
  29. package/2x/es/components/result-page/result-page.d.ts +23 -0
  30. package/2x/es/components/result-page/result-page.js +83 -0
  31. package/2x/es/components/swiper/swiper.js +1 -1
  32. package/2x/es/index.d.ts +1 -0
  33. package/2x/es/index.js +1 -0
  34. package/2x/package.json +3 -3
  35. package/2x/umd/antd-mobile.js +6882 -6786
  36. package/bundle/antd-mobile.cjs.js +12 -12
  37. package/bundle/antd-mobile.compatible.umd.js +6882 -6786
  38. package/bundle/antd-mobile.es.js +3779 -3709
  39. package/bundle/antd-mobile.umd.js +12 -12
  40. package/bundle/style.css +1 -1
  41. package/cjs/components/form/form-item.d.ts +1 -1
  42. package/cjs/components/picker-view/wheel.js +2 -0
  43. package/cjs/components/rate/rate.css +3 -0
  44. package/cjs/components/rate/rate.js +15 -14
  45. package/cjs/components/result-page/index.d.ts +7 -0
  46. package/cjs/components/result-page/index.js +20 -0
  47. package/cjs/components/result-page/result-page-card.d.ts +6 -0
  48. package/cjs/components/result-page/result-page-card.js +24 -0
  49. package/cjs/components/result-page/result-page.css +113 -0
  50. package/cjs/components/result-page/result-page.d.ts +23 -0
  51. package/cjs/components/result-page/result-page.js +108 -0
  52. package/cjs/components/swiper/swiper.js +1 -1
  53. package/cjs/index.d.ts +1 -0
  54. package/cjs/index.js +8 -0
  55. package/es/components/form/form-item.d.ts +1 -1
  56. package/es/components/picker-view/wheel.js +2 -0
  57. package/es/components/rate/rate.css +3 -0
  58. package/es/components/rate/rate.js +15 -14
  59. package/es/components/result-page/index.d.ts +7 -0
  60. package/es/components/result-page/index.js +7 -0
  61. package/es/components/result-page/result-page-card.d.ts +6 -0
  62. package/es/components/result-page/result-page-card.js +9 -0
  63. package/es/components/result-page/result-page.css +113 -0
  64. package/es/components/result-page/result-page.d.ts +23 -0
  65. package/es/components/result-page/result-page.js +83 -0
  66. package/es/components/swiper/swiper.js +1 -1
  67. package/es/index.d.ts +1 -0
  68. package/es/index.js +1 -0
  69. package/package.json +3 -3
  70. package/umd/antd-mobile.js +1 -1
@@ -28,15 +28,6 @@ export const Rate = p => {
28
28
  [`${classPrefix}-star-half`]: half,
29
29
  [`${classPrefix}-star-readonly`]: props.readOnly
30
30
  }),
31
- onClick: () => {
32
- if (props.readOnly) return;
33
-
34
- if (props.allowClear && value === v) {
35
- setValue(0);
36
- } else {
37
- setValue(v);
38
- }
39
- },
40
31
  role: 'radio',
41
32
  "aria-checked": value >= v,
42
33
  "aria-label": '' + v
@@ -46,20 +37,30 @@ export const Rate = p => {
46
37
  const bind = useDrag(state => {
47
38
  if (props.readOnly) return;
48
39
  const {
49
- xy: [clientX]
40
+ xy: [clientX],
41
+ tap
50
42
  } = state;
51
43
  const container = containerRef.current;
52
44
  if (!container) return;
53
45
  const rect = container.getBoundingClientRect();
54
46
  const rawValue = (clientX - rect.left) / rect.width * props.count;
55
- const roundedValue = props.allowHalf ? Math.round(rawValue * 2) / 2 : Math.round(rawValue);
56
- setValue(bound(roundedValue, 0, props.count));
47
+ const ceiledValue = props.allowHalf ? Math.ceil(rawValue * 2) / 2 : Math.ceil(rawValue);
48
+ const boundValue = bound(ceiledValue, 0, props.count);
49
+
50
+ if (tap) {
51
+ if (props.allowClear && boundValue === value) {
52
+ setValue(0);
53
+ return;
54
+ }
55
+ }
56
+
57
+ setValue(boundValue);
57
58
  }, {
58
59
  axis: 'x',
59
- preventScroll: true,
60
60
  pointer: {
61
61
  touch: true
62
- }
62
+ },
63
+ filterTaps: true
63
64
  });
64
65
  return withNativeProps(props, React.createElement("div", Object.assign({
65
66
  className: classPrefix,
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import './result-page.less';
3
+ export type { ResultPageProps } from './result-page';
4
+ declare const _default: import("react").FC<import("./result-page").ResultPageProps> & {
5
+ Card: import("react").FC<import("./result-page-card").ResultPageCardProps>;
6
+ };
7
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import "./result-page.css";
2
+ import { ResultPage } from './result-page';
3
+ import { attachPropertiesToComponent } from '../../utils/attach-properties-to-component';
4
+ import { ResultPageCard } from './result-page-card';
5
+ export default attachPropertiesToComponent(ResultPage, {
6
+ Card: ResultPageCard
7
+ });
@@ -0,0 +1,6 @@
1
+ import { FC, ReactNode } from 'react';
2
+ import { NativeProps } from '../../utils/native-props';
3
+ export declare type ResultPageCardProps = {
4
+ children?: ReactNode;
5
+ } & NativeProps;
6
+ export declare const ResultPageCard: FC<ResultPageCardProps>;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { withNativeProps } from '../../utils/native-props';
3
+ import classNames from 'classnames';
4
+ const classPrefix = `adm-result-page-card`;
5
+ export const ResultPageCard = props => {
6
+ return withNativeProps(props, React.createElement('div', {
7
+ className: classNames(`${classPrefix}`)
8
+ }, props.children));
9
+ };
@@ -0,0 +1,130 @@
1
+ .adm-result-page {
2
+ --background-color: var(--adm-color-primary);
3
+ position: relative;
4
+ background-color: var(--adm-color-box);
5
+ min-height: 100vh;
6
+ width: 100%;
7
+ }
8
+
9
+ .adm-result-page-header {
10
+ display: flex;
11
+ align-items: center;
12
+ flex-direction: column;
13
+ background-color: transparent;
14
+ position: relative;
15
+ padding: 40px;
16
+ padding-bottom: 200px;
17
+ z-index: 1;
18
+ overflow: hidden;
19
+ }
20
+
21
+ .adm-result-page-icon {
22
+ color: var(--adm-color-background);
23
+ box-sizing: border-box;
24
+ padding: 4px;
25
+ margin-bottom: 16px;
26
+ }
27
+
28
+ .adm-result-page-icon .antd-mobile-icon {
29
+ font-size: 64px;
30
+ }
31
+
32
+ .adm-result-page-title {
33
+ font-size: var(--adm-font-size-10);
34
+ color: var(--adm-color-background);
35
+ line-height: 1.4;
36
+ text-align: center;
37
+ }
38
+
39
+ .adm-result-page-description {
40
+ margin-top: 16px;
41
+ margin-bottom: 48px;
42
+ font-size: var(--adm-font-size-6);
43
+ color: rgba(255, 255, 255, 0.6);
44
+ line-height: 1.4;
45
+ text-align: center;
46
+ }
47
+
48
+ .adm-result-page-details {
49
+ width: 100%;
50
+ }
51
+
52
+ .adm-result-page-detail {
53
+ width: 100%;
54
+ display: flex;
55
+ flex-direction: row;
56
+ justify-content: space-between;
57
+ margin-bottom: 10px;
58
+ color: var(--adm-color-background);
59
+ font-size: var(--adm-font-size-6);
60
+ }
61
+
62
+ .adm-result-page-detail-bold {
63
+ font-weight: 600;
64
+ }
65
+
66
+ .adm-result-page-collapse {
67
+ opacity: 0.6;
68
+ width: 20px;
69
+ height: 20px;
70
+ margin: auto;
71
+ margin-bottom: 10px;
72
+ border-top: 4px solid var(--adm-color-background);
73
+ border-right: 4px solid var(--adm-color-background);
74
+ transform: rotate(135deg);
75
+ }
76
+
77
+ .adm-result-page-collapse-active {
78
+ transform: rotate(-45deg);
79
+ }
80
+
81
+ .adm-result-page-bgWrapper {
82
+ position: relative;
83
+ align-self: flex-start;
84
+ top: 108px;
85
+ }
86
+
87
+ .adm-result-page-bg {
88
+ --width: 440vw;
89
+ position: absolute;
90
+ height: var(--width);
91
+ width: var(--width);
92
+ left: calc((var(--width) - 100vw) * -1 / 2 - 40px);
93
+ top: calc(var(--width) * -1 + 1vw);
94
+ border-radius: 50%;
95
+ background-color: var(--background-color);
96
+ z-index: -1;
97
+ }
98
+
99
+ .adm-result-page-content {
100
+ position: relative;
101
+ padding: 24px;
102
+ top: -208px;
103
+ z-index: 2;
104
+ }
105
+
106
+ .adm-result-page-footer {
107
+ position: fixed;
108
+ bottom: 0;
109
+ width: 100%;
110
+ padding: 24px;
111
+ padding-bottom: 48px;
112
+ display: flex;
113
+ justify-content: center;
114
+ background-color: var(--adm-color-box);
115
+ z-index: 3;
116
+ }
117
+
118
+ .adm-result-page-footer-btn {
119
+ flex: 1;
120
+ max-width: calc((100vw - 72px) / 2);
121
+ }
122
+
123
+ .adm-result-page-footer-space {
124
+ width: 24px;
125
+ }
126
+
127
+ .adm-result-page-card {
128
+ border-radius: 16px;
129
+ background-color: var(--adm-color-background);
130
+ }
@@ -0,0 +1,23 @@
1
+ import React, { FC, ReactNode } from 'react';
2
+ import { NativeProps } from '../../utils/native-props';
3
+ interface ResultPageDetail {
4
+ label: ReactNode;
5
+ value: ReactNode;
6
+ bold?: boolean;
7
+ }
8
+ declare type ResultPageDetails = ResultPageDetail[];
9
+ declare type OnClick = (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void | Promise<void> | unknown;
10
+ export declare type ResultPageProps = {
11
+ status?: 'success' | 'error' | 'info' | 'waiting' | 'warning';
12
+ title: ReactNode;
13
+ description?: ReactNode;
14
+ icon?: ReactNode;
15
+ details?: ResultPageDetails;
16
+ children?: ReactNode;
17
+ primaryButtonText?: ReactNode;
18
+ secondaryButtonText?: ReactNode;
19
+ onPrimaryButtonClick?: OnClick;
20
+ onSecondaryButtonClick?: OnClick;
21
+ } & NativeProps<'--background-color'>;
22
+ export declare const ResultPage: FC<ResultPageProps>;
23
+ export {};
@@ -0,0 +1,83 @@
1
+ import React, { useState } from 'react';
2
+ import { CheckCircleFill, CloseCircleFill, InformationCircleFill, ClockCircleFill, ExclamationCircleFill } from 'antd-mobile-icons';
3
+ import classNames from 'classnames';
4
+ import { withNativeProps } from '../../utils/native-props';
5
+ import { mergeProps } from '../../utils/with-default-props';
6
+ import { isNodeWithContent } from '../../utils/is-node-with-content';
7
+ import Button from '../button';
8
+ const classPrefix = `adm-result-page`;
9
+ const iconRecord = {
10
+ success: CheckCircleFill,
11
+ error: CloseCircleFill,
12
+ info: InformationCircleFill,
13
+ waiting: ClockCircleFill,
14
+ warning: ExclamationCircleFill
15
+ };
16
+ const defaultProps = {
17
+ status: 'info',
18
+ details: []
19
+ };
20
+ export const ResultPage = p => {
21
+ const props = mergeProps(defaultProps, p);
22
+ const {
23
+ status,
24
+ title,
25
+ description,
26
+ details,
27
+ icon,
28
+ primaryButtonText,
29
+ secondaryButtonText,
30
+ onPrimaryButtonClick,
31
+ onSecondaryButtonClick
32
+ } = props;
33
+ const resultIcon = icon || React.createElement(iconRecord[status]);
34
+ const [collapse, setCollapse] = useState(true);
35
+ const showSecondaryButton = isNodeWithContent(secondaryButtonText);
36
+ const showPrimaryButton = isNodeWithContent(primaryButtonText);
37
+ return withNativeProps(props, React.createElement("div", {
38
+ className: classPrefix
39
+ }, React.createElement("div", {
40
+ className: `${classPrefix}-header`
41
+ }, React.createElement("div", {
42
+ className: `${classPrefix}-icon`
43
+ }, resultIcon), React.createElement("div", {
44
+ className: `${classPrefix}-title`
45
+ }, title), isNodeWithContent(description) ? React.createElement("div", {
46
+ className: `${classPrefix}-description`
47
+ }, description) : null, details.length ? React.createElement("div", {
48
+ className: `${classPrefix}-details`
49
+ }, (collapse ? details.slice(0, 3) : details).map((detail, index) => {
50
+ return React.createElement("div", {
51
+ className: classNames(`${classPrefix}-detail`, detail.bold && `${classPrefix}-detail-bold`),
52
+ key: index
53
+ }, React.createElement("span", null, detail.label), React.createElement("span", null, detail.value));
54
+ }), details.length > 3 && React.createElement("div", {
55
+ onClick: () => setCollapse(prev => !prev)
56
+ }, React.createElement("div", {
57
+ className: classNames(`${classPrefix}-collapse`, !collapse && `${classPrefix}-collapse-active`)
58
+ }))) : null, React.createElement("div", {
59
+ className: `${classPrefix}-bgWrapper`
60
+ }, React.createElement("div", {
61
+ className: `${classPrefix}-bg`
62
+ }))), React.createElement("div", {
63
+ className: `${classPrefix}-content`
64
+ }, props.children), React.createElement("div", {
65
+ className: `${classPrefix}-footer`
66
+ }, showSecondaryButton && React.createElement(Button, {
67
+ block: true,
68
+ color: 'default',
69
+ fill: 'solid',
70
+ size: 'large',
71
+ onClick: onSecondaryButtonClick,
72
+ className: `${classPrefix}-footer-btn`
73
+ }, secondaryButtonText), showPrimaryButton && showSecondaryButton && React.createElement("div", {
74
+ className: `${classPrefix}-footer-space`
75
+ }), showPrimaryButton && React.createElement(Button, {
76
+ block: true,
77
+ color: 'primary',
78
+ fill: 'solid',
79
+ size: 'large',
80
+ onClick: onPrimaryButtonClick,
81
+ className: `${classPrefix}-footer-btn`
82
+ }, primaryButtonText))));
83
+ };
@@ -217,7 +217,7 @@ export const Swiper = forwardRef(staged((p, ref) => {
217
217
  return () => {
218
218
  window.clearInterval(interval);
219
219
  };
220
- }, [autoplay, autoplayInterval, dragging]);
220
+ }, [autoplay, autoplayInterval, dragging, count]);
221
221
 
222
222
  function renderTrackInner() {
223
223
  if (loop) {
package/2x/es/index.d.ts CHANGED
@@ -56,6 +56,7 @@ export { default as PullToRefresh } from './components/pull-to-refresh';
56
56
  export { default as Radio } from './components/radio';
57
57
  export { default as Rate } from './components/rate';
58
58
  export { default as Result } from './components/result';
59
+ export { default as ResultPage } from './components/result-page';
59
60
  export { default as SafeArea } from './components/safe-area';
60
61
  export { default as ScrollMask } from './components/scroll-mask';
61
62
  export { default as SearchBar } from './components/search-bar';
package/2x/es/index.js CHANGED
@@ -56,6 +56,7 @@ export { default as PullToRefresh } from './components/pull-to-refresh';
56
56
  export { default as Radio } from './components/radio';
57
57
  export { default as Rate } from './components/rate';
58
58
  export { default as Result } from './components/result';
59
+ export { default as ResultPage } from './components/result-page';
59
60
  export { default as SafeArea } from './components/safe-area';
60
61
  export { default as ScrollMask } from './components/scroll-mask';
61
62
  export { default as SearchBar } from './components/search-bar';
package/2x/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "antd-mobile",
3
- "version": "5.20.0",
3
+ "version": "5.21.0",
4
4
  "dependencies": {
5
- "@floating-ui/dom": "^0.5.2",
5
+ "@floating-ui/dom": "^1.0.0",
6
6
  "@react-spring/web": "^9.4.5",
7
7
  "@use-gesture/react": "10.2.17",
8
- "ahooks": "^3.5.2",
8
+ "ahooks": "^3.7.0",
9
9
  "antd-mobile-icons": "^0.3.0",
10
10
  "antd-mobile-v5-count": "^1.0.1",
11
11
  "big.js": "^6.2.1",