@profitliga/ui 2.0.6 → 2.0.7

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,27 +1,27 @@
1
- import { defineComponent as W, useModel as Y, useId as _, computed as g, useTemplateRef as T, ref as ee, watch as te, onBeforeUnmount as oe, unref as t, openBlock as s, createBlock as w, createSlots as ie, withCtx as m, createElementVNode as d, createElementBlock as u, mergeProps as n, toDisplayString as A, createCommentVNode as c, renderSlot as f, normalizeProps as se, guardReactiveProps as ae, Fragment as ne, normalizeStyle as re, resolveDynamicComponent as N, createTextVNode as le, createVNode as de, mergeModels as x } from "vue";
2
- import { X as ue } from "@lucide/vue";
3
- import { breakpoints as ce } from "../../../utils/breakpoints.util.js";
4
- import { onClickOutside as fe } from "../../../utils/onClickOutside.util.js";
5
- import { useBodyScroll as ve } from "../../../utils/useBodyScroll.util.js";
6
- import { useFocusTrap as me } from "../../../utils/useFocusTrap.util.js";
1
+ import { defineComponent as Y, useModel as ee, useId as te, computed as g, useTemplateRef as E, ref as oe, watch as N, onBeforeUnmount as ie, unref as t, openBlock as s, createBlock as w, createSlots as se, withCtx as m, createElementVNode as d, createElementBlock as u, mergeProps as r, toDisplayString as x, createCommentVNode as c, renderSlot as f, normalizeProps as ae, guardReactiveProps as re, Fragment as ne, normalizeStyle as le, resolveDynamicComponent as K, createTextVNode as de, createVNode as ue, mergeModels as V } from "vue";
2
+ import { X as ce } from "@lucide/vue";
3
+ import { breakpoints as fe } from "../../../utils/breakpoints.util.js";
4
+ import { onClickOutside as ve } from "../../../utils/onClickOutside.util.js";
5
+ import { useBodyScroll as me } from "../../../utils/useBodyScroll.util.js";
6
+ import { useFocusTrap as ye } from "../../../utils/useFocusTrap.util.js";
7
7
  import pe from "../BottomSheet/BottomSheet.vue.js";
