@nutui/nutui 3.1.22-beta.5 → 3.1.23-beta.1
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/CHANGELOG.md +48 -0
- package/README.md +3 -4
- package/dist/nutui.es.js +20412 -4214
- package/dist/nutui.umd.js +20518 -4216
- package/dist/packages/_es/ActionSheet.js +149 -17
- package/dist/packages/_es/Address.js +535 -110
- package/dist/packages/_es/AddressList.js +615 -113
- package/dist/packages/_es/Animate.js +59 -17
- package/dist/packages/_es/Audio.js +257 -53
- package/dist/packages/_es/AudioOperate.js +100 -13
- package/dist/packages/_es/Avatar.js +162 -38
- package/dist/packages/_es/AvatarGroup.js +73 -14
- package/dist/packages/_es/BackTop.js +156 -43
- package/dist/packages/_es/Badge.js +86 -14
- package/dist/packages/_es/Barrage.js +120 -41
- package/dist/packages/_es/Button.js +128 -23
- package/dist/packages/_es/Calendar.js +246 -30
- package/dist/packages/_es/CalendarItem.js +1 -1
- package/dist/packages/_es/Card.js +107 -10
- package/dist/packages/_es/Cascader.js +496 -147
- package/dist/packages/_es/Category.js +58 -15
- package/dist/packages/_es/CategoryPane.js +111 -11
- package/dist/packages/_es/Cell.js +108 -21
- package/dist/packages/_es/CellGroup.js +44 -9
- package/dist/packages/_es/Checkbox.js +134 -29
- package/dist/packages/_es/CheckboxGroup.js +79 -29
- package/dist/packages/_es/CircleProgress.js +150 -28
- package/dist/packages/_es/Col.js +56 -14
- package/dist/packages/_es/Collapse.js +109 -32
- package/dist/packages/_es/CollapseItem.js +253 -59
- package/dist/packages/_es/Comment.js +434 -64
- package/dist/packages/_es/ConfigProvider.js +20 -8
- package/dist/packages/_es/CountDown.js +238 -56
- package/dist/packages/_es/CountUp.js +539 -140
- package/dist/packages/_es/DatePicker.js +315 -98
- package/dist/packages/_es/Dialog.js +289 -60
- package/dist/packages/_es/Divider.js +65 -13
- package/dist/packages/_es/Drag.js +197 -56
- package/dist/packages/_es/Ecard.js +159 -24
- package/dist/packages/_es/Elevator.js +255 -58
- package/dist/packages/_es/Ellipsis.js +200 -58
- package/dist/packages/_es/Empty.js +71 -12
- package/dist/packages/_es/FixedNav.js +122 -15
- package/dist/packages/_es/Form.js +151 -64
- package/dist/packages/_es/FormItem.js +114 -15
- package/dist/packages/_es/Grid.js +6 -5
- package/dist/packages/_es/GridItem.js +144 -33
- package/dist/packages/_es/Icon.js +40 -15
- package/dist/packages/_es/Image.js +137 -26
- package/dist/packages/_es/ImagePreview.js +547 -76
- package/dist/packages/_es/Indicator.js +62 -15
- package/dist/packages/_es/InfiniteLoading.js +249 -57
- package/dist/packages/_es/Input.js +433 -51
- package/dist/packages/_es/InputNumber.js +160 -41
- package/dist/packages/_es/Layout.js +5 -4
- package/dist/packages/_es/List.js +106 -18
- package/dist/packages/_es/Menu.js +168 -44
- package/dist/packages/_es/MenuItem.js +173 -37
- package/dist/packages/_es/Navbar.js +192 -30
- package/dist/packages/_es/NoticeBar.js +380 -74
- package/dist/packages/_es/Notify.js +227 -72
- package/dist/packages/_es/NumberKeyboard.js +272 -41
- package/dist/packages/_es/OldPicker.js +457 -130
- package/dist/packages/_es/OverLay.js +98 -24
- package/dist/packages/_es/Pagination.js +157 -39
- package/dist/packages/_es/Picker.js +454 -129
- package/dist/packages/_es/Popover.js +957 -318
- package/dist/packages/_es/Popup.js +299 -55
- package/dist/packages/_es/Price.js +118 -16
- package/dist/packages/_es/Progress.js +146 -14
- package/dist/packages/_es/PullRefresh.js +339 -84
- package/dist/packages/_es/Radio.js +90 -22
- package/dist/packages/_es/RadioGroup.js +37 -8
- package/dist/packages/_es/Range.js +408 -83
- package/dist/packages/_es/Rate.js +192 -36
- package/dist/packages/_es/Row.js +64 -22
- package/dist/packages/_es/SearchBar.js +238 -37
- package/dist/packages/_es/ShortPassword.js +225 -35
- package/dist/packages/_es/SideNavBar.js +81 -24
- package/dist/packages/_es/SideNavBarItem.js +46 -11
- package/dist/packages/_es/Signature.js +160 -41
- package/dist/packages/_es/Skeleton.js +136 -20
- package/dist/packages/_es/Sku.js +491 -84
- package/dist/packages/_es/Step.js +115 -20
- package/dist/packages/_es/Steps.js +53 -18
- package/dist/packages/_es/Sticky.js +138 -53
- package/dist/packages/_es/SubSideNavBar.js +82 -17
- package/dist/packages/_es/Swipe.js +178 -41
- package/dist/packages/_es/Swiper.js +433 -121
- package/dist/packages/_es/SwiperItem.js +53 -22
- package/dist/packages/_es/Switch.js +116 -21
- package/dist/packages/_es/TabPane.js +39 -12
- package/dist/packages/_es/Tabbar.js +72 -17
- package/dist/packages/_es/TabbarItem.js +151 -29
- package/dist/packages/_es/Table.js +178 -18
- package/dist/packages/_es/Tabs.js +202 -43
- package/dist/packages/_es/Tag.js +97 -20
- package/dist/packages/_es/TextArea.js +160 -42
- package/dist/packages/_es/TimeDetail.js +79 -18
- package/dist/packages/_es/TimePannel.js +48 -14
- package/dist/packages/_es/TimeSelect.js +112 -15
- package/dist/packages/_es/Toast.js +310 -71
- package/dist/packages/_es/Uploader.js +455 -104
- package/dist/packages/_es/Video.js +332 -74
- package/dist/packages/_es/common.js +128 -38
- package/dist/packages/_es/component.js +76 -35
- package/dist/packages/_es/index.js +6 -5
- package/dist/packages/_es/index2.js +30 -9
- package/dist/packages/_es/index3.js +8 -6
- package/dist/packages/_es/index4.js +64 -13
- package/dist/packages/_es/index5.js +780 -164
- package/dist/packages/_es/plugin-vue_export-helper.js +8 -7
- package/dist/packages/_es/pxCheck.js +5 -3
- package/dist/packages/_es/raf.js +15 -8
- package/dist/packages/imagepreview/index.scss +6 -1
- package/dist/packages/locale/lang/baseLang.js +3 -3
- package/dist/packages/locale/lang/en-US.js +105 -5
- package/dist/packages/locale/lang/id-ID.js +105 -5
- package/dist/packages/locale/lang/index.js +38 -16
- package/dist/packages/locale/lang/zh-CN.js +105 -5
- package/dist/packages/locale/lang/zh-TW.js +105 -5
- package/dist/packages/picker/index.scss +13 -0
- package/dist/smartips/attributes.json +8 -0
- package/dist/smartips/tags.json +3 -1
- package/dist/smartips/web-types.json +19 -1
- package/dist/style.css +1 -1
- package/dist/style.es.js +1 -1
- package/dist/styles/themes/default.scss +49 -49
- package/dist/styles/themes/jdb.scss +49 -49
- package/dist/styles/themes/jdt.scss +49 -49
- package/dist/styles/variables-jdb.scss +4 -1
- package/dist/styles/variables-jdt.scss +4 -1
- package/dist/styles/variables.scss +1 -1
- package/dist/types/__VUE/actionsheet/index.vue.d.ts +3 -3
- package/dist/types/__VUE/address/index.vue.d.ts +4 -4
- package/dist/types/__VUE/calendar/index.vue.d.ts +1 -1
- package/dist/types/__VUE/cascader/index.vue.d.ts +3 -3
- package/dist/types/__VUE/cell/index.vue.d.ts +2 -2
- package/dist/types/__VUE/checkbox/index.vue.d.ts +2 -2
- package/dist/types/__VUE/collapse/index.vue.d.ts +2 -2
- package/dist/types/__VUE/datepicker/index.vue.d.ts +2 -2
- package/dist/types/__VUE/dialog/index.vue.d.ts +2 -2
- package/dist/types/__VUE/ecard/index.vue.d.ts +2 -2
- package/dist/types/__VUE/fixednav/index.vue.d.ts +2 -2
- package/dist/types/__VUE/grid/index.vue.d.ts +3 -3
- package/dist/types/__VUE/imagepreview/imagePreviewItem.vue.d.ts +95 -0
- package/dist/types/__VUE/imagepreview/index.vue.d.ts +23 -25
- package/dist/types/__VUE/infiniteloading/index.vue.d.ts +6 -6
- package/dist/types/__VUE/input/index.vue.d.ts +2 -2
- package/dist/types/__VUE/menu/index.vue.d.ts +4 -4
- package/dist/types/__VUE/menuitem/index.vue.d.ts +1 -1
- package/dist/types/__VUE/numberkeyboard/index.vue.d.ts +2 -2
- package/dist/types/__VUE/oldpicker/index.vue.d.ts +3 -3
- package/dist/types/__VUE/picker/index.vue.d.ts +3 -3
- package/dist/types/__VUE/popover/index.vue.d.ts +6 -6
- package/dist/types/__VUE/popup/index.vue.d.ts +4 -4
- package/dist/types/__VUE/range/index.vue.d.ts +1 -1
- package/dist/types/__VUE/rate/index.vue.d.ts +2 -2
- package/dist/types/__VUE/searchbar/index.vue.d.ts +2 -2
- package/dist/types/__VUE/shortpassword/index.vue.d.ts +1 -1
- package/dist/types/__VUE/sku/index.vue.d.ts +3 -3
- package/dist/types/__VUE/swipe/index.vue.d.ts +2 -2
- package/dist/types/__VUE/switch/index.vue.d.ts +2 -2
- package/dist/types/__VUE/tabbar/index.vue.d.ts +2 -2
- package/dist/types/__VUE/textarea/index.vue.d.ts +2 -2
- package/dist/types/__VUE/toast/index.vue.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -2
|
@@ -1,28 +1,96 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @nutui/nutui v3.1.
|
|
2
|
+
* @nutui/nutui v3.1.23-beta.1 Mon Jun 27 2022 21:39:05 GMT+0800 (中国标准时间)
|
|
3
3
|
* (c) 2022 @jdf2e.
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import { inject
|
|
7
|
-
import { c as
|
|
8
|
-
import
|
|
6
|
+
import { inject, computed, h } from "vue";
|
|
7
|
+
import { c as createComponent } from "./component.js";
|
|
8
|
+
import _sfc_main$1 from "./Icon.js";
|
|
9
9
|
import "../locale/lang";
|
|
10
10
|
import "./pxCheck.js";
|
|
11
|
-
const { componentName
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
11
|
+
const { componentName, create } = createComponent("radio");
|
|
12
|
+
const _sfc_main = create({
|
|
13
|
+
props: {
|
|
14
|
+
disabled: {
|
|
15
|
+
type: Boolean,
|
|
16
|
+
default: false
|
|
17
|
+
},
|
|
18
|
+
shape: {
|
|
19
|
+
type: String,
|
|
20
|
+
default: "round"
|
|
21
|
+
},
|
|
22
|
+
label: {
|
|
23
|
+
type: [String, Number],
|
|
24
|
+
default: ""
|
|
25
|
+
},
|
|
26
|
+
iconName: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: "check-normal"
|
|
29
|
+
},
|
|
30
|
+
iconActiveName: {
|
|
31
|
+
type: String,
|
|
32
|
+
default: "check-checked"
|
|
33
|
+
},
|
|
34
|
+
iconSize: {
|
|
35
|
+
type: [String, Number],
|
|
36
|
+
default: ""
|
|
37
|
+
},
|
|
38
|
+
iconClassPrefix: {
|
|
39
|
+
type: String,
|
|
40
|
+
default: "nut-icon"
|
|
41
|
+
},
|
|
42
|
+
iconFontClassName: {
|
|
43
|
+
type: String,
|
|
44
|
+
default: "nutui-iconfont"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
setup(props, { emit, slots }) {
|
|
48
|
+
let parent = inject("parent", null);
|
|
49
|
+
const isCurValue = computed(() => {
|
|
50
|
+
return parent.label.value == props.label;
|
|
51
|
+
});
|
|
52
|
+
const color = computed(() => {
|
|
53
|
+
return !props.disabled ? isCurValue.value ? "nut-radio__icon" : "nut-radio__icon--unchecked" : "nut-radio__icon--disable";
|
|
54
|
+
});
|
|
55
|
+
const position = computed(() => {
|
|
56
|
+
return parent.position;
|
|
57
|
+
});
|
|
58
|
+
const renderIcon = () => {
|
|
59
|
+
const { iconName, iconSize, iconActiveName, iconClassPrefix, iconFontClassName } = props;
|
|
60
|
+
return h(_sfc_main$1, {
|
|
61
|
+
name: isCurValue.value ? iconActiveName : iconName,
|
|
62
|
+
size: iconSize,
|
|
63
|
+
class: color.value,
|
|
64
|
+
classPrefix: iconClassPrefix,
|
|
65
|
+
fontClassName: iconFontClassName
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
const renderLabel = () => {
|
|
69
|
+
var _a;
|
|
70
|
+
return h("view", {
|
|
71
|
+
class: `${componentName}__label ${props.disabled ? `${componentName}__label--disabled` : ""}`
|
|
72
|
+
}, (_a = slots.default) == null ? void 0 : _a.call(slots));
|
|
73
|
+
};
|
|
74
|
+
const renderButton = () => {
|
|
75
|
+
var _a;
|
|
76
|
+
return h("view", {
|
|
77
|
+
class: `${componentName}__button ${isCurValue.value && `${componentName}__button--active`} ${props.disabled ? `${componentName}__button--disabled` : ""}`
|
|
78
|
+
}, (_a = slots.default) == null ? void 0 : _a.call(slots));
|
|
79
|
+
};
|
|
80
|
+
const handleClick = () => {
|
|
81
|
+
if (isCurValue.value || props.disabled)
|
|
82
|
+
return;
|
|
83
|
+
parent.updateValue(props.label);
|
|
84
|
+
};
|
|
85
|
+
let reverseState = position.value === "left";
|
|
86
|
+
return () => {
|
|
87
|
+
return h("view", {
|
|
88
|
+
class: `${componentName} ${componentName}--${props.shape} ${reverseState ? `${componentName}--reverse` : ""}`,
|
|
89
|
+
onClick: handleClick
|
|
90
|
+
}, [
|
|
91
|
+
props.shape == "button" ? renderButton() : reverseState ? [renderLabel(), renderIcon()] : [renderIcon(), renderLabel()]
|
|
92
|
+
]);
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
export { _sfc_main as default };
|
|
@@ -1,13 +1,42 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @nutui/nutui v3.1.
|
|
2
|
+
* @nutui/nutui v3.1.23-beta.1 Mon Jun 27 2022 21:39:05 GMT+0800 (中国标准时间)
|
|
3
3
|
* (c) 2022 @jdf2e.
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import { provide
|
|
7
|
-
import { c as
|
|
6
|
+
import { provide, readonly, computed, watch, h } from "vue";
|
|
7
|
+
import { c as createComponent } from "./component.js";
|
|
8
8
|
import "../locale/lang";
|
|
9
|
-
const { componentName
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
const { componentName, create } = createComponent("radiogroup");
|
|
10
|
+
const _sfc_main = create({
|
|
11
|
+
props: {
|
|
12
|
+
modelValue: {
|
|
13
|
+
type: [Number, String, Boolean],
|
|
14
|
+
default: ""
|
|
15
|
+
},
|
|
16
|
+
direction: {
|
|
17
|
+
type: String,
|
|
18
|
+
default: "vertical"
|
|
19
|
+
},
|
|
20
|
+
textPosition: {
|
|
21
|
+
type: String,
|
|
22
|
+
default: "right"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
emits: ["change", "update:modelValue"],
|
|
26
|
+
setup(props, { emit, slots }) {
|
|
27
|
+
const updateValue = (value) => emit("update:modelValue", value);
|
|
28
|
+
provide("parent", {
|
|
29
|
+
label: readonly(computed(() => props.modelValue)),
|
|
30
|
+
position: props.textPosition,
|
|
31
|
+
updateValue
|
|
32
|
+
});
|
|
33
|
+
watch(() => props.modelValue, (value) => emit("change", value));
|
|
34
|
+
return () => {
|
|
35
|
+
var _a;
|
|
36
|
+
return h("view", {
|
|
37
|
+
class: `${componentName} ${componentName}--${props.direction}`
|
|
38
|
+
}, (_a = slots.default) == null ? void 0 : _a.call(slots));
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
export { _sfc_main as default };
|
|
@@ -1,89 +1,414 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @nutui/nutui v3.1.
|
|
2
|
+
* @nutui/nutui v3.1.23-beta.1 Mon Jun 27 2022 21:39:05 GMT+0800 (中国标准时间)
|
|
3
3
|
* (c) 2022 @jdf2e.
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import { ref
|
|
7
|
-
import { c as
|
|
8
|
-
import { u as
|
|
9
|
-
import { u as
|
|
10
|
-
import { _ as
|
|
6
|
+
import { ref, computed, toRefs, openBlock, createElementBlock, normalizeClass, toDisplayString, createCommentVNode, createElementVNode, normalizeStyle, withModifiers, Fragment, renderList, createTextVNode, renderSlot } from "vue";
|
|
7
|
+
import { c as createComponent } from "./component.js";
|
|
8
|
+
import { u as useTouch } from "./index4.js";
|
|
9
|
+
import { u as useRect } from "./index2.js";
|
|
10
|
+
import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
|
|
11
11
|
import "../locale/lang";
|
|
12
|
-
const { componentName
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
const a2 = h(s2);
|
|
55
|
-
let t2 = m2.deltaX.value, r3 = a2.width, d3 = t2 / r3 * v2.value;
|
|
56
|
-
n2.vertical && (t2 = m2.deltaY.value, r3 = a2.height, d3 = t2 / r3 * v2.value), T2(u2) ? i2[l2.value] = u2[l2.value] + d3 : i2 = u2 + d3, V2(i2), e2.stopPropagation(), e2.preventDefault();
|
|
57
|
-
}, onTouchEnd: () => {
|
|
58
|
-
n2.disabled || (c2.value === "draging" && (V2(i2, true), o2("drag-end")), c2.value = "");
|
|
59
|
-
}, ...t(n2), barStyle: S2, curValue: (e2) => typeof e2 == "number" ? n2.modelValue[e2] : n2.modelValue, buttonIndex: l2, containerClasses: b2, markClassName: (e2) => {
|
|
60
|
-
const { modelValue: a2, max: t2, min: o3 } = n2;
|
|
61
|
-
let r3 = Number(o3), l3 = Number(t2);
|
|
62
|
-
if (n2.range) {
|
|
63
|
-
const [e3, t3] = a2;
|
|
64
|
-
r3 = e3, l3 = t3;
|
|
65
|
-
} else
|
|
66
|
-
l3 = a2;
|
|
67
|
-
return { "nut-range-mark-text": true, "nut-range-mark-text-active": e2 <= l3 && e2 >= r3 };
|
|
68
|
-
}, marksStyle: (e2) => {
|
|
69
|
-
const { max: a2, min: t2, vertical: o3 } = n2;
|
|
70
|
-
let r3 = { left: (e2 - Number(t2)) / v2.value * 100 + "%" };
|
|
71
|
-
return o3 && (r3 = { top: (e2 - Number(t2)) / v2.value * 100 + "%" }), r3;
|
|
72
|
-
}, marksList: d2, tickStyle: (e2) => {
|
|
73
|
-
const { modelValue: a2, max: t2, min: o3 } = n2;
|
|
74
|
-
let r3 = Number(o3), l3 = Number(t2);
|
|
75
|
-
if (n2.range) {
|
|
76
|
-
const [e3, t3] = a2;
|
|
77
|
-
r3 = e3, l3 = t3;
|
|
12
|
+
const { componentName, create } = createComponent("range");
|
|
13
|
+
const _sfc_main = create({
|
|
14
|
+
props: {
|
|
15
|
+
range: {
|
|
16
|
+
type: Boolean,
|
|
17
|
+
default: false
|
|
18
|
+
},
|
|
19
|
+
disabled: Boolean,
|
|
20
|
+
activeColor: String,
|
|
21
|
+
inactiveColor: String,
|
|
22
|
+
buttonColor: String,
|
|
23
|
+
vertical: {
|
|
24
|
+
type: Boolean,
|
|
25
|
+
default: false
|
|
26
|
+
},
|
|
27
|
+
marks: {
|
|
28
|
+
type: Object,
|
|
29
|
+
default: {}
|
|
30
|
+
},
|
|
31
|
+
hiddenRange: {
|
|
32
|
+
type: Boolean,
|
|
33
|
+
default: false
|
|
34
|
+
},
|
|
35
|
+
hiddenTag: {
|
|
36
|
+
type: Boolean,
|
|
37
|
+
default: false
|
|
38
|
+
},
|
|
39
|
+
min: {
|
|
40
|
+
type: [Number, String],
|
|
41
|
+
default: 0
|
|
42
|
+
},
|
|
43
|
+
max: {
|
|
44
|
+
type: [Number, String],
|
|
45
|
+
default: 100
|
|
46
|
+
},
|
|
47
|
+
step: {
|
|
48
|
+
type: [Number, String],
|
|
49
|
+
default: 1
|
|
50
|
+
},
|
|
51
|
+
modelValue: {
|
|
52
|
+
type: [Number, Array],
|
|
53
|
+
default: 0
|
|
78
54
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
55
|
+
},
|
|
56
|
+
emits: ["change", "drag-end", "drag-start", "update:modelValue"],
|
|
57
|
+
setup(props, { emit, slots }) {
|
|
58
|
+
const buttonIndex = ref(0);
|
|
59
|
+
let startValue;
|
|
60
|
+
let currentValue;
|
|
61
|
+
const root = ref();
|
|
62
|
+
const dragStatus = ref();
|
|
63
|
+
const touch = useTouch();
|
|
64
|
+
const marksList = computed(() => {
|
|
65
|
+
const { marks, max, min } = props;
|
|
66
|
+
const marksKeys = Object.keys(marks);
|
|
67
|
+
const list = marksKeys.map(parseFloat).sort((a, b) => a - b).filter((point) => point >= min && point <= max);
|
|
68
|
+
return list;
|
|
69
|
+
});
|
|
70
|
+
const scope = computed(() => Number(props.max) - Number(props.min));
|
|
71
|
+
const classes = computed(() => {
|
|
72
|
+
const prefixCls = componentName;
|
|
73
|
+
return {
|
|
74
|
+
[prefixCls]: true,
|
|
75
|
+
[`${prefixCls}-disabled`]: props.disabled,
|
|
76
|
+
[`${prefixCls}-vertical`]: props.vertical,
|
|
77
|
+
[`${prefixCls}-show-number`]: !props.hiddenRange
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
const containerClasses = computed(() => {
|
|
81
|
+
const prefixCls = "nut-range-container";
|
|
82
|
+
return {
|
|
83
|
+
[prefixCls]: true,
|
|
84
|
+
[`${prefixCls}-vertical`]: props.vertical
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
const wrapperStyle = computed(() => {
|
|
88
|
+
return {
|
|
89
|
+
background: props.inactiveColor
|
|
90
|
+
};
|
|
91
|
+
});
|
|
92
|
+
const buttonStyle = computed(() => {
|
|
93
|
+
return {
|
|
94
|
+
borderColor: props.buttonColor
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
const isRange = (val) => !!props.range && Array.isArray(val);
|
|
98
|
+
const calcMainAxis = () => {
|
|
99
|
+
const { modelValue, min } = props;
|
|
100
|
+
if (isRange(modelValue)) {
|
|
101
|
+
return `${(modelValue[1] - modelValue[0]) * 100 / scope.value}%`;
|
|
102
|
+
}
|
|
103
|
+
return `${(modelValue - Number(min)) * 100 / scope.value}%`;
|
|
104
|
+
};
|
|
105
|
+
const calcOffset = () => {
|
|
106
|
+
const { modelValue, min } = props;
|
|
107
|
+
if (isRange(modelValue)) {
|
|
108
|
+
return `${(modelValue[0] - Number(min)) * 100 / scope.value}%`;
|
|
109
|
+
}
|
|
110
|
+
return `0%`;
|
|
111
|
+
};
|
|
112
|
+
const barStyle = computed(() => {
|
|
113
|
+
if (props.vertical) {
|
|
114
|
+
return {
|
|
115
|
+
height: calcMainAxis(),
|
|
116
|
+
top: calcOffset(),
|
|
117
|
+
background: props.activeColor,
|
|
118
|
+
transition: dragStatus.value ? "none" : void 0
|
|
119
|
+
};
|
|
120
|
+
} else {
|
|
121
|
+
return {
|
|
122
|
+
width: calcMainAxis(),
|
|
123
|
+
left: calcOffset(),
|
|
124
|
+
background: props.activeColor,
|
|
125
|
+
transition: dragStatus.value ? "none" : void 0
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
const markClassName = (mark) => {
|
|
130
|
+
const classPrefix = "nut-range-mark";
|
|
131
|
+
const { modelValue, max, min } = props;
|
|
132
|
+
let lowerBound = Number(min);
|
|
133
|
+
let upperBound = Number(max);
|
|
134
|
+
if (props.range) {
|
|
135
|
+
const [left, right] = modelValue;
|
|
136
|
+
lowerBound = left;
|
|
137
|
+
upperBound = right;
|
|
138
|
+
} else {
|
|
139
|
+
upperBound = modelValue;
|
|
140
|
+
}
|
|
141
|
+
let isActive = mark <= upperBound && mark >= lowerBound;
|
|
142
|
+
return {
|
|
143
|
+
[`${classPrefix}-text`]: true,
|
|
144
|
+
[`${classPrefix}-text-active`]: isActive
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
const marksStyle = (mark) => {
|
|
148
|
+
const { max, min, vertical } = props;
|
|
149
|
+
let style = {
|
|
150
|
+
left: `${(mark - Number(min)) / scope.value * 100}%`
|
|
151
|
+
};
|
|
152
|
+
if (vertical) {
|
|
153
|
+
style = {
|
|
154
|
+
top: `${(mark - Number(min)) / scope.value * 100}%`
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
return style;
|
|
158
|
+
};
|
|
159
|
+
const tickStyle = (mark) => {
|
|
160
|
+
const { modelValue, max, min } = props;
|
|
161
|
+
let lowerBound = Number(min);
|
|
162
|
+
let upperBound = Number(max);
|
|
163
|
+
if (props.range) {
|
|
164
|
+
const [left, right] = modelValue;
|
|
165
|
+
lowerBound = left;
|
|
166
|
+
upperBound = right;
|
|
167
|
+
}
|
|
168
|
+
let isActive = mark <= upperBound && mark >= lowerBound;
|
|
169
|
+
let style = {
|
|
170
|
+
background: !isActive ? props.inactiveColor : props.activeColor
|
|
171
|
+
};
|
|
172
|
+
return style;
|
|
173
|
+
};
|
|
174
|
+
const format = (value) => {
|
|
175
|
+
const { min, max, step } = props;
|
|
176
|
+
value = Math.max(+min, Math.min(value, +max));
|
|
177
|
+
return Math.round(value / +step) * +step;
|
|
178
|
+
};
|
|
179
|
+
const isSameValue = (newValue, oldValue) => JSON.stringify(newValue) === JSON.stringify(oldValue);
|
|
180
|
+
const handleOverlap = (value) => {
|
|
181
|
+
if (value[0] > value[1]) {
|
|
182
|
+
return value.slice(0).reverse();
|
|
183
|
+
}
|
|
184
|
+
return value;
|
|
185
|
+
};
|
|
186
|
+
const updateValue = (value, end) => {
|
|
187
|
+
if (isRange(value)) {
|
|
188
|
+
value = handleOverlap(value).map(format);
|
|
189
|
+
} else {
|
|
190
|
+
value = format(value);
|
|
191
|
+
}
|
|
192
|
+
if (!isSameValue(value, props.modelValue)) {
|
|
193
|
+
emit("update:modelValue", value);
|
|
194
|
+
}
|
|
195
|
+
if (end && !isSameValue(value, startValue)) {
|
|
196
|
+
emit("change", value);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
const onClick = (event) => {
|
|
200
|
+
if (props.disabled) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
const { min, modelValue } = props;
|
|
204
|
+
const rect = useRect(root);
|
|
205
|
+
let delta = event.clientX - rect.left;
|
|
206
|
+
let total = rect.width;
|
|
207
|
+
if (props.vertical) {
|
|
208
|
+
delta = event.clientY - rect.top;
|
|
209
|
+
total = rect.height;
|
|
210
|
+
}
|
|
211
|
+
const value = Number(min) + delta / total * scope.value;
|
|
212
|
+
if (isRange(modelValue)) {
|
|
213
|
+
const [left, right] = modelValue;
|
|
214
|
+
const middle = (left + right) / 2;
|
|
215
|
+
if (value <= middle) {
|
|
216
|
+
updateValue([value, right], true);
|
|
217
|
+
} else {
|
|
218
|
+
updateValue([left, value], true);
|
|
219
|
+
}
|
|
220
|
+
} else {
|
|
221
|
+
updateValue(value, true);
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
const onTouchStart = (event) => {
|
|
225
|
+
if (props.disabled) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
touch.start(event);
|
|
229
|
+
currentValue = props.modelValue;
|
|
230
|
+
if (isRange(currentValue)) {
|
|
231
|
+
startValue = currentValue.map(format);
|
|
232
|
+
} else {
|
|
233
|
+
startValue = format(currentValue);
|
|
234
|
+
}
|
|
235
|
+
dragStatus.value = "start";
|
|
236
|
+
};
|
|
237
|
+
const onTouchMove = (event) => {
|
|
238
|
+
if (props.disabled) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
if (dragStatus.value === "start") {
|
|
242
|
+
emit("drag-start");
|
|
243
|
+
}
|
|
244
|
+
touch.move(event);
|
|
245
|
+
dragStatus.value = "draging";
|
|
246
|
+
const rect = useRect(root);
|
|
247
|
+
let delta = touch.deltaX.value;
|
|
248
|
+
let total = rect.width;
|
|
249
|
+
let diff = delta / total * scope.value;
|
|
250
|
+
if (props.vertical) {
|
|
251
|
+
delta = touch.deltaY.value;
|
|
252
|
+
total = rect.height;
|
|
253
|
+
diff = delta / total * scope.value;
|
|
254
|
+
}
|
|
255
|
+
if (isRange(startValue)) {
|
|
256
|
+
currentValue[buttonIndex.value] = startValue[buttonIndex.value] + diff;
|
|
257
|
+
} else {
|
|
258
|
+
currentValue = startValue + diff;
|
|
259
|
+
}
|
|
260
|
+
updateValue(currentValue);
|
|
261
|
+
event.stopPropagation();
|
|
262
|
+
event.preventDefault();
|
|
263
|
+
};
|
|
264
|
+
const onTouchEnd = () => {
|
|
265
|
+
if (props.disabled) {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
if (dragStatus.value === "draging") {
|
|
269
|
+
updateValue(currentValue, true);
|
|
270
|
+
emit("drag-end");
|
|
271
|
+
}
|
|
272
|
+
dragStatus.value = "";
|
|
273
|
+
};
|
|
274
|
+
const curValue = (idx) => {
|
|
275
|
+
const value = typeof idx === "number" ? props.modelValue[idx] : props.modelValue;
|
|
276
|
+
return value;
|
|
277
|
+
};
|
|
278
|
+
return {
|
|
279
|
+
root,
|
|
280
|
+
classes,
|
|
281
|
+
wrapperStyle,
|
|
282
|
+
buttonStyle,
|
|
283
|
+
onClick,
|
|
284
|
+
onTouchStart,
|
|
285
|
+
onTouchMove,
|
|
286
|
+
onTouchEnd,
|
|
287
|
+
...toRefs(props),
|
|
288
|
+
barStyle,
|
|
289
|
+
curValue,
|
|
290
|
+
buttonIndex,
|
|
291
|
+
containerClasses,
|
|
292
|
+
markClassName,
|
|
293
|
+
marksStyle,
|
|
294
|
+
marksList,
|
|
295
|
+
tickStyle
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
const _hoisted_1 = {
|
|
300
|
+
key: 0,
|
|
301
|
+
class: "min"
|
|
302
|
+
};
|
|
303
|
+
const _hoisted_2 = {
|
|
304
|
+
key: 0,
|
|
305
|
+
class: "nut-range-mark"
|
|
306
|
+
};
|
|
307
|
+
const _hoisted_3 = ["tabindex", "aria-valuemin", "aria-valuenow", "aria-valuemax", "onTouchstart"];
|
|
308
|
+
const _hoisted_4 = {
|
|
309
|
+
key: 0,
|
|
310
|
+
class: "number"
|
|
311
|
+
};
|
|
312
|
+
const _hoisted_5 = ["tabindex", "aria-valuemin", "aria-valuenow", "aria-valuemax"];
|
|
313
|
+
const _hoisted_6 = {
|
|
314
|
+
key: 0,
|
|
315
|
+
class: "number"
|
|
316
|
+
};
|
|
317
|
+
const _hoisted_7 = {
|
|
318
|
+
key: 1,
|
|
319
|
+
class: "max"
|
|
320
|
+
};
|
|
321
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
322
|
+
return openBlock(), createElementBlock("view", {
|
|
323
|
+
class: normalizeClass(_ctx.containerClasses)
|
|
324
|
+
}, [
|
|
325
|
+
!_ctx.hiddenRange ? (openBlock(), createElementBlock("view", _hoisted_1, toDisplayString(+_ctx.min), 1)) : createCommentVNode("", true),
|
|
326
|
+
createElementVNode("view", {
|
|
327
|
+
ref: "root",
|
|
328
|
+
style: normalizeStyle(_ctx.wrapperStyle),
|
|
329
|
+
class: normalizeClass(_ctx.classes),
|
|
330
|
+
onClick: _cache[9] || (_cache[9] = withModifiers((...args) => _ctx.onClick && _ctx.onClick(...args), ["stop"]))
|
|
331
|
+
}, [
|
|
332
|
+
_ctx.marksList.length > 0 ? (openBlock(), createElementBlock("view", _hoisted_2, [
|
|
333
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.marksList, (marks) => {
|
|
334
|
+
return openBlock(), createElementBlock("span", {
|
|
335
|
+
key: marks,
|
|
336
|
+
class: normalizeClass(_ctx.markClassName(marks)),
|
|
337
|
+
style: normalizeStyle(_ctx.marksStyle(marks))
|
|
338
|
+
}, [
|
|
339
|
+
createTextVNode(toDisplayString(marks) + " ", 1),
|
|
340
|
+
createElementVNode("span", {
|
|
341
|
+
class: "nut-range-tick",
|
|
342
|
+
style: normalizeStyle(_ctx.tickStyle(marks))
|
|
343
|
+
}, null, 4)
|
|
344
|
+
], 6);
|
|
345
|
+
}), 128))
|
|
346
|
+
])) : createCommentVNode("", true),
|
|
347
|
+
createElementVNode("view", {
|
|
348
|
+
class: "nut-range-bar",
|
|
349
|
+
style: normalizeStyle(_ctx.barStyle)
|
|
350
|
+
}, [
|
|
351
|
+
_ctx.range ? (openBlock(), createElementBlock(Fragment, { key: 0 }, renderList([0, 1], (index2) => {
|
|
352
|
+
return createElementVNode("view", {
|
|
353
|
+
key: index2,
|
|
354
|
+
role: "slider",
|
|
355
|
+
class: normalizeClass({
|
|
356
|
+
"nut-range-button-wrapper-left": index2 == 0,
|
|
357
|
+
"nut-range-button-wrapper-right": index2 == 1
|
|
358
|
+
}),
|
|
359
|
+
tabindex: _ctx.disabled ? -1 : 0,
|
|
360
|
+
"aria-valuemin": +_ctx.min,
|
|
361
|
+
"aria-valuenow": _ctx.curValue(index2),
|
|
362
|
+
"aria-valuemax": +_ctx.max,
|
|
363
|
+
"aria-orientation": "horizontal",
|
|
364
|
+
onTouchstart: withModifiers((e) => {
|
|
365
|
+
if (typeof index2 === "number") {
|
|
366
|
+
_ctx.buttonIndex = index2;
|
|
367
|
+
}
|
|
368
|
+
_ctx.onTouchStart(e);
|
|
369
|
+
}, ["stop", "prevent"]),
|
|
370
|
+
onTouchmove: _cache[0] || (_cache[0] = withModifiers((...args) => _ctx.onTouchMove && _ctx.onTouchMove(...args), ["stop", "prevent"])),
|
|
371
|
+
onTouchend: _cache[1] || (_cache[1] = withModifiers((...args) => _ctx.onTouchEnd && _ctx.onTouchEnd(...args), ["stop", "prevent"])),
|
|
372
|
+
onTouchcancel: _cache[2] || (_cache[2] = withModifiers((...args) => _ctx.onTouchEnd && _ctx.onTouchEnd(...args), ["stop", "prevent"])),
|
|
373
|
+
onClick: _cache[3] || (_cache[3] = (e) => e.stopPropagation())
|
|
374
|
+
}, [
|
|
375
|
+
_ctx.$slots.button ? renderSlot(_ctx.$slots, "button", { key: 0 }) : (openBlock(), createElementBlock("view", {
|
|
376
|
+
key: 1,
|
|
377
|
+
class: "nut-range-button",
|
|
378
|
+
style: normalizeStyle(_ctx.buttonStyle)
|
|
379
|
+
}, [
|
|
380
|
+
!_ctx.hiddenTag ? (openBlock(), createElementBlock("view", _hoisted_4, toDisplayString(_ctx.curValue(index2)), 1)) : createCommentVNode("", true)
|
|
381
|
+
], 4))
|
|
382
|
+
], 42, _hoisted_3);
|
|
383
|
+
}), 64)) : (openBlock(), createElementBlock("view", {
|
|
384
|
+
key: 1,
|
|
385
|
+
role: "slider",
|
|
386
|
+
class: "nut-range-button-wrapper",
|
|
387
|
+
tabindex: _ctx.disabled ? -1 : 0,
|
|
388
|
+
"aria-valuemin": +_ctx.min,
|
|
389
|
+
"aria-valuenow": _ctx.curValue(),
|
|
390
|
+
"aria-valuemax": +_ctx.max,
|
|
391
|
+
"aria-orientation": "horizontal",
|
|
392
|
+
onTouchstart: _cache[4] || (_cache[4] = withModifiers((e) => {
|
|
393
|
+
_ctx.onTouchStart(e);
|
|
394
|
+
}, ["stop", "prevent"])),
|
|
395
|
+
onTouchmove: _cache[5] || (_cache[5] = withModifiers((...args) => _ctx.onTouchMove && _ctx.onTouchMove(...args), ["stop", "prevent"])),
|
|
396
|
+
onTouchend: _cache[6] || (_cache[6] = withModifiers((...args) => _ctx.onTouchEnd && _ctx.onTouchEnd(...args), ["stop", "prevent"])),
|
|
397
|
+
onTouchcancel: _cache[7] || (_cache[7] = withModifiers((...args) => _ctx.onTouchEnd && _ctx.onTouchEnd(...args), ["stop", "prevent"])),
|
|
398
|
+
onClick: _cache[8] || (_cache[8] = (e) => e.stopPropagation())
|
|
399
|
+
}, [
|
|
400
|
+
_ctx.$slots.button ? renderSlot(_ctx.$slots, "button", { key: 0 }) : (openBlock(), createElementBlock("view", {
|
|
401
|
+
key: 1,
|
|
402
|
+
class: "nut-range-button",
|
|
403
|
+
style: normalizeStyle(_ctx.buttonStyle)
|
|
404
|
+
}, [
|
|
405
|
+
!_ctx.hiddenTag ? (openBlock(), createElementBlock("view", _hoisted_6, toDisplayString(_ctx.curValue()), 1)) : createCommentVNode("", true)
|
|
406
|
+
], 4))
|
|
407
|
+
], 40, _hoisted_5))
|
|
408
|
+
], 4)
|
|
409
|
+
], 6),
|
|
410
|
+
!_ctx.hiddenRange ? (openBlock(), createElementBlock("view", _hoisted_7, toDisplayString(+_ctx.max), 1)) : createCommentVNode("", true)
|
|
411
|
+
], 2);
|
|
412
|
+
}
|
|
413
|
+
var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
414
|
+
export { index as default };
|