@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,65 +1,262 @@
|
|
|
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 { _ as
|
|
6
|
+
import { ref, reactive, computed, onMounted, watch, nextTick, toRefs, openBlock, createElementBlock, normalizeClass, createElementVNode, normalizeStyle, Fragment, renderList, toDisplayString, renderSlot, withDirectives, vShow, createCommentVNode, withModifiers } from "vue";
|
|
7
|
+
import { c as createComponent } from "./component.js";
|
|
8
|
+
import { u as useExpose } from "./index3.js";
|
|
9
|
+
import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
|
|
10
10
|
import "../locale/lang";
|
|
11
|
-
const { componentName
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
const { componentName, create } = createComponent("elevator");
|
|
12
|
+
const _sfc_main = create({
|
|
13
|
+
props: {
|
|
14
|
+
height: {
|
|
15
|
+
type: [Number, String],
|
|
16
|
+
default: "200px"
|
|
17
|
+
},
|
|
18
|
+
acceptKey: {
|
|
19
|
+
type: [String],
|
|
20
|
+
default: "title"
|
|
21
|
+
},
|
|
22
|
+
indexList: {
|
|
23
|
+
type: Array,
|
|
24
|
+
default: () => {
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
isSticky: {
|
|
29
|
+
type: [Boolean],
|
|
30
|
+
default: false
|
|
31
|
+
},
|
|
32
|
+
spaceHeight: {
|
|
33
|
+
type: [Number],
|
|
34
|
+
default: 23
|
|
35
|
+
},
|
|
36
|
+
titleHeight: {
|
|
37
|
+
type: [Number],
|
|
38
|
+
default: 35
|
|
17
39
|
}
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
},
|
|
41
|
+
emits: ["click-item", "click-index"],
|
|
42
|
+
setup(props, context) {
|
|
43
|
+
const listview = ref(null);
|
|
44
|
+
const state = reactive({
|
|
45
|
+
anchorIndex: 0,
|
|
46
|
+
codeIndex: 0,
|
|
47
|
+
listHeight: [],
|
|
48
|
+
listGroup: [],
|
|
49
|
+
touchState: {
|
|
50
|
+
y1: 0,
|
|
51
|
+
y2: 0
|
|
52
|
+
},
|
|
53
|
+
scrollStart: false,
|
|
54
|
+
currentIndex: 0,
|
|
55
|
+
currentData: {},
|
|
56
|
+
currentKey: "",
|
|
57
|
+
scrollY: 0,
|
|
58
|
+
diff: -1,
|
|
59
|
+
fixedTop: 0
|
|
60
|
+
});
|
|
61
|
+
const classes = computed(() => {
|
|
62
|
+
const prefixCls = componentName;
|
|
63
|
+
return {
|
|
64
|
+
[prefixCls]: true
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
const fixedStyle = computed(() => {
|
|
68
|
+
return {
|
|
69
|
+
transform: `translate3d(0, ${state.scrollY + state.fixedTop}px, 0)`
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
const clientHeight = computed(() => {
|
|
73
|
+
return listview.value.clientHeight;
|
|
74
|
+
});
|
|
75
|
+
const getData = (el, name) => {
|
|
76
|
+
const prefix = "data-";
|
|
77
|
+
return el.getAttribute(prefix + name);
|
|
78
|
+
};
|
|
79
|
+
const setListGroup = (el) => {
|
|
80
|
+
nextTick(() => {
|
|
81
|
+
if (!state.listGroup.includes(el) && el != null) {
|
|
82
|
+
state.listGroup.push(el);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
const calculateHeight = () => {
|
|
87
|
+
let height = 0;
|
|
88
|
+
state.listHeight.push(height);
|
|
89
|
+
for (let i = 0; i < state.listGroup.length; i++) {
|
|
90
|
+
let item = state.listGroup[i];
|
|
91
|
+
height += item.clientHeight;
|
|
92
|
+
state.listHeight.push(height);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const scrollTo = (index2) => {
|
|
96
|
+
if (!index2 && index2 !== 0) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (index2 < 0)
|
|
100
|
+
index2 = 0;
|
|
101
|
+
if (index2 > state.listHeight.length - 2)
|
|
102
|
+
index2 = state.listHeight.length - 2;
|
|
103
|
+
state.codeIndex = index2;
|
|
104
|
+
listview.value.scrollTo(0, state.listHeight[index2]);
|
|
105
|
+
};
|
|
106
|
+
const touchStart = (e) => {
|
|
107
|
+
state.scrollStart = true;
|
|
108
|
+
let index2 = getData(e.target, "index");
|
|
109
|
+
let firstTouch = e.touches[0];
|
|
110
|
+
state.touchState.y1 = firstTouch.pageY;
|
|
111
|
+
state.anchorIndex = +index2;
|
|
112
|
+
state.codeIndex = +index2;
|
|
113
|
+
scrollTo(+index2);
|
|
114
|
+
};
|
|
115
|
+
const touchMove = (e) => {
|
|
116
|
+
let firstTouch = e.touches[0];
|
|
117
|
+
state.touchState.y2 = firstTouch.pageY;
|
|
118
|
+
let delta = (state.touchState.y2 - state.touchState.y1) / props.spaceHeight | 0;
|
|
119
|
+
state.codeIndex = state.anchorIndex + delta;
|
|
120
|
+
scrollTo(state.codeIndex);
|
|
121
|
+
};
|
|
122
|
+
const touchEnd = () => {
|
|
123
|
+
state.scrollStart = false;
|
|
124
|
+
};
|
|
125
|
+
const handleClickItem = (key, item) => {
|
|
126
|
+
context.emit("click-item", key, item);
|
|
127
|
+
state.currentData = item;
|
|
128
|
+
state.currentKey = key;
|
|
129
|
+
};
|
|
130
|
+
const handleClickIndex = (key) => {
|
|
131
|
+
context.emit("click-index", key);
|
|
132
|
+
};
|
|
133
|
+
const listViewScroll = (e) => {
|
|
134
|
+
let target = e.target;
|
|
135
|
+
let scrollTop = target.scrollTop;
|
|
136
|
+
const listHeight = state.listHeight;
|
|
137
|
+
state.scrollY = scrollTop;
|
|
138
|
+
for (let i = 0; i < listHeight.length - 1; i++) {
|
|
139
|
+
let height1 = listHeight[i];
|
|
140
|
+
let height2 = listHeight[i + 1];
|
|
141
|
+
if (state.scrollY >= height1 && state.scrollY < height2) {
|
|
142
|
+
state.currentIndex = i;
|
|
143
|
+
state.diff = height2 - state.scrollY;
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
state.currentIndex = listHeight.length - 2;
|
|
148
|
+
};
|
|
149
|
+
onMounted(() => {
|
|
150
|
+
listview.value.addEventListener("scroll", listViewScroll);
|
|
151
|
+
});
|
|
152
|
+
useExpose({
|
|
153
|
+
scrollTo
|
|
154
|
+
});
|
|
155
|
+
watch(() => state.listGroup.length, () => {
|
|
156
|
+
state.listHeight = [];
|
|
157
|
+
nextTick(calculateHeight);
|
|
158
|
+
});
|
|
159
|
+
watch(() => state.diff, (newVal) => {
|
|
160
|
+
const listHeight = state.listHeight;
|
|
161
|
+
let fixedTop = newVal > 0 && newVal < props.titleHeight ? newVal - props.titleHeight : 0;
|
|
162
|
+
if (state.scrollY + clientHeight.value === listHeight[listHeight.length - 1]) {
|
|
163
|
+
if (fixedTop !== 0)
|
|
164
|
+
fixedTop = 0;
|
|
165
|
+
}
|
|
166
|
+
if (state.fixedTop === fixedTop)
|
|
167
|
+
return;
|
|
168
|
+
state.fixedTop = fixedTop;
|
|
42
169
|
});
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
170
|
+
return {
|
|
171
|
+
classes,
|
|
172
|
+
...toRefs(state),
|
|
173
|
+
fixedStyle,
|
|
174
|
+
clientHeight,
|
|
175
|
+
setListGroup,
|
|
176
|
+
listview,
|
|
177
|
+
touchStart,
|
|
178
|
+
touchMove,
|
|
179
|
+
touchEnd,
|
|
180
|
+
handleClickItem,
|
|
181
|
+
handleClickIndex
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
const _hoisted_1 = { class: "nut-elevator__list__item__code" };
|
|
186
|
+
const _hoisted_2 = ["onClick"];
|
|
187
|
+
const _hoisted_3 = ["innerHTML"];
|
|
188
|
+
const _hoisted_4 = { class: "fixed-title" };
|
|
189
|
+
const _hoisted_5 = { class: "nut-elevator__bars__inner" };
|
|
190
|
+
const _hoisted_6 = ["data-index", "onClick"];
|
|
191
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
192
|
+
return openBlock(), createElementBlock("view", {
|
|
193
|
+
class: normalizeClass(_ctx.classes)
|
|
194
|
+
}, [
|
|
195
|
+
createElementVNode("view", {
|
|
196
|
+
class: "nut-elevator__list",
|
|
197
|
+
ref: "listview",
|
|
198
|
+
style: normalizeStyle({ height: isNaN(+_ctx.height) ? _ctx.height : `${_ctx.height}px` })
|
|
199
|
+
}, [
|
|
200
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.indexList, (item) => {
|
|
201
|
+
return openBlock(), createElementBlock("view", {
|
|
202
|
+
class: "nut-elevator__list__item",
|
|
203
|
+
key: item[_ctx.acceptKey],
|
|
204
|
+
ref: _ctx.setListGroup
|
|
205
|
+
}, [
|
|
206
|
+
createElementVNode("view", _hoisted_1, toDisplayString(item[_ctx.acceptKey]), 1),
|
|
207
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(item.list, (subitem) => {
|
|
208
|
+
return openBlock(), createElementBlock("view", {
|
|
209
|
+
class: normalizeClass(["nut-elevator__list__item__name", {
|
|
210
|
+
"nut-elevator__list__item__name--highcolor": _ctx.currentData.id === subitem.id && _ctx.currentKey === item[_ctx.acceptKey]
|
|
211
|
+
}]),
|
|
212
|
+
key: subitem["id"],
|
|
213
|
+
onClick: ($event) => _ctx.handleClickItem(item[_ctx.acceptKey], subitem)
|
|
214
|
+
}, [
|
|
215
|
+
!_ctx.$slots.default ? (openBlock(), createElementBlock("span", {
|
|
216
|
+
key: 0,
|
|
217
|
+
innerHTML: subitem.name
|
|
218
|
+
}, null, 8, _hoisted_3)) : renderSlot(_ctx.$slots, "default", {
|
|
219
|
+
key: 1,
|
|
220
|
+
item: subitem
|
|
221
|
+
})
|
|
222
|
+
], 10, _hoisted_2);
|
|
223
|
+
}), 128))
|
|
224
|
+
], 512);
|
|
225
|
+
}), 128)),
|
|
226
|
+
_ctx.isSticky ? withDirectives((openBlock(), createElementBlock("view", {
|
|
227
|
+
key: 0,
|
|
228
|
+
class: "nut-elevator__list__fixed",
|
|
229
|
+
style: normalizeStyle(_ctx.fixedStyle)
|
|
230
|
+
}, [
|
|
231
|
+
createElementVNode("span", _hoisted_4, toDisplayString(_ctx.indexList[_ctx.currentIndex][_ctx.acceptKey]), 1)
|
|
232
|
+
], 4)), [
|
|
233
|
+
[vShow, _ctx.scrollY > 0]
|
|
234
|
+
]) : createCommentVNode("", true)
|
|
235
|
+
], 4),
|
|
236
|
+
_ctx.indexList.length ? withDirectives((openBlock(), createElementBlock("view", {
|
|
237
|
+
key: 0,
|
|
238
|
+
class: "nut-elevator__code--current"
|
|
239
|
+
}, toDisplayString(_ctx.indexList[_ctx.codeIndex][_ctx.acceptKey]), 513)), [
|
|
240
|
+
[vShow, _ctx.scrollStart]
|
|
241
|
+
]) : createCommentVNode("", true),
|
|
242
|
+
createElementVNode("view", {
|
|
243
|
+
class: "nut-elevator__bars",
|
|
244
|
+
onTouchstart: _cache[0] || (_cache[0] = (...args) => _ctx.touchStart && _ctx.touchStart(...args)),
|
|
245
|
+
onTouchmove: _cache[1] || (_cache[1] = withModifiers((...args) => _ctx.touchMove && _ctx.touchMove(...args), ["stop", "prevent"])),
|
|
246
|
+
onTouchend: _cache[2] || (_cache[2] = (...args) => _ctx.touchEnd && _ctx.touchEnd(...args))
|
|
247
|
+
}, [
|
|
248
|
+
createElementVNode("view", _hoisted_5, [
|
|
249
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.indexList, (item, index2) => {
|
|
250
|
+
return openBlock(), createElementBlock("view", {
|
|
251
|
+
class: normalizeClass(["nut-elevator__bars__inner__item", { active: item[_ctx.acceptKey] === _ctx.indexList[_ctx.currentIndex][_ctx.acceptKey] }]),
|
|
252
|
+
"data-index": index2,
|
|
253
|
+
key: item[_ctx.acceptKey],
|
|
254
|
+
onClick: ($event) => _ctx.handleClickIndex(item[_ctx.acceptKey])
|
|
255
|
+
}, toDisplayString(item[_ctx.acceptKey]), 11, _hoisted_6);
|
|
256
|
+
}), 128))
|
|
257
|
+
])
|
|
258
|
+
], 32)
|
|
259
|
+
], 2);
|
|
260
|
+
}
|
|
261
|
+
var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
262
|
+
export { index as default };
|
|
@@ -1,64 +1,206 @@
|
|
|
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 { _ as
|
|
6
|
+
import { ref, reactive, computed, watch, onMounted, toRefs, openBlock, createElementBlock, normalizeClass, toDisplayString, createCommentVNode, createTextVNode, withModifiers } from "vue";
|
|
7
|
+
import { c as createComponent } from "./component.js";
|
|
8
|
+
import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
|
|
9
9
|
import "../locale/lang";
|
|
10
|
-
const { componentName
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
10
|
+
const { componentName, create } = createComponent("ellipsis");
|
|
11
|
+
const _sfc_main = create({
|
|
12
|
+
props: {
|
|
13
|
+
content: {
|
|
14
|
+
type: String,
|
|
15
|
+
default: ""
|
|
16
|
+
},
|
|
17
|
+
direction: {
|
|
18
|
+
type: String,
|
|
19
|
+
default: "end"
|
|
20
|
+
},
|
|
21
|
+
rows: {
|
|
22
|
+
type: [Number, String],
|
|
23
|
+
default: 1
|
|
24
|
+
},
|
|
25
|
+
expandText: {
|
|
26
|
+
type: String,
|
|
27
|
+
default: ""
|
|
28
|
+
},
|
|
29
|
+
collapseText: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: ""
|
|
32
|
+
},
|
|
33
|
+
symbol: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: "..."
|
|
36
36
|
}
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
37
|
+
},
|
|
38
|
+
emits: ["click", "change"],
|
|
39
|
+
setup(props, { emit }) {
|
|
40
|
+
const root = ref(null);
|
|
41
|
+
let container = null;
|
|
42
|
+
let maxHeight = 0;
|
|
43
|
+
const ellipsis = ref();
|
|
44
|
+
const state = reactive({
|
|
45
|
+
exceeded: false,
|
|
46
|
+
expanded: false
|
|
47
|
+
});
|
|
48
|
+
const classes = computed(() => {
|
|
49
|
+
const prefixCls = componentName;
|
|
50
|
+
return {
|
|
51
|
+
[prefixCls]: true
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
watch(() => props.content, (newV, oldVal) => {
|
|
55
|
+
if (newV != oldVal) {
|
|
56
|
+
if (container) {
|
|
57
|
+
document.body.appendChild(container);
|
|
58
|
+
}
|
|
59
|
+
createContainer();
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
onMounted(() => {
|
|
63
|
+
createContainer();
|
|
64
|
+
});
|
|
65
|
+
const createContainer = () => {
|
|
66
|
+
if (!root.value)
|
|
67
|
+
return;
|
|
68
|
+
const originStyle = window.getComputedStyle(root.value);
|
|
69
|
+
container = document.createElement("div");
|
|
70
|
+
const styleNames = Array.prototype.slice.apply(originStyle);
|
|
71
|
+
styleNames.forEach((name) => {
|
|
72
|
+
container.style.setProperty(name, originStyle.getPropertyValue(name));
|
|
73
|
+
});
|
|
74
|
+
container.style.position = "fixed";
|
|
75
|
+
container.style.left = "999999px";
|
|
76
|
+
container.style.top = "999999px";
|
|
77
|
+
container.style.zIndex = "-1000";
|
|
78
|
+
container.style.height = "auto";
|
|
79
|
+
container.style.minHeight = "auto";
|
|
80
|
+
container.style.maxHeight = "auto";
|
|
81
|
+
container.style.textOverflow = "clip";
|
|
82
|
+
container.style.whiteSpace = "normal";
|
|
83
|
+
container.style.webkitLineClamp = "unset";
|
|
84
|
+
container.style.display = "block";
|
|
85
|
+
const lineHeight = pxToNumber(originStyle.lineHeight);
|
|
86
|
+
maxHeight = Math.floor(lineHeight * (Number(props.rows) + 0.5) + pxToNumber(originStyle.paddingTop) + pxToNumber(originStyle.paddingBottom));
|
|
87
|
+
container.innerText = props.content;
|
|
88
|
+
document.body.appendChild(container);
|
|
89
|
+
calcEllipse();
|
|
90
|
+
};
|
|
91
|
+
const calcEllipse = () => {
|
|
92
|
+
if (container.offsetHeight <= maxHeight) {
|
|
93
|
+
state.exceeded = false;
|
|
94
|
+
} else {
|
|
95
|
+
state.exceeded = true;
|
|
96
|
+
const end = props.content.length;
|
|
97
|
+
const middle = Math.floor((0 + end) / 2);
|
|
98
|
+
const ellipsised = props.direction === "middle" ? tailorMiddle([0, middle], [middle, end]) : tailor(0, end);
|
|
99
|
+
ellipsis.value = ellipsised;
|
|
100
|
+
document.body.removeChild(container);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const tailor = (left, right) => {
|
|
104
|
+
const actionText = state.expanded ? props.collapseText : props.expandText;
|
|
105
|
+
const end = props.content.length;
|
|
106
|
+
if (right - left <= 1) {
|
|
107
|
+
if (props.direction === "end") {
|
|
108
|
+
return {
|
|
109
|
+
leading: props.content.slice(0, left) + props.symbol
|
|
110
|
+
};
|
|
111
|
+
} else {
|
|
112
|
+
return {
|
|
113
|
+
tailing: props.symbol + props.content.slice(right, end)
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const middle = Math.round((left + right) / 2);
|
|
118
|
+
if (props.direction === "end") {
|
|
119
|
+
container.innerText = props.content.slice(0, middle) + props.symbol + actionText;
|
|
120
|
+
} else {
|
|
121
|
+
container.innerText = actionText + props.symbol + props.content.slice(middle, end);
|
|
122
|
+
}
|
|
123
|
+
if (container.offsetHeight <= maxHeight) {
|
|
124
|
+
if (props.direction === "end") {
|
|
125
|
+
return tailor(middle, right);
|
|
126
|
+
} else {
|
|
127
|
+
return tailor(left, middle);
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
if (props.direction === "end") {
|
|
131
|
+
return tailor(left, middle);
|
|
132
|
+
} else {
|
|
133
|
+
return tailor(middle, right);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
const tailorMiddle = (leftPart, rightPart) => {
|
|
138
|
+
const actionText = state.expanded ? props.collapseText : props.expandText;
|
|
139
|
+
const end = props.content.length;
|
|
140
|
+
if (leftPart[1] - leftPart[0] <= 1 && rightPart[1] - rightPart[0] <= 1) {
|
|
141
|
+
return {
|
|
142
|
+
leading: props.content.slice(0, leftPart[0]) + props.symbol,
|
|
143
|
+
tailing: props.symbol + props.content.slice(rightPart[1], end)
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
const leftPartMiddle = Math.floor((leftPart[0] + leftPart[1]) / 2);
|
|
147
|
+
const rightPartMiddle = Math.ceil((rightPart[0] + rightPart[1]) / 2);
|
|
148
|
+
container.innerText = props.content.slice(0, leftPartMiddle) + props.symbol + actionText + props.symbol + props.content.slice(rightPartMiddle, end);
|
|
149
|
+
if (container.offsetHeight <= maxHeight) {
|
|
150
|
+
return tailorMiddle([leftPartMiddle, leftPart[1]], [rightPart[0], rightPartMiddle]);
|
|
151
|
+
} else {
|
|
152
|
+
return tailorMiddle([leftPart[0], leftPartMiddle], [rightPartMiddle, rightPart[1]]);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
const pxToNumber = (value) => {
|
|
156
|
+
if (!value)
|
|
157
|
+
return 0;
|
|
158
|
+
const match = value.match(/^\d*(\.\d*)?/);
|
|
159
|
+
return match ? Number(match[0]) : 0;
|
|
160
|
+
};
|
|
161
|
+
const clickHandle = (type) => {
|
|
162
|
+
if (type == 1) {
|
|
163
|
+
state.expanded = true;
|
|
164
|
+
emit("change", "expand");
|
|
165
|
+
} else {
|
|
166
|
+
state.expanded = false;
|
|
167
|
+
emit("change", "collapse");
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
const handleClick = () => {
|
|
171
|
+
emit("click");
|
|
172
|
+
};
|
|
173
|
+
return { ...toRefs(state), root, ellipsis, classes, clickHandle, handleClick };
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
const _hoisted_1 = { key: 0 };
|
|
177
|
+
const _hoisted_2 = { key: 1 };
|
|
178
|
+
const _hoisted_3 = { key: 2 };
|
|
179
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
180
|
+
return openBlock(), createElementBlock("view", {
|
|
181
|
+
class: normalizeClass(_ctx.classes),
|
|
182
|
+
onClick: _cache[2] || (_cache[2] = (...args) => _ctx.handleClick && _ctx.handleClick(...args)),
|
|
183
|
+
ref: "root"
|
|
184
|
+
}, [
|
|
185
|
+
!_ctx.exceeded ? (openBlock(), createElementBlock("view", _hoisted_1, toDisplayString(_ctx.content), 1)) : createCommentVNode("", true),
|
|
186
|
+
_ctx.exceeded && !_ctx.expanded ? (openBlock(), createElementBlock("view", _hoisted_2, [
|
|
187
|
+
createTextVNode(toDisplayString(_ctx.ellipsis.leading), 1),
|
|
188
|
+
_ctx.expandText ? (openBlock(), createElementBlock("span", {
|
|
189
|
+
key: 0,
|
|
190
|
+
class: "nut-ellipsis-text",
|
|
191
|
+
onClick: _cache[0] || (_cache[0] = withModifiers(($event) => _ctx.clickHandle(1), ["stop"]))
|
|
192
|
+
}, toDisplayString(_ctx.expandText), 1)) : createCommentVNode("", true),
|
|
193
|
+
createTextVNode(toDisplayString(_ctx.ellipsis.tailing), 1)
|
|
194
|
+
])) : createCommentVNode("", true),
|
|
195
|
+
_ctx.exceeded && _ctx.expanded ? (openBlock(), createElementBlock("view", _hoisted_3, [
|
|
196
|
+
createTextVNode(toDisplayString(_ctx.content) + " ", 1),
|
|
197
|
+
_ctx.expandText ? (openBlock(), createElementBlock("span", {
|
|
198
|
+
key: 0,
|
|
199
|
+
class: "nut-ellipsis-text",
|
|
200
|
+
onClick: _cache[1] || (_cache[1] = withModifiers(($event) => _ctx.clickHandle(2), ["stop"]))
|
|
201
|
+
}, toDisplayString(_ctx.collapseText), 1)) : createCommentVNode("", true)
|
|
202
|
+
])) : createCommentVNode("", true)
|
|
203
|
+
], 2);
|
|
204
|
+
}
|
|
205
|
+
var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
206
|
+
export { index as default };
|