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