@salt-ds/data-grid 1.0.4-alpha.0 → 1.0.4-alpha.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-cjs/packages/grid/src/BaseCell.css.js +1 -1
- package/dist-cjs/packages/grid/src/BaseCell.js +35 -3
- package/dist-cjs/packages/grid/src/BaseCell.js.map +1 -1
- package/dist-cjs/packages/grid/src/ColumnSortContext.js +20 -0
- package/dist-cjs/packages/grid/src/ColumnSortContext.js.map +1 -0
- package/dist-cjs/packages/grid/src/Grid.js +208 -126
- package/dist-cjs/packages/grid/src/Grid.js.map +1 -1
- package/dist-cjs/packages/grid/src/GridColumn.js +1 -1
- package/dist-cjs/packages/grid/src/GridColumn.js.map +1 -1
- package/dist-cjs/packages/grid/src/HeaderCell.css.js +1 -1
- package/dist-cjs/packages/grid/src/HeaderCell.js +66 -2
- package/dist-cjs/packages/grid/src/HeaderCell.js.map +1 -1
- package/dist-cjs/packages/grid/src/RowSelectionCheckboxColumn.js +14 -7
- package/dist-cjs/packages/grid/src/RowSelectionCheckboxColumn.js.map +1 -1
- package/dist-cjs/packages/grid/src/RowSelectionRadioColumn.js +11 -7
- package/dist-cjs/packages/grid/src/RowSelectionRadioColumn.js.map +1 -1
- package/dist-cjs/packages/grid/src/RowValidationStatus.js +13 -0
- package/dist-cjs/packages/grid/src/RowValidationStatus.js.map +1 -0
- package/dist-cjs/packages/grid/src/index.js +1 -0
- package/dist-cjs/packages/grid/src/index.js.map +1 -1
- package/dist-cjs/packages/grid/src/internal/Cell.css.js +1 -1
- package/dist-cjs/packages/grid/src/internal/CellStatusIcons.js +46 -0
- package/dist-cjs/packages/grid/src/internal/CellStatusIcons.js.map +1 -0
- package/dist-cjs/packages/grid/src/internal/LeftPart.js +4 -2
- package/dist-cjs/packages/grid/src/internal/LeftPart.js.map +1 -1
- package/dist-cjs/packages/grid/src/internal/MiddlePart.js +4 -2
- package/dist-cjs/packages/grid/src/internal/MiddlePart.js.map +1 -1
- package/dist-cjs/packages/grid/src/internal/RightPart.js +4 -2
- package/dist-cjs/packages/grid/src/internal/RightPart.js.map +1 -1
- package/dist-cjs/packages/grid/src/internal/TableBody.js +11 -4
- package/dist-cjs/packages/grid/src/internal/TableBody.js.map +1 -1
- package/dist-cjs/packages/grid/src/internal/TableRow.css.js +1 -1
- package/dist-cjs/packages/grid/src/internal/TableRow.js +33 -12
- package/dist-cjs/packages/grid/src/internal/TableRow.js.map +1 -1
- package/dist-es/packages/grid/src/BaseCell.css.js +1 -1
- package/dist-es/packages/grid/src/BaseCell.js +35 -3
- package/dist-es/packages/grid/src/BaseCell.js.map +1 -1
- package/dist-es/packages/grid/src/ColumnSortContext.js +15 -0
- package/dist-es/packages/grid/src/ColumnSortContext.js.map +1 -0
- package/dist-es/packages/grid/src/Grid.js +208 -127
- package/dist-es/packages/grid/src/Grid.js.map +1 -1
- package/dist-es/packages/grid/src/GridColumn.js +1 -1
- package/dist-es/packages/grid/src/GridColumn.js.map +1 -1
- package/dist-es/packages/grid/src/HeaderCell.css.js +1 -1
- package/dist-es/packages/grid/src/HeaderCell.js +66 -2
- package/dist-es/packages/grid/src/HeaderCell.js.map +1 -1
- package/dist-es/packages/grid/src/RowSelectionCheckboxColumn.js +14 -7
- package/dist-es/packages/grid/src/RowSelectionCheckboxColumn.js.map +1 -1
- package/dist-es/packages/grid/src/RowSelectionRadioColumn.js +11 -7
- package/dist-es/packages/grid/src/RowSelectionRadioColumn.js.map +1 -1
- package/dist-es/packages/grid/src/RowValidationStatus.js +9 -0
- package/dist-es/packages/grid/src/RowValidationStatus.js.map +1 -0
- package/dist-es/packages/grid/src/index.js +1 -1
- package/dist-es/packages/grid/src/internal/Cell.css.js +1 -1
- package/dist-es/packages/grid/src/internal/CellStatusIcons.js +40 -0
- package/dist-es/packages/grid/src/internal/CellStatusIcons.js.map +1 -0
- package/dist-es/packages/grid/src/internal/LeftPart.js +4 -2
- package/dist-es/packages/grid/src/internal/LeftPart.js.map +1 -1
- package/dist-es/packages/grid/src/internal/MiddlePart.js +4 -2
- package/dist-es/packages/grid/src/internal/MiddlePart.js.map +1 -1
- package/dist-es/packages/grid/src/internal/RightPart.js +4 -2
- package/dist-es/packages/grid/src/internal/RightPart.js.map +1 -1
- package/dist-es/packages/grid/src/internal/TableBody.js +11 -4
- package/dist-es/packages/grid/src/internal/TableBody.js.map +1 -1
- package/dist-es/packages/grid/src/internal/TableRow.css.js +1 -1
- package/dist-es/packages/grid/src/internal/TableRow.js +33 -12
- package/dist-es/packages/grid/src/internal/TableRow.js.map +1 -1
- package/dist-es/packages/grid/src/internal/gridHooks.js +1 -1
- package/dist-types/ColumnSortContext.d.ts +12 -0
- package/dist-types/Grid.d.ts +7 -1
- package/dist-types/GridColumn.d.ts +54 -2
- package/dist-types/RowValidationStatus.d.ts +7 -0
- package/dist-types/internal/CellStatusIcons.d.ts +4 -0
- package/dist-types/internal/LeftPart.d.ts +2 -0
- package/dist-types/internal/MiddlePart.d.ts +2 -0
- package/dist-types/internal/RightPart.d.ts +2 -0
- package/dist-types/internal/TableBody.d.ts +2 -0
- package/dist-types/internal/TableRow.d.ts +2 -1
- package/package.json +4 -3
|
@@ -3,16 +3,20 @@ import { RowSelectionRadioCellValue } from './RowSelectionRadioCellValue.js';
|
|
|
3
3
|
import { GridColumn } from './GridColumn.js';
|
|
4
4
|
import { RowSelectionRadioHeaderCell } from './RowSelectionRadioHeaderCell.js';
|
|
5
5
|
import { useSelectionContext } from './SelectionContext.js';
|
|
6
|
+
import { useCallback } from 'react';
|
|
6
7
|
|
|
7
8
|
function RowSelectionRadioColumn(props) {
|
|
8
9
|
const { selectRows } = useSelectionContext();
|
|
9
|
-
const onKeyDown = (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
const onKeyDown = useCallback(
|
|
11
|
+
(event, rowIndex) => {
|
|
12
|
+
if (event.key === " ") {
|
|
13
|
+
selectRows({ rowIndex });
|
|
14
|
+
event.preventDefault();
|
|
15
|
+
event.stopPropagation();
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
[selectRows]
|
|
19
|
+
);
|
|
16
20
|
return /* @__PURE__ */ jsx(GridColumn, {
|
|
17
21
|
...props,
|
|
18
22
|
defaultWidth: 100,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RowSelectionRadioColumn.js","sources":["../src/RowSelectionRadioColumn.tsx"],"sourcesContent":["import { RowSelectionRadioCellValue } from \"./RowSelectionRadioCellValue\";\nimport { GridColumn, GridColumnProps } from \"./GridColumn\";\nimport { RowSelectionRadioHeaderCell } from \"./RowSelectionRadioHeaderCell\";\nimport { useSelectionContext } from \"./SelectionContext\";\nimport { KeyboardEvent } from \"react\";\n\nexport type RowSelectionRadioColumnProps<T> = Omit<\n GridColumnProps<T>,\n \"width\" | \"name\"\n>;\n\nexport function RowSelectionRadioColumn<T>(\n props: RowSelectionRadioColumnProps<T>\n) {\n const { selectRows } = useSelectionContext();\n\n const onKeyDown = (\n event: KeyboardEvent<HTMLDivElement
|
|
1
|
+
{"version":3,"file":"RowSelectionRadioColumn.js","sources":["../src/RowSelectionRadioColumn.tsx"],"sourcesContent":["import { RowSelectionRadioCellValue } from \"./RowSelectionRadioCellValue\";\nimport { GridColumn, GridColumnProps } from \"./GridColumn\";\nimport { RowSelectionRadioHeaderCell } from \"./RowSelectionRadioHeaderCell\";\nimport { useSelectionContext } from \"./SelectionContext\";\nimport { KeyboardEvent, useCallback } from \"react\";\n\nexport type RowSelectionRadioColumnProps<T> = Omit<\n GridColumnProps<T>,\n \"width\" | \"name\"\n>;\n\nexport function RowSelectionRadioColumn<T>(\n props: RowSelectionRadioColumnProps<T>\n) {\n const { selectRows } = useSelectionContext();\n\n const onKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>, rowIndex: number) => {\n if (event.key === \" \") {\n selectRows({ rowIndex });\n event.preventDefault();\n event.stopPropagation();\n }\n },\n [selectRows]\n );\n\n return (\n <GridColumn\n {...props}\n defaultWidth={100}\n headerComponent={RowSelectionRadioHeaderCell}\n cellValueComponent={RowSelectionRadioCellValue}\n onKeyDown={onKeyDown}\n />\n );\n}\n"],"names":[],"mappings":";;;;;;;AAWO,SAAS,wBACd,KACA,EAAA;AACA,EAAM,MAAA,EAAE,UAAW,EAAA,GAAI,mBAAoB,EAAA,CAAA;AAE3C,EAAA,MAAM,SAAY,GAAA,WAAA;AAAA,IAChB,CAAC,OAAsC,QAAqB,KAAA;AAC1D,MAAI,IAAA,KAAA,CAAM,QAAQ,GAAK,EAAA;AACrB,QAAW,UAAA,CAAA,EAAE,UAAU,CAAA,CAAA;AACvB,QAAA,KAAA,CAAM,cAAe,EAAA,CAAA;AACrB,QAAA,KAAA,CAAM,eAAgB,EAAA,CAAA;AAAA,OACxB;AAAA,KACF;AAAA,IACA,CAAC,UAAU,CAAA;AAAA,GACb,CAAA;AAEA,EAAA,uBACG,GAAA,CAAA,UAAA,EAAA;AAAA,IACE,GAAG,KAAA;AAAA,IACJ,YAAc,EAAA,GAAA;AAAA,IACd,eAAiB,EAAA,2BAAA;AAAA,IACjB,kBAAoB,EAAA,0BAAA;AAAA,IACpB,SAAA;AAAA,GACF,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import 'react/jsx-runtime';
|
|
2
|
+
import '@salt-ds/core';
|
|
3
|
+
import { createContext } from 'react';
|
|
4
|
+
import './GridContext.js';
|
|
5
|
+
|
|
6
|
+
const RowValidationStatusContext = createContext({});
|
|
7
|
+
|
|
8
|
+
export { RowValidationStatusContext };
|
|
9
|
+
//# sourceMappingURL=RowValidationStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RowValidationStatus.js","sources":["../src/RowValidationStatus.tsx"],"sourcesContent":["import { StatusIndicator } from \"@salt-ds/core\";\nimport { createContext, useContext } from \"react\";\nimport { CellValidationState, GridColumn, GridColumnProps } from \"./GridColumn\";\n\nexport const RowValidationStatusContext = createContext<{\n status?: CellValidationState;\n}>({});\n\nexport type RowValidationStatusColumnProps<T> = Omit<\n GridColumnProps<T>,\n \"width\" | \"name\"\n>;\n\nexport function RowValidationStatusColumn<T>(\n props: RowValidationStatusColumnProps<T>\n) {\n return (\n <GridColumn\n aria-label=\"Row status\"\n defaultWidth={30}\n cellValueComponent={RowValidationCell}\n {...props}\n />\n );\n}\n\nconst knownStatus = new Set([\"error\", \"warning\", \"success\"]);\n\nfunction RowValidationCell() {\n const rowValidationContext = useContext(RowValidationStatusContext);\n if (\n !rowValidationContext?.status ||\n !knownStatus.has(rowValidationContext.status)\n )\n return null;\n\n const validationStatus = rowValidationContext.status;\n\n return (\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n height: \"100%\",\n width: \"100%\",\n }}\n >\n <StatusIndicator\n aria-label={`Row ${validationStatus}`}\n status={validationStatus}\n />\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;AAIa,MAAA,0BAAA,GAA6B,aAEvC,CAAA,EAAE;;;;"}
|
|
@@ -12,7 +12,7 @@ export { RowSelectionCheckboxCellValue } from './RowSelectionCheckboxCellValue.j
|
|
|
12
12
|
export { RowSelectionRadioColumn } from './RowSelectionRadioColumn.js';
|
|
13
13
|
export { SelectionContext, useSelectionContext } from './SelectionContext.js';
|
|
14
14
|
export { SizingContext, useSizingContext } from './SizingContext.js';
|
|
15
|
-
export { Grid } from './Grid.js';
|
|
15
|
+
export { Grid, SortOrder } from './Grid.js';
|
|
16
16
|
export { GridColumn } from './GridColumn.js';
|
|
17
17
|
export { GridContext, useGridContext } from './GridContext.js';
|
|
18
18
|
export { RowSelectionCheckboxColumn } from './RowSelectionCheckboxColumn.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import styleInject from '../../../../node_modules/style-inject/dist/style-inject.es.js';
|
|
2
2
|
|
|
3
|
-
var css_248z = ".saltGridCell {\n box-sizing: border-box;\n
|
|
3
|
+
var css_248z = ".saltGridCell {\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n\n white-space: nowrap;\n position: relative;\n font-size: var(--grid-fontSize);\n font-weight: normal;\n\n outline: 0;\n}\n\n.saltGridCell-selected {\n background: var(--grid-cell-background-selected);\n}\n\n.saltGridCell-rowSeparator {\n position: absolute;\n right: 0;\n bottom: 0;\n left: 0;\n height: 1px;\n background-color: var(--grid-row-borderColor);\n}\n\n.saltGridCell-topSeparator {\n position: absolute;\n top: 0;\n right: 0;\n left: 0;\n height: 1px;\n background-color: transparent;\n display: none;\n}\n\n.saltGridTableRow-first .saltGridCell-topSeparator {\n display: unset;\n}\n\n.saltGridCell-columnSeparator {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n width: 1px;\n background-color: var(--grid-row-background);\n}\n\n.saltGrid-columnSeparators .saltGridCell-regularSeparator .saltGridCell-columnSeparator {\n background-color: var(--grid-columnSeparator-color);\n}\n\n.saltGrid-columnSeparators .saltGridCell-pinnedSeparator .saltGridCell-columnSeparator {\n background-color: var(--grid-columnSeparator-color);\n}\n\n.saltGrid-pinnedSeparators .saltGridCell-pinnedSeparator .saltGridCell-columnSeparator {\n background-color: var(--grid-pinnedSeparator-color);\n}\n\n.saltGridTableRow-selected.saltGridTableRow-first .saltGridCell-topSeparator {\n background-color: var(--grid-row-borderColor);\n}\n\n.saltGridCell-body {\n box-sizing: border-box;\n position: absolute;\n top: 0;\n right: 0;\n bottom: 1px;\n left: 0;\n background: var(--grid-row-background);\n border-right: solid 1px transparent;\n}\n\n.saltGridTableRow-first .saltGridCell-body {\n top: 1px;\n}\n";
|
|
4
4
|
styleInject(css_248z);
|
|
5
5
|
|
|
6
6
|
export { css_248z as default };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
const CellWarningIcon = /* @__PURE__ */ jsx("svg", {
|
|
4
|
+
"aria-hidden": true,
|
|
5
|
+
height: "1em",
|
|
6
|
+
viewBox: "0 0 10 8",
|
|
7
|
+
fill: "none",
|
|
8
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
9
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
10
|
+
d: "M4.6188 0L9.2376 8H0L4.6188 0Z"
|
|
11
|
+
})
|
|
12
|
+
});
|
|
13
|
+
const CellErrorIcon = /* @__PURE__ */ jsx("svg", {
|
|
14
|
+
"aria-hidden": true,
|
|
15
|
+
width: "1em",
|
|
16
|
+
height: "1em",
|
|
17
|
+
viewBox: "0 0 8 8",
|
|
18
|
+
fill: "none",
|
|
19
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
20
|
+
children: /* @__PURE__ */ jsx("circle", {
|
|
21
|
+
cx: "4",
|
|
22
|
+
cy: "4",
|
|
23
|
+
r: "4"
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
const CellSuccessIcon = /* @__PURE__ */ jsx("svg", {
|
|
27
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
28
|
+
width: "1em",
|
|
29
|
+
viewBox: "0 0 14 14",
|
|
30
|
+
fill: "none",
|
|
31
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
32
|
+
fillRule: "evenodd",
|
|
33
|
+
clipRule: "evenodd",
|
|
34
|
+
d: "M13.7668 2.63645L5.06034 12.0309L0.277532 7.56074L1.47248 6.28223L4.97136 9.55242L12.4832 1.4469L13.7668 2.63645Z",
|
|
35
|
+
fill: "#24874B"
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export { CellErrorIcon, CellSuccessIcon, CellWarningIcon };
|
|
40
|
+
//# sourceMappingURL=CellStatusIcons.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CellStatusIcons.js","sources":["../src/internal/CellStatusIcons.tsx"],"sourcesContent":["export const CellWarningIcon = (\n <svg\n aria-hidden\n height=\"1em\"\n viewBox=\"0 0 10 8\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path d=\"M4.6188 0L9.2376 8H0L4.6188 0Z\" />\n </svg>\n);\n\nexport const CellErrorIcon = (\n <svg\n aria-hidden\n width=\"1em\"\n height=\"1em\"\n viewBox=\"0 0 8 8\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <circle cx=\"4\" cy=\"4\" r=\"4\" />\n </svg>\n);\n\nexport const CellSuccessIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"1em\"\n viewBox=\"0 0 14 14\"\n fill=\"none\"\n >\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M13.7668 2.63645L5.06034 12.0309L0.277532 7.56074L1.47248 6.28223L4.97136 9.55242L12.4832 1.4469L13.7668 2.63645Z\"\n fill=\"#24874B\"\n />\n </svg>\n);\n"],"names":[],"mappings":";;AAAO,MAAM,kCACV,GAAA,CAAA,KAAA,EAAA;AAAA,EACC,aAAW,EAAA,IAAA;AAAA,EACX,MAAO,EAAA,KAAA;AAAA,EACP,OAAQ,EAAA,UAAA;AAAA,EACR,IAAK,EAAA,MAAA;AAAA,EACL,KAAM,EAAA,4BAAA;AAAA,EAEN,QAAC,kBAAA,GAAA,CAAA,MAAA,EAAA;AAAA,IAAK,CAAE,EAAA,gCAAA;AAAA,GAAiC,CAAA;AAAA,CAC3C,EAAA;AAGK,MAAM,gCACV,GAAA,CAAA,KAAA,EAAA;AAAA,EACC,aAAW,EAAA,IAAA;AAAA,EACX,KAAM,EAAA,KAAA;AAAA,EACN,MAAO,EAAA,KAAA;AAAA,EACP,OAAQ,EAAA,SAAA;AAAA,EACR,IAAK,EAAA,MAAA;AAAA,EACL,KAAM,EAAA,4BAAA;AAAA,EAEN,QAAC,kBAAA,GAAA,CAAA,QAAA,EAAA;AAAA,IAAO,EAAG,EAAA,GAAA;AAAA,IAAI,EAAG,EAAA,GAAA;AAAA,IAAI,CAAE,EAAA,GAAA;AAAA,GAAI,CAAA;AAAA,CAC9B,EAAA;AAGK,MAAM,kCACV,GAAA,CAAA,KAAA,EAAA;AAAA,EACC,KAAM,EAAA,4BAAA;AAAA,EACN,KAAM,EAAA,KAAA;AAAA,EACN,OAAQ,EAAA,WAAA;AAAA,EACR,IAAK,EAAA,MAAA;AAAA,EAEL,QAAC,kBAAA,GAAA,CAAA,MAAA,EAAA;AAAA,IACC,QAAS,EAAA,SAAA;AAAA,IACT,QAAS,EAAA,SAAA;AAAA,IACT,CAAE,EAAA,mHAAA;AAAA,IACF,IAAK,EAAA,SAAA;AAAA,GACP,CAAA;AAAA,CACF;;;;"}
|
|
@@ -16,7 +16,8 @@ function LeftPart(props) {
|
|
|
16
16
|
rows,
|
|
17
17
|
hoverOverRowKey,
|
|
18
18
|
setHoverOverRowKey,
|
|
19
|
-
zebra
|
|
19
|
+
zebra,
|
|
20
|
+
getRowValidationStatus
|
|
20
21
|
} = props;
|
|
21
22
|
const tableRef = useActiveOnWheel(onWheel);
|
|
22
23
|
if (columns.length === 0) {
|
|
@@ -42,7 +43,8 @@ function LeftPart(props) {
|
|
|
42
43
|
rows,
|
|
43
44
|
hoverRowKey: hoverOverRowKey,
|
|
44
45
|
setHoverRowKey: setHoverOverRowKey,
|
|
45
|
-
zebra
|
|
46
|
+
zebra,
|
|
47
|
+
getRowValidationStatus
|
|
46
48
|
})
|
|
47
49
|
]
|
|
48
50
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LeftPart.js","sources":["../src/internal/LeftPart.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport { TableColGroup } from \"./TableColGroup\";\nimport { TableBody } from \"./TableBody\";\nimport { RefObject } from \"react\";\nimport \"./LeftPart.css\";\nimport { makePrefixer } from \"@salt-ds/core\";\nimport { GridColumnModel, GridRowModel } from \"../Grid\";\nimport { useActiveOnWheel } from \"./gridHooks\";\n\nconst withBaseName = makePrefixer(\"saltGridLeftPart\");\n\nexport interface LeftPartProps<T> {\n leftRef: RefObject<HTMLDivElement>;\n onWheel: EventListener;\n rightShadow?: boolean;\n columns: GridColumnModel<T>[];\n rows: GridRowModel<T>[];\n hoverOverRowKey?: string;\n setHoverOverRowKey: (key: string | undefined) => void;\n zebra?: boolean;\n}\n\nexport function LeftPart<T>(props: LeftPartProps<T>) {\n const {\n leftRef,\n onWheel,\n rightShadow,\n columns,\n rows,\n hoverOverRowKey,\n setHoverOverRowKey,\n zebra,\n } = props;\n\n const tableRef = useActiveOnWheel(onWheel);\n\n if (columns.length === 0) {\n return null;\n }\n\n return (\n <div\n ref={leftRef}\n className={clsx(withBaseName(), {\n [withBaseName(\"rightShadow\")]: rightShadow,\n })}\n >\n <div className={withBaseName(\"space\")} data-testid=\"grid-left-part\">\n <table ref={tableRef} role=\"presentation\">\n <TableColGroup columns={columns} />\n <TableBody\n columns={columns}\n rows={rows}\n hoverRowKey={hoverOverRowKey}\n setHoverRowKey={setHoverOverRowKey}\n zebra={zebra}\n />\n </table>\n </div>\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"LeftPart.js","sources":["../src/internal/LeftPart.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport { TableColGroup } from \"./TableColGroup\";\nimport { TableBody } from \"./TableBody\";\nimport { RefObject } from \"react\";\nimport \"./LeftPart.css\";\nimport { makePrefixer } from \"@salt-ds/core\";\nimport { GridColumnModel, GridRowModel } from \"../Grid\";\nimport { useActiveOnWheel } from \"./gridHooks\";\nimport { CellValidationState } from \"../GridColumn\";\n\nconst withBaseName = makePrefixer(\"saltGridLeftPart\");\n\nexport interface LeftPartProps<T> {\n leftRef: RefObject<HTMLDivElement>;\n onWheel: EventListener;\n rightShadow?: boolean;\n columns: GridColumnModel<T>[];\n rows: GridRowModel<T>[];\n hoverOverRowKey?: string;\n setHoverOverRowKey: (key: string | undefined) => void;\n zebra?: boolean;\n getRowValidationStatus?: (\n row: GridRowModel<T>\n ) => CellValidationState | undefined;\n}\n\nexport function LeftPart<T>(props: LeftPartProps<T>) {\n const {\n leftRef,\n onWheel,\n rightShadow,\n columns,\n rows,\n hoverOverRowKey,\n setHoverOverRowKey,\n zebra,\n getRowValidationStatus,\n } = props;\n\n const tableRef = useActiveOnWheel(onWheel);\n\n if (columns.length === 0) {\n return null;\n }\n\n return (\n <div\n ref={leftRef}\n className={clsx(withBaseName(), {\n [withBaseName(\"rightShadow\")]: rightShadow,\n })}\n >\n <div className={withBaseName(\"space\")} data-testid=\"grid-left-part\">\n <table ref={tableRef} role=\"presentation\">\n <TableColGroup columns={columns} />\n <TableBody\n columns={columns}\n rows={rows}\n hoverRowKey={hoverOverRowKey}\n setHoverRowKey={setHoverOverRowKey}\n zebra={zebra}\n getRowValidationStatus={getRowValidationStatus}\n />\n </table>\n </div>\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;;;;AAUA,MAAM,YAAA,GAAe,aAAa,kBAAkB,CAAA,CAAA;AAgB7C,SAAS,SAAY,KAAyB,EAAA;AACnD,EAAM,MAAA;AAAA,IACJ,OAAA;AAAA,IACA,OAAA;AAAA,IACA,WAAA;AAAA,IACA,OAAA;AAAA,IACA,IAAA;AAAA,IACA,eAAA;AAAA,IACA,kBAAA;AAAA,IACA,KAAA;AAAA,IACA,sBAAA;AAAA,GACE,GAAA,KAAA,CAAA;AAEJ,EAAM,MAAA,QAAA,GAAW,iBAAiB,OAAO,CAAA,CAAA;AAEzC,EAAI,IAAA,OAAA,CAAQ,WAAW,CAAG,EAAA;AACxB,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAEA,EAAA,uBACG,GAAA,CAAA,KAAA,EAAA;AAAA,IACC,GAAK,EAAA,OAAA;AAAA,IACL,SAAA,EAAW,IAAK,CAAA,YAAA,EAAgB,EAAA;AAAA,MAC9B,CAAC,YAAa,CAAA,aAAa,CAAI,GAAA,WAAA;AAAA,KAChC,CAAA;AAAA,IAED,QAAC,kBAAA,GAAA,CAAA,KAAA,EAAA;AAAA,MAAI,SAAA,EAAW,aAAa,OAAO,CAAA;AAAA,MAAG,aAAY,EAAA,gBAAA;AAAA,MACjD,QAAC,kBAAA,IAAA,CAAA,OAAA,EAAA;AAAA,QAAM,GAAK,EAAA,QAAA;AAAA,QAAU,IAAK,EAAA,cAAA;AAAA,QACzB,QAAA,EAAA;AAAA,0BAAC,GAAA,CAAA,aAAA,EAAA;AAAA,YAAc,OAAA;AAAA,WAAkB,CAAA;AAAA,0BAChC,GAAA,CAAA,SAAA,EAAA;AAAA,YACC,OAAA;AAAA,YACA,IAAA;AAAA,YACA,WAAa,EAAA,eAAA;AAAA,YACb,cAAgB,EAAA,kBAAA;AAAA,YAChB,KAAA;AAAA,YACA,sBAAA;AAAA,WACF,CAAA;AAAA,SAAA;AAAA,OACF,CAAA;AAAA,KACF,CAAA;AAAA,GACF,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -15,7 +15,8 @@ function MiddlePart(props) {
|
|
|
15
15
|
hoverOverRowKey,
|
|
16
16
|
setHoverOverRowKey,
|
|
17
17
|
midGap,
|
|
18
|
-
zebra
|
|
18
|
+
zebra,
|
|
19
|
+
getRowValidationStatus
|
|
19
20
|
} = props;
|
|
20
21
|
const tableRef = useActiveOnWheel(onWheel);
|
|
21
22
|
return /* @__PURE__ */ jsx("div", {
|
|
@@ -38,7 +39,8 @@ function MiddlePart(props) {
|
|
|
38
39
|
hoverRowKey: hoverOverRowKey,
|
|
39
40
|
setHoverRowKey: setHoverOverRowKey,
|
|
40
41
|
gap: midGap,
|
|
41
|
-
zebra
|
|
42
|
+
zebra,
|
|
43
|
+
getRowValidationStatus
|
|
42
44
|
})
|
|
43
45
|
]
|
|
44
46
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MiddlePart.js","sources":["../src/internal/MiddlePart.tsx"],"sourcesContent":["import { RefObject } from \"react\";\nimport { TableColGroup } from \"./TableColGroup\";\nimport { TableBody } from \"./TableBody\";\nimport \"./MiddlePart.css\";\nimport { makePrefixer } from \"@salt-ds/core\";\nimport { GridColumnModel, GridRowModel } from \"../Grid\";\nimport { useActiveOnWheel } from \"./gridHooks\";\n\nconst withBaseName = makePrefixer(\"saltGridMiddlePart\");\n\nexport interface MiddlePartProps<T> {\n middleRef: RefObject<HTMLDivElement>;\n onWheel: EventListener;\n columns: GridColumnModel<T>[];\n rows: GridRowModel<T>[];\n hoverOverRowKey?: string;\n setHoverOverRowKey: (key: string | undefined) => void;\n midGap: number;\n zebra?: boolean;\n}\n\nexport function MiddlePart<T>(props: MiddlePartProps<T>) {\n const {\n middleRef,\n onWheel,\n columns,\n rows,\n hoverOverRowKey,\n setHoverOverRowKey,\n midGap,\n zebra,\n } = props;\n\n const tableRef = useActiveOnWheel(onWheel);\n\n return (\n <div\n ref={middleRef}\n className={withBaseName()}\n data-testid=\"grid-middle-part\"\n >\n <div className={withBaseName(\"space\")}>\n <table ref={tableRef} role=\"presentation\">\n <TableColGroup columns={columns} gap={midGap} />\n <TableBody\n columns={columns}\n rows={rows}\n hoverRowKey={hoverOverRowKey}\n setHoverRowKey={setHoverOverRowKey}\n gap={midGap}\n zebra={zebra}\n />\n </table>\n </div>\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"MiddlePart.js","sources":["../src/internal/MiddlePart.tsx"],"sourcesContent":["import { RefObject } from \"react\";\nimport { TableColGroup } from \"./TableColGroup\";\nimport { TableBody } from \"./TableBody\";\nimport \"./MiddlePart.css\";\nimport { makePrefixer } from \"@salt-ds/core\";\nimport { GridColumnModel, GridRowModel } from \"../Grid\";\nimport { useActiveOnWheel } from \"./gridHooks\";\nimport { CellValidationState } from \"../GridColumn\";\n\nconst withBaseName = makePrefixer(\"saltGridMiddlePart\");\n\nexport interface MiddlePartProps<T> {\n middleRef: RefObject<HTMLDivElement>;\n onWheel: EventListener;\n columns: GridColumnModel<T>[];\n rows: GridRowModel<T>[];\n hoverOverRowKey?: string;\n setHoverOverRowKey: (key: string | undefined) => void;\n midGap: number;\n zebra?: boolean;\n getRowValidationStatus?: (\n row: GridRowModel<T>\n ) => CellValidationState | undefined;\n}\n\nexport function MiddlePart<T>(props: MiddlePartProps<T>) {\n const {\n middleRef,\n onWheel,\n columns,\n rows,\n hoverOverRowKey,\n setHoverOverRowKey,\n midGap,\n zebra,\n getRowValidationStatus,\n } = props;\n\n const tableRef = useActiveOnWheel(onWheel);\n\n return (\n <div\n ref={middleRef}\n className={withBaseName()}\n data-testid=\"grid-middle-part\"\n >\n <div className={withBaseName(\"space\")}>\n <table ref={tableRef} role=\"presentation\">\n <TableColGroup columns={columns} gap={midGap} />\n <TableBody\n columns={columns}\n rows={rows}\n hoverRowKey={hoverOverRowKey}\n setHoverRowKey={setHoverOverRowKey}\n gap={midGap}\n zebra={zebra}\n getRowValidationStatus={getRowValidationStatus}\n />\n </table>\n </div>\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;;;AASA,MAAM,YAAA,GAAe,aAAa,oBAAoB,CAAA,CAAA;AAgB/C,SAAS,WAAc,KAA2B,EAAA;AACvD,EAAM,MAAA;AAAA,IACJ,SAAA;AAAA,IACA,OAAA;AAAA,IACA,OAAA;AAAA,IACA,IAAA;AAAA,IACA,eAAA;AAAA,IACA,kBAAA;AAAA,IACA,MAAA;AAAA,IACA,KAAA;AAAA,IACA,sBAAA;AAAA,GACE,GAAA,KAAA,CAAA;AAEJ,EAAM,MAAA,QAAA,GAAW,iBAAiB,OAAO,CAAA,CAAA;AAEzC,EAAA,uBACG,GAAA,CAAA,KAAA,EAAA;AAAA,IACC,GAAK,EAAA,SAAA;AAAA,IACL,WAAW,YAAa,EAAA;AAAA,IACxB,aAAY,EAAA,kBAAA;AAAA,IAEZ,QAAC,kBAAA,GAAA,CAAA,KAAA,EAAA;AAAA,MAAI,SAAA,EAAW,aAAa,OAAO,CAAA;AAAA,MAClC,QAAC,kBAAA,IAAA,CAAA,OAAA,EAAA;AAAA,QAAM,GAAK,EAAA,QAAA;AAAA,QAAU,IAAK,EAAA,cAAA;AAAA,QACzB,QAAA,EAAA;AAAA,0BAAC,GAAA,CAAA,aAAA,EAAA;AAAA,YAAc,OAAA;AAAA,YAAkB,GAAK,EAAA,MAAA;AAAA,WAAQ,CAAA;AAAA,0BAC7C,GAAA,CAAA,SAAA,EAAA;AAAA,YACC,OAAA;AAAA,YACA,IAAA;AAAA,YACA,WAAa,EAAA,eAAA;AAAA,YACb,cAAgB,EAAA,kBAAA;AAAA,YAChB,GAAK,EAAA,MAAA;AAAA,YACL,KAAA;AAAA,YACA,sBAAA;AAAA,WACF,CAAA;AAAA,SAAA;AAAA,OACF,CAAA;AAAA,KACF,CAAA;AAAA,GACF,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -16,7 +16,8 @@ function RightPart(props) {
|
|
|
16
16
|
rows,
|
|
17
17
|
hoverOverRowKey,
|
|
18
18
|
setHoverOverRowKey,
|
|
19
|
-
zebra
|
|
19
|
+
zebra,
|
|
20
|
+
getRowValidationStatus
|
|
20
21
|
} = props;
|
|
21
22
|
const tableRef = useActiveOnWheel(onWheel);
|
|
22
23
|
if (columns.length === 0) {
|
|
@@ -42,7 +43,8 @@ function RightPart(props) {
|
|
|
42
43
|
rows,
|
|
43
44
|
hoverRowKey: hoverOverRowKey,
|
|
44
45
|
setHoverRowKey: setHoverOverRowKey,
|
|
45
|
-
zebra
|
|
46
|
+
zebra,
|
|
47
|
+
getRowValidationStatus
|
|
46
48
|
})
|
|
47
49
|
]
|
|
48
50
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RightPart.js","sources":["../src/internal/RightPart.tsx"],"sourcesContent":["import { RefObject } from \"react\";\nimport { clsx } from \"clsx\";\nimport { TableColGroup } from \"./TableColGroup\";\nimport { TableBody } from \"./TableBody\";\nimport \"./RightPart.css\";\nimport { makePrefixer } from \"@salt-ds/core\";\nimport { GridColumnModel, GridRowModel } from \"../Grid\";\nimport { useActiveOnWheel } from \"./gridHooks\";\n\nconst withBaseName = makePrefixer(\"saltGridRightPart\");\n\nexport interface RightPartProps<T> {\n rightRef: RefObject<HTMLDivElement>;\n onWheel: EventListener;\n leftShadow?: boolean;\n columns: GridColumnModel<T>[];\n rows: GridRowModel<T>[];\n hoverOverRowKey?: string;\n setHoverOverRowKey: (key: string | undefined) => void;\n zebra?: boolean;\n}\n\nexport function RightPart<T>(props: RightPartProps<T>) {\n const {\n rightRef,\n onWheel,\n columns,\n leftShadow,\n rows,\n hoverOverRowKey,\n setHoverOverRowKey,\n zebra,\n } = props;\n\n const tableRef = useActiveOnWheel(onWheel);\n\n if (columns.length === 0) {\n return null;\n }\n\n return (\n <div\n ref={rightRef}\n className={clsx(withBaseName(), {\n [withBaseName(\"leftShadow\")]: leftShadow,\n })}\n data-testid=\"grid-right-part\"\n >\n <div className={withBaseName(\"space\")}>\n <table ref={tableRef} role=\"presentation\">\n <TableColGroup columns={columns} />\n <TableBody\n columns={columns}\n rows={rows}\n hoverRowKey={hoverOverRowKey}\n setHoverRowKey={setHoverOverRowKey}\n zebra={zebra}\n />\n </table>\n </div>\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"RightPart.js","sources":["../src/internal/RightPart.tsx"],"sourcesContent":["import { RefObject } from \"react\";\nimport { clsx } from \"clsx\";\nimport { TableColGroup } from \"./TableColGroup\";\nimport { TableBody } from \"./TableBody\";\nimport \"./RightPart.css\";\nimport { makePrefixer } from \"@salt-ds/core\";\nimport { GridColumnModel, GridRowModel } from \"../Grid\";\nimport { useActiveOnWheel } from \"./gridHooks\";\nimport { CellValidationState } from \"../GridColumn\";\n\nconst withBaseName = makePrefixer(\"saltGridRightPart\");\n\nexport interface RightPartProps<T> {\n rightRef: RefObject<HTMLDivElement>;\n onWheel: EventListener;\n leftShadow?: boolean;\n columns: GridColumnModel<T>[];\n rows: GridRowModel<T>[];\n hoverOverRowKey?: string;\n setHoverOverRowKey: (key: string | undefined) => void;\n zebra?: boolean;\n getRowValidationStatus?: (\n row: GridRowModel<T>\n ) => CellValidationState | undefined;\n}\n\nexport function RightPart<T>(props: RightPartProps<T>) {\n const {\n rightRef,\n onWheel,\n columns,\n leftShadow,\n rows,\n hoverOverRowKey,\n setHoverOverRowKey,\n zebra,\n getRowValidationStatus,\n } = props;\n\n const tableRef = useActiveOnWheel(onWheel);\n\n if (columns.length === 0) {\n return null;\n }\n\n return (\n <div\n ref={rightRef}\n className={clsx(withBaseName(), {\n [withBaseName(\"leftShadow\")]: leftShadow,\n })}\n data-testid=\"grid-right-part\"\n >\n <div className={withBaseName(\"space\")}>\n <table ref={tableRef} role=\"presentation\">\n <TableColGroup columns={columns} />\n <TableBody\n columns={columns}\n rows={rows}\n hoverRowKey={hoverOverRowKey}\n setHoverRowKey={setHoverOverRowKey}\n zebra={zebra}\n getRowValidationStatus={getRowValidationStatus}\n />\n </table>\n </div>\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;;;;AAUA,MAAM,YAAA,GAAe,aAAa,mBAAmB,CAAA,CAAA;AAgB9C,SAAS,UAAa,KAA0B,EAAA;AACrD,EAAM,MAAA;AAAA,IACJ,QAAA;AAAA,IACA,OAAA;AAAA,IACA,OAAA;AAAA,IACA,UAAA;AAAA,IACA,IAAA;AAAA,IACA,eAAA;AAAA,IACA,kBAAA;AAAA,IACA,KAAA;AAAA,IACA,sBAAA;AAAA,GACE,GAAA,KAAA,CAAA;AAEJ,EAAM,MAAA,QAAA,GAAW,iBAAiB,OAAO,CAAA,CAAA;AAEzC,EAAI,IAAA,OAAA,CAAQ,WAAW,CAAG,EAAA;AACxB,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAEA,EAAA,uBACG,GAAA,CAAA,KAAA,EAAA;AAAA,IACC,GAAK,EAAA,QAAA;AAAA,IACL,SAAA,EAAW,IAAK,CAAA,YAAA,EAAgB,EAAA;AAAA,MAC9B,CAAC,YAAa,CAAA,YAAY,CAAI,GAAA,UAAA;AAAA,KAC/B,CAAA;AAAA,IACD,aAAY,EAAA,iBAAA;AAAA,IAEZ,QAAC,kBAAA,GAAA,CAAA,KAAA,EAAA;AAAA,MAAI,SAAA,EAAW,aAAa,OAAO,CAAA;AAAA,MAClC,QAAC,kBAAA,IAAA,CAAA,OAAA,EAAA;AAAA,QAAM,GAAK,EAAA,QAAA;AAAA,QAAU,IAAK,EAAA,cAAA;AAAA,QACzB,QAAA,EAAA;AAAA,0BAAC,GAAA,CAAA,aAAA,EAAA;AAAA,YAAc,OAAA;AAAA,WAAkB,CAAA;AAAA,0BAChC,GAAA,CAAA,SAAA,EAAA;AAAA,YACC,OAAA;AAAA,YACA,IAAA;AAAA,YACA,WAAa,EAAA,eAAA;AAAA,YACb,cAAgB,EAAA,kBAAA;AAAA,YAChB,KAAA;AAAA,YACA,sBAAA;AAAA,WACF,CAAA;AAAA,SAAA;AAAA,OACF,CAAA;AAAA,KACF,CAAA;AAAA,GACF,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -7,7 +7,15 @@ import { useEditorContext } from '../EditorContext.js';
|
|
|
7
7
|
import { useCursorContext } from '../CursorContext.js';
|
|
8
8
|
|
|
9
9
|
function TableBody(props) {
|
|
10
|
-
const {
|
|
10
|
+
const {
|
|
11
|
+
columns,
|
|
12
|
+
rows,
|
|
13
|
+
hoverRowKey,
|
|
14
|
+
setHoverRowKey,
|
|
15
|
+
gap,
|
|
16
|
+
zebra,
|
|
17
|
+
getRowValidationStatus
|
|
18
|
+
} = props;
|
|
11
19
|
const { selRowIdxs, selectedCellRange } = useSelectionContext();
|
|
12
20
|
const isCellInSelectedRange = useCallback(
|
|
13
21
|
(rowIdx, colIdx) => {
|
|
@@ -41,7 +49,6 @@ function TableBody(props) {
|
|
|
41
49
|
onDoubleClick,
|
|
42
50
|
children: rows.map((row) => {
|
|
43
51
|
const isSelected = selRowIdxs.has(row.index);
|
|
44
|
-
const isFollowedBySelected = selRowIdxs.has(row.index + 1);
|
|
45
52
|
const cursorIdx = focusedPart === "body" && cursorRowIdx === row.index ? cursorColIdx : void 0;
|
|
46
53
|
const editorColIdx = editMode ? cursorIdx : void 0;
|
|
47
54
|
return /* @__PURE__ */ jsx(TableRow, {
|
|
@@ -50,13 +57,13 @@ function TableBody(props) {
|
|
|
50
57
|
columns,
|
|
51
58
|
isHoverOver: row.key === hoverRowKey,
|
|
52
59
|
isSelected,
|
|
53
|
-
isFollowedBySelected,
|
|
54
60
|
cursorColIdx: cursorIdx,
|
|
55
61
|
gap,
|
|
56
62
|
zebra: zebra && row.index % 2 == 0,
|
|
57
63
|
editorColIdx,
|
|
58
64
|
isCellSelected: isCellInSelectedRange,
|
|
59
|
-
headerIsFocusable
|
|
65
|
+
headerIsFocusable,
|
|
66
|
+
validationStatus: getRowValidationStatus ? getRowValidationStatus(row) : void 0
|
|
60
67
|
}, row.key);
|
|
61
68
|
})
|
|
62
69
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableBody.js","sources":["../src/internal/TableBody.tsx"],"sourcesContent":["import { MouseEventHandler, useCallback, useMemo } from \"react\";\nimport { TableRow } from \"./TableRow\";\nimport { GridColumnModel, GridRowModel } from \"../Grid\";\nimport { getRowKeyAttribute } from \"./utils\";\nimport { useSelectionContext } from \"../SelectionContext\";\nimport { useEditorContext } from \"../EditorContext\";\nimport { useCursorContext } from \"../CursorContext\";\n\nexport interface TableBodyProps<T> {\n columns: GridColumnModel<T>[];\n rows: GridRowModel<T>[];\n hoverRowKey?: string;\n setHoverRowKey: (key: string | undefined) => void;\n gap?: number;\n zebra?: boolean;\n}\n\nexport function TableBody<T>(props: TableBodyProps<T>) {\n const {
|
|
1
|
+
{"version":3,"file":"TableBody.js","sources":["../src/internal/TableBody.tsx"],"sourcesContent":["import { MouseEventHandler, useCallback, useMemo } from \"react\";\nimport { TableRow } from \"./TableRow\";\nimport { GridColumnModel, GridRowModel } from \"../Grid\";\nimport { getRowKeyAttribute } from \"./utils\";\nimport { useSelectionContext } from \"../SelectionContext\";\nimport { useEditorContext } from \"../EditorContext\";\nimport { useCursorContext } from \"../CursorContext\";\nimport { CellValidationState } from \"../GridColumn\";\n\nexport interface TableBodyProps<T> {\n columns: GridColumnModel<T>[];\n rows: GridRowModel<T>[];\n hoverRowKey?: string;\n setHoverRowKey: (key: string | undefined) => void;\n gap?: number;\n zebra?: boolean;\n getRowValidationStatus?: (\n row: GridRowModel<T>\n ) => CellValidationState | undefined;\n}\n\nexport function TableBody<T>(props: TableBodyProps<T>) {\n const {\n columns,\n rows,\n hoverRowKey,\n setHoverRowKey,\n gap,\n zebra,\n getRowValidationStatus,\n } = props;\n const { selRowIdxs, selectedCellRange } = useSelectionContext();\n\n const isCellInSelectedRange = useCallback(\n (rowIdx: number, colIdx: number) => {\n if (!selectedCellRange) {\n return false;\n }\n const { start, end } = selectedCellRange;\n const minRowIdx = Math.min(start.rowIdx, end.rowIdx);\n const maxRowIdx = Math.max(start.rowIdx, end.rowIdx);\n const minColIdx = Math.min(start.colIdx, end.colIdx);\n const maxColIdx = Math.max(start.colIdx, end.colIdx);\n return (\n rowIdx >= minRowIdx &&\n rowIdx <= maxRowIdx &&\n colIdx >= minColIdx &&\n colIdx <= maxColIdx\n );\n },\n [selectedCellRange]\n );\n\n const { cursorRowIdx, cursorColIdx, focusedPart, headerIsFocusable } =\n useCursorContext();\n\n const { editMode, startEditMode } = useEditorContext();\n\n const onRowMouseEnter: MouseEventHandler<HTMLTableRowElement> = (event) => {\n const target = event.target as HTMLElement;\n const rowKey = getRowKeyAttribute(target);\n setHoverRowKey(rowKey);\n };\n\n const onMouseLeave: MouseEventHandler<HTMLTableSectionElement> = (event) => {\n setHoverRowKey(undefined);\n };\n\n const onDoubleClick: MouseEventHandler<HTMLTableSectionElement> = (event) => {\n startEditMode();\n };\n\n return (\n <tbody onMouseLeave={onMouseLeave} onDoubleClick={onDoubleClick}>\n {rows.map((row) => {\n const isSelected = selRowIdxs.has(row.index);\n const cursorIdx =\n focusedPart === \"body\" && cursorRowIdx === row.index\n ? cursorColIdx\n : undefined;\n const editorColIdx = editMode ? cursorIdx : undefined;\n return (\n <TableRow\n key={row.key}\n row={row}\n onMouseEnter={onRowMouseEnter}\n columns={columns}\n isHoverOver={row.key === hoverRowKey}\n isSelected={isSelected}\n cursorColIdx={cursorIdx}\n gap={gap}\n zebra={zebra && row.index % 2 == 0}\n editorColIdx={editorColIdx}\n isCellSelected={isCellInSelectedRange}\n headerIsFocusable={headerIsFocusable}\n validationStatus={\n getRowValidationStatus ? getRowValidationStatus(row) : undefined\n }\n />\n );\n })}\n </tbody>\n );\n}\n"],"names":[],"mappings":"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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import styleInject from '../../../../node_modules/style-inject/dist/style-inject.es.js';
|
|
2
2
|
|
|
3
|
-
var css_248z = ".saltGridTableRow {\n height: var(--grid-row-height);\n /* Row border doesn't render properly in Chrome on Windows. Applying borders to cells */\n --grid-row-borderColor: var(--grid-rowSeparator-color);\n --grid-row-background: var(--grid-background);\n}\n\n.saltGridTableRow-first {\n height: calc(var(--grid-row-height) + 1px);\n}\n\n.saltGridTableRow th {\n border-style: solid;\n border-color: var(--grid-row-borderColor);\n border-width: var(--grid-rowSeparator-width) 0 0 0;\n}\n\n.saltGridTableRow-divided {\n --grid-row-borderColor: var(--grid-rowSeparator-color-divided);\n}\n\n.saltGridTableRow-zebra {\n --grid-row-background: var(--grid-zebraColor);\n}\n\n.saltGridTableRow-hover {\n --grid-row-background: var(--grid-row-background-hover);\n}\n\n.saltGridTableRow-selected {\n --grid-row-borderColor: var(--grid-row-borderColor-selected);\n --grid-row-background: var(--grid-row-background-selected);\n}\n\n.saltGridTableRow-
|
|
3
|
+
var css_248z = ".saltGridTableRow {\n height: var(--grid-row-height);\n /* Row border doesn't render properly in Chrome on Windows. Applying borders to cells */\n --grid-row-borderColor: var(--grid-rowSeparator-color);\n --grid-row-background: var(--grid-background);\n}\n\n.saltGridTableRow-first {\n height: calc(var(--grid-row-height) + 1px);\n}\n\n.saltGridTableRow th {\n border-style: solid;\n border-color: var(--grid-row-borderColor);\n border-width: var(--grid-rowSeparator-width) 0 0 0;\n}\n\n.saltGridTableRow-divided {\n --grid-row-borderColor: var(--grid-rowSeparator-color-divided);\n}\n\n.saltGridTableRow-zebra {\n --grid-row-background: var(--grid-zebraColor);\n}\n\n.saltGridTableRow-hover {\n --grid-row-background: var(--grid-row-background-hover);\n}\n\n.saltGridTableRow-selected {\n --grid-row-borderColor: var(--grid-row-borderColor-selected);\n --grid-row-background: var(--grid-row-background-selected);\n}\n\n.saltGridTableRow-selected .saltGridCell:before {\n content: \"\";\n position: absolute;\n top: -1px;\n left: 0;\n right: 0;\n height: 1px;\n background: var(--grid-row-borderColor);\n z-index: var(--salt-zIndex-default);\n}\n\n.saltGridTableRow-zebra.saltGridTableRow-selected {\n --grid-row-background: var(--grid-row-background-selected);\n}\n\n.saltGridTableRow-zebra.saltGridTableRow-hover {\n --grid-row-background: var(--grid-row-background-hover);\n}\n\n.saltGridTableRow-zebra.saltGridTableRow-selected.saltGridTableRow-hover {\n --grid-row-background: var(--grid-row-background-hover);\n}\n\n.saltGridTableRow-selected.saltGridTableRow-hover {\n --grid-row-background: var(--grid-row-background-hover);\n}\n\n.saltGridTableRow-validationStatus-error,\n.saltGridTableRow-validationStatus-error.saltGridTableRow-hover {\n --grid-row-background: var(--salt-status-error-background-emphasize);\n}\n.saltGridTableRow-validationStatus-warning,\n.saltGridTableRow-validationStatus-warning.saltGridTableRow-hover {\n --grid-row-background: var(--salt-status-warning-background-emphasize);\n}\n.saltGridTableRow-validationStatus-success,\n.saltGridTableRow-validationStatus-success.saltGridTableRow-hover {\n --grid-row-background: var(--salt-status-success-background-emphasize);\n}\n\n.saltGridTableRow-validationStatus-error.saltGridTableRow-selected {\n --grid-row-background: var(--salt-status-error-background-selected);\n --grid-row-borderColor: var(--salt-status-error-borderColor);\n}\n.saltGridTableRow-validationStatus-warning.saltGridTableRow-selected {\n --grid-row-background: var(--salt-status-warning-background-selected);\n --grid-row-borderColor: var(--salt-status-warning-borderColor);\n}\n.saltGridTableRow-validationStatus-success.saltGridTableRow-selected {\n --grid-row-background: var(--salt-status-success-background-selected);\n --grid-row-borderColor: var(--salt-status-success-borderColor);\n}\n";
|
|
4
4
|
styleInject(css_248z);
|
|
5
5
|
|
|
6
6
|
export { css_248z as default };
|
|
@@ -7,13 +7,13 @@ import { clsx } from 'clsx';
|
|
|
7
7
|
import { FakeCell } from './FakeCell.js';
|
|
8
8
|
import { DefaultCellValue } from './DefaultCellValue.js';
|
|
9
9
|
import { useGridContext } from '../GridContext.js';
|
|
10
|
+
import { RowValidationStatusContext } from '../RowValidationStatus.js';
|
|
10
11
|
|
|
11
12
|
const withBaseName = makePrefixer("saltGridTableRow");
|
|
12
13
|
function TableRow(props) {
|
|
13
14
|
const {
|
|
14
15
|
row,
|
|
15
16
|
isSelected,
|
|
16
|
-
isFollowedBySelected,
|
|
17
17
|
zebra,
|
|
18
18
|
isHoverOver,
|
|
19
19
|
columns,
|
|
@@ -23,7 +23,8 @@ function TableRow(props) {
|
|
|
23
23
|
gap,
|
|
24
24
|
editorColIdx,
|
|
25
25
|
isCellSelected,
|
|
26
|
-
headerIsFocusable
|
|
26
|
+
headerIsFocusable,
|
|
27
|
+
validationStatus: rowValidationStatus
|
|
27
28
|
} = props;
|
|
28
29
|
const grid = useGridContext();
|
|
29
30
|
if (!row.key) {
|
|
@@ -37,8 +38,8 @@ function TableRow(props) {
|
|
|
37
38
|
[withBaseName("zebra")]: zebra,
|
|
38
39
|
[withBaseName("hover")]: isHoverOver,
|
|
39
40
|
[withBaseName("selected")]: isSelected,
|
|
40
|
-
[withBaseName("
|
|
41
|
-
[withBaseName(
|
|
41
|
+
[withBaseName("first")]: row.index === 0,
|
|
42
|
+
[withBaseName(`validationStatus-${rowValidationStatus}`)]: rowValidationStatus
|
|
42
43
|
}),
|
|
43
44
|
onMouseEnter,
|
|
44
45
|
onMouseLeave,
|
|
@@ -47,6 +48,7 @@ function TableRow(props) {
|
|
|
47
48
|
role: "row",
|
|
48
49
|
children: [
|
|
49
50
|
columns.map((column, i) => {
|
|
51
|
+
var _a, _b, _c, _d;
|
|
50
52
|
const colKey = column.info.props.id;
|
|
51
53
|
const editorInfo = grid.getEditor(column.info.props.id);
|
|
52
54
|
const isEditable = !!editorInfo;
|
|
@@ -67,19 +69,38 @@ function TableRow(props) {
|
|
|
67
69
|
const value = column.info.props.getValue && row.data ? column.info.props.getValue(row.data) : null;
|
|
68
70
|
const isFocused = cursorColIdx === column.index;
|
|
69
71
|
const isSelected2 = isCellSelected && isCellSelected(row.index, column.index);
|
|
70
|
-
|
|
72
|
+
const validationFnArg = {
|
|
71
73
|
row,
|
|
72
74
|
column,
|
|
73
75
|
isFocused,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
value
|
|
77
|
+
};
|
|
78
|
+
const validationStatus = (_b = (_a = column.info.props).getValidationStatus) == null ? void 0 : _b.call(_a, validationFnArg);
|
|
79
|
+
const validationMessage = validationStatus && ((_d = (_c = column.info.props).getValidationMessage) == null ? void 0 : _d.call(_c, validationFnArg));
|
|
80
|
+
return /* @__PURE__ */ jsx(RowValidationStatusContext.Provider, {
|
|
81
|
+
value: { status: rowValidationStatus },
|
|
82
|
+
children: /* @__PURE__ */ jsx(Cell, {
|
|
78
83
|
row,
|
|
84
|
+
column,
|
|
85
|
+
isFocused,
|
|
86
|
+
isSelected: isSelected2,
|
|
87
|
+
isEditable,
|
|
88
|
+
validationStatus,
|
|
89
|
+
validationMessage,
|
|
90
|
+
validationType: column.info.props.validationType,
|
|
79
91
|
value,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
92
|
+
align: column.info.props.align,
|
|
93
|
+
children: /* @__PURE__ */ jsx(CellValue, {
|
|
94
|
+
column,
|
|
95
|
+
row,
|
|
96
|
+
value,
|
|
97
|
+
isFocused,
|
|
98
|
+
validationStatus,
|
|
99
|
+
validationMessage,
|
|
100
|
+
validationType: column.info.props.validationType
|
|
101
|
+
})
|
|
102
|
+
}, colKey)
|
|
103
|
+
});
|
|
83
104
|
}),
|
|
84
105
|
gap !== void 0 && gap > 0 ? /* @__PURE__ */ jsx(FakeCell, {
|
|
85
106
|
row
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableRow.js","sources":["../src/internal/TableRow.tsx"],"sourcesContent":["import {\n Children,\n cloneElement,\n isValidElement,\n MouseEventHandler,\n} from \"react\";\nimport \"./TableRow.css\";\nimport { BaseCell } from \"../BaseCell\";\nimport { makePrefixer } from \"@salt-ds/core\";\nimport { clsx } from \"clsx\";\nimport { GridColumnModel, GridRowModel } from \"../Grid\";\nimport { FakeCell } from \"./FakeCell\";\nimport { DefaultCellValue } from \"./DefaultCellValue\";\nimport { useGridContext } from \"../GridContext\";\n\nconst withBaseName = makePrefixer(\"saltGridTableRow\");\n\nexport interface TableRowProps<T> {\n row: GridRowModel<T>;\n isSelected?: boolean
|
|
1
|
+
{"version":3,"file":"TableRow.js","sources":["../src/internal/TableRow.tsx"],"sourcesContent":["import {\n Children,\n cloneElement,\n isValidElement,\n MouseEventHandler,\n} from \"react\";\nimport \"./TableRow.css\";\nimport { BaseCell } from \"../BaseCell\";\nimport { makePrefixer } from \"@salt-ds/core\";\nimport { clsx } from \"clsx\";\nimport { GridColumnModel, GridRowModel } from \"../Grid\";\nimport { FakeCell } from \"./FakeCell\";\nimport { DefaultCellValue } from \"./DefaultCellValue\";\nimport { useGridContext } from \"../GridContext\";\nimport { CellValidationState } from \"../GridColumn\";\nimport { RowValidationStatusContext } from \"../RowValidationStatus\";\n\nconst withBaseName = makePrefixer(\"saltGridTableRow\");\n\nexport interface TableRowProps<T> {\n row: GridRowModel<T>;\n isSelected?: boolean;\n isHoverOver?: boolean;\n zebra?: boolean;\n columns: GridColumnModel<T>[];\n cursorColIdx?: number;\n onMouseEnter?: MouseEventHandler<HTMLTableRowElement>;\n onMouseLeave?: MouseEventHandler<HTMLTableRowElement>;\n gap?: number;\n editorColIdx?: number;\n isCellSelected?: (rowIdx: number, colIdx: number) => boolean;\n headerIsFocusable?: boolean;\n validationStatus?: CellValidationState;\n}\n\nexport function TableRow<T>(props: TableRowProps<T>) {\n const {\n row,\n isSelected,\n zebra,\n isHoverOver,\n columns,\n onMouseEnter,\n onMouseLeave,\n cursorColIdx,\n gap,\n editorColIdx,\n isCellSelected,\n headerIsFocusable,\n validationStatus: rowValidationStatus,\n } = props;\n\n const grid = useGridContext();\n\n if (!row.key) {\n throw new Error(`Invalid row`);\n }\n\n const ariaRowIndex = headerIsFocusable ? row.index + 2 : row.index + 1;\n\n return (\n <tr\n aria-rowindex={ariaRowIndex}\n aria-selected={isSelected ? true : undefined}\n className={clsx(withBaseName(), {\n [withBaseName(\"zebra\")]: zebra,\n [withBaseName(\"hover\")]: isHoverOver,\n [withBaseName(\"selected\")]: isSelected,\n [withBaseName(\"first\")]: row.index === 0,\n [withBaseName(`validationStatus-${rowValidationStatus}`)]:\n rowValidationStatus,\n })}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n data-row-index={row.index}\n data-row-key={row.key}\n role=\"row\"\n >\n {columns.map((column, i) => {\n const colKey = column.info.props.id;\n const editorInfo = grid.getEditor(column.info.props.id);\n const isEditable = !!editorInfo;\n\n if (editorColIdx === column.index) {\n if (isEditable) {\n if (isValidElement(editorInfo.children)) {\n const editorElement = Children.only(editorInfo.children);\n return cloneElement(editorElement, {\n key: colKey,\n row,\n column,\n } as any);\n }\n }\n }\n\n const Cell = column.info.props.cellComponent || BaseCell;\n const CellValue =\n column.info.props.cellValueComponent || DefaultCellValue;\n const value =\n column.info.props.getValue && row.data\n ? column.info.props.getValue(row.data)\n : null;\n const isFocused = cursorColIdx === column.index;\n const isSelected =\n isCellSelected && isCellSelected(row.index, column.index);\n const validationFnArg = {\n row,\n column,\n isFocused,\n value,\n };\n const validationStatus =\n column.info.props.getValidationStatus?.(validationFnArg);\n const validationMessage =\n validationStatus &&\n column.info.props.getValidationMessage?.(validationFnArg);\n\n return (\n <RowValidationStatusContext.Provider\n value={{ status: rowValidationStatus }}\n >\n <Cell\n key={colKey}\n row={row}\n column={column}\n isFocused={isFocused}\n isSelected={isSelected}\n isEditable={isEditable}\n validationStatus={validationStatus}\n validationMessage={validationMessage}\n validationType={column.info.props.validationType}\n value={value}\n align={column.info.props.align}\n >\n <CellValue\n column={column}\n row={row}\n value={value}\n isFocused={isFocused}\n validationStatus={validationStatus}\n validationMessage={validationMessage}\n validationType={column.info.props.validationType}\n />\n </Cell>\n </RowValidationStatusContext.Provider>\n );\n })}\n {gap !== undefined && gap > 0 ? <FakeCell row={row} /> : null}\n </tr>\n );\n}\n"],"names":["isSelected"],"mappings":"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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMemo, useCallback, useRef, useState, useEffect, Children, isValidElement } from 'react';
|
|
2
2
|
import { NumberRange } from '../NumberRange.js';
|
|
3
3
|
import { getAttribute, makeMapAdder, makeMapDeleter, getCellPosition } from './utils.js';
|
|
4
4
|
import { useControlled } from '@salt-ds/core';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { SortOrder } from "./Grid";
|
|
3
|
+
import { GridColumnProps } from "./GridColumn";
|
|
4
|
+
export interface ColumnSortContext {
|
|
5
|
+
sortByColumnId?: GridColumnProps["id"];
|
|
6
|
+
setSortByColumnId: (c: React.SetStateAction<GridColumnProps["id"]>) => void;
|
|
7
|
+
sortOrder: SortOrder;
|
|
8
|
+
setSortOrder: (o: SortOrder) => void;
|
|
9
|
+
onClickSortColumn: (colHeaderId: GridColumnProps["id"]) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare const ColumnSortContext: React.Context<ColumnSortContext | undefined>;
|
|
12
|
+
export declare const useColumnSortContext: () => ColumnSortContext;
|
package/dist-types/Grid.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CSSProperties, ReactNode } from "react";
|
|
2
|
-
import { GridColumnInfo } from "./GridColumn";
|
|
2
|
+
import { CellValidationState, GridColumnInfo } from "./GridColumn";
|
|
3
3
|
import "./Grid.css";
|
|
4
4
|
import { ColumnGroupProps } from "./ColumnGroup";
|
|
5
5
|
export declare type ColumnSeparatorType = "regular" | "none" | "groupEdge" | "pinned";
|
|
@@ -7,6 +7,11 @@ export declare type ColumnGroupRowSeparatorType = "first" | "regular" | "last";
|
|
|
7
7
|
export declare type ColumnGroupColumnSeparatorType = "regular" | "none" | "pinned";
|
|
8
8
|
export declare type GridRowSelectionMode = "single" | "multi" | "none";
|
|
9
9
|
export declare type GridCellSelectionMode = "range" | "none";
|
|
10
|
+
export declare enum SortOrder {
|
|
11
|
+
ASC = "asc",
|
|
12
|
+
DESC = "desc",
|
|
13
|
+
NONE = "none"
|
|
14
|
+
}
|
|
10
15
|
export declare type RowKeyGetter<T> = (row: T, index: number) => string;
|
|
11
16
|
export declare type GridColumnMoveHandler = (columnId: string, fromIndex: number, toIndex: number) => void;
|
|
12
17
|
export interface GridProps<T = any> {
|
|
@@ -77,6 +82,7 @@ export interface GridProps<T = any> {
|
|
|
77
82
|
* If `true`, keyboard navigation is enabled for the header.
|
|
78
83
|
* */
|
|
79
84
|
headerIsFocusable?: boolean;
|
|
85
|
+
getRowValidationStatus?: (row: GridRowModel<T>) => CellValidationState | undefined;
|
|
80
86
|
}
|
|
81
87
|
export interface GridRowModel<T> {
|
|
82
88
|
key: string;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { ComponentType, CSSProperties, KeyboardEvent, ReactNode } from "react";
|
|
2
|
-
import { GridColumnModel, GridRowModel } from "./Grid";
|
|
2
|
+
import { GridColumnModel, GridRowModel, SortOrder } from "./Grid";
|
|
3
3
|
export declare type GridColumnPin = "left" | "right" | null;
|
|
4
|
-
export
|
|
4
|
+
export declare type CellValidationState = "error" | "warning" | "success";
|
|
5
|
+
declare type CellValidationType = "strong" | "light";
|
|
6
|
+
export interface GridCellProps<T, U = any> {
|
|
5
7
|
row: GridRowModel<T>;
|
|
6
8
|
column: GridColumnModel<T>;
|
|
7
9
|
className?: string;
|
|
@@ -10,12 +12,20 @@ export interface GridCellProps<T> {
|
|
|
10
12
|
isSelected?: boolean;
|
|
11
13
|
isEditable?: boolean;
|
|
12
14
|
children?: ReactNode;
|
|
15
|
+
align?: GridColumnProps["align"];
|
|
16
|
+
value?: U;
|
|
17
|
+
validationStatus?: CellValidationState;
|
|
18
|
+
validationMessage?: string;
|
|
19
|
+
validationType?: CellValidationType;
|
|
13
20
|
}
|
|
14
21
|
export interface GridCellValueProps<T, U = any> {
|
|
15
22
|
row: GridRowModel<T>;
|
|
16
23
|
column: GridColumnModel<T>;
|
|
17
24
|
isFocused?: boolean;
|
|
18
25
|
value?: U;
|
|
26
|
+
validationStatus?: CellValidationState;
|
|
27
|
+
validationMessage?: string;
|
|
28
|
+
validationType?: CellValidationType;
|
|
19
29
|
}
|
|
20
30
|
export interface HeaderCellProps<T> {
|
|
21
31
|
column: GridColumnModel<T>;
|
|
@@ -35,6 +45,26 @@ export interface GridColumnProps<T = any> {
|
|
|
35
45
|
* Unique identifier of the column.
|
|
36
46
|
* */
|
|
37
47
|
id: string;
|
|
48
|
+
/**
|
|
49
|
+
* Enables sorting (by sort order: `asc | desc | none`) for the column.
|
|
50
|
+
* To enable column header's keyboard navigation on sort,
|
|
51
|
+
* users need to set `headerIsFocusable` prop to `true` in Grid component.
|
|
52
|
+
* To customise how GridColumn data sorts, use also `customSort` or `onSortOrderChanged`.
|
|
53
|
+
* */
|
|
54
|
+
sortable?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Custom sorting function. Use for client side sorting.
|
|
57
|
+
* */
|
|
58
|
+
customSort?: (args: {
|
|
59
|
+
rowData: T[];
|
|
60
|
+
sortOrder: SortOrder;
|
|
61
|
+
}) => T[];
|
|
62
|
+
/**
|
|
63
|
+
* Exposes GridColumn sort order. Use for server side sorting.
|
|
64
|
+
* */
|
|
65
|
+
onSortOrderChange?: (args: {
|
|
66
|
+
sortOrder: SortOrder;
|
|
67
|
+
}) => void;
|
|
38
68
|
/**
|
|
39
69
|
* Name is displayed on the column header by default.
|
|
40
70
|
* */
|
|
@@ -77,6 +107,23 @@ export interface GridColumnProps<T = any> {
|
|
|
77
107
|
* for the given row data item.
|
|
78
108
|
* */
|
|
79
109
|
getValue?: (rowData: T) => any;
|
|
110
|
+
/**
|
|
111
|
+
* Cell validation status getter. Should return one of the known validation status names: "none" | "error" | "warning"
|
|
112
|
+
* If you require a custom validation status, you can achieve that by providing a custom cell component.
|
|
113
|
+
* */
|
|
114
|
+
getValidationStatus?: (value: GridCellValueProps<T>) => CellValidationState | undefined;
|
|
115
|
+
/**
|
|
116
|
+
* Cell validation status message getter. Should return a string description of the validation state that can be used for the screen reader.
|
|
117
|
+
* This prop is optional but if you don't provide a function a default message will be used.
|
|
118
|
+
* */
|
|
119
|
+
getValidationMessage?: (value: GridCellValueProps<T>) => string | undefined;
|
|
120
|
+
/**
|
|
121
|
+
* Cell validation type. Determines the visual style of the validation. The available values are "strong" and "light". Strong will display the icon
|
|
122
|
+
* along side the background and border. Light will only affect border and background. Use light if you are validation the whole row, and optionally
|
|
123
|
+
* strong on one of the columns, and strong if you are validating user input on a particular cell.
|
|
124
|
+
* The default value is "light".
|
|
125
|
+
* */
|
|
126
|
+
validationType?: GridCellProps<T>["validationType"];
|
|
80
127
|
/**
|
|
81
128
|
* CSS class to be applied to the column header.
|
|
82
129
|
* Useful for minor customizations
|
|
@@ -104,6 +151,10 @@ export interface GridColumnProps<T = any> {
|
|
|
104
151
|
* Children is optional, and accepts non-rendered elements i.e. `CellEditor`
|
|
105
152
|
*/
|
|
106
153
|
children?: ReactNode;
|
|
154
|
+
/**
|
|
155
|
+
* aria-label is optional, and accepts any string value
|
|
156
|
+
*/
|
|
157
|
+
"aria-label"?: string;
|
|
107
158
|
}
|
|
108
159
|
export interface GridColumnInfo<T> {
|
|
109
160
|
width: number;
|
|
@@ -111,3 +162,4 @@ export interface GridColumnInfo<T> {
|
|
|
111
162
|
props: GridColumnProps<T>;
|
|
112
163
|
}
|
|
113
164
|
export declare const GridColumn: <T = any>(props: GridColumnProps<T>) => JSX.Element;
|
|
165
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CellValidationState, GridColumnProps } from "./GridColumn";
|
|
3
|
+
export declare const RowValidationStatusContext: import("react").Context<{
|
|
4
|
+
status?: CellValidationState | undefined;
|
|
5
|
+
}>;
|
|
6
|
+
export declare type RowValidationStatusColumnProps<T> = Omit<GridColumnProps<T>, "width" | "name">;
|
|
7
|
+
export declare function RowValidationStatusColumn<T>(props: RowValidationStatusColumnProps<T>): JSX.Element;
|