playbook_ui 14.8.0 → 14.9.0.pre.alpha.PBNTR702stickyleftcolrails4806

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +2 -0
  3. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +61 -17
  4. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta.html.erb +1 -1
  5. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb +1 -1
  6. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_custom_cell_rails.html.erb +53 -0
  7. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_custom_cell_rails.md +5 -0
  8. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination.jsx +50 -0
  9. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination.md +1 -0
  10. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination_with_props.jsx +57 -0
  11. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination_with_props.md +5 -0
  12. data/app/pb_kits/playbook/pb_advanced_table/docs/advanced_table_pagination_mock_data.json +5600 -0
  13. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +3 -0
  14. data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +2 -0
  15. data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +3 -1
  16. data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +15 -0
  17. data/app/pb_kits/playbook/pb_background/_background.tsx +8 -2
  18. data/app/pb_kits/playbook/pb_button/_button.scss +6 -0
  19. data/app/pb_kits/playbook/pb_button/_button.tsx +1 -3
  20. data/app/pb_kits/playbook/pb_button/_button_mixins.scss +15 -0
  21. data/app/pb_kits/playbook/pb_button/button.rb +1 -1
  22. data/app/pb_kits/playbook/pb_button/docs/_button_default.html.erb +1 -0
  23. data/app/pb_kits/playbook/pb_button/docs/_button_default.jsx +8 -0
  24. data/app/pb_kits/playbook/pb_button/docs/_button_default.md +1 -1
  25. data/app/pb_kits/playbook/pb_checkbox/checkbox.html.erb +2 -2
  26. data/app/pb_kits/playbook/pb_checkbox/checkbox.rb +0 -4
  27. data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_indeterminate.html.erb +84 -7
  28. data/app/pb_kits/playbook/pb_collapsible/_collapsible.tsx +3 -1
  29. data/app/pb_kits/playbook/pb_currency/_currency.tsx +7 -3
  30. data/app/pb_kits/playbook/pb_currency/currency.html.erb +2 -2
  31. data/app/pb_kits/playbook/pb_currency/currency.rb +17 -1
  32. data/app/pb_kits/playbook/pb_currency/currency.test.js +40 -3
  33. data/app/pb_kits/playbook/pb_currency/docs/_currency_negative.html.erb +4 -0
  34. data/app/pb_kits/playbook/pb_currency/docs/_currency_negative.jsx +16 -0
  35. data/app/pb_kits/playbook/pb_currency/docs/example.yml +2 -0
  36. data/app/pb_kits/playbook/pb_currency/docs/index.js +1 -0
  37. data/app/pb_kits/playbook/pb_drawer/_drawer.scss +1 -0
  38. data/app/pb_kits/playbook/pb_drawer/_drawer.tsx +159 -45
  39. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_menu.jsx +31 -0
  40. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_menu.md +6 -0
  41. data/app/pb_kits/playbook/pb_drawer/docs/example.yml +1 -1
  42. data/app/pb_kits/playbook/pb_drawer/docs/index.js +1 -0
  43. data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +1 -0
  44. data/app/pb_kits/playbook/pb_dropdown/dropdown_container.html.erb +0 -1
  45. data/app/pb_kits/playbook/pb_dropdown/dropdown_container.rb +0 -4
  46. data/app/pb_kits/playbook/pb_dropdown/utilities/subComponentHelper.tsx +13 -2
  47. data/app/pb_kits/playbook/pb_form/docs/_form_form_with.html.erb +2 -2
  48. data/app/pb_kits/playbook/pb_form/docs/_form_form_with_loading.html.erb +1 -1
  49. data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +63 -12
  50. data/app/pb_kits/playbook/pb_image/_image.tsx +3 -1
  51. data/app/pb_kits/playbook/pb_layout/_layout.tsx +6 -3
  52. data/app/pb_kits/playbook/pb_overlay/_overlay.tsx +3 -1
  53. data/app/pb_kits/playbook/pb_pagination/_pagination.tsx +2 -2
  54. data/app/pb_kits/playbook/pb_progress_simple/_progress_simple.tsx +5 -3
  55. data/app/pb_kits/playbook/pb_progress_simple/progress_simple.html.erb +3 -2
  56. data/app/pb_kits/playbook/pb_progress_simple/progress_simple.rb +5 -0
  57. data/app/pb_kits/playbook/pb_section_separator/_section_separator.tsx +3 -1
  58. data/app/pb_kits/playbook/pb_selectable_card/docs/_selectable_card_default.html.erb +2 -1
  59. data/app/pb_kits/playbook/pb_table/_table.tsx +109 -25
  60. data/app/pb_kits/playbook/pb_table/docs/_table_sticky_left_columns.html.erb +95 -0
  61. data/app/pb_kits/playbook/pb_table/docs/_table_sticky_left_columns.jsx +87 -0
  62. data/app/pb_kits/playbook/pb_table/docs/_table_sticky_left_columns_react.md +2 -0
  63. data/app/pb_kits/playbook/pb_table/docs/index.js +1 -0
  64. data/app/pb_kits/playbook/pb_table/index.ts +100 -26
  65. data/app/pb_kits/playbook/pb_table/styles/_all.scss +2 -0
  66. data/app/pb_kits/playbook/pb_table/styles/_scroll.scss +4 -0
  67. data/app/pb_kits/playbook/pb_table/styles/_sticky_columns.scss +18 -0
  68. data/app/pb_kits/playbook/pb_table/table.html.erb +1 -1
  69. data/app/pb_kits/playbook/pb_table/table.rb +17 -2
  70. data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_children.html.erb +47 -0
  71. data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_children.jsx +59 -0
  72. data/app/pb_kits/playbook/pb_typeahead/_typeahead.scss +3 -0
  73. data/app/pb_kits/playbook/pb_typeahead/index.ts +29 -3
  74. data/app/pb_kits/playbook/pb_typeahead/typeahead.html.erb +5 -2
  75. data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +4 -0
  76. data/app/pb_kits/playbook/tokens/_height.scss +19 -0
  77. data/app/pb_kits/playbook/tokens/exports/_height.module.scss +37 -0
  78. data/app/pb_kits/playbook/utilities/_height.scss +33 -0
  79. data/app/pb_kits/playbook/utilities/_max_width.scss +29 -9
  80. data/app/pb_kits/playbook/utilities/_min_width.scss +6 -2
  81. data/app/pb_kits/playbook/utilities/_width.scss +45 -0
  82. data/app/pb_kits/playbook/utilities/globalPropNames.mjs +1 -1
  83. data/app/pb_kits/playbook/utilities/globalProps.ts +37 -4
  84. data/dist/chunks/_typeahead-CCDoUmRR.js +22 -0
  85. data/dist/chunks/_weekday_stacked-CxjKLoMr.js +45 -0
  86. data/dist/chunks/{lib-BC6ESsxG.js → lib-CVPInSs5.js} +2 -2
  87. data/dist/chunks/{pb_form_validation-B_Z9rEbg.js → pb_form_validation-CDLJ5eAG.js} +1 -1
  88. data/dist/chunks/vendor.js +1 -1
  89. data/dist/menu.yml +321 -0
  90. data/dist/playbook-doc.js +1 -1
  91. data/dist/playbook-rails-react-bindings.js +1 -1
  92. data/dist/playbook-rails.js +1 -1
  93. data/dist/playbook.css +1 -1
  94. data/lib/playbook/classnames.rb +4 -0
  95. data/lib/playbook/forms/builder/typeahead_field.rb +13 -0
  96. data/lib/playbook/height.rb +29 -0
  97. data/lib/playbook/kit_base.rb +16 -1
  98. data/lib/playbook/max_height.rb +29 -0
  99. data/lib/playbook/min_height.rb +29 -0
  100. data/lib/playbook/spacing.rb +21 -0
  101. data/lib/playbook/version.rb +2 -2
  102. metadata +32 -9
  103. data/dist/chunks/_typeahead-D0PihN_3.js +0 -22
  104. data/dist/chunks/_weekday_stacked-uMIX8f-A.js +0 -45
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 50483e323e3657c9c17cc6f65c4811eae2cd141bc6cc849182f12aa0c74144a8
4
- data.tar.gz: d32e240aa31216a9c0796fb0eda79acd8eb1c4fb1051f2306c8bfcc0a03357cd
3
+ metadata.gz: d89f4517dd122bc15bf46cece276b7623372b18e9c168bda22529f464e335b52
4
+ data.tar.gz: f4627b91aeb56d610c20341ffdf10f0d4d56df24889ce87e56c01f1878b3959a
5
5
  SHA512:
