asma-ui-core 3.123.0 → 3.123.1
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.
|
@@ -2,11 +2,11 @@ import { cn as g } from "../../../helpers/cn.js";
|
|
|
2
2
|
import { ChevronDownIcon as j } from "../../icons/chevron-down-icon/ChevronDownIcon.js";
|
|
3
3
|
import { ChevronUpIcon as z } from "../../icons/chevron-up-icon/ChevronUpIcon.js";
|
|
4
4
|
import o from "./Pathfinder.module.js";
|
|
5
|
-
import { useCallback as C, useEffect as
|
|
5
|
+
import { useCallback as C, useEffect as y, useLayoutEffect as O, useMemo as x, useRef as I, useState as M, useSyncExternalStore as P } from "react";
|
|
6
6
|
import { Fragment as D, jsx as e, jsxs as R } from "react/jsx-runtime";
|
|
7
|
-
var _ = typeof window < "u" ? O :
|
|
7
|
+
var _ = typeof window < "u" ? O : y;
|
|
8
8
|
function q() {
|
|
9
|
-
const [i, n] =
|
|
9
|
+
const [i, n] = M(null), a = C((t) => {
|
|
10
10
|
n(t);
|
|
11
11
|
}, []), s = C(() => i ? Math.floor(i.getBoundingClientRect().width) : 0, [i]);
|
|
12
12
|
return {
|
|
@@ -31,12 +31,12 @@ function A(i) {
|
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
function K(i) {
|
|
34
|
-
const { items: n, leadSlot: a, actionSlot: s } = i, t = I({}), d = I(null), l = I(null), [m, v] =
|
|
34
|
+
const { items: n, leadSlot: a, actionSlot: s } = i, t = I({}), d = I(null), l = I(null), [m, v] = M({
|
|
35
35
|
itemWidths: {},
|
|
36
36
|
leadWidth: 0,
|
|
37
37
|
actionWidth: 0
|
|
38
38
|
}), p = I(m);
|
|
39
|
-
|
|
39
|
+
y(() => {
|
|
40
40
|
p.current = m;
|
|
41
41
|
}, [m]);
|
|
42
42
|
const h = C((r) => (u) => {
|
|
@@ -45,11 +45,11 @@ function K(i) {
|
|
|
45
45
|
return _(() => {
|
|
46
46
|
const r = {};
|
|
47
47
|
for (const f of n) {
|
|
48
|
-
const k = t.current[f.id],
|
|
49
|
-
r[f.id] =
|
|
48
|
+
const k = t.current[f.id], W = Math.ceil(k?.getBoundingClientRect().width ?? f.estimatedWidth ?? 0);
|
|
49
|
+
r[f.id] = W;
|
|
50
50
|
}
|
|
51
|
-
const u = a ? Math.ceil(d.current?.getBoundingClientRect().width ?? 0) : 0, N = s ? Math.ceil(l.current?.getBoundingClientRect().width ?? 0) : 0,
|
|
52
|
-
(!(Object.keys(
|
|
51
|
+
const u = a ? Math.ceil(d.current?.getBoundingClientRect().width ?? 0) : 0, N = s ? Math.ceil(l.current?.getBoundingClientRect().width ?? 0) : 0, w = p.current;
|
|
52
|
+
(!(Object.keys(w.itemWidths).length === Object.keys(r).length && n.every((f) => w.itemWidths[f.id] === r[f.id])) || w.leadWidth !== u || w.actionWidth !== N) && v({
|
|
53
53
|
itemWidths: r,
|
|
54
54
|
leadWidth: u,
|
|
55
55
|
actionWidth: N
|
|
@@ -79,11 +79,11 @@ function b({ item: i, compact: n }) {
|
|
|
79
79
|
return /* @__PURE__ */ e(D, { children: i.render({ compact: n }) });
|
|
80
80
|
}
|
|
81
81
|
function Y({ items: i, expanded: n, onToggleExpanded: a, leadSlot: s, actionSlot: t, className: d, leadReservePx: l = 140, actionReservePx: m = 44 }) {
|
|
82
|
-
const { ref: v, width: p } = q(), h = !n, r =
|
|
82
|
+
const { ref: v, width: p } = q(), h = !n, r = x(() => A(i), [i]), { measurements: u, registerItemRef: N, leadRef: w, actionRef: f } = K({
|
|
83
83
|
items: r,
|
|
84
84
|
leadSlot: s,
|
|
85
85
|
actionSlot: t
|
|
86
|
-
}), k =
|
|
86
|
+
}), k = x(() => {
|
|
87
87
|
if (n) return r;
|
|
88
88
|
const c = 24, L = 48, B = s ? Math.max(l, u.leadWidth + 12) : 0, F = t ? Math.max(m, u.actionWidth) : 0;
|
|
89
89
|
return U({
|
|
@@ -101,7 +101,7 @@ function Y({ items: i, expanded: n, onToggleExpanded: a, leadSlot: s, actionSlot
|
|
|
101
101
|
l,
|
|
102
102
|
m,
|
|
103
103
|
u
|
|
104
|
-
]),
|
|
104
|
+
]), W = h && k.length < Math.min(2, r.length), E = W ? r.slice(0, 2) : k;
|
|
105
105
|
return /* @__PURE__ */ R("div", {
|
|
106
106
|
ref: v,
|
|
107
107
|
className: g(o.root, "asma-pressable", h ? "overflow-hidden" : "overflow-visible", d),
|
|
@@ -121,9 +121,9 @@ function Y({ items: i, expanded: n, onToggleExpanded: a, leadSlot: s, actionSlot
|
|
|
121
121
|
}) : null, /* @__PURE__ */ e("div", {
|
|
122
122
|
className: g(o.content, h && o.contentCompact),
|
|
123
123
|
children: h ? /* @__PURE__ */ e("div", {
|
|
124
|
-
className: g(o.compactItems,
|
|
124
|
+
className: g(o.compactItems, W && o.compactItemsStacked),
|
|
125
125
|
children: E.map((c) => /* @__PURE__ */ e("div", {
|
|
126
|
-
className: g("min-w-0 whitespace-nowrap",
|
|
126
|
+
className: g("min-w-0 whitespace-nowrap", W ? "w-full" : "shrink"),
|
|
127
127
|
children: /* @__PURE__ */ e(b, {
|
|
128
128
|
item: c,
|
|
129
129
|
compact: h
|
|
@@ -132,7 +132,7 @@ function Y({ items: i, expanded: n, onToggleExpanded: a, leadSlot: s, actionSlot
|
|
|
132
132
|
}) : /* @__PURE__ */ R("div", {
|
|
133
133
|
className: o.expandedItems,
|
|
134
134
|
children: [r.map((c) => /* @__PURE__ */ e("div", {
|
|
135
|
-
className: "shrink-0 whitespace-nowrap",
|
|
135
|
+
className: "min-w-0 max-w-full shrink-0 whitespace-nowrap",
|
|
136
136
|
children: /* @__PURE__ */ e(b, {
|
|
137
137
|
item: c,
|
|
138
138
|
compact: h
|
|
@@ -161,7 +161,7 @@ function Y({ items: i, expanded: n, onToggleExpanded: a, leadSlot: s, actionSlot
|
|
|
161
161
|
s ? /* @__PURE__ */ e("div", {
|
|
162
162
|
className: "shrink-0",
|
|
163
163
|
children: /* @__PURE__ */ e("div", {
|
|
164
|
-
ref:
|
|
164
|
+
ref: w,
|
|
165
165
|
children: s
|
|
166
166
|
})
|
|
167
167
|
}) : null,
|