@floegence/floe-webapp-core 0.2.3 → 0.3.0

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.
@@ -3,5 +3,6 @@ export interface BreadcrumbProps {
3
3
  }
4
4
  /**
5
5
  * Breadcrumb navigation showing current path
6
+ * 基于容器宽度自适应折叠:尽量显示更多路径段,宽度不足时折叠中间部分
6
7
  */
7
8
  export declare function Breadcrumb(props: BreadcrumbProps): import("solid-js").JSX.Element;
package/dist/index44.js CHANGED
@@ -1,69 +1,154 @@
1
- import { delegateEvents as g, template as l, insert as m, createComponent as s, effect as f, className as d } from "solid-js/web";
2
- import { createMemo as p, For as v, Show as x } from "solid-js";
3
- import { cn as h } from "./index67.js";
4
- import { useFileBrowser as b } from "./index39.js";
5
- import { ChevronRight as k } from "./index32.js";
6
- var C = /* @__PURE__ */ l("<nav aria-label=Breadcrumb>"), w = /* @__PURE__ */ l('<button type=button><span class="truncate max-w-[120px] block">');
7
- function y(o) {
8
- const e = b(), i = p(() => {
9
- const t = e.currentPath();
10
- if (t === "/" || t === "")
1
+ import { delegateEvents as H, template as v, insert as E, createComponent as a, memo as P, effect as b, className as x, use as y } from "solid-js/web";
2
+ import { createSignal as B, onMount as L, createMemo as k, For as O, Show as M, onCleanup as F } from "solid-js";
3
+ import { cn as W } from "./index67.js";
4
+ import { useFileBrowser as G } from "./index39.js";
5
+ import { ChevronRight as T } from "./index32.js";
6
+ import { Dropdown as z } from "./index24.js";
7
+ var X = /* @__PURE__ */ v("<nav aria-label=Breadcrumb>"), j = /* @__PURE__ */ v('<button type=button title="Show hidden path segments">…'), q = /* @__PURE__ */ v('<button type=button><span class="truncate max-w-[120px] block">');
8
+ const g = 16, J = 28, R = 12, K = 7, Q = 120, U = 100;
9
+ function V(n) {
10
+ const r = n.length * K;
11
+ return Math.min(r + R, Q + R);
12
+ }
13
+ function ce(n) {
14
+ const r = G();
15
+ let s;
16
+ const [t, c] = B(0);
17
+ L(() => {
18
+ if (!s) return;
19
+ const e = () => {
20
+ s && c(s.offsetWidth);
21
+ };
22
+ e();
23
+ const o = new ResizeObserver(e);
24
+ o.observe(s), F(() => o.disconnect());
25
+ });
26
+ const d = k(() => {
27
+ const e = r.currentPath();
28
+ if (e === "/" || e === "")
11
29
  return [{
12
30
  name: "Root",
13
31
  path: "/"
14
32
  }];
15
- const n = t.split("/").filter(Boolean), a = [{
33
+ const o = e.split("/").filter(Boolean), i = [{
16
34
  name: "Root",
17
35
  path: "/"
18
36
  }];
19
- let u = "";
20
- for (const c of n)
21
- u += "/" + c, a.push({
22
- name: c,
23
- path: u
37
+ let l = "";
38
+ for (const f of o)
39
+ l += "/" + f, i.push({
40
+ name: f,
41
+ path: l
24
42
  });
25
- return a;
26
- }), r = (t) => {
27
- e.setCurrentPath(t.path);
43
+ return i;
44
+ }), m = k(() => {
45
+ const e = d(), o = t();
46
+ if (o < U || e.length <= 2)
47
+ return {
48
+ collapsed: [],
49
+ visible: e,
50
+ shouldCollapse: !1
51
+ };
52
+ const i = e.map((u) => V(u.name)), l = i[0], f = i[e.length - 1], D = g, $ = e.length > 1 ? g : 0, S = l + f + D + $;
53
+ if (S > o && e.length > 2)
54
+ return {
55
+ collapsed: e.slice(1, -1),
56
+ visible: [e[0], e[e.length - 1]],
57
+ shouldCollapse: !0
58
+ };
59
+ const h = e.slice(1, -1), p = [];
60
+ let _ = o - S;
61
+ const N = h.length > 0 ? J + g : 0;
62
+ for (let u = h.length - 1; u >= 0; u--) {
63
+ const I = i[u + 1] + g, A = u > 0 ? N : 0;
64
+ if (_ - A >= I)
65
+ p.unshift(h[u]), _ -= I;
66
+ else
67
+ break;
68
+ }
69
+ const w = h.slice(0, h.length - p.length);
70
+ return {
71
+ collapsed: w,
72
+ visible: [e[0], ...p, e[e.length - 1]],
73
+ shouldCollapse: w.length > 0
74
+ };
75
+ }), C = (e) => {
76
+ r.setCurrentPath(e.path);
28
77
  };
29
78
  return (() => {
30
- var t = C();
31
- return m(t, s(v, {
79
+ var e = X(), o = s;
80
+ return typeof o == "function" ? y(o, e) : s = e, E(e, a(O, {
32
81
  get each() {
33
- return i();
82
+ return m().visible;
34
83
  },
35
- children: (n, a) => [s(x, {
84
+ children: (i, l) => [a(M, {
36
85
  get when() {
37
- return a() > 0;
86
+ return l() > 0;
38
87
  },
39
88
  get children() {
40
- return s(k, {
89
+ return a(T, {
41
90
  class: "w-3 h-3 text-muted-foreground/50 flex-shrink-0"
42
91
  });
43
92
  }
44
- }), s(B, {
45
- segment: n,
93
+ }), a(M, {
94
+ get when() {
95
+ return P(() => !!m().shouldCollapse)() && l() === 1;
96
+ },
97
+ get children() {
98
+ return [a(Y, {
99
+ get segments() {
100
+ return m().collapsed;
101
+ },
102
+ onSelect: C
103
+ }), a(T, {
104
+ class: "w-3 h-3 text-muted-foreground/50 flex-shrink-0"
105
+ })];
106
+ }
107
+ }), a(Z, {
108
+ segment: i,
46
109
  get isLast() {
47
- return a() === i().length - 1;
110
+ return l() === m().visible.length - 1;
48
111
  },
49
- onClick: () => r(n)
112
+ onClick: () => C(i)
50
113
  })]
51
- })), f(() => d(t, h("flex items-center gap-1 min-w-0", o.class))), t;
114
+ })), b(() => x(e, W("flex items-center gap-1 min-w-0 overflow-hidden", n.class))), e;
52
115
  })();
53
116
  }
54
- function B(o) {
117
+ function Y(n) {
118
+ const r = () => n.segments.map((t) => ({
119
+ id: t.path,
120
+ label: t.name
121
+ }));
122
+ return a(z, {
123
+ get trigger() {
124
+ return (() => {
125
+ var t = j();
126
+ return b(() => x(t, W("text-xs px-1.5 py-0.5 rounded cursor-pointer flex-shrink-0", "transition-all duration-100", "text-muted-foreground hover:text-foreground hover:bg-muted/50", "focus:outline-none focus-visible:ring-1 focus-visible:ring-ring"))), t;
127
+ })();
128
+ },
129
+ get items() {
130
+ return r();
131
+ },
132
+ onSelect: (t) => {
133
+ const c = n.segments.find((d) => d.path === t);
134
+ c && n.onSelect(c);
135
+ },
136
+ align: "start"
137
+ });
138
+ }
139
+ function Z(n) {
55
140
  return (() => {
56
- var e = w(), i = e.firstChild;
57
- return e.$$click = () => o.onClick(), m(i, () => o.segment.name), f((r) => {
58
- var t = o.isLast, n = h("text-xs px-1.5 py-0.5 rounded cursor-pointer", "transition-all duration-100", "focus:outline-none focus-visible:ring-1 focus-visible:ring-ring", o.isLast ? "font-medium text-foreground cursor-default" : "text-muted-foreground hover:text-foreground hover:bg-muted/50");
59
- return t !== r.e && (e.disabled = r.e = t), n !== r.t && d(e, r.t = n), r;
141
+ var r = q(), s = r.firstChild;
142
+ return r.$$click = () => n.onClick(), E(s, () => n.segment.name), b((t) => {
143
+ var c = n.isLast, d = W("text-xs px-1.5 py-0.5 rounded cursor-pointer flex-shrink-0", "transition-all duration-100", "focus:outline-none focus-visible:ring-1 focus-visible:ring-ring", n.isLast ? "font-medium text-foreground cursor-default" : "text-muted-foreground hover:text-foreground hover:bg-muted/50");
144
+ return c !== t.e && (r.disabled = t.e = c), d !== t.t && x(r, t.t = d), t;
60
145
  }, {
61
146
  e: void 0,
62
147
  t: void 0
63
- }), e;
148
+ }), r;
64
149
  })();
65
150
  }
66
- g(["click"]);
151
+ H(["click"]);
67
152
  export {
68
- y as Breadcrumb
153
+ ce as Breadcrumb
69
154
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-core",
3
- "version": "0.2.3",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",