@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,52 +1,53 @@
1
1
  import e from "./AcNavbarItem.js";
2
- import t from "./AcSkeleton.js";
3
- import { Fragment as n, Teleport as r, Transition as i, computed as a, createBlock as o, createCommentVNode as s, createElementBlock as c, createElementVNode as l, createTextVNode as u, createVNode as d, defineComponent as f, getCurrentInstance as p, mergeModels as m, mergeProps as h, nextTick as g, normalizeClass as _, normalizeStyle as ee, onBeforeUnmount as te, openBlock as v, ref as y, renderList as b, renderSlot as x, resolveDynamicComponent as S, toDisplayString as C, unref as w, useId as T, useModel as ne, watch as E, withCtx as D } from "vue";
4
- import { ArrowRight as re, Bell as ie, BellOff as ae } from "@lucide/vue";
2
+ import { fixedFrame as t } from "./fixedFrame.js";
3
+ import n from "./AcSkeleton.js";
4
+ import { Fragment as r, Teleport as i, Transition as a, computed as o, createBlock as s, createCommentVNode as c, createElementBlock as l, createElementVNode as u, createTextVNode as d, createVNode as f, defineComponent as p, getCurrentInstance as m, mergeModels as h, mergeProps as g, nextTick as _, normalizeClass as v, normalizeStyle as ee, onBeforeUnmount as te, openBlock as y, ref as b, renderList as x, renderSlot as S, resolveDynamicComponent as C, toDisplayString as w, unref as T, useId as ne, useModel as re, watch as E, withCtx as D } from "vue";
5
+ import { ArrowRight as ie, Bell as ae, BellOff as oe } from "@lucide/vue";
5
6
  //#region src/lib/components/AcNotificationMenu.vue?vue&type=script&setup=true&lang.ts
