@nutui/nutui 4.0.12-beta.1 → 4.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/dist/nutui.es.js +1 -1
  2. package/dist/nutui.js +1 -1
  3. package/dist/nutui.umd.js +1 -1
  4. package/dist/packages/_es/ActionSheet.js +111 -78
  5. package/dist/packages/_es/Address.js +375 -250
  6. package/dist/packages/_es/AddressList.js +354 -269
  7. package/dist/packages/_es/Animate.js +58 -41
  8. package/dist/packages/_es/Audio.js +197 -128
  9. package/dist/packages/_es/AudioOperate.js +71 -60
  10. package/dist/packages/_es/Avatar.js +89 -66
  11. package/dist/packages/_es/AvatarGroup.js +31 -23
  12. package/dist/packages/_es/Backtop.js +99 -59
  13. package/dist/packages/_es/Badge.js +47 -36
  14. package/dist/packages/_es/Barrage.js +147 -68
  15. package/dist/packages/_es/Button.js +66 -47
  16. package/dist/packages/_es/Calendar.js +157 -135
  17. package/dist/packages/_es/CalendarItem.js +6 -6
  18. package/dist/packages/_es/Card.js +56 -42
  19. package/dist/packages/_es/Cascader.js +474 -315
  20. package/dist/packages/_es/Category.js +39 -29
  21. package/dist/packages/_es/CategoryPane.js +83 -57
  22. package/dist/packages/_es/Cell.js +71 -56
  23. package/dist/packages/_es/CellGroup.js +27 -19
  24. package/dist/packages/_es/Checkbox.js +156 -109
  25. package/dist/packages/_es/CheckboxGroup.js +59 -38
  26. package/dist/packages/_es/CircleProgress.js +96 -67
  27. package/dist/packages/_es/Col.js +31 -23
  28. package/dist/packages/_es/Collapse.js +58 -33
  29. package/dist/packages/_es/CollapseItem.js +108 -78
  30. package/dist/packages/_es/Comment.js +279 -207
  31. package/dist/packages/_es/ConfigProvider.js +55 -37
  32. package/dist/packages/_es/Countdown.js +212 -100
  33. package/dist/packages/_es/Countup.js +445 -232
  34. package/dist/packages/_es/DatePicker.js +265 -162
  35. package/dist/packages/_es/Dialog.js +213 -161
  36. package/dist/packages/_es/Divider.js +57 -42
  37. package/dist/packages/_es/Drag.js +153 -70
  38. package/dist/packages/_es/Ecard.js +104 -64
  39. package/dist/packages/_es/Elevator.js +219 -143
  40. package/dist/packages/_es/Ellipsis.js +178 -95
  41. package/dist/packages/_es/Empty.js +39 -23
  42. package/dist/packages/_es/FixedNav.js +116 -93
  43. package/dist/packages/_es/Form.js +178 -107
  44. package/dist/packages/_es/FormItem.js +61 -48
  45. package/dist/packages/_es/Grid.js +6 -5
  46. package/dist/packages/_es/GridItem.js +84 -58
  47. package/dist/packages/_es/Image.js +130 -90
  48. package/dist/packages/_es/ImagePreview.js +412 -256
  49. package/dist/packages/_es/Indicator.js +34 -30
  50. package/dist/packages/_es/InfiniteLoading.js +136 -83
  51. package/dist/packages/_es/Input.js +264 -160
  52. package/dist/packages/_es/InputNumber.js +117 -81
  53. package/dist/packages/_es/Interceptor-956b24fc.js +29 -0
  54. package/dist/packages/_es/Invoice.js +130 -104
  55. package/dist/packages/_es/Layout.js +4 -3
  56. package/dist/packages/_es/List.js +215 -117
  57. package/dist/packages/_es/Menu.js +150 -95
  58. package/dist/packages/_es/MenuItem.js +154 -109
  59. package/dist/packages/_es/Navbar.js +119 -103
  60. package/dist/packages/_es/Noticebar.js +312 -197
  61. package/dist/packages/_es/Notify.js +166 -110
  62. package/dist/packages/_es/NumberKeyboard.js +202 -127
  63. package/dist/packages/_es/Overlay.js +80 -52
  64. package/dist/packages/_es/Pagination.js +100 -70
  65. package/dist/packages/_es/Picker.js +437 -275
  66. package/dist/packages/_es/Popover.js +225 -122
  67. package/dist/packages/_es/Popup.js +4 -4
  68. package/dist/packages/_es/Price.js +82 -44
  69. package/dist/packages/_es/Progress.js +79 -63
  70. package/dist/packages/_es/PullRefresh.js +173 -95
  71. package/dist/packages/_es/Radio.js +4 -4
  72. package/dist/packages/_es/RadioGroup.js +3 -3
  73. package/dist/packages/_es/Range.js +347 -204
  74. package/dist/packages/_es/Rate.js +141 -92
  75. package/dist/packages/_es/Row.js +27 -21
  76. package/dist/packages/_es/Searchbar.js +174 -123
  77. package/dist/packages/_es/ShortPassword.js +93 -69
  78. package/dist/packages/_es/SideNavbar.js +80 -49
  79. package/dist/packages/_es/SideNavbarItem.js +32 -22
  80. package/dist/packages/_es/Signature.js +146 -83
  81. package/dist/packages/_es/Skeleton.js +130 -110
  82. package/dist/packages/_es/Sku.js +343 -250
  83. package/dist/packages/_es/Step.js +86 -59
  84. package/dist/packages/_es/Steps.js +31 -26
  85. package/dist/packages/_es/Sticky.js +4 -4
  86. package/dist/packages/_es/SubSideNavbar.js +74 -52
  87. package/dist/packages/_es/Swipe.js +155 -83
  88. package/dist/packages/_es/Swiper.js +311 -174
  89. package/dist/packages/_es/SwiperItem.js +44 -28
  90. package/dist/packages/_es/Switch.js +68 -55
  91. package/dist/packages/_es/TabPane.js +41 -30
  92. package/dist/packages/_es/Tabbar.js +52 -41
  93. package/dist/packages/_es/TabbarItem.js +82 -61
  94. package/dist/packages/_es/Table.js +165 -109
  95. package/dist/packages/_es/Tabs.js +388 -240
  96. package/dist/packages/_es/Tag.js +61 -44
  97. package/dist/packages/_es/Textarea.js +124 -80
  98. package/dist/packages/_es/TimeDetail.js +76 -49
  99. package/dist/packages/_es/TimePannel.js +48 -34
  100. package/dist/packages/_es/TimeSelect.js +68 -47
  101. package/dist/packages/_es/Toast.js +218 -144
  102. package/dist/packages/_es/Tour.js +192 -138
  103. package/dist/packages/_es/TrendArrow.js +77 -57
  104. package/dist/packages/_es/Uploader.js +359 -234
  105. package/dist/packages/_es/Video.js +316 -191
  106. package/dist/packages/_es/Watermark.js +117 -84
  107. package/dist/packages/_es/_plugin-vue_export-helper-cc2b3d55.js +10 -0
  108. package/dist/packages/_es/common-b9a5e726.js +145 -0
  109. package/dist/packages/_es/component-81a4c1d0.js +145 -0
  110. package/dist/packages/_es/index-29892cda.js +33 -0
  111. package/dist/packages/_es/index-43c34ac6.js +30 -0
  112. package/dist/packages/_es/index-54d03fc1.js +8 -0
  113. package/dist/packages/_es/index-79c5dc33.js +10 -0
  114. package/dist/packages/_es/index-7a7385e4.js +67 -0
  115. package/dist/packages/_es/index-87422be8.js +942 -0
  116. package/dist/packages/_es/index-da0a7662.js +259 -0
  117. package/dist/packages/_es/index.vue_vue_type_script_lang-22dfc112.js +46 -0
  118. package/dist/packages/_es/index.vue_vue_type_script_lang-a8856969.js +97 -0
  119. package/dist/packages/_es/index.vue_vue_type_script_lang-cc5c4086.js +151 -0
  120. package/dist/packages/_es/mountComponent-8b24c346.js +39 -0
  121. package/dist/packages/_es/pxCheck-c6b9f6b7.js +6 -0
  122. package/dist/packages/_es/raf-729dad54.js +25 -0
  123. package/dist/packages/_es/renderIcon-3d0fd47c.js +9 -0
  124. package/dist/packages/locale/lang/baseLang-3a8457ac.js +5 -0
  125. package/dist/packages/locale/lang/en-US.js +39 -36
  126. package/dist/packages/locale/lang/id-ID.js +39 -36
  127. package/dist/packages/locale/lang/index.js +44 -22
  128. package/dist/packages/locale/lang/zh-CN.js +38 -35
  129. package/dist/packages/locale/lang/zh-TW.js +38 -35
  130. package/dist/resolver/index.js +26 -1
  131. package/dist/resolver/index.mjs +17 -14
  132. package/dist/smartips/web-types.json +1 -1
  133. package/dist/style.css +1 -1
  134. package/dist/styles/themes/default.scss +50 -50
  135. package/dist/styles/themes/jdb.scss +50 -50
  136. package/dist/styles/themes/jddkh.scss +50 -50
  137. package/dist/styles/themes/jdt.scss +50 -50
  138. package/dist/types/index.d.ts +1 -1
  139. package/package.json +2 -2
  140. package/dist/packages/_es/Interceptor-6e26b757.js +0 -18
  141. package/dist/packages/_es/_plugin-vue_export-helper-dad06003.js +0 -9
  142. package/dist/packages/_es/common-d218746f.js +0 -116
  143. package/dist/packages/_es/component-234624bc.js +0 -89
  144. package/dist/packages/_es/index-14dfadc4.js +0 -561
  145. package/dist/packages/_es/index-192a3ef6.js +0 -29
  146. package/dist/packages/_es/index-360c5092.js +0 -210
  147. package/dist/packages/_es/index-496e6e05.js +0 -24
  148. package/dist/packages/_es/index-50eed3d9.js +0 -7
  149. package/dist/packages/_es/index-53ec2d4d.js +0 -34
  150. package/dist/packages/_es/index-fadb0974.js +0 -8
  151. package/dist/packages/_es/index.vue_vue_type_script_lang-1139b29a.js +0 -43
  152. package/dist/packages/_es/index.vue_vue_type_script_lang-43b774dd.js +0 -77
  153. package/dist/packages/_es/index.vue_vue_type_script_lang-f44c159d.js +0 -110
  154. package/dist/packages/_es/mountComponent-6d4ff200.js +0 -23
  155. package/dist/packages/_es/pxCheck-38173291.js +0 -4
  156. package/dist/packages/_es/raf-a74f1a06.js +0 -16
  157. package/dist/packages/_es/renderIcon-47498b32.js +0 -5
  158. package/dist/packages/locale/lang/baseLang-0bdc6353.js +0 -5
