vue3-time-duration 0.4.0 → 0.4.2

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