playbook_ui 14.10.0.pre.alpha.PBNTR775formmatingmaskdefaultvalue5137 → 14.10.0.pre.alpha.play1662cssbargraph5193

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +32 -19
  3. data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableBody.tsx +3 -1
  4. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +37 -0
  5. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +32 -18
  6. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers.jsx +60 -0
  7. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers.md +1 -0
  8. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers_multiple.jsx +74 -0
  9. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers_multiple.md +1 -0
  10. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +2 -0
  11. data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +2 -0
  12. data/app/pb_kits/playbook/pb_circle_icon_button/_circle_icon_button.tsx +3 -0
  13. data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.html.erb +1 -1
  14. data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.rb +1 -0
  15. data/app/pb_kits/playbook/pb_circle_icon_button/docs/_circle_icon_button_link.html.erb +8 -0
  16. data/app/pb_kits/playbook/pb_circle_icon_button/docs/_circle_icon_button_link.jsx +9 -0
  17. data/app/pb_kits/playbook/pb_circle_icon_button/docs/_circle_icon_button_link.md +1 -0
  18. data/app/pb_kits/playbook/pb_dashboard/BarGraphStyles.scss +53 -0
  19. data/dist/chunks/{_typeahead-CoIYBETL.js → _typeahead-BXXEtXbz.js} +1 -1
  20. data/dist/chunks/_weekday_stacked-D0yBvHBb.js +45 -0
  21. data/dist/chunks/vendor.js +1 -1
  22. data/dist/playbook-doc.js +1 -1
  23. data/dist/playbook-rails-react-bindings.js +1 -1
  24. data/dist/playbook-rails.js +1 -1
  25. data/dist/playbook.css +1 -1
  26. data/lib/playbook/version.rb +1 -1
  27. metadata +10 -4
  28. data/dist/chunks/_weekday_stacked-Qj3GFYzA.js +0 -45
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4f8792edbc1bba55bdb026a17142b4ec1eda307af7043e0ab9900ea3e92a78bf
4
- data.tar.gz: 574614453f812f73b094fa52f2ce793b73f880630c94cd813e7c63f2ce5ad891
3
+ metadata.gz: f2e1aaf2cadccd158fb55ca05342e3dfefd6e2614dc37d220086b342e5df4340
4
+ data.tar.gz: fc03a93a9cc11765508190229426d34d507306ebf46aff0efe5ec23bb65ddb32
5
5
  SHA512:
