vue3-time-duration 0.3.8 → 0.4.0
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
.icon-x-mark[data-v-7f1f4e49]{display:flex}.ui-widget-time[data-v-
|
|
1
|
+
.icon-x-mark[data-v-7f1f4e49]{display:flex}.ui-widget-time[data-v-f0bb9455]{position:relative}.ui-widget-time__w[data-v-f0bb9455]{display:flex;align-items:center;justify-content:space-between;border:1px solid var(--color-border);border-radius:12px;padding:8px 8px 8px 2px;background-color:var(--bg-element);height:24px}.ui-widget-time__w_error[data-v-f0bb9455]{border:1px solid var(--color-border-error);background-color:var(--bg-element-error)}.ui-widget-time__w-input[data-v-f0bb9455]{background-color:var(--bg-element);border:1px solid var(--bg-element);color:var(--color-font);font-size:var(--size-font);margin-left:3px;width:100%}.ui-widget-time__w-input_error[data-v-f0bb9455]{background-color:var(--bg-element-error);border:1px solid var(--bg-element-error)}.ui-widget-time__w-input[data-v-f0bb9455]:focus{outline:0 solid transparent}.ui-widget-time__w-icon[data-v-f0bb9455]{cursor:pointer}.ui-widget-time__dropdown[data-v-f0bb9455]{position:absolute;left:0;right:0;max-height:150px;margin:4px;padding:6px;background:#fff;z-index:1;border:1px solid #f5f5f5;border-radius:6px;box-shadow:0 0 8px 4px #0000000a;overflow-y:auto}.ui-widget-time__dropdown-item[data-v-f0bb9455]{padding:6px 4px;cursor:pointer;font-size:var(--size-font)}.ui-widget-time__dropdown-item_selected[data-v-f0bb9455]{background:var(--bg-selected);border-radius:6px}body{margin:0;padding:0;font-family:Inter,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.vue3-time-duration{--bg-element: #ffffff;--bg-selected: #f3f3f3;--color-border: rgb(223, 230, 238);--bg-element-error: #ffe9e9;--color-border-error: rgb(236, 157, 157);--color-font: #333;--size-font: 14px}.vue3-time-duration__t{display:flex;align-items:center}.vue3-time-duration__t-mdash{font-size:12px}.vue3-time-duration__t-left{margin-right:6px}.vue3-time-duration__t-right{margin-left:6px}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { openBlock as
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
for (const [
|
|
5
|
-
|
|
6
|
-
return
|
|
7
|
-
},
|
|
8
|
-
function
|
|
9
|
-
return
|
|
10
|
-
|
|
1
|
+
import { openBlock as y, createElementBlock as I, createStaticVNode as z, defineComponent as F, ref as u, computed as k, watch as R, onMounted as H, onUnmounted as X, createElementVNode as E, normalizeClass as $, withDirectives as U, vModelText as Z, createVNode as N, Fragment as j, renderList as q, toDisplayString as M, createCommentVNode as P, vShow as G } from "vue";
|
|
2
|
+
const W = (h, m) => {
|
|
3
|
+
const o = h.__vccOpts || h;
|
|
4
|
+
for (const [L, v] of m)
|
|
5
|
+
o[L] = v;
|
|
6
|
+
return o;
|
|
7
|
+
}, J = {}, K = { class: "icon-x-mark" };
|
|
8
|
+
function Q(h, m) {
|
|
9
|
+
return y(), I("div", K, m[0] || (m[0] = [
|
|
10
|
+
z('<svg width="20.000000" height="20.000000" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" data-v-7f1f4e49><desc data-v-7f1f4e49>Created with Pixso.</desc><defs data-v-7f1f4e49><clipPath id="clip131_5974" data-v-7f1f4e49><rect id="user-time" width="20.000000" height="20.000000" fill="white" fill-opacity="0" data-v-7f1f4e49></rect></clipPath></defs><g clip-path="url(#clip131_5974)" data-v-7f1f4e49><path id="path (Border)" d="M3.72 3.72C3.47 3.97 3.47 4.36 3.72 4.6L9.11 10L3.72 15.39C3.47 15.63 3.47 16.02 3.72 16.27C3.97 16.52 4.36 16.52 4.6 16.27L10 10.88L15.39 16.27C15.63 16.52 16.02 16.52 16.27 16.27C16.52 16.02 16.52 15.63 16.27 15.39L10.88 10L16.27 4.6C16.39 4.48 16.45 4.33 16.45 4.16C16.45 3.99 16.39 3.84 16.27 3.72C16.15 3.6 16 3.54 15.83 3.54C15.66 3.54 15.51 3.6 15.39 3.72L10 9.11L4.6 3.72C4.36 3.47 3.97 3.47 3.72 3.72Z" fill="#77797C" fill-opacity="1.000000" fill-rule="evenodd" data-v-7f1f4e49></path></g></svg>', 1)
|
|
11
11
|
]));
|
|
12
12
|
}
|
|
13
|
-
const
|
|
13
|
+
const ee = /* @__PURE__ */ W(J, [["render", Q], ["__scopeId", "data-v-7f1f4e49"]]), te = { class: "ui-widget-time" }, ie = ["readonly"], le = {
|
|
14
14
|
key: 0,
|
|
15
15
|
class: "ui-widget-time__dropdown"
|
|
16
|
-
},
|
|
16
|
+
}, oe = ["onClick"], ne = /* @__PURE__ */ F({
|
|
17
17
|
__name: "UiWidgetTime",
|
|
18
18
|
props: {
|
|
19
19
|
timeListId: { type: Number, default: 0 },
|
|
@@ -22,82 +22,101 @@ const j = /* @__PURE__ */ F(z, [["render", Z], ["__scopeId", "data-v-7f1f4e49"]]
|
|
|
22
22
|
isMobile: { type: Boolean, default: !1 }
|
|
23
23
|
},
|
|
24
24
|
emits: ["selectedId"],
|
|
25
|
-
setup(
|
|
26
|
-
const
|
|
25
|
+
setup(h, { emit: m }) {
|
|
26
|
+
const o = h, L = m, v = u([]), s = u(!1), i = u(0), d = u(void 0), w = u(), f = u(!1), B = u(), x = u(0), S = u(0), _ = u(!1);
|
|
27
|
+
u(null);
|
|
28
|
+
const g = k(() => v.value.length > 0 ? v.value : o.timeList), T = k(() => o.timeListId), p = k({
|
|
27
29
|
get() {
|
|
28
|
-
var
|
|
29
|
-
return
|
|
30
|
+
var t;
|
|
31
|
+
return d.value === void 0 ? (t = o.timeList.find((l) => l.id === T.value)) == null ? void 0 : t.time : d.value;
|
|
30
32
|
},
|
|
31
|
-
set(
|
|
32
|
-
|
|
33
|
+
set(t) {
|
|
34
|
+
d.value = t;
|
|
33
35
|
}
|
|
34
36
|
});
|
|
35
|
-
|
|
36
|
-
var
|
|
37
|
-
|
|
37
|
+
R(T, (t) => {
|
|
38
|
+
var l;
|
|
39
|
+
i.value = t, p.value = (l = o.timeList.find((a) => a.id === t)) == null ? void 0 : l.time;
|
|
38
40
|
});
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
const e = () => {
|
|
42
|
+
_.value || (S.value = window.scrollY, _.value = !0, document.body.style.position = "fixed", document.body.style.top = `-${S.value}px`, document.body.style.width = "100%", document.body.style.overflow = "hidden");
|
|
43
|
+
}, n = () => {
|
|
44
|
+
_.value && (document.body.style.position = "", document.body.style.top = "", document.body.style.width = "", document.body.style.overflow = "", window.scrollTo(0, S.value), _.value = !1);
|
|
45
|
+
}, r = (t) => {
|
|
46
|
+
var l;
|
|
47
|
+
i.value = t, p.value = (l = g.value.find((a) => a.id === i.value)) == null ? void 0 : l.time, s.value = !1, L("selectedId", i.value);
|
|
48
|
+
}, c = () => {
|
|
49
|
+
s.value = !0, e(), setTimeout(() => {
|
|
50
|
+
var l;
|
|
51
|
+
const t = B.value;
|
|
52
|
+
t !== null && (x.value = g.value.findIndex((a) => Number(a.id) === i.value), (l = t[x.value]) == null || l.scrollIntoView());
|
|
47
53
|
}, 250);
|
|
48
|
-
},
|
|
54
|
+
}, b = () => {
|
|
49
55
|
setTimeout(() => {
|
|
50
|
-
var
|
|
51
|
-
|
|
52
|
-
}, 200),
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
},
|
|
56
|
-
v.value =
|
|
56
|
+
var t, l;
|
|
57
|
+
f.value || (p.value = (t = g.value.find((a) => a.id === i.value)) == null ? void 0 : t.time, L("selectedId", (l = g.value.find((a) => a.id === i.value)) == null ? void 0 : l.id), s.value = !1, n());
|
|
58
|
+
}, 200), f.value = !1;
|
|
59
|
+
}, A = () => {
|
|
60
|
+
i.value = 0, v.value = [], p.value = "", w.value.focus(), f.value = !0, s.value = !0, e(), c();
|
|
61
|
+
}, O = () => {
|
|
62
|
+
v.value = o.timeList.filter((t) => t.time.startsWith(d.value));
|
|
63
|
+
}, D = (t) => {
|
|
64
|
+
if (!_.value) return;
|
|
65
|
+
const l = t.target, a = l == null ? void 0 : l.closest(".ui-widget-time__dropdown");
|
|
66
|
+
if (a) {
|
|
67
|
+
const C = a;
|
|
68
|
+
if (C.scrollHeight > C.clientHeight)
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
t.preventDefault();
|
|
57
72
|
};
|
|
58
|
-
return (
|
|
59
|
-
|
|
60
|
-
|
|
73
|
+
return H(() => {
|
|
74
|
+
document.addEventListener("wheel", D, { passive: !1 }), document.addEventListener("touchmove", D, { passive: !1 });
|
|
75
|
+
}), X(() => {
|
|
76
|
+
n(), document.removeEventListener("wheel", D), document.removeEventListener("touchmove", D);
|
|
77
|
+
}), (t, l) => (y(), I("div", te, [
|
|
78
|
+
E("div", {
|
|
79
|
+
class: $({ "ui-widget-time__w": !0, "ui-widget-time__w_error": o.isError })
|
|
61
80
|
}, [
|
|
62
|
-
|
|
81
|
+
U(E("input", {
|
|
63
82
|
ref_key: "inputRef",
|
|
64
|
-
ref:
|
|
65
|
-
"onUpdate:modelValue":
|
|
83
|
+
ref: w,
|
|
84
|
+
"onUpdate:modelValue": l[0] || (l[0] = (a) => p.value = a),
|
|
66
85
|
type: "text",
|
|
67
|
-
class:
|
|
68
|
-
onClick:
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}, null,
|
|
74
|
-
[
|
|
86
|
+
class: $({ "ui-widget-time__w-input": !0, "ui-widget-time__w-input_error": o.isError }),
|
|
87
|
+
onClick: c,
|
|
88
|
+
onFocus: e,
|
|
89
|
+
onFocusout: b,
|
|
90
|
+
onInput: O,
|
|
91
|
+
readonly: o.isMobile
|
|
92
|
+
}, null, 42, ie), [
|
|
93
|
+
[Z, p.value]
|
|
75
94
|
]),
|
|
76
|
-
|
|
95
|
+
N(ee, {
|
|
77
96
|
class: "ui-widget-time__w-icon",
|
|
78
|
-
onClick:
|
|
97
|
+
onClick: A
|
|
79
98
|
})
|
|
80
99
|
], 2),
|
|
81
|
-
s.value ? (
|
|
82
|
-
(
|
|
83
|
-
|
|
100
|
+
s.value ? (y(), I("div", le, [
|
|
101
|
+
(y(!0), I(j, null, q(g.value, (a, C) => (y(), I("div", { key: C }, [
|
|
102
|
+
E("div", {
|
|
84
103
|
ref_for: !0,
|
|
85
104
|
ref_key: "refItemList",
|
|
86
|
-
ref:
|
|
87
|
-
class:
|
|
105
|
+
ref: B,
|
|
106
|
+
class: $({
|
|
88
107
|
"ui-widget-time__dropdown-item": !0,
|
|
89
|
-
"ui-widget-time__dropdown-item_selected":
|
|
108
|
+
"ui-widget-time__dropdown-item_selected": x.value === C
|
|
90
109
|
}),
|
|
91
|
-
onClick: (
|
|
92
|
-
},
|
|
110
|
+
onClick: (Y) => r(a.id)
|
|
111
|
+
}, M(a.time), 11, oe)
|
|
93
112
|
]))), 128))
|
|
94
|
-
])) :
|
|
113
|
+
])) : P("", !0)
|
|
95
114
|
]));
|
|
96
115
|
}
|
|
97
|
-
}),
|
|
116
|
+
}), V = /* @__PURE__ */ W(ne, [["__scopeId", "data-v-f0bb9455"]]), se = { class: "vue3-time-duration" }, ae = { class: "vue3-time-duration__t" }, ue = {
|
|
98
117
|
key: 0,
|
|
99
118
|
class: "vue3-time-duration__t-mdash"
|
|
100
|
-
},
|
|
119
|
+
}, re = /* @__PURE__ */ F({
|
|
101
120
|
__name: "App",
|
|
102
121
|
props: {
|
|
103
122
|
initStart: { default: () => "00:00" },
|
|
@@ -107,62 +126,62 @@ const j = /* @__PURE__ */ F(z, [["render", Z], ["__scopeId", "data-v-7f1f4e49"]]
|
|
|
107
126
|
isMobile: { type: Boolean, default: () => !1 }
|
|
108
127
|
},
|
|
109
128
|
emits: ["duration"],
|
|
110
|
-
setup(
|
|
111
|
-
const
|
|
112
|
-
var
|
|
113
|
-
return
|
|
114
|
-
}),
|
|
115
|
-
var
|
|
116
|
-
return
|
|
129
|
+
setup(h, { emit: m }) {
|
|
130
|
+
const o = h, L = m, v = u(0), s = u([]), i = u(), d = u(), w = u(), f = u(), B = k(() => {
|
|
131
|
+
var e;
|
|
132
|
+
return i.value = _(o.initStart), w.value = (e = s.value.find((n) => n.id === i.value)) == null ? void 0 : e.time, o.initStart;
|
|
133
|
+
}), x = k(() => {
|
|
134
|
+
var e;
|
|
135
|
+
return d.value = _(o.initEnd), f.value = (e = s.value.find((n) => n.id === d.value)) == null ? void 0 : e.time, o.initEnd;
|
|
117
136
|
});
|
|
118
137
|
H(() => {
|
|
119
|
-
|
|
138
|
+
g(), v.value = s.value.length - 1;
|
|
120
139
|
});
|
|
121
|
-
const
|
|
122
|
-
() => ({ start:
|
|
140
|
+
const S = k(
|
|
141
|
+
() => ({ start: w.value, end: f.value })
|
|
123
142
|
);
|
|
124
|
-
|
|
125
|
-
|
|
143
|
+
R(S, (e) => {
|
|
144
|
+
L("duration", { start: e.start, end: e.end });
|
|
126
145
|
});
|
|
127
|
-
const
|
|
146
|
+
const _ = (e) => {
|
|
128
147
|
var n;
|
|
129
|
-
return (n = s.value.find((
|
|
130
|
-
},
|
|
131
|
-
let
|
|
132
|
-
for (let
|
|
133
|
-
|
|
134
|
-
},
|
|
135
|
-
var n,
|
|
136
|
-
|
|
137
|
-
},
|
|
138
|
-
var n,
|
|
139
|
-
|
|
148
|
+
return (n = s.value.find((r) => r.time === e)) == null ? void 0 : n.id;
|
|
149
|
+
}, g = () => {
|
|
150
|
+
let e = -1, n = "", r = 0, c = "";
|
|
151
|
+
for (let b = 0; b < 288; b++)
|
|
152
|
+
r >= 60 && (r = 0), b % 12 === 0 && (e += 1), n = e.toString().length === 1 ? "0" + e.toString() : e.toString(), c = r.toString().length === 1 ? "0" + r.toString() : r.toString(), s.value.push({ id: b, time: n + ":" + c }), r += 5;
|
|
153
|
+
}, T = (e) => {
|
|
154
|
+
var n, r;
|
|
155
|
+
i.value = e, d.value = e >= d.value ? e + 1 : d.value, d.value > v.value && (d.value = 0), w.value = (n = s.value.find((c) => c.id === i.value)) == null ? void 0 : n.time, f.value = (r = s.value.find((c) => c.id === d.value)) == null ? void 0 : r.time;
|
|
156
|
+
}, p = (e) => {
|
|
157
|
+
var n, r;
|
|
158
|
+
d.value = e, i.value = e <= i.value ? e - 1 : i.value, i.value < 0 && (i.value = v.value), w.value = (n = s.value.find((c) => c.id === i.value)) == null ? void 0 : n.time, f.value = (r = s.value.find((c) => c.id === d.value)) == null ? void 0 : r.time;
|
|
140
159
|
};
|
|
141
|
-
return (
|
|
142
|
-
|
|
143
|
-
[
|
|
160
|
+
return (e, n) => (y(), I("div", se, [
|
|
161
|
+
U(E("div", null, M(S.value) + " " + M(B.value) + " " + M(x.value), 513), [
|
|
162
|
+
[G, !1]
|
|
144
163
|
]),
|
|
145
|
-
|
|
146
|
-
|
|
164
|
+
E("div", ae, [
|
|
165
|
+
N(V, {
|
|
147
166
|
class: "vue3-time-duration__t-left",
|
|
148
167
|
"time-list": s.value,
|
|
149
|
-
"time-list-id":
|
|
150
|
-
"is-error":
|
|
151
|
-
"is-mobile":
|
|
152
|
-
onSelectedId:
|
|
168
|
+
"time-list-id": i.value,
|
|
169
|
+
"is-error": o.isError,
|
|
170
|
+
"is-mobile": o.isMobile,
|
|
171
|
+
onSelectedId: T
|
|
153
172
|
}, null, 8, ["time-list", "time-list-id", "is-error", "is-mobile"]),
|
|
154
|
-
|
|
155
|
-
|
|
173
|
+
e.isDash ? (y(), I("div", ue, "—")) : P("", !0),
|
|
174
|
+
N(V, {
|
|
156
175
|
class: "vue3-time-duration__t-right",
|
|
157
176
|
"time-list": s.value,
|
|
158
|
-
"time-list-id":
|
|
159
|
-
"is-error":
|
|
160
|
-
onSelectedId:
|
|
177
|
+
"time-list-id": d.value,
|
|
178
|
+
"is-error": o.isError,
|
|
179
|
+
onSelectedId: p
|
|
161
180
|
}, null, 8, ["time-list", "time-list-id", "is-error"])
|
|
162
181
|
])
|
|
163
182
|
]));
|
|
164
183
|
}
|
|
165
184
|
});
|
|
166
185
|
export {
|
|
167
|
-
|
|
186
|
+
re as default
|
|
168
187
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,
|
|
1
|
+
(function(e,y){typeof exports=="object"&&typeof module<"u"?module.exports=y(require("vue")):typeof define=="function"&&define.amd?define(["vue"],y):(e=typeof globalThis<"u"?globalThis:e||self,e["vue3-time-duration"]=y(e.Vue))})(this,function(e){"use strict";const y=(h,f)=>{const n=h.__vccOpts||h;for(const[k,m]of f)n[k]=m;return n},V={},N={class:"icon-x-mark"};function D(h,f){return e.openBlock(),e.createElementBlock("div",N,f[0]||(f[0]=[e.createStaticVNode('<svg width="20.000000" height="20.000000" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" data-v-7f1f4e49><desc data-v-7f1f4e49>Created with Pixso.</desc><defs data-v-7f1f4e49><clipPath id="clip131_5974" data-v-7f1f4e49><rect id="user-time" width="20.000000" height="20.000000" fill="white" fill-opacity="0" data-v-7f1f4e49></rect></clipPath></defs><g clip-path="url(#clip131_5974)" data-v-7f1f4e49><path id="path (Border)" d="M3.72 3.72C3.47 3.97 3.47 4.36 3.72 4.6L9.11 10L3.72 15.39C3.47 15.63 3.47 16.02 3.72 16.27C3.97 16.52 4.36 16.52 4.6 16.27L10 10.88L15.39 16.27C15.63 16.52 16.02 16.52 16.27 16.27C16.52 16.02 16.52 15.63 16.27 15.39L10.88 10L16.27 4.6C16.39 4.48 16.45 4.33 16.45 4.16C16.45 3.99 16.39 3.84 16.27 3.72C16.15 3.6 16 3.54 15.83 3.54C15.66 3.54 15.51 3.6 15.39 3.72L10 9.11L4.6 3.72C4.36 3.47 3.97 3.47 3.72 3.72Z" fill="#77797C" fill-opacity="1.000000" fill-rule="evenodd" data-v-7f1f4e49></path></g></svg>',1)]))}const T=y(V,[["render",D],["__scopeId","data-v-7f1f4e49"]]),M={class:"ui-widget-time"},$=["readonly"],F={key:0,class:"ui-widget-time__dropdown"},R=["onClick"],x=y(e.defineComponent({__name:"UiWidgetTime",props:{timeListId:{type:Number,default:0},timeList:{type:Array,default:[]},isError:{type:Boolean,default:!1},isMobile:{type:Boolean,default:!1}},emits:["selectedId"],setup(h,{emit:f}){const n=h,k=f,m=e.ref([]),r=e.ref(!1),o=e.ref(0),d=e.ref(void 0),w=e.ref(),p=e.ref(!1),C=e.ref(),L=e.ref(0),S=e.ref(0),v=e.ref(!1);e.ref(null);const g=e.computed(()=>m.value.length>0?m.value:n.timeList),B=e.computed(()=>n.timeListId),_=e.computed({get(){var i;return d.value===void 0?(i=n.timeList.find(l=>l.id===B.value))==null?void 0:i.time:d.value},set(i){d.value=i}});e.watch(B,i=>{var l;o.value=i,_.value=(l=n.timeList.find(a=>a.id===i))==null?void 0:l.time});const t=()=>{v.value||(S.value=window.scrollY,v.value=!0,document.body.style.position="fixed",document.body.style.top=`-${S.value}px`,document.body.style.width="100%",document.body.style.overflow="hidden")},s=()=>{v.value&&(document.body.style.position="",document.body.style.top="",document.body.style.width="",document.body.style.overflow="",window.scrollTo(0,S.value),v.value=!1)},c=i=>{var l;o.value=i,_.value=(l=g.value.find(a=>a.id===o.value))==null?void 0:l.time,r.value=!1,k("selectedId",o.value)},u=()=>{r.value=!0,t(),setTimeout(()=>{var l;const i=C.value;i!==null&&(L.value=g.value.findIndex(a=>Number(a.id)===o.value),(l=i[L.value])==null||l.scrollIntoView())},250)},I=()=>{setTimeout(()=>{var i,l;p.value||(_.value=(i=g.value.find(a=>a.id===o.value))==null?void 0:i.time,k("selectedId",(l=g.value.find(a=>a.id===o.value))==null?void 0:l.id),r.value=!1,s())},200),p.value=!1},P=()=>{o.value=0,m.value=[],_.value="",w.value.focus(),p.value=!0,r.value=!0,t(),u()},W=()=>{m.value=n.timeList.filter(i=>i.time.startsWith(d.value))},b=i=>{if(!v.value)return;const l=i.target,a=l==null?void 0:l.closest(".ui-widget-time__dropdown");if(a){const E=a;if(E.scrollHeight>E.clientHeight)return}i.preventDefault()};return e.onMounted(()=>{document.addEventListener("wheel",b,{passive:!1}),document.addEventListener("touchmove",b,{passive:!1})}),e.onUnmounted(()=>{s(),document.removeEventListener("wheel",b),document.removeEventListener("touchmove",b)}),(i,l)=>(e.openBlock(),e.createElementBlock("div",M,[e.createElementVNode("div",{class:e.normalizeClass({"ui-widget-time__w":!0,"ui-widget-time__w_error":n.isError})},[e.withDirectives(e.createElementVNode("input",{ref_key:"inputRef",ref:w,"onUpdate:modelValue":l[0]||(l[0]=a=>_.value=a),type:"text",class:e.normalizeClass({"ui-widget-time__w-input":!0,"ui-widget-time__w-input_error":n.isError}),onClick:u,onFocus:t,onFocusout:I,onInput:W,readonly:n.isMobile},null,42,$),[[e.vModelText,_.value]]),e.createVNode(T,{class:"ui-widget-time__w-icon",onClick:P})],2),r.value?(e.openBlock(),e.createElementBlock("div",F,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.value,(a,E)=>(e.openBlock(),e.createElementBlock("div",{key:E},[e.createElementVNode("div",{ref_for:!0,ref_key:"refItemList",ref:C,class:e.normalizeClass({"ui-widget-time__dropdown-item":!0,"ui-widget-time__dropdown-item_selected":L.value===E}),onClick:A=>c(a.id)},e.toDisplayString(a.time),11,R)]))),128))])):e.createCommentVNode("",!0)]))}}),[["__scopeId","data-v-f0bb9455"]]),H={class:"vue3-time-duration"},U={class:"vue3-time-duration__t"},z={key:0,class:"vue3-time-duration__t-mdash"};return e.defineComponent({__name:"App",props:{initStart:{default:()=>"00:00"},initEnd:{default:()=>"00:05"},isDash:{type:Boolean,default:()=>!1},isError:{type:Boolean,default:()=>!1},isMobile:{type:Boolean,default:()=>!1}},emits:["duration"],setup(h,{emit:f}){const n=h,k=f,m=e.ref(0),r=e.ref([]),o=e.ref(),d=e.ref(),w=e.ref(),p=e.ref(),C=e.computed(()=>{var t;return o.value=v(n.initStart),w.value=(t=r.value.find(s=>s.id===o.value))==null?void 0:t.time,n.initStart}),L=e.computed(()=>{var t;return d.value=v(n.initEnd),p.value=(t=r.value.find(s=>s.id===d.value))==null?void 0:t.time,n.initEnd});e.onMounted(()=>{g(),m.value=r.value.length-1});const S=e.computed(()=>({start:w.value,end:p.value}));e.watch(S,t=>{k("duration",{start:t.start,end:t.end})});const v=t=>{var s;return(s=r.value.find(c=>c.time===t))==null?void 0:s.id},g=()=>{let t=-1,s="",c=0,u="";for(let I=0;I<288;I++)c>=60&&(c=0),I%12===0&&(t+=1),s=t.toString().length===1?"0"+t.toString():t.toString(),u=c.toString().length===1?"0"+c.toString():c.toString(),r.value.push({id:I,time:s+":"+u}),c+=5},B=t=>{var s,c;o.value=t,d.value=t>=d.value?t+1:d.value,d.value>m.value&&(d.value=0),w.value=(s=r.value.find(u=>u.id===o.value))==null?void 0:s.time,p.value=(c=r.value.find(u=>u.id===d.value))==null?void 0:c.time},_=t=>{var s,c;d.value=t,o.value=t<=o.value?t-1:o.value,o.value<0&&(o.value=m.value),w.value=(s=r.value.find(u=>u.id===o.value))==null?void 0:s.time,p.value=(c=r.value.find(u=>u.id===d.value))==null?void 0:c.time};return(t,s)=>(e.openBlock(),e.createElementBlock("div",H,[e.withDirectives(e.createElementVNode("div",null,e.toDisplayString(S.value)+" "+e.toDisplayString(C.value)+" "+e.toDisplayString(L.value),513),[[e.vShow,!1]]),e.createElementVNode("div",U,[e.createVNode(x,{class:"vue3-time-duration__t-left","time-list":r.value,"time-list-id":o.value,"is-error":n.isError,"is-mobile":n.isMobile,onSelectedId:B},null,8,["time-list","time-list-id","is-error","is-mobile"]),t.isDash?(e.openBlock(),e.createElementBlock("div",z,"—")):e.createCommentVNode("",!0),e.createVNode(x,{class:"vue3-time-duration__t-right","time-list":r.value,"time-list-id":d.value,"is-error":n.isError,onSelectedId:_},null,8,["time-list","time-list-id","is-error"])])]))}})});
|