@caspeco/casper-ui-library 10.7.3 → 10.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/components/rich-text-editor/boolean-control.js +1 -1
- package/dist/components/rich-text-editor/rich-text-editor-control.js +1 -1
- package/dist/components/rich-text-editor/rich-text-editor.js +1 -1
- package/dist/components/rich-text-editor/use-rich-text-editor.js +1 -1
- package/dist/components/table/helper.d.ts +3 -0
- package/dist/components/table/helper.d.ts.map +1 -1
- package/dist/components/table/helper.js +17 -11
- package/dist/components/table/index.d.ts +1 -1
- package/dist/components/table/index.d.ts.map +1 -1
- package/dist/components/table/table-cell.d.ts +2 -1
- package/dist/components/table/table-cell.d.ts.map +1 -1
- package/dist/components/table/table-cell.js +62 -55
- package/dist/components/table/table-content.d.ts.map +1 -1
- package/dist/components/table/table-content.js +84 -56
- package/dist/components/table/table-context-provider.d.ts +17 -2
- package/dist/components/table/table-context-provider.d.ts.map +1 -1
- package/dist/components/table/table-context-provider.js +179 -122
- package/dist/components/table/table-drag-accessibility.d.ts +11 -0
- package/dist/components/table/table-drag-accessibility.d.ts.map +1 -0
- package/dist/components/table/table-drag-accessibility.js +22 -0
- package/dist/components/table/table-header-dropdown.d.ts +3 -5
- package/dist/components/table/table-header-dropdown.d.ts.map +1 -1
- package/dist/components/table/table-header-dropdown.js +116 -108
- package/dist/components/table/table-header-dropdown.spec.d.ts +2 -0
- package/dist/components/table/table-header-dropdown.spec.d.ts.map +1 -0
- package/dist/components/table/table-header-row.d.ts.map +1 -1
- package/dist/components/table/table-header-row.js +70 -63
- package/dist/components/table/table-recipe.d.ts.map +1 -1
- package/dist/components/table/table-recipe.js +6 -0
- package/dist/components/table/table-row-drag-handle.d.ts +6 -0
- package/dist/components/table/table-row-drag-handle.d.ts.map +1 -0
- package/dist/components/table/table-row-drag-handle.js +53 -0
- package/dist/components/table/table-row-reorder.spec.d.ts +2 -0
- package/dist/components/table/table-row-reorder.spec.d.ts.map +1 -0
- package/dist/components/table/table-row.d.ts.map +1 -1
- package/dist/components/table/table-row.js +59 -42
- package/dist/components/table/table-sorted-reorder-prompt.d.ts +8 -0
- package/dist/components/table/table-sorted-reorder-prompt.d.ts.map +1 -0
- package/dist/components/table/table-sorted-reorder-prompt.js +64 -0
- package/dist/components/table/table-toolbar-settings.js +27 -27
- package/dist/components/table/table.composition.d.ts +2 -0
- package/dist/components/table/table.composition.d.ts.map +1 -1
- package/dist/components/table/table.constants.d.ts +15 -0
- package/dist/components/table/table.constants.d.ts.map +1 -1
- package/dist/components/table/table.constants.js +2 -2
- package/dist/components/table/table.d.ts +1 -1
- package/dist/components/table/table.d.ts.map +1 -1
- package/dist/components/table/table.js +4 -2
- package/dist/components/table/translations.d.ts +77 -0
- package/dist/components/table/translations.d.ts.map +1 -1
- package/dist/components/table/translations.js +72 -6
- package/dist/components/table/types.d.ts +37 -5
- package/dist/components/table/types.d.ts.map +1 -1
- package/dist/node_modules/@tiptap/core/dist/index.js +725 -951
- package/dist/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.js +37 -13
- package/dist/node_modules/@tiptap/core/dist/rolldown-runtime-D7D4PA-g.js +11 -0
- package/dist/node_modules/@tiptap/extension-code-block/dist/index.js +1 -3
- package/dist/node_modules/@tiptap/extension-list/dist/index.js +101 -128
- package/dist/node_modules/@tiptap/extension-paragraph/dist/index.js +3 -2
- package/dist/node_modules/@tiptap/extensions/dist/index.js +6 -7
- package/dist/{node_modules → packages/casper-ui-library/node_modules}/@tiptap/react/dist/index.js +24 -24
- package/package.json +10 -9
package/README.md
CHANGED
|
@@ -28,6 +28,7 @@ All commands are run from the root of the project, from a terminal.
|
|
|
28
28
|
| `npm run lint` | Run linting with [@caspeco/eslint-config](https://github.com/Caspeco/eslint-config). If you use the recommended [ESLint VSCode extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) you can see your eslint errors directly in your editor without having to run this. |
|
|
29
29
|
| `npm run prettier:fix` | Reformat all files with [@caspeco/prettier-config](https://github.com/Caspeco/prettier-config). If you use the recommended [Prettier VSCode extension](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) you can have your files automatically formatted on file save. |
|
|
30
30
|
| `npm run chakra:types` | Generate Chakra UI type definitions for the theme. You run this if you modify component variants and want to get rid of TS errors, for example. Happens automatically on `npm install`. |
|
|
31
|
+
| `npm run test:all` | Run every check the CI lint job runs, in sequence: `prettier`, `lint`, `tsc`, `knip` and `test`. Stops at the first failure. Requires Playwright browsers (`npm exec -- playwright install chromium`) for the unit tests. |
|
|
31
32
|
|
|
32
33
|
### Preview locally in another project
|
|
33
34
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { require_compiler_runtime as e } from "../../node_modules/react/compiler-runtime.js";
|
|
2
|
-
import { useEditorState as t } from "../../node_modules/@tiptap/react/dist/index.js";
|
|
2
|
+
import { useEditorState as t } from "../../packages/casper-ui-library/node_modules/@tiptap/react/dist/index.js";
|
|
3
3
|
import { useRichTextEditorContext as n } from "./rich-text-editor-context.js";
|
|
4
4
|
import { Tooltip as r } from "../tooltip/tooltip.js";
|
|
5
5
|
import { ToggleButton as i } from "../toggle-button/toggle-button.js";
|
|
@@ -10,7 +10,7 @@ import { MenuList as te } from "../menu/menu-list.js";
|
|
|
10
10
|
import { FormControl as l } from "../form-control/form-control.js";
|
|
11
11
|
import { FormLabel as u } from "../form-control/form-label.js";
|
|
12
12
|
import { Input as d } from "../input/input.js";
|
|
13
|
-
import { useEditorState as f } from "../../node_modules/@tiptap/react/dist/index.js";
|
|
13
|
+
import { useEditorState as f } from "../../packages/casper-ui-library/node_modules/@tiptap/react/dist/index.js";
|
|
14
14
|
import { useRichTextEditorContext as p } from "./rich-text-editor-context.js";
|
|
15
15
|
import { Tooltip as ne } from "../tooltip/tooltip.js";
|
|
16
16
|
import { find as m } from "../../node_modules/linkifyjs/dist/linkify.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { require_compiler_runtime as e } from "../../node_modules/react/compiler-runtime.js";
|
|
2
2
|
import { ThemeColorVariable as t, ThemeSpaceVariable as n } from "../../theme/theme-types.js";
|
|
3
|
-
import { EditorContent as r } from "../../node_modules/@tiptap/react/dist/index.js";
|
|
3
|
+
import { EditorContent as r } from "../../packages/casper-ui-library/node_modules/@tiptap/react/dist/index.js";
|
|
4
4
|
import { RichTextEditorContext as i, useRichTextEditorContext as a } from "./rich-text-editor-context.js";
|
|
5
5
|
import { proseMirrorContainerCss as o, proseMirrorContentCss as s, toolbarCss as c } from "./rich-text-editor-recipe.js";
|
|
6
6
|
import "react";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { require_compiler_runtime as e } from "../../node_modules/react/compiler-runtime.js";
|
|
2
|
-
import { useEditor as t } from "../../node_modules/@tiptap/react/dist/index.js";
|
|
2
|
+
import { useEditor as t } from "../../packages/casper-ui-library/node_modules/@tiptap/react/dist/index.js";
|
|
3
3
|
import { richTextExtensions as n } from "./extensions.js";
|
|
4
4
|
//#region lib/components/rich-text-editor/use-rich-text-editor.ts
|
|
5
5
|
var r = e();
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Column } from '@tanstack/react-table';
|
|
2
|
+
import { TableData, TableRow } from './types.js';
|
|
2
3
|
export declare function arrayMove<T>(array: T[], fromIndex: number, toIndex: number): T[];
|
|
4
|
+
export declare function getTopLevelRowIds<TData extends TableData>(data: TableRow<TData>[], getRowId: (originalRow: TableRow<TData>, index: number) => string): string[];
|
|
5
|
+
export declare function isSameSequence(first: readonly string[], second: readonly string[]): boolean;
|
|
3
6
|
export declare function getColumnLabel(header: unknown, columnId: string): string;
|
|
4
7
|
export declare function getColumnSizeCssVarName(columnId: string): string;
|
|
5
8
|
export declare function getColumnStartCssVarName(columnId: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../../lib/components/table/helper.ts"],"names":[],"mappings":"AAAA,OA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,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,oBAAoB,EAAE,OAAO,GAAG,MAAM,CAG1G"}
|
|
@@ -4,28 +4,34 @@ function e(e, t, n) {
|
|
|
4
4
|
return i !== void 0 && r.splice(n, 0, i), r;
|
|
5
5
|
}
|
|
6
6
|
function t(e, t) {
|
|
7
|
+
return e.map((e, n) => t(e, n));
|
|
8
|
+
}
|
|
9
|
+
function n(e, t) {
|
|
10
|
+
return e.length === t.length && e.every((e, n) => e === t[n]);
|
|
11
|
+
}
|
|
12
|
+
function r(e, t) {
|
|
7
13
|
return typeof e == "string" || typeof e == "number" ? String(e) : t;
|
|
8
14
|
}
|
|
9
|
-
function
|
|
15
|
+
function i(e) {
|
|
10
16
|
return e.replace(/[^a-zA-Z0-9]/g, (e) => `_${e.charCodeAt(0).toString(16)}_`);
|
|
11
17
|
}
|
|
12
|
-
function
|
|
13
|
-
return `--col-${
|
|
18
|
+
function a(e) {
|
|
19
|
+
return `--col-${i(e)}-size`;
|
|
14
20
|
}
|
|
15
|
-
function
|
|
16
|
-
return `--col-${
|
|
21
|
+
function o(e) {
|
|
22
|
+
return `--col-${i(e)}-start`;
|
|
17
23
|
}
|
|
18
|
-
function
|
|
24
|
+
function s(e, t) {
|
|
19
25
|
let { minSize: n = 80, maxSize: r = 2 ** 53 - 1 } = e.columnDef;
|
|
20
26
|
return Math.min(Math.max(t, n), r);
|
|
21
27
|
}
|
|
22
|
-
function
|
|
28
|
+
function c(e, t) {
|
|
23
29
|
let n = e.getSize();
|
|
24
|
-
return t ? `var(${
|
|
30
|
+
return t ? `var(${a(e.id)}, ${n}px)` : n;
|
|
25
31
|
}
|
|
26
|
-
function
|
|
32
|
+
function l(e, t) {
|
|
27
33
|
let n = `${e.getStart("left")}px`;
|
|
28
|
-
return t ? `var(${
|
|
34
|
+
return t ? `var(${o(e.id)}, ${n})` : n;
|
|
29
35
|
}
|
|
30
36
|
//#endregion
|
|
31
|
-
export { e as arrayMove,
|
|
37
|
+
export { e as arrayMove, s as getClampedColumnWidth, r as getColumnLabel, a as getColumnSizeCssVarName, o as getColumnStartCssVarName, c as getColumnWidth, l as getPinnedLeft, t as getTopLevelRowIds, n as isSameSequence };
|
|
@@ -9,5 +9,5 @@ export { TableToolbarAddButton } from './table-toolbar-add-button.js';
|
|
|
9
9
|
export { TableToolbarSearch } from './table-toolbar-search.js';
|
|
10
10
|
export { TableToolbarSettings } from './table-toolbar-settings.js';
|
|
11
11
|
export type { TableFilterProps } from './table-filter.js';
|
|
12
|
-
export type { CellContext, ColumnDef, ColumnSizingState, ExpandedState, Row, RowSelectionState, SortingState, TableContentProps, TableFilterBoxState, TableFilterVisibleChange, TableProps, TableRow, TableToolbarActionsProps, TableToolbarAddButtonProps, TableToolbarProps, TableToolbarSearchProps, VisibilityState, } from './types.js';
|
|
12
|
+
export type { CellContext, ColumnDef, ColumnSizingState, ExpandedState, Row, RowReorderDetails, RowSelectionState, SortingState, TableContentProps, TableFilterBoxState, TableFilterVisibleChange, TableProps, TableRow, TableToolbarActionsProps, TableToolbarAddButtonProps, TableToolbarProps, TableToolbarSearchProps, VisibilityState, } from './types.js';
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/components/table/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBA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AAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,EACnB,wBAAwB,EACxB,UAAU,EACV,QAAQ,EACR,wBAAwB,EACxB,0BAA0B,EAC1B,iBAAiB,EACjB,uBAAuB,EACvB,eAAe,GACf,MAAM,SAAS,CAAC"}
|
|
@@ -12,8 +12,9 @@ type TableCellProps<TData extends TableData> = {
|
|
|
12
12
|
actionMenu?: ReactNode;
|
|
13
13
|
canSelectRows?: boolean;
|
|
14
14
|
isCheckboxDisabled?: boolean;
|
|
15
|
+
dragHandleRef?: (element: Element | null) => void;
|
|
15
16
|
};
|
|
16
|
-
declare const TableCellComponent: <TData extends TableData>({ cell, row, rowIsExpanded, visibleCells, breakingContentState, localeString, actionMenu, canSelectRows, isCheckboxDisabled, }: TableCellProps<TData>) => import("react").JSX.Element;
|
|
17
|
+
declare const TableCellComponent: <TData extends TableData>({ cell, row, rowIsExpanded, visibleCells, breakingContentState, localeString, actionMenu, canSelectRows, isCheckboxDisabled, dragHandleRef, }: TableCellProps<TData>) => import("react").JSX.Element;
|
|
17
18
|
export declare const TableCell: typeof TableCellComponent;
|
|
18
19
|
export {};
|
|
19
20
|
//# sourceMappingURL=table-cell.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-cell.d.ts","sourceRoot":"","sources":["../../../lib/components/table/table-cell.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAc,KAAK,IAAI,EAAE,KAAK,GAAG,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAkD,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"table-cell.d.ts","sourceRoot":"","sources":["../../../lib/components/table/table-cell.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAc,KAAK,IAAI,EAAE,KAAK,GAAG,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAkD,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAMvF,OAAO,EAAgB,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnD,KAAK,cAAc,CAAC,KAAK,SAAS,SAAS,IAAI;IAC9C,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC;IACrC,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC;IAC/C,GAAG,EAAE,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IAC1B,aAAa,EAAE,OAAO,CAAC;IACvB,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9C,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC;CAClD,CAAC;AAEF,QAAA,MAAM,kBAAkB,GAAI,KAAK,SAAS,SAAS,EAAE,+IAWlD,cAAc,CAAC,KAAK,CAAC,gCA0LvB,CAAC;AAEF,eAAO,MAAM,SAAS,EAA+B,OAAO,kBAAkB,CAAC"}
|
|
@@ -9,24 +9,25 @@ import { flexRender as s } from "../../node_modules/@tanstack/react-table/build/
|
|
|
9
9
|
import { getColumnWidth as c, getPinnedLeft as l } from "./helper.js";
|
|
10
10
|
import { useTableContext as u } from "./table-context.js";
|
|
11
11
|
import { translations as d } from "./translations.js";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
import { TableRowDragHandle as f } from "./table-row-drag-handle.js";
|
|
13
|
+
import { TableRowExpandToggleButton as p } from "./table-row-expand-toggle-button.js";
|
|
14
|
+
import { memo as m, useCallback as h, useMemo as g } from "react";
|
|
15
|
+
import { Box as _, Flex as v, TableCell as y } from "@chakra-ui/react";
|
|
16
|
+
import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
|
|
17
|
+
var C = m(({ cell: m, row: C, rowIsExpanded: w, visibleCells: T, breakingContentState: E, localeString: D, actionMenu: O, canSelectRows: k, isCheckboxDisabled: A, dragHandleRef: j }) => {
|
|
18
|
+
let M = u(), { column: N } = m, P = d[D], F = g(() => {
|
|
18
19
|
let e = {
|
|
19
20
|
width: "100%",
|
|
20
21
|
display: "inline-flex",
|
|
21
22
|
height: "100%",
|
|
22
23
|
alignItems: "center"
|
|
23
24
|
};
|
|
24
|
-
return
|
|
25
|
-
}, [
|
|
25
|
+
return E[N.id] || (e.overflow = "hidden", e.whiteSpace = "nowrap"), e;
|
|
26
|
+
}, [E, N.id]), I = C.getCanExpand(), L = T[0]?.id === m.id, R = I && L, z = O || L && !!M.getRowActions || k, B = L && M.rowReorderMode !== "off", V = M.rowReorderMode !== "off" && L && C.depth === 0, H = B ? 24 : 0, U = z || B, W = g(() => {
|
|
26
27
|
let e = [];
|
|
27
|
-
for (let t = 0; t <
|
|
28
|
+
for (let t = 0; t < C.depth; t += 1) {
|
|
28
29
|
let n = `${t * 2 + .7}rem`;
|
|
29
|
-
|
|
30
|
+
U && (n = `calc(${n} + ${(z ? (O && k ? 2 : 1) * 24 : 0) + H}px)`), e.push(/* @__PURE__ */ x(o, {
|
|
30
31
|
orientation: "vertical",
|
|
31
32
|
position: "absolute",
|
|
32
33
|
top: "0",
|
|
@@ -35,102 +36,108 @@ var S = p(({ cell: p, row: S, rowIsExpanded: C, visibleCells: w, breakingContent
|
|
|
35
36
|
}
|
|
36
37
|
return e;
|
|
37
38
|
}, [
|
|
38
|
-
D,
|
|
39
39
|
O,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
k,
|
|
41
|
+
H,
|
|
42
|
+
z,
|
|
43
|
+
C.depth,
|
|
44
|
+
U
|
|
45
|
+
]), G = () => {
|
|
46
|
+
let t = N.getIsPinned(), n = c(N, M.enableColumnResizing);
|
|
44
47
|
return {
|
|
45
48
|
position: t ? "sticky" : "relative",
|
|
46
|
-
left: t ? l(
|
|
49
|
+
left: t ? l(N, M.enableColumnResizing) : void 0,
|
|
47
50
|
backgroundColor: t ? e.Background : void 0,
|
|
48
51
|
zIndex: t ? 1 : void 0,
|
|
49
52
|
width: n,
|
|
50
53
|
maxWidth: n
|
|
51
54
|
};
|
|
52
55
|
};
|
|
53
|
-
function
|
|
54
|
-
let e =
|
|
55
|
-
return
|
|
56
|
+
function K() {
|
|
57
|
+
let e = C.depth && L || R ? `${C.depth * 2}rem` : t.Small;
|
|
58
|
+
return U ? `calc(${e} + ${(z ? (O && k && C.depth === 0 ? 2 : 1) * 24 : 0) + H}px)` : e;
|
|
56
59
|
}
|
|
57
|
-
let
|
|
60
|
+
let q = h(({ checked: e }) => {
|
|
58
61
|
let t = (e) => {
|
|
59
|
-
if (
|
|
62
|
+
if (M.disableSelectionCheckbox?.(e)) return [];
|
|
60
63
|
let n = [e.id];
|
|
61
64
|
return e.subRows?.forEach((e) => {
|
|
62
65
|
n.push(...t(e));
|
|
63
66
|
}), n;
|
|
64
67
|
};
|
|
65
|
-
|
|
66
|
-
let r = t(
|
|
68
|
+
M.setSelectedRowIds((n) => {
|
|
69
|
+
let r = t(C), i = new Set(n);
|
|
67
70
|
return r.forEach((t) => {
|
|
68
71
|
e ? i.add(t) : i.delete(t);
|
|
69
72
|
}), Array.from(i);
|
|
70
73
|
});
|
|
71
|
-
}, [
|
|
72
|
-
return /* @__PURE__ */
|
|
73
|
-
id:
|
|
74
|
-
textAlign:
|
|
74
|
+
}, [C, M]), J = g(() => M.selectedRowIds?.includes(C.id) ?? !1, [C.id, M.selectedRowIds]);
|
|
75
|
+
return /* @__PURE__ */ x(y, {
|
|
76
|
+
id: m.id,
|
|
77
|
+
textAlign: N.columnDef.meta?.isNumeric ? "end" : void 0,
|
|
75
78
|
style: {
|
|
76
|
-
...
|
|
79
|
+
...G(),
|
|
77
80
|
borderBottom: 0,
|
|
78
|
-
paddingLeft:
|
|
81
|
+
paddingLeft: K()
|
|
79
82
|
},
|
|
80
|
-
children: /* @__PURE__ */
|
|
83
|
+
children: /* @__PURE__ */ S(v, {
|
|
81
84
|
w: "100%",
|
|
82
85
|
h: "100%",
|
|
83
86
|
align: "center",
|
|
84
87
|
children: [
|
|
85
|
-
|
|
88
|
+
V && /* @__PURE__ */ x(f, {
|
|
89
|
+
localeString: D,
|
|
90
|
+
handleRef: j
|
|
91
|
+
}),
|
|
92
|
+
O && /* @__PURE__ */ x(r, { children: ({ isOpen: e }) => /* @__PURE__ */ S(_, {
|
|
86
93
|
display: "contents",
|
|
87
94
|
onClick: (e) => e.stopPropagation(),
|
|
88
95
|
onKeyDown: (e) => e.stopPropagation(),
|
|
89
|
-
children: [/* @__PURE__ */
|
|
96
|
+
children: [/* @__PURE__ */ x(_, {
|
|
90
97
|
className: "action-menu-button",
|
|
91
98
|
position: "absolute",
|
|
92
|
-
left:
|
|
99
|
+
left: `${H}px`,
|
|
93
100
|
opacity: +!!e,
|
|
94
101
|
_hover: { opacity: 1 },
|
|
95
102
|
_focusVisible: { opacity: 1 },
|
|
96
103
|
css: { "&:has(:focus-visible)": { opacity: 1 } },
|
|
97
|
-
children: /* @__PURE__ */
|
|
104
|
+
children: /* @__PURE__ */ x(i, {
|
|
98
105
|
icon: n,
|
|
99
106
|
variant: "ghost",
|
|
100
107
|
size: "xs",
|
|
101
|
-
"aria-label":
|
|
108
|
+
"aria-label": P.moreActions,
|
|
102
109
|
borderRadius: "0"
|
|
103
110
|
})
|
|
104
|
-
}),
|
|
111
|
+
}), O]
|
|
105
112
|
}) }),
|
|
106
|
-
|
|
113
|
+
k && /* @__PURE__ */ x(_, {
|
|
107
114
|
display: "contents",
|
|
108
115
|
onClick: (e) => e.stopPropagation(),
|
|
109
116
|
onKeyDown: (e) => e.stopPropagation(),
|
|
110
|
-
children: /* @__PURE__ */
|
|
117
|
+
children: /* @__PURE__ */ x(_, {
|
|
111
118
|
position: "absolute",
|
|
112
|
-
left:
|
|
113
|
-
children: /* @__PURE__ */
|
|
114
|
-
isChecked:
|
|
115
|
-
onCheckedChange:
|
|
116
|
-
isDisabled:
|
|
119
|
+
left: `${H + (O ? 24 : 0)}px`,
|
|
120
|
+
children: /* @__PURE__ */ x(a, {
|
|
121
|
+
isChecked: J,
|
|
122
|
+
onCheckedChange: q,
|
|
123
|
+
isDisabled: A
|
|
117
124
|
})
|
|
118
125
|
})
|
|
119
126
|
}),
|
|
120
|
-
|
|
121
|
-
row:
|
|
122
|
-
localeString:
|
|
123
|
-
hidden: !
|
|
124
|
-
rowIsExpanded:
|
|
125
|
-
}) : /* @__PURE__ */ b
|
|
126
|
-
|
|
127
|
-
/* @__PURE__ */
|
|
128
|
-
style:
|
|
129
|
-
children: s(
|
|
127
|
+
R || C.depth > 0 && L ? /* @__PURE__ */ x(p, {
|
|
128
|
+
row: C,
|
|
129
|
+
localeString: D,
|
|
130
|
+
hidden: !I,
|
|
131
|
+
rowIsExpanded: w
|
|
132
|
+
}) : /* @__PURE__ */ x(b, {}),
|
|
133
|
+
L && W,
|
|
134
|
+
/* @__PURE__ */ x("div", {
|
|
135
|
+
style: F,
|
|
136
|
+
children: s(N.columnDef.cell, m.getContext())
|
|
130
137
|
})
|
|
131
138
|
]
|
|
132
139
|
})
|
|
133
|
-
},
|
|
140
|
+
}, m.id);
|
|
134
141
|
});
|
|
135
142
|
//#endregion
|
|
136
|
-
export {
|
|
143
|
+
export { C as TableCell };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-content.d.ts","sourceRoot":"","sources":["../../../lib/components/table/table-content.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAsB,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"table-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M,YAAY,EAA8B,OAAO,iBAAiB,CAAC"}
|
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
"use no memo";
|
|
2
2
|
import { ThemeColorVariable as e } from "../../theme/theme-types.js";
|
|
3
3
|
import { useVirtualizer as t } from "../../node_modules/@tanstack/react-virtual/dist/esm/index.js";
|
|
4
|
+
import "./table.constants.js";
|
|
4
5
|
import { getClampedColumnWidth as n, getColumnWidth as r } from "./helper.js";
|
|
5
6
|
import { useTableColumnResizeInfo as i, useTableColumnSizeVars as a, useTableContext as o } from "./table-context.js";
|
|
6
|
-
import {
|
|
7
|
-
import { DragDropProvider as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
7
|
+
import { Accessibility as s, AutoScroller as c, Feedback as l } from "../../node_modules/@dnd-kit/dom/index.js";
|
|
8
|
+
import { DragDropProvider as u } from "../../node_modules/@dnd-kit/react/index.js";
|
|
9
|
+
import { createDragAccessibility as d } from "./table-drag-accessibility.js";
|
|
10
|
+
import { TableHeaderRow as f } from "./table-header-row.js";
|
|
11
|
+
import { TableRow as p } from "./table-row.js";
|
|
12
|
+
import { memo as m, useEffect as h, useMemo as g, useRef as _ } from "react";
|
|
13
|
+
import { Box as v, Table as y } from "@chakra-ui/react";
|
|
14
|
+
import { jsx as b, jsxs as x } from "react/jsx-runtime";
|
|
13
15
|
//#region lib/components/table/table-content.tsx
|
|
14
|
-
var
|
|
16
|
+
var S = ({ virtualization: e, ...t }) => e ? /* @__PURE__ */ b(C, {
|
|
15
17
|
...t,
|
|
16
18
|
virtualization: e
|
|
17
|
-
}) : /* @__PURE__ */
|
|
18
|
-
let s = o(), c =
|
|
19
|
+
}) : /* @__PURE__ */ b(w, { ...t }), C = ({ onClickRow: e, onRowClickIndication: n, showRowHoverStyle: r = !0, virtualization: i, ...a }) => {
|
|
20
|
+
let s = o(), c = _(null), l = g(() => s.table.getRowModel().rows, [
|
|
19
21
|
s.expanded,
|
|
20
22
|
s.breakingContentState,
|
|
21
23
|
s.columnVisibility,
|
|
22
24
|
s.sorting,
|
|
23
25
|
s.data,
|
|
26
|
+
s.rowOrder,
|
|
24
27
|
s.columnOrder
|
|
25
|
-
]), u =
|
|
28
|
+
]), u = g(() => {
|
|
26
29
|
let e = i.estimateRowHeight ?? 40, t = i.overscan ?? 5;
|
|
27
30
|
return {
|
|
28
31
|
count: l.length,
|
|
@@ -38,19 +41,19 @@ var y = ({ virtualization: e, ...t }) => e ? /* @__PURE__ */ _(b, {
|
|
|
38
41
|
i.estimateRowHeight,
|
|
39
42
|
i.overscan,
|
|
40
43
|
l
|
|
41
|
-
]),
|
|
42
|
-
let t =
|
|
43
|
-
return /* @__PURE__ */
|
|
44
|
-
t > 0 && /* @__PURE__ */
|
|
44
|
+
]), d = t(u), f = d.getVirtualItems(), m = () => {
|
|
45
|
+
let t = f.length > 0 ? f[0]?.start ?? 0 : 0, i = f.length > 0 ? d.getTotalSize() - (f[f.length - 1]?.end ?? 0) : 0, a = (l[0]?.getVisibleCells().length ?? s.table.getVisibleLeafColumns().length) + +!!s.enableColumnResizing;
|
|
46
|
+
return /* @__PURE__ */ x(y.Body, { children: [
|
|
47
|
+
t > 0 && /* @__PURE__ */ b("tr", {
|
|
45
48
|
style: { height: `${t}px` },
|
|
46
49
|
"aria-hidden": "true",
|
|
47
|
-
children: /* @__PURE__ */
|
|
50
|
+
children: /* @__PURE__ */ b("td", { colSpan: a })
|
|
48
51
|
}),
|
|
49
|
-
|
|
52
|
+
f.map((t) => {
|
|
50
53
|
let i = l[t.index];
|
|
51
54
|
if (!i) return null;
|
|
52
55
|
let a = i.getVisibleCells();
|
|
53
|
-
return /* @__PURE__ */
|
|
56
|
+
return /* @__PURE__ */ b(p, {
|
|
54
57
|
row: i,
|
|
55
58
|
visibleCells: a,
|
|
56
59
|
onClickRow: e,
|
|
@@ -58,14 +61,14 @@ var y = ({ virtualization: e, ...t }) => e ? /* @__PURE__ */ _(b, {
|
|
|
58
61
|
showRowHoverStyle: r
|
|
59
62
|
}, i.id);
|
|
60
63
|
}),
|
|
61
|
-
i > 0 && /* @__PURE__ */
|
|
64
|
+
i > 0 && /* @__PURE__ */ b("tr", {
|
|
62
65
|
style: { height: `${i}px` },
|
|
63
66
|
"aria-hidden": "true",
|
|
64
|
-
children: /* @__PURE__ */
|
|
67
|
+
children: /* @__PURE__ */ b("td", { colSpan: a })
|
|
65
68
|
})
|
|
66
69
|
] });
|
|
67
70
|
};
|
|
68
|
-
return /* @__PURE__ */
|
|
71
|
+
return /* @__PURE__ */ b(v, {
|
|
69
72
|
ref: c,
|
|
70
73
|
overflowY: "auto",
|
|
71
74
|
height: i.height ?? "600px",
|
|
@@ -80,24 +83,25 @@ var y = ({ virtualization: e, ...t }) => e ? /* @__PURE__ */ _(b, {
|
|
|
80
83
|
outline: "none",
|
|
81
84
|
boxShadow: "none"
|
|
82
85
|
},
|
|
83
|
-
children: /* @__PURE__ */
|
|
86
|
+
children: /* @__PURE__ */ b(O, {
|
|
84
87
|
...a,
|
|
85
|
-
children:
|
|
88
|
+
children: m()
|
|
86
89
|
})
|
|
87
90
|
});
|
|
88
|
-
},
|
|
89
|
-
let i = o(), a =
|
|
91
|
+
}, w = ({ onClickRow: e, onRowClickIndication: t, showRowHoverStyle: n = !0, ...r }) => {
|
|
92
|
+
let i = o(), a = g(() => i.table.getRowModel().rows, [
|
|
90
93
|
i.expanded,
|
|
91
94
|
i.breakingContentState,
|
|
92
95
|
i.columnVisibility,
|
|
93
96
|
i.sorting,
|
|
94
|
-
i.data
|
|
97
|
+
i.data,
|
|
98
|
+
i.rowOrder
|
|
95
99
|
]);
|
|
96
|
-
return /* @__PURE__ */
|
|
100
|
+
return /* @__PURE__ */ b(O, {
|
|
97
101
|
...r,
|
|
98
|
-
children: /* @__PURE__ */
|
|
102
|
+
children: /* @__PURE__ */ b(y.Body, { children: a.map((r) => {
|
|
99
103
|
let i = r.getVisibleCells();
|
|
100
|
-
return /* @__PURE__ */
|
|
104
|
+
return /* @__PURE__ */ b(p, {
|
|
101
105
|
row: r,
|
|
102
106
|
visibleCells: i,
|
|
103
107
|
onClickRow: e,
|
|
@@ -107,7 +111,17 @@ var y = ({ virtualization: e, ...t }) => e ? /* @__PURE__ */ _(b, {
|
|
|
107
111
|
}) })
|
|
108
112
|
});
|
|
109
113
|
};
|
|
110
|
-
function
|
|
114
|
+
function T() {
|
|
115
|
+
let e = _(null);
|
|
116
|
+
return h(() => {
|
|
117
|
+
let t = e.current;
|
|
118
|
+
e.current = null, t && document.activeElement === document.body && t.focus();
|
|
119
|
+
}), (t) => {
|
|
120
|
+
let n = document.activeElement, r = n === t?.handle || n === t?.element;
|
|
121
|
+
e.current = r && n instanceof HTMLElement ? n : null;
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function E(e) {
|
|
111
125
|
let t = e?.parentElement ?? null;
|
|
112
126
|
for (; t;) {
|
|
113
127
|
let e = t.ownerDocument.defaultView?.getComputedStyle(t).overflowX;
|
|
@@ -116,13 +130,13 @@ function S(e) {
|
|
|
116
130
|
}
|
|
117
131
|
return 0;
|
|
118
132
|
}
|
|
119
|
-
var
|
|
133
|
+
var D = ({ contentRef: t }) => {
|
|
120
134
|
let r = o(), a = i(), s = a?.isResizingColumn;
|
|
121
135
|
if (!s) return null;
|
|
122
136
|
let c = r.table.getFlatHeaders().find((e) => e.column.id === s);
|
|
123
137
|
if (!c) return null;
|
|
124
|
-
let l = c.column.getIsPinned() === "left" ?
|
|
125
|
-
return /* @__PURE__ */
|
|
138
|
+
let l = c.column.getIsPinned() === "left" ? E(t.current) : 0, u = c.getSize() + (a?.deltaOffset ?? 0), d = n(c.column, u), f = c.getStart() + d + l;
|
|
139
|
+
return /* @__PURE__ */ b(v, {
|
|
126
140
|
"aria-hidden": !0,
|
|
127
141
|
className: "tableColumnResizeIndicator",
|
|
128
142
|
position: "absolute",
|
|
@@ -134,21 +148,21 @@ var C = ({ contentRef: t }) => {
|
|
|
134
148
|
zIndex: 11,
|
|
135
149
|
style: { left: `${f}px` }
|
|
136
150
|
});
|
|
137
|
-
},
|
|
138
|
-
let
|
|
139
|
-
...
|
|
151
|
+
}, O = ({ hideTableHeaderDropdown: e, stickyHeaders: t, portalContainerRef: n, children: i, ...p }) => {
|
|
152
|
+
let m = o(), h = T(), g = _(null), S = a(), C = m.enableColumnResizing ? {
|
|
153
|
+
...S,
|
|
140
154
|
tableLayout: "fixed",
|
|
141
155
|
width: "100%",
|
|
142
|
-
minWidth:
|
|
143
|
-
} : void 0,
|
|
144
|
-
...
|
|
145
|
-
id:
|
|
146
|
-
style:
|
|
156
|
+
minWidth: m.table.getTotalSize()
|
|
157
|
+
} : void 0, w = m.enableColumnResizing ? /* @__PURE__ */ b("colgroup", { children: m.table.getVisibleLeafColumns().map((e) => /* @__PURE__ */ b("col", { style: { width: r(e, !0) } }, e.id)) }) : null, E = /* @__PURE__ */ x(y.Root, {
|
|
158
|
+
...p,
|
|
159
|
+
id: m.id,
|
|
160
|
+
style: C,
|
|
147
161
|
children: [
|
|
148
|
-
|
|
149
|
-
/* @__PURE__ */
|
|
162
|
+
w,
|
|
163
|
+
/* @__PURE__ */ b(y.Header, {
|
|
150
164
|
"data-sticky-headers": t,
|
|
151
|
-
children:
|
|
165
|
+
children: m.table.getHeaderGroups().map((t) => /* @__PURE__ */ b(f, {
|
|
152
166
|
headerGroup: t,
|
|
153
167
|
hideTableHeaderDropdown: e,
|
|
154
168
|
portalContainerRef: n
|
|
@@ -156,20 +170,34 @@ var C = ({ contentRef: t }) => {
|
|
|
156
170
|
}),
|
|
157
171
|
i
|
|
158
172
|
]
|
|
159
|
-
}),
|
|
160
|
-
ref:
|
|
173
|
+
}), O = m.enableColumnResizing ? /* @__PURE__ */ x(v, {
|
|
174
|
+
ref: g,
|
|
161
175
|
position: "relative",
|
|
162
176
|
isolation: "isolate",
|
|
163
|
-
children: [
|
|
164
|
-
}) :
|
|
165
|
-
return
|
|
177
|
+
children: [E, /* @__PURE__ */ b(D, { contentRef: g })]
|
|
178
|
+
}) : E;
|
|
179
|
+
return m.enableColumnReorder || m.rowReorderMode === "enabled" ? /* @__PURE__ */ b(u, {
|
|
166
180
|
onDragEnd: (e) => {
|
|
167
|
-
let { operation: t } = e
|
|
168
|
-
|
|
181
|
+
let { operation: t } = e;
|
|
182
|
+
if (e.canceled) return;
|
|
183
|
+
let n = String(t.source?.id), r = String(t.target?.id);
|
|
184
|
+
n !== r && (t.source?.type === "table-row" ? m.handleRowDragEnd(n, r) : m.handleDragEnd(n, r), h(t.source));
|
|
169
185
|
},
|
|
170
|
-
plugins: (e) => [
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
186
|
+
plugins: (e) => [
|
|
187
|
+
...e.filter((e) => e !== c && e !== s),
|
|
188
|
+
d({
|
|
189
|
+
localeString: m.localeString,
|
|
190
|
+
rowCount: m.rowOrder.length,
|
|
191
|
+
columnCount: m.table.getVisibleLeafColumns().length
|
|
192
|
+
}),
|
|
193
|
+
...m.rowReorderMode === "enabled" ? [c.configure({ threshold: {
|
|
194
|
+
x: 0,
|
|
195
|
+
y: .2
|
|
196
|
+
} })] : [],
|
|
197
|
+
l.configure({ dropAnimation: null })
|
|
198
|
+
],
|
|
199
|
+
children: O
|
|
200
|
+
}) : O;
|
|
201
|
+
}, k = m(S);
|
|
174
202
|
//#endregion
|
|
175
|
-
export {
|
|
203
|
+
export { k as TableContent };
|
|
@@ -2,11 +2,19 @@ import { MenuList } from '../menu/index.js';
|
|
|
2
2
|
import { ColumnDef, ColumnOrderState, ColumnPinningState, ColumnSizingState, ExpandedState, Row, RowSelectionState, SortingState, Table, VisibilityState } from '@tanstack/react-table';
|
|
3
3
|
import { PropsWithChildren } from 'react';
|
|
4
4
|
import { Locales } from './translations.js';
|
|
5
|
-
import { SelectionAction, TableData, TableRow } from './types.js';
|
|
5
|
+
import { RowReorderDetails, SelectionAction, TableData, TableRow } from './types.js';
|
|
6
6
|
export interface TableFilterMethods {
|
|
7
7
|
onToggleFilterVisibility: (columnId: string) => void;
|
|
8
8
|
canFilterOnColumn: (columnId: string) => boolean;
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Defines the current state of row reordering.
|
|
12
|
+
*
|
|
13
|
+
* - `off` - row reordering is disabled; no grip or space is reserved
|
|
14
|
+
* - `blockedBySort` - the grip is visible, but sorting prevents reordering; dragging prompts the user to clear the sort
|
|
15
|
+
* - `enabled` - row reordering is enabled and dragging moves the row
|
|
16
|
+
*/
|
|
17
|
+
export type RowReorderMode = "off" | "blockedBySort" | "enabled";
|
|
10
18
|
interface TableProviderInterface<TData extends TableData> extends PropsWithChildren {
|
|
11
19
|
data: TableRow<TData>[];
|
|
12
20
|
columns: ColumnDef<TableRow<TData>>[];
|
|
@@ -39,6 +47,8 @@ interface TableProviderInterface<TData extends TableData> extends PropsWithChild
|
|
|
39
47
|
enableColumnResizing?: boolean;
|
|
40
48
|
initialColumnSizingState?: ColumnSizingState;
|
|
41
49
|
onColumnSizingChange?: (state: ColumnSizingState) => void;
|
|
50
|
+
enableRowReorder?: boolean;
|
|
51
|
+
onRowOrderChange?: (details: RowReorderDetails) => void;
|
|
42
52
|
}
|
|
43
53
|
export interface TableContextInterface<TData extends TableData = TableData> {
|
|
44
54
|
data: TableRow<TData>[];
|
|
@@ -81,7 +91,12 @@ export interface TableContextInterface<TData extends TableData = TableData> {
|
|
|
81
91
|
handleDragEnd: (sourceId: string, targetId: string) => void;
|
|
82
92
|
enableColumnResizing: boolean;
|
|
83
93
|
columnPinning: ColumnPinningState;
|
|
94
|
+
rowReorderMode: RowReorderMode;
|
|
95
|
+
setIsSortedReorderPromptOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
|
96
|
+
/** IDs of the top-level rows in the order they currently render. */
|
|
97
|
+
rowOrder: string[];
|
|
98
|
+
handleRowDragEnd: (sourceId: string, targetId: string) => void;
|
|
84
99
|
}
|
|
85
|
-
export declare const TableProvider: <TData extends TableData>({ data, totalDataCount, columns, children, expandedState, localeString, initialExpandedState, initialBreakingContentState, initialColumnVisibilityState, columnVisibilityState, onColumnVisibilityChange, onExpandedChange, getRowId, getRowActions, onBreakingContentChange, id, customRowIndication, onSortingChange, initialSortingState, sortingState, selectionState, initialSelectionState, onSelectionChange, selectionActions, disableSelectionCheckbox, enableColumnReorder, columnOrderState, initialColumnOrder, onColumnOrderChange, enableColumnResizing, initialColumnSizingState, onColumnSizingChange, }: TableProviderInterface<TData>) => import("react").JSX.Element;
|
|
100
|
+
export declare const TableProvider: <TData extends TableData>({ data, totalDataCount, columns, children, expandedState, localeString, initialExpandedState, initialBreakingContentState, initialColumnVisibilityState, columnVisibilityState, onColumnVisibilityChange, onExpandedChange, getRowId, getRowActions, onBreakingContentChange, id, customRowIndication, onSortingChange, initialSortingState, sortingState, selectionState, initialSelectionState, onSelectionChange, selectionActions, disableSelectionCheckbox, enableColumnReorder, columnOrderState, initialColumnOrder, onColumnOrderChange, enableColumnResizing, initialColumnSizingState, onColumnSizingChange, enableRowReorder, onRowOrderChange, }: TableProviderInterface<TData>) => import("react").JSX.Element;
|
|
86
101
|
export {};
|
|
87
102
|
//# sourceMappingURL=table-context-provider.d.ts.map
|