6
- var oe = {
7
+ var se = {
7
8
  class: "inline-flex",
8
9
  "data-ac-ds": "",
9
10
  "data-testid": "ac-notification-menu"
10
- }, se = { class: "flex shrink-0 items-center justify-between gap-2 border-b border-border p-3" }, ce = {
11
+ }, ce = { class: "flex shrink-0 items-center justify-between gap-2 border-b border-border p-3" }, le = {
11
12
  key: 0,
12
13
  class: "sr-only"
13
- }, le = {
14
+ }, ue = {
14
15
  key: 0,
15
16
  class: "flex flex-col gap-4 p-3",
16
17
  "aria-busy": "true",
17
18
  role: "status",
18
19
  "aria-label": "Loading notifications"
19
- }, ue = {
20
+ }, de = {
20
21
  key: 1,
21
22
  class: "flex flex-col items-center gap-3 px-6 py-10 text-center"
22
- }, de = {
23
+ }, fe = {
23
24
  class: "inline-flex size-12 items-center justify-center rounded-14 bg-primary/10 text-primary-strong",
24
25
  "aria-hidden": "true"
25
- }, fe = { class: "text-lg font-semibold text-heading" }, pe = {
26
+ }, pe = { class: "text-lg font-semibold text-heading" }, me = {
26
27
  key: 2,
27
28
  role: "list",
28
29
  class: "ac-scrollbar min-h-0 flex-1 divide-y divide-border",
29
30
  "data-ac-ds": "",
30
31
  "data-testid": "ac-notification-menu-list"
31
- }, me = { class: "flex items-center gap-2" }, he = { class: "line-clamp-2 min-w-0 text-base font-medium text-heading" }, ge = {
32
+ }, he = { class: "flex items-center gap-2" }, ge = { class: "line-clamp-2 min-w-0 text-base font-medium text-heading" }, _e = {
32
33
  key: 1,
33
34
  class: "size-2 shrink-0 rounded-full bg-primary",
34
35
  "aria-hidden": "true"
35
- }, _e = {
36
+ }, ve = {
36
37
  key: 2,
37
38
  class: "sr-only"
38
- }, ve = {
39
+ }, ye = {
39
40
  key: 0,
40
41
  class: "mt-1 line-clamp-2 block text-xs text-muted"
41
- }, ye = { class: "mt-1 flex items-center gap-1.5 text-xs text-muted" }, be = {
42
+ }, be = { class: "mt-1 flex items-center gap-1.5 text-xs text-muted" }, xe = {
42
43
  key: 1,
43
44
  "aria-hidden": "true"
44
- }, xe = ["datetime", "title"], Se = {
45
+ }, Se = ["datetime", "title"], Ce = {
45
46
  key: 3,
46
47
  class: "shrink-0 border-t border-border p-1.5"
47
- }, Ce = "[data-notification-item]", we = 6048e5, O = /*@__PURE__*/ f({
48
+ }, we = "[data-notification-item]", Te = 6048e5, O = /*@__PURE__*/ p({
48
49
  __name: "AcNotificationMenu",
49
- props: /*@__PURE__*/ m({
50
+ props: /*@__PURE__*/ h({
50
51
  notifications: { default: () => [] },
51
52
  unreadCount: { default: void 0 },
52
53
  loading: {
@@ -66,13 +67,13 @@ var oe = {
66
67
  },
67
68
  openModifiers: {}
68
69
  }),
69
- emits: /*@__PURE__*/ m([
70
+ emits: /*@__PURE__*/ h([
70
71
  "select",
71
72
  "markAllRead",
72
73
  "viewAll"
73
74
  ], ["update:open"]),
74
- setup(f, { emit: m }) {
75
- let O = f, k = ne(f, "open"), A = m, Te = {
75
+ setup(p, { emit: h }) {
76
+ let O = p, k = re(p, "open"), A = h, Ee = {
76
77
  success: "success",
77
78
  succeeded: "success",
78
79
  completed: "success",
@@ -91,7 +92,7 @@ var oe = {
91
92
  inprogress: "info",
92
93
  progressing: "info",
93
94
  info: "info"
94
- }, Ee = {
95
+ }, De = {
95
96
  success: "text-success-strong",
96
97
  danger: "text-danger-strong",
97
98
  warning: "text-warning-strong",
@@ -100,30 +101,30 @@ var oe = {
100
101
  }, j = new Intl.RelativeTimeFormat(void 0, {
101
102
  numeric: "auto",
102
103
  style: "narrow"
103
- }), De = new Intl.DateTimeFormat(void 0, {
104
+ }), Oe = new Intl.DateTimeFormat(void 0, {
104
105
  dateStyle: "medium",
105
106
  timeStyle: "short"
106
- }), Oe = new Intl.DateTimeFormat(void 0, {
107
+ }), ke = new Intl.DateTimeFormat(void 0, {
107
108
  month: "short",
108
109
  day: "numeric"
109
- }), M = p()?.appContext.components.RouterLink, N = T(), P = `${N}-panel`, F = `${N}-heading`, I = y(null), L = y(null), R = y({}), z = y(!0), B = y(Date.now()), V, H = a(() => O.unreadCount ?? O.notifications.filter((e) => !e.read).length), ke = a(() => O.notifications.some((e) => !e.read)), Ae = a(() => !!(O.viewAllHref || O.viewAllTo));
110
- function je(e) {
111
- return e.type ? e.type : Te[(e.status ?? "").toLowerCase().replace(/[^a-z]/g, "")] ?? "neutral";
110
+ }), M = m()?.appContext.components.RouterLink, N = ne(), P = `${N}-panel`, F = `${N}-heading`, I = b(null), L = b(null), R = b({}), z = b(!0), B = b(Date.now()), V, H = o(() => O.unreadCount ?? O.notifications.filter((e) => !e.read).length), Ae = o(() => O.notifications.some((e) => !e.read)), je = o(() => !!(O.viewAllHref || O.viewAllTo));
111
+ function Me(e) {
112
+ return e.type ? e.type : Ee[(e.status ?? "").toLowerCase().replace(/[^a-z]/g, "")] ?? "neutral";
112
113
  }
113
114
  function U(e) {
114
115
  return e instanceof Date ? e.getTime() : typeof e == "number" ? e < 1e11 ? e * 1e3 : e : new Date(e).getTime();
115
116
  }
116
- function Me(e) {
117
+ function Ne(e) {
117
118
  let t = U(e);
118
119
  if (Number.isNaN(t)) return "";
119
120
  let n = t - B.value, r = Math.abs(n);
120
- return r < 45e3 ? "Just now" : r >= we ? Oe.format(t) : r < 36e5 ? j.format(Math.round(n / 6e4), "minute") : r < 864e5 ? j.format(Math.round(n / 36e5), "hour") : j.format(Math.round(n / 864e5), "day");
121
+ return r < 45e3 ? "Just now" : r >= Te ? ke.format(t) : r < 36e5 ? j.format(Math.round(n / 6e4), "minute") : r < 864e5 ? j.format(Math.round(n / 36e5), "hour") : j.format(Math.round(n / 864e5), "day");
121
122
  }
122
- function Ne(e) {
123
+ function Pe(e) {
123
124
  let t = U(e);
124
- return Number.isNaN(t) ? "" : De.format(t);
125
+ return Number.isNaN(t) ? "" : Oe.format(t);
125
126
  }
126
- function Pe(e) {
127
+ function Fe(e) {
127
128
  let t = U(e);
128
129
  return Number.isNaN(t) ? void 0 : new Date(t).toISOString();
129
130
  }
@@ -138,7 +139,7 @@ var oe = {
138
139
  return I.value?.$el ?? null;
139
140
  }
140
141
  function q() {
141
- return [...L.value?.querySelectorAll(Ce) ?? []];
142
+ return [...L.value?.querySelectorAll(we) ?? []];
142
143
  }
143
144
  function J(e) {
144
145
  let t = q();
@@ -147,37 +148,37 @@ var oe = {
147
148
  function Y() {
148
149
  let e = K();
149
150
  if (!e || !L.value) return;
150
- let t = e.getBoundingClientRect(), { offsetWidth: n, offsetHeight: r } = L.value, i = window.innerHeight - t.bottom - 6 - 8, a = t.top - 6 - 8, o = i < r && a > i, s = O.align === "end" ? t.right - n : t.left;
151
- z.value = !o, R.value = {
152
- [o ? "bottom" : "top"]: `${o ? window.innerHeight - t.top + 6 : t.bottom + 6}px`,
153
- left: `${Math.max(8, Math.min(s, window.innerWidth - n - 8))}px`,
154
- maxHeight: `${Math.max(o ? a : i, 200)}px`
151
+ let n = e.getBoundingClientRect(), r = t(), { offsetWidth: i, offsetHeight: a } = L.value, o = r.bottom - n.bottom - 6 - 8, s = n.top - r.top - 6 - 8, c = o < a && s > o, l = (O.align === "end" ? n.right - i : n.left) - r.left;
152
+ z.value = !c, R.value = {
153
+ [c ? "bottom" : "top"]: `${c ? r.bottom - n.top + 6 : n.bottom + 6 - r.top}px`,
154
+ left: `${Math.max(8, Math.min(l, r.width - i - 8))}px`,
155
+ maxHeight: `${Math.max(c ? s : o, 200)}px`
155
156
  };
156
157
  }
157
158
  function X(e = !0) {
158
159
  k.value && (k.value = !1, e && K()?.focus());
159
160
  }
160
- function Z() {
161
+ function Ie() {
161
162
  k.value ? X() : k.value = !0;
162
163
  }
163
- function Fe(e) {
164
+ function Le(e) {
164
165
  A("select", e), X(!1);
165
166
  }
166
- function Ie() {
167
+ function Re() {
167
168
  A("viewAll"), X(!1);
168
169
  }
169
- function Le(e) {
170
+ function ze(e) {
170
171
  e.key !== "ArrowDown" || k.value || (e.preventDefault(), k.value = !0);
171
172
  }
172
- function Re(e) {
173
+ function Z(e) {
173
174
  let t = q(), n = t.indexOf(document.activeElement);
174
- (e.key === "ArrowDown" || e.key === "ArrowUp") && t.length ? (e.preventDefault(), J(n < 0 ? e.key === "ArrowDown" ? 0 : -1 : n + (e.key === "ArrowDown" ? 1 : -1))) : (e.key === "Home" || e.key === "End") && n >= 0 ? (e.preventDefault(), J(e.key === "Home" ? 0 : -1)) : e.key === "Escape" ? (e.preventDefault(), X()) : e.key === "Tab" && ze(e);
175
+ (e.key === "ArrowDown" || e.key === "ArrowUp") && t.length ? (e.preventDefault(), J(n < 0 ? e.key === "ArrowDown" ? 0 : -1 : n + (e.key === "ArrowDown" ? 1 : -1))) : (e.key === "Home" || e.key === "End") && n >= 0 ? (e.preventDefault(), J(e.key === "Home" ? 0 : -1)) : e.key === "Escape" ? (e.preventDefault(), X()) : e.key === "Tab" && Be(e);
175
176
  }
176
- function ze(e) {
177
+ function Be(e) {
177
178
  let t = [...L.value?.querySelectorAll("a[href], button:not([disabled])") ?? []], n = t[0], r = t[t.length - 1];
178
179
  e.shiftKey && (document.activeElement === n || document.activeElement === L.value) ? (e.preventDefault(), X()) : !e.shiftKey && (document.activeElement === r || !t.length) && X();
179
180
  }
180
- function Be(e) {
181
+ function Ve(e) {
181
182
  let t = e.target;
182
183
  K()?.contains(t) || L.value?.contains(t) || X(!1);
183
184
  }
@@ -186,28 +187,28 @@ var oe = {
186
187
  }
187
188
  function $(e) {
188
189
  let t = e ? "addEventListener" : "removeEventListener";
189
- document[t]("pointerdown", Be, !0), window[t]("scroll", Q, !0), window[t]("resize", Q), clearInterval(V), e && (V = setInterval(() => B.value = Date.now(), 3e4));
190
+ document[t]("pointerdown", Ve, !0), window[t]("scroll", Q, !0), window[t]("resize", Q), clearInterval(V), e && (V = setInterval(() => B.value = Date.now(), 3e4));
190
191
  }
191
192
  return E(k, async (e) => {
192
193
  if ($(e), !e) return;
193
- B.value = Date.now(), await g(), Y();
194
+ B.value = Date.now(), await _(), Y();
194
195
  let t = q()[0];
195
196
  t ? t.focus() : L.value?.focus();
196
- }), E(() => [O.notifications.length, O.loading], () => k.value && g(Y)), te(() => $(!1)), (a, p) => (v(), c("div", oe, [d(e, {
197
+ }), E(() => [O.notifications.length, O.loading], () => k.value && _(Y)), te(() => $(!1)), (t, o) => (y(), l("div", se, [f(e, {
197
198
  ref_key: "trigger",
198
199
  ref: I,
199
- label: f.label,
200
- icon: w(ie),
200
+ label: p.label,
201
+ icon: T(ae),
201
202
  "icon-only": "",
202
203
  badge: H.value,
203
204
  "aria-haspopup": "dialog",
204
205
  "aria-expanded": k.value,
205
206
  "aria-controls": k.value ? P : void 0,
206
- class: _(k.value && "border-border bg-surface-sunken/50 text-heading"),
207
+ class: v(k.value && "border-border bg-surface-sunken/50 text-heading"),
207
208
  "data-ac-ds": "",
208
209
  "data-testid": "ac-notification-menu-trigger",
209
- onClick: Z,
210
- onKeydown: Le
210
+ onClick: Ie,
211
+ onKeydown: ze
211
212
  }, null, 8, [
212
213
  "label",
213
214
  "icon",
@@ -215,13 +216,13 @@ var oe = {
215
216
  "aria-expanded",
216
217
  "aria-controls",
217
218
  "class"
218
- ]), (v(), o(r, { to: "body" }, [d(i, {
219
+ ]), (y(), s(i, { to: "body" }, [f(a, {
219
220
  "enter-active-class": "transition duration-150 ease-out",
220
221
  "enter-from-class": "opacity-0 motion-safe:scale-95",
221
222
  "leave-active-class": "transition duration-100 ease-in",
222
223
  "leave-to-class": "opacity-0"
223
224
  }, {
224
- default: D(() => [k.value ? (v(), c("div", {
225
+ default: D(() => [k.value ? (y(), l("div", {
225
226
  key: 0,
226
227
  id: P,
227
228
  ref_key: "panel",
@@ -229,79 +230,79 @@ var oe = {
229
230
  role: "dialog",
230
231
  tabindex: "-1",
231
232
  "aria-labelledby": F,
232
- class: _(["fixed z-[90] flex w-[calc(320px*var(--ac-scale))] max-w-[calc(100vw-16px)] flex-col overflow-hidden rounded-14 border border-border/80 bg-surface shadow-lg outline-none", z.value ? "origin-top-right" : "origin-bottom-right"]),
233
+ class: v(["fixed z-[90] flex w-[calc(320px*var(--ac-scale))] max-w-[calc(100vw-16px)] flex-col overflow-hidden rounded-14 border border-border/80 bg-surface shadow-lg outline-none", z.value ? "origin-top-right" : "origin-bottom-right"]),
233
234
  style: ee(R.value),
234
235
  "data-ac-ds": "",
235
236
  "data-testid": "ac-notification-menu-panel",
236
- onKeydown: Re
237
+ onKeydown: Z
237
238
  }, [
238
- l("div", se, [l("h2", {
239
+ u("div", ce, [u("h2", {
239
240
  id: F,
240
241
  class: "font-heading text-base font-semibold text-heading"
241
- }, C(f.label), 1), ke.value || H.value ? (v(), c("button", {
242
+ }, w(p.label), 1), Ae.value || H.value ? (y(), l("button", {
242
243
  key: 0,
243
244
  type: "button",
244
245
  class: "cursor-pointer rounded-4 text-xs text-muted transition-colors duration-200 hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
245
246
  "data-ac-ds": "",
246
247
  "data-testid": "ac-notification-menu-mark-all",
247
- onClick: p[0] ||= (e) => A("markAllRead")
248
- }, [p[1] ||= u(" Mark all as read", -1), H.value ? (v(), c("span", ce, " (" + C(H.value) + " unread)", 1)) : s("", !0)])) : s("", !0)]),
249
- f.loading ? (v(), c("div", le, [(v(), c(n, null, b(3, (e) => d(t, {
248
+ onClick: o[0] ||= (e) => A("markAllRead")
249
+ }, [o[1] ||= d(" Mark all as read", -1), H.value ? (y(), l("span", le, " (" + w(H.value) + " unread)", 1)) : c("", !0)])) : c("", !0)]),
250
+ p.loading ? (y(), l("div", ue, [(y(), l(r, null, x(3, (e) => f(n, {
250
251
  key: e,
251
252
  shape: "text",
252
253
  lines: 3,
253
254
  height: "10px",
254
255
  label: ""
255
- })), 64))])) : f.notifications.length ? (v(), c("ul", pe, [(v(!0), c(n, null, b(f.notifications, (e) => (v(), c("li", { key: e.id }, [(v(), o(S(W(e.to, e.href)), h({ ref_for: !0 }, G(e.to, e.href), {
256
+ })), 64))])) : p.notifications.length ? (y(), l("ul", me, [(y(!0), l(r, null, x(p.notifications, (e) => (y(), l("li", { key: e.id }, [(y(), s(C(W(e.to, e.href)), g({ ref_for: !0 }, G(e.to, e.href), {
256
257
  "data-notification-item": "",
257
258
  class: ["relative block w-full cursor-pointer p-3 text-left no-underline outline-none transition-colors duration-200 hover:bg-surface-sunken focus-visible:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset", !e.read && "bg-primary/8"],
258
259
  "data-ac-ds": "",
259
260
  "data-testid": "ac-notification-menu-item",
260
- onClick: (t) => Fe(e)
261
+ onClick: (t) => Le(e)
261
262
  }), {
262
- default: D(() => [x(a.$slots, "item", { item: e }, () => [
263
- l("span", me, [
264
- e.icon ? (v(), o(S(e.icon), {
263
+ default: D(() => [S(t.$slots, "item", { item: e }, () => [
264
+ u("span", he, [
265
+ e.icon ? (y(), s(C(e.icon), {
265
266
  key: 0,
266
267
  class: "size-4 shrink-0 text-muted",
267
268
  "aria-hidden": "true"
268
- })) : s("", !0),
269
- l("span", he, C(e.title || e.msg), 1),
270
- e.read ? s("", !0) : (v(), c("span", ge)),
271
- e.read ? s("", !0) : (v(), c("span", _e, "(unread)"))
269
+ })) : c("", !0),
270
+ u("span", ge, w(e.title || e.msg), 1),
271
+ e.read ? c("", !0) : (y(), l("span", _e)),
272
+ e.read ? c("", !0) : (y(), l("span", ve, "(unread)"))
272
273
  ]),
273
- e.title && e.msg ? (v(), c("span", ve, C(e.msg), 1)) : s("", !0),
274
- l("span", ye, [
275
- e.status ? (v(), c("span", {
274
+ e.title && e.msg ? (y(), l("span", ye, w(e.msg), 1)) : c("", !0),
275
+ u("span", be, [
276
+ e.status ? (y(), l("span", {
276
277
  key: 0,
277
- class: _(["font-medium", Ee[je(e)]])
278
- }, C(e.status), 3)) : s("", !0),
279
- e.status ? (v(), c("span", be, "·")) : s("", !0),
280
- l("time", {
281
- datetime: Pe(e.time),
282
- title: Ne(e.time)
283
- }, C(Me(e.time)), 9, xe)
278
+ class: v(["font-medium", De[Me(e)]])
279
+ }, w(e.status), 3)) : c("", !0),
280
+ e.status ? (y(), l("span", xe, "·")) : c("", !0),
281
+ u("time", {
282
+ datetime: Fe(e.time),
283
+ title: Pe(e.time)
284
+ }, w(Ne(e.time)), 9, Se)
284
285
  ])
285
286
  ])]),
286
287
  _: 2
287
- }, 1040, ["class", "onClick"]))]))), 128))])) : (v(), c("div", ue, [x(a.$slots, "empty", {}, () => [
288
- l("span", de, [d(w(ae), { class: "size-6" })]),
289
- l("p", fe, C(f.emptyText), 1),
290
- p[2] ||= l("p", { class: "max-w-64 text-base text-muted" }, "Backups, upgrades and alerts from your clusters show up here.", -1)
288
+ }, 1040, ["class", "onClick"]))]))), 128))])) : (y(), l("div", de, [S(t.$slots, "empty", {}, () => [
289
+ u("span", fe, [f(T(oe), { class: "size-6" })]),
290
+ u("p", pe, w(p.emptyText), 1),
291
+ o[2] ||= u("p", { class: "max-w-64 text-base text-muted" }, "Backups, upgrades and alerts from your clusters show up here.", -1)
291
292
  ])])),
292
- a.$slots.footer || Ae.value ? (v(), c("div", Se, [x(a.$slots, "footer", { close: X }, () => [(v(), o(S(W(f.viewAllTo, f.viewAllHref)), h(G(f.viewAllTo, f.viewAllHref), {
293
+ t.$slots.footer || je.value ? (y(), l("div", Ce, [S(t.$slots, "footer", { close: X }, () => [(y(), s(C(W(p.viewAllTo, p.viewAllHref)), g(G(p.viewAllTo, p.viewAllHref), {
293
294
  class: "group/link flex h-9 w-full cursor-pointer items-center justify-center gap-1.5 rounded-8 text-base font-semibold text-primary-strong no-underline outline-none transition-colors duration-200 hover:bg-surface-sunken focus-visible:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",
294
295
  "data-ac-ds": "",
295
296
  "data-testid": "ac-notification-menu-view-all",
296
- onClick: Ie
297
+ onClick: Re
297
298
  }), {
298
- default: D(() => [u(C(f.viewAllLabel) + " ", 1), d(w(re), {
299
+ default: D(() => [d(w(p.viewAllLabel) + " ", 1), f(T(ie), {
299
300
  class: "size-3.5 transition-transform duration-200 group-hover/link:translate-x-0.5 motion-reduce:transition-none",
300
301
  "aria-hidden": "true"
301
302
  })]),
302
303
  _: 1
303
- }, 16))])])) : s("", !0)
304
- ], 38)) : s("", !0)]),
304
+ }, 16))])])) : c("", !0)
305
+ ], 38)) : c("", !0)]),
305
306
  _: 3
306
307
  })]))]));
307
308
  }