vue3-time-duration 0.0.5 → 0.0.6

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-9ffea0af]{position:relative}.ui-widget-time__w[data-v-9ffea0af]{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-input[data-v-9ffea0af]{background-color:var(--bg-element);border:1px solid var(--bg-element);color:var(--color-font);font-size:16px;margin-left:3px;width:100%}.ui-widget-time__w-input[data-v-9ffea0af]:focus{outline-color:var(--bg-element);outline-style:solid}.ui-widget-time__w-icon[data-v-9ffea0af]{cursor:pointer}.ui-widget-time__dropdown[data-v-9ffea0af]{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-9ffea0af]{padding:6px 4px;cursor:pointer}.ui-widget-time__dropdown-item_selected[data-v-9ffea0af]{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-font: #333;--color-border: rgb(223, 230, 238)}.vue3-time-duration__t{display:flex;align-items:center}.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-8d06859e]{position:relative}.ui-widget-time__w[data-v-8d06859e]{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-input[data-v-8d06859e]{background-color:var(--bg-element);border:1px solid var(--bg-element);color:var(--color-font);font-size:16px;margin-left:3px;width:100%}.ui-widget-time__w-input[data-v-8d06859e]:focus{outline-color:var(--bg-element);outline-style:solid}.ui-widget-time__w-icon[data-v-8d06859e]{cursor:pointer}.ui-widget-time__dropdown[data-v-8d06859e]{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-8d06859e]{padding:6px 4px;cursor:pointer}.ui-widget-time__dropdown-item_selected[data-v-8d06859e]{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-font: #333;--color-border: rgb(223, 230, 238)}.vue3-time-duration__t{display:flex;align-items:center}.vue3-time-duration__t-left{margin-right:6px}.vue3-time-duration__t-right{margin-left:6px}
@@ -1,142 +1,135 @@
1
- import { createElementBlock as C, openBlock as x, createStaticVNode as M, defineComponent as $, ref as v, useTemplateRef as P, computed as V, watch as U, createElementVNode as S, createCommentVNode as W, withDirectives as B, createVNode as T, vModelText as b, Fragment as A, renderList as E, normalizeClass as H, toDisplayString as D, onMounted as O, vShow as z } from "vue";
2
- const F = (g, _) => {
3
- const c = g.__vccOpts || g;
4
- for (const [I, r] of _)
5
- c[I] = r;
1
+ import { createElementBlock as I, openBlock as L, createStaticVNode as F, defineComponent as B, ref as o, computed as S, watch as M, createElementVNode as C, createCommentVNode as P, withDirectives as N, createVNode as V, vModelText as U, Fragment as W, renderList as A, normalizeClass as E, toDisplayString as R, onMounted as H, vShow as O } from "vue";
2
+ const D = (h, f) => {
3
+ const c = h.__vccOpts || h;
4
+ for (const [w, r] of f)
5
+ c[w] = r;
6
6
  return c;
7
- }, X = {}, Z = { class: "icon-x-mark" };
8
- function j(g, _) {
9
- return x(), C("div", Z, _[0] || (_[0] = [
10
- M('<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)
7
+ }, b = {}, z = { class: "icon-x-mark" };
8
+ function X(h, f) {
9
+ return L(), I("div", z, f[0] || (f[0] = [
10
+ F('<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 q = /* @__PURE__ */ F(X, [["render", j], ["__scopeId", "data-v-7f1f4e49"]]), G = { class: "ui-widget-time" }, J = { class: "ui-widget-time__w" }, K = {
13
+ const Z = /* @__PURE__ */ D(b, [["render", X], ["__scopeId", "data-v-7f1f4e49"]]), j = { class: "ui-widget-time" }, q = { class: "ui-widget-time__w" }, G = {
14
14
  key: 0,
15
15
  class: "ui-widget-time__dropdown"
16
- }, Q = ["onClick"], Y = /* @__PURE__ */ $({
16
+ }, J = ["onClick"], K = /* @__PURE__ */ B({
17
17
  __name: "UiWidgetTime",
18
18
  props: {
19
19
  timeListId: { type: Number, default: 0 },
20
20
  timeList: { type: Array, default: [] }
21
21
  },
22
22
  emits: ["selectedId"],
23
- setup(g, { emit: _ }) {
24
- const c = g, I = _, r = v([]), a = v(!1), e = v(0), s = v(void 0), p = v(), f = v(!1), k = P("refItemList"), L = v(0), w = V(() => r.value.length > 0 ? r.value : c.timeList), y = V(() => c.timeListId), h = V({
23
+ setup(h, { emit: f }) {
24
+ const c = h, w = f, r = o([]), a = o(!1), i = o(0), n = o(void 0), _ = o(), m = o(!1), k = o(0), g = S(() => r.value.length > 0 ? r.value : c.timeList), x = S(() => c.timeListId), p = S({
25
25
  get() {
26
- var l;
27
- return s.value === void 0 ? (l = c.timeList.find((n) => n.id === y.value)) == null ? void 0 : l.time : s.value;
26
+ var e;
27
+ return n.value === void 0 ? (e = c.timeList.find((d) => d.id === x.value)) == null ? void 0 : e.time : n.value;
28
28
  },
29
- set(l) {
30
- s.value = l;
29
+ set(e) {
30
+ n.value = e;
31
31
  }
32
32
  });
33
- U(y, (l) => {
34
- var n;
35
- e.value = l, h.value = (n = c.timeList.find((o) => o.id === l)) == null ? void 0 : n.time;
33
+ M(x, (e) => {
34
+ var d;
35
+ i.value = e, p.value = (d = c.timeList.find((v) => v.id === e)) == null ? void 0 : d.time;
36
36
  });
37
- const t = (l) => {
38
- var n;
39
- e.value = l, h.value = (n = w.value.find((o) => o.id === e.value)) == null ? void 0 : n.time, a.value = !1, I("selectedId", e.value);
37
+ const y = (e) => {
38
+ var d;
39
+ i.value = e, p.value = (d = g.value.find((v) => v.id === i.value)) == null ? void 0 : d.time, a.value = !1, w("selectedId", i.value);
40
+ }, t = () => {
41
+ a.value = !0;
40
42
  }, u = () => {
41
- a.value = !0, setTimeout(() => {
42
- var n;
43
- const l = k.value;
44
- l !== null && (L.value = w.value.findIndex((o) => Number(o.id) === e.value), (n = l[L.value]) == null || n.scrollIntoView());
45
- }, 250);
46
- }, i = () => {
47
43
  setTimeout(() => {
48
- var l, n;
49
- f.value || (h.value = (l = w.value.find((o) => o.id === e.value)) == null ? void 0 : l.time, I("selectedId", (n = w.value.find((o) => o.id === e.value)) == null ? void 0 : n.id), a.value = !1);
50
- }, 200), f.value = !1;
51
- }, d = () => {
52
- e.value = 0, r.value = [], h.value = "", p.value.focus(), f.value = !0, a.value = !0;
53
- }, m = () => {
54
- r.value = c.timeList.filter((l) => l.time.startsWith(s.value));
44
+ var e, d;
45
+ m.value || (p.value = (e = g.value.find((v) => v.id === i.value)) == null ? void 0 : e.time, w("selectedId", (d = g.value.find((v) => v.id === i.value)) == null ? void 0 : d.id), a.value = !1);
46
+ }, 200), m.value = !1;
47
+ }, l = () => {
48
+ i.value = 0, r.value = [], p.value = "", _.value.focus(), m.value = !0, a.value = !0;
49
+ }, s = () => {
50
+ r.value = c.timeList.filter((e) => e.time.startsWith(n.value));
55
51
  };
56
- return (l, n) => (x(), C("div", G, [
57
- S("div", J, [
58
- B(S("input", {
52
+ return (e, d) => (L(), I("div", j, [
53
+ C("div", q, [
54
+ N(C("input", {
59
55
  ref_key: "inputRef",
60
- ref: p,
61
- "onUpdate:modelValue": n[0] || (n[0] = (o) => h.value = o),
56
+ ref: _,
57
+ "onUpdate:modelValue": d[0] || (d[0] = (v) => p.value = v),
62
58
  type: "text",
63
59
  class: "ui-widget-time__w-input",
64
- onClick: u,
65
- onFocusout: i,
66
- onInput: m
60
+ onClick: t,
61
+ onFocusout: u,
62
+ onInput: s
67
63
  }, null, 544), [
68
- [b, h.value]
64
+ [U, p.value]
69
65
  ]),
70
- T(q, {
66
+ V(Z, {
71
67
  class: "ui-widget-time__w-icon",
72
- onClick: d
68
+ onClick: l
73
69
  })
74
70
  ]),
75
- a.value ? (x(), C("div", K, [
76
- (x(!0), C(A, null, E(w.value, (o, N) => (x(), C("div", { key: N }, [
77
- S("div", {
78
- ref_for: !0,
79
- ref_key: "refItemList",
80
- ref: k,
81
- class: H({
71
+ a.value ? (L(), I("div", G, [
72
+ (L(!0), I(W, null, A(g.value, (v, T) => (L(), I("div", { key: T }, [
73
+ C("div", {
74
+ class: E({
82
75
  "ui-widget-time__dropdown-item": !0,
83
- "ui-widget-time__dropdown-item_selected": L.value === N
76
+ "ui-widget-time__dropdown-item_selected": k.value === T
84
77
  }),
85
- onClick: (ie) => t(o.id)
86
- }, D(o.time), 11, Q)
78
+ onClick: (ee) => y(v.id)
79
+ }, R(v.time), 11, J)
87
80
  ]))), 128))
88
- ])) : W("", !0)
81
+ ])) : P("", !0)
89
82
  ]));
90
83
  }
91
- }), R = /* @__PURE__ */ F(Y, [["__scopeId", "data-v-9ffea0af"]]), ee = { class: "vue3-time-duration" }, te = { class: "vue3-time-duration__t" }, ae = /* @__PURE__ */ $({
84
+ }), $ = /* @__PURE__ */ D(K, [["__scopeId", "data-v-8d06859e"]]), Q = { class: "vue3-time-duration" }, Y = { class: "vue3-time-duration__t" }, ie = /* @__PURE__ */ B({
92
85
  __name: "App",
93
86
  props: {
94
87
  modelValue: { default: () => ({ start: "00:00", end: "00:05" }) }
95
88
  },
96
89
  emits: ["update:modelValue"],
97
- setup(g, { emit: _ }) {
98
- const c = g, I = _, r = v(0), a = v([]), e = v(), s = v(), p = v(), f = v();
99
- O(() => {
100
- var t, u, i, d;
101
- w(), r.value = a.value.length - 1, e.value = L((t = c.modelValue) == null ? void 0 : t.start), s.value = L((u = c.modelValue) == null ? void 0 : u.end), p.value = (i = a.value.find((m) => m.id === e.value)) == null ? void 0 : i.time, f.value = (d = a.value.find((m) => m.id === s.value)) == null ? void 0 : d.time;
90
+ setup(h, { emit: f }) {
91
+ const c = h, w = f, r = o(0), a = o([]), i = o(), n = o(), _ = o(), m = o();
92
+ H(() => {
93
+ var t, u, l, s;
94
+ x(), r.value = a.value.length - 1, i.value = g((t = c.modelValue) == null ? void 0 : t.start), n.value = g((u = c.modelValue) == null ? void 0 : u.end), _.value = (l = a.value.find((e) => e.id === i.value)) == null ? void 0 : l.time, m.value = (s = a.value.find((e) => e.id === n.value)) == null ? void 0 : s.time;
102
95
  });
103
- const k = V(
104
- () => (I("update:modelValue", { start: p.value, end: f.value }), { start: p.value, end: f.value })
105
- ), L = (t) => {
96
+ const k = S(
97
+ () => (w("update:modelValue", { start: _.value, end: m.value }), { start: _.value, end: m.value })
98
+ ), g = (t) => {
106
99
  var u;
107
- return (u = a.value.find((i) => i.time === t)) == null ? void 0 : u.id;
108
- }, w = () => {
109
- let t = -1, u = "", i = 0, d = "";
110
- for (let m = 0; m < 288; m++)
111
- i >= 60 && (i = 0), m % 12 === 0 && (t += 1), u = t.toString().length === 1 ? "0" + t.toString() : t.toString(), d = i.toString().length === 1 ? "0" + i.toString() : i.toString(), a.value.push({ id: m, time: u + ":" + d }), i += 5;
100
+ return (u = a.value.find((l) => l.time === t)) == null ? void 0 : u.id;
101
+ }, x = () => {
102
+ let t = -1, u = "", l = 0, s = "";
103
+ for (let e = 0; e < 288; e++)
104
+ l >= 60 && (l = 0), e % 12 === 0 && (t += 1), u = t.toString().length === 1 ? "0" + t.toString() : t.toString(), s = l.toString().length === 1 ? "0" + l.toString() : l.toString(), a.value.push({ id: e, time: u + ":" + s }), l += 5;
105
+ }, p = (t) => {
106
+ var u, l;
107
+ i.value = t, n.value = t >= n.value ? t + 1 : n.value, n.value > r.value && (n.value = 0), _.value = (u = a.value.find((s) => s.id === i.value)) == null ? void 0 : u.time, m.value = (l = a.value.find((s) => s.id === n.value)) == null ? void 0 : l.time;
112
108
  }, y = (t) => {
113
- var u, i;
114
- e.value = t, s.value = t >= s.value ? t + 1 : s.value, s.value > r.value && (s.value = 0), p.value = (u = a.value.find((d) => d.id === e.value)) == null ? void 0 : u.time, f.value = (i = a.value.find((d) => d.id === s.value)) == null ? void 0 : i.time;
115
- }, h = (t) => {
116
- var u, i;
117
- s.value = t, e.value = t <= e.value ? t - 1 : e.value, e.value < 0 && (e.value = r.value), p.value = (u = a.value.find((d) => d.id === e.value)) == null ? void 0 : u.time, f.value = (i = a.value.find((d) => d.id === s.value)) == null ? void 0 : i.time;
109
+ var u, l;
110
+ n.value = t, i.value = t <= i.value ? t - 1 : i.value, i.value < 0 && (i.value = r.value), _.value = (u = a.value.find((s) => s.id === i.value)) == null ? void 0 : u.time, m.value = (l = a.value.find((s) => s.id === n.value)) == null ? void 0 : l.time;
118
111
  };
119
- return (t, u) => (x(), C("div", ee, [
120
- B(S("div", null, D(k.value), 513), [
121
- [z, !1]
112
+ return (t, u) => (L(), I("div", Q, [
113
+ N(C("div", null, R(k.value), 513), [
114
+ [O, !1]
122
115
  ]),
123
- S("div", te, [
124
- T(R, {
116
+ C("div", Y, [
117
+ V($, {
125
118
  class: "vue3-time-duration__t-left",
126
119
  "time-list": a.value,
127
- "time-list-id": e.value,
128
- onSelectedId: y
120
+ "time-list-id": i.value,
121
+ onSelectedId: p
129
122
  }, null, 8, ["time-list", "time-list-id"]),
130
- T(R, {
123
+ V($, {
131
124
  class: "vue3-time-duration__t-right",
132
125
  "time-list": a.value,
133
- "time-list-id": s.value,
134
- onSelectedId: h
126
+ "time-list-id": n.value,
127
+ onSelectedId: y
135
128
  }, null, 8, ["time-list", "time-list-id"])
136
129
  ])
137
130
  ]));
138
131
  }
139
132
  });
140
133
  export {
141
- ae as default
134
+ ie as default
142
135
  };
@@ -1 +1 @@
1
- (function(e,k){typeof exports=="object"&&typeof module<"u"?module.exports=k(require("vue")):typeof define=="function"&&define.amd?define(["vue"],k):(e=typeof globalThis<"u"?globalThis:e||self,e["vue3-time-duration"]=k(e.Vue))})(this,function(e){"use strict";const k=(g,p)=>{const u=g.__vccOpts||g;for(const[I,m]of p)u[I]=m;return u},y={},B={class:"icon-x-mark"};function N(g,p){return e.openBlock(),e.createElementBlock("div",B,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 T=k(y,[["render",N],["__scopeId","data-v-7f1f4e49"]]),E={class:"ui-widget-time"},$={class:"ui-widget-time__w"},D={key:0,class:"ui-widget-time__dropdown"},R=["onClick"],V=k(e.defineComponent({__name:"UiWidgetTime",props:{timeListId:{type:Number,default:0},timeList:{type:Array,default:[]}},emits:["selectedId"],setup(g,{emit:p}){const u=g,I=p,m=e.ref([]),a=e.ref(!1),t=e.ref(0),d=e.ref(void 0),_=e.ref(),v=e.ref(!1),C=e.useTemplateRef("refItemList"),L=e.ref(0),w=e.computed(()=>m.value.length>0?m.value:u.timeList),x=e.computed(()=>u.timeListId),h=e.computed({get(){var n;return d.value===void 0?(n=u.timeList.find(s=>s.id===x.value))==null?void 0:n.time:d.value},set(n){d.value=n}});e.watch(x,n=>{var s;t.value=n,h.value=(s=u.timeList.find(r=>r.id===n))==null?void 0:s.time});const i=n=>{var s;t.value=n,h.value=(s=w.value.find(r=>r.id===t.value))==null?void 0:s.time,a.value=!1,I("selectedId",t.value)},o=()=>{a.value=!0,setTimeout(()=>{var s;const n=C.value;n!==null&&(L.value=w.value.findIndex(r=>Number(r.id)===t.value),(s=n[L.value])==null||s.scrollIntoView())},250)},l=()=>{setTimeout(()=>{var n,s;v.value||(h.value=(n=w.value.find(r=>r.id===t.value))==null?void 0:n.time,I("selectedId",(s=w.value.find(r=>r.id===t.value))==null?void 0:s.id),a.value=!1)},200),v.value=!1},c=()=>{t.value=0,m.value=[],h.value="",_.value.focus(),v.value=!0,a.value=!0},f=()=>{m.value=u.timeList.filter(n=>n.time.startsWith(d.value))};return(n,s)=>(e.openBlock(),e.createElementBlock("div",E,[e.createElementVNode("div",$,[e.withDirectives(e.createElementVNode("input",{ref_key:"inputRef",ref:_,"onUpdate:modelValue":s[0]||(s[0]=r=>h.value=r),type:"text",class:"ui-widget-time__w-input",onClick:o,onFocusout:l,onInput:f},null,544),[[e.vModelText,h.value]]),e.createVNode(T,{class:"ui-widget-time__w-icon",onClick:c})]),a.value?(e.openBlock(),e.createElementBlock("div",D,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.value,(r,S)=>(e.openBlock(),e.createElementBlock("div",{key:S},[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===S}),onClick:W=>i(r.id)},e.toDisplayString(r.time),11,R)]))),128))])):e.createCommentVNode("",!0)]))}}),[["__scopeId","data-v-9ffea0af"]]),F={class:"vue3-time-duration"},M={class:"vue3-time-duration__t"};return e.defineComponent({__name:"App",props:{modelValue:{default:()=>({start:"00:00",end:"00:05"})}},emits:["update:modelValue"],setup(g,{emit:p}){const u=g,I=p,m=e.ref(0),a=e.ref([]),t=e.ref(),d=e.ref(),_=e.ref(),v=e.ref();e.onMounted(()=>{var i,o,l,c;w(),m.value=a.value.length-1,t.value=L((i=u.modelValue)==null?void 0:i.start),d.value=L((o=u.modelValue)==null?void 0:o.end),_.value=(l=a.value.find(f=>f.id===t.value))==null?void 0:l.time,v.value=(c=a.value.find(f=>f.id===d.value))==null?void 0:c.time});const C=e.computed(()=>(I("update:modelValue",{start:_.value,end:v.value}),{start:_.value,end:v.value})),L=i=>{var o;return(o=a.value.find(l=>l.time===i))==null?void 0:o.id},w=()=>{let i=-1,o="",l=0,c="";for(let f=0;f<288;f++)l>=60&&(l=0),f%12===0&&(i+=1),o=i.toString().length===1?"0"+i.toString():i.toString(),c=l.toString().length===1?"0"+l.toString():l.toString(),a.value.push({id:f,time:o+":"+c}),l+=5},x=i=>{var o,l;t.value=i,d.value=i>=d.value?i+1:d.value,d.value>m.value&&(d.value=0),_.value=(o=a.value.find(c=>c.id===t.value))==null?void 0:o.time,v.value=(l=a.value.find(c=>c.id===d.value))==null?void 0:l.time},h=i=>{var o,l;d.value=i,t.value=i<=t.value?i-1:t.value,t.value<0&&(t.value=m.value),_.value=(o=a.value.find(c=>c.id===t.value))==null?void 0:o.time,v.value=(l=a.value.find(c=>c.id===d.value))==null?void 0:l.time};return(i,o)=>(e.openBlock(),e.createElementBlock("div",F,[e.withDirectives(e.createElementVNode("div",null,e.toDisplayString(C.value),513),[[e.vShow,!1]]),e.createElementVNode("div",M,[e.createVNode(V,{class:"vue3-time-duration__t-left","time-list":a.value,"time-list-id":t.value,onSelectedId:x},null,8,["time-list","time-list-id"]),e.createVNode(V,{class:"vue3-time-duration__t-right","time-list":a.value,"time-list-id":d.value,onSelectedId:h},null,8,["time-list","time-list-id"])])]))}})});
1
+ (function(e,w){typeof exports=="object"&&typeof module<"u"?module.exports=w(require("vue")):typeof define=="function"&&define.amd?define(["vue"],w):(e=typeof globalThis<"u"?globalThis:e||self,e["vue3-time-duration"]=w(e.Vue))})(this,function(e){"use strict";const w=(h,p)=>{const u=h.__vccOpts||h;for(const[k,m]of p)u[k]=m;return u},V={},y={class:"icon-x-mark"};function B(h,p){return e.openBlock(),e.createElementBlock("div",y,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 E=w(V,[["render",B],["__scopeId","data-v-7f1f4e49"]]),N={class:"ui-widget-time"},T={class:"ui-widget-time__w"},$={key:0,class:"ui-widget-time__dropdown"},D=["onClick"],x=w(e.defineComponent({__name:"UiWidgetTime",props:{timeListId:{type:Number,default:0},timeList:{type:Array,default:[]}},emits:["selectedId"],setup(h,{emit:p}){const u=h,k=p,m=e.ref([]),a=e.ref(!1),l=e.ref(0),d=e.ref(void 0),v=e.ref(),f=e.ref(!1),I=e.ref(0),g=e.computed(()=>m.value.length>0?m.value:u.timeList),C=e.computed(()=>u.timeListId),_=e.computed({get(){var t;return d.value===void 0?(t=u.timeList.find(c=>c.id===C.value))==null?void 0:t.time:d.value},set(t){d.value=t}});e.watch(C,t=>{var c;l.value=t,_.value=(c=u.timeList.find(r=>r.id===t))==null?void 0:c.time});const L=t=>{var c;l.value=t,_.value=(c=g.value.find(r=>r.id===l.value))==null?void 0:c.time,a.value=!1,k("selectedId",l.value)},i=()=>{a.value=!0},o=()=>{setTimeout(()=>{var t,c;f.value||(_.value=(t=g.value.find(r=>r.id===l.value))==null?void 0:t.time,k("selectedId",(c=g.value.find(r=>r.id===l.value))==null?void 0:c.id),a.value=!1)},200),f.value=!1},n=()=>{l.value=0,m.value=[],_.value="",v.value.focus(),f.value=!0,a.value=!0},s=()=>{m.value=u.timeList.filter(t=>t.time.startsWith(d.value))};return(t,c)=>(e.openBlock(),e.createElementBlock("div",N,[e.createElementVNode("div",T,[e.withDirectives(e.createElementVNode("input",{ref_key:"inputRef",ref:v,"onUpdate:modelValue":c[0]||(c[0]=r=>_.value=r),type:"text",class:"ui-widget-time__w-input",onClick:i,onFocusout:o,onInput:s},null,544),[[e.vModelText,_.value]]),e.createVNode(E,{class:"ui-widget-time__w-icon",onClick:n})]),a.value?(e.openBlock(),e.createElementBlock("div",$,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.value,(r,S)=>(e.openBlock(),e.createElementBlock("div",{key:S},[e.createElementVNode("div",{class:e.normalizeClass({"ui-widget-time__dropdown-item":!0,"ui-widget-time__dropdown-item_selected":I.value===S}),onClick:U=>L(r.id)},e.toDisplayString(r.time),11,D)]))),128))])):e.createCommentVNode("",!0)]))}}),[["__scopeId","data-v-8d06859e"]]),R={class:"vue3-time-duration"},F={class:"vue3-time-duration__t"};return e.defineComponent({__name:"App",props:{modelValue:{default:()=>({start:"00:00",end:"00:05"})}},emits:["update:modelValue"],setup(h,{emit:p}){const u=h,k=p,m=e.ref(0),a=e.ref([]),l=e.ref(),d=e.ref(),v=e.ref(),f=e.ref();e.onMounted(()=>{var i,o,n,s;C(),m.value=a.value.length-1,l.value=g((i=u.modelValue)==null?void 0:i.start),d.value=g((o=u.modelValue)==null?void 0:o.end),v.value=(n=a.value.find(t=>t.id===l.value))==null?void 0:n.time,f.value=(s=a.value.find(t=>t.id===d.value))==null?void 0:s.time});const I=e.computed(()=>(k("update:modelValue",{start:v.value,end:f.value}),{start:v.value,end:f.value})),g=i=>{var o;return(o=a.value.find(n=>n.time===i))==null?void 0:o.id},C=()=>{let i=-1,o="",n=0,s="";for(let t=0;t<288;t++)n>=60&&(n=0),t%12===0&&(i+=1),o=i.toString().length===1?"0"+i.toString():i.toString(),s=n.toString().length===1?"0"+n.toString():n.toString(),a.value.push({id:t,time:o+":"+s}),n+=5},_=i=>{var o,n;l.value=i,d.value=i>=d.value?i+1:d.value,d.value>m.value&&(d.value=0),v.value=(o=a.value.find(s=>s.id===l.value))==null?void 0:o.time,f.value=(n=a.value.find(s=>s.id===d.value))==null?void 0:n.time},L=i=>{var o,n;d.value=i,l.value=i<=l.value?i-1:l.value,l.value<0&&(l.value=m.value),v.value=(o=a.value.find(s=>s.id===l.value))==null?void 0:o.time,f.value=(n=a.value.find(s=>s.id===d.value))==null?void 0:n.time};return(i,o)=>(e.openBlock(),e.createElementBlock("div",R,[e.withDirectives(e.createElementVNode("div",null,e.toDisplayString(I.value),513),[[e.vShow,!1]]),e.createElementVNode("div",F,[e.createVNode(x,{class:"vue3-time-duration__t-left","time-list":a.value,"time-list-id":l.value,onSelectedId:_},null,8,["time-list","time-list-id"]),e.createVNode(x,{class:"vue3-time-duration__t-right","time-list":a.value,"time-list-id":d.value,onSelectedId:L},null,8,["time-list","time-list-id"])])]))}})});
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.0.5",
4
+ "version": "0.0.6",
5
5
  "private": false,
6
6
  "author": "Egor Lentarev",
7
7
  "license": "MIT",