6
- metadata.gz: 5803de1020b0ff14843cd739fbe2ccb4aedfe9850e62e471d866e5389088c789146874bdd1d032fd5fac35d5ad1ba2848e31625f0ff870e8927fd8f67fc4fdf6
7
- data.tar.gz: 6663f9998ecf121561e0daf46412e5595589318aa2cca77da9ee46276d39b0d670488424d9f3c2303121ce57e1f1a11404a418b3579945c3171874c6af6207fd
6
+ metadata.gz: 00b7e5e785ad232a9e119eb3ad5911b540354cf83b50c69a25e16f928fee3f87819ae9b433be0a5d9ac6027d5e7a1e048dc1b0cd2db0362bf28b59e4e756fe30
7
+ data.tar.gz: 23c75179a18b0f6eb118e581e056deb65fd85c3d78f4316ba57d939f3a92452d62d3770a98c40a2b16efcaf52f49eb55647c443f672c1c9caf1c056184ce205e
@@ -111,6 +111,7 @@
111
111
  @import 'utilities/mixins';
112
112
  @import 'utilities/spacing';
113
113
  @import 'utilities/cursor';
114
+ @import 'utilities/width';
114
115
  @import 'utilities/min_width';
115
116
  @import 'utilities/max_width';
116
117
  @import 'utilities/positioning';
