@nutui/nutui 3.1.18-beta.0 → 3.1.19-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 (149) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/LICENSE +1 -1
  3. package/README.md +6 -0
  4. package/dist/nutui.d.ts +39 -36
  5. package/dist/nutui.es.js +13149 -11288
  6. package/dist/nutui.umd.js +13156 -11381
  7. package/dist/packages/_es/ActionSheet.js +13 -19
  8. package/dist/packages/_es/Address.js +70 -55
  9. package/dist/packages/_es/Audio.js +13 -13
  10. package/dist/packages/_es/AudioOperate.js +125 -0
  11. package/dist/packages/_es/Avatar.js +4 -4
  12. package/dist/packages/_es/BackTop.js +69 -108
  13. package/dist/packages/_es/Badge.js +4 -4
  14. package/dist/packages/_es/Barrage.js +63 -56
  15. package/dist/packages/_es/Button.js +3 -3
  16. package/dist/packages/_es/Calendar.js +30 -702
  17. package/dist/packages/_es/CalendarItem.js +10 -0
  18. package/dist/packages/_es/Card.js +7 -6
  19. package/dist/packages/_es/Cascader.js +8 -8
  20. package/dist/packages/_es/Cell.js +27 -27
  21. package/dist/packages/_es/CellGroup.js +2 -2
  22. package/dist/packages/_es/Checkbox.js +4 -4
  23. package/dist/packages/_es/CheckboxGroup.js +3 -3
  24. package/dist/packages/_es/CircleProgress.js +150 -41
  25. package/dist/packages/_es/Col.js +2 -2
  26. package/dist/packages/_es/Collapse.js +35 -9
  27. package/dist/packages/_es/CollapseItem.js +79 -38
  28. package/dist/packages/_es/CountDown.js +8 -6
  29. package/dist/packages/_es/CountUp.js +31 -30
  30. package/dist/packages/_es/DatePicker.js +81 -44
  31. package/dist/packages/_es/Dialog.js +7 -83
  32. package/dist/packages/_es/Divider.js +5 -5
  33. package/dist/packages/_es/Drag.js +93 -55
  34. package/dist/packages/_es/Elevator.js +75 -50
  35. package/dist/packages/_es/Empty.js +4 -4
  36. package/dist/packages/_es/FixedNav.js +6 -6
  37. package/dist/packages/_es/Form.js +11 -9
  38. package/dist/packages/_es/FormItem.js +9 -6
  39. package/dist/packages/_es/Grid.js +2 -2
  40. package/dist/packages/_es/GridItem.js +9 -27
  41. package/dist/packages/_es/Icon.js +2 -2
  42. package/dist/packages/_es/ImagePreview.js +14 -83
  43. package/dist/packages/_es/Indicator.js +4 -4
  44. package/dist/packages/_es/InfiniteLoading.js +94 -108
  45. package/dist/packages/_es/Input.js +297 -73
  46. package/dist/packages/_es/InputNumber.js +24 -17
  47. package/dist/packages/_es/Layout.js +2 -2
  48. package/dist/packages/_es/List.js +131 -0
  49. package/dist/packages/_es/Menu.js +16 -13
  50. package/dist/packages/_es/MenuItem.js +8 -8
  51. package/dist/packages/_es/Navbar.js +17 -12
  52. package/dist/packages/_es/NoticeBar.js +47 -39
  53. package/dist/packages/_es/Notify.js +28 -163
  54. package/dist/packages/_es/NumberKeyboard.js +4 -4
  55. package/dist/packages/_es/OldPicker.js +486 -0
  56. package/dist/packages/_es/OverLay.js +6 -26
  57. package/dist/packages/_es/Pagination.js +8 -8
  58. package/dist/packages/_es/Picker.js +192 -163
  59. package/dist/packages/_es/Popover.js +155 -30
  60. package/dist/packages/_es/Popup.js +7 -70
  61. package/dist/packages/_es/Price.js +18 -6
  62. package/dist/packages/_es/Progress.js +29 -27
  63. package/dist/packages/_es/PullRefresh.js +363 -0
  64. package/dist/packages/_es/Radio.js +4 -4
  65. package/dist/packages/_es/RadioGroup.js +2 -2
  66. package/dist/packages/_es/Range.js +169 -46
  67. package/dist/packages/_es/Rate.js +17 -20
  68. package/dist/packages/_es/Row.js +2 -2
  69. package/dist/packages/_es/SearchBar.js +9 -7
  70. package/dist/packages/_es/ShortPassword.js +90 -68
  71. package/dist/packages/_es/SideNavBar.js +6 -17
  72. package/dist/packages/_es/SideNavBarItem.js +2 -2
  73. package/dist/packages/_es/Signature.js +70 -70
  74. package/dist/packages/_es/Skeleton.js +9 -12
  75. package/dist/packages/_es/Sku.js +40 -31
  76. package/dist/packages/_es/Step.js +28 -12
  77. package/dist/packages/_es/Steps.js +8 -3
  78. package/dist/packages/_es/Sticky.js +29 -24
  79. package/dist/packages/_es/SubSideNavBar.js +2 -2
  80. package/dist/packages/_es/Swipe.js +40 -27
  81. package/dist/packages/_es/Swiper.js +32 -14
  82. package/dist/packages/_es/SwiperItem.js +2 -2
  83. package/dist/packages/_es/Switch.js +4 -4
  84. package/dist/packages/_es/TabPane.js +2 -2
  85. package/dist/packages/_es/Tabbar.js +4 -4
  86. package/dist/packages/_es/TabbarItem.js +28 -23
  87. package/dist/packages/_es/Table.js +14 -14
  88. package/dist/packages/_es/Tabs.js +19 -15
  89. package/dist/packages/_es/Tag.js +14 -8
  90. package/dist/packages/_es/TextArea.js +49 -15
  91. package/dist/packages/_es/TimeDetail.js +5 -4
  92. package/dist/packages/_es/TimePannel.js +4 -4
  93. package/dist/packages/_es/TimeSelect.js +9 -8
  94. package/dist/packages/_es/Toast.js +42 -171
  95. package/dist/packages/_es/Uploader.js +108 -139
  96. package/dist/packages/_es/Video.js +14 -10
  97. package/dist/packages/_es/common.js +2 -2
  98. package/dist/packages/_es/component.js +2 -2
  99. package/dist/packages/_es/index.js +45 -7
  100. package/dist/packages/_es/index.taro.js +719 -0
  101. package/dist/packages/_es/index2.js +2 -2
  102. package/dist/packages/_es/index3.js +57 -29
  103. package/dist/packages/_es/index4.js +414 -57
  104. package/dist/packages/_es/plugin-vue_export-helper.js +2 -2
  105. package/dist/packages/_es/pxCheck.js +2 -2
  106. package/dist/packages/_es/use-lock-scroll.js +23 -0
  107. package/dist/packages/_es/util.js +2 -2
  108. package/dist/packages/badge/index.scss +11 -13
  109. package/dist/packages/button/index.scss +1 -0
  110. package/dist/packages/calendar/index.scss +9 -4
  111. package/dist/packages/calendaritem/index.scss +0 -207
  112. package/dist/packages/cell/index.scss +6 -6
  113. package/dist/packages/checkbox/index.scss +4 -3
  114. package/dist/packages/collapseitem/index.scss +21 -11
  115. package/dist/packages/countdown/index.scss +3 -1
  116. package/dist/packages/divider/index.scss +8 -8
  117. package/dist/packages/elevator/index.scss +36 -36
  118. package/dist/packages/formitem/index.scss +15 -8
  119. package/dist/packages/indicator/index.scss +1 -1
  120. package/dist/packages/input/index.scss +70 -24
  121. package/dist/packages/inputnumber/index.scss +4 -2
  122. package/dist/packages/list/index.scss +24 -0
  123. package/dist/packages/menu/index.scss +3 -3
  124. package/dist/packages/navbar/index.scss +28 -8
  125. package/dist/packages/noticebar/index.scss +7 -8
  126. package/dist/packages/notify/index.scss +9 -0
  127. package/dist/packages/numberkeyboard/index.scss +22 -21
  128. package/dist/packages/oldpicker/index.scss +131 -0
  129. package/dist/packages/picker/index.scss +38 -32
  130. package/dist/packages/progress/index.scss +6 -5
  131. package/dist/packages/radio/index.scss +7 -6
  132. package/dist/packages/range/index.scss +109 -2
  133. package/dist/packages/searchbar/index.scss +7 -7
  134. package/dist/packages/sidenavbaritem/index.scss +5 -5
  135. package/dist/packages/step/index.scss +29 -29
  136. package/dist/packages/subsidenavbar/index.scss +10 -8
  137. package/dist/packages/tabbaritem/index.scss +15 -0
  138. package/dist/packages/timedetail/index.scss +13 -13
  139. package/dist/packages/timepannel/index.scss +7 -7
  140. package/dist/packages/timeselect/index.scss +3 -3
  141. package/dist/packages/uploader/index.scss +6 -6
  142. package/dist/style.css +1 -1
  143. package/dist/styles/themes/default.scss +64 -62
  144. package/dist/styles/themes/jdt.scss +91 -0
  145. package/dist/styles/variables-jdt.scss +728 -0
  146. package/dist/styles/variables.scss +250 -44
  147. package/package.json +2 -1
  148. package/dist/packages/_es/raf.js +0 -19
  149. package/dist/styles/themes/jdd.scss +0 -2
