@nutui/nutui 4.0.12-beta.1 → 4.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/dist/nutui.es.js +1 -1
  2. package/dist/nutui.js +1 -1
  3. package/dist/nutui.umd.js +1 -1
  4. package/dist/packages/_es/ActionSheet.js +111 -78
  5. package/dist/packages/_es/Address.js +375 -250
  6. package/dist/packages/_es/AddressList.js +354 -269
  7. package/dist/packages/_es/Animate.js +58 -41
  8. package/dist/packages/_es/Audio.js +197 -128
  9. package/dist/packages/_es/AudioOperate.js +71 -60
  10. package/dist/packages/_es/Avatar.js +89 -66
  11. package/dist/packages/_es/AvatarGroup.js +31 -23
  12. package/dist/packages/_es/Backtop.js +99 -59
  13. package/dist/packages/_es/Badge.js +47 -36
  14. package/dist/packages/_es/Barrage.js +147 -68
  15. package/dist/packages/_es/Button.js +66 -47
  16. package/dist/packages/_es/Calendar.js +157 -135
  17. package/dist/packages/_es/CalendarItem.js +6 -6
  18. package/dist/packages/_es/Card.js +56 -42
  19. package/dist/packages/_es/Cascader.js +474 -315
  20. package/dist/packages/_es/Category.js +39 -29
  21. package/dist/packages/_es/CategoryPane.js +83 -57
  22. package/dist/packages/_es/Cell.js +71 -56
  23. package/dist/packages/_es/CellGroup.js +27 -19
  24. package/dist/packages/_es/Checkbox.js +156 -109
  25. package/dist/packages/_es/CheckboxGroup.js +59 -38
  26. package/dist/packages/_es/CircleProgress.js +96 -67
  27. package/dist/packages/_es/Col.js +31 -23
  28. package/dist/packages/_es/Collapse.js +58 -33
  29. package/dist/packages/_es/CollapseItem.js +108 -78
  30. package/dist/packages/_es/Comment.js +279 -207
  31. package/dist/packages/_es/ConfigProvider.js +55 -37
  32. package/dist/packages/_es/Countdown.js +212 -100
  33. package/dist/packages/_es/Countup.js +445 -232
  34. package/dist/packages/_es/DatePicker.js +265 -162
  35. package/dist/packages/_es/Dialog.js +213 -161
  36. package/dist/packages/_es/Divider.js +57 -42
  37. package/dist/packages/_es/Drag.js +153 -70
  38. package/dist/packages/_es/Ecard.js +104 -64
  39. package/dist/packages/_es/Elevator.js +219 -143
  40. package/dist/packages/_es/Ellipsis.js +178 -95
  41. package/dist/packages/_es/Empty.js +39 -23
  42. package/dist/packages/_es/FixedNav.js +116 -93
  43. package/dist/packages/_es/Form.js +178 -107
  44. package/dist/packages/_es/FormItem.js +61 -48
  45. package/dist/packages/_es/Grid.js +6 -5
  46. package/dist/packages/_es/GridItem.js +84 -58
  47. package/dist/packages/_es/Image.js +130 -90
  48. package/dist/packages/_es/ImagePreview.js +412 -256
  49. package/dist/packages/_es/Indicator.js +34 -30
  50. package/dist/packages/_es/InfiniteLoading.js +136 -83
  51. package/dist/packages/_es/Input.js +264 -160
  52. package/dist/packages/_es/InputNumber.js +117 -81
  53. package/dist/packages/_es/Interceptor-956b24fc.js +29 -0
  54. package/dist/packages/_es/Invoice.js +130 -104
  55. package/dist/packages/_es/Layout.js +4 -3
  56. package/dist/packages/_es/List.js +215 -117
  57. package/dist/packages/_es/Menu.js +150 -95
  58. package/dist/packages/_es/MenuItem.js +154 -109
  59. package/dist/packages/_es/Navbar.js +119 -103
  60. package/dist/packages/_es/Noticebar.js +312 -197
  61. package/dist/packages/_es/Notify.js +166 -110
  62. package/dist/packages/_es/NumberKeyboard.js +202 -127
  63. package/dist/packages/_es/Overlay.js +80 -52
  64. package/dist/packages/_es/Pagination.js +100 -70
  65. package/dist/packages/_es/Picker.js +437 -275
  66. package/dist/packages/_es/Popover.js +225 -122
  67. package/dist/packages/_es/Popup.js +4 -4
  68. package/dist/packages/_es/Price.js +82 -44
  69. package/dist/packages/_es/Progress.js +79 -63
  70. package/dist/packages/_es/PullRefresh.js +173 -95
  71. package/dist/packages/_es/Radio.js +4 -4
  72. package/dist/packages/_es/RadioGroup.js +3 -3
  73. package/dist/packages/_es/Range.js +347 -204
  74. package/dist/packages/_es/Rate.js +141 -92
  75. package/dist/packages/_es/Row.js +27 -21
  76. package/dist/packages/_es/Searchbar.js +174 -123
  77. package/dist/packages/_es/ShortPassword.js +93 -69
  78. package/dist/packages/_es/SideNavbar.js +80 -49
  79. package/dist/packages/_es/SideNavbarItem.js +32 -22
  80. package/dist/packages/_es/Signature.js +146 -83
  81. package/dist/packages/_es/Skeleton.js +130 -110
  82. package/dist/packages/_es/Sku.js +343 -250
  83. package/dist/packages/_es/Step.js +86 -59
  84. package/dist/packages/_es/Steps.js +31 -26
  85. package/dist/packages/_es/Sticky.js +4 -4
  86. package/dist/packages/_es/SubSideNavbar.js +74 -52
  87. package/dist/packages/_es/Swipe.js +155 -83
  88. package/dist/packages/_es/Swiper.js +311 -174
  89. package/dist/packages/_es/SwiperItem.js +44 -28
  90. package/dist/packages/_es/Switch.js +68 -55
  91. package/dist/packages/_es/TabPane.js +41 -30
  92. package/dist/packages/_es/Tabbar.js +52 -41
  93. package/dist/packages/_es/TabbarItem.js +82 -61
  94. package/dist/packages/_es/Table.js +165 -109
  95. package/dist/packages/_es/Tabs.js +388 -240
  96. package/dist/packages/_es/Tag.js +61 -44
  97. package/dist/packages/_es/Textarea.js +124 -80
  98. package/dist/packages/_es/TimeDetail.js +76 -49
  99. package/dist/packages/_es/TimePannel.js +48 -34
  100. package/dist/packages/_es/TimeSelect.js +68 -47
  101. package/dist/packages/_es/Toast.js +218 -144
  102. package/dist/packages/_es/Tour.js +192 -138
  103. package/dist/packages/_es/TrendArrow.js +77 -57
  104. package/dist/packages/_es/Uploader.js +359 -234
  105. package/dist/packages/_es/Video.js +316 -191
  106. package/dist/packages/_es/Watermark.js +117 -84
  107. package/dist/packages/_es/_plugin-vue_export-helper-cc2b3d55.js +10 -0
  108. package/dist/packages/_es/common-b9a5e726.js +145 -0
  109. package/dist/packages/_es/component-81a4c1d0.js +145 -0
  110. package/dist/packages/_es/index-29892cda.js +33 -0
  111. package/dist/packages/_es/index-43c34ac6.js +30 -0
  112. package/dist/packages/_es/index-54d03fc1.js +8 -0
  113. package/dist/packages/_es/index-79c5dc33.js +10 -0
  114. package/dist/packages/_es/index-7a7385e4.js +67 -0
  115. package/dist/packages/_es/index-87422be8.js +942 -0
  116. package/dist/packages/_es/index-da0a7662.js +259 -0
  117. package/dist/packages/_es/index.vue_vue_type_script_lang-22dfc112.js +46 -0
  118. package/dist/packages/_es/index.vue_vue_type_script_lang-a8856969.js +97 -0
  119. package/dist/packages/_es/index.vue_vue_type_script_lang-cc5c4086.js +151 -0
  120. package/dist/packages/_es/mountComponent-8b24c346.js +39 -0
  121. package/dist/packages/_es/pxCheck-c6b9f6b7.js +6 -0
  122. package/dist/packages/_es/raf-729dad54.js +25 -0
  123. package/dist/packages/_es/renderIcon-3d0fd47c.js +9 -0
  124. package/dist/packages/locale/lang/baseLang-3a8457ac.js +5 -0
  125. package/dist/packages/locale/lang/en-US.js +39 -36
  126. package/dist/packages/locale/lang/id-ID.js +39 -36
  127. package/dist/packages/locale/lang/index.js +44 -22
  128. package/dist/packages/locale/lang/zh-CN.js +38 -35
  129. package/dist/packages/locale/lang/zh-TW.js +38 -35
  130. package/dist/resolver/index.js +26 -1
  131. package/dist/resolver/index.mjs +17 -14
  132. package/dist/smartips/web-types.json +1 -1
  133. package/dist/style.css +1 -1
  134. package/dist/styles/themes/default.scss +50 -50
  135. package/dist/styles/themes/jdb.scss +50 -50
  136. package/dist/styles/themes/jddkh.scss +50 -50
  137. package/dist/styles/themes/jdt.scss +50 -50
  138. package/dist/types/index.d.ts +1 -1
  139. package/package.json +2 -2
  140. package/dist/packages/_es/Interceptor-6e26b757.js +0 -18
  141. package/dist/packages/_es/_plugin-vue_export-helper-dad06003.js +0 -9
  142. package/dist/packages/_es/common-d218746f.js +0 -116
  143. package/dist/packages/_es/component-234624bc.js +0 -89
  144. package/dist/packages/_es/index-14dfadc4.js +0 -561
  145. package/dist/packages/_es/index-192a3ef6.js +0 -29
  146. package/dist/packages/_es/index-360c5092.js +0 -210
  147. package/dist/packages/_es/index-496e6e05.js +0 -24
  148. package/dist/packages/_es/index-50eed3d9.js +0 -7
  149. package/dist/packages/_es/index-53ec2d4d.js +0 -34
  150. package/dist/packages/_es/index-fadb0974.js +0 -8
  151. package/dist/packages/_es/index.vue_vue_type_script_lang-1139b29a.js +0 -43
  152. package/dist/packages/_es/index.vue_vue_type_script_lang-43b774dd.js +0 -77
  153. package/dist/packages/_es/index.vue_vue_type_script_lang-f44c159d.js +0 -110
  154. package/dist/packages/_es/mountComponent-6d4ff200.js +0 -23
  155. package/dist/packages/_es/pxCheck-38173291.js +0 -4
  156. package/dist/packages/_es/raf-a74f1a06.js +0 -16
  157. package/dist/packages/_es/renderIcon-47498b32.js +0 -5
  158. package/dist/packages/locale/lang/baseLang-0bdc6353.js +0 -5
