@indico-data/design-system 2.50.0 → 2.51.1

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 (74) hide show
  1. package/lib/components/tanstackTable/TankstackTable.types.d.ts +45 -0
  2. package/lib/components/tanstackTable/TanstackTable.stories.d.ts +16 -0
  3. package/lib/components/tanstackTable/TanstakTable.d.ts +4 -0
  4. package/lib/components/tanstackTable/__tests__/TanstackTable.test.d.ts +1 -0
  5. package/lib/components/tanstackTable/__tests__/__mocks__/test-mock-data.d.ts +8 -0
  6. package/lib/components/tanstackTable/components/ActionBar/ActionBar.d.ts +17 -0
  7. package/lib/components/tanstackTable/components/ActionBar/ActionBar.stories.d.ts +10 -0
  8. package/lib/components/tanstackTable/components/ActionBar/__tests__/ActionBar.test.d.ts +1 -0
  9. package/lib/components/tanstackTable/components/ActionBar/index.d.ts +1 -0
  10. package/lib/components/tanstackTable/components/NoResults/NoResults.d.ts +7 -0
  11. package/lib/components/tanstackTable/components/NoResults/__tests__/NoResult.test.d.ts +1 -0
  12. package/lib/components/tanstackTable/components/NoResults/index.d.ts +1 -0
  13. package/lib/components/tanstackTable/components/TableBody/TableBody.d.ts +11 -0
  14. package/lib/components/tanstackTable/components/TableBody/index.d.ts +1 -0
  15. package/lib/components/tanstackTable/components/TableHeader/TableHeader.d.ts +6 -0
  16. package/lib/components/tanstackTable/components/TableHeader/index.d.ts +1 -0
  17. package/lib/components/tanstackTable/components/TablePagination/TablePagination.d.ts +9 -0
  18. package/lib/components/tanstackTable/components/TablePagination/__tests__/TablePagination.test.d.ts +1 -0
  19. package/lib/components/tanstackTable/components/TablePagination/index.d.ts +1 -0
  20. package/lib/components/tanstackTable/docs/pinnedColumns/PinnedColumn.stories.d.ts +7 -0
  21. package/lib/components/tanstackTable/docs/withRowClick/WithRowClick.stories.d.ts +7 -0
  22. package/lib/components/tanstackTable/helpers.d.ts +830 -0
  23. package/lib/components/tanstackTable/index.d.ts +2 -0
  24. package/lib/components/tanstackTable/mock-data/mock-data.d.ts +14 -0
  25. package/lib/components/tanstackTable/mock-data/table-configuration.d.ts +3 -0
  26. package/lib/components/tanstackTable/useTanstackTable.d.ts +14 -0
  27. package/lib/index.css +262 -0
  28. package/lib/index.d.ts +67 -17
  29. package/lib/index.esm.css +262 -0
  30. package/lib/index.esm.js +20432 -56
  31. package/lib/index.esm.js.map +1 -1
  32. package/lib/index.js +20432 -55
  33. package/lib/index.js.map +1 -1
  34. package/package.json +2 -1
  35. package/src/components/tanstackTable/TankstackTable.types.ts +44 -0
  36. package/src/components/tanstackTable/TanstackTable.mdx +122 -0
  37. package/src/components/tanstackTable/TanstackTable.stories.tsx +284 -0
  38. package/src/components/tanstackTable/TanstakTable.tsx +156 -0
  39. package/src/components/tanstackTable/__tests__/TanstackTable.test.tsx +73 -0
  40. package/src/components/tanstackTable/__tests__/__mocks__/test-mock-data.tsx +83 -0
  41. package/src/components/tanstackTable/components/ActionBar/ActionBar.mdx +10 -0
  42. package/src/components/tanstackTable/components/ActionBar/ActionBar.scss +30 -0
  43. package/src/components/tanstackTable/components/ActionBar/ActionBar.stories.tsx +98 -0
  44. package/src/components/tanstackTable/components/ActionBar/ActionBar.tsx +43 -0
  45. package/src/components/tanstackTable/components/ActionBar/__tests__/ActionBar.test.tsx +65 -0
  46. package/src/components/tanstackTable/components/ActionBar/index.ts +1 -0
  47. package/src/components/tanstackTable/components/NoResults/NoResults.scss +24 -0
  48. package/src/components/tanstackTable/components/NoResults/NoResults.tsx +22 -0
  49. package/src/components/tanstackTable/components/NoResults/__tests__/NoResult.test.tsx +25 -0
  50. package/src/components/tanstackTable/components/NoResults/index.ts +1 -0
  51. package/src/components/tanstackTable/components/TableBody/TableBody.tsx +77 -0
  52. package/src/components/tanstackTable/components/TableBody/index.ts +1 -0
  53. package/src/components/tanstackTable/components/TableHeader/TableHeader.tsx +49 -0
  54. package/src/components/tanstackTable/components/TableHeader/index.ts +1 -0
  55. package/src/components/tanstackTable/components/TablePagination/TablePagination.tsx +45 -0
  56. package/src/components/tanstackTable/components/TablePagination/__tests__/TablePagination.test.tsx +18 -0
  57. package/src/components/tanstackTable/components/TablePagination/index.ts +1 -0
  58. package/src/components/tanstackTable/docs/pinnedColumns/PinnedColumn.mdx +34 -0
  59. package/src/components/tanstackTable/docs/pinnedColumns/PinnedColumn.stories.tsx +40 -0
  60. package/src/components/tanstackTable/docs/withRowClick/WithRowClick.mdx +48 -0
  61. package/src/components/tanstackTable/docs/withRowClick/WithRowClick.stories.tsx +32 -0
  62. package/src/components/tanstackTable/helpers.ts +45 -0
  63. package/src/components/tanstackTable/index.ts +2 -0
  64. package/src/components/tanstackTable/mock-data/mock-data.ts +256 -0
  65. package/src/components/tanstackTable/mock-data/table-configuration.tsx +222 -0
  66. package/src/components/tanstackTable/styles/_variables.scss +35 -0
  67. package/src/components/tanstackTable/styles/table.scss +218 -0
  68. package/src/components/tanstackTable/styles/test.scss +19 -0
  69. package/src/components/tanstackTable/tanstack-table.d.ts +19 -0
  70. package/src/components/tanstackTable/useTanstackTable.tsx +39 -0
  71. package/src/index.ts +1 -0
  72. package/src/legacy/components/loading-indicators/CirclePulse/CirclePulse.tsx +1 -0
  73. package/src/styles/index.scss +1 -0
  74. package/src/stylesAndAnimations/utilityClasses/UtilityClassesTable.tsx +16 -2