@@ -0,0 +1,131 @@
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
+ /*!
21
+ * @nutui/nutui v3.1.19-beta.1 Sat Apr 02 2022 16:26:37 GMT+0800 (中国标准时间)
22
+ * (c) 2022 @jdf2e.
23
+ * Released under the MIT License.
24
+ */
25
+ import { ref, reactive, computed, watch, toRefs, resolveComponent, openBlock, createBlock, normalizeClass, normalizeStyle, withCtx, createElementVNode, createElementBlock, Fragment, renderList, renderSlot } from "vue";
26
+ import { c as createComponent } from "./component.js";
27
+ import Taro from "@tarojs/taro";
28
+ import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
29
+ const { componentName, create } = createComponent("list");
30
+ const _sfc_main = create({
31
+ props: {
32
+ height: {
33
+ type: [Number],
34
+ default: 0
35
+ },
36
+ listData: {
37
+ type: Array,
38
+ default: () => {
39
+ return [];
40
+ }
41
+ }
42
+ },
43
+ emits: ["scroll"],
44
+ setup(props, { emit }) {
45
+ const list = ref(null);
46
+ const state = reactive({
47
+ screenHeight: Taro.getSystemInfoSync().windowHeight,
48
+ startOffset: 0,
49
+ start: 0,
50
+ list: props.listData.slice()
51
+ });
52
+ const visibleCount = computed(() => {
53
+ return Math.ceil(state.screenHeight / props.height);
54
+ });
55
+ const end = computed(() => {
56
+ return state.start + visibleCount.value;
57
+ });
58
+ const getTransform = computed(() => {
59
+ return `translate3d(0, ${state.startOffset}px, 0)`;
60
+ });
61
+ const classes = computed(() => {
62
+ const prefixCls = componentName;
63
+ return {
64
+ [prefixCls]: true
65
+ };
66
+ });
67
+ const listHeight = computed(() => {
68
+ return state.list.length * props.height;
69
+ });
70
+ const visibleData = computed(() => {
71
+ return state.list.slice(state.start, Math.min(end.value, state.list.length));
72
+ });
73
+ const handleScrollEvent = async (e) => {
74
+ const scrollTop = e.detail.scrollTop;
75
+ state.start = Math.floor(scrollTop / props.height);
76
+ if (end.value > state.list.length) {
77
+ emit("scroll");
78
+ }
79
+ state.startOffset = scrollTop - scrollTop % props.height;
80
+ };
81
+ watch(() => props.listData, () => {
82
+ state.list = props.listData.slice();
83
+ });
84
+ return __spreadProps(__spreadValues({}, toRefs(state)), {
85
+ list,
86
+ getTransform,
87
+ listHeight,
88
+ visibleData,
89
+ classes,
90
+ handleScrollEvent
91
+ });
92
+ }
93
+ });
94
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
95
+ const _component_scroll_view = resolveComponent("scroll-view");
96
+ return openBlock(), createBlock(_component_scroll_view, {
97
+ class: normalizeClass(_ctx.classes),
98
+ "scroll-y": true,
99
+ style: normalizeStyle({ height: _ctx.screenHeight + "px" }),
100
+ "scroll-top": "0",
101
+ onScroll: _ctx.handleScrollEvent,
102
+ ref: "list"
103
+ }, {
104
+ default: withCtx(() => [
105
+ createElementVNode("div", {
106
+ class: "nut-list-phantom",
107
+ style: normalizeStyle({ height: _ctx.listHeight + "px" })
108
+ }, null, 4),
109
+ createElementVNode("div", {
110
+ class: "nut-list-container",
111
+ style: normalizeStyle({ transform: _ctx.getTransform })
112
+ }, [
113
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.visibleData, (item, index) => {
114
+ return openBlock(), createElementBlock("div", {
115
+ class: "nut-list-item",
116
+ style: normalizeStyle({ height: _ctx.height + "px" }),
117
+ key: item
118
+ }, [
119
+ renderSlot(_ctx.$slots, "default", {
120
+ item,
121
+ index
122
+ })
123
+ ], 4);
124
+ }), 128))
125
+ ], 4)
126
+ ]),
127
+ _: 3
128
+ }, 8, ["class", "style", "onScroll"]);
129
+ }
130
+ var index_taro = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
131
+ export { index_taro as default };
@@ -1,11 +1,11 @@
1
1
  /*!
2
- * @nutui/nutui v3.1.18-beta.0 Tue Mar 08 2022 10:41:31 GMT+0800 (中国标准时间)
3
- * (c) 2021 @jdf2e.
2
+ * @nutui/nutui v3.1.19-beta.1 Sat Apr 02 2022 16:26:37 GMT+0800 (中国标准时间)
3
+ * (c) 2022 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
6
6
  import { ref, computed, reactive, provide, resolveComponent, openBlock, createElementBlock, normalizeClass, createElementVNode, Fragment, renderList, normalizeStyle, toDisplayString, createVNode, renderSlot } from "vue";
7
7
  import { c as createComponent } from "./component.js";
8
- import { u as useRect } from "./index3.js";
8
+ import Taro from "@tarojs/taro";
9
9
  import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
10
10
  const { componentName, create } = createComponent("menu");
11
11
  const _sfc_main = create({
@@ -20,7 +20,7 @@ const _sfc_main = create({
20
20
  },
21
21
  duration: {
22
22
  type: [Number, String],
23
- default: 0
23
+ default: 0.3
24
24
  }
25
25
  },
26
26
  setup(props, { emit, slots }) {
@@ -57,14 +57,17 @@ const _sfc_main = create({
57
57
  });
58
58
  const updateOffset = () => {
59
59
  if (barRef.value) {
60
- const rect = useRect(barRef);
61
- offset.value = rect.bottom;
60
+ setTimeout(() => {
61
+ Taro.createSelectorQuery().select(".nut-menu__bar.opened").boundingClientRect((rect) => {
62
+ offset.value = rect.bottom;
63
+ }).exec();
64
+ }, 100);
62
65
  }
63
66
  };
64
67
  linkChildren({ props, offset });
65
68
  const toggleItem = (active) => {
66
- children.forEach((item, index2) => {
67
- if (index2 === active) {
69
+ children.forEach((item, index) => {
70
+ if (index === active) {
68
71
  updateOffset();
69
72
  item.toggle();
70
73
  } else if (item.state.showPopup) {
@@ -92,11 +95,11 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
92
95
  class: normalizeClass(["nut-menu__bar", { opened: _ctx.opened }]),
93
96
  ref: "barRef"
94
97
  }, [
95
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.children, (item, index2) => {
98
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.children, (item, index) => {
96
99
  return openBlock(), createElementBlock("view", {
97
- key: index2,
100
+ key: index,
98
101
  class: normalizeClass(["nut-menu__item", { disabled: item.disabled, active: item.state.showPopup }]),
99
- onClick: ($event) => !item.disabled && _ctx.toggleItem(index2),
102
+ onClick: ($event) => !item.disabled && _ctx.toggleItem(index),
100
103
  style: normalizeStyle({ color: item.state.showPopup ? _ctx.activeColor : "" })
101
104
  }, [
102
105
  createElementVNode("view", {
@@ -115,5 +118,5 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
115
118
  renderSlot(_ctx.$slots, "default")
116
119
  ], 2);
117
120
  }
118
- var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
119
- export { index as default };
121
+ var index_taro = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
122
+ export { index_taro as default };
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * @nutui/nutui v3.1.18-beta.0 Tue Mar 08 2022 10:41:31 GMT+0800 (中国标准时间)
3
- * (c) 2021 @jdf2e.
2
+ * @nutui/nutui v3.1.19-beta.1 Sat Apr 02 2022 16:26:37 GMT+0800 (中国标准时间)
3
+ * (c) 2022 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
6
6
  import { reactive, computed, inject, getCurrentInstance, resolveComponent, withDirectives, openBlock, createElementBlock, normalizeClass, createElementVNode, normalizeStyle, vShow, createVNode, mergeProps, withCtx, Fragment, renderList, createBlock, createCommentVNode, toDisplayString, renderSlot } from "vue";
@@ -9,6 +9,7 @@ import _sfc_main$1 from "./Icon.js";
9
9
  import Popup from "./Popup.js";
10
10
  import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
11
11
  import "./pxCheck.js";
12
+ import "./use-lock-scroll.js";
12
13
  import "./OverLay.js";
13
14
  const { componentName, create } = createComponent("menu-item");
14
15
  const _sfc_main = create({
@@ -133,14 +134,13 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
133
134
  "pop-class": "nut-menu__pop",
134
135
  overlayClass: "nut-menu__overlay",
135
136
  overlay: _ctx.parent.props.overlay,
136
- onClosed: _ctx.handleClose,
137
- isWrapTeleport: false
137
+ onClosed: _ctx.handleClose
138
138
  }), {
139
139
  default: withCtx(() => [
140
140
  createElementVNode("view", _hoisted_1, [
141
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.options, (option, index2) => {
141
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.options, (option, index) => {
142
142
  return openBlock(), createElementBlock("view", {
143
- key: index2,
143
+ key: index,
144
144
  class: normalizeClass(["nut-menu-item__option", { active: option.value === _ctx.modelValue }]),
145
145
  style: normalizeStyle({ "flex-basis": 100 / _ctx.cols + "%" }),
146
146
  onClick: ($event) => _ctx.onClick(option)
@@ -164,5 +164,5 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
164
164
  [vShow, _ctx.state.showWrapper]
165
165
  ]);
166
166
  }
167
- var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
168
- export { index as default };
167
+ var index_taro = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
168
+ export { index_taro as default };
@@ -1,9 +1,9 @@
1
1
  /*!
2
- * @nutui/nutui v3.1.18-beta.0 Tue Mar 08 2022 10:41:31 GMT+0800 (中国标准时间)
3
- * (c) 2021 @jdf2e.
2
+ * @nutui/nutui v3.1.19-beta.1 Sat Apr 02 2022 16:26:37 GMT+0800 (中国标准时间)
3
+ * (c) 2022 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
6
- import { ref, computed, resolveComponent, openBlock, createElementBlock, normalizeClass, createElementVNode, createBlock, createCommentVNode, renderSlot, toDisplayString } from "vue";
6
+ import { toRefs, computed, resolveComponent, openBlock, createElementBlock, normalizeClass, createElementVNode, createBlock, createCommentVNode, renderSlot, toDisplayString } from "vue";
7
7
  import { c as createComponent } from "./component.js";
8
8
  import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
9
9
  const { componentName, create } = createComponent("navbar");
@@ -13,18 +13,24 @@ const _sfc_main = create({
13
13
  title: { type: String, default: "" },
14
14
  titIcon: { type: String, default: "" },
15
15
  desc: { type: String, default: "" },
16
- defaultIndex: {
17
- type: Number,
18
- default: 0
16
+ fixed: {
17
+ type: Boolean,
18
+ default: false
19
+ },
20
+ safeAreaInsetTop: {
21
+ type: Boolean,
22
+ default: false
19
23
  }
20
24
  },
21
25
  emits: ["click", "on-click-back", "on-click-title", "on-click-icon", "on-click-right"],
22
26
  setup(props, { emit }) {
23
- const activeIndex = ref(props.defaultIndex);
27
+ const { fixed, safeAreaInsetTop } = toRefs(props);
24
28
  const classes = computed(() => {
25
29
  const prefixCls = componentName;
26
30
  return {
27
- [prefixCls]: true
31
+ [prefixCls]: true,
32
+ [`${prefixCls}--fixed`]: fixed.value,
33
+ [`${prefixCls}--safe-area-inset-top`]: safeAreaInsetTop.value
28
34
  };
29
35
  });
30
36
  function handleLeft() {
@@ -44,8 +50,7 @@ const _sfc_main = create({
44
50
  handleLeft,
45
51
  handleCenter,
46
52
  handleCenterIcon,
47
- handleRight,
48
- activeIndex
53
+ handleRight
49
54
  };
50
55
  }
51
56
  });
@@ -89,5 +94,5 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
89
94
  ])
90
95
  ], 2);
91
96
  }
92
- var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
93
- export { index as default };
97
+ var index_taro = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
98
+ export { index_taro as default };
@@ -18,12 +18,13 @@ var __spreadValues = (a, b) => {
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
20
  /*!
21
- * @nutui/nutui v3.1.18-beta.0 Tue Mar 08 2022 10:41:31 GMT+0800 (中国标准时间)
22
- * (c) 2021 @jdf2e.
21
+ * @nutui/nutui v3.1.19-beta.1 Sat Apr 02 2022 16:26:37 GMT+0800 (中国标准时间)
22
+ * (c) 2022 @jdf2e.
23
23
  * Released under the MIT License.
24
24
  */
