@addev-be/ui 0.2.13 → 0.2.15

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 (114) hide show
  1. package/dist/Icons.d.ts +3 -1
  2. package/dist/Icons.js +5 -1
  3. package/dist/components/data/DataGrid/{FilterValuesScroller.d.ts → DataGridFilterMenu/FilterValuesScroller.d.ts} +1 -1
  4. package/dist/components/data/DataGrid/{FilterValuesScroller.js → DataGridFilterMenu/FilterValuesScroller.js} +6 -9
  5. package/dist/components/data/DataGrid/DataGridFilterMenu/index.js +3 -3
  6. package/dist/components/data/DataGrid/DataGridFilterMenu/styles.d.ts +9 -0
  7. package/dist/components/data/DataGrid/DataGridFilterMenu/styles.js +12 -2
  8. package/dist/components/data/DataGrid/FilterModalContent/index.js +18 -9
  9. package/dist/components/data/DataGrid/helpers/columns.d.ts +1 -0
  10. package/dist/components/data/DataGrid/helpers/columns.js +7 -6
  11. package/dist/components/data/DataGrid/helpers/filters.d.ts +1 -0
  12. package/dist/components/data/DataGrid/helpers/filters.js +71 -2
  13. package/dist/components/data/DataGrid/hooks/useDataGrid.js +2 -1
  14. package/dist/components/data/DataGrid/hooks/useDataGridCopy.js +2 -0
  15. package/dist/components/data/DataGrid/styles.d.ts +0 -9
  16. package/dist/components/data/DataGrid/styles.js +2 -12
  17. package/dist/components/data/DataGrid/types.d.ts +2 -0
  18. package/dist/components/data/SqlRequestDataGrid/helpers/columns.js +6 -6
  19. package/dist/helpers/numbers.d.ts +1 -0
  20. package/dist/helpers/numbers.js +9 -1
  21. package/dist/services/globalSearch.d.ts +13 -0
  22. package/dist/services/globalSearch.js +8 -0
  23. package/package.json +18 -12
  24. package/dist/components/data/DataGrid/AdvancedRequestDataGrid.d.ts +0 -9
  25. package/dist/components/data/DataGrid/AdvancedRequestDataGrid.js +0 -171
  26. package/dist/components/data/DataGrid/helpers/advancedRequests.d.ts +0 -12
  27. package/dist/components/data/DataGrid/helpers/advancedRequests.js +0 -53
  28. package/eslint.config.js +0 -28
  29. package/src/Icons.tsx +0 -108
  30. package/src/components/data/AdvancedRequestDataGrid/helpers/advancedRequests.ts +0 -93
  31. package/src/components/data/AdvancedRequestDataGrid/helpers/columns.tsx +0 -262
  32. package/src/components/data/AdvancedRequestDataGrid/helpers/index.ts +0 -2
  33. package/src/components/data/AdvancedRequestDataGrid/index.tsx +0 -267
  34. package/src/components/data/AdvancedRequestDataGrid/types.ts +0 -47
  35. package/src/components/data/DataGrid/DataGridCell.tsx +0 -73
  36. package/src/components/data/DataGrid/DataGridColumnsModal/helpers.ts +0 -14
  37. package/src/components/data/DataGrid/DataGridColumnsModal/hooks.tsx +0 -59
  38. package/src/components/data/DataGrid/DataGridColumnsModal/index.tsx +0 -181
  39. package/src/components/data/DataGrid/DataGridColumnsModal/styles.ts +0 -104
  40. package/src/components/data/DataGrid/DataGridEditableCell.tsx +0 -43
  41. package/src/components/data/DataGrid/DataGridFilterMenu/FilterValuesScroller.tsx +0 -120
  42. package/src/components/data/DataGrid/DataGridFilterMenu/hooks.tsx +0 -75
  43. package/src/components/data/DataGrid/DataGridFilterMenu/index.tsx +0 -360
  44. package/src/components/data/DataGrid/DataGridFilterMenu/styles.ts +0 -96
  45. package/src/components/data/DataGrid/DataGridFooter.tsx +0 -42
  46. package/src/components/data/DataGrid/DataGridHeader.tsx +0 -126
  47. package/src/components/data/DataGrid/DataGridHeaderCell.tsx +0 -132
  48. package/src/components/data/DataGrid/FilterModalContent/index.tsx +0 -136
  49. package/src/components/data/DataGrid/FilterModalContent/styles.ts +0 -22
  50. package/src/components/data/DataGrid/VirtualScroller.tsx +0 -46
  51. package/src/components/data/DataGrid/helpers/columns.tsx +0 -295
  52. package/src/components/data/DataGrid/helpers/filters.ts +0 -287
  53. package/src/components/data/DataGrid/helpers/index.ts +0 -2
  54. package/src/components/data/DataGrid/hooks/index.ts +0 -30
  55. package/src/components/data/DataGrid/hooks/useDataGrid.tsx +0 -306
  56. package/src/components/data/DataGrid/hooks/useDataGridCopy.ts +0 -175
  57. package/src/components/data/DataGrid/hooks/useDataGridSettings.ts +0 -48
  58. package/src/components/data/DataGrid/index.tsx +0 -140
  59. package/src/components/data/DataGrid/styles.ts +0 -323
  60. package/src/components/data/DataGrid/types.ts +0 -267
  61. package/src/components/data/SqlRequestDataGrid/helpers/columns.tsx +0 -277
  62. package/src/components/data/SqlRequestDataGrid/helpers/index.ts +0 -2
  63. package/src/components/data/SqlRequestDataGrid/helpers/sqlRequests.ts +0 -16
  64. package/src/components/data/SqlRequestDataGrid/index.tsx +0 -347
  65. package/src/components/data/SqlRequestDataGrid/types.ts +0 -47
  66. package/src/components/data/index.ts +0 -8
  67. package/src/components/forms/Button.tsx +0 -99
  68. package/src/components/forms/IconButton.tsx +0 -56
  69. package/src/components/forms/IndeterminateCheckbox.tsx +0 -46
  70. package/src/components/forms/Select.tsx +0 -40
  71. package/src/components/forms/index.ts +0 -5
  72. package/src/components/forms/styles.ts +0 -20
  73. package/src/components/index.ts +0 -3
  74. package/src/components/layout/Dropdown/index.tsx +0 -79
  75. package/src/components/layout/Dropdown/styles.ts +0 -44
  76. package/src/components/layout/Loading/index.tsx +0 -29
  77. package/src/components/layout/Loading/styles.ts +0 -29
  78. package/src/components/layout/Modal/index.tsx +0 -51
  79. package/src/components/layout/Modal/styles.ts +0 -110
  80. package/src/components/layout/index.ts +0 -3
  81. package/src/components/ui/ContextMenu/index.tsx +0 -79
  82. package/src/components/ui/ContextMenu/styles.ts +0 -119
  83. package/src/config/index.ts +0 -14
  84. package/src/helpers/dates.ts +0 -9
  85. package/src/helpers/getScrollbarSize.ts +0 -14
  86. package/src/helpers/numbers.ts +0 -26
  87. package/src/hooks/index.ts +0 -2
  88. package/src/hooks/useElementSize.ts +0 -24
  89. package/src/hooks/useWindowSize.ts +0 -20
  90. package/src/index.ts +0 -7
  91. package/src/providers/PortalsProvider/index.tsx +0 -54
  92. package/src/providers/PortalsProvider/styles.ts +0 -27
  93. package/src/providers/SettingsProvider/index.tsx +0 -70
  94. package/src/providers/ThemeProvider/ThemeProvider.ts +0 -55
  95. package/src/providers/ThemeProvider/defaultTheme.ts +0 -444
  96. package/src/providers/ThemeProvider/index.ts +0 -3
  97. package/src/providers/ThemeProvider/types.ts +0 -123
  98. package/src/providers/UiProviders/index.tsx +0 -65
  99. package/src/providers/UiProviders/styles.ts +0 -10
  100. package/src/providers/hooks.ts +0 -8
  101. package/src/providers/index.ts +0 -5
  102. package/src/services/HttpService.ts +0 -80
  103. package/src/services/WebSocketService.ts +0 -147
  104. package/src/services/advancedRequests.ts +0 -101
  105. package/src/services/base.ts +0 -31
  106. package/src/services/globalSearch.ts +0 -27
  107. package/src/services/hooks.ts +0 -23
  108. package/src/services/index.ts +0 -2
  109. package/src/services/sqlRequests.ts +0 -110
  110. package/src/styles/animations.scss +0 -30
  111. package/src/styles/index.scss +0 -42
  112. package/src/typings.d.ts +0 -6
  113. package/tsconfig.json +0 -18
  114. package/tsconfig.tsbuildinfo +0 -1
