@planningcenter/tapestry 3.7.0-rc.0 → 3.7.1-qa-1061.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/dist/components/DataTable/DataTable.d.ts +49 -0
- package/dist/components/DataTable/DataTable.d.ts.map +1 -0
- package/dist/components/DataTable/DataTable.js +71 -0
- package/dist/components/DataTable/DataTable.js.map +1 -0
- package/dist/components/DataTable/DataTableColumn.d.ts +105 -0
- package/dist/components/DataTable/DataTableColumn.d.ts.map +1 -0
- package/dist/components/DataTable/DataTableColumnTypes.d.ts +60 -0
- package/dist/components/DataTable/DataTableColumnTypes.d.ts.map +1 -0
- package/dist/components/DataTable/DataTableColumnTypes.js +167 -0
- package/dist/components/DataTable/DataTableColumnTypes.js.map +1 -0
- package/dist/components/DataTable/DataTableRow.d.ts +2 -0
- package/dist/components/DataTable/DataTableRow.d.ts.map +1 -0
- package/dist/components/DataTable/DataTableRow.js +9 -0
- package/dist/components/DataTable/DataTableRow.js.map +1 -0
- package/dist/components/DataTable/index.d.ts +5 -0
- package/dist/components/DataTable/index.d.ts.map +1 -0
- package/dist/components/dropdown/Dropdown.d.ts +9 -1
- package/dist/components/dropdown/Dropdown.d.ts.map +1 -1
- package/dist/components/dropdown/Dropdown.js.map +1 -1
- package/dist/ext/@internationalized/date/dist/private/DateFormatter.js +139 -0
- package/dist/ext/@internationalized/date/dist/private/DateFormatter.js.map +1 -0
- package/dist/reactRender.css +1635 -1493
- package/dist/reactRender.css.map +1 -1
- package/dist/reactRenderLegacy.css +1635 -1493
- package/dist/reactRenderLegacy.css.map +1 -1
- package/dist/unstable.css +142 -0
- package/dist/unstable.css.map +1 -1
- package/dist/unstable.d.ts +1 -0
- package/dist/unstable.d.ts.map +1 -1
- package/dist/unstable.js +1 -0
- package/dist/unstable.js.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import "./index.css";
|
|
2
|
+
import type { CombineAriaPropsWithCustomProps } from "../../utilities/reactAriaProps";
|
|
3
|
+
import React, { type ReactNode } from "react";
|
|
4
|
+
import { type TableProps as AriaTableProps } from "react-aria-components/Table";
|
|
5
|
+
import type { DataTableColumn } from "./DataTableColumn";
|
|
6
|
+
export type Sort = {
|
|
7
|
+
column: string;
|
|
8
|
+
direction: "asc" | "desc";
|
|
9
|
+
};
|
|
10
|
+
export interface DataTableProps {
|
|
11
|
+
/**
|
|
12
|
+
* Columns define what data is displayed and how. Pass a stable reference
|
|
13
|
+
* (e.g. a module constant or memoized value); columns are prepared per array
|
|
14
|
+
* identity, so an inline array rebuilds each column's formatter every render.
|
|
15
|
+
*/
|
|
16
|
+
columns: DataTableColumn[];
|
|
17
|
+
/** The array of rows to display. */
|
|
18
|
+
data: unknown[];
|
|
19
|
+
/** Rendered in place of the table body when there is no data. */
|
|
20
|
+
emptyState?: ReactNode;
|
|
21
|
+
/** Returns a stable identity for each row. Defaults to `row.id`. */
|
|
22
|
+
getRowId?: (row: unknown) => number | string;
|
|
23
|
+
/** Callback invoked when the sort state changes. */
|
|
24
|
+
onSortChange?: (sort: Sort) => void;
|
|
25
|
+
/** The current sort state for the table. */
|
|
26
|
+
sortBy?: Sort;
|
|
27
|
+
}
|
|
28
|
+
type AriaTablePropsToOmit = "children" | "slot";
|
|
29
|
+
type AriaTablePropsToInclude = never;
|
|
30
|
+
export type DataTableElementProps = CombineAriaPropsWithCustomProps<AriaTableProps, DataTableProps, AriaTablePropsToOmit, AriaTablePropsToInclude>;
|
|
31
|
+
/**
|
|
32
|
+
* A table for displaying tabular data. Built on React Aria's `Table`.
|
|
33
|
+
*
|
|
34
|
+
* Each column declares a `type` that controls how its cell values are
|
|
35
|
+
* formatted: `string`, `number`, `currency`, `date`, `datetime`, `boolean`,
|
|
36
|
+
* `enum`, and `custom`. A column's `render` function always takes precedence
|
|
37
|
+
* over the built-in type formatting.
|
|
38
|
+
*
|
|
39
|
+
* Sorting, filtering, pagination, selection, and other RFC features are not yet
|
|
40
|
+
* implemented.
|
|
41
|
+
*
|
|
42
|
+
* @component
|
|
43
|
+
*/
|
|
44
|
+
export declare const DataTable: {
|
|
45
|
+
({ className, columns, data, emptyState, getRowId, sortBy, onSortChange, ...restProps }: DataTableElementProps): React.JSX.Element;
|
|
46
|
+
displayName: string;
|
|
47
|
+
};
|
|
48
|
+
export {};
|
|
49
|
+
//# sourceMappingURL=DataTable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataTable.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/DataTable.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAGpB,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAA;AAEhF,OAAO,KAAK,EAAE,EAAE,KAAK,SAAS,EAAW,MAAM,OAAO,CAAA;AACtD,OAAO,EAQL,KAAK,UAAU,IAAI,cAAc,EAClC,MAAM,6BAA6B,CAAA;AAEpC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAIxD,MAAM,MAAM,IAAI,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,KAAK,GAAG,MAAM,CAAA;CAAE,CAAA;AAEhE,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,OAAO,EAAE,eAAe,EAAE,CAAA;IAC1B,oCAAoC;IACpC,IAAI,EAAE,OAAO,EAAE,CAAA;IACf,iEAAiE;IACjE,UAAU,CAAC,EAAE,SAAS,CAAA;IACtB,oEAAoE;IACpE,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,MAAM,GAAG,MAAM,CAAA;IAC5C,oDAAoD;IACpD,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;IACnC,4CAA4C;IAC5C,MAAM,CAAC,EAAE,IAAI,CAAA;CACd;AAED,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;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,SAAS;6FASnB,qBAAqB;;CAqFvB,CAAA"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import Icon from '../../utilities/Icon.js';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import React__default, { useMemo } from 'react';
|
|
4
|
+
import { Table, TableHeader, Column, TableBody, Row, Cell } from 'react-aria-components/Table';
|
|
5
|
+
import { prepareColumn } from './DataTableColumnTypes.js';
|
|
6
|
+
import { getRowKey } from './DataTableRow.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A table for displaying tabular data. Built on React Aria's `Table`.
|
|
10
|
+
*
|
|
11
|
+
* Each column declares a `type` that controls how its cell values are
|
|
12
|
+
* formatted: `string`, `number`, `currency`, `date`, `datetime`, `boolean`,
|
|
13
|
+
* `enum`, and `custom`. A column's `render` function always takes precedence
|
|
14
|
+
* over the built-in type formatting.
|
|
15
|
+
*
|
|
16
|
+
* Sorting, filtering, pagination, selection, and other RFC features are not yet
|
|
17
|
+
* implemented.
|
|
18
|
+
*
|
|
19
|
+
* @component
|
|
20
|
+
*/
|
|
21
|
+
const DataTable = ({ className, columns, data, emptyState, getRowId, sortBy, onSortChange, ...restProps }) => {
|
|
22
|
+
const combinedClassName = classNames("tds-data-table", className);
|
|
23
|
+
const sortDescriptor = useSortDescriptor(sortBy);
|
|
24
|
+
// Keyed on column names rather than the `columns` array identity so a fresh
|
|
25
|
+
// `columns` literal each render doesn't rebuild every formatter. `columns` is
|
|
26
|
+
// intentionally omitted from the deps.
|
|
27
|
+
const columnKey = columns.map((c) => `${c.name}/${c.type}`).join("|");
|
|
28
|
+
const preparedColumns = useMemo(() => columns.map(prepareColumn),
|
|
29
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
30
|
+
[columnKey]);
|
|
31
|
+
return (React__default.createElement("div", { className: "tds-data-table-wrapper" },
|
|
32
|
+
React__default.createElement("div", { className: "tds-data-table-scroll" },
|
|
33
|
+
React__default.createElement(Table, { ...restProps, className: combinedClassName, sortDescriptor: sortDescriptor, onSortChange: (sort) => {
|
|
34
|
+
onSortChange?.(serializeSort(sort));
|
|
35
|
+
} },
|
|
36
|
+
React__default.createElement(TableHeader, { className: "tds-data-table-header" }, preparedColumns.map(({ align, column }, index) => (React__default.createElement(Column, { key: column.name, id: column.name, isRowHeader: index === 0, className: classNames("tds-data-table-column", {
|
|
37
|
+
[`tds-data-table-column--align-${align}`]: align !== "start",
|
|
38
|
+
}), allowsSorting: column.sortable },
|
|
39
|
+
column.hideLabel ? (React__default.createElement("span", { className: "tds-data-table-column-label--hidden" }, column.headerLabel)) : (column.headerLabel),
|
|
40
|
+
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 })))))),
|
|
41
|
+
React__default.createElement(TableBody, { className: "tds-data-table-body", renderEmptyState: emptyState
|
|
42
|
+
? () => React__default.createElement("div", { className: "tds-data-table-empty" }, emptyState)
|
|
43
|
+
: undefined }, data.map((row, rowIndex) => {
|
|
44
|
+
const rowKey = getRowKey(row, rowIndex, getRowId);
|
|
45
|
+
return (React__default.createElement(Row, { key: rowKey, id: rowKey, className: "tds-data-table-row" }, preparedColumns.map((prepared) => (React__default.createElement(Cell, { key: prepared.column.name, className: classNames("tds-data-table-cell", {
|
|
46
|
+
[`tds-data-table-cell--align-${prepared.align}`]: prepared.align !== "start",
|
|
47
|
+
"tds-data-table-cell--numeric": prepared.isNumeric,
|
|
48
|
+
}) }, prepared.renderCell(row))))));
|
|
49
|
+
}))))));
|
|
50
|
+
};
|
|
51
|
+
DataTable.displayName = "DataTable";
|
|
52
|
+
function useSortDescriptor(sortBy) {
|
|
53
|
+
return useMemo(() => {
|
|
54
|
+
if (!sortBy)
|
|
55
|
+
return undefined;
|
|
56
|
+
return deserializeSort(sortBy);
|
|
57
|
+
}, [sortBy]);
|
|
58
|
+
}
|
|
59
|
+
function deserializeSort(sort) {
|
|
60
|
+
if (sort.direction === "desc")
|
|
61
|
+
return { column: sort.column, direction: "descending" };
|
|
62
|
+
return { column: sort.column, direction: "ascending" };
|
|
63
|
+
}
|
|
64
|
+
function serializeSort(sort) {
|
|
65
|
+
if (sort.direction === "descending")
|
|
66
|
+
return { column: sort.column, direction: "desc" };
|
|
67
|
+
return { column: sort.column, direction: "asc" };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { DataTable };
|
|
71
|
+
//# sourceMappingURL=DataTable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataTable.js","sources":["../../../src/components/DataTable/DataTable.tsx"],"sourcesContent":["import \"./index.css\"\n\nimport Icon from \"@utilities/Icon\"\nimport type { CombineAriaPropsWithCustomProps } from \"@utilities/reactAriaProps\"\nimport classNames from \"classnames\"\nimport React, { type ReactNode, useMemo } from \"react\"\nimport {\n Cell,\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\"\n\nexport type Sort = { column: string; direction: \"asc\" | \"desc\" }\n\nexport interface DataTableProps {\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 /** The array of rows to display. */\n data: unknown[]\n /** Rendered in place of the table body when there is no data. */\n emptyState?: ReactNode\n /** Returns a stable identity for each row. Defaults to `row.id`. */\n getRowId?: (row: unknown) => number | string\n /** Callback invoked when the sort state changes. */\n onSortChange?: (sort: Sort) => void\n /** The current sort state for the table. */\n sortBy?: Sort\n}\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 * Sorting, filtering, pagination, selection, and other RFC features are not yet\n * implemented.\n *\n * @component\n */\nexport const DataTable = ({\n className,\n columns,\n data,\n emptyState,\n getRowId,\n sortBy,\n onSortChange,\n ...restProps\n}: DataTableElementProps) => {\n const combinedClassName = classNames(\"tds-data-table\", className)\n const sortDescriptor = useSortDescriptor(sortBy)\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 return (\n <div className=\"tds-data-table-wrapper\">\n <div className=\"tds-data-table-scroll\">\n <Table\n {...restProps}\n className={combinedClassName}\n sortDescriptor={sortDescriptor}\n onSortChange={(sort) => {\n onSortChange?.(serializeSort(sort))\n }}\n >\n <TableHeader className=\"tds-data-table-header\">\n {preparedColumns.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}`]: 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 </TableHeader>\n <TableBody\n className=\"tds-data-table-body\"\n renderEmptyState={\n emptyState\n ? () => <div className=\"tds-data-table-empty\">{emptyState}</div>\n : undefined\n }\n >\n {data.map((row, rowIndex) => {\n const rowKey = getRowKey(row, rowIndex, getRowId)\n return (\n <Row key={rowKey} id={rowKey} className=\"tds-data-table-row\">\n {preparedColumns.map((prepared) => (\n <Cell\n key={prepared.column.name}\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 </Row>\n )\n })}\n </TableBody>\n </Table>\n </div>\n </div>\n )\n}\n\nDataTable.displayName = \"DataTable\"\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"],"names":["React"],"mappings":";;;;;;;AAqDA;;;;;;;;;;;;AAYG;AACI,MAAM,SAAS,GAAG,CAAC,EACxB,SAAS,EACT,OAAO,EACP,IAAI,EACJ,UAAU,EACV,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,GAAG,SAAS,EACU,KAAI;IAC1B,MAAM,iBAAiB,GAAG,UAAU,CAAC,gBAAgB,EAAE,SAAS,CAAC;AACjE,IAAA,MAAM,cAAc,GAAG,iBAAiB,CAA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iBAAiB,CACxB,MAAwB,EAAA;IAExB,OAAO,OAAO,CAAC,MAAK;AAClB,QAAA,IAAI,CAAC,MAAM;AAAE,YAAA,OAAO,SAAS;AAC7B,QAAA,OAAO,eAAe,CAAC,MAAM,CAAC;AAChC,IAAA,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;AACd;AAEA,SAAS,eAAe,CAAC,IAAU,EAAA;AACjC,IAAA,IAAI,IAAI,CAAC,SAAS,KAAK,MAAM;QAC3B,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE;IACzD,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE;AACxD;AAEA,SAAS,aAAa,CAAC,IAAoB,EAAA;AACzC,IAAA,IAAI,IAAI,CAAC,SAAS,KAAK,YAAY;QACjC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,MAAgB,EAAE,SAAS,EAAE,MAAM,EAAE;IAC7D,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,MAAgB,EAAE,SAAS,EAAE,KAAK,EAAE;AAC5D;;;;"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export type DataTableColumnType = "boolean"
|
|
3
|
+
/**
|
|
4
|
+
* @experimental Unstable — subject to change. Currency support is in beta
|
|
5
|
+
* and is currently hardwired to USD; the API may change without notice.
|
|
6
|
+
*/
|
|
7
|
+
| "currency" | "custom" | "date" | "datetime" | "enum" | "number" | "string";
|
|
8
|
+
export type DataTableColumnAlign = "center" | "end" | "start";
|
|
9
|
+
interface BaseColumn {
|
|
10
|
+
/** Determines how items align in the table. */
|
|
11
|
+
align?: DataTableColumnAlign;
|
|
12
|
+
/** Human-readable column header label. */
|
|
13
|
+
headerLabel: string;
|
|
14
|
+
/** Hides the visible header label (still announced to assistive tech). */
|
|
15
|
+
hideLabel?: boolean;
|
|
16
|
+
/** Key used to look up the value in each row by default. */
|
|
17
|
+
name: string;
|
|
18
|
+
/** Enables filtering on this column. See Filtering. */
|
|
19
|
+
queryable?: boolean;
|
|
20
|
+
/** Custom cell renderer. Defaults to a type-aware format of `row[column.name]`. */
|
|
21
|
+
render?: (row: unknown) => ReactNode;
|
|
22
|
+
/** Enables the resizing of that column. */
|
|
23
|
+
resizable?: boolean;
|
|
24
|
+
/** Enables sorting on this column. */
|
|
25
|
+
sortable?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/** Renders the raw value as text. */
|
|
28
|
+
export interface StringColumn extends BaseColumn {
|
|
29
|
+
type: "string";
|
|
30
|
+
}
|
|
31
|
+
/** Formats numeric values with `Intl.NumberFormat`. Aligns to the end by default. */
|
|
32
|
+
export interface NumberColumn extends BaseColumn {
|
|
33
|
+
/** Maximum value. Used by numeric filters. */
|
|
34
|
+
max?: number;
|
|
35
|
+
/** Minimum value. Used by numeric filters. */
|
|
36
|
+
min?: number;
|
|
37
|
+
/** Overrides the `Intl.NumberFormat` options used to display values. */
|
|
38
|
+
numberFormatOptions?: Intl.NumberFormatOptions;
|
|
39
|
+
/** Step increment. Used by numeric filters. */
|
|
40
|
+
step?: number;
|
|
41
|
+
type: "number";
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* @experimental Unstable — subject to change. Currency support is in beta and
|
|
45
|
+
* is currently hardwired to USD; the API may change without notice.
|
|
46
|
+
*
|
|
47
|
+
* Formats numeric values as currency. Aligns to the end by default.
|
|
48
|
+
*/
|
|
49
|
+
export interface CurrencyColumn extends BaseColumn {
|
|
50
|
+
/** Overrides the `Intl.NumberFormat` options used to display values. */
|
|
51
|
+
numberFormatOptions?: Intl.NumberFormatOptions;
|
|
52
|
+
type: "currency";
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Formats date values (without a time) with the `@internationalized/date`
|
|
56
|
+
* `DateFormatter` (a locale-aware wrapper around `Intl.DateTimeFormat`).
|
|
57
|
+
* Accepts `DateValue` objects from `@internationalized/date` (`CalendarDate`,
|
|
58
|
+
* `CalendarDateTime`, `ZonedDateTime`), `Date` objects, timestamps, or date
|
|
59
|
+
* strings (ISO `YYYY-MM-DD` strings are parsed as local dates to avoid
|
|
60
|
+
* time-zone drift). Defaults to a `medium` date style.
|
|
61
|
+
*/
|
|
62
|
+
export interface DateColumn extends BaseColumn {
|
|
63
|
+
/** Overrides the `Intl.DateTimeFormatOptions` used by the `DateFormatter`. */
|
|
64
|
+
dateFormatOptions?: Intl.DateTimeFormatOptions;
|
|
65
|
+
type: "date";
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Formats date values with both a date and a time, displaying the time after
|
|
69
|
+
* the date. Uses the `@internationalized/date` `DateFormatter` (a locale-aware
|
|
70
|
+
* wrapper around `Intl.DateTimeFormat`) and accepts the same value types as
|
|
71
|
+
* {@link DateColumn}. Defaults to a `medium` date style with a `short` time
|
|
72
|
+
* style.
|
|
73
|
+
*/
|
|
74
|
+
export interface DateTimeColumn extends BaseColumn {
|
|
75
|
+
/** Overrides the `Intl.DateTimeFormatOptions` used by the `DateFormatter`. */
|
|
76
|
+
dateFormatOptions?: Intl.DateTimeFormatOptions;
|
|
77
|
+
type: "datetime";
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Renders a boolean value as a check icon for truthy values and nothing for
|
|
81
|
+
* falsy ones. The meaning stays available to assistive tech: `trueLabel`
|
|
82
|
+
* becomes the icon's accessible name, and `falseLabel` renders as
|
|
83
|
+
* visually-hidden text.
|
|
84
|
+
*/
|
|
85
|
+
export interface BooleanColumn extends BaseColumn {
|
|
86
|
+
/** Accessible label for falsy values. Defaults to `"No"`. */
|
|
87
|
+
falseLabel?: string;
|
|
88
|
+
/** Accessible label for truthy values. Defaults to `"Yes"`. */
|
|
89
|
+
trueLabel?: string;
|
|
90
|
+
type: "boolean";
|
|
91
|
+
}
|
|
92
|
+
/** Renders one of a fixed set of values. */
|
|
93
|
+
export interface EnumColumn extends BaseColumn {
|
|
94
|
+
/** The set of allowed values. Used by enum filters. */
|
|
95
|
+
enumValues: string[];
|
|
96
|
+
type: "enum";
|
|
97
|
+
}
|
|
98
|
+
/** Renders entirely through a required `render` function. */
|
|
99
|
+
export interface CustomColumn extends BaseColumn {
|
|
100
|
+
render: (row: unknown) => ReactNode;
|
|
101
|
+
type: "custom";
|
|
102
|
+
}
|
|
103
|
+
export type DataTableColumn = BooleanColumn | CurrencyColumn | CustomColumn | DateColumn | DateTimeColumn | EnumColumn | NumberColumn | StringColumn;
|
|
104
|
+
export {};
|
|
105
|
+
//# sourceMappingURL=DataTableColumn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataTableColumn.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/DataTableColumn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,MAAM,MAAM,mBAAmB,GAC3B,SAAS;AACX;;;GAGG;GACD,UAAU,GACV,QAAQ,GACR,MAAM,GACN,UAAU,GACV,MAAM,GACN,QAAQ,GACR,QAAQ,CAAA;AAEZ,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,KAAK,GAAG,OAAO,CAAA;AAE7D,UAAU,UAAU;IAClB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,oBAAoB,CAAA;IAC5B,0CAA0C;IAC1C,WAAW,EAAE,MAAM,CAAA;IACnB,0EAA0E;IAC1E,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAA;IACZ,uDAAuD;IACvD,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,mFAAmF;IACnF,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,SAAS,CAAA;IACpC,2CAA2C;IAC3C,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,sCAAsC;IACtC,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,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YAAa,SAAQ,UAAU;IAC9C,MAAM,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,SAAS,CAAA;IACnC,IAAI,EAAE,QAAQ,CAAA;CACf;AAED,MAAM,MAAM,eAAe,GACvB,aAAa,GACb,cAAc,GACd,YAAY,GACZ,UAAU,GACV,cAAc,GACd,UAAU,GACV,YAAY,GACZ,YAAY,CAAA"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { DataTableColumn, DataTableColumnAlign } from "./DataTableColumn";
|
|
3
|
+
/** Formats a single cell value. Produced per column by the registry. */
|
|
4
|
+
export type Formatter = (value: unknown) => ReactNode;
|
|
5
|
+
/** Renders a cell from the whole row. The unified shape a prepared column exposes. */
|
|
6
|
+
export type CellRenderer = (row: unknown) => ReactNode;
|
|
7
|
+
export declare function isEmpty(value: unknown): value is null | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Everything that varies per column `type`, co-located in one place: how the
|
|
10
|
+
* column's values are formatted, its default alignment, and whether it counts
|
|
11
|
+
* as numeric. Adding a column type is a single entry in
|
|
12
|
+
* {@link columnTypeDefinitions} below.
|
|
13
|
+
*/
|
|
14
|
+
export interface ColumnTypeDefinition<C extends DataTableColumn> {
|
|
15
|
+
/** Default alignment when the column doesn't set `align`. Omitted = "start". */
|
|
16
|
+
align?: DataTableColumnAlign;
|
|
17
|
+
/**
|
|
18
|
+
* Builds the per-column value formatter. Called once per column by
|
|
19
|
+
* {@link prepareColumn}, so the `Intl`/`DateFormatter` instances it closes
|
|
20
|
+
* over are constructed once per column rather than per render — provided the
|
|
21
|
+
* consumer passes a stable `columns` reference (see `prepareColumn`).
|
|
22
|
+
*/
|
|
23
|
+
createFormatter: (column: C) => Formatter;
|
|
24
|
+
/** Marks numeric types (drives the `--numeric` cell class). */
|
|
25
|
+
isNumeric?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Maps each column discriminant to a definition typed to that column's
|
|
29
|
+
* interface, so `createFormatter` receives the correctly-narrowed column (e.g.
|
|
30
|
+
* the `number` entry's `column` is `NumberColumn`). The mapped type also makes
|
|
31
|
+
* a missing entry a compile error.
|
|
32
|
+
*/
|
|
33
|
+
type ColumnTypeRegistry = {
|
|
34
|
+
[C in DataTableColumn as C["type"]]: ColumnTypeDefinition<C>;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* The single source of truth for per-type behavior. To add a new column type:
|
|
38
|
+
* declare its literal + interface in `DataTableColumn.ts`, then add one entry
|
|
39
|
+
* here.
|
|
40
|
+
*/
|
|
41
|
+
export declare const columnTypeDefinitions: ColumnTypeRegistry;
|
|
42
|
+
/** A column with everything the table needs to render its header and cells. */
|
|
43
|
+
export interface PreparedColumn {
|
|
44
|
+
align: DataTableColumnAlign;
|
|
45
|
+
column: DataTableColumn;
|
|
46
|
+
isNumeric: boolean;
|
|
47
|
+
renderCell: CellRenderer;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Turns a column into the everything-resolved shape the table renders from.
|
|
51
|
+
* This is the single place `render` and the type formatter are reconciled: a
|
|
52
|
+
* `render` prop and a value formatter both become one `renderCell(row)`, with
|
|
53
|
+
* `render` taking precedence. The type formatter is built at most once here
|
|
54
|
+
* (and only when there is no `render`), so callers should prepare each column
|
|
55
|
+
* once — `DataTable` does this in a `useMemo` keyed on the `columns` array, so
|
|
56
|
+
* pass a stable `columns` reference to avoid rebuilding formatters every render.
|
|
57
|
+
*/
|
|
58
|
+
export declare function prepareColumn(column: DataTableColumn): PreparedColumn;
|
|
59
|
+
export {};
|
|
60
|
+
//# sourceMappingURL=DataTableColumnTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataTableColumnTypes.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/DataTableColumnTypes.tsx"],"names":[],"mappings":"AAOA,OAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAE7C,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AAW9E,wEAAwE;AACxE,MAAM,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,SAAS,CAAA;AAErD,sFAAsF;AACtF,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,SAAS,CAAA;AAEtD,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,IAAI,GAAG,SAAS,CAEjE;AAwCD;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB,CAAC,CAAC,SAAS,eAAe;IAC7D,gFAAgF;IAChF,KAAK,CAAC,EAAE,oBAAoB,CAAA;IAC5B;;;;;OAKG;IACH,eAAe,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,SAAS,CAAA;IACzC,+DAA+D;IAC/D,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED;;;;;GAKG;AACH,KAAK,kBAAkB,GAAG;KACvB,CAAC,IAAI,eAAe,IAAI,CAAC,CAAC,MAAM,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC;CAC7D,CAAA;AAID;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,kBAmFnC,CAAA;AAWD,+EAA+E;AAC/E,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,oBAAoB,CAAA;IAC3B,MAAM,EAAE,eAAe,CAAA;IACvB,SAAS,EAAE,OAAO,CAAA;IAClB,UAAU,EAAE,YAAY,CAAA;CACzB;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,GAAG,cAAc,CAoBrE"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { getLocalTimeZone as $ad063034c8620db8$export$aa8b41735afcabd2 } from './../../ext/@internationalized/date/dist/private/queries.js';
|
|
2
|
+
import { parseDate as $58246871e4652552$export$6b862160d295c8e } from './../../ext/@internationalized/date/dist/private/string.js';
|
|
3
|
+
import { DateFormatter as $12a3c853105e5a70$export$ad991b66133851cf } from './../../ext/@internationalized/date/dist/private/DateFormatter.js';
|
|
4
|
+
import Icon from '../../utilities/Icon.js';
|
|
5
|
+
import React__default from 'react';
|
|
6
|
+
|
|
7
|
+
const ISO_DATE_ONLY = /^\d{4}-\d{2}-\d{2}$/;
|
|
8
|
+
/**
|
|
9
|
+
* Locale used to build every `DateFormatter`. Resolved from the environment
|
|
10
|
+
* once so all columns share the same default, matching the behavior of the
|
|
11
|
+
* native `Intl` APIs these formatters replaced.
|
|
12
|
+
*/
|
|
13
|
+
const DEFAULT_LOCALE = new Intl.DateTimeFormat().resolvedOptions().locale;
|
|
14
|
+
function isEmpty(value) {
|
|
15
|
+
return value === null || value === undefined;
|
|
16
|
+
}
|
|
17
|
+
function isDateValue(value) {
|
|
18
|
+
return (typeof value === "object" &&
|
|
19
|
+
value !== null &&
|
|
20
|
+
"calendar" in value &&
|
|
21
|
+
typeof value.toDate === "function");
|
|
22
|
+
}
|
|
23
|
+
function toNumber(value) {
|
|
24
|
+
if (typeof value === "number")
|
|
25
|
+
return Number.isFinite(value) ? value : null;
|
|
26
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
27
|
+
const parsed = Number(value);
|
|
28
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
function toDate(value) {
|
|
33
|
+
let date = null;
|
|
34
|
+
if (value instanceof Date) {
|
|
35
|
+
date = value;
|
|
36
|
+
}
|
|
37
|
+
else if (isDateValue(value)) {
|
|
38
|
+
date =
|
|
39
|
+
"timeZone" in value ? value.toDate() : value.toDate($ad063034c8620db8$export$aa8b41735afcabd2());
|
|
40
|
+
}
|
|
41
|
+
else if (typeof value === "number") {
|
|
42
|
+
date = new Date(value);
|
|
43
|
+
}
|
|
44
|
+
else if (typeof value === "string") {
|
|
45
|
+
if (ISO_DATE_ONLY.test(value)) {
|
|
46
|
+
// Parse ISO date-only strings as local dates to avoid time-zone drift.
|
|
47
|
+
date = $58246871e4652552$export$6b862160d295c8e(value).toDate($ad063034c8620db8$export$aa8b41735afcabd2());
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
date = new Date(value);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return date && !Number.isNaN(date.getTime()) ? date : null;
|
|
54
|
+
}
|
|
55
|
+
const formatText = (value) => (isEmpty(value) ? "" : String(value));
|
|
56
|
+
/**
|
|
57
|
+
* The single source of truth for per-type behavior. To add a new column type:
|
|
58
|
+
* declare its literal + interface in `DataTableColumn.ts`, then add one entry
|
|
59
|
+
* here.
|
|
60
|
+
*/
|
|
61
|
+
const columnTypeDefinitions = {
|
|
62
|
+
boolean: {
|
|
63
|
+
createFormatter: (column) => {
|
|
64
|
+
const trueLabel = column.trueLabel ?? "Yes";
|
|
65
|
+
const falseLabel = column.falseLabel ?? "No";
|
|
66
|
+
return (value) => {
|
|
67
|
+
if (isEmpty(value))
|
|
68
|
+
return "";
|
|
69
|
+
// A truthy value shows a check icon labeled with `trueLabel`; a falsy
|
|
70
|
+
// value shows nothing but keeps `falseLabel` in the DOM as
|
|
71
|
+
// visually-hidden text so the meaning is available to assistive tech.
|
|
72
|
+
return value ? (React__default.createElement(Icon, { symbol: "general#check", role: "img", "aria-label": trueLabel })) : (React__default.createElement("span", { className: "tds-data-table-cell-label--hidden" }, falseLabel));
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
currency: {
|
|
77
|
+
align: "end",
|
|
78
|
+
createFormatter: (column) => {
|
|
79
|
+
// Currency support is in beta and hardwired to USD for now.
|
|
80
|
+
const formatter = new Intl.NumberFormat(undefined, {
|
|
81
|
+
...column.numberFormatOptions,
|
|
82
|
+
currency: "USD",
|
|
83
|
+
style: "currency",
|
|
84
|
+
});
|
|
85
|
+
return (value) => {
|
|
86
|
+
const num = toNumber(value);
|
|
87
|
+
return num === null ? "" : formatter.format(num);
|
|
88
|
+
};
|
|
89
|
+
},
|
|
90
|
+
isNumeric: true,
|
|
91
|
+
},
|
|
92
|
+
custom: {
|
|
93
|
+
createFormatter: () => formatText,
|
|
94
|
+
},
|
|
95
|
+
date: {
|
|
96
|
+
createFormatter: (column) => {
|
|
97
|
+
const formatter = new $12a3c853105e5a70$export$ad991b66133851cf(DEFAULT_LOCALE, column.dateFormatOptions ?? { dateStyle: "medium" });
|
|
98
|
+
return (value) => {
|
|
99
|
+
const date = toDate(value);
|
|
100
|
+
return date ? formatter.format(date) : "";
|
|
101
|
+
};
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
datetime: {
|
|
105
|
+
createFormatter: (column) => {
|
|
106
|
+
const formatter = new $12a3c853105e5a70$export$ad991b66133851cf(DEFAULT_LOCALE, column.dateFormatOptions ?? { dateStyle: "medium", timeStyle: "short" });
|
|
107
|
+
return (value) => {
|
|
108
|
+
const date = toDate(value);
|
|
109
|
+
return date ? formatter.format(date) : "";
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
enum: {
|
|
114
|
+
createFormatter: () => formatText,
|
|
115
|
+
},
|
|
116
|
+
number: {
|
|
117
|
+
align: "end",
|
|
118
|
+
createFormatter: (column) => {
|
|
119
|
+
const formatter = new Intl.NumberFormat(undefined, column.numberFormatOptions);
|
|
120
|
+
return (value) => {
|
|
121
|
+
const num = toNumber(value);
|
|
122
|
+
return num === null ? "" : formatter.format(num);
|
|
123
|
+
};
|
|
124
|
+
},
|
|
125
|
+
isNumeric: true,
|
|
126
|
+
},
|
|
127
|
+
string: {
|
|
128
|
+
createFormatter: () => formatText,
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
function resolveDefinition(column) {
|
|
132
|
+
// Fall back to the string definition if an unknown/undefined `type` slips
|
|
133
|
+
// through at runtime (e.g. untyped data); string formatting is always safe.
|
|
134
|
+
return (columnTypeDefinitions[column.type] ??
|
|
135
|
+
columnTypeDefinitions.string);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Turns a column into the everything-resolved shape the table renders from.
|
|
139
|
+
* This is the single place `render` and the type formatter are reconciled: a
|
|
140
|
+
* `render` prop and a value formatter both become one `renderCell(row)`, with
|
|
141
|
+
* `render` taking precedence. The type formatter is built at most once here
|
|
142
|
+
* (and only when there is no `render`), so callers should prepare each column
|
|
143
|
+
* once — `DataTable` does this in a `useMemo` keyed on the `columns` array, so
|
|
144
|
+
* pass a stable `columns` reference to avoid rebuilding formatters every render.
|
|
145
|
+
*/
|
|
146
|
+
function prepareColumn(column) {
|
|
147
|
+
const definition = resolveDefinition(column);
|
|
148
|
+
let renderCell;
|
|
149
|
+
if (column.render) {
|
|
150
|
+
renderCell = column.render;
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
// Localized cast: the registry is keyed by the same discriminant, but TS
|
|
154
|
+
// can't correlate the union member to its entry across the index.
|
|
155
|
+
const format = definition.createFormatter(column);
|
|
156
|
+
renderCell = (row) => format(row?.[column.name]);
|
|
157
|
+
}
|
|
158
|
+
return {
|
|
159
|
+
align: column.align ?? definition.align ?? "start",
|
|
160
|
+
column,
|
|
161
|
+
isNumeric: definition.isNumeric ?? false,
|
|
162
|
+
renderCell,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export { columnTypeDefinitions, isEmpty, prepareColumn };
|
|
167
|
+
//# sourceMappingURL=DataTableColumnTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataTableColumnTypes.js","sources":["../../../src/components/DataTable/DataTableColumnTypes.tsx"],"sourcesContent":["import {\n DateFormatter,\n type DateValue,\n getLocalTimeZone,\n parseDate,\n} from \"@internationalized/date\"\nimport Icon from \"@utilities/Icon\"\nimport React, { type ReactNode } from \"react\"\n\nimport type { DataTableColumn, DataTableColumnAlign } from \"./DataTableColumn\"\n\nconst ISO_DATE_ONLY = /^\\d{4}-\\d{2}-\\d{2}$/\n\n/**\n * Locale used to build every `DateFormatter`. Resolved from the environment\n * once so all columns share the same default, matching the behavior of the\n * native `Intl` APIs these formatters replaced.\n */\nconst DEFAULT_LOCALE = new Intl.DateTimeFormat().resolvedOptions().locale\n\n/** Formats a single cell value. Produced per column by the registry. */\nexport type Formatter = (value: unknown) => ReactNode\n\n/** Renders a cell from the whole row. The unified shape a prepared column exposes. */\nexport type CellRenderer = (row: unknown) => ReactNode\n\nexport function isEmpty(value: unknown): value is null | undefined {\n return value === null || value === undefined\n}\n\nfunction isDateValue(value: unknown): value is DateValue {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"calendar\" in value &&\n typeof (value as { toDate?: unknown }).toDate === \"function\"\n )\n}\n\nfunction toNumber(value: unknown): number | null {\n if (typeof value === \"number\") return Number.isFinite(value) ? value : null\n if (typeof value === \"string\" && value.trim() !== \"\") {\n const parsed = Number(value)\n return Number.isFinite(parsed) ? parsed : null\n }\n return null\n}\n\nfunction toDate(value: unknown): Date | null {\n let date: Date | null = null\n if (value instanceof Date) {\n date = value\n } else if (isDateValue(value)) {\n date =\n \"timeZone\" in value ? value.toDate() : value.toDate(getLocalTimeZone())\n } else if (typeof value === \"number\") {\n date = new Date(value)\n } else if (typeof value === \"string\") {\n if (ISO_DATE_ONLY.test(value)) {\n // Parse ISO date-only strings as local dates to avoid time-zone drift.\n date = parseDate(value).toDate(getLocalTimeZone())\n } else {\n date = new Date(value)\n }\n }\n return date && !Number.isNaN(date.getTime()) ? date : null\n}\n\n/**\n * Everything that varies per column `type`, co-located in one place: how the\n * column's values are formatted, its default alignment, and whether it counts\n * as numeric. Adding a column type is a single entry in\n * {@link columnTypeDefinitions} below.\n */\nexport interface ColumnTypeDefinition<C extends DataTableColumn> {\n /** Default alignment when the column doesn't set `align`. Omitted = \"start\". */\n align?: DataTableColumnAlign\n /**\n * Builds the per-column value formatter. Called once per column by\n * {@link prepareColumn}, so the `Intl`/`DateFormatter` instances it closes\n * over are constructed once per column rather than per render — provided the\n * consumer passes a stable `columns` reference (see `prepareColumn`).\n */\n createFormatter: (column: C) => Formatter\n /** Marks numeric types (drives the `--numeric` cell class). */\n isNumeric?: boolean\n}\n\n/**\n * Maps each column discriminant to a definition typed to that column's\n * interface, so `createFormatter` receives the correctly-narrowed column (e.g.\n * the `number` entry's `column` is `NumberColumn`). The mapped type also makes\n * a missing entry a compile error.\n */\ntype ColumnTypeRegistry = {\n [C in DataTableColumn as C[\"type\"]]: ColumnTypeDefinition<C>\n}\n\nconst formatText: Formatter = (value) => (isEmpty(value) ? \"\" : String(value))\n\n/**\n * The single source of truth for per-type behavior. To add a new column type:\n * declare its literal + interface in `DataTableColumn.ts`, then add one entry\n * here.\n */\nexport const columnTypeDefinitions: ColumnTypeRegistry = {\n boolean: {\n createFormatter: (column) => {\n const trueLabel = column.trueLabel ?? \"Yes\"\n const falseLabel = column.falseLabel ?? \"No\"\n return (value) => {\n if (isEmpty(value)) return \"\"\n // A truthy value shows a check icon labeled with `trueLabel`; a falsy\n // value shows nothing but keeps `falseLabel` in the DOM as\n // visually-hidden text so the meaning is available to assistive tech.\n return value ? (\n <Icon symbol=\"general#check\" role=\"img\" aria-label={trueLabel} />\n ) : (\n <span className=\"tds-data-table-cell-label--hidden\">\n {falseLabel}\n </span>\n )\n }\n },\n },\n currency: {\n align: \"end\",\n createFormatter: (column) => {\n // Currency support is in beta and hardwired to USD for now.\n const formatter = new Intl.NumberFormat(undefined, {\n ...column.numberFormatOptions,\n currency: \"USD\",\n style: \"currency\",\n })\n return (value) => {\n const num = toNumber(value)\n return num === null ? \"\" : formatter.format(num)\n }\n },\n isNumeric: true,\n },\n custom: {\n createFormatter: () => formatText,\n },\n date: {\n createFormatter: (column) => {\n const formatter = new DateFormatter(\n DEFAULT_LOCALE,\n column.dateFormatOptions ?? { dateStyle: \"medium\" }\n )\n return (value) => {\n const date = toDate(value)\n return date ? formatter.format(date) : \"\"\n }\n },\n },\n datetime: {\n createFormatter: (column) => {\n const formatter = new DateFormatter(\n DEFAULT_LOCALE,\n column.dateFormatOptions ?? { dateStyle: \"medium\", timeStyle: \"short\" }\n )\n return (value) => {\n const date = toDate(value)\n return date ? formatter.format(date) : \"\"\n }\n },\n },\n enum: {\n createFormatter: () => formatText,\n },\n number: {\n align: \"end\",\n createFormatter: (column) => {\n const formatter = new Intl.NumberFormat(\n undefined,\n column.numberFormatOptions\n )\n return (value) => {\n const num = toNumber(value)\n return num === null ? \"\" : formatter.format(num)\n }\n },\n isNumeric: true,\n },\n string: {\n createFormatter: () => formatText,\n },\n}\n\nfunction resolveDefinition(\n column: DataTableColumn\n): ColumnTypeDefinition<DataTableColumn> {\n // Fall back to the string definition if an unknown/undefined `type` slips\n // through at runtime (e.g. untyped data); string formatting is always safe.\n return (columnTypeDefinitions[column.type] ??\n columnTypeDefinitions.string) as ColumnTypeDefinition<DataTableColumn>\n}\n\n/** A column with everything the table needs to render its header and cells. */\nexport interface PreparedColumn {\n align: DataTableColumnAlign\n column: DataTableColumn\n isNumeric: boolean\n renderCell: CellRenderer\n}\n\n/**\n * Turns a column into the everything-resolved shape the table renders from.\n * This is the single place `render` and the type formatter are reconciled: a\n * `render` prop and a value formatter both become one `renderCell(row)`, with\n * `render` taking precedence. The type formatter is built at most once here\n * (and only when there is no `render`), so callers should prepare each column\n * once — `DataTable` does this in a `useMemo` keyed on the `columns` array, so\n * pass a stable `columns` reference to avoid rebuilding formatters every render.\n */\nexport function prepareColumn(column: DataTableColumn): PreparedColumn {\n const definition = resolveDefinition(column)\n let renderCell: CellRenderer\n if (column.render) {\n renderCell = column.render\n } else {\n // Localized cast: the registry is keyed by the same discriminant, but TS\n // can't correlate the union member to its entry across the index.\n const format = (\n definition.createFormatter as (c: DataTableColumn) => Formatter\n )(column)\n renderCell = (row) =>\n format((row as Record<string, unknown>)?.[column.name])\n }\n return {\n align: column.align ?? definition.align ?? \"start\",\n column,\n isNumeric: definition.isNumeric ?? false,\n renderCell,\n }\n}\n"],"names":["getLocalTimeZone","parseDate","React","DateFormatter"],"mappings":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,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK,IAAI,OAAO;QAClD,MAAM;AACN,QAAA,SAAS,EAAE,UAAU,CAAC,SAAS,IAAI,KAAK;QACxC,UAAU;KACX;AACH;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataTableRow.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/DataTableRow.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CACvB,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,MAAM,EACb,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,MAAM,GAAG,MAAM,GAC3C,MAAM,GAAG,MAAM,CAIjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataTableRow.js","sources":["../../../src/components/DataTable/DataTableRow.ts"],"sourcesContent":["export function getRowKey(\n row: unknown,\n index: number,\n getRowId?: (row: unknown) => number | string\n): number | string {\n if (getRowId) return getRowId(row)\n const id = (row as Record<string, unknown>)?.id\n return typeof id === \"number\" || typeof id === \"string\" ? id : index\n}\n"],"names":[],"mappings":"SAAgB,SAAS,CACvB,GAAY,EACZ,KAAa,EACb,QAA4C,EAAA;AAE5C,IAAA,IAAI,QAAQ;AAAE,QAAA,OAAO,QAAQ,CAAC,GAAG,CAAC;AAClC,IAAA,MAAM,EAAE,GAAI,GAA+B,EAAE,EAAE;AAC/C,IAAA,OAAO,OAAO,EAAE,KAAK,QAAQ,IAAI,OAAO,EAAE,KAAK,QAAQ,GAAG,EAAE,GAAG,KAAK;AACtE;;;;"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import "./index.css";
|
|
2
|
+
export type { DataTableElementProps, DataTableProps } from "./DataTable";
|
|
3
|
+
export { DataTable } from "./DataTable";
|
|
4
|
+
export type { BooleanColumn, CurrencyColumn, CustomColumn, DataTableColumn, DataTableColumnAlign, DataTableColumnType, DateColumn, DateTimeColumn, EnumColumn, NumberColumn, StringColumn, } from "./DataTableColumn";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,YAAY,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,YAAY,EACV,aAAa,EACb,cAAc,EACd,YAAY,EACZ,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,UAAU,EACV,cAAc,EACd,UAAU,EACV,YAAY,EACZ,YAAY,GACb,MAAM,mBAAmB,CAAA"}
|
|
@@ -91,7 +91,15 @@ export interface DropdownActionProps extends DropdownItemBaseProps {
|
|
|
91
91
|
* and focus tracking.
|
|
92
92
|
*/
|
|
93
93
|
id: Key;
|
|
94
|
-
/**
|
|
94
|
+
/**
|
|
95
|
+
* Callback fired when the item is activated.
|
|
96
|
+
*
|
|
97
|
+
* React Aria closes the menu and returns focus to the trigger after this
|
|
98
|
+
* runs, which can override a focus change made here — e.g. focusing a
|
|
99
|
+
* nearby input. If `onAction` needs to move focus elsewhere, wrap that
|
|
100
|
+
* part in `queueMicrotask` to defer it until after React Aria's
|
|
101
|
+
* focus-restore has finished: `queueMicrotask(() => inputRef.current?.focus())`.
|
|
102
|
+
*/
|
|
95
103
|
onAction: () => void;
|
|
96
104
|
}
|
|
97
105
|
type AriaActionPropsToOmit = "href" | "isDisabled" | "rel" | "routerOptions" | "target" | "value";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropdown.d.ts","sourceRoot":"","sources":["../../../src/components/dropdown/Dropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAA;AAEhF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