@webitel/ui-sdk 26.8.49 → 26.8.50

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,4 +1,4 @@
1
- import "./components-gG_-DJ10.js";
1
+ import "./components-2ISVk3oW.js";
2
2
  import { t as e } from "./_plugin-vue_export-helper-B3ysoDQm.js";
3
3
  import { l as t } from "./enums-De8CDKZ1.js";
4
4
  import { t as n } from "./wt-button-B7B7qITq.js";
@@ -3,8 +3,8 @@ import { d as t, f as n, l as r, r as i } from "./enums-De8CDKZ1.js";
3
3
  import { a, i as o, n as s, r as c, t as l } from "./toZonedTime-B8L5kbse.js";
4
4
  import { t as u } from "./vue-i18n-Db_oYfO8.js";
5
5
  import { t as d } from "./useValidation-D6P-wRwq.js";
6
- import { computed as f, createBlock as p, createCommentVNode as m, createElementBlock as h, createElementVNode as g, createTextVNode as _, createVNode as v, defineComponent as y, guardReactiveProps as b, mergeModels as x, mergeProps as S, nextTick as C, normalizeProps as w, onMounted as T, onUnmounted as E, openBlock as D, renderSlot as O, resolveComponent as k, toDisplayString as A, toRefs as j, unref as M, useModel as N, useTemplateRef as ee, vShow as te, withCtx as P, withDirectives as F } from "vue";
7
- import I from "primevue/datepicker";
6
+ import { computed as f, createBlock as p, createCommentVNode as m, createElementBlock as h, createElementVNode as g, createTextVNode as _, createVNode as v, defineComponent as y, guardReactiveProps as b, mergeModels as x, mergeProps as S, nextTick as C, normalizeProps as w, onMounted as T, onUnmounted as E, openBlock as D, renderSlot as O, resolveComponent as k, toDisplayString as A, toRefs as j, unref as M, useModel as N, useTemplateRef as P, vShow as F, withCtx as I, withDirectives as ee } from "vue";
7
+ import te from "primevue/datepicker";
8
8
  //#region node_modules/date-fns-tz/dist/esm/fromZonedTime/index.js
