@ngrok/mantle 0.93.7 → 0.94.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 +11 -2
- package/dist/accordion.d.ts +73 -21
- package/dist/accordion.js +1 -1
- package/dist/agent.json +1234 -84
- package/dist/alert-BkJHDx9X.js +1 -0
- package/dist/{alert-BcSBNR3S.d.ts → alert-D0zRRUHV.d.ts} +35 -25
- package/dist/alert-center.d.ts +67 -55
- package/dist/alert-center.js +1 -1
- package/dist/alert-dialog.d.ts +35 -10
- package/dist/alert-dialog.js +1 -1
- package/dist/alert.d.ts +6 -1
- package/dist/alert.js +1 -1
- package/dist/anchor-Dc6IgvXV.js +1 -0
- package/dist/anchor.d.ts +17 -5
- package/dist/anchor.js +1 -1
- package/dist/app-layout.d.ts +33 -18
- package/dist/app-layout.js +1 -1
- package/dist/area-chart.d.ts +153 -97
- package/dist/area-chart.js +1 -1
- package/dist/avatar.d.ts +36 -24
- package/dist/avatar.js +1 -1
- package/dist/badge.d.ts +19 -7
- package/dist/badge.js +1 -1
- package/dist/bar-chart.d.ts +155 -100
- package/dist/bar-chart.js +1 -1
- package/dist/breadcrumb.d.ts +47 -36
- package/dist/breadcrumb.js +1 -1
- package/dist/browser-only-CZfkNw5A.js +1 -0
- package/dist/browser-only-ymFoM3Ya.js +1 -0
- package/dist/browser-only.d.ts +8 -0
- package/dist/browser-only.js +1 -1
- package/dist/{button-BX-4lYUn.d.ts → button-5Pc7Mby_.d.ts} +4 -4
- package/dist/button-B9bChDgl.js +1 -0
- package/dist/button-D8jixIbH.js +1 -0
- package/dist/button-DNLTJ32M.js +1 -0
- package/dist/{button-CPsKGDK0.d.ts → button-Ddj6yr10.d.ts} +34 -27
- package/dist/{button-Yxyu1XMd.d.ts → button-DnYv7IOT.d.ts} +29 -22
- package/dist/button.d.ts +9 -3
- package/dist/button.js +1 -1
- package/dist/calendar.d.ts +8 -1
- package/dist/calendar.js +1 -1
- package/dist/card.d.ts +7 -2
- package/dist/card.js +1 -1
- package/dist/centered-layout.d.ts +34 -23
- package/dist/centered-layout.js +1 -1
- package/dist/chart-BLCqzt56.js +1 -0
- package/dist/chart-CChZiCrt.js +1 -0
- package/dist/chart-CUmSu9d7.js +1 -0
- package/dist/{chart-BpfbtOUN.d.ts → chart-Dl8gFo_D.d.ts} +117 -121
- package/dist/chart-DtgZBAas.js +2 -0
- package/dist/checkbox-Cu5cgZmk.js +1 -0
- package/dist/checkbox.d.ts +15 -2
- package/dist/checkbox.js +1 -1
- package/dist/choice-CCVG2hb9.js +1 -0
- package/dist/{choice-BLR0_MeB.d.ts → choice-CNiOSzqV.d.ts} +26 -20
- package/dist/choice.d.ts +6 -1
- package/dist/choice.js +1 -1
- package/dist/code-BPKNY1_w.js +1 -0
- package/dist/{code-block-BGdV4Yty.d.ts → code-block-BDw6MEwH.d.ts} +9 -9
- package/dist/{code-block-W3kWPxCJ.js → code-block-CKzsAMzj.js} +3 -3
- package/dist/code-block.d.ts +28 -19
- package/dist/code-block.js +1 -1
- package/dist/code-block_highlight-utils.d.ts +6 -1
- package/dist/code-block_highlight-utils.js +1 -1
- package/dist/code.d.ts +16 -3
- package/dist/code.js +1 -1
- package/dist/color-CHZbU1Ww.js +1 -0
- package/dist/color.js +1 -1
- package/dist/combobox.d.ts +42 -28
- package/dist/combobox.js +1 -1
- package/dist/command.d.ts +59 -47
- package/dist/command.js +1 -1
- package/dist/compose-refs-BdRUneoc.js +1 -0
- package/dist/{copy-to-clipboard-DInu78k_.js → copy-to-clipboard-Dd83caRw.js} +1 -1
- package/dist/cx.d.ts +4 -4
- package/dist/cx.js +1 -1
- package/dist/{data-slot-B-LqAcBB.d.ts → data-slot-BW8KQ9Xo.d.ts} +2 -2
- package/dist/data-table.d.ts +83 -52
- package/dist/data-table.js +1 -1
- package/dist/description-list.d.ts +13 -2
- package/dist/description-list.js +1 -1
- package/dist/{dialog-2fRO4ca4.d.ts → dialog-CIEuwNys.d.ts} +32 -8
- package/dist/dialog-CbEEA0fl.d.ts +32 -0
- package/dist/dialog-DmzoDfY3.js +1 -0
- package/dist/dialog.d.ts +7 -2
- package/dist/dialog.js +1 -1
- package/dist/{dropdown-menu-CpjRwMWe.d.ts → dropdown-menu-CeY498yk.d.ts} +41 -33
- package/dist/dropdown-menu-uheL0prz.js +1 -0
- package/dist/dropdown-menu.d.ts +6 -1
- package/dist/dropdown-menu.js +1 -1
- package/dist/empty.d.ts +7 -2
- package/dist/empty.js +1 -1
- package/dist/field-Bpvn4tQp.js +1 -0
- package/dist/{field-V_gnkcmN.d.ts → field-BshcNVe_.d.ts} +1 -1
- package/dist/field-Cai_4c1l.js +1 -0
- package/dist/field.d.ts +53 -42
- package/dist/field.js +1 -1
- package/dist/flag.d.ts +11 -3
- package/dist/flag.js +1 -1
- package/dist/hooks.d.ts +35 -10
- package/dist/hooks.js +1 -1
- package/dist/hover-card.d.ts +25 -14
- package/dist/hover-card.js +1 -1
- package/dist/{icon-CgNqu-fl.d.ts → icon--purqHRo.d.ts} +1 -1
- package/dist/{icon-ByLVhdYq.d.ts → icon-DuIYoyft.d.ts} +8 -2
- package/dist/{icon-DXDyhy2N.d.ts → icon-QCm1ui29.d.ts} +2 -2
- package/dist/icon-xb7d9M7X.js +1 -0
- package/dist/icon.d.ts +8 -3
- package/dist/icon.js +1 -1
- package/dist/icons-DEDCLZ8B.js +1 -0
- package/dist/icons-DXadFwpo.js +1 -0
- package/dist/icons-DcesO4Ng.js +1 -0
- package/dist/icons.d.ts +13 -1
- package/dist/icons.js +1 -1
- package/dist/{in-view-B3nMAzfE.d.ts → in-view-C_daNafg.d.ts} +4 -23
- package/dist/{index-BhfgyurF.d.ts → index-KJ06KK6t.d.ts} +3 -3
- package/dist/input-BjCDSOPA.js +1 -0
- package/dist/{input-Dx5owTCc.d.ts → input-DC4nW0Sr.d.ts} +12 -2
- package/dist/input-fW8QSZEO.js +1 -0
- package/dist/input.d.ts +37 -5
- package/dist/input.js +1 -1
- package/dist/kbd-P1nQshWo.js +1 -0
- package/dist/kbd.d.ts +17 -5
- package/dist/kbd.js +1 -1
- package/dist/label-DO1RlMKl.js +1 -0
- package/dist/{label-Dn5CPJUj.d.ts → label-epgtywRz.d.ts} +14 -8
- package/dist/label.d.ts +6 -1
- package/dist/label.js +1 -1
- package/dist/layer-container-DL4yclOu.js +1 -0
- package/dist/layer-container.d.ts +2 -2
- package/dist/layer-container.js +1 -1
- package/dist/line-chart.d.ts +147 -90
- package/dist/line-chart.js +1 -1
- package/dist/list-cQZPSjfz.js +1 -0
- package/dist/list.d.ts +34 -16
- package/dist/list.js +1 -1
- package/dist/live-region-Dhapu8a5.js +1 -0
- package/dist/live-region.d.ts +15 -2
- package/dist/live-region.js +1 -1
- package/dist/llms.txt +82 -79
- package/dist/main-CHyWYDak.js +1 -0
- package/dist/main.d.ts +13 -1
- package/dist/main.js +1 -1
- package/dist/mantle.css +133 -88
- package/dist/media-object.d.ts +16 -4
- package/dist/media-object.js +1 -1
- package/dist/migrations/0014-chart-named-colors.yml +1389 -0
- package/dist/migrations/0015-segmented-control.yml +788 -0
- package/dist/multi-select.d.ts +42 -29
- package/dist/multi-select.js +1 -1
- package/dist/otp-input.d.ts +20 -8
- package/dist/otp-input.js +1 -1
- package/dist/pagination.d.ts +93 -4
- package/dist/pagination.js +1 -1
- package/dist/{popover-BfB2I9G0.d.ts → popover-Bei0jyfH.d.ts} +87 -12
- package/dist/popover-DhgunktK.js +1 -0
- package/dist/popover-T2EyaqGK.d.ts +1 -0
- package/dist/popover.d.ts +7 -2
- package/dist/popover.js +1 -1
- package/dist/primitive-D8CzV_Ft.js +1 -0
- package/dist/progress.d.ts +28 -11
- package/dist/progress.js +1 -1
- package/dist/qr-code.d.ts +11 -3
- package/dist/qr-code.js +1 -1
- package/dist/query-filter.d.ts +6 -6
- package/dist/query.d.ts +9 -4
- package/dist/query.js +1 -1
- package/dist/radio-group-BJQ6EOqh.d.ts +27 -0
- package/dist/radio-group-BliblUqe.js +1 -0
- package/dist/radio-group-ggEkCi0V.js +1 -0
- package/dist/radio-group.d.ts +21 -100
- package/dist/radio-group.js +1 -1
- package/dist/sandbar.d.ts +43 -30
- package/dist/sandbar.js +1 -1
- package/dist/sandboxed-on-click-D4PL5_GR.js +1 -0
- package/dist/sandboxed-on-click.d.ts +8 -0
- package/dist/sandboxed-on-click.js +1 -1
- package/dist/scatter-plot.d.ts +137 -76
- package/dist/scatter-plot.js +1 -1
- package/dist/segmented-control.d.ts +136 -0
- package/dist/segmented-control.js +1 -0
- package/dist/select-1xuUx_os.js +1 -0
- package/dist/{select-BkhBxtOT.d.ts → select-BpaXHxJm.d.ts} +33 -25
- package/dist/select.d.ts +6 -1
- package/dist/select.js +1 -1
- package/dist/selectable-list.d.ts +29 -18
- package/dist/selectable-list.js +1 -1
- package/dist/{separator-D9AWEkcJ.d.ts → separator-Ck4sPrdN.d.ts} +4 -2
- package/dist/separator-DnvhwY2J.js +1 -0
- package/dist/separator.d.ts +6 -1
- package/dist/separator.js +1 -1
- package/dist/{shake-DL6WhMXM.js → shake-CAUpKBHe.js} +1 -1
- package/dist/sheet-DHy_vlme.js +1 -0
- package/dist/sheet.d.ts +36 -7
- package/dist/sheet.js +1 -1
- package/dist/sidebar.d.ts +53 -37
- package/dist/sidebar.js +1 -1
- package/dist/skeleton-DHfyjuQi.js +1 -0
- package/dist/skeleton.d.ts +15 -4
- package/dist/skeleton.js +1 -1
- package/dist/skip-to-main-link.d.ts +12 -1
- package/dist/skip-to-main-link.js +1 -1
- package/dist/slider.d.ts +11 -1
- package/dist/slider.js +1 -1
- package/dist/slot-B7rwscwd.js +1 -0
- package/dist/{slot-C0OCJjdJ.d.ts → slot-BEMQMbk3.d.ts} +6 -4
- package/dist/slot.d.ts +6 -1
- package/dist/slot.js +1 -1
- package/dist/source-all.css +5 -1
- package/dist/split-button.d.ts +20 -9
- package/dist/split-button.js +1 -1
- package/dist/strata.d.ts +35 -22
- package/dist/strata.js +1 -1
- package/dist/{suggestions-NkqYTT49.d.ts → suggestions-BJeGvwDa.d.ts} +7 -7
- package/dist/switch.d.ts +14 -2
- package/dist/switch.js +1 -1
- package/dist/table-BnLdXUai.js +1 -0
- package/dist/{table-vT6Okwfa.d.ts → table-Ii9hHUWN.d.ts} +84 -5
- package/dist/table.d.ts +6 -1
- package/dist/table.js +1 -1
- package/dist/tabs.d.ts +24 -12
- package/dist/tabs.js +1 -1
- package/dist/text-area.d.ts +12 -2
- package/dist/text-area.js +1 -1
- package/dist/theme-BNdZl352.js +1 -0
- package/dist/theme-switcher.d.ts +18 -4
- package/dist/theme-switcher.js +1 -1
- package/dist/theme.d.ts +25 -11
- package/dist/theme.js +1 -1
- package/dist/toast.d.ts +15 -2
- package/dist/toast.js +1 -1
- package/dist/tokens.dark.json +3261 -0
- package/dist/tokens.json +4933 -0
- package/dist/tokens.resolver.json +37 -0
- package/dist/{tooltip-NcLIeBy5.d.ts → tooltip-CstGDKwy.d.ts} +18 -11
- package/dist/tooltip-DQO40Mrq.js +1 -0
- package/dist/tooltip.d.ts +6 -1
- package/dist/tooltip.js +1 -1
- package/dist/truncated-text.d.ts +28 -14
- package/dist/truncated-text.js +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/dist/use-breakpoint-B4Kh0xE6.js +1 -0
- package/dist/use-callback-ref-DiOXFQzM.js +1 -0
- package/dist/use-composed-refs-DPYmLDSe.js +1 -0
- package/dist/use-copy-to-clipboard-hBL6_65i.js +1 -0
- package/dist/use-inert-siblings-C4RHXrZc.js +1 -0
- package/dist/use-is-apple-platform-Bq6_KbVX.js +1 -0
- package/dist/use-is-hydrated-BeLOGKwE.js +1 -0
- package/dist/use-is-hydrated-after-paint-CrHt3OHw.js +1 -0
- package/dist/use-isomorphic-layout-effect-CL6iq0Bj.js +1 -0
- package/dist/use-matches-media-query-FfvtNKQe.js +1 -0
- package/dist/use-prefers-reduced-motion-Ck6dnOM9.js +1 -0
- package/dist/use-swipe-to-dismiss-BYdlca8r.js +1 -0
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +1 -1
- package/dist/visually-hidden.d.ts +14 -1
- package/dist/visually-hidden.js +1 -1
- package/dist/well.d.ts +7 -2
- package/dist/well.js +1 -1
- package/package.json +21 -7
- package/src/components/chart/d3-license.md +25 -0
- package/dist/alert-P9lwn25X.js +0 -1
- package/dist/anchor-CgcbWEUs.js +0 -1
- package/dist/browser-only-BTSrYWLj.js +0 -1
- package/dist/button-69InNC_m.js +0 -1
- package/dist/button-B8k98Pby.js +0 -1
- package/dist/button-Dge0D5bl.js +0 -1
- package/dist/chart-BpWfQAwf.js +0 -2
- package/dist/checkbox-DmSQXs26.js +0 -1
- package/dist/choice-2Lrv8_nl.js +0 -1
- package/dist/code-DUJzSl4K.js +0 -1
- package/dist/compose-refs-sFdxsL7k.js +0 -1
- package/dist/dialog-7TUgiSzX.js +0 -1
- package/dist/dialog-Dp0QGWwo.d.ts +0 -28
- package/dist/dropdown-menu-BHBzCDSZ.js +0 -1
- package/dist/field-Bihblt8U.js +0 -1
- package/dist/field-CPvjazWN.js +0 -1
- package/dist/icon-kK0c-POG.js +0 -1
- package/dist/icons-CDLz5lpI.js +0 -1
- package/dist/icons-CSwTVV2m.js +0 -1
- package/dist/icons-DP3lQw5O.js +0 -1
- package/dist/input-CpQ6jlpI.js +0 -1
- package/dist/kbd-CLHsJ99p.js +0 -1
- package/dist/label-nHqqYS7e.js +0 -1
- package/dist/layer-container-kEQiE4zV.js +0 -1
- package/dist/list-RFRIQxU2.js +0 -1
- package/dist/live-region-DQ1QLv3L.js +0 -1
- package/dist/main-CC1L9IsH.js +0 -1
- package/dist/popover-C96V8SXi.d.ts +0 -1
- package/dist/popover-DxOqLKxy.js +0 -1
- package/dist/primitive-Dz9Al-us.js +0 -1
- package/dist/radio-group-HDVxTNPi.js +0 -1
- package/dist/sandboxed-on-click-C7pPu-2M.js +0 -1
- package/dist/select-CAAYk4Yj.js +0 -1
- package/dist/separator-DfzxVutO.js +0 -1
- package/dist/sheet-CSJc_sB4.js +0 -1
- package/dist/skeleton-DBpI-ko5.js +0 -1
- package/dist/slot-DdYN1L1C.js +0 -1
- package/dist/table-CFHiDBW8.js +0 -1
- package/dist/theme-C-glc5Q-.js +0 -1
- package/dist/tooltip-b6oiTaWq.js +0 -1
- package/dist/use-breakpoint--mo7kr9d.js +0 -1
- package/dist/use-callback-ref-BvVyI5K1.js +0 -1
- package/dist/use-copy-to-clipboard-Dy_0Qzb7.js +0 -1
- package/dist/use-is-apple-platform-D4nifHMx.js +0 -1
- package/dist/use-is-hydrated-after-paint-r9Cl2mGp.js +0 -1
- package/dist/use-isomorphic-layout-effect-CLSmHzo4.js +0 -1
- package/dist/use-matches-media-query-m860lols.js +0 -1
- package/dist/use-prefers-reduced-motion-CU6mWmOe.js +0 -1
- package/dist/use-swipe-to-dismiss-DceYk1Id.js +0 -1
package/dist/scatter-plot.d.ts
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Re-exports for the Scatter Plot component.
|
|
3
|
+
*
|
|
4
|
+
* @see https://mantle.ngrok.com/components/charts/scatter-plot
|
|
5
|
+
*/
|
|
6
|
+
import { a as XAxisPrimitiveProps, c as LegendPrimitiveProps, d as ChartMode, h as ChartDatumEvent, i as ReferenceLinePrimitiveProps, l as CopyButtonPrimitiveProps, m as ChartDatum, n as ChartRootBaseProps, o as YAxisPrimitiveProps, r as GridPrimitiveProps, s as ChartListPrimitiveProps, t as TooltipPrimitiveProps, u as ChartAccessibilityProps, v as PointShape, y as SeriesColor } from "./chart-Dl8gFo_D.js";
|
|
7
|
+
/**
|
|
8
|
+
* Props for {@link ScatterPlot.List}.
|
|
9
|
+
*/
|
|
10
|
+
type ScatterPlotListProps = ChartListPrimitiveProps;
|
|
2
11
|
/**
|
|
3
12
|
* Props for {@link ScatterPlot.Root}. Scatter x values must be continuous
|
|
4
|
-
* (numbers or `Date`s
|
|
13
|
+
* (numbers or `Date`s; there is no categorical scatter axis). Set `zKey` to
|
|
5
14
|
* switch the chart into the 3D projection: points render inside a rotatable
|
|
6
15
|
* cube (drag to orbit), depth-sorted with gentle perspective.
|
|
7
16
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
17
|
+
* Keep it to eight series or fewer: the top seven, plus an "Other" series in
|
|
18
|
+
* `"neutral"`. Scatter is an all-pairs chart form: any point can land next to a
|
|
19
|
+
* point from any other series, so every pair of series colors must stay apart.
|
|
20
|
+
* Mantle does not guarantee that any set of colors stays apart. To show more
|
|
21
|
+
* series, facet into small multiples.
|
|
11
22
|
*/
|
|
12
23
|
type ScatterPlotRootProps<TDatum extends ChartDatum = ChartDatum, TMode extends ChartMode = "interactive"> = Omit<ChartRootBaseProps, "stacked"> & ChartAccessibilityProps<TMode> & {
|
|
13
24
|
/** Rows of data; each row is one point per composed `ScatterPlot.Point` series. */
|
|
@@ -29,13 +40,15 @@ type ScatterPlotDepthProps<TDatum extends ChartDatum = ChartDatum> = {
|
|
|
29
40
|
* The key of each row's depth value. When set, the scatter renders in
|
|
30
41
|
* 3D: drag the plot to rotate the cube. Axis parts and reference lines
|
|
31
42
|
* apply to the 2D projection only and are ignored in 3D (the cube frame
|
|
32
|
-
* carries orientation). If no row has the key, the Root throws.
|
|
43
|
+
* carries orientation). If no row has the key, the Root throws. The 3D
|
|
44
|
+
* code loads when a Root with a `zKey` mounts, so a 2D scatter plot
|
|
45
|
+
* never downloads it.
|
|
33
46
|
*/
|
|
34
47
|
zKey: Extract<keyof TDatum, string>;
|
|
35
48
|
/**
|
|
36
49
|
* How many axes the cloud currently occupies (default `3`). Changing it
|
|
37
50
|
* morphs the points onto the x axis line (`1`), the xy plane (`2`), or
|
|
38
|
-
* the full cube (`3`) with a smooth glide
|
|
51
|
+
* the full cube (`3`) with a smooth glide. This is the pattern behind "click
|
|
39
52
|
* 1D/2D/3D to see the clusters separate" explainers. The y and z frame
|
|
40
53
|
* edges fade in with their dimension.
|
|
41
54
|
*/
|
|
@@ -57,35 +70,26 @@ type ScatterPlotPointProps = {
|
|
|
57
70
|
/** Display name for the legend, tooltip, and data table. Defaults to `dataKey`. */
|
|
58
71
|
label?: string;
|
|
59
72
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
73
|
+
* The color the series paints: a mantle color name, the same `Color` that
|
|
74
|
+
* `Badge` takes, or any CSS color. Required: name every series' color on
|
|
75
|
+
* purpose. Give an "Other" series `"neutral"`, and a series that means good
|
|
76
|
+
* or bad a functional color such as `"danger"`.
|
|
62
77
|
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
78
|
+
* A static CSS color (raw hex) cannot follow the two themes, so prefer a
|
|
79
|
+
* `var(--your-token)` declared per theme.
|
|
65
80
|
*
|
|
66
81
|
* @example
|
|
67
82
|
* ```tsx
|
|
68
|
-
* <ScatterPlot.Point dataKey="
|
|
83
|
+
* <ScatterPlot.Point dataKey="latency" label="Latency" color="blue" />
|
|
69
84
|
* ```
|
|
70
85
|
*/
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Override the color channel with a chart token or any CSS color. This does
|
|
74
|
-
* not change the series slot or its paired point shape. When omitted, the
|
|
75
|
-
* series paints the color from its slot.
|
|
76
|
-
*
|
|
77
|
-
* A static color (raw hex) cannot follow the two themes, so prefer a
|
|
78
|
-
* `var(--your-token)` declared per theme. A series that carries good/bad
|
|
79
|
-
* meaning should wear the semantic status colors, never a categorical slot.
|
|
80
|
-
*/
|
|
81
|
-
color?: SeriesColor;
|
|
86
|
+
color: SeriesColor;
|
|
82
87
|
/**
|
|
83
88
|
* The glyph this series' points wear, mirrored by the legend key and the
|
|
84
89
|
* hover dot: `"circle"`, `"square"`, `"triangle"`, `"diamond"`,
|
|
85
90
|
* `"triangle-down"`, `"plus"`, `"cross"`, or `"star"`. Shape is the
|
|
86
91
|
* redundant encoding that keeps overlapping clouds distinguishable without
|
|
87
|
-
* color vision.
|
|
88
|
-
* series slot, so both channels name one slot.
|
|
92
|
+
* color vision. Defaults to `"circle"`.
|
|
89
93
|
*/
|
|
90
94
|
shape?: PointShape;
|
|
91
95
|
};
|
|
@@ -127,7 +131,7 @@ type ScatterPlotCopyButtonProps = CopyButtonPrimitiveProps;
|
|
|
127
131
|
* 3D cube: drag to orbit, with points depth-sorted under gentle perspective.
|
|
128
132
|
*
|
|
129
133
|
* A Root mounts dormant: a shell of the plot, the named overlay, and its
|
|
130
|
-
* sr-only description. It builds its canvas
|
|
134
|
+
* sr-only description. It builds its canvas and its engine
|
|
131
135
|
* once it comes within one viewport of the visible area, takes focus, or
|
|
132
136
|
* prints (on-screen charts first, a few milliseconds at a time), and it mounts
|
|
133
137
|
* the sr-only data table once focus lands inside it. A list of charts pays
|
|
@@ -140,8 +144,9 @@ type ScatterPlotCopyButtonProps = CopyButtonPrimitiveProps;
|
|
|
140
144
|
* `scatter-plot-description`, and, once focus lands inside the chart,
|
|
141
145
|
* `scatter-plot-data-table`. A scatter plot shows one marker dot on the hit
|
|
142
146
|
* point, and never the crosshair or the band. The canvas and the three
|
|
143
|
-
* layers are engine-owned: absent from server HTML and from a dormant chart,
|
|
144
|
-
*
|
|
147
|
+
* layers are engine-owned: absent from server HTML and from a dormant chart. The canvas arrives at activation (near the viewport, on
|
|
148
|
+
* focus, or before print), and the layers arrive on the first hover or
|
|
149
|
+
* keyboard step. A
|
|
145
150
|
* static or decorative chart inserts the canvas alone. The
|
|
146
151
|
* tooltip surface mounts on the first hover or keyboard step and stays. That dot carries `chart-active-point` plus a `data-shape` of
|
|
147
152
|
* `"circle"`, `"square"`, `"triangle"`, `"diamond"`, `"triangle-down"`,
|
|
@@ -169,8 +174,8 @@ type ScatterPlotCopyButtonProps = CopyButtonPrimitiveProps;
|
|
|
169
174
|
* <ScatterPlot.Grid />
|
|
170
175
|
* <ScatterPlot.XAxis />
|
|
171
176
|
* <ScatterPlot.YAxis />
|
|
172
|
-
* <ScatterPlot.Point dataKey="throughputA" label="Region A" />
|
|
173
|
-
* <ScatterPlot.Point dataKey="throughputB" label="Region B" />
|
|
177
|
+
* <ScatterPlot.Point dataKey="throughputA" label="Region A" color="blue" />
|
|
178
|
+
* <ScatterPlot.Point dataKey="throughputB" label="Region B" color="emerald" />
|
|
174
179
|
* <ScatterPlot.Tooltip />
|
|
175
180
|
* <ScatterPlot.Legend />
|
|
176
181
|
* </ScatterPlot.Root>
|
|
@@ -178,7 +183,7 @@ type ScatterPlotCopyButtonProps = CopyButtonPrimitiveProps;
|
|
|
178
183
|
*/
|
|
179
184
|
declare const Root: <TDatum extends ChartDatum = ChartDatum, TMode extends ChartMode = "interactive">(props: ScatterPlotRootProps<TDatum, TMode>) => import("react").JSX.Element;
|
|
180
185
|
/**
|
|
181
|
-
* One point series. Renders nothing itself
|
|
186
|
+
* One point series. Renders nothing itself: it registers the series with the
|
|
182
187
|
* chart, which paints its points on canvas (r≥4 dots with a surface ring,
|
|
183
188
|
* degrading gracefully past thousands of points).
|
|
184
189
|
*
|
|
@@ -190,8 +195,8 @@ declare const Root: <TDatum extends ChartDatum = ChartDatum, TMode extends Chart
|
|
|
190
195
|
* <ScatterPlot.Grid />
|
|
191
196
|
* <ScatterPlot.XAxis />
|
|
192
197
|
* <ScatterPlot.YAxis />
|
|
193
|
-
* <ScatterPlot.Point dataKey="throughputA" label="Region A" />
|
|
194
|
-
* <ScatterPlot.Point dataKey="throughputB" label="Region B" />
|
|
198
|
+
* <ScatterPlot.Point dataKey="throughputA" label="Region A" color="blue" />
|
|
199
|
+
* <ScatterPlot.Point dataKey="throughputB" label="Region B" color="emerald" />
|
|
195
200
|
* <ScatterPlot.Tooltip />
|
|
196
201
|
* <ScatterPlot.Legend />
|
|
197
202
|
* </ScatterPlot.Root>
|
|
@@ -199,9 +204,8 @@ declare const Root: <TDatum extends ChartDatum = ChartDatum, TMode extends Chart
|
|
|
199
204
|
*/
|
|
200
205
|
declare const Point: (props: ScatterPlotPointProps) => null;
|
|
201
206
|
/**
|
|
202
|
-
* Hairline gridlines behind the points (
|
|
203
|
-
*
|
|
204
|
-
* grid.
|
|
207
|
+
* Hairline gridlines behind the points. Renderless (painted on canvas); 2D only
|
|
208
|
+
* (the 3D cube frame carries orientation). Omit the part to omit the grid.
|
|
205
209
|
*
|
|
206
210
|
* @see https://mantle.ngrok.com/components/charts/scatter-plot#scatterplotgrid
|
|
207
211
|
*
|
|
@@ -211,7 +215,7 @@ declare const Point: (props: ScatterPlotPointProps) => null;
|
|
|
211
215
|
* <ScatterPlot.Grid lines="both" />
|
|
212
216
|
* <ScatterPlot.XAxis />
|
|
213
217
|
* <ScatterPlot.YAxis />
|
|
214
|
-
* <ScatterPlot.Point dataKey="throughputA" label="Region A" />
|
|
218
|
+
* <ScatterPlot.Point dataKey="throughputA" label="Region A" color="blue" />
|
|
215
219
|
* <ScatterPlot.Legend />
|
|
216
220
|
* </ScatterPlot.Root>
|
|
217
221
|
* ```
|
|
@@ -229,7 +233,7 @@ declare const Grid: (props: ScatterPlotGridProps) => null;
|
|
|
229
233
|
* <ScatterPlot.Grid />
|
|
230
234
|
* <ScatterPlot.XAxis tickFormat={(value) => `${value}ms`} />
|
|
231
235
|
* <ScatterPlot.YAxis />
|
|
232
|
-
* <ScatterPlot.Point dataKey="throughputA" label="Region A" />
|
|
236
|
+
* <ScatterPlot.Point dataKey="throughputA" label="Region A" color="blue" />
|
|
233
237
|
* <ScatterPlot.Legend />
|
|
234
238
|
* </ScatterPlot.Root>
|
|
235
239
|
* ```
|
|
@@ -247,15 +251,15 @@ declare const XAxis: (props: ScatterPlotXAxisProps) => null;
|
|
|
247
251
|
* <ScatterPlot.Grid />
|
|
248
252
|
* <ScatterPlot.XAxis />
|
|
249
253
|
* <ScatterPlot.YAxis tickFormat={(value) => `${value / 1000}k`} />
|
|
250
|
-
* <ScatterPlot.Point dataKey="throughputA" label="Region A" />
|
|
254
|
+
* <ScatterPlot.Point dataKey="throughputA" label="Region A" color="blue" />
|
|
251
255
|
* <ScatterPlot.Legend />
|
|
252
256
|
* </ScatterPlot.Root>
|
|
253
257
|
* ```
|
|
254
258
|
*/
|
|
255
259
|
declare const YAxis: (props: ScatterPlotYAxisProps) => null;
|
|
256
260
|
/**
|
|
257
|
-
* A dashed horizontal marker at a y value (
|
|
258
|
-
* only
|
|
261
|
+
* A dashed horizontal marker at a y value. Renderless (painted on canvas); 2D
|
|
262
|
+
* only (ignored in the 3D projection).
|
|
259
263
|
*
|
|
260
264
|
* @see https://mantle.ngrok.com/components/charts/scatter-plot#scatterplotreferenceline
|
|
261
265
|
*
|
|
@@ -265,7 +269,7 @@ declare const YAxis: (props: ScatterPlotYAxisProps) => null;
|
|
|
265
269
|
* <ScatterPlot.Grid />
|
|
266
270
|
* <ScatterPlot.XAxis />
|
|
267
271
|
* <ScatterPlot.YAxis />
|
|
268
|
-
* <ScatterPlot.Point dataKey="throughputA" label="Region A" />
|
|
272
|
+
* <ScatterPlot.Point dataKey="throughputA" label="Region A" color="blue" />
|
|
269
273
|
* <ScatterPlot.ReferenceLine y={500} label="Target" />
|
|
270
274
|
* <ScatterPlot.Legend />
|
|
271
275
|
* </ScatterPlot.Root>
|
|
@@ -275,7 +279,7 @@ declare const ReferenceLine: (props: ScatterPlotReferenceLineProps) => null;
|
|
|
275
279
|
/**
|
|
276
280
|
* Customizes the hover/keyboard tooltip readout. The tooltip itself is part
|
|
277
281
|
* of `ScatterPlot.Root`'s interaction contract and renders even when this
|
|
278
|
-
* part is absent
|
|
282
|
+
* part is absent. Compose it to format the label or values, append a footer,
|
|
279
283
|
* or replace the content entirely via the render-prop `children`.
|
|
280
284
|
* In 3D the readout also carries the point's z value.
|
|
281
285
|
*
|
|
@@ -297,7 +301,7 @@ declare const ReferenceLine: (props: ScatterPlotReferenceLineProps) => null;
|
|
|
297
301
|
* @example
|
|
298
302
|
* ```tsx
|
|
299
303
|
* <ScatterPlot.Root data={data} xKey="latency" aria-label="Latency vs throughput">
|
|
300
|
-
* <ScatterPlot.Point dataKey="throughputA" label="Region A" />
|
|
304
|
+
* <ScatterPlot.Point dataKey="throughputA" label="Region A" color="blue" />
|
|
301
305
|
* <ScatterPlot.Tooltip valueFormat={(value) => `${value} rps`} />
|
|
302
306
|
* <ScatterPlot.Legend />
|
|
303
307
|
* </ScatterPlot.Root>
|
|
@@ -306,7 +310,7 @@ declare const ReferenceLine: (props: ScatterPlotReferenceLineProps) => null;
|
|
|
306
310
|
declare const Tooltip: (props: ScatterPlotTooltipProps) => null;
|
|
307
311
|
/**
|
|
308
312
|
* The legend: series names keyed by color dots, rendered as real DOM in flow
|
|
309
|
-
* below the plot. Always compose it on multi-series charts
|
|
313
|
+
* below the plot. Always compose it on multi-series charts: identity must
|
|
310
314
|
* never rely on color-matching alone. It renders nothing for a single series
|
|
311
315
|
* (the chart's title already names it).
|
|
312
316
|
*
|
|
@@ -323,15 +327,15 @@ declare const Tooltip: (props: ScatterPlotTooltipProps) => null;
|
|
|
323
327
|
* | --- | --- | --- |
|
|
324
328
|
* | `data-slot` | `"scatter-plot-legend"` | The legend list. `ScatterPlot.Legend` renders it in flow below the plot. |
|
|
325
329
|
* | `data-slot` | `"scatter-plot-legend-label"` | On the `<div>` wrapping a `children` render prop. The default legend has none. |
|
|
326
|
-
* | `data-shape` | `"circle"` \| `"square"` \| `"triangle"` \| `"diamond"` \| `"triangle-down"` \| `"plus"` \| `"cross"` \| `"star"` | On each series' swatch, naming the glyph its `ScatterPlot.Point` wears
|
|
330
|
+
* | `data-shape` | `"circle"` \| `"square"` \| `"triangle"` \| `"diamond"` \| `"triangle-down"` \| `"plus"` \| `"cross"` \| `"star"` | On each series' swatch, naming the glyph its `ScatterPlot.Point` wears: the `shape` it set, else the circle. The swatch clips itself to that glyph, so target this only to restyle a key. |
|
|
327
331
|
*
|
|
328
332
|
* @see https://mantle.ngrok.com/components/charts/scatter-plot#scatterplotlegend
|
|
329
333
|
*
|
|
330
334
|
* @example
|
|
331
335
|
* ```tsx
|
|
332
336
|
* <ScatterPlot.Root data={data} xKey="latency" aria-label="Latency vs throughput">
|
|
333
|
-
* <ScatterPlot.Point dataKey="throughputA" label="Region A" />
|
|
334
|
-
* <ScatterPlot.Point dataKey="throughputB" label="Region B" />
|
|
337
|
+
* <ScatterPlot.Point dataKey="throughputA" label="Region A" color="blue" />
|
|
338
|
+
* <ScatterPlot.Point dataKey="throughputB" label="Region B" color="emerald" />
|
|
335
339
|
* <ScatterPlot.Tooltip />
|
|
336
340
|
* <ScatterPlot.Legend />
|
|
337
341
|
* </ScatterPlot.Root>
|
|
@@ -341,7 +345,7 @@ declare const Legend: (props: ScatterPlotLegendProps) => import("react").JSX.Ele
|
|
|
341
345
|
/**
|
|
342
346
|
* A button that copies the chart's current data to the clipboard as a
|
|
343
347
|
* markdown table (ISO dates, plain numbers, one column per series, plus the
|
|
344
|
-
* z column on 3D scatters)
|
|
348
|
+
* z column on 3D scatters). The table pastes into Slack, issues, docs,
|
|
345
349
|
* spreadsheets, and LLM chats. Renders in flow where composed (alongside
|
|
346
350
|
* `Legend`, below the plot); `Root` is relatively positioned, so `className`
|
|
347
351
|
* can dock it over a corner instead (e.g. `absolute right-0 top-0`).
|
|
@@ -351,8 +355,8 @@ declare const Legend: (props: ScatterPlotLegendProps) => import("react").JSX.Ele
|
|
|
351
355
|
* @example
|
|
352
356
|
* ```tsx
|
|
353
357
|
* <ScatterPlot.Root data={data} xKey="latency" aria-label="Latency vs throughput">
|
|
354
|
-
* <ScatterPlot.Point dataKey="throughputA" label="Region A" />
|
|
355
|
-
* <ScatterPlot.Point dataKey="throughputB" label="Region B" />
|
|
358
|
+
* <ScatterPlot.Point dataKey="throughputA" label="Region A" color="blue" />
|
|
359
|
+
* <ScatterPlot.Point dataKey="throughputB" label="Region B" color="emerald" />
|
|
356
360
|
* <ScatterPlot.Legend />
|
|
357
361
|
* <ScatterPlot.CopyButton />
|
|
358
362
|
* </ScatterPlot.Root>
|
|
@@ -360,30 +364,63 @@ declare const Legend: (props: ScatterPlotLegendProps) => import("react").JSX.Ele
|
|
|
360
364
|
*/
|
|
361
365
|
declare const CopyButton: (props: ScatterPlotCopyButtonProps) => import("react").JSX.Element;
|
|
362
366
|
/**
|
|
363
|
-
*
|
|
367
|
+
* Groups a list of charts, such as one chart per card, so they share one
|
|
368
|
+
* `role="status"` live region. A page of 100 charts mounts one region instead
|
|
369
|
+
* of one per chart, plus one for each `ScatterPlot.CopyButton`. Each chart
|
|
370
|
+
* keeps its own tooltip, description, and data table.
|
|
371
|
+
*
|
|
372
|
+
* Renders a `div` (`scatter-plot-list`) that holds the charts in a `display: contents`
|
|
373
|
+
* wrapper (`scatter-plot-list-items`), so a grid or flex layout on the List reaches
|
|
374
|
+
* the cards, and the live region as its last child. No `asChild`: a list
|
|
375
|
+
* element such as `ul` cannot hold the live region as a child.
|
|
376
|
+
*
|
|
377
|
+
* @see https://mantle.ngrok.com/components/charts/scatter-plot#scatterplotlist
|
|
378
|
+
*
|
|
379
|
+
* @example
|
|
380
|
+
* ```tsx
|
|
381
|
+
* <ScatterPlot.List>
|
|
382
|
+
* {agents.map((agent) => (
|
|
383
|
+
* <ScatterPlot.Root key={agent.id} data={agent.rows} xKey="latency" aria-label={agent.name}>
|
|
384
|
+
* <ScatterPlot.Point dataKey="throughputA" label="Region A" color="blue" />
|
|
385
|
+
* <ScatterPlot.Tooltip />
|
|
386
|
+
* </ScatterPlot.Root>
|
|
387
|
+
* ))}
|
|
388
|
+
* </ScatterPlot.List>
|
|
389
|
+
* ```
|
|
390
|
+
*/
|
|
391
|
+
declare const List: (props: ScatterPlotListProps) => import("react").JSX.Element;
|
|
392
|
+
/**
|
|
393
|
+
* A canvas-rendered scatter plot for correlating two measures, or three with
|
|
364
394
|
* the 3D projection (`zKey`), which renders a rotatable, depth-sorted point
|
|
365
395
|
* cloud (drag to orbit). Hover hits the nearest point within 24px; keyboard
|
|
366
396
|
* stepping, polite announcements, and the sr-only description ship with
|
|
367
397
|
* `Root` unconditionally. A Root builds and paints its canvas once it comes
|
|
368
398
|
* within one viewport of the visible area, takes focus, or prints, and it mounts
|
|
369
|
-
* its sr-only data table once focus lands inside it.
|
|
370
|
-
*
|
|
371
|
-
*
|
|
399
|
+
* its sr-only data table once focus lands inside it. Keep it to eight series
|
|
400
|
+
* or fewer: the top seven, plus an "Other" series in `"neutral"`. Scatter is
|
|
401
|
+
* an all-pairs chart form, and mantle does not guarantee that any set of
|
|
402
|
+
* colors stays apart.
|
|
372
403
|
*
|
|
373
404
|
* **CSS variables (public API):**
|
|
374
405
|
*
|
|
375
406
|
* | CSS Variable | Default | Description |
|
|
376
407
|
* | --- | --- | --- |
|
|
377
|
-
* | `--color-chart
|
|
378
|
-
* | `--color-chart-other` | `--color-neutral-500` | The neutral overflow slot a series wears once every slot is held. |
|
|
408
|
+
* | `--color-chart-<name>` | per theme | The color a series with `color="<name>"` paints. Every mantle color name has one: the 600 step of its hue in light mode, and the 500 step in dark mode. Most names reach 3:1 contrast on the card surface, and the docs page lists the names that do not. |
|
|
379
409
|
*
|
|
380
410
|
* Two ways to change a series color, both public API. The `color` prop on
|
|
381
|
-
* `ScatterPlot.Point`
|
|
382
|
-
* redeclare its token on `Root
|
|
383
|
-
* `className="[--color-chart-
|
|
411
|
+
* `ScatterPlot.Point` takes a color name or any CSS color. To restyle a color name for one chart,
|
|
412
|
+
* redeclare its token on `Root`:
|
|
413
|
+
* `className="[--color-chart-blue:var(--color-brand)]"`. The engine resolves every
|
|
384
414
|
* token from `Root`'s computed style, so a declaration scoped there wins for
|
|
385
415
|
* that chart and leaves every other chart on the page alone.
|
|
386
416
|
*
|
|
417
|
+
* @useWhen Show how two measures correlate across many points, or three measures in a rotatable 3D
|
|
418
|
+
* view.
|
|
419
|
+
*
|
|
420
|
+
* @siblings
|
|
421
|
+
* - `LineChart`: one measure trends across an ordered x axis, such as time.
|
|
422
|
+
* - `BarChart`: values compare across categories.
|
|
423
|
+
*
|
|
387
424
|
* @see https://mantle.ngrok.com/components/charts/scatter-plot
|
|
388
425
|
*
|
|
389
426
|
* @example
|
|
@@ -400,6 +437,12 @@ declare const CopyButton: (props: ScatterPlotCopyButtonProps) => import("react")
|
|
|
400
437
|
* └── ScatterPlot.CopyButton
|
|
401
438
|
* ```
|
|
402
439
|
*
|
|
440
|
+
* A List groups Roots:
|
|
441
|
+
* ```
|
|
442
|
+
* ScatterPlot.List
|
|
443
|
+
* └── ScatterPlot.Root (one per chart)
|
|
444
|
+
* ```
|
|
445
|
+
*
|
|
403
446
|
* @example
|
|
404
447
|
* ```tsx
|
|
405
448
|
* const data = [
|
|
@@ -412,8 +455,8 @@ declare const CopyButton: (props: ScatterPlotCopyButtonProps) => import("react")
|
|
|
412
455
|
* <ScatterPlot.Grid />
|
|
413
456
|
* <ScatterPlot.XAxis />
|
|
414
457
|
* <ScatterPlot.YAxis />
|
|
415
|
-
* <ScatterPlot.Point dataKey="throughputA" label="Region A" />
|
|
416
|
-
* <ScatterPlot.Point dataKey="throughputB" label="Region B" />
|
|
458
|
+
* <ScatterPlot.Point dataKey="throughputA" label="Region A" color="blue" />
|
|
459
|
+
* <ScatterPlot.Point dataKey="throughputB" label="Region B" color="emerald" />
|
|
417
460
|
* <ScatterPlot.Tooltip />
|
|
418
461
|
* <ScatterPlot.Legend />
|
|
419
462
|
* </ScatterPlot.Root>
|
|
@@ -433,8 +476,8 @@ declare const ScatterPlot: {
|
|
|
433
476
|
* <ScatterPlot.Grid />
|
|
434
477
|
* <ScatterPlot.XAxis />
|
|
435
478
|
* <ScatterPlot.YAxis />
|
|
436
|
-
* <ScatterPlot.Point dataKey="throughputA" label="Region A" />
|
|
437
|
-
* <ScatterPlot.Point dataKey="throughputB" label="Region B" />
|
|
479
|
+
* <ScatterPlot.Point dataKey="throughputA" label="Region A" color="blue" />
|
|
480
|
+
* <ScatterPlot.Point dataKey="throughputB" label="Region B" color="emerald" />
|
|
438
481
|
* <ScatterPlot.Tooltip />
|
|
439
482
|
* <ScatterPlot.Legend />
|
|
440
483
|
* </ScatterPlot.Root>
|
|
@@ -452,8 +495,8 @@ declare const ScatterPlot: {
|
|
|
452
495
|
* <ScatterPlot.Grid />
|
|
453
496
|
* <ScatterPlot.XAxis />
|
|
454
497
|
* <ScatterPlot.YAxis />
|
|
455
|
-
* <ScatterPlot.Point dataKey="throughputA" label="Region A" />
|
|
456
|
-
* <ScatterPlot.Point dataKey="throughputB" label="Region B" />
|
|
498
|
+
* <ScatterPlot.Point dataKey="throughputA" label="Region A" color="blue" />
|
|
499
|
+
* <ScatterPlot.Point dataKey="throughputB" label="Region B" color="emerald" />
|
|
457
500
|
* <ScatterPlot.Tooltip />
|
|
458
501
|
* <ScatterPlot.Legend />
|
|
459
502
|
* </ScatterPlot.Root>
|
|
@@ -471,7 +514,7 @@ declare const ScatterPlot: {
|
|
|
471
514
|
* <ScatterPlot.Grid lines="both" />
|
|
472
515
|
* <ScatterPlot.XAxis />
|
|
473
516
|
* <ScatterPlot.YAxis />
|
|
474
|
-
* <ScatterPlot.Point dataKey="throughputA" label="Region A" />
|
|
517
|
+
* <ScatterPlot.Point dataKey="throughputA" label="Region A" color="blue" />
|
|
475
518
|
* <ScatterPlot.Tooltip />
|
|
476
519
|
* <ScatterPlot.Legend />
|
|
477
520
|
* </ScatterPlot.Root>
|
|
@@ -489,7 +532,7 @@ declare const ScatterPlot: {
|
|
|
489
532
|
* <ScatterPlot.Grid />
|
|
490
533
|
* <ScatterPlot.XAxis tickFormat={(value) => `${value}ms`} />
|
|
491
534
|
* <ScatterPlot.YAxis />
|
|
492
|
-
* <ScatterPlot.Point dataKey="throughputA" label="Region A" />
|
|
535
|
+
* <ScatterPlot.Point dataKey="throughputA" label="Region A" color="blue" />
|
|
493
536
|
* <ScatterPlot.Tooltip />
|
|
494
537
|
* <ScatterPlot.Legend />
|
|
495
538
|
* </ScatterPlot.Root>
|
|
@@ -507,7 +550,7 @@ declare const ScatterPlot: {
|
|
|
507
550
|
* <ScatterPlot.Grid />
|
|
508
551
|
* <ScatterPlot.XAxis />
|
|
509
552
|
* <ScatterPlot.YAxis tickFormat={(value) => `${value / 1000}k`} />
|
|
510
|
-
* <ScatterPlot.Point dataKey="throughputA" label="Region A" />
|
|
553
|
+
* <ScatterPlot.Point dataKey="throughputA" label="Region A" color="blue" />
|
|
511
554
|
* <ScatterPlot.Tooltip />
|
|
512
555
|
* <ScatterPlot.Legend />
|
|
513
556
|
* </ScatterPlot.Root>
|
|
@@ -525,7 +568,7 @@ declare const ScatterPlot: {
|
|
|
525
568
|
* <ScatterPlot.Grid />
|
|
526
569
|
* <ScatterPlot.XAxis />
|
|
527
570
|
* <ScatterPlot.YAxis />
|
|
528
|
-
* <ScatterPlot.Point dataKey="throughputA" label="Region A" />
|
|
571
|
+
* <ScatterPlot.Point dataKey="throughputA" label="Region A" color="blue" />
|
|
529
572
|
* <ScatterPlot.ReferenceLine y={500} label="Target" />
|
|
530
573
|
* <ScatterPlot.Tooltip />
|
|
531
574
|
* <ScatterPlot.Legend />
|
|
@@ -544,7 +587,7 @@ declare const ScatterPlot: {
|
|
|
544
587
|
* <ScatterPlot.Grid />
|
|
545
588
|
* <ScatterPlot.XAxis />
|
|
546
589
|
* <ScatterPlot.YAxis />
|
|
547
|
-
* <ScatterPlot.Point dataKey="throughputA" label="Region A" />
|
|
590
|
+
* <ScatterPlot.Point dataKey="throughputA" label="Region A" color="blue" />
|
|
548
591
|
* <ScatterPlot.Tooltip valueFormat={(value) => `${value} rps`} />
|
|
549
592
|
* <ScatterPlot.Legend />
|
|
550
593
|
* </ScatterPlot.Root>
|
|
@@ -563,8 +606,8 @@ declare const ScatterPlot: {
|
|
|
563
606
|
* <ScatterPlot.Grid />
|
|
564
607
|
* <ScatterPlot.XAxis />
|
|
565
608
|
* <ScatterPlot.YAxis />
|
|
566
|
-
* <ScatterPlot.Point dataKey="throughputA" label="Region A" />
|
|
567
|
-
* <ScatterPlot.Point dataKey="throughputB" label="Region B" />
|
|
609
|
+
* <ScatterPlot.Point dataKey="throughputA" label="Region A" color="blue" />
|
|
610
|
+
* <ScatterPlot.Point dataKey="throughputB" label="Region B" color="emerald" />
|
|
568
611
|
* <ScatterPlot.Tooltip />
|
|
569
612
|
* <ScatterPlot.Legend />
|
|
570
613
|
* </ScatterPlot.Root>
|
|
@@ -579,13 +622,31 @@ declare const ScatterPlot: {
|
|
|
579
622
|
* @example
|
|
580
623
|
* ```tsx
|
|
581
624
|
* <ScatterPlot.Root data={data} xKey="latency" aria-label="Latency vs throughput">
|
|
582
|
-
* <ScatterPlot.Point dataKey="throughputA" label="Region A" />
|
|
583
|
-
* <ScatterPlot.Point dataKey="throughputB" label="Region B" />
|
|
625
|
+
* <ScatterPlot.Point dataKey="throughputA" label="Region A" color="blue" />
|
|
626
|
+
* <ScatterPlot.Point dataKey="throughputB" label="Region B" color="emerald" />
|
|
584
627
|
* <ScatterPlot.Legend />
|
|
585
628
|
* <ScatterPlot.CopyButton />
|
|
586
629
|
* </ScatterPlot.Root>
|
|
587
630
|
* ```
|
|
588
631
|
*/
|
|
589
632
|
readonly CopyButton: typeof CopyButton;
|
|
633
|
+
/**
|
|
634
|
+
* Groups a list of charts so they share one live region.
|
|
635
|
+
*
|
|
636
|
+
* @see https://mantle.ngrok.com/components/charts/scatter-plot#scatterplotlist
|
|
637
|
+
*
|
|
638
|
+
* @example
|
|
639
|
+
* ```tsx
|
|
640
|
+
* <ScatterPlot.List>
|
|
641
|
+
* {agents.map((agent) => (
|
|
642
|
+
* <ScatterPlot.Root key={agent.id} data={agent.rows} xKey="latency" aria-label={agent.name}>
|
|
643
|
+
* <ScatterPlot.Point dataKey="throughputA" label="Region A" color="blue" />
|
|
644
|
+
* <ScatterPlot.Tooltip />
|
|
645
|
+
* </ScatterPlot.Root>
|
|
646
|
+
* ))}
|
|
647
|
+
* </ScatterPlot.List>
|
|
648
|
+
* ```
|
|
649
|
+
*/
|
|
650
|
+
readonly List: typeof List;
|
|
590
651
|
};
|
|
591
|
-
export { type ChartDatumEvent, type ChartMode, ScatterPlot, type ScatterPlotCopyButtonProps, type ScatterPlotGridProps, type ScatterPlotLegendProps, type ScatterPlotPointProps, type ScatterPlotReferenceLineProps, type ScatterPlotRootProps, type ScatterPlotTooltipProps, type ScatterPlotXAxisProps, type ScatterPlotYAxisProps };
|
|
652
|
+
export { type ChartDatumEvent, type ChartMode, ScatterPlot, type ScatterPlotCopyButtonProps, type ScatterPlotGridProps, type ScatterPlotLegendProps, type ScatterPlotListProps, type ScatterPlotPointProps, type ScatterPlotReferenceLineProps, type ScatterPlotRootProps, type ScatterPlotTooltipProps, type ScatterPlotXAxisProps, type ScatterPlotYAxisProps };
|
package/dist/scatter-plot.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
"use client";import{_ as e,a as t,c as n,d as r,i,l as a,n as o,o as s,r as c,s as l,t as u,u as d}from"./chart-DtgZBAas.js";import{n as f,r as p}from"./chart-BLCqzt56.js";import{c as m}from"react/compiler-runtime";import{useEffect as h}from"react";import{jsx as g}from"react/jsx-runtime";const _=/* @__PURE__ */ new WeakMap,v=e=>{let t=_.get(e);return(t==null||t.parentNode!==e)&&(t=e.ownerDocument.createElement(`span`),t.style.display=`none`,t.setAttribute(`aria-hidden`,`true`),e.appendChild(t),_.set(e,t)),t},y=(e,t)=>{let n=v(e);return n.style.color=t,e.ownerDocument.defaultView?.getComputedStyle(n).color??``},b=/* @__PURE__ */ new WeakMap,x=e=>{let t=b.get(e);if(t!==void 0)return t;let n=e.createElement(`canvas`);n.width=1,n.height=1;let r=n.getContext(`2d`);return b.set(e,r),r},S=[`#010203`,`#030201`],C=/* @__PURE__ */ new WeakMap,w=(e,t)=>{let n=C.get(e);n??(n=/* @__PURE__ */ new Map,C.set(e,n));let r=n.get(t);if(r!=null)return r;let i=!1;for(let n of S)if(e.fillStyle=n,e.fillStyle=t,e.fillStyle!==n){i=!0;break}return n.set(t,i),i},T=/^var\(\s*(--[\w-]+)\s*\)$/i,E=/var\(|currentcolor|light-dark\(/i,D=(e,t)=>{let{computed:n,parseContext:r}=t,i=/* @__PURE__ */ new Map;return{resolve:t=>{let a=i.get(t);if(a!=null)return a;let o=t.trim(),s=T.exec(o),c;c=s?.[1]==null?o.toLowerCase()===`currentcolor`?n.color:o:n.getPropertyValue(s[1]).trim();let l;return l=c===``||E.test(c)?y(e,o):r==null||w(r,c)?c:y(e,o),i.set(t,l),l},fontFamily:n.fontFamily||`sans-serif`}},O=(e,t)=>e.resolve(i(t)),k=e=>({grid:e.resolve(c.grid),baseline:e.resolve(c.baseline),tickText:e.resolve(c.tickText),reference:e.resolve(c.reference),surface:e.resolve(c.surface)}),A=e=>`${e.className}|${e.getAttribute(`data-applied-theme`)??``}|${e.getAttribute(`data-theme`)??``}`,j=/* @__PURE__ */ new WeakMap,M=(e,t)=>{let n=j.get(e);if(n==null){let t=/* @__PURE__ */ new Set,r={observer:new MutationObserver(()=>{let n=A(e);if(n!==r.signature){r.signature=n;for(let e of t)e()}}),listeners:t,signature:A(e)};r.observer.observe(e,{attributes:!0,attributeFilter:[`class`,`data-applied-theme`,`data-theme`]}),j.set(e,r),n=r}return n.listeners.add(t),()=>{n.listeners.delete(t),n.listeners.size===0&&(n.observer.disconnect(),j.delete(e))}};var N=class{kind=`canvas`;element;#e;#t;#n=null;#r=!1;#i;constructor({root:e,plot:t,slotName:n,onColorsChange:r}){this.#e=e,this.#t=t;let i=e.ownerDocument.createElement(`canvas`);i.setAttribute(`data-slot`,`${n}-canvas`),i.setAttribute(`aria-hidden`,`true`),i.style.position=`absolute`,i.style.inset=`0`,i.style.width=`100%`,i.style.height=`100%`,this.element=i,this.#i=M(e.ownerDocument.documentElement,r)}#a(){return this.#r||(this.#r=!0,this.#n=this.element.getContext(`2d`)),this.#n}paintSignature(){return A(this.#e.ownerDocument.documentElement)}resolvePaint({series:e,signature:t}){let n=this.#e.ownerDocument.defaultView;if(n==null)return null;let r=D(this.#t,{computed:n.getComputedStyle(this.#e),parseContext:x(this.#e.ownerDocument)}),i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Map;for(let t of e)i.set(t.dataKey,O(r,t.colorInput)),a.set(t.dataKey,`${t.colorInput}|${t.texture}`);return{signature:t,series:i,inputs:a,barFills:/* @__PURE__ */ new Map,chrome:k(r),fontFamily:()=>r.fontFamily,resolve:e=>O(r,e)}}measureContext(){return this.#a()}begin({cssWidth:e,cssHeight:t,devicePixelRatio:n}){let r=this.#a();if(r==null)return null;let i=this.element,a=Math.round(e*n),o=Math.round(t*n);return(i.width!==a||i.height!==o)&&(i.width=a,i.height=o),r.setTransform(n,0,0,n,0,0),r.clearRect(0,0,e,t),r}composite(e,t){let{underlay:n,marks:r,fade:i}=t,a=this.#n;if(i==null||a==null){n(),r();return}r(),a.save(),a.globalCompositeOperation=`destination-out`;let o=a.createLinearGradient(i.left,0,i.left+i.width,0);o.addColorStop(0,`rgba(0, 0, 0, ${i.alpha})`),o.addColorStop(1,`rgba(0, 0, 0, 0)`),a.fillStyle=o,a.fillRect(i.left,i.top,i.width,i.height),a.globalCompositeOperation=`destination-over`,n(),a.restore()}end(){}release(){let e=this.element;(e.width!==0||e.height!==0)&&(e.width=0,e.height=0)}destroy(){this.#i()}};const P=Object.assign(e=>new N(e),{kind:`canvas`}),F={Root:e=>{let t=m(5),n=e.zKey!=null,r,i;t[0]===n?(r=t[1],i=t[2]):(r=()=>{n&&p().catch(I)},i=[n],t[0]=n,t[1]=r,t[2]=i),h(r,i);let a;return t[3]===e?a=t[4]:(a=/* @__PURE__ */ g(u,{kind:`scatter`,componentName:`ScatterPlot`,slotName:`scatter-plot`,paintBackend:P,scatterView:f,...e}),t[3]=e,t[4]=a),a},Point:e=>l(`ScatterPlot.Point`,`scatter`,e),Grid:e=>t(`ScatterPlot.Grid`,e),XAxis:e=>n(`ScatterPlot.XAxis`,e),YAxis:e=>a(`ScatterPlot.YAxis`,e),ReferenceLine:e=>s(`ScatterPlot.ReferenceLine`,e),Tooltip:e=>o(`ScatterPlot.Tooltip`,e),Legend:e=>{let t=m(2),n;return t[0]===e?n=t[1]:(n=/* @__PURE__ */ g(r,{partName:`ScatterPlot.Legend`,slotName:`scatter-plot`,...e}),t[0]=e,t[1]=n),n},CopyButton:t=>{let n=m(2),r;return n[0]===t?r=n[1]:(r=/* @__PURE__ */ g(e,{partName:`ScatterPlot.CopyButton`,slotName:`scatter-plot`,...t}),n[0]=t,n[1]=r),r},List:e=>{let t=m(2),n;return t[0]===e?n=t[1]:(n=/* @__PURE__ */ g(d,{slotName:`scatter-plot-list`,...e}),t[0]=e,t[1]=n),n}};function I(){}export{F as ScatterPlot};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-exports for the Segmented Control component.
|
|
3
|
+
*
|
|
4
|
+
* @see https://mantle.ngrok.com/components/forms/segmented-control
|
|
5
|
+
*/
|
|
6
|
+
import { r as RootProps, t as ItemProps } from "./radio-group-BJQ6EOqh.js";
|
|
7
|
+
/**
|
|
8
|
+
* The props of `SegmentedControl.Root`: the same props as `RadioGroup.Root`,
|
|
9
|
+
* including `value`, `defaultValue`, `onChange`, `name`, `form`, and
|
|
10
|
+
* `disabled`.
|
|
11
|
+
*/
|
|
12
|
+
type SegmentedControlRootProps = RootProps;
|
|
13
|
+
/**
|
|
14
|
+
* The props of `SegmentedControl.Item`: the same props as `RadioGroup.Item`,
|
|
15
|
+
* including `value` and `disabled`.
|
|
16
|
+
*/
|
|
17
|
+
type SegmentedControlItemProps = ItemProps;
|
|
18
|
+
/**
|
|
19
|
+
* A row of segments, one checked at a time, on a dim track. A raised thumb
|
|
20
|
+
* slides to the checked `SegmentedControl.Item`. It is a radio group: it
|
|
21
|
+
* renders `role="radiogroup"`, arrow keys move the checked item, and with a
|
|
22
|
+
* `name` it submits its value in a form.
|
|
23
|
+
*
|
|
24
|
+
* Name it with `aria-label`, or with `aria-labelledby` that points at a
|
|
25
|
+
* visible label. A mouse or a finger can drag the thumb. A sideways drag on
|
|
26
|
+
* the checked item moves the thumb with the pointer. On release, the thumb
|
|
27
|
+
* slides to the nearest enabled item, and that item becomes checked. A flick
|
|
28
|
+
* carries the thumb further.
|
|
29
|
+
*
|
|
30
|
+
* | Data Attribute | Value | Description |
|
|
31
|
+
* | --------------- | --------------------- | --------------------------------------------------- |
|
|
32
|
+
* | `data-dragging` | present during a drag | The thumb follows the pointer. Presence-only. |
|
|
33
|
+
*
|
|
34
|
+
* @see https://mantle.ngrok.com/components/forms/segmented-control#segmentedcontrolroot
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* <SegmentedControl.Root aria-label="Environment" defaultValue="production">
|
|
39
|
+
* <SegmentedControl.Item value="development">Dev</SegmentedControl.Item>
|
|
40
|
+
* <SegmentedControl.Item value="staging">Staging</SegmentedControl.Item>
|
|
41
|
+
* <SegmentedControl.Item value="production">Prod</SegmentedControl.Item>
|
|
42
|
+
* </SegmentedControl.Root>
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
declare const Root: ({ "data-slot": dataSlot, className, ref, style, ...props }: SegmentedControlRootProps) => import("react").JSX.Element;
|
|
46
|
+
/**
|
|
47
|
+
* One segment of a `SegmentedControl.Root`: a `role="radio"` item that grows
|
|
48
|
+
* to share the row and keeps its label on one line. Keep the label to one or
|
|
49
|
+
* two words. An icon-only item needs its name in `sr-only` text or
|
|
50
|
+
* `aria-label`.
|
|
51
|
+
*
|
|
52
|
+
* Inside `Field.Control`, the item picks up `aria-invalid`,
|
|
53
|
+
* `aria-errormessage`, and `aria-describedby`.
|
|
54
|
+
*
|
|
55
|
+
* | Data Attribute | Value | Description |
|
|
56
|
+
* | ----------------- | --------------------- | ------------------------------------------- |
|
|
57
|
+
* | `data-thumb-over` | present during a drag | The thumb is over this item. Presence-only. |
|
|
58
|
+
*
|
|
59
|
+
* @see https://mantle.ngrok.com/components/forms/segmented-control#segmentedcontrolitem
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```tsx
|
|
63
|
+
* <SegmentedControl.Root aria-label="Environment" defaultValue="production">
|
|
64
|
+
* <SegmentedControl.Item value="development">Dev</SegmentedControl.Item>
|
|
65
|
+
* <SegmentedControl.Item value="staging">Staging</SegmentedControl.Item>
|
|
66
|
+
* <SegmentedControl.Item value="production">Prod</SegmentedControl.Item>
|
|
67
|
+
* </SegmentedControl.Root>
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
declare const Item: ({ "data-slot": dataSlot, className, ref, ...props }: SegmentedControlItemProps) => import("react").JSX.Element;
|
|
71
|
+
/**
|
|
72
|
+
* A row of segments that switches between a few short options, like a view
|
|
73
|
+
* or an environment. A raised thumb slides to the checked item,
|
|
74
|
+
* and a mouse or a finger can drag it. It is a radio group underneath, with
|
|
75
|
+
* the same keyboard, ARIA, and form contract as `RadioGroup`.
|
|
76
|
+
*
|
|
77
|
+
* @useWhen Switch between a few short options, like a view or an environment, in one row.
|
|
78
|
+
*
|
|
79
|
+
* @siblings
|
|
80
|
+
* - `RadioGroup`: a form field whose options need a description, or stack in a column.
|
|
81
|
+
* - `Tabs`: each option shows its own panel of content.
|
|
82
|
+
* - `Select`: the set is long, or the row has little space.
|
|
83
|
+
*
|
|
84
|
+
* @see https://mantle.ngrok.com/components/forms/segmented-control
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* Composition:
|
|
88
|
+
* ```
|
|
89
|
+
* SegmentedControl.Root
|
|
90
|
+
* └── SegmentedControl.Item
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```tsx
|
|
95
|
+
* <SegmentedControl.Root aria-label="Environment" defaultValue="production">
|
|
96
|
+
* <SegmentedControl.Item value="development">Dev</SegmentedControl.Item>
|
|
97
|
+
* <SegmentedControl.Item value="staging">Staging</SegmentedControl.Item>
|
|
98
|
+
* <SegmentedControl.Item value="production">Prod</SegmentedControl.Item>
|
|
99
|
+
* </SegmentedControl.Root>
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
declare const SegmentedControl: {
|
|
103
|
+
/**
|
|
104
|
+
* One segment of a `SegmentedControl.Root`: a `role="radio"` item that grows
|
|
105
|
+
* to share the row and keeps its label on one line.
|
|
106
|
+
*
|
|
107
|
+
* @see https://mantle.ngrok.com/components/forms/segmented-control#segmentedcontrolitem
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```tsx
|
|
111
|
+
* <SegmentedControl.Root aria-label="Environment" defaultValue="production">
|
|
112
|
+
* <SegmentedControl.Item value="development">Dev</SegmentedControl.Item>
|
|
113
|
+
* <SegmentedControl.Item value="staging">Staging</SegmentedControl.Item>
|
|
114
|
+
* <SegmentedControl.Item value="production">Prod</SegmentedControl.Item>
|
|
115
|
+
* </SegmentedControl.Root>
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
readonly Item: typeof Item;
|
|
119
|
+
/**
|
|
120
|
+
* A row of segments, one checked at a time, on a dim track. A raised thumb
|
|
121
|
+
* slides to the checked `SegmentedControl.Item`.
|
|
122
|
+
*
|
|
123
|
+
* @see https://mantle.ngrok.com/components/forms/segmented-control#segmentedcontrolroot
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```tsx
|
|
127
|
+
* <SegmentedControl.Root aria-label="Environment" defaultValue="production">
|
|
128
|
+
* <SegmentedControl.Item value="development">Dev</SegmentedControl.Item>
|
|
129
|
+
* <SegmentedControl.Item value="staging">Staging</SegmentedControl.Item>
|
|
130
|
+
* <SegmentedControl.Item value="production">Prod</SegmentedControl.Item>
|
|
131
|
+
* </SegmentedControl.Root>
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
readonly Root: typeof Root;
|
|
135
|
+
};
|
|
136
|
+
export { SegmentedControl };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{t as e}from"./css-properties-D85fCNV3.js";import{t}from"./use-composed-refs-DPYmLDSe.js";import{t as n}from"./cx-CK7o_rVv.js";import{t as r}from"./data-slot-EM6s2WEU.js";import{r as i,t as a}from"./radio-group-ggEkCi0V.js";import{t as o}from"./use-swipe-to-dismiss-BYdlca8r.js";import{t as s}from"./use-prefers-reduced-motion-Ck6dnOM9.js";import{c}from"react/compiler-runtime";import{createContext as l,useContext as u,useEffect as d,useId as f,useRef as p}from"react";import m from"tiny-invariant";import{jsx as h}from"react/jsx-runtime";const g=`--_segmented-control-thumb-offset`;function _(e,t){let n=-1,r=1/0;for(let[i,a]of e.entries()){let e=Math.abs((a.left+a.right)/2-t);!a.disabled&&e<r&&(n=i,r=e)}return n}function v({travel:e,min:t,max:n,give:r}){return e<t?t-o(t-e,r):e>n?n+o(e-n,r):e}function y(e){let t=c(3),n,r;t[0]===e?(n=t[1],r=t[2]):(n=()=>{let t=e.current;if(t==null)return;let n=null,r=!1,i=null,a=()=>t.querySelector(`:scope > [role='radio'][aria-checked='true']`),o=()=>Number.parseFloat(getComputedStyle(t,`::before`).translate)||0,c=e=>{i?.cancel(),i=null;let n=a();if(n==null||s())return;let r=e-n.getBoundingClientRect().left;Math.abs(r)<.5||(i=t.animate([{translate:`${r}px 0`},{translate:`0 0`}],{duration:200,easing:`cubic-bezier(0.23, 1, 0.32, 1)`,pseudoElement:`::before`}))},l=(e,n)=>{let r=n.getBoundingClientRect(),i=e.checkedLeft-r.left;e.checked=n,e.checkedLeft=r.left,e.checkedRight=r.right,e.base+=i,e.offset+=i,t.style.setProperty(g,`${e.offset}px`)},u=a(),d=new MutationObserver(()=>{let e=a();if(e===u)return;let t=u;u=e,n?.dragging?e!=null&&l(n,e):(n!=null&&p(),t?.isConnected&&c(t.getBoundingClientRect().left+o()))});d.observe(t,{attributeFilter:[`aria-checked`],subtree:!0});let f=e=>{t.removeAttribute(`data-dragging`),t.style.removeProperty(g);for(let t of e.segments)t.removeAttribute(`data-thumb-over`)},p=()=>{document.removeEventListener(`pointermove`,h),document.removeEventListener(`pointerup`,y),document.removeEventListener(`pointercancel`,y),n=null},m=e=>{if(!e.isPrimary||e.button!==0||n!=null)return;let r=e.target instanceof Element?e.target.closest(`[role='radio']`):null;if(!(r instanceof HTMLElement)||r.parentElement!==t||r.getAttribute(`aria-checked`)!==`true`||r.getAttribute(`aria-disabled`)===`true`)return;let i=Array.from(t.querySelectorAll(`:scope > [role='radio']`)),a=i.map(S),o=Math.min(...a.map(x)),s=Math.max(...a.map(b)),c=r.getBoundingClientRect();n={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,checked:r,checkedLeft:c.left,checkedRight:c.right,segments:i,boxes:a,trackLeft:o,trackRight:s,give:o-t.getBoundingClientRect().left-t.clientLeft,dragging:!1,base:0,offset:0,lastX:e.clientX,lastTime:e.timeStamp,velocity:0},document.addEventListener(`pointermove`,h),document.addEventListener(`pointerup`,y),document.addEventListener(`pointercancel`,y)},h=e=>{if(n==null||e.pointerId!==n.pointerId)return;if(!(e.buttons&1)){y(e);return}let r=e.clientX-n.startX;if(!n.dragging){let a=Math.abs(e.clientY-n.startY);if(a>=4&&a>Math.abs(r)){p();return}if(Math.abs(r)<4)return;n.dragging=!0,n.base=o(),i?.cancel(),i=null,t.setPointerCapture(e.pointerId),t.setAttribute(`data-dragging`,``)}let a=e.timeStamp-n.lastTime;a>0&&(n.velocity=(e.clientX-n.lastX)/a),n.lastX=e.clientX,n.lastTime=e.timeStamp,n.offset=v({travel:n.base+r,min:n.trackLeft-n.checkedLeft,max:n.trackRight-n.checkedRight,give:n.give}),t.style.setProperty(g,`${n.offset}px`);let s=(n.checkedLeft+n.checkedRight)/2,c=_(n.boxes,s+n.offset);for(let[e,t]of n.segments.entries())t.toggleAttribute(`data-thumb-over`,e===c)},y=e=>{if(n==null||e.pointerId!==n.pointerId)return;let t=n;if(p(),!t.dragging||(f(t),c(t.checkedLeft+t.offset),e.type===`pointercancel`))return;let i=e.timeStamp-t.lastTime>100?0:t.velocity,a=(t.checkedLeft+t.checkedRight)/2+t.offset+i*150,o=t.segments[_(t.boxes,a)];o!=null&&o!==t.checked&&o.click(),r=!0,window.setTimeout(()=>{r=!1},0)},C=e=>{r&&(r=!1,e.preventDefault(),e.stopPropagation())};return t.addEventListener(`pointerdown`,m),t.addEventListener(`click`,C,!0),()=>{d.disconnect(),i?.cancel(),n?.dragging&&f(n),p(),t.removeEventListener(`pointerdown`,m),t.removeEventListener(`click`,C,!0)}},r=[e],t[0]=e,t[1]=n,t[2]=r),d(n,r)}function b(e){return e.right}function x(e){return e.left}function S(e){let t=e.getBoundingClientRect();return{left:t.left,right:t.right,disabled:e.getAttribute(`aria-disabled`)===`true`}}const C=l(!1),w={Item:e=>{let t=c(14),i,o,s,l;t[0]===e?(i=t[1],o=t[2],s=t[3],l=t[4]):({"data-slot":o,className:i,ref:l,...s}=e,t[0]=e,t[1]=i,t[2]=o,t[3]=s,t[4]=l),m(u(C),`SegmentedControl.Item must be rendered inside SegmentedControl.Root.`);let d;t[5]===o?d=t[6]:(d=r(o,`segmented-control-item`),t[5]=o,t[6]=d);let f;t[7]===i?f=t[8]:(f=n(`group/radio [&_label]:cursor-inherit relative flex flex-1 select-none items-center justify-center gap-2 rounded-md px-3 text-sm`,`whitespace-nowrap`,`focus-visible:ring-focus-accent focus-visible:z-1 focus-visible:ring-4`,`cursor-pointer aria-disabled:cursor-default focus:outline-hidden`,`text-muted not-aria-disabled:hover:text-strong aria-disabled:opacity-50`,`not-aria-disabled:hover:bg-white/60 dark:not-aria-disabled:hover:bg-neutral-500/10`,`aria-checked:not-in-data-dragging:text-strong aria-checked:[anchor-name:var(--_segmented-control-thumb)]`,`data-thumb-over:text-strong`,`aria-checked:touch-pan-y`,`not-supports-[anchor-name:--a]:aria-checked:bg-card not-supports-[anchor-name:--a]:aria-checked:shadow-sm dark:not-supports-[anchor-name:--a]:aria-checked:bg-neutral-300`,i),t[7]=i,t[8]=f);let p;return t[9]!==s||t[10]!==l||t[11]!==d||t[12]!==f?(p=/* @__PURE__ */ h(a,{"data-slot":d,className:f,...s,ref:l}),t[9]=s,t[10]=l,t[11]=d,t[12]=f,t[13]=p):p=t[13],p},Root:a=>{let o=c(24),s,l,u,d,m;o[0]===a?(s=o[1],l=o[2],u=o[3],d=o[4],m=o[5]):({"data-slot":l,className:s,ref:d,style:m,...u}=a,o[0]=a,o[1]=s,o[2]=l,o[3]=u,o[4]=d,o[5]=m);let g=f(),_;if(o[6]!==g){let e;o[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=/[^\w-]/g,o[8]=e):e=o[8],_=g.replaceAll(e,``),o[6]=g,o[7]=_}else _=o[7];let v=`--segmented-control-thumb${_}`,b=p(null),x=t(d,b);y(b);let S;o[9]===l?S=o[10]:(S=r(l,`segmented-control`),o[9]=l,o[10]=S);let w;o[11]===s?w=o[12]:(w=n(`bg-neutral-500/10 relative flex h-9 flex-row flex-nowrap gap-px rounded-[0.625rem] p-1`,`before:absolute before:rounded-md before:bg-card before:shadow-sm dark:before:bg-neutral-300`,`before:[position-anchor:var(--_segmented-control-thumb)] before:top-[anchor(top)] before:left-[anchor(left)] before:w-[anchor-size(width)] before:h-[anchor-size(height)]`,`motion-safe:before:transition-[width] motion-safe:before:duration-200 motion-safe:before:ease-out-strong`,`before:translate-x-(--_segmented-control-thumb-offset,0px) data-dragging:cursor-grabbing`,`has-[[aria-checked=true]:not([aria-disabled]):hover]:before:shadow`,s),o[11]=s,o[12]=w);let T;o[13]===v?T=o[14]:(T=e({"--_segmented-control-thumb":v}),o[13]=v,o[14]=T);let E;o[15]!==m||o[16]!==T?(E={...T,...m},o[15]=m,o[16]=T,o[17]=E):E=o[17];let D;return o[18]!==x||o[19]!==u||o[20]!==S||o[21]!==w||o[22]!==E?(D=/* @__PURE__ */ h(C.Provider,{value:!0,children:/* @__PURE__ */ h(i,{"data-slot":S,className:w,style:E,...u,ref:x})}),o[18]=x,o[19]=u,o[20]=S,o[21]=w,o[22]=E,o[23]=D):D=o[23],D}};export{w as SegmentedControl};
|