@@ -126,3 +127,4 @@
126
127
  @import 'utilities/overflow';
127
128
  @import 'utilities/truncate';
128
129
  @import 'utilities/vertical_align';
130
+ @import 'utilities/height';
@@ -7,6 +7,7 @@ import {
7
7
  createColumnHelper,
8
8
  getCoreRowModel,
9
9
  getExpandedRowModel,
10
+ getPaginationRowModel,
10
11
  getSortedRowModel,
11
12
  Row,
12
13
  useReactTable,
@@ -25,6 +26,7 @@ import { updateExpandAndCollapseState } from "./Utilities/ExpansionControlHelper
25
26
  import { CustomCell } from "./Components/CustomCell"
26
27
  import { TableHeader } from "./SubKits/TableHeader"
27
28
  import { TableBody } from "./SubKits/TableBody"
29
+ import Pagination from "../pb_pagination/_pagination"
28
30
 
29
31
  type AdvancedTableProps = {
30
32
  aria?: { [key: string]: string }
@@ -42,6 +44,8 @@ type AdvancedTableProps = {
42
44
  loading?: boolean | string
43
45
  onRowToggleClick?: (arg: Row<GenericObject>) => void
44
46
  onToggleExpansionClick?: (arg: Row<GenericObject>) => void
47
+ pagination?: boolean,
48
+ paginationProps?: GenericObject
45
49
  responsive?: "scroll" | "none",
46
50
  sortControl?: GenericObject
47
51
  tableData: GenericObject[]
@@ -67,6 +71,8 @@ const AdvancedTable = (props: AdvancedTableProps) => {
67
71
  loading,
68
72
  onRowToggleClick,
69
73
  onToggleExpansionClick,
74
+ pagination = false,
75
+ paginationProps,
70
76
  responsive = "scroll",
71
77
  sortControl,
72
78
  tableData,
@@ -177,6 +183,17 @@ const AdvancedTable = (props: AdvancedTableProps) => {
177
183
  }
178
184
  }
179
185
 
186
+ const paginationInitializer = pagination ? {
187
+ getPaginationRowModel: getPaginationRowModel(),
188
+ paginateExpandedRows: false,
189
+ initialState: {
190
+ pagination: {
191
+ pageIndex: paginationProps?.pageIndex ?? 0,
192
+ pageSize: paginationProps?.pageSize ?? 20,
193
+ },
194
+ },
195
+ } : {}
196
+
180
197
  //initialize table
181
198
  const table = useReactTable({
182
199
  data: loading ? Array(loadingStateRowCount).fill({}) : tableData,
@@ -189,6 +206,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
189
206
  enableSortingRemoval: false,
190
207
  sortDescFirst: true,
191
208
  ...expandAndSortState(),
209
+ ... paginationInitializer,
192
210
  ...tableOptions,
193
211
  })
194
212
 
@@ -227,6 +245,10 @@ const AdvancedTable = (props: AdvancedTableProps) => {
227
245
  className
228
246
  )
229
247
 
248
+ const onPageChange = (page: number) => {
249
+ table.setPageIndex(page - 1)
250
+ }
251
+
230
252
  return (
231
253
  <div {...ariaProps}
232
254
  {...dataProps}
@@ -250,23 +272,45 @@ const AdvancedTable = (props: AdvancedTableProps) => {
250
272
  toggleExpansionIcon,
251
273
  }}
252
274
  >
253
- <Table
254
- className={`${loading ? "content-loading" : ""}`}
255
- dark={dark}
256
- dataTable
257
- numberSpacing="tabular"
258
- responsive="none"
259
- {...tableProps}
260
- >
261
- {children ? (
262
- children
263
- ) : (
264
- <>
265
- <TableHeader />
266
- <TableBody />
267
- </>
268
- )}
269
- </Table>
275
+ <>
276
+ {pagination &&
277
+ <Pagination
278
+ current={table.getState().pagination.pageIndex + 1}
279
+ key={`pagination-top-${table.getState().pagination.pageIndex + 1}`}
280
+ marginBottom="xs"
281
+ onChange={onPageChange}
282
+ range={paginationProps?.range ? paginationProps?.range : 5}
283
+ total={table.getPageCount()}
284
+ />
285
+ }
286
+ <Table
287
+ className={`${loading ? "content-loading" : ""}`}
288
+ dark={dark}
289
+ dataTable
290
+ numberSpacing="tabular"
291
+ responsive="none"
292
+ {...tableProps}
293
+ >
294
+ {children ? (
295
+ children
296
+ ) : (
297
+ <>
298
+ <TableHeader />
299
+ <TableBody />
300
+ </>
301
+ )}
302
+ </Table>
303
+ {pagination &&
304
+ <Pagination
305
+ current={table.getState().pagination.pageIndex + 1}
306
+ key={`pagination-bottom-${table.getState().pagination.pageIndex + 1}`}
307
+ marginTop="xs"
308
+ onChange={onPageChange}
309
+ range={paginationProps?.range ? paginationProps?.range : 5}
310
+ total={table.getPageCount()}
311
+ />
312
+ }
313
+ </>
270
314
  </AdvancedTableContext.Provider>
271
315
  </div>
272
316
  )
@@ -30,4 +30,4 @@
30
30
  }
31
31
  ] %>
