@koobiq/react-components 0.0.1-beta.24 → 0.0.1-beta.25

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.
Files changed (45) hide show
  1. package/dist/components/Collections/Cell.d.ts +28 -0
  2. package/dist/components/Collections/Cell.js +10 -0
  3. package/dist/components/Collections/Column.d.ts +28 -0
  4. package/dist/components/Collections/Column.js +10 -0
  5. package/dist/components/Collections/Row.d.ts +14 -0
  6. package/dist/components/Collections/Row.js +10 -0
  7. package/dist/components/Collections/TableBody.d.ts +6 -0
  8. package/dist/components/Collections/TableBody.js +10 -0
  9. package/dist/components/Collections/TableHeader.d.ts +6 -0
  10. package/dist/components/Collections/TableHeader.js +10 -0
  11. package/dist/components/Collections/index.d.ts +5 -0
  12. package/dist/components/Table/Table.d.ts +12 -0
  13. package/dist/components/Table/Table.js +104 -0
  14. package/dist/components/Table/Table.module.css.js +55 -0
  15. package/dist/components/Table/components/TableCell/TableCell.d.ts +7 -0
  16. package/dist/components/Table/components/TableCell/TableCell.js +39 -0
  17. package/dist/components/Table/components/TableCell/index.d.ts +1 -0
  18. package/dist/components/Table/components/TableCheckboxCell/TableCheckboxCell.d.ts +7 -0
  19. package/dist/components/Table/components/TableCheckboxCell/TableCheckboxCell.js +21 -0
  20. package/dist/components/Table/components/TableCheckboxCell/index.d.ts +1 -0
  21. package/dist/components/Table/components/TableColumnHeader/TableColumnHeader.d.ts +7 -0
  22. package/dist/components/Table/components/TableColumnHeader/TableColumnHeader.js +46 -0
  23. package/dist/components/Table/components/TableColumnHeader/index.d.ts +1 -0
  24. package/dist/components/Table/components/TableHeaderRow/TableHeaderRow.d.ts +9 -0
  25. package/dist/components/Table/components/TableHeaderRow/TableHeaderRow.js +16 -0
  26. package/dist/components/Table/components/TableHeaderRow/index.d.ts +1 -0
  27. package/dist/components/Table/components/TableRow/TableRow.d.ts +9 -0
  28. package/dist/components/Table/components/TableRow/TableRow.js +46 -0
  29. package/dist/components/Table/components/TableRow/index.d.ts +1 -0
  30. package/dist/components/Table/components/TableRowGroup/TableRowGroup.d.ts +6 -0
  31. package/dist/components/Table/components/TableRowGroup/TableRowGroup.js +17 -0
  32. package/dist/components/Table/components/TableRowGroup/index.d.ts +1 -0
  33. package/dist/components/Table/components/TableSelectAllCell/TableSelectAllCell.d.ts +7 -0
  34. package/dist/components/Table/components/TableSelectAllCell/TableSelectAllCell.js +22 -0
  35. package/dist/components/Table/components/TableSelectAllCell/index.d.ts +1 -0
  36. package/dist/components/Table/components/index.d.ts +7 -0
  37. package/dist/components/Table/index.d.ts +1 -0
  38. package/dist/components/Table/types.d.ts +76 -0
  39. package/dist/components/Table/utils.d.ts +2 -0
  40. package/dist/components/Table/utils.js +8 -0
  41. package/dist/components/TagGroup/TagGroup.js +1 -0
  42. package/dist/components/index.d.ts +1 -0
  43. package/dist/index.js +2 -0
  44. package/dist/style.css +177 -0
  45. package/package.json +5 -5
