@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.
Files changed (168) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +3 -4
  3. package/dist/nutui.es.js +20412 -4214
  4. package/dist/nutui.umd.js +20518 -4216
  5. package/dist/packages/_es/ActionSheet.js +149 -17
  6. package/dist/packages/_es/Address.js +535 -110
  7. package/dist/packages/_es/AddressList.js +615 -113
  8. package/dist/packages/_es/Animate.js +59 -17
  9. package/dist/packages/_es/Audio.js +257 -53
  10. package/dist/packages/_es/AudioOperate.js +100 -13
  11. package/dist/packages/_es/Avatar.js +162 -38
  12. package/dist/packages/_es/AvatarGroup.js +73 -14
  13. package/dist/packages/_es/BackTop.js +156 -43
  14. package/dist/packages/_es/Badge.js +86 -14
  15. package/dist/packages/_es/Barrage.js +120 -41
  16. package/dist/packages/_es/Button.js +128 -23
  17. package/dist/packages/_es/Calendar.js +246 -30
  18. package/dist/packages/_es/CalendarItem.js +1 -1
  19. package/dist/packages/_es/Card.js +107 -10
  20. package/dist/packages/_es/Cascader.js +496 -147
  21. package/dist/packages/_es/Category.js +58 -15
  22. package/dist/packages/_es/CategoryPane.js +111 -11
  23. package/dist/packages/_es/Cell.js +108 -21
  24. package/dist/packages/_es/CellGroup.js +44 -9
  25. package/dist/packages/_es/Checkbox.js +134 -29
  26. package/dist/packages/_es/CheckboxGroup.js +79 -29
  27. package/dist/packages/_es/CircleProgress.js +150 -28
  28. package/dist/packages/_es/Col.js +56 -14
  29. package/dist/packages/_es/Collapse.js +109 -32
  30. package/dist/packages/_es/CollapseItem.js +253 -59
  31. package/dist/packages/_es/Comment.js +434 -64
  32. package/dist/packages/_es/ConfigProvider.js +20 -8
  33. package/dist/packages/_es/CountDown.js +238 -56
  34. package/dist/packages/_es/CountUp.js +539 -140
  35. package/dist/packages/_es/DatePicker.js +315 -98
  36. package/dist/packages/_es/Dialog.js +289 -60
  37. package/dist/packages/_es/Divider.js +65 -13
  38. package/dist/packages/_es/Drag.js +197 -56
  39. package/dist/packages/_es/Ecard.js +159 -24
  40. package/dist/packages/_es/Elevator.js +255 -58
  41. package/dist/packages/_es/Ellipsis.js +200 -58
  42. package/dist/packages/_es/Empty.js +71 -12
  43. package/dist/packages/_es/FixedNav.js +122 -15
  44. package/dist/packages/_es/Form.js +151 -64
  45. package/dist/packages/_es/FormItem.js +114 -15
  46. package/dist/packages/_es/Grid.js +6 -5
  47. package/dist/packages/_es/GridItem.js +144 -33
  48. package/dist/packages/_es/Icon.js +40 -15
  49. package/dist/packages/_es/Image.js +137 -26
  50. package/dist/packages/_es/ImagePreview.js +547 -76
  51. package/dist/packages/_es/Indicator.js +62 -15
  52. package/dist/packages/_es/InfiniteLoading.js +249 -57
  53. package/dist/packages/_es/Input.js +433 -51
  54. package/dist/packages/_es/InputNumber.js +160 -41
  55. package/dist/packages/_es/Layout.js +5 -4
  56. package/dist/packages/_es/List.js +106 -18
  57. package/dist/packages/_es/Menu.js +168 -44
  58. package/dist/packages/_es/MenuItem.js +173 -37
  59. package/dist/packages/_es/Navbar.js +192 -30
  60. package/dist/packages/_es/NoticeBar.js +380 -74
  61. package/dist/packages/_es/Notify.js +227 -72
  62. package/dist/packages/_es/NumberKeyboard.js +272 -41
  63. package/dist/packages/_es/OldPicker.js +457 -130
  64. package/dist/packages/_es/OverLay.js +98 -24
  65. package/dist/packages/_es/Pagination.js +157 -39
  66. package/dist/packages/_es/Picker.js +454 -129
  67. package/dist/packages/_es/Popover.js +957 -318
  68. package/dist/packages/_es/Popup.js +299 -55
  69. package/dist/packages/_es/Price.js +118 -16
  70. package/dist/packages/_es/Progress.js +146 -14
  71. package/dist/packages/_es/PullRefresh.js +339 -84
  72. package/dist/packages/_es/Radio.js +90 -22
  73. package/dist/packages/_es/RadioGroup.js +37 -8
  74. package/dist/packages/_es/Range.js +408 -83
  75. package/dist/packages/_es/Rate.js +192 -36
  76. package/dist/packages/_es/Row.js +64 -22
  77. package/dist/packages/_es/SearchBar.js +238 -37
  78. package/dist/packages/_es/ShortPassword.js +225 -35
  79. package/dist/packages/_es/SideNavBar.js +81 -24
  80. package/dist/packages/_es/SideNavBarItem.js +46 -11
  81. package/dist/packages/_es/Signature.js +160 -41
  82. package/dist/packages/_es/Skeleton.js +136 -20
  83. package/dist/packages/_es/Sku.js +491 -84
  84. package/dist/packages/_es/Step.js +115 -20
  85. package/dist/packages/_es/Steps.js +53 -18
  86. package/dist/packages/_es/Sticky.js +138 -53
  87. package/dist/packages/_es/SubSideNavBar.js +82 -17
  88. package/dist/packages/_es/Swipe.js +178 -41
  89. package/dist/packages/_es/Swiper.js +433 -121
  90. package/dist/packages/_es/SwiperItem.js +53 -22
  91. package/dist/packages/_es/Switch.js +116 -21
  92. package/dist/packages/_es/TabPane.js +39 -12
  93. package/dist/packages/_es/Tabbar.js +72 -17
  94. package/dist/packages/_es/TabbarItem.js +151 -29
  95. package/dist/packages/_es/Table.js +178 -18
  96. package/dist/packages/_es/Tabs.js +202 -43
  97. package/dist/packages/_es/Tag.js +97 -20
  98. package/dist/packages/_es/TextArea.js +160 -42
  99. package/dist/packages/_es/TimeDetail.js +79 -18
  100. package/dist/packages/_es/TimePannel.js +48 -14
  101. package/dist/packages/_es/TimeSelect.js +112 -15
  102. package/dist/packages/_es/Toast.js +310 -71
  103. package/dist/packages/_es/Uploader.js +455 -104
  104. package/dist/packages/_es/Video.js +332 -74
  105. package/dist/packages/_es/common.js +128 -38
  106. package/dist/packages/_es/component.js +76 -35
  107. package/dist/packages/_es/index.js +6 -5
  108. package/dist/packages/_es/index2.js +30 -9
  109. package/dist/packages/_es/index3.js +8 -6
  110. package/dist/packages/_es/index4.js +64 -13
  111. package/dist/packages/_es/index5.js +780 -164
  112. package/dist/packages/_es/plugin-vue_export-helper.js +8 -7
  113. package/dist/packages/_es/pxCheck.js +5 -3
  114. package/dist/packages/_es/raf.js +15 -8
  115. package/dist/packages/imagepreview/index.scss +6 -1
  116. package/dist/packages/locale/lang/baseLang.js +3 -3
  117. package/dist/packages/locale/lang/en-US.js +105 -5
  118. package/dist/packages/locale/lang/id-ID.js +105 -5
  119. package/dist/packages/locale/lang/index.js +38 -16
  120. package/dist/packages/locale/lang/zh-CN.js +105 -5
  121. package/dist/packages/locale/lang/zh-TW.js +105 -5
  122. package/dist/packages/picker/index.scss +13 -0
  123. package/dist/smartips/attributes.json +8 -0
  124. package/dist/smartips/tags.json +3 -1
  125. package/dist/smartips/web-types.json +19 -1
  126. package/dist/style.css +1 -1
  127. package/dist/style.es.js +1 -1
  128. package/dist/styles/themes/default.scss +49 -49
  129. package/dist/styles/themes/jdb.scss +49 -49
  130. package/dist/styles/themes/jdt.scss +49 -49
  131. package/dist/styles/variables-jdb.scss +4 -1
  132. package/dist/styles/variables-jdt.scss +4 -1
  133. package/dist/styles/variables.scss +1 -1
  134. package/dist/types/__VUE/actionsheet/index.vue.d.ts +3 -3
  135. package/dist/types/__VUE/address/index.vue.d.ts +4 -4
  136. package/dist/types/__VUE/calendar/index.vue.d.ts +1 -1
  137. package/dist/types/__VUE/cascader/index.vue.d.ts +3 -3
  138. package/dist/types/__VUE/cell/index.vue.d.ts +2 -2
  139. package/dist/types/__VUE/checkbox/index.vue.d.ts +2 -2
  140. package/dist/types/__VUE/collapse/index.vue.d.ts +2 -2
  141. package/dist/types/__VUE/datepicker/index.vue.d.ts +2 -2
  142. package/dist/types/__VUE/dialog/index.vue.d.ts +2 -2
  143. package/dist/types/__VUE/ecard/index.vue.d.ts +2 -2
  144. package/dist/types/__VUE/fixednav/index.vue.d.ts +2 -2
  145. package/dist/types/__VUE/grid/index.vue.d.ts +3 -3
  146. package/dist/types/__VUE/imagepreview/imagePreviewItem.vue.d.ts +95 -0
  147. package/dist/types/__VUE/imagepreview/index.vue.d.ts +23 -25
  148. package/dist/types/__VUE/infiniteloading/index.vue.d.ts +6 -6
  149. package/dist/types/__VUE/input/index.vue.d.ts +2 -2
  150. package/dist/types/__VUE/menu/index.vue.d.ts +4 -4
  151. package/dist/types/__VUE/menuitem/index.vue.d.ts +1 -1
  152. package/dist/types/__VUE/numberkeyboard/index.vue.d.ts +2 -2
  153. package/dist/types/__VUE/oldpicker/index.vue.d.ts +3 -3
  154. package/dist/types/__VUE/picker/index.vue.d.ts +3 -3
  155. package/dist/types/__VUE/popover/index.vue.d.ts +6 -6
  156. package/dist/types/__VUE/popup/index.vue.d.ts +4 -4
  157. package/dist/types/__VUE/range/index.vue.d.ts +1 -1
  158. package/dist/types/__VUE/rate/index.vue.d.ts +2 -2
  159. package/dist/types/__VUE/searchbar/index.vue.d.ts +2 -2
  160. package/dist/types/__VUE/shortpassword/index.vue.d.ts +1 -1
  161. package/dist/types/__VUE/sku/index.vue.d.ts +3 -3
  162. package/dist/types/__VUE/swipe/index.vue.d.ts +2 -2
  163. package/dist/types/__VUE/switch/index.vue.d.ts +2 -2
  164. package/dist/types/__VUE/tabbar/index.vue.d.ts +2 -2
  165. package/dist/types/__VUE/textarea/index.vue.d.ts +2 -2
  166. package/dist/types/__VUE/toast/index.vue.d.ts +1 -1
  167. package/dist/types/index.d.ts +1 -1
  168. package/package.json +1 -2
