@semcore/data-table 16.0.0-prerelease.12 → 16.0.0-prerelease.14

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 (123) hide show
  1. package/lib/cjs/Body.js +4 -3
  2. package/lib/cjs/Body.js.map +1 -1
  3. package/lib/cjs/DataTable.js.map +1 -1
  4. package/lib/cjs/Head.js.map +1 -1
  5. package/lib/cjs/components/Body/Body.js +216 -0
  6. package/lib/cjs/components/Body/Body.js.map +1 -0
  7. package/lib/cjs/components/Body/Body.types.js +2 -0
  8. package/lib/cjs/components/Body/Body.types.js.map +1 -0
  9. package/lib/cjs/components/Body/Cell.js +133 -0
  10. package/lib/cjs/components/Body/Cell.js.map +1 -0
  11. package/lib/cjs/components/Body/Cell.types.js +2 -0
  12. package/lib/cjs/components/Body/Cell.types.js.map +1 -0
  13. package/lib/cjs/components/Body/MergedCells.js +27 -0
  14. package/lib/cjs/components/Body/MergedCells.js.map +1 -0
  15. package/lib/cjs/components/Body/Row.js +212 -0
  16. package/lib/cjs/components/Body/Row.js.map +1 -0
  17. package/lib/cjs/components/Body/Row.types.js +2 -0
  18. package/lib/cjs/components/Body/Row.types.js.map +1 -0
  19. package/lib/cjs/components/Body/style.shadow.css +190 -0
  20. package/lib/cjs/components/DataTable/DataTable.js +565 -0
  21. package/lib/cjs/components/DataTable/DataTable.js.map +1 -0
  22. package/lib/cjs/components/DataTable/DataTable.types.js +2 -0
  23. package/lib/cjs/components/DataTable/DataTable.types.js.map +1 -0
  24. package/lib/cjs/components/DataTable/dataTable.shadow.css +14 -0
  25. package/lib/cjs/components/Head/Column.js +277 -0
  26. package/lib/cjs/components/Head/Column.js.map +1 -0
  27. package/lib/cjs/components/Head/Column.types.js +2 -0
  28. package/lib/cjs/components/Head/Column.types.js.map +1 -0
  29. package/lib/cjs/components/Head/Group.js +98 -0
  30. package/lib/cjs/components/Head/Group.js.map +1 -0
  31. package/lib/cjs/components/Head/Group.type.js +2 -0
  32. package/lib/cjs/components/Head/Group.type.js.map +1 -0
  33. package/lib/cjs/components/Head/Head.js +152 -0
  34. package/lib/cjs/components/Head/Head.js.map +1 -0
  35. package/lib/cjs/components/Head/Head.types.js +2 -0
  36. package/lib/cjs/components/Head/Head.types.js.map +1 -0
  37. package/lib/cjs/components/Head/style.shadow.css +165 -0
  38. package/lib/cjs/index.js +22 -6
  39. package/lib/cjs/index.js.map +1 -1
  40. package/lib/cjs/style/scroll-shadows.shadow.css +4 -0
  41. package/lib/cjs/translations/en.json +3 -1
  42. package/lib/cjs/utils.js +16 -7
  43. package/lib/cjs/utils.js.map +1 -1
  44. package/lib/es6/Body.js +4 -3
  45. package/lib/es6/Body.js.map +1 -1
  46. package/lib/es6/DataTable.js.map +1 -1
  47. package/lib/es6/Head.js.map +1 -1
  48. package/lib/es6/components/Body/Body.js +209 -0
  49. package/lib/es6/components/Body/Body.js.map +1 -0
  50. package/lib/es6/components/Body/Body.types.js +2 -0
  51. package/lib/es6/components/Body/Body.types.js.map +1 -0
  52. package/lib/es6/components/Body/Cell.js +126 -0
  53. package/lib/es6/components/Body/Cell.js.map +1 -0
  54. package/lib/es6/components/Body/Cell.types.js +2 -0
  55. package/lib/es6/components/Body/Cell.types.js.map +1 -0
  56. package/lib/es6/components/Body/MergedCells.js +18 -0
  57. package/lib/es6/components/Body/MergedCells.js.map +1 -0
  58. package/lib/es6/components/Body/Row.js +205 -0
  59. package/lib/es6/components/Body/Row.js.map +1 -0
  60. package/lib/es6/components/Body/Row.types.js +2 -0
  61. package/lib/es6/components/Body/Row.types.js.map +1 -0
  62. package/lib/es6/components/Body/style.shadow.css +190 -0
  63. package/lib/es6/components/DataTable/DataTable.js +558 -0
  64. package/lib/es6/components/DataTable/DataTable.js.map +1 -0
  65. package/lib/es6/components/DataTable/DataTable.types.js +2 -0
  66. package/lib/es6/components/DataTable/DataTable.types.js.map +1 -0
  67. package/lib/es6/components/DataTable/dataTable.shadow.css +14 -0
  68. package/lib/es6/components/Head/Column.js +270 -0
  69. package/lib/es6/components/Head/Column.js.map +1 -0
  70. package/lib/es6/components/Head/Column.types.js +2 -0
  71. package/lib/es6/components/Head/Column.types.js.map +1 -0
  72. package/lib/es6/components/Head/Group.js +91 -0
  73. package/lib/es6/components/Head/Group.js.map +1 -0
  74. package/lib/es6/components/Head/Group.type.js +2 -0
  75. package/lib/es6/components/Head/Group.type.js.map +1 -0
  76. package/lib/es6/components/Head/Head.js +145 -0
  77. package/lib/es6/components/Head/Head.js.map +1 -0
  78. package/lib/es6/components/Head/Head.types.js +2 -0
  79. package/lib/es6/components/Head/Head.types.js.map +1 -0
  80. package/lib/es6/components/Head/style.shadow.css +165 -0
  81. package/lib/es6/index.js +2 -0
  82. package/lib/es6/index.js.map +1 -1
  83. package/lib/es6/style/scroll-shadows.shadow.css +4 -0
  84. package/lib/es6/translations/en.json +3 -1
  85. package/lib/es6/utils.js +14 -6
  86. package/lib/es6/utils.js.map +1 -1
  87. package/lib/esm/Body.mjs +23 -22
  88. package/lib/esm/DataTable.mjs +11 -11
  89. package/lib/esm/Head.mjs +15 -15
  90. package/lib/esm/components/Body/Body.mjs +195 -0
  91. package/lib/esm/components/Body/Cell.mjs +129 -0
  92. package/lib/esm/components/Body/MergedCells.mjs +21 -0
  93. package/lib/esm/components/Body/Row.mjs +193 -0
  94. package/lib/esm/components/DataTable/DataTable.mjs +492 -0
  95. package/lib/esm/components/Head/Column.mjs +262 -0
  96. package/lib/esm/components/Head/Group.mjs +89 -0
  97. package/lib/esm/components/Head/Head.mjs +134 -0
  98. package/lib/esm/index.mjs +3 -0
  99. package/lib/esm/translations/en.json.mjs +3 -1
  100. package/lib/esm/utils.mjs +6 -6
  101. package/lib/types/Body.d.ts +1 -1
  102. package/lib/types/DataTable.d.ts +3 -3
  103. package/lib/types/Head.d.ts +1 -1
  104. package/lib/types/components/Body/Body.d.ts +8 -0
  105. package/lib/types/components/Body/Body.types.d.ts +31 -0
  106. package/lib/types/components/Body/Cell.d.ts +3 -0
  107. package/lib/types/components/Body/Cell.types.d.ts +14 -0
  108. package/lib/types/components/Body/MergedCells.d.ts +10 -0
  109. package/lib/types/components/Body/Row.d.ts +3 -0
  110. package/lib/types/components/Body/Row.types.d.ts +24 -0
  111. package/lib/types/components/DataTable/DataTable.d.ts +9 -0
  112. package/lib/types/components/DataTable/DataTable.types.d.ts +50 -0
  113. package/lib/types/components/Head/Column.d.ts +26 -0
  114. package/lib/types/components/Head/Column.types.d.ts +80 -0
  115. package/lib/types/components/Head/Group.d.ts +12 -0
  116. package/lib/types/components/Head/Group.type.d.ts +10 -0
  117. package/lib/types/components/Head/Head.d.ts +8 -0
  118. package/lib/types/components/Head/Head.types.d.ts +26 -0
  119. package/lib/types/index.d.ts +2 -0
  120. package/lib/types/translations/__intergalactic-dynamic-locales.d.ts +2 -0
  121. package/lib/types/utils.d.ts +8 -4
  122. package/package.json +7 -6
  123. package/vite.config.ts +0 -3
