lkt-tabs 1.0.8 → 1.2.0

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,16 +1,19 @@
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;
1
+ var B = Object.defineProperty;
2
+ var H = (e, r, a) => r in e ? B(e, r, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[r] = a;
3
+ var i = (e, r, a) => H(e, typeof r != "symbol" ? r + "" : r, a);
4
+ import { defineComponent as _, ref as y, computed as m, watch as L, createElementBlock as h, createCommentVNode as O, openBlock as d, renderSlot as v, mergeDefaults as R, getCurrentInstance as z, useSlots as U, nextTick as F, normalizeClass as T, withDirectives as j, createElementVNode as D, Fragment as k, renderList as w, withModifiers as I, vShow as q, normalizeStyle as K, createBlock as Y, withCtx as G } from "vue";
5
+ import { getSessionStorage as J, setSessionStorage as Q } from "lkt-session";
6
+ function W(e = 10) {
7
+ let r = "";
8
+ const a = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", o = a.length;
9
+ for (let n = 0; n < e; n++)
10
+ r += a.charAt(Math.floor(Math.random() * o));
11
+ return r;
9
12
  }
10
- function Y(a) {
11
- return typeof a == "string";
13
+ function X(e) {
14
+ return typeof e == "string";
12
15
  }
13
- const G = ["id"], J = /* @__PURE__ */ B({
16
+ const Z = ["id"], ee = /* @__PURE__ */ _({
14
17
  __name: "LktTab",
15
18
  props: {
16
19
  id: { type: String, default: "" },
@@ -20,133 +23,163 @@ const G = ["id"], J = /* @__PURE__ */ B({
20
23
  isDisabled: { type: Boolean, default: !1 }
21
24
  },
22
25
  emits: ["is-active"],
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);
26
+ setup(e, { emit: r }) {
27
+ const a = e, o = r, n = y(!1), b = y(W(8)), u = m(() => a.id ? a.id : X(a.name) && a.name.length > 0 ? a.name.toLowerCase().replace(/ /g, "-") : b.value), p = () => {
28
+ n.value = a.activeHash === a.hash, o("is-active", n.value);
26
29
  };
27
- return $(() => t.activeHash, h), h(), (d, T) => s.value ? (r(), i("section", {
30
+ return L(() => a.activeHash, p), p(), (g, f) => n.value ? (d(), h("section", {
28
31
  key: 0,
29
32
  "data-lkt": "tab-content",
30
- id: u(m),
33
+ id: u.value,
31
34
  role: "tabpanel"
32
35
  }, [
33
- p(d.$slots, "default")
34
- ], 8, G)) : P("", !0);
36
+ v(g.$slots, "default")
37
+ ], 8, Z)) : O("", !0);
35
38
  }
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;
39
+ }), A = (e) => `lkt-tabs.${window.location.host}${window.location.pathname}.${e}`, te = (e) => J(A(e)), re = (e, r, a) => {
40
+ Q(A(e), r, a * 60);
41
+ };
42
+ var ae = ((e) => (e.Button = "button", e.Submit = "submit", e.Reset = "reset", e.Anchor = "anchor", e.Content = "content", e.Switch = "switch", e.HiddenSwitch = "hidden-switch", e.Split = "split", e.SplitLazy = "split-lazy", e.SplitEver = "split-ever", e.Tooltip = "tooltip", e.TooltipLazy = "tooltip-lazy", e.TooltipEver = "tooltip-ever", e))(ae || {}), ne = ((e) => (e.Text = "text", e.Email = "email", e.Tel = "tel", e.Password = "password", e.Search = "search", e.Number = "number", e.Color = "color", e.Range = "range", e.Textarea = "textarea", e.Html = "html", e.Date = "date", e.File = "file", e.Image = "image", e.Select = "select", e.Check = "check", e.Switch = "switch", e.Calc = "calc", e.Card = "card", e.Elements = "elements", e))(ne || {}), se = ["lktDateProps", "lktStrictItem", "lktExcludedProps"], c, le = (c = class {
43
+ constructor(r) {
44
+ }
45
+ feed(r = {}, a = this) {
46
+ if (typeof r == "object") for (let [o, n] of Object.entries(r)) a.assignProp(o, n);
47
+ }
48
+ assignProp(r, a) {
49
+ if (!(se.includes(r) || c.lktExcludedProps.includes(r))) {
50
+ if (c.lktDateProps.includes(r)) {
51
+ this[r] = new Date(a);
52
+ return;
53
+ }
54
+ this[r] = a;
55
+ }
44
56
  }
45
- for (const n in s)
46
- t[n] = s[n];
47
- return t;
57
+ }, i(c, "lktAllowUndefinedProps", []), i(c, "lktExcludedProps", []), i(c, "lktDateProps", []), i(c, "lktStrictItem", !1), i(c, "lktDefaultValues", []), c), oe = ((e) => (e.Auto = "auto", e.Always = "always", e.Lazy = "lazy", e.Ever = "ever", e))(oe || {}), ie = ((e) => (e.Transform = "transform", e.Height = "height", e.Display = "display", e))(ie || {}), ce = ((e) => (e.Href = "href", e.RouterLink = "router-link", e.RouterLinkBack = "router-link-back", e.Mail = "mail", e.Tel = "tel", e.Tab = "tab", e.Download = "download", e.Action = "action", e.Legacy = "", e))(ce || {}), ue = ((e) => (e.None = "", e.Field = "field", e.Button = "button", e.Anchor = "anchor", e))(ue || {}), de = ((e) => (e.List = "list", e.Inline = "inline", e.Count = "count", e))(de || {}), he = ((e) => (e.None = "", e.Focus = "focus", e.Blur = "blur", e.Always = "always", e))(he || {}), me = ((e) => (e.MinStringLength = "min-str", e.MinNumber = "min-num", e.MaxStringLength = "max-str", e.MaxNumber = "max-num", e.Email = "email", e.Empty = "empty", e.EqualTo = "equal-to", e.MinNumbers = "min-numbers", e.MaxNumbers = "max-numbers", e.MinChars = "min-chars", e.MaxChars = "max-chars", e.MinUpperChars = "min-upper-chars", e.MaxUpperChars = "max-upper-chars", e.MinLowerChars = "min-lower-chars", e.MaxLowerChars = "max-lower-chars", e.MinSpecialChars = "min-special-chars", e.MaxSpecialChars = "max-special-chars", e))(me || {}), fe = ((e) => (e.Ok = "ok", e.Ko = "ko", e.Info = "info", e))(fe || {}), pe = ((e) => (e.NotDefined = "", e.Button = "button", e))(pe || {}), ve = ((e) => (e.Create = "create", e.Update = "update", e.Read = "read", e))(ve || {}), be = ((e) => (e.Inline = "inline", e.Modal = "modal", e))(be || {}), ge = ((e) => (e.Top = "top", e.Bottom = "bottom", e))(ge || {}), Se = ((e) => (e.Changed = "changed", e.Always = "always", e.Never = "never", e))(Se || {}), Ce = ((e) => (e.Manual = "manual", e.Auto = "auto", e.Delay = "delay", e))(Ce || {}), ke = ((e) => (e.Toast = "toast", e.Inline = "inline", e))(ke || {}), we = ((e) => (e.Pages = "pages", e.PrevNext = "prev-next", e.PagesPrevNext = "pages-prev-next", e.PagesPrevNextFirstLast = "pages-prev-next-first-last", e.LoadMore = "load-more", e.Infinite = "infinite", e))(we || {}), xe = ((e) => (e.None = "", e.Incremental = "incremental", e.Decremental = "decremental", e))(xe || {}), ye = ((e) => (e.NotDefined = "", e.Hidden = "hidden", e.Integer = "integer", e.Decimal = "decimal", e.Auto = "auto", e))(ye || {}), Le = ((e) => (e.Table = "table", e.Item = "item", e.Ul = "ul", e.Ol = "ol", e))(Le || {}), Pe = ((e) => (e[e.Auto = 0] = "Auto", e[e.PreferItem = 1] = "PreferItem", e[e.PreferCustomItem = 2] = "PreferCustomItem", e[e.PreferColumns = 3] = "PreferColumns", e))(Pe || {}), x, Me = (x = class extends le {
58
+ constructor(r = {}) {
59
+ super();
60
+ i(this, "modelValue", "");
61
+ i(this, "id", "");
62
+ i(this, "useSession", !1);
63
+ i(this, "cacheLifetime", 5);
64
+ i(this, "contentPad");
65
+ i(this, "titles");
66
+ this.feed(r);
67
+ }
68
+ }, i(x, "lktDefaultValues", ["modelValue", "id", "useSession", "cacheLifetime", "contentPad", "titles"]), x), Te = ((e) => (e.NotDefined = "", e.ActionIcon = "action-icon", e))(Te || {}), De = ((e) => (e.Message = "message", e.Button = "button", e))(De || {}), Ie = ((e) => (e.Left = "left", e.Center = "center", e.Right = "right", e))(Ie || {}), _e = ((e) => (e.Fixed = "fixed", e.Absolute = "absolute", e))(_e || {}), Ae = ((e) => (e.Top = "top", e.Bottom = "bottom", e.Center = "center", e.ReferrerCenter = "referrer-center", e))(Ae || {}), Ee = ((e) => (e.Left = "left", e.Right = "right", e.Center = "center", e.LeftCorner = "left-corner", e.RightCorner = "right-corner", e))(Ee || {}), Ne = ((e) => (e.Refresh = "refresh", e.Close = "close", e.ReOpen = "reOpen", e.Exec = "exec", e.Open = "open", e))(Ne || {}), $e = ((e) => (e.Modal = "modal", e.Confirm = "confirm", e))($e || {}), Ve = ((e) => (e.Asc = "asc", e.Desc = "desc", e))(Ve || {}), Be = ((e) => (e.Create = "create", e.Update = "update", e.Edit = "edit", e.Drop = "drop", e.Sort = "sort", e.SwitchEditMode = "switch-edit-mode", e.InlineEdit = "inline-edit", e.InlineCreate = "inline-create", e.ModalCreate = "modal-create", e.InlineCreateEver = "inline-create-ever", e))(Be || {}), He = ((e) => (e.Lazy = "lazy", e.Ever = "ever", e))(He || {});
69
+ function Oe(e) {
70
+ let r = new e(), a = {};
71
+ if (!Array.isArray(e.lktDefaultValues)) throw new Error("lktDefaultValues must be a keys array.");
72
+ for (let o of e.lktDefaultValues) o in r && (a[o] = r[o]);
73
+ return a;
48
74
  }
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({
75
+ const Re = { class: "lkt-tabs__list" }, ze = ["href", "onClick"], Ue = ["innerHTML", "onClick", "href"], Fe = { "data-lkt": "tab" }, je = /* @__PURE__ */ _({
52
76
  __name: "LktTabs",
53
- props: {
54
- modelValue: { default: "" },
55
- id: { default: "" },
56
- useSession: { type: Boolean, default: !1 },
57
- cacheLifetime: { default: 5 },
58
- contentPad: { default: "" },
59
- palette: { default: "" },
60
- titles: { default: () => ({}) }
61
- },
62
- emits: ["update:modelValue"],
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);
77
+ props: /* @__PURE__ */ R({
78
+ modelValue: {},
79
+ id: {},
80
+ useSession: { type: Boolean },
81
+ cacheLifetime: {},
82
+ contentPad: {},
83
+ titles: {}
84
+ }, Oe(Me)),
85
+ emits: [
86
+ "update:modelValue"
87
+ ],
88
+ setup(e, { emit: r }) {
89
+ const { ctx: a } = z(), o = U(), n = e, b = r, u = y("");
90
+ if (n.useSession) {
91
+ n.id || console.warn("[LKT Tabs] You're trying to use session provided tabs without the required id. Please, add id attr");
92
+ let t = te(n.id);
93
+ t && (u.value = t);
69
94
  }
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);
95
+ L(() => n.modelValue, (t, l) => {
96
+ typeof t == "string" && (u.value = t);
97
+ }), L(u, (t, l) => {
98
+ b("update:modelValue"), F(() => {
99
+ a.$forceUpdate();
100
+ }), n.useSession && re(a.id, t, n.cacheLifetime);
76
101
  });
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();
102
+ const p = m(() => [].join(" ")), g = m(() => {
103
+ let t = [];
104
+ return n.contentPad && t.push(`padding: ${n.contentPad}`), t.join(";");
105
+ }), f = m(() => {
106
+ let t = [];
107
+ for (let l in o) l.indexOf("tab-") !== -1 && t.push(l);
108
+ return t;
109
+ }), E = m(() => {
110
+ let t = [];
111
+ for (let l in o) l.indexOf("title-") !== -1 && t.push(l);
112
+ return t;
113
+ }), N = m(() => {
114
+ let t = [];
115
+ for (let l in o) l.indexOf("li-") !== -1 && t.push(l);
116
+ return t;
117
+ }), S = m(() => {
118
+ let t = {};
119
+ for (let l in a.$refs)
120
+ t[l] = a.$refs[l].hash;
121
+ return t;
122
+ }), $ = m(() => Object.keys(f.value).length > 1), P = (t = "") => S.value.length > 0 && S.value[t] ? "#" + S.value[t] : "#", M = (t = "") => n.titles && n.titles[t] ? n.titles[t] : t, V = () => {
123
+ a.$forceUpdate();
90
124
  };
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)])
125
+ for (let t in f.value)
126
+ u.value === "" && (u.value = t);
127
+ return (t, l) => (d(), h("div", {
128
+ class: T(["lkt-tabs", p.value])
95
129
  }, [
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 }]),
130
+ j(D("ul", Re, [
131
+ (d(!0), h(k, null, w(f.value, (s) => (d(), h("li", {
132
+ key: s,
133
+ class: T(["lkt-tab", { "is-active": s === u.value }]),
100
134
  role: "presentation"
101
135
  }, [
102
- u(T)[o] ? (r(), i("a", {
136
+ E.value.includes(s) ? (d(), h("a", {
103
137
  key: 0,
104
- href: k(o),
105
- onClick: H((A) => n.value = o, ["prevent"]),
138
+ href: P(s),
139
+ onClick: I((C) => u.value = s, ["prevent"]),
106
140
  role: "tab"
107
141
  }, [
108
- p(e.$slots, "title-" + o)
109
- ], 8, X)) : (r(), i("a", {
142
+ v(t.$slots, "title-" + s)
143
+ ], 8, ze)) : (d(), h("a", {
110
144
  key: 1,
111
- innerHTML: w(o),
112
- onClick: H((A) => n.value = o, ["prevent"]),
113
- href: k(o),
145
+ innerHTML: M(s),
146
+ onClick: I((C) => u.value = s, ["prevent"]),
147
+ href: P(s),
114
148
  role: "tab"
115
- }, null, 8, Z))
149
+ }, null, 8, Ue))
116
150
  ], 2))), 128)),
117
- (r(!0), i(b, null, _(u(M), (C, o) => (r(), i("li", tt, [
118
- p(e.$slots, "li-" + o)
151
+ (d(!0), h(k, null, w(N.value, (s, C) => (d(), h("li", Fe, [
152
+ v(t.$slots, "li-" + C)
119
153
  ]))), 256))
120
154
  ], 512), [
121
- [O, u(j)]
155
+ [q, $.value]
122
156
  ]),
123
- V("div", {
157
+ D("div", {
124
158
  class: "lkt-tabs__content",
125
- style: z(u(h))
159
+ style: K(g.value)
126
160
  }, [
127
- (r(!0), i(b, null, _(u(d), (C, o) => (r(), D(J, {
161
+ (d(!0), h(k, null, w(f.value, (s) => (d(), Y(ee, {
128
162
  ref_for: !0,
129
- ref: o,
130
- hash: o,
131
- id: o,
132
- name: w(o),
133
- "active-hash": n.value,
134
- onIsActive: y
163
+ ref: s,
164
+ hash: s,
165
+ id: s,
166
+ name: M(s),
167
+ "active-hash": u.value,
168
+ onIsActive: V
135
169
  }, {
136
- default: E(() => [
137
- p(e.$slots, "tab-" + o)
170
+ default: G(() => [
171
+ v(t.$slots, "tab-" + s)
138
172
  ]),
139
173
  _: 2
140
174
  }, 1032, ["hash", "id", "name", "active-hash"]))), 256))
141
175
  ], 4)
142
176
  ], 2));
143
177
  }
144
- });
145
- const at = {
146
- install: (a, l) => {
147
- a.component("lkt-tabs", et);
178
+ }), Ge = {
179
+ install: (e, r) => {
180
+ e.component("lkt-tabs", je);
148
181
  }
149
182
  };
150
183
  export {
151
- at as default
184
+ Ge as default
152
185
  };
@@ -1 +1 @@
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
+ (function(t,s){typeof exports=="object"&&typeof module<"u"?module.exports=s(require("vue"),require("lkt-session")):typeof define=="function"&&define.amd?define(["vue","lkt-session"],s):(t=typeof globalThis<"u"?globalThis:t||self,t.LktTabs=s(t.Vue,t.LktSession))})(this,function(t,s){"use strict";var we=Object.defineProperty;var ve=(t,s,p)=>s in t?we(t,s,{enumerable:!0,configurable:!0,writable:!0,value:p}):t[s]=p;var d=(t,s,p)=>ve(t,typeof s!="symbol"?s+"":s,p);var u,k;function p(e=10){let n="";const a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",c=a.length;for(let o=0;o<e;o++)n+=a.charAt(Math.floor(Math.random()*c));return n}function L(e){return typeof e=="string"}const y=["id"],B=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(e,{emit:n}){const a=e,c=n,o=t.ref(!1),b=t.ref(p(8)),m=t.computed(()=>a.id?a.id:L(a.name)&&a.name.length>0?a.name.toLowerCase().replace(/ /g,"-"):b.value),h=()=>{o.value=a.activeHash===a.hash,c("is-active",o.value)};return t.watch(()=>a.activeHash,h),h(),(g,f)=>o.value?(t.openBlock(),t.createElementBlock("section",{key:0,"data-lkt":"tab-content",id:m.value,role:"tabpanel"},[t.renderSlot(g.$slots,"default")],8,y)):t.createCommentVNode("",!0)}}),w=e=>`lkt-tabs.${window.location.host}${window.location.pathname}.${e}`,T=e=>s.getSessionStorage(w(e)),E=(e,n,a)=>{s.setSessionStorage(w(e),n,a*60)};var M=(e=>(e.Button="button",e.Submit="submit",e.Reset="reset",e.Anchor="anchor",e.Content="content",e.Switch="switch",e.HiddenSwitch="hidden-switch",e.Split="split",e.SplitLazy="split-lazy",e.SplitEver="split-ever",e.Tooltip="tooltip",e.TooltipLazy="tooltip-lazy",e.TooltipEver="tooltip-ever",e))(M||{}),P=(e=>(e.Text="text",e.Email="email",e.Tel="tel",e.Password="password",e.Search="search",e.Number="number",e.Color="color",e.Range="range",e.Textarea="textarea",e.Html="html",e.Date="date",e.File="file",e.Image="image",e.Select="select",e.Check="check",e.Switch="switch",e.Calc="calc",e.Card="card",e.Elements="elements",e))(P||{}),D=["lktDateProps","lktStrictItem","lktExcludedProps"],I=(u=class{constructor(n){}feed(n={},a=this){if(typeof n=="object")for(let[c,o]of Object.entries(n))a.assignProp(c,o)}assignProp(n,a){if(!(D.includes(n)||u.lktExcludedProps.includes(n))){if(u.lktDateProps.includes(n)){this[n]=new Date(a);return}this[n]=a}}},d(u,"lktAllowUndefinedProps",[]),d(u,"lktExcludedProps",[]),d(u,"lktDateProps",[]),d(u,"lktStrictItem",!1),d(u,"lktDefaultValues",[]),u),_=(e=>(e.Auto="auto",e.Always="always",e.Lazy="lazy",e.Ever="ever",e))(_||{}),A=(e=>(e.Transform="transform",e.Height="height",e.Display="display",e))(A||{}),N=(e=>(e.Href="href",e.RouterLink="router-link",e.RouterLinkBack="router-link-back",e.Mail="mail",e.Tel="tel",e.Tab="tab",e.Download="download",e.Action="action",e.Legacy="",e))(N||{}),V=(e=>(e.None="",e.Field="field",e.Button="button",e.Anchor="anchor",e))(V||{}),$=(e=>(e.List="list",e.Inline="inline",e.Count="count",e))($||{}),H=(e=>(e.None="",e.Focus="focus",e.Blur="blur",e.Always="always",e))(H||{}),z=(e=>(e.MinStringLength="min-str",e.MinNumber="min-num",e.MaxStringLength="max-str",e.MaxNumber="max-num",e.Email="email",e.Empty="empty",e.EqualTo="equal-to",e.MinNumbers="min-numbers",e.MaxNumbers="max-numbers",e.MinChars="min-chars",e.MaxChars="max-chars",e.MinUpperChars="min-upper-chars",e.MaxUpperChars="max-upper-chars",e.MinLowerChars="min-lower-chars",e.MaxLowerChars="max-lower-chars",e.MinSpecialChars="min-special-chars",e.MaxSpecialChars="max-special-chars",e))(z||{}),O=(e=>(e.Ok="ok",e.Ko="ko",e.Info="info",e))(O||{}),R=(e=>(e.NotDefined="",e.Button="button",e))(R||{}),F=(e=>(e.Create="create",e.Update="update",e.Read="read",e))(F||{}),U=(e=>(e.Inline="inline",e.Modal="modal",e))(U||{}),q=(e=>(e.Top="top",e.Bottom="bottom",e))(q||{}),j=(e=>(e.Changed="changed",e.Always="always",e.Never="never",e))(j||{}),K=(e=>(e.Manual="manual",e.Auto="auto",e.Delay="delay",e))(K||{}),Y=(e=>(e.Toast="toast",e.Inline="inline",e))(Y||{}),G=(e=>(e.Pages="pages",e.PrevNext="prev-next",e.PagesPrevNext="pages-prev-next",e.PagesPrevNextFirstLast="pages-prev-next-first-last",e.LoadMore="load-more",e.Infinite="infinite",e))(G||{}),J=(e=>(e.None="",e.Incremental="incremental",e.Decremental="decremental",e))(J||{}),Q=(e=>(e.NotDefined="",e.Hidden="hidden",e.Integer="integer",e.Decimal="decimal",e.Auto="auto",e))(Q||{}),W=(e=>(e.Table="table",e.Item="item",e.Ul="ul",e.Ol="ol",e))(W||{}),X=(e=>(e[e.Auto=0]="Auto",e[e.PreferItem=1]="PreferItem",e[e.PreferCustomItem=2]="PreferCustomItem",e[e.PreferColumns=3]="PreferColumns",e))(X||{}),Z=(k=class extends I{constructor(n={}){super();d(this,"modelValue","");d(this,"id","");d(this,"useSession",!1);d(this,"cacheLifetime",5);d(this,"contentPad");d(this,"titles");this.feed(n)}},d(k,"lktDefaultValues",["modelValue","id","useSession","cacheLifetime","contentPad","titles"]),k),ee=(e=>(e.NotDefined="",e.ActionIcon="action-icon",e))(ee||{}),te=(e=>(e.Message="message",e.Button="button",e))(te||{}),re=(e=>(e.Left="left",e.Center="center",e.Right="right",e))(re||{}),ae=(e=>(e.Fixed="fixed",e.Absolute="absolute",e))(ae||{}),ne=(e=>(e.Top="top",e.Bottom="bottom",e.Center="center",e.ReferrerCenter="referrer-center",e))(ne||{}),oe=(e=>(e.Left="left",e.Right="right",e.Center="center",e.LeftCorner="left-corner",e.RightCorner="right-corner",e))(oe||{}),le=(e=>(e.Refresh="refresh",e.Close="close",e.ReOpen="reOpen",e.Exec="exec",e.Open="open",e))(le||{}),se=(e=>(e.Modal="modal",e.Confirm="confirm",e))(se||{}),ie=(e=>(e.Asc="asc",e.Desc="desc",e))(ie||{}),ce=(e=>(e.Create="create",e.Update="update",e.Edit="edit",e.Drop="drop",e.Sort="sort",e.SwitchEditMode="switch-edit-mode",e.InlineEdit="inline-edit",e.InlineCreate="inline-create",e.ModalCreate="modal-create",e.InlineCreateEver="inline-create-ever",e))(ce||{}),de=(e=>(e.Lazy="lazy",e.Ever="ever",e))(de||{});function ue(e){let n=new e,a={};if(!Array.isArray(e.lktDefaultValues))throw new Error("lktDefaultValues must be a keys array.");for(let c of e.lktDefaultValues)c in n&&(a[c]=n[c]);return a}const me={class:"lkt-tabs__list"},pe=["href","onClick"],fe=["innerHTML","onClick","href"],he={"data-lkt":"tab"},ke=t.defineComponent({__name:"LktTabs",props:t.mergeDefaults({modelValue:{},id:{},useSession:{type:Boolean},cacheLifetime:{},contentPad:{},titles:{}},ue(Z)),emits:["update:modelValue"],setup(e,{emit:n}){const{ctx:a}=t.getCurrentInstance(),c=t.useSlots(),o=e,b=n,m=t.ref("");if(o.useSession){o.id||console.warn("[LKT Tabs] You're trying to use session provided tabs without the required id. Please, add id attr");let r=T(o.id);r&&(m.value=r)}t.watch(()=>o.modelValue,(r,i)=>{typeof r=="string"&&(m.value=r)}),t.watch(m,(r,i)=>{b("update:modelValue"),t.nextTick(()=>{a.$forceUpdate()}),o.useSession&&E(a.id,r,o.cacheLifetime)});const h=t.computed(()=>[].join(" ")),g=t.computed(()=>{let r=[];return o.contentPad&&r.push(`padding: ${o.contentPad}`),r.join(";")}),f=t.computed(()=>{let r=[];for(let i in c)i.indexOf("tab-")!==-1&&r.push(i);return r}),be=t.computed(()=>{let r=[];for(let i in c)i.indexOf("title-")!==-1&&r.push(i);return r}),ge=t.computed(()=>{let r=[];for(let i in c)i.indexOf("li-")!==-1&&r.push(i);return r}),S=t.computed(()=>{let r={};for(let i in a.$refs)r[i]=a.$refs[i].hash;return r}),Se=t.computed(()=>Object.keys(f.value).length>1),v=(r="")=>S.value.length>0&&S.value[r]?"#"+S.value[r]:"#",x=(r="")=>o.titles&&o.titles[r]?o.titles[r]:r,Ce=()=>{a.$forceUpdate()};for(let r in f.value)m.value===""&&(m.value=r);return(r,i)=>(t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["lkt-tabs",h.value])},[t.withDirectives(t.createElementVNode("ul",me,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(f.value,l=>(t.openBlock(),t.createElementBlock("li",{key:l,class:t.normalizeClass(["lkt-tab",{"is-active":l===m.value}]),role:"presentation"},[be.value.includes(l)?(t.openBlock(),t.createElementBlock("a",{key:0,href:v(l),onClick:t.withModifiers(C=>m.value=l,["prevent"]),role:"tab"},[t.renderSlot(r.$slots,"title-"+l)],8,pe)):(t.openBlock(),t.createElementBlock("a",{key:1,innerHTML:x(l),onClick:t.withModifiers(C=>m.value=l,["prevent"]),href:v(l),role:"tab"},null,8,fe))],2))),128)),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(ge.value,(l,C)=>(t.openBlock(),t.createElementBlock("li",he,[t.renderSlot(r.$slots,"li-"+C)]))),256))],512),[[t.vShow,Se.value]]),t.createElementVNode("div",{class:"lkt-tabs__content",style:t.normalizeStyle(g.value)},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(f.value,l=>(t.openBlock(),t.createBlock(B,{ref_for:!0,ref:l,hash:l,id:l,name:x(l),"active-hash":m.value,onIsActive:Ce},{default:t.withCtx(()=>[t.renderSlot(r.$slots,"tab-"+l)]),_:2},1032,["hash","id","name","active-hash"]))),256))],4)],2))}});return{install:(e,n)=>{e.component("lkt-tabs",ke)}}});
@@ -1,125 +1,11 @@
1
- declare const _default: {
2
- new (...args: any[]): {
3
- $: import("vue").ComponentInternalInstance;
4
- $data: {};
5
- $props: Partial<{
6
- id: string;
7
- hash: string;
8
- activeHash: string;
9
- isDisabled: boolean;
10
- }> & Omit<Readonly<import("vue").ExtractPropTypes<{
11
- id: {
12
- type: StringConstructor;
13
- default: string;
14
- };
15
- name: {
16
- type: StringConstructor;
17
- required: true;
18
- };
19
- hash: {
20
- type: StringConstructor;
21
- default: string;
22
- };
23
- activeHash: {
24
- type: StringConstructor;
25
- default: string;
26
- };
27
- isDisabled: {
28
- type: BooleanConstructor;
29
- default: boolean;
30
- };
31
- }>> & {
32
- "onIs-active"?: ((...args: any[]) => any) | undefined;
33
- } & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "id" | "hash" | "activeHash" | "isDisabled">;
34
- $attrs: {
35
- [x: string]: unknown;
36
- };
37
- $refs: {
38
- [x: string]: unknown;
39
- };
40
- $slots: Readonly<{
41
- [name: string]: import("vue").Slot | undefined;
42
- }>;
43
- $root: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null;
44
- $parent: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null;
45
- $emit: (event: "is-active", ...args: any[]) => void;
46
- $el: any;
47
- $options: import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
48
- id: {
49
- type: StringConstructor;
50
- default: string;
51
- };
52
- name: {
53
- type: StringConstructor;
54
- required: true;
55
- };
56
- hash: {
57
- type: StringConstructor;
58
- default: string;
59
- };
60
- activeHash: {
61
- type: StringConstructor;
62
- default: string;
63
- };
64
- isDisabled: {
65
- type: BooleanConstructor;
66
- default: boolean;
67
- };
68
- }>> & {
69
- "onIs-active"?: ((...args: any[]) => any) | undefined;
70
- }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "is-active"[], string, {
71
- id: string;
72
- hash: string;
73
- activeHash: string;
74
- isDisabled: boolean;
75
- }> & {
76
- beforeCreate?: ((() => void) | (() => void)[]) | undefined;
77
- created?: ((() => void) | (() => void)[]) | undefined;
78
- beforeMount?: ((() => void) | (() => void)[]) | undefined;
79
- mounted?: ((() => void) | (() => void)[]) | undefined;
80
- beforeUpdate?: ((() => void) | (() => void)[]) | undefined;
81
- updated?: ((() => void) | (() => void)[]) | undefined;
82
- activated?: ((() => void) | (() => void)[]) | undefined;
83
- deactivated?: ((() => void) | (() => void)[]) | undefined;
84
- beforeDestroy?: ((() => void) | (() => void)[]) | undefined;
85
- beforeUnmount?: ((() => void) | (() => void)[]) | undefined;
86
- destroyed?: ((() => void) | (() => void)[]) | undefined;
87
- unmounted?: ((() => void) | (() => void)[]) | undefined;
88
- renderTracked?: (((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[]) | undefined;
89
- renderTriggered?: (((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[]) | undefined;
90
- 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;
91
- };
92
- $forceUpdate: () => void;
93
- $nextTick: typeof import("vue").nextTick;
94
- $watch(source: string | Function, cb: Function, options?: import("vue").WatchOptions<boolean> | undefined): import("vue").WatchStopHandle;
95
- } & Readonly<import("vue").ExtractPropTypes<{
96
- id: {
97
- type: StringConstructor;
98
- default: string;
99
- };
100
- name: {
101
- type: StringConstructor;
102
- required: true;
103
- };
104
- hash: {
105
- type: StringConstructor;
106
- default: string;
107
- };
108
- activeHash: {
109
- type: StringConstructor;
110
- default: string;
111
- };
112
- isDisabled: {
113
- type: BooleanConstructor;
114
- default: boolean;
115
- };
116
- }>> & {
117
- "onIs-active"?: ((...args: any[]) => any) | undefined;
118
- } & import("vue").ShallowUnwrapRef<{}> & {} & import("vue").ComponentCustomProperties;
119
- __isFragment?: undefined;
120
- __isTeleport?: undefined;
121
- __isSuspense?: undefined;
122
- } & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
1
+ declare const isActive: import("vue").Ref<boolean, boolean>;
2
+ declare const computedId: import("vue").ComputedRef<string>;
3
+ declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
4
+ declare var __VLS_1: {};
5
+ type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
6
+ default?: (props: typeof __VLS_1) => any;
7
+ }>;
8
+ declare const __VLS_self: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
123
9
  id: {
124
10
  type: StringConstructor;
125
11
  default: string;
@@ -140,16 +26,96 @@ declare const _default: {
140
26
  type: BooleanConstructor;
141
27
  default: boolean;
142
28
  };
143
- }>> & {
29
+ }>, {
30
+ isActive: typeof isActive;
31
+ computedId: typeof computedId;
32
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
33
+ "is-active": (...args: any[]) => void;
34
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
35
+ id: {
36
+ type: StringConstructor;
37
+ default: string;
38
+ };
39
+ name: {
40
+ type: StringConstructor;
41
+ required: true;
42
+ };
43
+ hash: {
44
+ type: StringConstructor;
45
+ default: string;
46
+ };
47
+ activeHash: {
48
+ type: StringConstructor;
49
+ default: string;
50
+ };
51
+ isDisabled: {
52
+ type: BooleanConstructor;
53
+ default: boolean;
54
+ };
55
+ }>> & Readonly<{
144
56
  "onIs-active"?: ((...args: any[]) => any) | undefined;
145
- }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "is-active"[], "is-active", {
57
+ }>, {
146
58
  id: string;
147
59
  hash: string;
148
60
  activeHash: string;
149
61
  isDisabled: boolean;
150
- }> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
151
- $slots: {
152
- default: (_: {}) => any;
62
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
63
+ declare const __VLS_component: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
64
+ id: {
65
+ type: StringConstructor;
66
+ default: string;
67
+ };
68
+ name: {
69
+ type: StringConstructor;
70
+ required: true;
71
+ };
72
+ hash: {
73
+ type: StringConstructor;
74
+ default: string;
153
75
  };
154
- });
76
+ activeHash: {
77
+ type: StringConstructor;
78
+ default: string;
79
+ };
80
+ isDisabled: {
81
+ type: BooleanConstructor;
82
+ default: boolean;
83
+ };
84
+ }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
85
+ "is-active": (...args: any[]) => void;
86
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
87
+ id: {
88
+ type: StringConstructor;
89
+ default: string;
90
+ };
91
+ name: {
92
+ type: StringConstructor;
93
+ required: true;
94
+ };
95
+ hash: {
96
+ type: StringConstructor;
97
+ default: string;
98
+ };
99
+ activeHash: {
100
+ type: StringConstructor;
101
+ default: string;
102
+ };
103
+ isDisabled: {
104
+ type: BooleanConstructor;
105
+ default: boolean;
106
+ };
107
+ }>> & Readonly<{
108
+ "onIs-active"?: ((...args: any[]) => any) | undefined;
109
+ }>, {
110
+ id: string;
111
+ hash: string;
112
+ activeHash: string;
113
+ isDisabled: boolean;
114
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
115
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
155
116
  export default _default;
117
+ type __VLS_WithSlots<T, S> = T & {
118
+ new (): {
119
+ $slots: S;
120
+ };
121
+ };
@@ -1,158 +1,64 @@
1
- import { nextTick } from 'vue';
2
- import { LktObject } from "lkt-ts-interfaces";
3
- declare const _default: {
4
- new (...args: any[]): {
5
- $: import("vue").ComponentInternalInstance;
6
- $data: {};
7
- $props: Partial<{
8
- id: string;
9
- modelValue: string | number;
10
- useSession: boolean;
11
- cacheLifetime: number;
12
- contentPad: string;
13
- palette: string;
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
- }>>> & {
32
- "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
33
- } & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "id" | "modelValue" | "useSession" | "cacheLifetime" | "contentPad" | "palette" | "titles">;
34
- $attrs: {
35
- [x: string]: unknown;
36
- };
37
- $refs: {
38
- [x: string]: unknown;
39
- };
40
- $slots: Readonly<{
41
- [name: string]: import("vue").Slot | undefined;
42
- }>;
43
- $root: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null;
44
- $parent: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null;
45
- $emit: (event: "update:modelValue", ...args: any[]) => void;
46
- $el: any;
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
- }>>> & {
64
- "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
65
- }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:modelValue"[], string, {
66
- id: string;
67
- modelValue: string | number;
68
- useSession: boolean;
69
- cacheLifetime: number;
70
- contentPad: string;
71
- palette: string;
72
- titles: LktObject;
73
- }> & {
74
- beforeCreate?: ((() => void) | (() => void)[]) | undefined;
75
- created?: ((() => void) | (() => void)[]) | undefined;
76
- beforeMount?: ((() => void) | (() => void)[]) | undefined;
77
- mounted?: ((() => void) | (() => void)[]) | undefined;
78
- beforeUpdate?: ((() => void) | (() => void)[]) | undefined;
79
- updated?: ((() => void) | (() => void)[]) | undefined;
80
- activated?: ((() => void) | (() => void)[]) | undefined;
81
- deactivated?: ((() => void) | (() => void)[]) | undefined;
82
- beforeDestroy?: ((() => void) | (() => void)[]) | undefined;
83
- beforeUnmount?: ((() => void) | (() => void)[]) | undefined;
84
- destroyed?: ((() => void) | (() => void)[]) | undefined;
85
- unmounted?: ((() => void) | (() => void)[]) | undefined;
86
- renderTracked?: (((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[]) | undefined;
87
- renderTriggered?: (((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[]) | undefined;
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;
89
- };
90
- $forceUpdate: () => void;
91
- $nextTick: typeof nextTick;
92
- $watch(source: string | Function, cb: Function, options?: import("vue").WatchOptions<boolean> | undefined): import("vue").WatchStopHandle;
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
- }>>> & {
110
- "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
111
- } & import("vue").ShallowUnwrapRef<{}> & {} & import("vue").ComponentCustomProperties;
112
- __isFragment?: undefined;
113
- __isTeleport?: undefined;
114
- __isSuspense?: undefined;
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;
1
+ import LktTab from "../components/LktTab.vue";
2
+ import { LktObject, TabsConfig } from "lkt-vue-kernel";
3
+ declare const Value: import("vue").Ref<string, string>;
4
+ declare const classes: import("vue").ComputedRef<string>;
5
+ declare const contentStyles: import("vue").ComputedRef<string>;
6
+ declare const tabsSlots: import("vue").ComputedRef<string[]>;
7
+ declare const titlesSlots: import("vue").ComputedRef<string[]>;
8
+ declare const liSlots: import("vue").ComputedRef<string[]>;
9
+ declare const displayButtons: import("vue").ComputedRef<boolean>;
10
+ declare const getTabHref: (key?: string | number) => string;
11
+ declare const getTabTitle: (key?: string | number) => any;
12
+ declare const refresh: () => void;
13
+ declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
14
+ declare var __VLS_2: string, __VLS_3: {}, __VLS_6: string, __VLS_7: {}, __VLS_16: string, __VLS_17: {};
15
+ type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
16
+ [K in NonNullable<typeof __VLS_2>]?: (props: typeof __VLS_3) => any;
17
+ } & {
18
+ [K in NonNullable<typeof __VLS_6>]?: (props: typeof __VLS_7) => any;
19
+ } & {
20
+ [K in NonNullable<typeof __VLS_16>]?: (props: typeof __VLS_17) => any;
21
+ }>;
22
+ declare const __VLS_self: import("vue").DefineComponent<TabsConfig, {
23
+ LktTab: typeof LktTab;
24
+ Value: typeof Value;
25
+ classes: typeof classes;
26
+ contentStyles: typeof contentStyles;
27
+ tabsSlots: typeof tabsSlots;
28
+ titlesSlots: typeof titlesSlots;
29
+ liSlots: typeof liSlots;
30
+ displayButtons: typeof displayButtons;
31
+ getTabHref: typeof getTabHref;
32
+ getTabTitle: typeof getTabTitle;
33
+ refresh: typeof refresh;
34
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
35
+ "update:modelValue": (...args: any[]) => void;
36
+ }, string, import("vue").PublicProps, Readonly<TabsConfig> & Readonly<{
37
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
123
38
  }>, {
124
- modelValue: string;
125
39
  id: string;
40
+ modelValue: string | number;
126
41
  useSession: boolean;
127
42
  cacheLifetime: number;
128
43
  contentPad: string;
129
- palette: string;
130
- titles: () => {};
131
- }>>> & {
44
+ titles: LktObject;
45
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
46
+ declare const __VLS_component: import("vue").DefineComponent<TabsConfig, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
47
+ "update:modelValue": (...args: any[]) => void;
48
+ }, string, import("vue").PublicProps, Readonly<TabsConfig> & Readonly<{
132
49
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
133
- }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", {
50
+ }>, {
134
51
  id: string;
135
52
  modelValue: string | number;
136
53
  useSession: boolean;
137
54
  cacheLifetime: number;
138
55
  contentPad: string;
139
- palette: string;
140
56
  titles: LktObject;
141
- }> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
142
- $slots: Record<string, {}> & Record<string, {}> & Record<string, {}>;
143
- });
57
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
58
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
144
59
  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;
60
+ type __VLS_WithSlots<T, S> = T & {
61
+ new (): {
62
+ $slots: S;
152
63
  };
153
64
  };
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
- };
@@ -1,35 +1,35 @@
1
1
  declare namespace _default {
2
- const plugins: import("vite").Plugin[];
2
+ let plugins: import("vite").Plugin<import("@vitejs/plugin-vue").Api>[];
3
3
  namespace resolve {
4
- const alias: {
4
+ let alias: {
5
5
  '@': string;
6
6
  '@test': string;
7
7
  };
8
8
  }
9
9
  namespace build {
10
10
  export namespace lib {
11
- const entry: string;
12
- const name: string;
11
+ let entry: string;
12
+ let name: string;
13
13
  function fileName(format: any): string;
14
14
  }
15
15
  export { outDir };
16
- export const minify: boolean;
16
+ export let minify: boolean;
17
17
  export namespace rollupOptions {
18
- const external: string[];
18
+ let external: string[];
19
19
  namespace output {
20
- const globals: {
20
+ let globals: {
21
21
  vue: string;
22
22
  "lkt-tools": string;
23
23
  "lkt-events": string;
24
24
  "lkt-session": string;
25
25
  };
26
- const sourcemapExcludeSources: boolean;
26
+ let sourcemapExcludeSources: boolean;
27
27
  }
28
28
  }
29
29
  }
30
30
  namespace test {
31
31
  namespace coverage {
32
- const reporter: string[];
32
+ let reporter: string[];
33
33
  }
34
34
  function resolveSnapshotPath(testPath: any, snapExtension: any): string;
35
35
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lkt-tabs",
3
- "version": "1.0.8",
3
+ "version": "1.2.0",
4
4
  "description": "",
5
5
  "main": "src/index.ts",
6
6
  "module": "src/index.ts",
@@ -15,7 +15,7 @@
15
15
  "import": "./dist/lkt-tabs.es.js",
16
16
  "require": "./dist/lkt-tabs.umd.js"
17
17
  },
18
- "./dist/style.css": "./dist/style.css",
18
+ "./dist/style.css": "./dist/lkt-tabs.css",
19
19
  "./theme": "./theme/default.css",
20
20
  "./theme/default": "./theme/default.css"
21
21
  },
@@ -29,21 +29,24 @@
29
29
  "test-coverage": "vitest run --coverage"
30
30
  },
31
31
  "author": "Antonio Ibáñez",
32
+ "engines": {
33
+ "node": ">=18"
34
+ },
32
35
  "devDependencies": {
33
- "@babel/types": "^7.18.9",
34
- "@types/node": "^18.0.6",
35
- "@vitejs/plugin-vue": "^3.0.1",
36
- "vue-tsc": "^0.38.9"
36
+ "@babel/types": "^7.23.6",
37
+ "@types/node": "^20.11.19",
38
+ "@types/rollup": "^0.54.0",
39
+ "@vitejs/plugin-vue": "^5.0.4",
40
+ "rollup": "^4.34.8",
41
+ "typescript": "^5.7.3",
42
+ "vite": "^6.1.1",
43
+ "vue": "^3.3.0",
44
+ "vue-tsc": "^2.2.0"
37
45
  },
38
- "dependencies": {
39
- "lkt-events": "^1.0.4",
46
+ "peerDependencies": {
40
47
  "lkt-session": "^1.0.6",
41
- "lkt-string-tools": "^1.0.5",
42
- "lkt-ts-interfaces": "^1.0.5",
43
- "lkt-vue-tools": "^1.0.1",
48
+ "lkt-string-tools": "^1.0.8",
49
+ "lkt-vue-kernel": "^1.0.32",
44
50
  "vue": "^3.0.5"
45
- },
46
- "engines": {
47
- "node": ">=12"
48
51
  }
49
52
  }
@@ -1,31 +1,18 @@
1
1
  <script lang="ts" setup>
2
2
  import LktTab from "../components/LktTab.vue";
3
- import {computed, getCurrentInstance, nextTick, ref, watch} from 'vue';
4
- import {getSlots} from "lkt-vue-tools";
3
+ import {computed, getCurrentInstance, nextTick, ref, useSlots, watch} from 'vue';
5
4
  import {loadSelectedTabFromSession, setSelectedTabFromSession} from "../functions/functions";
6
- import {LktObject} from "lkt-ts-interfaces";
5
+ import {getDefaultValues, LktObject, Tabs, TabsConfig} from "lkt-vue-kernel";
7
6
 
8
7
  const {ctx: _this}: any = getCurrentInstance();
9
8
 
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: () => ({}),
26
- });
9
+ const slots = useSlots();
10
+
11
+ const props = withDefaults(defineProps<TabsConfig>(), getDefaultValues(Tabs));
27
12
 
28
- const emit = defineEmits(['update:modelValue'])
13
+ const emit = defineEmits([
14
+ 'update:modelValue'
15
+ ])
29
16
 
30
17
  const Value = ref('');
31
18
 
@@ -55,8 +42,7 @@ watch(Value, (newVal, oldVal) => {
55
42
  })
56
43
 
57
44
  const classes = computed(() => {
58
- let r = [];
59
- if (!!props.palette) r.push(`lkt-tabs--${props.palette}`);
45
+ let r: Array<string> = [];
60
46
  return r.join(' ');
61
47
  });
62
48
 
@@ -67,15 +53,21 @@ const contentStyles = computed(() => {
67
53
  });
68
54
 
69
55
  const tabsSlots = computed(() => {
70
- return getSlots(_this.$slots, 'tab-');
56
+ let r: string[] = [];
57
+ for (let k in slots) if (k.indexOf('tab-') !== -1) r.push(k);
58
+ return r;
71
59
  });
72
60
 
73
61
  const titlesSlots = computed(() => {
74
- return getSlots(_this.$slots, 'title-');
62
+ let r: string[] = [];
63
+ for (let k in slots) if (k.indexOf('title-') !== -1) r.push(k);
64
+ return r;
75
65
  });
76
66
 
77
67
  const liSlots = computed(() => {
78
- return getSlots(_this.$slots, 'li-');
68
+ let r: string[] = [];
69
+ for (let k in slots) if (k.indexOf('li-') !== -1) r.push(k);
70
+ return r;
79
71
  });
80
72
 
81
73
  const tabsHref = computed(() => {
@@ -117,18 +109,18 @@ for (let k in tabsSlots.value) {
117
109
  <div class="lkt-tabs" v-bind:class="classes">
118
110
  <ul class="lkt-tabs__list" v-show="displayButtons">
119
111
  <li
120
- v-for="(_, key) in tabsSlots"
112
+ v-for="key in tabsSlots"
121
113
  v-bind:key="key"
122
114
  class="lkt-tab"
123
115
  v-bind:class="{'is-active': key === Value}"
124
116
  role="presentation"
125
117
  >
126
- <template v-if="!!titlesSlots[key]">
118
+ <template v-if="titlesSlots.includes(key)">
127
119
  <a v-bind:href="getTabHref(key)"
128
120
  v-on:click.prevent="Value = key"
129
121
  role="tab"
130
122
  >
131
- <slot v-bind:name="'title-' + key"></slot>
123
+ <slot v-bind:name="'title-' + key"/>
132
124
  </a>
133
125
  </template>
134
126
  <template v-else>
@@ -145,7 +137,7 @@ for (let k in tabsSlots.value) {
145
137
  </ul>
146
138
  <div class="lkt-tabs__content" v-bind:style="contentStyles">
147
139
  <lkt-tab
148
- v-for="(_, key) in tabsSlots"
140
+ v-for="key in tabsSlots"
149
141
  v-bind:ref="key"
150
142
  v-bind:hash="key"
151
143
  v-bind:id="key"
@@ -153,7 +145,7 @@ for (let k in tabsSlots.value) {
153
145
  v-bind:active-hash="Value"
154
146
  v-on:is-active="refresh"
155
147
  >
156
- <slot v-bind:name="'tab-' + key"></slot>
148
+ <slot v-bind:name="'tab-' + key"/>
157
149
  </lkt-tab>
158
150
  </div>
159
151
  </div>
@@ -1 +0,0 @@
1
- declare const SESSION_STORAGE_KEY = "lkt-tabs.cache";
File without changes