@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.
@@ -1,10 +1,11 @@
1
- import { toRefs as J, ref as w, reactive as P, computed as I, onMounted as Q, onUnmounted as E, watch as R, resolveComponent as W, openBlock as g, createElementBlock as p, normalizeClass as k, withModifiers as X, createElementVNode as c, normalizeStyle as H, createVNode as z, createCommentVNode as x, toDisplayString as Y, renderSlot as N, nextTick as Z } from "vue";
2
- import { mdiArrowLeft as $, mdiClose as ee, mdiExportVariant as te } from "@mdi/js";
3
- import oe from "./KvMaterialIcon.js";
4
- import ie from "../_virtual/_plugin-vue_export-helper.js";
5
- const ne = {
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: oe
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((s) => ["default", "sm", "md", "lg", "xl", "2xl"].includes(s) && /^(\d+px|[\d.]+%|auto|inherit|initial)$/.test(l[s])) : !1
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: s, slots: a }) {
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: u,
84
+ animationSourceElement: h,
84
85
  widthDimensions: i
85
- } = J(l), d = w(!1), b = w({}), f = w({}), T = w(null), m = w(null), v = w(null), V = w(window.innerHeight), h = P({
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
- }), U = I(() => {
89
- const e = V.value - h.headline - h.controls;
89
+ }), G = z(() => {
90
+ const e = M.value - v.headline - v.controls;
90
91
  return Math.max(e, 0);
91
- }), A = (e, n) => {
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 (...y) => {
94
- clearTimeout(o), o = setTimeout(() => e(...y), n);
105
+ return (...d) => {
106
+ clearTimeout(o), o = setTimeout(() => e(...d), n);
95
107
  };
96
- }, S = () => {
97
- V.value = window.innerHeight, setTimeout(() => {
98
- Z(() => {
108
+ }, E = () => {
109
+ M.value = window.innerHeight, D.value = window.innerWidth, setTimeout(() => {
110
+ te(() => {
99
111
  var e;
100
- if (v.value) {
101
- const n = v.value.getBoundingClientRect();
102
- h.headline = n.height;
112
+ if (y.value) {
113
+ const n = y.value.getBoundingClientRect();
114
+ v.headline = n.height;
103
115
  } else
104
- h.headline = 0;
105
- if ((e = a.controls) != null && e.call(a) && m.value) {
116
+ v.headline = 0;
117
+ if ((e = r.controls) != null && e.call(r) && m.value) {
106
118
  const n = m.value.getBoundingClientRect();
107
- h.controls = n.height;
119
+ v.controls = n.height;
108
120
  } else
109
- h.controls = 0;
121
+ v.controls = 0;
110
122
  });
111
123
  }, 300);
112
- }, B = A(S, 100), L = () => {
124
+ }, R = X(E, 100), O = () => {
113
125
  const e = "tw-overflow-hidden";
114
- d.value ? document.body.classList.add(e) : document.body.classList.remove(e);
115
- }, M = () => {
116
- d.value = !1, L(), _.value(K.value, "click", "side-sheet-closed"), u.value && (f.value = {
117
- ...b.value,
118
- transition: "all 0.5s ease-in-out"
119
- }), setTimeout(() => {
120
- s("side-sheet-closed");
121
- }, 700), document.removeEventListener("keyup", j);
122
- }, G = () => {
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
- Q(() => {
136
+ Y(() => {
128
137
  if (setTimeout(() => {
129
- S();
138
+ E();
130
139
  }, 100), m.value) {
131
- const e = new ResizeObserver(B);
132
- e.observe(m.value), E(() => e.disconnect());
140
+ const e = new ResizeObserver(R);
141
+ e.observe(m.value), j(() => e.disconnect());
133
142
  }
134
- if (v.value) {
135
- const e = new ResizeObserver(B);
136
- e.observe(v.value), E(() => e.disconnect());
143
+ if (y.value) {
144
+ const e = new ResizeObserver(R);
145
+ e.observe(y.value), j(() => e.disconnect());
137
146
  }
138
- window.addEventListener("resize", B), E(() => window.removeEventListener("resize", B));
139
- }), R(() => {
147
+ window.addEventListener("resize", R), j(() => window.removeEventListener("resize", R));
148
+ }), p(() => {
140
149
  var e;
141
- return (e = a.controls) == null ? void 0 : e.call(a);
150
+ return (e = r.controls) == null ? void 0 : e.call(r);
142
151
  }, () => {
143
152
  setTimeout(() => {
144
- S();
153
+ E();
145
154
  }, 100);
146
155
  }, { deep: !0, immediate: !0 });
147
- const q = I(() => {
148
- if (!d.value)
149
- return {};
150
- if (typeof i.value == "string")
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", j), setTimeout(() => {
159
- d.value = !0, L(), S();
160
- }, 100);
161
- const o = (n = u.value) == null ? void 0 : n.getBoundingClientRect(), y = (o == null ? void 0 : o.top) ?? 0, O = (o == null ? void 0 : o.left) ?? 0, r = (o == null ? void 0 : o.width) ?? 0, C = (o == null ? void 0 : o.height) ?? 0;
162
- y || O || r || C ? (b.value = {
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: `${y}px`,
165
- width: `${r}px`,
166
- height: `${C}px`
167
- }, f.value = {
168
- ...b.value,
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
- f.value = {
176
+ s.value = {
172
177
  top: "0",
178
+ width: C.value,
173
179
  height: "100%",
174
- transition: "all 0.5s ease-in-out"
180
+ transform: "translateX(0)",
181
+ transition: "all 0.3s ease-in-out"
175
182
  };
176
- }, 10)) : f.value = {
177
- height: "100%"
178
- };
183
+ }, 10));
179
184
  } else
180
- d.value = !1, L(), document.removeEventListener("keyup", j), f.value = u.value ? {
181
- ...b.value,
182
- transition: "all 0.5s ease-in-out"
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 D = () => {
186
- if (typeof i.value == "object" && T.value) {
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
- }, O = Object.keys(i.value).filter((r) => r !== "default").sort((r, C) => {
197
- const F = ["sm", "md", "lg", "xl", "2xl"];
198
- return F.indexOf(r) - F.indexOf(C);
199
- }).map((r) => `
200
- @media (min-width: ${o[r]}) {
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[r]} !important;
219
+ width: ${i.value[c]} !important;
203
220
  }
204
221
  }
205
222
  `).join("");
206
- n.textContent = O, T.value.id = `side-sheet-${l.trackEventCategory || "default"}`, E(() => {
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 R(i, () => {
212
- d.value && D();
213
- }, { immediate: !0 }), R(d, (e) => {
214
- e && D();
228
+ return p(i, () => {
229
+ w.value && I();
230
+ }, { immediate: !0 }), p(w, (e) => {
231
+ e && I();
215
232
  }), {
216
- closeSideSheet: M,
217
- contentHeight: U,
233
+ closeSideSheet: F,
234
+ contentHeight: G,
218
235
  controlsRef: m,
219
- headlineRef: v,
220
- sideSheetRef: T,
221
- sideSheetStyles: q,
222
- goToLink: G,
223
- mdiArrowLeft: $,
224
- mdiClose: ee,
225
- mdiExportVariant: te,
226
- modalStyles: f,
227
- open: d
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
- }, le = { class: "tw-flex tw-gap-1.5" }, se = { key: 1 }, ae = { class: "tw-flex tw-gap-1.5" };
231
- function re(l, s, a, t, _, K) {
232
- const u = W("kv-material-icon");
233
- return a.visible ? (g(), p("div", {
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: k(["tw-block lg:tw-mt-0 tw-fixed tw-inset-0 tw-bg-black tw-transition-all md:tw-duration-150 tw-z-modal", {
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: s[3] || (s[3] = X((...i) => t.closeSideSheet && t.closeSideSheet(...i), ["self"]))
257
+ onClick: a[3] || (a[3] = $((...i) => t.closeSideSheet && t.closeSideSheet(...i), ["self"]))
240
258
  }, [
241
- c("div", {
259
+ f("div", {
242
260
  ref: "sideSheetRef",
243
- class: k(["tw-fixed tw-right-0 tw-transition-all tw-duration-300 tw-bg-white tw-overflow-y-auto", {
244
- "tw-w-0 tw-delay-200 tw-opacity-0": !t.open,
245
- "tw-opacity-full": t.open,
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: H(t.sideSheetStyles)
266
+ style: W(t.sideSheetStyles)
249
267
  }, [
250
- c("div", {
268
+ f("div", {
251
269
  class: "tw-flex tw-flex-col tw-h-full",
252
- style: H(t.modalStyles)
270
+ style: W(t.modalStyles)
253
271
  }, [
254
- c("div", {
272
+ f("div", {
255
273
  ref: "headlineRef",
256
- class: k(["tw-flex tw-justify-between tw-transition-opacity tw-duration-200 tw-px-3 tw-py-2 tw-border-tertiary", {
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": a.showHeadlineBorder
277
+ "tw-border-b": r.showHeadlineBorder
260
278
  }])
261
279
  }, [
262
- c("div", le, [
263
- a.showBackButton ? (g(), p("button", {
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: s[0] || (s[0] = (...i) => t.closeSideSheet && t.closeSideSheet(...i))
284
+ onClick: a[0] || (a[0] = (...i) => t.closeSideSheet && t.closeSideSheet(...i))
267
285
  }, [
268
- z(u, {
286
+ _(h, {
269
287
  class: "tw-w-3 tw-h-3",
270
288
  icon: t.mdiArrowLeft
271
289
  }, null, 8, ["icon"])
272
- ])) : x("", !0),
273
- a.headline ? (g(), p("h2", se, Y(a.headline), 1)) : x("", !0)
290
+ ])) : S("", !0),
291
+ r.headline ? (k(), b("h2", de, ee(r.headline), 1)) : S("", !0)
274
292
  ]),
275
- c("div", ae, [
276
- a.showGoToLink ? (g(), p("button", {
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: s[1] || (s[1] = (...i) => t.goToLink && t.goToLink(...i))
297
+ onClick: a[1] || (a[1] = (...i) => t.goToLink && t.goToLink(...i))
280
298
  }, [
281
- z(u, {
299
+ _(h, {
282
300
  class: "tw-w-3 tw-h-3",
283
301
  icon: t.mdiExportVariant
284
302
  }, null, 8, ["icon"])
285
- ])) : x("", !0),
286
- c("button", {
303
+ ])) : S("", !0),
304
+ f("button", {
287
305
  class: "hover:tw-text-action-highlight tw-flex tw-items-center tw-justify-center",
288
- onClick: s[2] || (s[2] = (...i) => t.closeSideSheet && t.closeSideSheet(...i))
306
+ onClick: a[2] || (a[2] = (...i) => t.closeSideSheet && t.closeSideSheet(...i))
289
307
  }, [
290
- z(u, {
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
- c("div", {
315
+ f("div", {
316
+ id: "sidesheet-content",
317
+ ref: "contentRef",
298
318
  class: "tw-overflow-y-auto tw-overscroll-y-contain",
299
- style: H({ height: t.contentHeight + "px" })
319
+ style: W({ height: t.contentHeight + "px" })
300
320
  }, [
301
- c("div", {
302
- class: k(["tw-p-2 tw-transition-opacity tw-duration-200", {
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
- N(l.$slots, "default")
327
+ U(l.$slots, "default")
308
328
  ], 2)
309
329
  ], 4),
310
- l.$slots.controls ? (g(), p("div", {
330
+ l.$slots.controls ? (k(), b("div", {
311
331
  key: 0,
312
332
  ref: "controlsRef",
313
- class: k(["tw-absolute tw-bottom-0 tw-w-full tw-border-t tw-border-tertiary tw-bg-white tw-transition-opacity tw-duration-200", {
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
- N(l.$slots, "controls")
320
- ], 2)) : x("", !0)
339
+ U(l.$slots, "controls")
340
+ ], 2)) : S("", !0)
321
341
  ], 4)
322
342
  ], 6)
323
- ], 2)) : x("", !0);
343
+ ], 2)) : S("", !0);
324
344
  }
325
- const fe = /* @__PURE__ */ ie(ne, [["render", re]]);
345
+ const me = /* @__PURE__ */ ae(se, [["render", ue]]);
326
346
  export {
327
- fe as default
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.21.0",
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": "f15221e0afa6a6f02148a46f9f563e60c01fd0e8"
114
+ "gitHead": "a966746cbca329047a6c7f63f3a91af56857d7fb"
115
115
  }