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-a2391572]{position:relative}.ui-widget-time__w[data-v-a2391572]{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-a2391572]{border:1px solid var(--color-border-error);background-color:var(--bg-element-error)}.ui-widget-time__w-input[data-v-a2391572]{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-a2391572]{background-color:var(--bg-element-error);border:1px solid var(--bg-element-error)}.ui-widget-time__w-input[data-v-a2391572]:focus{outline:0 solid transparent}.ui-widget-time__w-icon[data-v-a2391572]{cursor:pointer}.ui-widget-time__dropdown[data-v-a2391572]{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-a2391572]{padding:6px 4px;cursor:pointer;font-size:var(--size-font)}.ui-widget-time__dropdown-item_selected[data-v-a2391572]{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
+ .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 g, createElementBlock as w, createStaticVNode as P, defineComponent as D, ref as d, computed as L, watch as N, createElementVNode as C, normalizeClass as T, withDirectives as V, vModelText as U, createVNode as b, Fragment as W, renderList as A, toDisplayString as k, createCommentVNode as R, onMounted as H, vShow as O } from "vue";
2
- const F = (p, c) => {
3
- const a = p.__vccOpts || p;
4
- for (const [I, v] of c)
5
- a[I] = v;
6
- return a;
7
- }, z = {}, X = { class: "icon-x-mark" };
8
- function Z(p, c) {
9
- return g(), w("div", X, c[0] || (c[0] = [
10
- P('<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)
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 j = /* @__PURE__ */ F(z, [["render", Z], ["__scopeId", "data-v-7f1f4e49"]]), q = { class: "ui-widget-time" }, G = {
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
- }, J = ["onClick"], K = /* @__PURE__ */ D({
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(p, { emit: c }) {
26
- const a = p, I = c, v = d([]), s = d(!1), l = d(0), o = d(void 0), h = d(), m = d(!1), x = d(), y = d(0), f = L(() => v.value.length > 0 ? v.value : a.timeList), S = L(() => a.timeListId), _ = L({
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 e;
29
- return o.value === void 0 ? (e = a.timeList.find((i) => i.id === S.value)) == null ? void 0 : e.time : o.value;
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(e) {
32
- o.value = e;
33
+ set(t) {
34
+ d.value = t;
33
35
  }
34
36
  });
35
- N(S, (e) => {
36
- var i;
37
- l.value = e, _.value = (i = a.timeList.find((r) => r.id === e)) == null ? void 0 : i.time;
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 E = (e) => {
40
- var i;
41
- l.value = e, _.value = (i = f.value.find((r) => r.id === l.value)) == null ? void 0 : i.time, s.value = !1, I("selectedId", l.value);
42
- }, B = () => {
43
- s.value = !0, setTimeout(() => {
44
- var i;
45
- const e = x.value;
46
- e !== null && (y.value = f.value.findIndex((r) => Number(r.id) === l.value), (i = e[y.value]) == null || i.scrollIntoView());
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
- }, t = () => {
54
+ }, b = () => {
49
55
  setTimeout(() => {
50
- var e, i;
51
- m.value || (_.value = (e = f.value.find((r) => r.id === l.value)) == null ? void 0 : e.time, I("selectedId", (i = f.value.find((r) => r.id === l.value)) == null ? void 0 : i.id), s.value = !1);
52
- }, 200), m.value = !1;
53
- }, n = () => {
54
- l.value = 0, v.value = [], _.value = "", h.value.focus(), m.value = !0, s.value = !0;
55
- }, u = () => {
56
- v.value = a.timeList.filter((e) => e.time.startsWith(o.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 (e, i) => (g(), w("div", q, [
59
- C("div", {
60
- class: T({ "ui-widget-time__w": !0, "ui-widget-time__w_error": a.isError })
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
- V(C("input", {
81
+ U(E("input", {
63
82
  ref_key: "inputRef",
64
- ref: h,
65
- "onUpdate:modelValue": i[0] || (i[0] = (r) => _.value = r),
83
+ ref: w,
84
+ "onUpdate:modelValue": l[0] || (l[0] = (a) => p.value = a),
66
85
  type: "text",
67
- class: T({ "ui-widget-time__w-input": !0, "ui-widget-time__w-input_error": a.isError }),
68
- onClick: B,
69
- onFocusout: t,
70
- onInput: u,
71
- readonly: !0,
72
- tabindex: "-1"
73
- }, null, 34), [
74
- [U, _.value]
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
- b(j, {
95
+ N(ee, {
77
96
  class: "ui-widget-time__w-icon",
78
- onClick: n
97
+ onClick: A
79
98
  })
80
99
  ], 2),
81
- s.value ? (g(), w("div", G, [
82
- (g(!0), w(W, null, A(f.value, (r, M) => (g(), w("div", { key: M }, [
83
- C("div", {
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: x,
87
- class: T({
105
+ ref: B,
106
+ class: $({
88
107
  "ui-widget-time__dropdown-item": !0,
89
- "ui-widget-time__dropdown-item_selected": y.value === M
108
+ "ui-widget-time__dropdown-item_selected": x.value === C
90
109
  }),
91
- onClick: (te) => E(r.id)
92
- }, k(r.time), 11, J)
110
+ onClick: (Y) => r(a.id)
111
+ }, M(a.time), 11, oe)
93
112
  ]))), 128))
94
- ])) : R("", !0)
113
+ ])) : P("", !0)
95
114
  ]));
96
115
  }
97
- }), $ = /* @__PURE__ */ F(K, [["__scopeId", "data-v-a2391572"]]), Q = { class: "vue3-time-duration" }, Y = { class: "vue3-time-duration__t" }, ee = {
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
- }, le = /* @__PURE__ */ D({
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(p, { emit: c }) {
111
- const a = p, I = c, v = d(0), s = d([]), l = d(), o = d(), h = d(), m = d(), x = L(() => {
112
- var t;
113
- return l.value = S(a.initStart), h.value = (t = s.value.find((n) => n.id === l.value)) == null ? void 0 : t.time, a.initStart;
114
- }), y = L(() => {
115
- var t;
116
- return o.value = S(a.initEnd), m.value = (t = s.value.find((n) => n.id === o.value)) == null ? void 0 : t.time, a.initEnd;
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
- _(), v.value = s.value.length - 1;
138
+ g(), v.value = s.value.length - 1;
120
139
  });
121
- const f = L(
122
- () => ({ start: h.value, end: m.value })
140
+ const S = k(
141
+ () => ({ start: w.value, end: f.value })
123
142
  );
124
- N(f, (t) => {
125
- I("duration", { start: t.start, end: t.end });
143
+ R(S, (e) => {
144
+ L("duration", { start: e.start, end: e.end });
126
145
  });
127
- const S = (t) => {
146
+ const _ = (e) => {
128
147
  var n;
129
- return (n = s.value.find((u) => u.time === t)) == null ? void 0 : n.id;
130
- }, _ = () => {
131
- let t = -1, n = "", u = 0, e = "";
132
- for (let i = 0; i < 288; i++)
133
- u >= 60 && (u = 0), i % 12 === 0 && (t += 1), n = t.toString().length === 1 ? "0" + t.toString() : t.toString(), e = u.toString().length === 1 ? "0" + u.toString() : u.toString(), s.value.push({ id: i, time: n + ":" + e }), u += 5;
134
- }, E = (t) => {
135
- var n, u;
136
- l.value = t, o.value = t >= o.value ? t + 1 : o.value, o.value > v.value && (o.value = 0), h.value = (n = s.value.find((e) => e.id === l.value)) == null ? void 0 : n.time, m.value = (u = s.value.find((e) => e.id === o.value)) == null ? void 0 : u.time;
137
- }, B = (t) => {
138
- var n, u;
139
- o.value = t, l.value = t <= l.value ? t - 1 : l.value, l.value < 0 && (l.value = v.value), h.value = (n = s.value.find((e) => e.id === l.value)) == null ? void 0 : n.time, m.value = (u = s.value.find((e) => e.id === o.value)) == null ? void 0 : u.time;
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 (t, n) => (g(), w("div", Q, [
142
- V(C("div", null, k(f.value) + " " + k(x.value) + " " + k(y.value), 513), [
143
- [O, !1]
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
- C("div", Y, [
146
- b($, {
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": l.value,
150
- "is-error": a.isError,
151
- "is-mobile": a.isMobile,
152
- onSelectedId: E
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
- t.isDash ? (g(), w("div", ee, "—")) : R("", !0),
155
- b($, {
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": o.value,
159
- "is-error": a.isError,
160
- onSelectedId: B
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
- le as default
186
+ re as default
168
187
  };
@@ -1 +1 @@
1
- (function(e,g){typeof exports=="object"&&typeof module<"u"?module.exports=g(require("vue")):typeof define=="function"&&define.amd?define(["vue"],g):(e=typeof globalThis<"u"?globalThis:e||self,e["vue3-time-duration"]=g(e.Vue))})(this,function(e){"use strict";const g=(v,m)=>{const o=v.__vccOpts||v;for(const[w,u]of m)o[w]=u;return o},L={},x={class:"icon-x-mark"};function V(v,m){return e.openBlock(),e.createElementBlock("div",x,m[0]||(m[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 N=g(L,[["render",V],["__scopeId","data-v-7f1f4e49"]]),T={class:"ui-widget-time"},D={key:0,class:"ui-widget-time__dropdown"},b=["onClick"],B=g(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(v,{emit:m}){const o=v,w=m,u=e.ref([]),r=e.ref(!1),n=e.ref(0),s=e.ref(void 0),h=e.ref(),f=e.ref(!1),y=e.ref(),k=e.ref(0),p=e.computed(()=>u.value.length>0?u.value:o.timeList),I=e.computed(()=>o.timeListId),_=e.computed({get(){var t;return s.value===void 0?(t=o.timeList.find(l=>l.id===I.value))==null?void 0:t.time:s.value},set(t){s.value=t}});e.watch(I,t=>{var l;n.value=t,_.value=(l=o.timeList.find(c=>c.id===t))==null?void 0:l.time});const C=t=>{var l;n.value=t,_.value=(l=p.value.find(c=>c.id===n.value))==null?void 0:l.time,r.value=!1,w("selectedId",n.value)},S=()=>{r.value=!0,setTimeout(()=>{var l;const t=y.value;t!==null&&(k.value=p.value.findIndex(c=>Number(c.id)===n.value),(l=t[k.value])==null||l.scrollIntoView())},250)},i=()=>{setTimeout(()=>{var t,l;f.value||(_.value=(t=p.value.find(c=>c.id===n.value))==null?void 0:t.time,w("selectedId",(l=p.value.find(c=>c.id===n.value))==null?void 0:l.id),r.value=!1)},200),f.value=!1},a=()=>{n.value=0,u.value=[],_.value="",h.value.focus(),f.value=!0,r.value=!0},d=()=>{u.value=o.timeList.filter(t=>t.time.startsWith(s.value))};return(t,l)=>(e.openBlock(),e.createElementBlock("div",T,[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:h,"onUpdate:modelValue":l[0]||(l[0]=c=>_.value=c),type:"text",class:e.normalizeClass({"ui-widget-time__w-input":!0,"ui-widget-time__w-input_error":o.isError}),onClick:S,onFocusout:i,onInput:d,readonly:!0,tabindex:"-1"},null,34),[[e.vModelText,_.value]]),e.createVNode(N,{class:"ui-widget-time__w-icon",onClick:a})],2),r.value?(e.openBlock(),e.createElementBlock("div",D,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,(c,E)=>(e.openBlock(),e.createElementBlock("div",{key:E},[e.createElementVNode("div",{ref_for:!0,ref_key:"refItemList",ref:y,class:e.normalizeClass({"ui-widget-time__dropdown-item":!0,"ui-widget-time__dropdown-item_selected":k.value===E}),onClick:P=>C(c.id)},e.toDisplayString(c.time),11,b)]))),128))])):e.createCommentVNode("",!0)]))}}),[["__scopeId","data-v-a2391572"]]),$={class:"vue3-time-duration"},M={class:"vue3-time-duration__t"},R={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(v,{emit:m}){const o=v,w=m,u=e.ref(0),r=e.ref([]),n=e.ref(),s=e.ref(),h=e.ref(),f=e.ref(),y=e.computed(()=>{var i;return n.value=I(o.initStart),h.value=(i=r.value.find(a=>a.id===n.value))==null?void 0:i.time,o.initStart}),k=e.computed(()=>{var i;return s.value=I(o.initEnd),f.value=(i=r.value.find(a=>a.id===s.value))==null?void 0:i.time,o.initEnd});e.onMounted(()=>{_(),u.value=r.value.length-1});const p=e.computed(()=>({start:h.value,end:f.value}));e.watch(p,i=>{w("duration",{start:i.start,end:i.end})});const I=i=>{var a;return(a=r.value.find(d=>d.time===i))==null?void 0:a.id},_=()=>{let i=-1,a="",d=0,t="";for(let l=0;l<288;l++)d>=60&&(d=0),l%12===0&&(i+=1),a=i.toString().length===1?"0"+i.toString():i.toString(),t=d.toString().length===1?"0"+d.toString():d.toString(),r.value.push({id:l,time:a+":"+t}),d+=5},C=i=>{var a,d;n.value=i,s.value=i>=s.value?i+1:s.value,s.value>u.value&&(s.value=0),h.value=(a=r.value.find(t=>t.id===n.value))==null?void 0:a.time,f.value=(d=r.value.find(t=>t.id===s.value))==null?void 0:d.time},S=i=>{var a,d;s.value=i,n.value=i<=n.value?i-1:n.value,n.value<0&&(n.value=u.value),h.value=(a=r.value.find(t=>t.id===n.value))==null?void 0:a.time,f.value=(d=r.value.find(t=>t.id===s.value))==null?void 0:d.time};return(i,a)=>(e.openBlock(),e.createElementBlock("div",$,[e.withDirectives(e.createElementVNode("div",null,e.toDisplayString(p.value)+" "+e.toDisplayString(y.value)+" "+e.toDisplayString(k.value),513),[[e.vShow,!1]]),e.createElementVNode("div",M,[e.createVNode(B,{class:"vue3-time-duration__t-left","time-list":r.value,"time-list-id":n.value,"is-error":o.isError,"is-mobile":o.isMobile,onSelectedId:C},null,8,["time-list","time-list-id","is-error","is-mobile"]),i.isDash?(e.openBlock(),e.createElementBlock("div",R,"—")):e.createCommentVNode("",!0),e.createVNode(B,{class:"vue3-time-duration__t-right","time-list":r.value,"time-list-id":s.value,"is-error":o.isError,onSelectedId:S},null,8,["time-list","time-list-id","is-error"])])]))}})});
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"])])]))}})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vue3-time-duration",
3
3
  "description": "UI Widget to set a time duration. This is a component for vue 3",
4
- "version": "0.3.8",
4
+ "version": "0.4.0",
5
5
  "private": false,
6
6
  "author": "Egor Lentarev",
7
7
  "license": "MIT",