ixia-ui-react 1.8.0 → 2.1.0
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 +24 -1
- package/dist/accordion/index.d.ts +41 -0
- package/dist/accordion/index.js +142 -0
- package/dist/accordion/index.js.map +1 -0
- package/dist/alert/index.d.ts +22 -0
- package/dist/alert/index.js +1 -0
- package/dist/alert-Dcu9R8CY.js +73 -0
- package/dist/alert-Dcu9R8CY.js.map +1 -0
- package/dist/alert-dialog/index.d.ts +39 -0
- package/dist/alert-dialog/index.js +134 -0
- package/dist/alert-dialog/index.js.map +1 -0
- package/dist/autocomplete/index.d.ts +2 -0
- package/dist/autocomplete/index.js +1 -0
- package/dist/autocomplete-BfpWVO1l.js +169 -0
- package/dist/autocomplete-BfpWVO1l.js.map +1 -0
- package/dist/avatar/index.d.ts +2 -0
- package/dist/avatar/index.js +1 -0
- package/dist/avatar-Bp4gZh21.js +93 -0
- package/dist/avatar-Bp4gZh21.js.map +1 -0
- package/dist/badge/index.d.ts +2 -0
- package/dist/badge/index.js +1 -0
- package/dist/badge-Cl-9WTW-.js +160 -0
- package/dist/badge-Cl-9WTW-.js.map +1 -0
- package/dist/bento-box/index.d.ts +30 -0
- package/dist/bento-box/index.js +103 -0
- package/dist/bento-box/index.js.map +1 -0
- package/dist/breadcrumb/index.d.ts +18 -0
- package/dist/breadcrumb/index.js +58 -0
- package/dist/breadcrumb/index.js.map +1 -0
- package/dist/button/index.d.ts +3 -0
- package/dist/button/index.js +1 -0
- package/dist/button-DXQvyQyj.js +309 -0
- package/dist/button-DXQvyQyj.js.map +1 -0
- package/dist/button-group/index.d.ts +2 -0
- package/dist/button-group/index.js +1 -0
- package/dist/button-group-BiSk3iIf.js +269 -0
- package/dist/button-group-BiSk3iIf.js.map +1 -0
- package/dist/button-group-context-CScS9Ntz.js +7 -0
- package/dist/button-group-context-CScS9Ntz.js.map +1 -0
- package/dist/button.types-BFKrBCGd.d.ts +10 -0
- package/dist/calendar/index.d.ts +63 -0
- package/dist/calendar/index.js +292 -0
- package/dist/calendar/index.js.map +1 -0
- package/dist/chart/index.d.ts +87 -0
- package/dist/chart/index.js +262 -0
- package/dist/chart/index.js.map +1 -0
- package/dist/checkbox/index.d.ts +2 -0
- package/dist/checkbox/index.js +1 -0
- package/dist/checkbox-BuUZ1Lly.js +54 -0
- package/dist/checkbox-BuUZ1Lly.js.map +1 -0
- package/dist/checkbox-group/index.d.ts +6 -0
- package/dist/checkbox-group/index.js +17 -0
- package/dist/checkbox-group/index.js.map +1 -0
- package/dist/cn-BDi0DfT5.js +29 -0
- package/dist/cn-BDi0DfT5.js.map +1 -0
- package/dist/code-block/index.d.ts +53 -0
- package/dist/code-block/index.js +193 -0
- package/dist/code-block/index.js.map +1 -0
- package/dist/collapsible/index.d.ts +2 -0
- package/dist/collapsible/index.js +1 -0
- package/dist/collapsible-C3OPWY9l.js +44 -0
- package/dist/collapsible-C3OPWY9l.js.map +1 -0
- package/dist/color-channel-slider/index.d.ts +2 -0
- package/dist/color-channel-slider/index.js +1 -0
- package/dist/color-channel-slider-h8mUPJ35.js +70 -0
- package/dist/color-channel-slider-h8mUPJ35.js.map +1 -0
- package/dist/color-picker/index.d.ts +137 -0
- package/dist/color-picker/index.js +621 -0
- package/dist/color-picker/index.js.map +1 -0
- package/dist/combobox/index.d.ts +64 -0
- package/dist/combobox/index.js +289 -0
- package/dist/combobox/index.js.map +1 -0
- package/dist/context-menu/index.d.ts +49 -0
- package/dist/context-menu/index.js +166 -0
- package/dist/context-menu/index.js.map +1 -0
- package/dist/copy-button/index.d.ts +2 -0
- package/dist/copy-button/index.js +1 -0
- package/dist/copy-button-BAG-P44v.js +28 -0
- package/dist/copy-button-BAG-P44v.js.map +1 -0
- package/dist/dialog/index.d.ts +36 -0
- package/dist/dialog/index.js +119 -0
- package/dist/dialog/index.js.map +1 -0
- package/dist/drawer/index.d.ts +31 -0
- package/dist/drawer/index.js +95 -0
- package/dist/drawer/index.js.map +1 -0
- package/dist/dropzone/index.d.ts +70 -0
- package/dist/dropzone/index.js +479 -0
- package/dist/dropzone/index.js.map +1 -0
- package/dist/field/index.d.ts +2 -0
- package/dist/field/index.js +1 -0
- package/dist/field-DkMfrmdj.js +254 -0
- package/dist/field-DkMfrmdj.js.map +1 -0
- package/dist/form/index.d.ts +220 -0
- package/dist/form/index.js +3 -0
- package/dist/form-V2VqHn0D.js +192 -0
- package/dist/form-V2VqHn0D.js.map +1 -0
- package/dist/has-single-element-child-DLGI0Dh2.js +12 -0
- package/dist/has-single-element-child-DLGI0Dh2.js.map +1 -0
- package/dist/hooks/index.d.ts +26 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks-DUm-q_ig.js +68 -0
- package/dist/hooks-DUm-q_ig.js.map +1 -0
- package/dist/icon/index.d.ts +2 -0
- package/dist/icon/index.js +1 -0
- package/dist/icon-D3JWfCa2.js +85 -0
- package/dist/icon-D3JWfCa2.js.map +1 -0
- package/dist/icon-container/index.d.ts +10 -0
- package/dist/icon-container/index.js +64 -0
- package/dist/icon-container/index.js.map +1 -0
- package/dist/index-0ZQzIKoE.d.ts +11 -0
- package/dist/index-B0Qz4Egw.d.ts +33 -0
- package/dist/index-BJVMIPq4.d.ts +54 -0
- package/dist/index-BsV-u_jc.d.ts +4 -0
- package/dist/index-BygR7cUT.d.ts +22 -0
- package/dist/index-BzTOLSgZ.d.ts +9 -0
- package/dist/index-C15xiG9O.d.ts +14 -0
- package/dist/index-C2zco6-C.d.ts +15 -0
- package/dist/index-CIDOd4Z8.d.ts +56 -0
- package/dist/index-CQti9gFb.d.ts +49 -0
- package/dist/index-CiE-Rqit.d.ts +70 -0
- package/dist/index-CpNMNewO.d.ts +11 -0
- package/dist/index-D1kkOg9k.d.ts +14 -0
- package/dist/index-DLfdAked.d.ts +34 -0
- package/dist/index-DMaW_XF1.d.ts +24 -0
- package/dist/index-DVMheqs_.d.ts +9 -0
- package/dist/index-DXDObRKO.d.ts +14 -0
- package/dist/index-Db_QGr6S.d.ts +5 -0
- package/dist/index-DdFxZ3Xr.d.ts +22 -0
- package/dist/index-DyQYoAUf.d.ts +29 -0
- package/dist/index-PuhTRMce.d.ts +11 -0
- package/dist/index-Wb_tILYa.d.ts +24 -0
- package/dist/index-uaJUy56Z.d.ts +4 -0
- package/dist/index-x4f8gnaI.d.ts +15 -0
- package/dist/input/index.d.ts +3 -0
- package/dist/input/index.js +1 -0
- package/dist/input-Czt30vp7.js +179 -0
- package/dist/input-Czt30vp7.js.map +1 -0
- package/dist/input-group/index.d.ts +2 -0
- package/dist/input-group/index.js +1 -0
- package/dist/input-group-CgdazGrY.js +111 -0
- package/dist/input-group-CgdazGrY.js.map +1 -0
- package/dist/input-otp/index.d.ts +13 -0
- package/dist/input-otp/index.js +44 -0
- package/dist/input-otp/index.js.map +1 -0
- package/dist/input.types-816rEVWU.d.ts +20 -0
- package/dist/input.types-D0gyoaQv.js +48 -0
- package/dist/input.types-D0gyoaQv.js.map +1 -0
- package/dist/kbd/index.d.ts +9 -0
- package/dist/kbd/index.js +25 -0
- package/dist/kbd/index.js.map +1 -0
- package/dist/label/index.d.ts +8 -0
- package/dist/label/index.js +1 -0
- package/dist/label-BgpayDvN.js +27 -0
- package/dist/label-BgpayDvN.js.map +1 -0
- package/dist/layer-tree/index.d.ts +728 -0
- package/dist/layer-tree/index.js +685 -0
- package/dist/layer-tree/index.js.map +1 -0
- package/dist/map/google/index.d.ts +143 -0
- package/dist/map/google/index.js +445 -0
- package/dist/map/google/index.js.map +1 -0
- package/dist/map/index.d.ts +94 -0
- package/dist/map/index.js +208 -0
- package/dist/map/index.js.map +1 -0
- package/dist/map.context-Dw1D7E8m.js +11 -0
- package/dist/map.context-Dw1D7E8m.js.map +1 -0
- package/dist/menu/index.d.ts +2 -0
- package/dist/menu/index.js +1 -0
- package/dist/menu-sf13cnGp.js +173 -0
- package/dist/menu-sf13cnGp.js.map +1 -0
- package/dist/menu-tone-DWBEHoX2.js +22 -0
- package/dist/menu-tone-DWBEHoX2.js.map +1 -0
- package/dist/meter/index.d.ts +2 -0
- package/dist/meter/index.js +1 -0
- package/dist/meter-HD5taq57.js +116 -0
- package/dist/meter-HD5taq57.js.map +1 -0
- package/dist/nav-bar/index.d.ts +25 -0
- package/dist/nav-bar/index.js +133 -0
- package/dist/nav-bar/index.js.map +1 -0
- package/dist/navigation-menu/index.d.ts +43 -0
- package/dist/navigation-menu/index.js +176 -0
- package/dist/navigation-menu/index.js.map +1 -0
- package/dist/number-field/index.d.ts +14 -0
- package/dist/number-field/index.js +116 -0
- package/dist/number-field/index.js.map +1 -0
- package/dist/popover/index.d.ts +2 -0
- package/dist/popover/index.js +1 -0
- package/dist/popover-0WDxRi-s.js +114 -0
- package/dist/popover-0WDxRi-s.js.map +1 -0
- package/dist/preview-card/index.d.ts +13 -0
- package/dist/preview-card/index.js +35 -0
- package/dist/preview-card/index.js.map +1 -0
- package/dist/profile/index.d.ts +21 -0
- package/dist/profile/index.js +52 -0
- package/dist/profile/index.js.map +1 -0
- package/dist/progress/index.d.ts +23 -0
- package/dist/progress/index.js +97 -0
- package/dist/progress/index.js.map +1 -0
- package/dist/radar-ping/index.d.ts +11 -0
- package/dist/radar-ping/index.js +49 -0
- package/dist/radar-ping/index.js.map +1 -0
- package/dist/radio-group/index.d.ts +2 -0
- package/dist/radio-group/index.js +1 -0
- package/dist/radio-group-Dj43u35Z.js +47 -0
- package/dist/radio-group-Dj43u35Z.js.map +1 -0
- package/dist/resizeable/index.d.ts +11 -0
- package/dist/resizeable/index.js +31 -0
- package/dist/resizeable/index.js.map +1 -0
- package/dist/scroll-area/index.d.ts +11 -0
- package/dist/scroll-area/index.js +51 -0
- package/dist/scroll-area/index.js.map +1 -0
- package/dist/select/index.d.ts +2 -0
- package/dist/select/index.js +1 -0
- package/dist/select-DncJXYim.js +159 -0
- package/dist/select-DncJXYim.js.map +1 -0
- package/dist/separator/index.d.ts +2 -0
- package/dist/separator/index.js +1 -0
- package/dist/separator-DgIQp1cB.js +97 -0
- package/dist/separator-DgIQp1cB.js.map +1 -0
- package/dist/sidebar/index.d.ts +80 -0
- package/dist/sidebar/index.js +334 -0
- package/dist/sidebar/index.js.map +1 -0
- package/dist/site-header/index.d.ts +22 -0
- package/dist/site-header/index.js +55 -0
- package/dist/site-header/index.js.map +1 -0
- package/dist/skeleton/index.d.ts +4 -0
- package/dist/skeleton/index.js +1 -0
- package/dist/skeleton-DSG3FWby.js +13 -0
- package/dist/skeleton-DSG3FWby.js.map +1 -0
- package/dist/slider/index.d.ts +2 -0
- package/dist/slider/index.js +1 -0
- package/dist/slider-D_XlV4OW.js +114 -0
- package/dist/slider-D_XlV4OW.js.map +1 -0
- package/dist/slider-group/index.d.ts +46 -0
- package/dist/slider-group/index.js +198 -0
- package/dist/slider-group/index.js.map +1 -0
- package/dist/styles.css +4 -1
- package/dist/switch/index.d.ts +2 -0
- package/dist/switch/index.js +1 -0
- package/dist/switch-DXHixGHe.js +23 -0
- package/dist/switch-DXHixGHe.js.map +1 -0
- package/dist/table/index.d.ts +920 -0
- package/dist/table/index.js +1544 -0
- package/dist/table/index.js.map +1 -0
- package/dist/tabs/index.d.ts +2 -0
- package/dist/tabs/index.js +1 -0
- package/dist/tabs-DTC7coap.js +270 -0
- package/dist/tabs-DTC7coap.js.map +1 -0
- package/dist/text-area/index.d.ts +2 -0
- package/dist/text-area/index.js +1 -0
- package/dist/text-area-H6HjKnv_.js +50 -0
- package/dist/text-area-H6HjKnv_.js.map +1 -0
- package/dist/toast/index.d.ts +65 -0
- package/dist/toast/index.js +216 -0
- package/dist/toast/index.js.map +1 -0
- package/dist/toggle/index.d.ts +2 -0
- package/dist/toggle/index.js +1 -0
- package/dist/toggle-ZT9thVmz.js +73 -0
- package/dist/toggle-ZT9thVmz.js.map +1 -0
- package/dist/toggle-group/index.d.ts +10 -0
- package/dist/toggle-group/index.js +63 -0
- package/dist/toggle-group/index.js.map +1 -0
- package/dist/toggle-group-context-CBNZEf1I.js +6 -0
- package/dist/toggle-group-context-CBNZEf1I.js.map +1 -0
- package/dist/tooltip/index.d.ts +18 -0
- package/dist/tooltip/index.js +1 -0
- package/dist/tooltip-B6z3tDbW.js +41 -0
- package/dist/tooltip-B6z3tDbW.js.map +1 -0
- package/dist/trim-text-children-CQRFg2fL.js +33 -0
- package/dist/trim-text-children-CQRFg2fL.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +3 -0
- package/dist/utils-BI2x7nW5.js +5 -0
- package/dist/utils-BI2x7nW5.js.map +1 -0
- package/package.json +100 -31
- package/dist/index.d.ts +0 -8000
- package/dist/index.js +0 -17274
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,1544 @@
|
|
|
1
|
+
import { t as cn } from "../cn-BDi0DfT5.js";
|
|
2
|
+
import { t as formatDate } from "../utils-BI2x7nW5.js";
|
|
3
|
+
import { n as Icon } from "../icon-D3JWfCa2.js";
|
|
4
|
+
import { t as Button } from "../button-DXQvyQyj.js";
|
|
5
|
+
import { t as Avatar } from "../avatar-Bp4gZh21.js";
|
|
6
|
+
import { t as Badge } from "../badge-Cl-9WTW-.js";
|
|
7
|
+
import { a as SelectPopup, c as SelectIcon, i as SelectTitle, n as SelectValue, o as SelectList, r as SelectTrigger, s as SelectItem, t as Select } from "../select-DncJXYim.js";
|
|
8
|
+
import { t as Checkbox } from "../checkbox-BuUZ1Lly.js";
|
|
9
|
+
import { i as TabsList, n as TabsTab, o as Tabs } from "../tabs-DTC7coap.js";
|
|
10
|
+
import { i as InputGroupAddon, r as InputGroupInput, t as InputGroup } from "../input-group-CgdazGrY.js";
|
|
11
|
+
import { c as PopoverContent, i as PopoverPanel, n as PopoverTrigger, o as PopoverHeader, r as PopoverTitle, t as Popover } from "../popover-0WDxRi-s.js";
|
|
12
|
+
import { t as Meter } from "../meter-HD5taq57.js";
|
|
13
|
+
import { t as Field } from "../field-DkMfrmdj.js";
|
|
14
|
+
import { n as Radio } from "../radio-group-Dj43u35Z.js";
|
|
15
|
+
import { d as FormFooter, n as useAppForm, t as Form } from "../form-V2VqHn0D.js";
|
|
16
|
+
import { c as MenuRadioGroup, i as MenuSubmenu, l as MenuPopup, n as MenuTrigger, p as MenuCheckboxItem, r as MenuSubmenuTrigger, s as MenuRadioItem, t as Menu, u as MenuItem } from "../menu-sf13cnGp.js";
|
|
17
|
+
import { cva } from "class-variance-authority";
|
|
18
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
19
|
+
import { useState } from "react";
|
|
20
|
+
import { assignTableAPIs, columnFacetingFeature, columnFilteringFeature, columnSizingFeature, columnVisibilityFeature, constructFilterFn, createFacetedRowModel, createFacetedUniqueValues, createFilteredRowModel, createPaginatedRowModel, createSortedRowModel, createTableHook, createTableHookContexts, filterFn_arrHas, filterFn_arrIncludes, filterFn_arrIncludesAll, filterFn_arrIncludesSome, filterFn_between, filterFn_betweenInclusive, filterFn_empty, filterFn_endsWith, filterFn_equals, filterFn_equalsString, filterFn_equalsStringSensitive, filterFn_inDateRange, filterFn_inNumberRange, filterFn_includesString, filterFn_includesStringSensitive, filterFn_notEmpty, filterFn_startsWith, filterFn_weakEquals, functionalUpdate, globalFilteringFeature, makeStateUpdater, metaHelper, rowPaginationFeature, rowSelectionFeature, rowSortingFeature, sortFn_alphanumeric, sortFn_basic, sortFn_datetime, sortFn_text, tableFeatures } from "@tanstack/react-table";
|
|
21
|
+
import { z } from "zod";
|
|
22
|
+
import { useSelector } from "@tanstack/react-store";
|
|
23
|
+
// src/components/table/table.types.ts
|
|
24
|
+
const tableContainerVariants = cva("group/table flex min-w-0 flex-col gap-0", {
|
|
25
|
+
defaultVariants: { variant: "outline" },
|
|
26
|
+
variants: { variant: {
|
|
27
|
+
ghost: "",
|
|
28
|
+
outline: "overflow-hidden rounded-2xl border border-border"
|
|
29
|
+
} }
|
|
30
|
+
});
|
|
31
|
+
const stringFilterOperators = [
|
|
32
|
+
"equals",
|
|
33
|
+
"notEquals",
|
|
34
|
+
"contains",
|
|
35
|
+
"notContains",
|
|
36
|
+
"startsWith",
|
|
37
|
+
"endsWith"
|
|
38
|
+
];
|
|
39
|
+
const numberFilterOperators = [
|
|
40
|
+
"equals",
|
|
41
|
+
"notEquals",
|
|
42
|
+
"greaterThan",
|
|
43
|
+
"lessThan",
|
|
44
|
+
"between"
|
|
45
|
+
];
|
|
46
|
+
const dateFilterOperators = [
|
|
47
|
+
"equals",
|
|
48
|
+
"notEquals",
|
|
49
|
+
"greaterThan",
|
|
50
|
+
"lessThan",
|
|
51
|
+
"between"
|
|
52
|
+
];
|
|
53
|
+
const defaultFilterOperatorLabels = {
|
|
54
|
+
between: "Is between",
|
|
55
|
+
contains: "Contains",
|
|
56
|
+
endsWith: "Ends with",
|
|
57
|
+
equals: "Is",
|
|
58
|
+
greaterThan: "Is greater than",
|
|
59
|
+
lessThan: "Is less than",
|
|
60
|
+
notContains: "Does not contain",
|
|
61
|
+
notEquals: "Is not",
|
|
62
|
+
startsWith: "Starts with"
|
|
63
|
+
};
|
|
64
|
+
const dateFilterSchema = z.object({
|
|
65
|
+
filterOperator: z.enum(dateFilterOperators),
|
|
66
|
+
filterValueFrom: z.union([z.literal(""), z.iso.date()]),
|
|
67
|
+
filterValueTo: z.union([z.literal(""), z.iso.date()])
|
|
68
|
+
});
|
|
69
|
+
const stringFilterSchema = z.object({
|
|
70
|
+
filterOperator: z.enum(stringFilterOperators),
|
|
71
|
+
filterValue: z.string()
|
|
72
|
+
});
|
|
73
|
+
const numberFilterSchema = z.object({
|
|
74
|
+
filterOperator: z.enum(numberFilterOperators),
|
|
75
|
+
filterValueFrom: z.string(),
|
|
76
|
+
filterValueTo: z.string()
|
|
77
|
+
});
|
|
78
|
+
// src/components/table/table.utils.ts
|
|
79
|
+
function getColumnHeaderLabel(column) {
|
|
80
|
+
const { header } = column.columnDef;
|
|
81
|
+
if (typeof header === "string" && header !== "") return header;
|
|
82
|
+
return column.id;
|
|
83
|
+
}
|
|
84
|
+
function asFilterValue(value) {
|
|
85
|
+
return value;
|
|
86
|
+
}
|
|
87
|
+
const ZERO$1 = 0;
|
|
88
|
+
const FIRST_RANGE_INDEX$1 = 0;
|
|
89
|
+
const SECOND_RANGE_INDEX = 1;
|
|
90
|
+
const getDateTimestamp = (date) => Date.UTC(date.getFullYear(), date.getMonth(), date.getDate());
|
|
91
|
+
const selectFilterFn = constructFilterFn({
|
|
92
|
+
autoRemove: (value) => !value?.length,
|
|
93
|
+
filter: (dataValue, filterValue) => filterValue.includes(dataValue)
|
|
94
|
+
});
|
|
95
|
+
const parseToTimestamp = (value) => {
|
|
96
|
+
if (!value) return;
|
|
97
|
+
const parsed = new Date(value);
|
|
98
|
+
if (Number.isNaN(parsed.getTime())) return;
|
|
99
|
+
return getDateTimestamp(parsed);
|
|
100
|
+
};
|
|
101
|
+
const normalizeDataValue = (value) => {
|
|
102
|
+
if (value instanceof Date) return getDateTimestamp(value);
|
|
103
|
+
if (typeof value === "number") return getDateTimestamp(new Date(value));
|
|
104
|
+
if (typeof value === "string") return parseToTimestamp(value) ?? ZERO$1;
|
|
105
|
+
return ZERO$1;
|
|
106
|
+
};
|
|
107
|
+
const dateFilterFn = constructFilterFn({
|
|
108
|
+
autoRemove: (value) => !value || !value.date[FIRST_RANGE_INDEX$1] && !value.date[SECOND_RANGE_INDEX],
|
|
109
|
+
filter: (dataValue, filterValue) => {
|
|
110
|
+
const { operator, from, to } = filterValue;
|
|
111
|
+
switch (operator) {
|
|
112
|
+
case "equals": return from !== void 0 && dataValue === from;
|
|
113
|
+
case "notEquals": return from !== void 0 && dataValue !== from;
|
|
114
|
+
case "greaterThan": return from !== void 0 && dataValue > from;
|
|
115
|
+
case "lessThan": return from !== void 0 && dataValue < from;
|
|
116
|
+
case "between": return from !== void 0 && to !== void 0 && dataValue >= from && dataValue <= to;
|
|
117
|
+
default: return true;
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
resolveDataValue: normalizeDataValue,
|
|
121
|
+
resolveFilterValue: (value) => ({
|
|
122
|
+
from: parseToTimestamp(value.date[FIRST_RANGE_INDEX$1]),
|
|
123
|
+
operator: value.operator,
|
|
124
|
+
to: parseToTimestamp(value.date[SECOND_RANGE_INDEX])
|
|
125
|
+
})
|
|
126
|
+
});
|
|
127
|
+
const stringFilterFn = constructFilterFn({
|
|
128
|
+
autoRemove: (value) => !value || value.value === "",
|
|
129
|
+
filter: (dataValue, filterValue) => {
|
|
130
|
+
const { operator, value } = filterValue, normalizedDataValue = dataValue.toLocaleLowerCase(), normalizedFilterValue = value.toLocaleLowerCase();
|
|
131
|
+
switch (operator) {
|
|
132
|
+
case "equals": return normalizedDataValue === normalizedFilterValue;
|
|
133
|
+
case "notEquals": return normalizedDataValue !== normalizedFilterValue;
|
|
134
|
+
case "contains": return normalizedDataValue.includes(normalizedFilterValue);
|
|
135
|
+
case "notContains": return !normalizedDataValue.includes(normalizedFilterValue);
|
|
136
|
+
case "startsWith": return normalizedDataValue.startsWith(normalizedFilterValue);
|
|
137
|
+
case "endsWith": return normalizedDataValue.endsWith(normalizedFilterValue);
|
|
138
|
+
default: return true;
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
resolveDataValue: (value) => {
|
|
142
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return String(value);
|
|
143
|
+
return "";
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
const parseToNumber = (value) => {
|
|
147
|
+
if (value.trim() === "") return;
|
|
148
|
+
const parsed = Number(value);
|
|
149
|
+
if (!Number.isFinite(parsed)) return;
|
|
150
|
+
return parsed;
|
|
151
|
+
};
|
|
152
|
+
const numberFilterFn = constructFilterFn({
|
|
153
|
+
autoRemove: (value) => !value || value.number[FIRST_RANGE_INDEX$1] === "" && value.number[SECOND_RANGE_INDEX] === "",
|
|
154
|
+
filter: (dataValue, filterValue) => {
|
|
155
|
+
const { operator, from, to } = filterValue;
|
|
156
|
+
switch (operator) {
|
|
157
|
+
case "equals": return from !== void 0 && dataValue === from;
|
|
158
|
+
case "notEquals": return from !== void 0 && dataValue !== from;
|
|
159
|
+
case "greaterThan": return from !== void 0 && dataValue > from;
|
|
160
|
+
case "lessThan": return from !== void 0 && dataValue < from;
|
|
161
|
+
case "between": return (from === void 0 || dataValue >= from) && (to === void 0 || dataValue <= to);
|
|
162
|
+
default: return true;
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
resolveDataValue: (value) => Number(value),
|
|
166
|
+
resolveFilterValue: (value) => {
|
|
167
|
+
const from = parseToNumber(value.number[FIRST_RANGE_INDEX$1]), to = parseToNumber(value.number[SECOND_RANGE_INDEX]);
|
|
168
|
+
if (from !== void 0 && to !== void 0 && from > to) return {
|
|
169
|
+
from: to,
|
|
170
|
+
operator: value.operator,
|
|
171
|
+
to: from
|
|
172
|
+
};
|
|
173
|
+
return {
|
|
174
|
+
from,
|
|
175
|
+
operator: value.operator,
|
|
176
|
+
to
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
// src/components/table/table-feature-context.ts
|
|
181
|
+
const features = tableFeatures({
|
|
182
|
+
columnFacetingFeature,
|
|
183
|
+
columnFilteringFeature,
|
|
184
|
+
columnMeta: metaHelper(),
|
|
185
|
+
columnSizingFeature,
|
|
186
|
+
columnVisibilityFeature,
|
|
187
|
+
datasetPlugin: {
|
|
188
|
+
constructTableAPIs: (table) => {
|
|
189
|
+
const options = table.options;
|
|
190
|
+
assignTableAPIs("datasetPlugin", table, { table_setCurrentDataset: { fn: (updater) => {
|
|
191
|
+
const safeUpdater = (old) => functionalUpdate(updater, old);
|
|
192
|
+
return options.onCurrentDatasetChange?.(safeUpdater);
|
|
193
|
+
} } });
|
|
194
|
+
},
|
|
195
|
+
getDefaultTableOptions: (table) => ({ onCurrentDatasetChange: makeStateUpdater("currentDataset", table) }),
|
|
196
|
+
getInitialState: (initialState) => ({
|
|
197
|
+
currentDataset: {
|
|
198
|
+
data: [],
|
|
199
|
+
id: "",
|
|
200
|
+
name: ""
|
|
201
|
+
},
|
|
202
|
+
datasets: [],
|
|
203
|
+
...initialState
|
|
204
|
+
})
|
|
205
|
+
},
|
|
206
|
+
facetedRowModel: createFacetedRowModel(),
|
|
207
|
+
facetedUniqueValues: createFacetedUniqueValues(),
|
|
208
|
+
filterFns: {
|
|
209
|
+
arrHas: filterFn_arrHas,
|
|
210
|
+
arrIncludes: filterFn_arrIncludes,
|
|
211
|
+
arrIncludesAll: filterFn_arrIncludesAll,
|
|
212
|
+
arrIncludesSome: filterFn_arrIncludesSome,
|
|
213
|
+
between: filterFn_between,
|
|
214
|
+
betweenInclusive: filterFn_betweenInclusive,
|
|
215
|
+
date: dateFilterFn,
|
|
216
|
+
empty: filterFn_empty,
|
|
217
|
+
endsWith: filterFn_endsWith,
|
|
218
|
+
equals: filterFn_equals,
|
|
219
|
+
equalsString: filterFn_equalsString,
|
|
220
|
+
equalsStringSensitive: filterFn_equalsStringSensitive,
|
|
221
|
+
inDateRange: filterFn_inDateRange,
|
|
222
|
+
inNumberRange: filterFn_inNumberRange,
|
|
223
|
+
includesString: filterFn_includesString,
|
|
224
|
+
includesStringSensitive: filterFn_includesStringSensitive,
|
|
225
|
+
notEmpty: filterFn_notEmpty,
|
|
226
|
+
number: numberFilterFn,
|
|
227
|
+
select: selectFilterFn,
|
|
228
|
+
startsWith: filterFn_startsWith,
|
|
229
|
+
string: stringFilterFn,
|
|
230
|
+
weakEquals: filterFn_weakEquals
|
|
231
|
+
},
|
|
232
|
+
filteredRowModel: createFilteredRowModel(),
|
|
233
|
+
globalFilteringFeature,
|
|
234
|
+
paginatedRowModel: createPaginatedRowModel(),
|
|
235
|
+
rowPaginationFeature,
|
|
236
|
+
rowSelectionFeature,
|
|
237
|
+
rowSortingFeature,
|
|
238
|
+
sortFns: {
|
|
239
|
+
alphanumeric: sortFn_alphanumeric,
|
|
240
|
+
basic: sortFn_basic,
|
|
241
|
+
datetime: sortFn_datetime,
|
|
242
|
+
text: sortFn_text
|
|
243
|
+
},
|
|
244
|
+
sortedRowModel: createSortedRowModel(),
|
|
245
|
+
tableMeta: metaHelper(),
|
|
246
|
+
viewModePlugin: {
|
|
247
|
+
constructTableAPIs: (table) => {
|
|
248
|
+
const options = table.options;
|
|
249
|
+
assignTableAPIs("viewModePlugin", table, {
|
|
250
|
+
table_setViewMode: { fn: (updater) => {
|
|
251
|
+
const safeUpdater = (old) => {
|
|
252
|
+
return functionalUpdate(updater, old);
|
|
253
|
+
};
|
|
254
|
+
return options.onViewModeChange?.(safeUpdater);
|
|
255
|
+
} },
|
|
256
|
+
table_toggleViewMode: { fn: (value) => {
|
|
257
|
+
const safeUpdater = (old) => {
|
|
258
|
+
if (value) return value;
|
|
259
|
+
if (old === "list") return "grid";
|
|
260
|
+
return "list";
|
|
261
|
+
};
|
|
262
|
+
return options.onViewModeChange?.(safeUpdater);
|
|
263
|
+
} }
|
|
264
|
+
});
|
|
265
|
+
},
|
|
266
|
+
getDefaultTableOptions: (table) => ({
|
|
267
|
+
enableViewModeToggle: true,
|
|
268
|
+
onViewModeChange: makeStateUpdater("viewMode", table)
|
|
269
|
+
}),
|
|
270
|
+
getInitialState: (initialState) => ({
|
|
271
|
+
viewMode: "list",
|
|
272
|
+
...initialState
|
|
273
|
+
})
|
|
274
|
+
}
|
|
275
|
+
}), { tableContext, cellContext, headerContext, useTableContext: useTableContext$1, useCellContext: useCellContext$1, useHeaderContext: useHeaderContext$1 } = createTableHookContexts();
|
|
276
|
+
// src/components/table/table-avatar-cell.tsx
|
|
277
|
+
function TableAvatarCell({ fallback, className, children, ref, ...props }) {
|
|
278
|
+
const value = useCellContext$1().getValue();
|
|
279
|
+
return /* @__PURE__ */ jsxs(Avatar, {
|
|
280
|
+
className: cn("", className),
|
|
281
|
+
ref,
|
|
282
|
+
...props,
|
|
283
|
+
children: [
|
|
284
|
+
/* @__PURE__ */ jsx(Avatar.Image, { src: value }),
|
|
285
|
+
fallback && /* @__PURE__ */ jsx(Avatar.Fallback, { children: fallback }),
|
|
286
|
+
children
|
|
287
|
+
]
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
// src/components/table/table-badge-cell.tsx
|
|
291
|
+
function resolveTone(tone, value) {
|
|
292
|
+
if (typeof tone === "function") return tone(value);
|
|
293
|
+
return tone;
|
|
294
|
+
}
|
|
295
|
+
function TableBadgeCell({ className, children, ref, tone, ...props }) {
|
|
296
|
+
const value = useCellContext$1().getValue(), resolvedTone = resolveTone(tone, value);
|
|
297
|
+
return /* @__PURE__ */ jsxs(Badge, {
|
|
298
|
+
variant: "soft",
|
|
299
|
+
className: cn("", className),
|
|
300
|
+
ref,
|
|
301
|
+
tone: resolvedTone,
|
|
302
|
+
...props,
|
|
303
|
+
children: [children, value]
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
// src/components/table/table-body.tsx
|
|
307
|
+
function TableBody({ showDivider = true, className, ref, ...props }) {
|
|
308
|
+
const table = useTableContext$1();
|
|
309
|
+
return /* @__PURE__ */ jsx(table.Subscribe, {
|
|
310
|
+
selector: (state) => state,
|
|
311
|
+
children: (state) => {
|
|
312
|
+
if (state.viewMode === "grid") return /* @__PURE__ */ jsx("ul", {
|
|
313
|
+
className: cn("grid auto-rows-fr grid-cols-[repeat(auto-fill,minmax(252px,1fr))] gap-sm overflow-y-auto border-border group-data-[variant=outline]/table:border-y group-data-[variant=outline]/table:p-md", className),
|
|
314
|
+
children: table.getRowModel().rows.map((row) => /* @__PURE__ */ jsx("li", {
|
|
315
|
+
className: "min-w-0",
|
|
316
|
+
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(table.AppCell, {
|
|
317
|
+
cell,
|
|
318
|
+
children: (renderedCell) => /* @__PURE__ */ jsx("div", {
|
|
319
|
+
className: "w-full",
|
|
320
|
+
children: /* @__PURE__ */ jsx(table.FlexRender, { cell: renderedCell })
|
|
321
|
+
})
|
|
322
|
+
}, cell.id))
|
|
323
|
+
}, row.id))
|
|
324
|
+
});
|
|
325
|
+
return /* @__PURE__ */ jsx("tbody", {
|
|
326
|
+
className: cn(showDivider && "divide-y divide-border", "overflow-y-auto", className),
|
|
327
|
+
ref,
|
|
328
|
+
...props,
|
|
329
|
+
children: table.getRowModel().rows.map((row) => /* @__PURE__ */ jsx("tr", {
|
|
330
|
+
className: cn(row.getIsSelected() && "bg-neutral-container-low"),
|
|
331
|
+
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(table.AppCell, {
|
|
332
|
+
cell,
|
|
333
|
+
children: (renderedCell) => /* @__PURE__ */ jsx("td", {
|
|
334
|
+
style: { width: renderedCell.column.getSize() },
|
|
335
|
+
className: cn("h-2xl p-xs", className),
|
|
336
|
+
children: /* @__PURE__ */ jsx(table.FlexRender, { cell: renderedCell })
|
|
337
|
+
})
|
|
338
|
+
}, cell.id))
|
|
339
|
+
}, row.id))
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
// src/components/table/table-boolean-cell.tsx
|
|
345
|
+
function TableBooleanCell({ trueLabel = "Yes", falseLabel = "No", children, ...props }) {
|
|
346
|
+
const value = useCellContext$1().getValue();
|
|
347
|
+
if (value === void 0 || value === null) return;
|
|
348
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
349
|
+
...props,
|
|
350
|
+
children: [
|
|
351
|
+
children,
|
|
352
|
+
value && trueLabel,
|
|
353
|
+
!value && falseLabel
|
|
354
|
+
]
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
// src/components/table/table-bottom-bar.tsx
|
|
358
|
+
function TableBottomBar({ className, ref, ...props }) {
|
|
359
|
+
return /* @__PURE__ */ jsx("div", {
|
|
360
|
+
className: cn("mt-auto flex w-full flex-wrap items-center justify-between pt-md group-data-[variant=outline]/table:border-t group-data-[variant=outline]/table:border-border", "in-data-[slot=table-container]:sticky in-data-[slot=table-container]:bottom-0 in-data-[slot=table-container]:z-10 in-data-[slot=table-container]:bg-inherit", className),
|
|
361
|
+
"data-slot": "table-bottom-bar",
|
|
362
|
+
ref,
|
|
363
|
+
...props
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
// src/components/table/table-checkbox-cell.tsx
|
|
367
|
+
function TableCheckboxCell({ className, ref, ...props }) {
|
|
368
|
+
const cell = useCellContext$1(), table = useTableContext$1(), { row } = cell;
|
|
369
|
+
return /* @__PURE__ */ jsx(table.Subscribe, {
|
|
370
|
+
selector: (state) => state.rowSelection,
|
|
371
|
+
children: () => /* @__PURE__ */ jsx(Checkbox, {
|
|
372
|
+
variant: "outline",
|
|
373
|
+
"aria-label": "Select row",
|
|
374
|
+
checked: row.getIsSelected() || row.getCanSelectSubRows() && row.getIsAllSubRowsSelected(),
|
|
375
|
+
disabled: !row.getCanSelect(),
|
|
376
|
+
indeterminate: row.getIsSomeSelected(),
|
|
377
|
+
onCheckedChange: (checked) => row.toggleSelected(checked),
|
|
378
|
+
className: cn("mx-auto flex", className),
|
|
379
|
+
ref,
|
|
380
|
+
...props
|
|
381
|
+
})
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
// src/components/table/table-checkbox-header.tsx
|
|
385
|
+
function TableCheckboxHeader({ className, ref, ...props }) {
|
|
386
|
+
const table = useTableContext$1();
|
|
387
|
+
return /* @__PURE__ */ jsx(table.Subscribe, {
|
|
388
|
+
selector: (state) => state.rowSelection,
|
|
389
|
+
children: () => {
|
|
390
|
+
const allRowsSelected = table.getIsAllRowsSelected();
|
|
391
|
+
return /* @__PURE__ */ jsx(Checkbox, {
|
|
392
|
+
"aria-label": "Select all rows",
|
|
393
|
+
variant: "outline",
|
|
394
|
+
checked: allRowsSelected,
|
|
395
|
+
indeterminate: !allRowsSelected && table.getIsSomeRowsSelected(),
|
|
396
|
+
onCheckedChange: (checked) => table.toggleAllRowsSelected(checked),
|
|
397
|
+
className: cn("mx-auto flex", className),
|
|
398
|
+
ref,
|
|
399
|
+
...props
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
// src/components/table/table-column-toggle.tsx
|
|
405
|
+
function TableColumnToggle({ className, ref, ...props }) {
|
|
406
|
+
const table = useTableContext$1(), handleToggleColumn = (columnId) => {
|
|
407
|
+
table.getColumn(columnId)?.toggleVisibility();
|
|
408
|
+
};
|
|
409
|
+
return /* @__PURE__ */ jsxs(Menu, { children: [/* @__PURE__ */ jsx(MenuTrigger, {
|
|
410
|
+
className: cn("shrink-0", className),
|
|
411
|
+
ref,
|
|
412
|
+
...props
|
|
413
|
+
}), /* @__PURE__ */ jsx(MenuPopup, { children: table.getAllColumns().flatMap((column) => {
|
|
414
|
+
if (!column.getCanHide()) return [];
|
|
415
|
+
return /* @__PURE__ */ jsx(MenuCheckboxItem, {
|
|
416
|
+
checked: column.getIsVisible(),
|
|
417
|
+
onCheckedChange: () => handleToggleColumn(column.id),
|
|
418
|
+
children: getColumnHeaderLabel(column)
|
|
419
|
+
}, column.id);
|
|
420
|
+
}) })] });
|
|
421
|
+
}
|
|
422
|
+
// src/components/table/table-container.tsx
|
|
423
|
+
function TableContainer({ variant = "outline", className, ref, ...props }) {
|
|
424
|
+
return /* @__PURE__ */ jsx("div", {
|
|
425
|
+
"data-slot": "table-container",
|
|
426
|
+
"data-variant": variant,
|
|
427
|
+
className: cn(tableContainerVariants({ variant }), className),
|
|
428
|
+
ref,
|
|
429
|
+
...props
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
// src/components/table/table-currency-cell.tsx
|
|
433
|
+
function TableCurrencyCell({ currency, locale, options, children, ...props }) {
|
|
434
|
+
const value = useCellContext$1().getValue();
|
|
435
|
+
if (value === void 0 || value === null) return;
|
|
436
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
437
|
+
...props,
|
|
438
|
+
children: [children, new Intl.NumberFormat(locale, {
|
|
439
|
+
...options,
|
|
440
|
+
currency,
|
|
441
|
+
style: "currency"
|
|
442
|
+
}).format(value)]
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
// src/components/table/table-dataset-tab.tsx
|
|
446
|
+
function TableDatasetTab({ className, children, ref, ...props }) {
|
|
447
|
+
const table = useTableContext$1(), datasets = useSelector(table.atoms.datasets), currentDataset = useSelector(table.atoms.currentDataset), handleTabChange = (datasetId) => {
|
|
448
|
+
const dataset = datasets.find((candidate) => candidate.id === datasetId);
|
|
449
|
+
if (!dataset) return;
|
|
450
|
+
table.setCurrentDataset(dataset);
|
|
451
|
+
};
|
|
452
|
+
return /* @__PURE__ */ jsxs(Tabs, {
|
|
453
|
+
value: currentDataset.id,
|
|
454
|
+
onValueChange: handleTabChange,
|
|
455
|
+
className: cn(className),
|
|
456
|
+
ref,
|
|
457
|
+
...props,
|
|
458
|
+
"data-slot": "table-dataset-tab",
|
|
459
|
+
children: [children, /* @__PURE__ */ jsx(TabsList, { children: datasets.map((dataset) => /* @__PURE__ */ jsx(TabsTab, {
|
|
460
|
+
value: dataset.id,
|
|
461
|
+
children: dataset.name
|
|
462
|
+
}, dataset.id)) })]
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
// src/components/table/table-date-time-cell.tsx
|
|
466
|
+
function TableDateTimeCell({ locale, options, className, children, ref, ...props }) {
|
|
467
|
+
const date = useCellContext$1().getValue();
|
|
468
|
+
if (!date) return;
|
|
469
|
+
if (Number.isNaN(date.getTime())) return "Invalid date";
|
|
470
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
471
|
+
className: cn("", className),
|
|
472
|
+
ref,
|
|
473
|
+
...props,
|
|
474
|
+
children: [children, formatDate(date, locale, options)]
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
// src/components/table/table-empty.tsx
|
|
478
|
+
const EMPTY_LIMIT = 0;
|
|
479
|
+
function TableEmpty({ className, children, ref, ...props }) {
|
|
480
|
+
const table = useTableContext$1();
|
|
481
|
+
return /* @__PURE__ */ jsx(table.Subscribe, {
|
|
482
|
+
selector: (state) => state.globalFilter,
|
|
483
|
+
children: () => table.getFilteredRowModel().rows.length <= EMPTY_LIMIT && /* @__PURE__ */ jsx("div", {
|
|
484
|
+
"data-slot": "table-empty",
|
|
485
|
+
className: cn("flex w-full min-w-0 flex-col items-center justify-center gap-md px-md py-3xl text-center", className),
|
|
486
|
+
ref,
|
|
487
|
+
...props,
|
|
488
|
+
children
|
|
489
|
+
})
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
// src/components/table/table-empty-content.tsx
|
|
493
|
+
function TableEmptyContent({ className, children, ref, ...props }) {
|
|
494
|
+
return /* @__PURE__ */ jsx("div", {
|
|
495
|
+
className: cn("flex w-full max-w-[28rem] min-w-0 flex-col items-center gap-2xs", className),
|
|
496
|
+
ref,
|
|
497
|
+
...props,
|
|
498
|
+
children
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
// src/components/table/table-empty-description.tsx
|
|
502
|
+
function TableEmptyDescription({ className, children, ref, ...props }) {
|
|
503
|
+
return /* @__PURE__ */ jsx("span", {
|
|
504
|
+
className: cn("block max-w-[28rem] style-text-default--1 text-pretty wrap-break-word text-on-surface-variant", className),
|
|
505
|
+
ref,
|
|
506
|
+
...props,
|
|
507
|
+
children
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
// src/components/table/table-empty-footer.tsx
|
|
511
|
+
function TableEmptyFooter({ className, children, ref, ...props }) {
|
|
512
|
+
return /* @__PURE__ */ jsx("div", {
|
|
513
|
+
className: cn("flex w-full flex-wrap items-center justify-center gap-xs", className),
|
|
514
|
+
ref,
|
|
515
|
+
...props,
|
|
516
|
+
children
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
// src/components/table/table-empty-header.tsx
|
|
520
|
+
function TableEmptyHeader({ className, children, ref, ...props }) {
|
|
521
|
+
return /* @__PURE__ */ jsx("div", {
|
|
522
|
+
className: cn("flex w-full max-w-[28rem] flex-col items-center gap-sm", className),
|
|
523
|
+
ref,
|
|
524
|
+
...props,
|
|
525
|
+
children
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
// src/components/table/table-empty-title.tsx
|
|
529
|
+
function TableEmptyTitle({ className, children, ref, ...props }) {
|
|
530
|
+
return /* @__PURE__ */ jsx("span", {
|
|
531
|
+
className: cn("block style-text-strong-1 text-balance text-on-surface", className),
|
|
532
|
+
ref,
|
|
533
|
+
...props,
|
|
534
|
+
children
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
// src/components/table/table-date-filter-form.tsx
|
|
538
|
+
const FROM_DATE_INDEX = 0;
|
|
539
|
+
const TO_DATE_INDEX = 1;
|
|
540
|
+
function TableDateFilterForm({ column, className, children, ref, ...props }) {
|
|
541
|
+
const table = useTableContext$1(), filterOperatorLabels = table.options.meta?.translations?.filterOperatorLabels, buttonLabels = table.options.meta?.translations?.buttonLabels ?? {
|
|
542
|
+
apply: "Apply",
|
|
543
|
+
reset: "Reset"
|
|
544
|
+
}, currentFilter = asFilterValue(column.getFilterValue()), form = useAppForm({
|
|
545
|
+
defaultValues: {
|
|
546
|
+
filterOperator: currentFilter?.operator ?? "equals",
|
|
547
|
+
filterValueFrom: currentFilter?.date[FROM_DATE_INDEX] ?? "",
|
|
548
|
+
filterValueTo: currentFilter?.date[TO_DATE_INDEX] ?? ""
|
|
549
|
+
},
|
|
550
|
+
onSubmit: ({ value }) => {
|
|
551
|
+
column.setFilterValue({
|
|
552
|
+
date: [value.filterValueFrom, value.filterValueTo],
|
|
553
|
+
operator: value.filterOperator
|
|
554
|
+
});
|
|
555
|
+
},
|
|
556
|
+
validators: { onSubmit: dateFilterSchema }
|
|
557
|
+
}), onReset = () => {
|
|
558
|
+
column.setFilterValue(void 0);
|
|
559
|
+
form.reset();
|
|
560
|
+
};
|
|
561
|
+
return /* @__PURE__ */ jsx(Form, {
|
|
562
|
+
onSubmit: async (event) => {
|
|
563
|
+
event.preventDefault();
|
|
564
|
+
event.stopPropagation();
|
|
565
|
+
await form.handleSubmit();
|
|
566
|
+
},
|
|
567
|
+
onReset,
|
|
568
|
+
className: cn("", className),
|
|
569
|
+
ref,
|
|
570
|
+
...props,
|
|
571
|
+
children: /* @__PURE__ */ jsxs(form.AppForm, { children: [
|
|
572
|
+
children,
|
|
573
|
+
/* @__PURE__ */ jsx(form.Errors, {}),
|
|
574
|
+
/* @__PURE__ */ jsx(form.Set, { children: /* @__PURE__ */ jsx(form.SetHeading, { children: /* @__PURE__ */ jsx(form.SetContent, { children: /* @__PURE__ */ jsx(Field, { children: /* @__PURE__ */ jsx(form.AppField, {
|
|
575
|
+
name: "filterOperator",
|
|
576
|
+
children: (field) => /* @__PURE__ */ jsxs(Field, { children: [/* @__PURE__ */ jsx(field.Errors, {}), /* @__PURE__ */ jsx(field.RadioGroup, { children: dateFilterOperators.map((operator) => /* @__PURE__ */ jsxs(field.Set, { children: [/* @__PURE__ */ jsx(Radio, {
|
|
577
|
+
value: operator,
|
|
578
|
+
variant: "inSurface",
|
|
579
|
+
children: filterOperatorLabels?.[operator] ?? defaultFilterOperatorLabels[operator]
|
|
580
|
+
}), field.state.value === operator && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(form.AppField, {
|
|
581
|
+
name: "filterValueFrom",
|
|
582
|
+
children: (valueField) => /* @__PURE__ */ jsxs(Field, { children: [/* @__PURE__ */ jsx(valueField.Errors, {}), /* @__PURE__ */ jsx(valueField.Input, {
|
|
583
|
+
type: "date",
|
|
584
|
+
variant: "secondary"
|
|
585
|
+
})] })
|
|
586
|
+
}), operator === "between" && /* @__PURE__ */ jsx(form.AppField, {
|
|
587
|
+
name: "filterValueTo",
|
|
588
|
+
children: (valueField) => /* @__PURE__ */ jsxs(Field, { children: [/* @__PURE__ */ jsx(valueField.Errors, {}), /* @__PURE__ */ jsx(valueField.Input, {
|
|
589
|
+
type: "date",
|
|
590
|
+
variant: "secondary"
|
|
591
|
+
})] })
|
|
592
|
+
})] })] }, operator)) })] })
|
|
593
|
+
}) }) }) }) }),
|
|
594
|
+
/* @__PURE__ */ jsxs(form.Footer, { children: [/* @__PURE__ */ jsx(form.Reset, { children: buttonLabels.reset }), /* @__PURE__ */ jsx(form.Submit, { children: buttonLabels.apply })] })
|
|
595
|
+
] })
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
// src/components/table/table-date-filter-chip.tsx
|
|
599
|
+
const FIRST_DATE_INDEX = 0;
|
|
600
|
+
const LAST_DATE_INDEX = 1;
|
|
601
|
+
function getDateFilterLabel(date) {
|
|
602
|
+
if (Array.isArray(date)) {
|
|
603
|
+
if (date[LAST_DATE_INDEX] !== "") return date.join(" - ");
|
|
604
|
+
return date[FIRST_DATE_INDEX];
|
|
605
|
+
}
|
|
606
|
+
return date;
|
|
607
|
+
}
|
|
608
|
+
function TableDateFilterChip({ column, className, children, ref, ...props }) {
|
|
609
|
+
const filterOperatorLabels = useTableContext$1().options.meta?.translations?.filterOperatorLabels, columnFilter = asFilterValue(column.getFilterValue());
|
|
610
|
+
return /* @__PURE__ */ jsxs(Popover, { children: [/* @__PURE__ */ jsx(PopoverTrigger, {
|
|
611
|
+
className: cn("", className),
|
|
612
|
+
ref,
|
|
613
|
+
...props,
|
|
614
|
+
children: /* @__PURE__ */ jsxs(Button, {
|
|
615
|
+
tone: "neutral",
|
|
616
|
+
size: "extraSmall",
|
|
617
|
+
variant: "soft",
|
|
618
|
+
children: [
|
|
619
|
+
/* @__PURE__ */ jsx(Icon, { name: "filter" }),
|
|
620
|
+
/* @__PURE__ */ jsx("span", { children: getColumnHeaderLabel(column) }),
|
|
621
|
+
/* @__PURE__ */ jsx("span", {
|
|
622
|
+
className: "lowercase",
|
|
623
|
+
children: filterOperatorLabels?.[columnFilter.operator] ?? defaultFilterOperatorLabels[columnFilter.operator]
|
|
624
|
+
}),
|
|
625
|
+
/* @__PURE__ */ jsx("span", { children: getDateFilterLabel(columnFilter.date) })
|
|
626
|
+
]
|
|
627
|
+
})
|
|
628
|
+
}), /* @__PURE__ */ jsx(PopoverPanel, { children: /* @__PURE__ */ jsxs(PopoverHeader, { children: [/* @__PURE__ */ jsx(PopoverTitle, { children: getColumnHeaderLabel(column) }), /* @__PURE__ */ jsxs(PopoverContent, { children: [children, /* @__PURE__ */ jsx(TableDateFilterForm, { column })] })] }) })] }, column.id);
|
|
629
|
+
}
|
|
630
|
+
// src/components/table/table-number-filter-form.tsx
|
|
631
|
+
const FROM_VALUE_INDEX = 0;
|
|
632
|
+
const TO_VALUE_INDEX = 1;
|
|
633
|
+
function TableNumberFilterForm({ column, className, children, ref, ...props }) {
|
|
634
|
+
const table = useTableContext$1(), filterOperatorLabels = table.options.meta?.translations?.filterOperatorLabels, buttonLabels = table.options.meta?.translations?.buttonLabels ?? {
|
|
635
|
+
apply: "Apply",
|
|
636
|
+
reset: "Reset"
|
|
637
|
+
}, currentFilter = asFilterValue(column.getFilterValue()), form = useAppForm({
|
|
638
|
+
defaultValues: {
|
|
639
|
+
filterOperator: currentFilter?.operator ?? "equals",
|
|
640
|
+
filterValueFrom: currentFilter?.number[FROM_VALUE_INDEX] ?? "",
|
|
641
|
+
filterValueTo: currentFilter?.number[TO_VALUE_INDEX] ?? ""
|
|
642
|
+
},
|
|
643
|
+
onSubmit: ({ value }) => {
|
|
644
|
+
column.setFilterValue({
|
|
645
|
+
number: [value.filterValueFrom, value.filterValueTo],
|
|
646
|
+
operator: value.filterOperator
|
|
647
|
+
});
|
|
648
|
+
},
|
|
649
|
+
validators: { onSubmit: numberFilterSchema }
|
|
650
|
+
}), onReset = () => {
|
|
651
|
+
column.setFilterValue(void 0);
|
|
652
|
+
form.reset({
|
|
653
|
+
filterOperator: "equals",
|
|
654
|
+
filterValueFrom: "",
|
|
655
|
+
filterValueTo: ""
|
|
656
|
+
});
|
|
657
|
+
};
|
|
658
|
+
return /* @__PURE__ */ jsx(Form, {
|
|
659
|
+
onSubmit: async (event) => {
|
|
660
|
+
event.preventDefault();
|
|
661
|
+
event.stopPropagation();
|
|
662
|
+
await form.handleSubmit();
|
|
663
|
+
},
|
|
664
|
+
onReset,
|
|
665
|
+
className: cn("", className),
|
|
666
|
+
ref,
|
|
667
|
+
...props,
|
|
668
|
+
children: /* @__PURE__ */ jsxs(form.AppForm, { children: [
|
|
669
|
+
children,
|
|
670
|
+
/* @__PURE__ */ jsx(form.Errors, {}),
|
|
671
|
+
/* @__PURE__ */ jsx(form.Set, { children: /* @__PURE__ */ jsx(form.SetContent, { children: /* @__PURE__ */ jsx(form.AppField, {
|
|
672
|
+
name: "filterOperator",
|
|
673
|
+
children: (field) => /* @__PURE__ */ jsxs(Field, { children: [/* @__PURE__ */ jsx(field.Errors, {}), /* @__PURE__ */ jsx(field.RadioGroup, { children: numberFilterOperators.map((operator) => /* @__PURE__ */ jsxs(field.Set, { children: [/* @__PURE__ */ jsx(Radio, {
|
|
674
|
+
value: operator,
|
|
675
|
+
variant: "inSurface",
|
|
676
|
+
children: filterOperatorLabels?.[operator] ?? defaultFilterOperatorLabels[operator]
|
|
677
|
+
}), field.state.value === operator && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(form.AppField, {
|
|
678
|
+
name: "filterValueFrom",
|
|
679
|
+
children: (valueField) => /* @__PURE__ */ jsxs(Field, { children: [/* @__PURE__ */ jsx(valueField.Errors, {}), /* @__PURE__ */ jsx(valueField.Input, {
|
|
680
|
+
"aria-label": `${column.id} filter value`,
|
|
681
|
+
type: "number",
|
|
682
|
+
variant: "secondary"
|
|
683
|
+
})] })
|
|
684
|
+
}), operator === "between" && /* @__PURE__ */ jsx(form.AppField, {
|
|
685
|
+
name: "filterValueTo",
|
|
686
|
+
children: (valueField) => /* @__PURE__ */ jsxs(Field, { children: [/* @__PURE__ */ jsx(valueField.Errors, {}), /* @__PURE__ */ jsx(valueField.Input, {
|
|
687
|
+
"aria-label": `${column.id} maximum filter value`,
|
|
688
|
+
type: "number",
|
|
689
|
+
variant: "secondary"
|
|
690
|
+
})] })
|
|
691
|
+
})] })] }, operator)) })] })
|
|
692
|
+
}) }) }),
|
|
693
|
+
/* @__PURE__ */ jsxs(form.Footer, { children: [/* @__PURE__ */ jsx(form.Reset, { children: buttonLabels.reset }), /* @__PURE__ */ jsx(form.Submit, { children: buttonLabels.apply })] })
|
|
694
|
+
] })
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
// src/components/table/table-number-filter-chip.tsx
|
|
698
|
+
const FIRST_RANGE_INDEX = 0;
|
|
699
|
+
function getFilterDisplayValue(filterValue) {
|
|
700
|
+
if (filterValue.operator === "between") return filterValue.number.filter(Boolean).join(" - ");
|
|
701
|
+
return filterValue.number[FIRST_RANGE_INDEX];
|
|
702
|
+
}
|
|
703
|
+
function TableNumberFilterChip({ column, className, children, ref, ...props }) {
|
|
704
|
+
const filterOperatorLabels = useTableContext$1().options.meta?.translations?.filterOperatorLabels, columnFilter = asFilterValue(column.getFilterValue()), filterValue = getFilterDisplayValue(columnFilter);
|
|
705
|
+
return /* @__PURE__ */ jsxs(Popover, { children: [/* @__PURE__ */ jsx(PopoverTrigger, {
|
|
706
|
+
className: cn("", className),
|
|
707
|
+
ref,
|
|
708
|
+
...props,
|
|
709
|
+
children: /* @__PURE__ */ jsxs(Button, {
|
|
710
|
+
tone: "neutral",
|
|
711
|
+
size: "extraSmall",
|
|
712
|
+
variant: "soft",
|
|
713
|
+
children: [
|
|
714
|
+
/* @__PURE__ */ jsx(Icon, { name: "filter" }),
|
|
715
|
+
/* @__PURE__ */ jsx("span", { children: getColumnHeaderLabel(column) }),
|
|
716
|
+
/* @__PURE__ */ jsx("span", {
|
|
717
|
+
className: "font-light lowercase",
|
|
718
|
+
children: filterOperatorLabels?.[columnFilter.operator] ?? defaultFilterOperatorLabels[columnFilter.operator]
|
|
719
|
+
}),
|
|
720
|
+
/* @__PURE__ */ jsx("span", { children: filterValue }),
|
|
721
|
+
children
|
|
722
|
+
]
|
|
723
|
+
})
|
|
724
|
+
}), /* @__PURE__ */ jsxs(PopoverPanel, { children: [/* @__PURE__ */ jsx(PopoverHeader, { children: /* @__PURE__ */ jsx(PopoverTitle, { children: getColumnHeaderLabel(column) }) }), /* @__PURE__ */ jsx(PopoverContent, { children: /* @__PURE__ */ jsx(TableNumberFilterForm, { column }) })] })] });
|
|
725
|
+
}
|
|
726
|
+
// src/components/table/table-select-filter-form.tsx
|
|
727
|
+
const EMPTY_FILTER_COUNT = 0;
|
|
728
|
+
const isSelectFilterOption = (value) => typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
729
|
+
const isSelectFilterValue = (value) => Array.isArray(value) && value.every(isSelectFilterOption);
|
|
730
|
+
const getSelectValueLabel = (value) => {
|
|
731
|
+
if (isSelectFilterValue(value)) return value.map(String).join(", ");
|
|
732
|
+
return "Select values";
|
|
733
|
+
};
|
|
734
|
+
function TableSelectFilterForm({ column, className, children, ref, ...props }) {
|
|
735
|
+
const table = useTableContext$1(), currentFilter = column.getFilterValue(), buttonLabels = table.options.meta?.translations?.buttonLabels ?? {
|
|
736
|
+
apply: "Apply",
|
|
737
|
+
reset: "Reset"
|
|
738
|
+
}, [filterValue, setFilterValue] = useState(() => {
|
|
739
|
+
if (isSelectFilterValue(currentFilter)) return currentFilter;
|
|
740
|
+
return [];
|
|
741
|
+
}), options = [...column.getFacetedUniqueValues().keys()].filter(isSelectFilterOption).toSorted((left, right) => String(left).localeCompare(String(right)));
|
|
742
|
+
return /* @__PURE__ */ jsxs(Form, {
|
|
743
|
+
className: cn("", className),
|
|
744
|
+
onReset: () => {
|
|
745
|
+
column.setFilterValue(void 0);
|
|
746
|
+
setFilterValue([]);
|
|
747
|
+
},
|
|
748
|
+
onSubmit: (event) => {
|
|
749
|
+
event.preventDefault();
|
|
750
|
+
event.stopPropagation();
|
|
751
|
+
if (filterValue.length > EMPTY_FILTER_COUNT) column.setFilterValue(filterValue);
|
|
752
|
+
},
|
|
753
|
+
ref,
|
|
754
|
+
...props,
|
|
755
|
+
children: [
|
|
756
|
+
children,
|
|
757
|
+
/* @__PURE__ */ jsxs(Select, {
|
|
758
|
+
multiple: true,
|
|
759
|
+
value: filterValue,
|
|
760
|
+
onValueChange: (value) => {
|
|
761
|
+
if (isSelectFilterValue(value)) setFilterValue(value);
|
|
762
|
+
},
|
|
763
|
+
children: [/* @__PURE__ */ jsxs(SelectTrigger, {
|
|
764
|
+
"aria-label": `${column.id} filter value`,
|
|
765
|
+
variant: "secondary",
|
|
766
|
+
children: [/* @__PURE__ */ jsx(SelectValue, {
|
|
767
|
+
placeholder: "Select values",
|
|
768
|
+
children: (value) => getSelectValueLabel(value)
|
|
769
|
+
}), /* @__PURE__ */ jsx(SelectIcon, { children: /* @__PURE__ */ jsx(Icon, { name: "chevronsUpDown" }) })]
|
|
770
|
+
}), /* @__PURE__ */ jsx(SelectPopup, {
|
|
771
|
+
alignItemWithTrigger: false,
|
|
772
|
+
sideOffset: 8,
|
|
773
|
+
children: /* @__PURE__ */ jsx(SelectList, { children: options.map((option) => /* @__PURE__ */ jsx(SelectItem, {
|
|
774
|
+
value: option,
|
|
775
|
+
children: /* @__PURE__ */ jsx(SelectTitle, { children: String(option) })
|
|
776
|
+
}, `${typeof option}:${String(option)}`)) })
|
|
777
|
+
})]
|
|
778
|
+
}),
|
|
779
|
+
/* @__PURE__ */ jsxs(FormFooter, { children: [/* @__PURE__ */ jsx(Button, {
|
|
780
|
+
className: "w-full",
|
|
781
|
+
tone: "neutral",
|
|
782
|
+
type: "reset",
|
|
783
|
+
variant: "outline",
|
|
784
|
+
children: buttonLabels.reset
|
|
785
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
786
|
+
className: "w-full",
|
|
787
|
+
disabled: filterValue.length === EMPTY_FILTER_COUNT,
|
|
788
|
+
type: "submit",
|
|
789
|
+
children: buttonLabels.apply
|
|
790
|
+
})] })
|
|
791
|
+
]
|
|
792
|
+
});
|
|
793
|
+
}
|
|
794
|
+
// src/components/table/table-select-filter-chip.tsx
|
|
795
|
+
function TableSelectFilterChip({ column, className, children, ref, ...props }) {
|
|
796
|
+
const columnFilter = asFilterValue(column.getFilterValue()), header = getColumnHeaderLabel(column);
|
|
797
|
+
return /* @__PURE__ */ jsxs(Popover, { children: [/* @__PURE__ */ jsx(PopoverTrigger, {
|
|
798
|
+
className: cn("", className),
|
|
799
|
+
ref,
|
|
800
|
+
...props,
|
|
801
|
+
children: /* @__PURE__ */ jsxs(Button, {
|
|
802
|
+
size: "extraSmall",
|
|
803
|
+
variant: "soft",
|
|
804
|
+
children: [
|
|
805
|
+
/* @__PURE__ */ jsx(Icon, { name: "filter" }),
|
|
806
|
+
/* @__PURE__ */ jsx("span", { children: header }),
|
|
807
|
+
/* @__PURE__ */ jsx("span", {
|
|
808
|
+
className: "font-light lowercase",
|
|
809
|
+
children: columnFilter.map(String).join(", ")
|
|
810
|
+
}),
|
|
811
|
+
children
|
|
812
|
+
]
|
|
813
|
+
})
|
|
814
|
+
}), /* @__PURE__ */ jsxs(PopoverPanel, { children: [/* @__PURE__ */ jsx(PopoverHeader, { children: /* @__PURE__ */ jsx(PopoverTitle, { children: header }) }), /* @__PURE__ */ jsx(PopoverContent, { children: /* @__PURE__ */ jsx(TableSelectFilterForm, { column }) })] })] });
|
|
815
|
+
}
|
|
816
|
+
// src/components/table/table-string-filter-form.tsx
|
|
817
|
+
function TableStringFilterForm({ column, className, children, ref, ...props }) {
|
|
818
|
+
const table = useTableContext$1(), filterOperatorLabels = table.options.meta?.translations?.filterOperatorLabels, buttonLabels = table.options.meta?.translations?.buttonLabels ?? {
|
|
819
|
+
apply: "Apply",
|
|
820
|
+
reset: "Reset"
|
|
821
|
+
}, currentFilter = asFilterValue(column.getFilterValue()), form = useAppForm({
|
|
822
|
+
defaultValues: {
|
|
823
|
+
filterOperator: currentFilter?.operator ?? "contains",
|
|
824
|
+
filterValue: currentFilter?.value ?? ""
|
|
825
|
+
},
|
|
826
|
+
onSubmit: ({ value }) => {
|
|
827
|
+
column.setFilterValue({
|
|
828
|
+
operator: value.filterOperator,
|
|
829
|
+
value: value.filterValue
|
|
830
|
+
});
|
|
831
|
+
},
|
|
832
|
+
validators: { onSubmit: stringFilterSchema }
|
|
833
|
+
}), onReset = () => {
|
|
834
|
+
column.setFilterValue(void 0);
|
|
835
|
+
form.reset({
|
|
836
|
+
filterOperator: "contains",
|
|
837
|
+
filterValue: ""
|
|
838
|
+
});
|
|
839
|
+
};
|
|
840
|
+
return /* @__PURE__ */ jsx(Form, {
|
|
841
|
+
onSubmit: async (event) => {
|
|
842
|
+
event.preventDefault();
|
|
843
|
+
event.stopPropagation();
|
|
844
|
+
await form.handleSubmit();
|
|
845
|
+
},
|
|
846
|
+
onReset,
|
|
847
|
+
className: cn("", className),
|
|
848
|
+
ref,
|
|
849
|
+
...props,
|
|
850
|
+
children: /* @__PURE__ */ jsxs(form.AppForm, { children: [
|
|
851
|
+
children,
|
|
852
|
+
/* @__PURE__ */ jsx(form.Errors, {}),
|
|
853
|
+
/* @__PURE__ */ jsx(form.Set, { children: /* @__PURE__ */ jsx(form.SetContent, { children: /* @__PURE__ */ jsx(form.AppField, {
|
|
854
|
+
name: "filterOperator",
|
|
855
|
+
children: (field) => /* @__PURE__ */ jsxs(Field, { children: [/* @__PURE__ */ jsx(field.Errors, {}), /* @__PURE__ */ jsx(field.RadioGroup, { children: stringFilterOperators.map((operator) => /* @__PURE__ */ jsxs(field.Set, { children: [/* @__PURE__ */ jsx(Radio, {
|
|
856
|
+
value: operator,
|
|
857
|
+
variant: "inSurface",
|
|
858
|
+
children: filterOperatorLabels?.[operator] ?? defaultFilterOperatorLabels[operator]
|
|
859
|
+
}), field.state.value === operator && /* @__PURE__ */ jsx(form.AppField, {
|
|
860
|
+
name: "filterValue",
|
|
861
|
+
children: (valueField) => /* @__PURE__ */ jsxs(Field, { children: [/* @__PURE__ */ jsx(valueField.Errors, {}), /* @__PURE__ */ jsx(valueField.Input, {
|
|
862
|
+
"aria-label": `${column.id} filter value`,
|
|
863
|
+
variant: "secondary"
|
|
864
|
+
})] })
|
|
865
|
+
})] }, operator)) })] })
|
|
866
|
+
}) }) }),
|
|
867
|
+
/* @__PURE__ */ jsxs(form.Footer, { children: [/* @__PURE__ */ jsx(form.Reset, { children: buttonLabels.reset }), /* @__PURE__ */ jsx(form.Submit, { children: buttonLabels.apply })] })
|
|
868
|
+
] })
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
// src/components/table/table-string-filter-chip.tsx
|
|
872
|
+
function TableStringFilterChip({ column, className, children, ref, ...props }) {
|
|
873
|
+
const filterOperatorLabels = useTableContext$1().options.meta?.translations?.filterOperatorLabels, columnFilter = asFilterValue(column.getFilterValue());
|
|
874
|
+
return /* @__PURE__ */ jsxs(Popover, { children: [/* @__PURE__ */ jsx(PopoverTrigger, {
|
|
875
|
+
className: cn("", className),
|
|
876
|
+
ref,
|
|
877
|
+
...props,
|
|
878
|
+
children: /* @__PURE__ */ jsxs(Button, {
|
|
879
|
+
tone: "neutral",
|
|
880
|
+
size: "extraSmall",
|
|
881
|
+
variant: "soft",
|
|
882
|
+
children: [
|
|
883
|
+
/* @__PURE__ */ jsx(Icon, { name: "filter" }),
|
|
884
|
+
/* @__PURE__ */ jsx("span", { children: getColumnHeaderLabel(column) }),
|
|
885
|
+
/* @__PURE__ */ jsx("span", {
|
|
886
|
+
className: "font-light lowercase",
|
|
887
|
+
children: filterOperatorLabels?.[columnFilter.operator] ?? defaultFilterOperatorLabels[columnFilter.operator]
|
|
888
|
+
}),
|
|
889
|
+
/* @__PURE__ */ jsx("span", { children: columnFilter.value }),
|
|
890
|
+
children
|
|
891
|
+
]
|
|
892
|
+
})
|
|
893
|
+
}), /* @__PURE__ */ jsxs(PopoverPanel, { children: [/* @__PURE__ */ jsx(PopoverHeader, { children: /* @__PURE__ */ jsx(PopoverTitle, { children: getColumnHeaderLabel(column) }) }), /* @__PURE__ */ jsx(PopoverContent, { children: /* @__PURE__ */ jsx(TableStringFilterForm, { column }) })] })] });
|
|
894
|
+
}
|
|
895
|
+
// src/components/table/table-filter-list.tsx
|
|
896
|
+
function TableFilterList({ className, children, ref, ...props }) {
|
|
897
|
+
const table = useTableContext$1();
|
|
898
|
+
return /* @__PURE__ */ jsx(table.Subscribe, {
|
|
899
|
+
selector: (state) => state.columnFilters,
|
|
900
|
+
children: () => {
|
|
901
|
+
if (!table.getAllColumns().some((column) => column.getIsFiltered())) return;
|
|
902
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
903
|
+
className: cn("flex flex-wrap items-center gap-xs", className),
|
|
904
|
+
ref,
|
|
905
|
+
...props,
|
|
906
|
+
children: [children, table.getAllColumns().map((column) => {
|
|
907
|
+
if (!column.getIsFiltered()) return;
|
|
908
|
+
switch (column.columnDef.meta?.filterVariant) {
|
|
909
|
+
case "date": return /* @__PURE__ */ jsx(TableDateFilterChip, { column }, column.id);
|
|
910
|
+
case "number": return /* @__PURE__ */ jsx(TableNumberFilterChip, { column }, column.id);
|
|
911
|
+
case "select": return /* @__PURE__ */ jsx(TableSelectFilterChip, { column }, column.id);
|
|
912
|
+
case "string": return /* @__PURE__ */ jsx(TableStringFilterChip, { column }, column.id);
|
|
913
|
+
default: return;
|
|
914
|
+
}
|
|
915
|
+
})]
|
|
916
|
+
});
|
|
917
|
+
}
|
|
918
|
+
});
|
|
919
|
+
}
|
|
920
|
+
// src/components/table/table-filter-menu.tsx
|
|
921
|
+
function TableFilterMenu({ className, ref, ...props }) {
|
|
922
|
+
const table = useTableContext$1();
|
|
923
|
+
return /* @__PURE__ */ jsxs(Menu, {
|
|
924
|
+
modal: false,
|
|
925
|
+
children: [/* @__PURE__ */ jsx(MenuTrigger, {
|
|
926
|
+
className: cn("shrink-0", className),
|
|
927
|
+
ref,
|
|
928
|
+
...props
|
|
929
|
+
}), /* @__PURE__ */ jsx(MenuPopup, {
|
|
930
|
+
align: "end",
|
|
931
|
+
className: "",
|
|
932
|
+
children: table.getAllColumns().filter((column) => column.getCanFilter()).map((column) => {
|
|
933
|
+
const { filterVariant } = column.columnDef.meta ?? {};
|
|
934
|
+
return /* @__PURE__ */ jsxs(Popover, { children: [/* @__PURE__ */ jsx(PopoverTrigger, {
|
|
935
|
+
nativeButton: true,
|
|
936
|
+
children: /* @__PURE__ */ jsx(MenuItem, {
|
|
937
|
+
closeOnClick: false,
|
|
938
|
+
children: getColumnHeaderLabel(column)
|
|
939
|
+
})
|
|
940
|
+
}), /* @__PURE__ */ jsxs(PopoverPanel, {
|
|
941
|
+
side: "inline-end",
|
|
942
|
+
align: "start",
|
|
943
|
+
className: cn("", className),
|
|
944
|
+
onKeyDownCapture: (event) => event.stopPropagation(),
|
|
945
|
+
children: [/* @__PURE__ */ jsx(PopoverHeader, { children: /* @__PURE__ */ jsx(PopoverTitle, { children: getColumnHeaderLabel(column) }) }), /* @__PURE__ */ jsx(PopoverContent, { children: (() => {
|
|
946
|
+
switch (filterVariant) {
|
|
947
|
+
case "date": return /* @__PURE__ */ jsx(TableDateFilterForm, { column });
|
|
948
|
+
case "number": return /* @__PURE__ */ jsx(TableNumberFilterForm, { column });
|
|
949
|
+
case "select": return /* @__PURE__ */ jsx(TableSelectFilterForm, { column });
|
|
950
|
+
case "string": return /* @__PURE__ */ jsx(TableStringFilterForm, { column });
|
|
951
|
+
default: return;
|
|
952
|
+
}
|
|
953
|
+
})() })]
|
|
954
|
+
})] }, column.id);
|
|
955
|
+
})
|
|
956
|
+
})]
|
|
957
|
+
});
|
|
958
|
+
}
|
|
959
|
+
// src/components/table/table-first-page.tsx
|
|
960
|
+
const DEFAULT_PAGE_INDEX = 0;
|
|
961
|
+
function TableFirstPage({ className, children, ref, ...props }) {
|
|
962
|
+
const table = useTableContext$1(), handleClick = () => {
|
|
963
|
+
table.setPageIndex(DEFAULT_PAGE_INDEX);
|
|
964
|
+
};
|
|
965
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
966
|
+
"aria-label": "Go to first page",
|
|
967
|
+
className: cn("shrink-0", className),
|
|
968
|
+
disabled: !table.getCanPreviousPage(),
|
|
969
|
+
onClick: handleClick,
|
|
970
|
+
ref,
|
|
971
|
+
variant: "outline",
|
|
972
|
+
tone: "neutral",
|
|
973
|
+
size: "medium",
|
|
974
|
+
...props,
|
|
975
|
+
children: children ?? /* @__PURE__ */ jsx(Icon, { name: "firstPage" })
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
// src/components/table/table-footer.tsx
|
|
979
|
+
function TableFooter({ className, children, ref, ...props }) {
|
|
980
|
+
const table = useTableContext$1();
|
|
981
|
+
return /* @__PURE__ */ jsxs("tfoot", {
|
|
982
|
+
className: cn("border-t border-border bg-neutral-container-low", className),
|
|
983
|
+
ref,
|
|
984
|
+
...props,
|
|
985
|
+
children: [children, table.getFooterGroups().map((footerGroup) => /* @__PURE__ */ jsx("tr", { children: footerGroup.headers.map((header) => /* @__PURE__ */ jsx(table.AppFooter, {
|
|
986
|
+
header,
|
|
987
|
+
children: (footer) => /* @__PURE__ */ jsx("td", {
|
|
988
|
+
style: { width: footer.getSize() },
|
|
989
|
+
className: "p-xs",
|
|
990
|
+
colSpan: footer.colSpan,
|
|
991
|
+
children: /* @__PURE__ */ jsx(table.FlexRender, { footer })
|
|
992
|
+
})
|
|
993
|
+
}, header.id)) }, footerGroup.id))]
|
|
994
|
+
});
|
|
995
|
+
}
|
|
996
|
+
// src/components/table/table-header.tsx
|
|
997
|
+
function TableHeader({ className, children, ref, ...props }) {
|
|
998
|
+
const table = useTableContext$1();
|
|
999
|
+
return /* @__PURE__ */ jsx(table.Subscribe, {
|
|
1000
|
+
selector: (state) => state,
|
|
1001
|
+
children: (state) => {
|
|
1002
|
+
if (state.viewMode === "grid") return;
|
|
1003
|
+
return /* @__PURE__ */ jsxs("thead", {
|
|
1004
|
+
className: cn("sticky top-0 bg-neutral-container-low", className),
|
|
1005
|
+
ref,
|
|
1006
|
+
...props,
|
|
1007
|
+
children: [children, table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx("tr", { children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx(table.AppHeader, {
|
|
1008
|
+
header,
|
|
1009
|
+
selector: (tableState) => tableState.sorting,
|
|
1010
|
+
children: (renderHeader) => {
|
|
1011
|
+
const sorting = renderHeader.column.getIsSorted();
|
|
1012
|
+
return /* @__PURE__ */ jsx("th", {
|
|
1013
|
+
style: { width: renderHeader.getSize() },
|
|
1014
|
+
className: cn("container p-xs text-left style-text-default-0 text-neutral-on-container-muted transition-colors group-data-[variant=outline]/table:shadow-[inset_0_-1px_0_var(--color-border)] group-data-[variant=ghost]/table:first:rounded-l-xl group-data-[variant=ghost]/table:last:rounded-r-xl", renderHeader.column.getCanSort() && "hover:cursor-pointer hover:bg-neutral-container hover:*:text-neutral-on-container", renderHeader.isPlaceholder && "cursor-default", renderHeader.column.getIsSorted() && "text-brand-on-container!", className),
|
|
1015
|
+
colSpan: renderHeader.colSpan,
|
|
1016
|
+
onClick: renderHeader.column.getToggleSortingHandler(),
|
|
1017
|
+
children: !renderHeader.isPlaceholder && /* @__PURE__ */ jsxs("div", {
|
|
1018
|
+
className: cn("flex items-center gap-2xs whitespace-nowrap has-[[role=checkbox]]:justify-center [&_svg]:size-sm", renderHeader.column.getCanSort() && "select-none hover:cursor-pointer"),
|
|
1019
|
+
children: [
|
|
1020
|
+
/* @__PURE__ */ jsx("div", {
|
|
1021
|
+
className: "flex items-center gap-2xs",
|
|
1022
|
+
children: /* @__PURE__ */ jsx(table.FlexRender, { header: renderHeader })
|
|
1023
|
+
}),
|
|
1024
|
+
sorting === "asc" && /* @__PURE__ */ jsx(Icon, { name: "sortDescending" }),
|
|
1025
|
+
sorting === "desc" && /* @__PURE__ */ jsx(Icon, { name: "sortAscending" }),
|
|
1026
|
+
!sorting && renderHeader.column.getCanSort() && /* @__PURE__ */ jsx(Icon, { name: "columnFilter" })
|
|
1027
|
+
]
|
|
1028
|
+
})
|
|
1029
|
+
}, renderHeader.id);
|
|
1030
|
+
}
|
|
1031
|
+
}, header.id)) }, headerGroup.id))]
|
|
1032
|
+
});
|
|
1033
|
+
}
|
|
1034
|
+
});
|
|
1035
|
+
}
|
|
1036
|
+
// src/components/table/table-image-cell.tsx
|
|
1037
|
+
function TableImageCell({ className, ref, ...props }) {
|
|
1038
|
+
const cell = useCellContext$1();
|
|
1039
|
+
return /* @__PURE__ */ jsx("img", {
|
|
1040
|
+
alt: "",
|
|
1041
|
+
src: cell.getValue(),
|
|
1042
|
+
className: cn("my-xs size-xl", className),
|
|
1043
|
+
ref,
|
|
1044
|
+
...props
|
|
1045
|
+
});
|
|
1046
|
+
}
|
|
1047
|
+
// src/components/table/table-last-page.tsx
|
|
1048
|
+
const LAST_PAGE_OFFSET = 1;
|
|
1049
|
+
function TableLastPage({ className, children, ref, ...props }) {
|
|
1050
|
+
const table = useTableContext$1(), handleClick = () => {
|
|
1051
|
+
table.setPageIndex(table.getPageCount() - LAST_PAGE_OFFSET);
|
|
1052
|
+
};
|
|
1053
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
1054
|
+
"aria-label": "Go to last page",
|
|
1055
|
+
className: cn("shrink-0", className),
|
|
1056
|
+
disabled: !table.getCanNextPage(),
|
|
1057
|
+
onClick: handleClick,
|
|
1058
|
+
ref,
|
|
1059
|
+
variant: "outline",
|
|
1060
|
+
tone: "neutral",
|
|
1061
|
+
size: "medium",
|
|
1062
|
+
...props,
|
|
1063
|
+
children: children ?? /* @__PURE__ */ jsx(Icon, { name: "lastPage" })
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
1066
|
+
// src/components/table/table-layout.tsx
|
|
1067
|
+
function TableLayout({ className, ref, ...props }) {
|
|
1068
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1069
|
+
"data-slot": "table-layout",
|
|
1070
|
+
className: cn("flex min-w-0 flex-col gap-md", className),
|
|
1071
|
+
ref,
|
|
1072
|
+
...props
|
|
1073
|
+
});
|
|
1074
|
+
}
|
|
1075
|
+
// src/components/table/table-link-cell.tsx
|
|
1076
|
+
function TableLinkCell({ className, children, ref, ...props }) {
|
|
1077
|
+
const value = useCellContext$1().getValue();
|
|
1078
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
1079
|
+
variant: "link",
|
|
1080
|
+
type: "button",
|
|
1081
|
+
className: cn("", className),
|
|
1082
|
+
ref,
|
|
1083
|
+
...props,
|
|
1084
|
+
children: children ?? value
|
|
1085
|
+
});
|
|
1086
|
+
}
|
|
1087
|
+
// src/components/table/table-next-page.tsx
|
|
1088
|
+
function TableNextPage({ className, children, ref, ...props }) {
|
|
1089
|
+
const table = useTableContext$1(), handleClick = () => {
|
|
1090
|
+
table.nextPage();
|
|
1091
|
+
};
|
|
1092
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
1093
|
+
"aria-label": "Go to next page",
|
|
1094
|
+
className: cn("shrink-0", className),
|
|
1095
|
+
disabled: !table.getCanNextPage(),
|
|
1096
|
+
onClick: handleClick,
|
|
1097
|
+
ref,
|
|
1098
|
+
size: "medium",
|
|
1099
|
+
variant: "outline",
|
|
1100
|
+
tone: "neutral",
|
|
1101
|
+
...props,
|
|
1102
|
+
children: children ?? /* @__PURE__ */ jsx(Icon, { name: "chevronRight" })
|
|
1103
|
+
});
|
|
1104
|
+
}
|
|
1105
|
+
// src/components/table/table-number-cell.tsx
|
|
1106
|
+
function TableNumberCell({ className, children, ref, ...props }) {
|
|
1107
|
+
const cell = useCellContext$1();
|
|
1108
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
1109
|
+
className: cn("", className),
|
|
1110
|
+
ref,
|
|
1111
|
+
...props,
|
|
1112
|
+
children: [children, cell.getValue().toLocaleString()]
|
|
1113
|
+
});
|
|
1114
|
+
}
|
|
1115
|
+
// src/components/table/table-pagination.tsx
|
|
1116
|
+
function TablePagination({ className, ref, ...props }) {
|
|
1117
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1118
|
+
className: cn("inline-flex items-center justify-center gap-3xs", className),
|
|
1119
|
+
ref,
|
|
1120
|
+
...props
|
|
1121
|
+
});
|
|
1122
|
+
}
|
|
1123
|
+
// src/components/table/table-paging.tsx
|
|
1124
|
+
const DEFAULT_VISIBLE_START_PAGES = 3;
|
|
1125
|
+
const DEFAULT_VISIBLE_END_PAGES = 1;
|
|
1126
|
+
const FIRST_PAGE_INDEX = 0;
|
|
1127
|
+
const PAGE_NUMBER_OFFSET$1 = 1;
|
|
1128
|
+
const PAGE_INDEX_INCREMENT = 1;
|
|
1129
|
+
const MORE_PAGES_MAX_HEIGHT = 200;
|
|
1130
|
+
function getLeadingPageIndexes(minimumPages, totalPages) {
|
|
1131
|
+
const pageIndexes = [];
|
|
1132
|
+
for (let pageIndex = FIRST_PAGE_INDEX; pageIndex < minimumPages && pageIndex < totalPages; pageIndex += PAGE_INDEX_INCREMENT) pageIndexes.push(pageIndex);
|
|
1133
|
+
return pageIndexes;
|
|
1134
|
+
}
|
|
1135
|
+
function getOverflowPageIndexes(minimumPages, maximumPages, totalPages) {
|
|
1136
|
+
const pageIndexes = [];
|
|
1137
|
+
for (let pageIndex = minimumPages; pageIndex < totalPages - maximumPages; pageIndex += PAGE_INDEX_INCREMENT) pageIndexes.push(pageIndex);
|
|
1138
|
+
return pageIndexes;
|
|
1139
|
+
}
|
|
1140
|
+
function getTrailingPageIndexes(minimumPages, maximumPages, totalPages) {
|
|
1141
|
+
const pageIndexes = [];
|
|
1142
|
+
for (let pageIndex = totalPages - maximumPages; pageIndex < totalPages; pageIndex += PAGE_INDEX_INCREMENT) if (pageIndex >= minimumPages) pageIndexes.push(pageIndex);
|
|
1143
|
+
return pageIndexes;
|
|
1144
|
+
}
|
|
1145
|
+
function getPageButtonTone(pageIndex, selectedPageIndex) {
|
|
1146
|
+
if (pageIndex === selectedPageIndex) return "brand";
|
|
1147
|
+
return "neutral";
|
|
1148
|
+
}
|
|
1149
|
+
function getPageButtonVariant(pageIndex, selectedPageIndex) {
|
|
1150
|
+
if (pageIndex === selectedPageIndex) return "fill";
|
|
1151
|
+
return "outline";
|
|
1152
|
+
}
|
|
1153
|
+
function TablePaging({ min = DEFAULT_VISIBLE_START_PAGES, max = DEFAULT_VISIBLE_END_PAGES, className, children, ref, ...props }) {
|
|
1154
|
+
const table = useTableContext$1(), handleClick = (pageIndex) => {
|
|
1155
|
+
table.setPageIndex(pageIndex);
|
|
1156
|
+
};
|
|
1157
|
+
return /* @__PURE__ */ jsx(table.Subscribe, {
|
|
1158
|
+
selector: (state) => state.pagination,
|
|
1159
|
+
children: (pagination) => {
|
|
1160
|
+
const totalPages = table.getPageCount(), leadingPageIndexes = getLeadingPageIndexes(min, totalPages), overflowPageIndexes = getOverflowPageIndexes(min, max, totalPages), trailingPageIndexes = getTrailingPageIndexes(min, max, totalPages);
|
|
1161
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1162
|
+
className: cn("flex items-center gap-2xs", className),
|
|
1163
|
+
ref,
|
|
1164
|
+
...props,
|
|
1165
|
+
children: [
|
|
1166
|
+
children,
|
|
1167
|
+
leadingPageIndexes.map((pageIndex) => /* @__PURE__ */ jsx(Button, {
|
|
1168
|
+
tone: getPageButtonTone(pageIndex, pagination.pageIndex),
|
|
1169
|
+
variant: getPageButtonVariant(pageIndex, pagination.pageIndex),
|
|
1170
|
+
className: "shrink-0",
|
|
1171
|
+
onClick: () => handleClick(pageIndex),
|
|
1172
|
+
children: pageIndex + PAGE_NUMBER_OFFSET$1
|
|
1173
|
+
}, `page-${pageIndex}`)),
|
|
1174
|
+
totalPages > min + max && /* @__PURE__ */ jsxs(Menu, { children: [/* @__PURE__ */ jsx(MenuTrigger, { children: /* @__PURE__ */ jsx(Button, {
|
|
1175
|
+
"aria-label": "Show more pages",
|
|
1176
|
+
tone: "neutral",
|
|
1177
|
+
size: "medium",
|
|
1178
|
+
variant: "outline",
|
|
1179
|
+
className: "shrink-0",
|
|
1180
|
+
children: /* @__PURE__ */ jsx(Icon, { name: "ellipsis" })
|
|
1181
|
+
}) }), /* @__PURE__ */ jsx(MenuPopup, {
|
|
1182
|
+
align: "center",
|
|
1183
|
+
children: /* @__PURE__ */ jsx(MenuRadioGroup, {
|
|
1184
|
+
value: pagination.pageIndex,
|
|
1185
|
+
onValueChange: handleClick,
|
|
1186
|
+
className: "overflow-y-auto",
|
|
1187
|
+
style: { maxHeight: `${MORE_PAGES_MAX_HEIGHT}px` },
|
|
1188
|
+
children: overflowPageIndexes.map((pageIndex) => /* @__PURE__ */ jsx(MenuRadioItem, {
|
|
1189
|
+
value: pageIndex,
|
|
1190
|
+
closeOnClick: true,
|
|
1191
|
+
children: pageIndex + PAGE_NUMBER_OFFSET$1
|
|
1192
|
+
}, pageIndex))
|
|
1193
|
+
})
|
|
1194
|
+
})] }),
|
|
1195
|
+
trailingPageIndexes.map((pageIndex) => /* @__PURE__ */ jsx(Button, {
|
|
1196
|
+
tone: getPageButtonTone(pageIndex, pagination.pageIndex),
|
|
1197
|
+
variant: getPageButtonVariant(pageIndex, pagination.pageIndex),
|
|
1198
|
+
className: "shrink-0",
|
|
1199
|
+
onClick: () => handleClick(pageIndex),
|
|
1200
|
+
children: pageIndex + PAGE_NUMBER_OFFSET$1
|
|
1201
|
+
}, `last-page-${pageIndex}`))
|
|
1202
|
+
]
|
|
1203
|
+
});
|
|
1204
|
+
}
|
|
1205
|
+
});
|
|
1206
|
+
}
|
|
1207
|
+
// src/components/table/table-percent-cell.tsx
|
|
1208
|
+
function TablePercentCell({ locale, options, children, ...props }) {
|
|
1209
|
+
const value = useCellContext$1().getValue();
|
|
1210
|
+
if (value === void 0 || value === null) return;
|
|
1211
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
1212
|
+
...props,
|
|
1213
|
+
children: [children, new Intl.NumberFormat(locale, {
|
|
1214
|
+
...options,
|
|
1215
|
+
style: "percent"
|
|
1216
|
+
}).format(value)]
|
|
1217
|
+
});
|
|
1218
|
+
}
|
|
1219
|
+
// src/components/table/table-previous-page.tsx
|
|
1220
|
+
function TablePreviousPage({ className, children, ref, ...props }) {
|
|
1221
|
+
const table = useTableContext$1(), handleClick = () => {
|
|
1222
|
+
table.previousPage();
|
|
1223
|
+
};
|
|
1224
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
1225
|
+
"aria-label": "Go to previous page",
|
|
1226
|
+
className: cn("shrink-0", className),
|
|
1227
|
+
disabled: !table.getCanPreviousPage(),
|
|
1228
|
+
onClick: handleClick,
|
|
1229
|
+
ref,
|
|
1230
|
+
variant: "outline",
|
|
1231
|
+
tone: "neutral",
|
|
1232
|
+
size: "medium",
|
|
1233
|
+
...props,
|
|
1234
|
+
children: children ?? /* @__PURE__ */ jsx(Icon, { name: "chevronLeft" })
|
|
1235
|
+
});
|
|
1236
|
+
}
|
|
1237
|
+
// src/components/table/table-progress-cell.tsx
|
|
1238
|
+
function TableProgressCell({ showValue = true, children, ...props }) {
|
|
1239
|
+
const value = useCellContext$1().getValue();
|
|
1240
|
+
if (value === void 0 || value === null) return;
|
|
1241
|
+
return /* @__PURE__ */ jsxs(Meter, {
|
|
1242
|
+
orientation: "horizontal",
|
|
1243
|
+
"aria-label": "Progress",
|
|
1244
|
+
...props,
|
|
1245
|
+
value,
|
|
1246
|
+
children: [
|
|
1247
|
+
/* @__PURE__ */ jsx(Meter.Track, { children: /* @__PURE__ */ jsx(Meter.Indicator, {}) }),
|
|
1248
|
+
showValue && /* @__PURE__ */ jsx(Meter.Value, {}),
|
|
1249
|
+
children
|
|
1250
|
+
]
|
|
1251
|
+
});
|
|
1252
|
+
}
|
|
1253
|
+
// src/components/table/table-relative-time-cell.tsx
|
|
1254
|
+
const MILLISECONDS_PER_SECOND = 1e3;
|
|
1255
|
+
const ZERO = 0;
|
|
1256
|
+
const SECONDS_PER_SECOND = 1;
|
|
1257
|
+
const RELATIVE_TIME_UNITS = [
|
|
1258
|
+
["year", 31536e3],
|
|
1259
|
+
["month", 2592e3],
|
|
1260
|
+
["week", 604800],
|
|
1261
|
+
["day", 86400],
|
|
1262
|
+
["hour", 3600],
|
|
1263
|
+
["minute", 60],
|
|
1264
|
+
["second", SECONDS_PER_SECOND]
|
|
1265
|
+
];
|
|
1266
|
+
function formatRelativeTime(date, now, { locale, options }) {
|
|
1267
|
+
const seconds = (date.getTime() - now.getTime()) / MILLISECONDS_PER_SECOND, [unit, divisor] = RELATIVE_TIME_UNITS.find(([, duration]) => Math.abs(seconds) >= duration) ?? ["second", SECONDS_PER_SECOND], amount = Math.round(seconds / divisor) || ZERO;
|
|
1268
|
+
return new Intl.RelativeTimeFormat(locale, {
|
|
1269
|
+
numeric: "auto",
|
|
1270
|
+
...options
|
|
1271
|
+
}).format(amount, unit);
|
|
1272
|
+
}
|
|
1273
|
+
function TableRelativeTimeCell({ locale, options, now, children, ...props }) {
|
|
1274
|
+
const date = useCellContext$1().getValue(), [mountedAt] = useState(() => /* @__PURE__ */ new Date()), referenceDate = now ?? mountedAt;
|
|
1275
|
+
if (!date) return;
|
|
1276
|
+
if (Number.isNaN(date.getTime())) return "Invalid date";
|
|
1277
|
+
if (Number.isNaN(referenceDate.getTime())) throw new RangeError("TableRelativeTimeCell requires a valid now date");
|
|
1278
|
+
return /* @__PURE__ */ jsxs("time", {
|
|
1279
|
+
dateTime: date.toISOString(),
|
|
1280
|
+
title: date.toLocaleString(locale),
|
|
1281
|
+
...props,
|
|
1282
|
+
children: [children, formatRelativeTime(date, referenceDate, {
|
|
1283
|
+
locale,
|
|
1284
|
+
options
|
|
1285
|
+
})]
|
|
1286
|
+
});
|
|
1287
|
+
}
|
|
1288
|
+
// src/components/table/table-results.tsx
|
|
1289
|
+
const EMPTY_ROW_COUNT = 0;
|
|
1290
|
+
const PAGE_NUMBER_OFFSET = 1;
|
|
1291
|
+
function getPageStart(totalRows, pageIndex, pageSize) {
|
|
1292
|
+
if (totalRows === EMPTY_ROW_COUNT) return EMPTY_ROW_COUNT;
|
|
1293
|
+
return pageIndex * pageSize + PAGE_NUMBER_OFFSET;
|
|
1294
|
+
}
|
|
1295
|
+
function getPageEnd(start, pageSize, totalRows) {
|
|
1296
|
+
if (totalRows === EMPTY_ROW_COUNT) return EMPTY_ROW_COUNT;
|
|
1297
|
+
return Math.min(start + pageSize - PAGE_NUMBER_OFFSET, totalRows);
|
|
1298
|
+
}
|
|
1299
|
+
function TableResults({ children, className, ref, ...props }) {
|
|
1300
|
+
const table = useTableContext$1(), { pageIndex } = table.state.pagination, { pageSize } = table.state.pagination, totalRows = table.getFilteredRowModel().rows.length, start = getPageStart(totalRows, pageIndex, pageSize), end = getPageEnd(start, pageSize, totalRows);
|
|
1301
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1302
|
+
className: cn("flex items-center gap-2xs style-text-default--1 text-on-surface-variant", className),
|
|
1303
|
+
ref,
|
|
1304
|
+
...props,
|
|
1305
|
+
children: children(start, end, totalRows)
|
|
1306
|
+
});
|
|
1307
|
+
}
|
|
1308
|
+
// src/components/table/table-search.tsx
|
|
1309
|
+
function TableSearch({ className, ref, ...props }) {
|
|
1310
|
+
const table = useTableContext$1(), handleChange = (event) => {
|
|
1311
|
+
table.setGlobalFilter(event.target.value);
|
|
1312
|
+
};
|
|
1313
|
+
return /* @__PURE__ */ jsx(table.Subscribe, {
|
|
1314
|
+
selector: (state) => state.globalFilter,
|
|
1315
|
+
children: (globalFilter) => /* @__PURE__ */ jsxs(InputGroup, {
|
|
1316
|
+
variant: props.variant ?? "outline",
|
|
1317
|
+
className: "flex-1",
|
|
1318
|
+
children: [/* @__PURE__ */ jsx(InputGroupAddon, { children: /* @__PURE__ */ jsx(Icon, { name: "search" }) }), /* @__PURE__ */ jsx(InputGroupInput, {
|
|
1319
|
+
className: cn("", className),
|
|
1320
|
+
onChange: handleChange,
|
|
1321
|
+
ref,
|
|
1322
|
+
value: globalFilter ?? "",
|
|
1323
|
+
...props
|
|
1324
|
+
})]
|
|
1325
|
+
})
|
|
1326
|
+
});
|
|
1327
|
+
}
|
|
1328
|
+
// src/components/table/table-sort-menu.tsx
|
|
1329
|
+
function TableSortMenu({ className, ref, ...props }) {
|
|
1330
|
+
const table = useTableContext$1(), buttonLabels = table.options.meta?.translations?.buttonLabels ?? {}, ascendingLabel = buttonLabels.ascending ?? "Ascending", descendingLabel = buttonLabels.descending ?? "Descending", handleSort = (columnId, direction) => {
|
|
1331
|
+
const column = table.getColumn(columnId);
|
|
1332
|
+
if (column?.getIsSorted() === direction) {
|
|
1333
|
+
column?.clearSorting();
|
|
1334
|
+
return;
|
|
1335
|
+
}
|
|
1336
|
+
column?.toggleSorting(direction === "desc", column.getCanMultiSort());
|
|
1337
|
+
};
|
|
1338
|
+
return /* @__PURE__ */ jsxs(Menu, { children: [/* @__PURE__ */ jsx(MenuTrigger, {
|
|
1339
|
+
className: cn("shrink-0", className),
|
|
1340
|
+
ref,
|
|
1341
|
+
...props
|
|
1342
|
+
}), /* @__PURE__ */ jsx(MenuPopup, {
|
|
1343
|
+
align: "end",
|
|
1344
|
+
children: /* @__PURE__ */ jsx(table.Subscribe, {
|
|
1345
|
+
selector: (state) => state.sorting,
|
|
1346
|
+
children: () => table.getAllColumns().filter((column) => column.getCanSort()).map((column) => /* @__PURE__ */ jsxs(MenuSubmenu, { children: [/* @__PURE__ */ jsx(MenuSubmenuTrigger, { children: getColumnHeaderLabel(column) }), /* @__PURE__ */ jsxs(MenuPopup, { children: [/* @__PURE__ */ jsxs(MenuCheckboxItem, {
|
|
1347
|
+
checked: column.getIsSorted() === "asc",
|
|
1348
|
+
onClick: () => handleSort(column.id, "asc"),
|
|
1349
|
+
children: [/* @__PURE__ */ jsx(Icon, { name: "sortDescending" }), ascendingLabel]
|
|
1350
|
+
}), /* @__PURE__ */ jsxs(MenuCheckboxItem, {
|
|
1351
|
+
checked: column.getIsSorted() === "desc",
|
|
1352
|
+
onClick: () => handleSort(column.id, "desc"),
|
|
1353
|
+
children: [/* @__PURE__ */ jsx(Icon, { name: "sortAscending" }), descendingLabel]
|
|
1354
|
+
})] })] }, column.id))
|
|
1355
|
+
})
|
|
1356
|
+
})] });
|
|
1357
|
+
}
|
|
1358
|
+
// src/components/table/table-sort-chip.tsx
|
|
1359
|
+
function TableSortChip({ column, className, children, ref, ...props }) {
|
|
1360
|
+
const table = useTableContext$1(), buttonLabels = table.options.meta?.translations?.buttonLabels ?? {}, ascendingLabel = buttonLabels.ascending ?? "Ascending", descendingLabel = buttonLabels.descending ?? "Descending";
|
|
1361
|
+
return /* @__PURE__ */ jsx(table.Subscribe, {
|
|
1362
|
+
selector: (state) => state.sorting,
|
|
1363
|
+
children: () => {
|
|
1364
|
+
const columnSort = column.getIsSorted();
|
|
1365
|
+
console.log(columnSort);
|
|
1366
|
+
if (!columnSort) return;
|
|
1367
|
+
return /* @__PURE__ */ jsx(TableSortMenu, {
|
|
1368
|
+
className: cn("", className),
|
|
1369
|
+
ref,
|
|
1370
|
+
...props,
|
|
1371
|
+
children: /* @__PURE__ */ jsxs(Button, {
|
|
1372
|
+
size: "extraSmall",
|
|
1373
|
+
variant: "soft",
|
|
1374
|
+
children: [
|
|
1375
|
+
columnSort === "asc" && /* @__PURE__ */ jsx(Icon, { name: "sortDescending" }),
|
|
1376
|
+
columnSort === "desc" && /* @__PURE__ */ jsx(Icon, { name: "sortAscending" }),
|
|
1377
|
+
/* @__PURE__ */ jsx("span", { children: getColumnHeaderLabel(column) }),
|
|
1378
|
+
/* @__PURE__ */ jsxs("span", {
|
|
1379
|
+
className: "font-light lowercase",
|
|
1380
|
+
children: [columnSort === "asc" && ascendingLabel, columnSort === "desc" && descendingLabel]
|
|
1381
|
+
}),
|
|
1382
|
+
children
|
|
1383
|
+
]
|
|
1384
|
+
})
|
|
1385
|
+
});
|
|
1386
|
+
}
|
|
1387
|
+
});
|
|
1388
|
+
}
|
|
1389
|
+
// src/components/table/table-sort-list.tsx
|
|
1390
|
+
function TableSortList({ className, children, ref, ...props }) {
|
|
1391
|
+
const table = useTableContext$1();
|
|
1392
|
+
if (!table.getAllColumns().some((column) => column.getIsSorted())) return;
|
|
1393
|
+
return /* @__PURE__ */ jsx(table.Subscribe, {
|
|
1394
|
+
selector: (state) => state.sorting,
|
|
1395
|
+
children: () => /* @__PURE__ */ jsxs("div", {
|
|
1396
|
+
className: cn("flex flex-wrap items-center gap-xs", className),
|
|
1397
|
+
ref,
|
|
1398
|
+
...props,
|
|
1399
|
+
children: [children, table.getAllColumns().map((column) => {
|
|
1400
|
+
if (!column.getIsSorted()) return;
|
|
1401
|
+
return /* @__PURE__ */ jsx(TableSortChip, { column }, column.id);
|
|
1402
|
+
})]
|
|
1403
|
+
})
|
|
1404
|
+
});
|
|
1405
|
+
}
|
|
1406
|
+
// src/components/table/table-tags-cell.tsx
|
|
1407
|
+
function TableTagsCell({ badgeProps, className, children, ...props }) {
|
|
1408
|
+
const value = useCellContext$1().getValue();
|
|
1409
|
+
if (value === void 0 || value === null) return;
|
|
1410
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1411
|
+
className: cn("flex flex-wrap gap-3xs", className),
|
|
1412
|
+
...props,
|
|
1413
|
+
children: [children, value.map((tag, index) => /* @__PURE__ */ jsx(Badge, {
|
|
1414
|
+
variant: "soft",
|
|
1415
|
+
...badgeProps,
|
|
1416
|
+
children: tag
|
|
1417
|
+
}, `${index}-${tag}`))]
|
|
1418
|
+
});
|
|
1419
|
+
}
|
|
1420
|
+
// src/components/table/table-text-cell.tsx
|
|
1421
|
+
function TableTextCell({ className, children, ref, ...props }) {
|
|
1422
|
+
const cell = useCellContext$1();
|
|
1423
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
1424
|
+
className: cn("", className),
|
|
1425
|
+
ref,
|
|
1426
|
+
...props,
|
|
1427
|
+
children: [children, cell.getValue()]
|
|
1428
|
+
});
|
|
1429
|
+
}
|
|
1430
|
+
// src/components/table/table-toolbar.tsx
|
|
1431
|
+
function TableToolbar({ className, ref, ...props }) {
|
|
1432
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1433
|
+
"data-slot": "table-toolbar",
|
|
1434
|
+
className: cn("flex w-full min-w-0 flex-wrap items-center gap-2xs", "[:where([data-slot=table-container][data-variant=outline]>&)]:px-md [:where([data-slot=table-container][data-variant=outline]>&:first-child)]:pt-md [:where([data-slot=table-container][data-variant=outline]>&:last-child)]:pb-md", className),
|
|
1435
|
+
ref,
|
|
1436
|
+
...props
|
|
1437
|
+
});
|
|
1438
|
+
}
|
|
1439
|
+
// src/components/table/table-top-bar.tsx
|
|
1440
|
+
function TableTopBar({ className, ref, ...props }) {
|
|
1441
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1442
|
+
className: cn("flex min-w-0 flex-col pb-md group-data-[variant=outline]/table:border-b group-data-[variant=outline]/table:border-border", "in-data-[slot=table-container]:sticky in-data-[slot=table-container]:top-0 in-data-[slot=table-container]:z-10", className),
|
|
1443
|
+
"data-slot": "table-top-bar",
|
|
1444
|
+
ref,
|
|
1445
|
+
...props
|
|
1446
|
+
});
|
|
1447
|
+
}
|
|
1448
|
+
// src/components/table/table-view-mode-toggle.tsx
|
|
1449
|
+
function TableViewModeToggle({ className, children, ref, ...props }) {
|
|
1450
|
+
const table = useTableContext$1(), isGridView = table.state.viewMode === "grid", handleClick = () => {
|
|
1451
|
+
table.toggleViewMode();
|
|
1452
|
+
};
|
|
1453
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
1454
|
+
onClick: handleClick,
|
|
1455
|
+
className: cn("shrink-0", className),
|
|
1456
|
+
ref,
|
|
1457
|
+
...props,
|
|
1458
|
+
children: children(isGridView)
|
|
1459
|
+
});
|
|
1460
|
+
}
|
|
1461
|
+
// src/components/table/table-viewport.tsx
|
|
1462
|
+
function TableViewport({ grow, className, children, ref, ...props }) {
|
|
1463
|
+
if (useTableContext$1().state.viewMode === "grid") return /* @__PURE__ */ jsx("div", {
|
|
1464
|
+
"data-slot": "table-viewport",
|
|
1465
|
+
className: cn("min-h-0 min-w-0 overflow-auto", grow && "flex-1", className),
|
|
1466
|
+
ref,
|
|
1467
|
+
...props,
|
|
1468
|
+
children
|
|
1469
|
+
});
|
|
1470
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1471
|
+
"data-slot": "table-viewport",
|
|
1472
|
+
className: cn("min-h-0 min-w-0 overflow-auto focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-surface-focus-ring", grow && "flex-1"),
|
|
1473
|
+
children: /* @__PURE__ */ jsx("table", {
|
|
1474
|
+
className: cn("w-full", grow && "h-full", className),
|
|
1475
|
+
ref,
|
|
1476
|
+
...props,
|
|
1477
|
+
children
|
|
1478
|
+
})
|
|
1479
|
+
});
|
|
1480
|
+
}
|
|
1481
|
+
// src/components/table/table-context.tsx
|
|
1482
|
+
const { createAppColumnHelper, useAppTable, useTableContext, useCellContext, useHeaderContext } = createTableHook({
|
|
1483
|
+
cellComponents: {
|
|
1484
|
+
AvatarCell: TableAvatarCell,
|
|
1485
|
+
BadgeCell: TableBadgeCell,
|
|
1486
|
+
BooleanCell: TableBooleanCell,
|
|
1487
|
+
CheckboxCell: TableCheckboxCell,
|
|
1488
|
+
CurrencyCell: TableCurrencyCell,
|
|
1489
|
+
DateTimeCell: TableDateTimeCell,
|
|
1490
|
+
ImageCell: TableImageCell,
|
|
1491
|
+
LinkCell: TableLinkCell,
|
|
1492
|
+
NumberCell: TableNumberCell,
|
|
1493
|
+
PercentCell: TablePercentCell,
|
|
1494
|
+
ProgressCell: TableProgressCell,
|
|
1495
|
+
RelativeTimeCell: TableRelativeTimeCell,
|
|
1496
|
+
TagsCell: TableTagsCell,
|
|
1497
|
+
TextCell: TableTextCell
|
|
1498
|
+
},
|
|
1499
|
+
cellContext,
|
|
1500
|
+
features,
|
|
1501
|
+
getRowId: (row, index, parent) => {
|
|
1502
|
+
if (row.id !== void 0 && row.id !== null) return row.id;
|
|
1503
|
+
if (parent) return `${parent.id}.${index}`;
|
|
1504
|
+
return String(index);
|
|
1505
|
+
},
|
|
1506
|
+
headerComponents: { CheckboxHeader: TableCheckboxHeader },
|
|
1507
|
+
headerContext,
|
|
1508
|
+
tableComponents: {
|
|
1509
|
+
Body: TableBody,
|
|
1510
|
+
BottomBar: TableBottomBar,
|
|
1511
|
+
ColumnToggle: TableColumnToggle,
|
|
1512
|
+
Container: TableContainer,
|
|
1513
|
+
DatasetTab: TableDatasetTab,
|
|
1514
|
+
Empty: TableEmpty,
|
|
1515
|
+
EmptyContent: TableEmptyContent,
|
|
1516
|
+
EmptyDescription: TableEmptyDescription,
|
|
1517
|
+
EmptyFooter: TableEmptyFooter,
|
|
1518
|
+
EmptyHeader: TableEmptyHeader,
|
|
1519
|
+
EmptyTitle: TableEmptyTitle,
|
|
1520
|
+
FilterList: TableFilterList,
|
|
1521
|
+
FilterMenu: TableFilterMenu,
|
|
1522
|
+
FirstPage: TableFirstPage,
|
|
1523
|
+
Footer: TableFooter,
|
|
1524
|
+
Header: TableHeader,
|
|
1525
|
+
LastPage: TableLastPage,
|
|
1526
|
+
Layout: TableLayout,
|
|
1527
|
+
NextPage: TableNextPage,
|
|
1528
|
+
Pagination: TablePagination,
|
|
1529
|
+
Paging: TablePaging,
|
|
1530
|
+
PreviousPage: TablePreviousPage,
|
|
1531
|
+
Results: TableResults,
|
|
1532
|
+
Search: TableSearch,
|
|
1533
|
+
SortList: TableSortList,
|
|
1534
|
+
SortMenu: TableSortMenu,
|
|
1535
|
+
Toolbar: TableToolbar,
|
|
1536
|
+
TopBar: TableTopBar,
|
|
1537
|
+
ViewModeToggle: TableViewModeToggle,
|
|
1538
|
+
Viewport: TableViewport
|
|
1539
|
+
},
|
|
1540
|
+
tableContext
|
|
1541
|
+
});
|
|
1542
|
+
export { TableAvatarCell, TableBadgeCell, TableBody, TableBooleanCell, TableBottomBar, TableCheckboxCell, TableCheckboxHeader, TableColumnToggle, TableContainer, TableCurrencyCell, TableDatasetTab, TableDateFilterChip, TableDateFilterForm, TableDateTimeCell, TableEmptyContent, TableEmptyDescription, TableEmptyFooter, TableEmptyHeader, TableEmpty as TableEmptyMessage, TableEmptyTitle, TableFilterList, TableFilterMenu, TableFirstPage, TableFooter, TableHeader, TableImageCell, TableLastPage, TableLayout, TableLinkCell, TableNextPage, TableNumberCell, TableNumberFilterChip, TableNumberFilterForm, TablePagination, TablePaging, TablePercentCell, TablePreviousPage, TableProgressCell, TableRelativeTimeCell, TableResults, TableSearch, TableSelectFilterChip, TableSelectFilterForm, TableSortChip, TableSortList, TableSortMenu, TableStringFilterChip, TableStringFilterForm, TableTagsCell, TableTextCell, TableToolbar, TableTopBar, TableViewModeToggle, TableViewport, createAppColumnHelper, dateFilterFn, defaultFilterOperatorLabels, features, numberFilterFn, selectFilterFn, stringFilterFn, useAppTable, useCellContext, useHeaderContext, useTableContext };
|
|
1543
|
+
|
|
1544
|
+
//# sourceMappingURL=index.js.map
|