@ac-design/design-system 2.2.0 → 2.2.1

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
1
  import e from "./AcButton.js";
2
- import { Teleport as t, Transition as n, computed as r, createBlock as i, createCommentVNode as a, createElementBlock as o, createVNode as s, defineComponent as c, mergeModels as l, nextTick as u, normalizeClass as d, normalizeStyle as f, onBeforeUnmount as p, onMounted as m, onUpdated as h, openBlock as g, provide as _, ref as v, renderSlot as y, toRef as ee, unref as b, useId as x, useModel as S, useSlots as te, watch as C, withCtx as w } from "vue";
3
- import { ChevronDown as T, Ellipsis as E } from "@lucide/vue";
2
+ import { fixedFrame as t } from "./fixedFrame.js";
3
+ import { Teleport as n, Transition as r, computed as i, createBlock as a, createCommentVNode as o, createElementBlock as s, createVNode as c, defineComponent as l, mergeModels as u, nextTick as d, normalizeClass as f, normalizeStyle as ee, onBeforeUnmount as te, onMounted as p, onUpdated as m, openBlock as h, provide as g, ref as _, renderSlot as v, toRef as y, unref as b, useId as x, useModel as S, useSlots as C, watch as w, withCtx as T } from "vue";
4
+ import { ChevronDown as E, Ellipsis as D } from "@lucide/vue";
4
5
  //#region src/lib/components/AcDropdown.vue?vue&type=script&setup=true&lang.ts
