antd-mobile 5.19.0 → 5.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/2x/bundle/antd-mobile.cjs.development.js +25724 -0
- package/2x/bundle/antd-mobile.cjs.js +8 -32
- package/2x/bundle/antd-mobile.compatible.umd.js +10464 -10860
- package/2x/bundle/antd-mobile.es.development.js +25704 -0
- package/2x/bundle/antd-mobile.es.js +8381 -8615
- package/2x/bundle/antd-mobile.umd.development.js +25726 -0
- package/2x/bundle/antd-mobile.umd.js +8 -32
- package/2x/bundle/style.css +153 -7
- package/2x/cjs/components/action-sheet/action-sheet.css +6 -2
- package/2x/cjs/components/action-sheet/action-sheet.d.ts +1 -0
- package/2x/cjs/components/action-sheet/action-sheet.js +2 -1
- package/2x/cjs/components/check-list/check-list.css +1 -1
- package/2x/cjs/components/ellipsis/ellipsis.js +1 -0
- package/2x/cjs/components/floating-panel/floating-panel.js +2 -2
- package/2x/cjs/components/form/context.d.ts +1 -1
- package/2x/cjs/components/form/form-item.d.ts +1 -1
- package/2x/cjs/components/form/form-item.js +3 -0
- package/2x/cjs/components/image/test/image.test.js +57 -8
- package/2x/cjs/components/image-viewer/image-viewer.js +4 -2
- package/2x/cjs/components/index-bar/index-bar.css +1 -1
- package/2x/cjs/components/page-indicator/page-indicator.css +1 -1
- package/2x/cjs/components/picker-view/wheel.js +2 -0
- package/2x/cjs/components/rate/rate.css +4 -0
- package/2x/cjs/components/rate/rate.js +42 -13
- package/2x/cjs/components/result-page/index.d.ts +7 -0
- package/2x/cjs/components/result-page/index.js +20 -0
- package/2x/cjs/components/result-page/result-page-card.d.ts +6 -0
- package/2x/cjs/components/result-page/result-page-card.js +24 -0
- package/2x/cjs/components/result-page/result-page.css +130 -0
- package/2x/cjs/components/result-page/result-page.d.ts +23 -0
- package/2x/cjs/components/result-page/result-page.js +108 -0
- package/2x/cjs/components/selector/selector.css +10 -0
- package/2x/cjs/components/selector/selector.d.ts +3 -2
- package/2x/cjs/components/selector/selector.js +1 -4
- package/2x/cjs/components/swipe-action/swipe-action.d.ts +2 -0
- package/2x/cjs/components/swipe-action/swipe-action.js +34 -6
- package/2x/cjs/components/swiper/swiper.js +15 -1
- package/2x/cjs/components/tab-bar/tab-bar.css +2 -2
- package/2x/cjs/index.d.ts +1 -0
- package/2x/cjs/index.js +8 -0
- package/2x/cjs/locales/id-ID.js +13 -0
- package/2x/cjs/utils/use-resize-effect.js +3 -1
- package/2x/es/components/action-sheet/action-sheet.css +6 -2
- package/2x/es/components/action-sheet/action-sheet.d.ts +1 -0
- package/2x/es/components/action-sheet/action-sheet.js +2 -1
- package/2x/es/components/check-list/check-list.css +1 -1
- package/2x/es/components/ellipsis/ellipsis.js +1 -0
- package/2x/es/components/floating-panel/floating-panel.js +2 -2
- package/2x/es/components/form/context.d.ts +1 -1
- package/2x/es/components/form/form-item.d.ts +1 -1
- package/2x/es/components/form/form-item.js +3 -0
- package/2x/es/components/image/test/image.test.js +54 -8
- package/2x/es/components/image-viewer/image-viewer.js +4 -2
- package/2x/es/components/index-bar/index-bar.css +1 -1
- package/2x/es/components/page-indicator/page-indicator.css +1 -1
- package/2x/es/components/picker-view/wheel.js +2 -0
- package/2x/es/components/rate/rate.css +4 -0
- package/2x/es/components/rate/rate.js +36 -13
- package/2x/es/components/result-page/index.d.ts +7 -0
- package/2x/es/components/result-page/index.js +7 -0
- package/2x/es/components/result-page/result-page-card.d.ts +6 -0
- package/2x/es/components/result-page/result-page-card.js +9 -0
- package/2x/es/components/result-page/result-page.css +130 -0
- package/2x/es/components/result-page/result-page.d.ts +23 -0
- package/2x/es/components/result-page/result-page.js +83 -0
- package/2x/es/components/selector/selector.css +10 -0
- package/2x/es/components/selector/selector.d.ts +3 -2
- package/2x/es/components/selector/selector.js +1 -3
- package/2x/es/components/swipe-action/swipe-action.d.ts +2 -0
- package/2x/es/components/swipe-action/swipe-action.js +34 -6
- package/2x/es/components/swiper/swiper.js +15 -1
- package/2x/es/components/tab-bar/tab-bar.css +2 -2
- package/2x/es/index.d.ts +1 -0
- package/2x/es/index.js +1 -0
- package/2x/es/locales/id-ID.js +13 -0
- package/2x/es/utils/use-resize-effect.js +3 -1
- package/2x/package.json +6 -6
- package/2x/umd/antd-mobile.js +10464 -10860
- package/bundle/antd-mobile.cjs.development.js +25724 -0
- package/bundle/antd-mobile.cjs.js +8 -32
- package/bundle/antd-mobile.compatible.umd.js +10464 -10860
- package/bundle/antd-mobile.es.development.js +25704 -0
- package/bundle/antd-mobile.es.js +8381 -8615
- package/bundle/antd-mobile.umd.development.js +25726 -0
- package/bundle/antd-mobile.umd.js +8 -32
- package/bundle/style.css +1 -1
- package/cjs/components/action-sheet/action-sheet.css +5 -2
- package/cjs/components/action-sheet/action-sheet.d.ts +1 -0
- package/cjs/components/action-sheet/action-sheet.js +2 -1
- package/cjs/components/check-list/check-list.css +1 -1
- package/cjs/components/ellipsis/ellipsis.js +1 -0
- package/cjs/components/floating-panel/floating-panel.js +2 -2
- package/cjs/components/form/context.d.ts +1 -1
- package/cjs/components/form/form-item.d.ts +1 -1
- package/cjs/components/form/form-item.js +3 -0
- package/cjs/components/image/test/image.test.js +57 -8
- package/cjs/components/image-viewer/image-viewer.js +4 -2
- package/cjs/components/index-bar/index-bar.css +1 -1
- package/cjs/components/page-indicator/page-indicator.css +1 -1
- package/cjs/components/picker-view/wheel.js +2 -0
- package/cjs/components/rate/rate.css +4 -0
- package/cjs/components/rate/rate.js +42 -13
- package/cjs/components/result-page/index.d.ts +7 -0
- package/cjs/components/result-page/index.js +20 -0
- package/cjs/components/result-page/result-page-card.d.ts +6 -0
- package/cjs/components/result-page/result-page-card.js +24 -0
- package/cjs/components/result-page/result-page.css +113 -0
- package/cjs/components/result-page/result-page.d.ts +23 -0
- package/cjs/components/result-page/result-page.js +108 -0
- package/cjs/components/selector/selector.css +9 -0
- package/cjs/components/selector/selector.d.ts +3 -2
- package/cjs/components/selector/selector.js +1 -4
- package/cjs/components/swipe-action/swipe-action.d.ts +2 -0
- package/cjs/components/swipe-action/swipe-action.js +34 -6
- package/cjs/components/swiper/swiper.js +15 -1
- package/cjs/components/tab-bar/tab-bar.css +2 -2
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +8 -0
- package/cjs/locales/id-ID.js +13 -0
- package/cjs/utils/use-resize-effect.js +3 -1
- package/es/components/action-sheet/action-sheet.css +5 -2
- package/es/components/action-sheet/action-sheet.d.ts +1 -0
- package/es/components/action-sheet/action-sheet.js +2 -1
- package/es/components/check-list/check-list.css +1 -1
- package/es/components/ellipsis/ellipsis.js +1 -0
- package/es/components/floating-panel/floating-panel.js +2 -2
- package/es/components/form/context.d.ts +1 -1
- package/es/components/form/form-item.d.ts +1 -1
- package/es/components/form/form-item.js +3 -0
- package/es/components/image/test/image.test.js +54 -8
- package/es/components/image-viewer/image-viewer.js +4 -2
- package/es/components/index-bar/index-bar.css +1 -1
- package/es/components/page-indicator/page-indicator.css +1 -1
- package/es/components/picker-view/wheel.js +2 -0
- package/es/components/rate/rate.css +4 -0
- package/es/components/rate/rate.js +36 -13
- package/es/components/result-page/index.d.ts +7 -0
- package/es/components/result-page/index.js +7 -0
- package/es/components/result-page/result-page-card.d.ts +6 -0
- package/es/components/result-page/result-page-card.js +9 -0
- package/es/components/result-page/result-page.css +113 -0
- package/es/components/result-page/result-page.d.ts +23 -0
- package/es/components/result-page/result-page.js +83 -0
- package/es/components/selector/selector.css +9 -0
- package/es/components/selector/selector.d.ts +3 -2
- package/es/components/selector/selector.js +1 -3
- package/es/components/swipe-action/swipe-action.d.ts +2 -0
- package/es/components/swipe-action/swipe-action.js +34 -6
- package/es/components/swiper/swiper.js +15 -1
- package/es/components/tab-bar/tab-bar.css +2 -2
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/locales/id-ID.js +13 -0
- package/es/utils/use-resize-effect.js +3 -1
- package/package.json +6 -6
- package/umd/antd-mobile.js +1 -1
package/cjs/index.js
CHANGED
|
@@ -339,6 +339,12 @@ Object.defineProperty(exports, "Result", {
|
|
|
339
339
|
return _result.default;
|
|
340
340
|
}
|
|
341
341
|
});
|
|
342
|
+
Object.defineProperty(exports, "ResultPage", {
|
|
343
|
+
enumerable: true,
|
|
344
|
+
get: function () {
|
|
345
|
+
return _resultPage.default;
|
|
346
|
+
}
|
|
347
|
+
});
|
|
342
348
|
Object.defineProperty(exports, "SafeArea", {
|
|
343
349
|
enumerable: true,
|
|
344
350
|
get: function () {
|
|
@@ -610,6 +616,8 @@ var _rate = _interopRequireDefault(require("./components/rate"));
|
|
|
610
616
|
|
|
611
617
|
var _result = _interopRequireDefault(require("./components/result"));
|
|
612
618
|
|
|
619
|
+
var _resultPage = _interopRequireDefault(require("./components/result-page"));
|
|
620
|
+
|
|
613
621
|
var _safeArea = _interopRequireDefault(require("./components/safe-area"));
|
|
614
622
|
|
|
615
623
|
var _scrollMask = _interopRequireDefault(require("./components/scroll-mask"));
|
package/cjs/locales/id-ID.js
CHANGED
|
@@ -115,6 +115,19 @@ const idID = (0, _mergeLocale.mergeLocale)(_base.base, {
|
|
|
115
115
|
pulling: 'Tarik ke bawah untuk menyegarkan',
|
|
116
116
|
canRelease: 'Lepaskan untuk menyegarkan segera',
|
|
117
117
|
complete: 'Segarkan berhasil'
|
|
118
|
+
},
|
|
119
|
+
SearchBar: {
|
|
120
|
+
name: 'Bilah Pencarian'
|
|
121
|
+
},
|
|
122
|
+
Slider: {
|
|
123
|
+
name: 'Penggeser'
|
|
124
|
+
},
|
|
125
|
+
Stepper: {
|
|
126
|
+
decrease: 'mengurangi',
|
|
127
|
+
increase: 'meningkat'
|
|
128
|
+
},
|
|
129
|
+
Switch: {
|
|
130
|
+
name: 'Mengalihkan'
|
|
118
131
|
}
|
|
119
132
|
});
|
|
120
133
|
var _default = idID;
|
|
@@ -14,11 +14,13 @@ function useResizeEffect(effect, targetRef) {
|
|
|
14
14
|
if (!target) return;
|
|
15
15
|
|
|
16
16
|
if (window.ResizeObserver) {
|
|
17
|
+
let animationFrame;
|
|
17
18
|
const observer = new ResizeObserver(() => {
|
|
18
|
-
fn(target);
|
|
19
|
+
animationFrame = window.requestAnimationFrame(() => fn(target));
|
|
19
20
|
});
|
|
20
21
|
observer.observe(target);
|
|
21
22
|
return () => {
|
|
23
|
+
window.cancelAnimationFrame(animationFrame);
|
|
22
24
|
observer.disconnect();
|
|
23
25
|
};
|
|
24
26
|
} else {
|
|
@@ -39,13 +39,16 @@
|
|
|
39
39
|
font-size: var(--adm-font-size-10);
|
|
40
40
|
}
|
|
41
41
|
.adm-action-sheet-button-item-description {
|
|
42
|
-
font-size: var(--adm-font-size-
|
|
42
|
+
font-size: var(--adm-font-size-6);
|
|
43
43
|
color: var(--adm-color-weak);
|
|
44
|
-
padding-top:
|
|
44
|
+
padding-top: 4px;
|
|
45
45
|
}
|
|
46
46
|
.adm-action-sheet-button-item-danger .adm-action-sheet-button-item-name {
|
|
47
47
|
color: var(--adm-color-danger);
|
|
48
48
|
}
|
|
49
|
+
.adm-action-sheet-button-item-bold .adm-action-sheet-button-item-name {
|
|
50
|
+
font-weight: bold;
|
|
51
|
+
}
|
|
49
52
|
.adm-action-sheet-cancel {
|
|
50
53
|
background-color: var(--adm-color-box);
|
|
51
54
|
padding-top: 8px;
|
|
@@ -47,7 +47,8 @@ export const ActionSheet = p => {
|
|
|
47
47
|
}, React.createElement("a", {
|
|
48
48
|
className: classNames('adm-plain-anchor', `${classPrefix}-button-item`, {
|
|
49
49
|
[`${classPrefix}-button-item-danger`]: action.danger,
|
|
50
|
-
[`${classPrefix}-button-item-disabled`]: action.disabled
|
|
50
|
+
[`${classPrefix}-button-item-disabled`]: action.disabled,
|
|
51
|
+
[`${classPrefix}-button-item-bold`]: action.bold
|
|
51
52
|
}),
|
|
52
53
|
onClick: () => {
|
|
53
54
|
var _a, _b, _c;
|
|
@@ -23,6 +23,7 @@ export const Ellipsis = p => {
|
|
|
23
23
|
function calcEllipsised() {
|
|
24
24
|
const root = rootRef.current;
|
|
25
25
|
if (!root) return;
|
|
26
|
+
if (!root.offsetParent) return;
|
|
26
27
|
const originStyle = window.getComputedStyle(root);
|
|
27
28
|
const container = document.createElement('div');
|
|
28
29
|
const styleNames = Array.prototype.slice.apply(originStyle);
|
|
@@ -113,8 +113,8 @@ export const FloatingPanel = forwardRef((p, ref) => {
|
|
|
113
113
|
ref: elementRef,
|
|
114
114
|
className: 'adm-floating-panel',
|
|
115
115
|
style: {
|
|
116
|
-
height: maxHeight,
|
|
117
|
-
translateY: y.to(y => `calc(100% + (${y}px))`)
|
|
116
|
+
height: Math.round(maxHeight),
|
|
117
|
+
translateY: y.to(y => `calc(100% + (${Math.round(y)}px))`)
|
|
118
118
|
}
|
|
119
119
|
}, React.createElement("div", {
|
|
120
120
|
className: 'adm-floating-panel-mask',
|
|
@@ -5,7 +5,7 @@ export declare type FormContextType = {
|
|
|
5
5
|
name?: string;
|
|
6
6
|
hasFeedback: boolean;
|
|
7
7
|
layout: FormLayout;
|
|
8
|
-
requiredMarkStyle: 'asterisk' | 'text-required' | 'text-optional';
|
|
8
|
+
requiredMarkStyle: 'asterisk' | 'text-required' | 'text-optional' | 'none';
|
|
9
9
|
disabled: boolean;
|
|
10
10
|
};
|
|
11
11
|
export declare const defaultFormContext: FormContextType;
|
|
@@ -7,7 +7,7 @@ import type { FormLayout } from './index';
|
|
|
7
7
|
declare type RenderChildren<Values = any> = (form: FormInstance<Values>) => React.ReactNode;
|
|
8
8
|
declare type ChildrenType<Values = any> = RenderChildren<Values> | React.ReactNode;
|
|
9
9
|
declare type RcFieldProps = Omit<FieldProps, 'children'>;
|
|
10
|
-
export declare type FormItemProps = Pick<RcFieldProps, 'dependencies' | 'valuePropName' | 'name' | 'rules' | 'messageVariables' | 'trigger' | 'validateTrigger' | 'shouldUpdate' | 'initialValue'> & Pick<ListItemProps, 'style' | 'extra' | 'clickable' | 'arrow' | 'description'> & {
|
|
10
|
+
export declare type FormItemProps = Pick<RcFieldProps, 'dependencies' | 'valuePropName' | 'name' | 'rules' | 'messageVariables' | 'trigger' | 'validateTrigger' | 'shouldUpdate' | 'initialValue' | 'getValueFromEvent' | 'getValueProps' | 'normalize' | 'preserve' | 'validateFirst'> & Pick<ListItemProps, 'style' | 'extra' | 'clickable' | 'arrow' | 'description'> & {
|
|
11
11
|
label?: React.ReactNode;
|
|
12
12
|
help?: React.ReactNode;
|
|
13
13
|
hasFeedback?: boolean;
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
2
1
|
import React from 'react';
|
|
3
|
-
import { fireEvent, render,
|
|
2
|
+
import { fireEvent, render, act } from 'testing';
|
|
4
3
|
import Image from '../index';
|
|
4
|
+
const classPrefix = `adm-image`;
|
|
5
5
|
const demoSrc = 'https://images.unsplash.com/photo-1567945716310-4745a6b7844b?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=300&q=60';
|
|
6
|
-
describe('
|
|
7
|
-
test('a11y', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
8
|
-
yield testA11y(React.createElement(Image, {
|
|
9
|
-
src: demoSrc
|
|
10
|
-
}));
|
|
11
|
-
}));
|
|
6
|
+
describe('Image', () => {
|
|
12
7
|
test('onContainerClick can work', () => {
|
|
13
8
|
const onContainerClick = jest.fn();
|
|
14
9
|
const {
|
|
@@ -21,4 +16,55 @@ describe('image', () => {
|
|
|
21
16
|
fireEvent.click(getByTestId('img'));
|
|
22
17
|
expect(onContainerClick).toBeCalledTimes(1);
|
|
23
18
|
});
|
|
19
|
+
test('load successfully', () => {
|
|
20
|
+
render(React.createElement(Image, {
|
|
21
|
+
src: demoSrc
|
|
22
|
+
}));
|
|
23
|
+
const img = document.querySelectorAll(`.${classPrefix}-img`)[0];
|
|
24
|
+
fireEvent.load(img);
|
|
25
|
+
expect(img).toHaveAttribute('src', demoSrc);
|
|
26
|
+
});
|
|
27
|
+
test('load failed', () => {
|
|
28
|
+
render(React.createElement(Image, {
|
|
29
|
+
src: '404'
|
|
30
|
+
}));
|
|
31
|
+
const img = document.querySelectorAll(`.${classPrefix}-img`)[0];
|
|
32
|
+
fireEvent.error(img);
|
|
33
|
+
expect(img).not.toBeInTheDocument();
|
|
34
|
+
expect(document.querySelectorAll(`.${classPrefix}-tip`)[0]).toBeInTheDocument();
|
|
35
|
+
});
|
|
36
|
+
test('lazy load should be work', () => {
|
|
37
|
+
// mock useInViewport
|
|
38
|
+
// https://github.com/alibaba/hooks/blob/master/packages/hooks/src/useInViewport/__tests__/index.test.ts
|
|
39
|
+
const mockIntersectionObserver = jest.fn().mockReturnValue({
|
|
40
|
+
observe: () => null,
|
|
41
|
+
disconnect: () => null
|
|
42
|
+
});
|
|
43
|
+
window.IntersectionObserver = mockIntersectionObserver;
|
|
44
|
+
render(React.createElement(Image, {
|
|
45
|
+
src: demoSrc,
|
|
46
|
+
lazy: true
|
|
47
|
+
}));
|
|
48
|
+
const img = document.querySelectorAll(`.${classPrefix}-img`)[0];
|
|
49
|
+
expect(img).not.toHaveAttribute('src');
|
|
50
|
+
const calls = mockIntersectionObserver.mock.calls;
|
|
51
|
+
const [onChange] = calls[calls.length - 1];
|
|
52
|
+
act(() => {
|
|
53
|
+
onChange([{
|
|
54
|
+
isIntersecting: true
|
|
55
|
+
}]);
|
|
56
|
+
});
|
|
57
|
+
expect(img).toHaveAttribute('src', demoSrc);
|
|
58
|
+
});
|
|
59
|
+
test('renders with width and height', () => {
|
|
60
|
+
const {
|
|
61
|
+
getByTestId
|
|
62
|
+
} = render(React.createElement(Image, {
|
|
63
|
+
src: demoSrc,
|
|
64
|
+
width: 100,
|
|
65
|
+
height: 100,
|
|
66
|
+
"data-testid": 'image'
|
|
67
|
+
}));
|
|
68
|
+
expect(getByTestId('image')).toHaveStyle('--width: 100px;--height: 100px');
|
|
69
|
+
});
|
|
24
70
|
});
|
|
@@ -19,7 +19,8 @@ export const ImageViewer = p => {
|
|
|
19
19
|
visible: props.visible,
|
|
20
20
|
disableBodyScroll: false,
|
|
21
21
|
opacity: 'thick',
|
|
22
|
-
afterClose: props.afterClose
|
|
22
|
+
afterClose: props.afterClose,
|
|
23
|
+
destroyOnClose: true
|
|
23
24
|
}, React.createElement("div", {
|
|
24
25
|
className: `${classPrefix}-content`
|
|
25
26
|
}, props.image && React.createElement(Slide, {
|
|
@@ -64,7 +65,8 @@ export const MultiImageViewer = forwardRef((p, ref) => {
|
|
|
64
65
|
visible: props.visible,
|
|
65
66
|
disableBodyScroll: false,
|
|
66
67
|
opacity: 'thick',
|
|
67
|
-
afterClose: props.afterClose
|
|
68
|
+
afterClose: props.afterClose,
|
|
69
|
+
destroyOnClose: true
|
|
68
70
|
}, React.createElement("div", {
|
|
69
71
|
className: `${classPrefix}-content`
|
|
70
72
|
}, props.images && React.createElement(Slides, {
|
|
@@ -186,6 +186,8 @@ export const Wheel = memo(props => {
|
|
|
186
186
|
if (prev.index !== next.index) return false;
|
|
187
187
|
if (prev.value !== next.value) return false;
|
|
188
188
|
if (prev.onSelect !== next.onSelect) return false;
|
|
189
|
+
if (prev.renderLabel !== next.renderLabel) return false;
|
|
190
|
+
if (prev.mouseWheel !== next.mouseWheel) return false;
|
|
189
191
|
|
|
190
192
|
if (!isEqual(prev.column, next.column)) {
|
|
191
193
|
return false;
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
--active-color: #ffd21e;
|
|
4
4
|
--inactive-color: var(--adm-color-border);
|
|
5
5
|
display: inline-flex;
|
|
6
|
+
touch-action: pan-y;
|
|
7
|
+
-webkit-user-select: none;
|
|
8
|
+
user-select: none;
|
|
6
9
|
}
|
|
7
10
|
.adm-rate-box {
|
|
8
11
|
position: relative;
|
|
@@ -16,6 +19,7 @@
|
|
|
16
19
|
overflow: hidden;
|
|
17
20
|
cursor: pointer;
|
|
18
21
|
box-sizing: border-box;
|
|
22
|
+
transition: all 0.3s;
|
|
19
23
|
}
|
|
20
24
|
.adm-rate-star-half {
|
|
21
25
|
padding-right: 0;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import { withNativeProps } from '../../utils/native-props';
|
|
4
4
|
import { mergeProps } from '../../utils/with-default-props';
|
|
5
5
|
import { usePropsValue } from '../../utils/use-props-value';
|
|
6
6
|
import { Star } from './star';
|
|
7
|
+
import { useDrag } from '@use-gesture/react';
|
|
8
|
+
import { bound } from '../../utils/bound';
|
|
7
9
|
const classPrefix = `adm-rate`;
|
|
8
10
|
const defaultProps = {
|
|
9
11
|
count: 5,
|
|
@@ -16,6 +18,7 @@ const defaultProps = {
|
|
|
16
18
|
export const Rate = p => {
|
|
17
19
|
const props = mergeProps(defaultProps, p);
|
|
18
20
|
const [value, setValue] = usePropsValue(props);
|
|
21
|
+
const containerRef = useRef(null);
|
|
19
22
|
const starList = Array(props.count).fill(null);
|
|
20
23
|
|
|
21
24
|
function renderStar(v, half) {
|
|
@@ -25,26 +28,46 @@ export const Rate = p => {
|
|
|
25
28
|
[`${classPrefix}-star-half`]: half,
|
|
26
29
|
[`${classPrefix}-star-readonly`]: props.readOnly
|
|
27
30
|
}),
|
|
28
|
-
onClick: () => {
|
|
29
|
-
if (props.readOnly) return;
|
|
30
|
-
|
|
31
|
-
if (props.allowClear && value === v) {
|
|
32
|
-
setValue(0);
|
|
33
|
-
} else {
|
|
34
|
-
setValue(v);
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
31
|
role: 'radio',
|
|
38
32
|
"aria-checked": value >= v,
|
|
39
33
|
"aria-label": '' + v
|
|
40
34
|
}, props.character);
|
|
41
35
|
}
|
|
42
36
|
|
|
43
|
-
|
|
37
|
+
const bind = useDrag(state => {
|
|
38
|
+
if (props.readOnly) return;
|
|
39
|
+
const {
|
|
40
|
+
xy: [clientX],
|
|
41
|
+
tap
|
|
42
|
+
} = state;
|
|
43
|
+
const container = containerRef.current;
|
|
44
|
+
if (!container) return;
|
|
45
|
+
const rect = container.getBoundingClientRect();
|
|
46
|
+
const rawValue = (clientX - rect.left) / rect.width * 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);
|
|
58
|
+
}, {
|
|
59
|
+
axis: 'x',
|
|
60
|
+
pointer: {
|
|
61
|
+
touch: true
|
|
62
|
+
},
|
|
63
|
+
filterTaps: true
|
|
64
|
+
});
|
|
65
|
+
return withNativeProps(props, React.createElement("div", Object.assign({
|
|
44
66
|
className: classPrefix,
|
|
45
67
|
role: 'radiogroup',
|
|
46
|
-
"aria-readonly": props.readOnly
|
|
47
|
-
|
|
68
|
+
"aria-readonly": props.readOnly,
|
|
69
|
+
ref: containerRef
|
|
70
|
+
}, bind()), starList.map((_, i) => React.createElement("div", {
|
|
48
71
|
key: i,
|
|
49
72
|
className: classNames(`${classPrefix}-box`)
|
|
50
73
|
}, props.allowHalf && renderStar(i + 0.5, true), renderStar(i + 1, false)))));
|
|
@@ -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,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,113 @@
|
|
|
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
|
+
.adm-result-page-header {
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
background-color: transparent;
|
|
13
|
+
position: relative;
|
|
14
|
+
padding: 20px;
|
|
15
|
+
padding-bottom: 100px;
|
|
16
|
+
z-index: 1;
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
}
|
|
19
|
+
.adm-result-page-icon {
|
|
20
|
+
color: var(--adm-color-background);
|
|
21
|
+
box-sizing: border-box;
|
|
22
|
+
padding: 2px;
|
|
23
|
+
margin-bottom: 8px;
|
|
24
|
+
}
|
|
25
|
+
.adm-result-page-icon .antd-mobile-icon {
|
|
26
|
+
font-size: 32px;
|
|
27
|
+
}
|
|
28
|
+
.adm-result-page-title {
|
|
29
|
+
font-size: var(--adm-font-size-10);
|
|
30
|
+
color: var(--adm-color-background);
|
|
31
|
+
line-height: 1.4;
|
|
32
|
+
text-align: center;
|
|
33
|
+
}
|
|
34
|
+
.adm-result-page-description {
|
|
35
|
+
margin-top: 8px;
|
|
36
|
+
margin-bottom: 24px;
|
|
37
|
+
font-size: var(--adm-font-size-6);
|
|
38
|
+
color: rgba(255, 255, 255, 0.6);
|
|
39
|
+
line-height: 1.4;
|
|
40
|
+
text-align: center;
|
|
41
|
+
}
|
|
42
|
+
.adm-result-page-details {
|
|
43
|
+
width: 100%;
|
|
44
|
+
}
|
|
45
|
+
.adm-result-page-detail {
|
|
46
|
+
width: 100%;
|
|
47
|
+
display: flex;
|
|
48
|
+
flex-direction: row;
|
|
49
|
+
justify-content: space-between;
|
|
50
|
+
margin-bottom: 5px;
|
|
51
|
+
color: var(--adm-color-background);
|
|
52
|
+
font-size: var(--adm-font-size-6);
|
|
53
|
+
}
|
|
54
|
+
.adm-result-page-detail-bold {
|
|
55
|
+
font-weight: 600;
|
|
56
|
+
}
|
|
57
|
+
.adm-result-page-collapse {
|
|
58
|
+
opacity: 0.6;
|
|
59
|
+
width: 10px;
|
|
60
|
+
height: 10px;
|
|
61
|
+
margin: auto;
|
|
62
|
+
margin-bottom: 5px;
|
|
63
|
+
border-top: 2px solid var(--adm-color-background);
|
|
64
|
+
border-right: 2px solid var(--adm-color-background);
|
|
65
|
+
transform: rotate(135deg);
|
|
66
|
+
}
|
|
67
|
+
.adm-result-page-collapse-active {
|
|
68
|
+
transform: rotate(-45deg);
|
|
69
|
+
}
|
|
70
|
+
.adm-result-page-bgWrapper {
|
|
71
|
+
position: relative;
|
|
72
|
+
align-self: flex-start;
|
|
73
|
+
top: 54px;
|
|
74
|
+
}
|
|
75
|
+
.adm-result-page-bg {
|
|
76
|
+
--width: 440vw;
|
|
77
|
+
position: absolute;
|
|
78
|
+
height: var(--width);
|
|
79
|
+
width: var(--width);
|
|
80
|
+
left: calc((var(--width) - 100vw) * -1 / 2 - 20px);
|
|
81
|
+
top: calc(var(--width) * -1 + 1vw);
|
|
82
|
+
border-radius: 50%;
|
|
83
|
+
background-color: var(--background-color);
|
|
84
|
+
z-index: -1;
|
|
85
|
+
}
|
|
86
|
+
.adm-result-page-content {
|
|
87
|
+
position: relative;
|
|
88
|
+
padding: 12px;
|
|
89
|
+
top: -104px;
|
|
90
|
+
z-index: 2;
|
|
91
|
+
}
|
|
92
|
+
.adm-result-page-footer {
|
|
93
|
+
position: fixed;
|
|
94
|
+
bottom: 0;
|
|
95
|
+
width: 100%;
|
|
96
|
+
padding: 12px;
|
|
97
|
+
padding-bottom: 24px;
|
|
98
|
+
display: flex;
|
|
99
|
+
justify-content: center;
|
|
100
|
+
background-color: var(--adm-color-box);
|
|
101
|
+
z-index: 3;
|
|
102
|
+
}
|
|
103
|
+
.adm-result-page-footer-btn {
|
|
104
|
+
flex: 1;
|
|
105
|
+
max-width: calc((100vw - 36px) / 2);
|
|
106
|
+
}
|
|
107
|
+
.adm-result-page-footer-space {
|
|
108
|
+
width: 12px;
|
|
109
|
+
}
|
|
110
|
+
.adm-result-page-card {
|
|
111
|
+
border-radius: 8px;
|
|
112
|
+
background-color: var(--adm-color-background);
|
|
113
|
+
}
|
|
@@ -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
|
+
};
|
|
@@ -7,6 +7,10 @@
|
|
|
7
7
|
--checked-border: none;
|
|
8
8
|
--border-radius: 2px;
|
|
9
9
|
--padding: 8px 16px;
|
|
10
|
+
--gap: 8px;
|
|
11
|
+
---gap: var(--gap);
|
|
12
|
+
---gap-horizontal: var(--gap-horizontal, var(--gap));
|
|
13
|
+
---gap-vertical: var(--gap-vertical, var(--gap));
|
|
10
14
|
overflow: hidden;
|
|
11
15
|
font-size: var(--adm-font-size-7);
|
|
12
16
|
line-height: 1.4;
|
|
@@ -14,6 +18,11 @@
|
|
|
14
18
|
.adm-selector .adm-space.adm-space {
|
|
15
19
|
--gap: 12px;
|
|
16
20
|
}
|
|
21
|
+
.adm-selector .adm-grid {
|
|
22
|
+
--gap: var(---gap);
|
|
23
|
+
--gap-horizontal: var(---gap-horizontal);
|
|
24
|
+
--gap-vertical: var(---gap-vertical);
|
|
25
|
+
}
|
|
17
26
|
.adm-selector-item {
|
|
18
27
|
padding: var(--padding);
|
|
19
28
|
position: relative;
|