@floegence/floe-webapp-core 0.101.5 → 0.101.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
- import { use as k, spread as V, mergeProps as q, insert as $, createComponent as E, memo as B, effect as N, setAttribute as p, className as T, setStyleProperty as x, template as A, delegateEvents as G } from "solid-js/web";
2
- import { splitProps as I, createSignal as J, createEffect as K, onMount as Q, onCleanup as j, For as U, untrack as X } from "solid-js";
3
- import { cn as z } from "../../utils/cn.js";
4
- var Y = /* @__PURE__ */ A("<div role=group data-floe-surface=inset data-floe-surface-part=rail><span aria-hidden=true>"), Z = /* @__PURE__ */ A('<button type=button role=radio data-floe-surface-part=segment data-floe-interactive=item><span class="inline-flex items-center gap-1.5"><span class=floe-segmented-control__label>');
5
- const ee = {
1
+ import { use as T, spread as X, mergeProps as Y, insert as p, createComponent as W, memo as V, effect as M, setAttribute as z, setStyleProperty as c, className as q, template as j, delegateEvents as Z } from "solid-js/web";
2
+ import { splitProps as ee, createSignal as B, createEffect as te, onMount as oe, onCleanup as G, For as I, untrack as re } from "solid-js";
3
+ import { cn as R } from "../../utils/cn.js";
4
+ var ne = /* @__PURE__ */ j("<div role=group data-floe-surface=inset data-floe-surface-part=rail><span aria-hidden=true><span class=floe-segmented-control__ink>"), ie = /* @__PURE__ */ j('<span class=floe-segmented-control__ink-label><span class="inline-flex items-center gap-1.5"><span>'), ae = /* @__PURE__ */ j('<button type=button role=radio data-floe-surface-part=segment data-floe-interactive=item><span class="inline-flex items-center gap-1.5"><span class=floe-segmented-control__label>');
5
+ const le = {
6
6
  sm: {
7
7
  container: "p-0.5 gap-0.5",
8
8
  button: "h-[var(--floe-control-height-xs)] px-[var(--floe-control-padding-sm)] rounded-sm",
@@ -19,92 +19,129 @@ const ee = {
19
19
  icon: "w-4 h-4"
20
20
  }
21
21
  };
22
- function ne(D) {
23
- const [r, H] = I(D, ["value", "onChange", "options", "size", "disabled", "class"]);
24
- let c, f;
25
- const h = /* @__PURE__ */ new Map(), [s, S] = J();
26
- let u, m, b;
27
- const y = () => {
28
- const o = h.get(r.value);
29
- if (!c || !o) {
30
- m?.cancel(), S(void 0), b = void 0;
22
+ function fe(J) {
23
+ const [l, K] = ee(J, ["value", "onChange", "options", "size", "disabled", "class"]);
24
+ let u, m, g;
25
+ const [P, Q] = B({}), y = /* @__PURE__ */ new Map(), [d, A] = B();
26
+ let h, b, w, F;
27
+ const E = () => {
28
+ const a = y.get(l.value);
29
+ if (!u || !a) {
30
+ b?.cancel(), w?.cancel(), A(void 0), F = void 0;
31
31
  return;
32
32
  }
33
- if (!o.offsetWidth || !c.getClientRects().length) return;
34
- const n = {
35
- x: o.offsetLeft,
36
- y: o.offsetTop,
37
- width: o.offsetWidth,
38
- height: o.offsetHeight
39
- }, v = X(s);
40
- if (v && Object.keys(n).every((a) => n[a] === v[a]) && b === r.value) return;
41
- const e = v && b !== r.value && f && !window.matchMedia("(prefers-reduced-motion: reduce), (forced-colors: active)").matches ? getComputedStyle(f) : void 0, l = e ? {
42
- transform: e.transform,
43
- width: e.width
44
- } : void 0;
45
- if (m?.cancel(), S(n), b = r.value, l && f) {
46
- const a = getComputedStyle(c), i = a.getPropertyValue("--floe-duration-slow").trim(), d = parseFloat(i) * (i.endsWith("ms") ? 1 : 1e3);
47
- m = f.animate([l, {
48
- transform: `translate(${n.x}px, ${n.y}px)`,
49
- width: `${n.width}px`
33
+ if (!a.offsetWidth || !u.getClientRects().length) return;
34
+ const r = {
35
+ x: a.offsetLeft,
36
+ y: a.offsetTop,
37
+ width: a.offsetWidth,
38
+ height: a.offsetHeight
39
+ };
40
+ Q(Object.fromEntries([...y].map(([o, s]) => [o, {
41
+ x: s.offsetLeft,
42
+ y: s.offsetTop,
43
+ width: s.offsetWidth,
44
+ height: s.offsetHeight
45
+ }])));
46
+ const f = re(d);
47
+ if (f && Object.keys(r).every((o) => r[o] === f[o]) && F === l.value) return;
48
+ const $ = f && F !== l.value && m && !window.matchMedia("(prefers-reduced-motion: reduce), (forced-colors: active)").matches, x = $ ? getComputedStyle(m) : void 0, C = x ? {
49
+ transform: x.transform,
50
+ width: x.width
51
+ } : void 0, e = $ && g ? getComputedStyle(g).transform : void 0;
52
+ if (b?.cancel(), w?.cancel(), A(r), F = l.value, C && m) {
53
+ const o = getComputedStyle(u), s = o.getPropertyValue("--floe-duration-slow").trim(), n = parseFloat(s) * (s.endsWith("ms") ? 1 : 1e3);
54
+ b = m.animate([C, {
55
+ transform: `translate(${r.x}px, ${r.y}px)`,
56
+ width: `${r.width}px`
50
57
  }], {
51
58
  // Position changes need visible travel: the fast entrance curve
52
59
  // covers almost 90% of this short rail in its first 60ms.
53
- duration: Number.isFinite(d) ? d : 280,
54
- easing: a.getPropertyValue("--floe-ease-in-out").trim() || "ease-in-out"
55
- }), m.id = "floe-segmented-selection";
60
+ duration: Number.isFinite(n) ? n : 280,
61
+ easing: o.getPropertyValue("--floe-ease-in-out").trim() || "ease-in-out"
62
+ }), b.id = "floe-segmented-selection", g && e && (w = g.animate([{
63
+ transform: e
64
+ }, {
65
+ transform: `translate(${-r.x}px, ${-r.y}px)`
66
+ }], b.effect.getTiming()), w.id = "floe-segmented-ink");
56
67
  }
57
68
  };
58
- K(() => {
59
- r.value, r.options, r.size, y();
60
- }), Q(() => {
69
+ te(() => {
70
+ l.value, l.options, l.size, E();
71
+ }), oe(() => {
61
72
  if (typeof ResizeObserver < "u") {
62
- u = new ResizeObserver(y), u.observe(c);
63
- for (const o of h.values()) u.observe(o);
73
+ h = new ResizeObserver(E), h.observe(u);
74
+ for (const a of y.values()) h.observe(a);
64
75
  }
65
- y();
66
- }), j(() => {
67
- u?.disconnect(), m?.cancel();
76
+ E();
77
+ }), G(() => {
78
+ h?.disconnect(), b?.cancel(), w?.cancel();
68
79
  });
69
- const P = () => r.size ?? "md", w = () => ee[P()], L = (o, n) => {
70
- r.disabled || n || o !== r.value && r.onChange(o);
80
+ const H = () => l.size ?? "md", O = () => le[H()], U = (a, r) => {
81
+ l.disabled || r || a !== l.value && l.onChange(a);
71
82
  };
72
83
  return (() => {
73
- var o = Y(), n = o.firstChild, v = c;
74
- typeof v == "function" ? k(v, o) : c = o, V(o, q({
84
+ var a = ne(), r = a.firstChild, f = r.firstChild, $ = u;
85
+ typeof $ == "function" ? T($, a) : u = a, X(a, Y({
75
86
  get "data-floe-segmented-pill"() {
76
- return s() ? "true" : void 0;
87
+ return d() ? "true" : void 0;
77
88
  },
78
89
  get "data-floe-segmented-motion"() {
79
- return s() ? "ready" : void 0;
90
+ return d() ? "ready" : void 0;
80
91
  },
81
92
  get class() {
82
- return z("floe-segmented-control relative inline-flex items-center border", "rounded-group", "text-[length:var(--floe-type-control)] leading-[var(--floe-line-control)]", w().container, r.disabled && "opacity-50 pointer-events-none", r.class);
93
+ return R("floe-segmented-control relative inline-flex items-center border", "rounded-group", "text-[length:var(--floe-type-control)] leading-[var(--floe-line-control)]", O().container, l.disabled && "opacity-50 pointer-events-none", l.class);
83
94
  }
84
- }, H), !1, !0);
85
- var C = f;
86
- return typeof C == "function" ? k(C, n) : f = n, $(o, E(U, {
95
+ }, K), !1, !0);
96
+ var x = m;
97
+ typeof x == "function" ? T(x, r) : m = r;
98
+ var C = g;
99
+ return typeof C == "function" ? T(C, f) : g = f, p(f, W(I, {
87
100
  get each() {
88
- return r.options;
101
+ return l.options;
102
+ },
103
+ children: (e) => (() => {
104
+ var o = ie(), s = o.firstChild, n = s.firstChild;
105
+ return p(s, (() => {
106
+ var i = V(() => !!e.icon);
107
+ return () => i() && W(e.icon, {
108
+ get class() {
109
+ return O().icon;
110
+ }
111
+ });
112
+ })(), n), p(n, () => e.label), M((i) => {
113
+ var v = e.value, t = `${P()[e.value]?.x ?? 0}px`, k = `${P()[e.value]?.y ?? 0}px`, _ = `${P()[e.value]?.width ?? 0}px`, S = `${P()[e.value]?.height ?? 0}px`;
114
+ return v !== i.e && z(o, "data-segmented-label", i.e = v), t !== i.t && c(o, "left", i.t = t), k !== i.a && c(o, "top", i.a = k), _ !== i.o && c(o, "width", i.o = _), S !== i.i && c(o, "height", i.i = S), i;
115
+ }, {
116
+ e: void 0,
117
+ t: void 0,
118
+ a: void 0,
119
+ o: void 0,
120
+ i: void 0
121
+ }), o;
122
+ })()
123
+ })), p(a, W(I, {
124
+ get each() {
125
+ return l.options;
89
126
  },
90
127
  children: (e) => {
91
- const l = () => r.value === e.value, a = () => r.disabled || e.disabled;
128
+ const o = () => l.value === e.value, s = () => l.disabled || e.disabled;
92
129
  return (() => {
93
- var i = Z(), d = i.firstChild, g = d.firstChild;
94
- return i.$$click = () => L(e.value, e.disabled), k((t) => {
95
- h.set(e.value, t), u?.observe(t), j(() => {
96
- u?.unobserve(t), h.delete(e.value);
130
+ var n = ae(), i = n.firstChild, v = i.firstChild;
131
+ return n.$$click = () => U(e.value, e.disabled), T((t) => {
132
+ y.set(e.value, t), h?.observe(t), G(() => {
133
+ h?.unobserve(t), y.delete(e.value);
97
134
  });
98
- }, i), $(d, (() => {
99
- var t = B(() => !!e.icon);
100
- return () => t() && E(e.icon, {
135
+ }, n), p(i, (() => {
136
+ var t = V(() => !!e.icon);
137
+ return () => t() && W(e.icon, {
101
138
  get class() {
102
- return w().icon;
139
+ return O().icon;
103
140
  }
104
141
  });
105
- })(), g), $(g, () => e.label), N((t) => {
106
- var _ = e.label, F = e.label, M = l() ? "raised" : "flat", O = l(), R = a(), W = z("floe-segmented-control__item relative font-medium cursor-pointer border", "transition-[background-color,border-color,color,box-shadow] duration-[var(--floe-duration-fast)] ease-[var(--floe-ease-out)]", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-[var(--floe-plane)]", w().button, l() ? "text-[var(--primary-foreground)]" : "text-[var(--floe-ink-soft)] hover:text-foreground", a() && "cursor-not-allowed opacity-50");
107
- return _ !== t.e && p(i, "aria-label", t.e = _), F !== t.t && p(i, "title", t.t = F), M !== t.a && p(i, "data-floe-surface", t.a = M), O !== t.o && p(i, "aria-checked", t.o = O), R !== t.i && (i.disabled = t.i = R), W !== t.n && T(i, t.n = W), t;
142
+ })(), v), p(v, () => e.label), M((t) => {
143
+ var k = e.label, _ = e.label, S = o() ? "raised" : "flat", L = o(), N = s(), D = R("floe-segmented-control__item relative font-medium cursor-pointer border", "transition-[background-color,border-color,color,box-shadow] duration-[var(--floe-duration-fast)] ease-[var(--floe-ease-out)]", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-[var(--floe-plane)]", O().button, o() ? "text-[var(--primary-foreground)]" : "text-[var(--floe-ink-soft)] hover:text-foreground", s() && "cursor-not-allowed opacity-50");
144
+ return k !== t.e && z(n, "aria-label", t.e = k), _ !== t.t && z(n, "title", t.t = _), S !== t.a && z(n, "data-floe-surface", t.a = S), L !== t.o && z(n, "aria-checked", t.o = L), N !== t.i && (n.disabled = t.i = N), D !== t.n && q(n, t.n = D), t;
108
145
  }, {
109
146
  e: void 0,
110
147
  t: void 0,
@@ -112,22 +149,23 @@ function ne(D) {
112
149
  o: void 0,
113
150
  i: void 0,
114
151
  n: void 0
115
- }), i;
152
+ }), n;
116
153
  })();
117
154
  }
118
- }), null), N((e) => {
119
- var l = z("floe-segmented-control__pill", P() === "lg" ? "rounded-md" : "rounded-sm"), a = s() ? "visible" : "hidden", i = `translate(${s()?.x ?? 0}px, ${s()?.y ?? 0}px)`, d = `${s()?.width ?? 0}px`, g = `${s()?.height ?? 0}px`;
120
- return l !== e.e && T(n, e.e = l), a !== e.t && x(n, "visibility", e.t = a), i !== e.a && x(n, "transform", e.a = i), d !== e.o && x(n, "width", e.o = d), g !== e.i && x(n, "height", e.i = g), e;
155
+ }), null), M((e) => {
156
+ var o = R("floe-segmented-control__pill", H() === "lg" ? "rounded-md" : "rounded-sm"), s = d() ? "visible" : "hidden", n = `translate(${d()?.x ?? 0}px, ${d()?.y ?? 0}px)`, i = `${d()?.width ?? 0}px`, v = `${d()?.height ?? 0}px`, t = `translate(${-(d()?.x ?? 0)}px, ${-(d()?.y ?? 0)}px)`;
157
+ return o !== e.e && q(r, e.e = o), s !== e.t && c(r, "visibility", e.t = s), n !== e.a && c(r, "transform", e.a = n), i !== e.o && c(r, "width", e.o = i), v !== e.i && c(r, "height", e.i = v), t !== e.n && c(f, "transform", e.n = t), e;
121
158
  }, {
122
159
  e: void 0,
123
160
  t: void 0,
124
161
  a: void 0,
125
162
  o: void 0,
126
- i: void 0
127
- }), o;
163
+ i: void 0,
164
+ n: void 0
165
+ }), a;
128
166
  })();
129
167
  }
130
- G(["click"]);
168
+ Z(["click"]);
131
169
  export {
132
- ne as SegmentedControl
170
+ fe as SegmentedControl
133
171
  };
@@ -0,0 +1,14 @@
1
+ import { type JSX } from 'solid-js';
2
+ export interface SettingsDisclosureProps {
3
+ title: string;
4
+ description?: string;
5
+ open?: boolean;
6
+ defaultOpen?: boolean;
7
+ onOpenChange?: (open: boolean) => void;
8
+ disabled?: boolean;
9
+ hidden?: boolean;
10
+ class?: string;
11
+ children: JSX.Element;
12
+ }
13
+ /** A retained settings group. Hosts still own draft and portalled-control authority. */
14
+ export declare function SettingsDisclosure(props: SettingsDisclosureProps): JSX.Element;
@@ -0,0 +1,77 @@
1
+ import { createComponent as f, setAttribute as n, insert as a, effect as m, use as $, template as g, delegateEvents as y } from "solid-js/web";
2
+ import { createUniqueId as S, createMemo as w, createRenderEffect as E, Show as b } from "solid-js";
3
+ import { ChevronRight as O } from "../icons/index.js";
4
+ import { cn as R } from "../../utils/cn.js";
5
+ import { createControllableValue as k } from "./controllable.js";
6
+ import { SettingsList as x } from "./Settings.js";
7
+ var V = /* @__PURE__ */ g("<span class=floe-settings-disclosure__description>"), q = /* @__PURE__ */ g("<button type=button class=floe-settings-disclosure__trigger><span class=floe-settings-disclosure__heading><span>"), A = /* @__PURE__ */ g("<div class=floe-settings-disclosure__content>"), D = /* @__PURE__ */ g("<div class=floe-settings-disclosure__panel><div class=floe-settings-disclosure__clip>");
8
+ function B(i) {
9
+ const l = S(), [s, C] = k({
10
+ value: () => i.open,
11
+ defaultValue: i.defaultOpen ?? !1,
12
+ onChange: (e) => i.onOpenChange?.(e)
13
+ }), p = w((e) => e || s(), !1);
14
+ let c, v;
15
+ return E(() => {
16
+ !s() && v?.contains(document.activeElement) && c?.getClientRects().length && c.focus({
17
+ preventScroll: !0
18
+ });
19
+ }), f(x, {
20
+ get class() {
21
+ return R("floe-settings-disclosure", i.class);
22
+ },
23
+ get hidden() {
24
+ return i.hidden;
25
+ },
26
+ get "data-open"() {
27
+ return s();
28
+ },
29
+ get children() {
30
+ return [(() => {
31
+ var e = q(), u = e.firstChild, d = u.firstChild;
32
+ e.$$click = () => C(!s());
33
+ var r = c;
34
+ return typeof r == "function" ? $(r, e) : c = e, n(e, "id", `${l}-trigger`), n(e, "aria-labelledby", `${l}-title`), n(e, "aria-controls", `${l}-panel`), n(d, "id", `${l}-title`), a(d, () => i.title), a(u, f(b, {
35
+ get when() {
36
+ return i.description;
37
+ },
38
+ get children() {
39
+ var t = V();
40
+ return n(t, "id", `${l}-description`), a(t, () => i.description), t;
41
+ }
42
+ }), null), a(e, f(O, {
43
+ class: "floe-settings-disclosure__chevron",
44
+ "aria-hidden": "true"
45
+ }), null), m((t) => {
46
+ var o = s(), _ = i.description ? `${l}-description` : void 0, h = i.disabled;
47
+ return o !== t.e && n(e, "aria-expanded", t.e = o), _ !== t.t && n(e, "aria-describedby", t.t = _), h !== t.a && (e.disabled = t.a = h), t;
48
+ }, {
49
+ e: void 0,
50
+ t: void 0,
51
+ a: void 0
52
+ }), e;
53
+ })(), (() => {
54
+ var e = D(), u = e.firstChild, d = v;
55
+ return typeof d == "function" ? $(d, e) : v = e, n(e, "id", `${l}-panel`), n(e, "aria-labelledby", `${l}-trigger`), a(u, f(b, {
56
+ get when() {
57
+ return p();
58
+ },
59
+ get children() {
60
+ var r = A();
61
+ return a(r, () => i.children), r;
62
+ }
63
+ })), m((r) => {
64
+ var t = !s(), o = !s();
65
+ return t !== r.e && n(e, "aria-hidden", r.e = t), o !== r.t && (e.inert = r.t = o), r;
66
+ }, {
67
+ e: void 0,
68
+ t: void 0
69
+ }), e;
70
+ })()];
71
+ }
72
+ });
73
+ }
74
+ y(["click"]);
75
+ export {
76
+ B as SettingsDisclosure
77
+ };
@@ -2,46 +2,45 @@ function g() {
2
2
  const e = globalThis.matchMedia;
3
3
  return typeof e != "function" ? !1 : e.call(globalThis, "(prefers-reduced-motion: reduce)").matches;
4
4
  }
5
- function p(e, l = {}) {
5
+ function p(e, c = {}) {
6
6
  const u = globalThis.ResizeObserver;
7
7
  if (typeof u != "function") return () => {
8
8
  };
9
- const f = () => e.offsetHeight, d = () => typeof e.getAnimations == "function" && e.getAnimations().some((t) => t !== n && t.playState === "running");
10
- let a = f(), n = null, c = !1, i = null;
11
- const b = () => {
12
- n = null, e.style.willChange = "", !c && i && i.observe(e, { box: "border-box" });
13
- }, h = (t) => {
14
- const r = a;
15
- if (a = t, !Number.isFinite(r) || Math.abs(r - t) < 0.5 || g()) return;
9
+ const l = () => e.offsetHeight, d = () => typeof e.getAnimations == "function" && e.getAnimations().some((n) => n !== t && n.playState === "running");
10
+ let o = l(), t = null, s = !1, i = null;
11
+ const f = () => {
12
+ t = null, e.style.willChange = "", !s && i && i.observe(e, { box: "border-box" });
13
+ }, b = (n) => {
14
+ const a = o;
15
+ if (o = n, !Number.isFinite(a) || Math.abs(a - n) < 0.5 || g()) return;
16
16
  i?.unobserve(e);
17
- const o = e.animate(
18
- [{ height: `${r}px` }, { height: `${t}px` }],
17
+ const r = e.animate(
18
+ [{ height: `${a}px` }, { height: `${n}px` }],
19
19
  {
20
20
  duration: 220,
21
21
  easing: "cubic-bezier(0.22, 1, 0.36, 1)",
22
22
  fill: "none"
23
23
  }
24
24
  );
25
- n = o, e.style.willChange = "height", o.addEventListener("finish", () => {
26
- if (c) return;
27
- b();
28
- const s = f();
29
- Math.abs(s - a) >= 0.5 && h(s);
30
- }), o.oncancel = () => {
31
- c || b();
25
+ t = r, e.style.willChange = "height", r.addEventListener("finish", () => {
26
+ if (s) return;
27
+ f();
28
+ const h = l();
29
+ Math.abs(h - o) >= 0.5 && b(h);
30
+ }), r.oncancel = () => {
31
+ s || f();
32
32
  };
33
33
  };
34
- return i = new u((t) => {
35
- const r = t[t.length - 1];
36
- if (!r || n) return;
37
- const o = Array.isArray(r.borderBoxSize) ? r.borderBoxSize[0] : r.borderBoxSize, s = o ? o.blockSize : r.contentRect.height;
38
- if (l.isSettled && !l.isSettled() || d()) {
39
- a = s;
34
+ return i = new u((n) => {
35
+ if (!n[n.length - 1] || t) return;
36
+ const r = l();
37
+ if (c.isSettled && !c.isSettled() || d()) {
38
+ o = r;
40
39
  return;
41
40
  }
42
- h(s);
41
+ b(r);
43
42
  }), i.observe(e, { box: "border-box" }), () => {
44
- c = !0, i.disconnect(), n?.cancel(), n = null, e.style.willChange = "";
43
+ s = !0, i.disconnect(), t?.cancel(), t = null, e.style.willChange = "";
45
44
  };
46
45
  }
47
46
  export {
@@ -69,3 +69,4 @@ export { DatePicker, DateRangePicker, type DatePickerProps, type DateRangePicker
69
69
  export { parseCalendarDate, formatCalendarDate, addCalendarDays, addCalendarMonths, calendarDays, } from './calendarModel';
70
70
  export { RetainedPanel, type RetainedPanelProps } from './RetainedPanel';
71
71
  export { ThemePicker, type ThemePickerProps } from "./ThemePicker";
72
+ export { SettingsDisclosure, type SettingsDisclosureProps } from './SettingsDisclosure';