@seekalfred/primitives 0.6.0 → 0.7.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 +19 -11
- package/dist/activity-heatmap/activity-heatmap.d.ts +92 -0
- package/dist/activity-heatmap/activity-heatmap.js +699 -0
- package/dist/activity-heatmap/activity-heatmap.js.map +1 -0
- package/dist/activity-heatmap/index.d.ts +2 -0
- package/dist/activity-heatmap/index.js +2 -0
- package/dist/alert/alert.d.ts +5 -1
- package/dist/alert/alert.js +68 -7
- package/dist/alert/alert.js.map +1 -1
- package/dist/alert-dialog/alert-dialog.d.ts +45 -18
- package/dist/alert-dialog/alert-dialog.js +128 -9
- package/dist/alert-dialog/alert-dialog.js.map +1 -1
- package/dist/alert-dialog/index.d.ts +2 -2
- package/dist/alert-dialog/index.js +2 -2
- package/dist/animated-counter/animated-counter.d.ts +38 -0
- package/dist/animated-counter/animated-counter.js +230 -0
- package/dist/animated-counter/animated-counter.js.map +1 -0
- package/dist/animated-counter/index.d.ts +2 -0
- package/dist/animated-counter/index.js +2 -0
- package/dist/announcement-bar/announcement-bar.d.ts +67 -0
- package/dist/announcement-bar/announcement-bar.js +364 -0
- package/dist/announcement-bar/announcement-bar.js.map +1 -0
- package/dist/announcement-bar/index.d.ts +2 -0
- package/dist/announcement-bar/index.js +2 -0
- package/dist/badge/badge.d.ts +1 -1
- package/dist/bar-chart/bar-chart.d.ts +51 -0
- package/dist/bar-chart/bar-chart.js +565 -0
- package/dist/bar-chart/bar-chart.js.map +1 -0
- package/dist/bar-chart/index.d.ts +2 -0
- package/dist/bar-chart/index.js +2 -0
- package/dist/breadcrumb/breadcrumb.d.ts +2 -2
- package/dist/breadcrumb/breadcrumb.js +12 -3
- package/dist/breadcrumb/breadcrumb.js.map +1 -1
- package/dist/brush-chart/brush-chart.d.ts +64 -0
- package/dist/brush-chart/brush-chart.js +1056 -0
- package/dist/brush-chart/brush-chart.js.map +1 -0
- package/dist/brush-chart/index.d.ts +2 -0
- package/dist/brush-chart/index.js +2 -0
- package/dist/button/button.d.ts +2 -2
- package/dist/button/button.js +31 -21
- package/dist/button/button.js.map +1 -1
- package/dist/button-group/button-group.js +3 -4
- package/dist/button-group/button-group.js.map +1 -1
- package/dist/card/card.js +1 -1
- package/dist/card/card.js.map +1 -1
- package/dist/card-stack/card-stack.d.ts +54 -0
- package/dist/card-stack/card-stack.js +492 -0
- package/dist/card-stack/card-stack.js.map +1 -0
- package/dist/card-stack/index.d.ts +2 -0
- package/dist/card-stack/index.js +2 -0
- package/dist/carousel/carousel.d.ts +56 -0
- package/dist/carousel/carousel.js +389 -0
- package/dist/carousel/carousel.js.map +1 -0
- package/dist/carousel/index.d.ts +2 -0
- package/dist/carousel/index.js +2 -0
- package/dist/checkbox/checkbox.js +4 -4
- package/dist/checkbox/checkbox.js.map +1 -1
- package/dist/chip-group/chip-group.d.ts +37 -0
- package/dist/chip-group/chip-group.js +148 -0
- package/dist/chip-group/chip-group.js.map +1 -0
- package/dist/chip-group/index.d.ts +2 -0
- package/dist/chip-group/index.js +2 -0
- package/dist/countdown/countdown.d.ts +45 -0
- package/dist/countdown/countdown.js +298 -0
- package/dist/countdown/countdown.js.map +1 -0
- package/dist/countdown/index.d.ts +2 -0
- package/dist/countdown/index.js +2 -0
- package/dist/date-picker/picker-parts.js +1 -1
- package/dist/date-picker/picker-parts.js.map +1 -1
- package/dist/dialog/dialog.js +1 -1
- package/dist/dialog/dialog.js.map +1 -1
- package/dist/donut-chart/donut-chart.d.ts +64 -0
- package/dist/donut-chart/donut-chart.js +576 -0
- package/dist/donut-chart/donut-chart.js.map +1 -0
- package/dist/donut-chart/index.d.ts +2 -0
- package/dist/donut-chart/index.js +2 -0
- package/dist/empty-state/empty-state.d.ts +21 -10
- package/dist/empty-state/empty-state.js +32 -26
- package/dist/empty-state/empty-state.js.map +1 -1
- package/dist/empty-state/index.d.ts +2 -2
- package/dist/empty-state/index.js +2 -2
- package/dist/file-drop-zone/file-drop-zone.js +1 -1
- package/dist/file-drop-zone/file-drop-zone.js.map +1 -1
- package/dist/filter-bar/filter-bar.d.ts +47 -26
- package/dist/filter-bar/filter-bar.js +272 -156
- package/dist/filter-bar/filter-bar.js.map +1 -1
- package/dist/gauge/gauge.d.ts +45 -0
- package/dist/gauge/gauge.js +219 -0
- package/dist/gauge/gauge.js.map +1 -0
- package/dist/gauge/index.d.ts +2 -0
- package/dist/gauge/index.js +2 -0
- package/dist/in-view-title/in-view-title.d.ts +33 -0
- package/dist/in-view-title/in-view-title.js +119 -0
- package/dist/in-view-title/in-view-title.js.map +1 -0
- package/dist/in-view-title/index.d.ts +2 -0
- package/dist/in-view-title/index.js +2 -0
- package/dist/index.d.ts +49 -6
- package/dist/index.js +48 -8
- package/dist/lib/cn.js +11 -1
- package/dist/lib/cn.js.map +1 -1
- package/dist/lib/field-message.js +28 -10
- package/dist/lib/field-message.js.map +1 -1
- package/dist/lib/field-surface.js +9 -8
- package/dist/lib/field-surface.js.map +1 -1
- package/dist/lib/flag-emoji.js +50 -0
- package/dist/lib/flag-emoji.js.map +1 -0
- package/dist/lib/flip.js +11 -3
- package/dist/lib/flip.js.map +1 -1
- package/dist/lib/menu-highlight.js +64 -0
- package/dist/lib/menu-highlight.js.map +1 -0
- package/dist/lib/motion.js +9 -2
- package/dist/lib/motion.js.map +1 -1
- package/dist/lib/rolling-value.js +1 -1
- package/dist/lib/rolling-value.js.map +1 -1
- package/dist/lib/spring-tween.js +500 -0
- package/dist/lib/spring-tween.js.map +1 -0
- package/dist/lib/swap-text.js +3 -1
- package/dist/lib/swap-text.js.map +1 -1
- package/dist/line-chart/index.d.ts +2 -0
- package/dist/line-chart/index.js +2 -0
- package/dist/line-chart/line-chart.d.ts +76 -0
- package/dist/line-chart/line-chart.js +611 -0
- package/dist/line-chart/line-chart.js.map +1 -0
- package/dist/mention-input/index.d.ts +2 -0
- package/dist/mention-input/index.js +2 -0
- package/dist/mention-input/mention-input.d.ts +98 -0
- package/dist/mention-input/mention-input.js +576 -0
- package/dist/mention-input/mention-input.js.map +1 -0
- package/dist/menu/menu.d.ts +2 -0
- package/dist/menu/menu.js +23 -12
- package/dist/menu/menu.js.map +1 -1
- package/dist/money-input/index.d.ts +2 -0
- package/dist/money-input/index.js +2 -0
- package/dist/money-input/money-input.d.ts +65 -0
- package/dist/money-input/money-input.js +607 -0
- package/dist/money-input/money-input.js.map +1 -0
- package/dist/morph-select/index.d.ts +2 -0
- package/dist/morph-select/index.js +2 -0
- package/dist/morph-select/morph-select.d.ts +71 -0
- package/dist/morph-select/morph-select.js +693 -0
- package/dist/morph-select/morph-select.js.map +1 -0
- package/dist/multi-select/index.d.ts +2 -0
- package/dist/multi-select/index.js +2 -0
- package/dist/multi-select/multi-select.d.ts +36 -0
- package/dist/multi-select/multi-select.js +152 -0
- package/dist/multi-select/multi-select.js.map +1 -0
- package/dist/number-field/index.d.ts +2 -0
- package/dist/number-field/index.js +2 -0
- package/dist/number-field/number-field.d.ts +42 -0
- package/dist/number-field/number-field.js +199 -0
- package/dist/number-field/number-field.js.map +1 -0
- package/dist/onboarding-checklist/index.d.ts +2 -0
- package/dist/onboarding-checklist/index.js +2 -0
- package/dist/onboarding-checklist/onboarding-checklist.d.ts +55 -0
- package/dist/onboarding-checklist/onboarding-checklist.js +577 -0
- package/dist/onboarding-checklist/onboarding-checklist.js.map +1 -0
- package/dist/password-field/password-field.js +2 -2
- package/dist/password-field/password-field.js.map +1 -1
- package/dist/phone-input/index.d.ts +3 -0
- package/dist/phone-input/index.js +3 -0
- package/dist/phone-input/phone-countries.d.ts +29 -0
- package/dist/phone-input/phone-countries.js +170 -0
- package/dist/phone-input/phone-countries.js.map +1 -0
- package/dist/phone-input/phone-input.d.ts +66 -0
- package/dist/phone-input/phone-input.js +440 -0
- package/dist/phone-input/phone-input.js.map +1 -0
- package/dist/popover/popover.d.ts +12 -0
- package/dist/popover/popover.js +31 -7
- package/dist/popover/popover.js.map +1 -1
- package/dist/progress/progress.js +1 -1
- package/dist/radio-group/radio-group.js +1 -1
- package/dist/radio-group/radio-group.js.map +1 -1
- package/dist/reactions/index.d.ts +2 -0
- package/dist/reactions/index.js +2 -0
- package/dist/reactions/reactions.d.ts +50 -0
- package/dist/reactions/reactions.js +315 -0
- package/dist/reactions/reactions.js.map +1 -0
- package/dist/rich-text-editor/index.d.ts +3 -0
- package/dist/rich-text-editor/index.js +2 -0
- package/dist/rich-text-editor/rich-text-editor.d.ts +70 -0
- package/dist/rich-text-editor/rich-text-editor.js +909 -0
- package/dist/rich-text-editor/rich-text-editor.js.map +1 -0
- package/dist/rich-text-editor/rich-text-engine.d.ts +16 -0
- package/dist/rich-text-editor/rich-text-engine.js +366 -0
- package/dist/rich-text-editor/rich-text-engine.js.map +1 -0
- package/dist/rich-text-editor/rich-text-html.js +174 -0
- package/dist/rich-text-editor/rich-text-html.js.map +1 -0
- package/dist/rich-text-editor/rich-text-icons.js +43 -0
- package/dist/rich-text-editor/rich-text-icons.js.map +1 -0
- package/dist/ridgeline/index.d.ts +2 -0
- package/dist/ridgeline/index.js +2 -0
- package/dist/ridgeline/ridgeline.d.ts +55 -0
- package/dist/ridgeline/ridgeline.js +701 -0
- package/dist/ridgeline/ridgeline.js.map +1 -0
- package/dist/scroll-area/index.d.ts +2 -2
- package/dist/scroll-area/index.js +2 -2
- package/dist/scroll-area/scroll-area.d.ts +68 -31
- package/dist/scroll-area/scroll-area.js +208 -59
- package/dist/scroll-area/scroll-area.js.map +1 -1
- package/dist/scrub-input/evaluate.d.ts +14 -0
- package/dist/scrub-input/evaluate.js +72 -0
- package/dist/scrub-input/evaluate.js.map +1 -0
- package/dist/scrub-input/index.d.ts +3 -0
- package/dist/scrub-input/index.js +3 -0
- package/dist/scrub-input/scrub-input.d.ts +74 -0
- package/dist/scrub-input/scrub-input.js +486 -0
- package/dist/scrub-input/scrub-input.js.map +1 -0
- package/dist/search-field/search-field.d.ts +2 -1
- package/dist/search-field/search-field.js +4 -4
- package/dist/search-field/search-field.js.map +1 -1
- package/dist/select/select.d.ts +3 -1
- package/dist/select/select.js +20 -8
- package/dist/select/select.js.map +1 -1
- package/dist/separator/separator.d.ts +1 -1
- package/dist/sheet/sheet.js +2 -1
- package/dist/sheet/sheet.js.map +1 -1
- package/dist/shortcut-recorder/index.d.ts +3 -0
- package/dist/shortcut-recorder/index.js +3 -0
- package/dist/shortcut-recorder/shortcut-model.d.ts +27 -0
- package/dist/shortcut-recorder/shortcut-model.js +206 -0
- package/dist/shortcut-recorder/shortcut-model.js.map +1 -0
- package/dist/shortcut-recorder/shortcut-recorder.d.ts +93 -0
- package/dist/shortcut-recorder/shortcut-recorder.js +489 -0
- package/dist/shortcut-recorder/shortcut-recorder.js.map +1 -0
- package/dist/slider/index.d.ts +2 -2
- package/dist/slider/slider.d.ts +46 -14
- package/dist/slider/slider.js +151 -67
- package/dist/slider/slider.js.map +1 -1
- package/dist/slope-chart/index.d.ts +2 -0
- package/dist/slope-chart/index.js +2 -0
- package/dist/slope-chart/slope-chart.d.ts +54 -0
- package/dist/slope-chart/slope-chart.js +568 -0
- package/dist/slope-chart/slope-chart.js.map +1 -0
- package/dist/sparkline/index.d.ts +2 -0
- package/dist/sparkline/index.js +2 -0
- package/dist/sparkline/sparkline.d.ts +46 -0
- package/dist/sparkline/sparkline.js +390 -0
- package/dist/sparkline/sparkline.js.map +1 -0
- package/dist/split-bar/index.d.ts +2 -0
- package/dist/split-bar/index.js +2 -0
- package/dist/split-bar/split-bar.d.ts +62 -0
- package/dist/split-bar/split-bar.js +513 -0
- package/dist/split-bar/split-bar.js.map +1 -0
- package/dist/split-button/split-button.d.ts +1 -1
- package/dist/split-button/split-button.js +12 -11
- package/dist/split-button/split-button.js.map +1 -1
- package/dist/stat-card/index.d.ts +2 -2
- package/dist/stat-card/index.js +2 -2
- package/dist/stat-card/stat-card.d.ts +24 -4
- package/dist/stat-card/stat-card.js +114 -17
- package/dist/stat-card/stat-card.js.map +1 -1
- package/dist/stepper/index.d.ts +2 -0
- package/dist/stepper/index.js +2 -0
- package/dist/stepper/stepper.d.ts +51 -0
- package/dist/stepper/stepper.js +215 -0
- package/dist/stepper/stepper.js.map +1 -0
- package/dist/streamgraph/index.d.ts +2 -0
- package/dist/streamgraph/index.js +2 -0
- package/dist/streamgraph/streamgraph.d.ts +70 -0
- package/dist/streamgraph/streamgraph.js +613 -0
- package/dist/streamgraph/streamgraph.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/swipe-actions/index.d.ts +2 -0
- package/dist/swipe-actions/index.js +2 -0
- package/dist/swipe-actions/swipe-actions.d.ts +67 -0
- package/dist/swipe-actions/swipe-actions.js +552 -0
- package/dist/swipe-actions/swipe-actions.js.map +1 -0
- package/dist/switch/switch.js +2 -2
- package/dist/switch/switch.js.map +1 -1
- package/dist/table/index.d.ts +2 -2
- package/dist/table/index.js +2 -2
- package/dist/table/table.d.ts +56 -4
- package/dist/table/table.js +340 -165
- package/dist/table/table.js.map +1 -1
- package/dist/tabs/tabs.js +2 -2
- package/dist/tabs/tabs.js.map +1 -1
- package/dist/tag-input/index.d.ts +2 -0
- package/dist/tag-input/index.js +2 -0
- package/dist/tag-input/tag-input.d.ts +40 -0
- package/dist/tag-input/tag-input.js +269 -0
- package/dist/tag-input/tag-input.js.map +1 -0
- package/dist/text-morph/index.d.ts +2 -0
- package/dist/text-morph/index.js +2 -0
- package/dist/text-morph/text-morph.d.ts +23 -0
- package/dist/text-morph/text-morph.js +21 -0
- package/dist/text-morph/text-morph.js.map +1 -0
- package/dist/text-reveal/index.d.ts +2 -0
- package/dist/text-reveal/index.js +2 -0
- package/dist/text-reveal/text-reveal.d.ts +27 -0
- package/dist/text-reveal/text-reveal.js +51 -0
- package/dist/text-reveal/text-reveal.js.map +1 -0
- package/dist/text-shimmer/index.d.ts +2 -0
- package/dist/text-shimmer/index.js +2 -0
- package/dist/text-shimmer/text-shimmer.d.ts +29 -0
- package/dist/text-shimmer/text-shimmer.js +29 -0
- package/dist/text-shimmer/text-shimmer.js.map +1 -0
- package/dist/time-picker/time-picker.js +2 -2
- package/dist/time-picker/time-picker.js.map +1 -1
- package/dist/toast/index.d.ts +2 -2
- package/dist/toast/index.js +2 -2
- package/dist/toast/toast.d.ts +6 -0
- package/dist/toast/toast.js +82 -40
- package/dist/toast/toast.js.map +1 -1
- package/dist/tooltip/tooltip.d.ts +9 -2
- package/dist/tooltip/tooltip.js +7 -7
- package/dist/tooltip/tooltip.js.map +1 -1
- package/dist/treemap/index.d.ts +2 -0
- package/dist/treemap/index.js +2 -0
- package/dist/treemap/treemap.d.ts +53 -0
- package/dist/treemap/treemap.js +699 -0
- package/dist/treemap/treemap.js.map +1 -0
- package/dist/usage-meter/index.d.ts +2 -0
- package/dist/usage-meter/index.js +2 -0
- package/dist/usage-meter/usage-meter.d.ts +50 -0
- package/dist/usage-meter/usage-meter.js +440 -0
- package/dist/usage-meter/usage-meter.js.map +1 -0
- package/dist/waffle-chart/index.d.ts +2 -0
- package/dist/waffle-chart/index.js +2 -0
- package/dist/waffle-chart/waffle-chart.d.ts +57 -0
- package/dist/waffle-chart/waffle-chart.js +426 -0
- package/dist/waffle-chart/waffle-chart.js.map +1 -0
- package/package.json +165 -3
package/dist/table/table.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn, cnAll } from "../lib/cn.js";
|
|
3
3
|
import { Button as Button$1 } from "../button/button.js";
|
|
4
|
+
import { SwapText } from "../lib/swap-text.js";
|
|
5
|
+
import { useFlip } from "../lib/flip.js";
|
|
6
|
+
import { Checkbox as Checkbox$1 } from "../checkbox/checkbox.js";
|
|
4
7
|
import { Select as Select$1, SelectItem } from "../select/select.js";
|
|
5
8
|
import { cva } from "class-variance-authority";
|
|
6
9
|
import { forwardRef, useEffect, useMemo, useRef, useState } from "react";
|
|
7
10
|
import { Cell, Column, Row, Table, TableBody, TableFooter, TableHeader } from "react-aria-components";
|
|
8
11
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { flushSync } from "react-dom";
|
|
9
13
|
//#region src/table/table.tsx
|
|
10
14
|
/**
|
|
11
15
|
* Table, ported from the legacy shadcn table onto React Aria's Table.
|
|
@@ -80,7 +84,7 @@ const tableCardVariants = cva([
|
|
|
80
84
|
"data-[overflow-end]:after:opacity-15"
|
|
81
85
|
], {
|
|
82
86
|
variants: { frame: {
|
|
83
|
-
card: "rounded-
|
|
87
|
+
card: "rounded-panel border-(length:--border-width) border-separator bg-surface",
|
|
84
88
|
none: ""
|
|
85
89
|
} },
|
|
86
90
|
defaultVariants: { frame: "card" }
|
|
@@ -104,12 +108,16 @@ function renderValue(column, value, row) {
|
|
|
104
108
|
/** Reserved id for the chevron column, so it cannot collide with a real one. */
|
|
105
109
|
const CHEVRON_COLUMN_ID = "__table_row_action";
|
|
106
110
|
const CHEVRON_CELL = "w-10 px-0 text-center";
|
|
111
|
+
/** Reserved id for the checkbox column of a selectable table. */
|
|
112
|
+
const SELECT_COLUMN_ID = "__table_row_select";
|
|
113
|
+
/** The checkbox column is as wide as its box needs, with the table's usual inset on its leading side. */
|
|
114
|
+
const SELECT_CELL = "w-11 px-0 ps-(--density-row-pad-x)";
|
|
107
115
|
/** The horizontal scroll container. The table owns it; 5 of 6 consumers built one by hand. */
|
|
108
116
|
const tableScrollVariants = cva(["w-full overflow-x-auto box-border"]);
|
|
109
117
|
const tableVariants = cva([
|
|
110
118
|
"w-full border-collapse box-border",
|
|
111
119
|
"font-sans text-base leading-(--leading-normal)",
|
|
112
|
-
"bg-
|
|
120
|
+
"bg-surface text-foreground"
|
|
113
121
|
]);
|
|
114
122
|
/**
|
|
115
123
|
* The header is near-white, not a grey band.
|
|
@@ -135,8 +143,24 @@ const tablePaginationVariants = cva([
|
|
|
135
143
|
"px-(--density-row-pad-x) py-(--density-row-pad-y)",
|
|
136
144
|
"font-sans text-sm leading-(--leading-normal) text-muted-foreground"
|
|
137
145
|
]);
|
|
146
|
+
/**
|
|
147
|
+
* The bar under a selectable table: how many rows, or how many are selected,
|
|
148
|
+
* and the action that clears them. A sibling of the table, like the pagination.
|
|
149
|
+
*/
|
|
150
|
+
const tableSelectionBarVariants = cva([
|
|
151
|
+
"flex min-h-11 items-center justify-between gap-(--density-control-gap) box-border",
|
|
152
|
+
"border-t-(length:--border-width) border-t-separator",
|
|
153
|
+
"ps-(--density-row-pad-x) pe-2 font-sans text-sm leading-(--leading-normal)",
|
|
154
|
+
"text-muted-foreground data-[active]:text-foreground",
|
|
155
|
+
"motion-safe:transition-colors motion-safe:duration-(--duration-standard) motion-safe:ease-settle"
|
|
156
|
+
]);
|
|
157
|
+
/**
|
|
158
|
+
* What stands in for the rows when there are none: centred, muted, and tall
|
|
159
|
+
* enough to read as a state rather than as a squashed row.
|
|
160
|
+
*/
|
|
161
|
+
const tableEmptyVariants = cva(["flex min-h-30 items-center justify-center px-(--density-row-pad-x) py-6", "box-border text-center text-sm text-muted-foreground wrap-anywhere"]);
|
|
138
162
|
/** The footer band. Heavier than a row rule, because it closes the table. */
|
|
139
|
-
const tableFooterVariants = cva(["bg-
|
|
163
|
+
const tableFooterVariants = cva(["bg-surface font-semibold text-foreground", "border-t-(length:--border-width) border-t-border"]);
|
|
140
164
|
/** Shared focus treatment. Authored once; both the column header and the row take it. */
|
|
141
165
|
const FOCUS_RING = [
|
|
142
166
|
"outline-none",
|
|
@@ -148,6 +172,7 @@ const FOCUS_RING = [
|
|
|
148
172
|
const tableColumnVariants = cva([
|
|
149
173
|
"px-(--density-row-pad-x) py-(--density-row-pad-y)",
|
|
150
174
|
"box-border align-middle text-sm font-semibold select-none",
|
|
175
|
+
"data-[sorted]:bg-foreground/3 data-[sorted]:text-foreground",
|
|
151
176
|
...FOCUS_RING,
|
|
152
177
|
"data-[allows-sorting]:cursor-pointer"
|
|
153
178
|
], {
|
|
@@ -168,9 +193,10 @@ const tableColumnVariants = cva([
|
|
|
168
193
|
}
|
|
169
194
|
});
|
|
170
195
|
const tableRowVariants = cva([
|
|
171
|
-
"group/row box-border",
|
|
196
|
+
"group/row box-border bg-surface",
|
|
172
197
|
"motion-safe:transition-colors motion-safe:duration-(--duration-fast) motion-safe:ease-standard",
|
|
173
198
|
"hover:bg-muted data-[hovered]:bg-muted data-[focused]:bg-muted",
|
|
199
|
+
"data-[selected]:bg-muted data-[selected]:hover:bg-separator data-[selected]:data-[hovered]:bg-separator",
|
|
174
200
|
"data-[highlighted]:bg-primary-subtle",
|
|
175
201
|
...FOCUS_RING
|
|
176
202
|
], {
|
|
@@ -191,7 +217,8 @@ const tableRowVariants = cva([
|
|
|
191
217
|
});
|
|
192
218
|
const tableCellVariants = cva([
|
|
193
219
|
"px-(--density-row-pad-x) py-(--density-row-pad-y)",
|
|
194
|
-
"box-border align-middle",
|
|
220
|
+
"box-border align-middle wrap-anywhere",
|
|
221
|
+
"data-[sorted]:bg-foreground/3",
|
|
195
222
|
...FOCUS_RING
|
|
196
223
|
], {
|
|
197
224
|
variants: {
|
|
@@ -201,7 +228,7 @@ const tableCellVariants = cva([
|
|
|
201
228
|
end: "text-end"
|
|
202
229
|
},
|
|
203
230
|
numeric: {
|
|
204
|
-
true: "tabular-nums",
|
|
231
|
+
true: "tabular-nums whitespace-nowrap",
|
|
205
232
|
false: ""
|
|
206
233
|
}
|
|
207
234
|
},
|
|
@@ -223,9 +250,9 @@ const tableStickyCellVariants = cva(["sticky start-0 z-1", "border-e-(length:--b
|
|
|
223
250
|
variants: {
|
|
224
251
|
part: {
|
|
225
252
|
header: "bg-header-fill",
|
|
226
|
-
bare: "bg-
|
|
253
|
+
bare: "bg-surface",
|
|
227
254
|
body: [
|
|
228
|
-
"bg-
|
|
255
|
+
"bg-surface",
|
|
229
256
|
"group-hover/row:bg-muted group-data-[hovered]/row:bg-muted group-data-[focused]/row:bg-muted",
|
|
230
257
|
"group-data-[highlighted]/row:bg-primary-subtle"
|
|
231
258
|
]
|
|
@@ -349,7 +376,7 @@ function RowChevronGlyph() {
|
|
|
349
376
|
});
|
|
350
377
|
}
|
|
351
378
|
function SortCaretGlyph({ direction }) {
|
|
352
|
-
return /* @__PURE__ */
|
|
379
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
353
380
|
"data-slot": "table-sort-caret",
|
|
354
381
|
"data-direction": direction,
|
|
355
382
|
"aria-hidden": "true",
|
|
@@ -359,8 +386,67 @@ function SortCaretGlyph({ direction }) {
|
|
|
359
386
|
strokeWidth: "1.5",
|
|
360
387
|
strokeLinecap: "round",
|
|
361
388
|
strokeLinejoin: "round",
|
|
362
|
-
className: "size-(--icon-sm) ms-1 inline-block align-middle",
|
|
363
|
-
children:
|
|
389
|
+
className: "table-sort-caret size-(--icon-sm) ms-1 inline-block align-middle",
|
|
390
|
+
children: [/* @__PURE__ */ jsxs("g", {
|
|
391
|
+
className: "table-sort-idle",
|
|
392
|
+
children: [/* @__PURE__ */ jsx("path", { d: "m4 7 4-4 4 4" }), /* @__PURE__ */ jsx("path", { d: "m4 9 4 4 4-4" })]
|
|
393
|
+
}), /* @__PURE__ */ jsxs("g", {
|
|
394
|
+
className: "table-sort-arrow",
|
|
395
|
+
children: [/* @__PURE__ */ jsx("path", { d: "M8 13V3" }), /* @__PURE__ */ jsx("path", { d: "m4.5 6.5 3.5-3.5 3.5 3.5" })]
|
|
396
|
+
})]
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
/** 1 when the value grew, -1 when it shrank: the way a changed number swaps. Updated during render. */
|
|
400
|
+
function useChangeDirection(value) {
|
|
401
|
+
const [seen, setSeen] = useState({
|
|
402
|
+
value,
|
|
403
|
+
dir: 1
|
|
404
|
+
});
|
|
405
|
+
if (seen.value !== value) setSeen({
|
|
406
|
+
value,
|
|
407
|
+
dir: value < seen.value ? -1 : 1
|
|
408
|
+
});
|
|
409
|
+
return seen.dir;
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* The bar under a selectable table. With nothing chosen it counts the rows
|
|
413
|
+
* ("12 rows"); with some chosen it counts them ("3 selected") and offers the
|
|
414
|
+
* way back. The number and the word swap in place as they change.
|
|
415
|
+
*/
|
|
416
|
+
function SelectionBar({ count, total, labels, onClear }) {
|
|
417
|
+
const shown = count || total;
|
|
418
|
+
const noun = count ? labels.selected : shown === 1 ? labels.item.one : labels.item.other;
|
|
419
|
+
const direction = useChangeDirection(shown);
|
|
420
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
421
|
+
"data-slot": "table-selection-bar",
|
|
422
|
+
"data-active": count > 0 || void 0,
|
|
423
|
+
className: cnAll(tableSelectionBarVariants()),
|
|
424
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
425
|
+
"data-slot": "table-selection-count",
|
|
426
|
+
className: "inline-flex items-baseline gap-1",
|
|
427
|
+
children: [
|
|
428
|
+
/* @__PURE__ */ jsx(SwapText, {
|
|
429
|
+
swapKey: String(shown),
|
|
430
|
+
dir: direction,
|
|
431
|
+
className: "inline-block tabular-nums",
|
|
432
|
+
children: shown
|
|
433
|
+
}),
|
|
434
|
+
" ",
|
|
435
|
+
/* @__PURE__ */ jsx(SwapText, {
|
|
436
|
+
swapKey: noun,
|
|
437
|
+
dir: count ? 1 : -1,
|
|
438
|
+
className: "inline-block",
|
|
439
|
+
children: noun
|
|
440
|
+
})
|
|
441
|
+
]
|
|
442
|
+
}), count > 0 ? /* @__PURE__ */ jsx(Button$1, {
|
|
443
|
+
variant: "ghost",
|
|
444
|
+
size: "sm",
|
|
445
|
+
"data-slot": "table-selection-clear",
|
|
446
|
+
className: "motion-safe:animate-fade-in",
|
|
447
|
+
onPress: onClear,
|
|
448
|
+
children: labels.clear
|
|
449
|
+
}) : null]
|
|
364
450
|
});
|
|
365
451
|
}
|
|
366
452
|
/** Builds columns that keep each column's own value type. */
|
|
@@ -370,9 +456,11 @@ function createColumns() {
|
|
|
370
456
|
/**
|
|
371
457
|
* A data table.
|
|
372
458
|
*
|
|
373
|
-
* Maturity: **beta**.
|
|
374
|
-
*
|
|
375
|
-
*
|
|
459
|
+
* Maturity: **beta**. Row expansion, filtering and grouping are deliberately
|
|
460
|
+
* absent -- each had one consumer or none across the six legacy tables, and the
|
|
461
|
+
* stateful ones belong to DataGrid. Sorting glides: when a sort reorders the
|
|
462
|
+
* rows, each slides to its new place instead of jumping (the lib/flip helper).
|
|
463
|
+
* Selection is opt-in with `selectionMode="multiple"`.
|
|
376
464
|
*
|
|
377
465
|
* @example
|
|
378
466
|
* const { column } = createColumns<Channel>();
|
|
@@ -408,7 +496,7 @@ function compareKeys(a, b) {
|
|
|
408
496
|
if (typeof a === "number" && typeof b === "number") return a - b;
|
|
409
497
|
return String(a).localeCompare(String(b));
|
|
410
498
|
}
|
|
411
|
-
const Table$1 = forwardRef(function Table$2({ data, columns, getRowId, variant, sortDescriptor, defaultSortDescriptor, onSortChange, onRowAction, isRowHighlighted, rowClassName, frame, headerType, headerFill, striped, totalRow, empty, minWidth, stickyFirstColumn, pageSize, pageSizeOptions, onPageSizeChange, pageLabels, className, ...props }, ref) {
|
|
499
|
+
const Table$1 = forwardRef(function Table$2({ data, columns, getRowId, variant, sortDescriptor, defaultSortDescriptor, onSortChange, onRowAction, isRowHighlighted, rowClassName, selectionMode, selectedKeys, defaultSelectedKeys, onSelectionChange, selectionLabels, frame, headerType, headerFill, striped, totalRow, empty, minWidth, stickyFirstColumn, pageSize, pageSizeOptions, onPageSizeChange, pageLabels, className, ...props }, ref) {
|
|
412
500
|
const isControlled = sortDescriptor !== void 0;
|
|
413
501
|
const [uncontrolledSort, setUncontrolledSort] = useState(defaultSortDescriptor);
|
|
414
502
|
const activeSort = isControlled ? sortDescriptor : uncontrolledSort;
|
|
@@ -439,12 +527,49 @@ const Table$1 = forwardRef(function Table$2({ data, columns, getRowId, variant,
|
|
|
439
527
|
rowsPerPage: pageLabels?.rowsPerPage ?? "Rows per page"
|
|
440
528
|
};
|
|
441
529
|
const rowsByKey = new Map(data.map((row) => [getRowId(row), row]));
|
|
530
|
+
const selectable = selectionMode === "multiple";
|
|
531
|
+
const [uncontrolledSelection, setUncontrolledSelection] = useState(defaultSelectedKeys ?? /* @__PURE__ */ new Set());
|
|
532
|
+
const selection = selectedKeys ?? uncontrolledSelection;
|
|
533
|
+
const commitSelection = (keys) => {
|
|
534
|
+
if (selectedKeys === void 0) setUncontrolledSelection(keys);
|
|
535
|
+
onSelectionChange?.(keys);
|
|
536
|
+
};
|
|
537
|
+
const selectedCount = selection === "all" ? visibleRows.length : [...selection].filter((key) => rowsByKey.has(key)).length;
|
|
538
|
+
const selectLabels = {
|
|
539
|
+
item: selectionLabels?.item ?? {
|
|
540
|
+
one: "row",
|
|
541
|
+
other: "rows"
|
|
542
|
+
},
|
|
543
|
+
selected: selectionLabels?.selected ?? "selected",
|
|
544
|
+
clear: selectionLabels?.clear ?? "Clear selection"
|
|
545
|
+
};
|
|
546
|
+
const sortedColumn = activeSort?.column;
|
|
442
547
|
const hasWidths = columns.some((column) => column.width !== void 0);
|
|
443
548
|
const tableStyle = {};
|
|
444
549
|
if (minWidth !== void 0) tableStyle.minWidth = minWidth;
|
|
445
550
|
if (hasWidths) tableStyle.tableLayout = "fixed";
|
|
446
551
|
const scrollRef = useRef(null);
|
|
447
552
|
const edges = useScrollEdges(scrollRef);
|
|
553
|
+
const [rowOrder, setRowOrder] = useState("");
|
|
554
|
+
useEffect(() => {
|
|
555
|
+
const root = scrollRef.current;
|
|
556
|
+
if (!root) return;
|
|
557
|
+
let last = "";
|
|
558
|
+
const look = () => {
|
|
559
|
+
const next = Array.from(root.querySelectorAll("tbody > [data-flip]")).map((row) => row.dataset.flip).join("\0");
|
|
560
|
+
if (next === last) return;
|
|
561
|
+
last = next;
|
|
562
|
+
flushSync(() => setRowOrder(next));
|
|
563
|
+
};
|
|
564
|
+
look();
|
|
565
|
+
const observer = new MutationObserver(look);
|
|
566
|
+
observer.observe(root, {
|
|
567
|
+
childList: true,
|
|
568
|
+
subtree: true
|
|
569
|
+
});
|
|
570
|
+
return () => observer.disconnect();
|
|
571
|
+
}, []);
|
|
572
|
+
useFlip(scrollRef, rowOrder, "var(--duration-smooth)", "var(--ease-smooth)", true);
|
|
448
573
|
const stickyCell = (part) => tableStickyCellVariants({
|
|
449
574
|
part,
|
|
450
575
|
striped: part === "body" && !!striped
|
|
@@ -455,161 +580,211 @@ const Table$1 = forwardRef(function Table$2({ data, columns, getRowId, variant,
|
|
|
455
580
|
"data-overflow-end": edges.end || void 0,
|
|
456
581
|
"data-sticky-first": stickyFirstColumn || void 0,
|
|
457
582
|
className: cnAll(tableCardVariants({ frame })),
|
|
458
|
-
children: [
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
children: visibleRows.map((row, index) => /* @__PURE__ */ jsxs(Row, {
|
|
504
|
-
id: getRowId(row),
|
|
505
|
-
"data-slot": "table-row",
|
|
506
|
-
"data-highlighted": isRowHighlighted?.(row) || void 0,
|
|
507
|
-
className: cn(cnAll(tableRowVariants({
|
|
508
|
-
variant,
|
|
509
|
-
striped
|
|
510
|
-
}), onRowAction && "cursor-pointer"), rowClassName?.(row)),
|
|
511
|
-
children: [columns.map((column) => {
|
|
512
|
-
const value = column.accessor(row);
|
|
513
|
-
return /* @__PURE__ */ jsx(Cell, {
|
|
514
|
-
"data-slot": "table-cell",
|
|
515
|
-
className: cnAll(tableCellVariants({
|
|
583
|
+
children: [
|
|
584
|
+
/* @__PURE__ */ jsx("div", {
|
|
585
|
+
ref: scrollRef,
|
|
586
|
+
"data-slot": "table-scroll",
|
|
587
|
+
className: cnAll(tableScrollVariants()),
|
|
588
|
+
children: /* @__PURE__ */ jsxs(Table, {
|
|
589
|
+
ref,
|
|
590
|
+
...props,
|
|
591
|
+
"data-slot": "table",
|
|
592
|
+
className: cn(tableVariants(), className),
|
|
593
|
+
style: tableStyle,
|
|
594
|
+
selectionMode: selectable ? "multiple" : void 0,
|
|
595
|
+
selectedKeys: selectable ? selection : void 0,
|
|
596
|
+
onSelectionChange: selectable ? commitSelection : void 0,
|
|
597
|
+
sortDescriptor: activeSort,
|
|
598
|
+
onSortChange: (descriptor) => {
|
|
599
|
+
if (!isControlled) setUncontrolledSort(descriptor);
|
|
600
|
+
setPage(1);
|
|
601
|
+
onSortChange?.(descriptor);
|
|
602
|
+
},
|
|
603
|
+
onRowAction: onRowAction ? (key) => {
|
|
604
|
+
const row = rowsByKey.get(key);
|
|
605
|
+
if (row !== void 0) onRowAction(row);
|
|
606
|
+
} : void 0,
|
|
607
|
+
children: [
|
|
608
|
+
/* @__PURE__ */ jsxs(TableHeader, {
|
|
609
|
+
"data-slot": "table-header",
|
|
610
|
+
className: cnAll(tableHeaderVariants({ headerFill })),
|
|
611
|
+
children: [
|
|
612
|
+
selectable ? /* @__PURE__ */ jsx(Column, {
|
|
613
|
+
id: SELECT_COLUMN_ID,
|
|
614
|
+
"data-slot": "table-column",
|
|
615
|
+
className: cnAll(tableColumnVariants({ headerType }), SELECT_CELL, stickyFirstColumn && stickyCell(headerFill === "none" ? "bare" : "header"), stickyFirstColumn && "border-e-0"),
|
|
616
|
+
children: /* @__PURE__ */ jsx(Checkbox$1, {
|
|
617
|
+
slot: "selection",
|
|
618
|
+
"aria-label": selectionLabels?.selectAll
|
|
619
|
+
})
|
|
620
|
+
}) : null,
|
|
621
|
+
columns.map((column) => /* @__PURE__ */ jsxs(Column, {
|
|
622
|
+
id: column.id,
|
|
623
|
+
isRowHeader: column === columns[0],
|
|
624
|
+
allowsSorting: column.sortable,
|
|
625
|
+
"data-slot": "table-column",
|
|
626
|
+
"data-sorted": sortedColumn === column.id || void 0,
|
|
627
|
+
className: cnAll(tableColumnVariants({
|
|
516
628
|
align: column.align ?? (column.numeric ? "end" : void 0),
|
|
517
|
-
|
|
518
|
-
}), stickyFirstColumn && column === columns[0] && stickyCell("
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
children:
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
629
|
+
headerType
|
|
630
|
+
}), stickyFirstColumn && column === columns[0] && stickyCell(headerFill === "none" ? "bare" : "header"), stickyFirstColumn && selectable && column === columns[0] && "start-11"),
|
|
631
|
+
style: column.width === void 0 ? void 0 : { width: column.width },
|
|
632
|
+
children: [column.header, column.sortable ? /* @__PURE__ */ jsx(SortCaretGlyph, { direction: activeSort?.column === column.id ? activeSort.direction : "none" }) : null]
|
|
633
|
+
}, column.id)),
|
|
634
|
+
onRowAction ? /* @__PURE__ */ jsx(Column, {
|
|
635
|
+
id: CHEVRON_COLUMN_ID,
|
|
636
|
+
"data-slot": "table-column",
|
|
637
|
+
className: cnAll(tableColumnVariants({ headerType }), CHEVRON_CELL),
|
|
638
|
+
children: ""
|
|
639
|
+
}) : null
|
|
640
|
+
]
|
|
641
|
+
}),
|
|
642
|
+
/* @__PURE__ */ jsx(TableBody, {
|
|
643
|
+
"data-slot": "table-body",
|
|
644
|
+
renderEmptyState: empty === void 0 ? void 0 : () => /* @__PURE__ */ jsx("div", {
|
|
645
|
+
"data-slot": "table-empty",
|
|
646
|
+
className: cnAll(tableEmptyVariants()),
|
|
647
|
+
children: empty
|
|
648
|
+
}),
|
|
649
|
+
children: visibleRows.map((row, index) => /* @__PURE__ */ jsxs(Row, {
|
|
650
|
+
id: getRowId(row),
|
|
651
|
+
"data-slot": "table-row",
|
|
652
|
+
"data-flip": String(getRowId(row)),
|
|
653
|
+
"data-highlighted": isRowHighlighted?.(row) || void 0,
|
|
654
|
+
className: cn(cnAll(tableRowVariants({
|
|
655
|
+
variant,
|
|
656
|
+
striped
|
|
657
|
+
}), onRowAction && "cursor-pointer"), rowClassName?.(row)),
|
|
658
|
+
children: [
|
|
659
|
+
selectable ? /* @__PURE__ */ jsx(Cell, {
|
|
660
|
+
"data-slot": "table-cell",
|
|
661
|
+
className: cnAll(tableCellVariants(), SELECT_CELL, stickyFirstColumn && stickyCell("body"), stickyFirstColumn && "border-e-0"),
|
|
662
|
+
children: /* @__PURE__ */ jsx(Checkbox$1, {
|
|
663
|
+
slot: "selection",
|
|
664
|
+
"aria-label": selectionLabels?.selectRow
|
|
665
|
+
})
|
|
666
|
+
}) : null,
|
|
667
|
+
columns.map((column) => {
|
|
668
|
+
const value = column.accessor(row);
|
|
669
|
+
return /* @__PURE__ */ jsx(Cell, {
|
|
670
|
+
"data-slot": "table-cell",
|
|
671
|
+
"data-sorted": sortedColumn === column.id || void 0,
|
|
672
|
+
className: cnAll(tableCellVariants({
|
|
673
|
+
align: column.align ?? (column.numeric ? "end" : void 0),
|
|
674
|
+
numeric: column.numeric
|
|
675
|
+
}), stickyFirstColumn && column === columns[0] && stickyCell("body"), stickyFirstColumn && selectable && column === columns[0] && "start-11"),
|
|
676
|
+
children: column.cell ? column.cell({
|
|
677
|
+
value,
|
|
678
|
+
row,
|
|
679
|
+
index
|
|
680
|
+
}) : renderValue(column, value, row)
|
|
681
|
+
}, column.id);
|
|
682
|
+
}),
|
|
683
|
+
onRowAction ? /* @__PURE__ */ jsx(Cell, {
|
|
684
|
+
"data-slot": "table-cell",
|
|
685
|
+
className: cnAll(tableCellVariants(), CHEVRON_CELL),
|
|
686
|
+
children: /* @__PURE__ */ jsx(RowChevronGlyph, {})
|
|
687
|
+
}) : null
|
|
688
|
+
]
|
|
689
|
+
}, String(getRowId(row))))
|
|
690
|
+
}),
|
|
691
|
+
totalRow ? /* @__PURE__ */ jsx(TableFooter, {
|
|
692
|
+
"data-slot": "table-footer",
|
|
693
|
+
className: cnAll(tableFooterVariants()),
|
|
694
|
+
children: /* @__PURE__ */ jsxs(Row, {
|
|
695
|
+
id: "__table_total",
|
|
696
|
+
children: [
|
|
697
|
+
selectable ? /* @__PURE__ */ jsx(Cell, {
|
|
698
|
+
"data-slot": "table-cell",
|
|
699
|
+
className: cnAll(tableCellVariants(), SELECT_CELL, stickyFirstColumn && stickyCell("bare"), stickyFirstColumn && "border-e-0"),
|
|
700
|
+
children: ""
|
|
701
|
+
}) : null,
|
|
702
|
+
columns.map((col) => /* @__PURE__ */ jsx(Cell, {
|
|
703
|
+
"data-slot": "table-cell",
|
|
704
|
+
className: cnAll(tableCellVariants({
|
|
705
|
+
align: col.align ?? (col.numeric ? "end" : void 0),
|
|
706
|
+
numeric: col.numeric
|
|
707
|
+
}), stickyFirstColumn && col === columns[0] && stickyCell("bare"), stickyFirstColumn && selectable && col === columns[0] && "start-11"),
|
|
708
|
+
children: totalRow(col)
|
|
709
|
+
}, col.id)),
|
|
710
|
+
onRowAction ? /* @__PURE__ */ jsx(Cell, {
|
|
711
|
+
"data-slot": "table-cell",
|
|
712
|
+
className: cnAll(tableCellVariants(), CHEVRON_CELL),
|
|
713
|
+
children: ""
|
|
714
|
+
}) : null
|
|
715
|
+
]
|
|
716
|
+
})
|
|
717
|
+
}) : null
|
|
718
|
+
]
|
|
719
|
+
})
|
|
720
|
+
}),
|
|
721
|
+
selectable ? /* @__PURE__ */ jsx(SelectionBar, {
|
|
722
|
+
count: selectedCount,
|
|
723
|
+
total: data.length,
|
|
724
|
+
labels: selectLabels,
|
|
725
|
+
onClear: () => commitSelection(/* @__PURE__ */ new Set())
|
|
726
|
+
}) : null,
|
|
727
|
+
rowsPerPage === void 0 || pageCount <= 1 && !pageSizeOptions ? null : /* @__PURE__ */ jsxs("nav", {
|
|
728
|
+
"data-slot": "table-pagination",
|
|
729
|
+
"aria-label": `${props["aria-label"]} pagination`,
|
|
730
|
+
className: cnAll(tablePaginationVariants()),
|
|
731
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
732
|
+
"data-slot": "table-pagination-pages",
|
|
733
|
+
className: "flex items-center gap-1",
|
|
734
|
+
children: pageCount <= 1 ? null : /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
735
|
+
/* @__PURE__ */ jsx(Button$1, {
|
|
736
|
+
variant: "ghost",
|
|
737
|
+
size: "sm",
|
|
738
|
+
className: "w-(--density-control-h-sm) px-0",
|
|
739
|
+
"aria-label": labels.previous,
|
|
740
|
+
isDisabled: currentPage <= 1,
|
|
741
|
+
onPress: () => setPage(currentPage - 1),
|
|
742
|
+
children: /* @__PURE__ */ jsx(PageChevronGlyph, { direction: "previous" })
|
|
743
|
+
}),
|
|
744
|
+
pageWindow(currentPage, pageCount).map((entry, index) => entry === "ellipsis" ? /* @__PURE__ */ jsx("span", {
|
|
745
|
+
"data-slot": "table-pagination-ellipsis",
|
|
746
|
+
"aria-hidden": "true",
|
|
747
|
+
className: "px-2 text-sm text-muted-foreground",
|
|
748
|
+
children: "…"
|
|
749
|
+
}, `ellipsis-${String(index)}`) : /* @__PURE__ */ jsx(Button$1, {
|
|
750
|
+
variant: entry === currentPage ? "primary" : "ghost",
|
|
751
|
+
size: "sm",
|
|
752
|
+
className: "min-w-(--density-control-h-sm) px-2",
|
|
753
|
+
"aria-label": labels.page(entry, entry === currentPage),
|
|
754
|
+
onPress: () => setPage(entry),
|
|
755
|
+
children: entry
|
|
756
|
+
}, entry)),
|
|
757
|
+
/* @__PURE__ */ jsx(Button$1, {
|
|
758
|
+
variant: "ghost",
|
|
759
|
+
size: "sm",
|
|
760
|
+
className: "w-(--density-control-h-sm) px-0",
|
|
761
|
+
"aria-label": labels.next,
|
|
762
|
+
isDisabled: currentPage >= pageCount,
|
|
763
|
+
onPress: () => setPage(currentPage + 1),
|
|
764
|
+
children: /* @__PURE__ */ jsx(PageChevronGlyph, { direction: "next" })
|
|
549
765
|
})
|
|
550
|
-
})
|
|
551
|
-
|
|
766
|
+
] })
|
|
767
|
+
}), pageSizeOptions === void 0 ? null : /* @__PURE__ */ jsx(Select$1, {
|
|
768
|
+
className: "w-auto",
|
|
769
|
+
label: labels.rowsPerPage,
|
|
770
|
+
labelHidden: true,
|
|
771
|
+
selectedKey: String(rowsPerPage),
|
|
772
|
+
onSelectionChange: (key) => {
|
|
773
|
+
const size = Number(key);
|
|
774
|
+
setChosenSize(size);
|
|
775
|
+
setPage(1);
|
|
776
|
+
onPageSizeChange?.(size);
|
|
777
|
+
},
|
|
778
|
+
children: pageSizeOptions.map((option) => /* @__PURE__ */ jsx(SelectItem, {
|
|
779
|
+
id: String(option),
|
|
780
|
+
children: labels.perPage(option)
|
|
781
|
+
}, option))
|
|
782
|
+
})]
|
|
552
783
|
})
|
|
553
|
-
|
|
554
|
-
"data-slot": "table-pagination",
|
|
555
|
-
"aria-label": `${props["aria-label"]} pagination`,
|
|
556
|
-
className: cnAll(tablePaginationVariants()),
|
|
557
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
558
|
-
"data-slot": "table-pagination-pages",
|
|
559
|
-
className: "flex items-center gap-1",
|
|
560
|
-
children: pageCount <= 1 ? null : /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
561
|
-
/* @__PURE__ */ jsx(Button$1, {
|
|
562
|
-
variant: "ghost",
|
|
563
|
-
size: "sm",
|
|
564
|
-
className: "w-(--density-control-h-sm) px-0",
|
|
565
|
-
"aria-label": labels.previous,
|
|
566
|
-
isDisabled: currentPage <= 1,
|
|
567
|
-
onPress: () => setPage(currentPage - 1),
|
|
568
|
-
children: /* @__PURE__ */ jsx(PageChevronGlyph, { direction: "previous" })
|
|
569
|
-
}),
|
|
570
|
-
pageWindow(currentPage, pageCount).map((entry, index) => entry === "ellipsis" ? /* @__PURE__ */ jsx("span", {
|
|
571
|
-
"data-slot": "table-pagination-ellipsis",
|
|
572
|
-
"aria-hidden": "true",
|
|
573
|
-
className: "px-2 text-sm text-muted-foreground",
|
|
574
|
-
children: "…"
|
|
575
|
-
}, `ellipsis-${String(index)}`) : /* @__PURE__ */ jsx(Button$1, {
|
|
576
|
-
variant: entry === currentPage ? "primary" : "ghost",
|
|
577
|
-
size: "sm",
|
|
578
|
-
className: "min-w-(--density-control-h-sm) px-2",
|
|
579
|
-
"aria-label": labels.page(entry, entry === currentPage),
|
|
580
|
-
onPress: () => setPage(entry),
|
|
581
|
-
children: entry
|
|
582
|
-
}, entry)),
|
|
583
|
-
/* @__PURE__ */ jsx(Button$1, {
|
|
584
|
-
variant: "ghost",
|
|
585
|
-
size: "sm",
|
|
586
|
-
className: "w-(--density-control-h-sm) px-0",
|
|
587
|
-
"aria-label": labels.next,
|
|
588
|
-
isDisabled: currentPage >= pageCount,
|
|
589
|
-
onPress: () => setPage(currentPage + 1),
|
|
590
|
-
children: /* @__PURE__ */ jsx(PageChevronGlyph, { direction: "next" })
|
|
591
|
-
})
|
|
592
|
-
] })
|
|
593
|
-
}), pageSizeOptions === void 0 ? null : /* @__PURE__ */ jsx(Select$1, {
|
|
594
|
-
className: "w-auto",
|
|
595
|
-
label: labels.rowsPerPage,
|
|
596
|
-
labelHidden: true,
|
|
597
|
-
selectedKey: String(rowsPerPage),
|
|
598
|
-
onSelectionChange: (key) => {
|
|
599
|
-
const size = Number(key);
|
|
600
|
-
setChosenSize(size);
|
|
601
|
-
setPage(1);
|
|
602
|
-
onPageSizeChange?.(size);
|
|
603
|
-
},
|
|
604
|
-
children: pageSizeOptions.map((option) => /* @__PURE__ */ jsx(SelectItem, {
|
|
605
|
-
id: String(option),
|
|
606
|
-
children: labels.perPage(option)
|
|
607
|
-
}, option))
|
|
608
|
-
})]
|
|
609
|
-
})]
|
|
784
|
+
]
|
|
610
785
|
});
|
|
611
786
|
});
|
|
612
787
|
//#endregion
|
|
613
|
-
export { Table$1 as Table, createColumns, tableCardVariants, tableCellVariants, tableColumnVariants, tableFooterVariants, tableHeaderVariants, tablePaginationVariants, tableRowVariants, tableScrollVariants, tableStickyCellVariants, tableVariants };
|
|
788
|
+
export { Table$1 as Table, createColumns, tableCardVariants, tableCellVariants, tableColumnVariants, tableEmptyVariants, tableFooterVariants, tableHeaderVariants, tablePaginationVariants, tableRowVariants, tableScrollVariants, tableSelectionBarVariants, tableStickyCellVariants, tableVariants };
|
|
614
789
|
|
|
615
790
|
//# sourceMappingURL=table.js.map
|