@floegence/floe-webapp-core 0.56.11 → 0.56.14
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/components/ui/PersistentHorizontalScrollbar.d.ts +11 -0
- package/dist/components/ui/PersistentHorizontalScrollbar.js +172 -0
- package/dist/components/ui/index.d.ts +1 -0
- package/dist/full.js +285 -283
- package/dist/styles.css +1 -1
- package/dist/ui.css +54 -0
- package/dist/ui.js +77 -75
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type JSX } from 'solid-js';
|
|
2
|
+
export interface PersistentHorizontalScrollbarProps extends Omit<JSX.HTMLAttributes<HTMLDivElement>, 'children' | 'onScroll' | 'onKeyDown' | 'onPointerDown'> {
|
|
3
|
+
/** The real, constrained left-to-right scroll viewport. Native scrolling remains authoritative. */
|
|
4
|
+
viewport: HTMLElement | undefined;
|
|
5
|
+
'aria-label': string;
|
|
6
|
+
}
|
|
7
|
+
/** A persistent overflow affordance independent of OS overlay-scrollbar settings.
|
|
8
|
+
* Place beside the viewport in a flex column. This control owns pointer and keyboard
|
|
9
|
+
* interaction only; the host retains wheel and Workbench activation ownership.
|
|
10
|
+
*/
|
|
11
|
+
export declare function PersistentHorizontalScrollbar(allProps: PersistentHorizontalScrollbarProps): JSX.Element;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { createComponent as E, use as y, spread as $, mergeProps as O, effect as _, setStyleProperty as W, template as B, delegateEvents as F } from "solid-js/web";
|
|
2
|
+
import { splitProps as q, createSignal as U, createUniqueId as X, createMemo as h, createEffect as H, onCleanup as z, Show as K, untrack as N } from "solid-js";
|
|
3
|
+
import { cn as V } from "../../utils/cn.js";
|
|
4
|
+
import { LOCAL_INTERACTION_SURFACE_ATTR as Y } from "./localInteractionSurface.js";
|
|
5
|
+
var j = /* @__PURE__ */ B("<div><div aria-hidden=true data-floe-horizontal-scrollbar-thumb=true class=floe-horizontal-scrollbar-thumb>");
|
|
6
|
+
const w = {
|
|
7
|
+
clientWidth: 0,
|
|
8
|
+
trackWidth: 0,
|
|
9
|
+
scrollLeft: 0,
|
|
10
|
+
scrollWidth: 0
|
|
11
|
+
};
|
|
12
|
+
function tt(C) {
|
|
13
|
+
const [c, P] = q(C, ["viewport", "class"]), [l, m] = U(w), f = X();
|
|
14
|
+
let n, g, s;
|
|
15
|
+
const p = () => {
|
|
16
|
+
const t = c.viewport;
|
|
17
|
+
if (!t) {
|
|
18
|
+
m(w);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
m({
|
|
22
|
+
clientWidth: t.clientWidth,
|
|
23
|
+
trackWidth: n?.clientWidth ?? t.clientWidth,
|
|
24
|
+
scrollLeft: t.scrollLeft,
|
|
25
|
+
scrollWidth: t.scrollWidth
|
|
26
|
+
});
|
|
27
|
+
}, u = () => {
|
|
28
|
+
if (s === void 0) {
|
|
29
|
+
if (typeof window > "u" || typeof window.requestAnimationFrame != "function") {
|
|
30
|
+
p();
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
s = window.requestAnimationFrame(() => {
|
|
34
|
+
s = void 0, N(p);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}, b = (t) => {
|
|
38
|
+
const e = c.viewport;
|
|
39
|
+
if (!e) return;
|
|
40
|
+
const o = Math.max(0, e.scrollWidth - e.clientWidth);
|
|
41
|
+
e.scrollLeft = Math.max(0, Math.min(o, t)), p();
|
|
42
|
+
}, a = h(() => {
|
|
43
|
+
const t = l();
|
|
44
|
+
return Math.max(0, t.scrollWidth - t.clientWidth);
|
|
45
|
+
}), T = h(() => a() > 1), v = h(() => {
|
|
46
|
+
const t = l();
|
|
47
|
+
return t.scrollWidth <= 0 ? 100 : Math.min(100, Math.max(28 / Math.max(1, t.trackWidth), t.clientWidth / t.scrollWidth) * 100);
|
|
48
|
+
}), k = h(() => {
|
|
49
|
+
const t = a();
|
|
50
|
+
return t <= 0 ? 0 : Math.max(0, Math.min(1, l().scrollLeft / t)) * (100 - v());
|
|
51
|
+
}), x = (t) => {
|
|
52
|
+
if (t.button !== 0 || !n) return;
|
|
53
|
+
t.preventDefault(), n.focus({
|
|
54
|
+
preventScroll: !0
|
|
55
|
+
});
|
|
56
|
+
const e = n.getBoundingClientRect(), r = n.querySelector("[data-floe-horizontal-scrollbar-thumb]")?.getBoundingClientRect().width ?? e.width * (v() / 100), i = Math.max(1, e.width - r), d = Math.max(0, Math.min(i, t.clientX - e.left - r / 2));
|
|
57
|
+
b(d / i * a());
|
|
58
|
+
};
|
|
59
|
+
let S = 0, M = 0;
|
|
60
|
+
const A = (t) => {
|
|
61
|
+
if (t.button !== 0 || !n) return;
|
|
62
|
+
const e = t.currentTarget;
|
|
63
|
+
n.focus({
|
|
64
|
+
preventScroll: !0
|
|
65
|
+
}), S = t.clientX, M = l().scrollLeft, e.setPointerCapture(t.pointerId), t.preventDefault(), t.stopPropagation();
|
|
66
|
+
}, D = (t) => {
|
|
67
|
+
const e = t.currentTarget;
|
|
68
|
+
if (!e.hasPointerCapture(t.pointerId) || !n) return;
|
|
69
|
+
const o = Math.max(1, n.getBoundingClientRect().width - e.getBoundingClientRect().width), r = (t.clientX - S) / o * a();
|
|
70
|
+
b(M + r);
|
|
71
|
+
}, L = (t) => {
|
|
72
|
+
const e = t.currentTarget;
|
|
73
|
+
e.hasPointerCapture(t.pointerId) && e.releasePointerCapture(t.pointerId);
|
|
74
|
+
}, R = (t) => {
|
|
75
|
+
const e = l(), o = 48;
|
|
76
|
+
let r;
|
|
77
|
+
switch (t.key) {
|
|
78
|
+
case "ArrowLeft":
|
|
79
|
+
r = e.scrollLeft - o;
|
|
80
|
+
break;
|
|
81
|
+
case "ArrowRight":
|
|
82
|
+
r = e.scrollLeft + o;
|
|
83
|
+
break;
|
|
84
|
+
case "Home":
|
|
85
|
+
r = 0;
|
|
86
|
+
break;
|
|
87
|
+
case "End":
|
|
88
|
+
r = a();
|
|
89
|
+
break;
|
|
90
|
+
case "PageUp":
|
|
91
|
+
r = e.scrollLeft - e.clientWidth;
|
|
92
|
+
break;
|
|
93
|
+
case "PageDown":
|
|
94
|
+
r = e.scrollLeft + e.clientWidth;
|
|
95
|
+
break;
|
|
96
|
+
default:
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
t.preventDefault(), t.stopPropagation(), b(r);
|
|
100
|
+
};
|
|
101
|
+
return H(() => {
|
|
102
|
+
const t = c.viewport;
|
|
103
|
+
if (!t) {
|
|
104
|
+
m(w);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const e = !t.id;
|
|
108
|
+
e && (t.id = f);
|
|
109
|
+
const o = t.getAttribute("data-floe-horizontal-scroll-viewport");
|
|
110
|
+
t.setAttribute("data-floe-horizontal-scroll-viewport", "true");
|
|
111
|
+
const r = new ResizeObserver(u);
|
|
112
|
+
g = r;
|
|
113
|
+
const i = () => {
|
|
114
|
+
r.disconnect(), r.observe(t);
|
|
115
|
+
for (const I of t.children) r.observe(I);
|
|
116
|
+
n?.isConnected && r.observe(n), u();
|
|
117
|
+
}, d = new MutationObserver(i);
|
|
118
|
+
d.observe(t, {
|
|
119
|
+
childList: !0,
|
|
120
|
+
subtree: !0,
|
|
121
|
+
characterData: !0
|
|
122
|
+
}), t.addEventListener("scroll", u, {
|
|
123
|
+
passive: !0
|
|
124
|
+
}), i(), z(() => {
|
|
125
|
+
r.disconnect(), d.disconnect(), t.removeEventListener("scroll", u), e && t.id === f && t.removeAttribute("id"), o === null ? t.removeAttribute("data-floe-horizontal-scroll-viewport") : t.setAttribute("data-floe-horizontal-scroll-viewport", o);
|
|
126
|
+
});
|
|
127
|
+
}), z(() => {
|
|
128
|
+
s !== void 0 && window.cancelAnimationFrame(s);
|
|
129
|
+
}), E(K, {
|
|
130
|
+
get when() {
|
|
131
|
+
return T();
|
|
132
|
+
},
|
|
133
|
+
get children() {
|
|
134
|
+
var t = j(), e = t.firstChild;
|
|
135
|
+
return y((o) => {
|
|
136
|
+
n = o, g?.observe(o), u();
|
|
137
|
+
}, t), $(t, O({
|
|
138
|
+
[Y]: "true"
|
|
139
|
+
}, P, {
|
|
140
|
+
get "aria-controls"() {
|
|
141
|
+
return c.viewport?.id || f;
|
|
142
|
+
},
|
|
143
|
+
"aria-orientation": "horizontal",
|
|
144
|
+
get "aria-valuemax"() {
|
|
145
|
+
return Math.round(a());
|
|
146
|
+
},
|
|
147
|
+
"aria-valuemin": "0",
|
|
148
|
+
get "aria-valuenow"() {
|
|
149
|
+
return Math.round(l().scrollLeft);
|
|
150
|
+
},
|
|
151
|
+
"data-floe-horizontal-scrollbar": "true",
|
|
152
|
+
role: "scrollbar",
|
|
153
|
+
tabIndex: 0,
|
|
154
|
+
get class() {
|
|
155
|
+
return V("floe-horizontal-scrollbar", c.class);
|
|
156
|
+
},
|
|
157
|
+
onKeyDown: R,
|
|
158
|
+
onPointerDown: x
|
|
159
|
+
}), !1, !0), e.addEventListener("pointercancel", L), e.$$pointerup = L, e.$$pointermove = D, e.$$pointerdown = A, _((o) => {
|
|
160
|
+
var r = `${k()}%`, i = `${v()}%`;
|
|
161
|
+
return r !== o.e && W(e, "left", o.e = r), i !== o.t && W(e, "width", o.t = i), o;
|
|
162
|
+
}, {
|
|
163
|
+
e: void 0,
|
|
164
|
+
t: void 0
|
|
165
|
+
}), t;
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
F(["pointerdown", "pointermove", "pointerup"]);
|
|
170
|
+
export {
|
|
171
|
+
tt as PersistentHorizontalScrollbar
|
|
172
|
+
};
|
|
@@ -41,3 +41,4 @@ export { Pagination, type PaginationProps, type PaginationSize, type PaginationV
|
|
|
41
41
|
export { MobileKeyboard, type MobileKeyboardProps, type MobileKeyboardSuggestionItem, } from './MobileKeyboard';
|
|
42
42
|
export { LinearProgress, CircularProgress, SegmentedProgress, StepsProgress, type LinearProgressProps, type CircularProgressProps, type SegmentedProgressProps, type StepsProgressProps, type ProgressSize, type ProgressColor, } from './Progress';
|
|
43
43
|
export { SurfaceAnchoredLayer, type SurfaceAnchoredLayerProps } from './SurfaceAnchoredLayer';
|
|
44
|
+
export { PersistentHorizontalScrollbar, type PersistentHorizontalScrollbarProps } from './PersistentHorizontalScrollbar';
|