@@ -0,0 +1,28 @@
1
+ import type { CSSProperties } from 'react';
2
+ import type { CellProps as AriaCellProps } from '@koobiq/react-primitives';
3
+ export declare const cellPropAlign: readonly ["left", "right", "center"];
4
+ export declare const cellPropVerticalAlign: readonly ["baseline", "top", "middle", "bottom", "sub", "text-top"];
5
+ export type CellPropAlign = (typeof cellPropAlign)[number];
6
+ export type CellPropVerticalAlign = (typeof cellPropVerticalAlign)[number];
7
+ export type CellProps = AriaCellProps & {
8
+ /** Additional CSS-classes. */
9
+ className?: string;
10
+ /** Inline styles. */
11
+ style?: CSSProperties;
12
+ /** Unique identifier for testing purposes. */
13
+ 'data-testid'?: string | number;
14
+ /**
15
+ * Horizontal alignment of the cell content.
16
+ * @default left
17
+ * */
18
+ align?: CellPropAlign;
19
+ /**
20
+ * Vertical alignment of the cell content.
21
+ * @default middle
22
+ * */
23
+ valign?: CellPropVerticalAlign;
24
+ };
25
+ export declare function Cell(_props: CellProps): null;
26
+ export declare namespace Cell {
27
+ var getCollectionNode: unknown;
28
+ }
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { Cell as Cell$1 } from "@koobiq/react-primitives";
3
+ const CellInner = Cell$1;
4
+ function Cell(_props) {
5
+ return null;
6
+ }
7
+ Cell.getCollectionNode = CellInner.getCollectionNode;
8
+ export {
9
+ Cell
10
+ };
@@ -0,0 +1,28 @@
1
+ import type { CSSProperties } from 'react';
2
+ import type { ColumnProps as AriaColumnProps } from '@koobiq/react-primitives';
3
+ export declare const columnPropAlign: readonly ["left", "right", "center"];
4
+ export declare const columnPropVerticalAlign: readonly ["baseline", "top", "middle", "bottom", "sub", "text-top"];
5
+ export type ColumnPropAlign = (typeof columnPropAlign)[number];
6
+ export type ColumnPropVerticalAlign = (typeof columnPropVerticalAlign)[number];
7
+ export type ColumnProps<T> = Omit<AriaColumnProps<T>, 'allowsResizing' | 'allowsSorting' | 'width' | 'defaultWidth' | 'minWidth' | 'maxWidth'> & {
8
+ /** Additional CSS-classes. */
9
+ className?: string;
10
+ /** Inline styles. */
11
+ style?: CSSProperties;
12
+ /** Unique identifier for testing purposes. */
13
+ 'data-testid'?: string | number;
14
+ /**
15
+ * Horizontal alignment of the cell content.
16
+ * @default left
17
+ * */
18
+ align?: ColumnPropAlign;
19
+ /**
20
+ * Vertical alignment of the cell content.
21
+ * @default middle
22
+ * */
23
+ valign?: ColumnPropVerticalAlign;
24
+ };
25
+ export declare function Column<T>(_props: ColumnProps<T>): null;
26
+ export declare namespace Column {
27
+ var getCollectionNode: unknown;
28
+ }
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { Column as Column$1 } from "@koobiq/react-primitives";
3
+ const ColumnInner = Column$1;
4
+ function Column(_props) {
5
+ return null;
6
+ }
7
+ Column.getCollectionNode = ColumnInner.getCollectionNode;
8
+ export {
9
+ Column
10
+ };
@@ -0,0 +1,14 @@
1
+ import type { CSSProperties } from 'react';
2
+ import type { RowProps as AriaRowProps } from '@koobiq/react-primitives';
3
+ export type RowProps<T> = AriaRowProps<T> & {
4
+ /** Additional CSS-classes. */
5
+ className?: string;
6
+ /** Inline styles. */
7
+ style?: CSSProperties;
8
+ /** Unique identifier for testing purposes. */
9
+ 'data-testid'?: string | number;
10
+ };
11
+ export declare function Row<T>(_props: RowProps<T>): null;
12
+ export declare namespace Row {
13
+ var getCollectionNode: unknown;
14
+ }
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { Row as Row$1 } from "@koobiq/react-primitives";
3
+ const RowInner = Row$1;
4
+ function Row(_props) {
5
+ return null;
6
+ }
7
+ Row.getCollectionNode = RowInner.getCollectionNode;
8
+ export {
9
+ Row
10
+ };
@@ -0,0 +1,6 @@
1
+ import type { TableBodyProps as AriaTableBodyProps } from '@koobiq/react-primitives';
2
+ export type TableBodyProps<T> = AriaTableBodyProps<T>;
3
+ export declare function TableBody<T>(_props: TableBodyProps<T>): null;
4
+ export declare namespace TableBody {
5
+ var getCollectionNode: unknown;
6
+ }
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { TableBody as TableBody$1 } from "@koobiq/react-primitives";
3
+ const TableBodyInner = TableBody$1;
4
+ function TableBody(_props) {
5
+ return null;
6
+ }
7
+ TableBody.getCollectionNode = TableBodyInner.getCollectionNode;
8
+ export {
9
+ TableBody
10
+ };
@@ -0,0 +1,6 @@
1
+ import type { TableHeaderProps as AriaTableHeaderProps } from '@koobiq/react-primitives';
2
+ export type TableHeaderProps<T> = AriaTableHeaderProps<T>;
3
+ export declare function TableHeader<T>(_props: TableHeaderProps<T>): null;
4
+ export declare namespace TableHeader {
5
+ var getCollectionNode: unknown;
6
+ }
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { TableHeader as TableHeader$1 } from "@koobiq/react-primitives";
3
+ const TableHeaderInner = TableHeader$1;
4
+ function TableHeader(_props) {
5
+ return null;
6
+ }
7
+ TableHeader.getCollectionNode = TableHeaderInner.getCollectionNode;
8
+ export {
9
+ TableHeader
10
+ };
@@ -2,3 +2,8 @@ export * from './Section';
2
2
  export * from './Item';
3
3
  export * from './Divider';
4
4
  export * from './Header';
