@stll/ui 0.80.0 → 0.81.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stll/ui",
3
- "version": "0.80.0",
3
+ "version": "0.81.1",
4
4
  "description": "Stella's design system: bidi-aware React primitives built on Base UI, the dockable inspector pane, and the Tailwind v4 theme they are styled with.",
5
5
  "keywords": [
6
6
  "base-ui",
@@ -270,6 +270,10 @@
270
270
  "types": "./dist/components/input.d.ts",
271
271
  "import": "./dist/components/input.js"
272
272
  },
273
+ "./inline-overflow": {
274
+ "types": "./dist/lib/inline-overflow.d.ts",
275
+ "import": "./dist/lib/inline-overflow.js"
276
+ },
273
277
  "./inline-rename": {
274
278
  "types": "./dist/components/inline-rename.d.ts",
275
279
  "import": "./dist/components/inline-rename.js"
@@ -634,6 +638,10 @@
634
638
  "types": "./dist/hooks/use-content-dir.d.ts",
635
639
  "import": "./dist/hooks/use-content-dir.js"
636
640
  },
641
+ "./use-inline-overflow": {
642
+ "types": "./dist/hooks/use-inline-overflow.d.ts",
643
+ "import": "./dist/hooks/use-inline-overflow.js"
644
+ },
637
645
  "./use-latest": {
638
646
  "types": "./dist/hooks/use-latest.d.ts",
639
647
  "import": "./dist/hooks/use-latest.js"
@@ -1,48 +0,0 @@
1
- /**
2
- * Pure overflow policy for `InspectorFacetBar`: given the row's available
3
- * width and each chip's natural (measured) width, decides how many chips
4
- * stay visible and whether the overflow trigger renders — kept out of the
5
- * component so it's unit-testable without a DOM or a `ResizeObserver`.
6
- */
7
- export type FacetOverflowInput = {
8
- /** Width inside the row available to the chips (the trigger's own
9
- * footprint is reserved out of this by the policy, not by the caller). */
10
- availableWidth: number;
11
- /** Each chip's natural width, in the same order as the facets they
12
- * represent. */
13
- chipWidths: readonly number[];
14
- /** Index into `chipWidths` of the active chip — always kept visible
15
- * whenever anything is. */
16
- activeIndex: number;
17
- /** The overflow trigger's own footprint, reserved alongside the chips
18
- * whenever not every chip fits. */
19
- triggerWidth: number;
20
- /** Horizontal gap between adjacent chips, and between the last chip and
21
- * the trigger. */
22
- gap?: number;
23
- };
24
- export type FacetOverflowPolicy = {
25
- /** How many chips are visible. Counts a prefix of `chipWidths` in their
26
- * given order when the active chip already falls inside that prefix;
27
- * otherwise counts the active chip plus however many others (in order,
28
- * skipping the active one) fit alongside it. `0` is the narrow-width
29
- * floor: not even the active chip fits, so nothing but the trigger
30
- * shows. */
31
- visibleCount: number;
32
- /** Whether the overflow trigger renders at all. */
33
- showOverflowTrigger: boolean;
34
- };
35
- /**
36
- * Decides the facet row's visible/overflow split.
37
- *
38
- * Narrow-width floor: if even the active chip cannot fit beside the
39
- * trigger, showing it anyway would push the trigger past
40
- * `availableWidth` — the row clips overflow, so the trigger (the only way
41
- * to reach ANY facet from this row) would become unreachable. Rather than
42
- * shrink the active chip below its natural width (this policy has no
43
- * minimum-width input to shrink to), this drops the active chip from the
44
- * visible row too and shows only the trigger: every facet, including the
45
- * active one, still reaches through the overflow menu, and the trigger
46
- * itself always stays on screen.
47
- */
48
- export declare const resolveFacetOverflow: ({ availableWidth, chipWidths, activeIndex, triggerWidth, gap }: FacetOverflowInput) => FacetOverflowPolicy;
@@ -1,52 +0,0 @@
1
- // src/inspector/facet-bar.logic.ts
2
- const sumWithGaps = (widths, gap) => widths.reduce((sum, width, index) => sum + width + (index > 0 ? gap : 0), 0);
3
- /**
4
- * Decides the facet row's visible/overflow split.
5
- *
6
- * Narrow-width floor: if even the active chip cannot fit beside the
7
- * trigger, showing it anyway would push the trigger past
8
- * `availableWidth` — the row clips overflow, so the trigger (the only way
9
- * to reach ANY facet from this row) would become unreachable. Rather than
10
- * shrink the active chip below its natural width (this policy has no
11
- * minimum-width input to shrink to), this drops the active chip from the
12
- * visible row too and shows only the trigger: every facet, including the
13
- * active one, still reaches through the overflow menu, and the trigger
14
- * itself always stays on screen.
15
- */
16
- const resolveFacetOverflow = ({ availableWidth, chipWidths, activeIndex, triggerWidth, gap = 0 }) => {
17
- if (sumWithGaps(chipWidths, gap) <= availableWidth) return {
18
- visibleCount: chipWidths.length,
19
- showOverflowTrigger: false
20
- };
21
- let used = 0;
22
- let count = 0;
23
- for (const width of chipWidths) {
24
- const add = width + (count > 0 ? gap : 0);
25
- if (used + add + gap + triggerWidth > availableWidth) break;
26
- used += add;
27
- count += 1;
28
- }
29
- if (activeIndex < count) return {
30
- visibleCount: count,
31
- showOverflowTrigger: true
32
- };
33
- const activeWidth = chipWidths[activeIndex] ?? 0;
34
- if (activeWidth + gap + triggerWidth > availableWidth) return {
35
- visibleCount: 0,
36
- showOverflowTrigger: true
37
- };
38
- used = activeWidth;
39
- count = 0;
40
- for (const [index, width] of chipWidths.entries()) {
41
- if (index === activeIndex) continue;
42
- const add = width + gap;
43
- if (used + add + gap + triggerWidth > availableWidth) break;
44
- used += add;
45
- count += 1;
46
- }
47
- return {
48
- visibleCount: count + 1,
49
- showOverflowTrigger: true
50
- };
51
- };
52
- export { resolveFacetOverflow };