@@ -1,65 +1,262 @@
1
1
  /*!
2
- * @nutui/nutui v3.1.22-beta.5 Fri Jun 24 2022 15:10:09 GMT+0800 (中国标准时间)
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 as e, reactive as t, computed as l, onMounted as i, watch as c, nextTick as n, toRefs as r, openBlock as s, createElementBlock as o, normalizeClass as a, createElementVNode as u, normalizeStyle as d, Fragment as h, renderList as p, toDisplayString as _, renderSlot as x, withDirectives as y, vShow as g, createCommentVNode as v, withModifiers as f } from "vue";
7
- import { c as m } from "./component.js";
8
- import { u as k } from "./index3.js";
9
- import { _ as H } from "./plugin-vue_export-helper.js";
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: I, create: S } = m("elevator"), K = S({ props: { height: { type: [Number, String], default: "200px" }, acceptKey: { type: [String], default: "title" }, indexList: { type: Array, default: () => [] }, isSticky: { type: [Boolean], default: false }, spaceHeight: { type: [Number], default: 23 }, titleHeight: { type: [Number], default: 35 } }, emits: ["click-item", "click-index"], setup(s2, o2) {
12
- const a2 = e(null), u2 = t({ anchorIndex: 0, codeIndex: 0, listHeight: [], listGroup: [], touchState: { y1: 0, y2: 0 }, scrollStart: false, currentIndex: 0, currentData: {}, currentKey: "", scrollY: 0, diff: -1, fixedTop: 0 }), d2 = l(() => ({ [I]: true })), h2 = l(() => ({ transform: `translate3d(0, ${u2.scrollY + u2.fixedTop}px, 0)` })), p2 = l(() => a2.value.clientHeight), _2 = () => {
13
- let e2 = 0;
14
- u2.listHeight.push(e2);
15
- for (let t2 = 0; t2 < u2.listGroup.length; t2++) {
16
- e2 += u2.listGroup[t2].clientHeight, u2.listHeight.push(e2);
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
- }, x2 = (e2) => {
19
- (e2 || e2 === 0) && (e2 < 0 && (e2 = 0), e2 > u2.listHeight.length - 2 && (e2 = u2.listHeight.length - 2), u2.codeIndex = e2, a2.value.scrollTo(0, u2.listHeight[e2]));
20
- }, y2 = (e2) => {
21
- let t2 = e2.target.scrollTop;
22
- const l2 = u2.listHeight;
23
- u2.scrollY = t2;
24
- for (let e3 = 0; e3 < l2.length - 1; e3++) {
25
- let t3 = l2[e3], i2 = l2[e3 + 1];
26
- if (u2.scrollY >= t3 && u2.scrollY < i2)
27
- return u2.currentIndex = e3, void (u2.diff = i2 - u2.scrollY);
28
- }
29
- u2.currentIndex = l2.length - 2;
30
- };
31
- return i(() => {
32
- a2.value.addEventListener("scroll", y2);
33
- }), k({ scrollTo: x2 }), c(() => u2.listGroup.length, () => {
34
- u2.listHeight = [], n(_2);
35
- }), c(() => u2.diff, (e2) => {
36
- const t2 = u2.listHeight;
37
- let l2 = e2 > 0 && e2 < s2.titleHeight ? e2 - s2.titleHeight : 0;
38
- u2.scrollY + p2.value === t2[t2.length - 1] && l2 !== 0 && (l2 = 0), u2.fixedTop !== l2 && (u2.fixedTop = l2);
39
- }), { classes: d2, ...r(u2), fixedStyle: h2, clientHeight: p2, setListGroup: (e2) => {
40
- n(() => {
41
- u2.listGroup.includes(e2) || e2 == null || u2.listGroup.push(e2);
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
- }, listview: a2, touchStart: (e2) => {
44
- u2.scrollStart = true;
45
- let t2 = (l2 = e2.target, i2 = "index", l2.getAttribute("data-" + i2));
46
- var l2, i2;
47
- let c2 = e2.touches[0];
48
- u2.touchState.y1 = c2.pageY, u2.anchorIndex = +t2, u2.codeIndex = +t2, x2(+t2);
49
- }, touchMove: (e2) => {
50
- let t2 = e2.touches[0];
51
- u2.touchState.y2 = t2.pageY;
52
- let l2 = (u2.touchState.y2 - u2.touchState.y1) / s2.spaceHeight | 0;
53
- u2.codeIndex = u2.anchorIndex + l2, x2(u2.codeIndex);
54
- }, touchEnd: () => {
55
- u2.scrollStart = false;
56
- }, handleClickItem: (e2, t2) => {
57
- o2.emit("click-item", e2, t2), u2.currentData = t2, u2.currentKey = e2;
58
- }, handleClickIndex: (e2) => {
59
- o2.emit("click-index", e2);
60
- } };
61
- } }), w = { class: "nut-elevator__list__item__code" }, L = ["onClick"], T = ["innerHTML"], Y = { class: "fixed-title" }, C = { class: "nut-elevator__bars__inner" }, G = ["data-index", "onClick"];
62
- var b = H(K, [["render", function(e2, t2, l2, i2, c2, n2) {
63
- return s(), o("view", { class: a(e2.classes) }, [u("view", { class: "nut-elevator__list", ref: "listview", style: d({ height: isNaN(+e2.height) ? e2.height : `${e2.height}px` }) }, [(s(true), o(h, null, p(e2.indexList, (t3) => (s(), o("view", { class: "nut-elevator__list__item", key: t3[e2.acceptKey], ref: e2.setListGroup }, [u("view", w, _(t3[e2.acceptKey]), 1), (s(true), o(h, null, p(t3.list, (l3) => (s(), o("view", { class: a(["nut-elevator__list__item__name", { "nut-elevator__list__item__name--highcolor": e2.currentData.id === l3.id && e2.currentKey === t3[e2.acceptKey] }]), key: l3.id, onClick: (i3) => e2.handleClickItem(t3[e2.acceptKey], l3) }, [e2.$slots.default ? x(e2.$slots, "default", { key: 1, item: l3 }) : (s(), o("span", { key: 0, innerHTML: l3.name }, null, 8, T))], 10, L))), 128))], 512))), 128)), e2.isSticky ? y((s(), o("view", { key: 0, class: "nut-elevator__list__fixed", style: d(e2.fixedStyle) }, [u("span", Y, _(e2.indexList[e2.currentIndex][e2.acceptKey]), 1)], 4)), [[g, e2.scrollY > 0]]) : v("", true)], 4), e2.indexList.length ? y((s(), o("view", { key: 0, class: "nut-elevator__code--current" }, _(e2.indexList[e2.codeIndex][e2.acceptKey]), 513)), [[g, e2.scrollStart]]) : v("", true), u("view", { class: "nut-elevator__bars", onTouchstart: t2[0] || (t2[0] = (...t3) => e2.touchStart && e2.touchStart(...t3)), onTouchmove: t2[1] || (t2[1] = f((...t3) => e2.touchMove && e2.touchMove(...t3), ["stop", "prevent"])), onTouchend: t2[2] || (t2[2] = (...t3) => e2.touchEnd && e2.touchEnd(...t3)) }, [u("view", C, [(s(true), o(h, null, p(e2.indexList, (t3, l3) => (s(), o("view", { class: a(["nut-elevator__bars__inner__item", { active: t3[e2.acceptKey] === e2.indexList[e2.currentIndex][e2.acceptKey] }]), "data-index": l3, key: t3[e2.acceptKey], onClick: (l4) => e2.handleClickIndex(t3[e2.acceptKey]) }, _(t3[e2.acceptKey]), 11, G))), 128))])], 32)], 2);
64
- }]]);
65
- export { b as default };
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.22-beta.5 Fri Jun 24 2022 15:10:09 GMT+0800 (中国标准时间)
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 as e, reactive as t, computed as n, watch as l, onMounted as o, toRefs as i, openBlock as c, createElementBlock as s, normalizeClass as d, toDisplayString as a, createCommentVNode as r, createTextVNode as p, withModifiers as x } from "vue";
7
- import { c as u } from "./component.js";
8
- import { _ as y } from "./plugin-vue_export-helper.js";
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: m, create: g } = u("ellipsis"), f = g({ props: { content: { type: String, default: "" }, direction: { type: String, default: "end" }, rows: { type: [Number, String], default: 1 }, expandText: { type: String, default: "" }, collapseText: { type: String, default: "" }, symbol: { type: String, default: "..." } }, emits: ["click", "change"], setup(c2, { emit: s2 }) {
11
- const d2 = e(null);
12
- let a2 = null, r2 = 0;
13
- const p2 = e(), x2 = t({ exceeded: false, expanded: false }), u2 = n(() => ({ [m]: true }));
14
- l(() => c2.content, (e2, t2) => {
15
- e2 != t2 && (a2 && document.body.appendChild(a2), y2());
16
- }), o(() => {
17
- y2();
18
- });
19
- const y2 = () => {
20
- if (!d2.value)
21
- return;
22
- const e2 = window.getComputedStyle(d2.value);
23
- a2 = document.createElement("div");
24
- Array.prototype.slice.apply(e2).forEach((t3) => {
25
- a2.style.setProperty(t3, e2.getPropertyValue(t3));
26
- }), a2.style.position = "fixed", a2.style.left = "999999px", a2.style.top = "999999px", a2.style.zIndex = "-1000", a2.style.height = "auto", a2.style.minHeight = "auto", a2.style.maxHeight = "auto", a2.style.textOverflow = "clip", a2.style.whiteSpace = "normal", a2.style.webkitLineClamp = "unset", a2.style.display = "block";
27
- const t2 = k2(e2.lineHeight);
28
- r2 = Math.floor(t2 * (Number(c2.rows) + 0.5) + k2(e2.paddingTop) + k2(e2.paddingBottom)), a2.innerText = c2.content, document.body.appendChild(a2), g2();
29
- }, g2 = () => {
30
- if (a2.offsetHeight <= r2)
31
- x2.exceeded = false;
32
- else {
33
- x2.exceeded = true;
34
- const e2 = c2.content.length, t2 = Math.floor((0 + e2) / 2), n2 = c2.direction === "middle" ? h2([0, t2], [t2, e2]) : f2(0, e2);
35
- p2.value = n2, document.body.removeChild(a2);
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
- }, f2 = (e2, t2) => {
38
- const n2 = x2.expanded ? c2.collapseText : c2.expandText, l2 = c2.content.length;
39
- if (t2 - e2 <= 1)
40
- return c2.direction === "end" ? { leading: c2.content.slice(0, e2) + c2.symbol } : { tailing: c2.symbol + c2.content.slice(t2, l2) };
41
- const o2 = Math.round((e2 + t2) / 2);
42
- return c2.direction === "end" ? a2.innerText = c2.content.slice(0, o2) + c2.symbol + n2 : a2.innerText = n2 + c2.symbol + c2.content.slice(o2, l2), a2.offsetHeight <= r2 ? c2.direction === "end" ? f2(o2, t2) : f2(e2, o2) : c2.direction === "end" ? f2(e2, o2) : f2(o2, t2);
43
- }, h2 = (e2, t2) => {
44
- const n2 = x2.expanded ? c2.collapseText : c2.expandText, l2 = c2.content.length;
45
- if (e2[1] - e2[0] <= 1 && t2[1] - t2[0] <= 1)
46
- return { leading: c2.content.slice(0, e2[0]) + c2.symbol, tailing: c2.symbol + c2.content.slice(t2[1], l2) };
47
- const o2 = Math.floor((e2[0] + e2[1]) / 2), i2 = Math.ceil((t2[0] + t2[1]) / 2);
48
- return a2.innerText = c2.content.slice(0, o2) + c2.symbol + n2 + c2.symbol + c2.content.slice(i2, l2), a2.offsetHeight <= r2 ? h2([o2, e2[1]], [t2[0], i2]) : h2([e2[0], o2], [i2, t2[1]]);
49
- }, k2 = (e2) => {
50
- if (!e2)
51
- return 0;
52
- const t2 = e2.match(/^\d*(\.\d*)?/);
53
- return t2 ? Number(t2[0]) : 0;
54
- };
55
- return { ...i(x2), root: d2, ellipsis: p2, classes: u2, clickHandle: (e2) => {
56
- e2 == 1 ? (x2.expanded = true, s2("change", "expand")) : (x2.expanded = false, s2("change", "collapse"));
57
- }, handleClick: () => {
58
- s2("click");
59
- } };
60
- } }), h = { key: 0 }, k = { key: 1 }, b = { key: 2 };
61
- var T = y(f, [["render", function(e2, t2, n2, l2, o2, i2) {
62
- return c(), s("view", { class: d(e2.classes), onClick: t2[2] || (t2[2] = (...t3) => e2.handleClick && e2.handleClick(...t3)), ref: "root" }, [e2.exceeded ? r("", true) : (c(), s("view", h, a(e2.content), 1)), e2.exceeded && !e2.expanded ? (c(), s("view", k, [p(a(e2.ellipsis.leading), 1), e2.expandText ? (c(), s("span", { key: 0, class: "nut-ellipsis-text", onClick: t2[0] || (t2[0] = x((t3) => e2.clickHandle(1), ["stop"])) }, a(e2.expandText), 1)) : r("", true), p(a(e2.ellipsis.tailing), 1)])) : r("", true), e2.exceeded && e2.expanded ? (c(), s("view", b, [p(a(e2.content) + " ", 1), e2.expandText ? (c(), s("span", { key: 0, class: "nut-ellipsis-text", onClick: t2[1] || (t2[1] = x((t3) => e2.clickHandle(2), ["stop"])) }, a(e2.collapseText), 1)) : r("", true)])) : r("", true)], 2);
63
- }]]);
64
- export { T as default };
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 };