5
+ export * from './Cell';
6
+ export * from './Row';
7
+ export * from './Column';
8
+ export * from './TableBody';
9
+ export * from './TableHeader';
@@ -0,0 +1,12 @@
1
+ import { Cell, Row, Column, TableBody, TableHeader } from '../Collections';
2
+ import type { TableComponentProp } from './types';
3
+ declare const TableComponent: TableComponentProp;
4
+ type CompoundedComponent = typeof TableComponent & {
5
+ Header: typeof TableHeader;
6
+ Body: typeof TableBody;
7
+ Column: typeof Column;
8
+ Row: typeof Row;
9
+ Cell: typeof Cell;
10
+ };
11
+ export declare const Table: CompoundedComponent;
12
+ export {};
@@ -0,0 +1,104 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { forwardRef, useRef } from "react";
4
+ import { useDOMRef, mergeProps, useElementSize, clsx } from "@koobiq/react-core";
5
+ import { useTableState, useTable } from "@koobiq/react-primitives";
6
+ import { utilClasses } from "../../styles/utility.js";
7
+ import s from "./Table.module.css.js";
8
+ import { normalizeBlockSize } from "./utils.js";
9
+ import { TableRowGroup } from "./components/TableRowGroup/TableRowGroup.js";
10
+ import { TableHeaderRow } from "./components/TableHeaderRow/TableHeaderRow.js";
11
+ import { TableSelectAllCell } from "./components/TableSelectAllCell/TableSelectAllCell.js";
12
+ import { TableColumnHeader } from "./components/TableColumnHeader/TableColumnHeader.js";
13
+ import { TableRow } from "./components/TableRow/TableRow.js";
14
+ import { TableCheckboxCell } from "./components/TableCheckboxCell/TableCheckboxCell.js";
15
+ import { TableCell } from "./components/TableCell/TableCell.js";
16
+ import { TableHeader } from "../Collections/TableHeader.js";
17
+ import { TableBody } from "../Collections/TableBody.js";
18
+ import { Column } from "../Collections/Column.js";
19
+ import { Row } from "../Collections/Row.js";
20
+ import { Cell } from "../Collections/Cell.js";
21
+ const textNormal = utilClasses.typography["text-normal"];
22
+ function TableRender(props, ref) {
23
+ const {
24
+ stickyHeader = false,
25
+ fullWidth = false,
26
+ divider = "none",
27
+ slotProps,
28
+ selectionMode,
29
+ selectionBehavior,
30
+ className,
31
+ blockSize,
32
+ maxBlockSize,
33
+ minBlockSize,
34
+ style: styleProp
35
+ } = props;
36
+ const state = useTableState({
37
+ ...props,
38
+ showSelectionCheckboxes: selectionMode === "multiple" && selectionBehavior !== "replace"
39
+ });
40
+ const domRef = useDOMRef(ref);
41
+ const tableRef = useRef(null);
42
+ const { collection } = state;
43
+ const { gridProps } = useTable(props, state, tableRef);
44
+ const tableProps = mergeProps(
45
+ { ref: tableRef, className: s.table },
46
+ gridProps,
47
+ slotProps?.table
48
+ );
49
+ const { ref: theadRef, height } = useElementSize();
50
+ const containerProps = mergeProps(
51
+ {
52
+ className: clsx(
53
+ s.base,
54
+ fullWidth && s.fullWidth,
55
+ textNormal,
56
+ className
57
+ ),
58
+ "data-divider": divider,
59
+ "data-fullwidth": fullWidth,
60
+ "data-sticky-header": stickyHeader,
61
+ style: {
62
+ ...styleProp,
63
+ "--table-container-block-size": normalizeBlockSize(blockSize),
64
+ "--table-container-min-block-size": normalizeBlockSize(minBlockSize),
65
+ "--table-container-max-block-size": normalizeBlockSize(maxBlockSize),
66
+ "--table-container-scroll-padding-top": `${height}px`
67
+ },
68
+ ref: domRef
69
+ },
70
+ slotProps?.container
71
+ );
72
+ return /* @__PURE__ */ jsx("div", { ...containerProps, children: /* @__PURE__ */ jsxs("table", { ...tableProps, children: [
73
+ /* @__PURE__ */ jsx(TableRowGroup, { type: "thead", ref: theadRef, children: collection.headerRows.map((headerRow) => /* @__PURE__ */ jsx(TableHeaderRow, { item: headerRow, state, children: [...headerRow.childNodes].map(
74
+ (column) => column.props.isSelectionCell ? /* @__PURE__ */ jsx(
75
+ TableSelectAllCell,
76
+ {
77
+ column,
78
+ state
79
+ },
80
+ column.key
81
+ ) : /* @__PURE__ */ jsx(
82
+ TableColumnHeader,
83
+ {
84
+ column,
85
+ state
86
+ },
87
+ column.key
88
+ )
89
+ ) }, headerRow.key)) }),
90
+ /* @__PURE__ */ jsx(TableRowGroup, { type: "tbody", children: [...collection.body.childNodes].map((row) => /* @__PURE__ */ jsx(TableRow, { item: row, state, children: [...row.childNodes].map(
91
+ (cell) => cell.props.isSelectionCell ? /* @__PURE__ */ jsx(TableCheckboxCell, { cell, state }, cell.key) : /* @__PURE__ */ jsx(TableCell, { cell, state }, cell.key)
92
+ ) }, row.key)) })
93
+ ] }) });
94
+ }
95
+ const TableComponent = forwardRef(TableRender);
96
+ const Table = TableComponent;
97
+ Table.Header = TableHeader;
98
+ Table.Body = TableBody;
99
+ Table.Column = Column;
100
+ Table.Row = Row;
101
+ Table.Cell = Cell;
102
+ export {
103
+ Table
104
+ };
@@ -0,0 +1,55 @@
1
+ const base = "kbq-table-55e555";
2
+ const fullWidth = "kbq-table-fullWidth-419d42";
3
+ const table = "kbq-table-table-836ffc";
4
+ const cell = "kbq-table-cell-728c41";
5
+ const row = "kbq-table-row-a9022f";
6
+ const thead = "kbq-table-thead-6c557a";
7
+ const hovered = "kbq-table-hovered-be04d3";
8
+ const pressed = "kbq-table-pressed-fea60d";
9
+ const selected = "kbq-table-selected-95ebb7";
10
+ const disabled = "kbq-table-disabled-16f6ce";
11
+ const focusVisible = "kbq-table-focusVisible-0bcc1d";
12
+ const top = "kbq-table-top-53f823";
13
+ const baseline = "kbq-table-baseline-bb5fa5";
14
+ const middle = "kbq-table-middle-5cae59";
15
+ const bottom = "kbq-table-bottom-e6ddd9";
16
+ const sub = "kbq-table-sub-4497f9";
17
+ const s = {
18
+ base,
19
+ fullWidth,
20
+ table,
21
+ cell,
22
+ row,
23
+ thead,
24
+ hovered,
25
+ pressed,
26
+ selected,
27
+ disabled,
28
+ "header-cell": "kbq-table-header-cell-34e3fa",
29
+ focusVisible,
30
+ top,
31
+ baseline,
32
+ middle,
33
+ bottom,
34
+ sub,
35
+ "text-top": "kbq-table-text-top-5c06c5"
36
+ };
37
+ export {
38
+ base,
39
+ baseline,
40
+ bottom,
41
+ cell,
42
+ s as default,
43
+ disabled,
44
+ focusVisible,
45
+ fullWidth,
46
+ hovered,
47
+ middle,
48
+ pressed,
49
+ row,
50
+ selected,
51
+ sub,
52
+ table,
53
+ thead,
54
+ top
55
+ };
@@ -0,0 +1,7 @@
1
+ import type { TableState, AriaTableCellProps } from '@koobiq/react-primitives';
2
+ type TableCellProps<T> = {
3
+ cell: AriaTableCellProps['node'];
4
+ state: TableState<T>;
5
+ };
6
+ export declare function TableCell<T>({ cell, state }: TableCellProps<T>): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,39 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { useRef } from "react";
4
+ import { useFocusRing, clsx, mergeProps } from "@koobiq/react-core";
5
+ import { useTableCell } from "@koobiq/react-primitives";
6
+ import { utilClasses } from "../../../../styles/utility.js";
7
+ import s from "../../Table.module.css.js";
8
+ const textNormal = utilClasses.typography["text-normal"];
9
+ function TableCell({ cell, state }) {
10
+ const ref = useRef(null);
11
+ const { gridCellProps } = useTableCell({ node: cell }, state, ref);
12
+ const { isFocusVisible, focusProps } = useFocusRing();
13
+ const {
14
+ style,
15
+ className,
16
+ align = "left",
17
+ valign = "middle"
18
+ } = cell.props;
19
+ return /* @__PURE__ */ jsx(
20
+ "td",
21
+ {
22
+ align,
23
+ ...mergeProps(gridCellProps, focusProps),
24
+ className: clsx(
25
+ s.cell,
26
+ textNormal,
27
+ valign && s[valign],
28
+ isFocusVisible && s.focusVisible,
29
+ className
30
+ ),
31
+ style,
32
+ ref,
33
+ children: cell.rendered
34
+ }
35
+ );
36
+ }
37
+ export {
38
+ TableCell
39
+ };
@@ -0,0 +1 @@
1
+ export * from './TableCell';
@@ -0,0 +1,7 @@
1
+ import { type AriaTableCellProps, type TableState } from '@koobiq/react-primitives';
2
+ type TableCheckboxCellProps<T> = {
3
+ cell: AriaTableCellProps['node'];
4
+ state: TableState<T>;
5
+ };
6
+ export declare function TableCheckboxCell<T>({ cell, state, }: TableCheckboxCellProps<T>): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,21 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { useRef } from "react";
4
+ import { useTableCell, useTableSelectionCheckbox } from "@koobiq/react-primitives";
5
+ import s from "../../Table.module.css.js";
6
+ import { Checkbox } from "../../../Checkbox/Checkbox.js";
7
+ function TableCheckboxCell({
8
+ cell,
9
+ state
10
+ }) {
11
+ const ref = useRef(null);
12
+ const { gridCellProps } = useTableCell({ node: cell }, state, ref);
13
+ const { checkboxProps } = useTableSelectionCheckbox(
14
+ { key: cell.parentKey },
15
+ state
16
+ );
17
+ return /* @__PURE__ */ jsx("td", { className: s.cell, ...gridCellProps, ref, children: /* @__PURE__ */ jsx(Checkbox, { ...checkboxProps }) });
18
+ }
19
+ export {
20
+ TableCheckboxCell
21
+ };
@@ -0,0 +1 @@
1
+ export * from './TableCheckboxCell';
@@ -0,0 +1,7 @@
1
+ import type { TableState, AriaTableColumnHeaderProps } from '@koobiq/react-primitives';
2
+ type TableColumnHeaderProps<T> = {
3
+ column: AriaTableColumnHeaderProps<T>['node'];
4
+ state: TableState<T>;
5
+ };
6
+ export declare function TableColumnHeader<T>({ column, state, }: TableColumnHeaderProps<T>): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,46 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { useRef } from "react";
4
+ import { useFocusRing, mergeProps, clsx } from "@koobiq/react-core";
5
+ import { useTableColumnHeader } from "@koobiq/react-primitives";
6
+ import { utilClasses } from "../../../../styles/utility.js";
7
+ import s from "../../Table.module.css.js";
8
+ const textNormal = utilClasses.typography["text-normal"];
9
+ function TableColumnHeader({
10
+ column,
11
+ state
12
+ }) {
13
+ const ref = useRef(null);
14
+ const { columnHeaderProps } = useTableColumnHeader(
15
+ { node: column },
16
+ state,
17
+ ref
18
+ );
19
+ const {
20
+ style,
21
+ className,
22
+ align = "left",
23
+ valign = "middle"
24
+ } = column.props;
25
+ const { isFocusVisible, focusProps } = useFocusRing();
26
+ return /* @__PURE__ */ jsx(
27
+ "th",
28
+ {
29
+ align,
30
+ className: clsx(
31
+ s["header-cell"],
32
+ isFocusVisible && s.focusVisible,
33
+ valign && s[valign],
34
+ textNormal,
35
+ className
36
+ ),
37
+ style,
38
+ ...mergeProps(columnHeaderProps, focusProps),
39
+ ref,
40
+ children: column.rendered
41
+ }
42
+ );
43
+ }
44
+ export {
45
+ TableColumnHeader
46
+ };
@@ -0,0 +1 @@
1
+ export * from './TableColumnHeader';
@@ -0,0 +1,9 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { TableState, GridRowProps } from '@koobiq/react-primitives';
3
+ type TableHeaderRowProps<T> = {
4
+ item: GridRowProps<T>['node'];
5
+ state: TableState<T>;
6
+ children: ReactNode;
7
+ };
8
+ export declare function TableHeaderRow<T>({ item, state, children, }: TableHeaderRowProps<T>): import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,16 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { useRef } from "react";
4
+ import { useTableHeaderRow } from "@koobiq/react-primitives";
5
+ function TableHeaderRow({
6
+ item,
7
+ state,
8
+ children
9
+ }) {
10
+ const ref = useRef(null);
11
+ const { rowProps } = useTableHeaderRow({ node: item }, state, ref);
12
+ return /* @__PURE__ */ jsx("tr", { ...rowProps, ref, children });
13
+ }
14
+ export {
15
+ TableHeaderRow
16
+ };
@@ -0,0 +1 @@
1
+ export * from './TableHeaderRow';
@@ -0,0 +1,9 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { TableState, GridRowProps } from '@koobiq/react-primitives';
3
+ type TableRowProps<T> = {
4
+ item: GridRowProps<T>['node'];
5
+ children: ReactNode;
6
+ state: TableState<T>;
7
+ };
8
+ export declare function TableRow<T>({ item, children, state }: TableRowProps<T>): import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,46 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { useRef } from "react";
4
+ import { useFocusRing, useHover, mergeProps, clsx } from "@koobiq/react-core";
5
+ import { useTableRow } from "@koobiq/react-primitives";
6
+ import s from "../../Table.module.css.js";
7
+ function TableRow({ item, children, state }) {
8
+ const ref = useRef(null);
9
+ const isSelected = state.selectionManager.isSelected(item.key);
10
+ const { rowProps, isPressed, isDisabled } = useTableRow(
11
+ {
12
+ node: item
13
+ },
14
+ state,
15
+ ref
16
+ );
17
+ const { style, className } = item.props;
18
+ const { isFocusVisible, focusProps } = useFocusRing();
19
+ const { isHovered, hoverProps } = useHover({ isDisabled });
20
+ return /* @__PURE__ */ jsx(
21
+ "tr",
22
+ {
23
+ className: clsx(
24
+ s.row,
25
+ isHovered && s.hovered,
26
+ isPressed && s.pressed,
27
+ isSelected && s.selected,
28
+ isDisabled && s.disabled,
29
+ isFocusVisible && s.focusVisible,
30
+ className
31
+ ),
32
+ "data-hovered": isHovered,
33
+ "data-disabled": isDisabled,
34
+ "data-selected": isSelected,
35
+ "data-pressed": isPressed,
36
+ "data-focus-visible": isFocusVisible,
37
+ ...mergeProps(rowProps, hoverProps, focusProps),
38
+ style,
39
+ ref,
40
+ children
41
+ }
42
+ );
43
+ }
44
+ export {
45
+ TableRow
46
+ };
@@ -0,0 +1 @@
1
+ export * from './TableRow';
@@ -0,0 +1,6 @@
1
+ import { type ReactNode } from 'react';
2
+ export type TableRowGroupProps = {
3
+ children: ReactNode;
4
+ type: 'thead' | 'tbody';
5
+ };
6
+ export declare const TableRowGroup: import("react").ForwardRefExoticComponent<TableRowGroupProps & import("react").RefAttributes<any>>;
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { forwardRef } from "react";
4
+ import { clsx } from "@koobiq/react-core";
5
+ import { useTableRowGroup } from "@koobiq/react-primitives";
6
+ import s from "../../Table.module.css.js";
7
+ const TableRowGroup = forwardRef(
8
+ ({ type = "thead", children }, ref) => {
9
+ const Element = type;
10
+ const { rowGroupProps } = useTableRowGroup();
11
+ return /* @__PURE__ */ jsx(Element, { ...rowGroupProps, ref, className: clsx(s[type]), children });
12
+ }
13
+ );
14
+ TableRowGroup.displayName = "TableRowGroup";
15
+ export {
16
+ TableRowGroup
17
+ };
@@ -0,0 +1 @@
1
+ export * from './TableRowGroup';
@@ -0,0 +1,7 @@
1
+ import { type AriaTableColumnHeaderProps, type TableState } from '@koobiq/react-primitives';
2
+ type TableSelectAllCellProps<T> = {
3
+ column: AriaTableColumnHeaderProps<T>['node'];
4
+ state: TableState<T>;
5
+ };
6
+ export declare function TableSelectAllCell<T>({ column, state, }: TableSelectAllCellProps<T>): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { useRef } from "react";
4
+ import { useTableColumnHeader, useTableSelectAllCheckbox, VisuallyHidden } from "@koobiq/react-primitives";
5
+ import s from "../../Table.module.css.js";
6
+ import { Checkbox } from "../../../Checkbox/Checkbox.js";
7
+ function TableSelectAllCell({
8
+ column,
9
+ state
10
+ }) {
11
+ const ref = useRef(null);
12
+ const { columnHeaderProps } = useTableColumnHeader(
13
+ { node: column },
14
+ state,
15
+ ref
16
+ );
17
+ const { checkboxProps } = useTableSelectAllCheckbox(state);
18
+ return /* @__PURE__ */ jsx("th", { className: s["header-cell"], ...columnHeaderProps, ref, children: state.selectionManager.selectionMode === "single" ? /* @__PURE__ */ jsx(VisuallyHidden, { children: checkboxProps["aria-label"] }) : /* @__PURE__ */ jsx(Checkbox, { ...checkboxProps }) });
19
+ }
20
+ export {
21
+ TableSelectAllCell
22
+ };
@@ -0,0 +1 @@
1
+ export * from './TableSelectAllCell';
@@ -0,0 +1,7 @@
1
+ export * from './TableRowGroup';
2
+ export * from './TableHeaderRow';
3
+ export * from './TableColumnHeader';
4
+ export * from './TableRow';
5
+ export * from './TableCell';
6
+ export * from './TableSelectAllCell';
7
+ export * from './TableCheckboxCell';
@@ -0,0 +1 @@
1
+ export * from './Table';
@@ -0,0 +1,76 @@
1
+ import type { ComponentPropsWithRef, ComponentRef, CSSProperties, ReactElement, Ref } from 'react';
2
+ import type { ExtendableComponentPropsWithRef } from '@koobiq/react-core';
3
+ import type { TableStateProps } from '@koobiq/react-primitives';
4
+ import type { Key } from '@react-types/shared';
5
+ export declare const tablePropDivider: readonly ["none", "row"];
6
+ export type TablePropDivider = (typeof tablePropDivider)[number];
7
+ export type TablePropChildren<T> = TableStateProps<T>['children'];
8
+ export type TablePropSelectionMode<T> = TableStateProps<T>['selectionMode'];
9
+ export type TablePropSelectionBehavior<T> = TableStateProps<T>['selectionBehavior'];
10
+ export type TablePropOnSelectionChange<T> = TableStateProps<T>['onSelectionChange'];
11
+ export type TablePropSelectedKeys<T> = TableStateProps<T>['selectedKeys'];
12
+ export type TablePropDefaultSelectedKeys<T> = TableStateProps<T>['defaultSelectedKeys'];
13
+ export type TablePropDisabledBehavior<T> = TableStateProps<T>['disabledBehavior'];
14
+ export type TablePropDisabledKeys<T> = TableStateProps<T>['disabledKeys'];
15
+ export type TablePropBlockSize = CSSProperties['blockSize'];
16
+ export type TablePropMinBlockSize = CSSProperties['minBlockSize'];
17
+ export type TablePropMaxBlockSize = CSSProperties['maxInlineSize'];
18
+ export type TableProps<T> = ExtendableComponentPropsWithRef<{
19
+ /** How multiple selection should behave in the collection. */
20
+ selectionBehavior?: TablePropSelectionBehavior<T>;
21
+ /** The type of selection that is allowed in the collection. */
22
+ selectionMode?: TablePropSelectionMode<T>;
23
+ /** The currently selected keys in the collection (controlled). */
24
+ selectedKeys?: TablePropSelectedKeys<T>;
25
+ /** The initial selected keys in the collection (uncontrolled). */
26
+ defaultSelectedKeys?: TablePropDefaultSelectedKeys<T>;
27
+ /** Handler that is called when the selection changes. */
28
+ onSelectionChange?: TablePropOnSelectionChange<T>;
29
+ /** A list of row keys to disable. */
30
+ disabledKeys?: TablePropDisabledKeys<T>;
31
+ /** Whether `disabledKeys` applies to all interactions, or only selection. */
32
+ disabledBehavior?: TablePropDisabledBehavior<T>;
33
+ /** Handler that is called when a user performs an action on the row. */
34
+ onRowAction?: (key: Key) => void;
35
+ /** Handler that is called when a user performs an action on the cell. */
36
+ onCellAction?: (key: Key) => void;
37
+ /** Inline styles. */
38
+ style?: CSSProperties;
39
+ /** Additional CSS-classes. */
40
+ className?: string;
41
+ /**
42
+ * Type of separators in the table.
43
+ * @default none
44
+ */
45
+ divider?: TablePropDivider;
46
+ /**
47
+ * If `true`, the table will take up the full width of its container.
48
+ * @default false
49
+ * */
50
+ fullWidth?: boolean;
51
+ /**
52
+ * Flag indicating a fixed table header.
53
+ * @default false
54
+ * */
55
+ stickyHeader?: boolean;
56
+ /**
57
+ * The elements that make up the table.
58
+ * Includes the Table.Header, Table.Body, Table.Column, and Table.Row.
59
+ * */
60
+ children?: TablePropChildren<T>;
61
+ /** Ref to the control. */
62
+ ref?: Ref<HTMLDivElement>;
63
+ /** Height of the table container. */
64
+ blockSize?: TablePropBlockSize;
65
+ /** Minimum height of the table container. */
66
+ minBlockSize?: TablePropMinBlockSize;
67
+ /** Maximum height of the table container. */
68
+ maxBlockSize?: TablePropMaxBlockSize;
69
+ /** The props used for each slot inside. */
70
+ slotProps?: {
71
+ container?: ComponentPropsWithRef<'div'>;
72
+ table?: ComponentPropsWithRef<'table'>;
73
+ };
74
+ }, 'div'>;
75
+ export type TableComponentProp = <T extends object>(props: TableProps<T>) => ReactElement | null;
76
+ export type TableRef = ComponentRef<'table'>;
@@ -0,0 +1,2 @@
1
+ import type { TablePropBlockSize } from './types';
2
+ export declare const normalizeBlockSize: (value: TablePropBlockSize | undefined) => string | undefined;
@@ -0,0 +1,8 @@
1
+ import { isNumber } from "@koobiq/react-core";
2
+ const normalizeBlockSize = (value) => {
3
+ if (isNumber(value)) return `${value}px`;
4
+ return value;
5
+ };
6
+ export {
7
+ normalizeBlockSize
8
+ };
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx } from "react/jsx-runtime";
2
3
  import { forwardRef } from "react";