@@ -0,0 +1,218 @@
1
+ @import './_variables.scss';
2
+ @import './test.scss';
3
+
4
+ @import '../components/ActionBar/ActionBar.scss';
5
+ @import '../components/NoResults/NoResults.scss';
6
+
7
+ .tanstack-table__outer-container {
8
+ .tanstack-table__column--is-pinned {
9
+ opacity: 1;
10
+ }
11
+
12
+ .tanstack-table__column--is-not-pinned {
13
+ opacity: 0.3;
14
+ }
15
+
16
+ .tanstack-table__container {
17
+ height: calc(100vh - 70px);
18
+ grid-template-rows: auto 1fr auto;
19
+ grid-template-columns: 1fr;
20
+ display: grid;
21
+ grid-template-rows: auto 1fr auto;
22
+ grid-template-columns: 1fr;
23
+ overflow-x: auto;
24
+ overflow-y: auto;
25
+ background-color: var(--pf-tanstack-table-background-color);
26
+ border-radius: var(--pf-rounded-lg);
27
+ border-left: var(--pf-border-sm) solid var(--pf-tanstack-table-border-color);
28
+ border-right: var(--pf-border-sm) solid var(--pf-tanstack-table-border-color);
29
+ border-bottom: var(--pf-border-sm) solid var(--pf-tanstack-table-border-color);
30
+
31
+ // Webkit scrollbar styles
32
+ &::-webkit-scrollbar {
33
+ width: var(--pf-size-2);
34
+ height: var(--pf-size-2);
35
+ cursor: pointer;
36
+ }
37
+
38
+ &::-webkit-scrollbar-track {
39
+ background: var(--pf-tanstack-table-background-color);
40
+ border-radius: var(--pf-rounded);
41
+ cursor: pointer;
42
+ }
43
+
44
+ &::-webkit-scrollbar-thumb {
45
+ background: var(--pf-tanstack-table-border-color);
46
+ border-radius: var(--pf-rounded);
47
+ cursor: pointer;
48
+ &:hover {
49
+ background: var(--pf-primary-color);
50
+ }
51
+ }
52
+
53
+ // Firefox scrollbar styles
54
+ scrollbar-width: thin;
55
+ scrollbar-color: var(--pf-tanstack-table-border-color) var(--pf-tanstack-table-background-color);
56
+ }
57
+ }
58
+
59
+ .tanstack-table {
60
+ border-collapse: separate;
61
+ margin: 0;
62
+ table-layout: auto;
63
+ border-spacing: 0;
64
+ border-radius: var(--pf-rounded-lg);
65
+ width: 100%;
66
+
67
+ &.is-loading {
68
+ border: var(--pf-border-thin) solid var(--pf-border-color);
69
+ height: 100%;
70
+ width: 100%;
71
+ }
72
+
73
+ &__thead {
74
+ position: sticky;
75
+ top: 0;
76
+ z-index: 3;
77
+ box-sizing: border-box;
78
+
79
+ background-color: var(--pf-tanstack-table-background-color);
80
+
81
+ tr:first-child {
82
+ th {
83
+ &:first-child {
84
+ border-left: none;
85
+ }
86
+
87
+ &:last-child {
88
+ border-right: none;
89
+ }
90
+ }
91
+ }
92
+
93
+ &__th {
94
+ color: var(--pf-tanstack-table-font-color);
95
+ background: var(--pf-tanstack-table-background-color);
96
+ font-size: var(--pf-tanstack-table-font-size);
97
+ font-weight: var(--pf-font-weight-medium);
98
+ box-sizing: border-box;
99
+
100
+ border-top: var(--pf-border-sm) solid var(--pf-tanstack-table-border-color);
101
+ border-bottom: var(--pf-border-sm) solid var(--pf-tanstack-table-border-color);
102
+ border-right: var(--pf-border-sm) solid var(--pf-tanstack-table-border-color);
103
+
104
+ user-select: none;
105
+
106
+ overflow: hidden;
107
+ text-overflow: ellipsis;
108
+ white-space: nowrap;
109
+
110
+ max-width: 300px;
111
+ width: auto;
112
+ padding: 0 var(--pf-padding-2);
113
+ text-align: left;
114
+
115
+ &:first-child {
116
+ border-left: none;
117
+ }
118
+
119
+ &:last-child {
120
+ border-right: none;
121
+ }
122
+ }
123
+ }
124
+
125
+ &__tbody {
126
+ tr:last-child {
127
+ border-bottom: none;
128
+ }
129
+
130
+ &__tr {
131
+ background: transparent;
132
+ width: 100%;
133
+ border-left: none;
134
+ border-right: none;
135
+
136
+ &.is-selected {
137
+ td {
138
+ background: var(--pf-tanstack-table-checked-color);
139
+ }
140
+ }
141
+
142
+ &.show-hover {
143
+ &:hover {
144
+ td {
145
+ background-color: var(--pf-tanstack-table-hover-color);
146
+ cursor: pointer;
147
+ }
148
+ }
149
+ }
150
+
151
+ &.is-clicked {
152
+ td {
153
+ background-color: var(--pf-tanstack-table-clicked-color);
154
+ }
155
+ }
156
+ }
157
+
158
+ &__td {
159
+ font-size: var(--pf-font-size-base);
160
+ font-weight: var(--pf-font-weight-medium);
161
+ color: var(--pf-tanstack-table-font-color);
162
+ background: var(--pf-tanstack-table-background-color);
163
+
164
+ border-right: var(--pf-border-sm) solid var(--pf-tanstack-table-border-color);
165
+ border-bottom: var(--pf-border-sm) solid var(--pf-tanstack-table-border-color);
166
+
167
+ box-sizing: border-box;
168
+
169
+ overflow: hidden;
170
+ text-overflow: ellipsis;
171
+ white-space: nowrap;
172
+
173
+ padding: 0 var(--pf-padding-2);
174
+ max-width: 300px;
175
+ width: auto;
176
+ text-align: left;
177
+
178
+ &:first-child {
179
+ border-left: none;
180
+ }
181
+
182
+ &:last-child {
183
+ border-right: none;
184
+ }
185
+ }
186
+ }
187
+
188
+ &__centered-row {
189
+ padding: var(--pf-padding-1) var(--pf-padding-2);
190
+ text-align: center;
191
+ vertical-align: middle;
192
+ height: 100%;
193
+ border: var(--pf-border-sm) solid var(--pf-border-color);
194
+
195
+ @keyframes shimmer {
196
+ 0% {
197
+ background-color: var(--pf-primary-color-700) 40;
198
+ }
199
+ 50% {
200
+ background-color: var(--pf-primary-color-700);
201
+ }
202
+ 100% {
203
+ background-color: var(--pf-primary-color-700) 40;
204
+ }
205
+ }
206
+
207
+ animation: none;
208
+
209
+ &.is-loading {
210
+ animation: shimmer 3s ease-in-out infinite;
211
+ }
212
+
213
+ svg {
214
+ margin: 0 auto;
215
+ display: block;
216
+ }
217
+ }
218
+ }
@@ -0,0 +1,19 @@
1
+ .tanstack-table__action-bar-test {
2
+ left: 20% !important;
3
+ }
4
+
5
+ .tanstack-table__action-bar-docs {
6
+ bottom: unset !important;
7
+ top: 50% !important;
8
+ transform: translate(-50%, -50%) !important;
9
+ }
10
+
11
+ .tanstack-table__column {
12
+ &.is-pinned {
13
+ opacity: 1;
14
+ }
15
+
16
+ &.is-not-pinned {
17
+ opacity: 0.3;
18
+ }
19
+ }
@@ -0,0 +1,19 @@
1
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2
+ import '@tanstack/react-table';
3
+
4
+ declare module '@tanstack/react-table' {
5
+ interface ColumnMeta<TData extends RowData, TValue> {
6
+ styles: {
7
+ definedColumnSize?: boolean;
8
+ header?: {
9
+ hasNoPadding?: boolean;
10
+ textAlign?: 'left' | 'center' | 'right';
11
+ };
12
+ cell?: {
13
+ hasNoPadding?: boolean;
14
+ textAlign?: 'left' | 'center' | 'right';
15
+ preventRowSelection?: boolean;
16
+ };
17
+ };
18
+ }
19
+ }
@@ -0,0 +1,39 @@
1
+ import { useState } from 'react';
2
+
3
+ import { ColumnDef } from '@tanstack/react-table';
4
+ import { useEffect, useMemo } from 'react';
5
+
6
+ type Props<T> = {
7
+ defaultColumns: ColumnDef<T>[];
8
+ };
9
+
10
+ export function useTanstackTable<T>({ defaultColumns }: Props<T>) {
11
+ const columns = useMemo<ColumnDef<T>[]>(() => defaultColumns, []);
12
+ const defaultData = useMemo(() => [], []);
13
+ const [windowWidth, setWindowWidth] = useState(window.innerWidth);
14
+ const [rowSelection, setRowSelection] = useState({});
15
+ const [formattedColumns, setFormattedColumns] = useState<ColumnDef<T>[]>(columns);
16
+
17
+ // Tracks changes to browser width to allow for updating of column widths
18
+ useEffect(() => {
19
+ const handleResize = () => {
20
+ setWindowWidth(window.innerWidth);
21
+ };
22
+
23
+ window.addEventListener('resize', handleResize);
24
+
25
+ return () => {
26
+ window.removeEventListener('resize', handleResize);
27
+ };
28
+ }, []);
29
+
30
+ return {
31
+ columns,
32
+ defaultData,
33
+ rowSelection,
34
+ setRowSelection,
35
+ windowWidth,
36
+ formattedColumns,
37
+ setFormattedColumns,
38
+ };
39
+ }
package/src/index.ts CHANGED
@@ -28,6 +28,7 @@ export { Menu } from './components/menu';
28
28
  export { Pill } from './components/pill';