6
- metadata.gz: dfef0aea6e35c15c7876b205c5103191b233bad3346654f2b1312557d3d79420e56939752fbb4b09d627ecd2b0b6d0c19bac23b5325f6a14a03c742120245cd8
7
- data.tar.gz: c33eb3ac3b988bfbbfd02d8088cd91dcdbe81f92457c94739910653202337a355ff15a79b8c27244ebbbe507e44563039fde131eb3dfc62034548ccdc75dda5b
6
+ metadata.gz: 88632df2e8dd9a501cd6d97a0bc60213d11a1a4f3e3b063c9318a83267177403c02adb69e60c69344c07c91e7a1915f8a3954069c8682839d8787879b3208219
7
+ data.tar.gz: 03f3eec3ebd3da933b162a985c72fde36109c4f2e01ad4d732f73cf27a1eae8fb633823af6859f659470d0dca062b8f1dba1777e172a05be30af19b19cc063a4
@@ -40,46 +40,59 @@ export const TableHeaderCell = ({
40
40
 
41
41
  const toggleSortButton = (event: React.SyntheticEvent) => {
42
42
  if (sortControl) {
43
- const sortIsDesc = header.column.getIsSorted() === "desc"
43
+ const sortIsDesc = header?.column.getIsSorted() === "desc"
44
44
  sortIsDesc
45
45
  ? sortControl.onChange({ desc: true })
46
46
  : sortControl.onChange({ desc: false })
47
47
  } else {
48
- header.column.getToggleSortingHandler()(event)
48
+ header?.column.getToggleSortingHandler()(event)
49
49
  }
50
50
  }
51
51
 
52
- const cellClassName = classnames("table-header-cells",
53
- `${isChrome() ? "chrome-styles" : ""}`,
52
+ const isLeafColumn =
53
+ header?.column.getLeafColumns().length === 1 &&
54
+ header?.column.getLeafColumns()[0].id === header.column.id
55
+
56
+ const isLastHeaderCell =
57
+ header?.column.parent?.columns.at(-1) === header?.column ||
58
+ (header?.colSpan > 1 && header?.column.parent !== undefined);
59
+
60
+ const cellClassName = classnames(
61
+ "table-header-cells",
62
+ `${isChrome() ? "chrome-styles" : ""}`,
54
63
  `${enableSorting ? "table-header-cells-active" : ""}`,
55
- { 'pinned-left': responsive === "scroll" && isPinnedLeft },
56
- )
64
+ { "pinned-left": responsive === "scroll" && isPinnedLeft },
65
+ isLastHeaderCell ? "last-header-cell" : ""
66
+ );
57
67
 
58
68
  const cellId = `${loading ?
59
- `loading-${header.id}`
60
- : `${header.id}`
69
+ `loading-${header?.id}`
70
+ : `${header?.id}`
61
71
  }`
62
72
 
63
73
  const isToggleExpansionEnabledLoading =
64
- header.index === 0 &&
74
+ header?.index === 0 &&
65
75
  loading &&
66
76
  (enableToggleExpansion === "all" || "header") &&
67
77
  enableToggleExpansion !== "none"
68
78
 
69
79
  const isToggleExpansionEnabled =
70
- header.index === 0 &&
80
+ header?.index === 0 &&
71
81
  !loading &&
72
82
  (enableToggleExpansion === "all" || "header") &&
73
83
  enableToggleExpansion !== "none"
74
84
 
85
+ const justifyHeader = isLeafColumn ? "end" : "center"
86
+
75
87
  return (
76
88
  <th
77
89
  align="right"
78
90
  className={cellClassName}
91
+ colSpan={header?.colSpan}
79
92
  id={cellId}
80
- key={`${header.id}-header`}
93
+ key={`${header?.id}-header`}
81
94
  >
82
- {header.isPlaceholder ? null : headerChildren && header.index === 0 ? (
95
+ {header?.isPlaceholder ? null : headerChildren && header?.index === 0 ? (
83
96
  <Flex alignItems="center">
84
97
  {headerChildren}
85
98
  <div>
@@ -89,7 +102,7 @@ const isToggleExpansionEnabled =
89
102
  ) : (
90
103
  <Flex
91
104
  alignItems="center"
92
- justify={header.index === 0 && enableSorting ? "between" : header.index === 0 && !enableSorting ? "start" : "end"}
105
+ justify={header?.index === 0 && enableSorting ? "between" : header?.index === 0 && !enableSorting ? "start" : justifyHeader}
93
106
  >
94
107
  {isToggleExpansionEnabled && (
95
108
  <ToggleIconButton onClick={handleExpandOrCollapse} />
@@ -100,11 +113,11 @@ const isToggleExpansionEnabled =
100
113
  )}
101
114
 
102
115
  <Flex
103
- className={`${header.index === 0 &&
116
+ className={`${header?.index === 0 &&
104
117
  enableSorting &&
105
118
  "header-sort-button pb_th_link"}`}
106
- cursor={header.index === 0 && enableSorting ? "pointer" : "default"}
107
- {...(header.index === 0 &&
119
+ cursor={header?.index === 0 && enableSorting ? "pointer" : "default"}
120
+ {...(header?.index === 0 &&
108
121
  enableSorting && {
109
122
  htmlOptions: {
110
123
  onClick: (event: React.MouseEvent) => toggleSortButton(event),
@@ -116,14 +129,14 @@ const isToggleExpansionEnabled =
116
129
  tabIndex: 0,
117
130
  },
118
131
  })}
119
- justify={header.index === 0 && enableSorting ? "between" : "none"}
132
+ justify={header?.index === 0 && enableSorting ? "between" : "none"}
120
133
  paddingLeft={enableSorting ? "xxs" : "xs"}
121
134
  >
122
135
  <div>
123
- {flexRender(header.column.columnDef.header, header.getContext())}
136
+ {flexRender(header?.column.columnDef.header, header?.getContext())}
124
137
  </div>
125
138
 
126
- {header.index === 0 &&
139
+ {header?.index === 0 &&
127
140
  header.column.getCanSort() &&
128
141
  enableSorting &&
129
142
  (loading ? (
@@ -86,6 +86,7 @@ export const TableBody = ({
86
86
  >
87
87
  {row.getVisibleCells().map((cell, i) => {
88
88
  const isPinnedLeft = columnPinning.left.includes(cell.column.id)
89
+ const isLastCell = cell.column.parent?.columns.at(-1)?.id === cell.column.id
89
90
 
90
91
  return (
91
92
  <td
@@ -93,7 +94,8 @@ export const TableBody = ({
93
94
  className={classnames(
94
95
  `${cell.id}-cell position_relative`,
95
96
  isChrome() ? "chrome-styles" : "",
96
- isPinnedLeft && 'pinned-left'
97
+ isPinnedLeft && 'pinned-left',
98
+ isLastCell && 'last-cell',
97
99
  )}
98
100
  key={`${cell.id}-data`}
99
101
  >
@@ -31,6 +31,43 @@
31
31
  min-width: 180px;
32
32
  }
33
33
 
34
+ .pb_advanced_table_header {
35
+ > tr:not(:first-child) {
36
+ .last-header-cell {
37
+ border-right: 1px solid $border_light !important;
38
+ }
39
+
40
+ th {
41
+ border-radius: 0px !important;
42
+ border-width: 0 0 1px 0 !important;
43
+ }
44
+ th:first-child {
45
+ border-left-width: 1px !important;
46
+ @media only screen and (max-width: $screen-xl-min) {
47
+ border-left-width: 0 !important;
48
+ }
49
+ }
50
+ th:last-child {
51
+ border-right-width: 1px !important;
52
+ @media only screen and (max-width: $screen-xl-min) {
53
+ border-right-width: 0 !important;
54
+ }
55
+ }
56
+ }
57
+ th[colspan]:not([colspan="1"]) {
58
+ border-right: 1px solid $border_light;
59
+ }
60
+
61
+
62
+ }
63
+
64
+ .pb_advanced_table_body {
65
+ .last-cell {
66
+ border-right: 1px solid $border_light !important;
67
+ }
68
+ }
69
+
70
+
34
71
  .table-header-cells-active:first-child {
35
72
  color: $primary !important;
36
73
  }
@@ -142,27 +142,41 @@ const AdvancedTable = (props: AdvancedTableProps) => {
142
142
  }
143
143
  return columnCells
144
144
  }
145
- //Create column array in format needed by Tanstack
146
- const columns =
147
- columnDefinitions &&
145
+
146
+ const buildColumns = (columnDefinitions: GenericObject[]): any => {
147
+ return (
148
+ columnDefinitions &&
148
149
  columnDefinitions.map((column, index) => {
149
- // Define the base column structure
150
- const columnStructure = {
151
- ...columnHelper.accessor(column.accessor, {
152
- header: column.label,
153
- }),
154
- }
150
+ //Checking to see if grouped column or not
151
+ if (column.columns && column.columns.length > 0) {
152
+ return {
153
+ header: column.label || "",
154
+ columns: buildColumns(column.columns),
155
+ };
156
+ } else {
157
+ // Define the base column structure
158
+ const columnStructure = {
159
+ ...columnHelper.accessor(column.accessor, {
160
+ header: column.label || "",
161
+ }),
162
+ };
155
163
 
156
- if (column.cellAccessors || column.customRenderer) {
157
- columnStructure.cell = createCellFunction(
158
- column.cellAccessors,
159
- column.customRenderer,
160
- index
161
- )
162
- }
164
+ if (column.cellAccessors || column.customRenderer) {
165
+ columnStructure.cell = createCellFunction(
166
+ column.cellAccessors,
167
+ column.customRenderer,
168
+ index
169
+ );
170
+ }
171
+
172
+ return columnStructure;
173
+ }
174
+ })
175
+ );
176
+ };
163
177
 
164
- return columnStructure
165
- })
178
+ //Create column array in format needed by Tanstack
179
+ const columns = buildColumns(columnDefinitions);
166
180
 
167
181
  //Syntax for sorting Array if we want to manage state ourselves
168
182
  const sorting = [
@@ -0,0 +1,60 @@
1
+ import React from "react"
2
+ import { AdvancedTable } from "playbook-ui"
3
+ import MOCK_DATA from "./advanced_table_mock_data.json"
4
+
5
+ const AdvancedTableColumnHeaders = (props) => {
6
+ const columnDefinitions = [
7
+ {
8
+ accessor: "year",
9
+ label: "Year",
10
+ cellAccessors: ["quarter", "month", "day"],
11
+ },
12
+ {
13
+ label: "Enrollment Data",
14
+ columns: [
15
+ {
16
+ accessor: "newEnrollments",
17
+ label: "New Enrollments",
18
+ },
19
+ {
20
+ accessor: "scheduledMeetings",
21
+ label: "Scheduled Meetings",
22
+ },
23
+ ],
24
+ },
25
+ {
26
+ label: "Performance Data",
27
+ columns: [
28
+ {
29
+ accessor: "attendanceRate",
30
+ label: "Attendance Rate",
31
+ },
32
+ {
33
+ accessor: "completedClasses",
34
+ label: "Completed Classes",
35
+ },
36
+ {
37
+ accessor: "classCompletionRate",
38
+ label: "Class Completion Rate",
39
+ },
40
+ {
41
+ accessor: "graduatedStudents",
42
+ label: "Graduated Students",
43
+ },
44
+ ],
45
+ },
46
+ ];
47
+
48
+
49
+ return (
50
+ <>
51
+ <AdvancedTable
52
+ columnDefinitions={columnDefinitions}
53
+ tableData={MOCK_DATA}
54
+ {...props}
55
+ />
56
+ </>
57
+ )
58
+ }
59
+
60
+ export default AdvancedTableColumnHeaders
@@ -0,0 +1 @@
1
+ Use a nested `columns` array in your columnDefinitions to create multiple header rows. Any column with `columns` is treated as a grouped header, and its child columns are displayed beneath it.
@@ -0,0 +1,74 @@
1
+ import React from "react";
2
+ import { AdvancedTable } from "playbook-ui";
3
+ import MOCK_DATA from "./advanced_table_mock_data.json";
4
+
5
+ const AdvancedTableColumnHeadersMultiple = (props) => {
6
+ const columnDefinitions = [
7
+ {
8
+ accessor: "year",
9
+ label: "Year",
10
+ cellAccessors: ["quarter", "month", "day"],
11
+ },
12
+ {
13
+ label: "Enrollment Data",
14
+ columns: [
15
+ {
16
+ label: "Enrollment Stats",
17
+ columns: [
18
+ {
19
+ accessor: "newEnrollments",
20
+ label: "New Enrollments",
21
+ },
22
+ {
23
+ accessor: "scheduledMeetings",
24
+ label: "Scheduled Meetings",
25
+ },
26
+ ],
27
+ },
28
+ ],
29
+ },
30
+ {
31
+ label: "Performance Data",
32
+ columns: [
33
+ {
34
+ label: "Completion Metrics",
35
+ columns: [
36
+ {
37
+ accessor: "completedClasses",
38
+ label: "Completed Classes",
39
+ },
40
+ {
41
+ accessor: "classCompletionRate",
42
+ label: "Class Completion Rate",
43
+ },
44
+ ],
45
+ },
46
+ {
47
+ label: "Attendance",
48
+ columns: [
49
+ {
50
+ accessor: "attendanceRate",
51
+ label: "Attendance Rate",
52
+ },
53
+ {
54
+ accessor: "scheduledMeetings",
55
+ label: "Scheduled Meetings",
56
+ },
57
+ ],
58
+ },
59
+ ],
60
+ },
61
+ ];
62
+
63
+ return (
64
+ <>
65
+ <AdvancedTable
66
+ columnDefinitions={columnDefinitions}
67
+ tableData={MOCK_DATA}
68
+ {...props}
69
+ />
70
+ </>
71
+ );
72
+ };
73
+
74
+ export default AdvancedTableColumnHeadersMultiple;
@@ -0,0 +1 @@
1
+ Multiple levels of column headers can also be rendered as seen here.
@@ -21,3 +21,5 @@ examples:
21
21
  - advanced_table_custom_cell: Custom Components for Cells
22
22
  - advanced_table_pagination: Pagination
23
23
  - advanced_table_pagination_with_props: Pagination Props
24
+ - advanced_table_column_headers: Multi-Header Columns
25
+ - advanced_table_column_headers_multiple: Multi-Header Columns (Multiple Levels)
@@ -12,3 +12,5 @@ export { default as AdvancedTableResponsive } from './_advanced_table_responsive
12
12
  export { default as AdvancedTableCustomCell } from './_advanced_table_custom_cell.jsx'
13
13
  export { default as AdvancedTablePagination } from './_advanced_table_pagination.jsx'
14
14
  export { default as AdvancedTablePaginationWithProps } from './_advanced_table_pagination_with_props.jsx'
15
+ export { default as AdvancedTableColumnHeaders } from './_advanced_table_column_headers.jsx'
16
+ export { default as AdvancedTableColumnHeadersMultiple } from './_advanced_table_column_headers_multiple.jsx'
@@ -20,6 +20,7 @@ type CircleIconButtonProps = {
20
20
  onClick?: React.MouseEventHandler<HTMLElement>,
21
21
  newWindow?: boolean,
22
22
  type?: 'button' | 'submit' | 'reset' | undefined,
23
+ target?: string
23
24
  variant?: 'primary' | 'secondary' | 'link',
24
25
  }
25
26
 
@@ -36,6 +37,7 @@ const CircleIconButton = (props: CircleIconButtonProps): React.ReactElement => {
36
37
  loading = false,
37
38
  onClick = noop,
38
39
  type,
40
+ target,
39
41
  link,
40
42
  newWindow,
41
43
  variant,
@@ -66,6 +68,7 @@ const CircleIconButton = (props: CircleIconButtonProps): React.ReactElement => {
66
68
  loading={loading}
67
69
  newWindow={newWindow}
68
70
  onClick={onClick}
71
+ target={target}
69
72
  text={null}
70
73
  variant={variant}
71
74
  >
@@ -1,5 +1,5 @@
1
1
  <%= pb_content_tag do %>
2
- <%= pb_rails("button", props: {type: object.type, loading: object.loading, link: object.link, new_window:object.new_window, variant: object.variant, disabled: object.disabled, dark: object.dark}) do %>
2
+ <%= pb_rails("button", props: {type: object.type, loading: object.loading, link: object.link, new_window:object.new_window, variant: object.variant, target: object.target, disabled: object.disabled, dark: object.dark}) do %>
3
3
  <%= pb_rails("icon", props: {icon: object.icon, fixed_width: true, dark: object.dark}) %>
4
4
  <% end %>
5
5
  <% end %>
@@ -17,6 +17,7 @@ module Playbook
17
17
  prop :link
18
18
  prop :new_window, type: Playbook::Props::Boolean,
19
19
  default: false
20
+ prop :target
20
21
  def classname
21
22
  generate_classname("pb_circle_icon_button_kit")
22
23
  end
@@ -10,3 +10,11 @@
10
10
  link: "https://google.com",
11
11
  new_window: true
12
12
  }) %>
13
+ <br/>
14
+ <%= pb_rails("circle_icon_button", props: {
15
+ icon: "info",
16
+ variant: "secondary",
17
+ aria: { label: "Link to Playbook in new window" },
18
+ link: "https://playbook.powerapp.cloud/",
19
+ target: "child"
20
+ }) %>
@@ -21,6 +21,15 @@ const CircleIconButtonLink = (props) => (
21
21
  {...props}
22
22
  />
23
23
 
24
+ <br/>
25
+
26
+ <CircleIconButton
27
+ aria={{ label: "Link to Playbook in new window" }}
28
+ icon="info"
29
+ link="https://playbook.powerapp.cloud/"
30
+ target="child"
31
+ variant="secondary"
32
+ />
24
33
  </div>
25
34
  )
26
35
 
@@ -0,0 +1 @@
1
+ The `link` prop accepts a string that is used as an href value and causes the button to act as a link. The default behavior of a link is to open in the current window. You can optionally alter the link behavior by adding the `newWindow` prop (boolean), which will open the link in a new window, or by calling the `target` prop, which accepts `_self`, `_blank`, `_parent`, `_top`, `child`, or any string, allowing you to specify any link target.
@@ -0,0 +1,53 @@
1
+ @import "../tokens/colors";
2
+ @import "../tokens/typography";
3
+ @import url("https://code.highcharts.com/css/highcharts.css");
4
+ // @import "highcharts/css/highcharts";
5
+ // @import "highcharts/highcharts.css";
6
+
7
+ :root {
8
+ --highcharts-color-0: #{$data_1};
9
+ --highcharts-color-1: #{$data_2};
10
+ --highcharts-color-2: #{$data_3};
11
+ --highcharts-color-3: #{$data_4};
12
+ --highcharts-color-4: #{$data_5};
13
+ --highcharts-color-5: #{$data_6};
14
+ --highcharts-color-6: #{$data_7};
15
+ --highcharts-color-7: #{$data_8};
16
+ }
17
+
18
+ .highcharts-title {
19
+ font-family: $font_family_base;
20
+ font-weight: $bold;
21
+ font-size: $heading_3;
22
+ color: $text_lt_default;
23
+ fill: $text_lt_default;
24
+ }
25
+
26
+ .highcharts-subtitle {
27
+ font-family: $font_family_base;
28
+ color: $text_lt_light;
29
+ fill: $text_lt_light;
30
+ font-weight: $regular;
31
+ font-size: $text_base;
32
+ }
33
+
34
+ .highcharts-yaxis > .highcharts-axis-title {
35
+ color: $text_lt_lighter;
36
+ fill: $text_lt_lighter;
37
+ font-family: $font_family_base;
38
+ font-weight: $bold;
39
+ font-size: $text_smaller;
40
+ }
41
+
42
+ .highcharts-axis-labels {
43
+ font-family: $font_family_base;
44
+ color: $text_lt_lighter;
45
+ fill: $text_lt_lighter;
46
+ font-weight: $bold;
47
+ font-size: $text_smaller;
48
+ }
49
+
50
+ .highcharts-grid-line {
51
+ stroke: $border_light;
52
+ }
53
+