vue3-time-duration 0.4.2 → 0.4.4
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-f3e8c0f8]{position:relative}.ui-widget-time__w[data-v-f3e8c0f8]{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-f3e8c0f8]{border:1px solid var(--color-border-error);background-color:var(--bg-element-error)}.ui-widget-time__w-input[data-v-f3e8c0f8]{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-f3e8c0f8]{background-color:var(--bg-element-error);border:1px solid var(--bg-element-error)}.ui-widget-time__w-input[data-v-f3e8c0f8]:focus{outline:0 solid transparent}.ui-widget-time__w-icon[data-v-f3e8c0f8]{cursor:pointer}.ui-widget-time__dropdown[data-v-f3e8c0f8]{position:absolute;left:0;right:0;max-height:150px;margin:4px;padding:6px;background:var(--bg-element);z-index:1;border:1px solid var(--bg-element);border-radius:6px;box-shadow:0 0 8px 4px #0000000a;overflow-y:auto}.ui-widget-time__dropdown-item[data-v-f3e8c0f8]{padding:6px 4px;cursor:pointer;font-size:var(--size-font);color:var(--color-font)}.ui-widget-time__dropdown-item_selected[data-v-f3e8c0f8]{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: var(--v-bg-element);--bg-selected: var(--v-bg-selected);--color-border: var(--v-color-border);--bg-element-error: #ffe9e9;--color-border-error: rgb(236, 157, 157);--color-font: var(--v-neutral-n900-color);--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 S, createElementBlock as I, createStaticVNode as Y, defineComponent as
|
|
2
|
-
const A = (w,
|
|
3
|
-
const
|
|
4
|
-
for (const [C, v] of
|
|
5
|
-
|
|
6
|
-
return
|
|
7
|
-
},
|
|
8
|
-
function
|
|
9
|
-
return S(), I("div",
|
|
1
|
+
import { openBlock as S, createElementBlock as I, createStaticVNode as Y, defineComponent as z, ref as u, computed as L, watch as H, onMounted as U, onUnmounted as X, createElementVNode as B, normalizeClass as V, withDirectives as P, vModelText as Z, createVNode as F, Fragment as j, renderList as q, toDisplayString as $, createCommentVNode as W, nextTick as G, normalizeStyle as J, vShow as K } from "vue";
|
|
2
|
+
const A = (w, m) => {
|
|
3
|
+
const i = w.__vccOpts || w;
|
|
4
|
+
for (const [C, v] of m)
|
|
5
|
+
i[C] = v;
|
|
6
|
+
return i;
|
|
7
|
+
}, Q = {}, ee = { class: "icon-x-mark" };
|
|
8
|
+
function te(w, m) {
|
|
9
|
+
return S(), I("div", ee, m[0] || (m[0] = [
|
|
10
10
|
Y('<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 ie = /* @__PURE__ */ A(Q, [["render", te], ["__scopeId", "data-v-7f1f4e49"]]), le = { class: "ui-widget-time" }, oe = ["readonly"], ne = {
|
|
14
14
|
key: 0,
|
|
15
15
|
class: "ui-widget-time__dropdown"
|
|
16
|
-
},
|
|
16
|
+
}, se = ["onClick"], re = /* @__PURE__ */ z({
|
|
17
17
|
__name: "UiWidgetTime",
|
|
18
18
|
props: {
|
|
19
19
|
timeListId: { type: Number, default: 0 },
|
|
@@ -22,104 +22,110 @@ const te = /* @__PURE__ */ A(K, [["render", ee], ["__scopeId", "data-v-7f1f4e49"
|
|
|
22
22
|
isMobile: { type: Boolean, default: !1 }
|
|
23
23
|
},
|
|
24
24
|
emits: ["selectedId"],
|
|
25
|
-
setup(w, { emit:
|
|
26
|
-
const
|
|
25
|
+
setup(w, { emit: m }) {
|
|
26
|
+
const i = w, C = m, v = u([]), r = u(!1), l = u(0), d = u(void 0), y = u(), p = u(!1), T = u(), k = u(0), x = u(0), _ = u(!1);
|
|
27
27
|
u(null);
|
|
28
|
-
const b = L(() => v.value.length > 0 ? v.value :
|
|
28
|
+
const b = L(() => v.value.length > 0 ? v.value : i.timeList), M = L(() => i.timeListId), h = L({
|
|
29
29
|
get() {
|
|
30
|
-
var
|
|
31
|
-
return d.value === void 0 ? (
|
|
30
|
+
var t;
|
|
31
|
+
return d.value === void 0 ? (t = i.timeList.find((s) => s.id === M.value)) == null ? void 0 : t.time : d.value;
|
|
32
32
|
},
|
|
33
|
-
set(
|
|
34
|
-
d.value =
|
|
33
|
+
set(t) {
|
|
34
|
+
d.value = t;
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
|
-
H(M, (
|
|
37
|
+
H(M, (t) => {
|
|
38
38
|
var s;
|
|
39
|
-
l.value =
|
|
39
|
+
l.value = t, h.value = (s = i.timeList.find((a) => a.id === t)) == null ? void 0 : s.time;
|
|
40
40
|
});
|
|
41
41
|
const g = () => {
|
|
42
|
-
_.value || (
|
|
42
|
+
_.value || (x.value = window.scrollY, _.value = !0, document.body.style.position = "fixed", document.body.style.top = `-${x.value}px`, document.body.style.width = "100%", document.body.style.overflow = "hidden");
|
|
43
43
|
}, e = () => {
|
|
44
|
-
_.value && (document.body.style.position = "", document.body.style.top = "", document.body.style.width = "", document.body.style.overflow = "", window.scrollTo(0,
|
|
45
|
-
}, o = (
|
|
44
|
+
_.value && (document.body.style.position = "", document.body.style.top = "", document.body.style.width = "", document.body.style.overflow = "", window.scrollTo(0, x.value), _.value = !1);
|
|
45
|
+
}, o = (t) => {
|
|
46
46
|
var s;
|
|
47
|
-
l.value =
|
|
47
|
+
l.value = t, h.value = (s = b.value.find((a) => a.id === l.value)) == null ? void 0 : s.time, r.value = !1, C("selectedId", l.value);
|
|
48
48
|
}, n = () => {
|
|
49
|
-
r.value = !0, g(),
|
|
49
|
+
r.value = !0, g(), G(() => {
|
|
50
50
|
var s;
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
const t = T.value;
|
|
52
|
+
t != null && t[k.value] && (k.value = b.value.findIndex((a) => Number(a.id) === l.value), (s = t[k.value]) == null || s.scrollIntoView({
|
|
53
|
+
block: "nearest",
|
|
54
|
+
// скроллить только если элемент вне зоны видимости
|
|
55
|
+
inline: "nearest",
|
|
56
|
+
behavior: "auto"
|
|
57
|
+
// без анимации, чтобы избежать дополнительного дергания
|
|
58
|
+
}));
|
|
59
|
+
});
|
|
54
60
|
}, c = () => {
|
|
55
61
|
setTimeout(() => {
|
|
56
|
-
var
|
|
57
|
-
p.value || (h.value = (
|
|
62
|
+
var t, s;
|
|
63
|
+
p.value || (h.value = (t = b.value.find((a) => a.id === l.value)) == null ? void 0 : t.time, C("selectedId", (s = b.value.find((a) => a.id === l.value)) == null ? void 0 : s.id), r.value = !1, e());
|
|
58
64
|
}, 200), p.value = !1;
|
|
59
|
-
},
|
|
65
|
+
}, f = () => {
|
|
60
66
|
l.value = 0, v.value = [], h.value = "", y.value.focus(), p.value = !0, r.value = !0, g(), n();
|
|
61
67
|
}, N = () => {
|
|
62
|
-
v.value =
|
|
63
|
-
}, D = (
|
|
68
|
+
v.value = i.timeList.filter((t) => t.time.startsWith(d.value));
|
|
69
|
+
}, D = (t) => {
|
|
64
70
|
if (!_.value) return;
|
|
65
|
-
const s =
|
|
71
|
+
const s = t.target, a = s == null ? void 0 : s.closest(".ui-widget-time__dropdown");
|
|
66
72
|
if (a) {
|
|
67
73
|
const E = a;
|
|
68
74
|
if (E.scrollHeight > E.clientHeight)
|
|
69
75
|
return;
|
|
70
76
|
}
|
|
71
|
-
|
|
77
|
+
t.preventDefault();
|
|
72
78
|
};
|
|
73
79
|
return U(() => {
|
|
74
80
|
document.addEventListener("wheel", D, { passive: !1 }), document.addEventListener("touchmove", D, { passive: !1 });
|
|
75
81
|
}), X(() => {
|
|
76
82
|
e(), document.removeEventListener("wheel", D), document.removeEventListener("touchmove", D);
|
|
77
|
-
}), (
|
|
83
|
+
}), (t, s) => (S(), I("div", le, [
|
|
78
84
|
B("div", {
|
|
79
|
-
class:
|
|
85
|
+
class: V({ "ui-widget-time__w": !0, "ui-widget-time__w_error": i.isError })
|
|
80
86
|
}, [
|
|
81
87
|
P(B("input", {
|
|
82
88
|
ref_key: "inputRef",
|
|
83
89
|
ref: y,
|
|
84
90
|
"onUpdate:modelValue": s[0] || (s[0] = (a) => h.value = a),
|
|
85
91
|
type: "text",
|
|
86
|
-
class:
|
|
92
|
+
class: V({ "ui-widget-time__w-input": !0, "ui-widget-time__w-input_error": i.isError }),
|
|
87
93
|
onClick: n,
|
|
88
94
|
onFocus: g,
|
|
89
95
|
onFocusout: c,
|
|
90
96
|
onInput: N,
|
|
91
|
-
readonly:
|
|
92
|
-
}, null, 42,
|
|
97
|
+
readonly: i.isMobile
|
|
98
|
+
}, null, 42, oe), [
|
|
93
99
|
[Z, h.value]
|
|
94
100
|
]),
|
|
95
|
-
|
|
101
|
+
F(ie, {
|
|
96
102
|
class: "ui-widget-time__w-icon",
|
|
97
|
-
onClick:
|
|
103
|
+
onClick: f
|
|
98
104
|
})
|
|
99
105
|
], 2),
|
|
100
|
-
r.value ? (S(), I("div",
|
|
106
|
+
r.value ? (S(), I("div", ne, [
|
|
101
107
|
(S(!0), I(j, null, q(b.value, (a, E) => (S(), I("div", { key: E }, [
|
|
102
108
|
B("div", {
|
|
103
109
|
ref_for: !0,
|
|
104
110
|
ref_key: "refItemList",
|
|
105
111
|
ref: T,
|
|
106
|
-
class:
|
|
112
|
+
class: V({
|
|
107
113
|
"ui-widget-time__dropdown-item": !0,
|
|
108
|
-
"ui-widget-time__dropdown-item_selected":
|
|
114
|
+
"ui-widget-time__dropdown-item_selected": k.value === E
|
|
109
115
|
}),
|
|
110
116
|
onClick: (O) => o(a.id)
|
|
111
|
-
}, $(a.time), 11,
|
|
117
|
+
}, $(a.time), 11, se)
|
|
112
118
|
]))), 128))
|
|
113
119
|
])) : W("", !0)
|
|
114
120
|
]));
|
|
115
121
|
}
|
|
116
|
-
}),
|
|
122
|
+
}), R = /* @__PURE__ */ A(re, [["__scopeId", "data-v-f3e8c0f8"]]), ae = { class: "vue3-time-duration__t" }, ue = {
|
|
117
123
|
key: 0,
|
|
118
124
|
class: "vue3-time-duration__t-mdash"
|
|
119
|
-
},
|
|
125
|
+
}, ce = /* @__PURE__ */ z({
|
|
120
126
|
__name: "App",
|
|
121
127
|
props: {
|
|
122
|
-
pTheme: { default: () => "
|
|
128
|
+
pTheme: { default: () => "default" },
|
|
123
129
|
initStart: { default: () => "00:00" },
|
|
124
130
|
initEnd: { default: () => "00:05" },
|
|
125
131
|
isDash: { type: Boolean, default: () => !1 },
|
|
@@ -127,21 +133,21 @@ const te = /* @__PURE__ */ A(K, [["render", ee], ["__scopeId", "data-v-7f1f4e49"
|
|
|
127
133
|
isMobile: { type: Boolean, default: () => !1 }
|
|
128
134
|
},
|
|
129
135
|
emits: ["duration"],
|
|
130
|
-
setup(w, { emit:
|
|
131
|
-
const
|
|
136
|
+
setup(w, { emit: m }) {
|
|
137
|
+
const i = w, C = m, v = u(0), r = u([]), l = u(), d = u(), y = u(), p = u(), T = L(() => {
|
|
132
138
|
var e;
|
|
133
|
-
return l.value = _(
|
|
134
|
-
}),
|
|
139
|
+
return l.value = _(i.initStart), y.value = (e = r.value.find((o) => o.id === l.value)) == null ? void 0 : e.time, i.initStart;
|
|
140
|
+
}), k = L(() => {
|
|
135
141
|
var e;
|
|
136
|
-
return d.value = _(
|
|
142
|
+
return d.value = _(i.initEnd), p.value = (e = r.value.find((o) => o.id === d.value)) == null ? void 0 : e.time, i.initEnd;
|
|
137
143
|
});
|
|
138
144
|
U(() => {
|
|
139
145
|
b(), v.value = r.value.length - 1;
|
|
140
146
|
});
|
|
141
|
-
const
|
|
147
|
+
const x = L(
|
|
142
148
|
() => ({ start: y.value, end: p.value })
|
|
143
149
|
);
|
|
144
|
-
H(
|
|
150
|
+
H(x, (e) => {
|
|
145
151
|
C("duration", { start: e.start, end: e.end });
|
|
146
152
|
});
|
|
147
153
|
const _ = (e) => {
|
|
@@ -149,8 +155,8 @@ const te = /* @__PURE__ */ A(K, [["render", ee], ["__scopeId", "data-v-7f1f4e49"
|
|
|
149
155
|
return (o = r.value.find((n) => n.time === e)) == null ? void 0 : o.id;
|
|
150
156
|
}, b = () => {
|
|
151
157
|
let e = -1, o = "", n = 0, c = "";
|
|
152
|
-
for (let
|
|
153
|
-
n >= 60 && (n = 0),
|
|
158
|
+
for (let f = 0; f < 288; f++)
|
|
159
|
+
n >= 60 && (n = 0), f % 12 === 0 && (e += 1), o = e.toString().length === 1 ? "0" + e.toString() : e.toString(), c = n.toString().length === 1 ? "0" + n.toString() : n.toString(), r.value.push({ id: f, time: o + ":" + c }), n += 5;
|
|
154
160
|
}, M = (e) => {
|
|
155
161
|
var o, n;
|
|
156
162
|
l.value = e, d.value = e >= d.value ? e + 1 : d.value, d.value > v.value && (d.value = 0), y.value = (o = r.value.find((c) => c.id === l.value)) == null ? void 0 : o.time, p.value = (n = r.value.find((c) => c.id === d.value)) == null ? void 0 : n.time;
|
|
@@ -171,39 +177,39 @@ const te = /* @__PURE__ */ A(K, [["render", ee], ["__scopeId", "data-v-7f1f4e49"
|
|
|
171
177
|
bgSelected: "rgba(36, 36, 36, 1)",
|
|
172
178
|
colorBorder: "rgba(17, 17, 17, 1)"
|
|
173
179
|
}
|
|
174
|
-
}, o =
|
|
180
|
+
}, o = i.pTheme;
|
|
175
181
|
return e[o];
|
|
176
182
|
});
|
|
177
183
|
return (e, o) => {
|
|
178
|
-
var n, c,
|
|
184
|
+
var n, c, f, N;
|
|
179
185
|
return S(), I("div", {
|
|
180
186
|
class: "vue3-time-duration",
|
|
181
|
-
style:
|
|
187
|
+
style: J({
|
|
182
188
|
"--v-bg-element": (n = g.value) == null ? void 0 : n.bgElement,
|
|
183
189
|
"--v-neutral-n900-color": (c = g.value) == null ? void 0 : c.neutralN900Color,
|
|
184
|
-
"--v-bg-selected": (
|
|
190
|
+
"--v-bg-selected": (f = g.value) == null ? void 0 : f.bgSelected,
|
|
185
191
|
"--v-color-border": (N = g.value) == null ? void 0 : N.colorBorder
|
|
186
192
|
})
|
|
187
193
|
}, [
|
|
188
|
-
P(B("div", null, $(
|
|
189
|
-
[
|
|
194
|
+
P(B("div", null, $(x.value) + " " + $(T.value) + " " + $(k.value), 513), [
|
|
195
|
+
[K, !1]
|
|
190
196
|
]),
|
|
191
|
-
B("div",
|
|
192
|
-
|
|
197
|
+
B("div", ae, [
|
|
198
|
+
F(R, {
|
|
193
199
|
class: "vue3-time-duration__t-left",
|
|
194
200
|
"time-list": r.value,
|
|
195
201
|
"time-list-id": l.value,
|
|
196
|
-
"is-error":
|
|
197
|
-
"is-mobile":
|
|
202
|
+
"is-error": i.isError,
|
|
203
|
+
"is-mobile": i.isMobile,
|
|
198
204
|
onSelectedId: M
|
|
199
205
|
}, null, 8, ["time-list", "time-list-id", "is-error", "is-mobile"]),
|
|
200
|
-
e.isDash ? (S(), I("div",
|
|
201
|
-
|
|
206
|
+
e.isDash ? (S(), I("div", ue, "—")) : W("", !0),
|
|
207
|
+
F(R, {
|
|
202
208
|
class: "vue3-time-duration__t-right",
|
|
203
209
|
"time-list": r.value,
|
|
204
210
|
"time-list-id": d.value,
|
|
205
|
-
"is-error":
|
|
206
|
-
"is-mobile":
|
|
211
|
+
"is-error": i.isError,
|
|
212
|
+
"is-mobile": i.isMobile,
|
|
207
213
|
onSelectedId: h
|
|
208
214
|
}, null, 8, ["time-list", "time-list-id", "is-error", "is-mobile"])
|
|
209
215
|
])
|
|
@@ -212,5 +218,5 @@ const te = /* @__PURE__ */ A(K, [["render", ee], ["__scopeId", "data-v-7f1f4e49"
|
|
|
212
218
|
}
|
|
213
219
|
});
|
|
214
220
|
export {
|
|
215
|
-
|
|
221
|
+
ce as default
|
|
216
222
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,
|
|
1
|
+
(function(e,k){typeof exports=="object"&&typeof module<"u"?module.exports=k(require("vue")):typeof define=="function"&&define.amd?define(["vue"],k):(e=typeof globalThis<"u"?globalThis:e||self,e["vue3-time-duration"]=k(e.Vue))})(this,function(e){"use strict";const k=(w,p)=>{const o=w.__vccOpts||w;for(const[S,f]of p)o[S]=f;return o},V={},D={class:"icon-x-mark"};function M(w,p){return e.openBlock(),e.createElementBlock("div",D,p[0]||(p[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 $=k(V,[["render",M],["__scopeId","data-v-7f1f4e49"]]),z={class:"ui-widget-time"},F=["readonly"],R={key:0,class:"ui-widget-time__dropdown"},H=["onClick"],T=k(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(w,{emit:p}){const o=w,S=p,f=e.ref([]),a=e.ref(!1),l=e.ref(0),c=e.ref(void 0),y=e.ref(),v=e.ref(!1),B=e.ref(),E=e.ref(0),I=e.ref(0),_=e.ref(!1);e.ref(null);const b=e.computed(()=>f.value.length>0?f.value:o.timeList),C=e.computed(()=>o.timeListId),h=e.computed({get(){var i;return c.value===void 0?(i=o.timeList.find(s=>s.id===C.value))==null?void 0:i.time:c.value},set(i){c.value=i}});e.watch(C,i=>{var s;l.value=i,h.value=(s=o.timeList.find(d=>d.id===i))==null?void 0:s.time});const g=()=>{_.value||(I.value=window.scrollY,_.value=!0,document.body.style.position="fixed",document.body.style.top=`-${I.value}px`,document.body.style.width="100%",document.body.style.overflow="hidden")},t=()=>{_.value&&(document.body.style.position="",document.body.style.top="",document.body.style.width="",document.body.style.overflow="",window.scrollTo(0,I.value),_.value=!1)},n=i=>{var s;l.value=i,h.value=(s=b.value.find(d=>d.id===l.value))==null?void 0:s.time,a.value=!1,S("selectedId",l.value)},r=()=>{a.value=!0,g(),e.nextTick(()=>{var s;const i=B.value;i!=null&&i[E.value]&&(E.value=b.value.findIndex(d=>Number(d.id)===l.value),(s=i[E.value])==null||s.scrollIntoView({block:"nearest",inline:"nearest",behavior:"auto"}))})},u=()=>{setTimeout(()=>{var i,s;v.value||(h.value=(i=b.value.find(d=>d.id===l.value))==null?void 0:i.time,S("selectedId",(s=b.value.find(d=>d.id===l.value))==null?void 0:s.id),a.value=!1,t())},200),v.value=!1},m=()=>{l.value=0,f.value=[],h.value="",y.value.focus(),v.value=!0,a.value=!0,g(),r()},x=()=>{f.value=o.timeList.filter(i=>i.time.startsWith(c.value))},N=i=>{if(!_.value)return;const s=i.target,d=s==null?void 0:s.closest(".ui-widget-time__dropdown");if(d){const L=d;if(L.scrollHeight>L.clientHeight)return}i.preventDefault()};return e.onMounted(()=>{document.addEventListener("wheel",N,{passive:!1}),document.addEventListener("touchmove",N,{passive:!1})}),e.onUnmounted(()=>{t(),document.removeEventListener("wheel",N),document.removeEventListener("touchmove",N)}),(i,s)=>(e.openBlock(),e.createElementBlock("div",z,[e.createElementVNode("div",{class:e.normalizeClass({"ui-widget-time__w":!0,"ui-widget-time__w_error":o.isError})},[e.withDirectives(e.createElementVNode("input",{ref_key:"inputRef",ref:y,"onUpdate:modelValue":s[0]||(s[0]=d=>h.value=d),type:"text",class:e.normalizeClass({"ui-widget-time__w-input":!0,"ui-widget-time__w-input_error":o.isError}),onClick:r,onFocus:g,onFocusout:u,onInput:x,readonly:o.isMobile},null,42,F),[[e.vModelText,h.value]]),e.createVNode($,{class:"ui-widget-time__w-icon",onClick:m})],2),a.value?(e.openBlock(),e.createElementBlock("div",R,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.value,(d,L)=>(e.openBlock(),e.createElementBlock("div",{key:L},[e.createElementVNode("div",{ref_for:!0,ref_key:"refItemList",ref:B,class:e.normalizeClass({"ui-widget-time__dropdown-item":!0,"ui-widget-time__dropdown-item_selected":E.value===L}),onClick:W=>n(d.id)},e.toDisplayString(d.time),11,H)]))),128))])):e.createCommentVNode("",!0)]))}}),[["__scopeId","data-v-f3e8c0f8"]]),U={class:"vue3-time-duration__t"},P={key:0,class:"vue3-time-duration__t-mdash"};return e.defineComponent({__name:"App",props:{pTheme:{default:()=>"default"},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(w,{emit:p}){const o=w,S=p,f=e.ref(0),a=e.ref([]),l=e.ref(),c=e.ref(),y=e.ref(),v=e.ref(),B=e.computed(()=>{var t;return l.value=_(o.initStart),y.value=(t=a.value.find(n=>n.id===l.value))==null?void 0:t.time,o.initStart}),E=e.computed(()=>{var t;return c.value=_(o.initEnd),v.value=(t=a.value.find(n=>n.id===c.value))==null?void 0:t.time,o.initEnd});e.onMounted(()=>{b(),f.value=a.value.length-1});const I=e.computed(()=>({start:y.value,end:v.value}));e.watch(I,t=>{S("duration",{start:t.start,end:t.end})});const _=t=>{var n;return(n=a.value.find(r=>r.time===t))==null?void 0:n.id},b=()=>{let t=-1,n="",r=0,u="";for(let m=0;m<288;m++)r>=60&&(r=0),m%12===0&&(t+=1),n=t.toString().length===1?"0"+t.toString():t.toString(),u=r.toString().length===1?"0"+r.toString():r.toString(),a.value.push({id:m,time:n+":"+u}),r+=5},C=t=>{var n,r;l.value=t,c.value=t>=c.value?t+1:c.value,c.value>f.value&&(c.value=0),y.value=(n=a.value.find(u=>u.id===l.value))==null?void 0:n.time,v.value=(r=a.value.find(u=>u.id===c.value))==null?void 0:r.time},h=t=>{var n,r;c.value=t,l.value=t<=l.value?t-1:l.value,l.value<0&&(l.value=f.value),y.value=(n=a.value.find(u=>u.id===l.value))==null?void 0:n.time,v.value=(r=a.value.find(u=>u.id===c.value))==null?void 0:r.time},g=e.computed(()=>{const t={default:{bgElement:"#ffffff",neutralN900Color:"rgb(49, 49, 50)",bgSelected:"#f3f3f3",colorBorder:"rgb(223, 230, 238)"},izziBot:{bgElement:"rgba(17, 17, 17, 1)",neutralN900Color:"#ffffff",bgSelected:"rgba(36, 36, 36, 1)",colorBorder:"rgba(17, 17, 17, 1)"}},n=o.pTheme;return t[n]});return(t,n)=>{var r,u,m,x;return e.openBlock(),e.createElementBlock("div",{class:"vue3-time-duration",style:e.normalizeStyle({"--v-bg-element":(r=g.value)==null?void 0:r.bgElement,"--v-neutral-n900-color":(u=g.value)==null?void 0:u.neutralN900Color,"--v-bg-selected":(m=g.value)==null?void 0:m.bgSelected,"--v-color-border":(x=g.value)==null?void 0:x.colorBorder})},[e.withDirectives(e.createElementVNode("div",null,e.toDisplayString(I.value)+" "+e.toDisplayString(B.value)+" "+e.toDisplayString(E.value),513),[[e.vShow,!1]]),e.createElementVNode("div",U,[e.createVNode(T,{class:"vue3-time-duration__t-left","time-list":a.value,"time-list-id":l.value,"is-error":o.isError,"is-mobile":o.isMobile,onSelectedId:C},null,8,["time-list","time-list-id","is-error","is-mobile"]),t.isDash?(e.openBlock(),e.createElementBlock("div",P,"—")):e.createCommentVNode("",!0),e.createVNode(T,{class:"vue3-time-duration__t-right","time-list":a.value,"time-list-id":c.value,"is-error":o.isError,"is-mobile":o.isMobile,onSelectedId:h},null,8,["time-list","time-list-id","is-error","is-mobile"])])],4)}}})});
|