29
29
  export { Badge } from './components/badge';
30
30
  export { Modal } from './components/modal';
31
+ export { TanstackTable } from './components/tanstackTable';
31
32
 
32
33
  // Utilities
33
34
  export { registerFontAwesomeIcons } from './setup/setupIcons';
@@ -29,6 +29,7 @@ export function CirclePulse(props: Props): React.ReactElement {
29
29
  aria-hidden={true}
30
30
  className={className}
31
31
  data-cy={props['data-cy']}
32
+ data-testid={props['data-testid']}
32
33
  id={id}
33
34
  overallsize={returnSizeString(overallSize)}
34
35
  ripplesize={returnSizeString(rippleSize)}
@@ -24,6 +24,7 @@
24
24
  @import '../components/badge/styles/Badge.scss';
25
25
  @import '../components/modal/styles/Modal.scss';
26
26
  @import '../components/pagination/styles/Pagination.scss';
27
+ @import '../components/tanstackTable/styles/table.scss';
27
28
 
28
29
  @import '../components/pill/styles/Pill.scss';
29
30
  @import 'sheets'; // Port to an sheets component when we build it
@@ -101,8 +101,15 @@ export const UtilityClassesTable = () => {
101
101
 
102
102
  <Table
103
103
  columns={[
104
- { name: 'Class Name', selector: (row) => row.className, sortable: true, width: '225px' },
105
104
  {
105
+ id: 'className',
106
+ name: 'Class Name',
107
+ selector: (row) => row.className,
108
+ sortable: true,
109
+ width: '225px',
110
+ },
111
+ {
112
+ id: 'cssApplied',
106
113
  name: 'CSS Applied',
107
114
  selector: (row) => formatCss(row.css),
108
115
  sortable: true,
@@ -119,6 +126,7 @@ export const UtilityClassesTable = () => {
119
126
  ),
120
127
  },
121
128
  {
129
+ id: 'resolvedCss',
122
130
  name: 'Resolved CSS',
123
131
  selector: (row) => formatCss(row.resolvedCss || ''),
124
132
  sortable: true,
@@ -134,7 +142,13 @@ export const UtilityClassesTable = () => {
134
142
  </pre>
135
143
  ),
136
144
  },
137
- { name: 'Category', selector: (row) => row.category, sortable: true, width: '114px' },
145
+ {
146
+ id: 'category',
147
+ name: 'Category',
148
+ selector: (row) => row.category,
149
+ sortable: true,
150
+ width: '114px',
151
+ },
138
152
  ]}
139
153
  data={filteredData}
140
154
  dense