3
4
  import { useDOMRef, mergeProps, clsx } from "@koobiq/react-core";
@@ -29,5 +29,6 @@ export * from './Divider';
29
29
  export * from './Menu';
30
30
  export * from './ButtonToggleGroup';
31
31
  export * from './TagGroup';
32
+ export * from './Table';
32
33
  export * from './layout';
33
34
  export { useListData } from '@koobiq/react-primitives';
package/dist/index.js CHANGED
@@ -71,6 +71,7 @@ import { ButtonToggle } from "./components/ButtonToggleGroup/components/ButtonTo
71
71
  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
+ import { Table } from "./components/Table/Table.js";
74
75
  import { flex, flexPropAlignItems, flexPropDirection, flexPropFlex, flexPropGap, flexPropJustifyContent, flexPropOrder, flexPropWrap } from "./components/layout/flex/flex.js";
75
76
  import { spacing, spacingGap } from "./components/layout/spacing/spacing.js";
76
77
  export {
@@ -123,6 +124,7 @@ export {
123
124
  SidePanelHeader,
124
125
  SkeletonBlock,
125
126
  SkeletonTypography,
127
+ Table,
126
128
  Tag,
127
129
  TagGroup,
128
130
  Textarea,
package/dist/style.css CHANGED
@@ -3453,6 +3453,183 @@
3453
3453
  --tag-outline-color: none;
3454
3454
  cursor: not-allowed;
3455
3455
  }
3456
+ .kbq-table-55e555 {
3457
+ --table-container-block-size: unset;
3458
+ --table-container-min-block-size: unset;
3459
+ --table-container-max-block-size: unset;
3460
+ --table-container-scroll-padding-top: 0;
3461
+ --table-cell-padding: 10px var(--kbq-size-s);
3462
+ --table-cell-color: var(--kbq-foreground-contrast);
3463
+ --table-header-cell-padding: 10px var(--kbq-size-s);
3464
+ --table-header-cell-color: var(--kbq-foreground-contrast-secondary);
3465
+ --table-border: 1px solid var(--kbq-line-contrast-less);
3466
+ block-size: var(--table-container-block-size);
3467
+ min-block-size: var(--table-container-min-block-size);
3468
+ max-block-size: var(--table-container-max-block-size);
3469
+ scroll-padding-block-start: var(--table-container-scroll-padding-top);
3470
+ overflow: auto;
3471
+ }
3472
+
3473
+ .kbq-table-fullWidth-419d42 .kbq-table-table-836ffc {
3474
+ inline-size: 100%;
3475
+ }
3476
+
3477
+ .kbq-table-55e555[data-divider="none"] .kbq-table-cell-728c41:first-child {
3478
+ border-start-start-radius: var(--kbq-size-s);
3479
+ border-end-start-radius: var(--kbq-size-s);
3480
+ }
3481
+
3482
+ .kbq-table-55e555[data-divider="none"] .kbq-table-cell-728c41:last-child {
3483
+ border-start-end-radius: var(--kbq-size-s);
3484
+ border-end-end-radius: var(--kbq-size-s);
3485
+ }
3486
+
3487
+ .kbq-table-55e555[data-divider="none"] .kbq-table-row-a9022f {
3488
+ border-radius: var(--kbq-size-s);
3489
+ }
3490
+
3491
+ .kbq-table-55e555[data-divider="none"] .kbq-table-row-a9022f:first-child {
3492
+ border-start-start-radius: 0;
3493
+ border-start-end-radius: 0;
3494
+ }
3495
+
3496
+ .kbq-table-55e555[data-divider="none"] .kbq-table-row-a9022f:first-child .kbq-table-cell-728c41:first-child {
3497
+ border-start-start-radius: 0;
3498
+ border-end-start-radius: var(--kbq-size-s);
3499
+ }
3500
+
3501
+ .kbq-table-55e555[data-divider="none"] .kbq-table-row-a9022f:first-child .kbq-table-cell-728c41:last-child {
3502
+ border-start-end-radius: 0;
3503
+ border-end-end-radius: var(--kbq-size-s);
3504
+ }
3505
+
3506
+ .kbq-table-55e555[data-divider="row"] .kbq-table-cell-728c41 {
3507
+ border-block-end: var(--table-border);
3508
+ }
3509
+
3510
+ .kbq-table-55e555[data-sticky-header="true"] .kbq-table-thead-6c557a {
3511
+ background-color: var(--kbq-background-bg);
3512
+ z-index: 1;
3513
+ position: sticky;
3514
+ inset-block-start: 0;
3515
+ }
3516
+
3517
+ .kbq-table-table-836ffc {
3518
+ border-spacing: 0;
3519
+ }
3520
+
3521
+ .kbq-table-table-836ffc[aria-multiselectable="true"] .kbq-table-row-a9022f:is([data-selected="true"], [data-focus-visible="true"]):has( + :is([data-selected="true"], [data-focus-visible="true"])) {
3522
+ border-end-end-radius: 0;
3523
+ border-end-start-radius: 0;
3524
+ }
3525
+
3526
+ .kbq-table-table-836ffc[aria-multiselectable="true"] .kbq-table-row-a9022f:is([data-selected="true"], [data-focus-visible="true"]):has( + :is([data-selected="true"], [data-focus-visible="true"])) .kbq-table-cell-728c41:first-child {
3527
+ border-end-start-radius: 0;
3528
+ }
3529
+
3530
+ .kbq-table-table-836ffc[aria-multiselectable="true"] .kbq-table-row-a9022f:is([data-selected="true"], [data-focus-visible="true"]):has( + :is([data-selected="true"], [data-focus-visible="true"])) .kbq-table-cell-728c41:last-child {
3531
+ border-end-end-radius: 0;
3532
+ }
3533
+
3534
+ .kbq-table-table-836ffc[aria-multiselectable="true"] .kbq-table-row-a9022f:is([data-selected="true"], [data-focus-visible="true"]) + :is([data-selected="true"], [data-focus-visible="true"]) {
3535
+ border-start-start-radius: 0;
3536
+ border-start-end-radius: 0;
3537
+ }
3538
+
3539
+ .kbq-table-table-836ffc[aria-multiselectable="true"] .kbq-table-row-a9022f:is([data-selected="true"], [data-focus-visible="true"]) + :is([data-selected="true"], [data-focus-visible="true"]) .kbq-table-cell-728c41:first-child {
3540
+ border-start-start-radius: 0;
3541
+ }
3542
+
3543
+ .kbq-table-table-836ffc[aria-multiselectable="true"] .kbq-table-row-a9022f:is([data-selected="true"], [data-focus-visible="true"]) + :is([data-selected="true"], [data-focus-visible="true"]) .kbq-table-cell-728c41:last-child {
3544
+ border-start-end-radius: 0;
3545
+ }
3546
+
3547
+ .kbq-table-cell-728c41 {
3548
+ box-sizing: border-box;
3549
+ color: var(--table-cell-color);
3550
+ padding: var(--table-cell-padding);
3551
+ transition: border-radius var(--kbq-transition-default);
3552
+ outline: none;
3553
+ }
3554
+
3555
+ .kbq-table-row-a9022f {
3556
+ box-sizing: border-box;
3557
+ cursor: default;
3558
+ transition: background-color var(--kbq-transition-default), border-radius var(--kbq-transition-default);
3559
+ outline: none;
3560
+ }
3561
+
3562
+ .kbq-table-row-a9022f.kbq-table-hovered-be04d3 {
3563
+ background-color: var(--kbq-states-background-transparent-hover);
3564
+ }
3565
+
3566
+ .kbq-table-row-a9022f.kbq-table-pressed-fea60d {
3567
+ background-color: var(--kbq-states-background-transparent-active);
3568
+ }
3569
+
3570
+ .kbq-table-row-a9022f.kbq-table-selected-95ebb7 {
3571
+ background-color: var(--kbq-background-theme-less);
3572
+ }
3573
+
3574
+ .kbq-table-row-a9022f.kbq-table-selected-95ebb7:where(.kbq-table-hovered-be04d3) {
3575
+ background-color: var(--kbq-states-background-theme-less-hover);
3576
+ }
3577
+
3578
+ .kbq-table-row-a9022f.kbq-table-selected-95ebb7:where(.kbq-table-pressed-fea60d) {
3579
+ background-color: var(--kbq-states-background-theme-less-active);
3580
+ }
3581
+
3582
+ .kbq-table-row-a9022f.kbq-table-disabled-16f6ce {
3583
+ cursor: not-allowed;
3584
+ opacity: .3;
3585
+ background-color: #0000;
3586
+ }
3587
+
3588
+ .kbq-table-row-a9022f.kbq-table-disabled-16f6ce:where(.kbq-table-selected-95ebb7) {
3589
+ background-color: var(--kbq-background-theme-less);
3590
+ }
3591
+
3592
+ .kbq-table-row-a9022f:last-child .kbq-table-cell-728c41 {
3593
+ border-block-end: none;
3594
+ }
3595
+
3596
+ .kbq-table-header-cell-34e3fa {
3597
+ box-sizing: border-box;
3598
+ cursor: default;
3599
+ padding: var(--table-header-cell-padding);
3600
+ color: var(--table-header-cell-color);
3601
+ border-block-end: var(--table-border);
3602
+ outline: none;
3603
+ }
3604
+
3605
+ .kbq-table-focusVisible-0bcc1d {
3606
+ outline-offset: -2px;
3607
+ outline: 2px solid var(--kbq-states-line-focus-theme);
3608
+ }
3609
+
3610
+ .kbq-table-top-53f823 {
3611
+ vertical-align: top;
3612
+ }
3613
+
3614
+ .kbq-table-baseline-bb5fa5 {
3615
+ vertical-align: baseline;
3616
+ }
3617
+
3618
+ .kbq-table-middle-5cae59 {
3619
+ vertical-align: middle;
3620
+ }
3621
+
3622
+ .kbq-table-bottom-e6ddd9 {
3623
+ vertical-align: bottom;
3624
+ }
3625
+
3626
+ .kbq-table-sub-4497f9 {
3627
+ vertical-align: sub;
3628
+ }
3629
+
3630
+ .kbq-table-text-top-5c06c5 {
3631
+ vertical-align: text-top;
3632
+ }
3456
3633
  .kbq-spacing-mbs_0-be7021 {
3457
3634
  margin-block-start: 0;
3458
3635
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koobiq/react-components",
3
- "version": "0.0.1-beta.24",
3
+ "version": "0.0.1-beta.25",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "exports": {
@@ -27,10 +27,10 @@
27
27
  "@koobiq/design-tokens": "^3.12.1",
28
28
  "@types/react-transition-group": "^4.4.12",
29
29
  "react-transition-group": "^4.4.5",
30
- "@koobiq/logger": "0.0.1-beta.24",
31
- "@koobiq/react-icons": "0.0.1-beta.24",
32
- "@koobiq/react-primitives": "0.0.1-beta.24",
33
- "@koobiq/react-core": "0.0.1-beta.24"
30
+ "@koobiq/logger": "0.0.1-beta.25",
31
+ "@koobiq/react-core": "0.0.1-beta.25",
32
+ "@koobiq/react-icons": "0.0.1-beta.25",
33
+ "@koobiq/react-primitives": "0.0.1-beta.25"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "@koobiq/design-tokens": "^3.11.2",