@@ -0,0 +1,14 @@
1
+ import { DTRow } from './Row.types';
2
+ import { DTUse } from '../DataTable/DataTable.types';
3
+ import { DTColumn, CommonColumnType } from '../Head/Column.types';
4
+ export type DataTableCellProps = CommonColumnType & {
5
+ name: string;
6
+ row: DTRow;
7
+ columnIndex: number;
8
+ column: DTColumn;
9
+ rowIndex: number;
10
+ gridArea?: string;
11
+ };
12
+ export type CellPropsInner = {
13
+ use: DTUse;
14
+ };
@@ -0,0 +1,10 @@
1
+ export declare class MergedRowsCell {
2
+ readonly value: any;
3
+ readonly rowsCount: number;
4
+ constructor(value: any, size: number);
5
+ }
6
+ export declare class MergedColumnsCell {
7
+ readonly value: any;
8
+ readonly columnsCount: number;
9
+ constructor(value: any, size: number);
10
+ }
@@ -0,0 +1,3 @@
1
+ export declare const Row: import("@semcore/core/lib/coreFactory").ComponentType<unknown, {}, {}, {
2
+ [key: string]: (arg: unknown) => void;
3
+ }, null>;
@@ -0,0 +1,24 @@
1
+ import { DTValue, DTKey, DTUse } from '../DataTable/DataTable.types';
2
+ import { DTColumn } from '../Head/Column.types';
3
+ import { MergedColumnsCell, MergedRowsCell } from './MergedCells';
4
+ export type DTRow = Record<DTKey, DTValue | MergedRowsCell | MergedColumnsCell>;
5
+ export type DataTableRowProps = {
6
+ columns: DTColumn[];
7
+ row: DTRow;
8
+ rows: DTRow[];
9
+ rowIndex: number;
10
+ headerRows: number;
11
+ expandedRows?: number[];
12
+ onExpandRow?: (expandedRowIndex: number) => void;
13
+ };
14
+ export type RowPropsInner = {
15
+ use: DTUse;
16
+ /**
17
+ * Expanded flag for rows with accordion
18
+ * @default false
19
+ */
20
+ expanded?: boolean;
21
+ gridTemplateAreas: string;
22
+ gridTemplateColumns: string;
23
+ accordionDataGridArea: string;
24
+ };
@@ -0,0 +1,9 @@
1
+ import { Intergalactic } from '@semcore/core';
2
+ import { DataTableProps } from './DataTable.types';
3
+ import { Head } from '../Head/Head';
4
+ import { Body } from '../Body/Body';
5
+ export declare const ACCORDION: unique symbol;
6
+ export declare const DataTable: (<Tag extends Intergalactic.InternalTypings.ComponentTag = "div", Props extends DataTableProps = DataTableProps>(props: Intergalactic.InternalTypings.ComponentProps<Tag, "div", Props, {}, never[]>) => Intergalactic.InternalTypings.ComponentRenderingResults) & Intergalactic.InternalTypings.ComponentAdditive<"div", Intergalactic.InternalTypings.ComponentTag, DataTableProps, {}, never[]> & {
7
+ Head: typeof Head;
8
+ Body: typeof Body;
9
+ };
@@ -0,0 +1,50 @@
1
+ /// <reference types="react" />
2
+ import { Intergalactic } from '@semcore/core';
3
+ import { BoxProps } from '@semcore/base-components';
4
+ /**
5
+ * Datatable must have an accessible name (aria-table-name).
6
+ * It should describe table content.
7
+ */
8
+ type DataTableAriaProps = Intergalactic.RequireAtLeastOne<{
9
+ 'aria-label'?: string;
10
+ 'aria-labelledby'?: string;
11
+ title?: string;
12
+ }>;
13
+ export type SortDirection = 'asc' | 'desc';
14
+ export type DataTableSort<Column = string> = [sortBy: Column, sortDirection: SortDirection];
15
+ export type DTKey = string | symbol;
16
+ export type DTValue = string | number | boolean;
17
+ export type DataTableData = Array<Record<DTKey, any>>;
18
+ export type DTUse = 'primary' | 'secondary';
19
+ type Sizes = Pick<BoxProps, 'w' | 'wMax' | 'wMin' | 'h' | 'hMax' | 'hMin'>;
20
+ export type DataTableProps = DataTableAriaProps & Sizes & {
21
+ /** Data for table */
22
+ data: DataTableData;
23
+ /** Count of total rows if table using virtual scroll. Needs for accessibility */
24
+ totalRows?: number;
25
+ /** Table theme according to visual hierarchy on the page
26
+ * @default primary
27
+ * */
28
+ use?: DTUse;
29
+ /** Active sort object */
30
+ sort?: DataTableSort;
31
+ /** Handler call when request will change sort */
32
+ onSortChange?: (sort: DataTableSort, e?: React.SyntheticEvent) => void;
33
+ /**
34
+ *
35
+ * @default auto
36
+ */
37
+ defaultGridTemplateColumnWidth?: 'auto' | '1fr';
38
+ /**
39
+ * Flag for compact view (less paddings)
40
+ */
41
+ compact?: boolean;
42
+ /**
43
+ * Flag for showing spinner on table body
44
+ */
45
+ loading?: boolean;
46
+ children?: any;
47
+ };
48
+ export type RowIndex = number;
49
+ export type ColIndex = number;
50
+ export {};
@@ -0,0 +1,26 @@
1
+ import * as React from 'react';
2
+ import { Component } from '@semcore/core';
3
+ import { ColumnPropsInner, DataTableColumnProps } from './Column.types';
4
+ type State = {
5
+ sortVisible: boolean;
6
+ };
7
+ export declare class Column extends Component<DataTableColumnProps, {}, {}, [], ColumnPropsInner> {
8
+ static displayName: string;
9
+ static style: {
10
+ [key: string]: string;
11
+ };
12
+ lockedCell: [HTMLElement | null, boolean];
13
+ columnRef: React.RefObject<HTMLDivElement>;
14
+ sortWrapperRef: React.RefObject<HTMLDivElement>;
15
+ state: State;
16
+ componentDidUpdate(prevProps: DataTableColumnProps & ColumnPropsInner): void;
17
+ calculateActiveColumnMinWidth: () => number | null;
18
+ handleMouseEnter: () => void;
19
+ handleMouseLeave: () => void;
20
+ handleBlur: () => void;
21
+ handleSortClick: (e: React.SyntheticEvent<HTMLButtonElement>) => void;
22
+ handleKeyDown: (e: React.KeyboardEvent) => void;
23
+ handleFocusCell: (e: React.FocusEvent<HTMLElement, HTMLElement>) => void;
24
+ render(): React.ReactNode;
25
+ }
26
+ export {};
@@ -0,0 +1,80 @@
1
+ /// <reference types="react" />
2
+ import { DataTableProps, DTUse } from '../DataTable/DataTable.types';
3
+ import { Property } from 'csstype';
4
+ export type CommonColumnType = {
5
+ /**
6
+ * Name of column for mapping with data
7
+ */
8
+ name: string;
9
+ /**
10
+ * Flag to define column as sortable
11
+ */
12
+ sortable?: boolean;
13
+ /**
14
+ * Fixes column to some side of table
15
+ */
16
+ fixed?: 'left' | 'right';
17
+ /**
18
+ * Adds vertical border(s)
19
+ */
20
+ borders?: 'both' | 'left' | 'right';
21
+ /**
22
+ * It manages the `flex-wrap` property
23
+ */
24
+ flexWrap?: boolean;
25
+ /**
26
+ * It manages the `align-items` property
27
+ */
28
+ alignItems?: Property.AlignItems;
29
+ /**
30
+ * It manages the `align-content` property
31
+ */
32
+ alignContent?: Property.AlignContent;
33
+ /**
34
+ * CSS `justify-content` property
35
+ */
36
+ justifyContent?: Property.JustifyContent;
37
+ };
38
+ export type DTColumn = CommonColumnType & {
39
+ ref: React.RefCallback<HTMLElement> & {
40
+ current: HTMLElement | null;
41
+ };
42
+ /**
43
+ * Width for grid-template-columns
44
+ */
45
+ gridColumnWidth: string;
46
+ /**
47
+ * Width of column by getBoundaryRect() value
48
+ */
49
+ calculatedWidth: number;
50
+ /**
51
+ * Height of column by getBoundaryRect() value
52
+ */
53
+ calculatedHeight: number;
54
+ parent?: DTColumn;
55
+ gridArea?: string;
56
+ };
57
+ export type DataTableColumnProps = CommonColumnType & {
58
+ /**
59
+ * Value for grid-template-columns for current column
60
+ */
61
+ gtcWidth?: string;
62
+ /**
63
+ * Flag for change column size if sorted by it
64
+ */
65
+ changeSortSize?: boolean;
66
+ children?: React.ReactElement[];
67
+ };
68
+ export type ColumnPropsInner = {
69
+ use: DTUse;
70
+ borders?: 'both' | 'left' | 'right';
71
+ sort?: DataTableProps['sort'];
72
+ onSortChange?: DataTableProps['onSortChange'];
73
+ uid: string;
74
+ parent?: DTColumn;
75
+ sortableColumnDescribeId: string;
76
+ columnIndex: number;
77
+ tableRef: React.RefObject<HTMLElement>;
78
+ gridTemplateColumns: string[];
79
+ gridTemplateAreas: string[];
80
+ };
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import { Component } from '@semcore/core';
3
+ import { DataTableGroupProps, GroupPropsInner } from './Group.type';
4
+ export declare class Group extends Component<DataTableGroupProps, {}, {}, [], GroupPropsInner> {
5
+ static displayName: string;
6
+ static style: {
7
+ [key: string]: string;
8
+ };
9
+ mounted: boolean;
10
+ componentDidMount(): void;
11
+ render(): React.ReactNode;
12
+ }
@@ -0,0 +1,10 @@
1
+ import { DTUse } from '../DataTable/DataTable.types';
2
+ export type DataTableGroupProps = {
3
+ title: string;
4
+ borders?: 'both' | 'left' | 'right';
5
+ fixed?: 'left' | 'right';
6
+ };
7
+ export type GroupPropsInner = {
8
+ use: DTUse;
9
+ fixedColumnsMap: Map<string, any>;
10
+ };
@@ -0,0 +1,8 @@
1
+ import { Component, Intergalactic } from '@semcore/core';
2
+ import { DataTableHeadProps } from './Head.types';
3
+ import { DataTableColumnProps } from './Column.types';
4
+ import { DataTableGroupProps } from './Group.type';
5
+ export declare const Head: (<Tag extends Intergalactic.InternalTypings.ComponentTag = "div", Props extends DataTableHeadProps = DataTableHeadProps>(props: Intergalactic.InternalTypings.ComponentProps<Tag, "div", Props, {}, never[]>) => Intergalactic.InternalTypings.ComponentRenderingResults) & Intergalactic.InternalTypings.ComponentAdditive<"div", Intergalactic.InternalTypings.ComponentTag, DataTableHeadProps, {}, never[]> & {
6
+ Column: Intergalactic.Component<'div', DataTableColumnProps>;
7
+ Group: Intergalactic.Component<'div', DataTableGroupProps>;
8
+ };
@@ -0,0 +1,26 @@
1
+ /// <reference types="react" />
2
+ import { DataTableProps, DTUse } from '../DataTable/DataTable.types';
3
+ import { DTColumn } from './Column.types';
4
+ export type DataTableHeadProps = {
5
+ /**
6
+ * Sticky header
7
+ * @default false
8
+ */
9
+ sticky?: boolean;
10
+ /** Enable scroll bar element in header */
11
+ withScrollBar?: boolean;
12
+ };
13
+ export type HeadPropsInner = {
14
+ use: DTUse;
15
+ tableRef: React.RefObject<HTMLElement>;
16
+ columns: DTColumn[];
17
+ compact: boolean;
18
+ sort?: DataTableProps['sort'];
19
+ onSortChange?: DataTableProps['onSortChange'];
20
+ getI18nText: (key: string) => string;
21
+ uid: string;
22
+ ref: React.RefObject<HTMLDivElement>;
23
+ gridAreaGroupMap: Map<number, string>;
24
+ gridTemplateColumns: string[];
25
+ gridTemplateAreas: string[];
26
+ };
@@ -1,2 +1,4 @@
1
+ import { DataTable, ACCORDION } from './components/DataTable/DataTable';
1
2
  export { default } from './DataTable';
