lkt-tabs 1.1.0 → 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.
package/dist/lkt-tabs.es.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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) {
|
|
4
7
|
let r = "";
|
|
5
|
-
const
|
|
6
|
-
for (let
|
|
7
|
-
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));
|
|
8
11
|
return r;
|
|
9
12
|
}
|
|
10
|
-
function
|
|
11
|
-
return typeof
|
|
13
|
+
function X(e) {
|
|
14
|
+
return typeof e == "string";
|
|
12
15
|
}
|
|
13
|
-
const
|
|
16
|
+
const Z = ["id"], ee = /* @__PURE__ */ _({
|
|
14
17
|
__name: "LktTab",
|
|
15
18
|
props: {
|
|
16
19
|
id: { type: String, default: "" },
|
|
@@ -20,129 +23,163 @@ const G = ["id"], J = /* @__PURE__ */ H({
|
|
|
20
23
|
isDisabled: { type: Boolean, default: !1 }
|
|
21
24
|
},
|
|
22
25
|
emits: ["is-active"],
|
|
23
|
-
setup(
|
|
24
|
-
const
|
|
25
|
-
|
|
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
|
|
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:
|
|
33
|
+
id: u.value,
|
|
31
34
|
role: "tabpanel"
|
|
32
35
|
}, [
|
|
33
|
-
v(
|
|
34
|
-
], 8,
|
|
36
|
+
v(g.$slots, "default")
|
|
37
|
+
], 8, Z)) : O("", !0);
|
|
35
38
|
}
|
|
36
|
-
}),
|
|
37
|
-
|
|
38
|
-
}
|
|
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
|
+
}
|
|
56
|
+
}
|
|
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;
|
|
74
|
+
}
|
|
75
|
+
const Re = { class: "lkt-tabs__list" }, ze = ["href", "onClick"], Ue = ["innerHTML", "onClick", "href"], Fe = { "data-lkt": "tab" }, je = /* @__PURE__ */ _({
|
|
39
76
|
__name: "LktTabs",
|
|
40
|
-
props: {
|
|
41
|
-
modelValue: {
|
|
42
|
-
id: {
|
|
43
|
-
useSession: { type: Boolean
|
|
44
|
-
cacheLifetime: {
|
|
45
|
-
contentPad: {
|
|
46
|
-
titles: {
|
|
47
|
-
},
|
|
77
|
+
props: /* @__PURE__ */ R({
|
|
78
|
+
modelValue: {},
|
|
79
|
+
id: {},
|
|
80
|
+
useSession: { type: Boolean },
|
|
81
|
+
cacheLifetime: {},
|
|
82
|
+
contentPad: {},
|
|
83
|
+
titles: {}
|
|
84
|
+
}, Oe(Me)),
|
|
48
85
|
emits: [
|
|
49
86
|
"update:modelValue"
|
|
50
87
|
],
|
|
51
|
-
setup(
|
|
52
|
-
const { ctx:
|
|
53
|
-
if (
|
|
54
|
-
|
|
55
|
-
let
|
|
56
|
-
|
|
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);
|
|
57
94
|
}
|
|
58
|
-
|
|
59
|
-
typeof
|
|
60
|
-
}),
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}),
|
|
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);
|
|
64
101
|
});
|
|
65
|
-
const
|
|
66
|
-
let
|
|
67
|
-
return
|
|
68
|
-
}), f =
|
|
69
|
-
let
|
|
70
|
-
for (let l in
|
|
71
|
-
return
|
|
72
|
-
}),
|
|
73
|
-
let
|
|
74
|
-
for (let l in
|
|
75
|
-
return
|
|
76
|
-
}),
|
|
77
|
-
let
|
|
78
|
-
for (let l in
|
|
79
|
-
return
|
|
80
|
-
}),
|
|
81
|
-
let
|
|
82
|
-
for (let l in
|
|
83
|
-
|
|
84
|
-
return
|
|
85
|
-
}),
|
|
86
|
-
|
|
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();
|
|
87
124
|
};
|
|
88
|
-
for (let
|
|
89
|
-
|
|
90
|
-
return (
|
|
91
|
-
class:
|
|
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])
|
|
92
129
|
}, [
|
|
93
|
-
|
|
94
|
-
(
|
|
95
|
-
key:
|
|
96
|
-
class:
|
|
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 }]),
|
|
97
134
|
role: "presentation"
|
|
98
135
|
}, [
|
|
99
|
-
|
|
136
|
+
E.value.includes(s) ? (d(), h("a", {
|
|
100
137
|
key: 0,
|
|
101
|
-
href:
|
|
102
|
-
onClick:
|
|
138
|
+
href: P(s),
|
|
139
|
+
onClick: I((C) => u.value = s, ["prevent"]),
|
|
103
140
|
role: "tab"
|
|
104
141
|
}, [
|
|
105
|
-
v(
|
|
106
|
-
], 8,
|
|
142
|
+
v(t.$slots, "title-" + s)
|
|
143
|
+
], 8, ze)) : (d(), h("a", {
|
|
107
144
|
key: 1,
|
|
108
|
-
innerHTML:
|
|
109
|
-
onClick:
|
|
110
|
-
href:
|
|
145
|
+
innerHTML: M(s),
|
|
146
|
+
onClick: I((C) => u.value = s, ["prevent"]),
|
|
147
|
+
href: P(s),
|
|
111
148
|
role: "tab"
|
|
112
|
-
}, null, 8,
|
|
149
|
+
}, null, 8, Ue))
|
|
113
150
|
], 2))), 128)),
|
|
114
|
-
(
|
|
115
|
-
v(
|
|
151
|
+
(d(!0), h(k, null, w(N.value, (s, C) => (d(), h("li", Fe, [
|
|
152
|
+
v(t.$slots, "li-" + C)
|
|
116
153
|
]))), 256))
|
|
117
154
|
], 512), [
|
|
118
|
-
[
|
|
155
|
+
[q, $.value]
|
|
119
156
|
]),
|
|
120
|
-
|
|
157
|
+
D("div", {
|
|
121
158
|
class: "lkt-tabs__content",
|
|
122
|
-
style:
|
|
159
|
+
style: K(g.value)
|
|
123
160
|
}, [
|
|
124
|
-
(
|
|
161
|
+
(d(!0), h(k, null, w(f.value, (s) => (d(), Y(ee, {
|
|
125
162
|
ref_for: !0,
|
|
126
|
-
ref:
|
|
127
|
-
hash:
|
|
128
|
-
id:
|
|
129
|
-
name:
|
|
130
|
-
"active-hash":
|
|
131
|
-
onIsActive:
|
|
163
|
+
ref: s,
|
|
164
|
+
hash: s,
|
|
165
|
+
id: s,
|
|
166
|
+
name: M(s),
|
|
167
|
+
"active-hash": u.value,
|
|
168
|
+
onIsActive: V
|
|
132
169
|
}, {
|
|
133
|
-
default:
|
|
134
|
-
v(
|
|
170
|
+
default: G(() => [
|
|
171
|
+
v(t.$slots, "tab-" + s)
|
|
135
172
|
]),
|
|
136
173
|
_: 2
|
|
137
174
|
}, 1032, ["hash", "id", "name", "active-hash"]))), 256))
|
|
138
175
|
], 4)
|
|
139
176
|
], 2));
|
|
140
177
|
}
|
|
141
|
-
}),
|
|
142
|
-
install: (
|
|
143
|
-
|
|
178
|
+
}), Ge = {
|
|
179
|
+
install: (e, r) => {
|
|
180
|
+
e.component("lkt-tabs", je);
|
|
144
181
|
}
|
|
145
182
|
};
|
|
146
183
|
export {
|
|
147
|
-
|
|
184
|
+
Ge as default
|
|
148
185
|
};
|
package/dist/lkt-tabs.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
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,13 +1,5 @@
|
|
|
1
1
|
import LktTab from "../components/LktTab.vue";
|
|
2
|
-
import { LktObject } from "lkt-vue-kernel";
|
|
3
|
-
type __VLS_Props = {
|
|
4
|
-
modelValue: string | number;
|
|
5
|
-
id?: string;
|
|
6
|
-
useSession?: boolean;
|
|
7
|
-
cacheLifetime?: number;
|
|
8
|
-
contentPad?: string;
|
|
9
|
-
titles?: LktObject;
|
|
10
|
-
};
|
|
2
|
+
import { LktObject, TabsConfig } from "lkt-vue-kernel";
|
|
11
3
|
declare const Value: import("vue").Ref<string, string>;
|
|
12
4
|
declare const classes: import("vue").ComputedRef<string>;
|
|
13
5
|
declare const contentStyles: import("vue").ComputedRef<string>;
|
|
@@ -19,15 +11,15 @@ declare const getTabHref: (key?: string | number) => string;
|
|
|
19
11
|
declare const getTabTitle: (key?: string | number) => any;
|
|
20
12
|
declare const refresh: () => void;
|
|
21
13
|
declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
|
|
22
|
-
declare var __VLS_2: string, __VLS_3: {}, __VLS_6: string, __VLS_7: {},
|
|
14
|
+
declare var __VLS_2: string, __VLS_3: {}, __VLS_6: string, __VLS_7: {}, __VLS_16: string, __VLS_17: {};
|
|
23
15
|
type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
|
|
24
16
|
[K in NonNullable<typeof __VLS_2>]?: (props: typeof __VLS_3) => any;
|
|
25
17
|
} & {
|
|
26
18
|
[K in NonNullable<typeof __VLS_6>]?: (props: typeof __VLS_7) => any;
|
|
27
19
|
} & {
|
|
28
|
-
[K in NonNullable<typeof
|
|
20
|
+
[K in NonNullable<typeof __VLS_16>]?: (props: typeof __VLS_17) => any;
|
|
29
21
|
}>;
|
|
30
|
-
declare const __VLS_self: import("vue").DefineComponent<
|
|
22
|
+
declare const __VLS_self: import("vue").DefineComponent<TabsConfig, {
|
|
31
23
|
LktTab: typeof LktTab;
|
|
32
24
|
Value: typeof Value;
|
|
33
25
|
classes: typeof classes;
|
|
@@ -41,7 +33,7 @@ declare const __VLS_self: import("vue").DefineComponent<__VLS_Props, {
|
|
|
41
33
|
refresh: typeof refresh;
|
|
42
34
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
43
35
|
"update:modelValue": (...args: any[]) => void;
|
|
44
|
-
}, string, import("vue").PublicProps, Readonly<
|
|
36
|
+
}, string, import("vue").PublicProps, Readonly<TabsConfig> & Readonly<{
|
|
45
37
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
46
38
|
}>, {
|
|
47
39
|
id: string;
|
|
@@ -51,9 +43,9 @@ declare const __VLS_self: import("vue").DefineComponent<__VLS_Props, {
|
|
|
51
43
|
contentPad: string;
|
|
52
44
|
titles: LktObject;
|
|
53
45
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
54
|
-
declare const __VLS_component: import("vue").DefineComponent<
|
|
46
|
+
declare const __VLS_component: import("vue").DefineComponent<TabsConfig, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
55
47
|
"update:modelValue": (...args: any[]) => void;
|
|
56
|
-
}, string, import("vue").PublicProps, Readonly<
|
|
48
|
+
}, string, import("vue").PublicProps, Readonly<TabsConfig> & Readonly<{
|
|
57
49
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
58
50
|
}>, {
|
|
59
51
|
id: string;
|
package/package.json
CHANGED
|
@@ -2,27 +2,13 @@
|
|
|
2
2
|
import LktTab from "../components/LktTab.vue";
|
|
3
3
|
import {computed, getCurrentInstance, nextTick, ref, useSlots, watch} from 'vue';
|
|
4
4
|
import {loadSelectedTabFromSession, setSelectedTabFromSession} from "../functions/functions";
|
|
5
|
-
import {LktObject} from "lkt-vue-kernel";
|
|
5
|
+
import {getDefaultValues, LktObject, Tabs, TabsConfig} from "lkt-vue-kernel";
|
|
6
6
|
|
|
7
7
|
const {ctx: _this}: any = getCurrentInstance();
|
|
8
8
|
|
|
9
9
|
const slots = useSlots();
|
|
10
10
|
|
|
11
|
-
const props = withDefaults(defineProps<
|
|
12
|
-
modelValue: string|number
|
|
13
|
-
id?: string
|
|
14
|
-
useSession?: boolean
|
|
15
|
-
cacheLifetime?: number
|
|
16
|
-
contentPad?: string
|
|
17
|
-
titles?: LktObject
|
|
18
|
-
}>(), {
|
|
19
|
-
modelValue: '',
|
|
20
|
-
id: '',
|
|
21
|
-
useSession: false,
|
|
22
|
-
cacheLifetime: 5,
|
|
23
|
-
contentPad: '',
|
|
24
|
-
titles: () => ({}),
|
|
25
|
-
});
|
|
11
|
+
const props = withDefaults(defineProps<TabsConfig>(), getDefaultValues(Tabs));
|
|
26
12
|
|
|
27
13
|
const emit = defineEmits([
|
|
28
14
|
'update:modelValue'
|
package/dist/src/constants.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
declare const SESSION_STORAGE_KEY = "lkt-tabs.cache";
|