@floegence/floe-webapp-core 0.101.41 → 0.101.43

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,7 +1,7 @@
1
1
  import { use as O, insert as U, createComponent as D, effect as X, setAttribute as h, setStyleProperty as M, memo as W, className as _, template as F, delegateEvents as p } from "solid-js/web";
2
2
  import { createSignal as j, createMemo as tt, onMount as et, onCleanup as it, For as G, Show as J } from "solid-js";
3
3
  import { imageAnnotationMarkup as Q, validateImageAnnotation as Y, imagePointFromClient as nt } from "./imageAnnotation.js";
4
- var at = /* @__PURE__ */ F("<div data-floe-image-annotation style=width:100%;height:100%;overflow:auto;scrollbar-gutter:stable;overscroll-behavior:contain><div style=display:grid;place-items:center><svg xmlns=http://www.w3.org/2000/svg role=img style=display:block;user-select:none;flex:none><image></image><g data-annotation-target>"), rt = /* @__PURE__ */ F("<svg><g></svg>", !1, !0, !1), ot = /* @__PURE__ */ F("<svg><rect data-annotation-target fill=white stroke=#111827></svg>", !1, !0, !1);
4
+ var at = /* @__PURE__ */ F("<div data-floe-image-annotation style=width:100%;height:100%;overflow:auto;scrollbar-gutter:stable;overscroll-behavior:contain><div style=display:grid;place-items:center><svg xmlns=http://www.w3.org/2000/svg role=img style=display:block;user-select:none;flex:none><image></image><g data-annotation-target>"), rt = /* @__PURE__ */ F("<svg><g style=pointer-events:none></svg>", !1, !0, !1), ot = /* @__PURE__ */ F("<svg><rect data-annotation-target fill=white stroke=#111827></svg>", !1, !0, !1);
5
5
  function ct(e) {
6
6
  let v, u;
7
7
  const [L, V] = j({
@@ -1,7 +1,7 @@
1
1
  function g(i, e) {
2
2
  return ![i.width, i.height].every((r) => Number.isSafeInteger(r) && r > 0 && r <= 16384) || !e || ![e.x, e.y].every(Number.isFinite) || e.x < 0 || e.y < 0 || e.x > i.width || e.y > i.height ? !1 : e.kind === "point" ? !0 : e.kind === "rectangle" && [e.width, e.height].every((r) => Number.isFinite(r) && r > 0) && e.x + e.width <= i.width && e.y + e.height <= i.height;
3
3
  }
4
- function x(i, e, r, t = !1) {
4
+ function m(i, e, r, t = !1) {
5
5
  if (e.width <= 0 || e.height <= 0) return;
6
6
  const h = (r.x - e.left) * i.width / e.width, n = (r.y - e.top) * i.height / e.height;
7
7
  if (!(![h, n].every(Number.isFinite) || !t && (h < 0 || n < 0 || h > i.width || n > i.height)))
@@ -10,31 +10,31 @@ function x(i, e, r, t = !1) {
10
10
  function $(i, e, r = 1) {
11
11
  if (!Number.isSafeInteger(r) || r < 1 || r > 99) throw new Error("Invalid annotation marker");
12
12
  if (!g(i, e)) throw new Error("Invalid image annotation");
13
- const t = Math.max(1, Math.min(i.width, i.height) / 500), { x: h, y: n } = e, s = 9 * t, w = Math.max(s + t, Math.min(i.width - s - t, h + 17 * t)), o = Math.max(s + t, Math.min(i.height - s - t, n - 17 * t)), l = e.kind === "rectangle" ? `<rect x="${h}" y="${n}" width="${e.width}" height="${e.height}" fill="#f59e0b" fill-opacity=".08"/>` : `<path d="M${h - 6 * t},${n}h${12 * t}M${h},${n - 6 * t}v${12 * t}"/><circle cx="${h}" cy="${n}" r="${2 * t}" fill="#f59e0b"/>`;
14
- return `<g fill="none" stroke-linejoin="round"><g stroke="#111827" stroke-width="${4 * t}">${l}</g><g stroke="#fbbf24" stroke-width="${2 * t}">${l}<path d="M${h},${n}L${w},${o}"/></g><circle cx="${w}" cy="${o}" r="${s}" fill="#fbbf24" stroke="#111827" stroke-width="${t}"/><text x="${w}" y="${o}" dy=".35em" text-anchor="middle" fill="#111827" stroke="none" font-family="sans-serif" font-size="${12 * t}" font-weight="700">${r}</text></g>`;
13
+ const t = Math.max(1, Math.min(i.width, i.height) / 500), { x: h, y: n } = e, a = 9 * t, l = Math.max(a + t, Math.min(i.width - a - t, h + 17 * t)), s = Math.max(a + t, Math.min(i.height - a - t, n - 17 * t)), o = e.kind === "rectangle" ? `<rect x="${h}" y="${n}" width="${e.width}" height="${e.height}" fill="#f59e0b" fill-opacity=".08"/>` : `<path d="M${h - 6 * t},${n}h${12 * t}M${h},${n - 6 * t}v${12 * t}"/><circle cx="${h}" cy="${n}" r="${2 * t}" fill="#f59e0b"/>`;
14
+ return `<g fill="none" stroke-linejoin="round"><g stroke="#111827" stroke-width="${4 * t}">${o}</g><g stroke="#fbbf24" stroke-width="${2 * t}">${o}<path d="M${h},${n}L${l},${s}"/></g><circle data-annotation-marker="" pointer-events="all" cx="${l}" cy="${s}" r="${a}" fill="#fbbf24" stroke="#111827" stroke-width="${t}"/><text data-annotation-marker="" pointer-events="all" x="${l}" y="${s}" dy=".35em" text-anchor="middle" fill="#111827" stroke="none" font-family="sans-serif" font-size="${12 * t}" font-weight="700">${r}</text></g>`;
15
15
  }
16
- async function y(i, e) {
16
+ async function x(i, e) {
17
17
  const r = await createImageBitmap(i);
18
18
  let t;
19
19
  try {
20
20
  const { width: h, height: n } = r;
21
21
  if (h * n > 32e6) throw new Error("Image exceeds annotation pixel limit");
22
- const s = Array.isArray(e) ? e : [e];
23
- if (!s.length || s.length > 99) throw new Error("Invalid annotation count");
24
- const w = s.map((c, d) => $({ width: h, height: n }, c, d + 1)).join(""), o = document.createElement("canvas");
25
- o.width = h, o.height = n;
26
- const l = o.getContext("2d");
27
- if (!l) throw new Error("Image annotation is unavailable");
28
- l.drawImage(r, 0, 0), t = URL.createObjectURL(new Blob([`<svg xmlns="http://www.w3.org/2000/svg" width="${h}" height="${n}" viewBox="0 0 ${h} ${n}">${w}</svg>`], { type: "image/svg+xml" }));
29
- const a = new Image();
30
- return a.src = t, await a.decode(), l.drawImage(a, 0, 0), await new Promise((c, d) => o.toBlob((f) => f ? c(f) : d(new Error("Image annotation is unavailable")), "image/png"));
22
+ const a = Array.isArray(e) ? e : [e];
23
+ if (!a.length || a.length > 99) throw new Error("Invalid annotation count");
24
+ const l = a.map((d, c) => $({ width: h, height: n }, d, c + 1)).join(""), s = document.createElement("canvas");
25
+ s.width = h, s.height = n;
26
+ const o = s.getContext("2d");
27
+ if (!o) throw new Error("Image annotation is unavailable");
28
+ o.drawImage(r, 0, 0), t = URL.createObjectURL(new Blob([`<svg xmlns="http://www.w3.org/2000/svg" width="${h}" height="${n}" viewBox="0 0 ${h} ${n}">${l}</svg>`], { type: "image/svg+xml" }));
29
+ const w = new Image();
30
+ return w.src = t, await w.decode(), o.drawImage(w, 0, 0), await new Promise((d, c) => s.toBlob((f) => f ? d(f) : c(new Error("Image annotation is unavailable")), "image/png"));
31
31
  } finally {
32
32
  r.close(), t && URL.revokeObjectURL(t);
33
33
  }
34
34
  }
35
35
  export {
36
- y as annotateImage,
36
+ x as annotateImage,
37
37
  $ as imageAnnotationMarkup,
38
- x as imagePointFromClient,
38
+ m as imagePointFromClient,
39
39
  g as validateImageAnnotation
40
40
  };
@@ -1,4 +1,4 @@
1
- import { setAttribute as d, insert as c, createComponent as u, Portal as X, use as F, spread as Y, mergeProps as Z, effect as z, className as _, template as L, memo as G, delegateEvents as ie } from "solid-js/web";
1
+ import { setAttribute as d, insert as f, createComponent as u, Portal as X, use as F, spread as Y, mergeProps as Z, effect as N, className as K, template as L, memo as G, delegateEvents as ie } from "solid-js/web";
2
2
  import { createControllableValue as le } from "./controllable.js";
3
3
  import { useFloeLocale as ue } from "../../context/LocaleContext.js";
4
4
  import { createSignal as q, createMemo as de, createEffect as ee, onCleanup as se, Show as b, Index as te } from "solid-js";
@@ -9,24 +9,24 @@ import { Check as me, ChevronRight as ge } from "../icons/index.js";
9
9
  import { focusMenuItem as T, calculateMenuPosition as ve, MENU_ITEM_SELECTOR as he, moveMenuFocus as Q, calculateSubmenuPosition as be } from "./menuUtils.js";
10
10
  import { LOCAL_INTERACTION_SURFACE_ATTR as ne } from "./localInteractionSurface.js";
11
11
  import { createFloatingPresence as re } from "./floatingPresence.js";
12
- import { useOverlayMask as we } from "../../hooks/useOverlayMask.js";
13
- import { resolveSurfacePortalHost as ye, projectSurfacePortalPosition as Se, resolveSurfacePortalBoundaryRect as xe, isSurfacePortalMode as ke, resolveSurfacePortalMount as Me } from "./dialogSurfaceScope.js";
14
- var U = /* @__PURE__ */ L("<div>"), Ce = /* @__PURE__ */ L("<div><div role=button aria-haspopup=menu data-floe-dropdown-trigger>"), oe = /* @__PURE__ */ L('<div class="my-1 h-px bg-border"role=separator>'), Pe = /* @__PURE__ */ L('<button type=button data-floe-interactive=item role=menuitem><span class="w-3.5 h-3.5 flex items-center justify-center"></span><span class="flex-1 text-left">'), Ae = /* @__PURE__ */ L("<div class=relative>"), Le = /* @__PURE__ */ L('<span class="w-3.5 h-3.5 flex items-center justify-center">');
15
- let Re = 0, Ee = 0;
16
- function Oe(e, w) {
12
+ import { useOverlayMask as ye } from "../../hooks/useOverlayMask.js";
13
+ import { resolveSurfacePortalHost as we, projectSurfacePortalPosition as Se, resolveSurfacePortalScale as xe, resolveSurfacePortalBoundaryRect as ke, isSurfacePortalMode as Me, resolveSurfacePortalMount as Pe } from "./dialogSurfaceScope.js";
14
+ var U = /* @__PURE__ */ L("<div>"), Ce = /* @__PURE__ */ L("<div><div role=button aria-haspopup=menu data-floe-dropdown-trigger>"), oe = /* @__PURE__ */ L('<div class="my-1 h-px bg-border"role=separator>'), Ae = /* @__PURE__ */ L('<button type=button data-floe-interactive=item role=menuitem><span class="w-3.5 h-3.5 flex items-center justify-center"></span><span class="flex-1 text-left">'), Le = /* @__PURE__ */ L("<div class=relative>"), Ee = /* @__PURE__ */ L('<span class="w-3.5 h-3.5 flex items-center justify-center">');
15
+ let Oe = 0, Re = 0;
16
+ function $e(e, y) {
17
17
  switch (e) {
18
18
  case "Enter":
19
19
  case " ":
20
- return w.open ? {
20
+ return y.open ? {
21
21
  nextOpen: !1
22
22
  } : {
23
23
  nextOpen: !0,
24
- focusMode: w.hasSelection ? "selected" : "first"
24
+ focusMode: y.hasSelection ? "selected" : "first"
25
25
  };
26
26
  case "ArrowDown":
27
27
  return {
28
28
  nextOpen: !0,
29
- focusMode: w.hasSelection ? "selected" : "first"
29
+ focusMode: y.hasSelection ? "selected" : "first"
30
30
  };
31
31
  case "ArrowUp":
32
32
  return {
@@ -37,40 +37,47 @@ function Oe(e, w) {
37
37
  return null;
38
38
  }
39
39
  }
40
- function ze(e) {
41
- const w = ue(), [g, i] = le({
40
+ function Ue(e) {
41
+ const y = ue(), [g, i] = le({
42
42
  value: () => e.open,
43
43
  defaultValue: e.defaultOpen ?? !1,
44
44
  onChange: (n) => e.onOpenChange?.(n)
45
- }), k = re({
45
+ }), M = re({
46
46
  open: g,
47
- element: () => f
48
- }), [M, R] = q({
47
+ element: () => m
48
+ }), [P, E] = q({
49
49
  x: -9999,
50
50
  y: -9999
51
- }), [B, N] = q("bottom");
52
- let v, f;
53
- const h = `floe-dropdown-${Re += 1}`, y = `${h}-menu`, S = () => typeof e.items == "function" ? e.items() : e.items, C = de(() => k.mounted() ? ye({
51
+ }), [B, _] = q("bottom");
52
+ let v, m;
53
+ const h = `floe-dropdown-${Oe += 1}`, w = `${h}-menu`, S = () => typeof e.items == "function" ? e.items() : e.items, x = de(() => M.mounted() ? we({
54
54
  owner: v
55
55
  }) : {
56
56
  host: null,
57
57
  boundaryHost: null,
58
58
  mountHost: null,
59
59
  mode: "global"
60
- }), m = {
61
- mount: () => Me(C()),
62
- isSurfaceMode: () => ke(C()),
63
- boundaryRect: () => xe(C()),
64
- projectPosition: (n) => Se(n, C())
65
- }, p = () => {
60
+ }), c = {
61
+ mount: () => Pe(x()),
62
+ isSurfaceMode: () => Me(x()),
63
+ boundaryRect: () => ke(x()),
64
+ measureSize: (n) => {
65
+ const t = xe(x());
66
+ return {
67
+ width: n.offsetWidth * t.x,
68
+ height: n.offsetHeight * t.y
69
+ };
70
+ },
71
+ projectPosition: (n) => Se(n, x())
72
+ }, j = () => {
66
73
  i(!1), requestAnimationFrame(() => v?.focus());
67
74
  };
68
- we({
69
- open: k.mounted,
70
- root: () => f,
75
+ ye({
76
+ open: M.mounted,
77
+ root: () => m,
71
78
  containsTarget: (n) => !!J(n, `[data-floe-dropdown="${h}"]`),
72
- onClose: p,
73
- onEscapeOutside: p,
79
+ onClose: j,
80
+ onEscapeOutside: j,
74
81
  lockBodyScroll: !1,
75
82
  trapFocus: !1,
76
83
  autoFocus: !1,
@@ -79,14 +86,14 @@ function ze(e) {
79
86
  closeOnEscape: "inside",
80
87
  escapeKeyPhase: "bubble"
81
88
  });
82
- const P = () => {
83
- if (!v || !f) return;
84
- const n = v.getBoundingClientRect(), t = f.getBoundingClientRect(), o = ve(n, t, w.direction === "rtl" ? e.align === "end" ? "start" : e.align === "center" ? "center" : "end" : e.align ?? "start", m.boundaryRect());
85
- N(o.y < n.top ? "top" : "bottom"), R(o);
89
+ const C = () => {
90
+ if (!v || !m) return;
91
+ const n = v.getBoundingClientRect(), t = c.measureSize(m), o = ve(n, t, y.direction === "rtl" ? e.align === "end" ? "start" : e.align === "center" ? "center" : "end" : e.align ?? "start", c.boundaryRect());
92
+ _(o.y < n.top ? "top" : "bottom"), E(o);
86
93
  };
87
94
  ee(() => {
88
- if (!k.mounted()) {
89
- R({
95
+ if (!M.mounted()) {
96
+ E({
90
97
  x: -9999,
91
98
  y: -9999
92
99
  });
@@ -97,23 +104,23 @@ function ze(e) {
97
104
  J(ce(t), `[data-floe-dropdown="${h}"]`) || i(!1);
98
105
  };
99
106
  document.addEventListener("pointerdown", n, !0), requestAnimationFrame(() => {
100
- P(), T(f, e.value ? "selected" : "first");
107
+ C(), T(m, e.value ? "selected" : "first");
101
108
  }), se(() => {
102
109
  document.removeEventListener("pointerdown", n, !0);
103
110
  });
104
111
  });
105
- const j = (n) => {
112
+ const p = (n) => {
106
113
  const t = e.onSelect;
107
114
  n.keepOpen || (i(!1), v?.focus({
108
115
  preventScroll: !0
109
116
  })), fe(() => t(n.id));
110
- }, H = (n, t = "first") => {
117
+ }, z = (n, t = "first") => {
111
118
  e.disabled || (i(n), requestAnimationFrame(() => {
112
- P(), T(f, t);
119
+ C(), T(m, t);
113
120
  }));
114
- }, K = (n) => {
121
+ }, H = (n) => {
115
122
  if (e.disabled) return;
116
- const t = Oe(n.key, {
123
+ const t = $e(n.key, {
117
124
  open: g(),
118
125
  hasSelection: !!e.value
119
126
  });
@@ -122,7 +129,7 @@ function ze(e) {
122
129
  i(!1);
123
130
  return;
124
131
  }
125
- H(!0, t.focusMode ?? "first");
132
+ z(!0, t.focusMode ?? "first");
126
133
  }
127
134
  }, l = (n) => {
128
135
  const t = n.target, o = t?.closest('[role="menu"]'), r = t?.closest(he);
@@ -148,58 +155,58 @@ function ze(e) {
148
155
  };
149
156
  return (() => {
150
157
  var n = Ce(), t = n.firstChild;
151
- d(n, "data-floe-dropdown", h), t.$$keydown = K, t.$$click = () => {
158
+ d(n, "data-floe-dropdown", h), t.$$keydown = H, t.$$click = () => {
152
159
  if (!e.disabled) {
153
160
  if (g()) {
154
161
  i(!1);
155
162
  return;
156
163
  }
157
- H(!0, e.value ? "selected" : "first");
164
+ z(!0, e.value ? "selected" : "first");
158
165
  }
159
166
  };
160
167
  var o = v;
161
- return typeof o == "function" ? F(o, t) : v = t, d(t, "aria-controls", y), c(t, () => e.trigger), c(n, u(b, {
168
+ return typeof o == "function" ? F(o, t) : v = t, d(t, "aria-controls", w), f(t, () => e.trigger), f(n, u(b, {
162
169
  get when() {
163
- return k.mounted();
170
+ return M.mounted();
164
171
  },
165
172
  get children() {
166
173
  return u(X, {
167
174
  get mount() {
168
- return m.mount();
175
+ return c.mount();
169
176
  },
170
177
  get children() {
171
178
  var r = U();
172
179
  return F((s) => {
173
- f = s, queueMicrotask(() => {
174
- s.isConnected && P();
180
+ m = s, queueMicrotask(() => {
181
+ s.isConnected && C();
175
182
  });
176
183
  }, r), d(r, "data-floe-dropdown", h), Y(r, Z({
177
184
  get class() {
178
- return A(m.isSurfaceMode() ? "absolute z-20 min-w-36" : "fixed z-50 min-w-36", "bg-popover text-popover-foreground p-1", "rounded-panel border border-[var(--floe-line)]", "shadow-[var(--floe-elevation-float)]", "floe-floating-presence floe-floating-menu");
185
+ return A(c.isSurfaceMode() ? "absolute z-20 min-w-36" : "fixed z-50 min-w-36", "bg-popover text-popover-foreground p-1", "rounded-panel border border-[var(--floe-line)]", "shadow-[var(--floe-elevation-float)]", "floe-floating-presence floe-floating-menu");
179
186
  },
180
187
  get "data-floating-presence"() {
181
- return k.state();
188
+ return M.state();
182
189
  },
183
190
  get "data-floating-side"() {
184
191
  return B();
185
192
  },
186
193
  get "aria-hidden"() {
187
- return k.exiting() ? "true" : void 0;
194
+ return M.exiting() ? "true" : void 0;
188
195
  }
189
196
  }, () => ({
190
- [ne]: m.isSurfaceMode() ? "true" : void 0
197
+ [ne]: c.isSurfaceMode() ? "true" : void 0
191
198
  }), {
192
199
  get style() {
193
200
  return {
194
- left: `${m.projectPosition(M()).x}px`,
195
- top: `${m.projectPosition(M()).y}px`
201
+ left: `${c.projectPosition(P()).x}px`,
202
+ top: `${c.projectPosition(P()).y}px`
196
203
  };
197
204
  },
198
205
  role: "menu",
199
206
  "data-floe-surface": "floating",
200
- id: y,
207
+ id: w,
201
208
  onKeyDown: l
202
- }), !1, !0), c(r, u(te, {
209
+ }), !1, !0), f(r, u(te, {
203
210
  get each() {
204
211
  return S();
205
212
  },
@@ -218,10 +225,10 @@ function ze(e) {
218
225
  get selected() {
219
226
  return e.value === s().id;
220
227
  },
221
- onSelect: j,
228
+ onSelect: p,
222
229
  onCloseMenu: () => i(!1),
223
230
  dropdownId: h,
224
- portalLayout: m
231
+ portalLayout: c
225
232
  });
226
233
  }
227
234
  })
@@ -229,9 +236,9 @@ function ze(e) {
229
236
  }
230
237
  });
231
238
  }
232
- }), null), z((r) => {
233
- var s = A("relative inline-block", e.class), a = A("cursor-pointer", e.triggerClass, e.disabled && "pointer-events-none opacity-50"), x = e.disabled ? -1 : 0, E = g(), O = e.triggerAriaLabel, $ = e.triggerAriaLabelledBy, D = e.triggerAriaDescribedBy, I = e.disabled ? "true" : void 0, V = e.triggerInputSurface ? "true" : void 0, W = e.triggerInputSurface ? "inset" : void 0;
234
- return s !== r.e && _(n, r.e = s), a !== r.t && _(t, r.t = a), x !== r.a && d(t, "tabindex", r.a = x), E !== r.o && d(t, "aria-expanded", r.o = E), O !== r.i && d(t, "aria-label", r.i = O), $ !== r.n && d(t, "aria-labelledby", r.n = $), D !== r.s && d(t, "aria-describedby", r.s = D), I !== r.h && d(t, "aria-disabled", r.h = I), V !== r.r && d(t, "data-floe-input-surface", r.r = V), W !== r.d && d(t, "data-floe-surface", r.d = W), r;
239
+ }), null), N((r) => {
240
+ var s = A("relative inline-block", e.class), a = A("cursor-pointer", e.triggerClass, e.disabled && "pointer-events-none opacity-50"), k = e.disabled ? -1 : 0, O = g(), R = e.triggerAriaLabel, $ = e.triggerAriaLabelledBy, D = e.triggerAriaDescribedBy, I = e.disabled ? "true" : void 0, V = e.triggerInputSurface ? "true" : void 0, W = e.triggerInputSurface ? "inset" : void 0;
241
+ return s !== r.e && K(n, r.e = s), a !== r.t && K(t, r.t = a), k !== r.a && d(t, "tabindex", r.a = k), O !== r.o && d(t, "aria-expanded", r.o = O), R !== r.i && d(t, "aria-label", r.i = R), $ !== r.n && d(t, "aria-labelledby", r.n = $), D !== r.s && d(t, "aria-describedby", r.s = D), I !== r.h && d(t, "aria-disabled", r.h = I), V !== r.r && d(t, "data-floe-input-surface", r.r = V), W !== r.d && d(t, "data-floe-surface", r.d = W), r;
235
242
  }, {
236
243
  e: void 0,
237
244
  t: void 0,
@@ -247,77 +254,77 @@ function ze(e) {
247
254
  })();
248
255
  }
249
256
  function ae(e) {
250
- const [w, g] = q(!1), i = () => e.item.children && e.item.children.length > 0, M = re({
251
- open: () => !!(w() && i()),
252
- element: () => y
253
- }), [R, B] = q({
257
+ const [y, g] = q(!1), i = () => e.item.children && e.item.children.length > 0, P = re({
258
+ open: () => !!(y() && i()),
259
+ element: () => w
260
+ }), [E, B] = q({
254
261
  x: -9999,
255
262
  y: -9999
256
- }), [N, v] = q("right");
257
- let f, h, y, S;
258
- const C = `floe-dropdown-item-${Ee += 1}`;
263
+ }), [_, v] = q("right");
264
+ let m, h, w, S;
265
+ const x = `floe-dropdown-item-${Re += 1}`;
259
266
  ee(() => {
260
- M.mounted() || B({
267
+ P.mounted() || B({
261
268
  x: -9999,
262
269
  y: -9999
263
270
  });
264
271
  });
265
- const m = () => {
266
- if (!f || !y) return;
267
- const l = f.getBoundingClientRect(), n = y.getBoundingClientRect(), t = be(l, n, e.portalLayout.boundaryRect());
272
+ const c = () => {
273
+ if (!m || !w) return;
274
+ const l = m.getBoundingClientRect(), n = e.portalLayout.measureSize(w), t = be(l, n, e.portalLayout.boundaryRect());
268
275
  v(t.x < l.left ? "left" : "right"), B(t);
269
- }, p = () => {
276
+ }, j = () => {
270
277
  i() && (clearTimeout(S), S = setTimeout(() => {
271
- g(!0), requestAnimationFrame(m);
278
+ g(!0), requestAnimationFrame(c);
272
279
  }, 100));
273
- }, P = () => {
280
+ }, C = () => {
274
281
  i() && (clearTimeout(S), S = void 0, !e.item.keepOpen && (S = setTimeout(() => {
275
282
  g(!1);
276
283
  }, 150)));
277
- }, j = (l) => {
284
+ }, p = (l) => {
278
285
  if (!e.item.disabled) {
279
286
  if (e.item.content && e.item.keepOpen) {
280
287
  l.stopPropagation();
281
288
  return;
282
289
  }
283
- i() ? (g((n) => !n), requestAnimationFrame(m)) : e.item.content || e.onSelect(e.item);
290
+ i() ? (g((n) => !n), requestAnimationFrame(c)) : e.item.content || e.onSelect(e.item);
284
291
  }
285
- }, H = (l = "first") => {
292
+ }, z = (l = "first") => {
286
293
  i() && (g(!0), requestAnimationFrame(() => {
287
- m(), T(y, l);
294
+ c(), T(w, l);
288
295
  }));
289
- }, K = () => {
296
+ }, H = () => {
290
297
  g(!1), requestAnimationFrame(() => h?.focus());
291
298
  };
292
299
  return (() => {
293
- var l = Ae();
294
- l.addEventListener("mouseleave", P), l.addEventListener("mouseenter", p);
295
- var n = f;
296
- return typeof n == "function" ? F(n, l) : f = l, c(l, u(b, {
300
+ var l = Le();
301
+ l.addEventListener("mouseleave", C), l.addEventListener("mouseenter", j);
302
+ var n = m;
303
+ return typeof n == "function" ? F(n, l) : m = l, f(l, u(b, {
297
304
  get when() {
298
305
  return e.item.content;
299
306
  },
300
307
  get children() {
301
308
  var t = U();
302
- return t.$$click = j, c(t, e.item.content), z((o) => {
309
+ return t.$$click = p, f(t, e.item.content), N((o) => {
303
310
  var r = A("w-full px-2 py-1.5", e.item.tone === "danger" && "text-error", e.item.disabled && "opacity-50 pointer-events-none"), s = e.item.tone ?? "default";
304
- return r !== o.e && _(t, o.e = r), s !== o.t && d(t, "data-tone", o.t = s), o;
311
+ return r !== o.e && K(t, o.e = r), s !== o.t && d(t, "data-tone", o.t = s), o;
305
312
  }, {
306
313
  e: void 0,
307
314
  t: void 0
308
315
  }), t;
309
316
  }
310
- }), null), c(l, u(b, {
317
+ }), null), f(l, u(b, {
311
318
  get when() {
312
319
  return !e.item.content;
313
320
  },
314
321
  get children() {
315
- var t = Pe(), o = t.firstChild, r = o.nextSibling;
322
+ var t = Ae(), o = t.firstChild, r = o.nextSibling;
316
323
  t.$$keydown = (a) => {
317
- e.item.disabled || i() && ((a.key === "ArrowRight" || a.key === "Enter" || a.key === " ") && (a.preventDefault(), H("first")), a.key === "ArrowLeft" && (a.preventDefault(), K()));
318
- }, t.$$click = j;
324
+ e.item.disabled || i() && ((a.key === "ArrowRight" || a.key === "Enter" || a.key === " ") && (a.preventDefault(), z("first")), a.key === "ArrowLeft" && (a.preventDefault(), H()));
325
+ }, t.$$click = p;
319
326
  var s = h;
320
- return typeof s == "function" ? F(s, t) : h = t, d(t, "id", C), c(o, u(b, {
327
+ return typeof s == "function" ? F(s, t) : h = t, d(t, "id", x), f(o, u(b, {
321
328
  get when() {
322
329
  return G(() => !!e.selected)() && !i();
323
330
  },
@@ -326,16 +333,16 @@ function ae(e) {
326
333
  class: "w-3 h-3"
327
334
  });
328
335
  }
329
- })), c(t, u(b, {
336
+ })), f(t, u(b, {
330
337
  get when() {
331
338
  return e.item.icon;
332
339
  },
333
340
  keyed: !0,
334
341
  children: (a) => (() => {
335
- var x = Le();
336
- return c(x, a), x;
342
+ var k = Ee();
343
+ return f(k, a), k;
337
344
  })()
338
- }), r), c(r, () => e.item.label), c(t, u(b, {
345
+ }), r), f(r, () => e.item.label), f(t, u(b, {
339
346
  get when() {
340
347
  return i();
341
348
  },
@@ -344,9 +351,9 @@ function ae(e) {
344
351
  class: "w-3 h-3 text-[var(--floe-ink-quiet)]"
345
352
  });
346
353
  }
347
- }), null), z((a) => {
348
- var x = A("w-full flex items-center gap-2 px-2", "min-h-[var(--floe-row-height)] rounded-sm", "text-[length:var(--floe-type-control)] leading-[var(--floe-line-control)]", "focus:outline-none", e.item.tone === "danger" ? "text-error" : "text-[var(--floe-ink-soft)]", e.item.disabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer"), E = e.item.disabled, O = i() ? "menu" : void 0, $ = i() ? w() : void 0, D = e.selected && !i() ? "true" : void 0, I = e.item.tone ?? "default";
349
- return x !== a.e && _(t, a.e = x), E !== a.t && (t.disabled = a.t = E), O !== a.a && d(t, "aria-haspopup", a.a = O), $ !== a.o && d(t, "aria-expanded", a.o = $), D !== a.i && d(t, "data-floe-selected", a.i = D), I !== a.n && d(t, "data-tone", a.n = I), a;
354
+ }), null), N((a) => {
355
+ var k = A("w-full flex items-center gap-2 px-2", "min-h-[var(--floe-row-height)] rounded-sm", "text-[length:var(--floe-type-control)] leading-[var(--floe-line-control)]", "focus:outline-none", e.item.tone === "danger" ? "text-error" : "text-[var(--floe-ink-soft)]", e.item.disabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer"), O = e.item.disabled, R = i() ? "menu" : void 0, $ = i() ? y() : void 0, D = e.selected && !i() ? "true" : void 0, I = e.item.tone ?? "default";
356
+ return k !== a.e && K(t, a.e = k), O !== a.t && (t.disabled = a.t = O), R !== a.a && d(t, "aria-haspopup", a.a = R), $ !== a.o && d(t, "aria-expanded", a.o = $), D !== a.i && d(t, "data-floe-selected", a.i = D), I !== a.n && d(t, "data-tone", a.n = I), a;
350
357
  }, {
351
358
  e: void 0,
352
359
  t: void 0,
@@ -356,9 +363,9 @@ function ae(e) {
356
363
  n: void 0
357
364
  }), t;
358
365
  }
359
- }), null), c(l, u(b, {
366
+ }), null), f(l, u(b, {
360
367
  get when() {
361
- return G(() => !!M.mounted())() && i();
368
+ return G(() => !!P.mounted())() && i();
362
369
  },
363
370
  get children() {
364
371
  return u(X, {
@@ -368,8 +375,8 @@ function ae(e) {
368
375
  get children() {
369
376
  var t = U();
370
377
  return F((o) => {
371
- y = o, queueMicrotask(() => {
372
- o.isConnected && m();
378
+ w = o, queueMicrotask(() => {
379
+ o.isConnected && c();
373
380
  });
374
381
  }, t), Y(t, Z({
375
382
  get class() {
@@ -379,34 +386,34 @@ function ae(e) {
379
386
  return e.dropdownId;
380
387
  },
381
388
  get "data-floating-presence"() {
382
- return M.state();
389
+ return P.state();
383
390
  },
384
391
  get "data-floating-side"() {
385
- return N();
392
+ return _();
386
393
  },
387
394
  get "aria-hidden"() {
388
- return M.exiting() ? "true" : void 0;
395
+ return P.exiting() ? "true" : void 0;
389
396
  }
390
397
  }, () => ({
391
398
  [ne]: e.portalLayout.isSurfaceMode() ? "true" : void 0
392
399
  }), {
393
400
  get style() {
394
401
  return {
395
- left: `${e.portalLayout.projectPosition(R()).x}px`,
396
- top: `${e.portalLayout.projectPosition(R()).y}px`
402
+ left: `${e.portalLayout.projectPosition(E()).x}px`,
403
+ top: `${e.portalLayout.projectPosition(E()).y}px`
397
404
  };
398
405
  },
399
406
  role: "menu",
400
407
  "data-floe-surface": "floating",
401
- "aria-labelledby": C,
408
+ "aria-labelledby": x,
402
409
  onMouseEnter: () => {
403
410
  clearTimeout(S);
404
411
  },
405
- onMouseLeave: P,
412
+ onMouseLeave: C,
406
413
  onKeyDown: (o) => {
407
- o.key !== "ArrowLeft" && o.key !== "Escape" || (o.preventDefault(), o.stopPropagation(), K());
414
+ o.key !== "ArrowLeft" && o.key !== "Escape" || (o.preventDefault(), o.stopPropagation(), H());
408
415
  }
409
- }), !1, !0), c(t, u(te, {
416
+ }), !1, !0), f(t, u(te, {
410
417
  get each() {
411
418
  return e.item.children;
412
419
  },
@@ -447,6 +454,6 @@ function ae(e) {
447
454
  }
448
455
  ie(["click", "keydown"]);
449
456
  export {
450
- ze as Dropdown,
451
- Oe as resolveDropdownTriggerKeyAction
457
+ Ue as Dropdown,
458
+ $e as resolveDropdownTriggerKeyAction
452
459
  };
@@ -29,11 +29,11 @@ export declare function clampMenuPosition(anchor: Readonly<{
29
29
  x: number;
30
30
  y: number;
31
31
  };
32
- export declare function calculateMenuPosition(triggerRect: DOMRect, menuRect: DOMRect, align: 'start' | 'center' | 'end', boundaryRect?: MenuBoundaryRect): {
32
+ export declare function calculateMenuPosition(triggerRect: DOMRect, menuRect: Pick<DOMRect, 'width' | 'height'>, align: 'start' | 'center' | 'end', boundaryRect?: MenuBoundaryRect): {
33
33
  x: number;
34
34
  y: number;
35
35
  };
36
- export declare function calculateSubmenuPosition(parentRect: DOMRect, submenuRect: DOMRect, boundaryRect?: MenuBoundaryRect): {
36
+ export declare function calculateSubmenuPosition(parentRect: DOMRect, submenuRect: Pick<DOMRect, 'width' | 'height'>, boundaryRect?: MenuBoundaryRect): {
37
37
  x: number;
38
38
  y: number;
39
39
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-core",
3
- "version": "0.101.41",
3
+ "version": "0.101.43",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",