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.
@@ -1,14 +1,17 @@
1
- import { defineComponent as H, ref as g, computed as i, watch as $, openBlock as l, createElementBlock as r, unref as u, renderSlot as h, createCommentVNode as P, getCurrentInstance as q, normalizeClass as C, withDirectives as F, createElementVNode as y, Fragment as _, renderList as b, withModifiers as V, vShow as M, normalizeStyle as x, createBlock as z, withCtx as D } from "vue";
2
- import { generateRandomString as E, isString as K, getSlots as S } from "lkt-tools";
3
- import { getSessionStorage as U, setSessionStorage as R } from "lkt-session";
4
- const B = (a) => `lkt-tabs.${window.location.host}${window.location.pathname}.${a}`, Y = (a) => U(B(a)), G = (a, c, e) => {
5
- R(B(a), c, e * 60);
6
- }, J = ["id"], Q = {
7
- name: "LktTab",
8
- inheritAttrs: !1,
9
- customOptions: {}
10
- }, A = /* @__PURE__ */ H({
11
- ...Q,
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: c }) {
21
- const e = a, n = g(!1), o = g(E(8)), m = i(() => e.id ? e.id : K(e.name) && e.name.length > 0 ? e.name.toLowerCase().replace(/ /g, "-") : o.value), p = () => {
22
- n.value = e.activeHash === e.hash, c("is-active", n.value);
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 $(() => e.activeHash, p), p(), (d, T) => n.value ? (l(), r("section", {
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
- h(d.$slots, "default")
31
- ], 8, J)) : P("", !0);
33
+ p(d.$slots, "default")
34
+ ], 8, G)) : P("", !0);
32
35
  }
