@koobiq/react-components 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Table/Table.d.ts +2 -1
- package/dist/components/Table/Table.js +17 -29
- package/dist/components/Table/Table.module.css.js +5 -5
- package/dist/components/Table/components/TableContainer/TableContainer.d.ts +4 -0
- package/dist/components/Table/components/TableContainer/TableContainer.js +30 -0
- package/dist/components/Table/components/TableContainer/TableContainer.module.css.js +8 -0
- package/dist/components/Table/components/TableContainer/TableContainerContext.d.ts +6 -0
- package/dist/components/Table/components/TableContainer/TableContainerContext.js +10 -0
- package/dist/components/Table/components/TableContainer/index.d.ts +3 -0
- package/dist/components/Table/components/TableContainer/types.d.ts +18 -0
- package/dist/components/Table/components/TableContainer/utils.d.ts +2 -0
- package/dist/components/Table/components/index.d.ts +1 -0
- package/dist/components/Table/types.d.ts +7 -12
- package/dist/index.js +2 -0
- package/dist/style.css +21 -14
- package/package.json +5 -5
- package/dist/components/Table/utils.d.ts +0 -2
- /package/dist/components/Table/{utils.js → components/TableContainer/utils.js} +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Cell, Row, Column, TableBody, TableHeader } from '../Collections';
|
|
2
|
+
import { TableContainer } from './components';
|
|
2
3
|
import type { TableComponent } from './types';
|
|
3
4
|
declare const TableComponent: TableComponent;
|
|
4
5
|
type CompoundedComponent = typeof TableComponent & {
|
|
@@ -9,4 +10,4 @@ type CompoundedComponent = typeof TableComponent & {
|
|
|
9
10
|
Cell: typeof Cell;
|
|
10
11
|
};
|
|
11
12
|
export declare const Table: CompoundedComponent;
|
|
12
|
-
export {};
|
|
13
|
+
export { TableContainer };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { forwardRef
|
|
4
|
-
import { useDOMRef, mergeProps,
|
|
2
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { useDOMRef, mergeProps, clsx } from "@koobiq/react-core";
|
|
5
5
|
import { useTableState, useTable } from "@koobiq/react-primitives";
|
|
6
6
|
import { utilClasses } from "../../styles/utility.js";
|
|
7
7
|
import s from "./Table.module.css.js";
|
|
8
|
-
import {
|
|
8
|
+
import { useTableContainerContext } from "./components/TableContainer/TableContainerContext.js";
|
|
9
9
|
import { TableRowGroup } from "./components/TableRowGroup/TableRowGroup.js";
|
|
10
10
|
import { TableHeaderRow } from "./components/TableHeaderRow/TableHeaderRow.js";
|
|
11
11
|
import { TableSelectAllCell } from "./components/TableSelectAllCell/TableSelectAllCell.js";
|
|
@@ -22,47 +22,35 @@ const textNormal = utilClasses.typography["text-normal"];
|
|
|
22
22
|
function TableRender(props, ref) {
|
|
23
23
|
const {
|
|
24
24
|
stickyHeader = false,
|
|
25
|
+
fullWidth = false,
|
|
25
26
|
divider = "none",
|
|
26
27
|
slotProps,
|
|
27
28
|
selectionMode,
|
|
28
29
|
selectionBehavior,
|
|
29
30
|
className,
|
|
30
|
-
|
|
31
|
-
maxBlockSize,
|
|
32
|
-
minBlockSize,
|
|
33
|
-
style: styleProp
|
|
31
|
+
style
|
|
34
32
|
} = props;
|
|
33
|
+
const { theadRef } = useTableContainerContext();
|
|
35
34
|
const state = useTableState({
|
|
36
35
|
...props,
|
|
37
36
|
showSelectionCheckboxes: selectionMode === "multiple" && selectionBehavior !== "replace"
|
|
38
37
|
});
|
|
39
38
|
const domRef = useDOMRef(ref);
|
|
40
|
-
const tableRef = useRef(null);
|
|
41
39
|
const { collection } = state;
|
|
42
|
-
const { gridProps } = useTable(props, state,
|
|
40
|
+
const { gridProps } = useTable(props, state, domRef);
|
|
43
41
|
const tableProps = mergeProps(
|
|
44
|
-
{ ref: tableRef, className: s.base },
|
|
45
|
-
gridProps,
|
|
46
|
-
slotProps?.table
|
|
47
|
-
);
|
|
48
|
-
const { ref: theadRef, height } = useElementSize();
|
|
49
|
-
const containerProps = mergeProps(
|
|
50
42
|
{
|
|
51
|
-
className: clsx(s.
|
|
52
|
-
"data-divider": divider,
|
|
43
|
+
className: clsx(s.base, fullWidth && s.fullWidth, textNormal, className),
|
|
53
44
|
"data-sticky-header": stickyHeader,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"--table-container-max-block-size": normalizeBlockSize(maxBlockSize),
|
|
59
|
-
"--table-container-scroll-padding-top": `${height}px`
|
|
60
|
-
},
|
|
61
|
-
ref: domRef
|
|
45
|
+
"data-divider": divider,
|
|
46
|
+
"data-fullwidth": fullWidth,
|
|
47
|
+
ref: domRef,
|
|
48
|
+
style
|
|
62
49
|
},
|
|
63
|
-
|
|
50
|
+
gridProps,
|
|
51
|
+
slotProps?.root
|
|
64
52
|
);
|
|
65
|
-
return /* @__PURE__ */
|
|
53
|
+
return /* @__PURE__ */ jsxs("table", { ...tableProps, children: [
|
|
66
54
|
/* @__PURE__ */ jsx(TableRowGroup, { type: "thead", ref: theadRef, children: collection.headerRows.map((headerRow) => /* @__PURE__ */ jsx(TableHeaderRow, { item: headerRow, state, children: [...headerRow.childNodes].map(
|
|
67
55
|
(column) => column.props.isSelectionCell ? /* @__PURE__ */ jsx(
|
|
68
56
|
TableSelectAllCell,
|
|
@@ -83,7 +71,7 @@ function TableRender(props, ref) {
|
|
|
83
71
|
/* @__PURE__ */ jsx(TableRowGroup, { type: "tbody", children: [...collection.body.childNodes].map((row) => /* @__PURE__ */ jsx(TableRow, { item: row, state, children: [...row.childNodes].map(
|
|
84
72
|
(cell) => cell.props.isSelectionCell ? /* @__PURE__ */ jsx(TableCheckboxCell, { cell, state }, cell.key) : /* @__PURE__ */ jsx(TableCell, { cell, state }, cell.key)
|
|
85
73
|
) }, row.key)) })
|
|
86
|
-
] })
|
|
74
|
+
] });
|
|
87
75
|
}
|
|
88
76
|
const TableComponent = forwardRef(TableRender);
|
|
89
77
|
const Table = TableComponent;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
const container = "kbq-table-container-ecbaa4";
|
|
2
1
|
const base = "kbq-table-55e555";
|
|
2
|
+
const fullWidth = "kbq-table-fullWidth-419d42";
|
|
3
3
|
const s = {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
base,
|
|
5
|
+
fullWidth
|
|
6
6
|
};
|
|
7
7
|
export {
|
|
8
8
|
base,
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
s as default,
|
|
10
|
+
fullWidth
|
|
11
11
|
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ComponentPropsWithRef, ElementType } from 'react';
|
|
2
|
+
import type { TableContainerBaseProps } from './types';
|
|
3
|
+
export declare const TableContainer: import("@koobiq/react-core").PolyForwardComponent<"div", TableContainerBaseProps, ElementType>;
|
|
4
|
+
export type TableContainerProps<As extends ElementType = 'div'> = ComponentPropsWithRef<typeof TableContainer<As>>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { polymorphicForwardRef, useElementSize, clsx } from "@koobiq/react-core";
|
|
4
|
+
import s from "./TableContainer.module.css.js";
|
|
5
|
+
import { TableContainerContext } from "./TableContainerContext.js";
|
|
6
|
+
import { normalizeBlockSize } from "./utils.js";
|
|
7
|
+
const TableContainer = polymorphicForwardRef((props, ref) => {
|
|
8
|
+
const {
|
|
9
|
+
as: Tag = "div",
|
|
10
|
+
children,
|
|
11
|
+
className,
|
|
12
|
+
blockSize,
|
|
13
|
+
maxBlockSize,
|
|
14
|
+
minBlockSize,
|
|
15
|
+
style: styleProp
|
|
16
|
+
} = props;
|
|
17
|
+
const { ref: theadRef, height } = useElementSize();
|
|
18
|
+
const style = {
|
|
19
|
+
...styleProp,
|
|
20
|
+
"--table-container-block-size": normalizeBlockSize(blockSize),
|
|
21
|
+
"--table-container-min-block-size": normalizeBlockSize(minBlockSize),
|
|
22
|
+
"--table-container-max-block-size": normalizeBlockSize(maxBlockSize),
|
|
23
|
+
"--table-container-scroll-padding-top": `${height}px`
|
|
24
|
+
};
|
|
25
|
+
return /* @__PURE__ */ jsx(TableContainerContext.Provider, { value: { theadRef }, children: /* @__PURE__ */ jsx(Tag, { className: clsx(s.base, className), style, ref, children }) });
|
|
26
|
+
});
|
|
27
|
+
TableContainer.displayName = "TableContainer";
|
|
28
|
+
export {
|
|
29
|
+
TableContainer
|
|
30
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Ref } from 'react';
|
|
2
|
+
export type TableContainerContextProps = {
|
|
3
|
+
theadRef: Ref<HTMLElement>;
|
|
4
|
+
};
|
|
5
|
+
export declare const TableContainerContext: import("react").Context<TableContainerContextProps>;
|
|
6
|
+
export declare const useTableContainerContext: () => TableContainerContextProps;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
const TableContainerContext = createContext(
|
|
4
|
+
{}
|
|
5
|
+
);
|
|
6
|
+
const useTableContainerContext = () => useContext(TableContainerContext);
|
|
7
|
+
export {
|
|
8
|
+
TableContainerContext,
|
|
9
|
+
useTableContainerContext
|
|
10
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
export type TableContainerPropBlockSize = CSSProperties['blockSize'];
|
|
3
|
+
export type TableContainerPropMinBlockSize = CSSProperties['minBlockSize'];
|
|
4
|
+
export type TableContainerPropMaxBlockSize = CSSProperties['maxInlineSize'];
|
|
5
|
+
export type TableContainerBaseProps = {
|
|
6
|
+
/** Height of the table container. */
|
|
7
|
+
blockSize?: TableContainerPropBlockSize;
|
|
8
|
+
/** Minimum height of the table container. */
|
|
9
|
+
minBlockSize?: TableContainerPropMinBlockSize;
|
|
10
|
+
/** Maximum height of the table container. */
|
|
11
|
+
maxBlockSize?: TableContainerPropMaxBlockSize;
|
|
12
|
+
/** The content of the component. */
|
|
13
|
+
children?: ReactNode;
|
|
14
|
+
/** Additional CSS-classes. */
|
|
15
|
+
className?: string;
|
|
16
|
+
/** Inline styles. */
|
|
17
|
+
style?: CSSProperties;
|
|
18
|
+
};
|
|
@@ -4,9 +4,6 @@ import type { Key } from '@react-types/shared';
|
|
|
4
4
|
export declare const tablePropDivider: readonly ["none", "row"];
|
|
5
5
|
export type TablePropDivider = (typeof tablePropDivider)[number];
|
|
6
6
|
export type TablePropChildren<T> = TableStateProps<T>['children'];
|
|
7
|
-
export type TablePropBlockSize = CSSProperties['blockSize'];
|
|
8
|
-
export type TablePropMinBlockSize = CSSProperties['minBlockSize'];
|
|
9
|
-
export type TablePropMaxBlockSize = CSSProperties['maxInlineSize'];
|
|
10
7
|
export type TableProps<T> = Pick<TableStateProps<T>, 'selectionBehavior' | 'selectionMode' | 'selectedKeys' | 'defaultSelectedKeys' | 'onSelectionChange' | 'disabledKeys' | 'disabledBehavior'> & {
|
|
11
8
|
/** Handler that is called when a user performs an action on the row. */
|
|
12
9
|
onRowAction?: (key: Key) => void;
|
|
@@ -21,6 +18,11 @@ export type TableProps<T> = Pick<TableStateProps<T>, 'selectionBehavior' | 'sele
|
|
|
21
18
|
* @default 'none'
|
|
22
19
|
*/
|
|
23
20
|
divider?: TablePropDivider;
|
|
21
|
+
/**
|
|
22
|
+
* If `true`, the button will take up the full width of its container.
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
fullWidth?: boolean;
|
|
24
26
|
/**
|
|
25
27
|
* Flag indicating a fixed table header.
|
|
26
28
|
* @default false
|
|
@@ -32,17 +34,10 @@ export type TableProps<T> = Pick<TableStateProps<T>, 'selectionBehavior' | 'sele
|
|
|
32
34
|
*/
|
|
33
35
|
children?: TablePropChildren<T>;
|
|
34
36
|
/** Ref to the control. */
|
|
35
|
-
ref?: Ref<
|
|
36
|
-
/** Height of the table container. */
|
|
37
|
-
blockSize?: TablePropBlockSize;
|
|
38
|
-
/** Minimum height of the table container. */
|
|
39
|
-
minBlockSize?: TablePropMinBlockSize;
|
|
40
|
-
/** Maximum height of the table container. */
|
|
41
|
-
maxBlockSize?: TablePropMaxBlockSize;
|
|
37
|
+
ref?: Ref<HTMLTableElement>;
|
|
42
38
|
/** The props used for each slot inside. */
|
|
43
39
|
slotProps?: {
|
|
44
|
-
|
|
45
|
-
table?: ComponentPropsWithRef<'table'>;
|
|
40
|
+
root?: ComponentPropsWithRef<'table'>;
|
|
46
41
|
};
|
|
47
42
|
};
|
|
48
43
|
export type TableComponent = <T>(props: TableProps<T>) => ReactElement | null;
|
package/dist/index.js
CHANGED
|
@@ -72,6 +72,7 @@ import { TagGroup } from "./components/TagGroup/TagGroup.js";
|
|
|
72
72
|
import { Tag } from "./components/TagGroup/Tag.js";
|
|
73
73
|
import { tagGroupPropVariant } from "./components/TagGroup/types.js";
|
|
74
74
|
import { Table } from "./components/Table/Table.js";
|
|
75
|
+
import { TableContainer } from "./components/Table/components/TableContainer/TableContainer.js";
|
|
75
76
|
import { Calendar } from "./components/Calendar/Calendar.js";
|
|
76
77
|
import { DateInput, DateInputRender } from "./components/DateInput/DateInput.js";
|
|
77
78
|
import { dateInputPropVariant } from "./components/DateInput/types.js";
|
|
@@ -138,6 +139,7 @@ export {
|
|
|
138
139
|
SkeletonBlock,
|
|
139
140
|
SkeletonTypography,
|
|
140
141
|
Table,
|
|
142
|
+
TableContainer,
|
|
141
143
|
Tag,
|
|
142
144
|
TagGroup,
|
|
143
145
|
Textarea,
|
package/dist/style.css
CHANGED
|
@@ -3605,20 +3605,17 @@
|
|
|
3605
3605
|
.kbq-taggroup-20136b [role="gridcell"] {
|
|
3606
3606
|
display: contents;
|
|
3607
3607
|
}
|
|
3608
|
-
.kbq-table-
|
|
3609
|
-
--table-container-block-size: 100%;
|
|
3610
|
-
--table-container-min-block-size: unset;
|
|
3611
|
-
--table-container-max-block-size: unset;
|
|
3612
|
-
--table-container-scroll-padding-top: 0;
|
|
3608
|
+
.kbq-table-55e555 {
|
|
3613
3609
|
--table-cell-padding: 10px var(--kbq-size-s);
|
|
3614
3610
|
--table-cell-color: var(--kbq-foreground-contrast);
|
|
3615
3611
|
--table-header-cell-padding: 10px var(--kbq-size-s);
|
|
3616
3612
|
--table-border: 1px solid var(--kbq-line-contrast-less);
|
|
3617
3613
|
--table-header-cell-color: var(--kbq-foreground-contrast-secondary);
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3614
|
+
border-spacing: 0;
|
|
3615
|
+
}
|
|
3616
|
+
|
|
3617
|
+
.kbq-table-fullWidth-419d42 {
|
|
3618
|
+
inline-size: 100%;
|
|
3622
3619
|
}
|
|
3623
3620
|
|
|
3624
3621
|
[data-divider="none"] tbody td:first-child {
|
|
@@ -3665,11 +3662,6 @@
|
|
|
3665
3662
|
inset-block-start: 0;
|
|
3666
3663
|
}
|
|
3667
3664
|
|
|
3668
|
-
.kbq-table-55e555 {
|
|
3669
|
-
border-spacing: 0;
|
|
3670
|
-
inline-size: 100%;
|
|
3671
|
-
}
|
|
3672
|
-
|
|
3673
3665
|
[aria-multiselectable="true"] tbody tr:is([data-selected="true"], [data-focus-visible="true"]):has( + :is([data-selected="true"], [data-focus-visible="true"])) {
|
|
3674
3666
|
border-end-end-radius: 0;
|
|
3675
3667
|
border-end-start-radius: 0;
|
|
@@ -3825,6 +3817,21 @@
|
|
|
3825
3817
|
outline-offset: -2px;
|
|
3826
3818
|
outline: 2px solid var(--kbq-states-line-focus-theme);
|
|
3827
3819
|
}
|
|
3820
|
+
.kbq-tablecontainer-0c5c0f {
|
|
3821
|
+
--table-container-block-size: ;
|
|
3822
|
+
--table-container-min-block-size: unset;
|
|
3823
|
+
--table-container-max-block-size: unset;
|
|
3824
|
+
--table-container-scroll-padding-top: 0;
|
|
3825
|
+
block-size: var(--table-container-block-size);
|
|
3826
|
+
min-block-size: var(--table-container-min-block-size);
|
|
3827
|
+
max-block-size: var(--table-container-max-block-size);
|
|
3828
|
+
scroll-padding-block-start: var(--table-container-scroll-padding-top);
|
|
3829
|
+
overflow: auto;
|
|
3830
|
+
}
|
|
3831
|
+
|
|
3832
|
+
.kbq-tablecontainer-0c5c0f table {
|
|
3833
|
+
inline-size: 100%;
|
|
3834
|
+
}
|
|
3828
3835
|
.kbq-calendar-fa3168 {
|
|
3829
3836
|
--calendar-cell-inline-size: 40px;
|
|
3830
3837
|
--calendar-cell-block-size: 32px;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koobiq/react-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"@koobiq/design-tokens": "^3.14.0",
|
|
29
29
|
"@types/react-transition-group": "^4.4.12",
|
|
30
30
|
"react-transition-group": "^4.4.5",
|
|
31
|
-
"@koobiq/
|
|
32
|
-
"@koobiq/
|
|
33
|
-
"@koobiq/react-
|
|
34
|
-
"@koobiq/react-primitives": "0.
|
|
31
|
+
"@koobiq/logger": "0.6.0",
|
|
32
|
+
"@koobiq/react-icons": "0.6.0",
|
|
33
|
+
"@koobiq/react-core": "0.6.0",
|
|
34
|
+
"@koobiq/react-primitives": "0.6.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@koobiq/design-tokens": "^3.14.0",
|
|
File without changes
|