@nutui/nutui 4.0.11 → 4.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/dist/nutui.es.js +1 -1
  2. package/dist/nutui.js +2 -2
  3. package/dist/nutui.umd.js +1 -1
  4. package/dist/packages/_es/ActionSheet.js +111 -78
  5. package/dist/packages/_es/Address.js +375 -250
  6. package/dist/packages/_es/AddressList.js +354 -269
  7. package/dist/packages/_es/Animate.js +58 -41
  8. package/dist/packages/_es/Audio.js +197 -128
  9. package/dist/packages/_es/AudioOperate.js +71 -60
  10. package/dist/packages/_es/Avatar.js +89 -66
  11. package/dist/packages/_es/AvatarGroup.js +31 -23
  12. package/dist/packages/_es/Backtop.js +99 -59
  13. package/dist/packages/_es/Badge.js +47 -36
  14. package/dist/packages/_es/Barrage.js +147 -68
  15. package/dist/packages/_es/Button.js +66 -47
  16. package/dist/packages/_es/Calendar.js +157 -135
  17. package/dist/packages/_es/CalendarItem.js +6 -6
  18. package/dist/packages/_es/Card.js +56 -42
  19. package/dist/packages/_es/Cascader.js +474 -315
  20. package/dist/packages/_es/Category.js +39 -29
  21. package/dist/packages/_es/CategoryPane.js +83 -57
  22. package/dist/packages/_es/Cell.js +71 -56
  23. package/dist/packages/_es/CellGroup.js +27 -19
  24. package/dist/packages/_es/Checkbox.js +156 -109
  25. package/dist/packages/_es/CheckboxGroup.js +59 -38
  26. package/dist/packages/_es/CircleProgress.js +96 -67
  27. package/dist/packages/_es/Col.js +31 -23
  28. package/dist/packages/_es/Collapse.js +58 -33
  29. package/dist/packages/_es/CollapseItem.js +108 -78
  30. package/dist/packages/_es/Comment.js +279 -207
  31. package/dist/packages/_es/ConfigProvider.js +55 -37
  32. package/dist/packages/_es/Countdown.js +212 -100
  33. package/dist/packages/_es/Countup.js +445 -232
  34. package/dist/packages/_es/DatePicker.js +265 -162
  35. package/dist/packages/_es/Dialog.js +213 -161
  36. package/dist/packages/_es/Divider.js +57 -42
  37. package/dist/packages/_es/Drag.js +153 -70
  38. package/dist/packages/_es/Ecard.js +104 -64
  39. package/dist/packages/_es/Elevator.js +219 -143
  40. package/dist/packages/_es/Ellipsis.js +178 -95
  41. package/dist/packages/_es/Empty.js +39 -23
  42. package/dist/packages/_es/FixedNav.js +116 -93
  43. package/dist/packages/_es/Form.js +178 -107
  44. package/dist/packages/_es/FormItem.js +61 -48
  45. package/dist/packages/_es/Grid.js +6 -5
  46. package/dist/packages/_es/GridItem.js +84 -58
  47. package/dist/packages/_es/Image.js +130 -90
  48. package/dist/packages/_es/ImagePreview.js +412 -256
  49. package/dist/packages/_es/Indicator.js +34 -30
  50. package/dist/packages/_es/InfiniteLoading.js +136 -83
  51. package/dist/packages/_es/Input.js +264 -160
  52. package/dist/packages/_es/InputNumber.js +117 -81
  53. package/dist/packages/_es/Interceptor-956b24fc.js +29 -0
  54. package/dist/packages/_es/Invoice.js +130 -104
  55. package/dist/packages/_es/Layout.js +4 -3
  56. package/dist/packages/_es/List.js +215 -117
  57. package/dist/packages/_es/Menu.js +150 -95
  58. package/dist/packages/_es/MenuItem.js +154 -109
  59. package/dist/packages/_es/Navbar.js +119 -103
  60. package/dist/packages/_es/Noticebar.js +312 -197
  61. package/dist/packages/_es/Notify.js +166 -110
  62. package/dist/packages/_es/NumberKeyboard.js +202 -127
  63. package/dist/packages/_es/Overlay.js +80 -52
  64. package/dist/packages/_es/Pagination.js +100 -70
  65. package/dist/packages/_es/Picker.js +437 -275
  66. package/dist/packages/_es/Popover.js +225 -122
  67. package/dist/packages/_es/Popup.js +4 -4
  68. package/dist/packages/_es/Price.js +82 -44
  69. package/dist/packages/_es/Progress.js +79 -63
  70. package/dist/packages/_es/PullRefresh.js +173 -95
  71. package/dist/packages/_es/Radio.js +4 -4
  72. package/dist/packages/_es/RadioGroup.js +3 -3
  73. package/dist/packages/_es/Range.js +347 -204
  74. package/dist/packages/_es/Rate.js +141 -92
  75. package/dist/packages/_es/Row.js +27 -21
  76. package/dist/packages/_es/Searchbar.js +174 -123
  77. package/dist/packages/_es/ShortPassword.js +93 -69
  78. package/dist/packages/_es/SideNavbar.js +80 -49
  79. package/dist/packages/_es/SideNavbarItem.js +32 -22
  80. package/dist/packages/_es/Signature.js +146 -83
  81. package/dist/packages/_es/Skeleton.js +130 -110
  82. package/dist/packages/_es/Sku.js +343 -250
  83. package/dist/packages/_es/Step.js +86 -59
  84. package/dist/packages/_es/Steps.js +31 -26
  85. package/dist/packages/_es/Sticky.js +4 -4
  86. package/dist/packages/_es/SubSideNavbar.js +74 -52
  87. package/dist/packages/_es/Swipe.js +155 -83
  88. package/dist/packages/_es/Swiper.js +311 -174
  89. package/dist/packages/_es/SwiperItem.js +44 -28
  90. package/dist/packages/_es/Switch.js +68 -55
  91. package/dist/packages/_es/TabPane.js +41 -30
  92. package/dist/packages/_es/Tabbar.js +52 -41
  93. package/dist/packages/_es/TabbarItem.js +82 -61
  94. package/dist/packages/_es/Table.js +165 -109
  95. package/dist/packages/_es/Tabs.js +388 -240
  96. package/dist/packages/_es/Tag.js +61 -44
  97. package/dist/packages/_es/Textarea.js +124 -80
  98. package/dist/packages/_es/TimeDetail.js +76 -49
  99. package/dist/packages/_es/TimePannel.js +48 -34
  100. package/dist/packages/_es/TimeSelect.js +68 -47
  101. package/dist/packages/_es/Toast.js +218 -144
  102. package/dist/packages/_es/Tour.js +192 -138
  103. package/dist/packages/_es/TrendArrow.js +77 -57
  104. package/dist/packages/_es/Uploader.js +359 -234
  105. package/dist/packages/_es/Video.js +316 -191
  106. package/dist/packages/_es/Watermark.js +117 -84
  107. package/dist/packages/_es/_plugin-vue_export-helper-cc2b3d55.js +10 -0
  108. package/dist/packages/_es/common-b9a5e726.js +145 -0
  109. package/dist/packages/_es/component-81a4c1d0.js +145 -0
  110. package/dist/packages/_es/index-29892cda.js +33 -0
  111. package/dist/packages/_es/index-43c34ac6.js +30 -0
  112. package/dist/packages/_es/index-54d03fc1.js +8 -0
  113. package/dist/packages/_es/index-79c5dc33.js +10 -0
  114. package/dist/packages/_es/index-7a7385e4.js +67 -0
  115. package/dist/packages/_es/index-87422be8.js +942 -0
  116. package/dist/packages/_es/index-da0a7662.js +259 -0
  117. package/dist/packages/_es/index.vue_vue_type_script_lang-22dfc112.js +46 -0
  118. package/dist/packages/_es/index.vue_vue_type_script_lang-a8856969.js +97 -0
  119. package/dist/packages/_es/index.vue_vue_type_script_lang-cc5c4086.js +151 -0
  120. package/dist/packages/_es/mountComponent-8b24c346.js +39 -0
  121. package/dist/packages/_es/pxCheck-c6b9f6b7.js +6 -0
  122. package/dist/packages/_es/raf-729dad54.js +25 -0
  123. package/dist/packages/_es/renderIcon-3d0fd47c.js +9 -0
  124. package/dist/packages/locale/lang/baseLang-3a8457ac.js +5 -0
  125. package/dist/packages/locale/lang/en-US.js +39 -36
  126. package/dist/packages/locale/lang/id-ID.js +39 -36
  127. package/dist/packages/locale/lang/index.js +44 -22
  128. package/dist/packages/locale/lang/zh-CN.js +38 -35
  129. package/dist/packages/locale/lang/zh-TW.js +38 -35
  130. package/dist/resolver/index.js +26 -1
  131. package/dist/resolver/index.mjs +17 -14
  132. package/dist/smartips/web-types.json +1 -1
  133. package/dist/style.css +1 -1
  134. package/dist/styles/themes/default.scss +48 -48
  135. package/dist/styles/themes/jdb.scss +48 -48
  136. package/dist/styles/themes/jddkh.scss +48 -48
  137. package/dist/styles/themes/jdt.scss +48 -48
  138. package/dist/types/index.d.ts +1 -1
  139. package/package.json +3 -4
  140. package/dist/packages/_es/Interceptor-6e26b757.js +0 -18
  141. package/dist/packages/_es/_plugin-vue_export-helper-dad06003.js +0 -9
  142. package/dist/packages/_es/common-d218746f.js +0 -116
  143. package/dist/packages/_es/component-234624bc.js +0 -89
  144. package/dist/packages/_es/index-14dfadc4.js +0 -561
  145. package/dist/packages/_es/index-192a3ef6.js +0 -29
  146. package/dist/packages/_es/index-360c5092.js +0 -210
  147. package/dist/packages/_es/index-496e6e05.js +0 -24
  148. package/dist/packages/_es/index-50eed3d9.js +0 -7
  149. package/dist/packages/_es/index-53ec2d4d.js +0 -34
  150. package/dist/packages/_es/index-fadb0974.js +0 -8
  151. package/dist/packages/_es/index.vue_vue_type_script_lang-1139b29a.js +0 -43
  152. package/dist/packages/_es/index.vue_vue_type_script_lang-43b774dd.js +0 -77
  153. package/dist/packages/_es/index.vue_vue_type_script_lang-f44c159d.js +0 -110
  154. package/dist/packages/_es/mountComponent-6d4ff200.js +0 -23
  155. package/dist/packages/_es/pxCheck-38173291.js +0 -4
  156. package/dist/packages/_es/raf-a74f1a06.js +0 -16
  157. package/dist/packages/_es/renderIcon-47498b32.js +0 -5
  158. package/dist/packages/locale/lang/baseLang-0bdc6353.js +0 -5