@@ -1,57 +1,75 @@
1
- import { c as g } from "./component-234624bc.js";
2
- import { h as m } from "vue";
1
+ import { c as createComponent } from "./component-81a4c1d0.js";
2
+ import { h } from "vue";
3
3
  import "../locale/lang";
4
- const { componentName: v, create: s } = g("config-provider"), $ = s({
4
+ const { componentName, create } = createComponent("config-provider");
5
+ const _sfc_main = create({
5
6
  props: {
6
7
  theme: { type: String, default: "" },
7
8
  themeVars: { type: Object, default: {} },
8
9
  tag: { type: String, default: "div" }
9
10
  },
10
- setup(o, { slots: c }) {
11
- const f = (t) => (t = t.replace(t.charAt(0), t.charAt(0).toLocaleLowerCase()), t.replace(/([a-z])([A-Z])/g, (e, r, n) => r + "-" + n.toLowerCase())), i = (t) => {
12
- if (t) {
13
- var e = t.toLowerCase(), r = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
14
- if (e && r.test(e)) {
15
- if (e.length === 4) {
16
- for (var n = "#", a = 1; a < 4; a += 1)
17
- n += e.slice(a, a + 1).concat(e.slice(a, a + 1));
18
- e = n;
11
+ setup(props, { slots }) {
12
+ const kebabCase = (str) => {
13
+ str = str.replace(str.charAt(0), str.charAt(0).toLocaleLowerCase());
14
+ return str.replace(/([a-z])([A-Z])/g, (_, p1, p2) => p1 + "-" + p2.toLowerCase());
15
+ };
16
+ const colorRgb = (str) => {
17
+ if (!str)
18
+ return;
19
+ var sColor = str.toLowerCase();
20
+ var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
21
+ if (sColor && reg.test(sColor)) {
22
+ if (sColor.length === 4) {
23
+ var sColorNew = "#";
24
+ for (var i = 1; i < 4; i += 1) {
25
+ sColorNew += sColor.slice(i, i + 1).concat(sColor.slice(i, i + 1));
19
26
  }
20
- for (var l = [], a = 1; a < 7; a += 2)
21
- l.push(parseInt("0x" + e.slice(a, a + 2)));
22
- return l.join(",");
27
+ sColor = sColorNew;
28
+ }
29
+ var sColorChange = [];
30
+ for (var i = 1; i < 7; i += 2) {
31
+ sColorChange.push(parseInt("0x" + sColor.slice(i, i + 2)));
23
32
  }
24
- return null;
33
+ return sColorChange.join(",");
25
34
  }
26
- }, u = (t) => {
27
- var n;
28
- if (!t)
35
+ return null;
36
+ };
37
+ const mapThemeVarsToCSSVars = (themeVars) => {
38
+ var _a;
39
+ if (!themeVars)
29
40
  return;
30
- const e = {}, r = (n = o == null ? void 0 : o.themeVars) == null ? void 0 : n.primaryColor;
31
- return r && (e["--nut-address-region-tab-line"] = `linear-gradient(90deg, ${r} 0%, rgba(${i(
32
- r
33
- )},0.15) 100%) `, e["--nut-tabs-horizontal-tab-line-color"] = `linear-gradient(90deg, ${r} 0%, rgba(${i(
34
- r
35
- )},0.15)100%)`, e["--nut-tabs-vertical-tab-line-color"] = `linear-gradient(180deg, ${r} 0%, rgba(${i(
36
- r
37
- )},0.15) 100%) `), Object.keys(t).forEach((a) => {
38
- e[`--nut-${f(a)}`] = t[a];
39
- }), e;
41
+ const cssVars = {};
42
+ const primaryColor = (_a = props == null ? void 0 : props.themeVars) == null ? void 0 : _a.primaryColor;
43
+ if (primaryColor) {
44
+ cssVars[`--nut-address-region-tab-line`] = `linear-gradient(90deg, ${primaryColor} 0%, rgba(${colorRgb(
45
+ primaryColor
46
+ )},0.15) 100%) `;
47
+ cssVars[`--nut-tabs-horizontal-tab-line-color`] = `linear-gradient(90deg, ${primaryColor} 0%, rgba(${colorRgb(
48
+ primaryColor
49
+ )},0.15)100%)`;
50
+ cssVars[`--nut-tabs-vertical-tab-line-color`] = `linear-gradient(180deg, ${primaryColor} 0%, rgba(${colorRgb(
51
+ primaryColor
52
+ )},0.15) 100%) `;
53
+ }
54
+ Object.keys(themeVars).forEach((key) => {
55
+ cssVars[`--nut-${kebabCase(key)}`] = themeVars[key];
56
+ });
57
+ return cssVars;
40
58
  };
41
59
  return () => {
42
- var e;
43
- const t = (e = c.default) == null ? void 0 : e.call(c);
44
- return m(
45
- o.tag,
60
+ var _a;
61
+ const defaultSlots = (_a = slots.default) == null ? void 0 : _a.call(slots);
62
+ return h(
63
+ props.tag,
46
64
  {
47
- class: `nut-theme-${o.theme}`,
48
- style: u(o.themeVars)
65
+ class: `nut-theme-${props.theme}`,
66
+ style: mapThemeVarsToCSSVars(props.themeVars)
49
67
  },
50
- t
68
+ defaultSlots
51
69
  );
52
70
  };
53
71
  }
54
72
  });
55
73
  export {
56
- $ as default
74
+ _sfc_main as default
57
75
  };
@@ -1,50 +1,64 @@
1
- var B = Object.defineProperty, k = Object.defineProperties;
2
- var $ = Object.getOwnPropertyDescriptors;
3
- var N = Object.getOwnPropertySymbols;
4
- var L = Object.prototype.hasOwnProperty, x = Object.prototype.propertyIsEnumerable;
5
- var v = (e, n, r) => n in e ? B(e, n, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[n] = r, g = (e, n) => {
6
- for (var r in n || (n = {}))
7
- L.call(n, r) && v(e, r, n[r]);
8
- if (N)
9
- for (var r of N(n))
10
- x.call(n, r) && v(e, r, n[r]);
11
- return e;
12
- }, b = (e, n) => k(e, $(n));
13
- import { reactive as A, computed as y, onBeforeMount as F, watch as S, toRefs as O, openBlock as M, createElementBlock as H, normalizeClass as R, renderSlot as V } from "vue";
14
- import { p as d, c as U } from "./component-234624bc.js";
15
- import { _ as j } 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, computed, onBeforeMount, watch, toRefs, openBlock, createElementBlock, normalizeClass, renderSlot } from "vue";
21
+ import { p as padZero, 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
- const q = (e) => {
18
- if (!e)
24
+ const getTimeStamp = (timeStr) => {
25
+ if (!timeStr)
19
26
  return Date.now();
20
- let n = e;
21
- return n = n > 0 ? +n : n.toString().replace(/\-/g, "/"), new Date(n).getTime();
22
- }, { componentName: z, create: I, translate: Y } = U("countdown"), Z = I({
27
+ let t = timeStr;
28
+ t = t > 0 ? +t : t.toString().replace(/\-/g, "/");
29
+ return new Date(t).getTime();
30
+ };
31
+ const { componentName, create, translate } = createComponent("countdown");
32
+ const _sfc_main = create({
23
33
  props: {
24
34
  modelValue: {
25
35
  type: Object,
26
- default: () => ({})
36
+ default: () => {
37
+ return {};
38
+ }
27
39
  },
28
40
  paused: {
29
- default: !1,
41
+ default: false,
30
42
  type: Boolean
31
43
  },
32
44
  startTime: {
33
45
  // 可以是服务器当前时间
34
46
  type: [Number, String],
35
- validator(e) {
36
- return new Date(e).toString().toLowerCase() !== "invalid date";
47
+ validator(v) {
48
+ const dateStr = new Date(v).toString().toLowerCase();
49
+ return dateStr !== "invalid date";
37
50
  }
38
51
  },
39
52
  endTime: {
40
53
  type: [Number, String],
41
- validator(e) {
42
- return new Date(e).toString().toLowerCase() !== "invalid date";
54
+ validator(v) {
55
+ const dateStr = new Date(v).toString().toLowerCase();
56
+ return dateStr !== "invalid date";
43
57
  }
44
58
  },
45
59
  // 是否开启毫秒
46
60
  millisecond: {
47
- default: !1,
61
+ default: false,
48
62
  type: Boolean
49
63
  },
50
64
  // 时间格式化
@@ -54,7 +68,7 @@ const q = (e) => {
54
68
  },
55
69
  autoStart: {
56
70
  type: Boolean,
57
- default: !0
71
+ default: true
58
72
  },
59
73
  // 倒计时时长,单位毫秒
60
74
  time: {
@@ -63,99 +77,197 @@ const q = (e) => {
63
77
  }
64
78
  },
65
79
  emits: ["input", "on-end", "on-restart", "on-paused", "update:modelValue"],
66
- setup(e, { emit: n, slots: r }) {
67
- const t = A({
80
+ setup(props, { emit, slots }) {
81
+ const state = reactive({
68
82
  restTime: 0,
69
83
  // 倒计时剩余时间时间
70
84
  timer: null,
71
- counting: !e.paused && e.autoStart,
85
+ counting: !props.paused && props.autoStart,
72
86
  // 是否处于倒计时中
73
87
  handleEndTime: Date.now(),
74
88
  // 最终截止时间
75
89
  diffTime: 0
76
90
  // 设置了 startTime 时,与 date.now() 的差异
77
- }), w = y(() => ({
78
- [z]: !0
79
- })), h = y(() => D(t.restTime)), p = () => {
80
- t.handleEndTime = e.endTime, t.diffTime = Date.now() - q(e.startTime), t.counting || (t.counting = !0), f();
81
- }, f = () => {
82
- window !== void 0 && (t.timer = requestAnimationFrame(() => {
83
- if (t.counting) {
84
- const o = Date.now() - t.diffTime, i = Math.max(t.handleEndTime - o, 0);
85
- t.restTime = i, i || (t.counting = !1, T(), n("on-end")), i > 0 && f();
86
- }
87
- }));
88
- }, D = (o, i) => {
89
- const s = o;
90
- let l = {
91
+ });
92
+ const classes = computed(() => {
93
+ const prefixCls = componentName;
94
+ return {
95
+ [prefixCls]: true
96
+ };
97
+ });
98
+ const renderTime = computed(() => {
99
+ return formatRemainTime(state.restTime);
100
+ });
101
+ const initTime = () => {
102
+ state.handleEndTime = props.endTime;
103
+ state.diffTime = Date.now() - getTimeStamp(props.startTime);
104
+ if (!state.counting)
105
+ state.counting = true;
106
+ tick();
107
+ };
108
+ const tick = () => {
109
+ if (window !== void 0) {
110
+ state.timer = requestAnimationFrame(() => {
111
+ if (state.counting) {
112
+ const currentTime = Date.now() - state.diffTime;
113
+ const remainTime = Math.max(state.handleEndTime - currentTime, 0);
114
+ state.restTime = remainTime;
115
+ if (!remainTime) {
116
+ state.counting = false;
117
+ pause();
118
+ emit("on-end");
119
+ }
120
+ if (remainTime > 0) {
121
+ tick();
122
+ }
123
+ }
124
+ });
125
+ }
126
+ };
127
+ const formatRemainTime = (t, type) => {
128
+ const ts = t;
129
+ let rest = {
91
130
  d: 0,
92
131
  h: 0,
93
132
  m: 0,
94
133
  s: 0,
95
134
  ms: 0
96
135
  };
97
- const m = 1e3, u = 60 * m, a = 60 * u, c = 24 * a;
98
- return s > 0 && (l.d = s >= m ? Math.floor(s / c) : 0, l.h = Math.floor(s % c / a), l.m = Math.floor(s % a / u), l.s = Math.floor(s % u / m), l.ms = Math.floor(s % m)), i == "custom" ? l : _(g({}, l));
99
- }, _ = (o) => {
100
- let { d: i, h: s, m: l, s: m, ms: u } = o, a = e.format;
101
- if (a.includes("DD") ? a = a.replace("DD", d(i)) : s += Number(i) * 24, a.includes("HH") ? a = a.replace("HH", d(s)) : l += Number(s) * 60, a.includes("mm") ? a = a.replace("mm", d(l)) : m += Number(l) * 60, a.includes("ss") ? a = a.replace("ss", d(m)) : u += Number(m) * 1e3, a.includes("S")) {
102
- const c = d(u, 3).toString();
103
- a.includes("SSS") ? a = a.replace("SSS", c) : a.includes("SS") ? a = a.replace("SS", c.slice(0, 2)) : a.includes("S") && (a = a.replace("SS", c.slice(0, 1)));
104
- }
105
- return a;
106
- }, C = () => {
107
- !t.counting && !e.autoStart && (t.counting = !0, t.handleEndTime = Date.now() + Number(t.restTime), f(), n("on-restart", t.restTime));
108
- }, T = () => {
109
- cancelAnimationFrame(t.timer), t.counting = !1, n("on-paused", t.restTime);
110
- }, E = () => {
111
- e.autoStart || (T(), t.restTime = e.time);
136
+ const SECOND = 1e3;
137
+ const MINUTE = 60 * SECOND;
138
+ const HOUR = 60 * MINUTE;
139
+ const DAY = 24 * HOUR;
140
+ if (ts > 0) {
141
+ rest.d = ts >= SECOND ? Math.floor(ts / DAY) : 0;
142
+ rest.h = Math.floor(ts % DAY / HOUR);
143
+ rest.m = Math.floor(ts % HOUR / MINUTE);
144
+ rest.s = Math.floor(ts % MINUTE / SECOND);
145
+ rest.ms = Math.floor(ts % SECOND);
146
+ }
147
+ return type == "custom" ? rest : parseFormat(__spreadValues({}, rest));
148
+ };
149
+ const parseFormat = (time) => {
150
+ let { d, h, m, s, ms } = time;
151
+ let format = props.format;
152
+ if (format.includes("DD")) {
153
+ format = format.replace("DD", padZero(d));
154
+ } else {
155
+ h += Number(d) * 24;
156
+ }
157
+ if (format.includes("HH")) {
158
+ format = format.replace("HH", padZero(h));
159
+ } else {
160
+ m += Number(h) * 60;
161
+ }
162
+ if (format.includes("mm")) {
163
+ format = format.replace("mm", padZero(m));
164
+ } else {
165
+ s += Number(m) * 60;
166
+ }
167
+ if (format.includes("ss")) {
168
+ format = format.replace("ss", padZero(s));
169
+ } else {
170
+ ms += Number(s) * 1e3;
171
+ }
172
+ if (format.includes("S")) {
173
+ const msC = padZero(ms, 3).toString();
174
+ if (format.includes("SSS")) {
175
+ format = format.replace("SSS", msC);
176
+ } else if (format.includes("SS")) {
177
+ format = format.replace("SS", msC.slice(0, 2));
178
+ } else if (format.includes("S")) {
179
+ format = format.replace("SS", msC.slice(0, 1));
180
+ }
181
+ }
182
+ return format;
183
+ };
184
+ const start = () => {
185
+ if (!state.counting && !props.autoStart) {
186
+ state.counting = true;
187
+ state.handleEndTime = Date.now() + Number(state.restTime);
188
+ tick();
189
+ emit("on-restart", state.restTime);
190
+ }
191
+ };
192
+ const pause = () => {
193
+ cancelAnimationFrame(state.timer);
194
+ state.counting = false;
195
+ emit("on-paused", state.restTime);
196
+ };
197
+ const reset = () => {
198
+ if (!props.autoStart) {
199
+ pause();
200
+ state.restTime = props.time;
201
+ }
112
202
  };
113
- return F(() => {
114
- e.autoStart ? p() : t.restTime = e.time;
115
- }), S(
116
- () => t.restTime,
117
- (o) => {
118
- let i = D(o, "custom");
119
- n("update:modelValue", i), n("input", i);
120
- }
121
- ), S(
122
- () => e.paused,
123
- (o, i) => {
124
- i ? (t.counting || (t.counting = !0, t.handleEndTime = Date.now() + Number(t.restTime), f()), n("on-restart", t.restTime)) : t.counting && T();
125
- }
126
- ), S(
127
- () => e.endTime,
128
- (o) => {
129
- p();
130
- }
131
- ), S(
132
- () => e.startTime,
133
- (o) => {
134
- p();
135
- }
136
- ), b(g({}, O(e)), {
137
- slots: r,
138
- classes: w,
139
- start: C,
140
- pause: T,
141
- renderTime: h,
142
- translate: Y,
143
- reset: E
203
+ onBeforeMount(() => {
204
+ if (props.autoStart) {
205
+ initTime();
206
+ } else {
207
+ state.restTime = props.time;
208
+ }
209
+ });
210
+ watch(
211
+ () => state.restTime,
212
+ (value) => {
213
+ let tranTime = formatRemainTime(value, "custom");
214
+ emit("update:modelValue", tranTime);
215
+ emit("input", tranTime);
216
+ }
217
+ );
218
+ watch(
219
+ () => props.paused,
220
+ (v, ov) => {
221
+ if (!ov) {
222
+ if (state.counting) {
223
+ pause();
224
+ }
225
+ } else {
226
+ if (!state.counting) {
227
+ state.counting = true;
228
+ state.handleEndTime = Date.now() + Number(state.restTime);
229
+ tick();
230
+ }
231
+ emit("on-restart", state.restTime);
232
+ }
233
+ }
234
+ );
235
+ watch(
236
+ () => props.endTime,
237
+ (value) => {
238
+ initTime();
239
+ }
240
+ );
241
+ watch(
242
+ () => props.startTime,
243
+ (value) => {
244
+ initTime();
245
+ }
246
+ );
247
+ return __spreadProps(__spreadValues({}, toRefs(props)), {
248
+ slots,
249
+ classes,
250
+ start,
251
+ pause,
252
+ renderTime,
253
+ translate,
254
+ reset
144
255
  });
145
256
  }
146
- }), G = ["innerHTML"];
147
- function J(e, n, r, t, w, h) {
148
- return M(), H("view", {
149
- class: R(e.classes)
257
+ });
258
+ const _hoisted_1 = ["innerHTML"];
259
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
260
+ return openBlock(), createElementBlock("view", {
261
+ class: normalizeClass(_ctx.classes)
150
262
  }, [
151
- e.slots.default ? V(e.$slots, "default", { key: 0 }) : (M(), H("view", {
263
+ _ctx.slots.default ? renderSlot(_ctx.$slots, "default", { key: 0 }) : (openBlock(), createElementBlock("view", {
152
264
  key: 1,
153
265
  class: "nut-countdown__content",
154
- innerHTML: e.renderTime
155
- }, null, 8, G))
266
+ innerHTML: _ctx.renderTime
267
+ }, null, 8, _hoisted_1))
156
268
  ], 2);
157
269
  }
158
- const ee = /* @__PURE__ */ j(Z, [["render", J]]);
270
+ const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
159
271
  export {
160
- ee as default
272
+ index as default
161
273
  };