2
3
  export * from './DataTable';
4
+ export { DataTable, ACCORDION };
@@ -4,6 +4,8 @@ export declare const localizedMessages: {
4
4
  };
5
5
  en: {
6
6
  sortableColumn: string;
7
+ "DataTable.Cell.AccordionToggle.expand:aria-label": string;
8
+ "DataTable.Cell.AccordionToggle.collapse:aria-label": string;
7
9
  };
8
10
  es: {
9
11
  sortableColumn: string;
@@ -1,4 +1,8 @@
1
- import type { Column } from './types';
2
- export declare const getScrollOffsetValue: (columns: Column[]) => [leftOffset: number, rightOffset: number];
3
- export declare const flattenColumns: (columns: Column[]) => Column[];
4
- export declare const getFixedStyle: (cell: Pick<Column, 'name' | 'fixed'>, columns: Column[]) => [side: "left" | "right", style: string | number] | [side: undefined, style: undefined];
1
+ import type { DTColumn } from './components/Head/Column.types';
2
+ export declare const getScrollOffsetValue: (columns: DTColumn[]) => [leftOffset: number, rightOffset: number];
3
+ export declare const createCssVarForWidth: (name: string) => string;
4
+ /**
5
+ * todo: Remove after v16
6
+ */
7
+ export declare const flattenColumns: (columns: any[]) => any;
8
+ export declare const getFixedStyle: (cell: Pick<DTColumn, 'name' | 'fixed'>, columns: DTColumn[]) => [side: "left" | "right", style: string | number] | [side: undefined, style: undefined];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@semcore/data-table",
3
3
  "description": "Semrush DataTable Component",
4
- "version": "16.0.0-prerelease.12",
4
+ "version": "16.0.0-prerelease.14",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es6/index.js",
7
7
  "typings": "lib/types/index.d.ts",
@@ -14,9 +14,10 @@
14
14
  "types": "./lib/types/index.d.ts"
15
15
  },