5
- var ne = ["aria-label", "disabled"], re = ["aria-labelledby", "aria-label"], D = "[role=\"menuitem\"]:not([aria-disabled=\"true\"])", O = /*@__PURE__*/ c({
6
+ var O = ["aria-label", "disabled"], k = ["aria-labelledby", "aria-label"], A = "[role=\"menuitem\"]:not([aria-disabled=\"true\"])", j = /*@__PURE__*/ l({
6
7
  __name: "AcDropdown",
7
- props: /*@__PURE__*/ l({
8
+ props: /*@__PURE__*/ u({
8
9
  label: { default: "" },
9
10
  menuLabel: { default: "Actions" },
10
11
  align: { default: "start" },
@@ -22,24 +23,24 @@ var ne = ["aria-label", "disabled"], re = ["aria-labelledby", "aria-label"], D =
22
23
  openModifiers: {}
23
24
  }),
24
25
  emits: ["update:open"],
25
- setup(c) {
26
- let l = c, O = S(c, "open"), k = te(), A = {
26
+ setup(l) {
27
+ let u = l, j = S(l, "open"), M = C(), ne = {
27
28
  menu: 240,
28
29
  panel: 320
29
- }, j = {
30
+ }, re = {
30
31
  "top-start": "origin-top-left",
31
32
  "top-end": "origin-top-right",
32
33
  "bottom-start": "origin-bottom-left",
33
34
  "bottom-end": "origin-bottom-right"
34
- }, M = {
35
+ }, ie = {
35
36
  menu: "rounded-10 border-border py-1",
36
37
  panel: "rounded-14 border-border/80 p-2"
37
- }, N = x(), P = `${N}-menu`, F = v(null), I = v(null), L = v({}), R = v(!1), z = v(""), B = null, V = "menu", H = "", U, W = r(() => j[`${R.value ? "top" : "bottom"}-${l.align}`]);
38
+ }, N = x(), P = `${N}-menu`, F = _(null), I = _(null), L = _({}), R = _(!1), z = _(""), B = null, V = "menu", H = "", U, W = i(() => re[`${R.value ? "top" : "bottom"}-${u.align}`]);
38
39
  function G() {
39
- B = F.value?.querySelector("button, a[href], [tabindex]") ?? null, B && (B.id || (B.id = `${N}-trigger`), z.value = B.id, B.setAttribute("aria-haspopup", "menu"), B.setAttribute("aria-expanded", String(O.value)), O.value ? B.setAttribute("aria-controls", P) : B.removeAttribute("aria-controls"));
40
+ B = F.value?.querySelector("button, a[href], [tabindex]") ?? null, B && (B.id || (B.id = `${N}-trigger`), z.value = B.id, B.setAttribute("aria-haspopup", "menu"), B.setAttribute("aria-expanded", String(j.value)), j.value ? B.setAttribute("aria-controls", P) : B.removeAttribute("aria-controls"));
40
41
  }
41
42
  function K() {
42
- return [...I.value?.querySelectorAll(D) ?? []];
43
+ return [...I.value?.querySelectorAll(A) ?? []];
43
44
  }
44
45
  function q(e) {
45
46
  let t = K();
@@ -47,44 +48,44 @@ var ne = ["aria-label", "disabled"], re = ["aria-labelledby", "aria-label"], D =
47
48
  t[e === "first" ? 0 : e === "last" ? t.length - 1 : (e + t.length) % t.length]?.focus();
48
49
  }
49
50
  function J(e) {
50
- l.disabled || (V = e, O.value = !0);
51
+ u.disabled || (V = e, j.value = !0);
51
52
  }
52
53
  function Y(e = !0) {
53
- O.value && (O.value = !1, e && B?.focus());
54
+ j.value && (j.value = !1, e && B?.focus());
54
55
  }
55
56
  function X() {
56
57
  if (!B || !I.value) return;
57
- let e = B.getBoundingClientRect(), t = `${Math.min(Math.max(e.width, A[l.variant]), window.innerWidth - 16)}px`;
58
- I.value.style.minWidth = t;
59
- let { offsetWidth: n, offsetHeight: r } = I.value, i = window.innerHeight - e.bottom - 8 - 8, a = e.top - 8 - 8, o = l.placement === "top" ? a >= r || a > i : i < r && a > i, s = l.align === "end" ? e.right - n : e.left;
60
- R.value = !o, L.value = {
61
- [o ? "bottom" : "top"]: `${o ? window.innerHeight - e.top + 8 : e.bottom + 8}px`,
62
- left: `${Math.max(8, Math.min(s, window.innerWidth - n - 8))}px`,
63
- minWidth: t,
64
- maxHeight: `${Math.max(o ? a : i, 120)}px`
58
+ let e = B.getBoundingClientRect(), n = t(), r = `${Math.min(Math.max(e.width, ne[u.variant]), n.width - 16)}px`;
59
+ I.value.style.minWidth = r;
60
+ let { offsetWidth: i, offsetHeight: a } = I.value, o = n.bottom - e.bottom - 8 - 8, s = e.top - n.top - 8 - 8, c = u.placement === "top" ? s >= a || s > o : o < a && s > o, l = (u.align === "end" ? e.right - i : e.left) - n.left;
61
+ R.value = !c, L.value = {
62
+ [c ? "bottom" : "top"]: `${c ? n.bottom - e.top + 8 : e.bottom + 8 - n.top}px`,
63
+ left: `${Math.max(8, Math.min(l, n.width - i - 8))}px`,
64
+ minWidth: r,
65
+ maxHeight: `${Math.max(c ? s : o, 120)}px`
65
66
  };
66
67
  }
67
- function ie(e) {
68
+ function ae(e) {
68
69
  if (B?.contains(e.target)) {
69
- if (O.value) return Y();
70
+ if (j.value) return Y();
70
71
  J(e.detail === 0 ? "first" : "menu");
71
72
  }
72
73
  }
73
- function ae(e) {
74
+ function oe(e) {
74
75
  if (e.key === "ArrowDown" || e.key === "ArrowUp") {
75
- if (e.preventDefault(), O.value) return q(e.key === "ArrowDown" ? "first" : "last");
76
+ if (e.preventDefault(), j.value) return q(e.key === "ArrowDown" ? "first" : "last");
76
77
  J(e.key === "ArrowDown" ? "first" : "last");
77
78
  }
78
79
  }
79
- function oe(e) {
80
+ function se(e) {
80
81
  let t = K(), n = t.indexOf(document.activeElement);
81
82
  if (e.key === "ArrowDown" || e.key === "ArrowUp") {
82
83
  e.preventDefault();
83
84
  let t = e.key === "ArrowDown" ? 1 : -1;
84
85
  q(n < 0 ? t > 0 ? "first" : "last" : n + t);
85
- } else e.key === "Home" || e.key === "End" ? (e.preventDefault(), q(e.key === "Home" ? "first" : "last")) : e.key === "Escape" ? (e.preventDefault(), Y()) : e.key === "Tab" ? Y() : e.key === " " && n >= 0 && t[n].tagName !== "BUTTON" ? (e.preventDefault(), t[n].click()) : e.key.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey && e.key !== " " && se(e.key, t, n);
86
+ } else e.key === "Home" || e.key === "End" ? (e.preventDefault(), q(e.key === "Home" ? "first" : "last")) : e.key === "Escape" ? (e.preventDefault(), Y()) : e.key === "Tab" ? Y() : e.key === " " && n >= 0 && t[n].tagName !== "BUTTON" ? (e.preventDefault(), t[n].click()) : e.key.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey && e.key !== " " && ce(e.key, t, n);
86
87
  }
87
- function se(e, t, n) {
88
+ function ce(e, t, n) {
88
89
  H += e.toLowerCase(), clearTimeout(U), U = setTimeout(() => H = "", 500);
89
90
  let r = (e) => (e.dataset.acLabel || e.textContent || "").trim().toLowerCase(), i = H.length === 1 ? n + 1 : Math.max(n, 0);
90
91
  [...t.slice(i), ...t.slice(0, i)].find((e) => r(e).startsWith(H))?.focus();
@@ -99,49 +100,49 @@ var ne = ["aria-label", "disabled"], re = ["aria-labelledby", "aria-label"], D =
99
100
  function $(e) {
100
101
  e ? (document.addEventListener("pointerdown", Z, !0), window.addEventListener("scroll", Q, !0), window.addEventListener("resize", Q)) : (document.removeEventListener("pointerdown", Z, !0), window.removeEventListener("scroll", Q, !0), window.removeEventListener("resize", Q));
101
102
  }
102
- return _("ac-dropdown", {
103
+ return g("ac-dropdown", {
103
104
  close: Y,
104
105
  focusMenu: () => I.value?.focus(),
105
- variant: ee(l, "variant")
106
- }), C(O, async (e) => {
107
- G(), $(e), e && (await u(), X(), V === "menu" ? I.value?.focus() : q(V), V = "menu");
108
- }), m(G), h(G), p(() => {
106
+ variant: y(u, "variant")
107
+ }), w(j, async (e) => {
108
+ G(), $(e), e && (await d(), X(), V === "menu" ? I.value?.focus() : q(V), V = "menu");
109
+ }), p(G), m(G), te(() => {
109
110
  $(!1), clearTimeout(U);
110
- }), (r, l) => (g(), o("div", {
111
+ }), (t, i) => (h(), s("div", {
111
112
  ref_key: "root",
112
113
  ref: F,
113
114
  class: "inline-flex",
114
115
  "data-ac-ds": "",
115
116
  "data-testid": "ac-dropdown",
116
- onClick: ie,
117
- onKeydown: ae
118
- }, [k.trigger ? y(r.$slots, "trigger", { open: O.value }, void 0, void 0, 0) : c.label ? (g(), i(e, {
117
+ onClick: ae,
118
+ onKeydown: oe
119
+ }, [M.trigger ? v(t.$slots, "trigger", { open: j.value }, void 0, void 0, 0) : l.label ? (h(), a(e, {
119
120
  key: 1,
120
- title: c.label,
121
+ title: l.label,
121
122
  color: "white",
122
- disabled: c.disabled
123
+ disabled: l.disabled
123
124
  }, {
124
- default: w(() => [s(b(T), {
125
- class: d(["-mr-1 text-muted transition-transform duration-200", O.value && "rotate-180"]),
125
+ default: T(() => [c(b(E), {
126
+ class: f(["-mr-1 text-muted transition-transform duration-200", j.value && "rotate-180"]),
126
127
  "aria-hidden": "true"
127
128
  }, null, 8, ["class"])]),
128
129
  _: 1
129
- }, 8, ["title", "disabled"])) : (g(), o("button", {
130
+ }, 8, ["title", "disabled"])) : (h(), s("button", {
130
131
  key: 2,
131
132
  type: "button",
132
- "aria-label": c.menuLabel,
133
- disabled: c.disabled,
134
- class: d(["inline-flex size-7 cursor-pointer items-center justify-center rounded-8 text-muted transition-colors duration-200 hover:bg-surface-sunken hover:text-heading focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-surface focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50", O.value && "bg-surface-sunken text-heading"])
135
- }, [s(b(E), {
133
+ "aria-label": l.menuLabel,
134
+ disabled: l.disabled,
135
+ class: f(["inline-flex size-7 cursor-pointer items-center justify-center rounded-8 text-muted transition-colors duration-200 hover:bg-surface-sunken hover:text-heading focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-surface focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50", j.value && "bg-surface-sunken text-heading"])
136
+ }, [c(b(D), {
136
137
  class: "size-4",
137
138
  "aria-hidden": "true"
138
- })], 10, ne)), (g(), i(t, { to: "body" }, [s(n, {
139
+ })], 10, O)), (h(), a(n, { to: "body" }, [c(r, {
139
140
  "enter-active-class": "transition-[opacity,scale] duration-150 ease-out motion-reduce:transition-none",
140
141
  "enter-from-class": "opacity-0 motion-safe:scale-95",
141
142
  "leave-active-class": "transition-[opacity,scale] duration-100 ease-in motion-reduce:transition-none",
142
143
  "leave-to-class": "opacity-0 motion-safe:scale-95"
143
144
  }, {
144
- default: w(() => [O.value ? (g(), o("div", {
145
+ default: T(() => [j.value ? (h(), s("div", {
145
146
  key: 0,
146
147
  id: P,
147
148
  ref_key: "panel",
@@ -149,17 +150,17 @@ var ne = ["aria-label", "disabled"], re = ["aria-labelledby", "aria-label"], D =
149
150
  role: "menu",
150
151
  tabindex: "-1",
151
152
  "aria-orientation": "vertical",
152
- "aria-labelledby": (k.trigger || c.label) && z.value ? z.value : void 0,
153
- "aria-label": k.trigger || c.label ? void 0 : c.menuLabel,
154
- class: d(["ac-scrollbar fixed z-[90] flex w-max max-w-[min(320px,calc(100vw-16px))] flex-col border bg-surface shadow-lg outline-none", [M[c.variant], W.value]]),
155
- style: f(L.value),
153
+ "aria-labelledby": (M.trigger || l.label) && z.value ? z.value : void 0,
154
+ "aria-label": M.trigger || l.label ? void 0 : l.menuLabel,
155
+ class: f(["ac-scrollbar fixed z-[90] flex w-max max-w-[min(320px,calc(100vw-16px))] flex-col border bg-surface shadow-lg outline-none", [ie[l.variant], W.value]]),
156
+ style: ee(L.value),
156
157
  "data-ac-ds": "",
157
158
  "data-testid": "ac-dropdown-menu",
158
- onKeydown: oe
159
- }, [y(r.$slots, "default")], 46, re)) : a("", !0)]),
159
+ onKeydown: se
160
+ }, [v(t.$slots, "default")], 46, k)) : o("", !0)]),
160
161
  _: 3
161
162
  })]))], 544));
162
163
  }
163
164
  });
164
165
  //#endregion
165
- export { O as default };
166
+ export { j as default };
@@ -1,7 +1,8 @@
1
1
  import e from "./AcButton.js";
2
- import { computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createVNode as o, defineComponent as s, inject as c, normalizeClass as l, normalizeStyle as u, onBeforeUnmount as d, onMounted as f, openBlock as p, ref as m, renderSlot as h, watch as g } from "vue";
2
+ import { fixedFrame as t } from "./fixedFrame.js";
3
+ import { computed as n, createBlock as r, createCommentVNode as i, createElementBlock as a, createElementVNode as o, createVNode as s, defineComponent as c, inject as l, normalizeClass as u, normalizeStyle as d, onBeforeUnmount as f, onMounted as p, openBlock as m, ref as h, renderSlot as g, watch as _ } from "vue";
3
4
  //#region src/lib/components/AcFormFooter.vue?vue&type=script&setup=true&lang.ts
4
- var _ = { class: "flex min-w-0 items-center gap-2 text-base text-muted" }, v = { class: "ml-auto flex items-center gap-3" }, y = /*@__PURE__*/ s({
5
+ var v = { class: "flex min-w-0 items-center gap-2 text-base text-muted" }, y = { class: "ml-auto flex items-center gap-3" }, b = /*@__PURE__*/ c({
5
6
  __name: "AcFormFooter",
6
7
  props: {
7
8
  submitLabel: { default: "Save" },
@@ -22,58 +23,58 @@ var _ = { class: "flex min-w-0 items-center gap-2 text-base text-muted" }, v = {
22
23
  form: { default: "" }
23
24
  },
24
25
  emits: ["cancel", "save"],
25
- setup(s, { emit: y }) {
26
- let b = s, x = y, S = c("ac-form", null), C = m(null), w = m(null), T = m({
26
+ setup(c, { emit: b }) {
27
+ let x = c, S = b, C = l("ac-form", null), w = h(null), T = h(null), E = h({
27
28
  left: 0,
28
29
  width: 0,
29
30
  height: 0
30
- }), E, D = t(() => S?.widthClass.value ?? "");
31
- function O(e) {
32
- e.currentTarget?.form || x("save");
31
+ }), D, O = n(() => C?.widthClass.value ?? "");
32
+ function k(e) {
33
+ e.currentTarget?.form || S("save");
33
34
  }
34
- function k() {
35
- if (!C.value || !w.value) return;
36
- let e = C.value.getBoundingClientRect();
37
- T.value = {
38
- left: e.left,
35
+ function A() {
36
+ if (!w.value || !T.value) return;
37
+ let e = w.value.getBoundingClientRect();
38
+ E.value = {
39
+ left: e.left - t().left,
39
40
  width: e.width,
40
- height: w.value.offsetHeight
41
+ height: T.value.offsetHeight
41
42
  };
42
43
  }
43
- function A() {
44
- j(), b.sticky === "viewport" && C.value && w.value && (k(), E = new ResizeObserver(k), E.observe(C.value), E.observe(w.value), window.addEventListener("resize", k));
45
- }
46
44
  function j() {
47
- E?.disconnect(), E = void 0, window.removeEventListener("resize", k);
45
+ M(), x.sticky === "viewport" && w.value && T.value && (A(), D = new ResizeObserver(A), D.observe(w.value), D.observe(T.value), window.addEventListener("resize", A));
48
46
  }
49
- return g(() => b.sticky, A, { flush: "post" }), f(A), d(j), (t, c) => (p(), i("div", {
47
+ function M() {
48
+ D?.disconnect(), D = void 0, window.removeEventListener("resize", A);
49
+ }
50
+ return _(() => x.sticky, j, { flush: "post" }), p(j), f(M), (t, n) => (m(), a("div", {
50
51
  ref_key: "root",
51
- ref: C,
52
- class: l(["mt-4 w-full", [s.sticky === "container" && "sticky bottom-0 z-10", s.sticky !== "viewport" && D.value]]),
53
- style: u(s.sticky === "viewport" ? { height: `${T.value.height}px` } : void 0),
52
+ ref: w,
53
+ class: u(["mt-4 w-full", [c.sticky === "container" && "sticky bottom-0 z-10", c.sticky !== "viewport" && O.value]]),
54
+ style: d(c.sticky === "viewport" ? { height: `${E.value.height}px` } : void 0),
54
55
  "data-ac-ds": "",
55
56
  "data-testid": "ac-form-footer"
56
- }, [a("div", {
57
+ }, [o("div", {
57
58
  ref_key: "bar",
58
- ref: w,
59
- class: l(["border-t border-border bg-surface py-4", s.sticky === "viewport" && "fixed bottom-0 z-40 px-4"]),
60
- style: u(s.sticky === "viewport" ? {
61
- left: `${T.value.left}px`,
62
- width: `${T.value.width}px`
59
+ ref: T,
60
+ class: u(["border-t border-border bg-surface py-4", c.sticky === "viewport" && "fixed bottom-0 z-40 px-4"]),
61
+ style: d(c.sticky === "viewport" ? {
62
+ left: `${E.value.left}px`,
63
+ width: `${E.value.width}px`
63
64
  } : void 0)
64
- }, [a("div", { class: l(["flex w-full flex-wrap items-center justify-between gap-x-4 gap-y-2", D.value]) }, [a("div", _, [h(t.$slots, "left")]), a("div", v, [h(t.$slots, "right", {}, () => [s.hideCancel ? r("", !0) : (p(), n(e, {
65
+ }, [o("div", { class: u(["flex w-full flex-wrap items-center justify-between gap-x-4 gap-y-2", O.value]) }, [o("div", v, [g(t.$slots, "left")]), o("div", y, [g(t.$slots, "right", {}, () => [c.hideCancel ? i("", !0) : (m(), r(e, {
65
66
  key: 0,
66
- title: s.cancelLabel,
67
+ title: c.cancelLabel,
67
68
  color: "white",
68
- disabled: s.loading,
69
- onClick: c[0] ||= (e) => x("cancel")
70
- }, null, 8, ["title", "disabled"])), o(e, {
71
- title: s.submitLabel,
69
+ disabled: c.loading,
70
+ onClick: n[0] ||= (e) => S("cancel")
71
+ }, null, 8, ["title", "disabled"])), s(e, {
72
+ title: c.submitLabel,
72
73
  type: "submit",
73
- form: s.form || void 0,
74
- loading: s.loading,
75
- disabled: s.disabled,
76
- onClick: O
74
+ form: c.form || void 0,
75
+ loading: c.loading,
76
+ disabled: c.disabled,
77
+ onClick: k
77
78
  }, null, 8, [
78
79
  "title",
79
80
  "form",
@@ -83,4 +84,4 @@ var _ = { class: "flex min-w-0 items-center gap-2 text-base text-muted" }, v = {
83
84
  }
84
85
  });
85
86
  //#endregion
86
- export { y as default };
87
+ export { b as default };
@@ -82,7 +82,9 @@ var w = [
82
82
  let t = document.body, n = Number(t.dataset.acModals ?? 0) + (e ? 1 : -1);
83
83
  if (t.dataset.acModals = String(Math.max(n, 0)), e && n === 1) {
84
84
  let e = window.innerWidth - document.documentElement.clientWidth;
85
- t.style.overflow = "hidden", e > 0 && (t.style.paddingRight = `${e}px`);
85
+ t.style.overflow = "hidden";
86
+ let n = getComputedStyle(document.documentElement).scrollbarGutter.includes("stable");
87
+ e > 0 && !n && (t.style.paddingRight = `${e}px`);
86
88
  } else !e && n <= 0 && (t.style.overflow = "", t.style.paddingRight = "");
87
89
  }
88
90
  return b(V, async (e, t) => {