25
25
  import { h, ref, reactive, computed, watch, onMounted, onActivated, onDeactivated, onUnmounted, toRefs, resolveComponent, openBlock, createElementBlock, normalizeClass, withDirectives, normalizeStyle, renderSlot, createBlock, createCommentVNode, createElementVNode, createTextVNode, toDisplayString, withModifiers, createVNode, vShow, Fragment, renderList } from "vue";
26
26
  import { c as createComponent } from "./component.js";
27
+ import Taro from "@tarojs/taro";
27
28
  import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
28
29
  const { componentName, create } = createComponent("noticebar");
29
30
  const _sfc_main = create({
@@ -66,7 +67,7 @@ const _sfc_main = create({
66
67
  rightIcon: { type: String, default: "" },
67
68
  color: {
68
69
  type: String,
69
- default: ""
70
+ default: "#F9911B"
70
71
  },
71
72
  background: {
72
73
  type: String,
@@ -88,7 +89,6 @@ const _sfc_main = create({
88
89
  components: {
89
90
  ScrollItem: function(props) {
90
91
  props.item.props.style = props.style;
91
- props.item.key = props.key;
92
92
  return h(props.item);
93
93
  }
94
94
  },
@@ -108,7 +108,8 @@ const _sfc_main = create({
108
108
  distance: 0,
109
109
  timer: null,
110
110
  keepAlive: false,
111
- isCanScroll: null
111
+ isCanScroll: null,
112
+ id: Math.round(Math.random() * 1e5)
112
113
  });
113
114
  const classes = computed(() => {
114
115
  const prefixCls = componentName;
@@ -131,9 +132,10 @@ const _sfc_main = create({
131
132
  }
132
133
  });
133
134
  const barStyle = computed(() => {
134
- let style = {};
135
- props.color && (style.color = props.color);
136
- props.background && (style.background = props.background);
135
+ let style = {
136
+ color: props.color,
137
+ background: props.background
138
+ };
137
139
  if (props.direction == "vertical") {
138
140
  style.height = `${props.height}px`;
139
141
  }
@@ -161,9 +163,8 @@ const _sfc_main = create({
161
163
  };
162
164
  } else {
163
165
  if (state.animate) {
164
- let a = ~~(props.height / props.speed / 4);
165
166
  styles = {
166
- transition: `all ${a == 0 ? ~~(props.height / props.speed) : a}s`,
167
+ transition: `all ${~~(props.height / props.speed / 4)}s`,
167
168
  "margin-top": `-${props.height}px`
168
169
  };
169
170
  }
@@ -184,18 +185,26 @@ const _sfc_main = create({
184
185
  if (!wrap.value || !content.value) {
185
186
  return;
186
187
  }
187
- const wrapWidth = wrap.value.getBoundingClientRect().width;
188
- const offsetWidth = content.value.getBoundingClientRect().width;
189
- state.isCanScroll = props.scrollable == null ? offsetWidth > wrapWidth : props.scrollable;
190
- if (state.isCanScroll) {
191
- state.wrapWidth = wrapWidth;
192
- state.offsetWidth = offsetWidth;
193
- state.duration = offsetWidth / props.speed;
194
- state.animationClass = "play";
195
- } else {
196
- state.animationClass = "";
197
- }
198
- });
188
+ let wrapWidth = 0;
189
+ let offsetWidth = 0;
190
+ Taro.createSelectorQuery().select(`.wrap${state.id}`).boundingClientRect((rect) => {
191
+ if (rect.width > 0)
192
+ wrapWidth = rect.width;
193
+ }).exec();
194
+ Taro.createSelectorQuery().select(`.content${state.id}`).boundingClientRect((rect) => {
195
+ if (rect.width > 0)
196
+ offsetWidth = rect.width;
197
+ state.isCanScroll = props.scrollable == null ? offsetWidth > wrapWidth : props.scrollable;
198
+ if (state.isCanScroll) {
199
+ state.wrapWidth = wrapWidth;
200
+ state.offsetWidth = offsetWidth;
201
+ state.duration = offsetWidth / props.speed;
202
+ state.animationClass = "play";
203
+ } else {
204
+ state.animationClass = "";
205
+ }
206
+ }).exec();
207
+ }, 100);
199
208
  };
200
209
  const handleClick = (event) => {
201
210
  emit("click", event);
@@ -215,7 +224,7 @@ const _sfc_main = create({
215
224
  };
216
225
  const startRollEasy = () => {
217
226
  showhorseLamp();
218
- state.timer = setInterval(showhorseLamp, ~~(props.height / props.speed / 4 * 1e3) + props.standTime);
227
+ state.timer = setInterval(showhorseLamp, ~~(props.height / props.speed / 4) * 1e3 + props.standTime);
219
228
  };
220
229
  const showhorseLamp = () => {
221
230
  state.animate = true;
@@ -223,7 +232,7 @@ const _sfc_main = create({
223
232
  state.scrollList.push(state.scrollList[0]);
224
233
  state.scrollList.shift();
225
234
  state.animate = false;
226
- }, ~~(props.height / props.speed / 4 * 1e3));
235
+ }, ~~(props.height / props.speed / 4) * 1e3);
227
236
  };
228
237
  const startRoll = () => {
229
238
  state.timer = setInterval(() => {
@@ -294,11 +303,7 @@ const _sfc_main = create({
294
303
  });
295
304
  }
296
305
  });
297
- const _hoisted_1 = {
298
- ref: "wrap",
299
- class: "wrap"
300
- };
301
- const _hoisted_2 = ["onClick"];
306
+ const _hoisted_1 = ["onClick"];
302
307
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
303
308
  const _component_nut_icon = resolveComponent("nut-icon");
304
309
  const _component_ScrollItem = resolveComponent("ScrollItem");
@@ -325,10 +330,13 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
325
330
  }, null, 8, ["color"])) : createCommentVNode("", true)
326
331
  ])
327
332
  ], 4)) : createCommentVNode("", true),
