@kiva/kv-components 6.21.0 → 6.21.1
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/vue/KvSideSheet.js +159 -142
- package/package.json +2 -2
package/dist/vue/KvSideSheet.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { toRefs as J, ref as w, reactive as P, computed as
|
|
2
|
-
import { mdiArrowLeft as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
const
|
|
1
|
+
import { toRefs as J, ref as w, reactive as P, computed as z, onMounted as Q, onUnmounted as j, watch as p, resolveComponent as Y, openBlock as k, createElementBlock as b, normalizeClass as x, withModifiers as Z, createElementVNode as f, normalizeStyle as W, createVNode as _, createCommentVNode as S, toDisplayString as $, renderSlot as U, nextTick as ee } from "vue";
|
|
2
|
+
import { mdiArrowLeft as te, mdiClose as oe, mdiExportVariant as ne } from "@mdi/js";
|
|
3
|
+
import ie from "./KvMaterialIcon.js";
|
|
4
|
+
import le from "../_virtual/_plugin-vue_export-helper.js";
|
|
5
|
+
const ae = {
|
|
6
|
+
name: "KvSideSheet",
|
|
6
7
|
components: {
|
|
7
|
-
KvMaterialIcon:
|
|
8
|
+
KvMaterialIcon: ie
|
|
8
9
|
},
|
|
9
10
|
props: {
|
|
10
11
|
/**
|
|
@@ -71,119 +72,135 @@ const ne = {
|
|
|
71
72
|
widthDimensions: {
|
|
72
73
|
type: [String, Object],
|
|
73
74
|
default: () => ({ default: "100%", md: "50%" }),
|
|
74
|
-
validator: (l) => typeof l == "string" ? /^(\d+px|[\d.]+%|auto|inherit|initial)$/.test(l) : typeof l == "object" ? Object.keys(l).every((
|
|
75
|
+
validator: (l) => typeof l == "string" ? /^(\d+px|[\d.]+%|auto|inherit|initial)$/.test(l) : typeof l == "object" ? Object.keys(l).every((a) => ["default", "sm", "md", "lg", "xl", "2xl"].includes(a) && /^(\d+px|[\d.]+%|auto|inherit|initial)$/.test(l[a])) : !1
|
|
75
76
|
}
|
|
76
77
|
},
|
|
77
78
|
emits: ["side-sheet-closed", "go-to-link"],
|
|
78
|
-
setup(l, { emit:
|
|
79
|
+
setup(l, { emit: a, slots: r }) {
|
|
79
80
|
const {
|
|
80
81
|
visible: t,
|
|
81
|
-
kvTrackFunction:
|
|
82
|
+
kvTrackFunction: V,
|
|
82
83
|
trackEventCategory: K,
|
|
83
|
-
animationSourceElement:
|
|
84
|
+
animationSourceElement: h,
|
|
84
85
|
widthDimensions: i
|
|
85
|
-
} = J(l),
|
|
86
|
+
} = J(l), u = w(!1), B = w({}), s = w({}), L = w(null), m = w(null), y = w(null), M = w(window.innerHeight), D = w(window.innerWidth), v = P({
|
|
86
87
|
headline: 0,
|
|
87
88
|
controls: 0
|
|
88
|
-
}),
|
|
89
|
-
const e =
|
|
89
|
+
}), A = z(() => {
|
|
90
|
+
const e = M.value - v.headline - v.controls;
|
|
90
91
|
return Math.max(e, 0);
|
|
91
|
-
}),
|
|
92
|
+
}), C = z(() => {
|
|
93
|
+
if (typeof i.value == "string")
|
|
94
|
+
return i.value;
|
|
95
|
+
const e = {
|
|
96
|
+
sm: 640,
|
|
97
|
+
md: 768,
|
|
98
|
+
lg: 1024,
|
|
99
|
+
xl: 1280,
|
|
100
|
+
"2xl": 1536
|
|
101
|
+
}, n = D.value || window.innerWidth, o = Object.keys(i.value).filter((d) => d !== "default").sort((d, g) => e[g] - e[d]).find((d) => n >= e[d]);
|
|
102
|
+
return o ? i.value[o] : i.value.default || "100%";
|
|
103
|
+
}), G = (e, n) => {
|
|
92
104
|
let o;
|
|
93
|
-
return (...
|
|
94
|
-
clearTimeout(o), o = setTimeout(() => e(...
|
|
105
|
+
return (...d) => {
|
|
106
|
+
clearTimeout(o), o = setTimeout(() => e(...d), n);
|
|
95
107
|
};
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
|
|
108
|
+
}, E = () => {
|
|
109
|
+
M.value = window.innerHeight, D.value = window.innerWidth, setTimeout(() => {
|
|
110
|
+
ee(() => {
|
|
99
111
|
var e;
|
|
100
|
-
if (
|
|
101
|
-
const n =
|
|
102
|
-
|
|
112
|
+
if (y.value) {
|
|
113
|
+
const n = y.value.getBoundingClientRect();
|
|
114
|
+
v.headline = n.height;
|
|
103
115
|
} else
|
|
104
|
-
|
|
105
|
-
if ((e =
|
|
116
|
+
v.headline = 0;
|
|
117
|
+
if ((e = r.controls) != null && e.call(r) && m.value) {
|
|
106
118
|
const n = m.value.getBoundingClientRect();
|
|
107
|
-
|
|
119
|
+
v.controls = n.height;
|
|
108
120
|
} else
|
|
109
|
-
|
|
121
|
+
v.controls = 0;
|
|
110
122
|
});
|
|
111
123
|
}, 300);
|
|
112
|
-
},
|
|
124
|
+
}, T = G(E, 100), O = () => {
|
|
113
125
|
const e = "tw-overflow-hidden";
|
|
114
|
-
|
|
115
|
-
},
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
s("go-to-link");
|
|
124
|
-
}, j = (e) => {
|
|
125
|
-
(e == null ? void 0 : e.key) === "Escape" && M();
|
|
126
|
+
u.value ? document.body.classList.add(e) : document.body.classList.remove(e);
|
|
127
|
+
}, F = () => {
|
|
128
|
+
u.value = !1, O(), V.value(K.value, "click", "side-sheet-closed"), setTimeout(() => {
|
|
129
|
+
a("side-sheet-closed");
|
|
130
|
+
}, 300), document.removeEventListener("keyup", H);
|
|
131
|
+
}, X = () => {
|
|
132
|
+
a("go-to-link");
|
|
133
|
+
}, H = (e) => {
|
|
134
|
+
(e == null ? void 0 : e.key) === "Escape" && F();
|
|
126
135
|
};
|
|
127
136
|
Q(() => {
|
|
128
137
|
if (setTimeout(() => {
|
|
129
|
-
|
|
138
|
+
E();
|
|
130
139
|
}, 100), m.value) {
|
|
131
|
-
const e = new ResizeObserver(
|
|
132
|
-
e.observe(m.value),
|
|
140
|
+
const e = new ResizeObserver(T);
|
|
141
|
+
e.observe(m.value), j(() => e.disconnect());
|
|
133
142
|
}
|
|
134
|
-
if (
|
|
135
|
-
const e = new ResizeObserver(
|
|
136
|
-
e.observe(
|
|
143
|
+
if (y.value) {
|
|
144
|
+
const e = new ResizeObserver(T);
|
|
145
|
+
e.observe(y.value), j(() => e.disconnect());
|
|
137
146
|
}
|
|
138
|
-
window.addEventListener("resize",
|
|
139
|
-
}),
|
|
147
|
+
window.addEventListener("resize", T), j(() => window.removeEventListener("resize", T));
|
|
148
|
+
}), p(() => {
|
|
140
149
|
var e;
|
|
141
|
-
return (e =
|
|
150
|
+
return (e = r.controls) == null ? void 0 : e.call(r);
|
|
142
151
|
}, () => {
|
|
143
152
|
setTimeout(() => {
|
|
144
|
-
|
|
153
|
+
E();
|
|
145
154
|
}, 100);
|
|
146
155
|
}, { deep: !0, immediate: !0 });
|
|
147
|
-
const q =
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
return { width: i.value };
|
|
152
|
-
const n = ["sm", "md", "lg", "xl", "2xl"].find((o) => i.value[o]);
|
|
153
|
-
return { width: i.value[n] || i.value.default || "100%" };
|
|
154
|
-
});
|
|
155
|
-
R([t, i], ([e]) => {
|
|
156
|
+
const q = z(() => ({
|
|
157
|
+
width: C.value
|
|
158
|
+
}));
|
|
159
|
+
p(t, (e) => {
|
|
156
160
|
var n;
|
|
157
161
|
if (e) {
|
|
158
|
-
document.addEventListener("keyup",
|
|
159
|
-
|
|
160
|
-
},
|
|
161
|
-
const o = (n =
|
|
162
|
-
|
|
162
|
+
document.addEventListener("keyup", H), s.value = {}, setTimeout(() => {
|
|
163
|
+
u.value = !0, O(), E();
|
|
164
|
+
}, 10);
|
|
165
|
+
const o = (n = h.value) == null ? void 0 : n.getBoundingClientRect(), d = (o == null ? void 0 : o.top) ?? 0, g = (o == null ? void 0 : o.left) ?? 0, c = (o == null ? void 0 : o.width) ?? 0, R = (o == null ? void 0 : o.height) ?? 0;
|
|
166
|
+
o && (d || g || c || R) && (B.value = {
|
|
163
167
|
position: "fixed",
|
|
164
|
-
top: `${
|
|
165
|
-
width: `${
|
|
166
|
-
height: `${
|
|
167
|
-
|
|
168
|
-
|
|
168
|
+
top: `${d}px`,
|
|
169
|
+
width: `${c}px`,
|
|
170
|
+
height: `${R}px`,
|
|
171
|
+
transform: `translateX(${C.value})`
|
|
172
|
+
}, s.value = {
|
|
173
|
+
...B.value,
|
|
169
174
|
transition: "none"
|
|
170
175
|
}, setTimeout(() => {
|
|
171
|
-
|
|
176
|
+
s.value = {
|
|
172
177
|
top: "0",
|
|
178
|
+
width: C.value,
|
|
173
179
|
height: "100%",
|
|
174
|
-
|
|
180
|
+
transform: "translateX(0)",
|
|
181
|
+
transition: "all 0.3s ease-in-out"
|
|
175
182
|
};
|
|
176
|
-
}, 10))
|
|
177
|
-
height: "100%"
|
|
178
|
-
};
|
|
183
|
+
}, 10));
|
|
179
184
|
} else
|
|
180
|
-
|
|
181
|
-
...
|
|
182
|
-
transition: "all 0.
|
|
183
|
-
} : {};
|
|
185
|
+
u.value = !1, O(), document.removeEventListener("keyup", H), h.value && Object.keys(B.value).length > 0 ? s.value = {
|
|
186
|
+
...B.value,
|
|
187
|
+
transition: "all 0.3s ease-in-out"
|
|
188
|
+
} : s.value = {};
|
|
189
|
+
}, { immediate: !0 }), p(C, (e) => {
|
|
190
|
+
u.value && t.value && s.value && Object.keys(s.value).length > 0 && (s.value = {
|
|
191
|
+
...s.value,
|
|
192
|
+
width: e,
|
|
193
|
+
transition: "none"
|
|
194
|
+
// No animation for resize
|
|
195
|
+
}, setTimeout(() => {
|
|
196
|
+
s.value && Object.keys(s.value).length > 0 && (s.value = {
|
|
197
|
+
...s.value,
|
|
198
|
+
transition: "all 0.3s ease-in-out"
|
|
199
|
+
});
|
|
200
|
+
}, 50));
|
|
184
201
|
});
|
|
185
|
-
const
|
|
186
|
-
if (typeof i.value == "object" &&
|
|
202
|
+
const I = () => {
|
|
203
|
+
if (typeof i.value == "object" && L.value) {
|
|
187
204
|
const e = "side-sheet-styles";
|
|
188
205
|
let n = document.getElementById(e);
|
|
189
206
|
n || (n = document.createElement("style"), n.id = e, document.head.appendChild(n));
|
|
@@ -193,136 +210,136 @@ const ne = {
|
|
|
193
210
|
lg: "1024px",
|
|
194
211
|
xl: "1280px",
|
|
195
212
|
"2xl": "1536px"
|
|
196
|
-
},
|
|
197
|
-
const
|
|
198
|
-
return
|
|
199
|
-
}).map((
|
|
200
|
-
@media (min-width: ${o[
|
|
213
|
+
}, g = Object.keys(i.value).filter((c) => c !== "default").sort((c, R) => {
|
|
214
|
+
const N = ["sm", "md", "lg", "xl", "2xl"];
|
|
215
|
+
return N.indexOf(c) - N.indexOf(R);
|
|
216
|
+
}).map((c) => `
|
|
217
|
+
@media (min-width: ${o[c]}) {
|
|
201
218
|
#side-sheet-${l.trackEventCategory || "default"} {
|
|
202
|
-
width: ${i.value[
|
|
219
|
+
width: ${i.value[c]} !important;
|
|
203
220
|
}
|
|
204
221
|
}
|
|
205
222
|
`).join("");
|
|
206
|
-
n.textContent =
|
|
223
|
+
n.textContent = g, L.value.id = `side-sheet-${l.trackEventCategory || "default"}`, j(() => {
|
|
207
224
|
n && n.remove();
|
|
208
225
|
});
|
|
209
226
|
}
|
|
210
227
|
};
|
|
211
|
-
return
|
|
212
|
-
|
|
213
|
-
}, { immediate: !0 }),
|
|
214
|
-
e &&
|
|
228
|
+
return p(i, () => {
|
|
229
|
+
u.value && I();
|
|
230
|
+
}, { immediate: !0 }), p(u, (e) => {
|
|
231
|
+
e && I();
|
|
215
232
|
}), {
|
|
216
|
-
closeSideSheet:
|
|
217
|
-
contentHeight:
|
|
233
|
+
closeSideSheet: F,
|
|
234
|
+
contentHeight: A,
|
|
218
235
|
controlsRef: m,
|
|
219
|
-
headlineRef:
|
|
220
|
-
sideSheetRef:
|
|
236
|
+
headlineRef: y,
|
|
237
|
+
sideSheetRef: L,
|
|
221
238
|
sideSheetStyles: q,
|
|
222
|
-
goToLink:
|
|
223
|
-
mdiArrowLeft:
|
|
224
|
-
mdiClose:
|
|
225
|
-
mdiExportVariant:
|
|
226
|
-
modalStyles:
|
|
227
|
-
open:
|
|
239
|
+
goToLink: X,
|
|
240
|
+
mdiArrowLeft: te,
|
|
241
|
+
mdiClose: oe,
|
|
242
|
+
mdiExportVariant: ne,
|
|
243
|
+
modalStyles: s,
|
|
244
|
+
open: u
|
|
228
245
|
};
|
|
229
246
|
}
|
|
230
|
-
},
|
|
231
|
-
function
|
|
232
|
-
const
|
|
233
|
-
return
|
|
247
|
+
}, se = { class: "tw-flex tw-gap-1.5" }, re = { key: 1 }, de = { class: "tw-flex tw-gap-1.5" };
|
|
248
|
+
function ce(l, a, r, t, V, K) {
|
|
249
|
+
const h = Y("kv-material-icon");
|
|
250
|
+
return r.visible ? (k(), b("div", {
|
|
234
251
|
key: 0,
|
|
235
|
-
class:
|
|
252
|
+
class: x(["tw-block lg:tw-mt-0 tw-fixed tw-inset-0 tw-bg-black tw-transition-all md:tw-duration-150 tw-z-modal", {
|
|
236
253
|
"tw-bg-opacity-0 tw-delay-300": !t.open,
|
|
237
254
|
"tw-bg-opacity-low": t.open
|
|
238
255
|
}]),
|
|
239
|
-
onClick:
|
|
256
|
+
onClick: a[3] || (a[3] = Z((...i) => t.closeSideSheet && t.closeSideSheet(...i), ["self"]))
|
|
240
257
|
}, [
|
|
241
|
-
|
|
258
|
+
f("div", {
|
|
242
259
|
ref: "sideSheetRef",
|
|
243
|
-
class:
|
|
244
|
-
"tw-
|
|
245
|
-
"tw-
|
|
260
|
+
class: x(["tw-fixed tw-right-0 tw-transition-all tw-duration-300 tw-bg-white tw-overflow-y-auto", {
|
|
261
|
+
"tw-translate-x-full": !t.open,
|
|
262
|
+
"tw-translate-x-0": t.open,
|
|
246
263
|
"tw-h-full": l.$slots.controls
|
|
247
264
|
}]),
|
|
248
|
-
style:
|
|
265
|
+
style: W(t.sideSheetStyles)
|
|
249
266
|
}, [
|
|
250
|
-
|
|
267
|
+
f("div", {
|
|
251
268
|
class: "tw-flex tw-flex-col tw-h-full",
|
|
252
|
-
style:
|
|
269
|
+
style: W(t.modalStyles)
|
|
253
270
|
}, [
|
|
254
|
-
|
|
271
|
+
f("div", {
|
|
255
272
|
ref: "headlineRef",
|
|
256
|
-
class:
|
|
273
|
+
class: x(["tw-flex tw-justify-between tw-transition-opacity tw-duration-200 tw-px-3 tw-py-2 tw-border-tertiary", {
|
|
257
274
|
"tw-opacity-0": !t.open,
|
|
258
275
|
"tw-opacity-full": t.open,
|
|
259
|
-
"tw-border-b":
|
|
276
|
+
"tw-border-b": r.showHeadlineBorder
|
|
260
277
|
}])
|
|
261
278
|
}, [
|
|
262
|
-
|
|
263
|
-
|
|
279
|
+
f("div", se, [
|
|
280
|
+
r.showBackButton ? (k(), b("button", {
|
|
264
281
|
key: 0,
|
|
265
282
|
class: "hover:tw-text-action-highlight tw-flex tw-items-center tw-justify-center",
|
|
266
|
-
onClick:
|
|
283
|
+
onClick: a[0] || (a[0] = (...i) => t.closeSideSheet && t.closeSideSheet(...i))
|
|
267
284
|
}, [
|
|
268
|
-
|
|
285
|
+
_(h, {
|
|
269
286
|
class: "tw-w-3 tw-h-3",
|
|
270
287
|
icon: t.mdiArrowLeft
|
|
271
288
|
}, null, 8, ["icon"])
|
|
272
|
-
])) :
|
|
273
|
-
|
|
289
|
+
])) : S("", !0),
|
|
290
|
+
r.headline ? (k(), b("h2", re, $(r.headline), 1)) : S("", !0)
|
|
274
291
|
]),
|
|
275
|
-
|
|
276
|
-
|
|
292
|
+
f("div", de, [
|
|
293
|
+
r.showGoToLink ? (k(), b("button", {
|
|
277
294
|
key: 0,
|
|
278
295
|
class: "hover:tw-text-action-highlight tw-flex tw-items-center tw-justify-center",
|
|
279
|
-
onClick:
|
|
296
|
+
onClick: a[1] || (a[1] = (...i) => t.goToLink && t.goToLink(...i))
|
|
280
297
|
}, [
|
|
281
|
-
|
|
298
|
+
_(h, {
|
|
282
299
|
class: "tw-w-3 tw-h-3",
|
|
283
300
|
icon: t.mdiExportVariant
|
|
284
301
|
}, null, 8, ["icon"])
|
|
285
|
-
])) :
|
|
286
|
-
|
|
302
|
+
])) : S("", !0),
|
|
303
|
+
f("button", {
|
|
287
304
|
class: "hover:tw-text-action-highlight tw-flex tw-items-center tw-justify-center",
|
|
288
|
-
onClick:
|
|
305
|
+
onClick: a[2] || (a[2] = (...i) => t.closeSideSheet && t.closeSideSheet(...i))
|
|
289
306
|
}, [
|
|
290
|
-
|
|
307
|
+
_(h, {
|
|
291
308
|
class: "tw-w-3 tw-h-3",
|
|
292
309
|
icon: t.mdiClose
|
|
293
310
|
}, null, 8, ["icon"])
|
|
294
311
|
])
|
|
295
312
|
])
|
|
296
313
|
], 2),
|
|
297
|
-
|
|
314
|
+
f("div", {
|
|
298
315
|
class: "tw-overflow-y-auto tw-overscroll-y-contain",
|
|
299
|
-
style:
|
|
316
|
+
style: W({ height: t.contentHeight + "px" })
|
|
300
317
|
}, [
|
|
301
|
-
|
|
302
|
-
class:
|
|
318
|
+
f("div", {
|
|
319
|
+
class: x(["tw-p-2 tw-transition-opacity tw-duration-200", {
|
|
303
320
|
"tw-opacity-0": !t.open,
|
|
304
321
|
"tw-opacity-full": t.open
|
|
305
322
|
}])
|
|
306
323
|
}, [
|
|
307
|
-
|
|
324
|
+
U(l.$slots, "default")
|
|
308
325
|
], 2)
|
|
309
326
|
], 4),
|
|
310
|
-
l.$slots.controls ? (
|
|
327
|
+
l.$slots.controls ? (k(), b("div", {
|
|
311
328
|
key: 0,
|
|
312
329
|
ref: "controlsRef",
|
|
313
|
-
class:
|
|
330
|
+
class: x(["tw-absolute tw-bottom-0 tw-w-full tw-border-t tw-border-tertiary tw-bg-white tw-transition-opacity tw-duration-200", {
|
|
314
331
|
"tw-opacity-0": !t.open,
|
|
315
332
|
"tw-opacity-full": t.open
|
|
316
333
|
}]),
|
|
317
334
|
style: { "z-index": "999" }
|
|
318
335
|
}, [
|
|
319
|
-
|
|
320
|
-
], 2)) :
|
|
336
|
+
U(l.$slots, "controls")
|
|
337
|
+
], 2)) : S("", !0)
|
|
321
338
|
], 4)
|
|
322
339
|
], 6)
|
|
323
|
-
], 2)) :
|
|
340
|
+
], 2)) : S("", !0);
|
|
324
341
|
}
|
|
325
|
-
const
|
|
342
|
+
const ve = /* @__PURE__ */ le(ae, [["render", ce]]);
|
|
326
343
|
export {
|
|
327
|
-
|
|
344
|
+
ve as default
|
|
328
345
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kiva/kv-components",
|
|
3
|
-
"version": "6.21.
|
|
3
|
+
"version": "6.21.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -111,5 +111,5 @@
|
|
|
111
111
|
"embla-carousel-fade",
|
|
112
112
|
"popper.js"
|
|
113
113
|
],
|
|
114
|
-
"gitHead": "
|
|
114
|
+
"gitHead": "aa646dc5aeb545bca9a0dc5a574bebc9e438a4d2"
|
|
115
115
|
}
|