taro-ui 3.3.3 → 3.4.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/LICENSE +1 -1
- package/README.md +85 -0
- package/dist/common/utils.d.ts +2 -1
- package/dist/common/utils.js +3 -0
- package/dist/common/utils.js.map +1 -1
- package/dist/components/accordion/index.d.ts +16 -13
- package/dist/components/accordion/index.js +77 -97
- package/dist/components/accordion/index.js.map +1 -1
- package/dist/components/action-sheet/body/index.d.ts +2 -4
- package/dist/components/action-sheet/body/index.js +8 -6
- package/dist/components/action-sheet/body/index.js.map +1 -1
- package/dist/components/action-sheet/body/item/index.d.ts +7 -7
- package/dist/components/action-sheet/body/item/index.js +14 -14
- package/dist/components/action-sheet/body/item/index.js.map +1 -1
- package/dist/components/action-sheet/footer/index.d.ts +7 -7
- package/dist/components/action-sheet/footer/index.js +14 -17
- package/dist/components/action-sheet/footer/index.js.map +1 -1
- package/dist/components/action-sheet/header/index.d.ts +2 -4
- package/dist/components/action-sheet/header/index.js +8 -9
- package/dist/components/action-sheet/header/index.js.map +1 -1
- package/dist/components/action-sheet/index.d.ts +12 -13
- package/dist/components/action-sheet/index.js +53 -57
- package/dist/components/action-sheet/index.js.map +1 -1
- package/dist/components/activity-indicator/index.d.ts +12 -6
- package/dist/components/activity-indicator/index.js +19 -22
- package/dist/components/activity-indicator/index.js.map +1 -1
- package/dist/components/avatar/index.d.ts +14 -8
- package/dist/components/avatar/index.js +36 -43
- package/dist/components/avatar/index.js.map +1 -1
- package/dist/components/badge/index.d.ts +11 -8
- package/dist/components/badge/index.js +18 -34
- package/dist/components/badge/index.js.map +1 -1
- package/dist/components/button/index.d.ts +29 -14
- package/dist/components/button/index.js +97 -112
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/calendar/body/index.d.ts +3 -26
- package/dist/components/calendar/body/index.js +215 -235
- package/dist/components/calendar/body/index.js.map +1 -1
- package/dist/components/calendar/controller/index.d.ts +3 -5
- package/dist/components/calendar/controller/index.js +47 -43
- package/dist/components/calendar/controller/index.js.map +1 -1
- package/dist/components/calendar/index.d.ts +3 -20
- package/dist/components/calendar/index.js +219 -201
- package/dist/components/calendar/index.js.map +1 -1
- package/dist/components/calendar/ui/date-list/index.d.ts +2 -6
- package/dist/components/calendar/ui/date-list/index.js +36 -41
- package/dist/components/calendar/ui/date-list/index.js.map +1 -1
- package/dist/components/calendar/ui/day-list/index.d.ts +2 -4
- package/dist/components/calendar/ui/day-list/index.js +6 -5
- package/dist/components/calendar/ui/day-list/index.js.map +1 -1
- package/dist/components/card/index.d.ts +15 -7
- package/dist/components/card/index.js +42 -43
- package/dist/components/card/index.js.map +1 -1
- package/dist/components/checkbox/index.d.ts +11 -7
- package/dist/components/checkbox/index.js +30 -35
- package/dist/components/checkbox/index.js.map +1 -1
- package/dist/components/config-provider/context.d.ts +6 -0
- package/dist/components/config-provider/context.js +13 -0
- package/dist/components/config-provider/context.js.map +1 -0
- package/dist/components/config-provider/index.d.ts +7 -0
- package/dist/components/config-provider/index.js +15 -0
- package/dist/components/config-provider/index.js.map +1 -0
- package/dist/components/countdown/index.d.ts +19 -19
- package/dist/components/countdown/index.js +183 -118
- package/dist/components/countdown/index.js.map +1 -1
- package/dist/components/countdown/item/index.d.ts +8 -7
- package/dist/components/countdown/item/index.js +10 -13
- package/dist/components/countdown/item/index.js.map +1 -1
- package/dist/components/curtain/index.d.ts +11 -8
- package/dist/components/curtain/index.js +36 -45
- package/dist/components/curtain/index.js.map +1 -1
- package/dist/components/divider/index.d.ts +13 -6
- package/dist/components/divider/index.js +29 -38
- package/dist/components/divider/index.js.map +1 -1
- package/dist/components/drawer/index.d.ts +13 -15
- package/dist/components/drawer/index.js +100 -93
- package/dist/components/drawer/index.js.map +1 -1
- package/dist/components/fab/index.d.ts +8 -7
- package/dist/components/fab/index.js +16 -16
- package/dist/components/fab/index.js.map +1 -1
- package/dist/components/flex/index.d.ts +11 -5
- package/dist/components/flex/index.js +17 -18
- package/dist/components/flex/index.js.map +1 -1
- package/dist/components/flex/item/index.d.ts +11 -5
- package/dist/components/flex/item/index.js +17 -18
- package/dist/components/flex/item/index.js.map +1 -1
- package/dist/components/float-layout/index.d.ts +20 -12
- package/dist/components/float-layout/index.js +56 -72
- package/dist/components/float-layout/index.js.map +1 -1
- package/dist/components/form/index.d.ts +11 -8
- package/dist/components/form/index.js +28 -28
- package/dist/components/form/index.js.map +1 -1
- package/dist/components/grid/index.d.ts +22 -7
- package/dist/components/grid/index.js +61 -66
- package/dist/components/grid/index.js.map +1 -1
- package/dist/components/icon/index.d.ts +13 -7
- package/dist/components/icon/index.js +24 -34
- package/dist/components/icon/index.js.map +1 -1
- package/dist/components/image-picker/index.d.ts +19 -9
- package/dist/components/image-picker/index.js +83 -102
- package/dist/components/image-picker/index.js.map +1 -1
- package/dist/components/indexes/index.d.ts +16 -28
- package/dist/components/indexes/index.js +198 -209
- package/dist/components/indexes/index.js.map +1 -1
- package/dist/components/input/index.d.ts +37 -15
- package/dist/components/input/index.js +152 -161
- package/dist/components/input/index.js.map +1 -1
- package/dist/components/input-number/index.d.ts +20 -11
- package/dist/components/input-number/index.js +107 -126
- package/dist/components/input-number/index.js.map +1 -1
- package/dist/components/list/index.d.ts +7 -6
- package/dist/components/list/index.js +15 -15
- package/dist/components/list/index.js.map +1 -1
- package/dist/components/list/item/index.d.ts +27 -9
- package/dist/components/list/item/index.js +89 -117
- package/dist/components/list/item/index.js.map +1 -1
- package/dist/components/load-more/index.d.ts +15 -7
- package/dist/components/load-more/index.js +29 -50
- package/dist/components/load-more/index.js.map +1 -1
- package/dist/components/loading/index.d.ts +8 -7
- package/dist/components/loading/index.js +14 -20
- package/dist/components/loading/index.js.map +1 -1
- package/dist/components/message/index.d.ts +9 -14
- package/dist/components/message/index.js +45 -59
- package/dist/components/message/index.js.map +1 -1
- package/dist/components/modal/action/index.d.ts +7 -6
- package/dist/components/modal/action/index.js +15 -15
- package/dist/components/modal/action/index.js.map +1 -1
- package/dist/components/modal/content/index.d.ts +2 -4
- package/dist/components/modal/content/index.js +8 -6
- package/dist/components/modal/content/index.js.map +1 -1
- package/dist/components/modal/header/index.d.ts +2 -4
- package/dist/components/modal/header/index.js +8 -6
- package/dist/components/modal/header/index.js.map +1 -1
- package/dist/components/modal/index.d.ts +16 -14
- package/dist/components/modal/index.js +63 -77
- package/dist/components/modal/index.js.map +1 -1
- package/dist/components/nav-bar/index.d.ts +20 -10
- package/dist/components/nav-bar/index.js +146 -162
- package/dist/components/nav-bar/index.js.map +1 -1
- package/dist/components/noticebar/index.d.ts +17 -15
- package/dist/components/noticebar/index.js +115 -128
- package/dist/components/noticebar/index.js.map +1 -1
- package/dist/components/pagination/index.d.ts +13 -11
- package/dist/components/pagination/index.js +64 -120
- package/dist/components/pagination/index.js.map +1 -1
- package/dist/components/progress/index.d.ts +11 -5
- package/dist/components/progress/index.js +39 -36
- package/dist/components/progress/index.js.map +1 -1
- package/dist/components/radio/index.d.ts +11 -7
- package/dist/components/radio/index.js +29 -33
- package/dist/components/radio/index.js.map +1 -1
- package/dist/components/range/index.d.ts +19 -21
- package/dist/components/range/index.js +146 -153
- package/dist/components/range/index.js.map +1 -1
- package/dist/components/rate/index.d.ts +13 -7
- package/dist/components/rate/index.js +47 -62
- package/dist/components/rate/index.js.map +1 -1
- package/dist/components/search-bar/index.d.ts +23 -15
- package/dist/components/search-bar/index.js +120 -146
- package/dist/components/search-bar/index.js.map +1 -1
- package/dist/components/segmented-control/index.d.ts +14 -7
- package/dist/components/segmented-control/index.js +52 -66
- package/dist/components/segmented-control/index.js.map +1 -1
- package/dist/components/slider/index.d.ts +21 -12
- package/dist/components/slider/index.js +66 -90
- package/dist/components/slider/index.js.map +1 -1
- package/dist/components/steps/index.d.ts +11 -7
- package/dist/components/steps/index.js +43 -48
- package/dist/components/steps/index.js.map +1 -1
- package/dist/components/swipe-action/index.d.ts +12 -25
- package/dist/components/swipe-action/index.js +118 -115
- package/dist/components/swipe-action/index.js.map +1 -1
- package/dist/components/swipe-action/options/index.d.ts +2 -4
- package/dist/components/swipe-action/options/index.js +18 -17
- package/dist/components/swipe-action/options/index.js.map +1 -1
- package/dist/components/switch/index.d.ts +14 -7
- package/dist/components/switch/index.js +36 -41
- package/dist/components/switch/index.js.map +1 -1
- package/dist/components/tab-bar/index.d.ts +17 -7
- package/dist/components/tab-bar/index.js +108 -135
- package/dist/components/tab-bar/index.js.map +1 -1
- package/dist/components/tabs/index.d.ts +17 -23
- package/dist/components/tabs/index.js +185 -174
- package/dist/components/tabs/index.js.map +1 -1
- package/dist/components/tabs-pane/index.d.ts +11 -6
- package/dist/components/tabs-pane/index.js +26 -28
- package/dist/components/tabs-pane/index.js.map +1 -1
- package/dist/components/tag/index.d.ts +14 -7
- package/dist/components/tag/index.js +31 -40
- package/dist/components/tag/index.js.map +1 -1
- package/dist/components/textarea/index.d.ts +29 -11
- package/dist/components/textarea/index.js +72 -92
- package/dist/components/textarea/index.js.map +1 -1
- package/dist/components/timeline/index.d.ts +9 -6
- package/dist/components/timeline/index.js +50 -56
- package/dist/components/timeline/index.js.map +1 -1
- package/dist/components/toast/img.json +3 -6
- package/dist/components/toast/index.d.ts +16 -15
- package/dist/components/toast/index.js +85 -94
- package/dist/components/toast/index.js.map +1 -1
- package/dist/hooks/useComponentLocale.d.ts +2 -0
- package/dist/hooks/useComponentLocale.js +12 -0
- package/dist/hooks/useComponentLocale.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.esm.js +4006 -4404
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +4032 -4434
- package/dist/index.js.map +1 -1
- package/dist/locale/en_US.d.ts +3 -0
- package/dist/locale/en_US.js +34 -0
- package/dist/locale/en_US.js.map +1 -0
- package/dist/locale/index.d.ts +4 -0
- package/dist/locale/index.js +10 -0
- package/dist/locale/index.js.map +1 -0
- package/dist/locale/types.d.ts +34 -0
- package/dist/locale/types.js +1 -0
- package/dist/locale/types.js.map +1 -0
- package/dist/locale/zh_CN.d.ts +3 -0
- package/dist/locale/zh_CN.js +34 -0
- package/dist/locale/zh_CN.js.map +1 -0
- package/dist/style/components/avatar.scss +1 -1
- package/dist/style/components/badge.scss +7 -2
- package/dist/style/components/calendar.scss +1 -1
- package/dist/style/components/countdown.scss +2 -1
- package/dist/style/components/flex.scss +1 -1
- package/dist/style/components/grid.scss +2 -2
- package/dist/style/components/icon.scss +302 -101
- package/dist/style/components/input.scss +2 -2
- package/dist/style/components/progress.scss +1 -1
- package/dist/style/components/search-bar.scss +1 -1
- package/dist/style/components/steps.scss +2 -2
- package/dist/style/components/tabs.scss +1 -1
- package/dist/style/components/tag.scss +1 -1
- package/dist/style/components/timeline.scss +1 -1
- package/dist/style/components/toast.scss +7 -3
- package/dist/style/index.css +176 -176
- package/dist/style/index.css.map +1 -1
- package/dist/style/mixins/libs/hairline.scss +4 -19
- package/dist/style/mixins/libs/shade.scss +3 -6
- package/dist/style/mixins/libs/tint.scss +4 -7
- package/dist/style/themes/purple.scss +15 -15
- package/dist/style/themes/red.scss +16 -13
- package/dist/style/variables/default.scss +69 -73
- package/package.json +5 -3
- package/rn/components/accordion/index.tsx +2 -9
- package/rn/components/action-sheet/body/index.tsx +1 -3
- package/rn/components/action-sheet/body/item/index.tsx +1 -3
- package/rn/components/action-sheet/footer/index.tsx +1 -3
- package/rn/components/action-sheet/header/index.tsx +1 -3
- package/rn/components/activity-indicator/index.tsx +1 -3
- package/rn/components/avatar/index.tsx +5 -5
- package/rn/components/calendar/controller/index.tsx +2 -7
- package/rn/components/card/index.tsx +4 -4
- package/rn/components/countdown/index.scss +5 -4
- package/rn/components/countdown/item/index.tsx +1 -3
- package/rn/components/curtain/index.tsx +5 -5
- package/rn/components/flex/index.scss +2 -2
- package/rn/components/flex/item/index.scss +2 -2
- package/rn/components/grid/index.tsx +15 -15
- package/rn/components/icon/index.tsx +4 -4
- package/rn/components/image-picker/index.tsx +7 -7
- package/rn/components/pagination/index.tsx +7 -7
- package/rn/components/progress/index.tsx +5 -5
- package/rn/components/radio/index.tsx +7 -7
- package/rn/components/rate/index.tsx +4 -4
- package/rn/components/segmented-control/index.tsx +8 -8
- package/rn/components/slider/index.tsx +9 -9
- package/rn/components/steps/index.tsx +8 -8
- package/rn/components/swipe-action/options/index.tsx +1 -3
- package/rn/components/switch/index.tsx +2 -9
- package/rn/components/toast/img.json +3 -6
- package/rn/components/toast/index.tsx +8 -8
- package/rn/style/components/accordion.scss +1 -1
- package/rn/style/components/action-sheet.scss +1 -1
- package/rn/style/components/avatar.scss +1 -1
- package/rn/style/components/badge.scss +8 -3
- package/rn/style/components/button.scss +1 -1
- package/rn/style/components/calendar.scss +1 -1
- package/rn/style/components/checkbox.scss +1 -1
- package/rn/style/components/curtain.scss +1 -1
- package/rn/style/components/fab.scss +1 -4
- package/rn/style/components/flex.scss +1 -1
- package/rn/style/components/grid.scss +2 -6
- package/rn/style/components/icon.scss +302 -101
- package/rn/style/components/index.scss +41 -41
- package/rn/style/components/input.scss +1 -1
- package/rn/style/components/list.scss +2 -4
- package/rn/style/components/loading.scss +4 -4
- package/rn/style/components/message.scss +1 -1
- package/rn/style/components/modal.scss +0 -2
- package/rn/style/components/nav-bar.scss +3 -3
- package/rn/style/components/noticebar.scss +0 -4
- package/rn/style/components/progress.scss +1 -1
- package/rn/style/components/radio.scss +2 -2
- package/rn/style/components/range.scss +1 -1
- package/rn/style/components/search-bar.scss +1 -1
- package/rn/style/components/segmented-control.scss +4 -1
- package/rn/style/components/slider.scss +0 -1
- package/rn/style/components/steps.scss +3 -3
- package/rn/style/components/switch.scss +0 -1
- package/rn/style/components/tabs.scss +2 -2
- package/rn/style/components/tag.scss +1 -1
- package/rn/style/components/timeline.scss +0 -2
- package/rn/style/components/toast.scss +5 -2
- package/rn/style/index.scss +1 -1
- package/rn/style/mixins/libs/hairline.scss +4 -22
- package/rn/style/mixins/libs/shade.scss +1 -4
- package/rn/style/mixins/libs/tint.scss +2 -5
- package/rn/style/themes/purple.scss +15 -15
- package/rn/style/themes/red.scss +16 -13
- package/rn/style/variables/default.scss +69 -73
|
@@ -1,78 +1,64 @@
|
|
|
1
1
|
import classNames from "classnames";
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
|
-
import React from "react";
|
|
3
|
+
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
4
4
|
import { View } from "@tarojs/components";
|
|
5
|
-
import Taro from "@tarojs/taro";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
bindMessageListener() {
|
|
5
|
+
import Taro, { useDidHide, useDidShow } from "@tarojs/taro";
|
|
6
|
+
function AtMessage({
|
|
7
|
+
customStyle = "",
|
|
8
|
+
className = ""
|
|
9
|
+
}) {
|
|
10
|
+
const [_isOpened, setIsOpened] = useState(false);
|
|
11
|
+
const [_message, setMessage] = useState("");
|
|
12
|
+
const [_type, setType] = useState("info");
|
|
13
|
+
const durationRef = useRef(3e3);
|
|
14
|
+
const timerRef = useRef(null);
|
|
15
|
+
const bindMessageListener = useCallback(() => {
|
|
18
16
|
Taro.eventCenter.on("atMessage", (options = {}) => {
|
|
19
17
|
const { message, type, duration } = options;
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
this.setState({
|
|
30
|
-
_isOpened: false
|
|
31
|
-
});
|
|
32
|
-
}, this.state._duration);
|
|
33
|
-
});
|
|
18
|
+
const newDuration = duration || durationRef.current;
|
|
19
|
+
durationRef.current = newDuration;
|
|
20
|
+
setIsOpened(true);
|
|
21
|
+
setMessage(message);
|
|
22
|
+
setType(type);
|
|
23
|
+
clearTimeout(timerRef.current);
|
|
24
|
+
timerRef.current = setTimeout(() => {
|
|
25
|
+
setIsOpened(false);
|
|
26
|
+
}, newDuration);
|
|
34
27
|
});
|
|
35
28
|
Taro.atMessage = Taro.eventCenter.trigger.bind(
|
|
36
29
|
Taro.eventCenter,
|
|
37
30
|
"atMessage"
|
|
38
31
|
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
32
|
+
}, []);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
bindMessageListener();
|
|
35
|
+
return () => {
|
|
36
|
+
Taro.eventCenter.off("atMessage");
|
|
37
|
+
};
|
|
38
|
+
}, [bindMessageListener]);
|
|
39
|
+
useDidShow(() => {
|
|
40
|
+
bindMessageListener();
|
|
41
|
+
});
|
|
42
|
+
useDidHide(() => {
|
|
50
43
|
Taro.eventCenter.off("atMessage");
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
className
|
|
63
|
-
);
|
|
64
|
-
return /* @__PURE__ */ React.createElement(View, { className: rootCls, style: customStyle }, _message);
|
|
65
|
-
}
|
|
44
|
+
});
|
|
45
|
+
const rootCls = classNames(
|
|
46
|
+
{
|
|
47
|
+
"at-message": true,
|
|
48
|
+
"at-message--show": _isOpened,
|
|
49
|
+
"at-message--hidden": !_isOpened
|
|
50
|
+
},
|
|
51
|
+
`at-message--${_type}`,
|
|
52
|
+
className
|
|
53
|
+
);
|
|
54
|
+
return /* @__PURE__ */ React.createElement(View, { className: rootCls, style: customStyle }, _message);
|
|
66
55
|
}
|
|
67
|
-
AtMessage.defaultProps = {
|
|
68
|
-
customStyle: "",
|
|
69
|
-
className: ""
|
|
70
|
-
};
|
|
71
56
|
AtMessage.propTypes = {
|
|
72
57
|
customStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
73
58
|
className: PropTypes.oneOfType([PropTypes.array, PropTypes.string])
|
|
74
59
|
};
|
|
60
|
+
var message_default = AtMessage;
|
|
75
61
|
export {
|
|
76
|
-
|
|
62
|
+
message_default as default
|
|
77
63
|
};
|
|
78
64
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/message/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport PropTypes
|
|
1
|
+
{"version":3,"sources":["../../../src/components/message/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport PropTypes from 'prop-types'\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\nimport { View } from '@tarojs/components'\nimport Taro, { useDidHide, useDidShow } from '@tarojs/taro'\nimport { AtMessageProps } from '../../../types/message'\n\nfunction AtMessage({\n customStyle = '',\n className = ''\n}: AtMessageProps): JSX.Element {\n const [_isOpened, setIsOpened] = useState(false)\n const [_message, setMessage] = useState('')\n const [_type, setType] = useState('info')\n const durationRef = useRef(3000)\n const timerRef = useRef<NodeJS.Timeout | number | null>(null)\n\n const bindMessageListener = useCallback((): void => {\n Taro.eventCenter.on('atMessage', (options = {}) => {\n const { message, type, duration } = options\n const newDuration = duration || durationRef.current\n durationRef.current = newDuration\n setIsOpened(true)\n setMessage(message)\n setType(type)\n clearTimeout(timerRef.current as number)\n timerRef.current = setTimeout(() => {\n setIsOpened(false)\n }, newDuration)\n })\n Taro.atMessage = Taro.eventCenter.trigger.bind(\n Taro.eventCenter,\n 'atMessage'\n )\n }, [])\n\n useEffect(() => {\n bindMessageListener()\n return () => {\n Taro.eventCenter.off('atMessage')\n }\n }, [bindMessageListener])\n\n useDidShow(() => {\n bindMessageListener()\n })\n\n useDidHide(() => {\n Taro.eventCenter.off('atMessage')\n })\n\n const rootCls = classNames(\n {\n 'at-message': true,\n 'at-message--show': _isOpened,\n 'at-message--hidden': !_isOpened\n },\n `at-message--${_type}`,\n className\n )\n\n return (\n <View className={rootCls} style={customStyle}>\n {_message}\n </View>\n )\n}\n\nAtMessage.propTypes = {\n customStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),\n className: PropTypes.oneOfType([PropTypes.array, PropTypes.string])\n}\n\nexport default AtMessage\n"],"mappings":"AAAA,OAAO,gBAAgB;AACvB,OAAO,eAAe;AACtB,OAAO,SAAS,aAAa,WAAW,QAAQ,gBAAgB;AAChE,SAAS,YAAY;AACrB,OAAO,QAAQ,YAAY,kBAAkB;AAG7C,SAAS,UAAU;AAAA,EACjB,cAAc;AAAA,EACd,YAAY;AACd,GAAgC;AAC9B,QAAM,CAAC,WAAW,WAAW,IAAI,SAAS,KAAK;AAC/C,QAAM,CAAC,UAAU,UAAU,IAAI,SAAS,EAAE;AAC1C,QAAM,CAAC,OAAO,OAAO,IAAI,SAAS,MAAM;AACxC,QAAM,cAAc,OAAO,GAAI;AAC/B,QAAM,WAAW,OAAuC,IAAI;AAE5D,QAAM,sBAAsB,YAAY,MAAY;AAClD,SAAK,YAAY,GAAG,aAAa,CAAC,UAAU,CAAC,MAAM;AACjD,YAAM,EAAE,SAAS,MAAM,SAAS,IAAI;AACpC,YAAM,cAAc,YAAY,YAAY;AAC5C,kBAAY,UAAU;AACtB,kBAAY,IAAI;AAChB,iBAAW,OAAO;AAClB,cAAQ,IAAI;AACZ,mBAAa,SAAS,OAAiB;AACvC,eAAS,UAAU,WAAW,MAAM;AAClC,oBAAY,KAAK;AAAA,MACnB,GAAG,WAAW;AAAA,IAChB,CAAC;AACD,SAAK,YAAY,KAAK,YAAY,QAAQ;AAAA,MACxC,KAAK;AAAA,MACL;AAAA,IACF;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,YAAU,MAAM;AACd,wBAAoB;AACpB,WAAO,MAAM;AACX,WAAK,YAAY,IAAI,WAAW;AAAA,IAClC;AAAA,EACF,GAAG,CAAC,mBAAmB,CAAC;AAExB,aAAW,MAAM;AACf,wBAAoB;AAAA,EACtB,CAAC;AAED,aAAW,MAAM;AACf,SAAK,YAAY,IAAI,WAAW;AAAA,EAClC,CAAC;AAED,QAAM,UAAU;AAAA,IACd;AAAA,MACE,cAAc;AAAA,MACd,oBAAoB;AAAA,MACpB,sBAAsB,CAAC;AAAA,IACzB;AAAA,IACA,eAAe,KAAK;AAAA,IACpB;AAAA,EACF;AAEA,SACE,oCAAC,QAAK,WAAW,SAAS,OAAO,eAC9B,QACH;AAEJ;AAEA,UAAU,YAAY;AAAA,EACpB,aAAa,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,MAAM,CAAC;AAAA,EACrE,WAAW,UAAU,UAAU,CAAC,UAAU,OAAO,UAAU,MAAM,CAAC;AACpE;AAEA,IAAO,kBAAQ;","names":[]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React from 'react';
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
3
2
|
import { AtModalActionProps } from '../../../../types/modal';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
declare function AtModalAction({ isSimple, className, children }: AtModalActionProps): JSX.Element;
|
|
4
|
+
declare namespace AtModalAction {
|
|
5
|
+
var propTypes: {
|
|
6
|
+
isSimple: PropTypes.Requireable<boolean>;
|
|
7
|
+
};
|
|
8
8
|
}
|
|
9
|
+
export default AtModalAction;
|
|
@@ -2,25 +2,25 @@ import classNames from "classnames";
|
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { View } from "@tarojs/components";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
function AtModalAction({
|
|
6
|
+
isSimple = false,
|
|
7
|
+
className,
|
|
8
|
+
children
|
|
9
|
+
}) {
|
|
10
|
+
const rootClass = classNames(
|
|
11
|
+
"at-modal__footer",
|
|
12
|
+
{
|
|
13
|
+
"at-modal__footer--simple": isSimple
|
|
14
|
+
},
|
|
15
|
+
className
|
|
16
|
+
);
|
|
17
|
+
return /* @__PURE__ */ React.createElement(View, { className: rootClass }, /* @__PURE__ */ React.createElement(View, { className: "at-modal__action" }, children));
|
|
16
18
|
}
|
|
17
|
-
AtModalAction.defaultProps = {
|
|
18
|
-
isSimple: false
|
|
19
|
-
};
|
|
20
19
|
AtModalAction.propTypes = {
|
|
21
20
|
isSimple: PropTypes.bool
|
|
22
21
|
};
|
|
22
|
+
var action_default = AtModalAction;
|
|
23
23
|
export {
|
|
24
|
-
|
|
24
|
+
action_default as default
|
|
25
25
|
};
|
|
26
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/modal/action/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport PropTypes
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/modal/action/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport PropTypes from 'prop-types'\nimport React from 'react'\nimport { View } from '@tarojs/components'\nimport { AtModalActionProps } from '../../../../types/modal'\n\nfunction AtModalAction({\n isSimple = false,\n className,\n children\n}: AtModalActionProps): JSX.Element {\n const rootClass = classNames(\n 'at-modal__footer',\n {\n 'at-modal__footer--simple': isSimple\n },\n className\n )\n\n return (\n <View className={rootClass}>\n <View className='at-modal__action'>{children}</View>\n </View>\n )\n}\n\nAtModalAction.propTypes = {\n isSimple: PropTypes.bool\n}\n\nexport default AtModalAction\n"],"mappings":"AAAA,OAAO,gBAAgB;AACvB,OAAO,eAAe;AACtB,OAAO,WAAW;AAClB,SAAS,YAAY;AAGrB,SAAS,cAAc;AAAA,EACrB,WAAW;AAAA,EACX;AAAA,EACA;AACF,GAAoC;AAClC,QAAM,YAAY;AAAA,IAChB;AAAA,IACA;AAAA,MACE,4BAA4B;AAAA,IAC9B;AAAA,IACA;AAAA,EACF;AAEA,SACE,oCAAC,QAAK,WAAW,aACf,oCAAC,QAAK,WAAU,sBAAoB,QAAS,CAC/C;AAEJ;AAEA,cAAc,YAAY;AAAA,EACxB,UAAU,UAAU;AACtB;AAEA,IAAO,iBAAQ;","names":[]}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { AtModalContentProps } from '../../../../types/modal';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
2
|
+
declare function AtModalContent({ className, children }: AtModalContentProps): JSX.Element;
|
|
3
|
+
export default AtModalContent;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import classNames from "classnames";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { ScrollView } from "@tarojs/components";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
function AtModalContent({
|
|
5
|
+
className,
|
|
6
|
+
children
|
|
7
|
+
}) {
|
|
8
|
+
const rootClass = classNames("at-modal__content", className);
|
|
9
|
+
return /* @__PURE__ */ React.createElement(ScrollView, { scrollY: true, className: rootClass }, children);
|
|
9
10
|
}
|
|
11
|
+
var content_default = AtModalContent;
|
|
10
12
|
export {
|
|
11
|
-
|
|
13
|
+
content_default as default
|
|
12
14
|
};
|
|
13
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/modal/content/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport React from 'react'\nimport { ScrollView } from '@tarojs/components'\nimport { AtModalContentProps } from '../../../../types/modal'\n\
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/modal/content/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport React from 'react'\nimport { ScrollView } from '@tarojs/components'\nimport { AtModalContentProps } from '../../../../types/modal'\n\nfunction AtModalContent({\n className,\n children\n}: AtModalContentProps): JSX.Element {\n const rootClass = classNames('at-modal__content', className)\n return (\n <ScrollView scrollY className={rootClass}>\n {children}\n </ScrollView>\n )\n}\n\nexport default AtModalContent\n"],"mappings":"AAAA,OAAO,gBAAgB;AACvB,OAAO,WAAW;AAClB,SAAS,kBAAkB;AAG3B,SAAS,eAAe;AAAA,EACtB;AAAA,EACA;AACF,GAAqC;AACnC,QAAM,YAAY,WAAW,qBAAqB,SAAS;AAC3D,SACE,oCAAC,cAAW,SAAO,MAAC,WAAW,aAC5B,QACH;AAEJ;AAEA,IAAO,kBAAQ;","names":[]}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { AtModalHeaderProps } from '../../../../types/modal';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
2
|
+
declare function AtModalHeader({ className, children }: AtModalHeaderProps): JSX.Element;
|
|
3
|
+
export default AtModalHeader;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import classNames from "classnames";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { View } from "@tarojs/components";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
function AtModalHeader({
|
|
5
|
+
className,
|
|
6
|
+
children
|
|
7
|
+
}) {
|
|
8
|
+
const rootClass = classNames("at-modal__header", className);
|
|
9
|
+
return /* @__PURE__ */ React.createElement(View, { className: rootClass }, children);
|
|
9
10
|
}
|
|
11
|
+
var header_default = AtModalHeader;
|
|
10
12
|
export {
|
|
11
|
-
|
|
13
|
+
header_default as default
|
|
12
14
|
};
|
|
13
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/modal/header/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport React from 'react'\nimport { View } from '@tarojs/components'\nimport { AtModalHeaderProps } from '../../../../types/modal'\n\
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/modal/header/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport React from 'react'\nimport { View } from '@tarojs/components'\nimport { AtModalHeaderProps } from '../../../../types/modal'\n\nfunction AtModalHeader({\n className,\n children\n}: AtModalHeaderProps): JSX.Element {\n const rootClass = classNames('at-modal__header', className)\n return <View className={rootClass}>{children}</View>\n}\n\nexport default AtModalHeader\n"],"mappings":"AAAA,OAAO,gBAAgB;AACvB,OAAO,WAAW;AAClB,SAAS,YAAY;AAGrB,SAAS,cAAc;AAAA,EACrB;AAAA,EACA;AACF,GAAoC;AAClC,QAAM,YAAY,WAAW,oBAAoB,SAAS;AAC1D,SAAO,oCAAC,QAAK,WAAW,aAAY,QAAS;AAC/C;AAEA,IAAO,iBAAQ;","names":[]}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import { AtModalProps } from '../../../types/modal';
|
|
3
|
+
declare function AtModal({ isOpened, closeOnClickOverlay, title, content, cancelText, confirmText, className, children, onClose, onCancel, onConfirm }: AtModalProps): JSX.Element;
|
|
4
|
+
declare namespace AtModal {
|
|
5
|
+
var propTypes: {
|
|
6
|
+
title: PropTypes.Requireable<string>;
|
|
7
|
+
isOpened: PropTypes.Requireable<boolean>;
|
|
8
|
+
onCancel: PropTypes.Requireable<(...args: any[]) => any>;
|
|
9
|
+
onConfirm: PropTypes.Requireable<(...args: any[]) => any>;
|
|
10
|
+
onClose: PropTypes.Requireable<(...args: any[]) => any>;
|
|
11
|
+
content: PropTypes.Requireable<string>;
|
|
12
|
+
closeOnClickOverlay: PropTypes.Requireable<boolean>;
|
|
13
|
+
cancelText: PropTypes.Requireable<string>;
|
|
14
|
+
confirmText: PropTypes.Requireable<string>;
|
|
15
|
+
};
|
|
15
16
|
}
|
|
17
|
+
export default AtModal;
|
|
@@ -1,94 +1,79 @@
|
|
|
1
1
|
import classNames from "classnames";
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
|
-
import React from "react";
|
|
3
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
4
4
|
import { Button, Text, View } from "@tarojs/components";
|
|
5
5
|
import Taro from "@tarojs/taro";
|
|
6
6
|
import { handleTouchScroll } from "../../common/utils";
|
|
7
7
|
import AtModalAction from "./action/index";
|
|
8
8
|
import AtModalContent from "./content/index";
|
|
9
9
|
import AtModalHeader from "./header/index";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
this.handleCancel = (event) => {
|
|
29
|
-
if (typeof this.props.onCancel === "function") {
|
|
30
|
-
this.props.onCancel(event);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
this.handleConfirm = (event) => {
|
|
34
|
-
if (typeof this.props.onConfirm === "function") {
|
|
35
|
-
this.props.onConfirm(event);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
this.handleTouchMove = (e) => {
|
|
39
|
-
e.stopPropagation();
|
|
40
|
-
};
|
|
41
|
-
const { isOpened } = props;
|
|
42
|
-
this.state = {
|
|
43
|
-
_isOpened: isOpened,
|
|
44
|
-
isWEB: Taro.getEnv() === Taro.ENV_TYPE.WEB
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
48
|
-
const { isOpened } = nextProps;
|
|
49
|
-
if (this.props.isOpened !== isOpened) {
|
|
10
|
+
function AtModal({
|
|
11
|
+
isOpened = false,
|
|
12
|
+
closeOnClickOverlay = true,
|
|
13
|
+
title,
|
|
14
|
+
content,
|
|
15
|
+
cancelText,
|
|
16
|
+
confirmText,
|
|
17
|
+
className,
|
|
18
|
+
children,
|
|
19
|
+
onClose,
|
|
20
|
+
onCancel,
|
|
21
|
+
onConfirm
|
|
22
|
+
}) {
|
|
23
|
+
const [_isOpened, setIsOpened] = useState(isOpened);
|
|
24
|
+
const prevIsOpenedPropRef = useRef(isOpened);
|
|
25
|
+
const isWEB = Taro.getEnv() === Taro.ENV_TYPE.WEB;
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (prevIsOpenedPropRef.current !== isOpened) {
|
|
50
28
|
handleTouchScroll(isOpened);
|
|
29
|
+
prevIsOpenedPropRef.current = isOpened;
|
|
51
30
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
31
|
+
setIsOpened((prev) => isOpened !== prev ? isOpened : prev);
|
|
32
|
+
}, [isOpened]);
|
|
33
|
+
const handleClose = (event) => {
|
|
34
|
+
if (typeof onClose === "function") {
|
|
35
|
+
onClose(event);
|
|
56
36
|
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
37
|
+
};
|
|
38
|
+
const handleClickOverlay = () => {
|
|
39
|
+
if (closeOnClickOverlay) {
|
|
40
|
+
setIsOpened(false);
|
|
41
|
+
handleClose();
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const handleCancel = (event) => {
|
|
45
|
+
if (typeof onCancel === "function") {
|
|
46
|
+
onCancel(event);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const handleConfirm = (event) => {
|
|
50
|
+
if (typeof onConfirm === "function") {
|
|
51
|
+
onConfirm(event);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const handleTouchMove = (e) => {
|
|
55
|
+
e.stopPropagation();
|
|
56
|
+
};
|
|
57
|
+
const rootClass = classNames(
|
|
58
|
+
"at-modal",
|
|
59
|
+
{
|
|
60
|
+
"at-modal--active": _isOpened
|
|
61
|
+
},
|
|
62
|
+
className
|
|
63
|
+
);
|
|
64
|
+
if (title || content) {
|
|
65
|
+
const isRenderAction = cancelText || confirmText;
|
|
66
|
+
return /* @__PURE__ */ React.createElement(View, { className: rootClass }, /* @__PURE__ */ React.createElement(View, { onClick: handleClickOverlay, className: "at-modal__overlay" }), /* @__PURE__ */ React.createElement(View, { className: "at-modal__container" }, title && /* @__PURE__ */ React.createElement(AtModalHeader, null, /* @__PURE__ */ React.createElement(Text, null, title)), content && /* @__PURE__ */ React.createElement(AtModalContent, null, /* @__PURE__ */ React.createElement(View, { className: "content-simple" }, isWEB ? /* @__PURE__ */ React.createElement(
|
|
67
|
+
Text,
|
|
63
68
|
{
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
this.props.className
|
|
67
|
-
);
|
|
68
|
-
if (title || content) {
|
|
69
|
-
const isRenderAction = cancelText || confirmText;
|
|
70
|
-
return /* @__PURE__ */ React.createElement(View, { className: rootClass }, /* @__PURE__ */ React.createElement(
|
|
71
|
-
View,
|
|
72
|
-
{
|
|
73
|
-
onClick: this.handleClickOverlay,
|
|
74
|
-
className: "at-modal__overlay"
|
|
75
|
-
}
|
|
76
|
-
), /* @__PURE__ */ React.createElement(View, { className: "at-modal__container" }, title && /* @__PURE__ */ React.createElement(AtModalHeader, null, /* @__PURE__ */ React.createElement(Text, null, title)), content && /* @__PURE__ */ React.createElement(AtModalContent, null, /* @__PURE__ */ React.createElement(View, { className: "content-simple" }, isWEB ? /* @__PURE__ */ React.createElement(
|
|
77
|
-
Text,
|
|
78
|
-
{
|
|
79
|
-
dangerouslySetInnerHTML: {
|
|
80
|
-
__html: content.replace(/\\n/g, "<br/>")
|
|
81
|
-
}
|
|
69
|
+
dangerouslySetInnerHTML: {
|
|
70
|
+
__html: content.replace(/\\n/g, "<br/>")
|
|
82
71
|
}
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
return /* @__PURE__ */ React.createElement(View, { onTouchMove: this.handleTouchMove, className: rootClass }, /* @__PURE__ */ React.createElement(View, { className: "at-modal__overlay", onClick: this.handleClickOverlay }), /* @__PURE__ */ React.createElement(View, { className: "at-modal__container" }, this.props.children));
|
|
72
|
+
}
|
|
73
|
+
) : /* @__PURE__ */ React.createElement(Text, null, content))), isRenderAction && /* @__PURE__ */ React.createElement(AtModalAction, { isSimple: true }, cancelText && /* @__PURE__ */ React.createElement(Button, { onClick: handleCancel }, cancelText), confirmText && /* @__PURE__ */ React.createElement(Button, { onClick: handleConfirm }, confirmText))));
|
|
86
74
|
}
|
|
75
|
+
return /* @__PURE__ */ React.createElement(View, { onTouchMove: handleTouchMove, className: rootClass }, /* @__PURE__ */ React.createElement(View, { className: "at-modal__overlay", onClick: handleClickOverlay }), /* @__PURE__ */ React.createElement(View, { className: "at-modal__container" }, children));
|
|
87
76
|
}
|
|
88
|
-
AtModal.defaultProps = {
|
|
89
|
-
isOpened: false,
|
|
90
|
-
closeOnClickOverlay: true
|
|
91
|
-
};
|
|
92
77
|
AtModal.propTypes = {
|
|
93
78
|
title: PropTypes.string,
|
|
94
79
|
isOpened: PropTypes.bool,
|
|
@@ -100,7 +85,8 @@ AtModal.propTypes = {
|
|
|
100
85
|
cancelText: PropTypes.string,
|
|
101
86
|
confirmText: PropTypes.string
|
|
102
87
|
};
|
|
88
|
+
var modal_default = AtModal;
|
|
103
89
|
export {
|
|
104
|
-
|
|
90
|
+
modal_default as default
|
|
105
91
|
};
|
|
106
92
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/modal/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport PropTypes
|
|
1
|
+
{"version":3,"sources":["../../../src/components/modal/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport PropTypes from 'prop-types'\nimport React, { useEffect, useRef, useState } from 'react'\nimport { Button, Text, View } from '@tarojs/components'\nimport { CommonEvent } from '@tarojs/components/types/common'\nimport Taro from '@tarojs/taro'\nimport { AtModalProps } from '../../../types/modal'\nimport { handleTouchScroll } from '../../common/utils'\nimport AtModalAction from './action/index'\nimport AtModalContent from './content/index'\nimport AtModalHeader from './header/index'\n\nfunction AtModal({\n isOpened = false,\n closeOnClickOverlay = true,\n title,\n content,\n cancelText,\n confirmText,\n className,\n children,\n onClose,\n onCancel,\n onConfirm\n}: AtModalProps): JSX.Element {\n const [_isOpened, setIsOpened] = useState(isOpened)\n const prevIsOpenedPropRef = useRef(isOpened)\n const isWEB = Taro.getEnv() === Taro.ENV_TYPE.WEB\n\n useEffect(() => {\n if (prevIsOpenedPropRef.current !== isOpened) {\n handleTouchScroll(isOpened)\n prevIsOpenedPropRef.current = isOpened\n }\n setIsOpened(prev => (isOpened !== prev ? isOpened : prev))\n }, [isOpened])\n\n const handleClose = (event?: CommonEvent): void => {\n if (typeof onClose === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n onClose(event!)\n }\n }\n\n const handleClickOverlay = (): void => {\n if (closeOnClickOverlay) {\n setIsOpened(false)\n handleClose()\n }\n }\n\n const handleCancel = (event: CommonEvent): void => {\n if (typeof onCancel === 'function') {\n onCancel(event)\n }\n }\n\n const handleConfirm = (event: CommonEvent): void => {\n if (typeof onConfirm === 'function') {\n onConfirm(event)\n }\n }\n\n const handleTouchMove = (e: CommonEvent): void => {\n e.stopPropagation()\n }\n\n const rootClass = classNames(\n 'at-modal',\n {\n 'at-modal--active': _isOpened\n },\n className\n )\n\n if (title || content) {\n const isRenderAction = cancelText || confirmText\n return (\n <View className={rootClass}>\n <View onClick={handleClickOverlay} className='at-modal__overlay' />\n <View className='at-modal__container'>\n {title && (\n <AtModalHeader>\n <Text>{title}</Text>\n </AtModalHeader>\n )}\n {content && (\n <AtModalContent>\n <View className='content-simple'>\n {isWEB ? (\n <Text\n dangerouslySetInnerHTML={{\n __html: content.replace(/\\\\n/g, '<br/>')\n }}\n ></Text>\n ) : (\n <Text>{content}</Text>\n )}\n </View>\n </AtModalContent>\n )}\n {isRenderAction && (\n <AtModalAction isSimple>\n {cancelText && (\n <Button onClick={handleCancel}>{cancelText}</Button>\n )}\n {confirmText && (\n <Button onClick={handleConfirm}>{confirmText}</Button>\n )}\n </AtModalAction>\n )}\n </View>\n </View>\n )\n }\n\n return (\n <View onTouchMove={handleTouchMove} className={rootClass}>\n <View className='at-modal__overlay' onClick={handleClickOverlay} />\n <View className='at-modal__container'>{children}</View>\n </View>\n )\n}\n\nAtModal.propTypes = {\n title: PropTypes.string,\n isOpened: PropTypes.bool,\n onCancel: PropTypes.func,\n onConfirm: PropTypes.func,\n onClose: PropTypes.func,\n content: PropTypes.string,\n closeOnClickOverlay: PropTypes.bool,\n cancelText: PropTypes.string,\n confirmText: PropTypes.string\n}\n\nexport default AtModal\n"],"mappings":"AAAA,OAAO,gBAAgB;AACvB,OAAO,eAAe;AACtB,OAAO,SAAS,WAAW,QAAQ,gBAAgB;AACnD,SAAS,QAAQ,MAAM,YAAY;AAEnC,OAAO,UAAU;AAEjB,SAAS,yBAAyB;AAClC,OAAO,mBAAmB;AAC1B,OAAO,oBAAoB;AAC3B,OAAO,mBAAmB;AAE1B,SAAS,QAAQ;AAAA,EACf,WAAW;AAAA,EACX,sBAAsB;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA8B;AAC5B,QAAM,CAAC,WAAW,WAAW,IAAI,SAAS,QAAQ;AAClD,QAAM,sBAAsB,OAAO,QAAQ;AAC3C,QAAM,QAAQ,KAAK,OAAO,MAAM,KAAK,SAAS;AAE9C,YAAU,MAAM;AACd,QAAI,oBAAoB,YAAY,UAAU;AAC5C,wBAAkB,QAAQ;AAC1B,0BAAoB,UAAU;AAAA,IAChC;AACA,gBAAY,UAAS,aAAa,OAAO,WAAW,IAAK;AAAA,EAC3D,GAAG,CAAC,QAAQ,CAAC;AAEb,QAAM,cAAc,CAAC,UAA8B;AACjD,QAAI,OAAO,YAAY,YAAY;AAEjC,cAAQ,KAAM;AAAA,IAChB;AAAA,EACF;AAEA,QAAM,qBAAqB,MAAY;AACrC,QAAI,qBAAqB;AACvB,kBAAY,KAAK;AACjB,kBAAY;AAAA,IACd;AAAA,EACF;AAEA,QAAM,eAAe,CAAC,UAA6B;AACjD,QAAI,OAAO,aAAa,YAAY;AAClC,eAAS,KAAK;AAAA,IAChB;AAAA,EACF;AAEA,QAAM,gBAAgB,CAAC,UAA6B;AAClD,QAAI,OAAO,cAAc,YAAY;AACnC,gBAAU,KAAK;AAAA,IACjB;AAAA,EACF;AAEA,QAAM,kBAAkB,CAAC,MAAyB;AAChD,MAAE,gBAAgB;AAAA,EACpB;AAEA,QAAM,YAAY;AAAA,IAChB;AAAA,IACA;AAAA,MACE,oBAAoB;AAAA,IACtB;AAAA,IACA;AAAA,EACF;AAEA,MAAI,SAAS,SAAS;AACpB,UAAM,iBAAiB,cAAc;AACrC,WACE,oCAAC,QAAK,WAAW,aACf,oCAAC,QAAK,SAAS,oBAAoB,WAAU,qBAAoB,GACjE,oCAAC,QAAK,WAAU,yBACb,SACC,oCAAC,qBACC,oCAAC,YAAM,KAAM,CACf,GAED,WACC,oCAAC,sBACC,oCAAC,QAAK,WAAU,oBACb,QACC;AAAA,MAAC;AAAA;AAAA,QACC,yBAAyB;AAAA,UACvB,QAAQ,QAAQ,QAAQ,QAAQ,OAAO;AAAA,QACzC;AAAA;AAAA,IACD,IAED,oCAAC,YAAM,OAAQ,CAEnB,CACF,GAED,kBACC,oCAAC,iBAAc,UAAQ,QACpB,cACC,oCAAC,UAAO,SAAS,gBAAe,UAAW,GAE5C,eACC,oCAAC,UAAO,SAAS,iBAAgB,WAAY,CAEjD,CAEJ,CACF;AAAA,EAEJ;AAEA,SACE,oCAAC,QAAK,aAAa,iBAAiB,WAAW,aAC7C,oCAAC,QAAK,WAAU,qBAAoB,SAAS,oBAAoB,GACjE,oCAAC,QAAK,WAAU,yBAAuB,QAAS,CAClD;AAEJ;AAEA,QAAQ,YAAY;AAAA,EAClB,OAAO,UAAU;AAAA,EACjB,UAAU,UAAU;AAAA,EACpB,UAAU,UAAU;AAAA,EACpB,WAAW,UAAU;AAAA,EACrB,SAAS,UAAU;AAAA,EACnB,SAAS,UAAU;AAAA,EACnB,qBAAqB,UAAU;AAAA,EAC/B,YAAY,UAAU;AAAA,EACtB,aAAa,UAAU;AACzB;AAEA,IAAO,gBAAQ;","names":[]}
|
|
@@ -1,12 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React from 'react';
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
3
2
|
import { AtNavBarProps } from '../../../types/nav-bar';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
declare function AtNavBar({ customStyle, className, fixed, border, color, leftIconType, leftText, title, rightFirstIconType, rightSecondIconType, children, onClickLeftIcon, onClickRgIconSt, onClickRgIconNd, onClickTitle }: AtNavBarProps): JSX.Element;
|
|
4
|
+
declare namespace AtNavBar {
|
|
5
|
+
var propTypes: {
|
|
6
|
+
customStyle: PropTypes.Requireable<NonNullable<string | object | null | undefined>>;
|
|
7
|
+
className: PropTypes.Requireable<NonNullable<string | any[] | null | undefined>>;
|
|
8
|
+
fixed: PropTypes.Requireable<boolean>;
|
|
9
|
+
border: PropTypes.Requireable<boolean>;
|
|
10
|
+
color: PropTypes.Requireable<string>;
|
|
11
|
+
leftIconType: PropTypes.Requireable<NonNullable<string | object | null | undefined>>;
|
|
12
|
+
leftText: PropTypes.Requireable<string>;
|
|
13
|
+
title: PropTypes.Requireable<string>;
|
|
14
|
+
rightFirstIconType: PropTypes.Requireable<NonNullable<string | object | null | undefined>>;
|
|
15
|
+
rightSecondIconType: PropTypes.Requireable<NonNullable<string | object | null | undefined>>;
|
|
16
|
+
onClickLeftIcon: PropTypes.Requireable<(...args: any[]) => any>;
|
|
17
|
+
onClickRgIconSt: PropTypes.Requireable<(...args: any[]) => any>;
|
|
18
|
+
onClickRgIconNd: PropTypes.Requireable<(...args: any[]) => any>;
|
|
19
|
+
onClickTitle: PropTypes.Requireable<(...args: any[]) => any>;
|
|
20
|
+
};
|
|
12
21
|
}
|
|
22
|
+
export default AtNavBar;
|