@kumix/ui 0.4.0 → 0.4.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/README.md +15 -15
- package/dist/components/agents/approval-card/index.d.ts +2 -0
- package/dist/components/agents/approval-card/index.d.ts.map +1 -1
- package/dist/components/agents/approval-card/index.js +2 -0
- package/dist/components/agents/approval-card/index.js.map +1 -1
- package/dist/components/agents/citations.d.ts +14 -2
- package/dist/components/agents/citations.d.ts.map +1 -1
- package/dist/components/agents/citations.js +11 -7
- package/dist/components/agents/citations.js.map +1 -1
- package/dist/components/agents/loading-states/reasoning-text.d.ts.map +1 -1
- package/dist/components/agents/loading-states/reasoning-text.js +3 -0
- package/dist/components/agents/loading-states/reasoning-text.js.map +1 -1
- package/dist/components/charts/bump-chart/context.js +1 -2
- package/dist/components/charts/bump-chart/plot.js +1 -2
- package/dist/components/charts/bump-chart/point.js +1 -1
- package/dist/components/charts/bump-chart/series.d.ts +1 -0
- package/dist/components/charts/candlestick-chart/context.d.ts +79 -0
- package/dist/components/charts/candlestick-chart/context.d.ts.map +1 -0
- package/dist/components/charts/candlestick-chart/context.js +69 -0
- package/dist/components/charts/candlestick-chart/context.js.map +1 -0
- package/dist/components/charts/candlestick-chart/legend.d.ts +12 -0
- package/dist/components/charts/candlestick-chart/legend.d.ts.map +1 -0
- package/dist/components/charts/candlestick-chart/legend.js +56 -0
- package/dist/components/charts/candlestick-chart/legend.js.map +1 -0
- package/dist/components/charts/candlestick-chart/plot.d.ts +9 -0
- package/dist/components/charts/candlestick-chart/plot.d.ts.map +1 -0
- package/dist/components/charts/candlestick-chart/plot.js +218 -0
- package/dist/components/charts/candlestick-chart/plot.js.map +1 -0
- package/dist/components/charts/candlestick-chart.d.ts +18 -0
- package/dist/components/charts/candlestick-chart.d.ts.map +1 -0
- package/dist/components/charts/candlestick-chart.js +34 -0
- package/dist/components/charts/candlestick-chart.js.map +1 -0
- package/dist/components/charts/composition-chart/context.js +1 -2
- package/dist/components/charts/composition-chart/plot.js +1 -1
- package/dist/components/charts/donut-chart/center.d.ts +16 -0
- package/dist/components/charts/donut-chart/center.d.ts.map +1 -0
- package/dist/components/charts/donut-chart/center.js +78 -0
- package/dist/components/charts/donut-chart/center.js.map +1 -0
- package/dist/components/charts/donut-chart/context.d.ts +68 -0
- package/dist/components/charts/donut-chart/context.d.ts.map +1 -0
- package/dist/components/charts/donut-chart/context.js +2 -0
- package/dist/components/charts/donut-chart/legend.d.ts +17 -0
- package/dist/components/charts/donut-chart/legend.d.ts.map +1 -0
- package/dist/components/charts/donut-chart/legend.js +85 -0
- package/dist/components/charts/donut-chart/legend.js.map +1 -0
- package/dist/components/charts/donut-chart/plot.d.ts +10 -0
- package/dist/components/charts/donut-chart/plot.d.ts.map +1 -0
- package/dist/components/charts/donut-chart/plot.js +108 -0
- package/dist/components/charts/donut-chart/plot.js.map +1 -0
- package/dist/components/charts/donut-chart.d.ts +22 -0
- package/dist/components/charts/donut-chart.d.ts.map +1 -0
- package/dist/components/charts/donut-chart.js +37 -0
- package/dist/components/charts/donut-chart.js.map +1 -0
- package/dist/components/charts/funnel-chart.d.ts.map +1 -1
- package/dist/components/charts/funnel-chart.js +1 -2
- package/dist/components/charts/funnel-chart.js.map +1 -1
- package/dist/components/charts/heat-calendar/tooltip.js +1 -1
- package/dist/components/charts/liquidity-heatmap.js +1 -1
- package/dist/components/charts/order-book/depth-row.d.ts +8 -2
- package/dist/components/charts/order-book/depth-row.d.ts.map +1 -1
- package/dist/components/charts/order-book/depth-row.js +11 -3
- package/dist/components/charts/order-book/depth-row.js.map +1 -1
- package/dist/components/charts/order-book.d.ts +33 -1
- package/dist/components/charts/order-book.d.ts.map +1 -1
- package/dist/components/charts/order-book.js +92 -17
- package/dist/components/charts/order-book.js.map +1 -1
- package/dist/components/charts/price-target-fan/tooltip.js +1 -1
- package/dist/components/charts/returns-calendar/tooltip.js +1 -1
- package/dist/components/charts/status-bar/tooltip.js +1 -1
- package/dist/components/charts/treemap/tooltip.js +1 -1
- package/dist/components/charts/volume-profile/tooltip.js +1 -1
- package/dist/components/custom/confirm-dialog.d.ts +1 -0
- package/dist/components/custom/toast.d.ts +1 -0
- package/dist/components/motion/action-swap.d.ts.map +1 -1
- package/dist/components/motion/action-swap.js +3 -0
- package/dist/components/motion/action-swap.js.map +1 -1
- package/dist/components/motion/animated-sidebar.d.ts +1 -0
- package/dist/components/motion/attachment-upload.d.ts.map +1 -1
- package/dist/components/motion/attachment-upload.js +1 -2
- package/dist/components/motion/attachment-upload.js.map +1 -1
- package/dist/components/motion/availability-scheduler/copy-menu.js +1 -2
- package/dist/components/motion/availability-scheduler/day-row.js +2 -2
- package/dist/components/motion/availability-scheduler/index.js +1 -1
- package/dist/components/motion/bloom-menu.d.ts +1 -0
- package/dist/components/motion/bounce-sidebar.d.ts.map +1 -1
- package/dist/components/motion/bounce-sidebar.js +34 -42
- package/dist/components/motion/bounce-sidebar.js.map +1 -1
- package/dist/components/motion/button/stateful.d.ts.map +1 -1
- package/dist/components/motion/button/stateful.js +3 -0
- package/dist/components/motion/button/stateful.js.map +1 -1
- package/dist/components/motion/card.d.ts +44 -0
- package/dist/components/motion/card.d.ts.map +1 -0
- package/dist/components/motion/card.js +122 -0
- package/dist/components/motion/card.js.map +1 -0
- package/dist/components/motion/checkbox.d.ts +3 -1
- package/dist/components/motion/checkbox.d.ts.map +1 -1
- package/dist/components/motion/checkbox.js +18 -6
- package/dist/components/motion/checkbox.js.map +1 -1
- package/dist/components/motion/color-picker.d.ts +110 -0
- package/dist/components/motion/color-picker.d.ts.map +1 -0
- package/dist/components/motion/color-picker.js +1053 -0
- package/dist/components/motion/color-picker.js.map +1 -0
- package/dist/components/motion/color-selector.d.ts.map +1 -1
- package/dist/components/motion/color-selector.js +9 -2
- package/dist/components/motion/color-selector.js.map +1 -1
- package/dist/components/motion/combobox/content.d.ts +1 -0
- package/dist/components/motion/command-palette.js +2 -2
- package/dist/components/motion/command-palette.js.map +1 -1
- package/dist/components/motion/context-menu.d.ts +1 -0
- package/dist/components/motion/digit-swap.d.ts +9 -1
- package/dist/components/motion/digit-swap.d.ts.map +1 -1
- package/dist/components/motion/digit-swap.js +18 -7
- package/dist/components/motion/digit-swap.js.map +1 -1
- package/dist/components/motion/expandable-control.d.ts +1 -0
- package/dist/components/motion/knockout-wheel.d.ts.map +1 -1
- package/dist/components/motion/knockout-wheel.js +1 -2
- package/dist/components/motion/knockout-wheel.js.map +1 -1
- package/dist/components/motion/morphing-search-chips.d.ts +54 -0
- package/dist/components/motion/morphing-search-chips.d.ts.map +1 -0
- package/dist/components/motion/morphing-search-chips.js +599 -0
- package/dist/components/motion/morphing-search-chips.js.map +1 -0
- package/dist/components/motion/multi-select/content.d.ts +1 -0
- package/dist/components/motion/not-found/shared.d.ts +1 -0
- package/dist/components/motion/number-ticker.d.ts +6 -1
- package/dist/components/motion/number-ticker.d.ts.map +1 -1
- package/dist/components/motion/number-ticker.js +19 -9
- package/dist/components/motion/number-ticker.js.map +1 -1
- package/dist/components/motion/parallax.js.map +1 -1
- package/dist/components/motion/popover-morph.d.ts +1 -0
- package/dist/components/motion/popover-morph.js +3 -0
- package/dist/components/motion/popover-morph.js.map +1 -1
- package/dist/components/motion/popover.d.ts +1 -0
- package/dist/components/motion/prediction-market-card.js +2 -3
- package/dist/components/motion/prediction-market-card.js.map +1 -1
- package/dist/components/motion/radio.d.ts +3 -1
- package/dist/components/motion/radio.d.ts.map +1 -1
- package/dist/components/motion/radio.js +17 -5
- package/dist/components/motion/radio.js.map +1 -1
- package/dist/components/motion/scroll-progress.d.ts +1 -0
- package/dist/components/motion/shader-background.d.ts +1 -0
- package/dist/components/motion/sortable-list.d.ts +1 -0
- package/dist/components/motion/sortable-stack.js +1 -2
- package/dist/components/motion/tabs.d.ts +1 -0
- package/dist/components/motion/text-reveal.d.ts +1 -0
- package/dist/components/motion/tooltip/positioner.d.ts +8 -26
- package/dist/components/motion/tooltip/positioner.d.ts.map +1 -1
- package/dist/components/motion/tooltip/positioner.js +1 -2
- package/dist/components/motion/tooltip.d.ts +62 -20
- package/dist/components/motion/tooltip.d.ts.map +1 -1
- package/dist/components/motion/tooltip.js +1 -135
- package/dist/components/motion/wallet-card/account-avatar.js +1 -2
- package/dist/components/reui/alert.d.ts +1 -1
- package/dist/components/reui/autocomplete.d.ts +1 -1
- package/dist/components/reui/autocomplete.d.ts.map +1 -1
- package/dist/components/reui/autocomplete.js.map +1 -1
- package/dist/components/reui/badge.d.ts +2 -2
- package/dist/components/reui/color-picker.d.ts +280 -0
- package/dist/components/reui/color-picker.d.ts.map +1 -0
- package/dist/components/reui/color-picker.js +2013 -0
- package/dist/components/reui/color-picker.js.map +1 -0
- package/dist/components/reui/data-grid/data-grid-cell-selection.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-header.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-header.js +43 -21
- package/dist/components/reui/data-grid/data-grid-column-header.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-pagination.js +1 -1
- package/dist/components/reui/data-grid/data-grid-scroll-area.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-scroll-area.js +9 -3
- package/dist/components/reui/data-grid/data-grid-scroll-area.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js +12 -8
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.d.ts +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.js +52 -13
- package/dist/components/reui/data-grid/data-grid-table-dnd.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.js +35 -41
- package/dist/components/reui/data-grid/data-grid-table-virtual.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table.d.ts +168 -5
- package/dist/components/reui/data-grid/data-grid-table.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table.js +203 -69
- package/dist/components/reui/data-grid/data-grid-table.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid.d.ts +39 -0
- package/dist/components/reui/data-grid/data-grid.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid.js +33 -1
- package/dist/components/reui/data-grid/data-grid.js.map +1 -1
- package/dist/components/reui/date-selector.d.ts +1 -0
- package/dist/components/reui/date-selector.js +1 -1
- package/dist/components/reui/emoji-picker.d.ts +367 -0
- package/dist/components/reui/emoji-picker.d.ts.map +1 -0
- package/dist/components/reui/emoji-picker.js +1768 -0
- package/dist/components/reui/emoji-picker.js.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-i18n.d.ts.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-nav.js +2 -2
- package/dist/components/reui/file-type.d.ts +496 -0
- package/dist/components/reui/file-type.d.ts.map +1 -0
- package/dist/components/reui/file-type.js +964 -0
- package/dist/components/reui/file-type.js.map +1 -0
- package/dist/components/reui/filters/filters-advanced.d.ts +1 -0
- package/dist/components/reui/filters/filters-advanced.js +1 -1
- package/dist/components/reui/filters/filters-advanced.js.map +1 -1
- package/dist/components/reui/filters/filters-chip.d.ts +5 -1
- package/dist/components/reui/filters/filters-chip.d.ts.map +1 -1
- package/dist/components/reui/filters/filters-chip.js +1 -1
- package/dist/components/reui/filters/filters-lib.d.ts.map +1 -1
- package/dist/components/reui/frame.d.ts +1 -1
- package/dist/components/reui/frame.d.ts.map +1 -1
- package/dist/components/reui/frame.js.map +1 -1
- package/dist/components/reui/gantt/gantt-nav.js +2 -2
- package/dist/components/reui/icon-tile.d.ts +2 -2
- package/dist/components/reui/icon-tile.js +8 -7
- package/dist/components/reui/icon-tile.js.map +1 -1
- package/dist/components/reui/kanban.d.ts.map +1 -1
- package/dist/components/reui/kanban.js +1 -1
- package/dist/components/reui/kanban.js.map +1 -1
- package/dist/components/reui/number-field.d.ts +3 -3
- package/dist/components/reui/number-field.d.ts.map +1 -1
- package/dist/components/reui/number-field.js.map +1 -1
- package/dist/components/reui/rating.d.ts +1 -1
- package/dist/components/reui/scrollspy.d.ts +1 -0
- package/dist/components/reui/time-picker.js.map +1 -1
- package/dist/components/ui/attachment.d.ts +3 -3
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/bubble.d.ts +1 -1
- package/dist/components/ui/button-group.d.ts +1 -1
- package/dist/components/ui/button.d.ts +2 -2
- package/dist/components/ui/command.d.ts.map +1 -1
- package/dist/components/ui/direction.js +1 -2
- package/dist/components/ui/empty.d.ts +1 -1
- package/dist/components/ui/field.d.ts +1 -1
- package/dist/components/ui/field.js +1 -1
- package/dist/components/ui/input-group.d.ts +1 -1
- package/dist/components/ui/item.d.ts +2 -2
- package/dist/components/ui/marker.d.ts +1 -1
- package/dist/components/ui/message-scroller.d.ts.map +1 -1
- package/dist/components/ui/questionnaire.d.ts.map +1 -1
- package/dist/components/ui/sidebar.d.ts +1 -1
- package/dist/components/ui/sidebar.js +1 -1
- package/dist/components/ui/toggle.d.ts +1 -1
- package/dist/context-tTdLKYNf.js +99 -0
- package/dist/context-tTdLKYNf.js.map +1 -0
- package/dist/{copy-menu-C5GaT4Z-.js → copy-menu-BXUh52bu.js} +2 -2
- package/dist/{copy-menu-C5GaT4Z-.js.map → copy-menu-BXUh52bu.js.map} +1 -1
- package/dist/hooks/use-copy-to-clipboard.d.ts +1 -0
- package/dist/hooks/use-hover-gesture.d.ts +1 -0
- package/dist/hooks/use-intersection-observer.d.ts +1 -0
- package/dist/hooks/use-scroll-position.d.ts +1 -0
- package/dist/hooks/use-slider-input.d.ts +1 -0
- package/dist/hooks/use-viewport.d.ts +1 -0
- package/dist/lib/tick-sound.d.ts +1 -0
- package/dist/model-NSIg2p7a.d.ts +20 -0
- package/dist/model-NSIg2p7a.d.ts.map +1 -0
- package/dist/model-_mRyI6V9.d.ts +18 -0
- package/dist/model-_mRyI6V9.d.ts.map +1 -0
- package/dist/{positioner-3mCqiebN.js → positioner-3r3cfkqT.js} +97 -33
- package/dist/positioner-3r3cfkqT.js.map +1 -0
- package/dist/tooltip-Bam5KeYe.js +535 -0
- package/dist/tooltip-Bam5KeYe.js.map +1 -0
- package/dist/use-position-DOi1gVL0.d.ts +32 -0
- package/dist/use-position-DOi1gVL0.d.ts.map +1 -0
- package/package.json +8 -8
- package/dist/components/motion/tooltip.js.map +0 -1
- package/dist/model-DfeFradZ.d.ts +0 -9
- package/dist/model-DfeFradZ.d.ts.map +0 -1
- package/dist/positioner-3mCqiebN.js.map +0 -1
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { t as DepthLevel } from "../../model-
|
|
1
|
+
import { n as DepthSummary, t as DepthLevel } from "../../model-NSIg2p7a.js";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
3
|
//#region src/components/charts/order-book.d.ts
|
|
4
4
|
export type OrderBookLevel = {
|
|
5
5
|
price: number;
|
|
6
6
|
size: number;
|
|
7
7
|
};
|
|
8
|
+
/** A level identified by its side and price, so it survives snapshot updates. */
|
|
9
|
+
export type OrderBookActiveLevel = {
|
|
10
|
+
side: "bid" | "ask";
|
|
11
|
+
price: number;
|
|
12
|
+
} | null;
|
|
8
13
|
export interface OrderBookProps {
|
|
9
14
|
/** Snapshot of buy levels. Equal prices are combined; invalid and zero sizes are omitted. */
|
|
10
15
|
bids: readonly OrderBookLevel[];
|
|
@@ -19,10 +24,26 @@ export interface OrderBookProps {
|
|
|
19
24
|
quoteSymbol?: string;
|
|
20
25
|
formatPrice?: (value: number) => string;
|
|
21
26
|
formatSize?: (value: number) => string;
|
|
27
|
+
/**
|
|
28
|
+
* The level whose depth is inspected: it and every better level on its side
|
|
29
|
+
* are highlighted, and `OrderBookDepthSummary` totals them. Controlled.
|
|
30
|
+
*/
|
|
31
|
+
activeLevel?: OrderBookActiveLevel;
|
|
32
|
+
defaultActiveLevel?: OrderBookActiveLevel;
|
|
33
|
+
onActiveLevelChange?: (level: OrderBookActiveLevel) => void;
|
|
34
|
+
/** Makes each price a button, for example to fill an order ticket. */
|
|
35
|
+
onLevelSelect?: (level: DepthLevel, side: "bid" | "ask") => void;
|
|
22
36
|
children?: ReactNode;
|
|
23
37
|
className?: string;
|
|
24
38
|
}
|
|
25
39
|
export declare function useOrderBook(): {
|
|
40
|
+
active: {
|
|
41
|
+
side: "bid" | "ask";
|
|
42
|
+
index: number;
|
|
43
|
+
} | null;
|
|
44
|
+
summary: DepthSummary | null;
|
|
45
|
+
setActiveLevel: (level: OrderBookActiveLevel) => void;
|
|
46
|
+
onLevelSelect: ((level: DepthLevel, side: "bid" | "ask") => void) | undefined;
|
|
26
47
|
price: number | null;
|
|
27
48
|
baseSymbol: string;
|
|
28
49
|
quoteSymbol: string;
|
|
@@ -53,5 +74,16 @@ export declare function OrderBookSpread({ className }: {
|
|
|
53
74
|
export declare function OrderBookBalance({ className }: {
|
|
54
75
|
className?: string;
|
|
55
76
|
}): import("react").JSX.Element;
|
|
77
|
+
/**
|
|
78
|
+
* Totals the inspected levels: the hovered or focused level and every better
|
|
79
|
+
* level on its side, as the cost of filling an order up to that price.
|
|
80
|
+
*/
|
|
81
|
+
export declare function OrderBookDepthSummary({ placeholder, children, className }: {
|
|
82
|
+
placeholder?: ReactNode;
|
|
83
|
+
/** Custom readout for the inspected levels. */
|
|
84
|
+
children?: (summary: NonNullable<ReturnType<typeof useOrderBook>["summary"]>) => ReactNode;
|
|
85
|
+
className?: string;
|
|
86
|
+
}): import("react").JSX.Element;
|
|
56
87
|
//#endregion
|
|
88
|
+
export type { DepthLevel as OrderBookDepthLevel, DepthSummary as OrderBookDepthSummaryData };
|
|
57
89
|
//# sourceMappingURL=order-book.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"order-book.d.ts","names":["_$
|
|
1
|
+
{"version":3,"file":"order-book.d.ts","names":["_$__order_book0.OrderBookDepthSummaryData"],"sources":["../../../src/components/charts/order-book.tsx"],"mappings":";;;YAkBY;EAAmB;EAAe;;;YAOlC;EAAyB;EAAqB;;iBAEzC;;EAEf,eAAe;;EAEf,eAAe;;EAEf;;EAEA;EACA;EACA;EACA;EACA,eAAe;EACf,cAAc;;;;;EAKd,cAAc;EACd,qBAAqB;EACrB,uBAAuB,OAAO;;EAE9B,iBAAiB,OAAO,YAAY;EACpC,WAAW;EACX;;wBAyEc;;;;;WAAAA;EA3B6B,iBAAA,OAAA;EAhDnB,iBAAA,OAAA,YAAU;;;;EAVZ,cAAA;EACD,aAAA;;;;;;;;;;;wBA2FP,YAAY,UAAU,WAAW,UAAyB,SAAS,iCAAc,IAAA;wBA2BjF,kBAAkB;EAAe;oBAAoB,IAAA;wBAiBrD,gBAAgB,MAAM;EAAe;EAAqB;oBAAoB,IAAA;wBA6D9E,kBAAkB;EAAe;oBAAoB,IAAA;;wBAyBrD,mBAAmB;EAAe;oBAAoB,IAAA;;;;;wBA+BtD,wBACd,aACA,UACA;EAEA,cAAc;;EAEd,YAAY,SAAS,YAAY,kBAAkB,8BAA8B;EACjF;oBACD,IAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { SPRING_PANEL } from "../../lib/ease.js";
|
|
3
3
|
import { OrderBookDepthRow } from "./order-book/depth-row.js";
|
|
4
|
-
import { createContext, useContext } from "react";
|
|
4
|
+
import { createContext, useCallback, useContext, useLayoutEffect, useRef, useState } from "react";
|
|
5
5
|
import { cn } from "@kumix/utils";
|
|
6
6
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { motion, useReducedMotion } from "motion/react";
|
|
@@ -22,6 +22,18 @@ function prepare(levels, side, limit) {
|
|
|
22
22
|
};
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
+
/** Totals levels ordered from the best price outward. */
|
|
26
|
+
function summarizeDepth(levels, side) {
|
|
27
|
+
const size = levels.reduce((sum, level) => sum + level.size, 0);
|
|
28
|
+
const quote = levels.reduce((sum, level) => sum + level.size * level.price, 0);
|
|
29
|
+
return {
|
|
30
|
+
side,
|
|
31
|
+
levels: levels.length,
|
|
32
|
+
size,
|
|
33
|
+
quote,
|
|
34
|
+
averagePrice: size ? quote / size : 0
|
|
35
|
+
};
|
|
36
|
+
}
|
|
25
37
|
/** Accumulate from the best quote outward before reversing asks for display. */
|
|
26
38
|
function buildOrderBook(bids, asks, levels) {
|
|
27
39
|
const limit = Number.isFinite(levels) ? Math.max(0, Math.floor(levels)) : 9;
|
|
@@ -55,10 +67,35 @@ const sizeFormatter = new Intl.NumberFormat("en-US", {
|
|
|
55
67
|
});
|
|
56
68
|
const defaultPrice = (value) => priceFormatter.format(value);
|
|
57
69
|
const defaultSize = (value) => sizeFormatter.format(value);
|
|
58
|
-
function useOrderBookModel({ bids, asks, levels = 9, lastPrice, baseSymbol = "", quoteSymbol = "USD", formatPrice = defaultPrice, formatSize = defaultSize }) {
|
|
70
|
+
function useOrderBookModel({ bids, asks, levels = 9, lastPrice, baseSymbol = "", quoteSymbol = "USD", formatPrice = defaultPrice, formatSize = defaultSize, activeLevel, defaultActiveLevel = null, onActiveLevelChange, onLevelSelect }) {
|
|
59
71
|
const book = buildOrderBook(bids, asks, levels);
|
|
72
|
+
const [internalActive, setInternalActive] = useState(defaultActiveLevel);
|
|
73
|
+
const rawActive = activeLevel === void 0 ? internalActive : activeLevel;
|
|
74
|
+
const activeIndex = rawActive ? (rawActive.side === "bid" ? book.bids : book.asks).findIndex((level) => level.price === rawActive.price) : -1;
|
|
75
|
+
const active = rawActive && activeIndex >= 0 ? {
|
|
76
|
+
side: rawActive.side,
|
|
77
|
+
index: activeIndex
|
|
78
|
+
} : null;
|
|
79
|
+
const latest = useRef({
|
|
80
|
+
controlled: activeLevel !== void 0,
|
|
81
|
+
onActiveLevelChange
|
|
82
|
+
});
|
|
83
|
+
useLayoutEffect(() => {
|
|
84
|
+
latest.current = {
|
|
85
|
+
controlled: activeLevel !== void 0,
|
|
86
|
+
onActiveLevelChange
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
const setActiveLevel = useCallback((level) => {
|
|
90
|
+
if (!latest.current.controlled) setInternalActive(level);
|
|
91
|
+
latest.current.onActiveLevelChange?.(level);
|
|
92
|
+
}, []);
|
|
60
93
|
return {
|
|
61
94
|
...book,
|
|
95
|
+
active,
|
|
96
|
+
summary: active ? summarizeDepth((active.side === "bid" ? book.bids : book.asks).slice(0, active.index + 1), active.side) : null,
|
|
97
|
+
setActiveLevel,
|
|
98
|
+
onLevelSelect,
|
|
62
99
|
price: lastPrice != null && Number.isFinite(lastPrice) && lastPrice > 0 ? lastPrice : book.midpoint,
|
|
63
100
|
baseSymbol,
|
|
64
101
|
quoteSymbol,
|
|
@@ -113,7 +150,7 @@ function OrderBookHeader({ className }) {
|
|
|
113
150
|
});
|
|
114
151
|
}
|
|
115
152
|
function OrderBookSide({ side, className }) {
|
|
116
|
-
const { bids, asks, maxTotal, formatPrice, formatSize, reduce, baseSymbol, quoteSymbol } = useOrderBook();
|
|
153
|
+
const { bids, asks, maxTotal, formatPrice, formatSize, reduce, baseSymbol, quoteSymbol, active, setActiveLevel, onLevelSelect } = useOrderBook();
|
|
117
154
|
const rows = side === "ask" ? [...asks].reverse() : bids;
|
|
118
155
|
const color = side === "ask" ? "text-rose-600 dark:text-rose-400" : "text-emerald-700 dark:text-emerald-400";
|
|
119
156
|
return /* @__PURE__ */ jsxs("table", {
|
|
@@ -135,19 +172,31 @@ function OrderBookSide({ side, className }) {
|
|
|
135
172
|
children: ["Cumulative total ", baseSymbol]
|
|
136
173
|
})
|
|
137
174
|
] })
|
|
138
|
-
}), /* @__PURE__ */ jsx("tbody", {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
175
|
+
}), /* @__PURE__ */ jsx("tbody", {
|
|
176
|
+
onPointerLeave: () => setActiveLevel(null),
|
|
177
|
+
children: rows.length === 0 ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsxs("td", {
|
|
178
|
+
colSpan: 3,
|
|
179
|
+
className: "px-4 py-6 text-center text-muted-foreground",
|
|
180
|
+
children: ["No ", side === "ask" ? "asks" : "bids"]
|
|
181
|
+
}) }) : rows.map((row, index) => {
|
|
182
|
+
const depthIndex = side === "ask" ? rows.length - 1 - index : index;
|
|
183
|
+
return /* @__PURE__ */ jsx(OrderBookDepthRow, {
|
|
184
|
+
row,
|
|
185
|
+
inRange: active?.side === side && depthIndex <= active.index,
|
|
186
|
+
onInspect: (inspect) => setActiveLevel(inspect ? {
|
|
187
|
+
side,
|
|
188
|
+
price: row.price
|
|
189
|
+
} : null),
|
|
190
|
+
onSelect: onLevelSelect ? () => onLevelSelect(row, side) : void 0,
|
|
191
|
+
fraction: maxTotal ? row.total / maxTotal : 0,
|
|
192
|
+
entranceIndex: side === "ask" ? rows.length - 1 - index : index,
|
|
193
|
+
color,
|
|
194
|
+
formatPrice,
|
|
195
|
+
formatSize,
|
|
196
|
+
reduce: !!reduce
|
|
197
|
+
}, row.price);
|
|
198
|
+
})
|
|
199
|
+
})]
|
|
151
200
|
});
|
|
152
201
|
}
|
|
153
202
|
function OrderBookSpread({ className }) {
|
|
@@ -201,7 +250,33 @@ function OrderBookBalance({ className }) {
|
|
|
201
250
|
})]
|
|
202
251
|
});
|
|
203
252
|
}
|
|
253
|
+
/**
|
|
254
|
+
* Totals the inspected levels: the hovered or focused level and every better
|
|
255
|
+
* level on its side, as the cost of filling an order up to that price.
|
|
256
|
+
*/
|
|
257
|
+
function OrderBookDepthSummary({ placeholder = "Hover a level to see the cost of filling up to it", children, className }) {
|
|
258
|
+
const { summary, formatPrice, formatSize, baseSymbol, quoteSymbol } = useOrderBook();
|
|
259
|
+
return /* @__PURE__ */ jsx("p", {
|
|
260
|
+
"aria-live": "polite",
|
|
261
|
+
className: cn("flex min-h-10 flex-wrap items-center justify-between gap-x-4 gap-y-1 border-border border-t px-4 py-2 text-muted-foreground", className),
|
|
262
|
+
children: !summary ? /* @__PURE__ */ jsx("span", {
|
|
263
|
+
className: "font-sans",
|
|
264
|
+
children: placeholder
|
|
265
|
+
}) : children ? children(summary) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("span", { children: ["Avg ", /* @__PURE__ */ jsx("span", {
|
|
266
|
+
className: "text-foreground",
|
|
267
|
+
children: formatPrice(summary.averagePrice)
|
|
268
|
+
})] }), /* @__PURE__ */ jsxs("span", { children: [
|
|
269
|
+
/* @__PURE__ */ jsxs("span", {
|
|
270
|
+
className: "text-foreground",
|
|
271
|
+
children: [formatSize(summary.size), baseSymbol && ` ${baseSymbol}`]
|
|
272
|
+
}),
|
|
273
|
+
" · ",
|
|
274
|
+
formatPrice(summary.quote),
|
|
275
|
+
quoteSymbol && ` ${quoteSymbol}`
|
|
276
|
+
] })] })
|
|
277
|
+
});
|
|
278
|
+
}
|
|
204
279
|
//#endregion
|
|
205
|
-
export { OrderBook, OrderBookBalance, OrderBookHeader, OrderBookSide, OrderBookSpread, useOrderBook };
|
|
280
|
+
export { OrderBook, OrderBookBalance, OrderBookDepthSummary, OrderBookHeader, OrderBookSide, OrderBookSpread, useOrderBook };
|
|
206
281
|
|
|
207
282
|
//# sourceMappingURL=order-book.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"order-book.js","names":[],"sources":["../../../src/components/charts/order-book/model.ts","../../../src/components/charts/order-book.tsx"],"sourcesContent":["export type DepthLevel = { price: number; size: number; total: number };\ntype Level = { price: number; size: number };\n\nfunction prepare(levels: readonly Level[], side: \"bid\" | \"ask\", limit: number): DepthLevel[] {\n const prices = new Map<number, number>();\n for (const { price, size } of levels) {\n if (!Number.isFinite(price) || !Number.isFinite(size) || price <= 0 || size <= 0) continue;\n prices.set(price, (prices.get(price) ?? 0) + size);\n }\n let total = 0;\n return [...prices]\n .sort(([a], [b]) => (side === \"bid\" ? b - a : a - b))\n .slice(0, limit)\n .map(([price, size]) => {\n total += size;\n return { price, size, total };\n });\n}\n\n/** Accumulate from the best quote outward before reversing asks for display. */\nexport function buildOrderBook(bids: readonly Level[], asks: readonly Level[], levels: number) {\n const limit = Number.isFinite(levels) ? Math.max(0, Math.floor(levels)) : 9;\n const buy = prepare(bids, \"bid\", limit);\n const sell = prepare(asks, \"ask\", limit);\n const bidTotal = buy.at(-1)?.total ?? 0;\n const askTotal = sell.at(-1)?.total ?? 0;\n const bestBid = buy[0]?.price;\n const bestAsk = sell[0]?.price;\n const midpoint = bestBid == null || bestAsk == null ? null : (bestBid + bestAsk) / 2;\n const spread = bestBid == null || bestAsk == null ? null : bestAsk - bestBid;\n return {\n bids: buy,\n asks: sell,\n bidTotal,\n askTotal,\n maxTotal: Math.max(bidTotal, askTotal),\n midpoint,\n spread,\n };\n}\n","\"use client\";\n\nimport { createContext, type ReactNode, useContext } from \"react\";\nimport { motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { SPRING_PANEL } from \"../../lib/ease\";\nimport { OrderBookDepthRow } from \"./order-book/depth-row\";\nimport { buildOrderBook } from \"./order-book/model\";\n\nexport type OrderBookLevel = { price: number; size: number };\n\nexport interface OrderBookProps {\n /** Snapshot of buy levels. Equal prices are combined; invalid and zero sizes are omitted. */\n bids: readonly OrderBookLevel[];\n /** Snapshot of sell levels. Supply new arrays when the book changes. */\n asks: readonly OrderBookLevel[];\n /** Number of nearest levels to show on each side. */\n levels?: number;\n /** Last traded price. Omit to show the midpoint of the best bid and ask. */\n lastPrice?: number;\n label?: string;\n baseSymbol?: string;\n quoteSymbol?: string;\n formatPrice?: (value: number) => string;\n formatSize?: (value: number) => string;\n children?: ReactNode;\n className?: string;\n}\n\nconst priceFormatter = new Intl.NumberFormat(\"en-US\", {\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n});\nconst sizeFormatter = new Intl.NumberFormat(\"en-US\", {\n notation: \"compact\",\n maximumFractionDigits: 1,\n});\nconst defaultPrice = (value: number) => priceFormatter.format(value);\nconst defaultSize = (value: number) => sizeFormatter.format(value);\n\nfunction useOrderBookModel({\n bids,\n asks,\n levels = 9,\n lastPrice,\n baseSymbol = \"\",\n quoteSymbol = \"USD\",\n formatPrice = defaultPrice,\n formatSize = defaultSize,\n}: OrderBookProps) {\n const book = buildOrderBook(bids, asks, levels);\n return {\n ...book,\n price:\n lastPrice != null && Number.isFinite(lastPrice) && lastPrice > 0 ? lastPrice : book.midpoint,\n baseSymbol,\n quoteSymbol,\n formatPrice,\n formatSize,\n reduce: useReducedMotion(),\n };\n}\nconst OrderBookContext = createContext<ReturnType<typeof useOrderBookModel> | null>(null);\n\nexport function useOrderBook() {\n const context = useContext(OrderBookContext);\n if (!context) throw new Error(\"Order book parts must be rendered inside OrderBook.\");\n return context;\n}\n\n/** A snapshot-driven depth ladder. No timers or invented market data live in the chart. */\nexport function OrderBook({ children, className, label = \"Order book\", ...props }: OrderBookProps) {\n const model = useOrderBookModel(props);\n return (\n <OrderBookContext.Provider value={model}>\n <section\n aria-label={label}\n className={cn(\n \"w-full max-w-[560px] overflow-hidden rounded-2xl border border-border bg-background font-mono text-xs tabular-nums\",\n className,\n )}\n >\n {children === undefined ? (\n <>\n <OrderBookHeader />\n <OrderBookSide side=\"ask\" />\n <OrderBookSpread />\n <OrderBookSide side=\"bid\" />\n <OrderBookBalance />\n </>\n ) : (\n children\n )}\n </section>\n </OrderBookContext.Provider>\n );\n}\n\nexport function OrderBookHeader({ className }: { className?: string }) {\n const { baseSymbol, quoteSymbol } = useOrderBook();\n return (\n <div\n aria-hidden=\"true\"\n className={cn(\n \"grid grid-cols-3 py-3 text-[10px] text-muted-foreground uppercase tracking-wider\",\n className,\n )}\n >\n <span className=\"px-4\">Price{quoteSymbol && ` (${quoteSymbol})`}</span>\n <span className=\"px-4 text-right\">Size{baseSymbol && ` (${baseSymbol})`}</span>\n <span className=\"px-4 text-right\">Total</span>\n </div>\n );\n}\n\nexport function OrderBookSide({ side, className }: { side: \"bid\" | \"ask\"; className?: string }) {\n const { bids, asks, maxTotal, formatPrice, formatSize, reduce, baseSymbol, quoteSymbol } =\n useOrderBook();\n const rows = side === \"ask\" ? [...asks].reverse() : bids;\n const color =\n side === \"ask\" ? \"text-rose-600 dark:text-rose-400\" : \"text-emerald-700 dark:text-emerald-400\";\n return (\n <table\n aria-label={side === \"ask\" ? \"Asks · sell orders\" : \"Bids · buy orders\"}\n className={cn(\"w-full table-fixed border-separate border-spacing-0\", className)}\n >\n <thead className=\"sr-only\">\n <tr>\n <th scope=\"col\">Price {quoteSymbol}</th>\n <th scope=\"col\">Size {baseSymbol}</th>\n <th scope=\"col\">Cumulative total {baseSymbol}</th>\n </tr>\n </thead>\n <tbody>\n {rows.length === 0 ? (\n <tr>\n <td colSpan={3} className=\"px-4 py-6 text-center text-muted-foreground\">\n No {side === \"ask\" ? \"asks\" : \"bids\"}\n </td>\n </tr>\n ) : (\n rows.map((row, index) => (\n <OrderBookDepthRow\n key={row.price}\n row={row}\n fraction={maxTotal ? row.total / maxTotal : 0}\n entranceIndex={side === \"ask\" ? rows.length - 1 - index : index}\n color={color}\n formatPrice={formatPrice}\n formatSize={formatSize}\n reduce={!!reduce}\n />\n ))\n )}\n </tbody>\n </table>\n );\n}\n\nexport function OrderBookSpread({ className }: { className?: string }) {\n const { price, spread, midpoint, formatPrice } = useOrderBook();\n return (\n <div\n className={cn(\n \"my-1 flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1 border-border border-y bg-muted/40 px-4 py-3\",\n className,\n )}\n >\n <span className=\"font-medium text-base tracking-tight\">\n <span className=\"sr-only\">Reference price: </span>\n {price == null ? \"—\" : formatPrice(price)}\n </span>\n <span className=\"text-[10px] text-muted-foreground\">\n {spread == null || midpoint == null\n ? \"Spread unavailable\"\n : spread < 0\n ? \"Crossed book\"\n : `Spread ${formatPrice(spread)} · ${((spread / midpoint) * 100).toFixed(3)}%`}\n </span>\n </div>\n );\n}\n\n/** Balance of the displayed depth, not the entire exchange order book. */\nexport function OrderBookBalance({ className }: { className?: string }) {\n const { bidTotal, askTotal, reduce } = useOrderBook();\n const total = bidTotal + askTotal;\n const ratio = total ? bidTotal / total : 0.5;\n return (\n <div className={cn(\"space-y-2 border-border border-t px-4 pt-3 pb-3\", className)}>\n <div className=\"flex justify-between text-[10px]\">\n <span className=\"text-emerald-700 dark:text-emerald-400\">\n Bids {total ? `${(ratio * 100).toFixed(1)}%` : \"—\"}\n </span>\n <span className=\"text-muted-foreground\">Visible depth</span>\n <span className=\"text-rose-600 dark:text-rose-400\">\n Asks {total ? `${((1 - ratio) * 100).toFixed(1)}%` : \"—\"}\n </span>\n </div>\n <div aria-hidden=\"true\" className=\"relative h-1 overflow-hidden rounded-full bg-rose-500/25\">\n <motion.div\n initial={false}\n animate={{ transform: `scaleX(${ratio})` }}\n transition={reduce ? { duration: 0 } : SPRING_PANEL}\n className=\"absolute inset-0 origin-left bg-emerald-500/60\"\n />\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;AAGA,SAAS,QAAQ,QAA0B,MAAqB,OAA6B;CAC3F,MAAM,yBAAS,IAAI,IAAoB;CACvC,KAAK,MAAM,EAAE,OAAO,UAAU,QAAQ;EACpC,IAAI,CAAC,OAAO,SAAS,KAAK,KAAK,CAAC,OAAO,SAAS,IAAI,KAAK,SAAS,KAAK,QAAQ,GAAG;EAClF,OAAO,IAAI,QAAQ,OAAO,IAAI,KAAK,KAAK,KAAK,IAAI;CACnD;CACA,IAAI,QAAQ;CACZ,OAAO,CAAC,GAAG,MAAM,CAAC,CACf,MAAM,CAAC,IAAI,CAAC,OAAQ,SAAS,QAAQ,IAAI,IAAI,IAAI,CAAE,CAAC,CACpD,MAAM,GAAG,KAAK,CAAC,CACf,KAAK,CAAC,OAAO,UAAU;EACtB,SAAS;EACT,OAAO;GAAE;GAAO;GAAM;EAAM;CAC9B,CAAC;AACL;;A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CAAC,EAAE;EAC5E,CAAA,CACH;;AAET;;AAGA,SAAgB,iBAAiB,EAAE,aAAqC;CACtE,MAAM,EAAE,UAAU,UAAU,WAAW,aAAa;CACpD,MAAM,QAAQ,WAAW;CACzB,MAAM,QAAQ,QAAQ,WAAW,QAAQ;CACzC,OACE,qBAAC,OAAD;EAAK,WAAW,GAAG,mDAAmD,SAAS;EAA/E,UAAA,CACE,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA;IACE,qBAAC,QAAD;KAAM,WAAU;KAAhB,UAAA,CAAyD,SACjD,QAAQ,IAAI,QAAQ,IAAA,CAAK,QAAQ,CAAC,EAAE,KAAK,GAC3C;;IACN,oBAAC,QAAD;KAAM,WAAU;KAAwB,UAAA;IAAmB,CAAA;IAC3D,qBAAC,QAAD;KAAM,WAAU;KAAhB,UAAA,CAAmD,SAC3C,QAAQ,KAAK,IAAI,SAAS,IAAA,CAAK,QAAQ,CAAC,EAAE,KAAK,GACjD;;GACH;EACL,CAAA,GAAA,oBAAC,OAAD;GAAK,eAAY;GAAO,WAAU;GAChC,UAAA,oBAAC,OAAO,KAAR;IACE,SAAS;IACT,SAAS,EAAE,WAAW,UAAU,MAAM,GAAG;IACzC,YAAY,SAAS,EAAE,UAAU,EAAE,IAAI;IACvC,WAAU;GACX,CAAA;EACE,CAAA,CACF;;AAET"}
|
|
1
|
+
{"version":3,"file":"order-book.js","names":[],"sources":["../../../src/components/charts/order-book/model.ts","../../../src/components/charts/order-book.tsx"],"sourcesContent":["export type DepthLevel = { price: number; size: number; total: number };\ntype Level = { price: number; size: number };\n\nfunction prepare(levels: readonly Level[], side: \"bid\" | \"ask\", limit: number): DepthLevel[] {\n const prices = new Map<number, number>();\n for (const { price, size } of levels) {\n if (!Number.isFinite(price) || !Number.isFinite(size) || price <= 0 || size <= 0) continue;\n prices.set(price, (prices.get(price) ?? 0) + size);\n }\n let total = 0;\n return [...prices]\n .sort(([a], [b]) => (side === \"bid\" ? b - a : a - b))\n .slice(0, limit)\n .map(([price, size]) => {\n total += size;\n return { price, size, total };\n });\n}\n\nexport type DepthSummary = {\n side: \"bid\" | \"ask\";\n /** Number of levels from the best price out to the inspected one. */\n levels: number;\n /** Total base size across those levels. */\n size: number;\n /** Total quote value across those levels. */\n quote: number;\n /** Size-weighted average fill price. */\n averagePrice: number;\n};\n\n/** Totals levels ordered from the best price outward. */\nexport function summarizeDepth(levels: readonly DepthLevel[], side: \"bid\" | \"ask\"): DepthSummary {\n const size = levels.reduce((sum, level) => sum + level.size, 0);\n const quote = levels.reduce((sum, level) => sum + level.size * level.price, 0);\n return { side, levels: levels.length, size, quote, averagePrice: size ? quote / size : 0 };\n}\n\n/** Accumulate from the best quote outward before reversing asks for display. */\nexport function buildOrderBook(bids: readonly Level[], asks: readonly Level[], levels: number) {\n const limit = Number.isFinite(levels) ? Math.max(0, Math.floor(levels)) : 9;\n const buy = prepare(bids, \"bid\", limit);\n const sell = prepare(asks, \"ask\", limit);\n const bidTotal = buy.at(-1)?.total ?? 0;\n const askTotal = sell.at(-1)?.total ?? 0;\n const bestBid = buy[0]?.price;\n const bestAsk = sell[0]?.price;\n const midpoint = bestBid == null || bestAsk == null ? null : (bestBid + bestAsk) / 2;\n const spread = bestBid == null || bestAsk == null ? null : bestAsk - bestBid;\n return {\n bids: buy,\n asks: sell,\n bidTotal,\n askTotal,\n maxTotal: Math.max(bidTotal, askTotal),\n midpoint,\n spread,\n };\n}\n","\"use client\";\n\nimport {\n createContext,\n type ReactNode,\n useCallback,\n useContext,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\nimport { motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { SPRING_PANEL } from \"../../lib/ease\";\nimport { OrderBookDepthRow } from \"./order-book/depth-row\";\nimport { buildOrderBook, type DepthLevel, summarizeDepth } from \"./order-book/model\";\n\nexport type OrderBookLevel = { price: number; size: number };\nexport type {\n DepthLevel as OrderBookDepthLevel,\n DepthSummary as OrderBookDepthSummaryData,\n} from \"./order-book/model\";\n\n/** A level identified by its side and price, so it survives snapshot updates. */\nexport type OrderBookActiveLevel = { side: \"bid\" | \"ask\"; price: number } | null;\n\nexport interface OrderBookProps {\n /** Snapshot of buy levels. Equal prices are combined; invalid and zero sizes are omitted. */\n bids: readonly OrderBookLevel[];\n /** Snapshot of sell levels. Supply new arrays when the book changes. */\n asks: readonly OrderBookLevel[];\n /** Number of nearest levels to show on each side. */\n levels?: number;\n /** Last traded price. Omit to show the midpoint of the best bid and ask. */\n lastPrice?: number;\n label?: string;\n baseSymbol?: string;\n quoteSymbol?: string;\n formatPrice?: (value: number) => string;\n formatSize?: (value: number) => string;\n /**\n * The level whose depth is inspected: it and every better level on its side\n * are highlighted, and `OrderBookDepthSummary` totals them. Controlled.\n */\n activeLevel?: OrderBookActiveLevel;\n defaultActiveLevel?: OrderBookActiveLevel;\n onActiveLevelChange?: (level: OrderBookActiveLevel) => void;\n /** Makes each price a button, for example to fill an order ticket. */\n onLevelSelect?: (level: DepthLevel, side: \"bid\" | \"ask\") => void;\n children?: ReactNode;\n className?: string;\n}\n\nconst priceFormatter = new Intl.NumberFormat(\"en-US\", {\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n});\nconst sizeFormatter = new Intl.NumberFormat(\"en-US\", {\n notation: \"compact\",\n maximumFractionDigits: 1,\n});\nconst defaultPrice = (value: number) => priceFormatter.format(value);\nconst defaultSize = (value: number) => sizeFormatter.format(value);\n\nfunction useOrderBookModel({\n bids,\n asks,\n levels = 9,\n lastPrice,\n baseSymbol = \"\",\n quoteSymbol = \"USD\",\n formatPrice = defaultPrice,\n formatSize = defaultSize,\n activeLevel,\n defaultActiveLevel = null,\n onActiveLevelChange,\n onLevelSelect,\n}: OrderBookProps) {\n const book = buildOrderBook(bids, asks, levels);\n const [internalActive, setInternalActive] = useState(defaultActiveLevel);\n const rawActive = activeLevel === undefined ? internalActive : activeLevel;\n // Resolve the inspected level during render by price; a level that left the\n // book clears the inspection instead of pointing at a different row.\n const activeIndex = rawActive\n ? (rawActive.side === \"bid\" ? book.bids : book.asks).findIndex(\n (level) => level.price === rawActive.price,\n )\n : -1;\n const active =\n rawActive && activeIndex >= 0 ? { side: rawActive.side, index: activeIndex } : null;\n\n // Stable setter: it reads the latest controlled flag and callback from refs.\n const latest = useRef({ controlled: activeLevel !== undefined, onActiveLevelChange });\n useLayoutEffect(() => {\n latest.current = { controlled: activeLevel !== undefined, onActiveLevelChange };\n });\n const setActiveLevel = useCallback((level: OrderBookActiveLevel) => {\n if (!latest.current.controlled) setInternalActive(level);\n latest.current.onActiveLevelChange?.(level);\n }, []);\n\n return {\n ...book,\n active,\n summary: active\n ? summarizeDepth(\n (active.side === \"bid\" ? book.bids : book.asks).slice(0, active.index + 1),\n active.side,\n )\n : null,\n setActiveLevel,\n onLevelSelect,\n price:\n lastPrice != null && Number.isFinite(lastPrice) && lastPrice > 0 ? lastPrice : book.midpoint,\n baseSymbol,\n quoteSymbol,\n formatPrice,\n formatSize,\n reduce: useReducedMotion(),\n };\n}\nconst OrderBookContext = createContext<ReturnType<typeof useOrderBookModel> | null>(null);\n\nexport function useOrderBook() {\n const context = useContext(OrderBookContext);\n if (!context) throw new Error(\"Order book parts must be rendered inside OrderBook.\");\n return context;\n}\n\n/** A snapshot-driven depth ladder. No timers or invented market data live in the chart. */\nexport function OrderBook({ children, className, label = \"Order book\", ...props }: OrderBookProps) {\n const model = useOrderBookModel(props);\n return (\n <OrderBookContext.Provider value={model}>\n <section\n aria-label={label}\n className={cn(\n \"w-full max-w-[560px] overflow-hidden rounded-2xl border border-border bg-background font-mono text-xs tabular-nums\",\n className,\n )}\n >\n {children === undefined ? (\n <>\n <OrderBookHeader />\n <OrderBookSide side=\"ask\" />\n <OrderBookSpread />\n <OrderBookSide side=\"bid\" />\n <OrderBookBalance />\n </>\n ) : (\n children\n )}\n </section>\n </OrderBookContext.Provider>\n );\n}\n\nexport function OrderBookHeader({ className }: { className?: string }) {\n const { baseSymbol, quoteSymbol } = useOrderBook();\n return (\n <div\n aria-hidden=\"true\"\n className={cn(\n \"grid grid-cols-3 py-3 text-[10px] text-muted-foreground uppercase tracking-wider\",\n className,\n )}\n >\n <span className=\"px-4\">Price{quoteSymbol && ` (${quoteSymbol})`}</span>\n <span className=\"px-4 text-right\">Size{baseSymbol && ` (${baseSymbol})`}</span>\n <span className=\"px-4 text-right\">Total</span>\n </div>\n );\n}\n\nexport function OrderBookSide({ side, className }: { side: \"bid\" | \"ask\"; className?: string }) {\n const {\n bids,\n asks,\n maxTotal,\n formatPrice,\n formatSize,\n reduce,\n baseSymbol,\n quoteSymbol,\n active,\n setActiveLevel,\n onLevelSelect,\n } = useOrderBook();\n const rows = side === \"ask\" ? [...asks].reverse() : bids;\n const color =\n side === \"ask\" ? \"text-rose-600 dark:text-rose-400\" : \"text-emerald-700 dark:text-emerald-400\";\n return (\n <table\n aria-label={side === \"ask\" ? \"Asks · sell orders\" : \"Bids · buy orders\"}\n className={cn(\"w-full table-fixed border-separate border-spacing-0\", className)}\n >\n <thead className=\"sr-only\">\n <tr>\n <th scope=\"col\">Price {quoteSymbol}</th>\n <th scope=\"col\">Size {baseSymbol}</th>\n <th scope=\"col\">Cumulative total {baseSymbol}</th>\n </tr>\n </thead>\n <tbody onPointerLeave={() => setActiveLevel(null)}>\n {rows.length === 0 ? (\n <tr>\n <td colSpan={3} className=\"px-4 py-6 text-center text-muted-foreground\">\n No {side === \"ask\" ? \"asks\" : \"bids\"}\n </td>\n </tr>\n ) : (\n rows.map((row, index) => {\n const depthIndex = side === \"ask\" ? rows.length - 1 - index : index;\n return (\n <OrderBookDepthRow\n key={row.price}\n row={row}\n inRange={active?.side === side && depthIndex <= active.index}\n onInspect={(inspect) => setActiveLevel(inspect ? { side, price: row.price } : null)}\n onSelect={onLevelSelect ? () => onLevelSelect(row, side) : undefined}\n fraction={maxTotal ? row.total / maxTotal : 0}\n entranceIndex={side === \"ask\" ? rows.length - 1 - index : index}\n color={color}\n formatPrice={formatPrice}\n formatSize={formatSize}\n reduce={!!reduce}\n />\n );\n })\n )}\n </tbody>\n </table>\n );\n}\n\nexport function OrderBookSpread({ className }: { className?: string }) {\n const { price, spread, midpoint, formatPrice } = useOrderBook();\n return (\n <div\n className={cn(\n \"my-1 flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1 border-border border-y bg-muted/40 px-4 py-3\",\n className,\n )}\n >\n <span className=\"font-medium text-base tracking-tight\">\n <span className=\"sr-only\">Reference price: </span>\n {price == null ? \"—\" : formatPrice(price)}\n </span>\n <span className=\"text-[10px] text-muted-foreground\">\n {spread == null || midpoint == null\n ? \"Spread unavailable\"\n : spread < 0\n ? \"Crossed book\"\n : `Spread ${formatPrice(spread)} · ${((spread / midpoint) * 100).toFixed(3)}%`}\n </span>\n </div>\n );\n}\n\n/** Balance of the displayed depth, not the entire exchange order book. */\nexport function OrderBookBalance({ className }: { className?: string }) {\n const { bidTotal, askTotal, reduce } = useOrderBook();\n const total = bidTotal + askTotal;\n const ratio = total ? bidTotal / total : 0.5;\n return (\n <div className={cn(\"space-y-2 border-border border-t px-4 pt-3 pb-3\", className)}>\n <div className=\"flex justify-between text-[10px]\">\n <span className=\"text-emerald-700 dark:text-emerald-400\">\n Bids {total ? `${(ratio * 100).toFixed(1)}%` : \"—\"}\n </span>\n <span className=\"text-muted-foreground\">Visible depth</span>\n <span className=\"text-rose-600 dark:text-rose-400\">\n Asks {total ? `${((1 - ratio) * 100).toFixed(1)}%` : \"—\"}\n </span>\n </div>\n <div aria-hidden=\"true\" className=\"relative h-1 overflow-hidden rounded-full bg-rose-500/25\">\n <motion.div\n initial={false}\n animate={{ transform: `scaleX(${ratio})` }}\n transition={reduce ? { duration: 0 } : SPRING_PANEL}\n className=\"absolute inset-0 origin-left bg-emerald-500/60\"\n />\n </div>\n </div>\n );\n}\n\n/**\n * Totals the inspected levels: the hovered or focused level and every better\n * level on its side, as the cost of filling an order up to that price.\n */\nexport function OrderBookDepthSummary({\n placeholder = \"Hover a level to see the cost of filling up to it\",\n children,\n className,\n}: {\n placeholder?: ReactNode;\n /** Custom readout for the inspected levels. */\n children?: (summary: NonNullable<ReturnType<typeof useOrderBook>[\"summary\"]>) => ReactNode;\n className?: string;\n}) {\n const { summary, formatPrice, formatSize, baseSymbol, quoteSymbol } = useOrderBook();\n return (\n <p\n aria-live=\"polite\"\n className={cn(\n \"flex min-h-10 flex-wrap items-center justify-between gap-x-4 gap-y-1 border-border border-t px-4 py-2 text-muted-foreground\",\n className,\n )}\n >\n {!summary ? (\n <span className=\"font-sans\">{placeholder}</span>\n ) : children ? (\n children(summary)\n ) : (\n <>\n <span>\n Avg <span className=\"text-foreground\">{formatPrice(summary.averagePrice)}</span>\n </span>\n <span>\n <span className=\"text-foreground\">\n {formatSize(summary.size)}\n {baseSymbol && ` ${baseSymbol}`}\n </span>\n {\" · \"}\n {formatPrice(summary.quote)}\n {quoteSymbol && ` ${quoteSymbol}`}\n </span>\n </>\n )}\n </p>\n );\n}\n"],"mappings":";;;;;;;;AAGA,SAAS,QAAQ,QAA0B,MAAqB,OAA6B;CAC3F,MAAM,yBAAS,IAAI,IAAoB;CACvC,KAAK,MAAM,EAAE,OAAO,UAAU,QAAQ;EACpC,IAAI,CAAC,OAAO,SAAS,KAAK,KAAK,CAAC,OAAO,SAAS,IAAI,KAAK,SAAS,KAAK,QAAQ,GAAG;EAClF,OAAO,IAAI,QAAQ,OAAO,IAAI,KAAK,KAAK,KAAK,IAAI;CACnD;CACA,IAAI,QAAQ;CACZ,OAAO,CAAC,GAAG,MAAM,CAAC,CACf,MAAM,CAAC,IAAI,CAAC,OAAQ,SAAS,QAAQ,IAAI,IAAI,IAAI,CAAE,CAAC,CACpD,MAAM,GAAG,KAAK,CAAC,CACf,KAAK,CAAC,OAAO,UAAU;EACtB,SAAS;EACT,OAAO;GAAE;GAAO;GAAM;EAAM;CAC9B,CAAC;AACL;;AAeA,SAAgB,eAAe,QAA+B,MAAmC;CAC/F,MAAM,OAAO,OAAO,QAAQ,KAAK,UAAU,MAA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,YAAY;EAAQ,CAAA,CAC3E,EAAA,CAAA,GACN,qBAAC,QAAD,EAAA,UAAA;GACE,qBAAC,QAAD;IAAM,WAAU;IAAhB,UAAA,CACG,WAAW,QAAQ,IAAI,GACvB,cAAc,IAAI,YACf;;GACL;GACA,YAAY,QAAQ,KAAK;GACzB,eAAe,IAAI;EAChB,EAAA,CAAA,CACN,EAAA,CAAA;CAEH,CAAA;AAEP"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Tooltip } from "
|
|
2
|
+
import { t as Tooltip } from "../../../tooltip-Bam5KeYe.js";
|
|
3
3
|
import { c as ink, n as usePriceTargetFan } from "../../../context-Rl5VCYA8.js";
|
|
4
4
|
import { useState } from "react";
|
|
5
5
|
import { cn } from "@kumix/utils";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Tooltip } from "
|
|
2
|
+
import { t as Tooltip } from "../../../tooltip-Bam5KeYe.js";
|
|
3
3
|
import { NumberTicker } from "../../motion/number-ticker.js";
|
|
4
4
|
import { l as ink, n as useReturnsCalendar } from "../../../context-Cn-00gfW.js";
|
|
5
5
|
import { useMemo, useState } from "react";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Tooltip } from "
|
|
2
|
+
import { t as Tooltip } from "../../../tooltip-Bam5KeYe.js";
|
|
3
3
|
import { r as useStatusBar } from "../../../context-BE60udRT.js";
|
|
4
4
|
import { cn } from "@kumix/utils";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Tooltip } from "
|
|
2
|
+
import { t as Tooltip } from "../../../tooltip-Bam5KeYe.js";
|
|
3
3
|
import { NumberTicker } from "../../motion/number-ticker.js";
|
|
4
4
|
import { n as useTreemap } from "../../../context-Bc6VC1HA.js";
|
|
5
5
|
import { cn } from "@kumix/utils";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Tooltip } from "
|
|
2
|
+
import { t as Tooltip } from "../../../tooltip-Bam5KeYe.js";
|
|
3
3
|
import { NumberTicker } from "../../motion/number-ticker.js";
|
|
4
4
|
import { n as useVolumeProfile } from "../../../context-3_vY1jbv.js";
|
|
5
5
|
import { cn } from "@kumix/utils";
|
|
@@ -12,4 +12,5 @@ interface ConfirmDialogProps {
|
|
|
12
12
|
export declare function ConfirmDialog({ open, onOpenChange, onConfirm, title, description, confirmText, cancelText, loading }: ConfirmDialogProps): import("react").JSX.Element;
|
|
13
13
|
export declare function ConfirmSignOut({ open, onOpenChange, onConfirm, title, description, confirmText, cancelText, loading }: ConfirmDialogProps): import("react").JSX.Element;
|
|
14
14
|
//#endregion
|
|
15
|
+
export {};
|
|
15
16
|
//# sourceMappingURL=confirm-dialog.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-swap.d.ts","names":[],"sources":["../../../src/components/motion/action-swap.tsx"],"mappings":";;;YAeY;EACV;EACA,OAAO;EACP,OAAO;EACP;;YAGU;YACA;YACA;iBAKK,8BACP,KAAK;EACb,OAAO;EACP;EACA;EACA,iBAAiB,eAAe,MAAM;EACtC,UAAU;EACV,OAAO;EACP,YAAY;EACZ;EACA;;iBAGe;EACf;EACA,UAAU;EACV,YAAY;EACZ;;iBAGe;EACf;EACA,UAAU;EACV,YAAY;EACZ;;wBA+Gc,iBACd,OACA,UACA,WACA,aACC,sCAAmB,IAAA;
|
|
1
|
+
{"version":3,"file":"action-swap.d.ts","names":[],"sources":["../../../src/components/motion/action-swap.tsx"],"mappings":";;;YAeY;EACV;EACA,OAAO;EACP,OAAO;EACP;;YAGU;YACA;YACA;iBAKK,8BACP,KAAK;EACb,OAAO;EACP;EACA;EACA,iBAAiB,eAAe,MAAM;EACtC,UAAU;EACV,OAAO;EACP,YAAY;EACZ;EACA;;iBAGe;EACf;EACA,UAAU;EACV,YAAY;EACZ;;iBAGe;EACf;EACA,UAAU;EACV,YAAY;EACZ;;wBA+Gc,iBACd,OACA,UACA,WACA,aACC,sCAAmB,IAAA;wBAgFN,iBACd,OACA,UACA,WACA,aACC,sCAAmB,IAAA;wBA0BN,mBACd,OACA,OACA,cACA,eACA,SACA,MACA,WACA,UACA,OACA,WACA,UACA,YACG,QACF,wCAAqB,IAAA"}
|
|
@@ -167,6 +167,9 @@ function ActionSwapText({ value, children, animation = "blur", className }) {
|
|
|
167
167
|
children: label.split("").map((char, i) => /* @__PURE__ */ jsx(motion.span, {
|
|
168
168
|
custom: i * CASCADE_STAGGER,
|
|
169
169
|
variants: CASCADE_LETTER_VARIANTS,
|
|
170
|
+
initial: "initial",
|
|
171
|
+
animate: "animate",
|
|
172
|
+
exit: "exit",
|
|
170
173
|
className: "inline-block whitespace-pre will-change-[opacity,filter,transform]",
|
|
171
174
|
children: char
|
|
172
175
|
}, i))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-swap.js","names":[],"sources":["../../../src/components/motion/action-swap.tsx"],"sourcesContent":["\"use client\";\n\nimport type { ReactNode } from \"react\";\nimport { useState } from \"react\";\nimport {\n AnimatePresence,\n type HTMLMotionProps,\n motion,\n useReducedMotion,\n type Variants,\n} from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT, SPRING_PRESS, SPRING_SWAP } from \"../../lib/ease\";\n\nexport type ActionSwapItem = {\n id: string;\n label: ReactNode;\n icon?: ReactNode;\n ariaLabel?: string;\n};\n\nexport type ActionSwapButtonVariant = \"primary\" | \"secondary\" | \"outline\" | \"ghost\";\nexport type ActionSwapButtonSize = \"sm\" | \"md\" | \"lg\" | \"icon\";\nexport type ActionSwapAnimation = \"blur\" | \"roll\" | \"cascade\";\n\n/** Animations with a single-element variant set (cascade animates per letter). */\ntype CoreAnimation = \"blur\" | \"roll\";\n\nexport interface ActionSwapButtonProps\n extends Omit<HTMLMotionProps<\"button\">, \"children\" | \"onChange\"> {\n items: ActionSwapItem[];\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string, item: ActionSwapItem) => void;\n variant?: ActionSwapButtonVariant;\n size?: ActionSwapButtonSize;\n animation?: ActionSwapAnimation;\n iconOnly?: boolean;\n cycle?: boolean;\n}\n\nexport interface ActionSwapTextProps {\n value: string;\n children: ReactNode;\n animation?: ActionSwapAnimation;\n className?: string;\n}\n\nexport interface ActionSwapIconProps {\n value: string;\n children: ReactNode;\n animation?: ActionSwapAnimation;\n className?: string;\n}\n\nconst BLUR_TRANSITION = { duration: 0.2, ease: \"easeInOut\" } as const;\nconst ROLL_TRANSITION = SPRING_SWAP;\nconst ROLL_EXIT_TRANSITION = { duration: 0.14, ease: EASE_OUT } as const;\nconst SWAP_BLUR = \"blur(8px)\";\nconst ROLL_BLUR = \"blur(3px)\";\n\n// Cascade rolls the label one letter at a time, left to right. The leaving\n// and landing strings overlap as independent layers (no shared cells), so\n// proportional glyph widths never jitter. Exits cascade at half the enter\n// stagger so the tail of the old label lingers briefly.\nconst CASCADE_STAGGER = 0.025;\n\nconst CASCADE_LETTER_VARIANTS: Variants = {\n initial: { opacity: 0, y: \"105%\", filter: ROLL_BLUR },\n animate: (delay: number = 0) => ({\n opacity: 1,\n y: \"0%\",\n filter: \"blur(0px)\",\n transition: { ...SPRING_SWAP, delay },\n }),\n exit: (delay: number = 0) => ({\n opacity: 0,\n y: \"-105%\",\n filter: ROLL_BLUR,\n transition: { duration: 0.16, ease: EASE_OUT, delay: delay * 0.5 },\n }),\n};\n\nconst TEXT_VARIANTS: Record<CoreAnimation, Variants> = {\n blur: {\n initial: { opacity: 0, scale: 0.94, filter: SWAP_BLUR },\n animate: {\n opacity: 1,\n scale: 1,\n filter: \"blur(0px)\",\n transition: BLUR_TRANSITION,\n },\n exit: {\n opacity: 0,\n scale: 0.94,\n filter: SWAP_BLUR,\n transition: BLUR_TRANSITION,\n },\n },\n roll: {\n initial: { opacity: 0, y: \"90%\", filter: ROLL_BLUR },\n animate: {\n opacity: 1,\n y: \"0%\",\n filter: \"blur(0px)\",\n transition: ROLL_TRANSITION,\n },\n exit: {\n opacity: 0,\n y: \"-90%\",\n filter: ROLL_BLUR,\n transition: ROLL_EXIT_TRANSITION,\n },\n },\n};\n\nconst ICON_VARIANTS: Record<CoreAnimation, Variants> = {\n blur: {\n initial: { opacity: 0, scale: 0.25, filter: SWAP_BLUR },\n animate: {\n opacity: 1,\n scale: 1,\n filter: \"blur(0px)\",\n transition: BLUR_TRANSITION,\n },\n exit: {\n opacity: 0,\n scale: 0.25,\n filter: SWAP_BLUR,\n transition: BLUR_TRANSITION,\n },\n },\n roll: {\n initial: { opacity: 0, y: 12, filter: ROLL_BLUR },\n animate: {\n opacity: 1,\n y: 0,\n filter: \"blur(0px)\",\n transition: ROLL_TRANSITION,\n },\n exit: {\n opacity: 0,\n y: -12,\n filter: ROLL_BLUR,\n transition: ROLL_EXIT_TRANSITION,\n },\n },\n};\n\nconst VARIANT_CLASS: Record<ActionSwapButtonVariant, string> = {\n primary: \"bg-primary text-primary-foreground hover:bg-primary/90\",\n secondary: \"border border-border bg-card text-foreground hover:border-border\",\n outline: \"border border-border bg-transparent text-foreground hover:bg-muted/60\",\n ghost: \"text-muted-foreground hover:bg-muted/60 hover:text-foreground\",\n};\n\nconst SIZE_CLASS: Record<ActionSwapButtonSize, string> = {\n sm: \"h-8 gap-1.5 rounded-full px-3 text-xs\",\n md: \"h-10 gap-2 rounded-full px-4 text-sm\",\n lg: \"h-12 gap-2.5 rounded-full px-5 text-base\",\n icon: \"h-10 w-10 rounded-full\",\n};\n\nexport function ActionSwapText({\n value,\n children,\n animation = \"blur\",\n className,\n}: ActionSwapTextProps) {\n const reduce = useReducedMotion();\n\n // Cascade needs a plain string to split into letters; non-string content\n // and reduced motion fall back to the closest single-element animation.\n const label = typeof children === \"string\" ? children : null;\n const cascade = animation === \"cascade\" && label !== null && !reduce;\n const coreAnimation: CoreAnimation = animation === \"cascade\" ? \"roll\" : animation;\n\n return (\n <span\n className={cn(\n \"relative -my-[0.08em] inline-block max-w-full whitespace-nowrap py-[0.08em] align-bottom\",\n className,\n )}\n style={{\n clipPath: \"inset(0 -999px)\",\n WebkitClipPath: \"inset(0 -999px)\",\n }}\n >\n <span aria-hidden className=\"invisible inline-block whitespace-nowrap\">\n {cascade\n ? label.split(\"\").map((char, index) => (\n <span key={index} className=\"inline-block whitespace-pre\">\n {char}\n </span>\n ))\n : children}\n </span>\n {cascade ? (\n <>\n {/* Letters are decorative fragments; readers get the whole label. */}\n <span className=\"sr-only\">{label}</span>\n <AnimatePresence initial={false}>\n <motion.span\n key={`cascade-${value}`}\n aria-hidden\n initial=\"initial\"\n animate=\"animate\"\n exit=\"exit\"\n className=\"absolute top-[0.08em] left-0 inline-block whitespace-pre\"\n >\n {label.split(\"\").map((char, i) => (\n <motion.span\n key={i}\n custom={i * CASCADE_STAGGER}\n variants={CASCADE_LETTER_VARIANTS}\n className=\"inline-block whitespace-pre will-change-[opacity,filter,transform]\"\n >\n {char}\n </motion.span>\n ))}\n </motion.span>\n </AnimatePresence>\n </>\n ) : (\n <AnimatePresence initial={false}>\n <motion.span\n key={`${animation}-${value}`}\n variants={TEXT_VARIANTS[coreAnimation]}\n initial={reduce ? false : \"initial\"}\n animate={reduce ? { opacity: 1, filter: \"blur(0px)\", scale: 1, y: 0 } : \"animate\"}\n exit={reduce ? undefined : \"exit\"}\n // Truncation lives on the layer that holds the text — the layer\n // moves as a whole, so clipping it never eats the roll.\n className=\"absolute top-[0.08em] left-0 inline-block max-w-full truncate will-change-[opacity,filter,transform]\"\n >\n {children}\n </motion.span>\n </AnimatePresence>\n )}\n </span>\n );\n}\n\nexport function ActionSwapIcon({\n value,\n children,\n animation = \"blur\",\n className,\n}: ActionSwapIconProps) {\n const reduce = useReducedMotion();\n // Icons are single elements — cascade maps to its closest motion, roll.\n const coreAnimation: CoreAnimation = animation === \"cascade\" ? \"roll\" : animation;\n\n return (\n <span\n className={cn(\"relative inline-grid shrink-0 place-items-center overflow-hidden\", className)}\n >\n <AnimatePresence mode=\"popLayout\" initial={false}>\n <motion.span\n key={`${animation}-${value}`}\n aria-hidden\n variants={ICON_VARIANTS[coreAnimation]}\n initial={reduce ? false : \"initial\"}\n animate={reduce ? { opacity: 1, filter: \"blur(0px)\", scale: 1, y: 0 } : \"animate\"}\n exit={reduce ? undefined : \"exit\"}\n className=\"col-start-1 row-start-1 inline-flex items-center justify-center will-change-[opacity,filter,transform]\"\n >\n {children}\n </motion.span>\n </AnimatePresence>\n </span>\n );\n}\n\nexport function ActionSwapButton({\n items,\n value,\n defaultValue,\n onValueChange,\n variant = \"secondary\",\n size = \"md\",\n animation = \"blur\",\n iconOnly = size === \"icon\",\n cycle = true,\n className,\n disabled,\n onClick,\n ...rest\n}: ActionSwapButtonProps) {\n const reduce = useReducedMotion();\n const [internalValue, setInternalValue] = useState(defaultValue ?? items[0]?.id);\n const currentValue = value ?? internalValue;\n const activeIndex = Math.max(\n 0,\n items.findIndex((item) => item.id === currentValue),\n );\n const activeItem = items[activeIndex] ?? items[0];\n const hasIcon = items.some((item) => item.icon);\n const nextItem = cycle && items.length > 0 ? items[(activeIndex + 1) % items.length] : undefined;\n\n if (!activeItem) return null;\n\n const accessibleLabel =\n activeItem.ariaLabel ??\n (iconOnly && typeof activeItem.label === \"string\" ? activeItem.label : undefined);\n\n return (\n <motion.button\n type=\"button\"\n disabled={disabled}\n whileTap={reduce || disabled ? undefined : { scale: 0.97 }}\n transition={SPRING_PRESS}\n className={cn(\n \"inline-flex items-center justify-center overflow-hidden font-medium transition-colors\",\n \"disabled:pointer-events-none disabled:opacity-50\",\n VARIANT_CLASS[variant],\n SIZE_CLASS[size],\n className,\n )}\n aria-label={accessibleLabel}\n onClick={(event) => {\n onClick?.(event);\n if (event.defaultPrevented || disabled || !cycle || !nextItem) return;\n if (value === undefined) setInternalValue(nextItem.id);\n onValueChange?.(nextItem.id, nextItem);\n }}\n {...rest}\n >\n {hasIcon ? (\n <ActionSwapIcon value={activeItem.id} animation={animation} className=\"h-4 w-4\">\n {activeItem.icon ?? null}\n </ActionSwapIcon>\n ) : null}\n {!iconOnly ? (\n <ActionSwapText value={activeItem.id} animation={animation}>\n {activeItem.label}\n </ActionSwapText>\n ) : null}\n </motion.button>\n );\n}\n"],"mappings":";;;;;;;AAwDA,MAAM,kBAAkB;CAAE,UAAU;CAAK,MAAM;AAAY;AAC3D,MAAM,kBAAkB;AACxB,MAAM,uBAAuB;CAAE,UAAU;CAAM,MAAM;AAAS;AAC9D,MAAM,YAAY;AAClB,MAAM,YAAY;AAMlB,MAAM,kBAAkB;AAExB,MAAM,0BAAoC;CACxC,SAAS;EAAE,SAAS;EAAG,GAAG;EAAQ,QAAQ;CAAU;CACpD,UAAU,QAAgB,OAAO;EAC/B,SAAS;EACT,GAAG;EACH,QAAQ;EACR,YAAY;GAAE,GAAG;GAAa;EAAM;CACtC;CACA,OAAO,QAAgB,OAAO;EAC5B,SAAS;EACT,GAAG;EACH,QAAQ;EACR,YAAY;GAAE,UAAU;GAAM,MAAM;GAAU,OAAO,QAAQ;EAAI;CACnE;AACF;AAEA,MAAM,gBAAiD;CACrD,MAAM;EACJ,SAAS;GAAE,SAAS;GAAG,OAAO;GAAM,QAAQ;EAAU;EACtD,SAAS;GACP,SAAS;GACT,OAAO;GACP,QAAQ;GACR,YAAY;EACd;EACA,MAAM;GACJ,SAAS;GACT,OAAO;GACP,QAAQ;GACR,YAAY;EACd;CACF;CACA,MAAM;EACJ,SAAS;GAAE,SAAS;GAAG,GAAG;GAAO,QAAQ;EAAU;EACnD,SAAS;GACP,SAAS;GACT,GAAG;GACH,QAAQ;GACR,YAAY;EACd;EACA,MAAM;GACJ,SAAS;GACT,GAAG;GACH,QAAQ;GACR,YAAY;EACd;CACF;AACF;AAEA,MAAM,gBAAiD;CACrD,MAAM;EACJ,SAAS;GAAE,SAAS;GAAG,OAAO;GAAM,QAAQ;EAAU;EACtD,SAAS;GACP,SAAS;GACT,OAAO;GACP,QAAQ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,OAAO,YAAY,CACpD;CACA,MAAM,aAAa,MAAM,gBAAgB,MAAM;CAC/C,MAAM,UAAU,MAAM,MAAM,SAAS,KAAK,IAAI;CAC9C,MAAM,WAAW,SAAS,MAAM,SAAS,IAAI,OAAO,cAAc,KAAK,MAAM,UAAU,KAAA;CAEvF,IAAI,CAAC,YAAY,OAAO;CAExB,MAAM,kBACJ,WAAW,cACV,YAAY,OAAO,WAAW,UAAU,WAAW,WAAW,QAAQ,KAAA;CAEzE,OACE,qBAAC,OAAO,QAAR;EACE,MAAK;EACK;EACV,UAAU,UAAU,WAAW,KAAA,IAAY,EAAE,OAAO,IAAK;EACzD,YAAY;EACZ,WAAW,GACT,yFACA,oDACA,cAAc,UACd,WAAW,OACX,SACF;EACA,cAAY;EACZ,UAAU,UAAU;GAClB,UAAU,KAAK;GACf,IAAI,MAAM,oBAAoB,YAAY,CAAC,SAAS,CAAC,UAAU;GAC/D,IAAI,UAAU,KAAA,GAAW,iBAAiB,SAAS,EAAE;GACrD,gBAAgB,SAAS,IAAI,QAAQ;EACvC;EACA,GAAI;EAnBN,UAAA,CAqBG,UACC,oBAAC,gBAAD;GAAgB,OAAO,WAAW;GAAe;GAAW,WAAU;GACnE,UAAA,WAAW,QAAQ;EACN,CAAA,IACd,MACH,CAAC,WACA,oBAAC,gBAAD;GAAgB,OAAO,WAAW;GAAe;GAC9C,UAAA,WAAW;EACE,CAAA,IACd,IACS;;AAEnB"}
|
|
1
|
+
{"version":3,"file":"action-swap.js","names":[],"sources":["../../../src/components/motion/action-swap.tsx"],"sourcesContent":["\"use client\";\n\nimport type { ReactNode } from \"react\";\nimport { useState } from \"react\";\nimport {\n AnimatePresence,\n type HTMLMotionProps,\n motion,\n useReducedMotion,\n type Variants,\n} from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT, SPRING_PRESS, SPRING_SWAP } from \"../../lib/ease\";\n\nexport type ActionSwapItem = {\n id: string;\n label: ReactNode;\n icon?: ReactNode;\n ariaLabel?: string;\n};\n\nexport type ActionSwapButtonVariant = \"primary\" | \"secondary\" | \"outline\" | \"ghost\";\nexport type ActionSwapButtonSize = \"sm\" | \"md\" | \"lg\" | \"icon\";\nexport type ActionSwapAnimation = \"blur\" | \"roll\" | \"cascade\";\n\n/** Animations with a single-element variant set (cascade animates per letter). */\ntype CoreAnimation = \"blur\" | \"roll\";\n\nexport interface ActionSwapButtonProps\n extends Omit<HTMLMotionProps<\"button\">, \"children\" | \"onChange\"> {\n items: ActionSwapItem[];\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string, item: ActionSwapItem) => void;\n variant?: ActionSwapButtonVariant;\n size?: ActionSwapButtonSize;\n animation?: ActionSwapAnimation;\n iconOnly?: boolean;\n cycle?: boolean;\n}\n\nexport interface ActionSwapTextProps {\n value: string;\n children: ReactNode;\n animation?: ActionSwapAnimation;\n className?: string;\n}\n\nexport interface ActionSwapIconProps {\n value: string;\n children: ReactNode;\n animation?: ActionSwapAnimation;\n className?: string;\n}\n\nconst BLUR_TRANSITION = { duration: 0.2, ease: \"easeInOut\" } as const;\nconst ROLL_TRANSITION = SPRING_SWAP;\nconst ROLL_EXIT_TRANSITION = { duration: 0.14, ease: EASE_OUT } as const;\nconst SWAP_BLUR = \"blur(8px)\";\nconst ROLL_BLUR = \"blur(3px)\";\n\n// Cascade rolls the label one letter at a time, left to right. The leaving\n// and landing strings overlap as independent layers (no shared cells), so\n// proportional glyph widths never jitter. Exits cascade at half the enter\n// stagger so the tail of the old label lingers briefly.\nconst CASCADE_STAGGER = 0.025;\n\nconst CASCADE_LETTER_VARIANTS: Variants = {\n initial: { opacity: 0, y: \"105%\", filter: ROLL_BLUR },\n animate: (delay: number = 0) => ({\n opacity: 1,\n y: \"0%\",\n filter: \"blur(0px)\",\n transition: { ...SPRING_SWAP, delay },\n }),\n exit: (delay: number = 0) => ({\n opacity: 0,\n y: \"-105%\",\n filter: ROLL_BLUR,\n transition: { duration: 0.16, ease: EASE_OUT, delay: delay * 0.5 },\n }),\n};\n\nconst TEXT_VARIANTS: Record<CoreAnimation, Variants> = {\n blur: {\n initial: { opacity: 0, scale: 0.94, filter: SWAP_BLUR },\n animate: {\n opacity: 1,\n scale: 1,\n filter: \"blur(0px)\",\n transition: BLUR_TRANSITION,\n },\n exit: {\n opacity: 0,\n scale: 0.94,\n filter: SWAP_BLUR,\n transition: BLUR_TRANSITION,\n },\n },\n roll: {\n initial: { opacity: 0, y: \"90%\", filter: ROLL_BLUR },\n animate: {\n opacity: 1,\n y: \"0%\",\n filter: \"blur(0px)\",\n transition: ROLL_TRANSITION,\n },\n exit: {\n opacity: 0,\n y: \"-90%\",\n filter: ROLL_BLUR,\n transition: ROLL_EXIT_TRANSITION,\n },\n },\n};\n\nconst ICON_VARIANTS: Record<CoreAnimation, Variants> = {\n blur: {\n initial: { opacity: 0, scale: 0.25, filter: SWAP_BLUR },\n animate: {\n opacity: 1,\n scale: 1,\n filter: \"blur(0px)\",\n transition: BLUR_TRANSITION,\n },\n exit: {\n opacity: 0,\n scale: 0.25,\n filter: SWAP_BLUR,\n transition: BLUR_TRANSITION,\n },\n },\n roll: {\n initial: { opacity: 0, y: 12, filter: ROLL_BLUR },\n animate: {\n opacity: 1,\n y: 0,\n filter: \"blur(0px)\",\n transition: ROLL_TRANSITION,\n },\n exit: {\n opacity: 0,\n y: -12,\n filter: ROLL_BLUR,\n transition: ROLL_EXIT_TRANSITION,\n },\n },\n};\n\nconst VARIANT_CLASS: Record<ActionSwapButtonVariant, string> = {\n primary: \"bg-primary text-primary-foreground hover:bg-primary/90\",\n secondary: \"border border-border bg-card text-foreground hover:border-border\",\n outline: \"border border-border bg-transparent text-foreground hover:bg-muted/60\",\n ghost: \"text-muted-foreground hover:bg-muted/60 hover:text-foreground\",\n};\n\nconst SIZE_CLASS: Record<ActionSwapButtonSize, string> = {\n sm: \"h-8 gap-1.5 rounded-full px-3 text-xs\",\n md: \"h-10 gap-2 rounded-full px-4 text-sm\",\n lg: \"h-12 gap-2.5 rounded-full px-5 text-base\",\n icon: \"h-10 w-10 rounded-full\",\n};\n\nexport function ActionSwapText({\n value,\n children,\n animation = \"blur\",\n className,\n}: ActionSwapTextProps) {\n const reduce = useReducedMotion();\n\n // Cascade needs a plain string to split into letters; non-string content\n // and reduced motion fall back to the closest single-element animation.\n const label = typeof children === \"string\" ? children : null;\n const cascade = animation === \"cascade\" && label !== null && !reduce;\n const coreAnimation: CoreAnimation = animation === \"cascade\" ? \"roll\" : animation;\n\n return (\n <span\n className={cn(\n \"relative -my-[0.08em] inline-block max-w-full whitespace-nowrap py-[0.08em] align-bottom\",\n className,\n )}\n style={{\n clipPath: \"inset(0 -999px)\",\n WebkitClipPath: \"inset(0 -999px)\",\n }}\n >\n <span aria-hidden className=\"invisible inline-block whitespace-nowrap\">\n {cascade\n ? label.split(\"\").map((char, index) => (\n <span key={index} className=\"inline-block whitespace-pre\">\n {char}\n </span>\n ))\n : children}\n </span>\n {cascade ? (\n <>\n {/* Letters are decorative fragments; readers get the whole label. */}\n <span className=\"sr-only\">{label}</span>\n <AnimatePresence initial={false}>\n <motion.span\n key={`cascade-${value}`}\n aria-hidden\n initial=\"initial\"\n animate=\"animate\"\n exit=\"exit\"\n className=\"absolute top-[0.08em] left-0 inline-block whitespace-pre\"\n >\n {label.split(\"\").map((char, i) => (\n <motion.span\n key={i}\n custom={i * CASCADE_STAGGER}\n variants={CASCADE_LETTER_VARIANTS}\n // Own states: a label that swaps away and straight back\n // re-enters mid-exit, and only owned targets are restored.\n initial=\"initial\"\n animate=\"animate\"\n exit=\"exit\"\n className=\"inline-block whitespace-pre will-change-[opacity,filter,transform]\"\n >\n {char}\n </motion.span>\n ))}\n </motion.span>\n </AnimatePresence>\n </>\n ) : (\n <AnimatePresence initial={false}>\n <motion.span\n key={`${animation}-${value}`}\n variants={TEXT_VARIANTS[coreAnimation]}\n initial={reduce ? false : \"initial\"}\n animate={reduce ? { opacity: 1, filter: \"blur(0px)\", scale: 1, y: 0 } : \"animate\"}\n exit={reduce ? undefined : \"exit\"}\n // Truncation lives on the layer that holds the text — the layer\n // moves as a whole, so clipping it never eats the roll.\n className=\"absolute top-[0.08em] left-0 inline-block max-w-full truncate will-change-[opacity,filter,transform]\"\n >\n {children}\n </motion.span>\n </AnimatePresence>\n )}\n </span>\n );\n}\n\nexport function ActionSwapIcon({\n value,\n children,\n animation = \"blur\",\n className,\n}: ActionSwapIconProps) {\n const reduce = useReducedMotion();\n // Icons are single elements — cascade maps to its closest motion, roll.\n const coreAnimation: CoreAnimation = animation === \"cascade\" ? \"roll\" : animation;\n\n return (\n <span\n className={cn(\"relative inline-grid shrink-0 place-items-center overflow-hidden\", className)}\n >\n <AnimatePresence mode=\"popLayout\" initial={false}>\n <motion.span\n key={`${animation}-${value}`}\n aria-hidden\n variants={ICON_VARIANTS[coreAnimation]}\n initial={reduce ? false : \"initial\"}\n animate={reduce ? { opacity: 1, filter: \"blur(0px)\", scale: 1, y: 0 } : \"animate\"}\n exit={reduce ? undefined : \"exit\"}\n className=\"col-start-1 row-start-1 inline-flex items-center justify-center will-change-[opacity,filter,transform]\"\n >\n {children}\n </motion.span>\n </AnimatePresence>\n </span>\n );\n}\n\nexport function ActionSwapButton({\n items,\n value,\n defaultValue,\n onValueChange,\n variant = \"secondary\",\n size = \"md\",\n animation = \"blur\",\n iconOnly = size === \"icon\",\n cycle = true,\n className,\n disabled,\n onClick,\n ...rest\n}: ActionSwapButtonProps) {\n const reduce = useReducedMotion();\n const [internalValue, setInternalValue] = useState(defaultValue ?? items[0]?.id);\n const currentValue = value ?? internalValue;\n const activeIndex = Math.max(\n 0,\n items.findIndex((item) => item.id === currentValue),\n );\n const activeItem = items[activeIndex] ?? items[0];\n const hasIcon = items.some((item) => item.icon);\n const nextItem = cycle && items.length > 0 ? items[(activeIndex + 1) % items.length] : undefined;\n\n if (!activeItem) return null;\n\n const accessibleLabel =\n activeItem.ariaLabel ??\n (iconOnly && typeof activeItem.label === \"string\" ? activeItem.label : undefined);\n\n return (\n <motion.button\n type=\"button\"\n disabled={disabled}\n whileTap={reduce || disabled ? undefined : { scale: 0.97 }}\n transition={SPRING_PRESS}\n className={cn(\n \"inline-flex items-center justify-center overflow-hidden font-medium transition-colors\",\n \"disabled:pointer-events-none disabled:opacity-50\",\n VARIANT_CLASS[variant],\n SIZE_CLASS[size],\n className,\n )}\n aria-label={accessibleLabel}\n onClick={(event) => {\n onClick?.(event);\n if (event.defaultPrevented || disabled || !cycle || !nextItem) return;\n if (value === undefined) setInternalValue(nextItem.id);\n onValueChange?.(nextItem.id, nextItem);\n }}\n {...rest}\n >\n {hasIcon ? (\n <ActionSwapIcon value={activeItem.id} animation={animation} className=\"h-4 w-4\">\n {activeItem.icon ?? null}\n </ActionSwapIcon>\n ) : null}\n {!iconOnly ? (\n <ActionSwapText value={activeItem.id} animation={animation}>\n {activeItem.label}\n </ActionSwapText>\n ) : null}\n </motion.button>\n );\n}\n"],"mappings":";;;;;;;AAwDA,MAAM,kBAAkB;CAAE,UAAU;CAAK,MAAM;AAAY;AAC3D,MAAM,kBAAkB;AACxB,MAAM,uBAAuB;CAAE,UAAU;CAAM,MAAM;AAAS;AAC9D,MAAM,YAAY;AAClB,MAAM,YAAY;AAMlB,MAAM,kBAAkB;AAExB,MAAM,0BAAoC;CACxC,SAAS;EAAE,SAAS;EAAG,GAAG;EAAQ,QAAQ;CAAU;CACpD,UAAU,QAAgB,OAAO;EAC/B,SAAS;EACT,GAAG;EACH,QAAQ;EACR,YAAY;GAAE,GAAG;GAAa;EAAM;CACtC;CACA,OAAO,QAAgB,OAAO;EAC5B,SAAS;EACT,GAAG;EACH,QAAQ;EACR,YAAY;GAAE,UAAU;GAAM,MAAM;GAAU,OAAO,QAAQ;EAAI;CACnE;AACF;AAEA,MAAM,gBAAiD;CACrD,MAAM;EACJ,SAAS;GAAE,SAAS;GAAG,OAAO;GAAM,QAAQ;EAAU;EACtD,SAAS;GACP,SAAS;GACT,OAAO;GACP,QAAQ;GACR,YAAY;EACd;EACA,MAAM;GACJ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D;GAAgB,OAAO,WAAW;GAAe;GAC9C,UAAA,WAAW;EACE,CAAA,IACd,IACS;;AAEnB"}
|
|
@@ -93,4 +93,5 @@ export interface AnimatedSidebarMenuButtonProps {
|
|
|
93
93
|
}
|
|
94
94
|
export declare function AnimatedSidebarMenuButton({ children, icon, badge, href, isActive, ariaExpanded, disabled, closeOnSelect, target, rel, onSelect, className }: AnimatedSidebarMenuButtonProps): import("react").JSX.Element;
|
|
95
95
|
//#endregion
|
|
96
|
+
export {};
|
|
96
97
|
//# sourceMappingURL=animated-sidebar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment-upload.d.ts","names":[],"sources":["../../../src/components/motion/attachment-upload.tsx"],"mappings":";YA0BY;YACA;YACA;YAEA;EACV;EACA;EACA,MAAM;EACN;EACA;EACA;EACA;EACA;EACA,SAAS;EACT;EACA,OAAO;;YAGG;EACV;EACA;EACA;;iBAGe;EACf,QAAQ;EACR,eAAe;EACf,iBAAiB,OAAO;EACxB,gBAAgB,OAAO,wBAAwB,OAAO;EACtD,mBAAmB,OAAO,QAAQ,QAAQ;EAC1C,YAAY,MAAM;EAClB,WAAW,MAAM;EACjB;EACA,iBAAiB,MAAM;EACvB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,aAAa;;
|
|
1
|
+
{"version":3,"file":"attachment-upload.d.ts","names":[],"sources":["../../../src/components/motion/attachment-upload.tsx"],"mappings":";YA0BY;YACA;YACA;YAEA;EACV;EACA;EACA,MAAM;EACN;EACA;EACA;EACA;EACA;EACA,SAAS;EACT;EACA,OAAO;;YAGG;EACV;EACA;EACA;;iBAGe;EACf,QAAQ;EACR,eAAe;EACf,iBAAiB,OAAO;EACxB,gBAAgB,OAAO,wBAAwB,OAAO;EACtD,mBAAmB,OAAO,QAAQ,QAAQ;EAC1C,YAAY,MAAM;EAClB,WAAW,MAAM;EACjB;EACA,iBAAiB,MAAM;EACvB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,aAAa;;wBAskBC,mBACd,OACA,cACA,eACA,cACA,iBACA,UACA,SACA,WACA,eACA,QACA,UACA,UACA,aACA,UACA,OACA,aACA,kBACA,WACA,cACC,wCAAqB,IAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { EASE_OUT, SPRING_LAYOUT, SPRING_PRESS } from "../../lib/ease.js";
|
|
3
|
-
import { Tooltip } from "
|
|
3
|
+
import { t as Tooltip } from "../../tooltip-Bam5KeYe.js";
|
|
4
4
|
import { t as PresenceGate } from "../../presence-gate-BekdC4Bo.js";
|
|
5
5
|
import { useCallback, useEffect, useId, useRef, useState } from "react";
|
|
6
6
|
import { cn } from "@kumix/utils";
|
|
@@ -190,7 +190,6 @@ function ImageThumbnail({ item, layoutId, onPreview, reduce }) {
|
|
|
190
190
|
return /* @__PURE__ */ jsx(Tooltip, {
|
|
191
191
|
side: "top",
|
|
192
192
|
delay: 160,
|
|
193
|
-
wrapperClassName: "shrink-0",
|
|
194
193
|
className: "rounded-xl p-1 shadow-xl",
|
|
195
194
|
content: /* @__PURE__ */ jsxs("span", {
|
|
196
195
|
className: "block w-32",
|