lkt-tabs 1.0.7 → 1.0.8
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.
- package/dist/lkt-tabs.es.js +102 -94
- package/dist/lkt-tabs.umd.js +1 -1
- package/dist/{types → src}/lib-components/LktTabs.vue.d.ts +88 -124
- package/package.json +4 -2
- package/src/components/LktTab.vue +1 -9
- package/src/lib-components/LktTabs.vue +26 -32
- /package/dist/{types → src}/components/LktTab.vue.d.ts +0 -0
- /package/dist/{types → src}/constants.d.ts +0 -0
- /package/dist/{types → src}/functions/functions.d.ts +0 -0
- /package/dist/{types → src}/index.d.ts +0 -0
package/dist/lkt-tabs.es.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { defineComponent as B, ref as g, computed as c, watch as $, openBlock as r, createElementBlock as i, unref as u, renderSlot as p, createCommentVNode as P, getCurrentInstance as q, nextTick as x, normalizeClass as L, withDirectives as F, createElementVNode as V, Fragment as b, renderList as _, withModifiers as H, vShow as O, normalizeStyle as z, createBlock as D, withCtx as E } from "vue";
|
|
2
|
+
import { getSessionStorage as K, setSessionStorage as N } from "lkt-session";
|
|
3
|
+
function U(a = 10) {
|
|
4
|
+
let l = "";
|
|
5
|
+
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", s = t.length;
|
|
6
|
+
for (let n = 0; n < a; n++)
|
|
7
|
+
l += t.charAt(Math.floor(Math.random() * s));
|
|
8
|
+
return l;
|
|
9
|
+
}
|
|
10
|
+
function Y(a) {
|
|
11
|
+
return typeof a == "string";
|
|
12
|
+
}
|
|
13
|
+
const G = ["id"], J = /* @__PURE__ */ B({
|
|
14
|
+
__name: "LktTab",
|
|
12
15
|
props: {
|
|
13
16
|
id: { type: String, default: "" },
|
|
14
17
|
name: { type: String, required: !0 },
|
|
@@ -17,116 +20,121 @@ const B = (a) => `lkt-tabs.${window.location.host}${window.location.pathname}.${
|
|
|
17
20
|
isDisabled: { type: Boolean, default: !1 }
|
|
18
21
|
},
|
|
19
22
|
emits: ["is-active"],
|
|
20
|
-
setup(a, { emit:
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
+
setup(a, { emit: l }) {
|
|
24
|
+
const t = a, s = g(!1), n = g(U(8)), m = c(() => t.id ? t.id : Y(t.name) && t.name.length > 0 ? t.name.toLowerCase().replace(/ /g, "-") : n.value), h = () => {
|
|
25
|
+
s.value = t.activeHash === t.hash, l("is-active", s.value);
|
|
23
26
|
};
|
|
24
|
-
return $(() =>
|
|
27
|
+
return $(() => t.activeHash, h), h(), (d, T) => s.value ? (r(), i("section", {
|
|
25
28
|
key: 0,
|
|
26
29
|
"data-lkt": "tab-content",
|
|
27
30
|
id: u(m),
|
|
28
31
|
role: "tabpanel"
|
|
29
32
|
}, [
|
|
30
|
-
|
|
31
|
-
], 8,
|
|
33
|
+
p(d.$slots, "default")
|
|
34
|
+
], 8, G)) : P("", !0);
|
|
32
35
|
}
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
});
|
|
37
|
+
function S(a, l) {
|
|
38
|
+
const t = {};
|
|
39
|
+
let s = {};
|
|
40
|
+
if (a && (s = Object.assign(s, a)), l) {
|
|
41
|
+
for (const n in s)
|
|
42
|
+
n.indexOf(l) === 0 && (t[n.replace(l, "")] = s[n]);
|
|
43
|
+
return t;
|
|
44
|
+
}
|
|
45
|
+
for (const n in s)
|
|
46
|
+
t[n] = s[n];
|
|
47
|
+
return t;
|
|
48
|
+
}
|
|
49
|
+
const I = (a) => `lkt-tabs.${window.location.host}${window.location.pathname}.${a}`, Q = (a) => K(I(a)), R = (a, l, t) => {
|
|
50
|
+
N(I(a), l, t * 60);
|
|
51
|
+
}, W = { class: "lkt-tabs__list" }, X = ["href", "onClick"], Z = ["innerHTML", "onClick", "href"], tt = { "data-lkt": "tab" }, et = /* @__PURE__ */ B({
|
|
52
|
+
__name: "LktTabs",
|
|
40
53
|
props: {
|
|
41
|
-
|
|
42
|
-
|
|
54
|
+
modelValue: { default: "" },
|
|
55
|
+
id: { default: "" },
|
|
43
56
|
useSession: { type: Boolean, default: !1 },
|
|
44
|
-
cacheLifetime: {
|
|
45
|
-
contentPad: {
|
|
46
|
-
palette: {
|
|
47
|
-
titles: {
|
|
48
|
-
type: Object,
|
|
49
|
-
default() {
|
|
50
|
-
return {};
|
|
51
|
-
}
|
|
52
|
-
}
|
|
57
|
+
cacheLifetime: { default: 5 },
|
|
58
|
+
contentPad: { default: "" },
|
|
59
|
+
palette: { default: "" },
|
|
60
|
+
titles: { default: () => ({}) }
|
|
53
61
|
},
|
|
54
62
|
emits: ["update:modelValue"],
|
|
55
|
-
setup(a, { emit:
|
|
56
|
-
const
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
let
|
|
60
|
-
|
|
63
|
+
setup(a, { emit: l }) {
|
|
64
|
+
const t = a, { ctx: s } = q(), n = g("");
|
|
65
|
+
if (t.useSession) {
|
|
66
|
+
t.id || console.warn("[LKT Tabs] You're trying to use session provided tabs without the required id. Please, add id attr");
|
|
67
|
+
let e = Q(t.id);
|
|
68
|
+
e && (n.value = e);
|
|
61
69
|
}
|
|
62
|
-
$(() =>
|
|
63
|
-
typeof
|
|
64
|
-
}), $(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}),
|
|
70
|
+
$(() => t.modelValue, (e, f) => {
|
|
71
|
+
typeof e == "string" && (n.value = e);
|
|
72
|
+
}), $(n, (e, f) => {
|
|
73
|
+
l("update:modelValue"), x(() => {
|
|
74
|
+
s.$forceUpdate();
|
|
75
|
+
}), t.useSession && R(s.id, e, t.cacheLifetime);
|
|
68
76
|
});
|
|
69
|
-
const m =
|
|
70
|
-
let
|
|
71
|
-
return
|
|
72
|
-
}),
|
|
73
|
-
let
|
|
74
|
-
return
|
|
75
|
-
}), d =
|
|
76
|
-
let
|
|
77
|
-
for (let f in
|
|
78
|
-
|
|
79
|
-
return
|
|
80
|
-
}), j =
|
|
81
|
-
|
|
77
|
+
const m = c(() => {
|
|
78
|
+
let e = [];
|
|
79
|
+
return t.palette && e.push(`lkt-tabs--${t.palette}`), e.join(" ");
|
|
80
|
+
}), h = c(() => {
|
|
81
|
+
let e = [];
|
|
82
|
+
return t.contentPad && e.push(`padding: ${t.contentPad}`), e.join(";");
|
|
83
|
+
}), d = c(() => S(s.$slots, "tab-")), T = c(() => S(s.$slots, "title-")), M = c(() => S(s.$slots, "li-")), v = c(() => {
|
|
84
|
+
let e = {};
|
|
85
|
+
for (let f in s.$refs)
|
|
86
|
+
e[f] = s.$refs[f].hash;
|
|
87
|
+
return e;
|
|
88
|
+
}), j = c(() => Object.keys(d.value).length > 1), k = (e = "") => v.value.length > 0 && v.value[e] ? "#" + v.value[e] : "#", w = (e = "") => t.titles && t.titles[e] ? t.titles[e] : e, y = () => {
|
|
89
|
+
s.$forceUpdate();
|
|
82
90
|
};
|
|
83
|
-
for (let
|
|
84
|
-
|
|
85
|
-
return (
|
|
86
|
-
class:
|
|
91
|
+
for (let e in d.value)
|
|
92
|
+
n.value === "" && (n.value = e);
|
|
93
|
+
return (e, f) => (r(), i("div", {
|
|
94
|
+
class: L(["lkt-tabs", u(m)])
|
|
87
95
|
}, [
|
|
88
|
-
F(
|
|
89
|
-
(
|
|
90
|
-
key:
|
|
91
|
-
class:
|
|
96
|
+
F(V("ul", W, [
|
|
97
|
+
(r(!0), i(b, null, _(u(d), (C, o) => (r(), i("li", {
|
|
98
|
+
key: o,
|
|
99
|
+
class: L(["lkt-tab", { "is-active": o === n.value }]),
|
|
92
100
|
role: "presentation"
|
|
93
101
|
}, [
|
|
94
|
-
u(T)[
|
|
102
|
+
u(T)[o] ? (r(), i("a", {
|
|
95
103
|
key: 0,
|
|
96
|
-
href: k(
|
|
97
|
-
onClick:
|
|
104
|
+
href: k(o),
|
|
105
|
+
onClick: H((A) => n.value = o, ["prevent"]),
|
|
98
106
|
role: "tab"
|
|
99
107
|
}, [
|
|
100
|
-
|
|
101
|
-
], 8, X)) : (
|
|
108
|
+
p(e.$slots, "title-" + o)
|
|
109
|
+
], 8, X)) : (r(), i("a", {
|
|
102
110
|
key: 1,
|
|
103
|
-
innerHTML: w(
|
|
104
|
-
onClick:
|
|
105
|
-
href: k(
|
|
111
|
+
innerHTML: w(o),
|
|
112
|
+
onClick: H((A) => n.value = o, ["prevent"]),
|
|
113
|
+
href: k(o),
|
|
106
114
|
role: "tab"
|
|
107
115
|
}, null, 8, Z))
|
|
108
116
|
], 2))), 128)),
|
|
109
|
-
(
|
|
110
|
-
|
|
117
|
+
(r(!0), i(b, null, _(u(M), (C, o) => (r(), i("li", tt, [
|
|
118
|
+
p(e.$slots, "li-" + o)
|
|
111
119
|
]))), 256))
|
|
112
120
|
], 512), [
|
|
113
|
-
[
|
|
121
|
+
[O, u(j)]
|
|
114
122
|
]),
|
|
115
|
-
|
|
123
|
+
V("div", {
|
|
116
124
|
class: "lkt-tabs__content",
|
|
117
|
-
style:
|
|
125
|
+
style: z(u(h))
|
|
118
126
|
}, [
|
|
119
|
-
(
|
|
127
|
+
(r(!0), i(b, null, _(u(d), (C, o) => (r(), D(J, {
|
|
120
128
|
ref_for: !0,
|
|
121
|
-
ref:
|
|
122
|
-
hash:
|
|
123
|
-
id:
|
|
124
|
-
name: w(
|
|
125
|
-
"active-hash":
|
|
126
|
-
onIsActive:
|
|
129
|
+
ref: o,
|
|
130
|
+
hash: o,
|
|
131
|
+
id: o,
|
|
132
|
+
name: w(o),
|
|
133
|
+
"active-hash": n.value,
|
|
134
|
+
onIsActive: y
|
|
127
135
|
}, {
|
|
128
|
-
default:
|
|
129
|
-
|
|
136
|
+
default: E(() => [
|
|
137
|
+
p(e.$slots, "tab-" + o)
|
|
130
138
|
]),
|
|
131
139
|
_: 2
|
|
132
140
|
}, 1032, ["hash", "id", "name", "active-hash"]))), 256))
|
|
@@ -134,11 +142,11 @@ const B = (a) => `lkt-tabs.${window.location.host}${window.location.pathname}.${
|
|
|
134
142
|
], 2));
|
|
135
143
|
}
|
|
136
144
|
});
|
|
137
|
-
const
|
|
138
|
-
install: (a,
|
|
139
|
-
a.component("lkt-tabs",
|
|
145
|
+
const at = {
|
|
146
|
+
install: (a, l) => {
|
|
147
|
+
a.component("lkt-tabs", et);
|
|
140
148
|
}
|
|
141
149
|
};
|
|
142
150
|
export {
|
|
143
|
-
|
|
151
|
+
at as default
|
|
144
152
|
};
|
package/dist/lkt-tabs.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(t,
|
|
1
|
+
(function(t,i){typeof exports=="object"&&typeof module<"u"?module.exports=i(require("vue"),require("lkt-session")):typeof define=="function"&&define.amd?define(["vue","lkt-session"],i):(t=typeof globalThis<"u"?globalThis:t||self,t.LktTabs=i(t.Vue,t.LktSession))})(this,function(t,i){"use strict";function B(l=10){let a="";const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",o=e.length;for(let s=0;s<l;s++)a+=e.charAt(Math.floor(Math.random()*o));return a}function g(l){return typeof l=="string"}const $=["id"],T=t.defineComponent({__name:"LktTab",props:{id:{type:String,default:""},name:{type:String,required:!0},hash:{type:String,default:""},activeHash:{type:String,default:""},isDisabled:{type:Boolean,default:!1}},emits:["is-active"],setup(l,{emit:a}){const e=l,o=t.ref(!1),s=t.ref(B(8)),u=t.computed(()=>e.id?e.id:g(e.name)&&e.name.length>0?e.name.toLowerCase().replace(/ /g,"-"):s.value),f=()=>{o.value=e.activeHash===e.hash,a("is-active",o.value)};return t.watch(()=>e.activeHash,f),f(),(c,k)=>o.value?(t.openBlock(),t.createElementBlock("section",{key:0,"data-lkt":"tab-content",id:t.unref(u),role:"tabpanel"},[t.renderSlot(c.$slots,"default")],8,$)):t.createCommentVNode("",!0)}});function p(l,a){const e={};let o={};if(l&&(o=Object.assign(o,l)),a){for(const s in o)s.indexOf(a)===0&&(e[s.replace(a,"")]=o[s]);return e}for(const s in o)e[s]=o[s];return e}const m=l=>`lkt-tabs.${window.location.host}${window.location.pathname}.${l}`,L=l=>i.getSessionStorage(m(l)),w=(l,a,e)=>{i.setSessionStorage(m(l),a,e*60)},C={class:"lkt-tabs__list"},E=["href","onClick"],V=["innerHTML","onClick","href"],H={"data-lkt":"tab"},y=t.defineComponent({__name:"LktTabs",props:{modelValue:{default:""},id:{default:""},useSession:{type:Boolean,default:!1},cacheLifetime:{default:5},contentPad:{default:""},palette:{default:""},titles:{default:()=>({})}},emits:["update:modelValue"],setup(l,{emit:a}){const e=l,{ctx:o}=t.getCurrentInstance(),s=t.ref("");if(e.useSession){e.id||console.warn("[LKT Tabs] You're trying to use session provided tabs without the required id. Please, add id attr");let n=L(e.id);n&&(s.value=n)}t.watch(()=>e.modelValue,(n,d)=>{typeof n=="string"&&(s.value=n)}),t.watch(s,(n,d)=>{a("update:modelValue"),t.nextTick(()=>{o.$forceUpdate()}),e.useSession&&w(o.id,n,e.cacheLifetime)});const u=t.computed(()=>{let n=[];return e.palette&&n.push(`lkt-tabs--${e.palette}`),n.join(" ")}),f=t.computed(()=>{let n=[];return e.contentPad&&n.push(`padding: ${e.contentPad}`),n.join(";")}),c=t.computed(()=>p(o.$slots,"tab-")),k=t.computed(()=>p(o.$slots,"title-")),M=t.computed(()=>p(o.$slots,"li-")),h=t.computed(()=>{let n={};for(let d in o.$refs)n[d]=o.$refs[d].hash;return n}),j=t.computed(()=>Object.keys(c.value).length>1),b=(n="")=>h.value.length>0&&h.value[n]?"#"+h.value[n]:"#",_=(n="")=>e.titles&&e.titles[n]?e.titles[n]:n,q=()=>{o.$forceUpdate()};for(let n in c.value)s.value===""&&(s.value=n);return(n,d)=>(t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["lkt-tabs",t.unref(u)])},[t.withDirectives(t.createElementVNode("ul",C,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(c),(S,r)=>(t.openBlock(),t.createElementBlock("li",{key:r,class:t.normalizeClass(["lkt-tab",{"is-active":r===s.value}]),role:"presentation"},[t.unref(k)[r]?(t.openBlock(),t.createElementBlock("a",{key:0,href:b(r),onClick:t.withModifiers(F=>s.value=r,["prevent"]),role:"tab"},[t.renderSlot(n.$slots,"title-"+r)],8,E)):(t.openBlock(),t.createElementBlock("a",{key:1,innerHTML:_(r),onClick:t.withModifiers(F=>s.value=r,["prevent"]),href:b(r),role:"tab"},null,8,V))],2))),128)),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(M),(S,r)=>(t.openBlock(),t.createElementBlock("li",H,[t.renderSlot(n.$slots,"li-"+r)]))),256))],512),[[t.vShow,t.unref(j)]]),t.createElementVNode("div",{class:"lkt-tabs__content",style:t.normalizeStyle(t.unref(f))},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(c),(S,r)=>(t.openBlock(),t.createBlock(T,{ref_for:!0,ref:r,hash:r,id:r,name:_(r),"active-hash":s.value,onIsActive:q},{default:t.withCtx(()=>[t.renderSlot(n.$slots,"tab-"+r)]),_:2},1032,["hash","id","name","active-hash"]))),256))],4)],2))}}),I="";return{install:(l,a)=>{l.component("lkt-tabs",y)}}});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { nextTick } from 'vue';
|
|
2
|
+
import { LktObject } from "lkt-ts-interfaces";
|
|
1
3
|
declare const _default: {
|
|
2
4
|
new (...args: any[]): {
|
|
3
5
|
$: import("vue").ComponentInternalInstance;
|
|
@@ -9,37 +11,24 @@ declare const _default: {
|
|
|
9
11
|
cacheLifetime: number;
|
|
10
12
|
contentPad: string;
|
|
11
13
|
palette: string;
|
|
12
|
-
titles:
|
|
13
|
-
}> & Omit<Readonly<import("vue").ExtractPropTypes<{
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
contentPad: {
|
|
31
|
-
type: StringConstructor;
|
|
32
|
-
default: undefined;
|
|
33
|
-
};
|
|
34
|
-
palette: {
|
|
35
|
-
type: StringConstructor;
|
|
36
|
-
default: undefined;
|
|
37
|
-
};
|
|
38
|
-
titles: {
|
|
39
|
-
type: ObjectConstructor;
|
|
40
|
-
default(): {};
|
|
41
|
-
};
|
|
42
|
-
}>> & {
|
|
14
|
+
titles: LktObject;
|
|
15
|
+
}> & Omit<Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
16
|
+
modelValue: string | number;
|
|
17
|
+
id?: string | undefined;
|
|
18
|
+
useSession?: boolean | undefined;
|
|
19
|
+
cacheLifetime?: number | undefined;
|
|
20
|
+
contentPad?: string | undefined;
|
|
21
|
+
palette?: string | undefined;
|
|
22
|
+
titles?: LktObject | undefined;
|
|
23
|
+
}>, {
|
|
24
|
+
modelValue: string;
|
|
25
|
+
id: string;
|
|
26
|
+
useSession: boolean;
|
|
27
|
+
cacheLifetime: number;
|
|
28
|
+
contentPad: string;
|
|
29
|
+
palette: string;
|
|
30
|
+
titles: () => {};
|
|
31
|
+
}>>> & {
|
|
43
32
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
44
33
|
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "id" | "modelValue" | "useSession" | "cacheLifetime" | "contentPad" | "palette" | "titles">;
|
|
45
34
|
$attrs: {
|
|
@@ -55,36 +44,23 @@ declare const _default: {
|
|
|
55
44
|
$parent: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null;
|
|
56
45
|
$emit: (event: "update:modelValue", ...args: any[]) => void;
|
|
57
46
|
$el: any;
|
|
58
|
-
$options: import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
contentPad: {
|
|
76
|
-
type: StringConstructor;
|
|
77
|
-
default: undefined;
|
|
78
|
-
};
|
|
79
|
-
palette: {
|
|
80
|
-
type: StringConstructor;
|
|
81
|
-
default: undefined;
|
|
82
|
-
};
|
|
83
|
-
titles: {
|
|
84
|
-
type: ObjectConstructor;
|
|
85
|
-
default(): {};
|
|
86
|
-
};
|
|
87
|
-
}>> & {
|
|
47
|
+
$options: import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
48
|
+
modelValue: string | number;
|
|
49
|
+
id?: string | undefined;
|
|
50
|
+
useSession?: boolean | undefined;
|
|
51
|
+
cacheLifetime?: number | undefined;
|
|
52
|
+
contentPad?: string | undefined;
|
|
53
|
+
palette?: string | undefined;
|
|
54
|
+
titles?: LktObject | undefined;
|
|
55
|
+
}>, {
|
|
56
|
+
modelValue: string;
|
|
57
|
+
id: string;
|
|
58
|
+
useSession: boolean;
|
|
59
|
+
cacheLifetime: number;
|
|
60
|
+
contentPad: string;
|
|
61
|
+
palette: string;
|
|
62
|
+
titles: () => {};
|
|
63
|
+
}>>> & {
|
|
88
64
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
89
65
|
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:modelValue"[], string, {
|
|
90
66
|
id: string;
|
|
@@ -93,7 +69,7 @@ declare const _default: {
|
|
|
93
69
|
cacheLifetime: number;
|
|
94
70
|
contentPad: string;
|
|
95
71
|
palette: string;
|
|
96
|
-
titles:
|
|
72
|
+
titles: LktObject;
|
|
97
73
|
}> & {
|
|
98
74
|
beforeCreate?: ((() => void) | (() => void)[]) | undefined;
|
|
99
75
|
created?: ((() => void) | (() => void)[]) | undefined;
|
|
@@ -112,73 +88,47 @@ declare const _default: {
|
|
|
112
88
|
errorCaptured?: (((err: unknown, instance: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null, info: string) => boolean | void) | ((err: unknown, instance: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null, info: string) => boolean | void)[]) | undefined;
|
|
113
89
|
};
|
|
114
90
|
$forceUpdate: () => void;
|
|
115
|
-
$nextTick: typeof
|
|
91
|
+
$nextTick: typeof nextTick;
|
|
116
92
|
$watch(source: string | Function, cb: Function, options?: import("vue").WatchOptions<boolean> | undefined): import("vue").WatchStopHandle;
|
|
117
|
-
} & Readonly<import("vue").ExtractPropTypes<{
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
contentPad: {
|
|
135
|
-
type: StringConstructor;
|
|
136
|
-
default: undefined;
|
|
137
|
-
};
|
|
138
|
-
palette: {
|
|
139
|
-
type: StringConstructor;
|
|
140
|
-
default: undefined;
|
|
141
|
-
};
|
|
142
|
-
titles: {
|
|
143
|
-
type: ObjectConstructor;
|
|
144
|
-
default(): {};
|
|
145
|
-
};
|
|
146
|
-
}>> & {
|
|
93
|
+
} & Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
94
|
+
modelValue: string | number;
|
|
95
|
+
id?: string | undefined;
|
|
96
|
+
useSession?: boolean | undefined;
|
|
97
|
+
cacheLifetime?: number | undefined;
|
|
98
|
+
contentPad?: string | undefined;
|
|
99
|
+
palette?: string | undefined;
|
|
100
|
+
titles?: LktObject | undefined;
|
|
101
|
+
}>, {
|
|
102
|
+
modelValue: string;
|
|
103
|
+
id: string;
|
|
104
|
+
useSession: boolean;
|
|
105
|
+
cacheLifetime: number;
|
|
106
|
+
contentPad: string;
|
|
107
|
+
palette: string;
|
|
108
|
+
titles: () => {};
|
|
109
|
+
}>>> & {
|
|
147
110
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
148
111
|
} & import("vue").ShallowUnwrapRef<{}> & {} & import("vue").ComponentCustomProperties;
|
|
149
112
|
__isFragment?: undefined;
|
|
150
113
|
__isTeleport?: undefined;
|
|
151
114
|
__isSuspense?: undefined;
|
|
152
|
-
} & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
contentPad: {
|
|
170
|
-
type: StringConstructor;
|
|
171
|
-
default: undefined;
|
|
172
|
-
};
|
|
173
|
-
palette: {
|
|
174
|
-
type: StringConstructor;
|
|
175
|
-
default: undefined;
|
|
176
|
-
};
|
|
177
|
-
titles: {
|
|
178
|
-
type: ObjectConstructor;
|
|
179
|
-
default(): {};
|
|
180
|
-
};
|
|
181
|
-
}>> & {
|
|
115
|
+
} & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
116
|
+
modelValue: string | number;
|
|
117
|
+
id?: string | undefined;
|
|
118
|
+
useSession?: boolean | undefined;
|
|
119
|
+
cacheLifetime?: number | undefined;
|
|
120
|
+
contentPad?: string | undefined;
|
|
121
|
+
palette?: string | undefined;
|
|
122
|
+
titles?: LktObject | undefined;
|
|
123
|
+
}>, {
|
|
124
|
+
modelValue: string;
|
|
125
|
+
id: string;
|
|
126
|
+
useSession: boolean;
|
|
127
|
+
cacheLifetime: number;
|
|
128
|
+
contentPad: string;
|
|
129
|
+
palette: string;
|
|
130
|
+
titles: () => {};
|
|
131
|
+
}>>> & {
|
|
182
132
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
183
133
|
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", {
|
|
184
134
|
id: string;
|
|
@@ -187,8 +137,22 @@ declare const _default: {
|
|
|
187
137
|
cacheLifetime: number;
|
|
188
138
|
contentPad: string;
|
|
189
139
|
palette: string;
|
|
190
|
-
titles:
|
|
140
|
+
titles: LktObject;
|
|
191
141
|
}> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
|
|
192
142
|
$slots: Record<string, {}> & Record<string, {}> & Record<string, {}>;
|
|
193
143
|
});
|
|
194
144
|
export default _default;
|
|
145
|
+
declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
146
|
+
declare type __VLS_TypePropsToRuntimeProps<T> = {
|
|
147
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
148
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
149
|
+
} : {
|
|
150
|
+
type: import('vue').PropType<T[K]>;
|
|
151
|
+
required: true;
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
declare type __VLS_WithDefaults<P, D> = {
|
|
155
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? P[K] & {
|
|
156
|
+
default: D[K];
|
|
157
|
+
} : P[K];
|
|
158
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lkt-tabs",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"module": "src/index.ts",
|
|
@@ -38,7 +38,9 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"lkt-events": "^1.0.4",
|
|
40
40
|
"lkt-session": "^1.0.6",
|
|
41
|
-
"lkt-tools": "^1.0.
|
|
41
|
+
"lkt-string-tools": "^1.0.5",
|
|
42
|
+
"lkt-ts-interfaces": "^1.0.5",
|
|
43
|
+
"lkt-vue-tools": "^1.0.1",
|
|
42
44
|
"vue": "^3.0.5"
|
|
43
45
|
},
|
|
44
46
|
"engines": {
|
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
export default {
|
|
3
|
-
name: "LktTab",
|
|
4
|
-
inheritAttrs: false,
|
|
5
|
-
customOptions: {},
|
|
6
|
-
};
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
1
|
<script lang="ts" setup>
|
|
10
2
|
import {computed, ref, watch} from "vue";
|
|
11
|
-
import {generateRandomString, isString} from "lkt-tools";
|
|
3
|
+
import {generateRandomString, isString} from "lkt-string-tools";
|
|
12
4
|
|
|
13
5
|
const props = defineProps({
|
|
14
6
|
id: {type: String, default: ''},
|
|
@@ -1,34 +1,28 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import LktTab from "../components/LktTab.vue";
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
name: 'LktTabs',
|
|
6
|
-
inheritAttrs: false,
|
|
7
|
-
customOptions: {},
|
|
8
|
-
components: {LktTab}
|
|
9
|
-
};
|
|
10
|
-
</script>
|
|
11
|
-
|
|
12
1
|
<script lang="ts" setup>
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
2
|
+
import LktTab from "../components/LktTab.vue";
|
|
3
|
+
import {computed, getCurrentInstance, nextTick, ref, watch} from 'vue';
|
|
4
|
+
import {getSlots} from "lkt-vue-tools";
|
|
15
5
|
import {loadSelectedTabFromSession, setSelectedTabFromSession} from "../functions/functions";
|
|
6
|
+
import {LktObject} from "lkt-ts-interfaces";
|
|
16
7
|
|
|
17
8
|
const {ctx: _this}: any = getCurrentInstance();
|
|
18
9
|
|
|
19
|
-
const props = defineProps
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
useSession
|
|
23
|
-
cacheLifetime
|
|
24
|
-
contentPad
|
|
25
|
-
palette
|
|
26
|
-
titles
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
10
|
+
const props = withDefaults(defineProps<{
|
|
11
|
+
modelValue: string|number,
|
|
12
|
+
id?: string,
|
|
13
|
+
useSession?: boolean,
|
|
14
|
+
cacheLifetime?: number,
|
|
15
|
+
contentPad?: string,
|
|
16
|
+
palette?: string,
|
|
17
|
+
titles?: LktObject,
|
|
18
|
+
}>(), {
|
|
19
|
+
modelValue: '',
|
|
20
|
+
id: '',
|
|
21
|
+
useSession: false,
|
|
22
|
+
cacheLifetime: 5,
|
|
23
|
+
contentPad: '',
|
|
24
|
+
palette: '',
|
|
25
|
+
titles: () => ({}),
|
|
32
26
|
});
|
|
33
27
|
|
|
34
28
|
const emit = defineEmits(['update:modelValue'])
|
|
@@ -36,11 +30,11 @@ const emit = defineEmits(['update:modelValue'])
|
|
|
36
30
|
const Value = ref('');
|
|
37
31
|
|
|
38
32
|
if (props.useSession) {
|
|
39
|
-
if (!
|
|
33
|
+
if (!props.id) {
|
|
40
34
|
console.warn('[LKT Tabs] You\'re trying to use session provided tabs without the required id. Please, add id attr');
|
|
41
35
|
}
|
|
42
36
|
|
|
43
|
-
let sessionVal = loadSelectedTabFromSession(
|
|
37
|
+
let sessionVal = loadSelectedTabFromSession(props.id);
|
|
44
38
|
if (sessionVal) Value.value = sessionVal;
|
|
45
39
|
}
|
|
46
40
|
|
|
@@ -52,7 +46,7 @@ watch(() => props.modelValue, (newVal, oldVal) => {
|
|
|
52
46
|
|
|
53
47
|
watch(Value, (newVal, oldVal) => {
|
|
54
48
|
emit('update:modelValue');
|
|
55
|
-
|
|
49
|
+
nextTick(() => {
|
|
56
50
|
_this.$forceUpdate()
|
|
57
51
|
});
|
|
58
52
|
if (props.useSession) {
|
|
@@ -85,7 +79,7 @@ const liSlots = computed(() => {
|
|
|
85
79
|
});
|
|
86
80
|
|
|
87
81
|
const tabsHref = computed(() => {
|
|
88
|
-
let r:
|
|
82
|
+
let r: LktObject = {};
|
|
89
83
|
for (let k in _this.$refs) {
|
|
90
84
|
r[k] = _this.$refs[k].hash;
|
|
91
85
|
}
|
|
@@ -97,14 +91,14 @@ const displayButtons = computed(() => {
|
|
|
97
91
|
return Object.keys(tabsSlots.value).length > 1;
|
|
98
92
|
});
|
|
99
93
|
|
|
100
|
-
const getTabHref = (key: string = '') => {
|
|
94
|
+
const getTabHref = (key: string|number = '') => {
|
|
101
95
|
if (tabsHref.value.length > 0 && tabsHref.value[key]) {
|
|
102
96
|
return '#' + tabsHref.value[key];
|
|
103
97
|
}
|
|
104
98
|
return '#';
|
|
105
99
|
}
|
|
106
100
|
|
|
107
|
-
const getTabTitle = (key: string = '') => {
|
|
101
|
+
const getTabTitle = (key: string|number = '') => {
|
|
108
102
|
if (props.titles && props.titles[key]) return props.titles[key];
|
|
109
103
|
return key;
|
|
110
104
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|