33
- }), W = { class: "lkt-tabs__list" }, X = ["href", "onClick"], Z = ["innerHTML", "onClick", "href"], tt = { "data-lkt": "tab" }, et = {
34
- name: "LktTabs",
35
- inheritAttrs: !1,
36
- customOptions: {},
37
- components: { LktTab: A }
38
- }, st = /* @__PURE__ */ H({
39
- ...et,
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
- id: { type: String, default: "" },
42
- modelValue: { type: [String, Number], default: "" },
54
+ modelValue: { default: "" },
55
+ id: { default: "" },
43
56
  useSession: { type: Boolean, default: !1 },
44
- cacheLifetime: { type: Number, default: 5 },
45
- contentPad: { type: String, default: void 0 },
46
- palette: { type: String, default: void 0 },
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: c }) {
56
- const e = a, { ctx: n } = q(), o = g("");
57
- if (e.useSession) {
58
- n.id || console.warn("[LKT Tabs] You're trying to use session provided tabs without the required id. Please, add id attr");
59
- let t = Y(n.id);
60
- t && (o.value = t);
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
- $(() => e.modelValue, (t, f) => {
63
- typeof t == "string" && (o.value = t);
64
- }), $(o, (t, f) => {
65
- c("update:modelValue"), n.$nextTick(() => {
66
- n.$forceUpdate();
67
- }), e.useSession && G(n.id, t, e.cacheLifetime);
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 = i(() => {
70
- let t = [];
71
- return e.palette && t.push(`lkt-tabs--${e.palette}`), t.join(" ");
72
- }), p = i(() => {
73
- let t = [];
74
- return e.contentPad && t.push(`padding: ${e.contentPad}`), t.join(";");
75
- }), d = i(() => S(n.$slots, "tab-")), T = i(() => S(n.$slots, "title-")), I = i(() => S(n.$slots, "li-")), v = i(() => {
76
- let t = {};
77
- for (let f in n.$refs)
78
- t[f] = n.$refs[f].hash;
79
- return t;
80
- }), j = i(() => Object.keys(d.value).length > 1), k = (t = "") => v.value.length > 0 && v.value[t] ? "#" + v.value[t] : "#", w = (t = "") => e.titles && e.titles[t] ? e.titles[t] : t, N = () => {
81
- n.$forceUpdate();
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 t in d.value)
84
- o.value === "" && (o.value = t);
85
- return (t, f) => (l(), r("div", {
86
- class: C(["lkt-tabs", u(m)])
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(y("ul", W, [
89
- (l(!0), r(_, null, b(u(d), (L, s) => (l(), r("li", {
90
- key: s,
91
- class: C(["lkt-tab", { "is-active": s === o.value }]),
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)[s] ? (l(), r("a", {
102
+ u(T)[o] ? (r(), i("a", {
95
103
  key: 0,
96
- href: k(s),
97
- onClick: V((O) => o.value = s, ["prevent"]),
104
+ href: k(o),
105
+ onClick: H((A) => n.value = o, ["prevent"]),
98
106
  role: "tab"
99
107
  }, [
100
- h(t.$slots, "title-" + s)
101
- ], 8, X)) : (l(), r("a", {
108
+ p(e.$slots, "title-" + o)
109
+ ], 8, X)) : (r(), i("a", {
102
110
  key: 1,
103
- innerHTML: w(s),
104
- onClick: V((O) => o.value = s, ["prevent"]),
105
- href: k(s),
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
- (l(!0), r(_, null, b(u(I), (L, s) => (l(), r("li", tt, [
110
- h(t.$slots, "li-" + s)
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
- [M, u(j)]
121
+ [O, u(j)]
114
122
  ]),
115
- y("div", {
123
+ V("div", {
116
124
  class: "lkt-tabs__content",
117
- style: x(u(p))
125
+ style: z(u(h))
118
126
  }, [
119
- (l(!0), r(_, null, b(u(d), (L, s) => (l(), z(A, {
127
+ (r(!0), i(b, null, _(u(d), (C, o) => (r(), D(J, {
120
128
  ref_for: !0,
121
- ref: s,
122
- hash: s,
123
- id: s,
124
- name: w(s),
125
- "active-hash": o.value,
126
- onIsActive: N
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: D(() => [
129
- h(t.$slots, "tab-" + s)
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 lt = {
138
- install: (a, c) => {
139
- a.component("lkt-tabs", st);
145
+ const at = {
146
+ install: (a, l) => {
147
+ a.component("lkt-tabs", et);
140
148
  }
141
149
  };
142
150
  export {
143
- lt as default
151
+ at as default
144
152
  };
@@ -1 +1 @@
1
- (function(t,a){typeof exports=="object"&&typeof module<"u"?module.exports=a(require("vue"),require("lkt-tools"),require("lkt-session")):typeof define=="function"&&define.amd?define(["vue","lkt-tools","lkt-session"],a):(t=typeof globalThis<"u"?globalThis:t||self,t.LktTabs=a(t.Vue,t.LktTools,t.LktSession))})(this,function(t,a,u){"use strict";const h=r=>`lkt-tabs.${window.location.host}${window.location.pathname}.${r}`,B=r=>u.getSessionStorage(h(r)),$=(r,i,n)=>{u.setSessionStorage(h(r),i,n*60)},L=["id"],T={name:"LktTab",inheritAttrs:!1,customOptions:{}},S=t.defineComponent({...T,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(r,{emit:i}){const n=r,o=t.ref(!1),l=t.ref(a.generateRandomString(8)),p=t.computed(()=>n.id?n.id:a.isString(n.name)&&n.name.length>0?n.name.toLowerCase().replace(/ /g,"-"):l.value),f=()=>{o.value=n.activeHash===n.hash,i("is-active",o.value)};return t.watch(()=>n.activeHash,f),f(),(c,k)=>o.value?(t.openBlock(),t.createElementBlock("section",{key:0,"data-lkt":"tab-content",id:t.unref(p),role:"tabpanel"},[t.renderSlot(c.$slots,"default")],8,L)):t.createCommentVNode("",!0)}}),w={class:"lkt-tabs__list"},C=["href","onClick"],y=["innerHTML","onClick","href"],E={"data-lkt":"tab"},V={name:"LktTabs",inheritAttrs:!1,customOptions:{},components:{LktTab:S}},H=t.defineComponent({...V,props:{id:{type:String,default:""},modelValue:{type:[String,Number],default:""},useSession:{type:Boolean,default:!1},cacheLifetime:{type:Number,default:5},contentPad:{type:String,default:void 0},palette:{type:String,default:void 0},titles:{type:Object,default(){return{}}}},emits:["update:modelValue"],setup(r,{emit:i}){const n=r,{ctx:o}=t.getCurrentInstance(),l=t.ref("");if(n.useSession){o.id||console.warn("[LKT Tabs] You're trying to use session provided tabs without the required id. Please, add id attr");let e=B(o.id);e&&(l.value=e)}t.watch(()=>n.modelValue,(e,d)=>{typeof e=="string"&&(l.value=e)}),t.watch(l,(e,d)=>{i("update:modelValue"),o.$nextTick(()=>{o.$forceUpdate()}),n.useSession&&$(o.id,e,n.cacheLifetime)});const p=t.computed(()=>{let e=[];return n.palette&&e.push(`lkt-tabs--${n.palette}`),e.join(" ")}),f=t.computed(()=>{let e=[];return n.contentPad&&e.push(`padding: ${n.contentPad}`),e.join(";")}),c=t.computed(()=>a.getSlots(o.$slots,"tab-")),k=t.computed(()=>a.getSlots(o.$slots,"title-")),q=t.computed(()=>a.getSlots(o.$slots,"li-")),m=t.computed(()=>{let e={};for(let d in o.$refs)e[d]=o.$refs[d].hash;return e}),j=t.computed(()=>Object.keys(c.value).length>1),_=(e="")=>m.value.length>0&&m.value[e]?"#"+m.value[e]:"#",b=(e="")=>n.titles&&n.titles[e]?n.titles[e]:e,A=()=>{o.$forceUpdate()};for(let e in c.value)l.value===""&&(l.value=e);return(e,d)=>(t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["lkt-tabs",t.unref(p)])},[t.withDirectives(t.createElementVNode("ul",w,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(c),(g,s)=>(t.openBlock(),t.createElementBlock("li",{key:s,class:t.normalizeClass(["lkt-tab",{"is-active":s===l.value}]),role:"presentation"},[t.unref(k)[s]?(t.openBlock(),t.createElementBlock("a",{key:0,href:_(s),onClick:t.withModifiers(F=>l.value=s,["prevent"]),role:"tab"},[t.renderSlot(e.$slots,"title-"+s)],8,C)):(t.openBlock(),t.createElementBlock("a",{key:1,innerHTML:b(s),onClick:t.withModifiers(F=>l.value=s,["prevent"]),href:_(s),role:"tab"},null,8,y))],2))),128)),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(q),(g,s)=>(t.openBlock(),t.createElementBlock("li",E,[t.renderSlot(e.$slots,"li-"+s)]))),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),(g,s)=>(t.openBlock(),t.createBlock(S,{ref_for:!0,ref:s,hash:s,id:s,name:b(s),"active-hash":l.value,onIsActive:A},{default:t.withCtx(()=>[t.renderSlot(e.$slots,"tab-"+s)]),_:2},1032,["hash","id","name","active-hash"]))),256))],4)],2))}}),I="";return{install:(r,i)=>{r.component("lkt-tabs",H)}}});
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: Record<string, any>;
13
- }> & Omit<Readonly<import("vue").ExtractPropTypes<{
14
- id: {
15
- type: StringConstructor;
16
- default: string;
17
- };
18
- modelValue: {
19
- type: (StringConstructor | NumberConstructor)[];
20
- default: string;
21
- };
22
- useSession: {
23
- type: BooleanConstructor;
24
- default: boolean;
25
- };
26
- cacheLifetime: {
27
- type: NumberConstructor;
28
- default: number;
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
- id: {
60
- type: StringConstructor;
61
- default: string;
62
- };
63
- modelValue: {
64
- type: (StringConstructor | NumberConstructor)[];
65
- default: string;
66
- };
67
- useSession: {
68
- type: BooleanConstructor;
69
- default: boolean;
70
- };
71
- cacheLifetime: {
72
- type: NumberConstructor;
73
- default: number;
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: Record<string, any>;
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 import("vue").nextTick;
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
- id: {
119
- type: StringConstructor;
120
- default: string;
121
- };
122
- modelValue: {
123
- type: (StringConstructor | NumberConstructor)[];
124
- default: string;
125
- };
126
- useSession: {
127
- type: BooleanConstructor;
128
- default: boolean;
129
- };
130
- cacheLifetime: {
131
- type: NumberConstructor;
132
- default: number;
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
- id: {
154
- type: StringConstructor;
155
- default: string;
156
- };
157
- modelValue: {
158
- type: (StringConstructor | NumberConstructor)[];
159
- default: string;
160
- };
161
- useSession: {
162
- type: BooleanConstructor;
163
- default: boolean;
164
- };
165
- cacheLifetime: {
166
- type: NumberConstructor;
167
- default: number;
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: Record<string, any>;
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.7",
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.10",
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 {computed, getCurrentInstance, ref, watch} from 'vue';
14
- import {getSlots, ILktObject} from "lkt-tools";
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
- id: {type: String, default: ''},
21
- modelValue: {type: [String, Number], default: ''},
22
- useSession: {type: Boolean, default: false},
23
- cacheLifetime: {type: Number, default: 5,},
24
- contentPad: {type: String, default: undefined,},
25
- palette: {type: String, default: undefined,},
26
- titles: {
27
- type: Object,
28
- default() {
29
- return {};
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 (!_this.id) {
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(_this.id);
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
- _this.$nextTick(() => {
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: ILktObject = {};
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