@kong-ui-public/page-layout 0.3.8 → 0.4.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/page-layout.es.js +160 -172
- package/dist/page-layout.umd.js +1 -1
- package/dist/style.css +1 -1
- package/package.json +3 -3
package/dist/page-layout.es.js
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
import { getCurrentScope as rt, onScopeDispose as ut, toValue as
|
|
1
|
+
import { getCurrentScope as rt, onScopeDispose as ut, toValue as F, watch as j, computed as g, shallowRef as lt, getCurrentInstance as ct, onMounted as Q, defineComponent as X, useCssVars as dt, unref as c, inject as L, useTemplateRef as U, ref as B, onBeforeUnmount as vt, resolveComponent as I, openBlock as s, createElementBlock as b, createElementVNode as w, normalizeClass as N, Fragment as O, renderList as R, createBlock as $, resolveDynamicComponent as W, mergeProps as Y, withKeys as tt, withModifiers as x, withCtx as C, renderSlot as _, createTextVNode as V, toDisplayString as z, createVNode as K, createCommentVNode as h, nextTick as Z, provide as ft, onUnmounted as bt, createSlots as pt, normalizeProps as yt, guardReactiveProps as mt } from "vue";
|
|
2
2
|
import { useRouter as et, useRoute as ht } from "vue-router";
|
|
3
3
|
import { createI18n as gt, i18nTComponent as kt } from "@kong-ui-public/i18n";
|
|
4
|
-
import { ChevronDownIcon as Tt, ArrowTopLeftIcon as wt, StarFillIcon as St, StarIcon as
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
remove_shortcut: "Remove page from shortcuts"
|
|
8
|
-
}, It = {
|
|
9
|
-
more_button: {
|
|
10
|
-
label: "More",
|
|
11
|
-
aria_label: "More tabs"
|
|
12
|
-
}
|
|
13
|
-
}, Dt = {
|
|
14
|
-
back_button: $t,
|
|
4
|
+
import { ChevronDownIcon as Tt, ArrowTopLeftIcon as wt, StarFillIcon as St, StarIcon as $t } from "@kong/icons";
|
|
5
|
+
const _t = "Go back", Ct = { save_shortcut: "Save page to shortcuts", remove_shortcut: "Remove page from shortcuts" }, It = { more_button: { label: "More", aria_label: "More tabs" } }, Dt = {
|
|
6
|
+
back_button: _t,
|
|
15
7
|
favorite_button: Ct,
|
|
16
8
|
tabs: It
|
|
17
9
|
};
|
|
@@ -29,83 +21,83 @@ const at = {
|
|
|
29
21
|
function Kt(t, o) {
|
|
30
22
|
return rt() ? (ut(t, o), !0) : !1;
|
|
31
23
|
}
|
|
32
|
-
const
|
|
24
|
+
const Lt = typeof window < "u" && typeof document < "u";
|
|
33
25
|
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
34
26
|
const H = () => {
|
|
35
27
|
};
|
|
36
|
-
function
|
|
37
|
-
function
|
|
38
|
-
return new Promise((
|
|
28
|
+
function Rt(t, o) {
|
|
29
|
+
function e(...n) {
|
|
30
|
+
return new Promise((d, i) => {
|
|
39
31
|
Promise.resolve(t(() => o.apply(this, n), {
|
|
40
32
|
fn: o,
|
|
41
33
|
thisArg: this,
|
|
42
34
|
args: n
|
|
43
|
-
})).then(
|
|
35
|
+
})).then(d).catch(i);
|
|
44
36
|
});
|
|
45
37
|
}
|
|
46
|
-
return
|
|
38
|
+
return e;
|
|
47
39
|
}
|
|
48
|
-
function
|
|
49
|
-
let
|
|
50
|
-
const
|
|
51
|
-
clearTimeout(
|
|
40
|
+
function zt(t, o = {}) {
|
|
41
|
+
let e, n, d = H;
|
|
42
|
+
const i = (r) => {
|
|
43
|
+
clearTimeout(r), d(), d = H;
|
|
52
44
|
};
|
|
53
|
-
let
|
|
54
|
-
return (
|
|
55
|
-
const
|
|
56
|
-
return
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
},
|
|
60
|
-
n &&
|
|
61
|
-
},
|
|
45
|
+
let p;
|
|
46
|
+
return (r) => {
|
|
47
|
+
const f = F(t), l = F(o.maxWait);
|
|
48
|
+
return e && i(e), f <= 0 || l !== void 0 && l <= 0 ? (n && (i(n), n = void 0), Promise.resolve(r())) : new Promise((u, T) => {
|
|
49
|
+
d = o.rejectOnCancel ? T : u, p = r, l && !n && (n = setTimeout(() => {
|
|
50
|
+
e && i(e), n = void 0, u(p());
|
|
51
|
+
}, l)), e = setTimeout(() => {
|
|
52
|
+
n && i(n), n = void 0, u(r());
|
|
53
|
+
}, f);
|
|
62
54
|
});
|
|
63
55
|
};
|
|
64
56
|
}
|
|
65
57
|
// @__NO_SIDE_EFFECTS__
|
|
66
|
-
function Ft(t, o = 200,
|
|
67
|
-
return zt(
|
|
58
|
+
function Ft(t, o = 200, e = {}) {
|
|
59
|
+
return Rt(zt(o, e), t);
|
|
68
60
|
}
|
|
69
|
-
const
|
|
61
|
+
const Nt = Lt ? window : void 0;
|
|
70
62
|
function q(t) {
|
|
71
63
|
var o;
|
|
72
|
-
const
|
|
73
|
-
return (o =
|
|
64
|
+
const e = F(t);
|
|
65
|
+
return (o = e?.$el) !== null && o !== void 0 ? o : e;
|
|
74
66
|
}
|
|
75
67
|
// @__NO_SIDE_EFFECTS__
|
|
76
|
-
function
|
|
68
|
+
function xt() {
|
|
77
69
|
const t = lt(!1), o = ct();
|
|
78
70
|
return o && Q(() => {
|
|
79
71
|
t.value = !0;
|
|
80
72
|
}, o), t;
|
|
81
73
|
}
|
|
82
74
|
// @__NO_SIDE_EFFECTS__
|
|
83
|
-
function
|
|
84
|
-
const o = /* @__PURE__ */
|
|
75
|
+
function Et(t) {
|
|
76
|
+
const o = /* @__PURE__ */ xt();
|
|
85
77
|
return g(() => (o.value, !!t()));
|
|
86
78
|
}
|
|
87
|
-
function
|
|
88
|
-
const { window: n =
|
|
89
|
-
let
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
},
|
|
93
|
-
const
|
|
94
|
-
return Array.isArray(
|
|
95
|
-
}), (
|
|
96
|
-
if (
|
|
97
|
-
|
|
98
|
-
for (const
|
|
79
|
+
function At(t, o, e = {}) {
|
|
80
|
+
const { window: n = Nt, ...d } = e;
|
|
81
|
+
let i;
|
|
82
|
+
const p = /* @__PURE__ */ Et(() => n && "ResizeObserver" in n), y = () => {
|
|
83
|
+
i && (i.disconnect(), i = void 0);
|
|
84
|
+
}, r = j(g(() => {
|
|
85
|
+
const l = F(t);
|
|
86
|
+
return Array.isArray(l) ? l.map((u) => q(u)) : [q(l)];
|
|
87
|
+
}), (l) => {
|
|
88
|
+
if (y(), p.value && n) {
|
|
89
|
+
i = new ResizeObserver(o);
|
|
90
|
+
for (const u of l) u && i.observe(u, d);
|
|
99
91
|
}
|
|
100
92
|
}, {
|
|
101
93
|
immediate: !0,
|
|
102
94
|
flush: "post"
|
|
103
|
-
}),
|
|
104
|
-
|
|
95
|
+
}), f = () => {
|
|
96
|
+
y(), r();
|
|
105
97
|
};
|
|
106
|
-
return Kt(
|
|
107
|
-
isSupported:
|
|
108
|
-
stop:
|
|
98
|
+
return Kt(f), {
|
|
99
|
+
isSupported: p,
|
|
100
|
+
stop: f
|
|
109
101
|
};
|
|
110
102
|
}
|
|
111
103
|
const Ot = {
|
|
@@ -121,108 +113,107 @@ const Ot = {
|
|
|
121
113
|
tabs: { default: () => [] }
|
|
122
114
|
},
|
|
123
115
|
setup(t) {
|
|
124
|
-
dt((
|
|
125
|
-
v94e59ca2:
|
|
116
|
+
dt((v) => ({
|
|
117
|
+
v94e59ca2: c(i)
|
|
126
118
|
}));
|
|
127
|
-
const { i18n: { t: o } } = at.useI18n(),
|
|
128
|
-
if (typeof
|
|
129
|
-
|
|
119
|
+
const { i18n: { t: o } } = at.useI18n(), e = et(), n = L("app:navigateTo", null), d = (v) => {
|
|
120
|
+
if (typeof v.to != "string") {
|
|
121
|
+
e.push(v.to);
|
|
130
122
|
return;
|
|
131
123
|
}
|
|
132
124
|
if (typeof n != "function") {
|
|
133
|
-
window.location.href =
|
|
125
|
+
window.location.href = v.to;
|
|
134
126
|
return;
|
|
135
127
|
}
|
|
136
|
-
n(
|
|
137
|
-
},
|
|
138
|
-
|
|
139
|
-
if (!y.value || !m.value)
|
|
128
|
+
n(v.to);
|
|
129
|
+
}, i = Bt, p = U("page-layout-tabs"), y = U("page-layout-tabs-list"), r = B(t.tabs.length), f = B(!1), l = g(() => t.tabs.slice(0, r.value)), u = g(() => t.tabs.slice(r.value)), T = async () => {
|
|
130
|
+
if (!p.value || !y.value)
|
|
140
131
|
return;
|
|
141
|
-
|
|
142
|
-
const
|
|
143
|
-
let
|
|
144
|
-
if (!
|
|
145
|
-
|
|
132
|
+
f.value = !1, r.value = t.tabs.length, await Z();
|
|
133
|
+
const v = p.value?.getBoundingClientRect().width - parseInt(i) * 2;
|
|
134
|
+
let S = y.value?.getBoundingClientRect().width;
|
|
135
|
+
if (!v || !S) {
|
|
136
|
+
f.value = !0;
|
|
146
137
|
return;
|
|
147
138
|
}
|
|
148
|
-
const
|
|
149
|
-
for (;
|
|
150
|
-
|
|
151
|
-
|
|
139
|
+
const P = 50;
|
|
140
|
+
for (; S + P > v && r.value > 1; )
|
|
141
|
+
r.value--, await Z(), S = y.value?.getBoundingClientRect().width || 0;
|
|
142
|
+
f.value = !0;
|
|
152
143
|
};
|
|
153
144
|
let k = null;
|
|
154
|
-
const
|
|
145
|
+
const D = () => {
|
|
155
146
|
k && clearTimeout(k), k = setTimeout(() => {
|
|
156
|
-
|
|
147
|
+
T();
|
|
157
148
|
}, 150);
|
|
158
149
|
};
|
|
159
150
|
return Q(() => {
|
|
160
|
-
|
|
151
|
+
T(), At(p, D);
|
|
161
152
|
}), vt(() => {
|
|
162
153
|
k && clearTimeout(k);
|
|
163
154
|
}), j(() => t.tabs, () => {
|
|
164
|
-
|
|
165
|
-
}, { deep: !0 }), (
|
|
166
|
-
const
|
|
167
|
-
return
|
|
168
|
-
|
|
155
|
+
T();
|
|
156
|
+
}, { deep: !0 }), (v, S) => {
|
|
157
|
+
const P = I("KDropdownItem"), E = I("KDropdown"), m = I("KSkeletonBox");
|
|
158
|
+
return s(), b("nav", Ot, [
|
|
159
|
+
w("ul", {
|
|
169
160
|
ref: "page-layout-tabs-list",
|
|
170
|
-
class:
|
|
161
|
+
class: N({ "layout-computing": !f.value })
|
|
171
162
|
}, [
|
|
172
|
-
(
|
|
173
|
-
key: `${
|
|
163
|
+
(s(!0), b(O, null, R(l.value, (a) => (s(), b("li", {
|
|
164
|
+
key: `${a.key}-tab`
|
|
174
165
|
}, [
|
|
175
|
-
(
|
|
176
|
-
"aria-current":
|
|
177
|
-
class: ["tab-link", { active:
|
|
178
|
-
"data-testid":
|
|
166
|
+
(s(), $(W(typeof a.to == "string" ? "a" : "router-link"), Y({ ref_for: !0 }, typeof a.to == "string" ? { href: a.to } : { to: a.to }, {
|
|
167
|
+
"aria-current": a.active ? "page" : void 0,
|
|
168
|
+
class: ["tab-link", { active: a.active }],
|
|
169
|
+
"data-testid": a.dataTestId ? a.dataTestId : `page-layout-tab-${a.key}`,
|
|
179
170
|
tabindex: "0",
|
|
180
|
-
onClick:
|
|
181
|
-
onKeydown: tt(
|
|
171
|
+
onClick: x((A) => d(a), ["prevent"]),
|
|
172
|
+
onKeydown: tt(x((A) => d(a), ["prevent"]), ["enter"])
|
|
182
173
|
}), {
|
|
183
174
|
default: C(() => [
|
|
184
|
-
|
|
185
|
-
V(
|
|
175
|
+
_(v.$slots, `tab-${a.key}`, { tab: a }, () => [
|
|
176
|
+
V(z(a.label), 1)
|
|
186
177
|
], !0)
|
|
187
178
|
]),
|
|
188
179
|
_: 2
|
|
189
180
|
}, 1040, ["aria-current", "class", "data-testid", "onClick", "onKeydown"]))
|
|
190
181
|
]))), 128)),
|
|
191
|
-
t.tabs.length >
|
|
192
|
-
|
|
182
|
+
t.tabs.length > r.value ? (s(), b("li", Vt, [
|
|
183
|
+
K(E, { "kpop-attributes": {
|
|
193
184
|
placement: "bottom-end",
|
|
194
185
|
popoverElementAttributes: { "data-testid": "tabs-overflow-dropdown-popover" }
|
|
195
186
|
} }, {
|
|
196
187
|
items: C(() => [
|
|
197
|
-
(
|
|
198
|
-
key: `${
|
|
199
|
-
"aria-current":
|
|
200
|
-
"data-testid":
|
|
188
|
+
(s(!0), b(O, null, R(u.value, (a) => (s(), $(P, {
|
|
189
|
+
key: `${a.key}-dropdown-item`,
|
|
190
|
+
"aria-current": a.active ? "page" : void 0,
|
|
191
|
+
"data-testid": a.dataTestId ? a.dataTestId : `page-layout-tab-${a.key}`,
|
|
201
192
|
item: {
|
|
202
|
-
label:
|
|
203
|
-
value:
|
|
204
|
-
to:
|
|
193
|
+
label: a.label,
|
|
194
|
+
value: a.key,
|
|
195
|
+
to: a.to
|
|
205
196
|
},
|
|
206
|
-
selected:
|
|
197
|
+
selected: a.active
|
|
207
198
|
}, {
|
|
208
199
|
default: C(() => [
|
|
209
|
-
|
|
210
|
-
V(
|
|
200
|
+
_(v.$slots, `tab-${a.key}`, { tab: a }, () => [
|
|
201
|
+
V(z(a.label), 1)
|
|
211
202
|
], !0)
|
|
212
203
|
]),
|
|
213
204
|
_: 2
|
|
214
205
|
}, 1032, ["aria-current", "data-testid", "item", "selected"]))), 128))
|
|
215
206
|
]),
|
|
216
207
|
default: C(() => [
|
|
217
|
-
|
|
218
|
-
"aria-label":
|
|
219
|
-
class:
|
|
208
|
+
w("button", {
|
|
209
|
+
"aria-label": c(o)("tabs.more_button.aria_label"),
|
|
210
|
+
class: N(["tab-link", { active: u.value.find((a) => a.active) }]),
|
|
220
211
|
"data-testid": "tabs-overflow-dropdown-button"
|
|
221
212
|
}, [
|
|
222
|
-
V(
|
|
223
|
-
|
|
213
|
+
V(z(c(o)("tabs.more_button.label")) + " ", 1),
|
|
214
|
+
K(c(Tt), {
|
|
224
215
|
decorative: "",
|
|
225
|
-
size: `var(--kui-icon-size-30, ${
|
|
216
|
+
size: `var(--kui-icon-size-30, ${c(M)})`
|
|
226
217
|
}, null, 8, ["size"])
|
|
227
218
|
], 10, Wt)
|
|
228
219
|
]),
|
|
@@ -230,9 +221,9 @@ const Ot = {
|
|
|
230
221
|
})
|
|
231
222
|
])) : h("", !0)
|
|
232
223
|
], 2),
|
|
233
|
-
|
|
234
|
-
(
|
|
235
|
-
key: `layout-loader-${
|
|
224
|
+
f.value ? h("", !0) : (s(), b("div", Mt, [
|
|
225
|
+
(s(), b(O, null, R(3, (a) => K(m, {
|
|
226
|
+
key: `layout-loader-${a}`,
|
|
236
227
|
height: "1",
|
|
237
228
|
width: "5"
|
|
238
229
|
})), 64))
|
|
@@ -241,11 +232,11 @@ const Ot = {
|
|
|
241
232
|
};
|
|
242
233
|
}
|
|
243
234
|
}), ot = (t, o) => {
|
|
244
|
-
const
|
|
245
|
-
for (const [n,
|
|
246
|
-
|
|
247
|
-
return
|
|
248
|
-
}, Gt = /* @__PURE__ */ ot(jt, [["__scopeId", "data-v-014ad9b1"]]), J = Symbol("nested-page-layout-detection"), Ut = {
|
|
235
|
+
const e = t.__vccOpts || t;
|
|
236
|
+
for (const [n, d] of o)
|
|
237
|
+
e[n] = d;
|
|
238
|
+
return e;
|
|
239
|
+
}, Gt = /* @__PURE__ */ ot(jt, [["__scopeId", "data-v-014ad9b1"]]), J = /* @__PURE__ */ Symbol("nested-page-layout-detection"), Ut = {
|
|
249
240
|
class: "kong-ui-public-page-layout",
|
|
250
241
|
"data-testid": "kong-ui-public-page-layout"
|
|
251
242
|
}, Zt = {
|
|
@@ -274,10 +265,10 @@ const Ot = {
|
|
|
274
265
|
pageShortcutData: {}
|
|
275
266
|
},
|
|
276
267
|
setup(t) {
|
|
277
|
-
const o =
|
|
268
|
+
const o = L("app:navigateTo", null), e = L("app:pageShortcutsContext", null), { i18n: { t: n } } = at.useI18n(), d = et(), i = ht(), p = g(() => !!(t.tabs && t.tabs.length)), y = g(() => typeof t.backTo == "string"), r = g(() => !!t.pageShortcutData && !!t.pageShortcutData.entityType && !!t.pageShortcutData.label), f = g(() => r.value && !!e && "onFavoriteToggle" in e && typeof e.onFavoriteToggle == "function"), l = B(0), u = g(() => !!e && "isFavorite" in e && typeof e.isFavorite == "function" && e.isFavorite(t.pageShortcutData) === !0), T = async () => {
|
|
278
269
|
if (t.backTo) {
|
|
279
270
|
if (typeof t.backTo == "object") {
|
|
280
|
-
|
|
271
|
+
d.push(t.backTo);
|
|
281
272
|
return;
|
|
282
273
|
}
|
|
283
274
|
if (typeof o != "function") {
|
|
@@ -286,111 +277,108 @@ const Ot = {
|
|
|
286
277
|
}
|
|
287
278
|
await o(t.backTo);
|
|
288
279
|
}
|
|
289
|
-
}, k =
|
|
280
|
+
}, k = B(0), D = g(() => k.value > 0);
|
|
290
281
|
ft(J, () => (k.value++, () => {
|
|
291
282
|
k.value--;
|
|
292
283
|
}));
|
|
293
|
-
const
|
|
294
|
-
typeof
|
|
295
|
-
const
|
|
296
|
-
|
|
297
|
-
a.onFavoriteToggle({ ...t.pageShortcutData, path: ((i = t.pageShortcutData) == null ? void 0 : i.path) || s.fullPath });
|
|
284
|
+
const v = L(J, null), S = B(null);
|
|
285
|
+
typeof v == "function" && (S.value = v());
|
|
286
|
+
const P = () => {
|
|
287
|
+
e.onFavoriteToggle({ ...t.pageShortcutData, path: t.pageShortcutData?.path || i.fullPath });
|
|
298
288
|
};
|
|
299
289
|
bt(() => {
|
|
300
|
-
|
|
301
|
-
(i = T.value) == null || i.call(T);
|
|
290
|
+
S.value?.();
|
|
302
291
|
});
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
!P.value && u.value && a && "onEntityPageVisit" in a && typeof a.onEntityPageVisit == "function" && (a.onEntityPageVisit({ ...t.pageShortcutData, path: ((i = t.pageShortcutData) == null ? void 0 : i.path) || (s == null ? void 0 : s.fullPath) }), c.value++);
|
|
292
|
+
const E = /* @__PURE__ */ Ft(() => {
|
|
293
|
+
!D.value && r.value && e && "onEntityPageVisit" in e && typeof e.onEntityPageVisit == "function" && (e.onEntityPageVisit({ ...t.pageShortcutData, path: t.pageShortcutData?.path || i?.fullPath }), l.value++);
|
|
306
294
|
}, 500);
|
|
307
|
-
return j([() => t.pageShortcutData, () =>
|
|
308
|
-
|
|
309
|
-
}, { immediate: !0, deep: !0 }), (
|
|
310
|
-
const
|
|
311
|
-
return
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
t.breadcrumbs && t.breadcrumbs.length ? (
|
|
295
|
+
return j([() => t.pageShortcutData, () => i?.fullPath], () => {
|
|
296
|
+
E();
|
|
297
|
+
}, { immediate: !0, deep: !0 }), (m, a) => {
|
|
298
|
+
const A = I("KBreadcrumbs"), nt = I("KTooltip"), st = I("router-view");
|
|
299
|
+
return s(), b("div", Ut, [
|
|
300
|
+
D.value ? h("", !0) : (s(), b("div", Zt, [
|
|
301
|
+
w("div", Ht, [
|
|
302
|
+
w("div", qt, [
|
|
303
|
+
t.breadcrumbs && t.breadcrumbs.length ? (s(), $(A, {
|
|
316
304
|
key: 0,
|
|
317
305
|
class: "header-breadcrumbs",
|
|
318
306
|
"data-testid": "page-layout-breadcrumbs",
|
|
319
307
|
"item-max-width": "25ch",
|
|
320
308
|
items: t.breadcrumbs
|
|
321
309
|
}, null, 8, ["items"])) : h("", !0),
|
|
322
|
-
|
|
323
|
-
t.backTo ? (
|
|
324
|
-
"aria-label":
|
|
310
|
+
w("div", Jt, [
|
|
311
|
+
t.backTo ? (s(), $(W(y.value ? "a" : "router-link"), Y({ key: 0 }, y.value ? { href: t.backTo } : { to: t.backTo }, {
|
|
312
|
+
"aria-label": c(n)("back_button"),
|
|
325
313
|
class: "navigate-back",
|
|
326
314
|
"data-testid": "page-layout-navigate-back",
|
|
327
315
|
tabindex: "0",
|
|
328
|
-
onClick:
|
|
329
|
-
onKeydown: tt(
|
|
316
|
+
onClick: x(T, ["prevent"]),
|
|
317
|
+
onKeydown: tt(x(T, ["prevent"]), ["enter"])
|
|
330
318
|
}), {
|
|
331
319
|
default: C(() => [
|
|
332
|
-
|
|
320
|
+
K(c(wt), {
|
|
333
321
|
decorative: "",
|
|
334
|
-
size: `var(--kui-icon-size-30, ${
|
|
322
|
+
size: `var(--kui-icon-size-30, ${c(M)})`
|
|
335
323
|
}, null, 8, ["size"])
|
|
336
324
|
]),
|
|
337
325
|
_: 1
|
|
338
326
|
}, 16, ["aria-label", "onKeydown"])) : h("", !0),
|
|
339
|
-
t.title ||
|
|
340
|
-
|
|
341
|
-
|
|
327
|
+
t.title || m.$slots.title ? (s(), b("span", Qt, [
|
|
328
|
+
_(m.$slots, "title", {}, () => [
|
|
329
|
+
w("h1", Xt, z(t.title), 1)
|
|
342
330
|
], !0)
|
|
343
331
|
])) : h("", !0),
|
|
344
|
-
|
|
345
|
-
key:
|
|
332
|
+
f.value ? (s(), b("div", {
|
|
333
|
+
key: l.value,
|
|
346
334
|
class: "favorite-button-container"
|
|
347
335
|
}, [
|
|
348
|
-
|
|
336
|
+
K(nt, {
|
|
349
337
|
placement: "right",
|
|
350
|
-
text:
|
|
338
|
+
text: u.value ? c(n)("favorite_button.remove_shortcut") : c(n)("favorite_button.save_shortcut")
|
|
351
339
|
}, {
|
|
352
340
|
default: C(() => [
|
|
353
|
-
|
|
354
|
-
"aria-label":
|
|
355
|
-
class:
|
|
341
|
+
w("button", {
|
|
342
|
+
"aria-label": u.value ? c(n)("favorite_button.remove_shortcut") : c(n)("favorite_button.save_shortcut"),
|
|
343
|
+
class: N(["favorite-button", { active: u.value }]),
|
|
356
344
|
"data-testid": "page-layout-favorite-button",
|
|
357
345
|
type: "button",
|
|
358
|
-
onClick:
|
|
346
|
+
onClick: P
|
|
359
347
|
}, [
|
|
360
|
-
(
|
|
348
|
+
(s(), $(W(u.value ? c(St) : c($t)), {
|
|
361
349
|
decorative: "",
|
|
362
|
-
size: `var(--kui-icon-size-30, ${
|
|
350
|
+
size: `var(--kui-icon-size-30, ${c(M)})`
|
|
363
351
|
}, null, 8, ["size"]))
|
|
364
352
|
], 10, Yt)
|
|
365
353
|
]),
|
|
366
354
|
_: 1
|
|
367
355
|
}, 8, ["text"])
|
|
368
356
|
])) : h("", !0),
|
|
369
|
-
|
|
370
|
-
|
|
357
|
+
m.$slots["title-after"] ? (s(), b("div", te, [
|
|
358
|
+
_(m.$slots, "title-after", {}, void 0, !0)
|
|
371
359
|
])) : h("", !0)
|
|
372
360
|
])
|
|
373
361
|
]),
|
|
374
|
-
|
|
375
|
-
|
|
362
|
+
m.$slots.actions ? (s(), b("div", ee, [
|
|
363
|
+
_(m.$slots, "actions", {}, void 0, !0)
|
|
376
364
|
])) : h("", !0)
|
|
377
365
|
]),
|
|
378
|
-
|
|
366
|
+
p.value ? (s(), $(Gt, {
|
|
379
367
|
key: 0,
|
|
380
368
|
tabs: t.tabs
|
|
381
369
|
}, pt({ _: 2 }, [
|
|
382
|
-
|
|
370
|
+
R(t.tabs, (G) => ({
|
|
383
371
|
name: `tab-${G.key}`,
|
|
384
372
|
fn: C((it) => [
|
|
385
|
-
|
|
373
|
+
_(m.$slots, `tab-${G.key}`, yt(mt(it)), void 0, !0)
|
|
386
374
|
])
|
|
387
375
|
}))
|
|
388
376
|
]), 1032, ["tabs"])) : h("", !0)
|
|
389
377
|
])),
|
|
390
|
-
|
|
391
|
-
class:
|
|
378
|
+
w("div", {
|
|
379
|
+
class: N(["page-layout-content", { "has-nested-page-layout": D.value }])
|
|
392
380
|
}, [
|
|
393
|
-
|
|
381
|
+
p.value ? (s(), $(st, { key: 0 })) : _(m.$slots, "default", { key: 1 }, void 0, !0)
|
|
394
382
|
], 2)
|
|
395
383
|
]);
|
|
396
384
|
};
|
package/dist/page-layout.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(b,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("vue-router"),require("@kong-ui-public/i18n"),require("@kong/icons")):typeof define=="function"&&define.amd?define(["exports","vue","vue-router","@kong-ui-public/i18n","@kong/icons"],t):(b=typeof globalThis<"u"?globalThis:b||self,t(b["kong-ui-public-page-layout"]={},b.Vue,b.VueRouter,b["kong-ui-public-i18n"],b.KongIcons))})(this,function(b,t,S,N,w){"use strict";const K={back_button:"Go back",favorite_button:{save_shortcut:"Save page to shortcuts",remove_shortcut:"Remove page from shortcuts"},tabs:{more_button:{label:"More",aria_label:"More tabs"}}};function z(){const e=N.createI18n("en-us",K);return{i18n:e,i18nT:N.i18nTComponent(e)}}const $={useI18n:z},V="16px",L="16px";function R(e,n){return t.getCurrentScope()?(t.onScopeDispose(e,n),!0):!1}const F=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const D=()=>{};function M(e,n){function a(...r){return new Promise((u,i)=>{Promise.resolve(e(()=>n.apply(this,r),{fn:n,thisArg:this,args:r})).then(u).catch(i)})}return a}function O(e,n={}){let a,r,u=D;const i=s=>{clearTimeout(s),u(),u=D};let f;return s=>{const p=t.toValue(e),d=t.toValue(n.maxWait);return a&&i(a),p<=0||d!==void 0&&d<=0?(r&&(i(r),r=void 0),Promise.resolve(s())):new Promise((l,g)=>{u=n.rejectOnCancel?g:l,f=s,d&&!r&&(r=setTimeout(()=>{a&&i(a),r=void 0,l(f())},d)),a=setTimeout(()=>{r&&i(r),r=void 0,l(s())},p)})}}function A(e,n=200,a={}){return M(O(n,a),e)}const j=F?window:void 0;function E(e){var n;const a=t.toValue(e);return(n=a==null?void 0:a.$el)!==null&&n!==void 0?n:a}function W(){const e=t.shallowRef(!1),n=t.getCurrentInstance();return n&&t.onMounted(()=>{e.value=!0},n),e}function G(e){const n=W();return t.computed(()=>(n.value,!!e()))}function q(e,n,a={}){const{window:r=j,...u}=a;let i;const f=G(()=>r&&"ResizeObserver"in r),y=()=>{i&&(i.disconnect(),i=void 0)},s=t.watch(t.computed(()=>{const d=t.toValue(e);return Array.isArray(d)?d.map(l=>E(l)):[E(d)]}),d=>{if(y(),f.value&&r){i=new ResizeObserver(n);for(const l of d)l&&i.observe(l,u)}},{immediate:!0,flush:"post"}),p=()=>{y(),s()};return R(p),{isSupported:f,stop:p}}const U={ref:"page-layout-tabs",class:"page-layout-tabs","data-testid":"page-layout-tabs"},Z={key:0},H=["aria-label"],J={key:0,class:"layout-loader-container"},Q=t.defineComponent({__name:"PageLayoutTabs",props:{tabs:{default:()=>[]}},setup(e){t.useCssVars(m=>({v94e59ca2:t.unref(i)}));const{i18n:{t:n}}=$.useI18n(),a=S.useRouter(),r=t.inject("app:navigateTo",null),u=m=>{if(typeof m.to!="string"){a.push(m.to);return}if(typeof r!="function"){window.location.href=m.to;return}r(m.to)},i=L,f=t.useTemplateRef("page-layout-tabs"),y=t.useTemplateRef("page-layout-tabs-list"),s=t.ref(e.tabs.length),p=t.ref(!1),d=t.computed(()=>e.tabs.slice(0,s.value)),l=t.computed(()=>e.tabs.slice(s.value)),g=async()=>{var B,c,o;if(!f.value||!y.value)return;p.value=!1,s.value=e.tabs.length,await t.nextTick();const m=((B=f.value)==null?void 0:B.getBoundingClientRect().width)-parseInt(i)*2;let h=(c=y.value)==null?void 0:c.getBoundingClientRect().width;if(!m||!h){p.value=!0;return}const T=50;for(;h+T>m&&s.value>1;)s.value--,await t.nextTick(),h=((o=y.value)==null?void 0:o.getBoundingClientRect().width)||0;p.value=!0};let k=null;const C=()=>{k&&clearTimeout(k),k=setTimeout(()=>{g()},150)};return t.onMounted(()=>{g(),q(f,C)}),t.onBeforeUnmount(()=>{k&&clearTimeout(k)}),t.watch(()=>e.tabs,()=>{g()},{deep:!0}),(m,h)=>{const T=t.resolveComponent("KDropdownItem"),B=t.resolveComponent("KDropdown"),c=t.resolveComponent("KSkeletonBox");return t.openBlock(),t.createElementBlock("nav",U,[t.createElementVNode("ul",{ref:"page-layout-tabs-list",class:t.normalizeClass({"layout-computing":!p.value})},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(d.value,o=>(t.openBlock(),t.createElementBlock("li",{key:`${o.key}-tab`},[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(typeof o.to=="string"?"a":"router-link"),t.mergeProps({ref_for:!0},typeof o.to=="string"?{href:o.to}:{to:o.to},{"aria-current":o.active?"page":void 0,class:["tab-link",{active:o.active}],"data-testid":o.dataTestId?o.dataTestId:`page-layout-tab-${o.key}`,tabindex:"0",onClick:t.withModifiers(_=>u(o),["prevent"]),onKeydown:t.withKeys(t.withModifiers(_=>u(o),["prevent"]),["enter"])}),{default:t.withCtx(()=>[t.renderSlot(m.$slots,`tab-${o.key}`,{tab:o},()=>[t.createTextVNode(t.toDisplayString(o.label),1)],!0)]),_:2},1040,["aria-current","class","data-testid","onClick","onKeydown"]))]))),128)),e.tabs.length>s.value?(t.openBlock(),t.createElementBlock("li",Z,[t.createVNode(B,{"kpop-attributes":{placement:"bottom-end",popoverElementAttributes:{"data-testid":"tabs-overflow-dropdown-popover"}}},{items:t.withCtx(()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.value,o=>(t.openBlock(),t.createBlock(T,{key:`${o.key}-dropdown-item`,"aria-current":o.active?"page":void 0,"data-testid":o.dataTestId?o.dataTestId:`page-layout-tab-${o.key}`,item:{label:o.label,value:o.key,to:o.to},selected:o.active},{default:t.withCtx(()=>[t.renderSlot(m.$slots,`tab-${o.key}`,{tab:o},()=>[t.createTextVNode(t.toDisplayString(o.label),1)],!0)]),_:2},1032,["aria-current","data-testid","item","selected"]))),128))]),default:t.withCtx(()=>[t.createElementVNode("button",{"aria-label":t.unref(n)("tabs.more_button.aria_label"),class:t.normalizeClass(["tab-link",{active:l.value.find(o=>o.active)}]),"data-testid":"tabs-overflow-dropdown-button"},[t.createTextVNode(t.toDisplayString(t.unref(n)("tabs.more_button.label"))+" ",1),t.createVNode(t.unref(w.ChevronDownIcon),{decorative:"",size:`var(--kui-icon-size-30, ${t.unref(V)})`},null,8,["size"])],10,H)]),_:3})])):t.createCommentVNode("",!0)],2),p.value?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("div",J,[(t.openBlock(),t.createElementBlock(t.Fragment,null,t.renderList(3,o=>t.createVNode(c,{key:`layout-loader-${o}`,height:"1",width:"5"})),64))]))],512)}}}),I=(e,n)=>{const a=e.__vccOpts||e;for(const[r,u]of n)a[r]=u;return a},X=I(Q,[["__scopeId","data-v-014ad9b1"]]),P=Symbol("nested-page-layout-detection"),Y={class:"kong-ui-public-page-layout","data-testid":"kong-ui-public-page-layout"},v={key:0,class:"page-layout-header","data-testid":"page-layout-header"},tt={class:"page-header-container"},et={class:"page-header-start"},ot={class:"title-container"},at={key:1,class:"page-layout-title-wrapper"},nt={class:"page-layout-title","data-testid":"page-layout-title"},rt=["aria-label"],it={key:3,class:"title-after-container"},ct={key:0,class:"page-header-actions-container"},st=I(t.defineComponent({__name:"PageLayout",props:{breadcrumbs:{default:()=>[]},title:{},backTo:{},tabs:{default:()=>[]},pageShortcutData:{}},setup(e){const n=t.inject("app:navigateTo",null),a=t.inject("app:pageShortcutsContext",null),{i18n:{t:r}}=$.useI18n(),u=S.useRouter(),i=S.useRoute(),f=t.computed(()=>!!(e.tabs&&e.tabs.length)),y=t.computed(()=>typeof e.backTo=="string"),s=t.computed(()=>!!e.pageShortcutData&&!!e.pageShortcutData.entityType&&!!e.pageShortcutData.label),p=t.computed(()=>s.value&&!!a&&"onFavoriteToggle"in a&&typeof a.onFavoriteToggle=="function"),d=t.ref(0),l=t.computed(()=>!!a&&"isFavorite"in a&&typeof a.isFavorite=="function"&&a.isFavorite(e.pageShortcutData)===!0),g=async()=>{if(e.backTo){if(typeof e.backTo=="object"){u.push(e.backTo);return}if(typeof n!="function"){window.location.href=e.backTo;return}await n(e.backTo)}},k=t.ref(0),C=t.computed(()=>k.value>0);t.provide(P,()=>(k.value++,()=>{k.value--}));const m=t.inject(P,null),h=t.ref(null);typeof m=="function"&&(h.value=m());const T=()=>{var c;a.onFavoriteToggle({...e.pageShortcutData,path:((c=e.pageShortcutData)==null?void 0:c.path)||i.fullPath})};t.onUnmounted(()=>{var c;(c=h.value)==null||c.call(h)});const B=A(()=>{var c;!C.value&&s.value&&a&&"onEntityPageVisit"in a&&typeof a.onEntityPageVisit=="function"&&(a.onEntityPageVisit({...e.pageShortcutData,path:((c=e.pageShortcutData)==null?void 0:c.path)||(i==null?void 0:i.fullPath)}),d.value++)},500);return t.watch([()=>e.pageShortcutData,()=>i==null?void 0:i.fullPath],()=>{B()},{immediate:!0,deep:!0}),(c,o)=>{const _=t.resolveComponent("KBreadcrumbs"),lt=t.resolveComponent("KTooltip"),dt=t.resolveComponent("router-view");return t.openBlock(),t.createElementBlock("div",Y,[C.value?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("div",v,[t.createElementVNode("div",tt,[t.createElementVNode("div",et,[e.breadcrumbs&&e.breadcrumbs.length?(t.openBlock(),t.createBlock(_,{key:0,class:"header-breadcrumbs","data-testid":"page-layout-breadcrumbs","item-max-width":"25ch",items:e.breadcrumbs},null,8,["items"])):t.createCommentVNode("",!0),t.createElementVNode("div",ot,[e.backTo?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(y.value?"a":"router-link"),t.mergeProps({key:0},y.value?{href:e.backTo}:{to:e.backTo},{"aria-label":t.unref(r)("back_button"),class:"navigate-back","data-testid":"page-layout-navigate-back",tabindex:"0",onClick:t.withModifiers(g,["prevent"]),onKeydown:t.withKeys(t.withModifiers(g,["prevent"]),["enter"])}),{default:t.withCtx(()=>[t.createVNode(t.unref(w.ArrowTopLeftIcon),{decorative:"",size:`var(--kui-icon-size-30, ${t.unref(V)})`},null,8,["size"])]),_:1},16,["aria-label","onKeydown"])):t.createCommentVNode("",!0),e.title||c.$slots.title?(t.openBlock(),t.createElementBlock("span",at,[t.renderSlot(c.$slots,"title",{},()=>[t.createElementVNode("h1",nt,t.toDisplayString(e.title),1)],!0)])):t.createCommentVNode("",!0),p.value?(t.openBlock(),t.createElementBlock("div",{key:d.value,class:"favorite-button-container"},[t.createVNode(lt,{placement:"right",text:l.value?t.unref(r)("favorite_button.remove_shortcut"):t.unref(r)("favorite_button.save_shortcut")},{default:t.withCtx(()=>[t.createElementVNode("button",{"aria-label":l.value?t.unref(r)("favorite_button.remove_shortcut"):t.unref(r)("favorite_button.save_shortcut"),class:t.normalizeClass(["favorite-button",{active:l.value}]),"data-testid":"page-layout-favorite-button",type:"button",onClick:T},[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(l.value?t.unref(w.StarFillIcon):t.unref(w.StarIcon)),{decorative:"",size:`var(--kui-icon-size-30, ${t.unref(V)})`},null,8,["size"]))],10,rt)]),_:1},8,["text"])])):t.createCommentVNode("",!0),c.$slots["title-after"]?(t.openBlock(),t.createElementBlock("div",it,[t.renderSlot(c.$slots,"title-after",{},void 0,!0)])):t.createCommentVNode("",!0)])]),c.$slots.actions?(t.openBlock(),t.createElementBlock("div",ct,[t.renderSlot(c.$slots,"actions",{},void 0,!0)])):t.createCommentVNode("",!0)]),f.value?(t.openBlock(),t.createBlock(X,{key:0,tabs:e.tabs},t.createSlots({_:2},[t.renderList(e.tabs,x=>({name:`tab-${x.key}`,fn:t.withCtx(ut=>[t.renderSlot(c.$slots,`tab-${x.key}`,t.normalizeProps(t.guardReactiveProps(ut)),void 0,!0)])}))]),1032,["tabs"])):t.createCommentVNode("",!0)])),t.createElementVNode("div",{class:t.normalizeClass(["page-layout-content",{"has-nested-page-layout":C.value}])},[f.value?(t.openBlock(),t.createBlock(dt,{key:0})):t.renderSlot(c.$slots,"default",{key:1},void 0,!0)],2)])}}}),[["__scopeId","data-v-6bd079dc"]]);b.PageLayout=st,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(f,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("vue-router"),require("@kong-ui-public/i18n"),require("@kong/icons")):typeof define=="function"&&define.amd?define(["exports","vue","vue-router","@kong-ui-public/i18n","@kong/icons"],t):(f=typeof globalThis<"u"?globalThis:f||self,t(f["kong-ui-public-page-layout"]={},f.Vue,f.VueRouter,f["kong-ui-public-i18n"],f.KongIcons))})(this,(function(f,t,w,_,T){"use strict";const K={back_button:"Go back",favorite_button:{save_shortcut:"Save page to shortcuts",remove_shortcut:"Remove page from shortcuts"},tabs:{more_button:{label:"More",aria_label:"More tabs"}}};function L(){const e=_.createI18n("en-us",K);return{i18n:e,i18nT:_.i18nTComponent(e)}}const $={useI18n:L},S="16px",z="16px";function R(e,n){return t.getCurrentScope()?(t.onScopeDispose(e,n),!0):!1}const F=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const D=()=>{};function M(e,n){function o(...r){return new Promise((d,i)=>{Promise.resolve(e(()=>n.apply(this,r),{fn:n,thisArg:this,args:r})).then(d).catch(i)})}return o}function O(e,n={}){let o,r,d=D;const i=s=>{clearTimeout(s),d(),d=D};let p;return s=>{const m=t.toValue(e),l=t.toValue(n.maxWait);return o&&i(o),m<=0||l!==void 0&&l<=0?(r&&(i(r),r=void 0),Promise.resolve(s())):new Promise((c,h)=>{d=n.rejectOnCancel?h:c,p=s,l&&!r&&(r=setTimeout(()=>{o&&i(o),r=void 0,c(p())},l)),o=setTimeout(()=>{r&&i(r),r=void 0,c(s())},m)})}}function A(e,n=200,o={}){return M(O(n,o),e)}const j=F?window:void 0;function E(e){var n;const o=t.toValue(e);return(n=o?.$el)!==null&&n!==void 0?n:o}function W(){const e=t.shallowRef(!1),n=t.getCurrentInstance();return n&&t.onMounted(()=>{e.value=!0},n),e}function G(e){const n=W();return t.computed(()=>(n.value,!!e()))}function q(e,n,o={}){const{window:r=j,...d}=o;let i;const p=G(()=>r&&"ResizeObserver"in r),y=()=>{i&&(i.disconnect(),i=void 0)},s=t.watch(t.computed(()=>{const l=t.toValue(e);return Array.isArray(l)?l.map(c=>E(c)):[E(l)]}),l=>{if(y(),p.value&&r){i=new ResizeObserver(n);for(const c of l)c&&i.observe(c,d)}},{immediate:!0,flush:"post"}),m=()=>{y(),s()};return R(m),{isSupported:p,stop:m}}const U={ref:"page-layout-tabs",class:"page-layout-tabs","data-testid":"page-layout-tabs"},Z={key:0},H=["aria-label"],J={key:0,class:"layout-loader-container"},Q=t.defineComponent({__name:"PageLayoutTabs",props:{tabs:{default:()=>[]}},setup(e){t.useCssVars(u=>({v94e59ca2:t.unref(i)}));const{i18n:{t:n}}=$.useI18n(),o=w.useRouter(),r=t.inject("app:navigateTo",null),d=u=>{if(typeof u.to!="string"){o.push(u.to);return}if(typeof r!="function"){window.location.href=u.to;return}r(u.to)},i=z,p=t.useTemplateRef("page-layout-tabs"),y=t.useTemplateRef("page-layout-tabs-list"),s=t.ref(e.tabs.length),m=t.ref(!1),l=t.computed(()=>e.tabs.slice(0,s.value)),c=t.computed(()=>e.tabs.slice(s.value)),h=async()=>{if(!p.value||!y.value)return;m.value=!1,s.value=e.tabs.length,await t.nextTick();const u=p.value?.getBoundingClientRect().width-parseInt(i)*2;let g=y.value?.getBoundingClientRect().width;if(!u||!g){m.value=!0;return}const C=50;for(;g+C>u&&s.value>1;)s.value--,await t.nextTick(),g=y.value?.getBoundingClientRect().width||0;m.value=!0};let k=null;const B=()=>{k&&clearTimeout(k),k=setTimeout(()=>{h()},150)};return t.onMounted(()=>{h(),q(p,B)}),t.onBeforeUnmount(()=>{k&&clearTimeout(k)}),t.watch(()=>e.tabs,()=>{h()},{deep:!0}),(u,g)=>{const C=t.resolveComponent("KDropdownItem"),V=t.resolveComponent("KDropdown"),b=t.resolveComponent("KSkeletonBox");return t.openBlock(),t.createElementBlock("nav",U,[t.createElementVNode("ul",{ref:"page-layout-tabs-list",class:t.normalizeClass({"layout-computing":!m.value})},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.value,a=>(t.openBlock(),t.createElementBlock("li",{key:`${a.key}-tab`},[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(typeof a.to=="string"?"a":"router-link"),t.mergeProps({ref_for:!0},typeof a.to=="string"?{href:a.to}:{to:a.to},{"aria-current":a.active?"page":void 0,class:["tab-link",{active:a.active}],"data-testid":a.dataTestId?a.dataTestId:`page-layout-tab-${a.key}`,tabindex:"0",onClick:t.withModifiers(N=>d(a),["prevent"]),onKeydown:t.withKeys(t.withModifiers(N=>d(a),["prevent"]),["enter"])}),{default:t.withCtx(()=>[t.renderSlot(u.$slots,`tab-${a.key}`,{tab:a},()=>[t.createTextVNode(t.toDisplayString(a.label),1)],!0)]),_:2},1040,["aria-current","class","data-testid","onClick","onKeydown"]))]))),128)),e.tabs.length>s.value?(t.openBlock(),t.createElementBlock("li",Z,[t.createVNode(V,{"kpop-attributes":{placement:"bottom-end",popoverElementAttributes:{"data-testid":"tabs-overflow-dropdown-popover"}}},{items:t.withCtx(()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(c.value,a=>(t.openBlock(),t.createBlock(C,{key:`${a.key}-dropdown-item`,"aria-current":a.active?"page":void 0,"data-testid":a.dataTestId?a.dataTestId:`page-layout-tab-${a.key}`,item:{label:a.label,value:a.key,to:a.to},selected:a.active},{default:t.withCtx(()=>[t.renderSlot(u.$slots,`tab-${a.key}`,{tab:a},()=>[t.createTextVNode(t.toDisplayString(a.label),1)],!0)]),_:2},1032,["aria-current","data-testid","item","selected"]))),128))]),default:t.withCtx(()=>[t.createElementVNode("button",{"aria-label":t.unref(n)("tabs.more_button.aria_label"),class:t.normalizeClass(["tab-link",{active:c.value.find(a=>a.active)}]),"data-testid":"tabs-overflow-dropdown-button"},[t.createTextVNode(t.toDisplayString(t.unref(n)("tabs.more_button.label"))+" ",1),t.createVNode(t.unref(T.ChevronDownIcon),{decorative:"",size:`var(--kui-icon-size-30, ${t.unref(S)})`},null,8,["size"])],10,H)]),_:3})])):t.createCommentVNode("",!0)],2),m.value?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("div",J,[(t.openBlock(),t.createElementBlock(t.Fragment,null,t.renderList(3,a=>t.createVNode(b,{key:`layout-loader-${a}`,height:"1",width:"5"})),64))]))],512)}}}),I=(e,n)=>{const o=e.__vccOpts||e;for(const[r,d]of n)o[r]=d;return o},X=I(Q,[["__scopeId","data-v-014ad9b1"]]),P=Symbol("nested-page-layout-detection"),Y={class:"kong-ui-public-page-layout","data-testid":"kong-ui-public-page-layout"},v={key:0,class:"page-layout-header","data-testid":"page-layout-header"},tt={class:"page-header-container"},et={class:"page-header-start"},ot={class:"title-container"},at={key:1,class:"page-layout-title-wrapper"},nt={class:"page-layout-title","data-testid":"page-layout-title"},rt=["aria-label"],it={key:3,class:"title-after-container"},st={key:0,class:"page-header-actions-container"},ct=I(t.defineComponent({__name:"PageLayout",props:{breadcrumbs:{default:()=>[]},title:{},backTo:{},tabs:{default:()=>[]},pageShortcutData:{}},setup(e){const n=t.inject("app:navigateTo",null),o=t.inject("app:pageShortcutsContext",null),{i18n:{t:r}}=$.useI18n(),d=w.useRouter(),i=w.useRoute(),p=t.computed(()=>!!(e.tabs&&e.tabs.length)),y=t.computed(()=>typeof e.backTo=="string"),s=t.computed(()=>!!e.pageShortcutData&&!!e.pageShortcutData.entityType&&!!e.pageShortcutData.label),m=t.computed(()=>s.value&&!!o&&"onFavoriteToggle"in o&&typeof o.onFavoriteToggle=="function"),l=t.ref(0),c=t.computed(()=>!!o&&"isFavorite"in o&&typeof o.isFavorite=="function"&&o.isFavorite(e.pageShortcutData)===!0),h=async()=>{if(e.backTo){if(typeof e.backTo=="object"){d.push(e.backTo);return}if(typeof n!="function"){window.location.href=e.backTo;return}await n(e.backTo)}},k=t.ref(0),B=t.computed(()=>k.value>0);t.provide(P,()=>(k.value++,()=>{k.value--}));const u=t.inject(P,null),g=t.ref(null);typeof u=="function"&&(g.value=u());const C=()=>{o.onFavoriteToggle({...e.pageShortcutData,path:e.pageShortcutData?.path||i.fullPath})};t.onUnmounted(()=>{g.value?.()});const V=A(()=>{!B.value&&s.value&&o&&"onEntityPageVisit"in o&&typeof o.onEntityPageVisit=="function"&&(o.onEntityPageVisit({...e.pageShortcutData,path:e.pageShortcutData?.path||i?.fullPath}),l.value++)},500);return t.watch([()=>e.pageShortcutData,()=>i?.fullPath],()=>{V()},{immediate:!0,deep:!0}),(b,a)=>{const N=t.resolveComponent("KBreadcrumbs"),lt=t.resolveComponent("KTooltip"),dt=t.resolveComponent("router-view");return t.openBlock(),t.createElementBlock("div",Y,[B.value?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("div",v,[t.createElementVNode("div",tt,[t.createElementVNode("div",et,[e.breadcrumbs&&e.breadcrumbs.length?(t.openBlock(),t.createBlock(N,{key:0,class:"header-breadcrumbs","data-testid":"page-layout-breadcrumbs","item-max-width":"25ch",items:e.breadcrumbs},null,8,["items"])):t.createCommentVNode("",!0),t.createElementVNode("div",ot,[e.backTo?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(y.value?"a":"router-link"),t.mergeProps({key:0},y.value?{href:e.backTo}:{to:e.backTo},{"aria-label":t.unref(r)("back_button"),class:"navigate-back","data-testid":"page-layout-navigate-back",tabindex:"0",onClick:t.withModifiers(h,["prevent"]),onKeydown:t.withKeys(t.withModifiers(h,["prevent"]),["enter"])}),{default:t.withCtx(()=>[t.createVNode(t.unref(T.ArrowTopLeftIcon),{decorative:"",size:`var(--kui-icon-size-30, ${t.unref(S)})`},null,8,["size"])]),_:1},16,["aria-label","onKeydown"])):t.createCommentVNode("",!0),e.title||b.$slots.title?(t.openBlock(),t.createElementBlock("span",at,[t.renderSlot(b.$slots,"title",{},()=>[t.createElementVNode("h1",nt,t.toDisplayString(e.title),1)],!0)])):t.createCommentVNode("",!0),m.value?(t.openBlock(),t.createElementBlock("div",{key:l.value,class:"favorite-button-container"},[t.createVNode(lt,{placement:"right",text:c.value?t.unref(r)("favorite_button.remove_shortcut"):t.unref(r)("favorite_button.save_shortcut")},{default:t.withCtx(()=>[t.createElementVNode("button",{"aria-label":c.value?t.unref(r)("favorite_button.remove_shortcut"):t.unref(r)("favorite_button.save_shortcut"),class:t.normalizeClass(["favorite-button",{active:c.value}]),"data-testid":"page-layout-favorite-button",type:"button",onClick:C},[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(c.value?t.unref(T.StarFillIcon):t.unref(T.StarIcon)),{decorative:"",size:`var(--kui-icon-size-30, ${t.unref(S)})`},null,8,["size"]))],10,rt)]),_:1},8,["text"])])):t.createCommentVNode("",!0),b.$slots["title-after"]?(t.openBlock(),t.createElementBlock("div",it,[t.renderSlot(b.$slots,"title-after",{},void 0,!0)])):t.createCommentVNode("",!0)])]),b.$slots.actions?(t.openBlock(),t.createElementBlock("div",st,[t.renderSlot(b.$slots,"actions",{},void 0,!0)])):t.createCommentVNode("",!0)]),p.value?(t.openBlock(),t.createBlock(X,{key:0,tabs:e.tabs},t.createSlots({_:2},[t.renderList(e.tabs,x=>({name:`tab-${x.key}`,fn:t.withCtx(ut=>[t.renderSlot(b.$slots,`tab-${x.key}`,t.normalizeProps(t.guardReactiveProps(ut)),void 0,!0)])}))]),1032,["tabs"])):t.createCommentVNode("",!0)])),t.createElementVNode("div",{class:t.normalizeClass(["page-layout-content",{"has-nested-page-layout":B.value}])},[p.value?(t.openBlock(),t.createBlock(dt,{key:0})):t.renderSlot(b.$slots,"default",{key:1},void 0,!0)],2)])}}}),[["__scopeId","data-v-6bd079dc"]]);f.PageLayout=ct,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})}));
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.page-layout-tabs[data-v-014ad9b1]{align-items:flex-end;border-bottom:1px solid #e0e4ea;border-bottom:var(--kui-border-width-10, 1px) solid var(--kui-color-border, #e0e4ea);box-sizing:border-box;display:flex;height:34px;overflow-x:clip;padding:0px var(--v94e59ca2);padding:var(--kui-space-0, 0px) var(--v94e59ca2);position:relative;width:100%}.page-layout-tabs a[data-v-014ad9b1],.page-layout-tabs button[data-v-014ad9b1]{background-color:transparent;background-color:var(--kui-color-background-transparent, transparent);border:none;color:inherit;cursor:pointer;outline:none;padding:0;padding:var(--kui-space-0, 0px);text-decoration:none}.page-layout-tabs ul[data-v-014ad9b1]{display:flex;gap:20px;gap:var(--kui-space-70, 20px);list-style:none;margin:0;margin:var(--kui-space-0, 0px);margin-bottom:-1px;margin-bottom:calc(-1 * var(--kui-border-width-10, 1px));max-width:100%;padding:0;padding:var(--kui-space-0, 0px)}.page-layout-tabs ul.layout-computing[data-v-014ad9b1]{height:0;visibility:hidden}.page-layout-tabs ul li[data-v-014ad9b1]{display:flex}.page-layout-tabs ul li .tab-link[data-v-014ad9b1]{align-items:center;border-bottom:2px solid transparent;border-bottom:var(--kui-border-width-20, 2px) solid var(--kui-color-border-transparent, transparent);border-radius:4px 4px 0 0;border-radius:var(--kui-border-radius-20, 4px) var(--kui-border-radius-20, 4px) var(--kui-border-radius-0, 0px) var(--kui-border-radius-0, 0px);color:#52596e;color:var(--kui-color-text-neutral-strong, #52596e);cursor:pointer;display:flex;font-size:12px;font-size:var(--kui-font-size-20, 12px);font-weight:500;font-weight:var(--kui-font-weight-medium, 500);gap:6px;gap:var(--kui-space-30, 6px);line-height:20px;line-height:var(--kui-line-height-30, 20px);padding:6px 0;padding:var(--kui-space-30, 6px) var(--kui-space-0, 0px);text-decoration:none;transition:color .2s ease-in,border-color .2s ease-in,font-weight .2s ease-in;white-space:nowrap}.page-layout-tabs ul li .tab-link[data-v-014ad9b1]:hover{border-bottom:2px solid #afb7c5;border-bottom:var(--kui-border-width-20, 2px) solid var(--kui-color-border-neutral-weak, #afb7c5);color:#000933;color:var(--kui-color-text, #000933);text-decoration:none}.page-layout-tabs ul li .tab-link[data-v-014ad9b1]:focus-visible{box-shadow:0 0 0 4px #0044f433;box-shadow:var(--kui-shadow-focus, 0px 0px 0px 4px rgba(0, 68, 244, .2));text-decoration:none}.page-layout-tabs ul li .tab-link.active[data-v-014ad9b1]{border-bottom:2px solid #0044f4;border-bottom:var(--kui-border-width-20, 2px) solid var(--kui-color-border-primary, #0044f4);color:#0044f4!important;color:var(--kui-color-text-primary, #0044f4)!important;font-weight:600;font-weight:var(--kui-font-weight-semibold, 600);text-decoration:none}.page-layout-tabs .layout-loader-container[data-v-014ad9b1]{align-items:center;display:flex;gap:20px;gap:var(--kui-space-70, 20px);height:34px;
|
|
1
|
+
.page-layout-tabs[data-v-014ad9b1]{align-items:flex-end;border-bottom:1px solid #e0e4ea;border-bottom:var(--kui-border-width-10, 1px) solid var(--kui-color-border, #e0e4ea);box-sizing:border-box;display:flex;height:34px;overflow-x:clip;padding:0px var(--v94e59ca2);padding:var(--kui-space-0, 0px) var(--v94e59ca2);position:relative;width:100%}.page-layout-tabs a[data-v-014ad9b1],.page-layout-tabs button[data-v-014ad9b1]{background-color:transparent;background-color:var(--kui-color-background-transparent, transparent);border:none;color:inherit;cursor:pointer;outline:none;padding:0;padding:var(--kui-space-0, 0px);text-decoration:none}.page-layout-tabs ul[data-v-014ad9b1]{display:flex;gap:20px;gap:var(--kui-space-70, 20px);list-style:none;margin:0;margin:var(--kui-space-0, 0px);margin-bottom:-1px;margin-bottom:calc(-1 * var(--kui-border-width-10, 1px));max-width:100%;padding:0;padding:var(--kui-space-0, 0px)}.page-layout-tabs ul.layout-computing[data-v-014ad9b1]{height:0;visibility:hidden}.page-layout-tabs ul li[data-v-014ad9b1]{display:flex}.page-layout-tabs ul li .tab-link[data-v-014ad9b1]{align-items:center;border-bottom:2px solid transparent;border-bottom:var(--kui-border-width-20, 2px) solid var(--kui-color-border-transparent, transparent);border-radius:4px 4px 0 0;border-radius:var(--kui-border-radius-20, 4px) var(--kui-border-radius-20, 4px) var(--kui-border-radius-0, 0px) var(--kui-border-radius-0, 0px);color:#52596e;color:var(--kui-color-text-neutral-strong, #52596e);cursor:pointer;display:flex;font-size:12px;font-size:var(--kui-font-size-20, 12px);font-weight:500;font-weight:var(--kui-font-weight-medium, 500);gap:6px;gap:var(--kui-space-30, 6px);line-height:20px;line-height:var(--kui-line-height-30, 20px);padding:6px 0;padding:var(--kui-space-30, 6px) var(--kui-space-0, 0px);text-decoration:none;transition:color .2s ease-in,border-color .2s ease-in,font-weight .2s ease-in;white-space:nowrap}.page-layout-tabs ul li .tab-link[data-v-014ad9b1]:hover{border-bottom:2px solid #afb7c5;border-bottom:var(--kui-border-width-20, 2px) solid var(--kui-color-border-neutral-weak, #afb7c5);color:#000933;color:var(--kui-color-text, #000933);text-decoration:none}.page-layout-tabs ul li .tab-link[data-v-014ad9b1]:focus-visible{box-shadow:0 0 0 4px #0044f433;box-shadow:var(--kui-shadow-focus, 0px 0px 0px 4px rgba(0, 68, 244, .2));text-decoration:none}.page-layout-tabs ul li .tab-link.active[data-v-014ad9b1]{border-bottom:2px solid #0044f4;border-bottom:var(--kui-border-width-20, 2px) solid var(--kui-color-border-primary, #0044f4);color:#0044f4!important;color:var(--kui-color-text-primary, #0044f4)!important;font-weight:600;font-weight:var(--kui-font-weight-semibold, 600);text-decoration:none}.page-layout-tabs .layout-loader-container[data-v-014ad9b1]{align-items:center;display:flex;gap:20px;gap:var(--kui-space-70, 20px);height:34px;inset:0;left:var(--v94e59ca2);position:absolute}.kong-ui-public-page-layout[data-v-6bd079dc]{box-sizing:border-box;font-family:Inter,Roboto,Helvetica,sans-serif;font-family:var(--kui-font-family-text, "Inter", Roboto, Helvetica, sans-serif)}.kong-ui-public-page-layout .page-layout-header[data-v-6bd079dc]{background-color:#fff;background-color:var(--kui-color-background, #ffffff);display:flex;flex-direction:column;gap:8px;gap:var(--kui-space-40, 8px)}.kong-ui-public-page-layout .page-layout-header .page-header-container[data-v-6bd079dc]{align-items:flex-end;display:flex;gap:6px;gap:var(--kui-space-30, 6px);justify-content:space-between;padding:16px 16px 0;padding:var(--kui-space-60, 16px) var(--kui-space-60, 16px) var(--kui-space-0, 0px) var(--kui-space-60, 16px)}.kong-ui-public-page-layout .page-layout-header .page-header-container .page-header-start .header-breadcrumbs[data-v-6bd079dc] .breadcrumbs-item-container:first-child .breadcrumbs-item{padding-left:0;padding-left:var(--kui-space-0, 0px)}.kong-ui-public-page-layout .page-layout-header .page-header-container .page-header-start .header-breadcrumbs[data-v-6bd079dc] .breadcrumbs-item-container .breadcrumbs-item.active .breadcrumbs-text{color:#6c7489;color:var(--kui-color-text-neutral, #6c7489)}.kong-ui-public-page-layout .page-layout-header .page-header-container .page-header-start .title-container[data-v-6bd079dc]{align-items:flex-end;display:flex;gap:4px;gap:var(--kui-space-20, 4px)}.kong-ui-public-page-layout .page-layout-header .page-header-container .page-header-start .title-container .navigate-back[data-v-6bd079dc],.kong-ui-public-page-layout .page-layout-header .page-header-container .page-header-start .title-container .favorite-button[data-v-6bd079dc]{background-color:transparent;background-color:var(--kui-color-background-transparent, transparent);border:none;border-radius:4px;border-radius:var(--kui-border-radius-20, 4px);color:#6c7489;color:var(--kui-color-text-neutral, #6c7489);cursor:pointer;outline:none;padding:4px;padding:var(--kui-space-20, 4px);transition:background-color .2s ease-in,color .2s ease-in}.kong-ui-public-page-layout .page-layout-header .page-header-container .page-header-start .title-container .navigate-back[data-v-6bd079dc]:hover,.kong-ui-public-page-layout .page-layout-header .page-header-container .page-header-start .title-container .favorite-button[data-v-6bd079dc]:hover{color:#000933;color:var(--kui-color-text, #000933)}.kong-ui-public-page-layout .page-layout-header .page-header-container .page-header-start .title-container .navigate-back[data-v-6bd079dc]:focus-visible,.kong-ui-public-page-layout .page-layout-header .page-header-container .page-header-start .title-container .favorite-button[data-v-6bd079dc]:focus-visible{box-shadow:0 0 0 4px #0044f433;box-shadow:var(--kui-shadow-focus, 0px 0px 0px 4px rgba(0, 68, 244, .2))}.kong-ui-public-page-layout .page-layout-header .page-header-container .page-header-start .title-container .page-layout-title-wrapper[data-v-6bd079dc]>*{color:#000933;color:var(--kui-color-text, #000933);font-size:18px;font-size:var(--kui-font-size-50, 18px);font-weight:600;font-weight:var(--kui-font-weight-semibold, 600);line-height:24px;line-height:var(--kui-line-height-40, 24px);margin:0;margin:var(--kui-space-0, 0px)}.kong-ui-public-page-layout .page-layout-header .page-header-container .page-header-start .title-container .favorite-button-container[data-v-6bd079dc]{align-self:center;display:flex;margin-left:4px;margin-left:var(--kui-space-20, 4px)}.kong-ui-public-page-layout .page-layout-header .page-header-container .page-header-start .title-container .favorite-button-container .favorite-button[data-v-6bd079dc]{color:#afb7c5;color:var(--kui-color-text-neutral-weak, #afb7c5);padding:0;padding:var(--kui-space-0, 0px)}.kong-ui-public-page-layout .page-layout-header .page-header-container .page-header-start .title-container .favorite-button-container .favorite-button[data-v-6bd079dc]:hover{color:#6c7489;color:var(--kui-color-text-neutral, #6c7489)}.kong-ui-public-page-layout .page-layout-header .page-header-container .page-header-start .title-container .favorite-button-container .favorite-button.active[data-v-6bd079dc]{color:#ffc400;color:var(--kui-color-text-warning-weak, #ffc400)}.kong-ui-public-page-layout .page-layout-header .page-header-container .page-header-start .title-container .title-after-container[data-v-6bd079dc]{align-items:flex-end;display:flex;gap:6px;gap:var(--kui-space-30, 6px);margin-left:4px;margin-left:var(--kui-space-20, 4px)}.kong-ui-public-page-layout .page-layout-header .page-header-container .page-header-actions-container[data-v-6bd079dc]{align-items:center;display:flex;gap:6px;gap:var(--kui-space-30, 6px)}.kong-ui-public-page-layout .page-layout-header:not(:has(.page-layout-tabs)) .page-header-container[data-v-6bd079dc]{border-bottom:1px solid #e0e4ea;border-bottom:var(--kui-border-width-10, 1px) solid var(--kui-color-border, #e0e4ea);padding:16px;padding:var(--kui-space-60, 16px)}.kong-ui-public-page-layout .page-layout-content[data-v-6bd079dc]{background-color:#f9fafb;background-color:var(--kui-color-background-neutral-weakest, #f9fafb);display:flex;flex-direction:column;gap:12px;gap:var(--kui-space-50, 12px);padding:16px;padding:var(--kui-space-60, 16px)}.kong-ui-public-page-layout .page-layout-content.has-nested-page-layout[data-v-6bd079dc]{padding:0;padding:var(--kui-space-0, 0px)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kong-ui-public/page-layout",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/page-layout.umd.js",
|
|
6
6
|
"module": "./dist/page-layout.es.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@kong/kongponents": "9.60.7",
|
|
27
27
|
"vue": "^3.5.35",
|
|
28
28
|
"vue-router": "^5.1.0",
|
|
29
|
-
"@kong-ui-public/i18n": "^2.
|
|
29
|
+
"@kong-ui-public/i18n": "^2.5.0"
|
|
30
30
|
},
|
|
31
31
|
"repository": {
|
|
32
32
|
"type": "git",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@kong/kongponents": "^9.59.0",
|
|
51
51
|
"vue": "^3.5.35",
|
|
52
52
|
"vue-router": "^4.6.4 || ^5.0.6",
|
|
53
|
-
"@kong-ui-public/i18n": "^2.
|
|
53
|
+
"@kong-ui-public/i18n": "^2.5.0"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@vueuse/core": "^14.3.0"
|