@@ -1,27 +1,44 @@
1
- var I = Object.defineProperty, G = Object.defineProperties;
2
- var J = Object.getOwnPropertyDescriptors;
3
- var k = Object.getOwnPropertySymbols;
4
- var K = Object.prototype.hasOwnProperty, Q = Object.prototype.propertyIsEnumerable;
5
- var B = (o, t, e) => t in o ? I(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e, c = (o, t) => {
6
- for (var e in t || (t = {}))
7
- K.call(t, e) && B(o, e, t[e]);
8
- if (k)
9
- for (var e of k(t))
10
- Q.call(t, e) && B(o, e, t[e]);
11
- return o;
12
- }, C = (o, t) => G(o, J(t));
13
- import { reactive as U, ref as W, computed as Y, watch as $, nextTick as Z, onMounted as _, toRefs as D, openBlock as f, createElementBlock as y, createElementVNode as r, createCommentVNode as L, withDirectives as E, vShow as g, normalizeClass as X, toDisplayString as v, normalizeStyle as R, withModifiers as h } from "vue";
14
- import { c as x } from "./component-234624bc.js";
15
- import { _ as ee } from "./_plugin-vue_export-helper-dad06003.js";
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ import { reactive, ref, computed, watch, nextTick, onMounted, toRefs, openBlock, createElementBlock, createElementVNode, createCommentVNode, withDirectives, vShow, normalizeClass, toDisplayString, normalizeStyle, withModifiers } from "vue";
21
+ import { c as createComponent } from "./component-81a4c1d0.js";
22
+ import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js";
16
23
  import "../locale/lang";
17
- function A(o, t) {
18
- let e = null, a = Date.now();
24
+ function throttle(fn, delay) {
25
+ let timer = null;
26
+ let startTime = Date.now();
19
27
  return function() {
20
- let p = Date.now(), u = t - (p - a);
21
- e && clearTimeout(e), u <= 0 ? (o.apply(null, arguments), a = Date.now()) : e = setTimeout(o, u);
28
+ let now = Date.now();
29
+ let remaining = delay - (now - startTime);
30
+ if (timer)
31
+ clearTimeout(timer);
32
+ if (remaining <= 0) {
33
+ fn.apply(null, arguments);
34
+ startTime = Date.now();
35
+ } else {
36
+ timer = setTimeout(fn, remaining);
37
+ }
22
38
  };
23
39
  }
24
- const { create: oe, translate: te } = x("video"), le = oe({
40
+ const { create, translate } = createComponent("video");
41
+ const _sfc_main = create({
25
42
  props: {
26
43
  source: {
27
44
  type: Object,
@@ -30,22 +47,22 @@ const { create: oe, translate: te } = x("video"), le = oe({
30
47
  options: {
31
48
  type: Object,
32
49
  default: {
33
- autoplay: !1,
50
+ autoplay: false,
34
51
  //是否自动播放
35
52
  volume: 0.5,
36
53
  poster: "",
37
- loop: !1,
38
- controls: !0,
39
- muted: !1,
54
+ loop: false,
55
+ controls: true,
56
+ muted: false,
40
57
  //是否静音
41
- disabled: !1,
58
+ disabled: false,
42
59
  //禁止操作
43
- playsinline: !1,
60
+ playsinline: false,
44
61
  //行内展示
45
- touchPlay: !1,
62
+ touchPlay: false,
46
63
  preload: ""
47
64
  },
48
- required: !0
65
+ required: true
49
66
  },
50
67
  model: {
51
68
  type: String,
@@ -54,12 +71,12 @@ const { create: oe, translate: te } = x("video"), le = oe({
54
71
  },
55
72
  components: {},
56
73
  emits: ["click", "play", "pause", "playend", "time"],
57
- setup(o, { emit: t }) {
58
- const e = U({
74
+ setup(props, { emit }) {
75
+ const state = reactive({
59
76
  videoElm: null,
60
- initial: !0,
77
+ initial: true,
61
78
  //控制封面的显示
62
- showToolbox: !1,
79
+ showToolbox: false,
63
80
  //控制控制器和标题的显示
64
81
  // 视频容器元素
65
82
  player: {
@@ -88,214 +105,322 @@ const { create: oe, translate: te } = x("video"), le = oe({
88
105
  }
89
106
  },
90
107
  state: {
91
- controlShow: !0,
108
+ controlShow: true,
92
109
  vol: 0.5,
93
110
  //音量
94
111
  currentTime: 0,
95
112
  //当前时间
96
- fullScreen: !1,
97
- playing: !1,
113
+ fullScreen: false,
114
+ playing: false,
98
115
  //是否正在播放
99
- isLoading: !1,
100
- isEnd: !1,
101
- isError: !1,
102
- isMuted: !1
116
+ isLoading: false,
117
+ isEnd: false,
118
+ isError: false,
119
+ isMuted: false
103
120
  },
104
- showTouchMask: !1
105
- }), a = W(null), p = Y(() => o.options.disabled);
106
- $(
107
- () => o.source,
108
- (s) => {
109
- s.src && Z(() => {
110
- e.videoElm.load();
111
- });
121
+ showTouchMask: false
122
+ });
123
+ const root = ref(null);
124
+ const isDisabled = computed(() => {
125
+ return props.options.disabled;
126
+ });
127
+ watch(
128
+ () => props.source,
129
+ (newValue) => {
130
+ if (newValue.src) {
131
+ nextTick(() => {
132
+ state.videoElm.load();
133
+ });
134
+ }
112
135
  },
113
- { immediate: !0, deep: !0 }
114
- ), $(
115
- () => o.options,
116
- (s) => {
117
- e.state.isMuted = s ? s.muted : !1;
136
+ { immediate: true, deep: true }
137
+ );
138
+ watch(
139
+ () => props.options,
140
+ (newValue) => {
141
+ state.state.isMuted = newValue ? newValue.muted : false;
118
142
  },
119
- { immediate: !0 }
143
+ { immediate: true }
120
144
  );
121
- const u = () => {
122
- e.videoElm = a.value, o.options.autoplay && setTimeout(() => {
123
- e.videoElm.play();
124
- }, 200), o.options.touchPlay && (e.showTouchMask = !0), o.options.playsinline && (e.videoElm.setAttribute("playsinline", o.options.playsinline), e.videoElm.setAttribute("webkit-playsinline", o.options.playsinline), e.videoElm.setAttribute("x5-video-player-type", "h5-page"), e.videoElm.setAttribute("x5-video-player-fullscreen", !1)), N(), e.showToolbox ? l() : (e.videoElm.addEventListener("play", () => {
125
- e.state.playing = !0, t("play", e.videoElm);
126
- }), e.videoElm.addEventListener("pause", () => {
127
- e.state.playing = !1, t("pause", e.videoElm);
128
- }), e.videoElm.addEventListener("ended", w), e.videoElm.addEventListener("timeupdate", A(T, 1e3)));
129
- }, l = () => {
130
- const s = a.value, n = a.value.getElementsByClassName("nut-video-controller__progress-value")[0];
131
- e.player.$player = s, e.progressBar.progressElm = n, e.progressBar.pos = n.getBoundingClientRect(), e.videoSet.progress.width = Math.round(n.getBoundingClientRect().width);
132
- }, P = () => {
133
- if (o.options.autoplay && o.options.disabled)
134
- return e.state.playing = !0, !1;
135
- if (e.state.playing = !e.state.playing, e.videoElm)
136
- if (e.state.playing)
145
+ const init = () => {
146
+ state.videoElm = root.value;
147
+ if (props.options.autoplay) {
148
+ setTimeout(() => {
149
+ state.videoElm.play();
150
+ }, 200);
151
+ }
152
+ if (props.options.touchPlay) {
153
+ state.showTouchMask = true;
154
+ }
155
+ if (props.options.playsinline) {
156
+ state.videoElm.setAttribute("playsinline", props.options.playsinline);
157
+ state.videoElm.setAttribute("webkit-playsinline", props.options.playsinline);
158
+ state.videoElm.setAttribute("x5-video-player-type", "h5-page");
159
+ state.videoElm.setAttribute("x5-video-player-fullscreen", false);
160
+ }
161
+ volumeHandle();
162
+ if (state.showToolbox) {
163
+ customerInit();
164
+ } else {
165
+ state.videoElm.addEventListener("play", () => {
166
+ state.state.playing = true;
167
+ emit("play", state.videoElm);
168
+ });
169
+ state.videoElm.addEventListener("pause", () => {
170
+ state.state.playing = false;
171
+ emit("pause", state.videoElm);
172
+ });
173
+ state.videoElm.addEventListener("ended", playEnded);
174
+ state.videoElm.addEventListener("timeupdate", throttle(getPlayTime, 1e3));
175
+ }
176
+ };
177
+ const customerInit = () => {
178
+ const $player = root.value;
179
+ const $progress = root.value.getElementsByClassName("nut-video-controller__progress-value")[0];
180
+ state.player.$player = $player;
181
+ state.progressBar.progressElm = $progress;
182
+ state.progressBar.pos = $progress.getBoundingClientRect();
183
+ state.videoSet.progress.width = Math.round($progress.getBoundingClientRect().width);
184
+ };
185
+ const play = () => {
186
+ if (props.options.autoplay && props.options.disabled) {
187
+ state.state.playing = true;
188
+ return false;
189
+ }
190
+ state.state.playing = !state.state.playing;
191
+ if (state.videoElm) {
192
+ if (state.state.playing) {
137
193
  try {
138
194
  setTimeout(() => {
139
- e.videoElm.play();
140
- }, 200), e.videoElm.addEventListener("progress", () => {
141
- F();
142
- }), e.videoElm.addEventListener("timeupdate", A(T, 1e3)), e.videoElm.addEventListener("ended", w), t("play", e.videoElm);
143
- } catch (s) {
144
- b();
195
+ state.videoElm.play();
196
+ }, 200);
197
+ state.videoElm.addEventListener("progress", () => {
198
+ getLoadTime();
199
+ });
200
+ state.videoElm.addEventListener("timeupdate", throttle(getPlayTime, 1e3));
201
+ state.videoElm.addEventListener("ended", playEnded);
202
+ emit("play", state.videoElm);
203
+ } catch (e) {
204
+ handleError();
145
205
  }
146
- else
147
- e.videoElm.pause(), t("pause", e.videoElm);
148
- }, S = (s) => {
149
- var n = Math.floor(s / 3600);
150
- n < 10 && (n = "0" + n);
151
- var i = Math.floor(s % 3600 / 60);
152
- i < 10 && (i = "0" + i);
153
- var d = Math.round(s % 3600 % 60);
154
- d < 10 && (d = "0" + d);
155
- var m = "";
156
- return n != 0 ? m = n + ":" + i + ":" + d : m = i + ":" + d, m;
157
- }, F = () => {
158
- e.videoSet.loaded && (e.videoSet.loaded = e.videoElm.buffered.end(0) / e.videoElm.duration * 100);
159
- }, T = () => {
160
- const s = e.videoElm.currentTime / e.videoElm.duration;
161
- e.videoSet.progress.current = Math.round(e.videoSet.progress.width * s), e.videoSet.totalTime = S(e.videoElm.duration), e.videoSet.displayTime = S(e.videoElm.currentTime), t("time", e.videoSet.displayTime, e.videoSet.totalTime);
162
- }, w = () => {
163
- e.state.playing = !1, e.state.isEnd = !0, e.videoSet.displayTime = "00:00", e.videoSet.progress.current = 0, e.videoElm.currentTime = 0, t("playend", e.videoElm);
164
- }, b = () => {
165
- e.state.isError = !0;
166
- }, N = () => {
167
- e.state.vol = o.options.volume;
168
- }, j = () => {
169
- e.state.isMuted = !e.state.isMuted, e.videoElm.muted = e.state.isMuted;
170
- }, q = () => {
171
- }, z = (s) => {
172
- let i = s.targetTouches[0].pageX - e.progressBar.pos.left;
173
- i <= 0 && (i = 0), i >= e.videoSet.progress.width && (i = e.videoSet.progress.width), e.videoSet.progress.current = i;
174
- let d = e.videoSet.progress.current / e.videoSet.progress.width;
175
- e.videoElm.duration && M(d, e.videoElm.duration);
176
- }, O = (s) => {
177
- let i = s.changedTouches[0].pageX - e.progressBar.pos.left;
178
- e.videoSet.progress.current = i;
179
- let d = i / e.videoSet.progress.width;
180
- e.videoElm.duration && M(d, e.videoElm.duration);
181
- }, M = (s, n) => {
182
- e.videoElm.currentTime = Math.floor(s * n);
183
- }, V = () => {
184
- e.state.isError = !1, u();
185
- }, H = () => {
186
- e.state.fullScreen ? (e.state.fullScreen = !1, document.webkitCancelFullScreen()) : (e.state.fullScreen = !0, e.videoElm.webkitRequestFullScreen());
206
+ } else {
207
+ state.videoElm.pause();
208
+ emit("pause", state.videoElm);
209
+ }
210
+ }
211
+ };
212
+ const timeFormat = (t) => {
213
+ var h = Math.floor(t / 3600);
214
+ if (h < 10) {
215
+ h = "0" + h;
216
+ }
217
+ var m = Math.floor(t % 3600 / 60);
218
+ if (m < 10) {
219
+ m = "0" + m;
220
+ }
221
+ var s = Math.round(t % 3600 % 60);
222
+ if (s < 10) {
223
+ s = "0" + s;
224
+ }
225
+ var str = "";
226
+ if (h != 0) {
227
+ str = h + ":" + m + ":" + s;
228
+ } else {
229
+ str = m + ":" + s;
230
+ }
231
+ return str;
232
+ };
233
+ const getLoadTime = () => {
234
+ if (state.videoSet.loaded)
235
+ state.videoSet.loaded = state.videoElm.buffered.end(0) / state.videoElm.duration * 100;
187
236
  };
188
- return _(() => {
189
- u();
190
- }), C(c(c({
191
- root: a
192
- }, D(o)), D(e)), {
193
- handleError: b,
194
- isDisabled: p,
195
- play: P,
196
- handleMuted: j,
197
- touchSlidSrart: q,
198
- touchSlidMove: z,
199
- touchSlidEnd: O,
200
- retry: V,
201
- fullScreen: H,
202
- translate: te
237
+ const getPlayTime = () => {
238
+ const percent = state.videoElm.currentTime / state.videoElm.duration;
239
+ state.videoSet.progress.current = Math.round(state.videoSet.progress.width * percent);
240
+ state.videoSet.totalTime = timeFormat(state.videoElm.duration);
241
+ state.videoSet.displayTime = timeFormat(state.videoElm.currentTime);
242
+ emit("time", state.videoSet.displayTime, state.videoSet.totalTime);
243
+ };
244
+ const playEnded = () => {
245
+ state.state.playing = false;
246
+ state.state.isEnd = true;
247
+ state.videoSet.displayTime = "00:00";
248
+ state.videoSet.progress.current = 0;
249
+ state.videoElm.currentTime = 0;
250
+ emit("playend", state.videoElm);
251
+ };
252
+ const handleError = () => {
253
+ state.state.isError = true;
254
+ };
255
+ const volumeHandle = () => {
256
+ state.state.vol = props.options.volume;
257
+ };
258
+ const handleMuted = () => {
259
+ state.state.isMuted = !state.state.isMuted;
260
+ state.videoElm.muted = state.state.isMuted;
261
+ };
262
+ const touchSlidSrart = () => {
263
+ };
264
+ const touchSlidMove = (e) => {
265
+ let currentX = e.targetTouches[0].pageX;
266
+ let offsetX = currentX - state.progressBar.pos.left;
267
+ if (offsetX <= 0) {
268
+ offsetX = 0;
269
+ }
270
+ if (offsetX >= state.videoSet.progress.width) {
271
+ offsetX = state.videoSet.progress.width;
272
+ }
273
+ state.videoSet.progress.current = offsetX;
274
+ let percent = state.videoSet.progress.current / state.videoSet.progress.width;
275
+ state.videoElm.duration && setPlayTime(percent, state.videoElm.duration);
276
+ };
277
+ const touchSlidEnd = (e) => {
278
+ let currentX = e.changedTouches[0].pageX;
279
+ let offsetX = currentX - state.progressBar.pos.left;
280
+ state.videoSet.progress.current = offsetX;
281
+ let percent = offsetX / state.videoSet.progress.width;
282
+ state.videoElm.duration && setPlayTime(percent, state.videoElm.duration);
283
+ };
284
+ const setPlayTime = (percent, totalTime) => {
285
+ state.videoElm.currentTime = Math.floor(percent * totalTime);
286
+ };
287
+ const retry = () => {
288
+ state.state.isError = false;
289
+ init();
290
+ };
291
+ const fullScreen = () => {
292
+ if (!state.state.fullScreen) {
293
+ state.state.fullScreen = true;
294
+ state.videoElm.webkitRequestFullScreen();
295
+ } else {
296
+ state.state.fullScreen = false;
297
+ document.webkitCancelFullScreen();
298
+ }
299
+ };
300
+ onMounted(() => {
301
+ init();
302
+ });
303
+ return __spreadProps(__spreadValues(__spreadValues({
304
+ root
305
+ }, toRefs(props)), toRefs(state)), {
306
+ handleError,
307
+ isDisabled,
308
+ play,
309
+ handleMuted,
310
+ touchSlidSrart,
311
+ touchSlidMove,
312
+ touchSlidEnd,
313
+ retry,
314
+ fullScreen,
315
+ translate
203
316
  });
204
317
  }
205
- }), se = {
318
+ });
319
+ const _hoisted_1 = {
206
320
  class: "nut-video",
207
321
  ref: "videocon"
208
- }, re = ["muted", "autoplay", "loop", "poster", "controls", "preload"], ie = ["src", "type"], ne = { class: "nut-video-controller__now" }, de = { class: "nut-video-controller__progress" }, ae = {
322
+ };
323
+ const _hoisted_2 = ["muted", "autoplay", "loop", "poster", "controls", "preload"];
324
+ const _hoisted_3 = ["src", "type"];
325
+ const _hoisted_4 = { class: "nut-video-controller__now" };
326
+ const _hoisted_5 = { class: "nut-video-controller__progress" };
327
+ const _hoisted_6 = {
209
328
  class: "nut-video-controller__progress-value",
210
329
  ref: "progressBar"
211
- }, ue = /* @__PURE__ */ r("div", { class: "nut-video-controller__ball-move" }, null, -1), pe = [
212
- ue
213
- ], ve = {
330
+ };
331
+ const _hoisted_7 = /* @__PURE__ */ createElementVNode("div", { class: "nut-video-controller__ball-move" }, null, -1);
332
+ const _hoisted_8 = [
333
+ _hoisted_7
334
+ ];
335
+ const _hoisted_9 = {
214
336
  class: "nut-video-controller__played",
215
337
  ref: "playedBar"
216
- }, me = { class: "nut-video-controller__total" }, ce = { class: "nut-video-error" }, fe = { class: "nut-video-error-tip" };
217
- function ye(o, t, e, a, p, u) {
218
- return f(), y("div", se, [
219
- r("video", {
338
+ };
339
+ const _hoisted_10 = { class: "nut-video-controller__total" };
340
+ const _hoisted_11 = { class: "nut-video-error" };
341
+ const _hoisted_12 = { class: "nut-video-error-tip" };
342
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
343
+ return openBlock(), createElementBlock("div", _hoisted_1, [
344
+ createElementVNode("video", {
220
345
  ref: "root",
221
346
  class: "nut-video-player",
222
- muted: o.options.muted,
223
- autoplay: o.options.autoplay,
224
- loop: o.options.loop,
225
- poster: o.options.poster,
226
- controls: o.options.controls,
227
- preload: o.options.preload,
228
- onError: t[0] || (t[0] = (...l) => o.handleError && o.handleError(...l))
347
+ muted: _ctx.options.muted,
348
+ autoplay: _ctx.options.autoplay,
349
+ loop: _ctx.options.loop,
350
+ poster: _ctx.options.poster,
351
+ controls: _ctx.options.controls,
352
+ preload: _ctx.options.preload,
353
+ onError: _cache[0] || (_cache[0] = (...args) => _ctx.handleError && _ctx.handleError(...args))
229
354
  }, [
230
- r("source", {
231
- src: o.source.src,
232
- type: o.source.type
233
- }, null, 8, ie)
234
- ], 40, re),
235
- o.showToolbox && !o.isDisabled ? (f(), y("div", {
355
+ createElementVNode("source", {
356
+ src: _ctx.source.src,
357
+ type: _ctx.source.type
358
+ }, null, 8, _hoisted_3)
359
+ ], 40, _hoisted_2),
360
+ _ctx.showToolbox && !_ctx.isDisabled ? (openBlock(), createElementBlock("div", {
236
361
  key: 0,
237
362
  class: "nut-video-mask",
238
363
  ref: "touchMask",
239
- onClick: t[1] || (t[1] = (...l) => o.play && o.play(...l))
240
- }, null, 512)) : L("", !0),
241
- o.showToolbox && !o.isDisabled ? E((f(), y("div", {
364
+ onClick: _cache[1] || (_cache[1] = (...args) => _ctx.play && _ctx.play(...args))
365
+ }, null, 512)) : createCommentVNode("", true),
366
+ _ctx.showToolbox && !_ctx.isDisabled ? withDirectives((openBlock(), createElementBlock("div", {
242
367
  key: 1,
243
368
  class: "nut-video-play-btn",
244
369
  ref: "palyBtn",
245
- onClick: t[2] || (t[2] = (...l) => o.play && o.play(...l))
370
+ onClick: _cache[2] || (_cache[2] = (...args) => _ctx.play && _ctx.play(...args))
246
371
  }, null, 512)), [
247
- [g, !o.state.playing]
248
- ]) : L("", !0),
249
- E(r("div", {
250
- class: X(["nut-video-controller", { "nut-video-controller--show": !o.state.playing, "nut-video-controller--hide": o.state.playing }])
372
+ [vShow, !_ctx.state.playing]
373
+ ]) : createCommentVNode("", true),
374
+ withDirectives(createElementVNode("div", {
375
+ class: normalizeClass(["nut-video-controller", { "nut-video-controller--show": !_ctx.state.playing, "nut-video-controller--hide": _ctx.state.playing }])
251
376
  }, [
252
- r("div", {
377
+ createElementVNode("div", {
253
378
  class: "nut-video-controller__playbtn",
254
- onClick: t[3] || (t[3] = (...l) => o.play && o.play(...l))
379
+ onClick: _cache[3] || (_cache[3] = (...args) => _ctx.play && _ctx.play(...args))
255
380
  }),
256
- r("div", ne, v(o.videoSet.displayTime), 1),
257
- r("div", de, [
258
- r("div", ae, [
259
- r("div", {
381
+ createElementVNode("div", _hoisted_4, toDisplayString(_ctx.videoSet.displayTime), 1),
382
+ createElementVNode("div", _hoisted_5, [
383
+ createElementVNode("div", _hoisted_6, [
384
+ createElementVNode("div", {
260
385
  class: "buffered",
261
- style: R({ width: `${o.videoSet.loaded}%` })
386
+ style: normalizeStyle({ width: `${_ctx.videoSet.loaded}%` })
262
387
  }, null, 4),
263
- r("div", {
388
+ createElementVNode("div", {
264
389
  class: "nut-video-controller__ball",
265
- style: R({
266
- transform: `translate3d(${o.videoSet.progress.current}px, -50%, 0)`
390
+ style: normalizeStyle({
391
+ transform: `translate3d(${_ctx.videoSet.progress.current}px, -50%, 0)`
267
392
  }),
268
- onTouchmove: t[4] || (t[4] = h((l) => o.touchSlidMove(l), ["stop", "prevent"])),
269
- onTouchstart: t[5] || (t[5] = h((l) => o.touchSlidSrart(), ["stop"])),
270
- onTouchend: t[6] || (t[6] = h((l) => o.touchSlidEnd(l), ["stop"]))
271
- }, pe, 36),
272
- r("div", ve, null, 512)
393
+ onTouchmove: _cache[4] || (_cache[4] = withModifiers(($event) => _ctx.touchSlidMove($event), ["stop", "prevent"])),
394
+ onTouchstart: _cache[5] || (_cache[5] = withModifiers(($event) => _ctx.touchSlidSrart(), ["stop"])),
395
+ onTouchend: _cache[6] || (_cache[6] = withModifiers(($event) => _ctx.touchSlidEnd($event), ["stop"]))
396
+ }, _hoisted_8, 36),
397
+ createElementVNode("div", _hoisted_9, null, 512)
273
398
  ], 512)
274
399
  ]),
275
- r("div", me, v(o.videoSet.totalTime), 1),
276
- r("div", {
277
- class: X(["nut-video-controller__volume", { muted: o.state.isMuted }]),
278
- onClick: t[7] || (t[7] = (...l) => o.handleMuted && o.handleMuted(...l))
400
+ createElementVNode("div", _hoisted_10, toDisplayString(_ctx.videoSet.totalTime), 1),
401
+ createElementVNode("div", {
402
+ class: normalizeClass(["nut-video-controller__volume", { muted: _ctx.state.isMuted }]),
403
+ onClick: _cache[7] || (_cache[7] = (...args) => _ctx.handleMuted && _ctx.handleMuted(...args))
279
404
  }, null, 2),
280
- r("div", {
405
+ createElementVNode("div", {
281
406
  class: "nut-video-controller__full",
282
- onClick: t[8] || (t[8] = (...l) => o.fullScreen && o.fullScreen(...l))
407
+ onClick: _cache[8] || (_cache[8] = (...args) => _ctx.fullScreen && _ctx.fullScreen(...args))
283
408
  })
284
409
  ], 2), [
285
- [g, o.showToolbox && !o.isDisabled]
410
+ [vShow, _ctx.showToolbox && !_ctx.isDisabled]
286
411
  ]),
287
- E(r("div", ce, [
288
- r("p", fe, v(o.translate("errorTip")), 1),
289
- r("p", {
412
+ withDirectives(createElementVNode("div", _hoisted_11, [
413
+ createElementVNode("p", _hoisted_12, toDisplayString(_ctx.translate("errorTip")), 1),
414
+ createElementVNode("p", {
290
415
  class: "nut-video-error-retry",
291
- onClick: t[9] || (t[9] = (...l) => o.retry && o.retry(...l))
292
- }, v(o.translate("clickRetry")), 1)
416
+ onClick: _cache[9] || (_cache[9] = (...args) => _ctx.retry && _ctx.retry(...args))
417
+ }, toDisplayString(_ctx.translate("clickRetry")), 1)
293
418
  ], 512), [
294
- [g, o.state.isError]
419
+ [vShow, _ctx.state.isError]
295
420
  ])
296
421
  ], 512);
297
422
  }
298
- const we = /* @__PURE__ */ ee(le, [["render", ye]]);
423
+ const Video = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
299
424
  export {
300
- we as default
425
+ Video as default
301
426
  };