8
- import { ANIMATION_DURATION_MS as K } from "../shared/animation.const.js";
9
- import ye from "../shared/Portal.vue.js";
10
- import { useDelayedVisibility as be } from "../shared/useDelayedVisibility.util.js";
11
- import { useLayerZIndex as ge } from "../shared/useLayerZIndex.util.js";
12
- import { useTestId as we } from "../shared/useTestId.util.js";
13
- import { useTriggerAria as ke } from "../shared/useTriggerAria.util.js";
14
- import he from "../shared/VisuallyHidden.vue.js";
15
- const $e = { class: "drawer-mobile" }, Ie = {
8
+ import { ANIMATION_DURATION_MS as q } from "../shared/animation.const.js";
9
+ import be from "../shared/Portal.vue.js";
10
+ import { useDelayedVisibility as ge } from "../shared/useDelayedVisibility.util.js";
11
+ import { useLayerZIndex as we } from "../shared/useLayerZIndex.util.js";
12
+ import { useTestId as ke } from "../shared/useTestId.util.js";
13
+ import { useTriggerAria as he } from "../shared/useTriggerAria.util.js";
14
+ import $e from "../shared/VisuallyHidden.vue.js";
15
+ const Ie = { class: "drawer-mobile" }, Ce = {
16
16
  key: 1,
17
17
  class: "drawer-mobile__divider"
18
- }, Ce = ["data-state"], Oe = ["aria-describedby", "data-state"], Pe = { class: "drawer-content__header" }, De = ["aria-label"], Ee = {
18
+ }, Oe = ["data-state"], Pe = ["aria-describedby", "data-state"], De = { class: "drawer-content__header" }, Ee = ["aria-label"], Se = {
19
19
  key: 0,
20
20
  class: "drawer-content__divider"
21
- }, Ue = /* @__PURE__ */ W({
21
+ }, Ze = /* @__PURE__ */ Y({
22
22
  inheritAttrs: !1,
23
23
  __name: "Drawer",
24
- props: /* @__PURE__ */ x({
24
+ props: /* @__PURE__ */ V({
25
25
  position: { default: "right" },
26
26
  title: { default: void 0 },
27
27
  closeButton: { default: () => ({ enabled: !0 }) },
@@ -37,102 +37,103 @@ const $e = { class: "drawer-mobile" }, Ie = {
37
37
  open: { type: Boolean, default: !1 },
38
38
  openModifiers: {}
39
39
  }),
40
- emits: /* @__PURE__ */ x(["escapeKeyDown", "pointerDownOutside"], ["update:open"]),
41
- setup(o, { expose: V, emit: q }) {
42
- const i = o, k = q, r = Y(o, "open"), E = ce.smaller(i.breakpointMobile), h = _(), v = `drawer-title-${h}`, $ = `drawer-content-${h}`, S = `drawer-body-${h}`, a = we(() => i.testId), L = g(() => ({
40
+ emits: /* @__PURE__ */ V(["escapeKeyDown", "pointerDownOutside"], ["update:open"]),
41
+ setup(o, { expose: L, emit: F }) {
42
+ const i = o, k = F, n = ee(o, "open"), S = fe.smaller(i.breakpointMobile), h = te(), v = `drawer-title-${h}`, $ = `drawer-content-${h}`, B = `drawer-body-${h}`, a = ke(() => i.testId), U = g(() => ({
43
43
  "aria-haspopup": "dialog",
44
- "aria-expanded": r.value,
45
- "aria-controls": r.value ? $ : void 0
46
- })), B = g(() => i.title?.as ?? "h2"), F = g(
44
+ "aria-expanded": n.value,
45
+ "aria-controls": n.value ? $ : void 0
46
+ })), R = g(() => i.title?.as ?? "h2"), Z = g(
47
47
  () => i.position === "left" || i.position === "right" ? { width: `${i.width}px` } : { height: `${i.height}px` }
48
- ), z = T("triggerRef"), I = T("contentRef");
49
- ke({
48
+ ), z = E("triggerRef"), I = E("contentRef"), M = E("layerRef");
49
+ he({
50
50
  host: () => z.value,
51
- isOpen: () => r.value,
51
+ isOpen: () => n.value,
52
52
  contentId: () => $,
53
53
  hasPopup: () => "dialog"
54
54
  });
55
- const { lockScroll: U, unlockScroll: Z } = ve(), C = me(() => I.value), p = ge(), H = g(
56
- () => i.zIndex === "auto" ? p.zIndex.value : i.zIndex
57
- ), O = ee(!1);
58
- async function y(e) {
55
+ const { lockScroll: H, unlockScroll: X } = me(), C = ye(() => I.value), y = we(), _ = g(
56
+ () => i.zIndex === "auto" ? y.zIndex.value : i.zIndex
57
+ ), O = oe(!1);
58
+ async function p(e) {
59
59
  if (!i.beforeClose) {
60
- r.value = !1;
60
+ n.value = !1;
61
61
  return;
62
62
  }
63
63
  if (!O.value) {
64
64
  O.value = !0;
65
65
  try {
66
- await i.beforeClose(e) && (r.value = !1);
66
+ await i.beforeClose(e) && (n.value = !1);
67
67
  } finally {
68
68
  O.value = !1;
69
69
  }
70
70
  }
71
71
  }
72
72
  function P(e) {
73
- e.key === "Escape" && (k("escapeKeyDown", e), e.defaultPrevented || y("escapeKey"));
74
- }
75
- function X(e) {
76
- k("pointerDownOutside", e), !i.disableOutsidePointerEvents && !e.defaultPrevented && y("outsidePointer");
77
- }
78
- function R(e, l) {
79
- e.defaultPrevented || !i.beforeClose || (e.preventDefault(), y(l));
73
+ e.key === "Escape" && (k("escapeKeyDown", e), e.defaultPrevented || p("escapeKey"));
80
74
  }
81
75
  function j(e) {
82
- k("escapeKeyDown", e), R(e, "escapeKey");
76
+ k("pointerDownOutside", e), !i.disableOutsidePointerEvents && !e.defaultPrevented && p("outsidePointer");
77
+ }
78
+ function T(e, l) {
79
+ e.defaultPrevented || !i.beforeClose || (e.preventDefault(), p(l));
83
80
  }
84
81
  function G(e) {
85
- k("pointerDownOutside", e), !i.disableOutsidePointerEvents && R(e, "outsidePointer");
82
+ k("escapeKeyDown", e), T(e, "escapeKey");
83
+ }
84
+ function J(e) {
85
+ k("pointerDownOutside", e), !i.disableOutsidePointerEvents && T(e, "outsidePointer");
86
86
  }
87
- const J = g(() => r.value && !E.value), { visible: Q, dataState: M } = be(
88
- J,
89
- K,
87
+ const Q = g(() => n.value && !S.value), { visible: W, dataState: A } = ge(
88
+ Q,
89
+ q,
90
90
  {
91
91
  onOpen: () => {
92
- p.acquire(), U(), C.activate({ focusDelayMs: K }), document.addEventListener("keydown", P);
92
+ y.acquire(), H(), C.activate({ focusDelayMs: q }), document.addEventListener("keydown", P);
93
93
  },
94
94
  onCloseStart: () => {
95
95
  C.deactivate(), document.removeEventListener("keydown", P);
96
96
  },
97
97
  onCloseEnd: () => {
98
- Z(), p.release();
98
+ X(), y.release();
99
99
  }
100
100
  }
101
101
  );
102
+ N(M, (e) => y.registerElement(e));
102
103
  let D;
103
- return te(I, (e) => {
104
- p.registerElement(e), D?.(), D = e ? fe(e, X, {
105
- ignore: () => p.elementsAbove()
104
+ return N(I, (e) => {
105
+ D?.(), D = e ? ve(e, j, {
106
+ ignore: () => y.elementsAbove()
106
107
  }) : void 0;
107
- }), oe(() => {
108
+ }), ie(() => {
108
109
  D?.(), document.removeEventListener("keydown", P), C.deactivate();
109
- }), V({
110
- requestClose: (e = "programmatic") => y(e)
111
- }), (e, l) => t(E) ? (s(), w(t(pe), {
110
+ }), L({
111
+ requestClose: (e = "programmatic") => p(e)
112
+ }), (e, l) => t(S) ? (s(), w(t(pe), {
112
113
  key: 0,
113
- open: r.value,
114
- "onUpdate:open": l[0] || (l[0] = (b) => r.value = b),
114
+ open: n.value,
115
+ "onUpdate:open": l[0] || (l[0] = (b) => n.value = b),
115
116
  "z-index": o.zIndex,
116
117
  "disable-outside-pointer-events": o.disableOutsidePointerEvents,
117
118
  "disable-swipe-to-close": !!o.beforeClose,
118
119
  "labelled-by": o.title?.text && !e.$slots.title ? v : void 0,
119
120
  "test-id": o.testId,
120
- onEscapeKeyDown: j,
121
- onPointerDownOutside: G
122
- }, ie({
121
+ onEscapeKeyDown: G,
122
+ onPointerDownOutside: J
123
+ }, se({
123
124
  default: m(() => [
124
- d("div", $e, [
125
- o.title?.text && !e.$slots.title ? (s(), u("div", n({
125
+ d("div", Ie, [
126
+ o.title?.text && !e.$slots.title ? (s(), u("div", r({
126
127
  key: 0,
127
128
  id: v,
128
129
  class: "drawer-mobile__title"
129
- }, t(a)("title")), A(o.title.text), 17)) : c("", !0),
130
- o.divider ? (s(), u("div", Ie)) : c("", !0),
131
- d("div", n({ class: "drawer-mobile__content" }, t(a)("body")), [
130
+ }, t(a)("title")), x(o.title.text), 17)) : c("", !0),
131
+ o.divider ? (s(), u("div", Ce)) : c("", !0),
132
+ d("div", r({ class: "drawer-mobile__content" }, t(a)("body")), [
132
133
  f(e.$slots, "title", {}, void 0, !0),
133
134
  f(e.$slots, "default", {}, void 0, !0)
134
135
  ], 16),
135
- e.$slots.actions ? (s(), u("div", n({
136
+ e.$slots.actions ? (s(), u("div", r({
136
137
  key: 2,
137
138
  class: "drawer-mobile__actions"
138
139
  }, t(a)("actions")), [
@@ -145,54 +146,56 @@ const $e = { class: "drawer-mobile" }, Ie = {
145
146
  e.$slots.trigger ? {
146
147
  name: "trigger",
147
148
  fn: m((b) => [
148
- f(e.$slots, "trigger", se(ae(b)), void 0, !0)
149
+ f(e.$slots, "trigger", ae(re(b)), void 0, !0)
149
150
  ]),
150
151
  key: "0"
151
152
  } : void 0
152
153
  ]), 1032, ["open", "z-index", "disable-outside-pointer-events", "disable-swipe-to-close", "labelled-by", "test-id"])) : (s(), u(ne, { key: 1 }, [
153
- e.$slots.trigger ? (s(), u("span", n({
154
+ e.$slots.trigger ? (s(), u("span", r({
154
155
  key: 0,
155
156
  ref_key: "triggerRef",
156
157
  ref: z,
157
158
  class: "drawer-trigger"
158
159
  }, t(a)("trigger"), {
159
- onClick: l[1] || (l[1] = (b) => r.value = !0)
160
+ onClick: l[1] || (l[1] = (b) => n.value = !0)
160
161
  }), [
161
- f(e.$slots, "trigger", { props: L.value }, void 0, !0)
162
+ f(e.$slots, "trigger", { props: U.value }, void 0, !0)
162
163
  ], 16)) : c("", !0),
163
- t(Q) ? (s(), w(ye, { key: 1 }, {
164
+ t(W) ? (s(), w(be, { key: 1 }, {
164
165
  default: m(() => [
165
166
  d("div", {
167
+ ref_key: "layerRef",
168
+ ref: M,
166
169
  class: "drawer-layer",
167
- style: re({ zIndex: H.value })
170
+ style: le({ zIndex: _.value })
168
171
  }, [
169
- d("div", n({
172
+ d("div", r({
170
173
  class: "overlay drawer-overlay",
171
- "data-state": t(M)
172
- }, t(a)("overlay")), null, 16, Ce),
173
- d("div", n({
174
+ "data-state": t(A)
175
+ }, t(a)("overlay")), null, 16, Oe),
176
+ d("div", r({
174
177
  id: $,
175
178
  ref_key: "contentRef",
176
179
  ref: I,
177
180
  role: "dialog",
178
181
  "aria-modal": "true",
179
182
  "aria-labelledby": v,
180
- "aria-describedby": e.$slots.default ? S : void 0,
183
+ "aria-describedby": e.$slots.default ? B : void 0,
181
184
  class: ["drawer-content", `drawer-content--${o.position}`],
182
- "data-state": t(M),
183
- style: F.value
185
+ "data-state": t(A),
186
+ style: Z.value
184
187
  }, { ...e.$attrs, ...t(a)("content") }), [
185
- d("div", Pe, [
186
- o.title?.text ? (s(), w(N(B.value), n({
188
+ d("div", De, [
189
+ o.title?.text ? (s(), w(K(R.value), r({
187
190
  key: 0,
188
191
  id: v,
189
192
  class: "drawer-content__title"
190
193
  }, t(a)("title")), {
191
194
  default: m(() => [
192
- le(A(o.title.text), 1)
195
+ de(x(o.title.text), 1)
193
196
  ]),
194
197
  _: 1
195
- }, 16)) : e.$slots.title ? (s(), w(N(B.value), n({
198
+ }, 16)) : e.$slots.title ? (s(), w(K(R.value), r({
196
199
  key: 1,
197
200
  id: v,
198
201
  class: "drawer-content__title"
@@ -201,37 +204,37 @@ const $e = { class: "drawer-mobile" }, Ie = {
201
204
  f(e.$slots, "title", {}, void 0, !0)
202
205
  ]),
203
206
  _: 3
204
- }, 16)) : (s(), w(he, { key: 2 }, {
207
+ }, 16)) : (s(), w($e, { key: 2 }, {
205
208
  default: m(() => [
206
209
  d("h2", { id: v }, "Боковая панель")
207
210
  ]),
208
211
  _: 1
209
212
  })),
210
- o.closeButton?.enabled ? (s(), u("button", n({
213
+ o.closeButton?.enabled ? (s(), u("button", r({
211
214
  key: 3,
212
215
  type: "button",
213
216
  class: "drawer-content__close",
214
217
  "aria-label": o.closeButton.label ?? "Закрыть"
215
218
  }, t(a)("close"), {
216
- onClick: l[2] || (l[2] = (b) => y("closeButton"))
219
+ onClick: l[2] || (l[2] = (b) => p("closeButton"))
217
220
  }), [
218
- de(t(ue), { size: 20 })
219
- ], 16, De)) : c("", !0)
221
+ ue(t(ce), { size: 20 })
222
+ ], 16, Ee)) : c("", !0)
220
223
  ]),
221
- o.divider ? (s(), u("div", Ee)) : c("", !0),
222
- d("div", n({
223
- id: S,
224
+ o.divider ? (s(), u("div", Se)) : c("", !0),
225
+ d("div", r({
226
+ id: B,
224
227
  class: "drawer-content__wrapper"
225
228
  }, t(a)("body")), [
226
229
  f(e.$slots, "default", {}, void 0, !0)
227
230
  ], 16),
228
- e.$slots.actions ? (s(), u("div", n({
231
+ e.$slots.actions ? (s(), u("div", r({
229
232
  key: 1,
230
233
  class: "drawer-content__actions"
231
234
  }, t(a)("actions")), [
232
235
  f(e.$slots, "actions", {}, void 0, !0)
233
236
  ], 16)) : c("", !0)
234
- ], 16, Oe)
237
+ ], 16, Pe)
235
238
  ], 4)
236
239
  ]),
237
240
  _: 3
@@ -240,5 +243,5 @@ const $e = { class: "drawer-mobile" }, Ie = {
240
243
  }
241
244
  });
242
245
  export {
243
- Ue as default
246
+ Ze as default
244
247
  };
@@ -1,30 +1,36 @@
1
- import { toValue as f, unref as p } from "vue";
2
- const u = /* @__PURE__ */ new WeakMap();
3
- function d(t) {
4
- const r = p(t);
5
- return r?.$el ?? r;
1
+ import { toValue as p, unref as g } from "vue";
2
+ const s = /* @__PURE__ */ new WeakMap();
3
+ let c = 0;
4
+ const E = 500;
5
+ function l(t) {
6
+ const o = g(t);
7
+ return o?.$el ?? o;
6
8
  }
7
- function g(t) {
8
- return typeof t == "string" ? document.querySelector(t) : d(t);
9
+ function L(t) {
10
+ return typeof t == "string" ? document.querySelector(t) : l(t);
9
11
  }
10
- function w(t, r, l = {}) {
11
- const n = g(t);
12
+ function y(t, o, d = {}) {
13
+ const n = L(t);
12
14
  if (!n) return () => {
13
15
  };
14
- const i = u.get(n);
15
- i && (i(), u.delete(n));
16
- const o = (s) => {
17
- const c = s.target instanceof Node ? s.target : null;
18
- if (!c) return;
19
- const m = (f(l.ignore) ?? []).map((e) => typeof e == "string" ? document.querySelector(e) : d(e)).filter((e) => e != null);
20
- n.contains(c) || m.some((e) => e.contains(c)) || r(s);
16
+ const a = s.get(n);
17
+ a && (a(), s.delete(n));
18
+ const u = (r) => {
19
+ if (r.type === "touchstart")
20
+ c = r.timeStamp;
21
+ else if (c > 0 && r.timeStamp - c < E)
22
+ return;
23
+ const i = r.target instanceof Node ? r.target : null;
24
+ if (!i) return;
25
+ const f = (p(d.ignore) ?? []).map((e) => typeof e == "string" ? document.querySelector(e) : l(e)).filter((e) => e != null);
26
+ n.contains(i) || f.some((e) => e.contains(i)) || o(r);
21
27
  };
22
- document.addEventListener("mousedown", o, { capture: !0 }), document.addEventListener("touchstart", o, { capture: !0 });
23
- const a = () => {
24
- document.removeEventListener("mousedown", o, { capture: !0 }), document.removeEventListener("touchstart", o, { capture: !0 }), u.delete(n);
28
+ document.addEventListener("mousedown", u, { capture: !0 }), document.addEventListener("touchstart", u, { capture: !0 });
29
+ const m = () => {
30
+ document.removeEventListener("mousedown", u, { capture: !0 }), document.removeEventListener("touchstart", u, { capture: !0 }), s.delete(n);
25
31
  };
26
- return u.set(n, a), a;
32
+ return s.set(n, m), m;
27
33
  }
28
34
  export {
29
- w as onClickOutside
35
+ y as onClickOutside
30
36
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@profitliga/ui",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
4
4
  "author": "Profit League<dev@pr-lg.ru>",
5
5
  "license": "MIT",
6
6
  "description": "Vue 3 UI component library with TypeScript and SCSS",