@@ -1,26 +1,34 @@
1
- var oe = Object.defineProperty, re = Object.defineProperties;
2
- var le = Object.getOwnPropertyDescriptors;
3
- var L = Object.getOwnPropertySymbols;
4
- var ue = Object.prototype.hasOwnProperty, ie = Object.prototype.propertyIsEnumerable;
5
- var P = (e, n, u) => n in e ? oe(e, n, { enumerable: !0, configurable: !0, writable: !0, value: u }) : e[n] = u, j = (e, n) => {
6
- for (var u in n || (n = {}))
7
- ue.call(n, u) && P(e, u, n[u]);
8
- if (L)
9
- for (var u of L(n))
10
- ie.call(n, u) && P(e, u, n[u]);
11
- return e;
12
- }, D = (e, n) => re(e, le(n));
13
- import { ref as A, computed as h, toRefs as se, openBlock as m, createElementBlock as c, normalizeClass as E, toDisplayString as N, createCommentVNode as $, createElementVNode as M, normalizeStyle as w, withModifiers as g, Fragment as F, renderList as I, createTextVNode as de, renderSlot as J } from "vue";
14
- import { c as me, i as ce } from "./component-234624bc.js";
15
- import { u as fe } from "./index-53ec2d4d.js";
16
- import { u as K } from "./index-192a3ef6.js";
17
- import { _ as ve } from "./_plugin-vue_export-helper-dad06003.js";
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ import { ref, computed, toRefs, openBlock, createElementBlock, normalizeClass, toDisplayString, createCommentVNode, createElementVNode, normalizeStyle, withModifiers, Fragment, renderList, createTextVNode, renderSlot } from "vue";
21
+ import { c as createComponent, i as isArray } from "./component-81a4c1d0.js";
22
+ import { u as useTouch } from "./index-7a7385e4.js";
23
+ import { u as useRect } from "./index-29892cda.js";
24
+ import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js";
18
25
  import "../locale/lang";
