@citrusworx/juiceui 0.9.3 → 0.9.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/README.md +367 -247
- package/dist/index.css +360 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +437 -2
- package/dist/js/juice.d.ts +4 -0
- package/dist/js/src/pressable/pressable-runtime.d.ts +106 -0
- package/dist/js/src/shared/change.d.ts +1 -0
- package/dist/js/src/touchable-row/touchable-row-runtime.d.ts +123 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -254,6 +254,9 @@ var b = "juice:change", x = (e) => typeof e == "object" && !!e && !Array.isArray
|
|
|
254
254
|
return;
|
|
255
255
|
}
|
|
256
256
|
S(t.get(n), a) || (t.set(n, a), w(n, e, a));
|
|
257
|
+
},
|
|
258
|
+
adopt: (e, n) => {
|
|
259
|
+
t.set(e, C(n));
|
|
257
260
|
}
|
|
258
261
|
};
|
|
259
262
|
}, E = {
|
|
@@ -5738,8 +5741,440 @@ typeof window < "u" && typeof document < "u" && (document.readyState === "loadin
|
|
|
5738
5741
|
pu = null, fu || hu();
|
|
5739
5742
|
}, document.addEventListener("DOMContentLoaded", pu)) : hu());
|
|
5740
5743
|
//#endregion
|
|
5744
|
+
//#region src/js/src/pressable/pressable-runtime.ts
|
|
5745
|
+
var _u = "juice:longpress", vu = {
|
|
5746
|
+
root: typeof document < "u" ? document : {},
|
|
5747
|
+
pressableSelector: "[pressable]",
|
|
5748
|
+
longPressDelay: 500,
|
|
5749
|
+
moveSlop: 10
|
|
5750
|
+
}, yu = (e) => Array.from(e), bu = L(), xu = {
|
|
5751
|
+
pressed: !1,
|
|
5752
|
+
longPressed: !1
|
|
5753
|
+
}, Su = (e) => !!(e.getAttribute("aria-disabled") === "true" || e.hasAttribute("disabled") || "disabled" in e && e.disabled), Cu = (e) => e.hasAttribute("aria-pressed") || e.hasAttribute("icon-button") && e.hasAttribute("toggle"), wu = (e) => e === "Enter" || e === " " || e === "Spacebar", Tu = (e) => e === " " || e === "Spacebar", Eu = new Set([
|
|
5754
|
+
"button",
|
|
5755
|
+
"switch",
|
|
5756
|
+
"checkbox",
|
|
5757
|
+
"radio",
|
|
5758
|
+
"menuitem",
|
|
5759
|
+
"menuitemcheckbox",
|
|
5760
|
+
"menuitemradio",
|
|
5761
|
+
"option",
|
|
5762
|
+
"tab",
|
|
5763
|
+
"treeitem"
|
|
5764
|
+
]), Du = (e) => !!(e instanceof HTMLButtonElement || e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement || e.tagName === "SUMMARY" || Ou(e)), Ou = (e) => {
|
|
5765
|
+
if (e.isContentEditable) return !0;
|
|
5766
|
+
let t = e.getAttribute("contenteditable");
|
|
5767
|
+
if (t === null) return !1;
|
|
5768
|
+
let n = t.trim().toLowerCase();
|
|
5769
|
+
return n === "" || n === "true" || n === "plaintext-only";
|
|
5770
|
+
}, ku = (e) => {
|
|
5771
|
+
let t = e.getAttribute("role");
|
|
5772
|
+
if (!t) return !1;
|
|
5773
|
+
let n = t.trim().toLowerCase().split(/\s+/)[0];
|
|
5774
|
+
return n !== void 0 && Eu.has(n);
|
|
5775
|
+
}, Au = (e) => ku(e) && !Du(e), ju = (e) => {
|
|
5776
|
+
if (e === null) return null;
|
|
5777
|
+
let t = e.trim();
|
|
5778
|
+
if (t === "" || !/^\d+(?:\.\d+)?$/.test(t)) return null;
|
|
5779
|
+
let n = Number(t);
|
|
5780
|
+
return Number.isFinite(n) ? n : null;
|
|
5781
|
+
}, Mu = (e, t) => {
|
|
5782
|
+
if (!e.hasAttribute("pressable-longpress")) return null;
|
|
5783
|
+
let n = e.getAttribute("pressable-longpress");
|
|
5784
|
+
if (n !== null && n.trim().toLowerCase() === "false") return null;
|
|
5785
|
+
let r = ju(n);
|
|
5786
|
+
return r === null ? t : r;
|
|
5787
|
+
}, Nu = (e, t) => {
|
|
5788
|
+
if (!e.hasAttribute("pressable-slop")) return t;
|
|
5789
|
+
let n = ju(e.getAttribute("pressable-slop"));
|
|
5790
|
+
return n === null ? t : n;
|
|
5791
|
+
}, Pu = (e, t) => typeof e != "number" || !Number.isFinite(e) || e < 0 ? t : e, Fu = () => ({
|
|
5792
|
+
destroy: () => {},
|
|
5793
|
+
sync: () => {},
|
|
5794
|
+
getState: () => null
|
|
5795
|
+
}), Iu = (e = {}) => {
|
|
5796
|
+
if (typeof window > "u" || typeof document > "u") return Fu();
|
|
5797
|
+
let t = {
|
|
5798
|
+
...vu,
|
|
5799
|
+
...e,
|
|
5800
|
+
longPressDelay: Pu(e.longPressDelay, vu.longPressDelay),
|
|
5801
|
+
moveSlop: Pu(e.moveSlop, vu.moveSlop)
|
|
5802
|
+
}, n = t.root ?? document, r = n, i = T("pressable"), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = !1, c = (e) => !(e instanceof HTMLElement) || !e.matches(t.pressableSelector) ? !1 : n instanceof Document ? !0 : n instanceof Node ? n === e || n.contains(e) : !1, l = () => {
|
|
5803
|
+
let e = yu(n.querySelectorAll(t.pressableSelector)).filter(c);
|
|
5804
|
+
return n instanceof HTMLElement && c(n) ? [n, ...e.filter((e) => e !== n)] : e;
|
|
5805
|
+
}, u = (e) => {
|
|
5806
|
+
if (e) {
|
|
5807
|
+
if (c(e)) return e;
|
|
5808
|
+
let n = e.closest(t.pressableSelector);
|
|
5809
|
+
return n instanceof HTMLElement && c(n) ? n : null;
|
|
5810
|
+
}
|
|
5811
|
+
return l()[0] ?? null;
|
|
5812
|
+
}, d = (e) => {
|
|
5813
|
+
if (!(e instanceof Element)) return null;
|
|
5814
|
+
let n = e.closest(t.pressableSelector);
|
|
5815
|
+
return !(n instanceof HTMLElement) || !c(n) ? null : n;
|
|
5816
|
+
}, f = (e) => {
|
|
5817
|
+
let t = a.get(e);
|
|
5818
|
+
return t ? {
|
|
5819
|
+
pressed: t.active,
|
|
5820
|
+
longPressed: t.longPressed
|
|
5821
|
+
} : { ...xu };
|
|
5822
|
+
}, p = (e) => {
|
|
5823
|
+
let t = f(e);
|
|
5824
|
+
if (!i.has(e)) {
|
|
5825
|
+
i.note(e, t, { baseline: { ...xu } });
|
|
5826
|
+
return;
|
|
5827
|
+
}
|
|
5828
|
+
i.note(e, t);
|
|
5829
|
+
}, m = (e, t, n) => {
|
|
5830
|
+
if (Cu(e)) {
|
|
5831
|
+
n.ownsPressed = !1;
|
|
5832
|
+
return;
|
|
5833
|
+
}
|
|
5834
|
+
if (t) {
|
|
5835
|
+
if (e.hasAttribute("pressed")) {
|
|
5836
|
+
n.ownsPressed = !1;
|
|
5837
|
+
return;
|
|
5838
|
+
}
|
|
5839
|
+
e.setAttribute("pressed", ""), n.ownsPressed = !0;
|
|
5840
|
+
return;
|
|
5841
|
+
}
|
|
5842
|
+
n.ownsPressed && !Cu(e) && e.removeAttribute("pressed"), n.ownsPressed = !1;
|
|
5843
|
+
}, h = (e) => {
|
|
5844
|
+
e.timer !== null && (clearTimeout(e.timer), e.timer = null);
|
|
5845
|
+
}, g = (e) => {
|
|
5846
|
+
let t = o.get(e);
|
|
5847
|
+
t !== void 0 && clearTimeout(t), o.delete(e);
|
|
5848
|
+
}, _ = (e) => {
|
|
5849
|
+
g(e);
|
|
5850
|
+
let t = setTimeout(() => {
|
|
5851
|
+
o.delete(e);
|
|
5852
|
+
}, 0);
|
|
5853
|
+
o.set(e, t);
|
|
5854
|
+
}, v = (e) => {
|
|
5855
|
+
for (let [t, n] of a) if (n.source === "pointer" && n.pointerId === e) return t;
|
|
5856
|
+
return null;
|
|
5857
|
+
}, y = (e) => {
|
|
5858
|
+
let t = a.get(e);
|
|
5859
|
+
if (!t) return;
|
|
5860
|
+
h(t), t.onLeave &&= (e.removeEventListener("pointerleave", t.onLeave), null), m(e, !1, t);
|
|
5861
|
+
let n = t.suppressClick;
|
|
5862
|
+
a.delete(e), n && _(e), p(e);
|
|
5863
|
+
}, b = (e, n) => {
|
|
5864
|
+
let r = Mu(e, t.longPressDelay);
|
|
5865
|
+
r !== null && (n.timer = setTimeout(() => {
|
|
5866
|
+
if (n.timer = null, s || a.get(e) !== n) return;
|
|
5867
|
+
if (Su(e) || !c(e)) {
|
|
5868
|
+
y(e);
|
|
5869
|
+
return;
|
|
5870
|
+
}
|
|
5871
|
+
n.longPressed = !0;
|
|
5872
|
+
let t = new CustomEvent(_u, {
|
|
5873
|
+
bubbles: !0,
|
|
5874
|
+
cancelable: !0,
|
|
5875
|
+
composed: !0,
|
|
5876
|
+
detail: {
|
|
5877
|
+
pressed: !0,
|
|
5878
|
+
longPressed: !0
|
|
5879
|
+
}
|
|
5880
|
+
});
|
|
5881
|
+
e.dispatchEvent(t), t.defaultPrevented || (n.suppressClick = !0), a.get(e) === n && p(e);
|
|
5882
|
+
}, r));
|
|
5883
|
+
}, x = (e, n, r) => {
|
|
5884
|
+
if (a.has(e) || Su(e) || !c(e)) return !1;
|
|
5885
|
+
let i = {
|
|
5886
|
+
source: n,
|
|
5887
|
+
pointerId: r?.pointerId ?? null,
|
|
5888
|
+
originX: r?.clientX ?? 0,
|
|
5889
|
+
originY: r?.clientY ?? 0,
|
|
5890
|
+
slop: Nu(e, t.moveSlop),
|
|
5891
|
+
timer: null,
|
|
5892
|
+
active: !0,
|
|
5893
|
+
longPressed: !1,
|
|
5894
|
+
suppressClick: !1,
|
|
5895
|
+
ownsPressed: !1,
|
|
5896
|
+
onLeave: null
|
|
5897
|
+
};
|
|
5898
|
+
if (a.set(e, i), m(e, !0, i), n === "pointer") {
|
|
5899
|
+
let t = (t) => {
|
|
5900
|
+
s || t instanceof PointerEvent && t.pointerId === i.pointerId && y(e);
|
|
5901
|
+
};
|
|
5902
|
+
i.onLeave = t, e.addEventListener("pointerleave", t), b(e, i);
|
|
5903
|
+
}
|
|
5904
|
+
return p(e), !0;
|
|
5905
|
+
}, S = (e, t) => {
|
|
5906
|
+
let n = e.ownerDocument.defaultView;
|
|
5907
|
+
return t == null || t === n || t === e.ownerDocument || t === e.ownerDocument.documentElement ? !0 : t instanceof Node && t.contains(e);
|
|
5908
|
+
}, C = (e) => {
|
|
5909
|
+
if (s || !(e instanceof PointerEvent) || !e.isPrimary || e.button !== 0) return;
|
|
5910
|
+
let t = d(e.target);
|
|
5911
|
+
!t || Su(t) || a.has(t) || bu(e) && x(t, "pointer", {
|
|
5912
|
+
pointerId: e.pointerId,
|
|
5913
|
+
clientX: e.clientX,
|
|
5914
|
+
clientY: e.clientY
|
|
5915
|
+
});
|
|
5916
|
+
}, w = (e) => {
|
|
5917
|
+
if (s || !(e instanceof PointerEvent)) return;
|
|
5918
|
+
let t = v(e.pointerId);
|
|
5919
|
+
if (!t) return;
|
|
5920
|
+
let n = a.get(t);
|
|
5921
|
+
if (n) {
|
|
5922
|
+
if (e.target instanceof Node && !t.contains(e.target)) {
|
|
5923
|
+
y(t);
|
|
5924
|
+
return;
|
|
5925
|
+
}
|
|
5926
|
+
Math.hypot(e.clientX - n.originX, e.clientY - n.originY) > n.slop && y(t);
|
|
5927
|
+
}
|
|
5928
|
+
}, E = (e) => {
|
|
5929
|
+
if (s || !(e instanceof PointerEvent)) return;
|
|
5930
|
+
let t = v(e.pointerId);
|
|
5931
|
+
t && y(t);
|
|
5932
|
+
}, D = (e) => {
|
|
5933
|
+
if (s || !(e instanceof PointerEvent)) return;
|
|
5934
|
+
let t = v(e.pointerId);
|
|
5935
|
+
if (!t || !(e.target instanceof Node) || !t.contains(e.target)) return;
|
|
5936
|
+
let n = e.relatedTarget;
|
|
5937
|
+
n instanceof Node && t.contains(n) || y(t);
|
|
5938
|
+
}, O = (e) => {
|
|
5939
|
+
if (s || !(e instanceof PointerEvent)) return;
|
|
5940
|
+
let t = v(e.pointerId);
|
|
5941
|
+
t && y(t);
|
|
5942
|
+
}, k = (e) => {
|
|
5943
|
+
if (!(s || a.size === 0)) for (let t of Array.from(a.keys())) {
|
|
5944
|
+
let n = a.get(t);
|
|
5945
|
+
!n || n.source !== "pointer" || S(t, e.target) && y(t);
|
|
5946
|
+
}
|
|
5947
|
+
}, A = (e) => {
|
|
5948
|
+
if (s || !(e instanceof KeyboardEvent) || !wu(e.key) || !(e.target instanceof HTMLElement) || !e.target.matches(t.pressableSelector)) return;
|
|
5949
|
+
let n = e.target;
|
|
5950
|
+
c(n) && (Tu(e.key) && Au(n) && e.cancelable && e.preventDefault(), !(e.repeat || Su(n) || a.has(n)) && bu(e) && x(n, "keyboard", null));
|
|
5951
|
+
}, j = (e) => {
|
|
5952
|
+
if (s || !(e instanceof KeyboardEvent) || !wu(e.key) || !(e.target instanceof HTMLElement) || !e.target.matches(t.pressableSelector)) return;
|
|
5953
|
+
let n = a.get(e.target);
|
|
5954
|
+
!n || n.source !== "keyboard" || y(e.target);
|
|
5955
|
+
}, M = (e) => {
|
|
5956
|
+
s || e.target instanceof HTMLElement && e.target.matches(t.pressableSelector) && c(e.target) && y(e.target);
|
|
5957
|
+
}, N = (e) => {
|
|
5958
|
+
if (s) return;
|
|
5959
|
+
let t = d(e.target);
|
|
5960
|
+
!t || !o.has(t) || (g(t), e.cancelable && e.preventDefault(), e.stopPropagation());
|
|
5961
|
+
}, P = !1, F = 0, I = () => {
|
|
5962
|
+
P || s || (P = !0, F = requestAnimationFrame(() => {
|
|
5963
|
+
P = !1, R();
|
|
5964
|
+
}));
|
|
5965
|
+
}, L = () => {
|
|
5966
|
+
for (let e of Array.from(a.keys())) (!c(e) || Su(e)) && y(e);
|
|
5967
|
+
}, R = () => {
|
|
5968
|
+
s || (L(), l().forEach((e) => {
|
|
5969
|
+
i.note(e, f(e));
|
|
5970
|
+
}));
|
|
5971
|
+
}, z = typeof MutationObserver < "u" ? new MutationObserver(() => {
|
|
5972
|
+
L(), I();
|
|
5973
|
+
}) : null, B = {
|
|
5974
|
+
capture: !0,
|
|
5975
|
+
passive: !0
|
|
5976
|
+
}, V = { passive: !0 };
|
|
5977
|
+
r.addEventListener("pointerdown", C), r.addEventListener("pointermove", w, V), r.addEventListener("pointerup", E), r.addEventListener("pointercancel", E), r.addEventListener("pointerout", D), r.addEventListener("lostpointercapture", O), r.addEventListener("keydown", A), r.addEventListener("keyup", j), r.addEventListener("click", N, !0), r.addEventListener("blur", M, !0), r.addEventListener("scroll", k, B);
|
|
5978
|
+
let H = n instanceof Document ? n.defaultView : n instanceof Node ? n.ownerDocument?.defaultView ?? null : null;
|
|
5979
|
+
return H && H.addEventListener("scroll", k, B), z && n instanceof Node && z.observe(n, {
|
|
5980
|
+
childList: !0,
|
|
5981
|
+
subtree: !0,
|
|
5982
|
+
attributes: !0,
|
|
5983
|
+
attributeFilter: [
|
|
5984
|
+
"pressable",
|
|
5985
|
+
"pressable-longpress",
|
|
5986
|
+
"pressable-slop",
|
|
5987
|
+
"pressed",
|
|
5988
|
+
"disabled",
|
|
5989
|
+
"aria-disabled",
|
|
5990
|
+
"aria-pressed",
|
|
5991
|
+
"icon-button",
|
|
5992
|
+
"toggle"
|
|
5993
|
+
]
|
|
5994
|
+
}), R(), {
|
|
5995
|
+
destroy: () => {
|
|
5996
|
+
if (!s) {
|
|
5997
|
+
s = !0, P &&= (cancelAnimationFrame(F), !1);
|
|
5998
|
+
for (let e of Array.from(a.keys())) y(e);
|
|
5999
|
+
for (let e of Array.from(o.keys())) g(e);
|
|
6000
|
+
r.removeEventListener("pointerdown", C), r.removeEventListener("pointermove", w, V), r.removeEventListener("pointerup", E), r.removeEventListener("pointercancel", E), r.removeEventListener("pointerout", D), r.removeEventListener("lostpointercapture", O), r.removeEventListener("keydown", A), r.removeEventListener("keyup", j), r.removeEventListener("click", N, !0), r.removeEventListener("blur", M, !0), r.removeEventListener("scroll", k, B), H && H.removeEventListener("scroll", k, B), z?.disconnect();
|
|
6001
|
+
}
|
|
6002
|
+
},
|
|
6003
|
+
sync: R,
|
|
6004
|
+
getState: (e) => {
|
|
6005
|
+
if (s) return null;
|
|
6006
|
+
let t = u(e);
|
|
6007
|
+
return t ? f(t) : null;
|
|
6008
|
+
}
|
|
6009
|
+
};
|
|
6010
|
+
}, Lu = Iu, Ru = null, zu = !1, Bu = null, Vu = () => {
|
|
6011
|
+
!Bu || typeof document > "u" || (document.removeEventListener("DOMContentLoaded", Bu), Bu = null);
|
|
6012
|
+
}, Hu = () => typeof window > "u" || typeof document > "u" ? null : (zu = !1, Vu(), Ru ? (Ru.sync(), Ru) : (Ru = Iu(), Ru)), Uu = () => {
|
|
6013
|
+
zu = !0, Vu(), Ru?.destroy(), Ru = null;
|
|
6014
|
+
};
|
|
6015
|
+
typeof window < "u" && typeof document < "u" && (document.readyState === "loading" ? (Bu = () => {
|
|
6016
|
+
Bu = null, zu || Hu();
|
|
6017
|
+
}, document.addEventListener("DOMContentLoaded", Bu)) : Hu());
|
|
6018
|
+
//#endregion
|
|
6019
|
+
//#region src/js/src/touchable-row/touchable-row-runtime.ts
|
|
6020
|
+
var Wu = {
|
|
6021
|
+
root: typeof document < "u" ? document : {},
|
|
6022
|
+
touchableRowSelector: "[touchable-row]"
|
|
6023
|
+
}, Gu = (e) => Array.from(e), Ku = L(), qu = new Set([
|
|
6024
|
+
"button",
|
|
6025
|
+
"switch",
|
|
6026
|
+
"checkbox",
|
|
6027
|
+
"radio",
|
|
6028
|
+
"link",
|
|
6029
|
+
"menuitem",
|
|
6030
|
+
"menuitemcheckbox",
|
|
6031
|
+
"menuitemradio",
|
|
6032
|
+
"option",
|
|
6033
|
+
"tab",
|
|
6034
|
+
"textbox",
|
|
6035
|
+
"searchbox",
|
|
6036
|
+
"combobox",
|
|
6037
|
+
"slider",
|
|
6038
|
+
"spinbutton"
|
|
6039
|
+
]), Ju = new Set([
|
|
6040
|
+
"menuitem",
|
|
6041
|
+
"menuitemcheckbox",
|
|
6042
|
+
"menuitemradio"
|
|
6043
|
+
]), Yu = (e) => e === "Enter" || e === " " || e === "Spacebar", Xu = (e) => e === " " || e === "Spacebar", Zu = (e) => {
|
|
6044
|
+
let t = e.getAttribute("role");
|
|
6045
|
+
return t ? t.trim().toLowerCase().split(/\s+/)[0] ?? "" : "";
|
|
6046
|
+
}, Qu = (e, t) => {
|
|
6047
|
+
let n = e.getAttribute("touchable-row");
|
|
6048
|
+
return n ? n.split(/\s+/).includes(t) : !1;
|
|
6049
|
+
}, $u = (e) => Qu(e, "select"), ed = (e) => Qu(e, "activate"), td = (e) => e.hasAttribute("pressable") || $u(e) || ed(e), nd = (e) => e instanceof HTMLButtonElement || e instanceof HTMLAnchorElement, rd = (e) => {
|
|
6050
|
+
if (e.isContentEditable) return !0;
|
|
6051
|
+
let t = e.getAttribute("contenteditable");
|
|
6052
|
+
if (t === null) return !1;
|
|
6053
|
+
let n = t.trim().toLowerCase();
|
|
6054
|
+
return n === "" || n === "true" || n === "plaintext-only";
|
|
6055
|
+
}, id = (e) => e.hasAttribute("menuitem") || Ju.has(Zu(e)), ad = (e) => e instanceof HTMLAnchorElement || Zu(e) === "link", od = (e) => !!(e.getAttribute("aria-disabled") === "true" || e.hasAttribute("disabled") || "disabled" in e && e.disabled), sd = (e) => {
|
|
6056
|
+
let t = e.tagName;
|
|
6057
|
+
return t === "A" || t === "BUTTON" || t === "INPUT" || t === "TEXTAREA" || t === "SELECT" || t === "SUMMARY" || e.hasAttribute("switch") || e.hasAttribute("icon-button") || e.hasAttribute("menuitem") || rd(e) ? !0 : qu.has(Zu(e));
|
|
6058
|
+
}, cd = (e) => {
|
|
6059
|
+
if (e.hasAttribute("selected") || e.getAttribute("aria-selected") === "true") return !0;
|
|
6060
|
+
let t = e.getAttribute("aria-current");
|
|
6061
|
+
return t !== null && t !== "false";
|
|
6062
|
+
}, ld = (e) => ({
|
|
6063
|
+
selected: cd(e),
|
|
6064
|
+
disabled: od(e)
|
|
6065
|
+
}), ud = (e, t) => {
|
|
6066
|
+
if (t ? e.setAttribute("selected", "") : e.removeAttribute("selected"), ad(e)) {
|
|
6067
|
+
let n = t ? "true" : "false";
|
|
6068
|
+
e.getAttribute("aria-current") !== n && e.setAttribute("aria-current", n), !t && e.getAttribute("aria-selected") === "true" && e.setAttribute("aria-selected", "false");
|
|
6069
|
+
return;
|
|
6070
|
+
}
|
|
6071
|
+
let n = t ? "true" : "false";
|
|
6072
|
+
if (e.getAttribute("aria-selected") !== n && e.setAttribute("aria-selected", n), !t) {
|
|
6073
|
+
let t = e.getAttribute("aria-current");
|
|
6074
|
+
t !== null && t !== "false" && e.setAttribute("aria-current", "false");
|
|
6075
|
+
}
|
|
6076
|
+
}, dd = (e) => e instanceof HTMLElement ? e : e instanceof Node ? e.parentElement : null, fd = () => ({
|
|
6077
|
+
destroy: () => {},
|
|
6078
|
+
sync: () => {},
|
|
6079
|
+
getState: () => null
|
|
6080
|
+
}), pd = (e = {}) => {
|
|
6081
|
+
if (typeof window > "u" || typeof document > "u") return fd();
|
|
6082
|
+
let t = {
|
|
6083
|
+
...Wu,
|
|
6084
|
+
...e
|
|
6085
|
+
}, n = t.root ?? document, r = n, i = T("touchable-row"), a = !1, o = !1, s = (e) => !(e instanceof HTMLElement) || !e.matches(t.touchableRowSelector) ? !1 : n instanceof Document ? !0 : n instanceof Node ? n === e || n.contains(e) : !1, c = () => {
|
|
6086
|
+
let e = Gu(n.querySelectorAll(t.touchableRowSelector)).filter(s);
|
|
6087
|
+
return n instanceof HTMLElement && s(n) ? [n, ...e.filter((e) => e !== n)] : e;
|
|
6088
|
+
}, l = (e) => {
|
|
6089
|
+
if (e) {
|
|
6090
|
+
if (s(e)) return e;
|
|
6091
|
+
let n = e.closest(t.touchableRowSelector);
|
|
6092
|
+
return n instanceof HTMLElement && s(n) ? n : null;
|
|
6093
|
+
}
|
|
6094
|
+
return c()[0] ?? null;
|
|
6095
|
+
}, u = (e) => {
|
|
6096
|
+
let n = dd(e);
|
|
6097
|
+
if (!n) return null;
|
|
6098
|
+
let r = n.closest(t.touchableRowSelector);
|
|
6099
|
+
if (!(r instanceof HTMLElement) || !s(r)) return null;
|
|
6100
|
+
let i = n;
|
|
6101
|
+
for (; i && i !== r;) {
|
|
6102
|
+
if (sd(i)) return null;
|
|
6103
|
+
i = i.parentElement;
|
|
6104
|
+
}
|
|
6105
|
+
return r;
|
|
6106
|
+
}, d = (e) => {
|
|
6107
|
+
nd(e) || id(e) || od(e) || td(e) && (e.hasAttribute("role") || e.setAttribute("role", "button"), e.hasAttribute("tabindex") || e.setAttribute("tabindex", "0"));
|
|
6108
|
+
}, f = (e) => {
|
|
6109
|
+
let t = ld(e);
|
|
6110
|
+
d(e), ud(e, !cd(e)), i.adopt(e, t), i.note(e, ld(e));
|
|
6111
|
+
}, p = () => {
|
|
6112
|
+
if (!(a || o)) {
|
|
6113
|
+
o = !0;
|
|
6114
|
+
try {
|
|
6115
|
+
c().forEach((e) => {
|
|
6116
|
+
d(e), i.note(e, ld(e));
|
|
6117
|
+
});
|
|
6118
|
+
} finally {
|
|
6119
|
+
o = !1;
|
|
6120
|
+
}
|
|
6121
|
+
}
|
|
6122
|
+
}, m = (e) => {
|
|
6123
|
+
if (a) return;
|
|
6124
|
+
let t = u(e.target);
|
|
6125
|
+
!t || od(t) || !$u(t) || Ku(e) && f(t);
|
|
6126
|
+
}, h = (e) => {
|
|
6127
|
+
if (a || !(e instanceof KeyboardEvent) || e.repeat || e.isComposing || !Yu(e.key)) return;
|
|
6128
|
+
let t = u(e.target);
|
|
6129
|
+
!t || od(t) || nd(t) || rd(t) || id(t) || (Xu(e.key) && e.cancelable && e.preventDefault(), Ku(e) && t.dispatchEvent(new MouseEvent("click", {
|
|
6130
|
+
bubbles: !0,
|
|
6131
|
+
cancelable: !0,
|
|
6132
|
+
composed: !0
|
|
6133
|
+
})));
|
|
6134
|
+
}, g = !1, _ = 0, v = () => {
|
|
6135
|
+
g || a || (g = !0, _ = requestAnimationFrame(() => {
|
|
6136
|
+
g = !1, p();
|
|
6137
|
+
}));
|
|
6138
|
+
}, y = typeof MutationObserver < "u" ? new MutationObserver(() => v()) : null;
|
|
6139
|
+
return r.addEventListener("click", m), r.addEventListener("keydown", h), y && n instanceof Node && y.observe(n, {
|
|
6140
|
+
childList: !0,
|
|
6141
|
+
subtree: !0,
|
|
6142
|
+
attributes: !0,
|
|
6143
|
+
attributeFilter: [
|
|
6144
|
+
"touchable-row",
|
|
6145
|
+
"pressable",
|
|
6146
|
+
"selected",
|
|
6147
|
+
"disabled",
|
|
6148
|
+
"role",
|
|
6149
|
+
"tabindex",
|
|
6150
|
+
"href",
|
|
6151
|
+
"aria-disabled",
|
|
6152
|
+
"aria-selected",
|
|
6153
|
+
"aria-current",
|
|
6154
|
+
"menuitem"
|
|
6155
|
+
]
|
|
6156
|
+
}), p(), {
|
|
6157
|
+
destroy: () => {
|
|
6158
|
+
a || (a = !0, g &&= (cancelAnimationFrame(_), !1), r.removeEventListener("click", m), r.removeEventListener("keydown", h), y?.disconnect());
|
|
6159
|
+
},
|
|
6160
|
+
sync: p,
|
|
6161
|
+
getState: (e) => {
|
|
6162
|
+
if (a) return null;
|
|
6163
|
+
let t = l(e);
|
|
6164
|
+
return t ? ld(t) : null;
|
|
6165
|
+
}
|
|
6166
|
+
};
|
|
6167
|
+
}, md = pd, hd = null, gd = !1, _d = null, vd = () => {
|
|
6168
|
+
!_d || typeof document > "u" || (document.removeEventListener("DOMContentLoaded", _d), _d = null);
|
|
6169
|
+
}, yd = () => typeof window > "u" || typeof document > "u" ? null : (gd = !1, vd(), hd ? (hd.sync(), hd) : (hd = pd(), hd)), bd = () => {
|
|
6170
|
+
gd = !0, vd(), hd?.destroy(), hd = null;
|
|
6171
|
+
};
|
|
6172
|
+
typeof window < "u" && typeof document < "u" && (document.readyState === "loading" ? (_d = () => {
|
|
6173
|
+
_d = null, gd || yd();
|
|
6174
|
+
}, document.addEventListener("DOMContentLoaded", _d)) : yd());
|
|
6175
|
+
//#endregion
|
|
5741
6176
|
//#region src/tokens/index.ts
|
|
5742
|
-
var
|
|
6177
|
+
var xd = {
|
|
5743
6178
|
colors: {
|
|
5744
6179
|
families: [
|
|
5745
6180
|
"black",
|
|
@@ -5907,4 +6342,4 @@ var _u = {
|
|
|
5907
6342
|
themes: {}
|
|
5908
6343
|
};
|
|
5909
6344
|
//#endregion
|
|
5910
|
-
export { y as Accordion, b as JUICE_CHANGE_EVENT, ve as createAccordion, jl as createAvatar, $r as createBanner, po as createBreadcrumb, ja as createCheckbox, Fr as createCombobox, Ss as createDisclosure, xt as createDrawer, se as createElementMotion, Rc as createField, ll as createIconButton, cc as createInput, bi as createMenu, rt as createModal, te as createMotionCancelToken, M as createNavigation, ns as createPagination, vn as createPopover, No as createProgress, Za as createRadio, qs as createSelect, pa as createSlider, Ps as createSpinner, Ri as createSwitch, lu as createTable, Pe as createTabs, xc as createTextarea, Ut as createToast, Wn as createTooltip, dr as createWizard, ye as initAccordion, Ml as initAvatar, ei as initBanner, mo as initBreadcrumb, Ma as initCheckbox, Ir as initCombobox, Cs as initDisclosure, St as initDrawer, zc as initField, ul as initIconButton, lc as initInput, xi as initMenu, it as initModal, N as initNavigation, rs as initPagination, yn as initPopover, Po as initProgress, Qa as initRadio, Js as initSelect, ma as initSlider, Fs as initSpinner, zi as initSwitch, uu as initTable, Fe as initTabs, Sc as initTextarea, Wt as initToast, Gn as initTooltip, fr as initWizard, K as prefersReducedMotion, oe as runMotion, we as startAccordionRuntime, Ll as startAvatarRuntime, ai as startBannerRuntime, yo as startBreadcrumbRuntime, La as startCheckboxRuntime, Vr as startComboboxRuntime, Os as startDisclosureRuntime, Dt as startDrawerRuntime, Wc as startFieldRuntime, hl as startIconButtonRuntime, mc as startInputRuntime, Ei as startMenuRuntime, lt as startModalRuntime, F as startNavigationRuntime, cs as startPaginationRuntime, wn as startPopoverRuntime, zo as startProgressRuntime, ro as startRadioRuntime, $s as startSelectRuntime, ya as startSliderRuntime, Bs as startSpinnerRuntime, Wi as startSwitchRuntime, hu as startTableRuntime, Be as startTabsRuntime, Dc as startTextareaRuntime, Yt as startToastRuntime, Xn as startTooltipRuntime, _r as startWizardRuntime, Te as stopAccordionRuntime, Rl as stopAvatarRuntime, oi as stopBannerRuntime, bo as stopBreadcrumbRuntime, Ra as stopCheckboxRuntime, Hr as stopComboboxRuntime, ks as stopDisclosureRuntime, Ot as stopDrawerRuntime, Gc as stopFieldRuntime, gl as stopIconButtonRuntime, hc as stopInputRuntime, Di as stopMenuRuntime, ut as stopModalRuntime, I as stopNavigationRuntime, ls as stopPaginationRuntime, Tn as stopPopoverRuntime, Bo as stopProgressRuntime, io as stopRadioRuntime, ec as stopSelectRuntime, ba as stopSliderRuntime, Vs as stopSpinnerRuntime, Gi as stopSwitchRuntime, gu as stopTableRuntime, Ve as stopTabsRuntime, Oc as stopTextareaRuntime, Xt as stopToastRuntime, Zn as stopTooltipRuntime, vr as stopWizardRuntime, ee as subscribeReducedMotion,
|
|
6345
|
+
export { y as Accordion, b as JUICE_CHANGE_EVENT, ve as createAccordion, jl as createAvatar, $r as createBanner, po as createBreadcrumb, ja as createCheckbox, Fr as createCombobox, Ss as createDisclosure, xt as createDrawer, se as createElementMotion, Rc as createField, ll as createIconButton, cc as createInput, bi as createMenu, rt as createModal, te as createMotionCancelToken, M as createNavigation, ns as createPagination, vn as createPopover, Iu as createPressable, No as createProgress, Za as createRadio, qs as createSelect, pa as createSlider, Ps as createSpinner, Ri as createSwitch, lu as createTable, Pe as createTabs, xc as createTextarea, Ut as createToast, Wn as createTooltip, pd as createTouchableRow, dr as createWizard, ye as initAccordion, Ml as initAvatar, ei as initBanner, mo as initBreadcrumb, Ma as initCheckbox, Ir as initCombobox, Cs as initDisclosure, St as initDrawer, zc as initField, ul as initIconButton, lc as initInput, xi as initMenu, it as initModal, N as initNavigation, rs as initPagination, yn as initPopover, Lu as initPressable, Po as initProgress, Qa as initRadio, Js as initSelect, ma as initSlider, Fs as initSpinner, zi as initSwitch, uu as initTable, Fe as initTabs, Sc as initTextarea, Wt as initToast, Gn as initTooltip, md as initTouchableRow, fr as initWizard, K as prefersReducedMotion, oe as runMotion, we as startAccordionRuntime, Ll as startAvatarRuntime, ai as startBannerRuntime, yo as startBreadcrumbRuntime, La as startCheckboxRuntime, Vr as startComboboxRuntime, Os as startDisclosureRuntime, Dt as startDrawerRuntime, Wc as startFieldRuntime, hl as startIconButtonRuntime, mc as startInputRuntime, Ei as startMenuRuntime, lt as startModalRuntime, F as startNavigationRuntime, cs as startPaginationRuntime, wn as startPopoverRuntime, Hu as startPressableRuntime, zo as startProgressRuntime, ro as startRadioRuntime, $s as startSelectRuntime, ya as startSliderRuntime, Bs as startSpinnerRuntime, Wi as startSwitchRuntime, hu as startTableRuntime, Be as startTabsRuntime, Dc as startTextareaRuntime, Yt as startToastRuntime, Xn as startTooltipRuntime, yd as startTouchableRowRuntime, _r as startWizardRuntime, Te as stopAccordionRuntime, Rl as stopAvatarRuntime, oi as stopBannerRuntime, bo as stopBreadcrumbRuntime, Ra as stopCheckboxRuntime, Hr as stopComboboxRuntime, ks as stopDisclosureRuntime, Ot as stopDrawerRuntime, Gc as stopFieldRuntime, gl as stopIconButtonRuntime, hc as stopInputRuntime, Di as stopMenuRuntime, ut as stopModalRuntime, I as stopNavigationRuntime, ls as stopPaginationRuntime, Tn as stopPopoverRuntime, Uu as stopPressableRuntime, Bo as stopProgressRuntime, io as stopRadioRuntime, ec as stopSelectRuntime, ba as stopSliderRuntime, Vs as stopSpinnerRuntime, Gi as stopSwitchRuntime, gu as stopTableRuntime, Ve as stopTabsRuntime, Oc as stopTextareaRuntime, Xt as stopToastRuntime, Zn as stopTooltipRuntime, bd as stopTouchableRowRuntime, vr as stopWizardRuntime, ee as subscribeReducedMotion, xd as tokens };
|
package/dist/js/juice.d.ts
CHANGED
|
@@ -54,6 +54,10 @@ export { createAvatar, initAvatar, startAvatarRuntime, stopAvatarRuntime } from
|
|
|
54
54
|
export type { AvatarController, AvatarOptions, AvatarState } from "./src/avatar/avatar-runtime.js";
|
|
55
55
|
export { createTable, initTable, startTableRuntime, stopTableRuntime } from "./src/table/table-runtime.js";
|
|
56
56
|
export type { TableController, TableOptions, TableSortDirection, TableState } from "./src/table/table-runtime.js";
|
|
57
|
+
export { createPressable, initPressable, startPressableRuntime, stopPressableRuntime } from "./src/pressable/pressable-runtime.js";
|
|
58
|
+
export type { PressableController, PressableOptions, PressableState } from "./src/pressable/pressable-runtime.js";
|
|
59
|
+
export { createTouchableRow, initTouchableRow, startTouchableRowRuntime, stopTouchableRowRuntime } from "./src/touchable-row/touchable-row-runtime.js";
|
|
60
|
+
export type { TouchableRowController, TouchableRowOptions, TouchableRowState } from "./src/touchable-row/touchable-row-runtime.js";
|
|
57
61
|
export { JUICE_CHANGE_EVENT } from "./src/shared/change.js";
|
|
58
62
|
export type { JuiceChangeDetail } from "./src/shared/change.js";
|
|
59
63
|
export { prefersReducedMotion, subscribeReducedMotion, createMotionCancelToken, runMotion, createElementMotion } from "./src/shared/motion.js";
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOM-first runtime for Juice pressable chrome.
|
|
3
|
+
*
|
|
4
|
+
* Markup contract (Slice A — do not rename attrs):
|
|
5
|
+
* [pressable] host. Any value, including "scale", is still
|
|
6
|
+
* a pressable. Sync does not rewrite it.
|
|
7
|
+
* [pressed] transient press. This runtime sets it only
|
|
8
|
+
* for the gesture, and only when it added the
|
|
9
|
+
* attribute. It is not a latched toggle.
|
|
10
|
+
* [pressable-longpress] opt-in. Absent, the host does not arm a
|
|
11
|
+
* long-press. Present with an empty value or
|
|
12
|
+
* "true", the delay is `longPressDelay`
|
|
13
|
+
* (default 500). A non-negative number is the
|
|
14
|
+
* delay in milliseconds. "false" does not arm.
|
|
15
|
+
* Any other value uses the default delay.
|
|
16
|
+
* [pressable-slop] optional pixel slop for this host. A
|
|
17
|
+
* non-negative number overrides `moveSlop`
|
|
18
|
+
* (default 10). Anything else uses the option.
|
|
19
|
+
*
|
|
20
|
+
* Pointer:
|
|
21
|
+
* Primary pointerdown (mouse button 0, touch, or pen, and a primary
|
|
22
|
+
* pointer) sets the transient press. It clears on pointerup,
|
|
23
|
+
* pointercancel, pointerleave, pointerout that leaves the host,
|
|
24
|
+
* pointermove whose target is outside the host, lostpointercapture,
|
|
25
|
+
* and blur of the host itself. Moving farther than the slop, or a
|
|
26
|
+
* scroll whose target is the host or an ancestor (including the
|
|
27
|
+
* document), cancels the press and drops a pending long-press.
|
|
28
|
+
* pointermove and touch scrolling are not preventDefault'd.
|
|
29
|
+
* touch-action stays in CSS.
|
|
30
|
+
*
|
|
31
|
+
* Keyboard:
|
|
32
|
+
* Enter or Space on the host itself sets the transient press while
|
|
33
|
+
* the key is held, including on a native button. Native buttons
|
|
34
|
+
* already match :active; the attribute is set too so the pressed
|
|
35
|
+
* ring matches a pointer press. Keyup clears it. Repeat keydowns
|
|
36
|
+
* do not restart the gesture. Enter is never preventDefault'd, so
|
|
37
|
+
* a native click still fires. Space is preventDefault'd only on a
|
|
38
|
+
* custom button-like host, so the page does not scroll. That host's
|
|
39
|
+
* first role token is button, switch, checkbox, radio, menuitem,
|
|
40
|
+
* menuitemcheckbox, menuitemradio, option, tab, or treeitem, and
|
|
41
|
+
* the host is not a native control that already owns Space (button,
|
|
42
|
+
* input, textarea, select, summary, or contenteditable). A pressable
|
|
43
|
+
* with no button-like role is left alone, and role="link" keeps the
|
|
44
|
+
* scroll. Long-press is pointer-only. The host has to be the event
|
|
45
|
+
* target. This runtime does not add tabindex or role.
|
|
46
|
+
*
|
|
47
|
+
* Long-press:
|
|
48
|
+
* Armed only when [pressable-longpress] enables it. After the delay,
|
|
49
|
+
* the host dispatches a bubbling, cancelable, composed
|
|
50
|
+
* `juice:longpress` CustomEvent. detail is
|
|
51
|
+
* `{ pressed: true, longPressed: true }`. If the event is not
|
|
52
|
+
* preventDefault'd, the click that follows that gesture is
|
|
53
|
+
* suppressed once (capture-phase preventDefault and
|
|
54
|
+
* stopPropagation). If the event is canceled, the click is left
|
|
55
|
+
* alone. A slop or scroll cancel before the timer fires does not
|
|
56
|
+
* long-press and does not suppress the click. If the long-press
|
|
57
|
+
* already fired, a later cancel still suppresses that one click.
|
|
58
|
+
* The suppress flag expires on that click or on the next turn, so
|
|
59
|
+
* a later click is not swallowed.
|
|
60
|
+
*
|
|
61
|
+
* Latched [pressed]:
|
|
62
|
+
* [icon-button][toggle] and any host with aria-pressed own [pressed]
|
|
63
|
+
* as a latched toggle. This runtime never sets or removes [pressed]
|
|
64
|
+
* on those hosts. The gesture is still getState().pressed and still
|
|
65
|
+
* dispatches juice:change. :active paints the ring. On every other
|
|
66
|
+
* host, [pressed] is set only when it was absent, and removed only
|
|
67
|
+
* when this runtime added it. An author [pressed] that was already
|
|
68
|
+
* there is left in place.
|
|
69
|
+
*
|
|
70
|
+
* Disabled:
|
|
71
|
+
* :disabled (the disabled property), [disabled], and
|
|
72
|
+
* [aria-disabled="true"] do not press and do not long-press. A host
|
|
73
|
+
* that becomes disabled during a press is cleared.
|
|
74
|
+
*
|
|
75
|
+
* State is { pressed, longPressed }. pressed is the transient gesture,
|
|
76
|
+
* not a latched attribute. longPressed is true only after
|
|
77
|
+
* juice:longpress has fired for the current gesture. Both return to
|
|
78
|
+
* false when the gesture ends. The first observation is recorded
|
|
79
|
+
* and does not dispatch. Later changes dispatch a bubbling
|
|
80
|
+
* juice:change CustomEvent with detail
|
|
81
|
+
* { runtime: "pressable", state }.
|
|
82
|
+
*
|
|
83
|
+
* Reduced motion stays in CSS. This runtime does not read
|
|
84
|
+
* prefers-reduced-motion and does not animate. No Sig Pressable
|
|
85
|
+
* factory. Pressable is the twenty-ninth Emerging auto-enhance
|
|
86
|
+
* runtime.
|
|
87
|
+
*/
|
|
88
|
+
export type PressableOptions = {
|
|
89
|
+
root?: ParentNode;
|
|
90
|
+
pressableSelector?: string;
|
|
91
|
+
longPressDelay?: number;
|
|
92
|
+
moveSlop?: number;
|
|
93
|
+
};
|
|
94
|
+
export type PressableState = {
|
|
95
|
+
pressed: boolean;
|
|
96
|
+
longPressed: boolean;
|
|
97
|
+
};
|
|
98
|
+
export type PressableController = {
|
|
99
|
+
destroy: () => void;
|
|
100
|
+
sync: () => void;
|
|
101
|
+
getState: (target?: HTMLElement | null) => PressableState | null;
|
|
102
|
+
};
|
|
103
|
+
export declare const createPressable: (options?: PressableOptions) => PressableController;
|
|
104
|
+
export declare const initPressable: (options?: PressableOptions) => PressableController;
|
|
105
|
+
export declare const startPressableRuntime: () => PressableController | null;
|
|
106
|
+
export declare const stopPressableRuntime: () => void;
|
|
@@ -29,4 +29,5 @@ export declare const createJuiceChanges: <TState>(runtime: string) => {
|
|
|
29
29
|
has: (host: EventTarget) => boolean;
|
|
30
30
|
prime: (host: EventTarget, state: TState) => void;
|
|
31
31
|
note: (host: EventTarget, state: TState, options?: JuiceChangeNoteOptions<TState>) => void;
|
|
32
|
+
adopt: (host: EventTarget, state: TState) => void;
|
|
32
33
|
};
|