@floegence/floe-webapp-core 0.14.1 → 0.14.2

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.
Files changed (2) hide show
  1. package/dist/index24.js +142 -135
  2. package/package.json +1 -1
package/dist/index24.js CHANGED
@@ -1,278 +1,285 @@
1
- import { delegateEvents as j, insert as f, createComponent as l, Portal as B, effect as _, className as E, setStyleProperty as p, template as S, memo as T, use as L } from "solid-js/web";
2
- import { createSignal as O, createEffect as q, onCleanup as D, Show as $, For as A } from "solid-js";
3
- import { cn as M } from "./index110.js";
4
- import { deferNonBlocking as I } from "./index111.js";
5
- import { ChevronDown as N, Check as z, ChevronRight as G } from "./index40.js";
6
- var W = /* @__PURE__ */ S("<div role=menu>"), V = /* @__PURE__ */ S("<div><div class=cursor-pointer>"), F = /* @__PURE__ */ S('<div class="my-1 h-px bg-border"role=separator>'), J = /* @__PURE__ */ S("<div>"), K = /* @__PURE__ */ S('<button type=button role=menuitem><span class="w-3.5 h-3.5 flex items-center justify-center"></span><span class="flex-1 text-left">'), Q = /* @__PURE__ */ S("<div class=relative>"), U = /* @__PURE__ */ S('<span class="w-3.5 h-3.5 flex items-center justify-center">'), X = /* @__PURE__ */ S("<button type=button><span>");
7
- const m = 8;
8
- function Y(e, i, u) {
9
- const o = window.innerWidth, a = window.innerHeight;
10
- let t;
11
- switch (u) {
1
+ import { delegateEvents as j, setAttribute as I, insert as m, createComponent as d, Portal as B, effect as E, className as S, setStyleProperty as _, template as C, memo as A, use as L } from "solid-js/web";
2
+ import { createSignal as O, createEffect as D, onCleanup as N, Show as y, For as W } from "solid-js";
3
+ import { cn as p } from "./index110.js";
4
+ import { deferNonBlocking as z } from "./index111.js";
5
+ import { ChevronDown as G, Check as V, ChevronRight as J } from "./index40.js";
6
+ var q = /* @__PURE__ */ C("<div role=menu>"), K = /* @__PURE__ */ C("<div><div class=cursor-pointer>"), F = /* @__PURE__ */ C('<div class="my-1 h-px bg-border"role=separator>'), Q = /* @__PURE__ */ C("<div>"), U = /* @__PURE__ */ C('<button type=button role=menuitem><span class="w-3.5 h-3.5 flex items-center justify-center"></span><span class="flex-1 text-left">'), X = /* @__PURE__ */ C("<div class=relative>"), Y = /* @__PURE__ */ C('<span class="w-3.5 h-3.5 flex items-center justify-center">'), Z = /* @__PURE__ */ C("<button type=button><span>");
7
+ const h = 8;
8
+ let R = 0;
9
+ function ee(e, r, c) {
10
+ const i = window.innerWidth, a = window.innerHeight;
11
+ let n;
12
+ switch (c) {
12
13
  case "center":
13
- t = e.left + e.width / 2 - i.width / 2;
14
+ n = e.left + e.width / 2 - r.width / 2;
14
15
  break;
15
16
  case "end":
16
- t = e.right - i.width;
17
+ n = e.right - r.width;
17
18
  break;
18
19
  default:
19
- t = e.left;
20
+ n = e.left;
20
21
  }
21
- let r = e.bottom + 4;
22
- if (t + i.width > o - m && (t = o - i.width - m), t = Math.max(m, t), r + i.height > a - m) {
23
- const v = e.top - m, g = a - e.bottom - m;
24
- v > g && v >= i.height ? r = e.top - i.height - 4 : r = a - i.height - m;
22
+ let l = e.bottom + 4;
23
+ if (n + r.width > i - h && (n = i - r.width - h), n = Math.max(h, n), l + r.height > a - h) {
24
+ const s = e.top - h, g = a - e.bottom - h;
25
+ s > g && s >= r.height ? l = e.top - r.height - 4 : l = a - r.height - h;
25
26
  }
26
- return r = Math.max(m, r), {
27
- x: t,
28
- y: r
27
+ return l = Math.max(h, l), {
28
+ x: n,
29
+ y: l
29
30
  };
30
31
  }
31
- function Z(e, i) {
32
- const u = window.innerWidth, o = window.innerHeight;
33
- let a = e.right, t = e.top;
34
- if (a + i.width > u - m) {
35
- const r = e.left - i.width;
36
- r >= m ? a = r : a = u - i.width - m;
32
+ function te(e, r) {
33
+ const c = window.innerWidth, i = window.innerHeight;
34
+ let a = e.right, n = e.top;
35
+ if (a + r.width > c - h) {
36
+ const l = e.left - r.width;
37
+ l >= h ? a = l : a = c - r.width - h;
37
38
  }
38
- return t + i.height > o - m && (t = o - i.height - m), a = Math.max(m, a), t = Math.max(m, t), {
39
+ return n + r.height > i - h && (n = i - r.height - h), a = Math.max(h, a), n = Math.max(h, n), {
39
40
  x: a,
40
- y: t
41
+ y: n
41
42
  };
42
43
  }
43
- function R(e) {
44
- const [i, u] = O(!1), [o, a] = O({
44
+ function ne(e) {
45
+ const [r, c] = O(!1), [i, a] = O({
45
46
  x: -9999,
46
47
  y: -9999
47
48
  });
48
- let t, r;
49
- const v = () => {
50
- if (!t || !r) return;
51
- const h = t.getBoundingClientRect(), w = r.getBoundingClientRect(), b = Y(h, w, e.align ?? "start");
49
+ let n, l;
50
+ const s = `floe-dropdown-${R += 1}`, g = () => {
51
+ if (!n || !l) return;
52
+ const f = n.getBoundingClientRect(), v = l.getBoundingClientRect(), b = ee(f, v, e.align ?? "start");
52
53
  a(b);
53
54
  };
54
- q(() => {
55
- if (!i()) {
55
+ D(() => {
56
+ if (!r()) {
56
57
  a({
57
58
  x: -9999,
58
59
  y: -9999
59
60
  });
60
61
  return;
61
62
  }
62
- const h = (b) => {
63
- t && !t.contains(b.target) && r && !r.contains(b.target) && u(!1);
64
- }, w = (b) => {
65
- b.key === "Escape" && u(!1);
63
+ const f = (b) => {
64
+ const o = b.target;
65
+ o && typeof o.closest == "function" && o.closest(`[data-floe-dropdown="${s}"]`) || c(!1);
66
+ }, v = (b) => {
67
+ b.key === "Escape" && c(!1);
66
68
  };
67
- document.addEventListener("mousedown", h), document.addEventListener("keydown", w), requestAnimationFrame(v), D(() => {
68
- document.removeEventListener("mousedown", h), document.removeEventListener("keydown", w);
69
+ document.addEventListener("mousedown", f), document.addEventListener("keydown", v), requestAnimationFrame(g), N(() => {
70
+ document.removeEventListener("mousedown", f), document.removeEventListener("keydown", v);
69
71
  });
70
72
  });
71
- const g = (h) => {
72
- const w = e.onSelect;
73
- u(!1), I(() => w(h));
73
+ const P = (f) => {
74
+ const v = e.onSelect;
75
+ f.keepOpen || c(!1), z(() => v(f.id));
74
76
  };
75
77
  return (() => {
76
- var h = V(), w = h.firstChild;
77
- w.$$click = () => u((x) => !x);
78
- var b = t;
79
- return typeof b == "function" ? L(b, w) : t = w, f(w, () => e.trigger), f(h, l($, {
78
+ var f = K(), v = f.firstChild;
79
+ I(f, "data-floe-dropdown", s), v.$$click = () => c((o) => !o);
80
+ var b = n;
81
+ return typeof b == "function" ? L(b, v) : n = v, m(v, () => e.trigger), m(f, d(y, {
80
82
  get when() {
81
- return i();
83
+ return r();
82
84
  },
83
85
  get children() {
84
- return l(B, {
86
+ return d(B, {
85
87
  get children() {
86
- var x = W(), c = r;
87
- return typeof c == "function" ? L(c, x) : r = x, f(x, l(A, {
88
+ var o = q(), x = l;
89
+ return typeof x == "function" ? L(x, o) : l = o, I(o, "data-floe-dropdown", s), m(o, d(W, {
88
90
  get each() {
89
91
  return e.items;
90
92
  },
91
- children: (d) => l($, {
93
+ children: (t) => d(y, {
92
94
  get when() {
93
- return !d.separator;
95
+ return !t.separator;
94
96
  },
95
97
  get fallback() {
96
98
  return F();
97
99
  },
98
100
  get children() {
99
- return l(H, {
100
- item: d,
101
+ return d(H, {
102
+ item: t,
101
103
  get selected() {
102
- return e.value === d.id;
104
+ return e.value === t.id;
103
105
  },
104
- onSelect: g,
105
- onCloseMenu: () => u(!1)
106
+ onSelect: P,
107
+ onCloseMenu: () => c(!1),
108
+ dropdownId: s
106
109
  });
107
110
  }
108
111
  })
109
- })), _((d) => {
110
- var n = M("fixed z-50 min-w-36 py-0.5", "bg-popover text-popover-foreground", "rounded border border-border shadow-md", "animate-in fade-in slide-in-from-top-2"), k = `${o().x}px`, s = `${o().y}px`;
111
- return n !== d.e && E(x, d.e = n), k !== d.t && p(x, "left", d.t = k), s !== d.a && p(x, "top", d.a = s), d;
112
+ })), E((t) => {
113
+ var $ = p("fixed z-50 min-w-36 py-0.5", "bg-popover text-popover-foreground", "rounded border border-border shadow-md", "animate-in fade-in slide-in-from-top-2"), u = `${i().x}px`, w = `${i().y}px`;
114
+ return $ !== t.e && S(o, t.e = $), u !== t.t && _(o, "left", t.t = u), w !== t.a && _(o, "top", t.a = w), t;
112
115
  }, {
113
116
  e: void 0,
114
117
  t: void 0,
115
118
  a: void 0
116
- }), x;
119
+ }), o;
117
120
  }
118
121
  });
119
122
  }
120
- }), null), _(() => E(h, M("relative inline-block", e.class))), h;
123
+ }), null), E(() => S(f, p("relative inline-block", e.class))), f;
121
124
  })();
122
125
  }
123
126
  function H(e) {
124
- const [i, u] = O(!1), [o, a] = O({
127
+ const [r, c] = O(!1), [i, a] = O({
125
128
  x: -9999,
126
129
  y: -9999
127
130
  });
128
- let t, r, v;
129
- const g = () => e.item.children && e.item.children.length > 0, h = () => {
130
- if (!t || !r) return;
131
- const c = t.getBoundingClientRect(), d = r.getBoundingClientRect(), n = Z(c, d);
132
- a(n);
133
- }, w = () => {
134
- g() && (clearTimeout(v), v = setTimeout(() => {
135
- u(!0), requestAnimationFrame(h);
131
+ let n, l, s;
132
+ const g = () => e.item.children && e.item.children.length > 0, P = () => {
133
+ if (!n || !l) return;
134
+ const o = n.getBoundingClientRect(), x = l.getBoundingClientRect(), t = te(o, x);
135
+ a(t);
136
+ }, f = () => {
137
+ g() && (clearTimeout(s), s = setTimeout(() => {
138
+ c(!0), requestAnimationFrame(P);
136
139
  }, 100));
137
- }, b = () => {
138
- g() && (clearTimeout(v), v = setTimeout(() => {
139
- u(!1);
140
- }, 150));
141
- }, x = (c) => {
140
+ }, v = () => {
141
+ g() && (clearTimeout(s), s = void 0, !e.item.keepOpen && (s = setTimeout(() => {
142
+ c(!1);
143
+ }, 150)));
144
+ }, b = (o) => {
142
145
  if (!e.item.disabled) {
143
146
  if (e.item.content && e.item.keepOpen) {
144
- c.stopPropagation();
147
+ o.stopPropagation();
145
148
  return;
146
149
  }
147
- g() ? (u((d) => !d), requestAnimationFrame(h)) : e.item.content || e.onSelect(e.item.id);
150
+ g() ? (c((x) => !x), requestAnimationFrame(P)) : e.item.content || e.onSelect(e.item);
148
151
  }
149
152
  };
150
153
  return (() => {
151
- var c = Q();
152
- c.addEventListener("mouseleave", b), c.addEventListener("mouseenter", w);
153
- var d = t;
154
- return typeof d == "function" ? L(d, c) : t = c, f(c, l($, {
154
+ var o = X();
155
+ o.addEventListener("mouseleave", v), o.addEventListener("mouseenter", f);
156
+ var x = n;
157
+ return typeof x == "function" ? L(x, o) : n = o, m(o, d(y, {
155
158
  get when() {
156
159
  return e.item.content;
157
160
  },
158
161
  get children() {
159
- var n = J();
160
- return n.$$click = x, f(n, e.item.content), _(() => E(n, M("w-full px-2 py-1.5", e.item.disabled && "opacity-50 pointer-events-none"))), n;
162
+ var t = Q();
163
+ return t.$$click = b, m(t, e.item.content), E(() => S(t, p("w-full px-2 py-1.5", e.item.disabled && "opacity-50 pointer-events-none"))), t;
161
164
  }
162
- }), null), f(c, l($, {
165
+ }), null), m(o, d(y, {
163
166
  get when() {
164
167
  return !e.item.content;
165
168
  },
166
169
  get children() {
167
- var n = K(), k = n.firstChild, s = k.nextSibling;
168
- return n.$$click = x, f(k, l($, {
170
+ var t = U(), $ = t.firstChild, u = $.nextSibling;
171
+ return t.$$click = b, m($, d(y, {
169
172
  get when() {
170
- return T(() => !!e.selected)() && !g();
173
+ return A(() => !!e.selected)() && !g();
171
174
  },
172
175
  get children() {
173
- return l(z, {
176
+ return d(V, {
174
177
  class: "w-3 h-3"
175
178
  });
176
179
  }
177
- })), f(n, l($, {
180
+ })), m(t, d(y, {
178
181
  get when() {
179
182
  return e.item.icon;
180
183
  },
181
184
  keyed: !0,
182
- children: (y) => (() => {
183
- var C = U();
184
- return f(C, y), C;
185
+ children: (w) => (() => {
186
+ var k = Y();
187
+ return m(k, w), k;
185
188
  })()
186
- }), s), f(s, () => e.item.label), f(n, l($, {
189
+ }), u), m(u, () => e.item.label), m(t, d(y, {
187
190
  get when() {
188
191
  return g();
189
192
  },
190
193
  get children() {
191
- return l(G, {
194
+ return d(J, {
192
195
  class: "w-3 h-3 text-muted-foreground"
193
196
  });
194
197
  }
195
- }), null), _((y) => {
196
- var C = M("w-full flex items-center gap-1.5 px-2 py-1 text-xs", "transition-colors duration-75", "focus:outline-none focus:bg-accent", e.item.disabled ? "opacity-50 cursor-not-allowed" : "hover:bg-accent cursor-pointer"), P = e.item.disabled;
197
- return C !== y.e && E(n, y.e = C), P !== y.t && (n.disabled = y.t = P), y;
198
+ }), null), E((w) => {
199
+ var k = p("w-full flex items-center gap-1.5 px-2 py-1 text-xs", "transition-colors duration-75", "focus:outline-none focus:bg-accent", e.item.disabled ? "opacity-50 cursor-not-allowed" : "hover:bg-accent cursor-pointer"), M = e.item.disabled;
200
+ return k !== w.e && S(t, w.e = k), M !== w.t && (t.disabled = w.t = M), w;
198
201
  }, {
199
202
  e: void 0,
200
203
  t: void 0
201
- }), n;
204
+ }), t;
202
205
  }
203
- }), null), f(c, l($, {
206
+ }), null), m(o, d(y, {
204
207
  get when() {
205
- return T(() => !!i())() && g();
208
+ return A(() => !!r())() && g();
206
209
  },
207
210
  get children() {
208
- return l(B, {
211
+ return d(B, {
209
212
  get children() {
210
- var n = W();
211
- n.addEventListener("mouseleave", b), n.addEventListener("mouseenter", () => {
212
- clearTimeout(v);
213
+ var t = q();
214
+ t.addEventListener("mouseleave", v), t.addEventListener("mouseenter", () => {
215
+ clearTimeout(s);
213
216
  });
214
- var k = r;
215
- return typeof k == "function" ? L(k, n) : r = n, f(n, l(A, {
217
+ var $ = l;
218
+ return typeof $ == "function" ? L($, t) : l = t, m(t, d(W, {
216
219
  get each() {
217
220
  return e.item.children;
218
221
  },
219
- children: (s) => l($, {
222
+ children: (u) => d(y, {
220
223
  get when() {
221
- return !s.separator;
224
+ return !u.separator;
222
225
  },
223
226
  get fallback() {
224
227
  return F();
225
228
  },
226
229
  get children() {
227
- return l(H, {
228
- item: s,
230
+ return d(H, {
231
+ item: u,
229
232
  selected: !1,
230
233
  get onSelect() {
231
234
  return e.onSelect;
232
235
  },
233
236
  get onCloseMenu() {
234
237
  return e.onCloseMenu;
238
+ },
239
+ get dropdownId() {
240
+ return e.dropdownId;
235
241
  }
236
242
  });
237
243
  }
238
244
  })
239
- })), _((s) => {
240
- var y = M("fixed z-50 min-w-36 py-0.5", "bg-popover text-popover-foreground", "rounded border border-border shadow-md", "animate-in fade-in slide-in-from-left-1"), C = `${o().x}px`, P = `${o().y}px`;
241
- return y !== s.e && E(n, s.e = y), C !== s.t && p(n, "left", s.t = C), P !== s.a && p(n, "top", s.a = P), s;
245
+ })), E((u) => {
246
+ var w = p("fixed z-50 min-w-36 py-0.5", "bg-popover text-popover-foreground", "rounded border border-border shadow-md", "animate-in fade-in slide-in-from-left-1"), k = e.dropdownId, M = `${i().x}px`, T = `${i().y}px`;
247
+ return w !== u.e && S(t, u.e = w), k !== u.t && I(t, "data-floe-dropdown", u.t = k), M !== u.a && _(t, "left", u.a = M), T !== u.o && _(t, "top", u.o = T), u;
242
248
  }, {
243
249
  e: void 0,
244
250
  t: void 0,
245
- a: void 0
246
- }), n;
251
+ a: void 0,
252
+ o: void 0
253
+ }), t;
247
254
  }
248
255
  });
249
256
  }
250
- }), null), c;
257
+ }), null), o;
251
258
  })();
252
259
  }
253
- function oe(e) {
254
- const i = () => e.options.find((o) => o.value === e.value), u = () => e.options.map((o) => ({
255
- id: o.value,
256
- label: o.label
260
+ function ae(e) {
261
+ const r = () => e.options.find((i) => i.value === e.value), c = () => e.options.map((i) => ({
262
+ id: i.value,
263
+ label: i.label
257
264
  }));
258
- return l(R, {
265
+ return d(ne, {
259
266
  get trigger() {
260
267
  return (() => {
261
- var o = X(), a = o.firstChild;
262
- return f(a, () => i()?.label ?? e.placeholder ?? "Select..."), f(o, l(N, {
268
+ var i = Z(), a = i.firstChild;
269
+ return m(a, () => r()?.label ?? e.placeholder ?? "Select..."), m(i, d(G, {
263
270
  class: "w-3.5 h-3.5 text-muted-foreground"
264
- }), null), _((t) => {
265
- var r = M("flex items-center justify-between gap-2 h-8 px-2.5 w-full cursor-pointer", "rounded border border-input bg-background text-xs shadow-sm", "transition-colors duration-100", "focus:outline-none focus:ring-1 focus:ring-ring", "disabled:cursor-not-allowed disabled:opacity-50", e.class), v = e.disabled, g = M(!i() && "text-muted-foreground");
266
- return r !== t.e && E(o, t.e = r), v !== t.t && (o.disabled = t.t = v), g !== t.a && E(a, t.a = g), t;
271
+ }), null), E((n) => {
272
+ var l = p("flex items-center justify-between gap-2 h-8 px-2.5 w-full cursor-pointer", "rounded border border-input bg-background text-xs shadow-sm", "transition-colors duration-100", "focus:outline-none focus:ring-1 focus:ring-ring", "disabled:cursor-not-allowed disabled:opacity-50", e.class), s = e.disabled, g = p(!r() && "text-muted-foreground");
273
+ return l !== n.e && S(i, n.e = l), s !== n.t && (i.disabled = n.t = s), g !== n.a && S(a, n.a = g), n;
267
274
  }, {
268
275
  e: void 0,
269
276
  t: void 0,
270
277
  a: void 0
271
- }), o;
278
+ }), i;
272
279
  })();
273
280
  },
274
281
  get items() {
275
- return u();
282
+ return c();
276
283
  },
277
284
  get value() {
278
285
  return e.value;
@@ -284,6 +291,6 @@ function oe(e) {
284
291
  }
285
292
  j(["click"]);
286
293
  export {
287
- R as Dropdown,
288
- oe as Select
294
+ ne as Dropdown,
295
+ ae as Select
289
296
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-core",
3
- "version": "0.14.1",
3
+ "version": "0.14.2",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",