@@ -1,175 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
-
3
- import { DataGridColumn, DataGridContextProps } from '../types';
4
-
5
- import { useCallback } from 'react';
6
-
7
- export const useDataGridCopy = <R>({
8
- rows,
9
- visibleColumns = [],
10
- loadCopyRows,
11
- footerFunctions,
12
- }: Pick<
13
- DataGridContextProps<R>,
14
- 'rows' | 'visibleColumns' | 'loadCopyRows' | 'footerFunctions'
15
- >) => {
16
- const generateHeadersHtml = useCallback(() => {
17
- return `<tr>
18
- ${visibleColumns
19
- .map(
20
- ([, col]) =>
21
- `<th style="
22
- text-align: left;
23
- font-weight: bold;
24
- white-space: nowrap;
25
- ">
26
- ${col.name}
27
- </th>`
28
- )
29
- .join('\n')}
30
- </tr>`;
31
- }, [visibleColumns]);
32
-
33
- const generateFootersHtml = useCallback(
34
- (rowsToCopy: R[]) => {
35
- console.log('generate footers html');
36
- return `<tr>
37
- ${visibleColumns
38
- .map(
39
- ([colKey]) =>
40
- `<td style="
41
- font-weight: bold;
42
- white-space: nowrap;
43
- ">
44
- ${
45
- footerFunctions?.[colKey]?.(
46
- rowsToCopy,
47
- rowsToCopy,
48
- []
49
- ) ?? ''
50
- }
51
- </td>`
52
- )
53
- .join('\n')}
54
- </tr>`;
55
- },
56
- [footerFunctions, visibleColumns]
57
- );
58
-
59
- const generateCellText = useCallback((col: DataGridColumn<R>, value: any) => {
60
- return col.excelValue ? col.excelValue(value) : value?.toString() ?? '';
61
- }, []);
62
-
63
- const generateCellHtml = useCallback(
64
- (col: DataGridColumn<R>, value: any) => `<td style="
65
- ${
66
- col.excelFormatter
67
- ? "mso-number-format: '" + col.excelFormatter(col) + "';"
68
- : ''
69
- }
70
- ${
71
- col.excelBackgroundColor
72
- ? "background-color: '" + col.excelBackgroundColor(value) + "';"
73
- : ''
74
- }
75
- white-space: nowrap;
76
- ">
77
- ${generateCellText(col, value)}
78
- </td>`,
79
- [generateCellText]
80
- );
81
-
82
- const generateCopyHtml = useCallback(
83
- (rowsToCopy: R[], includeHeaders: boolean, includeFooters: boolean) => {
84
- return `
85
- <table>
86
- ${includeHeaders ? generateHeadersHtml() : ''}
87
- ${(rowsToCopy || [])
88
- .map(
89
- (row) =>
90
- `<tr>
91
- ${visibleColumns
92
- .map(([, col]) => {
93
- const value: any =
94
- col.getter && row ? col.getter(row) : '';
95
- return generateCellHtml(col, value);
96
- })
97
- .join('\n')}
98
- </tr>`
99
- )
100
- .join('\n')}
101
- ${includeFooters ? generateFootersHtml(rowsToCopy) : ''}
102
- </table>
103
- `;
104
- },
105
- [visibleColumns, generateCellHtml, generateFootersHtml, generateHeadersHtml]
106
- );
107
-
108
- const generateHeadersText = useCallback(() => {
109
- return visibleColumns.map(([, col]) => col.name).join('\t');
110
- }, [visibleColumns]);
111
-
112
- const generateFootersText = useCallback(
113
- (rowsToCopy: R[]) => {
114
- return visibleColumns
115
- .map(
116
- ([colKey]) => footerFunctions?.[colKey]?.(rowsToCopy, [], []) ?? ''
117
- )
118
- .join('\t');
119
- },
120
- [footerFunctions, visibleColumns]
121
- );
122
-
123
- const generateCopyText = useCallback(
124
- (rowsToCopy: R[], includeHeaders: boolean, includeFooters: boolean) => {
125
- return [
126
- includeHeaders ? generateHeadersText() : '',
127
- ...(rowsToCopy || []).map((row) =>
128
- visibleColumns
129
- .map(([, col]) => {
130
- const value: any = col.getter && row ? col.getter(row) : '';
131
- return col.excelValue
132
- ? col.excelValue(value)
133
- : value != null && value !== undefined
134
- ? value.toString()
135
- : '';
136
- })
137
- .join('\t')
138
- ),
139
- includeFooters ? generateFootersText(rowsToCopy) : '',
140
- ]
141
- .filter((s) => s != null)
142
- .join('\n');
143
- },
144
- [visibleColumns, generateFootersText, generateHeadersText]
145
- );
146
-
147
- const copyTable = useCallback(
148
- async (includeHeaders = true, includeFooters = true) => {
149
- const rowsToCopy = await (loadCopyRows ?? (async () => rows))();
150
-
151
- const copyHtml = generateCopyHtml(
152
- rowsToCopy,
153
- includeHeaders,
154
- includeFooters
155
- );
156
- const copyText = generateCopyText(
157
- rowsToCopy,
158
- includeHeaders,
159
- includeFooters
160
- );
161
-
162
- await navigator['clipboard'].write([
163
- new ClipboardItem({
164
- 'text/plain': new Blob([copyText], { type: 'text/plain' }),
165
- 'text/html': new Blob([copyHtml], { type: 'text/html' }),
166
- }),
167
- ]);
168
- },
169
- [generateCopyHtml, generateCopyText, loadCopyRows, rows]
170
- );
171
-
172
- return {
173
- copyTable,
174
- };
175
- };
@@ -1,48 +0,0 @@
1
- import { useCallback, useEffect, useState } from 'react';
2
-
3
- import { DataGridSettings } from '../types';
4
- import { useSettings } from '../../../../providers';
5
-
6
- export const useDataGridSettings = (name?: string) => {
7
- // TODO: Implement settings context
8
- const { settings, updateSettings } = useSettings();
9
- const [dataGridSettings, setDataGridSettings] = useState<DataGridSettings>(
10
- {}
11
- );
12
-
13
- useEffect(() => {
14
- if (name) {
15
- const settingName = `user.datagrid.settings.${name}`;
16
- const gridSettingsJson = settings?.[settingName] || '{}';
17
- let gridSettings: DataGridSettings = {};
18
- try {
19
- gridSettings = JSON.parse(gridSettingsJson);
20
- } catch (error) {
21
- console.error('[GRID] cannot decode datagrid settings for', {
22
- name,
23
- gridSettingsJson,
24
- error,
25
- });
26
- }
27
- setDataGridSettings(gridSettings);
28
- }
29
- }, [name, settings]);
30
-
31
- const saveSettings = useCallback(
32
- (newValue?: DataGridSettings) => {
33
- if (name) {
34
- const settingName = `user.datagrid.settings.${name}`;
35
- const newSettings = newValue ?? dataGridSettings;
36
- const newSettingsJson = JSON.stringify(newSettings);
37
- updateSettings({ [settingName]: newSettingsJson });
38
- }
39
- },
40
- [dataGridSettings, name, updateSettings]
41
- );
42
-
43
- return {
44
- settings: dataGridSettings,
45
- setSettings: setDataGridSettings,
46
- saveSettings,
47
- };
48
- };
@@ -1,140 +0,0 @@
1
- import * as styles from './styles';
2
-
3
- import { DataGridContextProps, DataGridProps } from './types';
4
-
5
- import { DataGridCell } from './DataGridCell';
6
- import { DataGridFooter } from './DataGridFooter';
7
- import { DataGridHeader } from './DataGridHeader';
8
- import { VirtualScroller } from './VirtualScroller';
9
- import { useCallback } from 'react';
10
- import { useDataGrid } from './hooks';
11
-
12
- /* eslint-disable @typescript-eslint/no-explicit-any */
13
- /* eslint-disable @typescript-eslint/no-unnecessary-type-constraint */
14
-
15
- export const DataGrid = <R,>({
16
- contextOverride,
17
- ...props
18
- }: DataGridProps<R> & {
19
- contextOverride?: Partial<DataGridContextProps<R>>;
20
- }) => {
21
- const {
22
- className,
23
- // onRowDoubleClick,
24
- onVisibleRowsChange,
25
- } = props;
26
- const [contextProps, DataGridContext] = useDataGrid(props, contextOverride);
27
- const {
28
- selectedKeys,
29
- setSelectedKeys,
30
- columns,
31
- visibleColumns,
32
- rowHeight = 32,
33
- headerRowHeight = 40,
34
- scrollableRef,
35
- onScroll,
36
- rowKeyGetter,
37
- } = contextProps;
38
-
39
- const hasFooter = Object.values(columns).some((col) => col.footer);
40
-
41
- const toggleSelection = useCallback(
42
- (key: string) => {
43
- if (selectedKeys.includes(key)) {
44
- setSelectedKeys(selectedKeys.filter((p) => p !== key));
45
- } else {
46
- setSelectedKeys([...selectedKeys, key]);
47
- }
48
- },
49
- [selectedKeys, setSelectedKeys]
50
- );
51
-
52
- const rowTemplate = useCallback(
53
- (row: R, rowIndex: number) => {
54
- if (!row) {
55
- return (
56
- <styles.DataGridRow key={`loading-row-${rowIndex}`}>
57
- {!!props.selectable && (
58
- <styles.LoadingCell className="animate-pulse">
59
- <div />
60
- </styles.LoadingCell>
61
- )}
62
- {visibleColumns.map((_, index) => (
63
- <styles.LoadingCell
64
- className="animate-pulse"
65
- key={`loading-${rowIndex}-${index}`}
66
- >
67
- <div />
68
- </styles.LoadingCell>
69
- ))}
70
- </styles.DataGridRow>
71
- );
72
- }
73
- const key = rowKeyGetter(row);
74
- const { className, style } = props.rowClassNameGetter?.(row) ?? {
75
- className: '',
76
- style: undefined,
77
- };
78
- return (
79
- <styles.DataGridRow key={key}>
80
- {!!props.selectable && (
81
- <styles.SelectionCell
82
- key="__select_checkbox__"
83
- onClick={() => toggleSelection(key)}
84
- >
85
- <input
86
- type="checkbox"
87
- value={key as string}
88
- checked={selectedKeys.includes(key)}
89
- readOnly
90
- />
91
- </styles.SelectionCell>
92
- )}
93
- {visibleColumns.map(([key, col], index) => (
94
- <DataGridCell
95
- key={`loading-${rowIndex}-${index}`}
96
- {...(index === 0 ? { className, style } : {})}
97
- row={row}
98
- rowIndex={rowIndex}
99
- column={col}
100
- columnIndex={index}
101
- context={DataGridContext}
102
- columnKey={key}
103
- />
104
- ))}
105
- </styles.DataGridRow>
106
- );
107
- },
108
- [
109
- DataGridContext,
110
- props,
111
- rowKeyGetter,
112
- selectedKeys,
113
- toggleSelection,
114
- visibleColumns,
115
- ]
116
- );
117
-
118
- return (
119
- <DataGridContext.Provider value={contextProps}>
120
- <styles.DataGridContainer
121
- ref={scrollableRef}
122
- onScroll={onScroll}
123
- $headerRowHeight={headerRowHeight}
124
- $rowHeight={rowHeight}
125
- $rowsCount={contextProps.sortedRows.length}
126
- $withFooter={hasFooter}
127
- className={className}
128
- >
129
- <DataGridHeader context={DataGridContext} />
130
- <VirtualScroller
131
- onRangeChange={onVisibleRowsChange}
132
- hasFooter={hasFooter}
133
- rowTemplate={rowTemplate}
134
- context={DataGridContext}
135
- />
136
- {hasFooter && <DataGridFooter context={DataGridContext} />}
137
- </styles.DataGridContainer>
138
- </DataGridContext.Provider>
139
- );
140
- };
@@ -1,323 +0,0 @@
1
- import styled, { css } from 'styled-components';
2
-
3
- import { ThemeColor } from '../../../providers/ThemeProvider/types';
4
-
5
- export const VIRTUAL_SCROLL_TOLERANCE = 20;
6
- export const TOOLBAR_HEIGHT = 40;
7
- export const DEFAULT_HEADER_ROW_HEIGHT = 40;
8
- export const DEFAULT_FOOTER_ROW_HEIGHT = 40;
9
- export const DEFAULT_ROW_HEIGHT = 32;
10
-
11
- export const TopPaddingRow = styled.div``;
12
- export const BottomPaddingRow = styled.div``;
13
-
14
- export const VirtualScrollerContainer = styled.div<{
15
- $height: number;
16
- }>`
17
- position: relative;
18
- overflow: visible;
19
- height: ${({ $height }) => `${$height}px`};
20
- `;
21
- export const VirtualScrollerRowsContainer = styled.div.attrs<{
22
- $gridTemplateColumns: string;
23
- $topPadding: number;
24
- $rowHeight?: number;
25
- }>(({ $gridTemplateColumns, $topPadding, $rowHeight = DEFAULT_ROW_HEIGHT }) => {
26
- const rowHeightValue = `${$rowHeight}px`;
27
- return {
28
- style: {
29
- top: `${$topPadding}px`,
30
- gridTemplateColumns: $gridTemplateColumns,
31
- gridAutoRows: rowHeightValue,
32
- },
33
- };
34
- })`
35
- display: grid;
36
- position: absolute;
37
-
38
- ${TopPaddingRow} {
39
- grid-column-start: 1;
40
- grid-column-end: -1;
41
- grid-row: 1;
42
- }
43
- ${BottomPaddingRow} {
44
- grid-column-start: 1;
45
- grid-column-end: -1;
46
- grid-row: -1;
47
- }
48
- `;
49
-
50
- export const DataGridResizeGrip = styled.div<{ $headerColor?: ThemeColor }>`
51
- position: absolute;
52
- top: 0;
53
- right: 0;
54
- width: var(--space-1);
55
- height: 100%;
56
-
57
- ${({ $headerColor }) =>
58
- $headerColor
59
- ? css`
60
- background-color: var(--color-${$headerColor}-400);
61
- &:hover,
62
- &.active {
63
- background-color: var(--color-${$headerColor}-500);
64
- }
65
- `
66
- : css`
67
- background-color: var(--color-neutral-400);
68
- &:hover,
69
- &.active {
70
- background-color: var(--color-neutral-500);
71
- }
72
- `}
73
-
74
- cursor: col-resize;
75
- display: none;
76
- `;
77
-
78
- type DataGridHeaderCellContainerProps = {
79
- $isResizing?: boolean;
80
- $headerColor?: ThemeColor;
81
- };
82
-
83
- export const DataGridHeaderCellContainer = styled.div<DataGridHeaderCellContainerProps>`
84
- position: relative;
85
- display: flex;
86
- align-items: center;
87
- flex-wrap: nowrap;
88
- gap: var(--space-1);
89
- padding: 0 0.75rem;
90
- height: 100%;
91
- font-weight: var(--font-bold);
92
- line-height: 1.5rem;
93
- z-index: ${({ $isResizing }) => ($isResizing ? 1 : 0)};
94
-
95
- ${({ $headerColor }) =>
96
- $headerColor
97
- ? css`
98
- background-color: var(--color-${$headerColor}-200);
99
- color: var(--color-${$headerColor}-950);
100
- &:hover {
101
- background-color: var(--color-${$headerColor}-300);
102
- }
103
-
104
- & > button {
105
- background-color: var(--color-${$headerColor}-400);
106
- border-color: var(--color-${$headerColor}-500);
107
- &:hover {
108
- background-color: var(--color-${$headerColor}-500);
109
- border-color: var(--color-${$headerColor}-600);
110
- }
111
- }
112
- & > button.danger {
113
- background-color: var(--color-red-400);
114
- border-color: var(--color-red-500);
115
- &:hover {
116
- background-color: var(--color-red-500);
117
- border-color: var(--color-red-600);
118
- }
119
- }
120
- `
121
- : css`
122
- background-color: var(--color-neutral-200);
123
- color: var(--color-neutral-950);
124
- &:hover {
125
- background-color: var(--color-neutral-300);
126
- }
127
- `}
128
-
129
- &:hover {
130
- ${DataGridResizeGrip} {
131
- display: block;
132
- }
133
- }
134
-
135
- & > span {
136
- display: inline-block;
137
- text-overflow: ellipsis;
138
- overflow: hidden;
139
- white-space: nowrap;
140
- flex: 1;
141
- font-weight: bold;
142
- }
143
- `;
144
- DataGridHeaderCellContainer.displayName = 'DataGridHeaderCellContainer';
145
-
146
- export const DataGridCell = styled.div`
147
- position: relative;
148
- padding: 0 var(--space-3);
149
- overflow: hidden;
150
- text-overflow: ellipsis;
151
- white-space: nowrap;
152
- border-right: 1px solid var(--color-neutral-200);
153
- border-bottom: 1px solid var(--color-neutral-200);
154
- `;
155
- DataGridCell.displayName = 'DataGridCell';
156
-
157
- export const DataGridToolsRow = styled.div`
158
- grid-column-start: 1;
159
- grid-column-end: -1;
160
- grid-row: 1;
161
- display: flex;
162
- gap: var(--space-1);
163
- padding: 0 var(--space-1);
164
- align-items: center;
165
- background-color: var(--color-neutral-200);
166
- position: sticky;
167
- top: 0;
168
- left: 0;
169
- z-index: 10;
170
- `;
171
- DataGridToolsRow.displayName = 'DataGridToolsRow';
172
-
173
- export const DataGridContainer = styled.div<{
174
- $headerRowHeight?: number;
175
- $rowHeight?: number;
176
- $rowsCount: number;
177
- $showToolsHeader?: boolean;
178
- $withFooter?: boolean;
179
- }>`
180
- display: grid;
181
- width: 100%;
182
- height: 100%;
183
- background-color: var(--color-neutral-50);
184
- font-size: var(--text-base);
185
- overflow: scroll;
186
- grid-template-rows: ${({
187
- $headerRowHeight = DEFAULT_HEADER_ROW_HEIGHT,
188
- $withFooter = false,
189
- }) =>
190
- `${TOOLBAR_HEIGHT}px ${$headerRowHeight}px auto ${
191
- $withFooter ? DEFAULT_FOOTER_ROW_HEIGHT + 'px' : ''
192
- }`};
193
-
194
- ${DataGridToolsRow} {
195
- height: ${TOOLBAR_HEIGHT}px;
196
- }
197
- ${DataGridHeaderCellContainer} {
198
- position: sticky;
199
- top: ${({ $headerRowHeight = DEFAULT_HEADER_ROW_HEIGHT }) =>
200
- `${$headerRowHeight}px`};
201
- height: ${({ $headerRowHeight = DEFAULT_HEADER_ROW_HEIGHT }) =>
202
- `${$headerRowHeight}px`};
203
- }
204
- ${DataGridCell} {
205
- height: ${({ $rowHeight = DEFAULT_ROW_HEIGHT }) => `${$rowHeight}px`};
206
- line-height: ${({ $rowHeight = DEFAULT_ROW_HEIGHT }) => `${$rowHeight}px`};
207
- }
208
-
209
- ${VirtualScrollerContainer} {
210
- grid-column-start: 1;
211
- grid-column-end: -1;
212
- grid-row: 3;
213
- }
214
- `;
215
- DataGridContainer.displayName = 'DataGridContainer';
216
-
217
- type DataGridHeaderOrFooterRowProps = {
218
- $headerRowHeight?: number;
219
- $headerColor?: ThemeColor;
220
- $gridTemplateColumns: string;
221
- };
222
-
223
- const dataGridHeaderOrFooterRowCss = css<DataGridHeaderOrFooterRowProps>`
224
- display: grid;
225
- grid-template-rows: ${({ $headerRowHeight = DEFAULT_HEADER_ROW_HEIGHT }) =>
226
- `${$headerRowHeight}px`};
227
- z-index: 10;
228
- position: sticky;
229
- align-items: center;
230
-
231
- ${({ $headerColor }) =>
232
- $headerColor
233
- ? css`
234
- background-color: var(--color-${$headerColor}-100);
235
- color: var(--color-${$headerColor}-900);
236
- `
237
- : css`
238
- background-color: var(--color-neutral-200);
239
- color: var(--color-neutral-900);
240
- `}
241
- `;
242
-
243
- export const DataGridHeaderRow = styled.div.attrs<DataGridHeaderOrFooterRowProps>(
244
- ({ $gridTemplateColumns }) => ({
245
- style: {
246
- gridTemplateColumns: $gridTemplateColumns,
247
- },
248
- })
249
- )`
250
- ${dataGridHeaderOrFooterRowCss}
251
- top: ${TOOLBAR_HEIGHT}px;
252
- `;
253
- DataGridHeaderRow.displayName = 'DataGridHeaderRow';
254
-
255
- export const DataGridFooterRow = styled.div.attrs<DataGridHeaderOrFooterRowProps>(
256
- ({ $gridTemplateColumns }) => ({
257
- style: {
258
- gridTemplateColumns: $gridTemplateColumns,
259
- },
260
- })
261
- )`
262
- ${dataGridHeaderOrFooterRowCss}
263
- bottom: 0;
264
- `;
265
- DataGridFooterRow.displayName = 'DataGridFooterRow';
266
-
267
- export const DataGridRow = styled.div`
268
- display: contents;
269
- `;
270
- DataGridRow.displayName = 'DataGridRow';
271
-
272
- export const LoadingCell = styled(DataGridCell)`
273
- padding: var(--space-2);
274
- box-sizing: border-box;
275
-
276
- &.animate-pulse > div {
277
- background-color: var(--color-neutral-200);
278
- border-radius: var(--rounded-full);
279
- width: 100%;
280
- height: 100%;
281
- }
282
- `;
283
- LoadingCell.displayName = 'LoadingCell';
284
-
285
- const selectionCellStyle = css`
286
- display: flex;
287
- align-items: center;
288
- justify-content: center;
289
- width: var(--space-8);
290
- padding: 0 var(--space-1);
291
- cursor: pointer;
292
-
293
- & > input[type='checkbox'] {
294
- height: var(--space-4);
295
- width: var(--space-4);
296
- border-radius: var(--rounded-sm);
297
- border: 1px solid var(--color-neutral-300);
298
- color: var(--color-primary-600);
299
- }
300
- `;
301
-
302
- export const SelectionCell = styled(DataGridCell)`
303
- ${selectionCellStyle}
304
- `;
305
- SelectionCell.displayName = 'SelectionCell';
306
-
307
- export const HeaderSelectionCell = styled(DataGridHeaderCellContainer)`
308
- ${selectionCellStyle}
309
- `;
310
- HeaderSelectionCell.displayName = 'HeaderSelectionCell';
311
-
312
- export const ResizeBackdrop = styled.div.attrs({
313
- className: 'ResizeBackdrop',
314
- })`
315
- position: fixed;
316
- top: 0;
317
- left: 0;
318
- right: 0;
319
- bottom: 0;
320
- background-color: rgba(0, 0, 0, 0);
321
- cursor: col-resize;
322
- `;
323
- ResizeBackdrop.displayName = 'ResizeBackdrop';