vue3-time-duration 0.4.2 → 0.4.3
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,4 +1,4 @@
|
|
|
1
|
-
import { openBlock as S, createElementBlock as I, createStaticVNode as Y, defineComponent as
|
|
1
|
+
import { openBlock as S, createElementBlock as I, createStaticVNode as Y, defineComponent as z, ref as u, computed as L, watch as H, onMounted as U, onUnmounted as X, createElementVNode as B, normalizeClass as V, withDirectives as P, vModelText as Z, createVNode as F, Fragment as j, renderList as q, toDisplayString as $, createCommentVNode as W, normalizeStyle as G, vShow as J } from "vue";
|
|
2
2
|
const A = (w, f) => {
|
|
3
3
|
const t = w.__vccOpts || w;
|
|
4
4
|
for (const [C, v] of f)
|
|
@@ -13,7 +13,7 @@ function ee(w, f) {
|
|
|
13
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
|
-
}, ne = ["onClick"], se = /* @__PURE__ */
|
|
16
|
+
}, ne = ["onClick"], se = /* @__PURE__ */ z({
|
|
17
17
|
__name: "UiWidgetTime",
|
|
18
18
|
props: {
|
|
19
19
|
timeListId: { type: Number, default: 0 },
|
|
@@ -76,14 +76,14 @@ const te = /* @__PURE__ */ A(K, [["render", ee], ["__scopeId", "data-v-7f1f4e49"
|
|
|
76
76
|
e(), document.removeEventListener("wheel", D), document.removeEventListener("touchmove", D);
|
|
77
77
|
}), (i, s) => (S(), I("div", ie, [
|
|
78
78
|
B("div", {
|
|
79
|
-
class:
|
|
79
|
+
class: V({ "ui-widget-time__w": !0, "ui-widget-time__w_error": t.isError })
|
|
80
80
|
}, [
|
|
81
81
|
P(B("input", {
|
|
82
82
|
ref_key: "inputRef",
|
|
83
83
|
ref: y,
|
|
84
84
|
"onUpdate:modelValue": s[0] || (s[0] = (a) => h.value = a),
|
|
85
85
|
type: "text",
|
|
86
|
-
class:
|
|
86
|
+
class: V({ "ui-widget-time__w-input": !0, "ui-widget-time__w-input_error": t.isError }),
|
|
87
87
|
onClick: n,
|
|
88
88
|
onFocus: g,
|
|
89
89
|
onFocusout: c,
|
|
@@ -92,7 +92,7 @@ const te = /* @__PURE__ */ A(K, [["render", ee], ["__scopeId", "data-v-7f1f4e49"
|
|
|
92
92
|
}, null, 42, le), [
|
|
93
93
|
[Z, h.value]
|
|
94
94
|
]),
|
|
95
|
-
|
|
95
|
+
F(te, {
|
|
96
96
|
class: "ui-widget-time__w-icon",
|
|
97
97
|
onClick: m
|
|
98
98
|
})
|
|
@@ -103,7 +103,7 @@ const te = /* @__PURE__ */ A(K, [["render", ee], ["__scopeId", "data-v-7f1f4e49"
|
|
|
103
103
|
ref_for: !0,
|
|
104
104
|
ref_key: "refItemList",
|
|
105
105
|
ref: T,
|
|
106
|
-
class:
|
|
106
|
+
class: V({
|
|
107
107
|
"ui-widget-time__dropdown-item": !0,
|
|
108
108
|
"ui-widget-time__dropdown-item_selected": x.value === E
|
|
109
109
|
}),
|
|
@@ -113,13 +113,13 @@ const te = /* @__PURE__ */ A(K, [["render", ee], ["__scopeId", "data-v-7f1f4e49"
|
|
|
113
113
|
])) : W("", !0)
|
|
114
114
|
]));
|
|
115
115
|
}
|
|
116
|
-
}),
|
|
116
|
+
}), R = /* @__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
|
-
}, de = /* @__PURE__ */
|
|
119
|
+
}, de = /* @__PURE__ */ z({
|
|
120
120
|
__name: "App",
|
|
121
121
|
props: {
|
|
122
|
-
pTheme: { default: () => "
|
|
122
|
+
pTheme: { default: () => "default" },
|
|
123
123
|
initStart: { default: () => "00:00" },
|
|
124
124
|
initEnd: { default: () => "00:05" },
|
|
125
125
|
isDash: { type: Boolean, default: () => !1 },
|
|
@@ -189,7 +189,7 @@ const te = /* @__PURE__ */ A(K, [["render", ee], ["__scopeId", "data-v-7f1f4e49"
|
|
|
189
189
|
[J, !1]
|
|
190
190
|
]),
|
|
191
191
|
B("div", re, [
|
|
192
|
-
|
|
192
|
+
F(R, {
|
|
193
193
|
class: "vue3-time-duration__t-left",
|
|
194
194
|
"time-list": r.value,
|
|
195
195
|
"time-list-id": l.value,
|
|
@@ -198,7 +198,7 @@ const te = /* @__PURE__ */ A(K, [["render", ee], ["__scopeId", "data-v-7f1f4e49"
|
|
|
198
198
|
onSelectedId: M
|
|
199
199
|
}, null, 8, ["time-list", "time-list-id", "is-error", "is-mobile"]),
|
|
200
200
|
e.isDash ? (S(), I("div", ae, "—")) : W("", !0),
|
|
201
|
-
|
|
201
|
+
F(R, {
|
|
202
202
|
class: "vue3-time-duration__t-right",
|
|
203
203
|
"time-list": r.value,
|
|
204
204
|
"time-list-id": d.value,
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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 $=S(V,[["render",M],["__scopeId","data-v-7f1f4e49"]]),z={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),B=e.ref(),I=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=B.value;l!==null&&(I.value=b.value.findIndex(d=>Number(d.id)===o.value),(s=l[I.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 L=d;if(L.scrollHeight>L.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",z,[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($,{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,L)=>(e.openBlock(),e.createElementBlock("div",{key:L},[e.createElementVNode("div",{ref_for:!0,ref_key:"refItemList",ref:B,class:e.normalizeClass({"ui-widget-time__dropdown-item":!0,"ui-widget-time__dropdown-item_selected":I.value===L}),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:()=>"default"},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(),B=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}),I=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(B.value)+" "+e.toDisplayString(I.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)}}})});
|