328
- createElementVNode("view", _hoisted_1, [
333
+ createElementVNode("view", {
334
+ ref: "wrap",
335
+ class: normalizeClass(`wrap wrap${_ctx.id}`)
336
+ }, [
329
337
  createElementVNode("view", {
330
338
  ref: "content",
331
- class: normalizeClass(["content", [_ctx.animationClass, { "nut-ellipsis": _ctx.isEllipsis }]]),
339
+ class: normalizeClass(["content", [_ctx.animationClass, { "nut-ellipsis": _ctx.isEllipsis }, `content${_ctx.id}`]]),
332
340
  style: normalizeStyle(_ctx.contentStyle),
333
341
  onAnimationend: _cache[0] || (_cache[0] = (...args) => _ctx.onAnimationEnd && _ctx.onAnimationEnd(...args)),
334
342
  onWebkitAnimationEnd: _cache[1] || (_cache[1] = (...args) => _ctx.onAnimationEnd && _ctx.onAnimationEnd(...args))
@@ -337,7 +345,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
337
345
  createTextVNode(toDisplayString(_ctx.text), 1)
338
346
  ])
339
347
  ], 38)
340
- ], 512),
348
+ ], 2),
341
349
  _ctx.closeMode || _ctx.rightIcon ? (openBlock(), createElementBlock("view", {
342
350
  key: 1,
343
351
  class: "right-icon",
@@ -363,9 +371,9 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
363
371
  class: "horseLamp_list",
364
372
  style: normalizeStyle(_ctx.horseLampStyle)
365
373
  }, [
366
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.scrollList, (item, index2) => {
374
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.scrollList, (item, index) => {
367
375
  return openBlock(), createBlock(_component_ScrollItem, {
368
- key: index2,
376
+ key: index,
369
377
  style: normalizeStyle({ height: _ctx.height + "px", "line-height": _ctx.height + "px" }),
370
378
  item
371
379
  }, null, 8, ["style", "item"]);
@@ -375,13 +383,13 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
375
383
  class: "horseLamp_list",
376
384
  style: normalizeStyle(_ctx.horseLampStyle)
377
385
  }, [
378
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.scrollList, (item, index2) => {
386
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.scrollList, (item, index) => {
379
387
  return openBlock(), createElementBlock("li", {
380
388
  class: "horseLamp_list_item",
381
- key: index2,
389
+ key: index,
382
390
  style: normalizeStyle({ height: _ctx.height }),
383
391
  onClick: ($event) => _ctx.go(item)
384
- }, toDisplayString(item), 13, _hoisted_2);
392
+ }, toDisplayString(item), 13, _hoisted_1);
385
393
  }), 128))
386
394
  ], 4)),
387
395
  createElementVNode("view", {
@@ -398,5 +406,5 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
398
406
  ], 4)) : createCommentVNode("", true)
399
407
  ], 2);
400
408
  }
401
- var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
402
- export { index as default };
409
+ var index_taro = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
410
+ export { index_taro as default };