@planningcenter/tapestry 4.5.0 → 4.5.1-qa-1263.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/dist/components/DataTable/ActiveFilters.d.ts +10 -0
- package/dist/components/DataTable/ActiveFilters.d.ts.map +1 -0
- package/dist/components/DataTable/ActiveFilters.js +32 -0
- package/dist/components/DataTable/ActiveFilters.js.map +1 -0
- package/dist/components/DataTable/DataTable.d.ts +12 -1
- package/dist/components/DataTable/DataTable.d.ts.map +1 -1
- package/dist/components/DataTable/DataTable.js +55 -48
- package/dist/components/DataTable/DataTable.js.map +1 -1
- package/dist/components/DataTable/FilterContext.d.ts +16 -0
- package/dist/components/DataTable/FilterContext.d.ts.map +1 -0
- package/dist/components/DataTable/FilterContext.js +32 -0
- package/dist/components/DataTable/FilterContext.js.map +1 -0
- package/dist/components/DataTable/FilterControls.d.ts +11 -0
- package/dist/components/DataTable/FilterControls.d.ts.map +1 -0
- package/dist/components/DataTable/FilterControls.js +57 -0
- package/dist/components/DataTable/FilterControls.js.map +1 -0
- package/dist/components/DataTable/FilterTypes.d.ts +49 -0
- package/dist/components/DataTable/FilterTypes.d.ts.map +1 -0
- package/dist/components/DataTable/ViewSettingsToggle.d.ts.map +1 -1
- package/dist/components/DataTable/ViewSettingsToggle.js +5 -6
- package/dist/components/DataTable/ViewSettingsToggle.js.map +1 -1
- package/dist/components/combo-box/ComboBox.d.ts +1 -1
- package/dist/components/combo-box/ComboBox.d.ts.map +1 -1
- package/dist/components/combo-box/ComboBox.js.map +1 -1
- package/dist/components/select/SelectNative.d.ts.map +1 -1
- package/dist/components/select/SelectNative.js +14 -4
- package/dist/components/select/SelectNative.js.map +1 -1
- package/dist/index.css +4 -3
- package/dist/index.css.map +1 -1
- package/dist/packages/tapestry-render/dist/{buildComponent-Dr2UOgFa.js → buildComponent-DDhu-82j.js} +44 -25
- package/dist/packages/tapestry-render/dist/buildComponent-DDhu-82j.js.map +1 -0
- package/dist/packages/tapestry-render/dist/index.js +2 -2
- package/dist/packages/tapestry-render/dist/index.js.map +1 -1
- package/dist/packages/tapestry-render/dist/legacy.js +2 -2
- package/dist/packages/tapestry-render/dist/legacy.js.map +1 -1
- package/dist/reactRender.css +1031 -974
- package/dist/reactRender.css.map +1 -1
- package/dist/reactRenderLegacy.css +1031 -974
- package/dist/reactRenderLegacy.css.map +1 -1
- package/dist/unstable.css +107 -50
- package/dist/unstable.css.map +1 -1
- package/package.json +5 -5
- package/dist/packages/tapestry-render/dist/buildComponent-Dr2UOgFa.js.map +0 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ActiveFilter } from "./FilterTypes";
|
|
3
|
+
export declare function ActiveFilters({ activeFilters, }: {
|
|
4
|
+
activeFilters: ActiveFilter[];
|
|
5
|
+
}): React.JSX.Element;
|
|
6
|
+
declare function ActiveFilter({ activeFilter }: {
|
|
7
|
+
activeFilter: ActiveFilter;
|
|
8
|
+
}): React.JSX.Element;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=ActiveFilters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActiveFilters.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/ActiveFilters.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD,wBAAgB,aAAa,CAAC,EAC5B,aAAa,GACd,EAAE;IACD,aAAa,EAAE,YAAY,EAAE,CAAA;CAC9B,qBAUA;AAED,iBAAS,YAAY,CAAC,EAAE,YAAY,EAAE,EAAE;IAAE,YAAY,EAAE,YAAY,CAAA;CAAE,qBAwBrE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import '../button/ActionsDropdownIconButton.js';
|
|
2
|
+
import { Button } from '../button/Button.js';
|
|
3
|
+
import '../button/DropdownButton.js';
|
|
4
|
+
import '../button/DropdownIconButton.js';
|
|
5
|
+
import '../button/IconButton.js';
|
|
6
|
+
import '../button/LoadingButton.js';
|
|
7
|
+
import '../button/PageHeaderActionsDropdownButton.js';
|
|
8
|
+
import { Flex } from '../flex/Flex.js';
|
|
9
|
+
import { Popover, PopoverTrigger, PopoverContent } from '../popover/Popover.js';
|
|
10
|
+
import React__default from 'react';
|
|
11
|
+
import { useRelatedFilterOperator } from './FilterContext.js';
|
|
12
|
+
|
|
13
|
+
function ActiveFilters({ activeFilters, }) {
|
|
14
|
+
return (React__default.createElement("div", { className: "tds-data-table-active-filters" },
|
|
15
|
+
React__default.createElement(Flex, { gap: 1, inline: true }, activeFilters.map((filter, index) => (React__default.createElement(ActiveFilter, { key: index, activeFilter: filter }))))));
|
|
16
|
+
}
|
|
17
|
+
function ActiveFilter({ activeFilter }) {
|
|
18
|
+
const { relatedFilter, operator } = useRelatedFilterOperator(activeFilter) || {};
|
|
19
|
+
if (!relatedFilter || !operator)
|
|
20
|
+
return (React__default.createElement(Button, { label: "Unrecognized Filter: TODO: THIS NEEDS STYLING. Should probably have a remove button to clear it." }));
|
|
21
|
+
const value = activeFilter.value;
|
|
22
|
+
const segments = operator.label
|
|
23
|
+
? [relatedFilter.label, operator.label, value]
|
|
24
|
+
: [relatedFilter.label, value];
|
|
25
|
+
return (React__default.createElement(Popover, null,
|
|
26
|
+
React__default.createElement(PopoverTrigger, null,
|
|
27
|
+
React__default.createElement(Button, { label: segments.join(" | ") })),
|
|
28
|
+
React__default.createElement(PopoverContent, { modal: false }, "Here is where you would edit the chip")));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { ActiveFilters };
|
|
32
|
+
//# sourceMappingURL=ActiveFilters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActiveFilters.js","sources":["../../../src/components/DataTable/ActiveFilters.tsx"],"sourcesContent":["import { Button } from \"@components/button\"\nimport { Flex } from \"@components/flex\"\nimport {\n Popover,\n PopoverContent,\n PopoverTrigger,\n} from \"@components/popover/Popover\"\nimport React from \"react\"\n\nimport { useRelatedFilterOperator } from \"./FilterContext\"\nimport type { ActiveFilter } from \"./FilterTypes\"\n\nexport function ActiveFilters({\n activeFilters,\n}: {\n activeFilters: ActiveFilter[]\n}) {\n return (\n <div className=\"tds-data-table-active-filters\">\n <Flex gap={1} inline>\n {activeFilters.map((filter, index) => (\n <ActiveFilter key={index} activeFilter={filter} />\n ))}\n </Flex>\n </div>\n )\n}\n\nfunction ActiveFilter({ activeFilter }: { activeFilter: ActiveFilter }) {\n const { relatedFilter, operator } =\n useRelatedFilterOperator(activeFilter) || {}\n\n if (!relatedFilter || !operator)\n return (\n <Button label=\"Unrecognized Filter: TODO: THIS NEEDS STYLING. Should probably have a remove button to clear it.\" />\n )\n\n const value = activeFilter.value as string\n const segments = operator.label\n ? [relatedFilter.label, operator.label, value]\n : [relatedFilter.label, value]\n\n return (\n <Popover>\n <PopoverTrigger>\n <Button label={segments.join(\" | \")} />\n </PopoverTrigger>\n <PopoverContent modal={false}>\n Here is where you would edit the chip\n </PopoverContent>\n </Popover>\n )\n}\n"],"names":["React"],"mappings":";;;;;;;;;;;;AAYM,SAAU,aAAa,CAAC,EAC5B,aAAa,GAGd,EAAA;AACC,IAAA,QACEA,cAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,+BAA+B,EAAA;AAC5C,QAAAA,cAAA,CAAA,aAAA,CAAC,IAAI,EAAA,EAAC,GAAG,EAAE,CAAC,EAAE,MAAM,EAAA,IAAA,EAAA,EACjB,aAAa,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,MAC/BA,6BAAC,YAAY,EAAA,EAAC,GAAG,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,GAAI,CACnD,CAAC,CACG,CACH;AAEV;AAEA,SAAS,YAAY,CAAC,EAAE,YAAY,EAAkC,EAAA;AACpE,IAAA,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,GAC/B,wBAAwB,CAAC,YAAY,CAAC,IAAI,EAAE;AAE9C,IAAA,IAAI,CAAC,aAAa,IAAI,CAAC,QAAQ;QAC7B,QACEA,6BAAC,MAAM,EAAA,EAAC,KAAK,EAAC,mGAAmG,EAAA,CAAG;AAGxH,IAAA,MAAM,KAAK,GAAG,YAAY,CAAC,KAAe;AAC1C,IAAA,MAAM,QAAQ,GAAG,QAAQ,CAAC;UACtB,CAAC,aAAa,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,KAAK;UAC3C,CAAC,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC;IAEhC,QACEA,6BAAC,OAAO,EAAA,IAAA;AACN,QAAAA,cAAA,CAAA,aAAA,CAAC,cAAc,EAAA,IAAA;YACbA,cAAA,CAAA,aAAA,CAAC,MAAM,EAAA,EAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAA,CAAI,CACxB;QACjBA,cAAA,CAAA,aAAA,CAAC,cAAc,IAAC,KAAK,EAAE,KAAK,EAAA,EAAA,uCAAA,CAEX,CACT;AAEd;;;;"}
|
|
@@ -3,6 +3,7 @@ import type { CombineAriaPropsWithCustomProps } from "../../utilities/reactAriaP
|
|
|
3
3
|
import React, { type ReactNode } from "react";
|
|
4
4
|
import { type TableProps as AriaTableProps } from "react-aria-components/Table";
|
|
5
5
|
import type { DataTableColumn } from "./DataTableColumn";
|
|
6
|
+
import type { ActiveFilter, FilterNode } from "./FilterTypes";
|
|
6
7
|
import { type ResultNoun } from "./ResultsCount";
|
|
7
8
|
import { type RowAction } from "./RowActions";
|
|
8
9
|
import { type TableAction } from "./TableActions";
|
|
@@ -14,6 +15,7 @@ export type Sort = {
|
|
|
14
15
|
};
|
|
15
16
|
export type DataTableLoadingState = "error" | "idle" | "loading";
|
|
16
17
|
interface DataTableBaseProps {
|
|
18
|
+
activeFilters?: ActiveFilter[];
|
|
17
19
|
/**
|
|
18
20
|
* Columns define what data is displayed and how. Pass a stable reference
|
|
19
21
|
* (e.g. a module constant or memoized value); columns are prepared per array
|
|
@@ -39,6 +41,11 @@ interface DataTableBaseProps {
|
|
|
39
41
|
emptyState?: ReactNode;
|
|
40
42
|
/** Rendered in place of the table body when `loadingState` is `"error"`. */
|
|
41
43
|
errorState?: ReactNode;
|
|
44
|
+
/**
|
|
45
|
+
* The filter tree shown in the "Add filter" popover. Renders the filter
|
|
46
|
+
* controls in the header when set; omit to leave filtering off entirely.
|
|
47
|
+
*/
|
|
48
|
+
filters?: FilterNode[];
|
|
42
49
|
/** Returns a stable identity for each row. Defaults to `row.id`. */
|
|
43
50
|
getRowId?: (row: unknown) => number | string;
|
|
44
51
|
/**
|
|
@@ -73,6 +80,10 @@ interface DataTableBaseProps {
|
|
|
73
80
|
* - `"idle"` (default): Normal rendering.
|
|
74
81
|
*/
|
|
75
82
|
loadingState?: DataTableLoadingState;
|
|
83
|
+
/**
|
|
84
|
+
* Called when the active filters change. Provides the list of currently applied filters.
|
|
85
|
+
*/
|
|
86
|
+
onActiveFiltersChange?: (appliedFilters: ActiveFilter[]) => void;
|
|
76
87
|
/**
|
|
77
88
|
* Called when the Next button is activated. Only used by
|
|
78
89
|
* `paginationType="indexed"`; load the following page's rows and pass them
|
|
@@ -257,7 +268,7 @@ export type DataTableElementProps = CombineAriaPropsWithCustomProps<AriaTablePro
|
|
|
257
268
|
* @component
|
|
258
269
|
*/
|
|
259
270
|
export declare const DataTable: {
|
|
260
|
-
({ className, canSelectAllPages, columns, currentPage, data, disabledKeys, emptyState, errorState, getRowId, getRowLink, hasNextPage, hasPreviousPage, id, loadingState, paginationType, resultCount, resultNoun, scrollContainerRef, scrollContainerSelector, rowActions, selectable, selectedKeys: controlledSelectedKeys, stickyHeader, sortBy, tableActions, totalDisabledCount, totalPages, visibleColumnNames, onNextPageClick, onPageChange, onPreviousPageClick, onRowClick, onSelectedChange, onSortChange, onVisibleColumnNamesChange, ...restProps }: DataTableElementProps): React.JSX.Element;
|
|
271
|
+
({ activeFilters, className, canSelectAllPages, columns, currentPage, data, disabledKeys, emptyState, errorState, filters, getRowId, getRowLink, hasNextPage, hasPreviousPage, id, loadingState, paginationType, resultCount, resultNoun, scrollContainerRef, scrollContainerSelector, rowActions, selectable, selectedKeys: controlledSelectedKeys, stickyHeader, sortBy, tableActions, totalDisabledCount, totalPages, visibleColumnNames, onNextPageClick, onPageChange, onPreviousPageClick, onRowClick, onSelectedChange, onSortChange, onVisibleColumnNamesChange, ...restProps }: DataTableElementProps): React.JSX.Element;
|
|
261
272
|
displayName: string;
|
|
262
273
|
};
|
|
263
274
|
//# sourceMappingURL=DataTable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTable.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/DataTable.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAKpB,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAA;AAGhF,OAAO,KAAK,EAAE,EACZ,KAAK,SAAS,EAKf,MAAM,OAAO,CAAA;AACd,OAAO,EASL,KAAK,UAAU,IAAI,cAAc,EAClC,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"DataTable.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/DataTable.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAKpB,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAA;AAGhF,OAAO,KAAK,EAAE,EACZ,KAAK,SAAS,EAKf,MAAM,OAAO,CAAA;AACd,OAAO,EASL,KAAK,UAAU,IAAI,cAAc,EAClC,MAAM,6BAA6B,CAAA;AAGpC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAKxD,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC7D,OAAO,EAGL,KAAK,UAAU,EAEhB,MAAM,gBAAgB,CAAA;AACvB,OA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,CAAA;IACnB;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAA;CAC9B;AAED,UAAU,+BAA+B;IACvC,oDAAoD;IACpD,iBAAiB,CAAC,EAAE,KAAK,CAAA;IACzB,oEAAoE;IACpE,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,KAAK,IAAI,CAAA;IACtD,6BAA6B;IAC7B,YAAY,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;IAClC,mEAAmE;IACnE,YAAY,CAAC,EAAE,WAAW,EAAE,CAAA;CAC7B;AAED,UAAU,+BAA+B;IACvC;;;;;;OAMG;IACH,iBAAiB,EAAE,IAAI,CAAA;IACvB,+DAA+D;IAC/D,gBAAgB,CAAC,EAAE,CAAC,SAAS,EAAE,kBAAkB,KAAK,IAAI,CAAA;IAC1D;;;;OAIG;IACH,YAAY,CAAC,EAAE,kBAAkB,CAAA;IACjC,mEAAmE;IACnE,YAAY,CAAC,EAAE,WAAW,CAAC,kBAAkB,CAAC,EAAE,CAAA;CACjD;AAED,MAAM,MAAM,cAAc,GAAG,kBAAkB,GAC7C,CAAC,+BAA+B,GAAG,+BAA+B,CAAC,CAAA;AAIrE,KAAK,oBAAoB,GAAG,UAAU,GAAG,MAAM,CAAA;AAE/C,KAAK,uBAAuB,GAAG,KAAK,CAAA;AAEpC,MAAM,MAAM,qBAAqB,GAAG,+BAA+B,CACjE,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,uBAAuB,CACxB,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,SAAS;6jBAuCnB,qBAAqB;;CAmUvB,CAAA"}
|
|
@@ -6,8 +6,11 @@ import { useId } from '../../utilities/useId.js';
|
|
|
6
6
|
import classNames from 'classnames';
|
|
7
7
|
import React__default, { useRef, useMemo, useState, useLayoutEffect } from 'react';
|
|
8
8
|
import { Table, TableHeader, Column, Checkbox, TableBody, Row, Cell } from 'react-aria-components/Table';
|
|
9
|
+
import { ActiveFilters } from './ActiveFilters.js';
|
|
9
10
|
import { prepareColumn } from './DataTableColumnTypes.js';
|
|
10
11
|
import { getRowKey } from './DataTableRow.js';
|
|
12
|
+
import { FiltersProvider } from './FilterContext.js';
|
|
13
|
+
import { FilterControls } from './FilterControls.js';
|
|
11
14
|
import { hasResultsCount, resolveResultNounLabel, ResultsCount } from './ResultsCount.js';
|
|
12
15
|
import { RowActions } from './RowActions.js';
|
|
13
16
|
import { SelectAllBanner } from './SelectAllBanner.js';
|
|
@@ -35,7 +38,7 @@ const DEFAULT_ERROR_STATE = "Something went wrong.";
|
|
|
35
38
|
*
|
|
36
39
|
* @component
|
|
37
40
|
*/
|
|
38
|
-
const DataTable = ({ className, canSelectAllPages, columns, currentPage = 1, data, disabledKeys, emptyState, errorState, getRowId, getRowLink, hasNextPage = false, hasPreviousPage = false, id, loadingState = "idle", paginationType = "paged", resultCount, resultNoun, scrollContainerRef, scrollContainerSelector = ".content-wrap", rowActions, selectable, selectedKeys: controlledSelectedKeys, stickyHeader, sortBy, tableActions, totalDisabledCount, totalPages, visibleColumnNames, onNextPageClick, onPageChange, onPreviousPageClick, onRowClick, onSelectedChange, onSortChange, onVisibleColumnNamesChange, ...restProps }) => {
|
|
41
|
+
const DataTable = ({ activeFilters = [], className, canSelectAllPages, columns, currentPage = 1, data, disabledKeys, emptyState, errorState, filters = [], getRowId, getRowLink, hasNextPage = false, hasPreviousPage = false, id, loadingState = "idle", paginationType = "paged", resultCount, resultNoun, scrollContainerRef, scrollContainerSelector = ".content-wrap", rowActions, selectable, selectedKeys: controlledSelectedKeys, stickyHeader, sortBy, tableActions, totalDisabledCount, totalPages, visibleColumnNames, onNextPageClick, onPageChange, onPreviousPageClick, onRowClick, onSelectedChange, onSortChange, onVisibleColumnNamesChange, ...restProps }) => {
|
|
39
42
|
const hasRowPressAction = Boolean(onRowClick || getRowLink);
|
|
40
43
|
const rowsAreInteractive = hasRowPressAction || Boolean(selectable);
|
|
41
44
|
const combinedClassName = classNames("tds-data-table-grid", className);
|
|
@@ -101,8 +104,9 @@ const DataTable = ({ className, canSelectAllPages, columns, currentPage = 1, dat
|
|
|
101
104
|
? `${resultNounLabel} table pagination`
|
|
102
105
|
: undefined;
|
|
103
106
|
const hasActions = (tableActions?.length ?? 0) > 0;
|
|
107
|
+
const hasFilters = (filters?.length ?? 0) > 0;
|
|
104
108
|
const hasViewSettingsToggle = hideableColumns.length > 0;
|
|
105
|
-
const showHeader = Boolean(resultNoun || hasActions || hasViewSettingsToggle);
|
|
109
|
+
const showHeader = Boolean(resultNoun || hasActions || hasFilters || hasViewSettingsToggle);
|
|
106
110
|
const hasRowActions = (rowActions?.length ?? 0) > 0;
|
|
107
111
|
// A lone page has nothing to navigate to, so the paged controls stay out of
|
|
108
112
|
// the frame entirely rather than rendering a single inert page marker. The
|
|
@@ -111,52 +115,55 @@ const DataTable = ({ className, canSelectAllPages, columns, currentPage = 1, dat
|
|
|
111
115
|
// set that fits on one page shows both buttons disabled.
|
|
112
116
|
const isIndexedPagination = paginationType === "indexed";
|
|
113
117
|
const showPagination = isIndexedPagination || (totalPages !== undefined && totalPages > 1);
|
|
114
|
-
return (React__default.createElement(
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
React__default.createElement(
|
|
119
|
-
|
|
120
|
-
React__default.createElement(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
"tds-data-table-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
118
|
+
return (React__default.createElement(FiltersProvider, { filters: filters },
|
|
119
|
+
React__default.createElement("div", { className: classNames("tds-data-table", {
|
|
120
|
+
"tds-data-table--sticky-header": hasScrollContainer,
|
|
121
|
+
}) },
|
|
122
|
+
React__default.createElement("div", { className: "tds-data-table-frame" },
|
|
123
|
+
React__default.createElement(DataTableSelectionContext.Provider, { value: selectionModel },
|
|
124
|
+
showHeader && (React__default.createElement("div", { className: "tds-data-table-frame-header" },
|
|
125
|
+
React__default.createElement(ResultsCount, { id: resultsCountId, resultNoun: resultNoun, selectable: selectable, selectedCount: selectedCount, totalCount: totalCount }),
|
|
126
|
+
hasActions && (React__default.createElement(TableActions, { actions: tableActions, resultNoun: resultNoun })),
|
|
127
|
+
hasFilters && (React__default.createElement(FilterControls, { filters: filters })),
|
|
128
|
+
hasViewSettingsToggle && (React__default.createElement(ViewSettingsToggle, { columns: hideableColumns, onColumnVisibilityChange: onColumnVisibilityChange, visibleColumnNames: visibleHideableColumns })))),
|
|
129
|
+
React__default.createElement(SelectAllBanner, { resultNoun: resultNoun })),
|
|
130
|
+
activeFilters?.length > 0 && (React__default.createElement(ActiveFilters, { activeFilters: activeFilters })),
|
|
131
|
+
React__default.createElement("div", { ref: wrapperRef, className: "tds-data-table-scroll-wrapper" },
|
|
132
|
+
React__default.createElement("div", { ref: scrollRef, className: "tds-data-table-scroll" },
|
|
133
|
+
React__default.createElement(Table, { ...restProps, ...selectionProps, ...(ariaLabel ? { "aria-label": ariaLabel } : {}), ...(describedBy ? { "aria-describedby": describedBy } : {}), ...{ id: tableId }, className: combinedClassName,
|
|
134
|
+
// Pinned rather than exposed as a prop: `disabledKeys` only ever
|
|
135
|
+
// turns off selection here, leaving the row clickable and
|
|
136
|
+
// focusable. React Aria defaults this to "all", which would also
|
|
137
|
+
// disable `onRowClick`/`getRowLink` and drop the row out of the
|
|
138
|
+
// focus order, so it has to be set explicitly.
|
|
139
|
+
disabledBehavior: "selection", disabledKeys: disabledKeys, sortDescriptor: sortDescriptor, onSortChange: (sort) => {
|
|
140
|
+
onSortChange?.(serializeSort(sort));
|
|
141
|
+
} },
|
|
142
|
+
React__default.createElement(TableHeader, { className: "tds-data-table-header" },
|
|
143
|
+
selectable && (React__default.createElement(Column, { className: "tds-data-table-column tds-data-table-column--selectable" }, headerCheckboxProps ? (React__default.createElement(Checkbox, { ...headerCheckboxProps, "aria-label": "Select all", slot: null, className: "tds-data-table-selectable-checkbox" })) : (React__default.createElement(Checkbox, { slot: "selection", className: "tds-data-table-selectable-checkbox" })))),
|
|
144
|
+
visiblePreparedColumns.map(({ align, column }, index) => (React__default.createElement(Column, { key: column.name, id: column.name, isRowHeader: index === 0, className: classNames("tds-data-table-column", {
|
|
145
|
+
[`tds-data-table-column--align-${align}`]: align !== "start",
|
|
146
|
+
}), allowsSorting: column.sortable },
|
|
147
|
+
column.hideLabel ? (React__default.createElement("span", { className: "tds-data-table-column-label--hidden" }, column.headerLabel)) : (column.headerLabel),
|
|
148
|
+
column.sortable && (React__default.createElement(Icon, { className: "tds-data-table-column-icon tds-data-table-column-icon--sort", symbol: "general#up-caret", "aria-hidden": true }))))),
|
|
149
|
+
hasRowActions && (React__default.createElement(Column, { className: "tds-data-table-column tds-data-table-column--actions" },
|
|
150
|
+
React__default.createElement("span", { className: "tds-data-table-column-label--hidden" }, "Actions")))),
|
|
151
|
+
React__default.createElement(TableBody, { className: "tds-data-table-body", renderEmptyState: renderEmptyState }, data.map((row, rowIndex) => {
|
|
152
|
+
const rowKey = getRowKey(row, rowIndex, getRowId);
|
|
153
|
+
return (React__default.createElement(Row, { key: rowKey, id: rowKey, href: getRowLink?.(row), onAction: onRowClick ? () => onRowClick(row) : undefined, className: classNames("tds-data-table-row", {
|
|
154
|
+
"tds-data-table-row--interactive": rowsAreInteractive,
|
|
155
|
+
"tds-data-table-row--press-selects": rowPressSelects,
|
|
156
|
+
}) },
|
|
157
|
+
selectable && (React__default.createElement(Cell, { className: "tds-data-table-cell tds-data-table-cell--selectable" },
|
|
158
|
+
React__default.createElement(Checkbox, { slot: "selection", className: "tds-data-table-selectable-checkbox" }))),
|
|
159
|
+
visiblePreparedColumns.map((prepared) => (React__default.createElement(Cell, { key: prepared.column.name, ...cellBoundaryProps, "data-pii": prepared.column.pii || undefined, className: classNames("tds-data-table-cell", {
|
|
160
|
+
[`tds-data-table-cell--align-${prepared.align}`]: prepared.align !== "start",
|
|
161
|
+
"tds-data-table-cell--numeric": prepared.isNumeric,
|
|
162
|
+
}) }, prepared.renderCell(row)))),
|
|
163
|
+
hasRowActions && (React__default.createElement(Cell, { ...cellBoundaryProps, className: "tds-data-table-cell tds-data-table-cell--actions" },
|
|
164
|
+
React__default.createElement(RowActions, { actions: rowActions, row: row, rowKey: rowKey })))));
|
|
165
|
+
}))))),
|
|
166
|
+
showPagination && (React__default.createElement("div", { className: "tds-data-table-frame-footer" }, isIndexedPagination ? (React__default.createElement(Pagination, { "aria-label": paginationLabel, hasNextPage: hasNextPage, hasPreviousPage: hasPreviousPage, onNextPageClick: onNextPageClick, onPreviousPageClick: onPreviousPageClick, type: "indexed" })) : (React__default.createElement(Pagination, { "aria-label": paginationLabel, currentPage: currentPage, onPageChange: onPageChange, totalPages: totalPages }))))))));
|
|
160
167
|
};
|
|
161
168
|
DataTable.displayName = "DataTable";
|
|
162
169
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTable.js","sources":["../../../src/components/DataTable/DataTable.tsx"],"sourcesContent":["import \"./index.css\"\n\nimport { LoadingSpinner } from \"@components/internal\"\nimport { Pagination } from \"@components/internal/pagination\"\nimport Icon from \"@utilities/Icon\"\nimport type { CombineAriaPropsWithCustomProps } from \"@utilities/reactAriaProps\"\nimport { useId } from \"@utilities/useId\"\nimport classNames from \"classnames\"\nimport React, {\n type ReactNode,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\"\nimport {\n Cell,\n Checkbox,\n Column,\n Row,\n type SortDescriptor,\n Table,\n TableBody,\n TableHeader,\n type TableProps as AriaTableProps,\n} from \"react-aria-components/Table\"\n\nimport type { DataTableColumn } from \"./DataTableColumn\"\nimport { prepareColumn, type PreparedColumn } from \"./DataTableColumnTypes\"\nimport { getRowKey } from \"./DataTableRow\"\nimport {\n hasResultsCount,\n resolveResultNounLabel,\n type ResultNoun,\n ResultsCount,\n} from \"./ResultsCount\"\nimport { type RowAction, RowActions } from \"./RowActions\"\nimport { SelectAllBanner } from \"./SelectAllBanner\"\nimport { type TableAction, TableActions } from \"./TableActions\"\nimport { useColumnVisibility } from \"./useColumnVisibility\"\nimport {\n type DataTableSelection,\n DataTableSelectionContext,\n useDataTableSelection,\n} from \"./useDataTableSelection\"\nimport { useRowPressBoundary } from \"./useRowPressBoundary\"\nimport { ViewSettingsToggle } from \"./ViewSettingsToggle\"\n\nexport type { DataTableSelection, ResultNoun, RowAction, TableAction }\n\nexport type Sort = { column: string; direction: \"asc\" | \"desc\" }\n\nexport type DataTableLoadingState = \"error\" | \"idle\" | \"loading\"\n\ninterface DataTableBaseProps {\n /**\n * Columns define what data is displayed and how. Pass a stable reference\n * (e.g. a module constant or memoized value); columns are prepared per array\n * identity, so an inline array rebuilds each column's formatter every render.\n */\n columns: DataTableColumn[]\n /**\n * The 1-indexed current page. Only used by the default `\"paged\"` pagination,\n * where `totalPages` is set, and defaults to `1`.\n */\n currentPage?: number\n /** The array of rows to display. */\n data: unknown[]\n /**\n * Row keys that can't be selected. Keys are the values returned by `getRowId`\n * (or `row.id`, or the row's index) — the same keys used by `selectedKeys`.\n * Only selection is disabled: the row's checkbox renders disabled and \"select\n * all\" skips it, while the row itself stays clickable, navigable, and\n * focusable. Has no effect unless the table is `selectable`.\n */\n disabledKeys?: (number | string)[]\n /** Rendered in place of the table body when there is no data. */\n emptyState?: ReactNode\n /** Rendered in place of the table body when `loadingState` is `\"error\"`. */\n errorState?: ReactNode\n /** Returns a stable identity for each row. Defaults to `row.id`. */\n getRowId?: (row: unknown) => number | string\n /**\n * Returns a URL to navigate to when the row is clicked. Rows with a link\n * render as navigable elements (clickable, keyboard-focusable, and\n * openable in a new tab). Works alongside `onRowClick` and `selectable`.\n */\n getRowLink?: (row: unknown) => string\n /**\n * Whether a page exists after the current one. Only used by\n * `paginationType=\"indexed\"`, which has no page count to derive it from;\n * `false` (the default) disables the Next button.\n */\n hasNextPage?: boolean\n /**\n * Whether a page exists before the current one. Only used by\n * `paginationType=\"indexed\"`, which has no page count to derive it from;\n * `false` (the default) disables the Previous button.\n */\n hasPreviousPage?: boolean\n /**\n * An `id` for the table element. When omitted, a stable generated id is used\n * so the results count can be linked to the table via `aria-describedby`.\n */\n id?: string\n /**\n * Async loading state for the table body.\n * - `\"loading\"`: While `data` is empty, replaces the empty state with a\n * centered spinner.\n * - `\"error\"`: While `data` is empty, replaces the empty state with\n * `errorState` (or a default error message).\n * - `\"idle\"` (default): Normal rendering.\n */\n loadingState?: DataTableLoadingState\n /**\n * Called when the Next button is activated. Only used by\n * `paginationType=\"indexed\"`; load the following page's rows and pass them\n * back in through `data` in response.\n */\n onNextPageClick?: () => void\n /**\n * Called with the 1-indexed page the user navigated to. The table doesn't\n * page `data` itself — pass the rows for the new page back in through `data`\n * (and update `currentPage`) in response. Only used by the default `\"paged\"`\n * pagination; the indexed type has no page number to report.\n */\n onPageChange?: (page: number) => void\n /**\n * Called when the Previous button is activated. Only used by\n * `paginationType=\"indexed\"`; load the preceding page's rows and pass them\n * back in through `data` in response.\n */\n onPreviousPageClick?: () => void\n /**\n * Called with the row when it is clicked. Rows with a click handler render\n * as interactive elements (clickable and keyboard-focusable). When\n * `getRowLink` is also set, both run and the row navigates.\n */\n onRowClick?: (row: unknown) => void\n /** Callback invoked when the sort state changes. */\n onSortChange?: (sort: Sort) => void\n /**\n * Called with the full ordered list of visible column names when the\n * visibility toggle changes. Always-visible columns are included, so the\n * value can be passed straight back as `visibleColumnNames`. Column\n * visibility is controlled, so the table only updates once\n * `visibleColumnNames` changes.\n */\n onVisibleColumnNamesChange?: (visibleColumnNames: string[]) => void\n /**\n * Which shape the page controls take, forwarded to the `Pagination` control's\n * `type`.\n * - `\"paged\"` (the default): a numbered run of pages. Driven by `totalPages`,\n * `currentPage`, and `onPageChange`, and rendered only once `totalPages` is\n * set and greater than `1`.\n * - `\"indexed\"`: a labeled Previous/Next pair, for a result set that can only\n * be stepped through — a cursor-paged API, say, which reports whether a\n * neighboring page exists but not how many there are. Driven by\n * `hasPreviousPage`/`hasNextPage` and `onPreviousPageClick`/\n * `onNextPageClick`; `totalPages` and `currentPage` play no part. With no\n * page count there's no threshold to hide the controls below, so they\n * always render — a single page of results shows both buttons disabled.\n */\n paginationType?: \"indexed\" | \"paged\"\n /**\n * Overrides the number shown by the `resultNoun` count, which otherwise\n * uses the length of `data`. Use this when the table renders only part of\n * the result set — a paginated or virtualized table — so the count reflects\n * the whole set. It also sizes an all-pages selection when\n * `canSelectAllPages` is true, including the count used by table actions and\n * the select-all banner. Without a result count, the banner isn't offered\n * because the table can't accurately describe the all-pages selection.\n * Otherwise, it has no effect unless `resultNoun` is set.\n */\n resultCount?: number\n /**\n * Displays the number of results (the length of `data`, or `resultCount`\n * when supplied) above the table, followed by a noun that matches the count.\n * Pass a string to use it as the singular noun and append `\"s\"` for the\n * plural (e.g. `\"result\"` → `\"results\"`), or a `[singular, plural]` tuple to\n * supply an irregular plural explicitly (e.g. `[\"person\", \"people\"]`). Pass\n * `true` to use `\"result\"`.\n * When `false` or omitted, no count is rendered. The count is formatted with\n * `Intl.NumberFormat` and the singular form is used only when the count is\n * exactly `1`. When the table is `selectable` and rows are selected, the\n * count instead reflects the selection as `\"{selected} of {total}\"`, e.g.\n * `\"2 of 100\"`, with a visually-hidden suffix naming the noun so assistive\n * tech reads the unambiguous `\"2 of 100 people selected\"`.\n * The count is linked to the table with `aria-describedby` so\n * screen readers announce it as a description of the table. When a string or\n * `[singular, plural]` tuple is provided, the noun also supplies the table's\n * `aria-label` in its plural form (e.g. `\"items\"` or `\"people\"`) unless an\n * `aria-label` is passed directly, which always takes precedence; `true`\n * never provides a label. The same plural noun also names the pagination\n * landmark (e.g. `\"people table pagination\"`), which otherwise falls back to\n * `\"Pagination\"`.\n */\n resultNoun?: ResultNoun\n /**\n * Displays a sticky column to the right that holds row-scoped actions.\n * Renders as a dropdown with 2+ actions or a single button with one. Each\n * action's `onAction` or `getHref` receives the row.\n */\n rowActions?: RowAction[]\n /** Ref to the scroll container the sticky header should track. Takes priority over `scrollContainerSelector`. Only used when `stickyHeader` is true. */\n scrollContainerRef?: React.RefObject<HTMLElement>\n /** CSS selector for the scroll container the sticky header should track. Only used when `stickyHeader` is true. Defaults to \".content-wrap\" */\n scrollContainerSelector?: string\n /**\n * Enables row selection via checkboxes, including a \"select all\" checkbox in\n * the header for the loaded page. Without a row action (`onRowClick` or\n * `getRowLink`), pressing anywhere in a row toggles the row selection.\n */\n selectable?: boolean\n /** The current sort state for the table. */\n sortBy?: Sort\n /** Enables a sticky header that tracks an outer scroll container. Progressive enhancement: Relies on `animation-timeline: scroll()`, which isn't supported in all browsers (e.g. Firefox) — the header scrolls with the table body instead of sticking in those cases. */\n stickyHeader?: boolean\n /**\n * The number of disabled rows across the whole result set. Used to size an\n * all-pages selection when disabled rows exist on unloaded pages. Replaces\n * the count inferred from `disabledKeys` rather than adding to it. Values are\n * clamped to the result count, and zero is used as supplied.\n */\n totalDisabledCount?: number\n /**\n * The total number of pages in the result set. Setting it renders the page\n * controls below the table; leaving it unset renders no pagination at all.\n * A single page has nothing to navigate to, so the controls only render once\n * there are two or more pages. Only used by the default `\"paged\"` pagination\n * — an indexed result set has no page count, which is the reason to reach for\n * `paginationType=\"indexed\"` in the first place.\n *\n * The table displays whatever rows it is given — paging is the caller's job.\n * `data` should hold only the current page's rows, `resultCount` the size of\n * the whole result set, and `onPageChange` should load the next page.\n */\n totalPages?: number\n /**\n * The names of the columns currently visible. Only columns marked `hideable`\n * are affected — every other column stays visible. Omitting this leaves all\n * columns visible. Unknown names are ignored and display order always\n * follows `columns`.\n */\n visibleColumnNames?: string[]\n}\n\ninterface DataTableExplicitSelectionProps {\n /** Keeps selection values as arrays of row keys. */\n canSelectAllPages?: false\n /** Called with the selected row keys whenever selection changes. */\n onSelectedChange?: (keys: (number | string)[]) => void\n /** The selected row keys. */\n selectedKeys?: (number | string)[]\n /** Table actions whose callbacks receive the selected row keys. */\n tableActions?: TableAction[]\n}\n\ninterface DataTableAllPagesSelectionProps {\n /**\n * Enables tagged selection values that can represent every page plus\n * exclusions. Explicit arrays and the header checkbox remain page-scoped.\n * When `resultCount` proves more selectable results exist, selecting the\n * loaded page reveals a banner that widens the selection to every page or\n * clears it again. This works with both paged and indexed pagination.\n */\n canSelectAllPages: true\n /** Called with the current explicit or all-pages selection. */\n onSelectedChange?: (selection: DataTableSelection) => void\n /**\n * The current explicit or all-pages selection. Use\n * `{ keys: \"all\", excludedKeys: [] }` for every selectable result; a bare\n * `\"all\"` value is not accepted.\n */\n selectedKeys?: DataTableSelection\n /** Table actions whose callbacks receive the current selection. */\n tableActions?: TableAction<DataTableSelection>[]\n}\n\nexport type DataTableProps = DataTableBaseProps &\n (DataTableAllPagesSelectionProps | DataTableExplicitSelectionProps)\n\nconst DEFAULT_ERROR_STATE = \"Something went wrong.\"\n\ntype AriaTablePropsToOmit = \"children\" | \"slot\"\n\ntype AriaTablePropsToInclude = never\n\nexport type DataTableElementProps = CombineAriaPropsWithCustomProps<\n AriaTableProps,\n DataTableProps,\n AriaTablePropsToOmit,\n AriaTablePropsToInclude\n>\n\n/**\n * A table for displaying tabular data. Built on React Aria's `Table`.\n *\n * Each column declares a `type` that controls how its cell values are\n * formatted: `string`, `number`, `currency`, `date`, `datetime`, `boolean`,\n * `enum`, and `custom`. A column's `render` function always takes precedence\n * over the built-in type formatting.\n *\n * Setting `totalPages` renders page controls below the table; the table itself\n * never slices `data`, so `onPageChange` is where the caller loads the page.\n * `paginationType=\"indexed\"` swaps the numbered run for a labeled\n * Previous/Next pair, for a result set with no known page count.\n *\n * Filtering, presets, and other RFC features are not yet implemented.\n *\n * @component\n */\nexport const DataTable = ({\n className,\n canSelectAllPages,\n columns,\n currentPage = 1,\n data,\n disabledKeys,\n emptyState,\n errorState,\n getRowId,\n getRowLink,\n hasNextPage = false,\n hasPreviousPage = false,\n id,\n loadingState = \"idle\",\n paginationType = \"paged\",\n resultCount,\n resultNoun,\n scrollContainerRef,\n scrollContainerSelector = \".content-wrap\",\n rowActions,\n selectable,\n selectedKeys: controlledSelectedKeys,\n stickyHeader,\n sortBy,\n tableActions,\n totalDisabledCount,\n totalPages,\n visibleColumnNames,\n onNextPageClick,\n onPageChange,\n onPreviousPageClick,\n onRowClick,\n onSelectedChange,\n onSortChange,\n onVisibleColumnNamesChange,\n ...restProps\n}: DataTableElementProps) => {\n const hasRowPressAction = Boolean(onRowClick || getRowLink)\n const rowsAreInteractive = hasRowPressAction || Boolean(selectable)\n const combinedClassName = classNames(\"tds-data-table-grid\", className)\n const sortDescriptor = useSortDescriptor(sortBy)\n const { hasScrollContainer, wrapperRef } = useStickyHeader(\n stickyHeader,\n scrollContainerRef,\n scrollContainerSelector\n )\n const scrollRef = useRef<HTMLDivElement>(null)\n // A `Button` or `Link` in a cell keeps its presses to itself, so activating\n // one doesn't also press the row it's in.\n const cellBoundaryProps = useRowPressBoundary(scrollRef, rowsAreInteractive)\n\n // React Aria only invokes `renderEmptyState` when the collection is empty, so\n // the loading spinner and error message only take over the body while `data`\n // is empty; once rows exist they always render.\n const emptyStateContent = getEmptyStateContent({\n emptyState,\n errorState,\n loadingState,\n })\n const renderEmptyState = emptyStateContent\n ? () => emptyStateContent\n : undefined\n\n // Keyed on column names rather than the `columns` array identity so a fresh\n // `columns` literal each render doesn't rebuild every formatter. `columns` is\n // intentionally omitted from the deps.\n const columnKey = columns.map((c) => `${c.name}/${c.type}`).join(\"|\")\n const preparedColumns = useMemo<PreparedColumn[]>(\n () => columns.map(prepareColumn),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [columnKey]\n )\n\n const {\n hideableColumns,\n isColumnVisible,\n onColumnVisibilityChange,\n visibleHideableColumns,\n } = useColumnVisibility({\n columns,\n onVisibleColumnNamesChange,\n visibleColumnNames,\n })\n const visiblePreparedColumns = useMemo(\n () => preparedColumns.filter(({ column }) => isColumnVisible(column)),\n [preparedColumns, isColumnVisible]\n )\n\n const selectionModel = useDataTableSelection({\n canSelectAllPages,\n data,\n disabledKeys,\n getRowId,\n hasRowPressAction,\n onSelectedChange,\n resultCount,\n selectable,\n selectedKeys: controlledSelectedKeys,\n totalDisabledCount,\n })\n const {\n headerCheckboxProps,\n rowPressSelects,\n selectedCount,\n tableProps: selectionProps,\n totalCount,\n } = selectionModel\n\n // Associate the visible results count with the table so screen readers\n // announce it as a description of the table. `Table` doesn't support a real\n // `<caption>` (its children go through a collection builder), so we link the\n // count via `aria-describedby`, merging with any caller-supplied value.\n const stableId = useId()\n const tableId = id || `tds-data-table-${stableId}`\n const resultsCountId = `${tableId}-results-count`\n const describedBy = hasResultsCount(resultNoun)\n ? [restProps[\"aria-describedby\"], resultsCountId].filter(Boolean).join(\" \")\n : restProps[\"aria-describedby\"]\n\n // A caller-supplied `aria-label` always wins; otherwise the results noun\n // provides the table's accessible name so a label is present whenever a noun\n // is given. Array nouns are transformed to their plural form.\n const resultNounLabel = resolveResultNounLabel(resultNoun)\n const ariaLabel = restProps[\"aria-label\"] || resultNounLabel\n const paginationLabel = resultNounLabel\n ? `${resultNounLabel} table pagination`\n : undefined\n\n const hasActions = (tableActions?.length ?? 0) > 0\n const hasViewSettingsToggle = hideableColumns.length > 0\n const showHeader = Boolean(resultNoun || hasActions || hasViewSettingsToggle)\n const hasRowActions = (rowActions?.length ?? 0) > 0\n // A lone page has nothing to navigate to, so the paged controls stay out of\n // the frame entirely rather than rendering a single inert page marker. The\n // indexed type has no page count to measure against — stepping is the only\n // way through the set — so asking for it always renders the controls, and a\n // set that fits on one page shows both buttons disabled.\n const isIndexedPagination = paginationType === \"indexed\"\n const showPagination =\n isIndexedPagination || (totalPages !== undefined && totalPages > 1)\n\n return (\n <div\n className={classNames(\"tds-data-table\", {\n \"tds-data-table--sticky-header\": hasScrollContainer,\n })}\n >\n <div className=\"tds-data-table-frame\">\n <DataTableSelectionContext.Provider value={selectionModel}>\n {showHeader && (\n <div className=\"tds-data-table-frame-header\">\n <ResultsCount\n id={resultsCountId}\n resultNoun={resultNoun}\n selectable={selectable}\n selectedCount={selectedCount}\n totalCount={totalCount}\n />\n {hasActions && (\n <TableActions\n actions={tableActions as TableAction<DataTableSelection>[]}\n resultNoun={resultNoun}\n />\n )}\n {hasViewSettingsToggle && (\n <ViewSettingsToggle\n columns={hideableColumns}\n onColumnVisibilityChange={onColumnVisibilityChange}\n visibleColumnNames={visibleHideableColumns}\n />\n )}\n </div>\n )}\n <SelectAllBanner resultNoun={resultNoun} />\n </DataTableSelectionContext.Provider>\n <div ref={wrapperRef} className=\"tds-data-table-scroll-wrapper\">\n <div ref={scrollRef} className=\"tds-data-table-scroll\">\n <Table\n {...restProps}\n {...selectionProps}\n {...(ariaLabel ? { \"aria-label\": ariaLabel } : {})}\n {...(describedBy ? { \"aria-describedby\": describedBy } : {})}\n // RAC's `Table` forwards `id` to the underlying table element at\n // runtime (via `filterDOMProps({ global: true })`) but omits `id`\n // from its prop types, so spread it through a cast.\n {...({ id: tableId } as Partial<AriaTableProps>)}\n className={combinedClassName}\n // Pinned rather than exposed as a prop: `disabledKeys` only ever\n // turns off selection here, leaving the row clickable and\n // focusable. React Aria defaults this to \"all\", which would also\n // disable `onRowClick`/`getRowLink` and drop the row out of the\n // focus order, so it has to be set explicitly.\n disabledBehavior=\"selection\"\n disabledKeys={disabledKeys}\n sortDescriptor={sortDescriptor}\n onSortChange={(sort) => {\n onSortChange?.(serializeSort(sort))\n }}\n >\n <TableHeader className=\"tds-data-table-header\">\n {/*\n Rendered as a sibling before the `preparedColumns.map` below\n (not folded into it) so the map's `index` still starts at 0\n for the first *data* column — that's what keeps\n `isRowHeader={index === 0}` pointing at the first data\n column instead of this selection column.\n */}\n {selectable && (\n <Column className=\"tds-data-table-column tds-data-table-column--selectable\">\n {headerCheckboxProps ? (\n <Checkbox\n {...headerCheckboxProps}\n aria-label=\"Select all\"\n slot={null}\n className=\"tds-data-table-selectable-checkbox\"\n />\n ) : (\n <Checkbox\n slot=\"selection\"\n className=\"tds-data-table-selectable-checkbox\"\n />\n )}\n </Column>\n )}\n {visiblePreparedColumns.map(({ align, column }, index) => (\n <Column\n key={column.name}\n id={column.name}\n isRowHeader={index === 0}\n className={classNames(\"tds-data-table-column\", {\n [`tds-data-table-column--align-${align}`]:\n align !== \"start\",\n })}\n allowsSorting={column.sortable}\n >\n {column.hideLabel ? (\n <span className=\"tds-data-table-column-label--hidden\">\n {column.headerLabel}\n </span>\n ) : (\n column.headerLabel\n )}\n {column.sortable && (\n <Icon\n className=\"tds-data-table-column-icon tds-data-table-column-icon--sort\"\n symbol=\"general#up-caret\"\n aria-hidden={true}\n />\n )}\n </Column>\n ))}\n {hasRowActions && (\n <Column className=\"tds-data-table-column tds-data-table-column--actions\">\n <span className=\"tds-data-table-column-label--hidden\">\n Actions\n </span>\n </Column>\n )}\n </TableHeader>\n <TableBody\n className=\"tds-data-table-body\"\n renderEmptyState={renderEmptyState}\n >\n {data.map((row, rowIndex) => {\n const rowKey = getRowKey(row, rowIndex, getRowId)\n return (\n <Row\n key={rowKey}\n id={rowKey}\n href={getRowLink?.(row)}\n onAction={onRowClick ? () => onRowClick(row) : undefined}\n className={classNames(\"tds-data-table-row\", {\n \"tds-data-table-row--interactive\": rowsAreInteractive,\n \"tds-data-table-row--press-selects\": rowPressSelects,\n })}\n >\n {selectable && (\n <Cell className=\"tds-data-table-cell tds-data-table-cell--selectable\">\n <Checkbox\n slot=\"selection\"\n className=\"tds-data-table-selectable-checkbox\"\n />\n </Cell>\n )}\n {visiblePreparedColumns.map((prepared) => (\n <Cell\n key={prepared.column.name}\n {...cellBoundaryProps}\n data-pii={prepared.column.pii || undefined}\n className={classNames(\"tds-data-table-cell\", {\n [`tds-data-table-cell--align-${prepared.align}`]:\n prepared.align !== \"start\",\n \"tds-data-table-cell--numeric\": prepared.isNumeric,\n })}\n >\n {prepared.renderCell(row)}\n </Cell>\n ))}\n {hasRowActions && (\n <Cell\n {...cellBoundaryProps}\n className=\"tds-data-table-cell tds-data-table-cell--actions\"\n >\n <RowActions\n actions={rowActions!} // Safe to assert non-null here because of `hasRowActions`\n row={row}\n rowKey={rowKey}\n />\n </Cell>\n )}\n </Row>\n )\n })}\n </TableBody>\n </Table>\n </div>\n </div>\n {showPagination && (\n <div className=\"tds-data-table-frame-footer\">\n {/*\n `Pagination`'s two shapes are a discriminated union, so each is\n spelled out in full rather than assembled from one prop bag.\n */}\n {isIndexedPagination ? (\n <Pagination\n aria-label={paginationLabel}\n hasNextPage={hasNextPage}\n hasPreviousPage={hasPreviousPage}\n onNextPageClick={onNextPageClick}\n onPreviousPageClick={onPreviousPageClick}\n type=\"indexed\"\n />\n ) : (\n <Pagination\n aria-label={paginationLabel}\n currentPage={currentPage}\n onPageChange={onPageChange}\n totalPages={totalPages!}\n />\n )}\n </div>\n )}\n </div>\n </div>\n )\n}\n\nDataTable.displayName = \"DataTable\"\n\n/**\n * Resolves the content rendered in the table body's empty-state slot based on\n * `loadingState`, falling back to `emptyState`. Returns `null` when nothing\n * should render (idle with no `emptyState`).\n */\nfunction getEmptyStateContent({\n emptyState,\n errorState,\n loadingState,\n}: {\n emptyState: ReactNode\n errorState: ReactNode\n loadingState: DataTableLoadingState\n}): ReactNode {\n if (loadingState === \"loading\") {\n return (\n <div className=\"tds-data-table-loading\" role=\"status\">\n <span className=\"tds-data-table-cell-label--hidden\">Loading</span>\n <span className=\"tds-data-table-loading-spinner\" aria-hidden=\"true\">\n <LoadingSpinner />\n </span>\n </div>\n )\n }\n\n // Error and empty share the same container; they differ only in content.\n const content =\n loadingState === \"error\" ? (errorState ?? DEFAULT_ERROR_STATE) : emptyState\n if (content == null) return null\n\n return <div className=\"tds-data-table-empty\">{content}</div>\n}\n\nfunction useSortDescriptor(\n sortBy: Sort | undefined\n): SortDescriptor | undefined {\n return useMemo(() => {\n if (!sortBy) return undefined\n return deserializeSort(sortBy)\n }, [sortBy])\n}\n\nfunction deserializeSort(sort: Sort): SortDescriptor {\n if (sort.direction === \"desc\")\n return { column: sort.column, direction: \"descending\" }\n return { column: sort.column, direction: \"ascending\" }\n}\n\nfunction serializeSort(sort: SortDescriptor): Sort {\n if (sort.direction === \"descending\")\n return { column: sort.column as string, direction: \"desc\" }\n return { column: sort.column as string, direction: \"asc\" }\n}\n\nfunction useStickyHeader(\n stickyHeader: boolean | undefined,\n scrollContainerRef: React.RefObject<HTMLElement> | undefined,\n scrollContainerSelector: string | undefined\n) {\n const wrapperRef = useRef<HTMLDivElement>(null)\n const [hasScrollContainer, setHasScrollContainer] = useState(false)\n\n useLayoutEffect(() => {\n setHasScrollContainer(false)\n if (!stickyHeader) return\n if (typeof ResizeObserver === \"undefined\") return\n const wrapper = wrapperRef.current\n if (!wrapper) return\n\n const scrollContainer = getScrollContainer(\n scrollContainerRef,\n scrollContainerSelector,\n wrapper\n )\n if (!scrollContainer) return\n\n setHasScrollContainer(true)\n\n let thead: HTMLElement | null = null\n\n const resizeObserver = new ResizeObserver(() => {\n if (!thead) {\n thead = wrapper.querySelector<HTMLElement>(\".tds-data-table-header\")\n if (!thead) return\n scrollContainer.style.setProperty(\n \"scroll-timeline-name\",\n \"--_sticky-header-scroll\"\n )\n }\n\n const { top: wrapperTop, bottom: wrapperBottom } =\n wrapper.getBoundingClientRect()\n const { top: scrollContainerTop } =\n scrollContainer.getBoundingClientRect()\n // Derive headerTop from the untransformed wrapper to avoid reading the\n // scroll-driven translateY that getBoundingClientRect() includes on thead.\n const headerTop = wrapperTop + wrapper.clientTop\n const start = scrollContainer.scrollTop + (headerTop - scrollContainerTop)\n const max = Math.max(0, wrapperBottom - headerTop - thead.offsetHeight)\n wrapper.style.setProperty(\"--_sticky-header-scroll-start\", `${start}px`)\n wrapper.style.setProperty(\"--_sticky-header-scroll-max\", `${max}px`)\n })\n\n resizeObserver.observe(wrapper)\n // The banner moves the wrapper without changing its size.\n if (wrapper.parentElement) resizeObserver.observe(wrapper.parentElement)\n resizeObserver.observe(scrollContainer)\n\n return () => {\n resizeObserver.disconnect()\n wrapper.style.removeProperty(\"--_sticky-header-scroll-start\")\n wrapper.style.removeProperty(\"--_sticky-header-scroll-max\")\n }\n }, [stickyHeader, scrollContainerRef, scrollContainerSelector])\n\n return { hasScrollContainer, wrapperRef }\n}\n\nfunction getScrollContainer(\n scrollContainerRef: React.RefObject<HTMLElement> | undefined,\n scrollContainerSelector: string | undefined,\n wrapper: HTMLElement\n): HTMLElement | undefined {\n const element =\n scrollContainerRef?.current ??\n getScrollContainerFromSelector(scrollContainerSelector, wrapper)\n if (element instanceof Window) return\n return element\n}\n\nfunction getScrollContainerFromSelector(\n scrollContainerSelector: string | undefined,\n wrapper: HTMLElement\n): HTMLElement | undefined {\n return scrollContainerSelector\n ? (wrapper.parentElement?.closest<HTMLElement>(scrollContainerSelector) ??\n undefined)\n : undefined\n}\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;AA0RA,MAAM,mBAAmB,GAAG,uBAAuB;AAanD;;;;;;;;;;;;;;;;AAgBG;MACU,SAAS,GAAG,CAAC,EACxB,SAAS,EACT,iBAAiB,EACjB,OAAO,EACP,WAAW,GAAG,CAAC,EACf,IAAI,EACJ,YAAY,EACZ,UAAU,EACV,UAAU,EACV,QAAQ,EACR,UAAU,EACV,WAAW,GAAG,KAAK,EACnB,eAAe,GAAG,KAAK,EACvB,EAAE,EACF,YAAY,GAAG,MAAM,EACrB,cAAc,GAAG,OAAO,EACxB,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,uBAAuB,GAAG,eAAe,EACzC,UAAU,EACV,UAAU,EACV,YAAY,E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U,EAAE;AAC3B,YAAA,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,+BAA+B,CAAC;AAC7D,YAAA,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,6BAA6B,CAAC;AAC7D,QAAA,CAAC;IACH,CAAC,EAAE,CAAC,YAAY,EAAE,kBAAkB,EAAE,uBAAuB,CAAC,CAAC;AAE/D,IAAA,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE;AAC3C;AAEA,SAAS,kBAAkB,CACzB,kBAA4D,EAC5D,uBAA2C,EAC3C,OAAoB,EAAA;AAEpB,IAAA,MAAM,OAAO,GACX,kBAAkB,EAAE,OAAO;AAC3B,QAAA,8BAA8B,CAAC,uBAAuB,EAAE,OAAO,CAAC;IAClE,IAAI,OAAO,YAAY,MAAM;QAAE;AAC/B,IAAA,OAAO,OAAO;AAChB;AAEA,SAAS,8BAA8B,CACrC,uBAA2C,EAC3C,OAAoB,EAAA;AAEpB,IAAA,OAAO;WACF,OAAO,CAAC,aAAa,EAAE,OAAO,CAAc,uBAAuB,CAAC;AACnE,YAAA,SAAS;UACX,SAAS;AACf;;;;"}
|
|
1
|
+
{"version":3,"file":"DataTable.js","sources":["../../../src/components/DataTable/DataTable.tsx"],"sourcesContent":["import \"./index.css\"\n\nimport { LoadingSpinner } from \"@components/internal\"\nimport { Pagination } from \"@components/internal/pagination\"\nimport Icon from \"@utilities/Icon\"\nimport type { CombineAriaPropsWithCustomProps } from \"@utilities/reactAriaProps\"\nimport { useId } from \"@utilities/useId\"\nimport classNames from \"classnames\"\nimport React, {\n type ReactNode,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\"\nimport {\n Cell,\n Checkbox,\n Column,\n Row,\n type SortDescriptor,\n Table,\n TableBody,\n TableHeader,\n type TableProps as AriaTableProps,\n} from \"react-aria-components/Table\"\n\nimport { ActiveFilters } from \"./ActiveFilters\"\nimport type { DataTableColumn } from \"./DataTableColumn\"\nimport { prepareColumn, type PreparedColumn } from \"./DataTableColumnTypes\"\nimport { getRowKey } from \"./DataTableRow\"\nimport { FiltersProvider } from \"./FilterContext\"\nimport { FilterControls } from \"./FilterControls\"\nimport type { ActiveFilter, FilterNode } from \"./FilterTypes\"\nimport {\n hasResultsCount,\n resolveResultNounLabel,\n type ResultNoun,\n ResultsCount,\n} from \"./ResultsCount\"\nimport { type RowAction, RowActions } from \"./RowActions\"\nimport { SelectAllBanner } from \"./SelectAllBanner\"\nimport { type TableAction, TableActions } from \"./TableActions\"\nimport { useColumnVisibility } from \"./useColumnVisibility\"\nimport {\n type DataTableSelection,\n DataTableSelectionContext,\n useDataTableSelection,\n} from \"./useDataTableSelection\"\nimport { useRowPressBoundary } from \"./useRowPressBoundary\"\nimport { ViewSettingsToggle } from \"./ViewSettingsToggle\"\n\nexport type { DataTableSelection, ResultNoun, RowAction, TableAction }\n\nexport type Sort = { column: string; direction: \"asc\" | \"desc\" }\n\nexport type DataTableLoadingState = \"error\" | \"idle\" | \"loading\"\n\ninterface DataTableBaseProps {\n activeFilters?: ActiveFilter[]\n /**\n * Columns define what data is displayed and how. Pass a stable reference\n * (e.g. a module constant or memoized value); columns are prepared per array\n * identity, so an inline array rebuilds each column's formatter every render.\n */\n columns: DataTableColumn[]\n /**\n * The 1-indexed current page. Only used by the default `\"paged\"` pagination,\n * where `totalPages` is set, and defaults to `1`.\n */\n currentPage?: number\n /** The array of rows to display. */\n data: unknown[]\n /**\n * Row keys that can't be selected. Keys are the values returned by `getRowId`\n * (or `row.id`, or the row's index) — the same keys used by `selectedKeys`.\n * Only selection is disabled: the row's checkbox renders disabled and \"select\n * all\" skips it, while the row itself stays clickable, navigable, and\n * focusable. Has no effect unless the table is `selectable`.\n */\n disabledKeys?: (number | string)[]\n /** Rendered in place of the table body when there is no data. */\n emptyState?: ReactNode\n /** Rendered in place of the table body when `loadingState` is `\"error\"`. */\n errorState?: ReactNode\n /**\n * The filter tree shown in the \"Add filter\" popover. Renders the filter\n * controls in the header when set; omit to leave filtering off entirely.\n */\n filters?: FilterNode[]\n /** Returns a stable identity for each row. Defaults to `row.id`. */\n getRowId?: (row: unknown) => number | string\n /**\n * Returns a URL to navigate to when the row is clicked. Rows with a link\n * render as navigable elements (clickable, keyboard-focusable, and\n * openable in a new tab). Works alongside `onRowClick` and `selectable`.\n */\n getRowLink?: (row: unknown) => string\n /**\n * Whether a page exists after the current one. Only used by\n * `paginationType=\"indexed\"`, which has no page count to derive it from;\n * `false` (the default) disables the Next button.\n */\n hasNextPage?: boolean\n /**\n * Whether a page exists before the current one. Only used by\n * `paginationType=\"indexed\"`, which has no page count to derive it from;\n * `false` (the default) disables the Previous button.\n */\n hasPreviousPage?: boolean\n /**\n * An `id` for the table element. When omitted, a stable generated id is used\n * so the results count can be linked to the table via `aria-describedby`.\n */\n id?: string\n /**\n * Async loading state for the table body.\n * - `\"loading\"`: While `data` is empty, replaces the empty state with a\n * centered spinner.\n * - `\"error\"`: While `data` is empty, replaces the empty state with\n * `errorState` (or a default error message).\n * - `\"idle\"` (default): Normal rendering.\n */\n loadingState?: DataTableLoadingState\n /**\n * Called when the active filters change. Provides the list of currently applied filters.\n */\n onActiveFiltersChange?: (appliedFilters: ActiveFilter[]) => void\n /**\n * Called when the Next button is activated. Only used by\n * `paginationType=\"indexed\"`; load the following page's rows and pass them\n * back in through `data` in response.\n */\n onNextPageClick?: () => void\n /**\n * Called with the 1-indexed page the user navigated to. The table doesn't\n * page `data` itself — pass the rows for the new page back in through `data`\n * (and update `currentPage`) in response. Only used by the default `\"paged\"`\n * pagination; the indexed type has no page number to report.\n */\n onPageChange?: (page: number) => void\n /**\n * Called when the Previous button is activated. Only used by\n * `paginationType=\"indexed\"`; load the preceding page's rows and pass them\n * back in through `data` in response.\n */\n onPreviousPageClick?: () => void\n /**\n * Called with the row when it is clicked. Rows with a click handler render\n * as interactive elements (clickable and keyboard-focusable). When\n * `getRowLink` is also set, both run and the row navigates.\n */\n onRowClick?: (row: unknown) => void\n /** Callback invoked when the sort state changes. */\n onSortChange?: (sort: Sort) => void\n /**\n * Called with the full ordered list of visible column names when the\n * visibility toggle changes. Always-visible columns are included, so the\n * value can be passed straight back as `visibleColumnNames`. Column\n * visibility is controlled, so the table only updates once\n * `visibleColumnNames` changes.\n */\n onVisibleColumnNamesChange?: (visibleColumnNames: string[]) => void\n /**\n * Which shape the page controls take, forwarded to the `Pagination` control's\n * `type`.\n * - `\"paged\"` (the default): a numbered run of pages. Driven by `totalPages`,\n * `currentPage`, and `onPageChange`, and rendered only once `totalPages` is\n * set and greater than `1`.\n * - `\"indexed\"`: a labeled Previous/Next pair, for a result set that can only\n * be stepped through — a cursor-paged API, say, which reports whether a\n * neighboring page exists but not how many there are. Driven by\n * `hasPreviousPage`/`hasNextPage` and `onPreviousPageClick`/\n * `onNextPageClick`; `totalPages` and `currentPage` play no part. With no\n * page count there's no threshold to hide the controls below, so they\n * always render — a single page of results shows both buttons disabled.\n */\n paginationType?: \"indexed\" | \"paged\"\n /**\n * Overrides the number shown by the `resultNoun` count, which otherwise\n * uses the length of `data`. Use this when the table renders only part of\n * the result set — a paginated or virtualized table — so the count reflects\n * the whole set. It also sizes an all-pages selection when\n * `canSelectAllPages` is true, including the count used by table actions and\n * the select-all banner. Without a result count, the banner isn't offered\n * because the table can't accurately describe the all-pages selection.\n * Otherwise, it has no effect unless `resultNoun` is set.\n */\n resultCount?: number\n /**\n * Displays the number of results (the length of `data`, or `resultCount`\n * when supplied) above the table, followed by a noun that matches the count.\n * Pass a string to use it as the singular noun and append `\"s\"` for the\n * plural (e.g. `\"result\"` → `\"results\"`), or a `[singular, plural]` tuple to\n * supply an irregular plural explicitly (e.g. `[\"person\", \"people\"]`). Pass\n * `true` to use `\"result\"`.\n * When `false` or omitted, no count is rendered. The count is formatted with\n * `Intl.NumberFormat` and the singular form is used only when the count is\n * exactly `1`. When the table is `selectable` and rows are selected, the\n * count instead reflects the selection as `\"{selected} of {total}\"`, e.g.\n * `\"2 of 100\"`, with a visually-hidden suffix naming the noun so assistive\n * tech reads the unambiguous `\"2 of 100 people selected\"`.\n * The count is linked to the table with `aria-describedby` so\n * screen readers announce it as a description of the table. When a string or\n * `[singular, plural]` tuple is provided, the noun also supplies the table's\n * `aria-label` in its plural form (e.g. `\"items\"` or `\"people\"`) unless an\n * `aria-label` is passed directly, which always takes precedence; `true`\n * never provides a label. The same plural noun also names the pagination\n * landmark (e.g. `\"people table pagination\"`), which otherwise falls back to\n * `\"Pagination\"`.\n */\n resultNoun?: ResultNoun\n /**\n * Displays a sticky column to the right that holds row-scoped actions.\n * Renders as a dropdown with 2+ actions or a single button with one. Each\n * action's `onAction` or `getHref` receives the row.\n */\n rowActions?: RowAction[]\n /** Ref to the scroll container the sticky header should track. Takes priority over `scrollContainerSelector`. Only used when `stickyHeader` is true. */\n scrollContainerRef?: React.RefObject<HTMLElement>\n /** CSS selector for the scroll container the sticky header should track. Only used when `stickyHeader` is true. Defaults to \".content-wrap\" */\n scrollContainerSelector?: string\n /**\n * Enables row selection via checkboxes, including a \"select all\" checkbox in\n * the header for the loaded page. Without a row action (`onRowClick` or\n * `getRowLink`), pressing anywhere in a row toggles the row selection.\n */\n selectable?: boolean\n /** The current sort state for the table. */\n sortBy?: Sort\n /** Enables a sticky header that tracks an outer scroll container. Progressive enhancement: Relies on `animation-timeline: scroll()`, which isn't supported in all browsers (e.g. Firefox) — the header scrolls with the table body instead of sticking in those cases. */\n stickyHeader?: boolean\n /**\n * The number of disabled rows across the whole result set. Used to size an\n * all-pages selection when disabled rows exist on unloaded pages. Replaces\n * the count inferred from `disabledKeys` rather than adding to it. Values are\n * clamped to the result count, and zero is used as supplied.\n */\n totalDisabledCount?: number\n /**\n * The total number of pages in the result set. Setting it renders the page\n * controls below the table; leaving it unset renders no pagination at all.\n * A single page has nothing to navigate to, so the controls only render once\n * there are two or more pages. Only used by the default `\"paged\"` pagination\n * — an indexed result set has no page count, which is the reason to reach for\n * `paginationType=\"indexed\"` in the first place.\n *\n * The table displays whatever rows it is given — paging is the caller's job.\n * `data` should hold only the current page's rows, `resultCount` the size of\n * the whole result set, and `onPageChange` should load the next page.\n */\n totalPages?: number\n /**\n * The names of the columns currently visible. Only columns marked `hideable`\n * are affected — every other column stays visible. Omitting this leaves all\n * columns visible. Unknown names are ignored and display order always\n * follows `columns`.\n */\n visibleColumnNames?: string[]\n}\n\ninterface DataTableExplicitSelectionProps {\n /** Keeps selection values as arrays of row keys. */\n canSelectAllPages?: false\n /** Called with the selected row keys whenever selection changes. */\n onSelectedChange?: (keys: (number | string)[]) => void\n /** The selected row keys. */\n selectedKeys?: (number | string)[]\n /** Table actions whose callbacks receive the selected row keys. */\n tableActions?: TableAction[]\n}\n\ninterface DataTableAllPagesSelectionProps {\n /**\n * Enables tagged selection values that can represent every page plus\n * exclusions. Explicit arrays and the header checkbox remain page-scoped.\n * When `resultCount` proves more selectable results exist, selecting the\n * loaded page reveals a banner that widens the selection to every page or\n * clears it again. This works with both paged and indexed pagination.\n */\n canSelectAllPages: true\n /** Called with the current explicit or all-pages selection. */\n onSelectedChange?: (selection: DataTableSelection) => void\n /**\n * The current explicit or all-pages selection. Use\n * `{ keys: \"all\", excludedKeys: [] }` for every selectable result; a bare\n * `\"all\"` value is not accepted.\n */\n selectedKeys?: DataTableSelection\n /** Table actions whose callbacks receive the current selection. */\n tableActions?: TableAction<DataTableSelection>[]\n}\n\nexport type DataTableProps = DataTableBaseProps &\n (DataTableAllPagesSelectionProps | DataTableExplicitSelectionProps)\n\nconst DEFAULT_ERROR_STATE = \"Something went wrong.\"\n\ntype AriaTablePropsToOmit = \"children\" | \"slot\"\n\ntype AriaTablePropsToInclude = never\n\nexport type DataTableElementProps = CombineAriaPropsWithCustomProps<\n AriaTableProps,\n DataTableProps,\n AriaTablePropsToOmit,\n AriaTablePropsToInclude\n>\n\n/**\n * A table for displaying tabular data. Built on React Aria's `Table`.\n *\n * Each column declares a `type` that controls how its cell values are\n * formatted: `string`, `number`, `currency`, `date`, `datetime`, `boolean`,\n * `enum`, and `custom`. A column's `render` function always takes precedence\n * over the built-in type formatting.\n *\n * Setting `totalPages` renders page controls below the table; the table itself\n * never slices `data`, so `onPageChange` is where the caller loads the page.\n * `paginationType=\"indexed\"` swaps the numbered run for a labeled\n * Previous/Next pair, for a result set with no known page count.\n *\n * Filtering, presets, and other RFC features are not yet implemented.\n *\n * @component\n */\nexport const DataTable = ({\n activeFilters = [],\n className,\n canSelectAllPages,\n columns,\n currentPage = 1,\n data,\n disabledKeys,\n emptyState,\n errorState,\n filters = [],\n getRowId,\n getRowLink,\n hasNextPage = false,\n hasPreviousPage = false,\n id,\n loadingState = \"idle\",\n paginationType = \"paged\",\n resultCount,\n resultNoun,\n scrollContainerRef,\n scrollContainerSelector = \".content-wrap\",\n rowActions,\n selectable,\n selectedKeys: controlledSelectedKeys,\n stickyHeader,\n sortBy,\n tableActions,\n totalDisabledCount,\n totalPages,\n visibleColumnNames,\n onNextPageClick,\n onPageChange,\n onPreviousPageClick,\n onRowClick,\n onSelectedChange,\n onSortChange,\n onVisibleColumnNamesChange,\n ...restProps\n}: DataTableElementProps) => {\n const hasRowPressAction = Boolean(onRowClick || getRowLink)\n const rowsAreInteractive = hasRowPressAction || Boolean(selectable)\n const combinedClassName = classNames(\"tds-data-table-grid\", className)\n const sortDescriptor = useSortDescriptor(sortBy)\n const { hasScrollContainer, wrapperRef } = useStickyHeader(\n stickyHeader,\n scrollContainerRef,\n scrollContainerSelector\n )\n const scrollRef = useRef<HTMLDivElement>(null)\n // A `Button` or `Link` in a cell keeps its presses to itself, so activating\n // one doesn't also press the row it's in.\n const cellBoundaryProps = useRowPressBoundary(scrollRef, rowsAreInteractive)\n\n // React Aria only invokes `renderEmptyState` when the collection is empty, so\n // the loading spinner and error message only take over the body while `data`\n // is empty; once rows exist they always render.\n const emptyStateContent = getEmptyStateContent({\n emptyState,\n errorState,\n loadingState,\n })\n const renderEmptyState = emptyStateContent\n ? () => emptyStateContent\n : undefined\n\n // Keyed on column names rather than the `columns` array identity so a fresh\n // `columns` literal each render doesn't rebuild every formatter. `columns` is\n // intentionally omitted from the deps.\n const columnKey = columns.map((c) => `${c.name}/${c.type}`).join(\"|\")\n const preparedColumns = useMemo<PreparedColumn[]>(\n () => columns.map(prepareColumn),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [columnKey]\n )\n\n const {\n hideableColumns,\n isColumnVisible,\n onColumnVisibilityChange,\n visibleHideableColumns,\n } = useColumnVisibility({\n columns,\n onVisibleColumnNamesChange,\n visibleColumnNames,\n })\n const visiblePreparedColumns = useMemo(\n () => preparedColumns.filter(({ column }) => isColumnVisible(column)),\n [preparedColumns, isColumnVisible]\n )\n\n const selectionModel = useDataTableSelection({\n canSelectAllPages,\n data,\n disabledKeys,\n getRowId,\n hasRowPressAction,\n onSelectedChange,\n resultCount,\n selectable,\n selectedKeys: controlledSelectedKeys,\n totalDisabledCount,\n })\n const {\n headerCheckboxProps,\n rowPressSelects,\n selectedCount,\n tableProps: selectionProps,\n totalCount,\n } = selectionModel\n\n // Associate the visible results count with the table so screen readers\n // announce it as a description of the table. `Table` doesn't support a real\n // `<caption>` (its children go through a collection builder), so we link the\n // count via `aria-describedby`, merging with any caller-supplied value.\n const stableId = useId()\n const tableId = id || `tds-data-table-${stableId}`\n const resultsCountId = `${tableId}-results-count`\n const describedBy = hasResultsCount(resultNoun)\n ? [restProps[\"aria-describedby\"], resultsCountId].filter(Boolean).join(\" \")\n : restProps[\"aria-describedby\"]\n\n // A caller-supplied `aria-label` always wins; otherwise the results noun\n // provides the table's accessible name so a label is present whenever a noun\n // is given. Array nouns are transformed to their plural form.\n const resultNounLabel = resolveResultNounLabel(resultNoun)\n const ariaLabel = restProps[\"aria-label\"] || resultNounLabel\n const paginationLabel = resultNounLabel\n ? `${resultNounLabel} table pagination`\n : undefined\n\n const hasActions = (tableActions?.length ?? 0) > 0\n const hasFilters = (filters?.length ?? 0) > 0\n const hasViewSettingsToggle = hideableColumns.length > 0\n const showHeader = Boolean(\n resultNoun || hasActions || hasFilters || hasViewSettingsToggle\n )\n const hasRowActions = (rowActions?.length ?? 0) > 0\n // A lone page has nothing to navigate to, so the paged controls stay out of\n // the frame entirely rather than rendering a single inert page marker. The\n // indexed type has no page count to measure against — stepping is the only\n // way through the set — so asking for it always renders the controls, and a\n // set that fits on one page shows both buttons disabled.\n const isIndexedPagination = paginationType === \"indexed\"\n const showPagination =\n isIndexedPagination || (totalPages !== undefined && totalPages > 1)\n\n return (\n <FiltersProvider filters={filters}>\n <div\n className={classNames(\"tds-data-table\", {\n \"tds-data-table--sticky-header\": hasScrollContainer,\n })}\n >\n <div className=\"tds-data-table-frame\">\n <DataTableSelectionContext.Provider value={selectionModel}>\n {showHeader && (\n <div className=\"tds-data-table-frame-header\">\n <ResultsCount\n id={resultsCountId}\n resultNoun={resultNoun}\n selectable={selectable}\n selectedCount={selectedCount}\n totalCount={totalCount}\n />\n {hasActions && (\n <TableActions\n actions={tableActions as TableAction<DataTableSelection>[]}\n resultNoun={resultNoun}\n />\n )}\n {hasFilters && (\n <FilterControls filters={filters as FilterNode[]} />\n )}\n {hasViewSettingsToggle && (\n <ViewSettingsToggle\n columns={hideableColumns}\n onColumnVisibilityChange={onColumnVisibilityChange}\n visibleColumnNames={visibleHideableColumns}\n />\n )}\n </div>\n )}\n <SelectAllBanner resultNoun={resultNoun} />\n </DataTableSelectionContext.Provider>\n {activeFilters?.length > 0 && (\n <ActiveFilters activeFilters={activeFilters} />\n )}\n <div ref={wrapperRef} className=\"tds-data-table-scroll-wrapper\">\n <div ref={scrollRef} className=\"tds-data-table-scroll\">\n <Table\n {...restProps}\n {...selectionProps}\n {...(ariaLabel ? { \"aria-label\": ariaLabel } : {})}\n {...(describedBy ? { \"aria-describedby\": describedBy } : {})}\n // RAC's `Table` forwards `id` to the underlying table element at\n // runtime (via `filterDOMProps({ global: true })`) but omits `id`\n // from its prop types, so spread it through a cast.\n {...({ id: tableId } as Partial<AriaTableProps>)}\n className={combinedClassName}\n // Pinned rather than exposed as a prop: `disabledKeys` only ever\n // turns off selection here, leaving the row clickable and\n // focusable. React Aria defaults this to \"all\", which would also\n // disable `onRowClick`/`getRowLink` and drop the row out of the\n // focus order, so it has to be set explicitly.\n disabledBehavior=\"selection\"\n disabledKeys={disabledKeys}\n sortDescriptor={sortDescriptor}\n onSortChange={(sort) => {\n onSortChange?.(serializeSort(sort))\n }}\n >\n <TableHeader className=\"tds-data-table-header\">\n {/*\n Rendered as a sibling before the `preparedColumns.map` below\n (not folded into it) so the map's `index` still starts at 0\n for the first *data* column — that's what keeps\n `isRowHeader={index === 0}` pointing at the first data\n column instead of this selection column.\n */}\n {selectable && (\n <Column className=\"tds-data-table-column tds-data-table-column--selectable\">\n {headerCheckboxProps ? (\n <Checkbox\n {...headerCheckboxProps}\n aria-label=\"Select all\"\n slot={null}\n className=\"tds-data-table-selectable-checkbox\"\n />\n ) : (\n <Checkbox\n slot=\"selection\"\n className=\"tds-data-table-selectable-checkbox\"\n />\n )}\n </Column>\n )}\n {visiblePreparedColumns.map(({ align, column }, index) => (\n <Column\n key={column.name}\n id={column.name}\n isRowHeader={index === 0}\n className={classNames(\"tds-data-table-column\", {\n [`tds-data-table-column--align-${align}`]:\n align !== \"start\",\n })}\n allowsSorting={column.sortable}\n >\n {column.hideLabel ? (\n <span className=\"tds-data-table-column-label--hidden\">\n {column.headerLabel}\n </span>\n ) : (\n column.headerLabel\n )}\n {column.sortable && (\n <Icon\n className=\"tds-data-table-column-icon tds-data-table-column-icon--sort\"\n symbol=\"general#up-caret\"\n aria-hidden={true}\n />\n )}\n </Column>\n ))}\n {hasRowActions && (\n <Column className=\"tds-data-table-column tds-data-table-column--actions\">\n <span className=\"tds-data-table-column-label--hidden\">\n Actions\n </span>\n </Column>\n )}\n </TableHeader>\n <TableBody\n className=\"tds-data-table-body\"\n renderEmptyState={renderEmptyState}\n >\n {data.map((row, rowIndex) => {\n const rowKey = getRowKey(row, rowIndex, getRowId)\n return (\n <Row\n key={rowKey}\n id={rowKey}\n href={getRowLink?.(row)}\n onAction={\n onRowClick ? () => onRowClick(row) : undefined\n }\n className={classNames(\"tds-data-table-row\", {\n \"tds-data-table-row--interactive\": rowsAreInteractive,\n \"tds-data-table-row--press-selects\": rowPressSelects,\n })}\n >\n {selectable && (\n <Cell className=\"tds-data-table-cell tds-data-table-cell--selectable\">\n <Checkbox\n slot=\"selection\"\n className=\"tds-data-table-selectable-checkbox\"\n />\n </Cell>\n )}\n {visiblePreparedColumns.map((prepared) => (\n <Cell\n key={prepared.column.name}\n {...cellBoundaryProps}\n data-pii={prepared.column.pii || undefined}\n className={classNames(\"tds-data-table-cell\", {\n [`tds-data-table-cell--align-${prepared.align}`]:\n prepared.align !== \"start\",\n \"tds-data-table-cell--numeric\":\n prepared.isNumeric,\n })}\n >\n {prepared.renderCell(row)}\n </Cell>\n ))}\n {hasRowActions && (\n <Cell\n {...cellBoundaryProps}\n className=\"tds-data-table-cell tds-data-table-cell--actions\"\n >\n <RowActions\n actions={rowActions!} // Safe to assert non-null here because of `hasRowActions`\n row={row}\n rowKey={rowKey}\n />\n </Cell>\n )}\n </Row>\n )\n })}\n </TableBody>\n </Table>\n </div>\n </div>\n {showPagination && (\n <div className=\"tds-data-table-frame-footer\">\n {/*\n `Pagination`'s two shapes are a discriminated union, so each is\n spelled out in full rather than assembled from one prop bag.\n */}\n {isIndexedPagination ? (\n <Pagination\n aria-label={paginationLabel}\n hasNextPage={hasNextPage}\n hasPreviousPage={hasPreviousPage}\n onNextPageClick={onNextPageClick}\n onPreviousPageClick={onPreviousPageClick}\n type=\"indexed\"\n />\n ) : (\n <Pagination\n aria-label={paginationLabel}\n currentPage={currentPage}\n onPageChange={onPageChange}\n totalPages={totalPages!}\n />\n )}\n </div>\n )}\n </div>\n </div>\n </FiltersProvider>\n )\n}\n\nDataTable.displayName = \"DataTable\"\n\n/**\n * Resolves the content rendered in the table body's empty-state slot based on\n * `loadingState`, falling back to `emptyState`. Returns `null` when nothing\n * should render (idle with no `emptyState`).\n */\nfunction getEmptyStateContent({\n emptyState,\n errorState,\n loadingState,\n}: {\n emptyState: ReactNode\n errorState: ReactNode\n loadingState: DataTableLoadingState\n}): ReactNode {\n if (loadingState === \"loading\") {\n return (\n <div className=\"tds-data-table-loading\" role=\"status\">\n <span className=\"tds-data-table-cell-label--hidden\">Loading</span>\n <span className=\"tds-data-table-loading-spinner\" aria-hidden=\"true\">\n <LoadingSpinner />\n </span>\n </div>\n )\n }\n\n // Error and empty share the same container; they differ only in content.\n const content =\n loadingState === \"error\" ? (errorState ?? DEFAULT_ERROR_STATE) : emptyState\n if (content == null) return null\n\n return <div className=\"tds-data-table-empty\">{content}</div>\n}\n\nfunction useSortDescriptor(\n sortBy: Sort | undefined\n): SortDescriptor | undefined {\n return useMemo(() => {\n if (!sortBy) return undefined\n return deserializeSort(sortBy)\n }, [sortBy])\n}\n\nfunction deserializeSort(sort: Sort): SortDescriptor {\n if (sort.direction === \"desc\")\n return { column: sort.column, direction: \"descending\" }\n return { column: sort.column, direction: \"ascending\" }\n}\n\nfunction serializeSort(sort: SortDescriptor): Sort {\n if (sort.direction === \"descending\")\n return { column: sort.column as string, direction: \"desc\" }\n return { column: sort.column as string, direction: \"asc\" }\n}\n\nfunction useStickyHeader(\n stickyHeader: boolean | undefined,\n scrollContainerRef: React.RefObject<HTMLElement> | undefined,\n scrollContainerSelector: string | undefined\n) {\n const wrapperRef = useRef<HTMLDivElement>(null)\n const [hasScrollContainer, setHasScrollContainer] = useState(false)\n\n useLayoutEffect(() => {\n setHasScrollContainer(false)\n if (!stickyHeader) return\n if (typeof ResizeObserver === \"undefined\") return\n const wrapper = wrapperRef.current\n if (!wrapper) return\n\n const scrollContainer = getScrollContainer(\n scrollContainerRef,\n scrollContainerSelector,\n wrapper\n )\n if (!scrollContainer) return\n\n setHasScrollContainer(true)\n\n let thead: HTMLElement | null = null\n\n const resizeObserver = new ResizeObserver(() => {\n if (!thead) {\n thead = wrapper.querySelector<HTMLElement>(\".tds-data-table-header\")\n if (!thead) return\n scrollContainer.style.setProperty(\n \"scroll-timeline-name\",\n \"--_sticky-header-scroll\"\n )\n }\n\n const { top: wrapperTop, bottom: wrapperBottom } =\n wrapper.getBoundingClientRect()\n const { top: scrollContainerTop } =\n scrollContainer.getBoundingClientRect()\n // Derive headerTop from the untransformed wrapper to avoid reading the\n // scroll-driven translateY that getBoundingClientRect() includes on thead.\n const headerTop = wrapperTop + wrapper.clientTop\n const start = scrollContainer.scrollTop + (headerTop - scrollContainerTop)\n const max = Math.max(0, wrapperBottom - headerTop - thead.offsetHeight)\n wrapper.style.setProperty(\"--_sticky-header-scroll-start\", `${start}px`)\n wrapper.style.setProperty(\"--_sticky-header-scroll-max\", `${max}px`)\n })\n\n resizeObserver.observe(wrapper)\n // The banner moves the wrapper without changing its size.\n if (wrapper.parentElement) resizeObserver.observe(wrapper.parentElement)\n resizeObserver.observe(scrollContainer)\n\n return () => {\n resizeObserver.disconnect()\n wrapper.style.removeProperty(\"--_sticky-header-scroll-start\")\n wrapper.style.removeProperty(\"--_sticky-header-scroll-max\")\n }\n }, [stickyHeader, scrollContainerRef, scrollContainerSelector])\n\n return { hasScrollContainer, wrapperRef }\n}\n\nfunction getScrollContainer(\n scrollContainerRef: React.RefObject<HTMLElement> | undefined,\n scrollContainerSelector: string | undefined,\n wrapper: HTMLElement\n): HTMLElement | undefined {\n const element =\n scrollContainerRef?.current ??\n getScrollContainerFromSelector(scrollContainerSelector, wrapper)\n if (element instanceof Window) return\n return element\n}\n\nfunction getScrollContainerFromSelector(\n scrollContainerSelector: string | undefined,\n wrapper: HTMLElement\n): HTMLElement | undefined {\n return scrollContainerSelector\n ? (wrapper.parentElement?.closest<HTMLElement>(scrollContainerSelector) ??\n undefined)\n : undefined\n}\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwSA,MAAM,mBAAmB,GAAG,uBAAuB;AAanD;;;;;;;;;;;;;;;;AAgBG;MACU,SAAS,GAAG,CAAC,EACxB,aAAa,GAAG,EAAE,EAClB,SAAS,EACT,iBAAiB,EACjB,OAAO,EACP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AChB;AAEA,SAAS,8BAA8B,CACrC,uBAA2C,EAC3C,OAAoB,EAAA;AAEpB,IAAA,OAAO;WACF,OAAO,CAAC,aAAa,EAAE,OAAO,CAAc,uBAAuB,CAAC;AACnE,YAAA,SAAS;UACX,SAAS;AACf;;;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ActiveFilter, FilterNode, FilterNodeItem, Operator } from "./FilterTypes";
|
|
3
|
+
export type RelatedFilterOperatorResult = {
|
|
4
|
+
operator?: Operator;
|
|
5
|
+
relatedFilter?: FilterNodeItem;
|
|
6
|
+
};
|
|
7
|
+
export declare const FilterContext: React.Context<{
|
|
8
|
+
findActiveFilterOperator: (activeFilter: ActiveFilter) => RelatedFilterOperatorResult | undefined;
|
|
9
|
+
flatFilters: FilterNodeItem[];
|
|
10
|
+
}>;
|
|
11
|
+
export declare function FiltersProvider({ filters, children, }: {
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
filters: FilterNode[];
|
|
14
|
+
}): React.JSX.Element;
|
|
15
|
+
export declare function useRelatedFilterOperator(activeFilter: ActiveFilter): RelatedFilterOperatorResult;
|
|
16
|
+
//# sourceMappingURL=FilterContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilterContext.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/FilterContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8C,MAAM,OAAO,CAAA;AAElE,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,cAAc,EACd,QAAQ,EACT,MAAM,eAAe,CAAA;AAEtB,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,aAAa,CAAC,EAAE,cAAc,CAAA;CAC/B,CAAA;AACD,eAAO,MAAM,aAAa;8BACE,CACxB,YAAY,EAAE,YAAY,KACvB,2BAA2B,GAAG,SAAS;iBAC/B,cAAc,EAAE;EAI7B,CAAA;AAQF,wBAAgB,eAAe,CAAC,EAC9B,OAAO,EACP,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,OAAO,EAAE,UAAU,EAAE,CAAA;CACtB,qBAuBA;AAED,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,YAAY,GACzB,2BAA2B,CAQ7B"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React__default, { createContext, useMemo, useCallback } from 'react';
|
|
2
|
+
|
|
3
|
+
const FilterContext = createContext({
|
|
4
|
+
findActiveFilterOperator: () => undefined,
|
|
5
|
+
flatFilters: [],
|
|
6
|
+
});
|
|
7
|
+
function flattenFilters(nodes) {
|
|
8
|
+
return nodes.flatMap((node) => node.children ? flattenFilters(node.children) : node);
|
|
9
|
+
}
|
|
10
|
+
function FiltersProvider({ filters, children, }) {
|
|
11
|
+
const flatFilters = useMemo(() => flattenFilters(filters), [filters]);
|
|
12
|
+
const findFilter = useCallback((activeFilter) => flatFilters.find((f) => f.name === activeFilter.name), [flatFilters]);
|
|
13
|
+
const value = useMemo(() => ({
|
|
14
|
+
findActiveFilterOperator: (activeFilter) => {
|
|
15
|
+
const filter = findFilter(activeFilter);
|
|
16
|
+
const operator = filter?.operators.find((op) => op.name === activeFilter.operator);
|
|
17
|
+
return { operator, relatedFilter: filter };
|
|
18
|
+
},
|
|
19
|
+
flatFilters,
|
|
20
|
+
}), [findFilter, flatFilters]);
|
|
21
|
+
return (React__default.createElement(FilterContext.Provider, { value: value }, children));
|
|
22
|
+
}
|
|
23
|
+
function useRelatedFilterOperator(activeFilter) {
|
|
24
|
+
const context = React__default.useContext(FilterContext);
|
|
25
|
+
return (context.findActiveFilterOperator(activeFilter) || {
|
|
26
|
+
operator: undefined,
|
|
27
|
+
relatedFilter: undefined,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { FilterContext, FiltersProvider, useRelatedFilterOperator };
|
|
32
|
+
//# sourceMappingURL=FilterContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilterContext.js","sources":["../../../src/components/DataTable/FilterContext.tsx"],"sourcesContent":["import React, { createContext, useCallback, useMemo } from \"react\"\n\nimport type {\n ActiveFilter,\n FilterNode,\n FilterNodeItem,\n Operator,\n} from \"./FilterTypes\"\n\nexport type RelatedFilterOperatorResult = {\n operator?: Operator\n relatedFilter?: FilterNodeItem\n}\nexport const FilterContext = createContext<{\n findActiveFilterOperator: (\n activeFilter: ActiveFilter\n ) => RelatedFilterOperatorResult | undefined\n flatFilters: FilterNodeItem[]\n}>({\n findActiveFilterOperator: () => undefined,\n flatFilters: [],\n})\n\nfunction flattenFilters(nodes: FilterNode[]): FilterNodeItem[] {\n return nodes.flatMap((node) =>\n node.children ? flattenFilters(node.children) : node\n )\n}\n\nexport function FiltersProvider({\n filters,\n children,\n}: {\n children: React.ReactNode\n filters: FilterNode[]\n}) {\n const flatFilters = useMemo(() => flattenFilters(filters), [filters])\n const findFilter = useCallback(\n (activeFilter: ActiveFilter) =>\n flatFilters.find((f) => f.name === activeFilter.name),\n [flatFilters]\n )\n const value = useMemo(\n () => ({\n findActiveFilterOperator: (activeFilter: ActiveFilter) => {\n const filter = findFilter(activeFilter)\n const operator = filter?.operators.find(\n (op) => op.name === activeFilter.operator\n )\n return { operator, relatedFilter: filter }\n },\n flatFilters,\n }),\n [findFilter, flatFilters]\n )\n return (\n <FilterContext.Provider value={value}>{children}</FilterContext.Provider>\n )\n}\n\nexport function useRelatedFilterOperator(\n activeFilter: ActiveFilter\n): RelatedFilterOperatorResult {\n const context = React.useContext(FilterContext)\n return (\n context.findActiveFilterOperator(activeFilter) || {\n operator: undefined,\n relatedFilter: undefined,\n }\n )\n}\n"],"names":["React"],"mappings":";;AAaO,MAAM,aAAa,GAAG,aAAa,CAKvC;AACD,IAAA,wBAAwB,EAAE,MAAM,SAAS;AACzC,IAAA,WAAW,EAAE,EAAE;AAChB,CAAA;AAED,S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AQ,EAAE,SAAS;AACnB,QAAA,aAAa,EAAE,SAAS;AACzB,KAAA;AAEL;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { FilterNode } from "./FilterTypes";
|
|
3
|
+
export interface FilterControlsProps {
|
|
4
|
+
filters: FilterNode[];
|
|
5
|
+
}
|
|
6
|
+
/** Skeleton for the DataTable filters cluster — grows incrementally. */
|
|
7
|
+
export declare function FilterControls({ filters }: FilterControlsProps): React.JSX.Element;
|
|
8
|
+
export declare namespace FilterControls {
|
|
9
|
+
var displayName: string;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=FilterControls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilterControls.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/FilterControls.tsx"],"names":[],"mappings":"AAMA,OAAO,KAA4B,MAAM,OAAO,CAAA;AAShD,OAAO,KAAK,EAAE,UAAU,EAAmB,MAAM,eAAe,CAAA;AAkEhE,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,UAAU,EAAE,CAAA;CACtB;AAED,wEAAwE;AACxE,wBAAgB,cAAc,CAAC,EAAE,OAAO,EAAE,EAAE,mBAAmB,qBA+C9D;yBA/Ce,cAAc"}
|