@phantomclient/plugin 0.1.3 → 0.1.4
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.
- package/dist/lib/chunks/sdk-permissions-BQlOakj9.js +429 -0
- package/dist/lib/guest.js +2509 -1576
- package/dist/lib/index.js +22 -22
- package/dist/lib/styles.css +1 -1
- package/dist/lib/vue.js +307 -222
- package/dist/runtime/chunks/sdk-permissions-DXVe00ho.js +1 -0
- package/dist/runtime/frame.html +1 -1
- package/dist/runtime/runtime.js +3 -3
- package/dist/runtime/sdk.js +1 -1
- package/dist/types/index.d.ts +10 -0
- package/dist/types/vue.d.ts +9 -0
- package/package.json +1 -1
- package/dist/lib/chunks/api-DhaU9Jsd.js +0 -1667
- package/dist/lib/chunks/sdk-permissions-CyDMa4we.js +0 -429
- package/dist/lib/chunks/sdk-permissions-DQOAag0j.js +0 -429
- package/dist/lib/chunks/state-BGYMFLti.js +0 -34
- package/dist/runtime/chunks/sdk-permissions-CDp6went.js +0 -1
package/dist/lib/vue.js
CHANGED
|
@@ -1,160 +1,168 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as
|
|
3
|
-
import {
|
|
4
|
-
function
|
|
5
|
-
const e =
|
|
6
|
-
if (!e) throw new
|
|
1
|
+
import { inject as Be, computed as v, h as ne, toValue as oe, defineComponent as N, useAttrs as ve, useSlots as J, openBlock as n, createBlock as V, resolveDynamicComponent as P, normalizeClass as k, withCtx as R, createElementBlock as r, createCommentVNode as h, renderSlot as F, ref as I, watch as Z, toDisplayString as w, createElementVNode as _, useId as Q, onMounted as xe, onBeforeUnmount as ie, Fragment as L, withKeys as Me, unref as $, createVNode as ee, Teleport as re, normalizeStyle as te, createTextVNode as se, createSlots as Se, mergeProps as Ne, renderList as W, nextTick as le, normalizeProps as qe, guardReactiveProps as Ie, withModifiers as Ae, Comment as Pe, Text as Ee } from "vue";
|
|
2
|
+
import { c as Te } from "./chunks/api-q8Jk0T10.js";
|
|
3
|
+
import { P as je, c as Fe, f as G } from "./chunks/state-CAfC_MRc.js";
|
|
4
|
+
function ge() {
|
|
5
|
+
const e = Be(je, null) ?? Fe();
|
|
6
|
+
if (!e) throw new Te("NOT_SUPPORTED", Le());
|
|
7
7
|
return e;
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
return typeof document < "u" && "kind" in document.documentElement.dataset ?
|
|
9
|
+
function Le() {
|
|
10
|
+
return typeof document < "u" && "kind" in document.documentElement.dataset ? G.initialized ? "usePlugin() found no plugin context: this frame is closing, and the plugin it ran has already been let go" : "usePlugin() found no plugin context, although a Phantom frame mounted this component. That is two copies of @phantomclient/plugin in the one frame: the frame provides the context on its copy, this component asks another, and neither can see the other. Check that @phantomclient/plugin and @phantomclient/plugin/vue resolve to the same installed package, and that nothing bundles the package into the plugin instead of leaving it to the frame" : "usePlugin() works inside a Phantom plugin frame; this component was drawn outside one";
|
|
11
|
+
}
|
|
12
|
+
function ka(e) {
|
|
13
|
+
return ge().phantom(e);
|
|
11
14
|
}
|
|
12
|
-
function
|
|
13
|
-
return
|
|
15
|
+
function wa() {
|
|
16
|
+
return v(() => G.games);
|
|
14
17
|
}
|
|
15
|
-
function
|
|
16
|
-
return
|
|
18
|
+
function za() {
|
|
19
|
+
return v(() => G.preferences);
|
|
17
20
|
}
|
|
18
|
-
function
|
|
19
|
-
return
|
|
21
|
+
function _a() {
|
|
22
|
+
return v(() => G.snags);
|
|
20
23
|
}
|
|
21
|
-
function
|
|
22
|
-
return
|
|
24
|
+
function $a() {
|
|
25
|
+
return v(() => G.mode);
|
|
23
26
|
}
|
|
24
|
-
const
|
|
25
|
-
var
|
|
26
|
-
const
|
|
27
|
+
const Ue = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
28
|
+
var Y = { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": 2, "stroke-linecap": "round", "stroke-linejoin": "round" };
|
|
29
|
+
const De = ({ size: e, strokeWidth: a = 2, absoluteStrokeWidth: t, color: i, iconNode: o, name: s, class: d, ...b }, { slots: f }) => ne("svg", { ...Y, width: e || Y.width, height: e || Y.height, stroke: i || Y.stroke, "stroke-width": t ? Number(a) * 24 / Number(e) : a, class: ["lucide", `lucide-${Ue(s ?? "icon")}`], ...b }, [...o.map((z) => ne(...z)), ...f.default ? [f.default()] : []]), U = (e, a) => (t, { slots: i }) => ne(De, { ...t, iconNode: a, name: e }, i), ye = U("CheckIcon", [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]]), Re = U("ChevronDownIcon", [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]]), We = U("CircleAlertIcon", [["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }], ["line", { x1: "12", x2: "12", y1: "8", y2: "12", key: "1pkeuh" }], ["line", { x1: "12", x2: "12.01", y1: "16", y2: "16", key: "4dfq90" }]]), He = U("EyeOffIcon", [["path", { d: "M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49", key: "ct8e1f" }], ["path", { d: "M14.084 14.158a3 3 0 0 1-4.242-4.242", key: "151rxh" }], ["path", { d: "M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143", key: "13bj9a" }], ["path", { d: "m2 2 20 20", key: "1ooewy" }]]), Ke = U("EyeIcon", [["path", { d: "M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0", key: "1nclc0" }], ["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]]), Oe = U("InfoIcon", [["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }], ["path", { d: "M12 16v-4", key: "1dtifu" }], ["path", { d: "M12 8h.01", key: "e9boi3" }]]), Ge = U("LoaderCircleIcon", [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]]), Ye = U("MinusIcon", [["path", { d: "M5 12h14", key: "1ays0h" }]]), he = { xs: "w-6", sm: "w-7", md: "w-8", lg: "w-10", xl: "w-10" };
|
|
27
30
|
function Xe(e) {
|
|
28
|
-
const a =
|
|
29
|
-
const
|
|
30
|
-
return
|
|
31
|
-
}), t =
|
|
31
|
+
const a = v(() => {
|
|
32
|
+
const i = { xs: "h-6 px-2 text-2xs", sm: "h-7 px-2.5 text-xs", md: "h-8 px-3 text-xs", lg: "h-10 px-3.5 text-sm", xl: "h-10 px-4 text-sm" };
|
|
33
|
+
return i[oe(e)] || i.md;
|
|
34
|
+
}), t = v(() => he[oe(e)] || he.md);
|
|
32
35
|
return { sizeClasses: a, squareClasses: t };
|
|
33
36
|
}
|
|
34
37
|
function Ze(e) {
|
|
35
|
-
return { variantClasses:
|
|
38
|
+
return { variantClasses: v(() => {
|
|
36
39
|
const a = { primary: ["border-transparent bg-phantom-accent text-phantom-accent-contrast", "hover:bg-phantom-accent-hover", "active:bg-phantom-accent-active"].join(" "), secondary: ["border-transparent bg-phantom-surface text-phantom-text", "hover:bg-phantom-selected", "active:bg-phantom-elevated"].join(" "), outline: ["border-phantom-border bg-transparent text-phantom-text", "hover:border-phantom-border-strong hover:bg-phantom-surface", "active:bg-phantom-selected"].join(" "), ghost: ["border-transparent bg-transparent text-phantom-muted", "hover:bg-phantom-surface hover:text-phantom-text", "active:bg-phantom-selected"].join(" "), danger: ["border-transparent bg-phantom-danger/[0.12] text-phantom-danger", "hover:bg-phantom-danger/20 hover:text-phantom-danger-hover", "active:bg-phantom-danger/25"].join(" "), success: ["border-transparent bg-phantom-positive/15 text-phantom-positive-strong", "hover:bg-phantom-positive/[0.22]", "active:bg-phantom-positive/[0.28]"].join(" ") };
|
|
37
|
-
return a[
|
|
40
|
+
return a[oe(e)] || a.primary;
|
|
38
41
|
}) };
|
|
39
42
|
}
|
|
40
|
-
const Je = { key: 0, class: "size-3.5 shrink-0 animate-spin rounded-full border border-current border-r-transparent", "aria-hidden": "true" },
|
|
41
|
-
const t = e,
|
|
42
|
-
!t.disabled && !t.loading &&
|
|
43
|
+
const Je = { key: 0, class: "size-3.5 shrink-0 animate-spin rounded-full border border-current border-r-transparent", "aria-hidden": "true" }, Va = N({ __name: "index", props: { variant: { default: "primary" }, size: { default: "md" }, disabled: { type: Boolean, default: !1 }, loading: { type: Boolean, default: !1 }, icon: {}, iconRight: {}, type: { default: "button" }, fullWidth: { type: Boolean, default: !1 }, href: {} }, emits: ["click"], setup(e, { emit: a }) {
|
|
44
|
+
const t = e, i = a, o = ve(), s = J(), { variantClasses: d } = Ze(() => t.variant), { sizeClasses: b, squareClasses: f } = Xe(() => t.size), z = v(() => typeof o.class == "string" && /(^|\s)rounded(-|\s|$)/.test(o.class)), g = v(() => !!(t.icon || t.iconRight) && !t.loading && !s.default), y = v(() => ["inline-flex items-center justify-center gap-1.5", z.value ? "" : "rounded-[7px]", "border font-medium tracking-normal", "transition-[background-color,border-color,color,box-shadow,transform] duration-150 ease-spring", "active:scale-[0.98]", "focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-phantom-accent/60", "disabled:opacity-50 disabled:cursor-not-allowed disabled:pointer-events-none", d.value, b.value, g.value && ["px-0", f.value], t.fullWidth && "w-full", t.loading && "cursor-wait", o.class]), C = v(() => t.href !== void 0), S = v(() => t.disabled || t.loading), A = (q) => {
|
|
45
|
+
!t.disabled && !t.loading && i("click", q);
|
|
43
46
|
};
|
|
44
|
-
return (
|
|
45
|
-
} }), Qe = ["title"],
|
|
46
|
-
const a = e, t =
|
|
47
|
-
return
|
|
47
|
+
return (q, T) => (n(), V(P(C.value ? "a" : "button"), { type: C.value ? void 0 : t.type, href: C.value && !S.value ? t.href : void 0, disabled: C.value ? void 0 : S.value, "aria-disabled": C.value && S.value ? "true" : void 0, class: k([y.value, C.value && S.value && "pointer-events-none cursor-not-allowed opacity-50"]), onClick: A }, { default: R(() => [t.loading ? (n(), r("span", Je)) : t.icon ? (n(), V(P(t.icon), { key: 1, size: 14, class: "shrink-0" })) : h("", !0), F(q.$slots, "default"), t.iconRight && !t.loading ? (n(), V(P(t.iconRight), { key: 2, size: 14, class: "shrink-0" })) : h("", !0)]), _: 3 }, 8, ["type", "href", "disabled", "aria-disabled", "class"]));
|
|
48
|
+
} }), Qe = ["title"], et = ["src", "alt"], tt = { key: 1 }, Ca = N({ __name: "index", props: { name: {}, imageUrl: { default: null }, size: { default: "md" } }, setup(e) {
|
|
49
|
+
const a = e, t = I(!1), i = v(() => a.name.split(/\s+|@/).filter(Boolean).slice(0, 2).map((s) => s[0]).join("").toUpperCase()), o = v(() => a.size === "sm" ? "size-6 text-[8px]" : a.size === "lg" ? "size-10 text-xs" : a.size === "xl" ? "size-16 text-base" : "size-8 text-2xs");
|
|
50
|
+
return Z(() => a.imageUrl, () => {
|
|
48
51
|
t.value = !1;
|
|
49
|
-
}), (
|
|
50
|
-
} }),
|
|
51
|
-
const a = e, t =
|
|
52
|
-
const
|
|
53
|
-
return a.quiet ? "bg-transparent text-phantom-muted" :
|
|
54
|
-
}),
|
|
55
|
-
const
|
|
56
|
-
return a.quiet ?
|
|
52
|
+
}), (s, d) => (n(), r("span", { class: k(["grid shrink-0 place-items-center overflow-hidden rounded-full bg-phantom-selected font-semibold text-phantom-muted", o.value]), title: a.name }, [a.imageUrl && !t.value ? (n(), r("img", { key: 0, src: a.imageUrl, alt: a.name, class: "size-full object-cover", referrerpolicy: "no-referrer", onError: d[0] || (d[0] = (b) => t.value = !0) }, null, 40, et)) : (n(), r("span", tt, w(i.value), 1))], 10, Qe));
|
|
53
|
+
} }), at = ["data-tone", "data-quiet"], Ba = N({ __name: "index", props: { tone: { default: "neutral" }, dot: { type: Boolean, default: !1 }, size: { default: "md" }, quiet: { type: Boolean, default: !1 } }, setup(e) {
|
|
54
|
+
const a = e, t = v(() => {
|
|
55
|
+
const s = { neutral: "bg-phantom-selected text-phantom-muted", success: "bg-phantom-positive/15 text-phantom-positive-strong", warning: "bg-phantom-amber/15 text-phantom-amber", danger: "bg-phantom-danger/15 text-phantom-danger", info: "bg-phantom-info/15 text-phantom-info", blue: "bg-phantom-blue/15 text-phantom-blue", violet: "bg-phantom-violet/15 text-phantom-violet", aqua: "bg-phantom-aqua/15 text-phantom-aqua", orange: "bg-phantom-orange/15 text-phantom-orange", magenta: "bg-phantom-magenta/15 text-phantom-magenta" };
|
|
56
|
+
return a.quiet ? "bg-transparent text-phantom-muted" : s[a.tone];
|
|
57
|
+
}), i = v(() => a.quiet ? { neutral: "bg-phantom-subtle", success: "bg-phantom-positive", warning: "bg-phantom-amber", danger: "bg-phantom-danger", info: "bg-phantom-info", blue: "bg-phantom-blue", violet: "bg-phantom-violet", aqua: "bg-phantom-aqua", orange: "bg-phantom-orange", magenta: "bg-phantom-magenta" }[a.tone] : "bg-current"), o = v(() => {
|
|
58
|
+
const s = a.size === "sm";
|
|
59
|
+
return a.quiet ? s ? "h-[18px] gap-1.5 text-2xs" : "h-6 gap-1.5 text-xs" : s ? "h-[18px] gap-1 rounded px-1.5 text-[10px] leading-4" : "h-6 gap-1.5 rounded-full px-2.5 text-xs capitalize";
|
|
57
60
|
});
|
|
58
|
-
return (
|
|
59
|
-
} }),
|
|
60
|
-
const a = e, t = { neutral: { box: "border-phantom-border bg-phantom-surface text-phantom-text", icon: "text-phantom-muted" }, success: { box: "border-phantom-border bg-phantom-surface text-phantom-text", icon: "text-phantom-positive" }, warning: { box: "border-phantom-amber/25 bg-phantom-amber/10 text-phantom-amber", icon: "text-phantom-amber" }, danger: { box: "border-phantom-danger/25 bg-phantom-danger/10 text-phantom-danger", icon: "text-phantom-danger" }, info: { box: "border-phantom-info/25 bg-phantom-info/10 text-phantom-info", icon: "text-phantom-info" } },
|
|
61
|
-
return (o,
|
|
62
|
-
} }),
|
|
63
|
-
return (a, t) => (n(),
|
|
64
|
-
} }),
|
|
65
|
-
const a = e, t =
|
|
66
|
-
function
|
|
67
|
-
var
|
|
68
|
-
const g = (
|
|
61
|
+
return (s, d) => (n(), r("span", { class: k(["phantom-badge inline-flex shrink-0 items-center font-medium", [t.value, o.value]]), "data-tone": a.tone, "data-quiet": a.quiet || void 0 }, [a.dot || a.quiet ? (n(), r("span", { key: 0, class: k(["size-1.5 shrink-0 rounded-full", i.value]), "aria-hidden": "true" }, null, 2)) : h("", !0), F(s.$slots, "default")], 10, at));
|
|
62
|
+
} }), nt = ["role"], ot = { class: "min-w-0 flex-1" }, lt = N({ __name: "index", props: { tone: { default: "neutral" }, icon: { default: void 0 } }, setup(e) {
|
|
63
|
+
const a = e, t = { neutral: { box: "border-phantom-border bg-phantom-surface text-phantom-text", icon: "text-phantom-muted" }, success: { box: "border-phantom-border bg-phantom-surface text-phantom-text", icon: "text-phantom-positive" }, warning: { box: "border-phantom-amber/25 bg-phantom-amber/10 text-phantom-amber", icon: "text-phantom-amber" }, danger: { box: "border-phantom-danger/25 bg-phantom-danger/10 text-phantom-danger", icon: "text-phantom-danger" }, info: { box: "border-phantom-info/25 bg-phantom-info/10 text-phantom-info", icon: "text-phantom-info" } }, i = v(() => t[a.tone]);
|
|
64
|
+
return (o, s) => (n(), r("div", { class: k(["flex items-start gap-2 rounded-lg border px-3 py-2.5 text-xs leading-5", i.value.box]), role: a.tone === "danger" ? "alert" : void 0 }, [a.icon ? (n(), V(P(a.icon), { key: 0, size: 14, class: k(["mt-[3px] shrink-0", i.value.icon]) }, null, 8, ["class"])) : h("", !0), _("div", ot, [F(o.$slots, "default")])], 10, nt));
|
|
65
|
+
} }), Ma = N({ __name: "EmptyState", props: { title: {}, description: { default: void 0 }, icon: { default: void 0 }, size: { default: "sm" }, plain: { type: Boolean, default: !1 } }, setup(e) {
|
|
66
|
+
return (a, t) => (n(), r("div", { class: k(["flex h-full flex-col items-center justify-center text-center", [e.size === "lg" ? "min-h-64 gap-2 rounded-xl px-6 py-14" : "min-h-24 gap-1.5 rounded-lg px-4 py-5", !e.plain && "border border-dashed border-phantom-border"]]) }, [e.icon ? (n(), r("span", { key: 0, class: k(["grid shrink-0 place-items-center border border-phantom-border bg-phantom-surface text-phantom-muted", e.size === "lg" ? "mb-3 size-12 rounded-[14px]" : "mb-2 size-9 rounded-[10px]"]), "aria-hidden": "true" }, [(n(), V(P(e.icon), { size: e.size === "lg" ? 20 : 16, "stroke-width": "1.8" }, null, 8, ["size"]))], 2)) : h("", !0), _("p", { class: k(e.size === "lg" ? "text-base font-medium text-phantom-text" : "text-xs font-medium text-phantom-text") }, w(e.title), 3), e.description ? (n(), r("p", { key: 1, class: k(e.size === "lg" ? "max-w-sm text-sm leading-6 text-phantom-muted" : "max-w-72 text-2xs leading-[18px] text-phantom-muted") }, w(e.description), 3)) : h("", !0), a.$slots.default ? (n(), r("div", { key: 2, class: k(e.size === "lg" ? "mt-4" : "mt-3") }, [F(a.$slots, "default")], 2)) : h("", !0)], 2));
|
|
67
|
+
} }), it = ["aria-label", "aria-describedby"], rt = ["id"], st = N({ __name: "InfoTip", props: { text: {}, label: {} }, setup(e) {
|
|
68
|
+
const a = e, t = Q(), i = I(null), o = I(null);
|
|
69
|
+
function s() {
|
|
70
|
+
var z;
|
|
71
|
+
const g = (z = i.value) == null ? void 0 : z.getBoundingClientRect();
|
|
69
72
|
if (!g) return;
|
|
70
|
-
const
|
|
71
|
-
o.value = { top: g.top - 8, left:
|
|
73
|
+
const y = 136, C = g.left + g.width / 2, S = Math.min(Math.max(C, y), window.innerWidth - y);
|
|
74
|
+
o.value = { top: g.top - 8, left: S };
|
|
72
75
|
}
|
|
73
|
-
function
|
|
76
|
+
function d() {
|
|
74
77
|
o.value = null;
|
|
75
78
|
}
|
|
76
|
-
function
|
|
77
|
-
o.value ?
|
|
79
|
+
function b() {
|
|
80
|
+
o.value ? d() : s();
|
|
78
81
|
}
|
|
79
82
|
function f() {
|
|
80
|
-
|
|
83
|
+
d();
|
|
81
84
|
}
|
|
82
|
-
return
|
|
83
|
-
} }),
|
|
84
|
-
function
|
|
85
|
+
return xe(() => window.addEventListener("scroll", f, { capture: !0, passive: !0 })), ie(() => window.removeEventListener("scroll", f, { capture: !0 })), (z, g) => (n(), r(L, null, [_("button", { ref_key: "button", ref: i, type: "button", class: "inline-grid size-4 shrink-0 place-items-center rounded-full text-phantom-subtle outline-none transition-colors hover:text-phantom-text focus-visible:text-phantom-text focus-visible:ring-2 focus-visible:ring-phantom-accent/30", "aria-label": a.label ? `About ${a.label}` : "More about this", "aria-describedby": o.value ? $(t) : void 0, "data-info-tip": "", onMouseenter: s, onMouseleave: d, onFocus: s, onBlur: d, onClick: b, onKeydown: Me(d, ["escape"]) }, [ee($(Oe), { size: 12, "stroke-width": "2", "aria-hidden": "true" })], 40, it), (n(), V(re, { to: "body" }, [o.value ? (n(), r("span", { key: 0, id: $(t), role: "tooltip", class: "pointer-events-none fixed z-[200] w-max max-w-64 bg-phantom-elevated -translate-x-1/2 -translate-y-full rounded-lg border border-phantom-border-strong/80 px-2.5 py-1.5 text-left text-2xs leading-4 text-phantom-text-soft shadow-popover", style: te({ top: `${o.value.top}px`, left: `${o.value.left}px` }) }, w(a.text), 13, rt)) : h("", !0)]))], 64));
|
|
86
|
+
} }), dt = { class: "min-w-0", "data-field": "" }, ut = { key: 0, class: "mb-1.5 flex min-w-0 items-center gap-1.5" }, pt = ["for"], ct = { key: 1, class: "ml-auto shrink-0 text-2xs text-phantom-subtle" }, mt = ["id"], ht = ["id"];
|
|
87
|
+
function ke(e, a, t) {
|
|
85
88
|
return t || a ? `${e}-note` : void 0;
|
|
86
89
|
}
|
|
87
|
-
const
|
|
90
|
+
const we = N({ __name: "FieldFrame", props: { for: {}, label: { default: void 0 }, info: { default: void 0 }, optional: { type: Boolean, default: !1 }, hint: { default: void 0 }, error: { default: void 0 }, disabled: { type: Boolean, default: !1 } }, setup(e) {
|
|
88
91
|
const a = e;
|
|
89
|
-
return (t,
|
|
90
|
-
} }),
|
|
91
|
-
const t = e,
|
|
92
|
-
var
|
|
93
|
-
return (
|
|
94
|
-
}),
|
|
95
|
-
function
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
92
|
+
return (t, i) => (n(), r("div", dt, [a.label || t.$slots.label ? (n(), r("div", ut, [_("label", { for: a.for, class: k(["truncate text-xs font-medium text-phantom-text-soft", a.disabled && "opacity-60"]) }, [F(t.$slots, "label", {}, () => [se(w(a.label), 1)])], 10, pt), a.info ? (n(), V(st, { key: 0, text: a.info, label: a.label }, null, 8, ["text", "label"])) : h("", !0), a.optional ? (n(), r("span", ct, " Optional ")) : h("", !0)])) : h("", !0), F(t.$slots, "default"), a.error ? (n(), r("p", { key: 1, id: `${a.for}-note`, class: "mt-1.5 flex items-start gap-1.5 text-2xs leading-4 text-phantom-danger", role: "alert" }, [ee($(We), { size: 12, class: "mt-0.5 shrink-0", "aria-hidden": "true" }), _("span", null, w(a.error), 1)], 8, mt)) : a.hint ? (n(), r("p", { key: 2, id: `${a.for}-note`, class: "mt-1.5 text-2xs leading-4 text-phantom-subtle" }, w(a.hint), 9, ht)) : h("", !0)]));
|
|
93
|
+
} }), bt = { class: "group relative min-w-0" }, ft = ["id", "value", "type", "placeholder", "disabled", "required", "list", "aria-invalid", "aria-describedby"], vt = { key: 1, class: "absolute inset-y-0 right-1.5 flex items-center gap-1 text-2xs text-phantom-subtle" }, xt = ["aria-label", "aria-pressed", "title", "disabled"], gt = ["id"], yt = ["value"], kt = N({ inheritAttrs: !1, __name: "index", props: { modelValue: { default: "" }, id: { default: void 0 }, label: { default: void 0 }, type: { default: "text" }, placeholder: { default: void 0 }, icon: { default: void 0 }, disabled: { type: Boolean, default: !1 }, required: { type: Boolean, default: !1 }, suggestions: { default: void 0 }, size: { default: "md" }, hint: { default: void 0 }, error: { default: void 0 }, info: { default: void 0 }, optional: { type: Boolean, default: !1 } }, emits: ["update:modelValue"], setup(e, { emit: a }) {
|
|
94
|
+
const t = e, i = a, o = { xs: "h-7 text-2xs rounded-md bg-phantom-canvas px-2", sm: "h-8 text-xs rounded-lg bg-phantom-surface px-3", md: "h-9 text-[13px] rounded-lg bg-phantom-surface px-3", lg: "h-10 text-sm rounded-lg bg-phantom-surface px-3" }, s = { xs: 12, sm: 13, md: 14, lg: 15 }, d = ve(), b = J(), f = Q(), z = v(() => t.id ?? f), g = v(() => {
|
|
95
|
+
var c;
|
|
96
|
+
return (c = t.suggestions) != null && c.length ? `${z.value}-suggestions` : void 0;
|
|
97
|
+
}), y = I(!1), C = v(() => t.type === "password"), S = v(() => C.value && y.value ? "text" : t.type), A = v(() => !!t.error), q = v(() => ke(z.value, t.hint, t.error)), T = v(() => C.value || !!b.trailing);
|
|
98
|
+
function x(c) {
|
|
99
|
+
const B = c.target;
|
|
100
|
+
if (t.type !== "number") {
|
|
101
|
+
i("update:modelValue", B.value);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const l = B.valueAsNumber;
|
|
105
|
+
i("update:modelValue", Number.isNaN(l) ? "" : l);
|
|
106
|
+
}
|
|
107
|
+
return (c, B) => (n(), V(we, { for: z.value, label: t.label, info: t.info, optional: t.optional, hint: t.hint, error: t.error, disabled: t.disabled, "data-input": "" }, Se({ default: R(() => [_("div", bt, [t.icon ? (n(), V(P(t.icon), { key: 0, size: s[t.size], "stroke-width": "1.8", class: k(["pointer-events-none absolute top-1/2 -translate-y-1/2 transition-colors", [t.size === "xs" ? "left-2" : "left-3", A.value ? "text-phantom-danger" : "text-phantom-subtle group-focus-within:text-phantom-text-soft"]]), "aria-hidden": "true" }, null, 8, ["size", "class"])) : h("", !0), _("input", Ne($(d), { id: z.value, value: t.modelValue, type: S.value, placeholder: t.placeholder, disabled: t.disabled, required: t.required, list: g.value, "aria-invalid": A.value || void 0, "aria-describedby": q.value, class: ["w-full min-w-0 border text-phantom-text shadow-[inset_0_1px_0_rgb(0_0_0/0.04)] outline-none transition-[border-color,background-color,box-shadow] placeholder:text-phantom-subtle hover:border-phantom-border-strong focus:bg-phantom-selected focus:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50", [o[t.size], t.icon && (t.size === "xs" ? "pl-7" : "pl-9"), T.value && "pr-10", A.value ? "border-phantom-danger/60 hover:border-phantom-danger/80 focus:border-phantom-danger/80 focus:ring-phantom-danger/15" : "border-phantom-border focus:border-phantom-border-strong focus:ring-phantom-accent/10"]], onInput: x }), null, 16, ft), T.value ? (n(), r("span", vt, [F(c.$slots, "trailing"), C.value ? (n(), r("button", { key: 0, type: "button", class: "grid size-7 place-items-center rounded-md text-phantom-subtle outline-none transition-colors hover:bg-phantom-selected hover:text-phantom-text focus-visible:ring-2 focus-visible:ring-phantom-accent/30 disabled:pointer-events-none", "aria-label": y.value ? "Hide password" : "Show password", "aria-pressed": y.value, title: y.value ? "Hide password" : "Show password", disabled: t.disabled, "data-reveal-password": "", onClick: B[0] || (B[0] = (l) => y.value = !y.value) }, [(n(), V(P(y.value ? $(He) : $(Ke)), { size: 14, "stroke-width": "1.8" }))], 8, xt)) : h("", !0)])) : h("", !0), g.value ? (n(), r("datalist", { key: 2, id: g.value }, [(n(!0), r(L, null, W(t.suggestions, (l) => (n(), r("option", { key: l, value: l }, null, 8, yt))), 128))], 8, gt)) : h("", !0)])]), _: 2 }, [$(b).label ? { name: "label", fn: R(() => [F(c.$slots, "label")]), key: "0" } : void 0]), 1032, ["for", "label", "info", "optional", "hint", "error", "disabled"]));
|
|
108
|
+
} }), wt = { class: "flex flex-wrap items-end justify-between gap-4" }, zt = { class: "min-w-0" }, _t = { key: 0, class: "mb-1 text-xs font-medium text-phantom-subtle" }, $t = { class: "text-display text-phantom-text" }, Vt = { key: 1, class: "mt-1.5 max-w-xl text-[13px] leading-6 text-phantom-muted" }, Ct = { key: 0, class: "flex shrink-0 flex-wrap items-center gap-2" }, Sa = N({ __name: "index", props: { title: {}, eyebrow: { default: void 0 }, description: { default: void 0 } }, setup(e) {
|
|
109
|
+
return (a, t) => (n(), r("header", wt, [_("div", zt, [e.eyebrow ? (n(), r("p", _t, w(e.eyebrow), 1)) : h("", !0), _("h1", $t, w(e.title), 1), e.description ? (n(), r("p", Vt, w(e.description), 1)) : h("", !0)]), a.$slots.actions ? (n(), r("div", Ct, [F(a.$slots, "actions")])) : h("", !0)]));
|
|
110
|
+
} }), Bt = ["aria-selected", "onClick"], Mt = { key: 1, class: "text-2xs text-phantom-subtle" }, Na = N({ __name: "index", props: { modelValue: {}, options: {}, variant: { default: "pill" }, size: { default: "md" }, track: { type: Boolean, default: !1 }, block: { type: Boolean, default: !1 } }, emits: ["update:modelValue"], setup(e, { emit: a }) {
|
|
111
|
+
const t = e, i = a, o = I(null), s = I(null), d = I(!1);
|
|
112
|
+
function b() {
|
|
113
|
+
var z;
|
|
114
|
+
const g = (z = o.value) == null ? void 0 : z.querySelector('[aria-selected="true"]');
|
|
115
|
+
s.value = g ? { left: g.offsetLeft, width: g.offsetWidth } : null;
|
|
108
116
|
}
|
|
109
117
|
let f = null;
|
|
110
|
-
return
|
|
111
|
-
|
|
112
|
-
}),
|
|
113
|
-
|
|
114
|
-
}, { deep: !0 }), (
|
|
118
|
+
return xe(() => {
|
|
119
|
+
b(), requestAnimationFrame(() => d.value = !0), f = new ResizeObserver(() => b()), o.value && f.observe(o.value);
|
|
120
|
+
}), ie(() => f == null ? void 0 : f.disconnect()), Z(() => [t.modelValue, t.options.map((z) => `${z.label}${z.badge ?? ""}`)], () => {
|
|
121
|
+
le(b);
|
|
122
|
+
}, { deep: !0 }), (z, g) => (n(), r("div", { ref_key: "root", ref: o, class: k(["relative items-center", [e.block ? "flex w-full" : "inline-flex", e.variant === "underline" ? "gap-6" : "gap-0.5 rounded-lg p-0.5", e.variant === "pill" && e.track && "border border-phantom-border bg-phantom-surface"]]), role: "tablist" }, [s.value ? (n(), r("span", { key: 0, class: k(["absolute left-0", [e.variant === "underline" ? "bottom-0 h-0.5 rounded-full bg-phantom-text" : "phantom-segment-indicator inset-y-0.5 rounded-md bg-phantom-selected shadow-sm", d.value && "transition-[transform,width] duration-300 ease-spring"]]), style: te({ transform: `translateX(${s.value.left}px)`, width: `${s.value.width}px` }), "aria-hidden": "true" }, null, 6)) : h("", !0), (n(!0), r(L, null, W(e.options, (y) => (n(), r("button", { key: y.value, type: "button", role: "tab", "aria-selected": y.value === e.modelValue, class: k(["relative inline-flex items-center gap-1.5 font-medium outline-none transition-colors duration-150 focus-visible:ring-2 focus-visible:ring-phantom-accent/45", [e.block && "flex-1 justify-center", e.variant === "underline" ? "rounded-md py-3 text-sm" : e.size === "sm" ? "rounded-md px-2 py-0.5 text-2xs" : "rounded-md px-2.5 py-1 text-xs", y.value === e.modelValue ? "text-phantom-text" : "text-phantom-muted hover:text-phantom-text", e.variant === "underline" && !s.value && y.value === e.modelValue && "shadow-[inset_0_-2px_0_rgb(var(--phantom-text))]"]]), onClick: (C) => i("update:modelValue", y.value) }, [y.icon ? (n(), V(P(y.icon), { key: 0, size: e.size === "sm" ? 12 : 13, class: "shrink-0", "aria-hidden": "true" }, null, 8, ["size"])) : h("", !0), se(" " + w(y.label) + " ", 1), y.badge !== void 0 ? (n(), r("span", Mt, w(y.badge), 1)) : h("", !0)], 10, Bt))), 128))], 2));
|
|
115
123
|
} });
|
|
116
|
-
function
|
|
117
|
-
var
|
|
124
|
+
function O(e, a, t) {
|
|
125
|
+
var i;
|
|
118
126
|
const o = e.length;
|
|
119
|
-
for (let
|
|
120
|
-
const
|
|
121
|
-
if (!((
|
|
127
|
+
for (let s = 1; s <= o; s += 1) {
|
|
128
|
+
const d = ((a + t * s) % o + o) % o;
|
|
129
|
+
if (!((i = e[d]) != null && i.disabled)) return d;
|
|
122
130
|
}
|
|
123
131
|
return -1;
|
|
124
132
|
}
|
|
125
|
-
function
|
|
133
|
+
function St(e, a) {
|
|
126
134
|
var t;
|
|
127
|
-
const
|
|
128
|
-
return
|
|
135
|
+
const i = e.findIndex((o) => o.value === a);
|
|
136
|
+
return i >= 0 && !((t = e[i]) != null && t.disabled) ? i : O(e, -1, 1);
|
|
129
137
|
}
|
|
130
|
-
function
|
|
131
|
-
const
|
|
132
|
-
for (let
|
|
133
|
-
const
|
|
134
|
-
if (f && !f.disabled && f.label.toLowerCase().startsWith(
|
|
138
|
+
function Nt(e, a, t) {
|
|
139
|
+
const i = t.toLowerCase(), o = e.length, s = t.length === 1 ? a + 1 : Math.max(a, 0);
|
|
140
|
+
for (let d = 0; d < o; d += 1) {
|
|
141
|
+
const b = (s + d) % o, f = e[b];
|
|
142
|
+
if (f && !f.disabled && f.label.toLowerCase().startsWith(i)) return b;
|
|
135
143
|
}
|
|
136
144
|
return -1;
|
|
137
145
|
}
|
|
138
|
-
const
|
|
139
|
-
function
|
|
146
|
+
const qt = 600;
|
|
147
|
+
function It(e = Date.now) {
|
|
140
148
|
let a = "", t = -1 / 0;
|
|
141
|
-
return (
|
|
149
|
+
return (i) => {
|
|
142
150
|
const o = e();
|
|
143
|
-
return a = o - t >
|
|
151
|
+
return a = o - t > qt ? i : a + i, t = o, a;
|
|
144
152
|
};
|
|
145
153
|
}
|
|
146
|
-
function
|
|
154
|
+
function At(e, a, t, i) {
|
|
147
155
|
const { key: o } = e;
|
|
148
156
|
if (!a) return ["ArrowDown", "ArrowUp", "Enter", " "].includes(o) ? { kind: "open" } : { kind: "none" };
|
|
149
157
|
switch (o) {
|
|
150
158
|
case "ArrowDown":
|
|
151
|
-
return { kind: "move", index:
|
|
159
|
+
return { kind: "move", index: O(i, t, 1) };
|
|
152
160
|
case "ArrowUp":
|
|
153
|
-
return { kind: "move", index:
|
|
161
|
+
return { kind: "move", index: O(i, t, -1) };
|
|
154
162
|
case "Home":
|
|
155
|
-
return { kind: "move", index:
|
|
163
|
+
return { kind: "move", index: O(i, -1, 1) };
|
|
156
164
|
case "End":
|
|
157
|
-
return { kind: "move", index:
|
|
165
|
+
return { kind: "move", index: O(i, i.length, -1) };
|
|
158
166
|
case "Enter":
|
|
159
167
|
case " ":
|
|
160
168
|
return { kind: "choose", index: t };
|
|
@@ -166,144 +174,221 @@ function St(e, a, t, l) {
|
|
|
166
174
|
return o.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey ? { kind: "type", key: o } : { kind: "none" };
|
|
167
175
|
}
|
|
168
176
|
}
|
|
169
|
-
const
|
|
170
|
-
function
|
|
171
|
-
const o = a.height - e.bottom -
|
|
172
|
-
return { left: `${
|
|
177
|
+
const be = 288, X = 4, K = 8;
|
|
178
|
+
function fe(e, a, t, i = e.width) {
|
|
179
|
+
const o = a.height - e.bottom - K, s = e.top - K, d = o < Math.min(be, t) && s > o, b = e.left + i - (a.width - K);
|
|
180
|
+
return { left: `${b > 0 ? Math.max(K, e.left - b) : e.left}px`, minWidth: `${e.width}px`, maxWidth: `${Math.max(e.width, Math.min(352, a.width - K * 2))}px`, maxHeight: `${Math.max(0, Math.min(be, d ? s - X : o - X))}px`, ...d ? { bottom: `${a.height - e.top + X}px` } : { top: `${e.bottom + X}px` } };
|
|
173
181
|
}
|
|
174
|
-
const
|
|
175
|
-
const t = e,
|
|
176
|
-
function
|
|
177
|
-
return typeof
|
|
178
|
-
}
|
|
179
|
-
function
|
|
180
|
-
for (const
|
|
181
|
-
if (!
|
|
182
|
-
const
|
|
183
|
-
if (
|
|
184
|
-
const E =
|
|
185
|
-
|
|
186
|
-
} else
|
|
182
|
+
const Pt = ["id", "disabled", "aria-label", "aria-invalid", "aria-describedby", "aria-expanded", "aria-controls", "aria-activedescendant"], Et = { key: 1, class: "shrink-0 text-phantom-subtle" }, Tt = ["id", "aria-label"], jt = ["id", "data-index", "aria-selected", "aria-disabled", "onMouseenter", "onClick"], Ft = { class: "min-w-0 flex-1" }, Lt = { key: 0, class: "mt-0.5 block text-2xs leading-4 text-phantom-subtle" }, Ut = { key: 1, class: "shrink-0 text-phantom-subtle" }, Dt = { key: 3, class: "w-3 shrink-0", "aria-hidden": "true" }, Rt = { key: 0, class: "px-3 py-1.5 text-2xs text-phantom-subtle" }, Wt = N({ __name: "Select", props: { modelValue: {}, options: { default: void 0 }, ariaLabel: { default: void 0 }, label: { default: void 0 }, info: { default: void 0 }, hint: { default: void 0 }, error: { default: void 0 }, optional: { type: Boolean, default: !1 }, icon: { default: void 0 }, disabled: { type: Boolean, default: !1 }, placeholder: { default: "Choose one" }, size: { default: "md" }, variant: { default: "default" }, id: { default: void 0 } }, emits: ["update:modelValue"], setup(e, { emit: a }) {
|
|
183
|
+
const t = e, i = a, o = J(), s = `phantom-select-${Q()}`, d = v(() => t.id ?? `${s}-field`), b = I(!1), f = I(-1), z = I(null), g = I(null), y = I({}), C = v(() => t.size === "sm"), S = v(() => t.size === "lg"), A = v(() => t.variant === "ghost"), q = v(() => !!(t.label || t.hint || t.error));
|
|
184
|
+
function T(m) {
|
|
185
|
+
return typeof m == "string" ? m : Array.isArray(m) ? m.map((p) => T(p)).join("") : m && typeof m == "object" && "children" in m ? T(m.children) : "";
|
|
186
|
+
}
|
|
187
|
+
function x(m, p) {
|
|
188
|
+
for (const u of m ?? []) {
|
|
189
|
+
if (!u || typeof u != "object" || Array.isArray(u)) continue;
|
|
190
|
+
const M = u;
|
|
191
|
+
if (M.type === "option") {
|
|
192
|
+
const E = M.props ?? {}, H = T(M.children).trim();
|
|
193
|
+
p.push({ value: "value" in E ? E.value : H, label: H, description: typeof E.title == "string" ? E.title : void 0, disabled: E.disabled === "" || E.disabled === !0 });
|
|
194
|
+
} else M.type !== Pe && M.type !== Ee && Array.isArray(M.children) && x(M.children, p);
|
|
187
195
|
}
|
|
188
|
-
return
|
|
189
|
-
}
|
|
190
|
-
let
|
|
191
|
-
function
|
|
192
|
-
var
|
|
193
|
-
return
|
|
194
|
-
}
|
|
195
|
-
function
|
|
196
|
-
return
|
|
197
|
-
}
|
|
198
|
-
async function
|
|
199
|
-
var
|
|
200
|
-
const
|
|
201
|
-
if (!
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
function
|
|
208
|
-
|
|
209
|
-
var
|
|
210
|
-
(
|
|
196
|
+
return p;
|
|
197
|
+
}
|
|
198
|
+
let c = [];
|
|
199
|
+
function B() {
|
|
200
|
+
var m;
|
|
201
|
+
return c = t.options ?? x((m = o.default) == null ? void 0 : m.call(o), []), c;
|
|
202
|
+
}
|
|
203
|
+
function l(m) {
|
|
204
|
+
return m.find((p) => p.value === t.modelValue);
|
|
205
|
+
}
|
|
206
|
+
async function j() {
|
|
207
|
+
var m;
|
|
208
|
+
const p = z.value;
|
|
209
|
+
if (!p) return;
|
|
210
|
+
const u = { width: window.innerWidth, height: window.innerHeight }, M = c.length * 32 + 8, E = p.getBoundingClientRect();
|
|
211
|
+
y.value = fe(E, u, M), await le();
|
|
212
|
+
const H = (m = g.value) == null ? void 0 : m.getBoundingClientRect().width;
|
|
213
|
+
H && (y.value = fe(E, u, M, H));
|
|
214
|
+
}
|
|
215
|
+
function ae() {
|
|
216
|
+
le(() => {
|
|
217
|
+
var m, p;
|
|
218
|
+
(p = (m = g.value) == null ? void 0 : m.querySelector(`[data-index="${f.value}"]`)) == null || p.scrollIntoView({ block: "nearest" });
|
|
211
219
|
});
|
|
212
220
|
}
|
|
213
|
-
async function
|
|
214
|
-
t.disabled ||
|
|
221
|
+
async function de() {
|
|
222
|
+
t.disabled || b.value || (f.value = St(c, t.modelValue), b.value = !0, await j(), ae());
|
|
215
223
|
}
|
|
216
|
-
function
|
|
217
|
-
var
|
|
218
|
-
|
|
224
|
+
function D(m = !1) {
|
|
225
|
+
var p;
|
|
226
|
+
b.value && (b.value = !1, m && ((p = z.value) == null || p.focus()));
|
|
219
227
|
}
|
|
220
|
-
function
|
|
221
|
-
const
|
|
222
|
-
!
|
|
228
|
+
function ue(m) {
|
|
229
|
+
const p = c[m];
|
|
230
|
+
!p || p.disabled || (p.value !== t.modelValue && i("update:modelValue", p.value), D(!0));
|
|
223
231
|
}
|
|
224
|
-
const
|
|
225
|
-
function
|
|
226
|
-
const
|
|
227
|
-
switch (
|
|
232
|
+
const _e = It();
|
|
233
|
+
function $e(m) {
|
|
234
|
+
const p = At(m, b.value, f.value, c);
|
|
235
|
+
switch (p.kind) {
|
|
228
236
|
case "open":
|
|
229
|
-
|
|
237
|
+
m.preventDefault(), de();
|
|
230
238
|
return;
|
|
231
239
|
case "move":
|
|
232
|
-
|
|
240
|
+
m.preventDefault(), f.value = p.index, ae();
|
|
233
241
|
return;
|
|
234
242
|
case "choose":
|
|
235
|
-
|
|
243
|
+
m.preventDefault(), ue(p.index);
|
|
236
244
|
return;
|
|
237
245
|
case "close":
|
|
238
|
-
|
|
246
|
+
p.refocus && (m.preventDefault(), m.stopPropagation()), D(p.refocus);
|
|
239
247
|
return;
|
|
240
248
|
case "type": {
|
|
241
|
-
const
|
|
242
|
-
|
|
249
|
+
const u = Nt(c, f.value, _e(p.key));
|
|
250
|
+
u >= 0 && (f.value = u, ae());
|
|
243
251
|
return;
|
|
244
252
|
}
|
|
245
253
|
}
|
|
246
254
|
}
|
|
247
|
-
function
|
|
248
|
-
var
|
|
249
|
-
const
|
|
250
|
-
(
|
|
251
|
-
}
|
|
252
|
-
function
|
|
253
|
-
var
|
|
254
|
-
(
|
|
255
|
-
}
|
|
256
|
-
function
|
|
257
|
-
|
|
258
|
-
}
|
|
259
|
-
function
|
|
260
|
-
const
|
|
261
|
-
document[
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
const
|
|
265
|
-
return (
|
|
266
|
-
}, ["prevent"])), onMouseenter: (E) => !
|
|
267
|
-
} }),
|
|
268
|
-
return (a, t) => (n(),
|
|
269
|
-
} }),
|
|
270
|
-
const t = a,
|
|
271
|
-
return (o,
|
|
272
|
-
} }),
|
|
273
|
-
const t = e,
|
|
274
|
-
function o(
|
|
275
|
-
const
|
|
276
|
-
t.disabled ||
|
|
277
|
-
}
|
|
278
|
-
return (
|
|
279
|
-
} }),
|
|
280
|
-
return (a, t) => (n(),
|
|
255
|
+
function pe(m) {
|
|
256
|
+
var p, u;
|
|
257
|
+
const M = m.target;
|
|
258
|
+
(p = z.value) != null && p.contains(M) || (u = g.value) != null && u.contains(M) || D();
|
|
259
|
+
}
|
|
260
|
+
function Ve(m) {
|
|
261
|
+
var p;
|
|
262
|
+
(p = g.value) != null && p.contains(m.target) || D();
|
|
263
|
+
}
|
|
264
|
+
function ce() {
|
|
265
|
+
D();
|
|
266
|
+
}
|
|
267
|
+
function me(m) {
|
|
268
|
+
const p = m ? "addEventListener" : "removeEventListener";
|
|
269
|
+
document[p]("mousedown", pe, !0), document[p]("touchstart", pe, !0), window[p]("scroll", Ve, !0), window[p]("resize", ce), window[p]("blur", ce);
|
|
270
|
+
}
|
|
271
|
+
Z(b, (m) => me(m)), Z(() => t.disabled, (m) => m && D()), ie(() => me(!1));
|
|
272
|
+
const Ce = v(() => A.value ? ["gap-1 rounded-md bg-transparent px-1.5 font-medium text-inherit hover:bg-phantom-text/5 focus-visible:ring-2 focus-visible:ring-phantom-accent/20", C.value ? "h-8 text-xs" : "h-9 text-[13px]"] : ["border text-phantom-text focus-visible:border-phantom-border-strong focus-visible:ring-2 focus-visible:ring-phantom-accent/15", C.value ? "h-8 gap-1.5 rounded-lg bg-phantom-surface pl-3 pr-2 text-xs" : S.value ? "h-12 gap-3 rounded-full bg-phantom-panel pl-5 pr-4 text-sm" : "h-9 gap-2 rounded-lg bg-phantom-surface pl-3 pr-2.5 text-[13px]", t.error ? "border-phantom-danger/60 hover:border-phantom-danger/80" : b.value ? "border-phantom-border-strong" : "border-phantom-border hover:border-phantom-border-strong"]);
|
|
273
|
+
return (m, p) => (n(), V(P(q.value ? we : "div"), qe(Ie(q.value ? { for: d.value, label: e.label, info: e.info, optional: e.optional, hint: e.hint, error: e.error, disabled: e.disabled } : { class: "relative inline-flex min-w-0 align-middle" })), { default: R(() => [_("div", { class: k(q.value ? "relative flex min-w-0" : "contents") }, [_("button", { id: d.value, ref_key: "trigger", ref: z, type: "button", class: k(["flex w-full min-w-0 items-center outline-none transition-colors duration-150 disabled:pointer-events-none disabled:opacity-50", Ce.value]), disabled: e.disabled, "aria-label": e.label ? void 0 : e.ariaLabel, "aria-invalid": e.error ? !0 : void 0, "aria-describedby": $(ke)(d.value, e.hint, e.error), "aria-haspopup": "listbox", "aria-expanded": b.value, "aria-controls": b.value ? `${s}-list` : void 0, "aria-activedescendant": b.value && f.value >= 0 ? `${s}-option-${f.value}` : void 0, onClick: p[0] || (p[0] = (u) => b.value ? D() : void de()), onKeydown: $e }, [(n(!0), r(L, null, W([l(B())], (u) => (n(), r(L, { key: String(u == null ? void 0 : u.value) }, [!A.value && (e.icon ?? (u == null ? void 0 : u.icon)) ? (n(), V(P(e.icon ?? (u == null ? void 0 : u.icon)), { key: 0, size: 13, "stroke-width": 1.8, "aria-hidden": "true", class: k(["shrink-0", [C.value ? "" : "mr-0.5", e.error ? "text-phantom-danger" : "text-phantom-subtle"]]) }, null, 8, ["class"])) : h("", !0), _("span", { class: k(["min-w-0 truncate text-left", [A.value ? "" : "flex-1", u ? "" : "text-phantom-subtle"]]) }, w((u == null ? void 0 : u.label) ?? e.placeholder), 3), u != null && u.detail ? (n(), r("span", Et, w(u.detail), 1)) : h("", !0)], 64))), 128)), ee($(Re), { size: C.value || A.value ? 12 : S.value ? 15 : 13, "aria-hidden": "true", class: k(["shrink-0 transition-transform duration-150", [A.value ? "opacity-70" : "text-phantom-subtle", b.value ? "rotate-180" : ""]]) }, null, 8, ["size", "class"])], 42, Pt), (n(), V(re, { to: "body" }, [b.value ? (n(), r("ul", { key: 0, id: `${s}-list`, ref_key: "list", ref: g, role: "listbox", "aria-label": e.label ?? e.ariaLabel, class: k(["phantom-select-list fixed z-[1000] overflow-y-auto border border-phantom-border-strong/80 bg-phantom-elevated shadow-popover", S.value ? "rounded-[22px] p-1.5" : "rounded-[10px] p-1"]), style: te(y.value) }, [(n(!0), r(L, null, W($(c), (u, M) => (n(), r("li", { id: `${s}-option-${M}`, key: `${String(u.value)}-${M}`, "data-index": M, role: "option", "aria-selected": u.value === e.modelValue, "aria-disabled": u.disabled || void 0, class: k(["flex cursor-default gap-2 text-phantom-text", [C.value ? "rounded-lg px-2 py-1 text-2xs" : S.value ? "rounded-2xl px-3.5 py-2.5 text-sm" : "rounded-lg px-2 py-1.5 text-xs", u.description ? "items-start" : "items-center", u.disabled ? "opacity-40" : "", M === f.value && !u.disabled ? "bg-phantom-control" : ""]]), onMousedown: p[1] || (p[1] = Ae(() => {
|
|
274
|
+
}, ["prevent"])), onMouseenter: (E) => !u.disabled && (f.value = M), onClick: (E) => ue(M) }, [u.icon ? (n(), V(P(u.icon), { key: 0, size: 13, "stroke-width": 1.8, "aria-hidden": "true", class: k(["shrink-0 text-phantom-subtle", u.description ? "mt-px" : ""]) }, null, 8, ["class"])) : h("", !0), _("span", Ft, [_("span", { class: k(["block truncate", u.value === e.modelValue ? "font-medium" : ""]) }, w(u.label), 3), u.description ? (n(), r("span", Lt, w(u.description), 1)) : h("", !0)]), u.detail ? (n(), r("span", Ut, w(u.detail), 1)) : h("", !0), u.value === e.modelValue ? (n(), V($(ye), { key: 2, size: 12, "aria-hidden": "true", class: k(["shrink-0 text-phantom-accent", u.description ? "mt-0.5" : ""]) }, null, 8, ["class"])) : (n(), r("span", Dt))], 42, jt))), 128)), $(c).length ? h("", !0) : (n(), r("li", Rt, " Nothing to choose from "))], 14, Tt)) : h("", !0)]))], 2)]), _: 1 }, 16));
|
|
275
|
+
} }), qa = N({ __name: "Spinner", props: { size: { default: 13 } }, setup(e) {
|
|
276
|
+
return (a, t) => (n(), V($(Ge), { size: e.size, class: "animate-spin", "aria-hidden": "true" }, null, 8, ["size"]));
|
|
277
|
+
} }), Ht = ["id", "checked", "indeterminate", "disabled", "aria-label"], Ia = N({ __name: "Checkbox", props: { modelValue: { type: Boolean }, label: { default: void 0 }, indeterminate: { type: Boolean, default: !1 }, disabled: { type: Boolean, default: !1 }, block: { type: Boolean, default: !1 }, align: { default: "center" }, id: { default: void 0 } }, emits: ["update:modelValue"], setup(e, { emit: a }) {
|
|
278
|
+
const t = a, i = J();
|
|
279
|
+
return (o, s) => (n(), V(P($(i).default ? "label" : "span"), { class: k(["gap-2.5", [$(i).default && e.block ? "flex w-full" : "inline-flex", e.align === "start" ? "items-start" : "items-center", e.disabled ? "cursor-not-allowed opacity-50" : "cursor-pointer"]]) }, { default: R(() => [_("span", { class: k(["relative grid size-4 shrink-0 place-items-center", $(i).default && e.align === "start" ? "mt-px" : ""]) }, [_("input", { id: e.id, type: "checkbox", class: "peer absolute inset-0 m-0 size-full cursor-[inherit] appearance-none opacity-0", checked: e.modelValue, indeterminate: e.indeterminate, disabled: e.disabled, "aria-label": $(i).default ? void 0 : e.label, onChange: s[0] || (s[0] = (d) => t("update:modelValue", d.target.checked)) }, null, 40, Ht), _("span", { class: k(["pointer-events-none grid size-4 place-items-center rounded-[5px] border transition-colors duration-150 peer-focus-visible:ring-2 peer-focus-visible:ring-phantom-accent/40", [e.modelValue || e.indeterminate ? "border-phantom-text bg-phantom-text text-phantom-canvas" : "border-phantom-border-strong bg-phantom-surface", !e.disabled && !e.modelValue && !e.indeterminate && "peer-hover:border-phantom-muted"]]), "aria-hidden": "true" }, [e.indeterminate ? (n(), V($(Ye), { key: 0, size: 11, "stroke-width": 3 })) : e.modelValue ? (n(), V($(ye), { key: 1, size: 11, "stroke-width": 3 })) : h("", !0)], 2)], 2), F(o.$slots, "default")]), _: 3 }, 8, ["class"]));
|
|
280
|
+
} }), Kt = ["checked", "disabled", "aria-label"], Ot = N({ __name: "Switch", props: { modelValue: { type: Boolean }, label: { default: void 0 }, disabled: { type: Boolean, default: !1 } }, emits: ["update:modelValue"], setup(e, { emit: a }) {
|
|
281
|
+
const t = e, i = a;
|
|
282
|
+
function o(s) {
|
|
283
|
+
const d = s.currentTarget;
|
|
284
|
+
t.disabled || d.closest("label") || i("update:modelValue", !t.modelValue);
|
|
285
|
+
}
|
|
286
|
+
return (s, d) => (n(), r("span", { class: k(["relative inline-flex shrink-0", e.disabled ? "opacity-50" : "cursor-pointer"]), onClick: o }, [_("input", { type: "checkbox", role: "switch", class: "peer sr-only", checked: e.modelValue, disabled: e.disabled, "aria-label": e.label, onChange: d[0] || (d[0] = (b) => i("update:modelValue", b.target.checked)) }, null, 40, Kt), _("span", { class: k(["relative h-[17px] w-[30px] rounded-full border border-phantom-border-strong bg-phantom-surface transition-[background-color,border-color] duration-150 peer-checked:border-phantom-text-soft peer-checked:bg-phantom-text-soft peer-checked:[&>span]:translate-x-[13px] peer-checked:[&>span]:bg-phantom-accent-contrast peer-focus-visible:ring-2 peer-focus-visible:ring-phantom-accent/30", !e.disabled && "hover:border-phantom-muted peer-checked:hover:border-phantom-text"]), "aria-hidden": "true" }, [...d[1] || (d[1] = [_("span", { class: "absolute left-[2px] top-[2px] size-[11px] rounded-full bg-phantom-subtle shadow-[0_1px_2px_rgb(var(--phantom-shadow)/0.35)] transition-[transform,background-color] duration-200 ease-spring" }, null, -1)])], 2)], 2));
|
|
287
|
+
} }), Gt = { class: "block text-xs font-semibold text-phantom-text" }, Yt = { key: 0, class: "mt-0.5 block text-2xs text-phantom-subtle" }, Xt = { key: 1, class: "mt-1 block text-2xs text-phantom-amber" }, Aa = N({ __name: "Tooltip", props: { at: {}, title: {}, description: { default: void 0 }, note: { default: void 0 }, place: { default: "beside" } }, setup(e) {
|
|
288
|
+
return (a, t) => (n(), V(re, { to: "body" }, [e.at ? (n(), r("span", { key: 0, role: "tooltip", class: k(["phantom-glass-raised pointer-events-none fixed z-[200] max-w-56 rounded-lg border border-phantom-border-strong/80 px-2.5 py-1.5 text-left", e.place === "below" ? "-translate-x-1/2" : "-translate-y-1/2"]), style: te({ top: `${e.at.top}px`, left: `${e.at.left}px` }) }, [_("span", Gt, w(e.title), 1), e.description ? (n(), r("span", Yt, w(e.description), 1)) : h("", !0), e.note ? (n(), r("span", Xt, w(e.note), 1)) : h("", !0)], 6)) : h("", !0)]));
|
|
281
289
|
} });
|
|
282
|
-
function
|
|
290
|
+
function Pa(e, a = 10) {
|
|
283
291
|
const t = e.getBoundingClientRect();
|
|
284
292
|
return { top: t.top + t.height / 2, left: t.right + a };
|
|
285
293
|
}
|
|
286
|
-
|
|
294
|
+
I("dark");
|
|
295
|
+
function Zt(e) {
|
|
296
|
+
return e.default !== void 0 ? e.default : e.type === "checkbox" ? !1 : null;
|
|
297
|
+
}
|
|
298
|
+
function Jt(e, a) {
|
|
299
|
+
const t = {};
|
|
300
|
+
for (const i of e) {
|
|
301
|
+
const o = a[i.name];
|
|
302
|
+
t[i.name] = o ?? Zt(i);
|
|
303
|
+
}
|
|
304
|
+
return t;
|
|
305
|
+
}
|
|
306
|
+
function Qt(e, a) {
|
|
307
|
+
return e.needs.every((t) => a(t));
|
|
308
|
+
}
|
|
309
|
+
function ea(e) {
|
|
310
|
+
const a = [];
|
|
311
|
+
for (const t of e) {
|
|
312
|
+
const i = t.group ?? null, o = a.find((s) => s.title === i);
|
|
313
|
+
o ? o.fields.push(t) : a.push({ title: i, fields: [t] });
|
|
314
|
+
}
|
|
315
|
+
return a;
|
|
316
|
+
}
|
|
317
|
+
function ze(e) {
|
|
318
|
+
return e.step && e.step > 0 ? e.step : 1;
|
|
319
|
+
}
|
|
320
|
+
function ta(e, a) {
|
|
321
|
+
const t = ze(e), i = e.min ?? Number.NEGATIVE_INFINITY, o = e.max ?? Number.POSITIVE_INFINITY, s = e.min ?? 0, d = s + Math.round((a - s) / t) * t, b = Number(d.toFixed(6));
|
|
322
|
+
return Math.min(o, Math.max(i, b));
|
|
323
|
+
}
|
|
324
|
+
const aa = { class: "flex flex-col gap-3", "data-plugin-preferences": "" }, na = { key: 0, class: "text-2xs font-medium uppercase tracking-wide text-phantom-muted" }, oa = { key: 0, class: "flex items-start justify-between gap-3" }, la = { class: "min-w-0" }, ia = { class: "block text-xs font-medium text-phantom-text" }, ra = { key: 0, class: "block text-2xs text-phantom-subtle" }, sa = { key: 1, class: "mt-1 block text-2xs text-phantom-amber" }, da = { key: 1, class: "flex flex-col gap-1" }, ua = { class: "flex items-baseline justify-between gap-3" }, pa = ["for"], ca = { class: "text-2xs tabular-nums text-phantom-subtle" }, ma = ["id", "min", "max", "step", "value", "disabled", "onChange"], ha = { key: 0, class: "text-2xs text-phantom-subtle" }, ba = { key: 1, class: "text-2xs text-phantom-amber" }, fa = { key: 2, class: "flex flex-col gap-1" }, va = { key: 2, class: "text-2xs text-phantom-amber" }, Ea = N({ __name: "Preferences", props: { group: { default: void 0 }, game: { default: void 0 } }, setup(e) {
|
|
325
|
+
const a = e, t = ge(), i = Q(), o = I(null), s = v(() => {
|
|
326
|
+
var x;
|
|
327
|
+
return a.game ?? ((x = t.games()[0]) == null ? void 0 : x.id) ?? null;
|
|
328
|
+
}), d = v(() => Jt(t.preferenceFields, s.value ? t.preferencesFor(s.value) : t.preferences)), b = v(() => ea(t.preferenceFields).filter((x) => a.group === void 0 || x.title === a.group)), f = v(() => {
|
|
329
|
+
const x = /* @__PURE__ */ new Map();
|
|
330
|
+
for (const c of t.snags) c.game !== null && s.value !== null && c.game !== s.value || x.set(c.name, c.reason);
|
|
331
|
+
return x;
|
|
332
|
+
});
|
|
333
|
+
function z(x) {
|
|
334
|
+
const c = x.needs.filter((B) => !t.can(B));
|
|
335
|
+
return c.length ? `Not allowed: this plugin was not granted ${c.join(", ")}.` : null;
|
|
336
|
+
}
|
|
337
|
+
function g(x) {
|
|
338
|
+
return Qt(x, (c) => t.can(c));
|
|
339
|
+
}
|
|
340
|
+
const y = (x) => `${i}-${x.name}`;
|
|
341
|
+
function C(x) {
|
|
342
|
+
const c = d.value[x.name];
|
|
343
|
+
return c == null ? "" : String(c);
|
|
344
|
+
}
|
|
345
|
+
function S(x) {
|
|
346
|
+
const c = d.value[x.name];
|
|
347
|
+
return typeof c == "number" ? c : x.min ?? 0;
|
|
348
|
+
}
|
|
349
|
+
function A(x) {
|
|
350
|
+
return [{ value: "", label: x.placeholder ?? "Choose one" }, ...(x.options ?? []).map((c) => ({ value: c.value, label: c.title }))];
|
|
351
|
+
}
|
|
352
|
+
async function q(x, c) {
|
|
353
|
+
o.value = null;
|
|
354
|
+
try {
|
|
355
|
+
await t.setPreferences({ [x.name]: c }, x.scope === "player" && s.value ? { game: s.value } : void 0);
|
|
356
|
+
} catch (B) {
|
|
357
|
+
o.value = B instanceof Error ? B.message : String(B);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
function T(x, c) {
|
|
361
|
+
const B = typeof c == "number" ? c : Number(c);
|
|
362
|
+
if (c === "" || Number.isNaN(B)) {
|
|
363
|
+
q(x, null);
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
q(x, ta(x, B));
|
|
367
|
+
}
|
|
368
|
+
return (x, c) => (n(), r("div", aa, [(n(!0), r(L, null, W(b.value, (B) => (n(), r("div", { key: B.title ?? "", class: "flex flex-col gap-2" }, [B.title ? (n(), r("p", na, w(B.title), 1)) : h("", !0), (n(!0), r(L, null, W(B.fields, (l) => (n(), r(L, { key: l.name }, [l.type === "checkbox" ? (n(), r("label", oa, [_("span", la, [_("span", ia, w(l.title), 1), l.description || !g(l) ? (n(), r("span", ra, w(g(l) ? l.description : z(l)), 1)) : h("", !0), f.value.get(l.name) ? (n(), r("span", sa, w(f.value.get(l.name)), 1)) : h("", !0)]), ee($(Ot), { "model-value": d.value[l.name] === !0, disabled: !g(l), label: l.title, "onUpdate:modelValue": (j) => q(l, j) }, null, 8, ["model-value", "disabled", "label", "onUpdate:modelValue"])])) : l.type === "range" ? (n(), r("div", da, [_("div", ua, [_("label", { for: y(l), class: "text-xs font-medium text-phantom-text" }, w(l.title), 9, pa), _("span", ca, w(S(l)), 1)]), _("input", { id: y(l), type: "range", class: "h-1 w-full cursor-pointer accent-phantom-accent", min: l.min, max: l.max, step: $(ze)(l), value: S(l), disabled: !g(l), onChange: (j) => T(l, j.target.value) }, null, 40, ma), l.description || !g(l) ? (n(), r("span", ha, w(g(l) ? l.description : z(l)), 1)) : h("", !0), f.value.get(l.name) ? (n(), r("span", ba, w(f.value.get(l.name)), 1)) : h("", !0)])) : (n(), r("div", fa, [l.type === "dropdown" ? (n(), V($(Wt), { key: 0, id: y(l), "model-value": C(l), options: A(l), label: l.title, hint: g(l) ? l.description : z(l) ?? void 0, disabled: !g(l), optional: !l.required, size: "sm", class: "w-full", "onUpdate:modelValue": (j) => q(l, j || null) }, null, 8, ["id", "model-value", "options", "label", "hint", "disabled", "optional", "onUpdate:modelValue"])) : (n(), V($(kt), { key: 1, id: y(l), "model-value": C(l), label: l.title, hint: g(l) ? l.description : z(l) ?? void 0, type: l.type, placeholder: l.placeholder, disabled: !g(l), optional: !l.required, size: "sm", autocomplete: "off", onBlur: (j) => l.type === "number" ? T(l, j.target.value) : q(l, j.target.value) }, null, 8, ["id", "model-value", "label", "hint", "type", "placeholder", "disabled", "optional", "onBlur"])), f.value.get(l.name) ? (n(), r("span", va, w(f.value.get(l.name)), 1)) : h("", !0)]))], 64))), 128))]))), 128)), o.value ? (n(), V($(lt), { key: 0, tone: "danger" }, { default: R(() => [se(w(o.value), 1)]), _: 1 })) : h("", !0)]));
|
|
369
|
+
} });
|
|
287
370
|
export {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
371
|
+
Ca as Avatar,
|
|
372
|
+
Ba as Badge,
|
|
373
|
+
Va as Button,
|
|
374
|
+
lt as Callout,
|
|
375
|
+
Ia as Checkbox,
|
|
376
|
+
Ma as EmptyState,
|
|
377
|
+
we as FieldFrame,
|
|
378
|
+
st as InfoTip,
|
|
379
|
+
kt as Input,
|
|
380
|
+
Sa as PageHeader,
|
|
381
|
+
Ea as Preferences,
|
|
382
|
+
Na as SegmentedControl,
|
|
383
|
+
Wt as Select,
|
|
384
|
+
qa as Spinner,
|
|
385
|
+
Ot as Switch,
|
|
386
|
+
Aa as Tooltip,
|
|
387
|
+
Pa as tooltipBeside,
|
|
388
|
+
wa as useGames,
|
|
389
|
+
ka as usePhantom,
|
|
390
|
+
ge as usePlugin,
|
|
391
|
+
za as usePreferences,
|
|
392
|
+
_a as useSnags,
|
|
393
|
+
$a as useThemeMode
|
|
309
394
|
};
|