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-
|
|
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
|
|
2
|
-
const
|
|
3
|
-
const c =
|
|
4
|
-
for (const [
|
|
5
|
-
c[
|
|
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
|
-
},
|
|
8
|
-
function
|
|
9
|
-
return
|
|
10
|
-
|
|
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
|
|
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
|
-
},
|
|
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(
|
|
24
|
-
const c =
|
|
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
|
|
27
|
-
return
|
|
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(
|
|
30
|
-
|
|
29
|
+
set(e) {
|
|
30
|
+
n.value = e;
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
|
-
|
|
34
|
-
var
|
|
35
|
-
|
|
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
|
|
38
|
-
var
|
|
39
|
-
|
|
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
|
|
49
|
-
|
|
50
|
-
}, 200),
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
},
|
|
54
|
-
r.value = c.timeList.filter((
|
|
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 (
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
return (e, d) => (L(), I("div", j, [
|
|
53
|
+
C("div", q, [
|
|
54
|
+
N(C("input", {
|
|
59
55
|
ref_key: "inputRef",
|
|
60
|
-
ref:
|
|
61
|
-
"onUpdate:modelValue":
|
|
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:
|
|
65
|
-
onFocusout:
|
|
66
|
-
onInput:
|
|
60
|
+
onClick: t,
|
|
61
|
+
onFocusout: u,
|
|
62
|
+
onInput: s
|
|
67
63
|
}, null, 544), [
|
|
68
|
-
[
|
|
64
|
+
[U, p.value]
|
|
69
65
|
]),
|
|
70
|
-
|
|
66
|
+
V(Z, {
|
|
71
67
|
class: "ui-widget-time__w-icon",
|
|
72
|
-
onClick:
|
|
68
|
+
onClick: l
|
|
73
69
|
})
|
|
74
70
|
]),
|
|
75
|
-
a.value ? (
|
|
76
|
-
(
|
|
77
|
-
|
|
78
|
-
|
|
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":
|
|
76
|
+
"ui-widget-time__dropdown-item_selected": k.value === T
|
|
84
77
|
}),
|
|
85
|
-
onClick: (
|
|
86
|
-
},
|
|
78
|
+
onClick: (ee) => y(v.id)
|
|
79
|
+
}, R(v.time), 11, J)
|
|
87
80
|
]))), 128))
|
|
88
|
-
])) :
|
|
81
|
+
])) : P("", !0)
|
|
89
82
|
]));
|
|
90
83
|
}
|
|
91
|
-
}),
|
|
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(
|
|
98
|
-
const c =
|
|
99
|
-
|
|
100
|
-
var t, u,
|
|
101
|
-
|
|
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 =
|
|
104
|
-
() => (
|
|
105
|
-
),
|
|
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((
|
|
108
|
-
},
|
|
109
|
-
let t = -1, u = "",
|
|
110
|
-
for (let
|
|
111
|
-
|
|
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,
|
|
114
|
-
|
|
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) => (
|
|
120
|
-
|
|
121
|
-
[
|
|
112
|
+
return (t, u) => (L(), I("div", Q, [
|
|
113
|
+
N(C("div", null, R(k.value), 513), [
|
|
114
|
+
[O, !1]
|
|
122
115
|
]),
|
|
123
|
-
|
|
124
|
-
|
|
116
|
+
C("div", Y, [
|
|
117
|
+
V($, {
|
|
125
118
|
class: "vue3-time-duration__t-left",
|
|
126
119
|
"time-list": a.value,
|
|
127
|
-
"time-list-id":
|
|
128
|
-
onSelectedId:
|
|
120
|
+
"time-list-id": i.value,
|
|
121
|
+
onSelectedId: p
|
|
129
122
|
}, null, 8, ["time-list", "time-list-id"]),
|
|
130
|
-
|
|
123
|
+
V($, {
|
|
131
124
|
class: "vue3-time-duration__t-right",
|
|
132
125
|
"time-list": a.value,
|
|
133
|
-
"time-list-id":
|
|
134
|
-
onSelectedId:
|
|
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
|
-
|
|
134
|
+
ie as default
|
|
142
135
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,
|
|
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"])])]))}})});
|