32
32
 
33
- <%= pb_rails("advanced_table", props: {table_data: @table_data, column_definitions: column_definitions}) %>
33
+ <%= pb_rails("advanced_table", props: { id: "beta_table", table_data: @table_data, column_definitions: column_definitions }) %>
@@ -55,5 +55,5 @@
55
55
 
56
56
  <%= pb_rails("advanced_table", props: { table_data: @table_data, column_definitions: column_definitions }) do %>
57
57
  <%= pb_rails("advanced_table/table_header", props: { column_definitions: column_definitions }) %>
58
- <%= pb_rails("advanced_table/table_body", props: { id: "subrow_headers", table_data: @table_data, column_definitions: column_definitions, subrow_headers: subrow_headers, enable_toggle_expansion: "all" }) %>
58
+ <%= pb_rails("advanced_table/table_body", props: { id: "beta_sort", table_data: @table_data, column_definitions: column_definitions, subrow_headers: subrow_headers, enable_toggle_expansion: "all" }) %>
59
59
  <% end %>
@@ -0,0 +1,53 @@
1
+ <%
2
+ column_definitions = [
3
+ {
4
+ accessor: "year",
5
+ label: "Year",
6
+ cellAccessors: ["quarter", "month", "day"],
7
+ custom_renderer: ->(row, value) {
8
+ capture do
9
+ pb_rails("flex") do
10
+ pb_rails("title", props: { text: value, size: 4 }) +
11
+ pb_rails("badge", props: { dark: true, margin_left: "xxs", text: row[:newEnrollments].to_i > 20 ? "High" : "Low", variant: "neutral" })
12
+ end
13
+ end
14
+ }
15
+ },
16
+ {
17
+ accessor: "newEnrollments",
18
+ label: "New Enrollments",
19
+ custom_renderer: ->(row, value) { pb_rails("pill", props: { text: value, variant: "success" }) }
20
+ },
21
+ {
22
+ accessor: "scheduledMeetings",
23
+ label: "Scheduled Meetings",
24
+ custom_renderer: ->(row, value) { content_tag(:a, value, href: "#") }
25
+ },
26
+ {
27
+ accessor: "attendanceRate",
28
+ label: "Attendance Rate",
29
+ custom_renderer: ->(row, value) {
30
+ capture do
31
+ pb_rails("flex", props: { align_items: "end", orientation: "column" }) do
32
+ pb_rails("detail", props: { bold: true, color: "default", text: value }) +
33
+ pb_rails("caption", props: { size: "xs", text: row[:graduatedStudents] })
34
+ end
35
+ end
36
+ }
37
+ },
38
+ {
39
+ accessor: "completedClasses",
40
+ label: "Completed Classes",
41
+ },
42
+ {
43
+ accessor: "classCompletionRate",
44
+ label: "Class Completion Rate",
45
+ },
46
+ {
47
+ accessor: "graduatedStudents",
48
+ label: "Graduated Students",
49
+ }
50
+ ]
51
+ %>
52
+
53
+ <%= pb_rails("advanced_table", props: { id: "custom_cell", table_data: @table_data, column_definitions: column_definitions }) %>
@@ -0,0 +1,5 @@
1
+ The Advanced Table also allows for rendering custom components within individual Cells. To achieve this, you can make use of the optional `custom_renderer` item within each column_definitions. This function gives you access to the current Cell's value if you just want to use that with a custom Kit, but it also gives you access to the entire `row` object. The row object provides all data for the current row.
2
+
3
+ See [here](https://playbook.powerapp.cloud/kits/advanced_table/rails#column_definitions) for more indepth information on column_definitions are how to use them.
4
+
5
+ See [here](https://github.com/powerhome/playbook/tree/master/playbook/app/pb_kits/playbook/pb_advanced_table#readme) for the structure of the table_data used.
@@ -0,0 +1,50 @@
1
+ import React from "react"
2
+ import { AdvancedTable } from "playbook-ui"
3
+ import PAGINATION_MOCK_DATA from "./advanced_table_pagination_mock_data.json"
4
+
5
+ const AdvancedTablePagination = (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
+ <>
40
+ <AdvancedTable
41
+ columnDefinitions={columnDefinitions}
42
+ pagination
43
+ tableData={PAGINATION_MOCK_DATA}
44
+ {...props}
45
+ />
46
+ </>
47
+ )
48
+ }
49
+
50
+ export default AdvancedTablePagination
@@ -0,0 +1 @@
1
+ `pagination` is an optional prop that can be used to add pagination to the AdvancedTable. If present, it will add pagination with default values for pageSize, etc. To customize pagination, you can also use `paginationProps` shown in the next example.
@@ -0,0 +1,57 @@
1
+ import React from "react"
2
+ import { AdvancedTable } from "playbook-ui"
3
+ import PAGINATION_MOCK_DATA from "./advanced_table_pagination_mock_data.json"
4
+
5
+ const AdvancedTablePaginationWithProps = (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
+ const paginationProps = {
39
+ pageIndex: 1,
40
+ pageSize: 10,
41
+ range: 2
42
+ }
43
+
44
+ return (
45
+ <>
46
+ <AdvancedTable
47
+ columnDefinitions={columnDefinitions}
48
+ pagination
49
+ paginationProps={paginationProps}
50
+ tableData={PAGINATION_MOCK_DATA}
51
+ {...props}
52
+ />
53
+ </>
54
+ )
55
+ }
56
+
57
+ export default AdvancedTablePaginationWithProps
@@ -0,0 +1,5 @@
1
+ `paginationProps` is an optional prop that can be used to further customize pagination for the AdvancedTable. This prop is an object with 2 optional items:
2
+
3
+ - `pageIndex`: An optional prop to set which page is set to open on initial load. Default is '0'
4
+ - `pageSize`: An optional prop to set total number of rows for each page before the Table paginates. Default is '20'
5
+ - `range`: The range prop determines how many pages to display in the Pagination component. Regardless of this value, the first two and last two pages are always visible to facilitate navigation to the beginning and end of the pagination. If these always-visible pages fall within the specified range, they are included in the display. If they fall outside the range, the pagination will show additional pages up to the number defined by the range prop. See [here for more details](https://playbook.powerapp.cloud/kits/pagination/react#default). Default is set to '5'