16
16
  "dependencies": {
17
- "@semcore/icon": "16.0.0-prerelease.12",
18
- "@semcore/flex-box": "16.0.0-prerelease.12",
19
- "@semcore/scroll-area": "16.0.0-prerelease.12"
17
+ "@semcore/icon": "16.0.0-prerelease.14",
18
+ "@semcore/button": "16.0.0-prerelease.14",
19
+ "@semcore/flex-box": "16.0.0-prerelease.14",
20
+ "@semcore/scroll-area": "16.0.0-prerelease.14"
20
21
  },
21
22
  "devDependencies": {
22
23
  "@types/react": "18.0.21",
@@ -36,7 +37,7 @@
36
37
  "csstype": "3.0.8"
37
38
  },
38
39
  "peerDependencies": {
39
- "@semcore/base-components": "^16.0.0-prerelease.12"
40
+ "@semcore/base-components": "^16.0.0-prerelease.14"
40
41
  },
41
42
  "repository": {
42
43
  "type": "git",
@@ -44,6 +45,6 @@
44
45
  "directory": "semcore/data-table"
45
46
  },
46
47
  "scripts": {
47
- "build": "pnpm semcore-builder --source=ts && pnpm vite build"
48
+ "build": "pnpm semcore-builder && pnpm vite build"
48
49
  }
49
50
  }
package/vite.config.ts CHANGED
@@ -9,9 +9,6 @@ export default mergeConfig(
9
9
  lib: {
10
10
  entry: './src/index.ts',
11
11
  },
12
- rollupOptions: {
13
- external: ['react', 'react-dom', 'react/jsx-runtime', /@babel\/runtime\/*/, /@semcore\/*/],
14
- },
15
12
  },
16
13
  }),
17
14
  );