@mt-gloss/ui 0.0.24 → 0.0.26
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/{Expandable-GaZcfHDZ.js → Expandable-CeOXiCY7.js} +2694 -2664
- package/catalog.js +2 -2
- package/index.js +338 -330
- package/lib/primitives/dashboard/MetricCard/StackedGroupCard.d.ts +46 -1
- package/lib/primitives/dashboard/MetricCard/__tests__/nyquist-11-fixtures.d.ts +38 -0
- package/lib/primitives/dashboard/MetricCard/index.d.ts +3 -1
- package/lib/primitives/dashboard/MetricCard/utils/computeGutterAnchorX.d.ts +48 -0
- package/package.json +1 -1
- package/ui.css +1 -1
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
import { TrendData } from './types';
|
|
2
|
+
import { PrimaryAction, OverflowAction } from '../../overlays/ActionStrip/types';
|
|
2
3
|
export interface StackedValueEntry {
|
|
3
4
|
timeframe: string;
|
|
4
5
|
value: number | null;
|
|
5
6
|
trend?: TrendData | null;
|
|
6
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* Phase 18 plan 18-01 — per-slot ActionStrip config shape returned by
|
|
10
|
+
* `slotToActionStripConfig(slotIdx)`. Composed from Phase 16 ActionStrip
|
|
11
|
+
* `PrimaryAction` + `OverflowAction` types so consumers import a single
|
|
12
|
+
* contract. Collapses CONTEXT §Per-slot API shape onto the two-array API.
|
|
13
|
+
*/
|
|
14
|
+
export interface SlotActionStripConfig {
|
|
15
|
+
primary: PrimaryAction[];
|
|
16
|
+
overflow: OverflowAction[];
|
|
17
|
+
}
|
|
18
|
+
/** Selector mapping slot index → ActionStrip config for that slot. */
|
|
19
|
+
export type SlotToActionStripConfig = (slotIdx: number) => SlotActionStripConfig;
|
|
7
20
|
export interface StackedGroupCardProps {
|
|
8
21
|
title: string;
|
|
9
22
|
prefix?: string;
|
|
@@ -44,6 +57,38 @@ export interface StackedGroupCardProps {
|
|
|
44
57
|
* padding so trend text on the right does not collide with the stroke.
|
|
45
58
|
*/
|
|
46
59
|
sparklineInset?: 'padded' | 'bleed';
|
|
60
|
+
/**
|
|
61
|
+
* Phase 18 plan 18-01 — per-slot ActionStrip config selector. Called with
|
|
62
|
+
* the currently-hovered slot index; returns the `{primary, overflow}`
|
|
63
|
+
* arrays that ActionStrip will render while that slot is hovered.
|
|
64
|
+
*
|
|
65
|
+
* When omitted (back-compat), the existing Cluster D `onSlotHoverStart/End`
|
|
66
|
+
* surface is preserved byte-for-byte — no new callbacks fire, no new DOM
|
|
67
|
+
* attributes appear, parent ActionStrip falls back to card-default config.
|
|
68
|
+
*
|
|
69
|
+
* When supplied, the selector runs on each slot `pointerenter` AFTER
|
|
70
|
+
* `onSlotHoverStart`. The resolved config is forwarded to the parent via
|
|
71
|
+
* `onSlotActionStripConfigChange`. The selector is invoked inside a
|
|
72
|
+
* try/catch; throws produce `console.error` + a `(idx, null)` change
|
|
73
|
+
* callback so the parent can fall back to card-default.
|
|
74
|
+
*
|
|
75
|
+
* AP-12 (Phase 18 new anti-pattern guard): When this prop co-occurs with
|
|
76
|
+
* a legacy global-action prop (detected at mount as `onTableAction` in
|
|
77
|
+
* props), the component emits `console.warn('[StackedGroupCard AP-12] …')`
|
|
78
|
+
* exactly once per mount. Mixing per-slot + global dispatch is ambiguous;
|
|
79
|
+
* remove the legacy global prop.
|
|
80
|
+
*/
|
|
81
|
+
slotToActionStripConfig?: SlotToActionStripConfig;
|
|
82
|
+
/**
|
|
83
|
+
* Phase 18 plan 18-01 — fires whenever the resolved per-slot config
|
|
84
|
+
* changes. `(slotIdx, config)` on enter; `(null, null)` when pointer
|
|
85
|
+
* leaves the card (NOT fired when leaving to a sibling slot; the
|
|
86
|
+
* existing Cluster E `relatedTarget` guard keeps the bridge active).
|
|
87
|
+
*
|
|
88
|
+
* Parent owns the ActionStrip render + `anchorX` wiring; this callback
|
|
89
|
+
* is the bridge between per-slot hover and parent-level config state.
|
|
90
|
+
*/
|
|
91
|
+
onSlotActionStripConfigChange?: (slotIdx: number | null, config: SlotActionStripConfig | null) => void;
|
|
47
92
|
}
|
|
48
93
|
/**
|
|
49
94
|
* StackedGroupCard -- Renders 3 mini metric values horizontally within a 2-col card.
|
|
@@ -66,6 +111,6 @@ export interface StackedGroupCardProps {
|
|
|
66
111
|
* ```
|
|
67
112
|
*/
|
|
68
113
|
export declare const StackedGroupCard: {
|
|
69
|
-
(
|
|
114
|
+
(props: StackedGroupCardProps): import("react/jsx-runtime").JSX.Element;
|
|
70
115
|
displayName: string;
|
|
71
116
|
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { computeGutterAnchorX as ComputeGutterAnchorXFn } from '../utils/computeGutterAnchorX';
|
|
2
|
+
export interface NyquistHarness {
|
|
3
|
+
/** Reference to the promoted math helper (assertion invariants call through it). */
|
|
4
|
+
computeGutterAnchorX: typeof ComputeGutterAnchorXFn;
|
|
5
|
+
}
|
|
6
|
+
export interface BehaviorDef {
|
|
7
|
+
/** 1-indexed for human readability in test output. */
|
|
8
|
+
id: number;
|
|
9
|
+
/** Short, greppable label. */
|
|
10
|
+
label: string;
|
|
11
|
+
/**
|
|
12
|
+
* The contract invariant this row pins. Either an assert-lambda that the
|
|
13
|
+
* runner invokes inside `it.each`, or `null` when the row is documented as
|
|
14
|
+
* covered by a sibling test file (runner skips but keeps the row in the
|
|
15
|
+
* matrix count pin).
|
|
16
|
+
*/
|
|
17
|
+
assert: ((harness: NyquistHarness) => void | Promise<void>) | null;
|
|
18
|
+
/**
|
|
19
|
+
* When present, the runner skips the row with the returned reason string
|
|
20
|
+
* instead of calling `assert`. Used to document rows whose contract is
|
|
21
|
+
* pinned by a dedicated sibling test file (cross-reference maintained in
|
|
22
|
+
* 18-VALIDATION.md).
|
|
23
|
+
*/
|
|
24
|
+
skipFor?: () => string | undefined;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The 9 NYQUIST-11 behaviors. Each row's `assert` OR `skipFor` is evaluated
|
|
28
|
+
* by the runner. Rows without an inline assert are documented in
|
|
29
|
+
* 18-VALIDATION.md as covered by sibling test files — they remain in the
|
|
30
|
+
* matrix so the row-count pin (9) catches silent drops.
|
|
31
|
+
*/
|
|
32
|
+
export declare const BEHAVIORS: BehaviorDef[];
|
|
33
|
+
/**
|
|
34
|
+
* Row-count pin — NYQUIST-11 runner asserts exactly this number of rows.
|
|
35
|
+
* Changing the behavior set requires updating this constant and adding a
|
|
36
|
+
* line in 18-VALIDATION.md §NYQUIST-11 behavior matrix.
|
|
37
|
+
*/
|
|
38
|
+
export declare const BEHAVIOR_ROW_COUNT = 9;
|
|
@@ -13,7 +13,7 @@ export { useEdgeHoverResize } from './useEdgeHoverResize';
|
|
|
13
13
|
export * from './flipAndStage';
|
|
14
14
|
export * from './types';
|
|
15
15
|
export type { CardBackProps } from './CardBack';
|
|
16
|
-
export type { StackedGroupCardProps, StackedValueEntry } from './StackedGroupCard';
|
|
16
|
+
export type { StackedGroupCardProps, StackedValueEntry, SlotActionStripConfig, SlotToActionStripConfig, } from './StackedGroupCard';
|
|
17
17
|
export type { SlideOutRevealConfig, SlideOutRevealReturn } from './useSlideOutReveal';
|
|
18
18
|
export type { ResizeState, ResizeDirection, ResizeMode, ResizeCommit, UseEdgeHoverResizeArgs, UseEdgeHoverResizeReturn, } from './useEdgeHoverResize';
|
|
19
19
|
export type { EdgeHoverHandleProps } from './EdgeHoverHandle';
|
|
@@ -24,6 +24,8 @@ export { DonutChart } from './visualizations/DonutChart';
|
|
|
24
24
|
export { ObjectArrow } from './visualizations/ObjectArrow';
|
|
25
25
|
export { formatValue } from './utils/formatValue';
|
|
26
26
|
export { formatTrend } from './utils/formatTrend';
|
|
27
|
+
export { computeGutterAnchorX } from './utils/computeGutterAnchorX';
|
|
28
|
+
export type { GutterAnchorInput } from './utils/computeGutterAnchorX';
|
|
27
29
|
export { allVariantFixtures } from './fixtures/allVariants';
|
|
28
30
|
export { loadingFixture, errorFixture, emptyFixture, staleFixture, staleSparklineFixture, staleDonutFixture, allStateFixtures, } from './fixtures/states';
|
|
29
31
|
export { sparklineFixture, sparklineUpFixture } from './fixtures/sparklineCard';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* computeGutterAnchorX — Pure math for per-slot gutter-actions anchor (AP-13).
|
|
3
|
+
*
|
|
4
|
+
* AP-13 invariant (Phase 18): The gutter pill's horizontal `anchorX` MUST be
|
|
5
|
+
* derived via this helper — never hardcoded pixel offsets. Consumers include
|
|
6
|
+
* reptime's `MetricCardGrid` stacked-group branch (via plan 18-02 swap) and
|
|
7
|
+
* gloss-side tests; source-grep guard in plan 18-05 enforces that no other
|
|
8
|
+
* `anchorX = <number>` computation exists outside this module.
|
|
9
|
+
*
|
|
10
|
+
* Stack cards host N equally-distributed metric slots along their width.
|
|
11
|
+
* When the pointer hovers a slot, the ActionStrip pill must slide to that
|
|
12
|
+
* slot's horizontal midpoint (or pill-left offset, if `pillWidthPx` is
|
|
13
|
+
* supplied) so metric-scoped actions visually hang off the hovered metric.
|
|
14
|
+
*
|
|
15
|
+
* Formula (slot-center, default):
|
|
16
|
+
* anchorX = (activeSlotIdx + 0.5) * (cardWidthPx / slotCount)
|
|
17
|
+
*
|
|
18
|
+
* Formula (pill-left-offset, when `pillWidthPx` present and > 0 and finite):
|
|
19
|
+
* anchorX = (activeSlotIdx + 0.5) * (cardWidthPx / slotCount) - pillWidthPx / 2
|
|
20
|
+
* (so the pill's visual CENTER sits at slot-center — per UI-SPEC §Spacing)
|
|
21
|
+
*
|
|
22
|
+
* Returns `undefined` when any input is invalid so the caller can skip the
|
|
23
|
+
* transition entirely and leave the pill at its current position.
|
|
24
|
+
*
|
|
25
|
+
* This utility is zero-dep by design — promoted to @mt-gloss/ui so every
|
|
26
|
+
* consumer shares the same formula without copy-paste. Plan 18-01 (this plan)
|
|
27
|
+
* publishes; plan 18-02 swaps reptime's local gutterAnchor.ts helper to
|
|
28
|
+
* import from here (byte-for-byte behavior parity when `pillWidthPx` absent).
|
|
29
|
+
*/
|
|
30
|
+
export interface GutterAnchorInput {
|
|
31
|
+
/** Measured width of the stack card, in CSS pixels. MUST be > 0 and finite. */
|
|
32
|
+
cardWidthPx: number;
|
|
33
|
+
/** Number of slots in the stack card (typically 3 or 5). MUST be > 0 and finite. */
|
|
34
|
+
slotCount: number;
|
|
35
|
+
/**
|
|
36
|
+
* Index of the currently-hovered slot (0-based). `null` returns `undefined`
|
|
37
|
+
* so the caller can unset the anchor and let the pill return to default.
|
|
38
|
+
*/
|
|
39
|
+
activeSlotIdx: number | null;
|
|
40
|
+
/**
|
|
41
|
+
* Optional pill width. When present and finite and > 0, the returned value
|
|
42
|
+
* is the pill-LEFT offset so the pill's CENTER sits at slot center. When
|
|
43
|
+
* absent, zero, negative, or non-finite, the returned value is the raw
|
|
44
|
+
* slot-center pixel (matches reptime's original helper byte-for-byte).
|
|
45
|
+
*/
|
|
46
|
+
pillWidthPx?: number;
|
|
47
|
+
}
|
|
48
|
+
export declare function computeGutterAnchorX(input: GutterAnchorInput): number | undefined;
|