@webitel/ui-sdk 26.6.76 → 26.6.77

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-BTdvsbd3.js";
1
+ import "./components-DfoMgyOo.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-dC4nOW56.js";
@@ -3,7 +3,7 @@ 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-DGl2otXJ.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 P, vShow as F, withCtx as I, withDirectives as L } from "vue";
6
+ import { computed as f, createBlock as p, createCommentVNode as m, createElementBlock as ee, createElementVNode as h, createTextVNode as g, createVNode as _, defineComponent as v, guardReactiveProps as y, mergeModels as b, mergeProps as x, nextTick as S, normalizeProps as C, onMounted as w, onUnmounted as T, openBlock as E, renderSlot as D, resolveComponent as O, toDisplayString as k, toRefs as A, unref as j, useModel as M, useTemplateRef as N, vShow as P, watch as F, withCtx as I, withDirectives as L } from "vue";
7
7
  import R from "primevue/datepicker";
8
8
  //#region node_modules/date-fns-tz/dist/esm/fromZonedTime/index.js
9
9
  function z(e, t, n) {
@@ -38,35 +38,56 @@ function B(e) {
38
38
  let n = e.target, { value: r, cursor: i } = t;
39
39
  t = null, n.value !== r && (n.value = r, n.setSelectionRange(i, i), e.stopImmediatePropagation());
40
40
  }
41
- T(() => {
41
+ w(() => {
42
42
  let t = e();
43
43
  t && (t.addEventListener("input", n, { capture: !0 }), t.addEventListener("input", r));
44
- }), E(() => {
44
+ }), T(() => {
45
45
  let t = e();
46
46
  t && (t.removeEventListener("input", n, { capture: !0 }), t.removeEventListener("input", r));
47
47
  });
48
48
  }
49
49
  //#endregion
50
+ //#region src/components/wt-datepicker/_internals/composables/useRestoreOnBlur.ts
51
+ function V(e, t, n) {
52
+ let r = null;
53
+ function i() {
54
+ F(e, (e) => {
55
+ e !== null && (r = e);
56
+ }, { immediate: !0 });
57
+ }
58
+ function a() {
59
+ if (n()) return;
60
+ let e = t();
61
+ e && e.rawValue === null && r !== null && S(() => {
62
+ e.updateModel(new Date(r.getTime()));
63
+ });
64
+ }
65
+ return {
66
+ onBlur: a,
67
+ watchRestoreOnBlurLastValidValue: i
68
+ };
69
+ }
70
+ //#endregion
50
71
  //#region src/components/wt-datepicker/wt-datepicker.vue?vue&type=script&setup=true&lang.ts
51
- var V = { class: "wt-datepicker" }, H = { class: "wt-datepicker__button-bar" }, U = [
72
+ var H = { class: "wt-datepicker" }, U = { class: "wt-datepicker__button-bar" }, W = [
52
73
  "onMousedown",
53
74
  "onMouseup",
54
75
  "onMouseleave"
55
- ], W = [
76
+ ], G = [
56
77
  "onMousedown",
57
78
  "onMouseup",
58
79
  "onMouseleave"
59
- ], G = [
80
+ ], K = [
60
81
  "onMousedown",
61
82
  "onMouseup",
62
83
  "onMouseleave"
63
- ], K = [
84
+ ], q = [
64
85
  "onMousedown",
65
86
  "onMouseup",
66
87
  "onMouseleave"
67
- ], q = /*#__PURE__*/ e(/* @__PURE__ */ y({
88
+ ], J = /*#__PURE__*/ e(/* @__PURE__ */ v({
68
89
  __name: "wt-datepicker",
69
- props: /*@__PURE__*/ x({
90
+ props: /*@__PURE__*/ b({
70
91
  showTime: { type: Boolean },
71
92
  minDate: {},
72
93
  maxDate: {},
@@ -146,7 +167,7 @@ var V = { class: "wt-datepicker" }, H = { class: "wt-datepicker__button-bar" },
146
167
  modelValue: { default: null },
147
168
  modelModifiers: {}
148
169
  }),
149
- emits: /*@__PURE__*/ x([
170
+ emits: /*@__PURE__*/ b([
150
171
  "update:modelValue",
151
172
  "value-change",
152
173
  "input",
@@ -162,7 +183,7 @@ var V = { class: "wt-datepicker" }, H = { class: "wt-datepicker__button-bar" },
162
183
  "keydown"
163
184
  ], ["update:modelValue"]),
164
185
  setup(e, { emit: a }) {
165
- let o = e, s = N(e, "modelValue"), { t: c } = u(), y = f({
186
+ let o = e, s = M(e, "modelValue"), { t: c } = u(), v = f({
166
187
  get() {
167
188
  if (!s.value) return null;
168
189
  let e = /* @__PURE__ */ new Date(+s.value);
@@ -170,54 +191,58 @@ var V = { class: "wt-datepicker" }, H = { class: "wt-datepicker__button-bar" },
170
191
  },
171
192
  set(e) {
172
193
  if (!e) {
194
+ if (!o.clearable) return;
173
195
  s.value = null;
174
196
  return;
175
197
  }
176
198
  let t = o.timezone ? z(e, o.timezone) : e;
177
199
  s.value = t.getTime();
178
200
  }
179
- }), x = P("datepicker"), T = `datepicker-${Math.random().toString(36).slice(2, 11)}`;
180
- B(() => x.value?.$el?.querySelector("input"));
181
- let E = f(() => o.placholder || `dd/mm/yyyy ${o.showTime ? "hh:mm" : ""}`), q = () => {
182
- if (o.showTime && y.value) {
183
- let e = y.value;
184
- C(() => {
185
- y.value = new Date(e.getTime());
201
+ }), b = N("datepicker"), w = `datepicker-${Math.random().toString(36).slice(2, 11)}`;
202
+ B(() => b.value?.$el?.querySelector("input"));
203
+ let { onBlur: T, watchRestoreOnBlurLastValidValue: F } = V(v, () => b.value, () => !!o.clearable);
204
+ F();
205
+ let J = f(() => o.placholder || `dd/mm/yyyy ${o.showTime ? "hh:mm" : ""}`), Y = () => {
206
+ if (o.showTime && v.value) {
207
+ let e = v.value;
208
+ S(() => {
209
+ v.value = new Date(e.getTime());
186
210
  });
187
211
  }
188
212
  setTimeout(() => {
189
- x.value?.alignOverlay();
190
- let e = x.value?.overlay;
213
+ b.value?.alignOverlay();
214
+ let e = b.value?.overlay;
191
215
  e && (e.style.minWidth = "");
192
216
  }, 0);
193
- }, J = f(() => o.required ? `${o.label}*` : o.label), { v: Y, customValidators: X } = j(o), { isValidation: Z, invalid: Q, validationText: $, validationTextColor: ee } = d({
194
- v: Y,
195
- customValidators: X
217
+ }, X = f(() => o.required ? `${o.label}*` : o.label), { v: Z, customValidators: Q } = A(o), { isValidation: te, invalid: ne, validationText: $, validationTextColor: re } = d({
218
+ v: Z,
219
+ customValidators: Q
196
220
  });
197
221
  return (a, o) => {
198
- let s = k("wt-label"), l = k("wt-button"), u = k("wt-icon-btn"), d = k("wt-message");
199
- return D(), h("div", V, [
200
- v(s, S(e.labelProps, { disabled: e.disabled }, {
201
- for: T,
202
- invalid: M(Q)
222
+ let s = O("wt-label"), l = O("wt-button"), u = O("wt-icon-btn"), d = O("wt-message");
223
+ return E(), ee("div", H, [
224
+ _(s, x(e.labelProps, { disabled: e.disabled }, {
225
+ for: w,
226
+ invalid: j(ne)
203
227
  }), {
204
- default: I(() => [O(a.$slots, "label", w(b({ label: e.label })), () => [_(A(J.value), 1)], !0)], void 0, !0),
228
+ default: I(() => [D(a.$slots, "label", C(y({ label: e.label })), () => [g(k(X.value), 1)], !0)], void 0, !0),
205
229
  _: 3
206
230
  }, 16, ["disabled", "invalid"]),
207
- v(M(R), {
231
+ _(j(R), {
208
232
  ref_key: "datepicker",
209
- ref: x,
210
- id: T,
211
- modelValue: y.value,
212
- "onUpdate:modelValue": o[0] ||= (e) => y.value = e,
233
+ ref: b,
234
+ id: w,
235
+ modelValue: v.value,
236
+ "onUpdate:modelValue": o[0] ||= (e) => v.value = e,
213
237
  "date-format": "dd/mm/yy",
238
+ "input-class": "typo-body-1",
214
239
  required: e.required,
215
240
  disabled: e.disabled,
216
241
  "show-time": e.showTime,
217
242
  "min-date": e.minDate,
218
243
  "max-date": e.maxDate,
219
- placeholder: E.value,
220
- "show-clear": e.clearable && y.value,
244
+ placeholder: J.value,
245
+ "show-clear": e.clearable && v.value,
221
246
  "show-button-bar": "",
222
247
  fluid: "",
223
248
  pt: {
@@ -229,68 +254,69 @@ var V = { class: "wt-datepicker" }, H = { class: "wt-datepicker__button-bar" },
229
254
  minute: { class: "typo-body-2" },
230
255
  panel: { style: { maxWidth: "380px" } }
231
256
  },
232
- onShow: q
257
+ onShow: Y,
258
+ onBlur: j(T)
233
259
  }, {
234
- buttonbar: I(({ todayCallback: i, clearCallback: a }) => [g("div", H, [v(l, {
235
- color: M(n).SECONDARY,
236
- variant: M(t).OUTLINED,
237
- size: M(r).SM,
260
+ buttonbar: I(({ todayCallback: i, clearCallback: a }) => [h("div", U, [_(l, {
261
+ color: j(n).SECONDARY,
262
+ variant: j(t).OUTLINED,
263
+ size: j(r).SM,
238
264
  onClick: i
239
265
  }, {
240
- default: I(() => [_(A(M(c)("reusable.today")), 1)], void 0, !0),
266
+ default: I(() => [g(k(j(c)("reusable.today")), 1)], void 0, !0),
241
267
  _: 1
242
268
  }, 8, [
243
269
  "color",
244
270
  "variant",
245
271
  "size",
246
272
  "onClick"
247
- ]), L(v(l, {
248
- color: M(n).SECONDARY,
249
- variant: M(t).OUTLINED,
250
- size: M(r).SM,
273
+ ]), L(_(l, {
274
+ color: j(n).SECONDARY,
275
+ variant: j(t).OUTLINED,
276
+ size: j(r).SM,
251
277
  onClick: a
252
278
  }, {
253
- default: I(() => [_(A(M(c)("reusable.clear")), 1)], void 0, !0),
279
+ default: I(() => [g(k(j(c)("reusable.clear")), 1)], void 0, !0),
254
280
  _: 1
255
281
  }, 8, [
256
282
  "color",
257
283
  "variant",
258
284
  "size",
259
285
  "onClick"
260
- ]), [[F, e.clearable && y.value]])])]),
261
- prevbutton: I(({ actionCallback: e }) => [v(u, {
286
+ ]), [[P, e.clearable && v.value]])])]),
287
+ prevbutton: I(({ actionCallback: e }) => [_(u, {
262
288
  icon: "arrow-left",
263
289
  onClick: e
264
290
  }, null, 8, ["onClick"])]),
265
- nextbutton: I(({ actionCallback: e }) => [v(u, {
291
+ nextbutton: I(({ actionCallback: e }) => [_(u, {
266
292
  icon: "arrow-right",
267
293
  onClick: e
268
294
  }, null, 8, ["onClick"])]),
269
- clearicon: I(({ clearCallback: e }) => [v(u, {
295
+ clearicon: I(({ clearCallback: e }) => [_(u, {
270
296
  icon: "close",
271
297
  class: "wt-datepicker__clear-icon",
272
298
  onClick: e
273
299
  }, null, 8, ["onClick"])]),
274
- hourincrementbutton: I(({ callbacks: e }) => [g("span", {
300
+ hourincrementbutton: I(({ callbacks: e }) => [h("span", {
275
301
  onMousedown: e.mousedown,
276
302
  onMouseup: e.mouseup,
277
303
  onMouseleave: e.mouseleave
278
- }, [v(u, { icon: "arrow-up" })], 40, U)]),
279
- hourdecrementbutton: I(({ callbacks: e }) => [g("span", {
304
+ }, [_(u, { icon: "arrow-up" })], 40, W)]),
305
+ hourdecrementbutton: I(({ callbacks: e }) => [h("span", {
280
306
  onMousedown: e.mousedown,
281
307
  onMouseup: e.mouseup,
282
308
  onMouseleave: e.mouseleave
283
- }, [v(u, { icon: "arrow-down" })], 40, W)]),
284
- minuteincrementbutton: I(({ callbacks: e }) => [g("span", {
309
+ }, [_(u, { icon: "arrow-down" })], 40, G)]),
310
+ minuteincrementbutton: I(({ callbacks: e }) => [h("span", {
285
311
  onMousedown: e.mousedown,
286
312
  onMouseup: e.mouseup,
287
313
  onMouseleave: e.mouseleave
288
- }, [v(u, { icon: "arrow-up" })], 40, G)]),
289
- minutedecrementbutton: I(({ callbacks: e }) => [g("span", {
314
+ }, [_(u, { icon: "arrow-up" })], 40, K)]),
315
+ minutedecrementbutton: I(({ callbacks: e }) => [h("span", {
290
316
  onMousedown: e.mousedown,
291
317
  onMouseup: e.mouseup,
292
318
  onMouseleave: e.mouseleave
293
- }, [v(u, { icon: "arrow-down" })], 40, K)]),
319
+ }, [_(u, { icon: "arrow-down" })], 40, q)]),
294
320
  _: 1
295
321
  }, 8, [
296
322
  "modelValue",
@@ -300,15 +326,16 @@ var V = { class: "wt-datepicker" }, H = { class: "wt-datepicker__button-bar" },
300
326
  "min-date",
301
327
  "max-date",
302
328
  "placeholder",
303
- "show-clear"
329
+ "show-clear",
330
+ "onBlur"
304
331
  ]),
305
- M(Z) && M($) ? (D(), p(d, {
332
+ j(te) && j($) ? (E(), p(d, {
306
333
  key: 0,
307
- color: M(ee),
308
- variant: M(i).SIMPLE,
309
- size: M(r).SM
334
+ color: j(re),
335
+ variant: j(i).SIMPLE,
336
+ size: j(r).SM
310
337
  }, {
311
- default: I(() => [_(A(M($)), 1)], void 0, !0),
338
+ default: I(() => [g(k(j($)), 1)], void 0, !0),
312
339
  _: 1
313
340
  }, 8, [
314
341
  "color",
@@ -318,6 +345,6 @@ var V = { class: "wt-datepicker" }, H = { class: "wt-datepicker__button-bar" },
318
345
  ]);
319
346
  };
320
347
  }
321
- }), [["__scopeId", "data-v-b7a87a75"]]);
348
+ }), [["__scopeId", "data-v-4be684aa"]]);
322
349
  //#endregion
323
- export { q as default };
350
+ export { J as default };
@@ -1,4 +1,4 @@
1
- import { C as e, i as t } from "./components-BTdvsbd3.js";
1
+ import { C as e, i as t } from "./components-DfoMgyOo.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,5 +1,5 @@
1
1
  import { n as e, r as t } from "./clients-CIZxqjbV.js";
2
- import { n } from "./components-BTdvsbd3.js";
2
+ import { n } from "./components-DfoMgyOo.js";
3
3
  import { t as r } from "./vue-i18n-Db_oYfO8.js";
4
4
  import { createBlock as i, createTextVNode as a, createVNode as o, defineComponent as s, inject as c, mergeProps as l, onMounted as u, openBlock as d, ref as f, resolveComponent as p, toDisplayString as m, unref as h, withCtx as g } from "vue";
5
5
  //#endregion
@@ -1,5 +1,5 @@
1
1
  import { t as e } from "./clients-CIZxqjbV.js";
2
- import { a as t, o as n, r, s as i } from "./components-BTdvsbd3.js";
2
+ import { a as t, o as n, r, s as i } from "./components-DfoMgyOo.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 { w as e } from "./components-BTdvsbd3.js";
1
+ import { w as e } from "./components-DfoMgyOo.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-dC4nOW56.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webitel/ui-sdk",
3
- "version": "26.6.76",
3
+ "version": "26.6.77",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "npm run docs:dev",
@@ -0,0 +1,53 @@
1
+ import { nextTick, type WritableComputedRef, watch } from 'vue';
2
+
3
+ /**
4
+ * @author @HlukhovYe
5
+ *
6
+ * https://webitel.atlassian.net/browse/WTEL-9880
7
+ *
8
+ * When the datepicker is not clearable, restores the last valid value on blur
9
+ * if the user left the field empty or typed an invalid date.
10
+ *
11
+ * Since the parent model never becomes null (null writes are blocked in the
12
+ * modelValue setter), PrimeVue's watcher won't re-fire on restore. Instead we
13
+ * call PrimeVue's internal updateModel() directly so it resyncs rawValue and
14
+ * redraws the input.
15
+ */
16
+ export function useRestoreOnBlur(
17
+ modelValue: WritableComputedRef<Date | null>,
18
+ getDatepicker: () => {
19
+ rawValue: Date | null;
20
+ updateModel: (v: Date) => void;
21
+ } | null,
22
+ isClearable: () => boolean,
23
+ ) {
24
+ let lastValid: Date | null = null;
25
+
26
+ function watchRestoreOnBlurLastValidValue() {
27
+ watch(
28
+ modelValue,
29
+ (value) => {
30
+ if (value !== null) lastValid = value;
31
+ },
32
+ {
33
+ immediate: true,
34
+ },
35
+ );
36
+ }
37
+
38
+ function onBlur() {
39
+ if (isClearable()) return;
40
+ const datePickerEl = getDatepicker();
41
+ if (!datePickerEl) return;
42
+ if (datePickerEl.rawValue === null && lastValid !== null) {
43
+ nextTick(() => {
44
+ datePickerEl.updateModel(new Date(lastValid.getTime()));
45
+ });
46
+ }
47
+ }
48
+
49
+ return {
50
+ onBlur,
51
+ watchRestoreOnBlurLastValidValue,
52
+ };
53
+ }
@@ -13,6 +13,7 @@
13
13
  :id="datepickerId"
14
14
  v-model="modelValue"
15
15
  date-format="dd/mm/yy"
16
+ input-class="typo-body-1"
16
17
  :required="required"
17
18
  :disabled="disabled"
18
19
  :show-time="showTime"
@@ -48,6 +49,7 @@
48
49
  }
49
50
  }"
50
51
  @show="onPanelShow"
52
+ @blur="onBlur"
51
53
  >
52
54
  <template #buttonbar="{ todayCallback, clearCallback }">
53
55
  <div class="wt-datepicker__button-bar">
@@ -151,6 +153,7 @@ import {
151
153
  } from '../../enums';
152
154
  import { useValidation } from '../../mixins/validationMixin/useValidation';
153
155
  import { usePreventZeroPad } from './_internals/composables/usePreventZeroPad';
156
+ import { useRestoreOnBlur } from './_internals/composables/useRestoreOnBlur';
154
157
 
155
158
  interface Props extends DatePickerProps {
156
159
  showTime?: boolean;
@@ -188,6 +191,9 @@ const modelValue = computed({
188
191
  },
189
192
  set(value) {
190
193
  if (!value) {
194
+ // When not clearable, don't propagate null to the parent while the user
195
+ // is typing — the blur handler will restore the last valid value instead.
196
+ if (!props.clearable) return;
191
197
  model.value = null;
192
198
  return;
193
199
  }
@@ -202,6 +208,14 @@ const datepickerId = `datepicker-${Math.random().toString(36).slice(2, 11)}`;
202
208
 
203
209
  usePreventZeroPad(() => datepicker.value?.$el?.querySelector('input'));
204
210
 
211
+ const { onBlur, watchRestoreOnBlurLastValidValue } = useRestoreOnBlur(
212
+ modelValue,
213
+ () => datepicker.value,
214
+ () => !!props.clearable,
215
+ );
216
+
217
+ watchRestoreOnBlurLastValidValue();
218
+
205
219
  const getPlaceholder = computed(() => {
206
220
  return props.placholder || `dd/mm/yyyy ${props.showTime ? 'hh:mm' : ''}`;
207
221
  });
@@ -0,0 +1,21 @@
1
+ import { type WritableComputedRef } from 'vue';
2
+ /**
3
+ * @author @HlukhovYe
4
+ *
5
+ * https://webitel.atlassian.net/browse/WTEL-9880
6
+ *
7
+ * When the datepicker is not clearable, restores the last valid value on blur
8
+ * if the user left the field empty or typed an invalid date.
9
+ *
10
+ * Since the parent model never becomes null (null writes are blocked in the
11
+ * modelValue setter), PrimeVue's watcher won't re-fire on restore. Instead we
12
+ * call PrimeVue's internal updateModel() directly so it resyncs rawValue and
13
+ * redraws the input.
14
+ */
15
+ export declare function useRestoreOnBlur(modelValue: WritableComputedRef<Date | null>, getDatepicker: () => {
16
+ rawValue: Date | null;
17
+ updateModel: (v: Date) => void;
18
+ } | null, isClearable: () => boolean): {
19
+ onBlur: () => void;
20
+ watchRestoreOnBlurLastValidValue: () => void;
21
+ };