@dodopayments/ui 1.0.0 → 1.0.2
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 +2 -0
- package/ai/component-registry.json +431 -88
- package/ai/components/app-top-bar.md +18 -10
- package/ai/components/bar-chart.md +5 -3
- package/ai/components/button.md +1 -1
- package/ai/components/chart-legend.md +3 -1
- package/ai/components/chart-tooltip.md +2 -2
- package/ai/components/composed-chart.md +5 -6
- package/ai/components/data-grid.md +11 -23
- package/ai/components/date-picker.md +1 -1
- package/ai/components/details-panel.md +1 -1
- package/ai/components/funnel-chart.md +12 -5
- package/ai/components/gauge-chart.md +9 -4
- package/ai/components/line-chart.md +1 -0
- package/ai/components/list-item.md +146 -6
- package/ai/components/pie-chart.md +1 -0
- package/ai/components/quantity-stepper.md +34 -2
- package/ai/components/radio-group.md +2 -2
- package/ai/components/retention-matrix.md +20 -5
- package/ai/components/ring-chart.md +7 -4
- package/ai/components/sankey-chart.md +18 -8
- package/ai/components/scatter-chart.md +4 -2
- package/ai/components/settings-section.md +1 -62
- package/ai/components/setup-guide.md +114 -118
- package/ai/components/sidebar.md +5 -0
- package/ai/components/stat-card.md +13 -14
- package/ai/components/sunburst-chart.md +138 -18
- package/ai/components/value-flash.md +74 -15
- package/ai/skills/dodo-charts/SKILL.md +3 -2
- package/ai/skills/dodo-design/SKILL.md +2 -2
- package/dist/components/button/button.d.ts +1 -1
- package/dist/components/button/button.d.ts.map +1 -1
- package/dist/components/button/button.js +5 -3
- package/dist/components/button/button.js.map +1 -1
- package/dist/components/data-grid/data-grid.d.ts +16 -13
- package/dist/components/data-grid/data-grid.d.ts.map +1 -1
- package/dist/components/data-grid/data-grid.js +17 -110
- package/dist/components/data-grid/data-grid.js.map +1 -1
- package/dist/components/data-grid/index.d.ts.map +1 -1
- package/dist/components/data-grid/index.js +1 -0
- package/dist/components/data-grid/index.js.map +1 -1
- package/dist/components/data-grid/table.d.ts +3 -6
- package/dist/components/data-grid/table.d.ts.map +1 -1
- package/dist/components/data-grid/table.js +10 -12
- package/dist/components/data-grid/table.js.map +1 -1
- package/dist/components/funnel-chart/funnel-chart.d.ts +3 -1
- package/dist/components/funnel-chart/funnel-chart.d.ts.map +1 -1
- package/dist/components/funnel-chart/funnel-chart.js +3 -1
- package/dist/components/funnel-chart/funnel-chart.js.map +1 -1
- package/dist/components/gauge-chart/gauge-chart.d.ts +3 -1
- package/dist/components/gauge-chart/gauge-chart.d.ts.map +1 -1
- package/dist/components/gauge-chart/gauge-chart.js +3 -1
- package/dist/components/gauge-chart/gauge-chart.js.map +1 -1
- package/dist/components/icon-morph/icon-morph.d.ts.map +1 -1
- package/dist/components/icon-morph/icon-morph.js +7 -4
- package/dist/components/icon-morph/icon-morph.js.map +1 -1
- package/dist/components/list-item/list-item.d.ts +21 -2
- package/dist/components/list-item/list-item.d.ts.map +1 -1
- package/dist/components/list-item/list-item.js +18 -4
- package/dist/components/list-item/list-item.js.map +1 -1
- package/dist/components/plan-picker/plan-picker.js +1 -1
- package/dist/components/plan-picker/plan-picker.js.map +1 -1
- package/dist/components/product-card/product-card.d.ts.map +1 -1
- package/dist/components/product-card/product-card.js +10 -3
- package/dist/components/product-card/product-card.js.map +1 -1
- package/dist/components/quantity-stepper/index.d.ts +1 -1
- package/dist/components/quantity-stepper/index.d.ts.map +1 -1
- package/dist/components/quantity-stepper/index.js +1 -1
- package/dist/components/quantity-stepper/index.js.map +1 -1
- package/dist/components/quantity-stepper/quantity-stepper.d.ts +33 -3
- package/dist/components/quantity-stepper/quantity-stepper.d.ts.map +1 -1
- package/dist/components/quantity-stepper/quantity-stepper.js +41 -8
- package/dist/components/quantity-stepper/quantity-stepper.js.map +1 -1
- package/dist/components/radio-group/radio-group.d.ts +6 -6
- package/dist/components/radio-group/radio-group.d.ts.map +1 -1
- package/dist/components/radio-group/radio-group.js +11 -10
- package/dist/components/radio-group/radio-group.js.map +1 -1
- package/dist/components/retention-matrix/index.d.ts +1 -1
- package/dist/components/retention-matrix/index.d.ts.map +1 -1
- package/dist/components/retention-matrix/index.js +1 -1
- package/dist/components/retention-matrix/index.js.map +1 -1
- package/dist/components/retention-matrix/retention-matrix.d.ts +32 -16
- package/dist/components/retention-matrix/retention-matrix.d.ts.map +1 -1
- package/dist/components/retention-matrix/retention-matrix.js +42 -19
- package/dist/components/retention-matrix/retention-matrix.js.map +1 -1
- package/dist/components/sankey-chart/sankey-chart.d.ts +4 -1
- package/dist/components/sankey-chart/sankey-chart.d.ts.map +1 -1
- package/dist/components/sankey-chart/sankey-chart.js +4 -1
- package/dist/components/sankey-chart/sankey-chart.js.map +1 -1
- package/dist/components/settings-section/index.d.ts.map +1 -1
- package/dist/components/settings-section/index.js +1 -0
- package/dist/components/settings-section/index.js.map +1 -1
- package/dist/components/settings-section/settings-section.d.ts +8 -5
- package/dist/components/settings-section/settings-section.d.ts.map +1 -1
- package/dist/components/settings-section/settings-section.js +8 -11
- package/dist/components/settings-section/settings-section.js.map +1 -1
- package/dist/components/setup-guide/index.d.ts +1 -1
- package/dist/components/setup-guide/index.d.ts.map +1 -1
- package/dist/components/setup-guide/index.js +1 -1
- package/dist/components/setup-guide/index.js.map +1 -1
- package/dist/components/setup-guide/setup-guide.d.ts +41 -16
- package/dist/components/setup-guide/setup-guide.d.ts.map +1 -1
- package/dist/components/setup-guide/setup-guide.js +53 -30
- package/dist/components/setup-guide/setup-guide.js.map +1 -1
- package/dist/components/sidebar/sidebar.d.ts +12 -5
- package/dist/components/sidebar/sidebar.d.ts.map +1 -1
- package/dist/components/sidebar/sidebar.js +127 -16
- package/dist/components/sidebar/sidebar.js.map +1 -1
- package/dist/components/stat-card/stat-card.d.ts +18 -11
- package/dist/components/stat-card/stat-card.d.ts.map +1 -1
- package/dist/components/stat-card/stat-card.js +18 -12
- package/dist/components/stat-card/stat-card.js.map +1 -1
- package/dist/components/sunburst-chart/index.d.ts +1 -0
- package/dist/components/sunburst-chart/index.d.ts.map +1 -1
- package/dist/components/sunburst-chart/index.js +1 -0
- package/dist/components/sunburst-chart/index.js.map +1 -1
- package/dist/components/sunburst-chart/sunburst-chart.d.ts +7 -5
- package/dist/components/sunburst-chart/sunburst-chart.d.ts.map +1 -1
- package/dist/components/sunburst-chart/sunburst-chart.js +7 -5
- package/dist/components/sunburst-chart/sunburst-chart.js.map +1 -1
- package/dist/components/value-flash/index.d.ts +1 -1
- package/dist/components/value-flash/index.d.ts.map +1 -1
- package/dist/components/value-flash/index.js +1 -1
- package/dist/components/value-flash/index.js.map +1 -1
- package/dist/components/value-flash/value-flash.d.ts +52 -0
- package/dist/components/value-flash/value-flash.d.ts.map +1 -1
- package/dist/components/value-flash/value-flash.js +37 -1
- package/dist/components/value-flash/value-flash.js.map +1 -1
- package/dist/icons/index.d.ts +6 -0
- package/dist/icons/index.js +6 -0
- package/dist/icons/ui/arrow-door-out-3.d.ts +3 -0
- package/dist/icons/ui/arrow-door-out-3.js +5 -0
- package/dist/icons/ui/circle-check-outline-duo.d.ts +3 -0
- package/dist/icons/ui/circle-check-outline-duo.d.ts.map +1 -0
- package/dist/icons/ui/circle-check-outline-duo.js +5 -0
- package/dist/icons/ui/circle-check-outline-duo.js.map +1 -0
- package/dist/icons/ui/circle-dashed-outline-duo.d.ts +3 -0
- package/dist/icons/ui/circle-dashed-outline-duo.d.ts.map +1 -0
- package/dist/icons/ui/circle-dashed-outline-duo.js +5 -0
- package/dist/icons/ui/circle-dashed-outline-duo.js.map +1 -0
- package/dist/icons/ui/circle-warning-outline-duo.d.ts +3 -0
- package/dist/icons/ui/circle-warning-outline-duo.d.ts.map +1 -0
- package/dist/icons/ui/circle-warning-outline-duo.js +5 -0
- package/dist/icons/ui/circle-warning-outline-duo.js.map +1 -0
- package/dist/icons/ui/circle-xmark-outline-duo.d.ts +3 -0
- package/dist/icons/ui/circle-xmark-outline-duo.d.ts.map +1 -0
- package/dist/icons/ui/circle-xmark-outline-duo.js +5 -0
- package/dist/icons/ui/circle-xmark-outline-duo.js.map +1 -0
- package/dist/icons/ui/clock-outline-duo.d.ts +3 -0
- package/dist/icons/ui/clock-outline-duo.d.ts.map +1 -0
- package/dist/icons/ui/clock-outline-duo.js +5 -0
- package/dist/icons/ui/clock-outline-duo.js.map +1 -0
- package/dist/lib/cn-tables.js +5 -5
- package/dist/lib/cn-tables.js.map +1 -1
- package/dist/lib/locale-messages.d.ts +6 -3
- package/dist/lib/locale-messages.d.ts.map +1 -1
- package/dist/lib/locale-messages.js +6 -3
- package/dist/lib/locale-messages.js.map +1 -1
- package/dist/locales/ar.d.ts.map +1 -1
- package/dist/locales/ar.js +1 -0
- package/dist/locales/ar.js.map +1 -1
- package/dist/locales/de.d.ts.map +1 -1
- package/dist/locales/de.js +1 -0
- package/dist/locales/de.js.map +1 -1
- package/dist/locales/es.d.ts.map +1 -1
- package/dist/locales/es.js +1 -0
- package/dist/locales/es.js.map +1 -1
- package/dist/locales/fr.d.ts.map +1 -1
- package/dist/locales/fr.js +1 -0
- package/dist/locales/fr.js.map +1 -1
- package/dist/locales/he.d.ts.map +1 -1
- package/dist/locales/he.js +1 -0
- package/dist/locales/he.js.map +1 -1
- package/dist/locales/hi.d.ts.map +1 -1
- package/dist/locales/hi.js +1 -0
- package/dist/locales/hi.js.map +1 -1
- package/dist/locales/ja.d.ts.map +1 -1
- package/dist/locales/ja.js +1 -0
- package/dist/locales/ja.js.map +1 -1
- package/dist/locales/pt-BR.d.ts.map +1 -1
- package/dist/locales/pt-BR.js +1 -0
- package/dist/locales/pt-BR.js.map +1 -1
- package/dist/locales/zh-CN.d.ts.map +1 -1
- package/dist/locales/zh-CN.js +1 -0
- package/dist/locales/zh-CN.js.map +1 -1
- package/dist/primitives/charts/bar.d.ts +11 -0
- package/dist/primitives/charts/bar.d.ts.map +1 -1
- package/dist/primitives/charts/bar.js +65 -11
- package/dist/primitives/charts/bar.js.map +1 -1
- package/dist/primitives/charts/funnel-chart.d.ts +22 -3
- package/dist/primitives/charts/funnel-chart.d.ts.map +1 -1
- package/dist/primitives/charts/funnel-chart.js +122 -110
- package/dist/primitives/charts/funnel-chart.js.map +1 -1
- package/dist/primitives/charts/gauge.d.ts +7 -0
- package/dist/primitives/charts/gauge.d.ts.map +1 -1
- package/dist/primitives/charts/gauge.js +37 -9
- package/dist/primitives/charts/gauge.js.map +1 -1
- package/dist/primitives/charts/index.d.ts +1 -0
- package/dist/primitives/charts/index.d.ts.map +1 -1
- package/dist/primitives/charts/index.js +1 -0
- package/dist/primitives/charts/index.js.map +1 -1
- package/dist/primitives/charts/legend/legend-marker.d.ts +7 -2
- package/dist/primitives/charts/legend/legend-marker.d.ts.map +1 -1
- package/dist/primitives/charts/legend/legend-marker.js +9 -3
- package/dist/primitives/charts/legend/legend-marker.js.map +1 -1
- package/dist/primitives/charts/legend/legend-progress.d.ts +6 -1
- package/dist/primitives/charts/legend/legend-progress.d.ts.map +1 -1
- package/dist/primitives/charts/legend/legend-progress.js +7 -2
- package/dist/primitives/charts/legend/legend-progress.js.map +1 -1
- package/dist/primitives/charts/loading-sweep.d.ts.map +1 -1
- package/dist/primitives/charts/loading-sweep.js +11 -2
- package/dist/primitives/charts/loading-sweep.js.map +1 -1
- package/dist/primitives/charts/pie-slice.d.ts +6 -1
- package/dist/primitives/charts/pie-slice.d.ts.map +1 -1
- package/dist/primitives/charts/pie-slice.js +26 -16
- package/dist/primitives/charts/pie-slice.js.map +1 -1
- package/dist/primitives/charts/ring.d.ts +12 -3
- package/dist/primitives/charts/ring.d.ts.map +1 -1
- package/dist/primitives/charts/ring.js +46 -9
- package/dist/primitives/charts/ring.js.map +1 -1
- package/dist/primitives/charts/sankey/sankey-link.d.ts +14 -5
- package/dist/primitives/charts/sankey/sankey-link.d.ts.map +1 -1
- package/dist/primitives/charts/sankey/sankey-link.js +34 -10
- package/dist/primitives/charts/sankey/sankey-link.js.map +1 -1
- package/dist/primitives/charts/sankey/sankey-node.d.ts +8 -2
- package/dist/primitives/charts/sankey/sankey-node.d.ts.map +1 -1
- package/dist/primitives/charts/sankey/sankey-node.js +13 -7
- package/dist/primitives/charts/sankey/sankey-node.js.map +1 -1
- package/dist/primitives/charts/scatter-chart.d.ts.map +1 -1
- package/dist/primitives/charts/scatter-chart.js +22 -8
- package/dist/primitives/charts/scatter-chart.js.map +1 -1
- package/dist/primitives/charts/scatter.d.ts +8 -3
- package/dist/primitives/charts/scatter.d.ts.map +1 -1
- package/dist/primitives/charts/scatter.js +9 -4
- package/dist/primitives/charts/scatter.js.map +1 -1
- package/dist/primitives/charts/series-bar.d.ts +5 -1
- package/dist/primitives/charts/series-bar.d.ts.map +1 -1
- package/dist/primitives/charts/series-bar.js +30 -11
- package/dist/primitives/charts/series-bar.js.map +1 -1
- package/dist/primitives/charts/series-markers.d.ts +6 -1
- package/dist/primitives/charts/series-markers.d.ts.map +1 -1
- package/dist/primitives/charts/series-markers.js +19 -8
- package/dist/primitives/charts/series-markers.js.map +1 -1
- package/dist/primitives/charts/sunburst-center.d.ts +10 -3
- package/dist/primitives/charts/sunburst-center.d.ts.map +1 -1
- package/dist/primitives/charts/sunburst-center.js +20 -12
- package/dist/primitives/charts/sunburst-center.js.map +1 -1
- package/dist/primitives/charts/sunburst-chart.d.ts +1 -1
- package/dist/primitives/charts/sunburst-chart.d.ts.map +1 -1
- package/dist/primitives/charts/sunburst-chart.js +27 -7
- package/dist/primitives/charts/sunburst-chart.js.map +1 -1
- package/dist/primitives/charts/sunburst-context.d.ts +2 -0
- package/dist/primitives/charts/sunburst-context.d.ts.map +1 -1
- package/dist/primitives/charts/sunburst-context.js +2 -0
- package/dist/primitives/charts/sunburst-context.js.map +1 -1
- package/dist/primitives/charts/sunburst-labels.d.ts.map +1 -1
- package/dist/primitives/charts/sunburst-labels.js +2 -2
- package/dist/primitives/charts/sunburst-labels.js.map +1 -1
- package/dist/primitives/charts/sunburst-legend.d.ts +19 -0
- package/dist/primitives/charts/sunburst-legend.d.ts.map +1 -0
- package/dist/primitives/charts/sunburst-legend.js +52 -0
- package/dist/primitives/charts/sunburst-legend.js.map +1 -0
- package/dist/primitives/charts/sunburst-segment.d.ts +7 -1
- package/dist/primitives/charts/sunburst-segment.d.ts.map +1 -1
- package/dist/primitives/charts/sunburst-segment.js +35 -10
- package/dist/primitives/charts/sunburst-segment.js.map +1 -1
- package/dist/primitives/charts/sunburst.d.ts +7 -5
- package/dist/primitives/charts/sunburst.d.ts.map +1 -1
- package/dist/primitives/charts/sunburst.js +24 -25
- package/dist/primitives/charts/sunburst.js.map +1 -1
- package/dist/primitives/ui/button.d.ts.map +1 -1
- package/dist/primitives/ui/button.js +3 -1
- package/dist/primitives/ui/button.js.map +1 -1
- package/dist/primitives/ui/sidebar.d.ts.map +1 -1
- package/dist/primitives/ui/sidebar.js +4 -2
- package/dist/primitives/ui/sidebar.js.map +1 -1
- package/dist/styles/theme.css +4 -0
- package/dist/styles/tokens.css +3 -1
- package/dist/styles/tokens.test.tsx +5 -2
- package/eslint/restricted-classes.js +46 -5
- package/package.json +1 -2
- package/dist/icons/ui/refresh-clockwise.d.ts.map +0 -1
- package/dist/icons/ui/refresh-clockwise.js.map +0 -1
|
@@ -7,7 +7,7 @@ slightly, and a caret pops in beside it. Changes are announced through a polite
|
|
|
7
7
|
the value settles. With reduced motion the number cross-fades and nothing moves.
|
|
8
8
|
|
|
9
9
|
```tsx
|
|
10
|
-
import { ValueFlash, useValueFlash } from "@dodopayments/ui/value-flash";
|
|
10
|
+
import { ValueFlash, ValueFlashChange, useValueFlash } from "@dodopayments/ui/value-flash";
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
## ValueFlash
|
|
@@ -27,6 +27,21 @@ the value settles. With reduced motion the number cross-fades and nothing moves.
|
|
|
27
27
|
| `hold` | `number` | `900` | How long the flash lasts, in milliseconds. |
|
|
28
28
|
| `label` | `string` | - | Names the value for assistive technology, e.g. "Balance". Announced as "Balance: $1,204". |
|
|
29
29
|
|
|
30
|
+
## ValueFlashChange
|
|
31
|
+
|
|
32
|
+
The resting look of a value flash, for a change shown next to a number (a stat card's trend): the change, then a
|
|
33
|
+
caret pointing the way it moved, on the tone's subtle tint, with no border. A `neutral` change without a `value`
|
|
34
|
+
shows "-%" in grey, read as "No change". It does not animate; a tone change fades its colours.
|
|
35
|
+
|
|
36
|
+
| Prop | Type | Default | Description |
|
|
37
|
+
| --- | --- | --- | --- |
|
|
38
|
+
| `direction` (required) | `ValueFlashChangeDirection` | - | Which way it moved: picks the caret and, without `tone`, the colour (up success, down error). |
|
|
39
|
+
| `caret` | `boolean` | `true` | Show the caret after the value. |
|
|
40
|
+
| `label` | `string` | - | Read before the value on an up or down change, e.g. "Increased by". |
|
|
41
|
+
| `noChangeLabel` | `string` | `"No change"` | Read in place of "-%" on a neutral change without a value. |
|
|
42
|
+
| `tone` | `"success" \| "error" \| "neutral"` | `"neutral"` | Overrides the colour, e.g. `error` for growth that is bad (refunds, churn). Defaults from `direction`.<br>`success`: A good change: Content/Success on the success subtle tint.<br>`error`: A bad change: Content/Error on the error subtle tint.<br>`neutral`: No change: Content/Secondary on Surface/Secondary. |
|
|
43
|
+
| `value` | `ReactNode` | - | The change, preformatted and without a sign, e.g. "24%" or "$1,204.00". Leave it out on a `neutral` change to show "-%". |
|
|
44
|
+
|
|
30
45
|
## useValueFlash
|
|
31
46
|
|
|
32
47
|
Tracks changes of a value for a flash, after interior.dev's value flash
|
|
@@ -54,32 +69,57 @@ Options of {@link useValueFlash}.
|
|
|
54
69
|
"use client";
|
|
55
70
|
|
|
56
71
|
import { Button } from "@dodopayments/ui/button";
|
|
57
|
-
import {
|
|
72
|
+
import {
|
|
73
|
+
ValueFlash,
|
|
74
|
+
ValueFlashChange,
|
|
75
|
+
type ValueFlashChangeDirection,
|
|
76
|
+
} from "@dodopayments/ui/value-flash";
|
|
58
77
|
import { useState } from "react";
|
|
59
78
|
|
|
60
79
|
const usd = new Intl.NumberFormat("en-US", { style: "currency", currency: "USD" });
|
|
80
|
+
const percent = new Intl.NumberFormat("en-US", { style: "percent", maximumFractionDigits: 1 });
|
|
81
|
+
|
|
82
|
+
interface Change {
|
|
83
|
+
direction: ValueFlashChangeDirection;
|
|
84
|
+
/** The last change as a share of the previous value, without a sign; none when nothing changed. */
|
|
85
|
+
value?: string;
|
|
86
|
+
}
|
|
61
87
|
|
|
62
88
|
export default function ValueFlashBasic() {
|
|
63
89
|
const [value, setValue] = useState(1204.5);
|
|
90
|
+
const [change, setChange] = useState<Change>({ direction: "neutral" });
|
|
91
|
+
|
|
92
|
+
/** Moves the balance by `delta` (0 for no change) and shows the move in the change chip. */
|
|
93
|
+
const move = (delta: number) => {
|
|
94
|
+
setValue((current) => current + delta);
|
|
95
|
+
setChange(
|
|
96
|
+
delta === 0
|
|
97
|
+
? { direction: "neutral" }
|
|
98
|
+
: {
|
|
99
|
+
direction: delta > 0 ? "up" : "down",
|
|
100
|
+
value: percent.format(Math.abs(delta) / value),
|
|
101
|
+
},
|
|
102
|
+
);
|
|
103
|
+
};
|
|
64
104
|
|
|
65
105
|
return (
|
|
66
106
|
<div className="flex flex-col items-center gap-3">
|
|
67
|
-
<
|
|
107
|
+
<div className="flex items-center gap-2">
|
|
108
|
+
<ValueFlash value={value} format={(v) => usd.format(v)} label="Balance" />
|
|
109
|
+
<ValueFlashChange
|
|
110
|
+
direction={change.direction}
|
|
111
|
+
value={change.value}
|
|
112
|
+
label={change.direction === "up" ? "Increased by" : "Decreased by"}
|
|
113
|
+
/>
|
|
114
|
+
</div>
|
|
68
115
|
<div className="flex gap-2">
|
|
69
|
-
<Button
|
|
70
|
-
variant="secondary"
|
|
71
|
-
onClick={() => {
|
|
72
|
-
setValue((v) => v - 25);
|
|
73
|
-
}}
|
|
74
|
-
>
|
|
116
|
+
<Button variant="secondary" onClick={() => move(-25)}>
|
|
75
117
|
Down
|
|
76
118
|
</Button>
|
|
77
|
-
<Button
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}}
|
|
82
|
-
>
|
|
119
|
+
<Button variant="secondary" onClick={() => move(0)}>
|
|
120
|
+
No change
|
|
121
|
+
</Button>
|
|
122
|
+
<Button variant="secondary" onClick={() => move(25)}>
|
|
83
123
|
Up
|
|
84
124
|
</Button>
|
|
85
125
|
</div>
|
|
@@ -88,6 +128,25 @@ export default function ValueFlashBasic() {
|
|
|
88
128
|
}
|
|
89
129
|
```
|
|
90
130
|
|
|
131
|
+
### value-flash/change
|
|
132
|
+
|
|
133
|
+
```tsx
|
|
134
|
+
"use client";
|
|
135
|
+
|
|
136
|
+
import { ValueFlashChange } from "@dodopayments/ui/value-flash";
|
|
137
|
+
|
|
138
|
+
export default function ValueFlashChangeExample() {
|
|
139
|
+
return (
|
|
140
|
+
<div className="flex flex-wrap items-center gap-3">
|
|
141
|
+
<ValueFlashChange direction="up" value="24%" label="Increased by" />
|
|
142
|
+
<ValueFlashChange direction="down" value="3.2%" label="Decreased by" />
|
|
143
|
+
<ValueFlashChange direction="up" value="8.1%" tone="error" label="Increased by" />
|
|
144
|
+
<ValueFlashChange direction="neutral" />
|
|
145
|
+
</div>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
91
150
|
### value-flash/ticker
|
|
92
151
|
|
|
93
152
|
```tsx
|
|
@@ -305,8 +305,9 @@ tooltip of the marker, not in a paragraph under the chart.
|
|
|
305
305
|
raw value with `HeatmapTooltip formatLabel`.
|
|
306
306
|
- `ChoroplethChart` takes a GeoJSON `FeatureCollection`. The library ships no map geometry. Load it
|
|
307
307
|
yourself (for example `world-atlas` with `topojson-client`).
|
|
308
|
-
- In `SunburstChart`, drill-down works with the pointer. Keep `
|
|
309
|
-
users need
|
|
308
|
+
- In `SunburstChart`, drill-down works with the pointer. Keep `SunburstLegend` (its rows zoom in) and
|
|
309
|
+
`SunburstBreadcrumb` (zooms out), because keyboard users need them. Give `SunburstCenter` a
|
|
310
|
+
`formatValue` so the hub shows the total; leave both out only in a small card.
|
|
310
311
|
- Put `FunnelChart` stages in flow order, largest first.
|
|
311
312
|
|
|
312
313
|
## Review checklist
|
|
@@ -56,7 +56,7 @@ another component library.
|
|
|
56
56
|
| A two-state icon control (theme, menu, play) | `IconMorph` | Two icons swapped with a ternary |
|
|
57
57
|
| Many hints on a row of icon buttons | `TooltipGroup` (one shared tooltip) | A `Tooltip` on each button with its own delay |
|
|
58
58
|
| The dashboard search palette (jump to a page; opens on `/` or the top bar search) | `CommandPalette` with `groups` of `{ title, description, icon, tag, href }`; the `Command` parts for a custom palette or a list on the page | A searchable `Select`; actions, settings toggles or forms in the palette; item shortcut keys |
|
|
59
|
-
| One line of a list or one small card (order lines, add-ons, saved payment methods, sessions, settings links) | `ListItem` (`layout` row / card / add) with `leading`, `title`, `description`, `trailing` (`ListItemPrice`, a Badge, a Button), `ListItemThumbnail` for products; rows in a `<ul>` with `render={<li />}` | Hand-built flex rows, a hover or selected state on a row (choices use a Radio card), a List item for tables or label/value pairs |
|
|
59
|
+
| One line of a list or one small card (order lines, add-ons, saved payment methods, sessions, settings links) | `ListItem` (`layout` row / card / tile / add) with `leading`, `title`, `description`, `trailing` (`ListItemPrice`, a Badge, a Button), `ListItemThumbnail` for products; rows in a `<ul>` with `render={<li />}`; side-by-side tiles that read in one line (add-ons with a quantity) are `layout="tile"`; settings index tiles add `href` and a `FeaturedIcon tone="info"` as `leading` | Hand-built flex rows, a hover or selected state on a row (choices use a Radio card), a List item for tables or label/value pairs |
|
|
60
60
|
| Actions on right-click | `ContextMenu` + `ContextMenuTrigger` + `ContextMenuContent` holding the Menu parts (`MenuItem`, `MenuSub` with `ContextMenuSubContent`), each action repeated in a visible `Menu` | A `Menu` opened from `onContextMenu`, or `ContextMenuItem`-style row names (removed) |
|
|
61
61
|
| Stacked sections that expand (FAQ, settings) | Stacked `Collapsible`s (`variant="card"` for settings sections) | A hand-built disclosure with `useState` and a chevron |
|
|
62
62
|
| A checkbox option with its text, help, error or settings revealed when ticked (consents, opt-ins) | `Checkbox` with `label` (+ `description`, `error`, `reveal`); several consents in a `fieldset` | A `<label>` and paragraphs hand-built around a bare `Checkbox` |
|
|
@@ -78,7 +78,7 @@ another component library.
|
|
|
78
78
|
| Compact invoice history | A `DataGrid` with number, date (`Timestamp`), amount (`Money`, integer minor units), `Badge kind="invoice" status` and a download link (Data table → Invoices) | Clickable table rows containing download and date actions |
|
|
79
79
|
| An amount of money (price, balance, refund) | `Money` with integer minor units and the ISO code (`formatMoney` for strings) | `toFixed`, dividing by 100, or a red negative amount |
|
|
80
80
|
| Entering an amount (price, refund, payout) | `Input type="money"` with `currency` (emits minor units; `onCurrencyChange` joins a currency picker; `max` + `maxLabel` adds a Max button for refundable amounts) | `QuantityStepper` or `Input type="number"` with float math |
|
|
81
|
-
| Picking how many of something (seats, add-ons) next to a price | `QuantityStepper` (`value`, `min` (default 0), `max`, `onValueChange`; whole numbers, 0 shows 0 with − disabled) | A single + button that expands into a stepper, or `Input type="number"` |
|
|
81
|
+
| Picking how many of something (seats, add-ons) next to a price | `QuantityStepper` (`value`, `min` (default 0), `max`, `onValueChange`; whole numbers, 0 shows 0 with − disabled); `size="lg"` (36) in a row with a lg Button, such as Buy now | A single + button that expands into a stepper, or `Input type="number"` |
|
|
82
82
|
| A currency conversion (settlement amount, rate, rate lock) | `FxConversion` | Two amounts and a hand-written "1 USD = ..." line |
|
|
83
83
|
| A record's fields grouped in sections (payment, customer, billing) | `DetailsPanel` | A two-column Data table |
|
|
84
84
|
| The title row at the top of every page (title, back or breadcrumb, status, up to two buttons) | `PageHeader` with `title`, `description`, `back` (one level up) or `breadcrumb` (2+ levels), `meta` (Badge, Copyable ID), `help` and `actions` (two `Button size="lg"`, one primary at most) | A text back link (‹ Products) above the title, or a Page header for an in-page section heading (use a `Card` header) |
|
|
@@ -47,7 +47,7 @@ export declare const DODO_BUTTON_VARIANTS: {
|
|
|
47
47
|
};
|
|
48
48
|
};
|
|
49
49
|
readonly link: {
|
|
50
|
-
readonly description: "Looks like an inline link but behaves as a button.";
|
|
50
|
+
readonly description: "Looks like an inline link (link colour, underlined; the underline turns solid on hover) but behaves as a button.";
|
|
51
51
|
readonly primitive: {
|
|
52
52
|
readonly variant: "link";
|
|
53
53
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/components/button/button.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAK7D,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AAQpC,OAAO,EAA2B,KAAK,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGvF,+EAA+E;AAC/E,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/components/button/button.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAK7D,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AAQpC,OAAO,EAA2B,KAAK,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGvF,+EAA+E;AAC/E,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuEvB,CAAC;AAEX,eAAO,MAAM,4BAA4B;;;CAA8C,CAAC;AAQxF,KAAK,sBAAsB,GAAG,gBAAgB,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAE5E;;;GAGG;AACH,wBAAgB,cAAc,CAAC,SAAS,GAAE,sBAA2B,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAGjG;AAED,KAAK,eAAe,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,WAAW,GAAG,UAAU,CAAC,CAAC;AAExE,UAAU,cAAe,SAAQ,sBAAsB;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,gFAAgF;IAChF,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,IAAI,CAAC;IACpC;;;OAGG;IACH,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B;;;OAGG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC7B;AAED,UAAU,cAAc;IACtB,uFAAuF;IACvF,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;IACtB,qDAAqD;IACrD,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC;CACjC;AAED,UAAU,iBAAiB;IACzB,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,aAAa,CAAC,EAAE,KAAK,CAAC;CACvB;AAED,MAAM,MAAM,WAAW,GAAG,eAAe,GAAG,cAAc,GAAG,CAAC,cAAc,GAAG,iBAAiB,CAAC,CAAC;AAElG;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,EACrB,SAAS,EACT,OAAO,EACP,IAAI,EACJ,IAAI,EACJ,aAAa,EACb,OAAO,EACP,QAAe,EACf,WAAW,EACX,MAAM,EACN,WAAoB,EACpB,SAAuB,EACvB,QAAQ,EACR,qBAAqB,EACrB,QAAQ,EACR,MAAM,EACN,GAAG,KAAK,EACT,EAAE,WAAW,qBAoKb"}
|
|
@@ -43,7 +43,7 @@ export const DODO_BUTTON_VARIANTS = {
|
|
|
43
43
|
primitive: { variant: "destructive-outline" },
|
|
44
44
|
},
|
|
45
45
|
link: {
|
|
46
|
-
description: "Looks like an inline link but behaves as a button.",
|
|
46
|
+
description: "Looks like an inline link (link colour, underlined; the underline turns solid on hover) but behaves as a button.",
|
|
47
47
|
primitive: { variant: "link" },
|
|
48
48
|
},
|
|
49
49
|
},
|
|
@@ -116,11 +116,13 @@ export function Button({ className, variant, size, icon, iconPlacement, loading,
|
|
|
116
116
|
const onSolidFill = resolvedVariant === "default" ||
|
|
117
117
|
resolvedVariant === "destructive" ||
|
|
118
118
|
resolvedVariant === "warning";
|
|
119
|
-
|
|
119
|
+
// `min-w-0` on the faces and their grid: a button squeezed below its label (`min-w-0` on the Button) lets a
|
|
120
|
+
// truncating label shrink instead of spilling out. Buttons at their natural width are unchanged.
|
|
121
|
+
const faceClasses = cn("inline-flex min-w-0 max-w-full items-center justify-center whitespace-nowrap", faceGap);
|
|
120
122
|
const label = (_jsxs(_Fragment, { children: [icon && iconPlacement === "left" ? icon : null, children, icon && iconPlacement === "right" ? icon : null] }));
|
|
121
123
|
const button = (_jsx(PrimitiveButton, { "data-slot": "button", ...primitive.props, "data-busy": busy || undefined, "data-result": outcome ?? undefined,
|
|
122
124
|
// Busy buttons stay focusable, so a keyboard user's focus is not dropped when they press Enter.
|
|
123
|
-
disabled: busy || disabled, "aria-disabled": ((busy || focusableWhenDisabled) && (busy || disabled)) || undefined, "aria-busy": busy || undefined, className: cn(MOTION_PRESS_CLASSES, primitive.className, showProgress && "overflow-hidden", className), render: _jsx(BaseButton, { ...props, focusableWhenDisabled: busy || focusableWhenDisabled, render: render }), children: showProgress ? (_jsxs(_Fragment, { children: [_jsx(LazyMotion, { features: loadDomAnimation, strict: true, children: _jsx(m.span, { "aria-hidden": "true", "data-slot": "button-progress", className: "absolute inset-0 bg-current/16", initial: false, animate: { clipPath: `inset(0 ${String(100 - clamped)}% 0 0)` }, transition: { type: "spring", stiffness: 90, damping: 20, mass: 0.5 } }) }), _jsxs("span", { "data-slot": "button-progress-label", className: "relative inline-flex items-center gap-2", children: [loadingText ?? children, _jsxs("span", { className: "tabular-nums", children: [Math.round(clamped), "%"] })] })] })) : withFaces ? (_jsx(LazyMotion, { features: loadDomAnimation, strict: true, children: _jsxs("span", { "data-slot": "button-faces", className: "grid place-items-center *:col-start-1 *:row-start-1", children: [_jsx(m.span, { "data-slot": "button-label", "aria-hidden": spinning || outcome !== null || undefined, className: faceClasses, initial: false, animate: motionFaceState(!spinning && outcome === null), transition: fade, children: label }), loading === undefined ? null : (_jsxs(m.span, { "data-slot": "button-loading", "aria-hidden": !spinning || undefined,
|
|
125
|
+
disabled: busy || disabled, "aria-disabled": ((busy || focusableWhenDisabled) && (busy || disabled)) || undefined, "aria-busy": busy || undefined, className: cn(MOTION_PRESS_CLASSES, primitive.className, showProgress && "overflow-hidden", className), render: _jsx(BaseButton, { ...props, focusableWhenDisabled: busy || focusableWhenDisabled, render: render }), children: showProgress ? (_jsxs(_Fragment, { children: [_jsx(LazyMotion, { features: loadDomAnimation, strict: true, children: _jsx(m.span, { "aria-hidden": "true", "data-slot": "button-progress", className: "absolute inset-0 bg-current/16", initial: false, animate: { clipPath: `inset(0 ${String(100 - clamped)}% 0 0)` }, transition: { type: "spring", stiffness: 90, damping: 20, mass: 0.5 } }) }), _jsxs("span", { "data-slot": "button-progress-label", className: "relative inline-flex items-center gap-2", children: [loadingText ?? children, _jsxs("span", { className: "tabular-nums", children: [Math.round(clamped), "%"] })] })] })) : withFaces ? (_jsx(LazyMotion, { features: loadDomAnimation, strict: true, children: _jsxs("span", { "data-slot": "button-faces", className: "grid min-w-0 place-items-center *:col-start-1 *:row-start-1", children: [_jsx(m.span, { "data-slot": "button-label", "aria-hidden": spinning || outcome !== null || undefined, className: faceClasses, initial: false, animate: motionFaceState(!spinning && outcome === null), transition: fade, children: label }), loading === undefined ? null : (_jsxs(m.span, { "data-slot": "button-loading", "aria-hidden": !spinning || undefined,
|
|
124
126
|
// The hidden face stays mounted to reserve its width; stop its spinner so idle buttons
|
|
125
127
|
// (`loading={false}`) do not each run an invisible infinite animation.
|
|
126
128
|
className: cn(faceClasses, !spinning && "[&_.animate-spin]:animate-none"), initial: false, animate: motionFaceState(spinning), transition: fade, children: [_jsx(Spinner, { "aria-hidden": "true", "aria-label": undefined, role: undefined, "data-slot": "button-loading-indicator" }), loadingText ?? children] })), result === undefined ? null : (_jsxs(_Fragment, { children: [_jsxs(m.span, { "data-slot": "button-success", "aria-hidden": outcome !== "success" || undefined, className: cn(faceClasses, !onSolidFill && "text-success-foreground"), initial: false, animate: motionFaceState(outcome === "success"), transition: fade, children: [_jsx(CheckIcon, { "aria-hidden": "true" }), successText] }), _jsxs(m.span, { "data-slot": "button-error", "aria-hidden": outcome !== "error" || undefined, className: cn(faceClasses, !onSolidFill && "text-destructive-foreground"), initial: false, animate: motionFaceState(outcome === "error"), transition: fade, children: [_jsx(CircleWarningIcon, { "aria-hidden": "true" }), errorText] })] }))] }) })) : (label) }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.js","sourceRoot":"","sources":["../../../src/components/button/button.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAmB,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE,OAAO,EACL,MAAM,IAAI,eAAe,EACzB,cAAc,IAAI,uBAAuB,GAC1C,MAAM,+BAAgC,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAiC,CAAC;AAC1D,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3F,OAAO,EAAE,uBAAuB,EAAyB,MAAM,uBAAuB,CAAC;AACvF,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,+EAA+E;AAC/E,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,OAAO,EAAE;QACP,OAAO,EAAE;YACP,WAAW,EACT,uJAAuJ;YACzJ,SAAS,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;SAClC;QACD,SAAS,EAAE;YACT,WAAW,EACT,6GAA6G;YAC/G,SAAS,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE;SACpC;QACD,KAAK,EAAE;YACL,WAAW,EAAE,gFAAgF;YAC7F,SAAS,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;SAChC;QACD,WAAW,EAAE;YACX,WAAW,EACT,wHAAwH;YAC1H,SAAS,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE;SACtC;QACD,OAAO,EAAE;YACP,WAAW,EACT,qIAAqI;YACvI,SAAS,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;SAClC;QACD,MAAM,EAAE;YACN,WAAW,EACT,yOAAyO;YAC3O,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE;SACjC;QACD,qBAAqB,EAAE;YACrB,WAAW,EACT,6FAA6F;YAC/F,SAAS,EAAE,EAAE,OAAO,EAAE,qBAAqB,EAAE;SAC9C;QACD,IAAI,EAAE;YACJ,WAAW,
|
|
1
|
+
{"version":3,"file":"button.js","sourceRoot":"","sources":["../../../src/components/button/button.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAmB,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE,OAAO,EACL,MAAM,IAAI,eAAe,EACzB,cAAc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K,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAC7B,8BACE,MAAC,CAAC,CAAC,IAAI,iBACK,gBAAgB,iBACb,OAAO,KAAK,SAAS,IAAI,SAAS,EAC/C,SAAS,EAAE,EAAE,CAAC,WAAW,EAAE,CAAC,WAAW,IAAI,yBAAyB,CAAC,EACrE,OAAO,EAAE,KAAK,EACd,OAAO,EAAE,eAAe,CAAC,OAAO,KAAK,SAAS,CAAC,EAC/C,UAAU,EAAE,IAAI,aAEhB,KAAC,SAAS,mBAAa,MAAM,GAAG,EAC/B,WAAW,IACL,EACT,MAAC,CAAC,CAAC,IAAI,iBACK,cAAc,iBACX,OAAO,KAAK,OAAO,IAAI,SAAS,EAC7C,SAAS,EAAE,EAAE,CAAC,WAAW,EAAE,CAAC,WAAW,IAAI,6BAA6B,CAAC,EACzE,OAAO,EAAE,KAAK,EACd,OAAO,EAAE,eAAe,CAAC,OAAO,KAAK,OAAO,CAAC,EAC7C,UAAU,EAAE,IAAI,aAEhB,KAAC,iBAAiB,mBAAa,MAAM,GAAG,EACvC,SAAS,IACH,IACR,CACJ,IACI,GACI,CACd,CAAC,CAAC,CAAC,CACF,KAAK,CACN,GACe,CACnB,CAAC;IAEF,iGAAiG;IACjG,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC;IACxC,OAAO,CACL,8BACG,MAAM,EACP,4BAAgB,eAAe,EAAC,IAAI,EAAC,QAAQ,eAAW,QAAQ,EAAC,SAAS,EAAC,SAAS,YACjF,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,GACtE,IACN,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -5,7 +5,7 @@ import { type PaginationProps } from "../pagination/pagination.tsx";
|
|
|
5
5
|
import { type DataGridBulkActionLabels, type DataGridSelection } from "./bulk-actions.tsx";
|
|
6
6
|
declare module "@tanstack/react-table" {
|
|
7
7
|
interface ColumnMeta<TData extends RowData, TValue> {
|
|
8
|
-
/** Human-readable column name
|
|
8
|
+
/** Human-readable column name, read in the sort announcement. */
|
|
9
9
|
headerTitle?: string;
|
|
10
10
|
/** Extra classes for the column's header cell. */
|
|
11
11
|
headerClassName?: string;
|
|
@@ -13,20 +13,23 @@ declare module "@tanstack/react-table" {
|
|
|
13
13
|
cellClassName?: string;
|
|
14
14
|
/** Placeholder rendered in this column's cells while `DataGrid` is loading. */
|
|
15
15
|
skeleton?: React.ReactNode;
|
|
16
|
-
/**
|
|
17
|
-
* Where the column goes on a mobile card (the card list below a 896 container): `title` (the head,
|
|
18
|
-
* usually a `DataGridCellPrimary`), `badge` and `actions` beside it, `line` (a label/value line) or
|
|
19
|
-
* `hidden`. Without any `card` meta the first column is the title and the next three are lines.
|
|
20
|
-
*/
|
|
21
|
-
card?: DataGridCardSlot;
|
|
22
16
|
/**
|
|
23
17
|
* This column takes all the spare width (the table view), e.g. a long path that truncates (add
|
|
24
18
|
* `cellClassName: "max-w-0"`). Without it, the spare width is shared so every gap between columns is equal.
|
|
25
19
|
*/
|
|
26
20
|
grow?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Where the column went on the old mobile card list. The Data table keeps the table layout at every width now (it
|
|
23
|
+
* scrolls sideways), so this has no effect.
|
|
24
|
+
* @deprecated No effect since the card list was removed. Removed in 2.0.
|
|
25
|
+
*/
|
|
26
|
+
card?: DataGridCardSlot;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* The slots of the old mobile card list (`meta.card`).
|
|
31
|
+
* @deprecated No effect since the Data table keeps its table layout at every width. Removed in 2.0.
|
|
32
|
+
*/
|
|
30
33
|
export type DataGridCardSlot = "title" | "badge" | "actions" | "line" | "hidden";
|
|
31
34
|
/** Row size (.Table row md / lg). Class-based: the height is set per cell (see `SIZE_CELL_CLASSES`). */
|
|
32
35
|
export declare const DODO_DATA_GRID_VARIANTS: {
|
|
@@ -116,17 +119,17 @@ export interface DataGridProps<TData extends RowData> extends Omit<React.Compone
|
|
|
116
119
|
*/
|
|
117
120
|
bulkActionsQueryKey?: unknown;
|
|
118
121
|
/**
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
* @
|
|
122
|
+
* Chose between the table and the old mobile card list. The table layout is used at every width now (a table wider
|
|
123
|
+
* than its container scrolls sideways), so this has no effect.
|
|
124
|
+
* @deprecated No effect since the card list was removed. Removed in 2.0.
|
|
122
125
|
*/
|
|
123
126
|
layout?: "auto" | "table" | "cards";
|
|
124
127
|
}
|
|
125
128
|
/**
|
|
126
129
|
* The Dodo Nest Data table, driven by a TanStack Table v8 instance: the column headers on a grey tray,
|
|
127
130
|
* the rows (`size` md 48 / lg 64) on the white panel inside it, skeleton rows while `isLoading`, and
|
|
128
|
-
* `emptyMessage` centred in the panel when there are no rows.
|
|
129
|
-
*
|
|
131
|
+
* `emptyMessage` centred in the panel when there are no rows. It keeps the table layout at every width:
|
|
132
|
+
* a table wider than its container scrolls sideways (the container is then a tab stop). It sets
|
|
130
133
|
* `aria-sort` on sortable headers and marks selected rows `data-state="selected"` (they keep their
|
|
131
134
|
* colour; the checkbox shows the selection). Sorting, selection and pagination stay in the table
|
|
132
135
|
* instance; pair it with `DataGridColumnHeader`, `DataGridRowSelect(All)` and `DataGridPagination`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-grid.d.ts","sourceRoot":"","sources":["../../../src/components/data-grid/data-grid.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,MAAM,EAGX,KAAK,GAAG,EACR,KAAK,OAAO,EACZ,KAAK,KAAK,IAAI,aAAa,EAC5B,MAAM,uBAAuB,CAAC;AAK/B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,EAAkB,KAAK,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAI9E,OAAO,EAAc,KAA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CAAC,KAAK,CAAC,qBAY/B;AAED,MAAM,WAAW,yBAAyB,CAAC,KAAK,SAAS,OAAO;IAC9D,yCAAyC;IACzC,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;IAC5B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,SAAS,OAAO,EAAE,EAC1D,KAAK,EACL,YAAY,EAAE,SAAS,GACxB,EAAE,yBAAyB,CAAC,KAAK,CAAC,qBAelC;AAED,MAAM,WAAW,uBAAuB,CAAC,KAAK,SAAS,OAAO,CAC5D,SAAQ,IAAI,CACV,eAAe,EACb,OAAO,GACP,aAAa,GACb,SAAS,GACT,YAAY,GACZ,QAAQ,GACR,aAAa,GACb,qBAAqB,CACxB;IACD,mCAAmC;IACnC,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;CAC7B;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,SAAS,OAAO,EAAE,EACxD,KAAK,EACL,GAAG,KAAK,EACT,EAAE,uBAAuB,CAAC,KAAK,CAAC,qBAiChC"}
|
|
@@ -19,6 +19,7 @@ import { loadDomAnimation } from "../../lib/motion-features.js";
|
|
|
19
19
|
import { DataGridBulkActionBar, } from "./bulk-actions.js";
|
|
20
20
|
import { columnTitle } from "./column-title.js";
|
|
21
21
|
import { InsertedRowStyles, useInsertedRows } from "./inserted-rows.js";
|
|
22
|
+
import { warnDeprecated } from "../../lib/deprecation.js";
|
|
22
23
|
import { useLocale } from "../../lib/locale.js";
|
|
23
24
|
/** Row size (.Table row md / lg). Class-based: the height is set per cell (see `SIZE_CELL_CLASSES`). */
|
|
24
25
|
export const DODO_DATA_GRID_VARIANTS = {
|
|
@@ -151,27 +152,6 @@ key) {
|
|
|
151
152
|
};
|
|
152
153
|
}, [root, apply]);
|
|
153
154
|
}
|
|
154
|
-
/** Below this width (a ~960 main panel, `@4xl`) the rows become a card list. */
|
|
155
|
-
const CARD_BREAKPOINT_PX = 896;
|
|
156
|
-
/** Whether the element is narrower than the card breakpoint, measured as it resizes. */
|
|
157
|
-
function useNarrow() {
|
|
158
|
-
const [narrow, setNarrow] = React.useState(false);
|
|
159
|
-
const observer = React.useRef(null);
|
|
160
|
-
const ref = React.useCallback((node) => {
|
|
161
|
-
observer.current?.disconnect();
|
|
162
|
-
observer.current = null;
|
|
163
|
-
if (!node)
|
|
164
|
-
return;
|
|
165
|
-
const update = (width) => setNarrow(width > 0 && width < CARD_BREAKPOINT_PX);
|
|
166
|
-
update(node.getBoundingClientRect().width);
|
|
167
|
-
observer.current = new ResizeObserver(([entry]) => {
|
|
168
|
-
if (entry)
|
|
169
|
-
update(entry.contentRect.width);
|
|
170
|
-
});
|
|
171
|
-
observer.current.observe(node);
|
|
172
|
-
}, []);
|
|
173
|
-
return [ref, narrow];
|
|
174
|
-
}
|
|
175
155
|
const DataGridContext = React.createContext({ isLoading: false });
|
|
176
156
|
/**
|
|
177
157
|
* Row reorder after a sort, after interior.dev's sortable table: each row glides from its old
|
|
@@ -198,8 +178,8 @@ function ariaSort(column) {
|
|
|
198
178
|
/**
|
|
199
179
|
* The Dodo Nest Data table, driven by a TanStack Table v8 instance: the column headers on a grey tray,
|
|
200
180
|
* the rows (`size` md 48 / lg 64) on the white panel inside it, skeleton rows while `isLoading`, and
|
|
201
|
-
* `emptyMessage` centred in the panel when there are no rows.
|
|
202
|
-
*
|
|
181
|
+
* `emptyMessage` centred in the panel when there are no rows. It keeps the table layout at every width:
|
|
182
|
+
* a table wider than its container scrolls sideways (the container is then a tab stop). It sets
|
|
203
183
|
* `aria-sort` on sortable headers and marks selected rows `data-state="selected"` (they keep their
|
|
204
184
|
* colour; the checkbox shows the selection). Sorting, selection and pagination stay in the table
|
|
205
185
|
* instance; pair it with `DataGridColumnHeader`, `DataGridRowSelect(All)` and `DataGridPagination`
|
|
@@ -207,18 +187,24 @@ function ariaSort(column) {
|
|
|
207
187
|
* live region announces the new sort. `bulkActions` adds a sticky "N selected" bar with actions for
|
|
208
188
|
* the selected rows.
|
|
209
189
|
*/
|
|
210
|
-
export function DataGrid({ table, isLoading = false, loadingRows, emptyMessage = "No data available", onRowClick, size, className, "aria-label": ariaLabel, animateSort = true, formatSortAnnouncement = defaultSortAnnouncement, bulkActions, bulkActionLabels, bulkActionsQueryKey,
|
|
211
|
-
|
|
212
|
-
|
|
190
|
+
export function DataGrid({ table, isLoading = false, loadingRows, emptyMessage = "No data available", onRowClick, size, className, "aria-label": ariaLabel, animateSort = true, formatSortAnnouncement = defaultSortAnnouncement, bulkActions, bulkActionLabels, bulkActionsQueryKey,
|
|
191
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- read only to warn
|
|
192
|
+
layout, ref, ...props }) {
|
|
193
|
+
const usesCardMeta = table
|
|
194
|
+
.getAllLeafColumns()
|
|
195
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- read only to warn
|
|
196
|
+
.some((column) => column.columnDef.meta?.card !== undefined);
|
|
197
|
+
if (layout !== undefined || usesCardMeta) {
|
|
198
|
+
warnDeprecated("DataGrid `layout` and column `meta.card`", "The Data table keeps its table layout at every width and scrolls sideways, so they have no effect. Remove them; they are removed in 2.0.");
|
|
199
|
+
}
|
|
213
200
|
const [rootNode, setRootNode] = React.useState(null);
|
|
214
201
|
const rootRef = React.useCallback((node) => {
|
|
215
|
-
measureRef(node);
|
|
216
202
|
setRootNode(node);
|
|
217
203
|
if (typeof ref === "function")
|
|
218
204
|
ref(node);
|
|
219
205
|
else if (ref)
|
|
220
206
|
ref.current = node;
|
|
221
|
-
}, [
|
|
207
|
+
}, [ref]);
|
|
222
208
|
const visibleColumns = table.getVisibleLeafColumns();
|
|
223
209
|
const sized = ownSizedColumns(table);
|
|
224
210
|
const gapCount = visibleColumns.filter((_, index) => takesGap(visibleColumns, index)).length;
|
|
@@ -228,7 +214,7 @@ export function DataGrid({ table, isLoading = false, loadingRows, emptyMessage =
|
|
|
228
214
|
const rows = table.getRowModel().rows;
|
|
229
215
|
// Measured again when the rows, the loading state (skeletons swap for cells) or the visible columns change.
|
|
230
216
|
const gapsKey = `${String(isLoading)}|${visibleColumns.map((column) => column.id).join(",")}`;
|
|
231
|
-
useEvenGaps(rootNode,
|
|
217
|
+
useEvenGaps(rootNode, growId === undefined, gapCount, rows, gapsKey);
|
|
232
218
|
const insertedRows = useInsertedRows(table.getCoreRowModel().rows);
|
|
233
219
|
const skeletonCount = Math.max(1, loadingRows ?? table.getState().pagination.pageSize);
|
|
234
220
|
const context = React.useMemo(() => ({ isLoading }), [isLoading]);
|
|
@@ -315,7 +301,7 @@ export function DataGrid({ table, isLoading = false, loadingRows, emptyMessage =
|
|
|
315
301
|
onRowClick(row.original);
|
|
316
302
|
}
|
|
317
303
|
};
|
|
318
|
-
return (_jsx(DataGridContext.Provider, { value: context, children: _jsxs("div", { ref: rootRef, "data-slot": "data-grid",
|
|
304
|
+
return (_jsx(DataGridContext.Provider, { value: context, children: _jsxs("div", { ref: rootRef, "data-slot": "data-grid", className: dataGridVariants({ size }, className), ...props, children: [_jsx(InsertedRowStyles, {}), _jsxs(Table, { "aria-label": ariaLabel, "aria-busy": isLoading || undefined, className: "table-auto text-start", containerProps: { "aria-label": ariaLabel }, children: [_jsx(TableHeader, { "data-slot": "data-grid-header", children: table.getHeaderGroups().map((headerGroup) => (_jsx(TableRow, { "data-slot": "data-grid-header-row", children: headerGroup.headers.map((header) => (_jsx(TableHead, { "data-slot": "data-grid-head", colSpan: header.colSpan, "aria-sort": header.isPlaceholder ? undefined : ariaSort(header.column), style: sized(header.column.id) ? { width: header.getSize() } : undefined, className: cn(widthClass(header.column, growId, sized),
|
|
319
305
|
// A group header starts at its first leaf column, so it lines up with the cells below.
|
|
320
306
|
takesGap(visibleColumns, visibleColumns.indexOf(header.getLeafHeaders()[0]?.column ?? header.column)) && "ps-(--data-grid-gap,--spacing(4))", header.column.columnDef.meta?.headerClassName), children: header.isPlaceholder
|
|
321
307
|
? null
|
|
@@ -325,75 +311,7 @@ export function DataGrid({ table, isLoading = false, loadingRows, emptyMessage =
|
|
|
325
311
|
return (_jsx(TableRow, { "data-slot": "data-grid-row", "data-row-id": row.id, "data-inserted": insertedRows.has(row.id) || undefined, "data-state": selected ? "selected" : undefined, tabIndex: onRowClick ? 0 : undefined, onClick: onRowClick ? (event) => handleRowClick(row, event) : undefined, onKeyDown: onRowClick ? (event) => handleRowKeyDown(row, event) : undefined, className: cn(onRowClick &&
|
|
326
312
|
"cursor-pointer outline-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring"), children: row.getVisibleCells().map((cell) => (_jsx(TableCell, { "data-slot": "data-grid-cell", className: cn(widthClass(cell.column, growId, sized), takesGap(visibleColumns, visibleColumns.indexOf(cell.column)) &&
|
|
327
313
|
"ps-(--data-grid-gap,--spacing(4))", sizeClasses, cell.column.columnDef.meta?.cellClassName), children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))) }, row.id));
|
|
328
|
-
})) : (_jsx(TableRow, { "data-slot": "data-grid-empty-row", className: "*:hover:bg-background", children: _jsx(TableCell, { "data-slot": "data-grid-empty", colSpan: Math.max(1, visibleColumns.length), className: "h-auto py-12 text-center whitespace-normal text-muted-foreground", children: emptyMessage }) })) })] })
|
|
329
|
-
}
|
|
330
|
-
/** Where each visible column goes on a card: `meta.card`, else the first is the title and the next three are lines. */
|
|
331
|
-
function cardSlots(columns) {
|
|
332
|
-
const slots = new Map();
|
|
333
|
-
const explicit = columns.some((column) => column.columnDef.meta?.card !== undefined);
|
|
334
|
-
let lines = 0;
|
|
335
|
-
for (const column of columns) {
|
|
336
|
-
const meta = column.columnDef.meta?.card;
|
|
337
|
-
if (explicit) {
|
|
338
|
-
slots.set(column.id, meta ?? "hidden");
|
|
339
|
-
continue;
|
|
340
|
-
}
|
|
341
|
-
// The selection column has no accessor; the card shows no checkbox.
|
|
342
|
-
if (column.accessorFn === undefined && !slots.size) {
|
|
343
|
-
slots.set(column.id, "hidden");
|
|
344
|
-
continue;
|
|
345
|
-
}
|
|
346
|
-
if (![...slots.values()].includes("title"))
|
|
347
|
-
slots.set(column.id, "title");
|
|
348
|
-
else if (lines < 3) {
|
|
349
|
-
slots.set(column.id, "line");
|
|
350
|
-
lines += 1;
|
|
351
|
-
}
|
|
352
|
-
else
|
|
353
|
-
slots.set(column.id, "hidden");
|
|
354
|
-
}
|
|
355
|
-
return slots;
|
|
356
|
-
}
|
|
357
|
-
/**
|
|
358
|
-
* The card list below a 896 container (.Table card): one card per row in the white panel, 12/16 padding,
|
|
359
|
-
* the title with its badge and actions on top and label/value lines under it, a divider between cards.
|
|
360
|
-
*/
|
|
361
|
-
function DataGridCards({ table, isLoading, skeletonCount, emptyMessage, onRowClick, ariaLabel, }) {
|
|
362
|
-
const { messages } = useLocale();
|
|
363
|
-
const columns = table.getVisibleLeafColumns();
|
|
364
|
-
const slots = cardSlots(columns);
|
|
365
|
-
const rows = table.getRowModel().rows;
|
|
366
|
-
// The cards have no column headers, so the sortable columns get their sort buttons here.
|
|
367
|
-
const sortable = columns.filter((column) => column.getCanSort());
|
|
368
|
-
return (_jsxs("div", { "data-slot": "data-grid-cards", className: "rounded-2xl bg-muted p-1", children: [sortable.length > 0 ? (_jsxs("div", { role: "group", "aria-label": messages.dataGridSortBy, "data-slot": "data-grid-card-sort", className: "flex flex-wrap items-center gap-x-3 gap-y-1 px-3 py-2 text-label-secondary text-muted-foreground", children: [_jsx("span", { "aria-hidden": "true", children: messages.dataGridSortBy }), sortable.map((column) => (_jsx(DataGridSortButton, { column: column, disabled: isLoading }, column.id)))] })) : null, _jsx("ul", { "aria-label": ariaLabel, "aria-busy": isLoading || undefined, className: "divide-y divide-border overflow-hidden rounded-xl bg-background shadow-panel", children: isLoading ? (Array.from({ length: skeletonCount }, (_, index) => (_jsxs("li", { "data-slot": "data-grid-card-skeleton", className: "flex flex-col gap-2 px-4 py-3", children: [_jsx(Skeleton, { className: "h-4 w-40" }), _jsx(Skeleton, { className: "h-4 w-full" }), _jsx(Skeleton, { className: "h-4 w-2/3" })] }, index)))) : rows.length === 0 ? (_jsx("li", { "data-slot": "data-grid-card-empty", className: "px-4 py-12 text-center text-muted-foreground", children: emptyMessage })) : (rows.map((row) => {
|
|
369
|
-
const cells = row.getVisibleCells();
|
|
370
|
-
const render = (slot) => cells
|
|
371
|
-
.filter((cell) => slots.get(cell.column.id) === slot)
|
|
372
|
-
.map((cell) => (_jsx(React.Fragment, { children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id)));
|
|
373
|
-
const lineCells = cells.filter((cell) => slots.get(cell.column.id) === "line");
|
|
374
|
-
return (_jsxs("li", { "data-slot": "data-grid-card", "data-state": row.getIsSelected() ? "selected" : undefined,
|
|
375
|
-
// eslint-disable-next-line jsx-a11y-x/no-noninteractive-tabindex -- mirrors the row of the table
|
|
376
|
-
tabIndex: onRowClick ? 0 : undefined, onClick: onRowClick
|
|
377
|
-
? (event) => {
|
|
378
|
-
const target = event.target;
|
|
379
|
-
if (target instanceof Element && target.closest(INTERACTIVE_SELECTOR))
|
|
380
|
-
return;
|
|
381
|
-
if (target instanceof Node && !event.currentTarget.contains(target))
|
|
382
|
-
return;
|
|
383
|
-
onRowClick(row.original);
|
|
384
|
-
}
|
|
385
|
-
: undefined, onKeyDown: onRowClick
|
|
386
|
-
? (event) => {
|
|
387
|
-
if (event.target !== event.currentTarget)
|
|
388
|
-
return;
|
|
389
|
-
if (event.key === "Enter" || event.key === " ") {
|
|
390
|
-
event.preventDefault();
|
|
391
|
-
onRowClick(row.original);
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
: undefined, className: cn("flex flex-col gap-2 px-4 py-3", onRowClick &&
|
|
395
|
-
"cursor-pointer outline-none hover:bg-muted focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-brand-border"), children: [_jsxs("div", { "data-slot": "data-grid-card-head", className: "flex items-start gap-2", children: [_jsx("div", { className: "min-w-0 flex-1 text-label-primary text-foreground", children: render("title") }), render("badge"), render("actions")] }), lineCells.length > 0 ? (_jsx("dl", { "data-slot": "data-grid-card-fields", className: "grid grid-cols-[auto_minmax(0,1fr)] items-baseline gap-x-3 gap-y-1", children: lineCells.map((cell) => (_jsxs("div", { className: "contents", children: [_jsx("dt", { className: "text-body-secondary text-muted-foreground", children: columnTitle(cell.column) }), _jsx("dd", { "data-slot": "data-grid-card-value", className: "min-w-0 truncate text-end text-body-primary text-foreground has-[>[data-slot=data-grid-cell-date]]:contents", children: flexRender(cell.column.columnDef.cell, cell.getContext()) })] }, cell.id))) })) : null] }, row.id));
|
|
396
|
-
})) })] }));
|
|
314
|
+
})) : (_jsx(TableRow, { "data-slot": "data-grid-empty-row", className: "*:hover:bg-background", children: _jsx(TableCell, { "data-slot": "data-grid-empty", colSpan: Math.max(1, visibleColumns.length), className: "h-auto py-12 text-center whitespace-normal text-muted-foreground", children: emptyMessage }) })) })] }), bulkActions === undefined ? null : (_jsx(DataGridBulkActionBar, { table: table, actions: bulkActions, labels: bulkActionLabels, queryKey: bulkActionsQueryKey })), _jsx("span", { "data-slot": "data-grid-status", role: "status", "aria-live": "polite", className: "sr-only", children: announcement })] }) }));
|
|
397
315
|
}
|
|
398
316
|
/**
|
|
399
317
|
* Column header label (.Table header cell): Labels/Secondary in Content/Secondary, with 12px icons 4
|
|
@@ -422,17 +340,6 @@ function cycleSort(column) {
|
|
|
422
340
|
else
|
|
423
341
|
column.toggleSorting(false);
|
|
424
342
|
}
|
|
425
|
-
/** A sort button of the card layout: the column title and its sort icon, with the sort state in `aria-pressed`. */
|
|
426
|
-
function DataGridSortButton({ column, disabled, }) {
|
|
427
|
-
const { messages } = useLocale();
|
|
428
|
-
const sorted = column.getIsSorted();
|
|
429
|
-
const state = sorted === "asc"
|
|
430
|
-
? messages.dataGridSortAscending
|
|
431
|
-
: sorted === "desc"
|
|
432
|
-
? messages.dataGridSortDescending
|
|
433
|
-
: null;
|
|
434
|
-
return (_jsxs("button", { type: "button", "data-slot": "data-grid-card-sort-button", "data-sort": sorted || "none", "aria-pressed": sorted !== false, disabled: disabled, onClick: () => cycleSort(column), className: "inline-flex min-h-6 items-center gap-1 rounded-sm text-foreground outline-none focus-visible:outline-1 focus-visible:outline-solid focus-visible:outline-brand-border focus-visible:ring-2 focus-visible:ring-brand-subtle disabled:cursor-not-allowed [&_svg]:size-3", children: [_jsx("span", { children: columnTitle(column) }), state ? _jsxs("span", { className: "sr-only", children: [", ", state] }) : null, _jsx(DataGridSortIcon, { sorted: sorted })] }));
|
|
435
|
-
}
|
|
436
343
|
/**
|
|
437
344
|
* Sort indicator of `DataGridColumnHeader`, after interior.dev's sortable table. A neutral caret
|
|
438
345
|
* shows while the column is unsorted. When the column is sorted, one arrow fades in and turns on a
|