@kiva/kv-components 6.21.0 → 6.22.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/vue/KvSideSheet.js +164 -144
- package/package.json +2 -2
package/dist/vue/KvSideSheet.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { toRefs as
|
|
2
|
-
import { mdiArrowLeft as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
const
|
|
1
|
+
import { toRefs as P, ref as u, reactive as Q, computed as z, onMounted as Y, onUnmounted as j, watch as p, resolveComponent as Z, openBlock as k, createElementBlock as b, normalizeClass as x, withModifiers as $, createElementVNode as f, normalizeStyle as W, createVNode as _, createCommentVNode as S, toDisplayString as ee, renderSlot as U, nextTick as te } from "vue";
|
|
2
|
+
import { mdiArrowLeft as oe, mdiClose as ne, mdiExportVariant as ie } from "@mdi/js";
|
|
3
|
+
import le from "./KvMaterialIcon.js";
|
|
4
|
+
import ae from "../_virtual/_plugin-vue_export-helper.js";
|
|
5
|
+
const se = {
|
|
6
|
+
name: "KvSideSheet",
|
|
6
7
|
components: {
|
|
7
|
-
KvMaterialIcon:
|
|
8
|
+
KvMaterialIcon: le
|
|
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
|
-
} =
|
|
86
|
+
} = P(l), w = u(!1), B = u({}), s = u({}), L = u(null), m = u(null), y = u(null), A = u(null), M = u(window.innerHeight), D = u(window.innerWidth), v = Q({
|
|
86
87
|
headline: 0,
|
|
87
88
|
controls: 0
|
|
88
|
-
}),
|
|
89
|
-
const e =
|
|
89
|
+
}), G = 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
|
+
}), X = (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
|
+
te(() => {
|
|
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
|
+
}, R = X(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
|
+
w.value ? document.body.classList.add(e) : document.body.classList.remove(e);
|
|
127
|
+
}, F = () => {
|
|
128
|
+
w.value = !1, O(), V.value(K.value, "click", "side-sheet-closed"), setTimeout(() => {
|
|
129
|
+
a("side-sheet-closed");
|
|
130
|
+
}, 300), document.removeEventListener("keyup", H);
|
|
131
|
+
}, q = () => {
|
|
132
|
+
a("go-to-link");
|
|
133
|
+
}, H = (e) => {
|
|
134
|
+
(e == null ? void 0 : e.key) === "Escape" && F();
|
|
126
135
|
};
|
|
127
|
-
|
|
136
|
+
Y(() => {
|
|
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(R);
|
|
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(R);
|
|
145
|
+
e.observe(y.value), j(() => e.disconnect());
|
|
137
146
|
}
|
|
138
|
-
window.addEventListener("resize",
|
|
139
|
-
}),
|
|
147
|
+
window.addEventListener("resize", R), j(() => window.removeEventListener("resize", R));
|
|
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
|
|
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 J = 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
|
+
w.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, T = (o == null ? void 0 : o.height) ?? 0;
|
|
166
|
+
o && (d || g || c || T) && (B.value = {
|
|
163
167
|
position: "fixed",
|
|
164
|
-
top: `${
|
|
165
|
-
width: `${
|
|
166
|
-
height: `${
|
|
167
|
-
|
|
168
|
-
|
|
168
|
+
top: `${d}px`,
|
|
169
|
+
width: `${c}px`,
|
|
170
|
+
height: `${T}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
|
+
w.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
|
+
w.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,139 @@ 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, T) => {
|
|
214
|
+
const N = ["sm", "md", "lg", "xl", "2xl"];
|
|
215
|
+
return N.indexOf(c) - N.indexOf(T);
|
|
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
|
+
w.value && I();
|
|
230
|
+
}, { immediate: !0 }), p(w, (e) => {
|
|
231
|
+
e && I();
|
|
215
232
|
}), {
|
|
216
|
-
closeSideSheet:
|
|
217
|
-
contentHeight:
|
|
233
|
+
closeSideSheet: F,
|
|
234
|
+
contentHeight: G,
|
|
218
235
|
controlsRef: m,
|
|
219
|
-
headlineRef:
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
236
|
+
headlineRef: y,
|
|
237
|
+
contentRef: A,
|
|
238
|
+
sideSheetRef: L,
|
|
239
|
+
sideSheetStyles: J,
|
|
240
|
+
goToLink: q,
|
|
241
|
+
mdiArrowLeft: oe,
|
|
242
|
+
mdiClose: ne,
|
|
243
|
+
mdiExportVariant: ie,
|
|
244
|
+
modalStyles: s,
|
|
245
|
+
open: w
|
|
228
246
|
};
|
|
229
247
|
}
|
|
230
|
-
},
|
|
231
|
-
function
|
|
232
|
-
const
|
|
233
|
-
return
|
|
248
|
+
}, re = { class: "tw-flex tw-gap-1.5" }, de = { key: 1 }, ce = { class: "tw-flex tw-gap-1.5" };
|
|
249
|
+
function ue(l, a, r, t, V, K) {
|
|
250
|
+
const h = Z("kv-material-icon");
|
|
251
|
+
return r.visible ? (k(), b("div", {
|
|
234
252
|
key: 0,
|
|
235
|
-
class:
|
|
253
|
+
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
254
|
"tw-bg-opacity-0 tw-delay-300": !t.open,
|
|
237
255
|
"tw-bg-opacity-low": t.open
|
|
238
256
|
}]),
|
|
239
|
-
onClick:
|
|
257
|
+
onClick: a[3] || (a[3] = $((...i) => t.closeSideSheet && t.closeSideSheet(...i), ["self"]))
|
|
240
258
|
}, [
|
|
241
|
-
|
|
259
|
+
f("div", {
|
|
242
260
|
ref: "sideSheetRef",
|
|
243
|
-
class:
|
|
244
|
-
"tw-
|
|
245
|
-
"tw-
|
|
261
|
+
class: x(["tw-fixed tw-right-0 tw-transition-all tw-duration-300 tw-bg-white tw-overflow-y-auto", {
|
|
262
|
+
"tw-translate-x-full": !t.open,
|
|
263
|
+
"tw-translate-x-0": t.open,
|
|
246
264
|
"tw-h-full": l.$slots.controls
|
|
247
265
|
}]),
|
|
248
|
-
style:
|
|
266
|
+
style: W(t.sideSheetStyles)
|
|
249
267
|
}, [
|
|
250
|
-
|
|
268
|
+
f("div", {
|
|
251
269
|
class: "tw-flex tw-flex-col tw-h-full",
|
|
252
|
-
style:
|
|
270
|
+
style: W(t.modalStyles)
|
|
253
271
|
}, [
|
|
254
|
-
|
|
272
|
+
f("div", {
|
|
255
273
|
ref: "headlineRef",
|
|
256
|
-
class:
|
|
274
|
+
class: x(["tw-flex tw-justify-between tw-transition-opacity tw-duration-200 tw-px-3 tw-py-2 tw-border-tertiary", {
|
|
257
275
|
"tw-opacity-0": !t.open,
|
|
258
276
|
"tw-opacity-full": t.open,
|
|
259
|
-
"tw-border-b":
|
|
277
|
+
"tw-border-b": r.showHeadlineBorder
|
|
260
278
|
}])
|
|
261
279
|
}, [
|
|
262
|
-
|
|
263
|
-
|
|
280
|
+
f("div", re, [
|
|
281
|
+
r.showBackButton ? (k(), b("button", {
|
|
264
282
|
key: 0,
|
|
265
283
|
class: "hover:tw-text-action-highlight tw-flex tw-items-center tw-justify-center",
|
|
266
|
-
onClick:
|
|
284
|
+
onClick: a[0] || (a[0] = (...i) => t.closeSideSheet && t.closeSideSheet(...i))
|
|
267
285
|
}, [
|
|
268
|
-
|
|
286
|
+
_(h, {
|
|
269
287
|
class: "tw-w-3 tw-h-3",
|
|
270
288
|
icon: t.mdiArrowLeft
|
|
271
289
|
}, null, 8, ["icon"])
|
|
272
|
-
])) :
|
|
273
|
-
|
|
290
|
+
])) : S("", !0),
|
|
291
|
+
r.headline ? (k(), b("h2", de, ee(r.headline), 1)) : S("", !0)
|
|
274
292
|
]),
|
|
275
|
-
|
|
276
|
-
|
|
293
|
+
f("div", ce, [
|
|
294
|
+
r.showGoToLink ? (k(), b("button", {
|
|
277
295
|
key: 0,
|
|
278
296
|
class: "hover:tw-text-action-highlight tw-flex tw-items-center tw-justify-center",
|
|
279
|
-
onClick:
|
|
297
|
+
onClick: a[1] || (a[1] = (...i) => t.goToLink && t.goToLink(...i))
|
|
280
298
|
}, [
|
|
281
|
-
|
|
299
|
+
_(h, {
|
|
282
300
|
class: "tw-w-3 tw-h-3",
|
|
283
301
|
icon: t.mdiExportVariant
|
|
284
302
|
}, null, 8, ["icon"])
|
|
285
|
-
])) :
|
|
286
|
-
|
|
303
|
+
])) : S("", !0),
|
|
304
|
+
f("button", {
|
|
287
305
|
class: "hover:tw-text-action-highlight tw-flex tw-items-center tw-justify-center",
|
|
288
|
-
onClick:
|
|
306
|
+
onClick: a[2] || (a[2] = (...i) => t.closeSideSheet && t.closeSideSheet(...i))
|
|
289
307
|
}, [
|
|
290
|
-
|
|
308
|
+
_(h, {
|
|
291
309
|
class: "tw-w-3 tw-h-3",
|
|
292
310
|
icon: t.mdiClose
|
|
293
311
|
}, null, 8, ["icon"])
|
|
294
312
|
])
|
|
295
313
|
])
|
|
296
314
|
], 2),
|
|
297
|
-
|
|
315
|
+
f("div", {
|
|
316
|
+
id: "sidesheet-content",
|
|
317
|
+
ref: "contentRef",
|
|
298
318
|
class: "tw-overflow-y-auto tw-overscroll-y-contain",
|
|
299
|
-
style:
|
|
319
|
+
style: W({ height: t.contentHeight + "px" })
|
|
300
320
|
}, [
|
|
301
|
-
|
|
302
|
-
class:
|
|
321
|
+
f("div", {
|
|
322
|
+
class: x(["tw-p-2 tw-transition-opacity tw-duration-200", {
|
|
303
323
|
"tw-opacity-0": !t.open,
|
|
304
324
|
"tw-opacity-full": t.open
|
|
305
325
|
}])
|
|
306
326
|
}, [
|
|
307
|
-
|
|
327
|
+
U(l.$slots, "default")
|
|
308
328
|
], 2)
|
|
309
329
|
], 4),
|
|
310
|
-
l.$slots.controls ? (
|
|
330
|
+
l.$slots.controls ? (k(), b("div", {
|
|
311
331
|
key: 0,
|
|
312
332
|
ref: "controlsRef",
|
|
313
|
-
class:
|
|
333
|
+
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
334
|
"tw-opacity-0": !t.open,
|
|
315
335
|
"tw-opacity-full": t.open
|
|
316
336
|
}]),
|
|
317
337
|
style: { "z-index": "999" }
|
|
318
338
|
}, [
|
|
319
|
-
|
|
320
|
-
], 2)) :
|
|
339
|
+
U(l.$slots, "controls")
|
|
340
|
+
], 2)) : S("", !0)
|
|
321
341
|
], 4)
|
|
322
342
|
], 6)
|
|
323
|
-
], 2)) :
|
|
343
|
+
], 2)) : S("", !0);
|
|
324
344
|
}
|
|
325
|
-
const
|
|
345
|
+
const me = /* @__PURE__ */ ae(se, [["render", ue]]);
|
|
326
346
|
export {
|
|
327
|
-
|
|
347
|
+
me as default
|
|
328
348
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kiva/kv-components",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.22.0",
|
|
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": "a966746cbca329047a6c7f63f3a91af56857d7fb"
|
|
115
115
|
}
|