19
- const { componentName: ge, create: be } = me("range"), ye = be({
26
+ const { componentName, create } = createComponent("range");
27
+ const _sfc_main = create({
20
28
  props: {
21
29
  range: {
22
30
  type: Boolean,
23
- default: !1
31
+ default: false
24
32
  },
25
33
  disabled: Boolean,
26
34
  activeColor: String,
@@ -28,7 +36,7 @@ const { componentName: ge, create: be } = me("range"), ye = be({
28
36
  buttonColor: String,
29
37
  vertical: {
30
38
  type: Boolean,
31
- default: !1
39
+ default: false
32
40
  },
33
41
  marks: {
34
42
  type: Object,
@@ -36,11 +44,11 @@ const { componentName: ge, create: be } = me("range"), ye = be({
36
44
  },
37
45
  hiddenRange: {
38
46
  type: Boolean,
39
- default: !1
47
+ default: false
40
48
  },
41
49
  hiddenTag: {
42
50
  type: Boolean,
43
- default: !1
51
+ default: false
44
52
  },
45
53
  min: {
46
54
  type: [Number, String],
@@ -60,234 +68,369 @@ const { componentName: ge, create: be } = me("range"), ye = be({
60
68
  }
61
69
  },
62
70
  emits: ["change", "drag-end", "drag-start", "update:modelValue"],
63
- setup(e, { emit: n }) {
64
- const u = A(0);
65
- let y, v;
66
- const p = A(), a = A(), i = fe(), X = h(() => {
67
- const { marks: t, max: o, min: l } = e;
68
- return Object.keys(t).map(parseFloat).sort((s, f) => s - f).filter((s) => s >= l && s <= o);
69
- }), b = h(() => Number(e.max) - Number(e.min)), Y = h(() => {
70
- const t = ge;
71
+ setup(props, { emit }) {
72
+ const buttonIndex = ref(0);
73
+ let startValue;
74
+ let currentValue;
75
+ const root = ref();
76
+ const dragStatus = ref();
77
+ const touch = useTouch();
78
+ const marksList = computed(() => {
79
+ const { marks, max, min } = props;
80
+ const marksKeys = Object.keys(marks);
81
+ const list = marksKeys.map(parseFloat).sort((a, b) => a - b).filter((point) => point >= min && point <= max);
82
+ return list;
83
+ });
84
+ const scope = computed(() => Number(props.max) - Number(props.min));
85
+ const classes = computed(() => {
86
+ const prefixCls = componentName;
71
87
  return {
72
- [t]: !0,
73
- [`${t}-disabled`]: e.disabled,
74
- [`${t}-vertical`]: e.vertical,
75
- [`${t}-show-number`]: !e.hiddenRange
88
+ [prefixCls]: true,
89
+ [`${prefixCls}-disabled`]: props.disabled,
90
+ [`${prefixCls}-vertical`]: props.vertical,
91
+ [`${prefixCls}-show-number`]: !props.hiddenRange
76
92
  };
77
- }), q = h(() => {
78
- const t = "nut-range-container";
93
+ });
94
+ const containerClasses = computed(() => {
95
+ const prefixCls = "nut-range-container";
79
96
  return {
80
- [t]: !0,
81
- [`${t}-vertical`]: e.vertical
97
+ [prefixCls]: true,
98
+ [`${prefixCls}-vertical`]: props.vertical
82
99
  };
83
- }), G = h(() => ({
84
- background: e.inactiveColor
85
- })), H = h(() => ({
86
- borderColor: e.buttonColor
87
- })), k = (t) => !!e.range && Array.isArray(t), R = () => {
88
- const { modelValue: t, min: o } = e;
89
- return k(t) ? `${(t[1] - t[0]) * 100 / b.value}%` : `${(t - Number(o)) * 100 / b.value}%`;
90
- }, O = () => {
91
- const { modelValue: t, min: o } = e;
92
- return k(t) ? `${(t[0] - Number(o)) * 100 / b.value}%` : "0%";
93
- }, Q = h(() => e.vertical ? {
94
- height: R(),
95
- top: O(),
96
- background: e.activeColor,
97
- transition: a.value ? "none" : void 0
98
- } : {
99
- width: R(),
100
- left: O(),
101
- background: e.activeColor,
102
- transition: a.value ? "none" : void 0
103
- }), U = (t) => {
104
- const o = "nut-range-mark", { modelValue: l, max: r, min: d } = e;
105
- let s = Number(d), f = Number(r);
106
- if (e.range) {
107
- const [T, V] = l;
108
- s = T, f = V;
109
- } else
110
- f = l;
111
- let C = t <= f && t >= s;
100
+ });
101
+ const wrapperStyle = computed(() => {
112
102
  return {
113
- [`${o}-text`]: !0,
114
- [`${o}-text-active`]: C
103
+ background: props.inactiveColor
115
104
  };
116
- }, W = (t) => {
117
- const { min: o, vertical: l } = e;
118
- let r = {
119
- left: `${(t - Number(o)) / b.value * 100}%`
105
+ });
106
+ const buttonStyle = computed(() => {
107
+ return {
108
+ borderColor: props.buttonColor
120
109
  };
121
- return l && (r = {
122
- top: `${(t - Number(o)) / b.value * 100}%`
123
- }), r;
124
- }, Z = (t) => {
125
- const { modelValue: o, max: l, min: r } = e;
126
- let d = Number(r), s = Number(l);
127
- if (e.range) {
128
- const [T, V] = o;
129
- d = T, s = V;
110
+ });
111
+ const isRange = (val) => !!props.range && Array.isArray(val);
112
+ const calcMainAxis = () => {
113
+ const { modelValue, min } = props;
114
+ if (isRange(modelValue)) {
115
+ return `${(modelValue[1] - modelValue[0]) * 100 / scope.value}%`;
116
+ }
117
+ return `${(modelValue - Number(min)) * 100 / scope.value}%`;
118
+ };
119
+ const calcOffset = () => {
120
+ const { modelValue, min } = props;
121
+ if (isRange(modelValue)) {
122
+ return `${(modelValue[0] - Number(min)) * 100 / scope.value}%`;
123
+ }
124
+ return `0%`;
125
+ };
126
+ const barStyle = computed(() => {
127
+ if (props.vertical) {
128
+ return {
129
+ height: calcMainAxis(),
130
+ top: calcOffset(),
131
+ background: props.activeColor,
132
+ transition: dragStatus.value ? "none" : void 0
133
+ };
134
+ } else {
135
+ return {
136
+ width: calcMainAxis(),
137
+ left: calcOffset(),
138
+ background: props.activeColor,
139
+ transition: dragStatus.value ? "none" : void 0
140
+ };
141
+ }
142
+ });
143
+ const markClassName = (mark) => {
144
+ const classPrefix = "nut-range-mark";
145
+ const { modelValue, max, min } = props;
146
+ let lowerBound = Number(min);
147
+ let upperBound = Number(max);
148
+ if (props.range) {
149
+ const [left, right] = modelValue;
150
+ lowerBound = left;
151
+ upperBound = right;
152
+ } else {
153
+ upperBound = modelValue;
130
154
  }
155
+ let isActive = mark <= upperBound && mark >= lowerBound;
131
156
  return {
132
- background: t <= s && t >= d ? e.activeColor : e.inactiveColor
157
+ [`${classPrefix}-text`]: true,
158
+ [`${classPrefix}-text-active`]: isActive
133
159
  };
134
- }, B = (t) => {
135
- const { min: o, max: l, step: r } = e;
136
- return t = Math.max(+o, Math.min(t, +l)), Math.round(t / +r) * +r;
137
- }, z = (t, o) => JSON.stringify(t) === JSON.stringify(o), x = (t) => t[0] > t[1] ? t.slice(0).reverse() : t, S = (t, o) => {
138
- k(t) ? t = x(t).map(B) : t = B(t), z(t, e.modelValue) || n("update:modelValue", t), o && !z(t, y) && n("change", t);
139
- }, _ = (t) => {
140
- if (e.disabled)
160
+ };
161
+ const marksStyle = (mark) => {
162
+ const { min, vertical } = props;
163
+ let style = {
164
+ left: `${(mark - Number(min)) / scope.value * 100}%`
165
+ };
166
+ if (vertical) {
167
+ style = {
168
+ top: `${(mark - Number(min)) / scope.value * 100}%`
169
+ };
170
+ }
171
+ return style;
172
+ };
173
+ const tickStyle = (mark) => {
174
+ const { modelValue, max, min } = props;
175
+ let lowerBound = Number(min);
176
+ let upperBound = Number(max);
177
+ if (props.range) {
178
+ const [left, right] = modelValue;
179
+ lowerBound = left;
180
+ upperBound = right;
181
+ }
182
+ let isActive = mark <= upperBound && mark >= lowerBound;
183
+ let style = {
184
+ background: !isActive ? props.inactiveColor : props.activeColor
185
+ };
186
+ return style;
187
+ };
188
+ const format = (value) => {
189
+ const { min, max, step } = props;
190
+ value = Math.max(+min, Math.min(value, +max));
191
+ return Math.round(value / +step) * +step;
192
+ };
193
+ const isSameValue = (newValue, oldValue) => JSON.stringify(newValue) === JSON.stringify(oldValue);
194
+ const handleOverlap = (value) => {
195
+ if (value[0] > value[1]) {
196
+ return value.slice(0).reverse();
197
+ }
198
+ return value;
199
+ };
200
+ const updateValue = (value, end) => {
201
+ if (isRange(value)) {
202
+ value = handleOverlap(value).map(format);
203
+ } else {
204
+ value = format(value);
205
+ }
206
+ if (!isSameValue(value, props.modelValue)) {
207
+ emit("update:modelValue", value);
208
+ }
209
+ if (end && !isSameValue(value, startValue)) {
210
+ emit("change", value);
211
+ }
212
+ };
213
+ const onClick = (event) => {
214
+ if (props.disabled) {
141
215
  return;
142
- const { min: o, modelValue: l } = e, r = K(p);
143
- let d = t.clientX - r.left, s = r.width;
144
- e.vertical && (d = t.clientY - r.top, s = r.height);
145
- const f = Number(o) + d / s * b.value;
146
- if (k(l)) {
147
- const [C, T] = l, V = (C + T) / 2;
148
- f <= V ? S([f, T], !0) : S([C, f], !0);
149
- } else
150
- S(f, !0);
151
- }, ee = (t) => {
152
- e.disabled || (i.start(t), v = e.modelValue, k(v) ? y = v.map(B) : y = B(v), a.value = "start");
153
- }, te = (t) => {
154
- if (e.disabled)
216
+ }
217
+ const { min, modelValue } = props;
218
+ const rect = useRect(root);
219
+ let delta = event.clientX - rect.left;
220
+ let total = rect.width;
221
+ if (props.vertical) {
222
+ delta = event.clientY - rect.top;
223
+ total = rect.height;
224
+ }
225
+ const value = Number(min) + delta / total * scope.value;
226
+ if (isRange(modelValue)) {
227
+ const [left, right] = modelValue;
228
+ const middle = (left + right) / 2;
229
+ if (value <= middle) {
230
+ updateValue([value, right], true);
231
+ } else {
232
+ updateValue([left, value], true);
233
+ }
234
+ } else {
235
+ updateValue(value, true);
236
+ }
237
+ };
238
+ const onTouchStart = (event) => {
239
+ if (props.disabled) {
155
240
  return;
156
- a.value === "start" && n("drag-start"), i.move(t), a.value = "draging";
157
- const o = K(p);
158
- let l = i.deltaX.value, r = o.width, d = l / r * b.value;
159
- e.vertical && (l = i.deltaY.value, r = o.height, d = l / r * b.value), k(y) ? v[u.value] = y[u.value] + d : v = y + d, S(v), t.stopPropagation(), t.preventDefault();
160
- }, ne = () => {
161
- e.disabled || (a.value === "draging" && (S(v, !0), n("drag-end")), a.value = "");
162
- }, ae = (t) => ce(e.modelValue) && typeof t == "number" ? e.modelValue[t] : Number(e.modelValue);
163
- return D(j({
164
- root: p,
165
- classes: Y,
166
- wrapperStyle: G,
167
- buttonStyle: H,
168
- onClick: _,
169
- onTouchStart: ee,
170
- onTouchMove: te,
171
- onTouchEnd: ne
172
- }, se(e)), {
173
- barStyle: Q,
174
- curValue: ae,
175
- buttonIndex: u,
176
- containerClasses: q,
177
- markClassName: U,
178
- marksStyle: W,
179
- marksList: X,
180
- tickStyle: Z
241
+ }
242
+ touch.start(event);
243
+ currentValue = props.modelValue;
244
+ if (isRange(currentValue)) {
245
+ startValue = currentValue.map(format);
246
+ } else {
247
+ startValue = format(currentValue);
248
+ }
249
+ dragStatus.value = "start";
250
+ };
251
+ const onTouchMove = (event) => {
252
+ if (props.disabled) {
253
+ return;
254
+ }
255
+ if (dragStatus.value === "start") {
256
+ emit("drag-start");
257
+ }
258
+ touch.move(event);
259
+ dragStatus.value = "draging";
260
+ const rect = useRect(root);
261
+ let delta = touch.deltaX.value;
262
+ let total = rect.width;
263
+ let diff = delta / total * scope.value;
264
+ if (props.vertical) {
265
+ delta = touch.deltaY.value;
266
+ total = rect.height;
267
+ diff = delta / total * scope.value;
268
+ }
269
+ if (isRange(startValue)) {
270
+ currentValue[buttonIndex.value] = startValue[buttonIndex.value] + diff;
271
+ } else {
272
+ currentValue = startValue + diff;
273
+ }
274
+ updateValue(currentValue);
275
+ event.stopPropagation();
276
+ event.preventDefault();
277
+ };
278
+ const onTouchEnd = () => {
279
+ if (props.disabled) {
280
+ return;
281
+ }
282
+ if (dragStatus.value === "draging") {
283
+ updateValue(currentValue, true);
284
+ emit("drag-end");
285
+ }
286
+ dragStatus.value = "";
287
+ };
288
+ const curValue = (idx) => {
289
+ const value = isArray(props.modelValue) && typeof idx === "number" ? props.modelValue[idx] : Number(props.modelValue);
290
+ return value;
291
+ };
292
+ return __spreadProps(__spreadValues({
293
+ root,
294
+ classes,
295
+ wrapperStyle,
296
+ buttonStyle,
297
+ onClick,
298
+ onTouchStart,
299
+ onTouchMove,
300
+ onTouchEnd
301
+ }, toRefs(props)), {
302
+ barStyle,
303
+ curValue,
304
+ buttonIndex,
305
+ containerClasses,
306
+ markClassName,
307
+ marksStyle,
308
+ marksList,
309
+ tickStyle
181
310
  });
182
311
  }
183
- }), he = {
312
+ });
313
+ const _hoisted_1 = {
184
314
  key: 0,
185
315
  class: "nut-range-min"
186
- }, ke = {
316
+ };
317
+ const _hoisted_2 = {
187
318
  key: 0,
188
319
  class: "nut-range-mark"
189
- }, Te = ["tabindex", "aria-valuemin", "aria-valuenow", "aria-valuemax", "onTouchstart"], we = {
320
+ };
321
+ const _hoisted_3 = ["tabindex", "aria-valuemin", "aria-valuenow", "aria-valuemax", "onTouchstart"];
322
+ const _hoisted_4 = {
190
323
  key: 0,
191
324
  class: "number"
192
- }, Se = ["tabindex", "aria-valuemin", "aria-valuenow", "aria-valuemax"], Ce = {
325
+ };
326
+ const _hoisted_5 = ["tabindex", "aria-valuemin", "aria-valuenow", "aria-valuemax"];
327
+ const _hoisted_6 = {
193
328
  key: 0,
194
329
  class: "number"
195
- }, Ve = {
330
+ };
331
+ const _hoisted_7 = {
196
332
  key: 1,
197
333
  class: "nut-range-max"
198
334
  };
199
- function Ne(e, n, u, y, v, p) {
200
- return m(), c("view", {
201
- class: E(e.containerClasses)
335
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
336
+ return openBlock(), createElementBlock("view", {
337
+ class: normalizeClass(_ctx.containerClasses)
202
338
  }, [
203
- e.hiddenRange ? $("", !0) : (m(), c("view", he, N(+e.min), 1)),
204
- M("view", {
339
+ !_ctx.hiddenRange ? (openBlock(), createElementBlock("view", _hoisted_1, toDisplayString(+_ctx.min), 1)) : createCommentVNode("", true),
340
+ createElementVNode("view", {
205
341
  ref: "root",
206
- style: w(e.wrapperStyle),
207
- class: E(e.classes),
208
- onClick: n[9] || (n[9] = g((...a) => e.onClick && e.onClick(...a), ["stop"]))
342
+ style: normalizeStyle(_ctx.wrapperStyle),
343
+ class: normalizeClass(_ctx.classes),
344
+ onClick: _cache[9] || (_cache[9] = withModifiers((...args) => _ctx.onClick && _ctx.onClick(...args), ["stop"]))
209
345
  }, [
210
- e.marksList.length > 0 ? (m(), c("view", ke, [
211
- (m(!0), c(F, null, I(e.marksList, (a) => (m(), c("span", {
212
- key: a,
213
- class: E(e.markClassName(a)),
214
- style: w(e.marksStyle(a))
215
- }, [
216
- de(N(a) + " ", 1),
217
- M("span", {
218
- class: "nut-range-tick",
219
- style: w(e.tickStyle(a))
220
- }, null, 4)
221
- ], 6))), 128))
222
- ])) : $("", !0),
223
- M("view", {
346
+ _ctx.marksList.length > 0 ? (openBlock(), createElementBlock("view", _hoisted_2, [
347
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.marksList, (marks) => {
348
+ return openBlock(), createElementBlock("span", {
349
+ key: marks,
350
+ class: normalizeClass(_ctx.markClassName(marks)),
351
+ style: normalizeStyle(_ctx.marksStyle(marks))
352
+ }, [
353
+ createTextVNode(toDisplayString(marks) + " ", 1),
354
+ createElementVNode("span", {
355
+ class: "nut-range-tick",
356
+ style: normalizeStyle(_ctx.tickStyle(marks))
357
+ }, null, 4)
358
+ ], 6);
359
+ }), 128))
360
+ ])) : createCommentVNode("", true),
361
+ createElementVNode("view", {
224
362
  class: "nut-range-bar",
225
- style: w(e.barStyle)
363
+ style: normalizeStyle(_ctx.barStyle)
226
364
  }, [
227
- e.range ? (m(), c(F, { key: 0 }, I([0, 1], (a) => M("view", {
228
- key: a,
229
- role: "slider",
230
- class: E({
231
- "nut-range-button-wrapper-left": a == 0,
232
- "nut-range-button-wrapper-right": a == 1
233
- }),
234
- tabindex: e.disabled ? -1 : 0,
235
- "aria-valuemin": +e.min,
236
- "aria-valuenow": e.curValue(a),
237
- "aria-valuemax": +e.max,
238
- "aria-orientation": "horizontal",
239
- onTouchstart: g(
240
- (i) => {
241
- typeof a == "number" && (e.buttonIndex = a), e.onTouchStart(i);
242
- },
243
- ["stop", "prevent"]
244
- ),
245
- onTouchmove: n[0] || (n[0] = g((...i) => e.onTouchMove && e.onTouchMove(...i), ["stop", "prevent"])),
246
- onTouchend: n[1] || (n[1] = g((...i) => e.onTouchEnd && e.onTouchEnd(...i), ["stop", "prevent"])),
247
- onTouchcancel: n[2] || (n[2] = g((...i) => e.onTouchEnd && e.onTouchEnd(...i), ["stop", "prevent"])),
248
- onClick: n[3] || (n[3] = (i) => i.stopPropagation())
249
- }, [
250
- e.$slots.button ? J(e.$slots, "button", { key: 0 }) : (m(), c("view", {
251
- key: 1,
252
- class: "nut-range-button",
253
- style: w(e.buttonStyle)
365
+ _ctx.range ? (openBlock(), createElementBlock(Fragment, { key: 0 }, renderList([0, 1], (index) => {
366
+ return createElementVNode("view", {
367
+ key: index,
368
+ role: "slider",
369
+ class: normalizeClass({
370
+ "nut-range-button-wrapper-left": index == 0,
371
+ "nut-range-button-wrapper-right": index == 1
372
+ }),
373
+ tabindex: _ctx.disabled ? -1 : 0,
374
+ "aria-valuemin": +_ctx.min,
375
+ "aria-valuenow": _ctx.curValue(index),
376
+ "aria-valuemax": +_ctx.max,
377
+ "aria-orientation": "horizontal",
378
+ onTouchstart: withModifiers(
379
+ (e) => {
380
+ if (typeof index === "number") {
381
+ _ctx.buttonIndex = index;
382
+ }
383
+ _ctx.onTouchStart(e);
384
+ },
385
+ ["stop", "prevent"]
386
+ ),
387
+ onTouchmove: _cache[0] || (_cache[0] = withModifiers((...args) => _ctx.onTouchMove && _ctx.onTouchMove(...args), ["stop", "prevent"])),
388
+ onTouchend: _cache[1] || (_cache[1] = withModifiers((...args) => _ctx.onTouchEnd && _ctx.onTouchEnd(...args), ["stop", "prevent"])),
389
+ onTouchcancel: _cache[2] || (_cache[2] = withModifiers((...args) => _ctx.onTouchEnd && _ctx.onTouchEnd(...args), ["stop", "prevent"])),
390
+ onClick: _cache[3] || (_cache[3] = (e) => e.stopPropagation())
254
391
  }, [
255
- e.hiddenTag ? $("", !0) : (m(), c("view", we, N(e.curValue(a)), 1))
256
- ], 4))
257
- ], 42, Te)), 64)) : (m(), c("view", {
392
+ _ctx.$slots.button ? renderSlot(_ctx.$slots, "button", { key: 0 }) : (openBlock(), createElementBlock("view", {
393
+ key: 1,
394
+ class: "nut-range-button",
395
+ style: normalizeStyle(_ctx.buttonStyle)
396
+ }, [
397
+ !_ctx.hiddenTag ? (openBlock(), createElementBlock("view", _hoisted_4, toDisplayString(_ctx.curValue(index)), 1)) : createCommentVNode("", true)
398
+ ], 4))
399
+ ], 42, _hoisted_3);
400
+ }), 64)) : (openBlock(), createElementBlock("view", {
258
401
  key: 1,
259
402
  role: "slider",
260
403
  class: "nut-range-button-wrapper",
261
- tabindex: e.disabled ? -1 : 0,
262
- "aria-valuemin": +e.min,
263
- "aria-valuenow": e.curValue(),
264
- "aria-valuemax": +e.max,
404
+ tabindex: _ctx.disabled ? -1 : 0,
405
+ "aria-valuemin": +_ctx.min,
406
+ "aria-valuenow": _ctx.curValue(),
407
+ "aria-valuemax": +_ctx.max,
265
408
  "aria-orientation": "horizontal",
266
- onTouchstart: n[4] || (n[4] = g(
267
- (a) => {
268
- e.onTouchStart(a);
409
+ onTouchstart: _cache[4] || (_cache[4] = withModifiers(
410
+ (e) => {
411
+ _ctx.onTouchStart(e);
269
412
  },
270
413
  ["stop", "prevent"]
271
414
  )),
272
- onTouchmove: n[5] || (n[5] = g((...a) => e.onTouchMove && e.onTouchMove(...a), ["stop", "prevent"])),
273
- onTouchend: n[6] || (n[6] = g((...a) => e.onTouchEnd && e.onTouchEnd(...a), ["stop", "prevent"])),
274
- onTouchcancel: n[7] || (n[7] = g((...a) => e.onTouchEnd && e.onTouchEnd(...a), ["stop", "prevent"])),
275
- onClick: n[8] || (n[8] = (a) => a.stopPropagation())
415
+ onTouchmove: _cache[5] || (_cache[5] = withModifiers((...args) => _ctx.onTouchMove && _ctx.onTouchMove(...args), ["stop", "prevent"])),
416
+ onTouchend: _cache[6] || (_cache[6] = withModifiers((...args) => _ctx.onTouchEnd && _ctx.onTouchEnd(...args), ["stop", "prevent"])),
417
+ onTouchcancel: _cache[7] || (_cache[7] = withModifiers((...args) => _ctx.onTouchEnd && _ctx.onTouchEnd(...args), ["stop", "prevent"])),
418
+ onClick: _cache[8] || (_cache[8] = (e) => e.stopPropagation())
276
419
  }, [
277
- e.$slots.button ? J(e.$slots, "button", { key: 0 }) : (m(), c("view", {
420
+ _ctx.$slots.button ? renderSlot(_ctx.$slots, "button", { key: 0 }) : (openBlock(), createElementBlock("view", {
278
421
  key: 1,
279
422
  class: "nut-range-button",
280
- style: w(e.buttonStyle)
423
+ style: normalizeStyle(_ctx.buttonStyle)
281
424
  }, [
282
- e.hiddenTag ? $("", !0) : (m(), c("view", Ce, N(e.curValue()), 1))
425
+ !_ctx.hiddenTag ? (openBlock(), createElementBlock("view", _hoisted_6, toDisplayString(_ctx.curValue()), 1)) : createCommentVNode("", true)
283
426
  ], 4))
284
- ], 40, Se))
427
+ ], 40, _hoisted_5))
285
428
  ], 4)
286
429
  ], 6),
287
- e.hiddenRange ? $("", !0) : (m(), c("view", Ve, N(+e.max), 1))
430
+ !_ctx.hiddenRange ? (openBlock(), createElementBlock("view", _hoisted_7, toDisplayString(+_ctx.max), 1)) : createCommentVNode("", true)
288
431
  ], 2);
289
432
  }
290
- const Oe = /* @__PURE__ */ ve(ye, [["render", Ne]]);
433
+ const Range = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
291
434
  export {
292
- Oe as default
435
+ Range as default
293
436
  };