playbook_ui 13.17.0 → 13.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_reset.scss +2 -2
  3. data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +1 -2
  4. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +1 -0
  5. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +292 -3
  6. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_collapsible_trail.jsx +52 -0
  7. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_collapsible_trail.md +1 -0
  8. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.md +7 -2
  9. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_expanded_control.jsx +59 -0
  10. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_expanded_control.md +18 -0
  11. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_loading.jsx +60 -0
  12. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_loading.md +3 -0
  13. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort.jsx +1 -6
  14. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort.md +5 -0
  15. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_control.jsx +63 -0
  16. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_control.md +3 -0
  17. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_subrow_headers.jsx +57 -0
  18. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_subrow_headers.md +3 -0
  19. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_options.jsx +61 -0
  20. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_options.md +3 -0
  21. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.jsx +55 -0
  22. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.md +1 -0
  23. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +10 -4
  24. data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +7 -0
  25. data/app/pb_kits/playbook/pb_advanced_table/scss_partials/_loading.scss +4 -3
  26. data/app/pb_kits/playbook/pb_collapsible/_collapsible.scss +2 -2
  27. data/app/pb_kits/playbook/pb_date_picker/sass_partials/_flatpickr_styles.scss +1 -1
  28. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_validation.html.erb +5 -7
  29. data/app/pb_kits/playbook/pb_popover/_popover.tsx +12 -14
  30. data/app/pb_kits/playbook/pb_popover/docs/_popover_actionable_content.html.erb +30 -0
  31. data/app/pb_kits/playbook/pb_popover/docs/_popover_actionable_content.jsx +57 -0
  32. data/app/pb_kits/playbook/pb_popover/docs/example.yml +2 -1
  33. data/app/pb_kits/playbook/pb_popover/docs/index.js +1 -0
  34. data/app/pb_kits/playbook/pb_popover/popover.test.js +29 -31
  35. data/app/pb_kits/playbook/pb_table/_table.tsx +3 -0
  36. data/app/pb_kits/playbook/pb_table/docs/_table_striped.html.erb +48 -0
  37. data/app/pb_kits/playbook/pb_table/docs/_table_striped.jsx +58 -0
  38. data/app/pb_kits/playbook/pb_table/docs/_table_striped.md +1 -0
  39. data/app/pb_kits/playbook/pb_table/docs/example.yml +2 -0
  40. data/app/pb_kits/playbook/pb_table/docs/index.js +1 -0
  41. data/app/pb_kits/playbook/pb_table/styles/_all.scss +1 -0
  42. data/app/pb_kits/playbook/pb_table/styles/_striped.scss +19 -0
  43. data/app/pb_kits/playbook/pb_table/table.rb +7 -1
  44. data/app/pb_kits/playbook/pb_table/table.test.js +5 -0
  45. data/dist/menu.yml +102 -3
  46. data/dist/playbook-rails.js +7 -7
  47. data/dist/reset.css +1 -2
  48. data/lib/playbook/version.rb +2 -2
  49. metadata +23 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c288d80cbfc92741e976eda7ca6fd7e4ecbf256b5f5ad9e4e8a23f2b4ddb6ae
4
- data.tar.gz: 675612e33fd9e560aa274763e5de44bfea34fd1af570d03b951a803994fbd4dd
3
+ metadata.gz: f629448a4cd0208c365ff8cd0c7c18a3fb911bdc118497843b76279f9309b7c9
4
+ data.tar.gz: 466dd0df9bd42b611106524156fc473ad518fbe78ae1bb586a3e8715317586f3
5
5
  SHA512:
6
- metadata.gz: 3d14807433425abbbd0fdf53733c4e2addc7ebb6506d35a89ea7b06f06746c39e815d7e3100a57e54cf4fea14cfb8779693b0140da9d4b4f31eb5867a752b467
7
- data.tar.gz: 916468edea21563fb47710ec9a691e16a0ba1852fc4b4f97637884d560a5ae0b7b55a6a434bfd73fec6d756e68b5af89a5b4b49f2b97f4f19d3b38fa4463df0e
6
+ metadata.gz: 5f1d56aa0e2398edd4c6f97ea258e7d2f4d71f11b18a5410c82a9a142c4a3324ec0dd71dca84c7554dc0a7aee273e6e56c936c80351a241ce49157ef76806e36
7
+ data.tar.gz: 216199bebe300338129cda84ff8c4d0765231c1aecfa2bbfec3f008012ee39e019aac578b88926d06f5e7823d593f177ba699b4ae43091a6648cf1b77c4d24b0
@@ -1,5 +1,5 @@
1
- @import "./tokens/typography";
2
- @import "./tokens/colors";
1
+ @import "tokens/typography";
2
+ @import "tokens/colors";
3
3
 
4
4
  * {
5
5
  box-sizing: border-box;
@@ -72,7 +72,6 @@ const cellId = `${loading ?
72
72
  <Flex
73
73
  alignItems="center"
74
74
  justify={header.index === 0 && enableSorting ? "between" : header.index === 0 && !enableSorting ? "start" : "end"}
75
- paddingLeft={loading ? "sm" : "none"}
76
75
  >
77
76
  {header.index === 0 &&
78
77
  !loading &&
@@ -114,7 +113,7 @@ const cellId = `${loading ?
114
113
  header.column.getCanSort() &&
115
114
  enableSorting &&
116
115
  (loading ? (
117
- <div className="loading-toggle-icon header-sort-icon" />
116
+ <div className="loading-toggle-icon" />
118
117
  ) : (
119
118
  <SortIconButton header={header}
120
119
  sortIcon={sortIcon}
@@ -162,6 +162,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
162
162
  getExpandedRowModel: getExpandedRowModel(),
163
163
  getSortedRowModel: getSortedRowModel(),
164
164
  enableSortingRemoval: false,
165
+ sortDescFirst: true,
165
166
  ...expandAndSortState(),
166
167
  ...tableOptions,
167
168
  });
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React, {useState} from "react";
2
2
  import { render, screen } from "../utilities/test-utils";
3
3
 
4
4
  import { AdvancedTable } from "../";
@@ -13,7 +13,25 @@ const MOCK_DATA = [
13
13
  scheduledMeetings: "10",
14
14
  children: [
15
15
  {
16
- year: "2011",
16
+ year: "2021",
17
+ quarter: "Q1",
18
+ month: null,
19
+ day: null,
20
+ newEnrollments: "2",
21
+ scheduledMeetings: "35",
22
+ },
23
+ ],
24
+ },
25
+ {
26
+ year: "2022",
27
+ quarter: null,
28
+ month: null,
29
+ day: null,
30
+ newEnrollments: "20",
31
+ scheduledMeetings: "10",
32
+ children: [
33
+ {
34
+ year: "2022",
17
35
  quarter: "Q1",
18
36
  month: null,
19
37
  day: null,
@@ -40,9 +58,70 @@ const columnDefinitions = [
40
58
  },
41
59
  ];
42
60
 
61
+ const subRowHeaders = ["Quarter"]
62
+
43
63
  const testId = "advanced_table";
44
64
 
45
- test("generated scaffold test", () => {
65
+ const AdvancedTableExpandControl = () => {
66
+ const [expanded, setExpanded] = useState({'0': true})
67
+
68
+ const expandedControl = {
69
+ value: expanded,
70
+ onChange: setExpanded,
71
+ }
72
+
73
+ return (
74
+ <div>
75
+ <AdvancedTable
76
+ columnDefinitions={columnDefinitions}
77
+ data={{ testid: testId }}
78
+ expandedControl={expandedControl}
79
+ tableData={MOCK_DATA}
80
+ />
81
+ </div>
82
+ );
83
+ }
84
+
85
+ const AdvancedTableSortControl = () => {
86
+ const [isSortDesc, setIsSortDesc] = useState({desc: false})
87
+
88
+ const sortControl = {
89
+ value: isSortDesc,
90
+ onChange: setIsSortDesc,
91
+ }
92
+
93
+ return (
94
+ <div>
95
+ <AdvancedTable
96
+ columnDefinitions={columnDefinitions}
97
+ data={{testid: testId}}
98
+ sortControl={sortControl}
99
+ tableData={MOCK_DATA}
100
+ >
101
+ <AdvancedTable.Header enableSorting />
102
+ <AdvancedTable.Body />
103
+ </AdvancedTable>
104
+ </div>
105
+ );
106
+ }
107
+
108
+ const tableOptions = {
109
+ initialState: {
110
+ sorting: [
111
+ {
112
+ id: "year",
113
+ desc: true,
114
+ },
115
+ ],
116
+ },
117
+ }
118
+
119
+ const tableProps = {
120
+ container: false,
121
+ sticky: true
122
+ }
123
+
124
+ test("Generates default kit and classname", () => {
46
125
  render(
47
126
  <AdvancedTable
48
127
  columnDefinitions={columnDefinitions}
@@ -53,4 +132,214 @@ test("generated scaffold test", () => {
53
132
 
54
133
  const kit = screen.getByTestId(testId);
55
134
  expect(kit).toBeInTheDocument();
135
+ expect(kit).toHaveClass('pb_advanced_table')
136
+ });
137
+
138
+ test("Generates aria label", () => {
139
+ render(
140
+ <AdvancedTable
141
+ aria={{label:testId}}
142
+ columnDefinitions={columnDefinitions}
143
+ data={{ testid: testId }}
144
+ tableData={MOCK_DATA}
145
+ />
146
+ );
147
+
148
+ const kit = screen.getByTestId(testId);
149
+ expect(kit).toHaveAttribute('aria-label', testId)
150
+ });
151
+
152
+ test("Row toggle button exists and toggles subrows open and closed", () => {
153
+ render(
154
+ <AdvancedTable
155
+ columnDefinitions={columnDefinitions}
156
+ data={{ testid: testId }}
157
+ tableData={MOCK_DATA}
158
+ />
159
+ );
160
+
161
+ const kit = screen.getByTestId(testId);
162
+ const rowButton = kit.querySelector(".gray-icon.expand-toggle-icon")
163
+ expect(rowButton).toBeInTheDocument()
164
+ const subRow1 = kit.querySelector(".bg-white.depth-sub-row-1")
165
+ expect(subRow1).not.toBeInTheDocument()
166
+ rowButton.click()
167
+ const subRow = kit.querySelector(".bg-white.depth-sub-row-1")
168
+ expect(subRow).toBeInTheDocument()
169
+ });
170
+
171
+ test("toggleExpansionAll button exists and toggles subrows open and closed", () => {
172
+ render(
173
+ <AdvancedTable
174
+ columnDefinitions={columnDefinitions}
175
+ data={{ testid: testId }}
176
+ tableData={MOCK_DATA}
177
+ />
178
+ );
179
+
180
+ const kit = screen.getByTestId(testId);
181
+ const toggleButton = kit.querySelector(".gray-icon.toggle-all-icon")
182
+ expect(toggleButton).toBeInTheDocument()
183
+ const subRow1 = kit.querySelector(".bg-white.depth-sub-row-1")
184
+ expect(subRow1).not.toBeInTheDocument()
185
+ toggleButton.click()
186
+ const subRow = kit.querySelector(".bg-white.depth-sub-row-1")
187
+ expect(subRow).toBeInTheDocument()
188
+ });
189
+
190
+ test("loading state + initialLoadingRowCount prop", () => {
191
+ render(
192
+ <AdvancedTable
193
+ columnDefinitions={columnDefinitions}
194
+ data={{ testid: testId }}
195
+ initialLoadingRowsCount={13}
196
+ loading
197
+ tableData={MOCK_DATA}
198
+ />
199
+ );
200
+
201
+ const kit = screen.getByTestId(testId);
202
+ const table = kit.querySelector('table')
203
+ expect(table).toHaveClass('pb_table table-sm table-responsive-none table-card data_table ns_tabular content-loading')
204
+
205
+ const tableBody = kit.querySelector('tbody')
206
+ const tableRows = tableBody.getElementsByTagName('tr')
207
+ expect(tableRows).toHaveLength(13)
208
+ });
209
+
210
+ test("subRowHeaders are rendered", () => {
211
+ render(
212
+ <AdvancedTable
213
+ columnDefinitions={columnDefinitions}
214
+ data={{ testid: testId }}
215
+ tableData={MOCK_DATA}
216
+ >
217
+ <AdvancedTable.Header />
218
+ <AdvancedTable.Body subRowHeaders={subRowHeaders}/>
219
+ </AdvancedTable>
220
+ );
221
+
222
+ const kit = screen.getByTestId(testId);
223
+
224
+ const rowButton = kit.querySelector(".gray-icon.expand-toggle-icon")
225
+ rowButton.click()
226
+
227
+ const subRowHeader = kit.querySelector(".custom-row.bg-silver")
228
+ expect(subRowHeader).toBeInTheDocument()
229
+ });
230
+
231
+ test("expandControl prop works as expected", () => {
232
+ render (<AdvancedTableExpandControl/>)
233
+
234
+ const kit = screen.getByTestId(testId);
235
+ const subRow = kit.querySelector(".bg-white.depth-sub-row-1")
236
+ expect(subRow).toBeInTheDocument()
237
+ })
238
+
239
+ test("tableOptions prop functions as expected", () => {
240
+ render(
241
+ <AdvancedTable
242
+ columnDefinitions={columnDefinitions}
243
+ data={{ testid: testId }}
244
+ tableData={MOCK_DATA}
245
+ tableOptions={tableOptions}
246
+ />
247
+ );
248
+
249
+ const kit = screen.getByTestId(testId);
250
+ const row1 = kit.getElementsByTagName('tr')[1]
251
+
252
+ expect(row1.id).toBe("1-1-0-row")
253
+ });
254
+
255
+ test("tableProps prop functions as expected", () => {
256
+ render(
257
+ <AdvancedTable
258
+ columnDefinitions={columnDefinitions}
259
+ data={{ testid: testId }}
260
+ tableData={MOCK_DATA}
261
+ tableProps={tableProps}
262
+ />
263
+ );
264
+
265
+ const kit = screen.getByTestId(testId);
266
+ const table = kit.querySelector('table')
267
+ expect(table).toHaveClass("pb_table table-sm table-responsive-none data_table sticky-header ns_tabular")
56
268
  });
269
+
270
+ test("enableExpansionIcon changes icon", () => {
271
+ render(
272
+ <AdvancedTable
273
+ columnDefinitions={columnDefinitions}
274
+ data={{ testid: testId }}
275
+ tableData={MOCK_DATA}
276
+ tableProps={tableProps}
277
+ toggleExpansionIcon= "chevron-up"
278
+ />
279
+ );
280
+
281
+ const kit = screen.getByTestId(testId);
282
+ const tableHead = kit.querySelector('table')
283
+ const toggleIcon= tableHead.querySelector(".pb_icon_kit")
284
+ expect(toggleIcon).toHaveClass("fa-chevron-up")
285
+ });
286
+
287
+ test("sortIcon changes icon", () => {
288
+ render(
289
+ <AdvancedTable
290
+ columnDefinitions={columnDefinitions}
291
+ data={{ testid: testId }}
292
+ tableData={MOCK_DATA}
293
+ tableProps={tableProps}
294
+ >
295
+ <AdvancedTable.Header
296
+ enableSorting
297
+ sortIcon= {["chevron-up","chevron-down"]}
298
+ />
299
+ <AdvancedTable.Body />
300
+ </AdvancedTable>
301
+ );
302
+
303
+ const kit = screen.getByTestId(testId);
304
+ const sortIcon = kit.querySelector('.sort-button-icon')
305
+ const icon= sortIcon.querySelector(".pb_icon_kit")
306
+ expect(icon).toHaveClass("fa-chevron-down")
307
+ });
308
+
309
+ test("Sort icon renders with enableSorting + sortControl works as expected", () => {
310
+ render (<AdvancedTableSortControl/>)
311
+
312
+ const kit = screen.getByTestId(testId);
313
+ const sortIcon = kit.querySelector(".sort-button-icon")
314
+ expect(sortIcon).toBeInTheDocument()
315
+
316
+ const row1 = kit.getElementsByTagName('tr')[1]
317
+
318
+ expect(row1.id).toBe("1-1-0-row")
319
+ })
320
+
321
+ test("sort button exists and sorts column data", () => {
322
+ render(
323
+ <AdvancedTable
324
+ columnDefinitions={columnDefinitions}
325
+ data={{ testid: testId }}
326
+ tableData={MOCK_DATA}
327
+ >
328
+ <AdvancedTable.Header enableSorting />
329
+ <AdvancedTable.Body />
330
+ </AdvancedTable>
331
+ );
332
+
333
+ const kit = screen.getByTestId(testId);
334
+
335
+ const sortButton= kit.querySelector(".pb_flex_kit_orientation_row_justify_content_between_align_items_top_spacing_none.pl_xxs.cursor_pointer.header-sort-button.pb_th_link")
336
+ expect(sortButton).toBeInTheDocument()
337
+
338
+ const row1 = kit.getElementsByTagName('tr')[1]
339
+
340
+ expect(row1.id).toBe("0-0-0-row")
341
+ sortButton.click()
342
+
343
+ const row2 = kit.getElementsByTagName('tr')[2]
344
+ expect(row2.id).toBe("0-0-0-row")
345
+ });
@@ -0,0 +1,52 @@
1
+ import React from "react";
2
+ import { AdvancedTable } from "../../";
3
+ import { MOCK_DATA } from "./_mock_data";
4
+
5
+ const AdvancedTableCollapsibleTrail = (props) => {
6
+ const columnDefinitions = [
7
+ {
8
+ accessor: "year",
9
+ label: "Year",
10
+ cellAccessors: ["quarter", "month", "day"],
11
+ },
12
+ {
13
+ accessor: "newEnrollments",
14
+ label: "New Enrollments",
15
+ },
16
+ {
17
+ accessor: "scheduledMeetings",
18
+ label: "Scheduled Meetings",
19
+ },
20
+ {
21
+ accessor: "attendanceRate",
22
+ label: "Attendance Rate",
23
+ },
24
+ {
25
+ accessor: "completedClasses",
26
+ label: "Completed Classes",
27
+ },
28
+ {
29
+ accessor: "classCompletionRate",
30
+ label: "Class Completion Rate",
31
+ },
32
+ {
33
+ accessor: "graduatedStudents",
34
+ label: "Graduated Students",
35
+ },
36
+ ];
37
+
38
+ return (
39
+ <div>
40
+ <AdvancedTable
41
+ columnDefinitions={columnDefinitions}
42
+ tableData={MOCK_DATA}
43
+ {...props}
44
+ >
45
+ <AdvancedTable.Header />
46
+ <AdvancedTable.Body collapsibleTrail={false} />
47
+ </AdvancedTable>
48
+ </div>
49
+ );
50
+ };
51
+
52
+ export default AdvancedTableCollapsibleTrail;
@@ -0,0 +1 @@
1
+ `collapsibleTrail` is an optional prop that is set to 'true' by default. If set to 'false', it will remove the trail on the left of rows when subRows are toggled open.
@@ -1,7 +1,12 @@
1
- The AdvancedTable kit takes the table data and automatically renders expandable subrows for nested items to any depth needed. In it's simplest form, the kit has two required props:
1
+ The AdvancedTable kit accepts tree data and automatically renders expansion controls for nested subrows, to any depth, based on the data it is given. In it's simplest form, __the kit has two required props__:
2
2
 
3
- `tableData` is the data that the kit needs to consume to render the table. This data will take the structure of an array of objects where each object will be rendered as a row with the key/value pairs being the column values. If an object within that data has children, the kit will automatically create subRows with icon buttons on the parent rows to toggle the subRows open or closed. The toggleExpansionAll button in the first column header can also be used to toggle expansion for the top level parent rows. For a visual of the data structure needed for `tableData`, see [here](https://github.com/powerhome/playbook/blob/PBNTR-177-New-Advanced-Table-Kit/playbook/app/pb_kits/playbook/pb_advanced_table/README.md).
3
+ ### tableData
4
4
 
5
+ `tableData` accepts an array of objects as the table data. Each object is a table row, and each key:value pair within an object is a column value within that row. Nested children within a data object are automatically rendered as subrows under their parent row. Each parent row is prepended with expansion controls for toggling its nested child rows. The `toggleExpansionAll` button in the first column header can also be used to toggle expansion of all parent rows within the table.
6
+
7
+ For a visual of the data structure needed for `tableData`, see [here](https://github.com/powerhome/playbook/tree/master/playbook/app/pb_kits/playbook/pb_advanced_table#readme).
8
+
9
+ ### columnDefinitions
5
10
 
6
11
  `columnDefinitions` maps to the columns prop on the Tanstack table. Column definitions are the single most important part of building a table as they are responsible for building the underlying data model that is used for all sorting, expansion, etc. `ColumnDefinitions` in the AdvancedTable kit is a array of objects as seen in the code snippet below. Each object within the array has two REQUIRED items:
7
12
 
@@ -0,0 +1,59 @@
1
+ import React, { useState } from "react";
2
+ import { AdvancedTable } from "../../";
3
+ import { MOCK_DATA } from "./_mock_data";
4
+
5
+ const AdvancedTableExpandedControl = (props) => {
6
+ const columnDefinitions = [
7
+ {
8
+ accessor: "year",
9
+ label: "Year",
10
+ cellAccessors: ["quarter", "month", "day"],
11
+ },
12
+ {
13
+ accessor: "newEnrollments",
14
+ label: "New Enrollments",
15
+ },
16
+ {
17
+ accessor: "scheduledMeetings",
18
+ label: "Scheduled Meetings",
19
+ },
20
+ {
21
+ accessor: "attendanceRate",
22
+ label: "Attendance Rate",
23
+ },
24
+ {
25
+ accessor: "completedClasses",
26
+ label: "Completed Classes",
27
+ },
28
+ {
29
+ accessor: "classCompletionRate",
30
+ label: "Class Completion Rate",
31
+ },
32
+ {
33
+ accessor: "graduatedStudents",
34
+ label: "Graduated Students",
35
+ },
36
+ ];
37
+
38
+ //State for manually effecting what is expanded
39
+ const [expanded, setExpanded] = useState({'0': true, '0.0': true, '0.0.1': true})
40
+
41
+ //Passing expanded state to AdvancedTable as prop
42
+ const expandedControl = {
43
+ value: expanded,
44
+ onChange: setExpanded,
45
+ }
46
+
47
+ return (
48
+ <div>
49
+ <AdvancedTable
50
+ columnDefinitions={columnDefinitions}
51
+ expandedControl={expandedControl}
52
+ tableData={MOCK_DATA}
53
+ {...props}
54
+ />
55
+ </div>
56
+ );
57
+ };
58
+
59
+ export default AdvancedTableExpandedControl;
@@ -0,0 +1,18 @@
1
+ `expandedControl` is an optional prop that can be used to gain greater control over the expansion state of the Advanced Table. Tanstack handles expansion itself, however it does provide for a way to handle the state manually if needed. Usecases for this include needing to store the expansion state so it persists on page reload, set an initial expansion state, etc.
2
+
3
+ In this example we are showing that if initial expansion state is set, it will render the table expanded according to that state.
4
+
5
+ The expanded state must be an object with key/value pairs where the key is the row id and the value is a boolean, true or false. Tanstack by default assigns row ids based on index and depth of the row as can be seen in this example. For more information on row ids, see [here](https://tanstack.com/table/v8/docs/api/core/row#id).
6
+
7
+ ### Single Row Expansion
8
+
9
+ By default, the click event on the row level toggleExpansion icon simply toggles the immediate sub rows open or closed. If you want to attach further logic to that button, the optional `onRowToggleClick` prop can be used. This click event provides one argument that can be hooked into: the current `row` object. Any additional functionality provided through this onClick will be applied in addition to the default.
10
+
11
+ ### Multi-Row Expansion
12
+
13
+ Similar to the row level click event, the default of the click event on the toggleExpansion buttons that render in the first column header (and the subRow Header rows if prop enabled) toggles all top level rows open and closed. If you want to attach further logic to that button, the optional `onToggleExpansionClick` prop can be used. This click event provides one argument that can be hooked into: the current `row` object. Any additional functionality provided through this onClick will be applied in addition to the default.
14
+
15
+ ### ToggleExpansionIcon
16
+
17
+ `ToggleExpansionIcon` is another optional prop that can be used to customize the icon for the toggleExpansion button. This prop takes a string value with the default set to `arrows-from-line`. All strings must be valid FA icons.
18
+
@@ -0,0 +1,60 @@
1
+ import React, { useState } from "react";
2
+ import { AdvancedTable } from "../../";
3
+ import { Button } from "../../"
4
+ import { MOCK_DATA } from "./_mock_data";
5
+
6
+ const AdvancedTableLoading = (props) => {
7
+
8
+ const [isloading, setIsLoading] = useState(true)
9
+
10
+ const columnDefinitions = [
11
+ {
12
+ accessor: "year",
13
+ label: "Year",
14
+ cellAccessors: ["quarter", "month", "day"],
15
+ },
16
+ {
17
+ accessor: "newEnrollments",
18
+ label: "New Enrollments",
19
+ },
20
+ {
21
+ accessor: "scheduledMeetings",
22
+ label: "Scheduled Meetings",
23
+ },
24
+ {
25
+ accessor: "attendanceRate",
26
+ label: "Attendance Rate",
27
+ },
28
+ {
29
+ accessor: "completedClasses",
30
+ label: "Completed Classes",
31
+ },
32
+ {
33
+ accessor: "classCompletionRate",
34
+ label: "Class Completion Rate",
35
+ },
36
+ {
37
+ accessor: "graduatedStudents",
38
+ label: "Graduated Students",
39
+ },
40
+ ];
41
+
42
+ return (
43
+ <div>
44
+ <Button marginBottom="md"
45
+ onClick={()=> setIsLoading(!isloading)}
46
+ text="Toggle Loading State"
47
+ variant="secondary"
48
+ {...props}
49
+ />
50
+ <AdvancedTable
51
+ columnDefinitions={columnDefinitions}
52
+ loading={isloading}
53
+ tableData={MOCK_DATA}
54
+ {...props}
55
+ />
56
+ </div>
57
+ );
58
+ };
59
+
60
+ export default AdvancedTableLoading;
@@ -0,0 +1,3 @@
1
+ the optional `loading` prop takes a boolean value that can be managed using state. If loading is true, the table will display the loading skeleton and once loading is false, the table will render with the data provided.
2
+
3
+ By default, the inital row count of the loading skeleton is set to 10. If you want more control over this initial row count, the optional `initialLoadingRowCount` prop can be used to to pass in a number. __NOTE__: This is only for the first render of the table, subsequent loading skeleton row count logic is handled within the kit itself.
@@ -35,20 +35,15 @@ const AdvancedTableSort = (props) => {
35
35
  },
36
36
  ];
37
37
 
38
- //Render the subRow header rows
39
- const subRowHeaders = ["Quarter", "Month", "Day"]
40
-
41
-
42
38
  return (
43
39
  <div>
44
40
  <AdvancedTable
45
41
  columnDefinitions={columnDefinitions}
46
- enableToggleExpansion="all"
47
42
  tableData={MOCK_DATA}
48
43
  {...props}
49
44
  >
50
45
  <AdvancedTable.Header enableSorting />
51
- <AdvancedTable.Body subRowHeaders={subRowHeaders} />
46
+ <AdvancedTable.Body />
52
47
  </AdvancedTable>
53
48
  </div>
54
49
  );
@@ -0,0 +1,5 @@
1
+ the `enableSorting` prop is a boolean prop set to false by default. If true, the table will add sort logic linked to the sort button in the header. Clicking the sort button will toggle sort between ascending and descending. Currently this sort functionality is only available on the first column.
2
+
3
+ ### sortIcon
4
+
5
+ An optional prop, `sortIcon` allows you to customize your icon sets by passing it an array of any comma-separated pair of icon values. The first icon value will replace the kit's default icon when sort direction is desc, and the second value will replace the default icon when sort direction is asc. `sortIcon` also allows you to pass it a single icon as a string, in which case the icon will not toggle with the sort state. Default for this prop is `["arrow-up-short-wide", "arrow-down-short-wide"]`. All strings must be valid FA icons.
@@ -0,0 +1,63 @@
1
+ import React, { useState } from "react";
2
+ import { AdvancedTable } from "../..";
3
+ import { MOCK_DATA } from "./_mock_data";
4
+
5
+ const AdvancedTableSortControl = (props) => {
6
+ const columnDefinitions = [
7
+ {
8
+ accessor: "year",
9
+ label: "Year",
10
+ cellAccessors: ["quarter", "month", "day"],
11
+ },
12
+ {
13
+ accessor: "newEnrollments",
14
+ label: "New Enrollments",
15
+ },
16
+ {
17
+ accessor: "scheduledMeetings",
18
+ label: "Scheduled Meetings",
19
+ },
20
+ {
21
+ accessor: "attendanceRate",
22
+ label: "Attendance Rate",
23
+ },
24
+ {
25
+ accessor: "completedClasses",
26
+ label: "Completed Classes",
27
+ },
28
+ {
29
+ accessor: "classCompletionRate",
30
+ label: "Class Completion Rate",
31
+ },
32
+ {
33
+ accessor: "graduatedStudents",
34
+ label: "Graduated Students",
35
+ },
36
+ ];
37
+
38
+ //State for sort direction
39
+ const [isSortDesc, setIsSortDesc] = useState({desc: false})
40
+
41
+ // //Passing sort state to AdvancedTable as prop
42
+ const sortControl = {
43
+ value: isSortDesc,
44
+ onChange: setIsSortDesc,
45
+ }
46
+
47
+
48
+ return (
49
+ <div>
50
+ <AdvancedTable
51
+ columnDefinitions={columnDefinitions}
52
+ sortControl={sortControl}
53
+ tableData={MOCK_DATA}
54
+ {...props}
55
+ >
56
+ <AdvancedTable.Header enableSorting />
57
+ <AdvancedTable.Body />
58
+ </AdvancedTable>
59
+ </div>
60
+ );
61
+ };
62
+
63
+ export default AdvancedTableSortControl;
@@ -0,0 +1,3 @@
1
+ `sortControl` is an optional prop that can be used to gain greater control over the sort state of the Advanced Table. Tanstack handles sort itself, however it does provide for a way to handle the state manually if needed. Usecases for this include needing to store the sort state so it persists on page reload, set an initial sort state, etc.
2
+
3
+ The sort state must be an object with a single key/value pair, with the key being "desc" and the value being a boolean. The default for sort directino is `desc: true`.