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
|
@@ -3,7 +3,7 @@ import _toString from "lodash/toString";
|
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import React from "react";
|
|
5
5
|
import { Input, Text, View } from "@tarojs/components";
|
|
6
|
-
import { pxTransform } from "../../common/utils";
|
|
6
|
+
import { noop, pxTransform } from "../../common/utils";
|
|
7
7
|
function addNum(num1, num2) {
|
|
8
8
|
let sq1, sq2;
|
|
9
9
|
try {
|
|
@@ -27,66 +27,67 @@ function parseValue(num) {
|
|
|
27
27
|
}
|
|
28
28
|
return _toString(num);
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
30
|
+
function AtInputNumber({
|
|
31
|
+
customStyle = {},
|
|
32
|
+
className = "",
|
|
33
|
+
disabled = false,
|
|
34
|
+
disabledInput = false,
|
|
35
|
+
type = "number",
|
|
36
|
+
width = 0,
|
|
37
|
+
min = 0,
|
|
38
|
+
max = 100,
|
|
39
|
+
step = 1,
|
|
40
|
+
size = "normal",
|
|
41
|
+
value,
|
|
42
|
+
onChange = noop,
|
|
43
|
+
onBlur,
|
|
44
|
+
onErrorInput
|
|
45
|
+
}) {
|
|
46
|
+
const handleError = (errorValue) => {
|
|
47
|
+
if (!onErrorInput) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
onErrorInput(errorValue);
|
|
51
|
+
};
|
|
52
|
+
const handleValue = (val) => {
|
|
53
|
+
let resultValue = val === "" ? min : val;
|
|
54
|
+
if (Number(resultValue) > max) {
|
|
55
|
+
resultValue = max;
|
|
56
|
+
handleError({
|
|
57
|
+
type: "OVER",
|
|
58
|
+
errorValue: resultValue
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
if (Number(resultValue) < min) {
|
|
62
|
+
resultValue = min;
|
|
63
|
+
handleError({
|
|
64
|
+
type: "LOW",
|
|
65
|
+
errorValue: resultValue
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
if (resultValue && !Number(resultValue)) {
|
|
69
|
+
resultValue = parseFloat(String(resultValue)) || min;
|
|
70
|
+
handleError({
|
|
71
|
+
type: "OVER",
|
|
72
|
+
errorValue: resultValue
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
resultValue = parseValue(String(resultValue));
|
|
76
|
+
return resultValue;
|
|
77
|
+
};
|
|
78
|
+
const handleClick = (clickType, e) => {
|
|
78
79
|
const lowThanMin = clickType === "minus" && Number(value) <= min;
|
|
79
80
|
const overThanMax = clickType === "plus" && Number(value) >= max;
|
|
80
81
|
if (lowThanMin || overThanMax || disabled) {
|
|
81
82
|
const deltaValue2 = clickType === "minus" ? -step : step;
|
|
82
83
|
const errorValue = addNum(Number(value), deltaValue2);
|
|
83
84
|
if (disabled) {
|
|
84
|
-
|
|
85
|
+
handleError({
|
|
85
86
|
type: "DISABLED",
|
|
86
87
|
errorValue
|
|
87
88
|
});
|
|
88
89
|
} else {
|
|
89
|
-
|
|
90
|
+
handleError({
|
|
90
91
|
type: lowThanMin ? "LOW" : "OVER",
|
|
91
92
|
errorValue
|
|
92
93
|
});
|
|
@@ -95,82 +96,61 @@ class AtInputNumber extends React.Component {
|
|
|
95
96
|
}
|
|
96
97
|
const deltaValue = clickType === "minus" ? -step : step;
|
|
97
98
|
let newValue = addNum(Number(value), deltaValue);
|
|
98
|
-
newValue = Number(
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
99
|
+
newValue = Number(handleValue(newValue));
|
|
100
|
+
onChange(newValue, e);
|
|
101
|
+
};
|
|
102
|
+
const handleInput = (e) => {
|
|
103
|
+
const { value: inputVal } = e.target;
|
|
104
|
+
if (disabled) return "";
|
|
105
|
+
const newValue = handleValue(inputVal);
|
|
106
|
+
onChange(Number(newValue), e);
|
|
107
|
+
return newValue;
|
|
108
|
+
};
|
|
109
|
+
const handleBlur = (event) => onBlur && onBlur(event);
|
|
110
|
+
const inputStyle = {
|
|
111
|
+
width: width ? `${pxTransform(width)}` : ""
|
|
112
|
+
};
|
|
113
|
+
const inputValue = typeof value !== "undefined" ? Number(handleValue(value)) : null;
|
|
114
|
+
const rootCls = classNames(
|
|
115
|
+
"at-input-number",
|
|
116
|
+
{
|
|
117
|
+
"at-input-number--lg": size === "large"
|
|
118
|
+
},
|
|
119
|
+
className
|
|
120
|
+
);
|
|
121
|
+
const minusBtnCls = classNames("at-input-number__btn", {
|
|
122
|
+
"at-input-number--disabled": inputValue !== null && inputValue <= min || disabled
|
|
123
|
+
});
|
|
124
|
+
const plusBtnCls = classNames("at-input-number__btn", {
|
|
125
|
+
"at-input-number--disabled": inputValue !== null && inputValue >= max || disabled
|
|
126
|
+
});
|
|
127
|
+
return /* @__PURE__ */ React.createElement(View, { className: rootCls, style: customStyle }, /* @__PURE__ */ React.createElement(
|
|
128
|
+
View,
|
|
129
|
+
{
|
|
130
|
+
className: minusBtnCls,
|
|
131
|
+
onClick: (e) => handleClick("minus", e)
|
|
132
|
+
},
|
|
133
|
+
/* @__PURE__ */ React.createElement(Text, { className: "at-icon at-icon-subtract at-input-number__btn-subtract" })
|
|
134
|
+
), /* @__PURE__ */ React.createElement(
|
|
135
|
+
Input,
|
|
136
|
+
{
|
|
137
|
+
className: "at-input-number__input",
|
|
138
|
+
style: inputStyle,
|
|
108
139
|
type,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
},
|
|
123
|
-
className
|
|
124
|
-
);
|
|
125
|
-
const minusBtnCls = classNames("at-input-number__btn", {
|
|
126
|
-
"at-input-number--disabled": inputValue !== null && inputValue <= min || disabled
|
|
127
|
-
});
|
|
128
|
-
const plusBtnCls = classNames("at-input-number__btn", {
|
|
129
|
-
"at-input-number--disabled": inputValue !== null && inputValue >= max || disabled
|
|
130
|
-
});
|
|
131
|
-
return /* @__PURE__ */ React.createElement(View, { className: rootCls, style: customStyle }, /* @__PURE__ */ React.createElement(
|
|
132
|
-
View,
|
|
133
|
-
{
|
|
134
|
-
className: minusBtnCls,
|
|
135
|
-
onClick: this.handleClick.bind(this, "minus")
|
|
136
|
-
},
|
|
137
|
-
/* @__PURE__ */ React.createElement(Text, { className: "at-icon at-icon-subtract at-input-number__btn-subtract" })
|
|
138
|
-
), /* @__PURE__ */ React.createElement(
|
|
139
|
-
Input,
|
|
140
|
-
{
|
|
141
|
-
className: "at-input-number__input",
|
|
142
|
-
style: inputStyle,
|
|
143
|
-
type,
|
|
144
|
-
value: inputValue !== null ? String(inputValue) : "",
|
|
145
|
-
disabled: disabledInput || disabled,
|
|
146
|
-
onInput: this.handleInput,
|
|
147
|
-
onBlur: this.handleBlur
|
|
148
|
-
}
|
|
149
|
-
), /* @__PURE__ */ React.createElement(
|
|
150
|
-
View,
|
|
151
|
-
{
|
|
152
|
-
className: plusBtnCls,
|
|
153
|
-
onClick: this.handleClick.bind(this, "plus")
|
|
154
|
-
},
|
|
155
|
-
/* @__PURE__ */ React.createElement(Text, { className: "at-icon at-icon-add at-input-number__btn-add" })
|
|
156
|
-
));
|
|
157
|
-
}
|
|
140
|
+
value: inputValue !== null ? String(inputValue) : "",
|
|
141
|
+
disabled: disabledInput || disabled,
|
|
142
|
+
onInput: handleInput,
|
|
143
|
+
onBlur: handleBlur
|
|
144
|
+
}
|
|
145
|
+
), /* @__PURE__ */ React.createElement(
|
|
146
|
+
View,
|
|
147
|
+
{
|
|
148
|
+
className: plusBtnCls,
|
|
149
|
+
onClick: (e) => handleClick("plus", e)
|
|
150
|
+
},
|
|
151
|
+
/* @__PURE__ */ React.createElement(Text, { className: "at-icon at-icon-add at-input-number__btn-add" })
|
|
152
|
+
));
|
|
158
153
|
}
|
|
159
|
-
AtInputNumber.defaultProps = {
|
|
160
|
-
customStyle: {},
|
|
161
|
-
className: "",
|
|
162
|
-
disabled: false,
|
|
163
|
-
disabledInput: false,
|
|
164
|
-
type: "number",
|
|
165
|
-
width: 0,
|
|
166
|
-
min: 0,
|
|
167
|
-
max: 100,
|
|
168
|
-
step: 1,
|
|
169
|
-
size: "normal",
|
|
170
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
171
|
-
onChange: () => {
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
154
|
AtInputNumber.propTypes = {
|
|
175
155
|
customStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
176
156
|
className: PropTypes.oneOfType([PropTypes.array, PropTypes.string]),
|
|
@@ -187,7 +167,8 @@ AtInputNumber.propTypes = {
|
|
|
187
167
|
onBlur: PropTypes.func,
|
|
188
168
|
onErrorInput: PropTypes.func
|
|
189
169
|
};
|
|
170
|
+
var input_number_default = AtInputNumber;
|
|
190
171
|
export {
|
|
191
|
-
|
|
172
|
+
input_number_default as default
|
|
192
173
|
};
|
|
193
174
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/input-number/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport _toString from 'lodash/toString'\nimport PropTypes, { InferProps } from 'prop-types'\nimport React from 'react'\nimport { Input, Text, View } from '@tarojs/components'\nimport { CommonEvent, ITouchEvent } from '@tarojs/components/types/common'\nimport { AtInputNumberProps, InputError } from '../../../types/input-number'\nimport { pxTransform } from '../../common/utils'\n\n// TODO: Check all types\n\n// 实现两数相加并保留小数点后最短尾数\nfunction addNum(num1: number, num2: number): number {\n let sq1: number, sq2: number\n try {\n sq1 = _toString(num1).split('.')[1].length\n } catch (e) {\n sq1 = 0\n }\n try {\n sq2 = _toString(num2).split('.')[1].length\n } catch (e) {\n sq2 = 0\n }\n const m = Math.pow(10, Math.max(sq1, sq2))\n return (Math.round(num1 * m) + Math.round(num2 * m)) / m\n}\n\n// 格式化数字,处理01变成1,并且不处理1. 这种情况\nfunction parseValue(num: string): string {\n if (num === '') return '0'\n\n const numStr = _toString(num)\n if (numStr.indexOf('0') === 0 && numStr.indexOf('.') === -1) {\n // 处理01变成1,并且不处理1.\n return _toString(parseFloat(num))\n }\n return _toString(num)\n}\n\ntype ExtendEvent = {\n target: {\n value: string | number\n }\n}\n\nexport default class AtInputNumber extends React.Component<AtInputNumberProps> {\n public static defaultProps: AtInputNumberProps\n public static propTypes: InferProps<AtInputNumberProps>\n\n private handleClick(clickType: 'minus' | 'plus', e: CommonEvent): void {\n const { disabled, value, min = 0, max = 100, step = 1 } = this.props\n const lowThanMin = clickType === 'minus' && Number(value) <= min\n const overThanMax = clickType === 'plus' && Number(value) >= max\n if (lowThanMin || overThanMax || disabled) {\n const deltaValue = clickType === 'minus' ? -step : step\n const errorValue = addNum(Number(value), deltaValue)\n if (disabled) {\n this.handleError({\n type: 'DISABLED',\n errorValue\n })\n } else {\n this.handleError({\n type: lowThanMin ? 'LOW' : 'OVER',\n errorValue\n })\n }\n return\n }\n const deltaValue = clickType === 'minus' ? -step : step\n let newValue = addNum(Number(value), deltaValue)\n newValue = Number(this.handleValue(newValue))\n this.props.onChange(newValue, e)\n }\n\n private handleValue = (value: string | number): string => {\n const { max = 100, min = 0 } = this.props\n let resultValue = value === '' ? min : value\n // 此处不能使用 Math.max,会是字符串变数字,并丢失 .\n if (Number(resultValue) > max) {\n resultValue = max\n this.handleError({\n type: 'OVER',\n errorValue: resultValue\n })\n }\n if (Number(resultValue) < min) {\n resultValue = min\n this.handleError({\n type: 'LOW',\n errorValue: resultValue\n })\n }\n if (resultValue && !Number(resultValue)) {\n resultValue = parseFloat(String(resultValue)) || min\n\n this.handleError({\n type: 'OVER',\n errorValue: resultValue\n })\n }\n\n resultValue = parseValue(String(resultValue))\n return resultValue\n }\n\n private handleInput = (e: CommonEvent & ExtendEvent): string => {\n const { value } = e.target\n const { disabled } = this.props\n if (disabled) return ''\n\n const newValue = this.handleValue(value)\n this.props.onChange(Number(newValue), e)\n return newValue\n }\n\n private handleBlur = (event: ITouchEvent): void =>\n this.props.onBlur && this.props.onBlur(event)\n\n private handleError = (errorValue: InputError): void => {\n if (!this.props.onErrorInput) {\n return\n }\n this.props.onErrorInput(errorValue)\n }\n\n public render(): JSX.Element {\n const {\n customStyle,\n className,\n width,\n disabled,\n value,\n type,\n min = 0,\n max = 100,\n size,\n disabledInput\n } = this.props\n\n const inputStyle = {\n width: width ? `${pxTransform(width)}` : ''\n }\n const inputValue =\n typeof value !== 'undefined' ? Number(this.handleValue(value)) : null\n const rootCls = classNames(\n 'at-input-number',\n {\n 'at-input-number--lg': size === 'large'\n },\n className\n )\n const minusBtnCls = classNames('at-input-number__btn', {\n 'at-input-number--disabled':\n (inputValue !== null && inputValue <= min) || disabled\n })\n const plusBtnCls = classNames('at-input-number__btn', {\n 'at-input-number--disabled':\n (inputValue !== null && inputValue >= max) || disabled\n })\n\n return (\n <View className={rootCls} style={customStyle}>\n <View\n className={minusBtnCls}\n onClick={this.handleClick.bind(this, 'minus')}\n >\n <Text className='at-icon at-icon-subtract at-input-number__btn-subtract'></Text>\n </View>\n <Input\n className='at-input-number__input'\n style={inputStyle}\n type={type}\n value={inputValue !== null ? String(inputValue) : ''}\n disabled={disabledInput || disabled}\n onInput={this.handleInput}\n onBlur={this.handleBlur}\n />\n <View\n className={plusBtnCls}\n onClick={this.handleClick.bind(this, 'plus')}\n >\n <Text className='at-icon at-icon-add at-input-number__btn-add'></Text>\n </View>\n </View>\n )\n }\n}\n\nAtInputNumber.defaultProps = {\n customStyle: {},\n className: '',\n disabled: false,\n disabledInput: false,\n type: 'number',\n width: 0,\n min: 0,\n max: 100,\n step: 1,\n size: 'normal',\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n onChange: (): void => {}\n}\n\nAtInputNumber.propTypes = {\n customStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),\n className: PropTypes.oneOfType([PropTypes.array, PropTypes.string]),\n value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n type: PropTypes.oneOf(['number', 'digit']),\n disabled: PropTypes.bool,\n width: PropTypes.number,\n min: PropTypes.number,\n max: PropTypes.number,\n step: PropTypes.number,\n size: PropTypes.oneOf(['normal', 'large']),\n disabledInput: PropTypes.bool,\n onChange: PropTypes.func,\n onBlur: PropTypes.func,\n onErrorInput: PropTypes.func\n}\n"],"mappings":"AAAA,OAAO,gBAAgB;AACvB,OAAO,eAAe;AACtB,OAAO,eAA+B;AACtC,OAAO,WAAW;AAClB,SAAS,OAAO,MAAM,YAAY;AAGlC,SAAS,mBAAmB;AAK5B,SAAS,OAAO,MAAc,MAAsB;AAClD,MAAI,KAAa;AACjB,MAAI;AACF,UAAM,UAAU,IAAI,EAAE,MAAM,GAAG,EAAE,CAAC,EAAE;AAAA,EACtC,SAAS,GAAG;AACV,UAAM;AAAA,EACR;AACA,MAAI;AACF,UAAM,UAAU,IAAI,EAAE,MAAM,GAAG,EAAE,CAAC,EAAE;AAAA,EACtC,SAAS,GAAG;AACV,UAAM;AAAA,EACR;AACA,QAAM,IAAI,KAAK,IAAI,IAAI,KAAK,IA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,WAAW,UAAU,UAAU,CAAC,UAAU,OAAO,UAAU,MAAM,CAAC;AAAA,EAClE,OAAO,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,MAAM,CAAC;AAAA,EAC/D,MAAM,UAAU,MAAM,CAAC,UAAU,OAAO,CAAC;AAAA,EACzC,UAAU,UAAU;AAAA,EACpB,OAAO,UAAU;AAAA,EACjB,KAAK,UAAU;AAAA,EACf,KAAK,UAAU;AAAA,EACf,MAAM,UAAU;AAAA,EAChB,MAAM,UAAU,MAAM,CAAC,UAAU,OAAO,CAAC;AAAA,EACzC,eAAe,UAAU;AAAA,EACzB,UAAU,UAAU;AAAA,EACpB,QAAQ,UAAU;AAAA,EAClB,cAAc,UAAU;AAC1B;","names":["deltaValue"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/input-number/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport _toString from 'lodash/toString'\nimport PropTypes from 'prop-types'\nimport React from 'react'\nimport { Input, Text, View } from '@tarojs/components'\nimport { CommonEvent, ITouchEvent } from '@tarojs/components/types/common'\nimport { AtInputNumberProps, InputError } from '../../../types/input-number'\nimport { noop, pxTransform } from '../../common/utils'\n\n// TODO: Check all types\n\n// 实现两数相加并保留小数点后最短尾数\nfunction addNum(num1: number, num2: number): number {\n let sq1: number, sq2: number\n try {\n sq1 = _toString(num1).split('.')[1].length\n } catch (e) {\n sq1 = 0\n }\n try {\n sq2 = _toString(num2).split('.')[1].length\n } catch (e) {\n sq2 = 0\n }\n const m = Math.pow(10, Math.max(sq1, sq2))\n return (Math.round(num1 * m) + Math.round(num2 * m)) / m\n}\n\n// 格式化数字,处理01变成1,并且不处理1. 这种情况\nfunction parseValue(num: string): string {\n if (num === '') return '0'\n\n const numStr = _toString(num)\n if (numStr.indexOf('0') === 0 && numStr.indexOf('.') === -1) {\n // 处理01变成1,并且不处理1.\n return _toString(parseFloat(num))\n }\n return _toString(num)\n}\n\ntype ExtendEvent = {\n target: {\n value: string | number\n }\n}\n\nfunction AtInputNumber({\n customStyle = {},\n className = '',\n disabled = false,\n disabledInput = false,\n type = 'number',\n width = 0,\n min = 0,\n max = 100,\n step = 1,\n size = 'normal',\n value,\n onChange = noop,\n onBlur,\n onErrorInput\n}: AtInputNumberProps): JSX.Element {\n const handleError = (errorValue: InputError): void => {\n if (!onErrorInput) {\n return\n }\n onErrorInput(errorValue)\n }\n\n const handleValue = (val: string | number): string => {\n let resultValue = val === '' ? min : val\n // 此处不能使用 Math.max,会是字符串变数字,并丢失 .\n if (Number(resultValue) > max) {\n resultValue = max\n handleError({\n type: 'OVER',\n errorValue: resultValue\n })\n }\n if (Number(resultValue) < min) {\n resultValue = min\n handleError({\n type: 'LOW',\n errorValue: resultValue\n })\n }\n if (resultValue && !Number(resultValue)) {\n resultValue = parseFloat(String(resultValue)) || min\n\n handleError({\n type: 'OVER',\n errorValue: resultValue\n })\n }\n\n resultValue = parseValue(String(resultValue))\n return resultValue\n }\n\n const handleClick = (clickType: 'minus' | 'plus', e: CommonEvent): void => {\n const lowThanMin = clickType === 'minus' && Number(value) <= min\n const overThanMax = clickType === 'plus' && Number(value) >= max\n if (lowThanMin || overThanMax || disabled) {\n const deltaValue = clickType === 'minus' ? -step : step\n const errorValue = addNum(Number(value), deltaValue)\n if (disabled) {\n handleError({\n type: 'DISABLED',\n errorValue\n })\n } else {\n handleError({\n type: lowThanMin ? 'LOW' : 'OVER',\n errorValue\n })\n }\n return\n }\n const deltaValue = clickType === 'minus' ? -step : step\n let newValue = addNum(Number(value), deltaValue)\n newValue = Number(handleValue(newValue))\n onChange(newValue, e)\n }\n\n const handleInput = (e: CommonEvent & ExtendEvent): string => {\n const { value: inputVal } = e.target\n if (disabled) return ''\n\n const newValue = handleValue(inputVal)\n onChange(Number(newValue), e)\n return newValue\n }\n\n const handleBlur = (event: ITouchEvent): void => onBlur && onBlur(event)\n\n const inputStyle = {\n width: width ? `${pxTransform(width)}` : ''\n }\n const inputValue =\n typeof value !== 'undefined' ? Number(handleValue(value)) : null\n const rootCls = classNames(\n 'at-input-number',\n {\n 'at-input-number--lg': size === 'large'\n },\n className\n )\n const minusBtnCls = classNames('at-input-number__btn', {\n 'at-input-number--disabled':\n (inputValue !== null && inputValue <= min) || disabled\n })\n const plusBtnCls = classNames('at-input-number__btn', {\n 'at-input-number--disabled':\n (inputValue !== null && inputValue >= max) || disabled\n })\n\n return (\n <View className={rootCls} style={customStyle}>\n <View\n className={minusBtnCls}\n onClick={(e: CommonEvent) => handleClick('minus', e)}\n >\n <Text className='at-icon at-icon-subtract at-input-number__btn-subtract'></Text>\n </View>\n <Input\n className='at-input-number__input'\n style={inputStyle}\n type={type}\n value={inputValue !== null ? String(inputValue) : ''}\n disabled={disabledInput || disabled}\n onInput={handleInput}\n onBlur={handleBlur}\n />\n <View\n className={plusBtnCls}\n onClick={(e: CommonEvent) => handleClick('plus', e)}\n >\n <Text className='at-icon at-icon-add at-input-number__btn-add'></Text>\n </View>\n </View>\n )\n}\n\nAtInputNumber.propTypes = {\n customStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),\n className: PropTypes.oneOfType([PropTypes.array, PropTypes.string]),\n value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n type: PropTypes.oneOf(['number', 'digit']),\n disabled: PropTypes.bool,\n width: PropTypes.number,\n min: PropTypes.number,\n max: PropTypes.number,\n step: PropTypes.number,\n size: PropTypes.oneOf(['normal', 'large']),\n disabledInput: PropTypes.bool,\n onChange: PropTypes.func,\n onBlur: PropTypes.func,\n onErrorInput: PropTypes.func\n}\n\nexport default AtInputNumber\n"],"mappings":"AAAA,OAAO,gBAAgB;AACvB,OAAO,eAAe;AACtB,OAAO,eAAe;AACtB,OAAO,WAAW;AAClB,SAAS,OAAO,MAAM,YAAY;AAGlC,SAAS,MAAM,mBAAmB;AAKlC,SAAS,OAAO,MAAc,MAAsB;AAClD,MAAI,KAAa;AACjB,MAAI;AACF,UAAM,UAAU,IAAI,EAAE,MAAM,GAAG,EAAE,CAAC,EAAE;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AM,UAAU,MAAM,CAAC,UAAU,OAAO,CAAC;AAAA,EACzC,eAAe,UAAU;AAAA,EACzB,UAAU,UAAU;AAAA,EACpB,QAAQ,UAAU;AAAA,EAClB,cAAc,UAAU;AAC1B;AAEA,IAAO,uBAAQ;","names":["deltaValue"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React from 'react';
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
3
2
|
import { AtListProps } from '../../../types/list';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
declare function AtList({ hasBorder, className, children }: AtListProps): JSX.Element;
|
|
4
|
+
declare namespace AtList {
|
|
5
|
+
var propTypes: {
|
|
6
|
+
hasBorder: PropTypes.Requireable<boolean>;
|
|
7
|
+
};
|
|
8
8
|
}
|
|
9
|
+
export default AtList;
|
|
@@ -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 AtList({
|
|
6
|
+
hasBorder = true,
|
|
7
|
+
className,
|
|
8
|
+
children
|
|
9
|
+
}) {
|
|
10
|
+
const rootClass = classNames(
|
|
11
|
+
"at-list",
|
|
12
|
+
{
|
|
13
|
+
"at-list--no-border": !hasBorder
|
|
14
|
+
},
|
|
15
|
+
className
|
|
16
|
+
);
|
|
17
|
+
return /* @__PURE__ */ React.createElement(View, { className: rootClass }, children);
|
|
16
18
|
}
|
|
17
|
-
AtList.defaultProps = {
|
|
18
|
-
hasBorder: true
|
|
19
|
-
};
|
|
20
19
|
AtList.propTypes = {
|
|
21
20
|
hasBorder: PropTypes.bool
|
|
22
21
|
};
|
|
22
|
+
var list_default = AtList;
|
|
23
23
|
export {
|
|
24
|
-
|
|
24
|
+
list_default as default
|
|
25
25
|
};
|
|
26
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/list/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport PropTypes
|
|
1
|
+
{"version":3,"sources":["../../../src/components/list/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport PropTypes from 'prop-types'\nimport React from 'react'\nimport { View } from '@tarojs/components'\nimport { AtListProps } from '../../../types/list'\n\nfunction AtList({\n hasBorder = true,\n className,\n children\n}: AtListProps): JSX.Element {\n const rootClass = classNames(\n 'at-list',\n {\n 'at-list--no-border': !hasBorder\n },\n className\n )\n\n return <View className={rootClass}>{children}</View>\n}\n\nAtList.propTypes = {\n hasBorder: PropTypes.bool\n}\n\nexport default AtList\n"],"mappings":"AAAA,OAAO,gBAAgB;AACvB,OAAO,eAAe;AACtB,OAAO,WAAW;AAClB,SAAS,YAAY;AAGrB,SAAS,OAAO;AAAA,EACd,YAAY;AAAA,EACZ;AAAA,EACA;AACF,GAA6B;AAC3B,QAAM,YAAY;AAAA,IAChB;AAAA,IACA;AAAA,MACE,sBAAsB,CAAC;AAAA,IACzB;AAAA,IACA;AAAA,EACF;AAEA,SAAO,oCAAC,QAAK,WAAW,aAAY,QAAS;AAC/C;AAEA,OAAO,YAAY;AAAA,EACjB,WAAW,UAAU;AACvB;AAEA,IAAO,eAAQ;","names":[]}
|
|
@@ -1,11 +1,29 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React from 'react';
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
3
2
|
import { AtListItemProps } from '../../../../types/list';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
declare function AtListItem({ note, disabled, title, thumb, isSwitch, hasBorder, switchColor, switchIsCheck, extraText, extraThumb, iconInfo, arrow, icon, className, onClick, onSwitchChange }: AtListItemProps): JSX.Element;
|
|
4
|
+
declare namespace AtListItem {
|
|
5
|
+
var propTypes: {
|
|
6
|
+
note: PropTypes.Requireable<NonNullable<string | PropTypes.ReactElementLike | null | undefined>>;
|
|
7
|
+
disabled: PropTypes.Requireable<boolean>;
|
|
8
|
+
title: PropTypes.Requireable<NonNullable<string | PropTypes.ReactElementLike | null | undefined>>;
|
|
9
|
+
thumb: PropTypes.Requireable<string>;
|
|
10
|
+
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
11
|
+
isSwitch: PropTypes.Requireable<boolean>;
|
|
12
|
+
hasBorder: PropTypes.Requireable<boolean>;
|
|
13
|
+
switchColor: PropTypes.Requireable<string>;
|
|
14
|
+
switchIsCheck: PropTypes.Requireable<boolean>;
|
|
15
|
+
extraText: PropTypes.Requireable<NonNullable<string | PropTypes.ReactElementLike | null | undefined>>;
|
|
16
|
+
extraThumb: PropTypes.Requireable<string>;
|
|
17
|
+
onSwitchChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
18
|
+
arrow: PropTypes.Requireable<string>;
|
|
19
|
+
iconInfo: PropTypes.Requireable<PropTypes.InferProps<{
|
|
20
|
+
size: PropTypes.Requireable<number>;
|
|
21
|
+
value: PropTypes.Requireable<string>;
|
|
22
|
+
color: PropTypes.Requireable<string>;
|
|
23
|
+
prefixClass: PropTypes.Requireable<string>;
|
|
24
|
+
customStyle: PropTypes.Requireable<NonNullable<string | object | null | undefined>>;
|
|
25
|
+
className: PropTypes.Requireable<NonNullable<string | any[] | null | undefined>>;
|
|
26
|
+
}>>;
|
|
27
|
+
};
|
|
11
28
|
}
|
|
29
|
+
export default AtListItem;
|