@profitliga/ui 2.0.5 → 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 b, 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 N, createCommentVNode as c, renderSlot as f, normalizeProps as se, guardReactiveProps as ae, Fragment as ne, normalizeStyle as re, resolveDynamicComponent as x, createTextVNode as le, createVNode as de, mergeModels as A } 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";
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
11
  import { useLayerZIndex as we } from "../shared/useLayerZIndex.util.js";
12
- import { useTestId as ge } 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 = {
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"], Se = {
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__ */ A({
24
+ props: /* @__PURE__ */ V({
25
25
  position: { default: "right" },
26
26
  title: { default: void 0 },
27
27
  closeButton: { default: () => ({ enabled: !0 }) },
@@ -37,100 +37,103 @@ const $e = { class: "drawer-mobile" }, Ie = {
37
37
  open: { type: Boolean, default: !1 },
38
38
  openModifiers: {}
39
39
  }),
40
- emits: /* @__PURE__ */ A(["escapeKeyDown", "pointerDownOutside"], ["update:open"]),
41
- setup(o, { expose: V, emit: q }) {
42
- const i = o, g = q, r = Y(o, "open"), S = ce.smaller(i.breakpointMobile), k = _(), v = `drawer-title-${k}`, h = `drawer-content-${k}`, B = `drawer-body-${k}`, a = ge(() => i.testId), L = b(() => ({
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 ? h : void 0
46
- })), E = b(() => i.title?.as ?? "h2"), F = b(
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"), $ = 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,
52
- contentId: () => h,
51
+ isOpen: () => n.value,
52
+ contentId: () => $,
53
53
  hasPopup: () => "dialog"
54
54
  });
55
- const { lockScroll: U, unlockScroll: Z } = ve(), I = me(() => $.value), C = we(), H = b(
56
- () => i.zIndex === "auto" ? C.zIndex.value : i.zIndex
57
- ), O = ee(!1);
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
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" && (g("escapeKeyDown", e), e.defaultPrevented || p("escapeKey"));
73
+ e.key === "Escape" && (k("escapeKeyDown", e), e.defaultPrevented || p("escapeKey"));
74
74
  }
75
- function X(e) {
76
- g("pointerDownOutside", e), !i.disableOutsidePointerEvents && !e.defaultPrevented && p("outsidePointer");
75
+ function j(e) {
76
+ k("pointerDownOutside", e), !i.disableOutsidePointerEvents && !e.defaultPrevented && p("outsidePointer");
77
77
  }
78
- function R(e, l) {
78
+ function T(e, l) {
79
79
  e.defaultPrevented || !i.beforeClose || (e.preventDefault(), p(l));
80
80
  }
81
- function j(e) {
82
- g("escapeKeyDown", e), R(e, "escapeKey");
83
- }
84
81
  function G(e) {
85
- g("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 = b(() => r.value && !S.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
- C.acquire(), U(), I.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
- I.deactivate(), document.removeEventListener("keydown", P);
95
+ C.deactivate(), document.removeEventListener("keydown", P);
96
96
  },
97
97
  onCloseEnd: () => {
98
- Z(), C.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($, (e) => {
104
- D?.(), D = e ? fe(e, X) : void 0;
105
- }), oe(() => {
106
- D?.(), document.removeEventListener("keydown", P), I.deactivate();
107
- }), V({
104
+ return N(I, (e) => {
105
+ D?.(), D = e ? ve(e, j, {
106
+ ignore: () => y.elementsAbove()
107
+ }) : void 0;
108
+ }), ie(() => {
109
+ D?.(), document.removeEventListener("keydown", P), C.deactivate();
110
+ }), L({
108
111
  requestClose: (e = "programmatic") => p(e)
109
112
  }), (e, l) => t(S) ? (s(), w(t(pe), {
110
113
  key: 0,
111
- open: r.value,
112
- "onUpdate:open": l[0] || (l[0] = (y) => r.value = y),
114
+ open: n.value,
115
+ "onUpdate:open": l[0] || (l[0] = (b) => n.value = b),
113
116
  "z-index": o.zIndex,
114
117
  "disable-outside-pointer-events": o.disableOutsidePointerEvents,
115
118
  "disable-swipe-to-close": !!o.beforeClose,
116
119
  "labelled-by": o.title?.text && !e.$slots.title ? v : void 0,
117
120
  "test-id": o.testId,
118
- onEscapeKeyDown: j,
119
- onPointerDownOutside: G
120
- }, ie({
121
+ onEscapeKeyDown: G,
122
+ onPointerDownOutside: J
123
+ }, se({
121
124
  default: m(() => [
122
- d("div", $e, [
123
- 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({
124
127
  key: 0,
125
128
  id: v,
126
129
  class: "drawer-mobile__title"
127
- }, t(a)("title")), N(o.title.text), 17)) : c("", !0),
128
- o.divider ? (s(), u("div", Ie)) : c("", !0),
129
- 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")), [
130
133
  f(e.$slots, "title", {}, void 0, !0),
131
134
  f(e.$slots, "default", {}, void 0, !0)
132
135
  ], 16),
133
- e.$slots.actions ? (s(), u("div", n({
136
+ e.$slots.actions ? (s(), u("div", r({
134
137
  key: 2,
135
138
  class: "drawer-mobile__actions"
136
139
  }, t(a)("actions")), [
@@ -142,55 +145,57 @@ const $e = { class: "drawer-mobile" }, Ie = {
142
145
  }, [
143
146
  e.$slots.trigger ? {
144
147
  name: "trigger",
145
- fn: m((y) => [
146
- f(e.$slots, "trigger", se(ae(y)), void 0, !0)
148
+ fn: m((b) => [
149
+ f(e.$slots, "trigger", ae(re(b)), void 0, !0)
147
150
  ]),
148
151
  key: "0"
149
152
  } : void 0
150
153
  ]), 1032, ["open", "z-index", "disable-outside-pointer-events", "disable-swipe-to-close", "labelled-by", "test-id"])) : (s(), u(ne, { key: 1 }, [
151
- e.$slots.trigger ? (s(), u("span", n({
154
+ e.$slots.trigger ? (s(), u("span", r({
152
155
  key: 0,
153
156
  ref_key: "triggerRef",
154
157
  ref: z,
155
158
  class: "drawer-trigger"
156
159
  }, t(a)("trigger"), {
157
- onClick: l[1] || (l[1] = (y) => r.value = !0)
160
+ onClick: l[1] || (l[1] = (b) => n.value = !0)
158
161
  }), [
159
- f(e.$slots, "trigger", { props: L.value }, void 0, !0)
162
+ f(e.$slots, "trigger", { props: U.value }, void 0, !0)
160
163
  ], 16)) : c("", !0),
161
- t(Q) ? (s(), w(ye, { key: 1 }, {
164
+ t(W) ? (s(), w(be, { key: 1 }, {
162
165
  default: m(() => [
163
166
  d("div", {
167
+ ref_key: "layerRef",
168
+ ref: M,
164
169
  class: "drawer-layer",
165
- style: re({ zIndex: H.value })
170
+ style: le({ zIndex: _.value })
166
171
  }, [
167
- d("div", n({
172
+ d("div", r({
168
173
  class: "overlay drawer-overlay",
169
- "data-state": t(M)
170
- }, t(a)("overlay")), null, 16, Ce),
171
- d("div", n({
172
- id: h,
174
+ "data-state": t(A)
175
+ }, t(a)("overlay")), null, 16, Oe),
176
+ d("div", r({
177
+ id: $,
173
178
  ref_key: "contentRef",
174
- ref: $,
179
+ ref: I,
175
180
  role: "dialog",
176
181
  "aria-modal": "true",
177
182
  "aria-labelledby": v,
178
183
  "aria-describedby": e.$slots.default ? B : void 0,
179
184
  class: ["drawer-content", `drawer-content--${o.position}`],
180
- "data-state": t(M),
181
- style: F.value
185
+ "data-state": t(A),
186
+ style: Z.value
182
187
  }, { ...e.$attrs, ...t(a)("content") }), [
183
- d("div", Pe, [
184
- o.title?.text ? (s(), w(x(E.value), n({
188
+ d("div", De, [
189
+ o.title?.text ? (s(), w(K(R.value), r({
185
190
  key: 0,
186
191
  id: v,
187
192
  class: "drawer-content__title"
188
193
  }, t(a)("title")), {
189
194
  default: m(() => [
190
- le(N(o.title.text), 1)
195
+ de(x(o.title.text), 1)
191
196
  ]),
192
197
  _: 1
193
- }, 16)) : e.$slots.title ? (s(), w(x(E.value), n({
198
+ }, 16)) : e.$slots.title ? (s(), w(K(R.value), r({
194
199
  key: 1,
195
200
  id: v,
196
201
  class: "drawer-content__title"
@@ -199,37 +204,37 @@ const $e = { class: "drawer-mobile" }, Ie = {
199
204
  f(e.$slots, "title", {}, void 0, !0)
200
205
  ]),
201
206
  _: 3
202
- }, 16)) : (s(), w(he, { key: 2 }, {
207
+ }, 16)) : (s(), w($e, { key: 2 }, {
203
208
  default: m(() => [
204
209
  d("h2", { id: v }, "Боковая панель")
205
210
  ]),
206
211
  _: 1
207
212
  })),
208
- o.closeButton?.enabled ? (s(), u("button", n({
213
+ o.closeButton?.enabled ? (s(), u("button", r({
209
214
  key: 3,
210
215
  type: "button",
211
216
  class: "drawer-content__close",
212
217
  "aria-label": o.closeButton.label ?? "Закрыть"
213
218
  }, t(a)("close"), {
214
- onClick: l[2] || (l[2] = (y) => p("closeButton"))
219
+ onClick: l[2] || (l[2] = (b) => p("closeButton"))
215
220
  }), [
216
- de(t(ue), { size: 20 })
217
- ], 16, De)) : c("", !0)
221
+ ue(t(ce), { size: 20 })
222
+ ], 16, Ee)) : c("", !0)
218
223
  ]),
219
224
  o.divider ? (s(), u("div", Se)) : c("", !0),
220
- d("div", n({
225
+ d("div", r({
221
226
  id: B,
222
227
  class: "drawer-content__wrapper"
223
228
  }, t(a)("body")), [
224
229
  f(e.$slots, "default", {}, void 0, !0)
225
230
  ], 16),
226
- e.$slots.actions ? (s(), u("div", n({
231
+ e.$slots.actions ? (s(), u("div", r({
227
232
  key: 1,
228
233
  class: "drawer-content__actions"
229
234
  }, t(a)("actions")), [
230
235
  f(e.$slots, "actions", {}, void 0, !0)
231
236
  ], 16)) : c("", !0)
232
- ], 16, Oe)
237
+ ], 16, Pe)
233
238
  ], 4)
234
239
  ]),
235
240
  _: 3
@@ -238,5 +243,5 @@ const $e = { class: "drawer-mobile" }, Ie = {
238
243
  }
239
244
  });
240
245
  export {
241
- Ue as default
246
+ Ze as default
242
247
  };
@@ -17,5 +17,15 @@ export interface UseLayerZIndexReturn {
17
17
  zIndex: Ref<number | undefined>;
18
18
  acquire: () => void;
19
19
  release: () => void;
20
+ /** Элемент контента слоя — источник для чужого `elementsAbove()`. */
21
+ registerElement: (el: HTMLElement | null) => void;
22
+ /**
23
+ * DOM-элементы слоёв, открытых позже текущего (значит, лежащих выше по
24
+ * z-index) — например, ConfirmDialog поверх BottomSheet. Передавать в
25
+ * `onClickOutside` как `ignore`: клик по вложенному слою не должен
26
+ * считаться «кликом вне» текущего — иначе закрытие вложенного окна
27
+ * утаскивало бы за собой и родителя.
28
+ */
29
+ elementsAbove: () => HTMLElement[];
20
30
  }
21
31
  export declare function useLayerZIndex(): UseLayerZIndexReturn;
@@ -1,18 +1,30 @@
1
- import { ref as u, onBeforeUnmount as a } from "vue";
2
- const i = 1e3, f = 10;
3
- let n = 0, o = 0;
4
- function l() {
5
- const e = u();
6
- function r() {
7
- e.value === void 0 && (n++, o++, e.value = i + o * f);
1
+ import { ref as a, onBeforeUnmount as d } from "vue";
2
+ const v = 1e3, x = 10;
3
+ let i = 0, u = 0;
4
+ const o = [];
5
+ function m() {
6
+ const t = a();
7
+ let e;
8
+ function f() {
9
+ t.value === void 0 && (i++, u++, t.value = v + u * x, e = { zIndex: t.value, el: null }, o.push(e));
8
10
  }
9
- function t() {
10
- e.value !== void 0 && (e.value = void 0, n = Math.max(0, n - 1), n === 0 && (o = 0));
11
+ function l() {
12
+ if (t.value !== void 0 && (t.value = void 0, i = Math.max(0, i - 1), i === 0 && (u = 0), e)) {
13
+ const n = o.indexOf(e);
14
+ n !== -1 && o.splice(n, 1), e = void 0;
15
+ }
11
16
  }
12
- return a(t), { zIndex: e, acquire: r, release: t };
17
+ function s(n) {
18
+ e && (e.el = n);
19
+ }
20
+ function c() {
21
+ const n = e;
22
+ return n ? o.filter((r) => r !== n && r.zIndex > n.zIndex).map((r) => r.el).filter((r) => r !== null) : [];
23
+ }
24
+ return d(l), { zIndex: t, acquire: f, release: l, registerElement: s, elementsAbove: c };
13
25
  }
14
26
  export {
15
- i as LAYER_BASE_Z_INDEX,
16
- f as LAYER_Z_INDEX_STEP,
17
- l as useLayerZIndex
27
+ v as LAYER_BASE_Z_INDEX,
28
+ x as LAYER_Z_INDEX_STEP,
29
+ m as useLayerZIndex
18
30
  };
@@ -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.5",
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",