9
9
  function L(e, t, n) {
10
10
  if (typeof e == "string" && !e.match(c)) return s(e, {
@@ -55,8 +55,29 @@ function R(e) {
55
55
  };
56
56
  }
57
57
  //#endregion
58
+ //#region src/components/wt-datepicker/_internals/composables/useCloseOnAnchorHidden.ts
59
+ function z(e, t) {
60
+ let n = null;
61
+ function r() {
62
+ i();
63
+ let r = e();
64
+ r && (n = new IntersectionObserver((e) => {
65
+ if (!e.some((e) => !e.isIntersecting)) return;
66
+ let n = t();
67
+ n && (n.overlayVisible = !1);
68
+ }), n.observe(r));
69
+ }
70
+ function i() {
71
+ n?.disconnect(), n = null;
72
+ }
73
+ return E(i), {
74
+ watch: r,
75
+ unwatch: i
76
+ };
77
+ }
78
+ //#endregion
58
79
  //#region src/components/wt-datepicker/_internals/composables/useOverlayAnchor.ts
59
- function z() {
80
+ function B() {
60
81
  let e = null;
61
82
  function t(e, t) {
62
83
  e.style.width !== t && (e.style.width = t, e.style.minWidth = "");
@@ -84,7 +105,7 @@ function z() {
84
105
  }
85
106
  //#endregion
86
107
  //#region src/components/wt-datepicker/_internals/composables/usePreventZeroPad.ts
87
- function B() {
108
+ function V() {
88
109
  let e = null;
89
110
  function t(t) {
90
111
  let n = t.target, r = n.value, i = n.selectionStart ?? 0, a = r.split("/"), o = 0;
@@ -112,7 +133,7 @@ function B() {
112
133
  }
113
134
  //#endregion
114
135
  //#region src/components/wt-datepicker/_internals/composables/useRestoreOnBlur.ts
115
- function V(e, t) {
136
+ function H(e, t) {
116
137
  function n() {
117
138
  if (t()) return;
118
139
  let n = e();
@@ -124,7 +145,7 @@ function V(e, t) {
124
145
  }
125
146
  //#endregion
126
147
  //#region src/components/wt-datepicker/_internals/composables/useStrictInput.ts
127
- function H(e) {
148
+ function U(e) {
128
149
  let t = /^[0-9]$/, n = /* @__PURE__ */ new Set([
129
150
  "Backspace",
130
151
  "Delete",
@@ -151,45 +172,51 @@ function H(e) {
151
172
  }
152
173
  //#endregion
153
174
  //#region src/components/wt-datepicker/_internals/composables/useDatepicker.ts
154
- function U(e, t, n, r) {
155
- let { onInputCapture: i, onInputBubble: a } = B(), { onInputBubble: o, resetLength: s } = R(n), { onKeydown: c } = H(n), { lock: l, unlock: u } = z(), { onBlur: d } = V(t, r);
156
- function f(e) {
175
+ function W(e, t, n, r) {
176
+ let { onInputCapture: i, onInputBubble: a } = V(), { onInputBubble: o, resetLength: s } = R(n), { onKeydown: c } = U(n), { lock: l, unlock: u } = B(), { watch: d, unwatch: f } = z(e, t), { onBlur: p } = H(t, r);
177
+ function m(e) {
178
+ l(e), d();
179
+ }
180
+ function h() {
181
+ u(), f();
182
+ }
183
+ function g(e) {
157
184
  i(e);
158
185
  }
159
- function p(e) {
186
+ function _(e) {
160
187
  a(e), o(e);
161
188
  }
162
189
  return T(() => {
163
190
  let t = e();
164
- t && (s(t), t.addEventListener("input", f, { capture: !0 }), t.addEventListener("input", p), t.addEventListener("keydown", c));
191
+ t && (s(t), t.addEventListener("input", g, { capture: !0 }), t.addEventListener("input", _), t.addEventListener("keydown", c));
165
192
  }), E(() => {
166
193
  let t = e();
167
- t && (t.removeEventListener("input", f, { capture: !0 }), t.removeEventListener("input", p), t.removeEventListener("keydown", c));
194
+ t && (t.removeEventListener("input", g, { capture: !0 }), t.removeEventListener("input", _), t.removeEventListener("keydown", c));
168
195
  }), {
169
- onBlur: d,
170
- lockOverlay: l,
171
- unlockOverlay: u
196
+ onBlur: p,
197
+ lockOverlay: m,
198
+ unlockOverlay: h
172
199
  };
173
200
  }
174
201
  //#endregion
175
202
  //#region src/components/wt-datepicker/wt-datepicker.vue?vue&type=script&setup=true&lang.ts
176
- var W = { class: "wt-datepicker" }, G = { class: "wt-datepicker__button-bar" }, K = [
203
+ var G = { class: "wt-datepicker" }, K = { class: "wt-datepicker__button-bar" }, q = [
177
204
  "onMousedown",
178
205
  "onMouseup",
179
206
  "onMouseleave"
180
- ], q = [
207
+ ], J = [
181
208
  "onMousedown",
182
209
  "onMouseup",
183
210
  "onMouseleave"
184
- ], J = [
211
+ ], Y = [
185
212
  "onMousedown",
186
213
  "onMouseup",
187
214
  "onMouseleave"
188
- ], Y = [
215
+ ], X = [
189
216
  "onMousedown",
190
217
  "onMouseup",
191
218
  "onMouseleave"
192
- ], X = /*#__PURE__*/ e(/* @__PURE__ */ y({
219
+ ], Z = /*#__PURE__*/ e(/* @__PURE__ */ y({
193
220
  __name: "wt-datepicker",
194
221
  props: /*@__PURE__*/ x({
195
222
  showTime: { type: Boolean },
@@ -307,7 +334,7 @@ var W = { class: "wt-datepicker" }, G = { class: "wt-datepicker__button-bar" },
307
334
  let t = o.timezone ? L(e, o.timezone) : e;
308
335
  s.value = t.getTime();
309
336
  }
310
- }), x = ee("datepicker"), T = (e) => e, E = `datepicker-${Math.random().toString(36).slice(2, 11)}`, { onBlur: R, lockOverlay: z, unlockOverlay: B } = U(() => x.value?.$el?.querySelector("input") ?? null, () => x.value ?? null, () => !!o.showTime, () => !!o.clearable), V = f(() => o.placholder || `dd/mm/yyyy ${o.showTime ? "hh:mm" : ""}`), H = () => {
337
+ }), x = P("datepicker"), T = (e) => e, E = `datepicker-${Math.random().toString(36).slice(2, 11)}`, { onBlur: R, lockOverlay: z, unlockOverlay: B } = W(() => x.value?.$el?.querySelector("input") ?? null, () => x.value ?? null, () => !!o.showTime, () => !!o.clearable), V = f(() => o.placholder || `dd/mm/yyyy ${o.showTime ? "hh:mm" : ""}`), H = () => {
311
338
  if (o.showTime && y.value) {
312
339
  let e = y.value;
313
340
  C(() => {
@@ -319,7 +346,7 @@ var W = { class: "wt-datepicker" }, G = { class: "wt-datepicker__button-bar" },
319
346
  let e = x.value?.overlay;
320
347
  e && (e.style.minWidth = "", z(e));
321
348
  }, 0);
322
- }, X = () => {
349
+ }, U = () => {
323
350
  B();
324
351
  }, Z = f(() => o.required ? `${o.label}*` : o.label), { v: ne, customValidators: re, regleValidation: ie } = j(o), { isValidation: ae, invalid: Q, validationText: $, validationTextColor: oe } = d({
325
352
  v: ne,
@@ -328,15 +355,15 @@ var W = { class: "wt-datepicker" }, G = { class: "wt-datepicker__button-bar" },
328
355
  });
329
356
  return (a, o) => {
330
357
  let s = k("wt-label"), l = k("wt-button"), u = k("wt-icon-btn"), d = k("wt-message");
331
- return D(), h("div", W, [
358
+ return D(), h("div", G, [
332
359
  v(s, S(e.labelProps, { disabled: e.disabled }, {
333
360
  for: E,
334
361
  invalid: M(Q)
335
362
  }), {
336
- default: P(() => [O(a.$slots, "label", w(b({ label: e.label })), () => [_(A(Z.value), 1)], !0)], void 0, !0),
363
+ default: I(() => [O(a.$slots, "label", w(b({ label: e.label })), () => [_(A(Z.value), 1)], !0)], void 0, !0),
337
364
  _: 3
338
365
  }, 16, ["disabled", "invalid"]),
339
- v(M(I), {
366
+ v(M(te), {
340
367
  ref_key: "datepicker",
341
368
  ref: x,
342
369
  id: E,
@@ -364,69 +391,69 @@ var W = { class: "wt-datepicker" }, G = { class: "wt-datepicker__button-bar" },
364
391
  panel: { style: { maxWidth: "380px" } }
365
392
  },
366
393
  onShow: H,
367
- onHide: X,
394
+ onHide: U,
368
395
  onBlur: M(R)
369
396
  }, {
370
- buttonbar: P(({ todayCallback: i, clearCallback: a }) => [g("div", G, [v(l, {
397
+ buttonbar: I(({ todayCallback: i, clearCallback: a }) => [g("div", K, [v(l, {
371
398
  color: M(n).SECONDARY,
372
399
  variant: M(t).OUTLINED,
373
400
  size: M(r).SM,
374
401
  onClick: i
375
402
  }, {
376
- default: P(() => [_(A(M(c)("reusable.today")), 1)], void 0, !0),
403
+ default: I(() => [_(A(M(c)("reusable.today")), 1)], void 0, !0),
377
404
  _: 1
378
405
  }, 8, [
379
406
  "color",
380
407
  "variant",
381
408
  "size",
382
409
  "onClick"
383
- ]), F(v(l, {
410
+ ]), ee(v(l, {
384
411
  color: M(n).SECONDARY,
385
412
  variant: M(t).OUTLINED,
386
413
  size: M(r).SM,
387
414
  onClick: a
388
415
  }, {
389
- default: P(() => [_(A(M(c)("reusable.clear")), 1)], void 0, !0),
416
+ default: I(() => [_(A(M(c)("reusable.clear")), 1)], void 0, !0),
390
417
  _: 1
391
418
  }, 8, [
392
419
  "color",
393
420
  "variant",
394
421
  "size",
395
422
  "onClick"
396
- ]), [[te, e.clearable && y.value]])])]),
397
- prevbutton: P(({ actionCallback: e }) => [v(u, {
423
+ ]), [[F, e.clearable && y.value]])])]),
424
+ prevbutton: I(({ actionCallback: e }) => [v(u, {
398
425
  icon: "arrow-left",
399
426
  onClick: e
400
427
  }, null, 8, ["onClick"])]),
401
- nextbutton: P(({ actionCallback: e }) => [v(u, {
428
+ nextbutton: I(({ actionCallback: e }) => [v(u, {
402
429
  icon: "arrow-right",
403
430
  onClick: e
404
431
  }, null, 8, ["onClick"])]),
405
- clearicon: P(({ clearCallback: e }) => [v(u, {
432
+ clearicon: I(({ clearCallback: e }) => [v(u, {
406
433
  icon: "close",
407
434
  class: "wt-datepicker__clear-icon",
408
435
  onClick: e
409
436
  }, null, 8, ["onClick"])]),
410
- hourincrementbutton: P(({ callbacks: e }) => [g("span", {
437
+ hourincrementbutton: I(({ callbacks: e }) => [g("span", {
411
438
  onMousedown: T(e).mousedown,
412
439
  onMouseup: T(e).mouseup,
413
440
  onMouseleave: T(e).mouseleave
414
- }, [v(u, { icon: "arrow-up" })], 40, K)]),
415
- hourdecrementbutton: P(({ callbacks: e }) => [g("span", {
441
+ }, [v(u, { icon: "arrow-up" })], 40, q)]),
442
+ hourdecrementbutton: I(({ callbacks: e }) => [g("span", {
416
443
  onMousedown: T(e).mousedown,
417
444
  onMouseup: T(e).mouseup,
418
445
  onMouseleave: T(e).mouseleave
419
- }, [v(u, { icon: "arrow-down" })], 40, q)]),
420
- minuteincrementbutton: P(({ callbacks: e }) => [g("span", {
446
+ }, [v(u, { icon: "arrow-down" })], 40, J)]),
447
+ minuteincrementbutton: I(({ callbacks: e }) => [g("span", {
421
448
  onMousedown: T(e).mousedown,
422
449
  onMouseup: T(e).mouseup,
423
450
  onMouseleave: T(e).mouseleave
424
- }, [v(u, { icon: "arrow-up" })], 40, J)]),
425
- minutedecrementbutton: P(({ callbacks: e }) => [g("span", {
451
+ }, [v(u, { icon: "arrow-up" })], 40, Y)]),
452
+ minutedecrementbutton: I(({ callbacks: e }) => [g("span", {
426
453
  onMousedown: T(e).mousedown,
427
454
  onMouseup: T(e).mouseup,
428
455
  onMouseleave: T(e).mouseleave
429
- }, [v(u, { icon: "arrow-down" })], 40, Y)]),
456
+ }, [v(u, { icon: "arrow-down" })], 40, X)]),
430
457
  _: 1
431
458
  }, 8, [
432
459
  "modelValue",
@@ -446,7 +473,7 @@ var W = { class: "wt-datepicker" }, G = { class: "wt-datepicker__button-bar" },
446
473
  variant: M(i).SIMPLE,
447
474
  size: M(r).SM
448
475
  }, {
449
- default: P(() => [_(A(M($)), 1)], void 0, !0),
476
+ default: I(() => [_(A(M($)), 1)], void 0, !0),
450
477
  _: 1
451
478
  }, 8, [
452
479
  "color",
@@ -456,6 +483,6 @@ var W = { class: "wt-datepicker" }, G = { class: "wt-datepicker__button-bar" },
456
483
  ]);
457
484
  };
458
485
  }
459
- }), [["__scopeId", "data-v-4c2f4f33"]]);
486
+ }), [["__scopeId", "data-v-7e8ec149"]]);
460
487
  //#endregion
461
- export { X as default };
488
+ export { Z as default };
@@ -1,4 +1,4 @@
1
- import { C as e, i as t } from "./components-gG_-DJ10.js";
1
+ import { C as e, i as t } from "./components-2ISVk3oW.js";
2
2
  import { t as n } from "./_plugin-vue_export-helper-B3ysoDQm.js";
3
3
  import { t as r } from "./displayText-CtaxzaBz.js";
4
4
  import { Fragment as i, computed as a, createCommentVNode as o, createElementBlock as s, createTextVNode as c, createVNode as l, defineComponent as u, openBlock as d, renderList as f, renderSlot as p, toDisplayString as m, unref as h, withCtx as g } from "vue";
@@ -1,6 +1,6 @@
1
1
  import { t as e } from "./rolldown-runtime-BEcgMyyN.js";
2
2
  import { n as t, r as n } from "./clients-DBqdsc05.js";
3
- import { T as r, n as i, w as a } from "./components-gG_-DJ10.js";
3
+ import { T as r, n as i, w as a } from "./components-2ISVk3oW.js";
4
4
  import { t as o } from "./vue-i18n-Db_oYfO8.js";
5
5
  import { n as s } from "./useEventBus-B-ZeklLu.js";
6
6
  import { createBlock as c, createTextVNode as l, createVNode as u, defineComponent as d, mergeProps as f, onMounted as p, openBlock as m, ref as h, resolveComponent as g, toDisplayString as _, unref as v, withCtx as y } from "vue";
@@ -1,5 +1,5 @@
1
1
  import { t as e } from "./clients-DBqdsc05.js";
2
- import { a as t, o as n, r, s as i } from "./components-gG_-DJ10.js";
2
+ import { a as t, o as n, r, s as i } from "./components-2ISVk3oW.js";
3
3
  import { t as a } from "./enums-De8CDKZ1.js";
4
4
  import { t as o } from "./vue-i18n-Db_oYfO8.js";
5
5
  import { computed as s, createBlock as c, createCommentVNode as l, createVNode as u, defineComponent as d, mergeModels as f, mergeProps as p, openBlock as m, renderSlot as h, resolveComponent as g, unref as _, useModel as v } from "vue";
@@ -1,4 +1,4 @@
1
- import { E as e } from "./components-gG_-DJ10.js";
1
+ import { E as e } from "./components-2ISVk3oW.js";
2
2
  import { t } from "./_plugin-vue_export-helper-B3ysoDQm.js";
3
3
  import { l as n } from "./enums-De8CDKZ1.js";
4
4
  import "./wt-button-B7B7qITq.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webitel/ui-sdk",
3
- "version": "26.8.49",
3
+ "version": "26.8.50",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "npm run docs:dev",
@@ -0,0 +1,51 @@
1
+ import { onUnmounted } from 'vue';
2
+
3
+ /**
4
+ * @author @HlukhovYe
5
+ *
6
+ * https://webitel.atlassian.net/browse/WTEL-10175
7
+ *
8
+ * PrimeVue's DatePicker only closes its overlay on window resize or on scroll
9
+ * of the input's scrollable ancestors — it has no way to notice the input
10
+ * itself disappearing (e.g. a tab switch, a `v-if`, or a collapsing parent
11
+ * that doesn't fire scroll/resize). When that happens the overlay is left
12
+ * open and detached from its anchor.
13
+ *
14
+ * Watches the datepicker's root element with an IntersectionObserver, which
15
+ * also fires when the element is hidden via `display: none` or detached from
16
+ * the layout, and force-closes the overlay when that happens.
17
+ */
18
+ export function useCloseOnAnchorHidden(
19
+ getAnchor: () => HTMLElement | null,
20
+ getDatepicker: () => {
21
+ overlayVisible?: boolean;
22
+ } | null,
23
+ ) {
24
+ let observer: IntersectionObserver | null = null;
25
+
26
+ function watch() {
27
+ unwatch();
28
+ const anchor = getAnchor();
29
+ if (!anchor) return;
30
+
31
+ observer = new IntersectionObserver((entries) => {
32
+ const isHidden = entries.some((entry) => !entry.isIntersecting);
33
+ if (!isHidden) return;
34
+ const datepicker = getDatepicker();
35
+ if (datepicker) datepicker.overlayVisible = false;
36
+ });
37
+ observer.observe(anchor);
38
+ }
39
+
40
+ function unwatch() {
41
+ observer?.disconnect();
42
+ observer = null;
43
+ }
44
+
45
+ onUnmounted(unwatch);
46
+
47
+ return {
48
+ watch,
49
+ unwatch,
50
+ };
51
+ }
@@ -1,5 +1,6 @@
1
1
  import { onMounted, onUnmounted } from 'vue';
2
2
  import { createAutoSeparatorHandler } from './useAutoSeparator';
3
+ import { useCloseOnAnchorHidden } from './useCloseOnAnchorHidden';
3
4
  import { useOverlayAnchor } from './useOverlayAnchor';
4
5
  import { createPreventZeroPadHandlers } from './usePreventZeroPad';
5
6
  import { useRestoreOnBlur } from './useRestoreOnBlur';
@@ -21,6 +22,7 @@ export function useDatepicker(
21
22
  getDatepicker: () => {
22
23
  rawValue: Date | null;
23
24
  updateModel: (v: Date) => void;
25
+ overlayVisible?: boolean;
24
26
  } | null,
25
27
  showTime: () => boolean,
26
28
  isClearable: () => boolean,
@@ -33,10 +35,24 @@ export function useDatepicker(
33
35
 
34
36
  const { onKeydown } = createStrictInputHandler(showTime);
35
37
 
36
- const { lock: lockOverlay, unlock: unlockOverlay } = useOverlayAnchor();
38
+ const { lock: lockOverlayAnchor, unlock: unlockOverlayAnchor } =
39
+ useOverlayAnchor();
40
+
41
+ const { watch: watchAnchorVisibility, unwatch: unwatchAnchorVisibility } =
42
+ useCloseOnAnchorHidden(getInput, getDatepicker);
37
43
 
38
44
  const { onBlur } = useRestoreOnBlur(getDatepicker, isClearable);
39
45
 
46
+ function lockOverlay(panel: HTMLElement) {
47
+ lockOverlayAnchor(panel);
48
+ watchAnchorVisibility();
49
+ }
50
+
51
+ function unlockOverlay() {
52
+ unlockOverlayAnchor();
53
+ unwatchAnchorVisibility();
54
+ }
55
+
40
56
  function onInputCaptureHandler(event: Event) {
41
57
  zeroPadCapture(event);
42
58
  }
@@ -206,6 +206,7 @@ const modelValue = computed({
206
206
  interface DatePickerRef extends PrimevueOverlayInstance {
207
207
  rawValue: Date | null;
208
208
  updateModel: (v: Date) => void;
209
+ overlayVisible?: boolean;
209
210
  }
210
211
 
211
212
  const datepicker = useTemplateRef<DatePickerRef>('datepicker');