playbook_ui 16.7.0 → 16.8.0.pre.alpha.PLAY2935formbuilderrequiredindicatorbug16780
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.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_advanced_table/Components/RegularTableView.tsx +2 -0
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +2 -0
- data/app/pb_kits/playbook/pb_advanced_table/Components/VirtualizedTableView.tsx +5 -1
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +24 -0
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/ColumnLayoutHelper.ts +138 -0
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +144 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling.jsx +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling.md +6 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_width.jsx +57 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_width.md +66 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_enable_toggle_expansion_rails.html.erb +62 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_enable_toggle_expansion_rails.md +7 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sticky_header.jsx +12 -4
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sticky_header.md +4 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sticky_header_rails.html.erb +16 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sticky_header_rails.md +4 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sticky_scroll_limitation.jsx +68 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sticky_scroll_limitation.md +7 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header.html.erb +16 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header.jsx +12 -5
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header_rails.md +4 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header_react.md +5 -3
- data/app/pb_kits/playbook/pb_advanced_table/docs/_playground.json +180 -5839
- data/app/pb_kits/playbook/pb_advanced_table/docs/_playground.overrides.json +5 -30
- data/app/pb_kits/playbook/pb_advanced_table/docs/advanced_table_column_definitions_styling.json +4 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +3 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_card/_card.tsx +1 -1
- data/app/pb_kits/playbook/pb_card/card.html.erb +1 -1
- data/app/pb_kits/playbook/pb_currency/_currency.tsx +9 -6
- data/app/pb_kits/playbook/pb_currency/currency.rb +5 -10
- data/app/pb_kits/playbook/pb_currency/currency.test.js +44 -1
- data/app/pb_kits/playbook/pb_date/docs/_playground.json +13 -17
- data/app/pb_kits/playbook/pb_date/docs/_playground.overrides.json +13 -16
- data/app/pb_kits/playbook/pb_date_picker/_date_picker.tsx +3 -2
- data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +38 -23
- data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +2 -1
- data/app/pb_kits/playbook/pb_date_picker/date_picker.test.js +31 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_dialog_submission.jsx +2 -2
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_inline.html.erb +0 -2
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_inline.jsx +0 -2
- data/app/pb_kits/playbook/pb_date_picker/docs/_playground.json +136 -42
- data/app/pb_kits/playbook/pb_date_picker/docs/_playground.overrides.json +113 -45
- data/app/pb_kits/playbook/pb_date_range_inline/docs/_playground.json +48 -6
- data/app/pb_kits/playbook/pb_date_range_inline/docs/_playground.overrides.json +57 -0
- data/app/pb_kits/playbook/pb_date_range_stacked/docs/_playground.json +28 -5
- data/app/pb_kits/playbook/pb_date_range_stacked/docs/_playground.overrides.json +38 -0
- data/app/pb_kits/playbook/pb_date_stacked/docs/_playground.json +1 -1
- data/app/pb_kits/playbook/pb_date_stacked/docs/_playground.overrides.json +1 -1
- data/app/pb_kits/playbook/pb_date_time/docs/_playground.json +16 -3
- data/app/pb_kits/playbook/pb_date_time/docs/_playground.overrides.json +16 -3
- data/app/pb_kits/playbook/pb_date_time_stacked/docs/_playground.json +11 -15
- data/app/pb_kits/playbook/pb_date_time_stacked/docs/_playground.overrides.json +11 -15
- data/app/pb_kits/playbook/pb_date_year_stacked/docs/_playground.json +4 -4
- data/app/pb_kits/playbook/pb_date_year_stacked/docs/_playground.overrides.json +4 -4
- data/app/pb_kits/playbook/pb_detail/docs/_playground.json +12 -18
- data/app/pb_kits/playbook/pb_detail/docs/_playground.overrides.json +13 -12
- data/app/pb_kits/playbook/pb_dialog/docs/_playground.json +108 -42
- data/app/pb_kits/playbook/pb_dialog/docs/_playground.overrides.json +88 -40
- data/app/pb_kits/playbook/pb_distribution_bar/docs/_playground.json +65 -7
- data/app/pb_kits/playbook/pb_distribution_bar/docs/_playground.overrides.json +45 -0
- data/app/pb_kits/playbook/pb_draggable/_draggable.scss +19 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_cards_rails.md +2 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_cards_react.md +1 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_list_rails.md +2 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_list_react.md +3 -1
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_selectable_list_rails.md +3 -1
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_selectable_list_react.md +3 -1
- data/app/pb_kits/playbook/pb_draggable/draggable.test.jsx +16 -0
- data/app/pb_kits/playbook/pb_draggable/draggable_container.html.erb +3 -1
- data/app/pb_kits/playbook/pb_draggable/draggable_item.html.erb +1 -0
- data/app/pb_kits/playbook/pb_draggable/index.js +149 -7
- data/app/pb_kits/playbook/pb_draggable/subcomponents/DraggableContainer.tsx +1 -0
- data/app/pb_kits/playbook/pb_draggable/subcomponents/DraggableItem.tsx +67 -1
- data/app/pb_kits/playbook/pb_draggable/touchDrag.test.js +38 -0
- data/app/pb_kits/playbook/pb_draggable/utilities/touchDrag.ts +173 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_playground.json +318 -21
- data/app/pb_kits/playbook/pb_dropdown/docs/_playground.overrides.json +192 -19
- data/app/pb_kits/playbook/pb_empty_state/docs/_playground.json +77 -12
- data/app/pb_kits/playbook/pb_empty_state/docs/_playground.overrides.json +79 -0
- data/app/pb_kits/playbook/pb_file_upload/docs/_playground.json +98 -13
- data/app/pb_kits/playbook/pb_file_upload/docs/_playground.overrides.json +99 -0
- data/app/pb_kits/playbook/pb_form/docs/_form_with_required_indicator.html.erb +20 -19
- data/app/pb_kits/playbook/pb_icon/_icon.scss +2 -1
- data/app/pb_kits/playbook/pb_icon/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_icon/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_link/docs/_playground.json +81 -40
- data/app/pb_kits/playbook/pb_link/docs/_playground.overrides.json +88 -30
- data/app/pb_kits/playbook/pb_list/_list_item.tsx +4 -1
- data/app/pb_kits/playbook/pb_list/item.html.erb +1 -1
- data/app/pb_kits/playbook/pb_pb_circle_chart/docs/_pb_circle_chart_centered_data.html.erb +90 -0
- data/app/pb_kits/playbook/pb_pb_circle_chart/docs/_pb_circle_chart_centered_data.jsx +100 -0
- data/app/pb_kits/playbook/pb_pb_circle_chart/docs/_pb_circle_chart_centered_data.md +1 -0
- data/app/pb_kits/playbook/pb_pb_circle_chart/docs/_pb_circle_chart_default.jsx +1 -1
- data/app/pb_kits/playbook/pb_pb_circle_chart/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_pb_circle_chart/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_playground.json +4 -2
- data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +1 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/_tiptap_styles.scss +262 -43
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_rails_default.html.erb +1 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_rails_default.md +12 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_rails_simple.html.erb +9 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_rails_simple.md +8 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/kit.schema.json +18 -9
- data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.html.erb +162 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.rb +71 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor_rails.js +202 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky.html.erb +85 -83
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky.jsx +88 -86
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky.md +3 -1
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_external_filter_rails.md +1 -1
- data/app/pb_kits/playbook/pb_text_input/_text_input.scss +37 -0
- data/app/pb_kits/playbook/pb_title/docs/_playground.json +72 -23
- data/app/pb_kits/playbook/pb_title/docs/_playground.overrides.json +80 -16
- data/app/pb_kits/playbook/pb_tooltip/_tooltip.scss +133 -102
- data/app/pb_kits/playbook/pb_tooltip/_tooltip.tsx +54 -41
- data/app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx +60 -2
- data/dist/chunks/{_pb_line_graph-CIWJe3Gr.js → _pb_line_graph-BgsTI0CL.js} +1 -1
- data/dist/chunks/_typeahead-DA__Kgp5.js +5 -0
- data/dist/chunks/{globalProps-CqO4Tko1.js → globalProps-DOB47YGB.js} +1 -1
- data/dist/chunks/{lib-czQnE40X.js → lib-BzglXly2.js} +2 -2
- data/dist/chunks/vendor.js +4 -4
- data/dist/menu.yml +71 -132
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/forms/builder/form_field_builder.rb +2 -0
- data/lib/playbook/version.rb +2 -2
- metadata +31 -10
- data/app/pb_kits/playbook/pb_icon/docs/_icon_fa_kit.html.erb +0 -1
- data/app/pb_kits/playbook/pb_icon/docs/_icon_fa_kit.jsx +0 -21
- data/app/pb_kits/playbook/pb_icon/docs/_icon_fa_kit.md +0 -7
- data/dist/chunks/_typeahead-B_Ac4z84.js +0 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 31a01c81d8013032547d3d5fdecadec787d6f2f8d64591898561444dea9d1197
|
|
4
|
+
data.tar.gz: cce4942d95c7cd06969a18b909971122ee75b0d0e650df4bc3acfb497b53f489
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 54c76487f36cfd1f04cdf9b17b39233250edb2f6be394797f117b40089b3b45c5e3fe498b7c4c85c2b1a430c8b475a33a30f6afabdd819135f236b4f5b982af0
|
|
7
|
+
data.tar.gz: aa703b2f6075230c4b1bdb9dd6f5add9dcee7905292eb5167e34bbf7f5ce8c0ac8a3a031610da6e29f72286f3f0a3814de80ac92e2d8b2de6903a99a30c8c6a1
|
|
@@ -5,6 +5,7 @@ import { flexRender, Row, Cell } from "@tanstack/react-table"
|
|
|
5
5
|
import { GenericObject } from "../../types"
|
|
6
6
|
import { isChrome } from "../Utilities/BrowserCheck"
|
|
7
7
|
import { findColumnDefByAccessor } from "../Utilities/ColumnStylingHelper"
|
|
8
|
+
import { playbookColumnLayoutStylesFromMeta } from "../Utilities/ColumnLayoutHelper"
|
|
8
9
|
import { getRowColorClass, shouldShowLoadingIndicator } from "../Utilities/RowUtils"
|
|
9
10
|
|
|
10
11
|
import LoadingInline from "../../pb_loading_inline/_loading_inline"
|
|
@@ -94,6 +95,7 @@ const TableCellRenderer = ({
|
|
|
94
95
|
)}
|
|
95
96
|
key={`${cell.id}-data`}
|
|
96
97
|
style={{
|
|
98
|
+
...playbookColumnLayoutStylesFromMeta(column.columnDef),
|
|
97
99
|
left: isPinnedLeft
|
|
98
100
|
? i === 1 // Accounting for set min-width for first column
|
|
99
101
|
? '180px'
|
|
@@ -16,6 +16,7 @@ import { SortIconButton } from "./SortIconButton"
|
|
|
16
16
|
import { ToggleIconButton } from "./ToggleIconButton"
|
|
17
17
|
import { displayIcon } from "../Utilities/IconHelpers"
|
|
18
18
|
import { findColumnDefByAccessor } from "../Utilities/ColumnStylingHelper"
|
|
19
|
+
import { playbookColumnLayoutStylesFromMeta } from "../Utilities/ColumnLayoutHelper"
|
|
19
20
|
import { updateExpandAndCollapseState } from "../Utilities/ExpansionControlHelpers"
|
|
20
21
|
|
|
21
22
|
import { isChrome } from "../Utilities/BrowserCheck"
|
|
@@ -198,6 +199,7 @@ const isToggleExpansionEnabled =
|
|
|
198
199
|
id={cellId}
|
|
199
200
|
key={`${header?.id}-header`}
|
|
200
201
|
style={{
|
|
202
|
+
...playbookColumnLayoutStylesFromMeta(header?.column?.columnDef),
|
|
201
203
|
backgroundColor: headerBackgroundColor,
|
|
202
204
|
color: headerFontColor,
|
|
203
205
|
left: isPinnedLeft
|
|
@@ -19,6 +19,7 @@ import { LoadingCell } from "../Components/LoadingCell"
|
|
|
19
19
|
import { renderCollapsibleTrail } from "../Components/CollapsibleTrail"
|
|
20
20
|
|
|
21
21
|
import AdvancedTableContext from "../Context/AdvancedTableContext"
|
|
22
|
+
import { playbookColumnLayoutStylesFromMeta } from "../Utilities/ColumnLayoutHelper"
|
|
22
23
|
|
|
23
24
|
type VirtualizedTableViewProps = {
|
|
24
25
|
collapsibleTrail?: boolean
|
|
@@ -224,7 +225,10 @@ export const VirtualizedTableView = ({
|
|
|
224
225
|
isLastCell && 'last-cell',
|
|
225
226
|
)}
|
|
226
227
|
key={`${cell.id}-data`}
|
|
227
|
-
style={{
|
|
228
|
+
style={{
|
|
229
|
+
...playbookColumnLayoutStylesFromMeta(cell.column.columnDef),
|
|
230
|
+
width: cellWidth,
|
|
231
|
+
}}
|
|
228
232
|
>
|
|
229
233
|
{collapsibleTrail && i === 0 && row.depth > 0 && renderCollapsibleTrail(row.depth)}
|
|
230
234
|
<span id={`${cell.id}-span`}>
|
|
@@ -12,6 +12,10 @@ import {
|
|
|
12
12
|
import { GenericObject } from "../../types";
|
|
13
13
|
import { createColumnHelper } from "@tanstack/react-table";
|
|
14
14
|
import { createCellFunction } from "../Utilities/CellRendererUtils";
|
|
15
|
+
import {
|
|
16
|
+
buildPlaybookColumnLayoutStyles,
|
|
17
|
+
buildTanStackSizingFromColumn,
|
|
18
|
+
} from "../Utilities/ColumnLayoutHelper";
|
|
15
19
|
import { getParentOnlySortedRowModel } from "../Utilities/RowModelUtils";
|
|
16
20
|
|
|
17
21
|
interface UseTableStateProps {
|
|
@@ -105,11 +109,31 @@ export function useTableState({
|
|
|
105
109
|
columns: buildColumns(column.columns, false),
|
|
106
110
|
};
|
|
107
111
|
}
|
|
112
|
+
const tanStackSizing = buildTanStackSizingFromColumn(column);
|
|
113
|
+
const layoutStyles = buildPlaybookColumnLayoutStyles(column, tanStackSizing);
|
|
114
|
+
const userMeta =
|
|
115
|
+
column.meta &&
|
|
116
|
+
typeof column.meta === "object" &&
|
|
117
|
+
!Array.isArray(column.meta)
|
|
118
|
+
? column.meta
|
|
119
|
+
: {};
|
|
120
|
+
const hasLayoutStyles =
|
|
121
|
+
layoutStyles.width !== undefined ||
|
|
122
|
+
layoutStyles.minWidth !== undefined ||
|
|
123
|
+
layoutStyles.maxWidth !== undefined;
|
|
124
|
+
|
|
108
125
|
// Define the base column structure
|
|
109
126
|
const columnStructure = {
|
|
110
127
|
...columnHelper.accessor(column.accessor, {
|
|
111
128
|
header: column.header ?? column.label ?? "",
|
|
112
129
|
enableSorting: isFirstColumn || column.enableSort === true,
|
|
130
|
+
...tanStackSizing,
|
|
131
|
+
meta: {
|
|
132
|
+
...userMeta,
|
|
133
|
+
...(hasLayoutStyles
|
|
134
|
+
? { playbookColumnLayoutStyles: layoutStyles }
|
|
135
|
+
: {}),
|
|
136
|
+
},
|
|
113
137
|
}),
|
|
114
138
|
};
|
|
115
139
|
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type { CSSProperties } from "react"
|
|
2
|
+
|
|
3
|
+
import { GenericObject } from "../../types"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Converts a Playbook column width value to a CSS length string.
|
|
7
|
+
* Numbers are treated as pixels; strings are passed through (e.g. `"12rem"`, `"200px"`).
|
|
8
|
+
*/
|
|
9
|
+
export function cssLength(
|
|
10
|
+
value: number | string | undefined | null
|
|
11
|
+
): string | undefined {
|
|
12
|
+
if (value === undefined || value === null || value === "") return undefined
|
|
13
|
+
if (typeof value === "number" && Number.isFinite(value)) return `${value}px`
|
|
14
|
+
return String(value)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const columnStylingKeys = (column: GenericObject) =>
|
|
18
|
+
(column.columnStyling || column.column_styling || {}) as GenericObject
|
|
19
|
+
|
|
20
|
+
function readStylingLength(
|
|
21
|
+
styling: GenericObject,
|
|
22
|
+
camel: string,
|
|
23
|
+
snake?: string
|
|
24
|
+
): string | number | undefined {
|
|
25
|
+
if (snake) return styling[camel] ?? styling[snake]
|
|
26
|
+
return styling[camel] as string | number | undefined
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* TanStack Table v8 `ColumnDef` sizing fields we forward from each `columnDefinitions` entry.
|
|
31
|
+
* See AdvancedTable kit docs for precedence with `columnStyling` width keys.
|
|
32
|
+
*/
|
|
33
|
+
export const PLAYBOOK_FORWARDED_COLUMN_DEF_SIZING_KEYS = [
|
|
34
|
+
"size",
|
|
35
|
+
"minSize",
|
|
36
|
+
"maxSize",
|
|
37
|
+
] as const
|
|
38
|
+
|
|
39
|
+
export type PlaybookForwardedColumnSizing = Partial<
|
|
40
|
+
Record<(typeof PLAYBOOK_FORWARDED_COLUMN_DEF_SIZING_KEYS)[number], number>
|
|
41
|
+
>
|
|
42
|
+
|
|
43
|
+
export function buildTanStackSizingFromColumn(
|
|
44
|
+
column: GenericObject
|
|
45
|
+
): PlaybookForwardedColumnSizing {
|
|
46
|
+
const out: PlaybookForwardedColumnSizing = {}
|
|
47
|
+
PLAYBOOK_FORWARDED_COLUMN_DEF_SIZING_KEYS.forEach((key) => {
|
|
48
|
+
const v = column[key]
|
|
49
|
+
if (typeof v === "number" && Number.isFinite(v)) out[key] = v
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
const styling = columnStylingKeys(column)
|
|
53
|
+
|
|
54
|
+
if (out.size === undefined && readStylingLength(styling, "width") !== undefined) {
|
|
55
|
+
const w = readStylingLength(styling, "width")
|
|
56
|
+
if (typeof w === "number" && Number.isFinite(w)) out.size = w
|
|
57
|
+
}
|
|
58
|
+
if (out.minSize === undefined && readStylingLength(styling, "minWidth", "min_width") !== undefined) {
|
|
59
|
+
const w = readStylingLength(styling, "minWidth", "min_width")
|
|
60
|
+
if (typeof w === "number" && Number.isFinite(w)) out.minSize = w
|
|
61
|
+
}
|
|
62
|
+
if (out.maxSize === undefined && readStylingLength(styling, "maxWidth", "max_width") !== undefined) {
|
|
63
|
+
const w = readStylingLength(styling, "maxWidth", "max_width")
|
|
64
|
+
if (typeof w === "number" && Number.isFinite(w)) out.maxSize = w
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// width/size only → fixed column (min and max match preferred)
|
|
68
|
+
if (out.size !== undefined && out.minSize === undefined && out.maxSize === undefined) {
|
|
69
|
+
out.minSize = out.size
|
|
70
|
+
out.maxSize = out.size
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return out
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Inline width styles for `<th>` / `<td>` so `table-layout: fixed` tables keep stable
|
|
78
|
+
* columns when row content changes (e.g. expand/collapse). Values mirror TanStack sizing
|
|
79
|
+
* and/or `columnStyling` width keys; string values in `columnStyling` win over numeric
|
|
80
|
+
* TanStack fields when both describe the same axis.
|
|
81
|
+
*/
|
|
82
|
+
export function buildPlaybookColumnLayoutStyles(
|
|
83
|
+
column: GenericObject,
|
|
84
|
+
tanStackSizing: PlaybookForwardedColumnSizing
|
|
85
|
+
): CSSProperties {
|
|
86
|
+
const styling = columnStylingKeys(column)
|
|
87
|
+
const styles: CSSProperties = {}
|
|
88
|
+
|
|
89
|
+
const stylingWidth = readStylingLength(styling, "width")
|
|
90
|
+
const stylingMin = readStylingLength(styling, "minWidth", "min_width")
|
|
91
|
+
const stylingMax = readStylingLength(styling, "maxWidth", "max_width")
|
|
92
|
+
|
|
93
|
+
const hasStylingWidth = stylingWidth !== undefined && stylingWidth !== ""
|
|
94
|
+
const hasStylingMin = stylingMin !== undefined && stylingMin !== ""
|
|
95
|
+
const hasStylingMax = stylingMax !== undefined && stylingMax !== ""
|
|
96
|
+
|
|
97
|
+
let widthValue: string | number | undefined = hasStylingWidth
|
|
98
|
+
? stylingWidth
|
|
99
|
+
: tanStackSizing.size
|
|
100
|
+
let minValue: string | number | undefined = hasStylingMin
|
|
101
|
+
? stylingMin
|
|
102
|
+
: tanStackSizing.minSize
|
|
103
|
+
let maxValue: string | number | undefined = hasStylingMax
|
|
104
|
+
? stylingMax
|
|
105
|
+
: tanStackSizing.maxSize
|
|
106
|
+
|
|
107
|
+
const preferredForLock = hasStylingWidth ? stylingWidth : tanStackSizing.size
|
|
108
|
+
const explicitMin = hasStylingMin || tanStackSizing.minSize !== undefined
|
|
109
|
+
const explicitMax = hasStylingMax || tanStackSizing.maxSize !== undefined
|
|
110
|
+
|
|
111
|
+
if (
|
|
112
|
+
preferredForLock !== undefined &&
|
|
113
|
+
preferredForLock !== "" &&
|
|
114
|
+
!explicitMin &&
|
|
115
|
+
!explicitMax
|
|
116
|
+
) {
|
|
117
|
+
minValue = preferredForLock
|
|
118
|
+
maxValue = preferredForLock
|
|
119
|
+
widthValue = preferredForLock
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const widthCss = cssLength(widthValue)
|
|
123
|
+
const minCss = cssLength(minValue)
|
|
124
|
+
const maxCss = cssLength(maxValue)
|
|
125
|
+
|
|
126
|
+
if (widthCss !== undefined) styles.width = widthCss
|
|
127
|
+
if (minCss !== undefined) styles.minWidth = minCss
|
|
128
|
+
if (maxCss !== undefined) styles.maxWidth = maxCss
|
|
129
|
+
|
|
130
|
+
return styles
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export function playbookColumnLayoutStylesFromMeta(
|
|
134
|
+
columnDef: GenericObject | undefined
|
|
135
|
+
): CSSProperties {
|
|
136
|
+
const meta = columnDef?.meta as GenericObject | undefined
|
|
137
|
+
return (meta?.playbookColumnLayoutStyles || {}) as CSSProperties
|
|
138
|
+
}
|
|
@@ -774,6 +774,150 @@ test("columnStyling.cellPadding sets cell padding", () => {
|
|
|
774
774
|
expect(firstEnrollmentCell).toHaveClass('p_none')
|
|
775
775
|
});
|
|
776
776
|
|
|
777
|
+
test("columnStyling minWidth, width, and maxWidth apply to header and body cells", () => {
|
|
778
|
+
const styledColumnDefs = [
|
|
779
|
+
{
|
|
780
|
+
accessor: "year",
|
|
781
|
+
label: "Year",
|
|
782
|
+
cellAccessors: ["quarter", "month", "day"],
|
|
783
|
+
columnStyling: { minWidth: 240, width: 260, maxWidth: 400 },
|
|
784
|
+
},
|
|
785
|
+
{
|
|
786
|
+
accessor: "newEnrollments",
|
|
787
|
+
label: "New Enrollments",
|
|
788
|
+
},
|
|
789
|
+
{
|
|
790
|
+
accessor: "scheduledMeetings",
|
|
791
|
+
label: "Scheduled Meetings",
|
|
792
|
+
},
|
|
793
|
+
];
|
|
794
|
+
|
|
795
|
+
render(
|
|
796
|
+
<AdvancedTable
|
|
797
|
+
columnDefinitions={styledColumnDefs}
|
|
798
|
+
data={{ testid: testId }}
|
|
799
|
+
tableData={MOCK_DATA}
|
|
800
|
+
/>
|
|
801
|
+
);
|
|
802
|
+
|
|
803
|
+
const yearHeader = screen.getByText("Year").closest("th");
|
|
804
|
+
expect(yearHeader).toHaveStyle({ minWidth: "240px", width: "260px", maxWidth: "400px" });
|
|
805
|
+
|
|
806
|
+
const yearCell = screen.getAllByText("2021")[0].closest("td");
|
|
807
|
+
expect(yearCell).toHaveStyle({ minWidth: "240px", width: "260px", maxWidth: "400px" });
|
|
808
|
+
});
|
|
809
|
+
|
|
810
|
+
test("columnStyling width only locks minWidth and maxWidth to the same value", () => {
|
|
811
|
+
const styledColumnDefs = [
|
|
812
|
+
{
|
|
813
|
+
accessor: "year",
|
|
814
|
+
label: "Year",
|
|
815
|
+
cellAccessors: ["quarter", "month", "day"],
|
|
816
|
+
columnStyling: { width: 128 },
|
|
817
|
+
},
|
|
818
|
+
{
|
|
819
|
+
accessor: "newEnrollments",
|
|
820
|
+
label: "New Enrollments",
|
|
821
|
+
},
|
|
822
|
+
{
|
|
823
|
+
accessor: "scheduledMeetings",
|
|
824
|
+
label: "Scheduled Meetings",
|
|
825
|
+
},
|
|
826
|
+
];
|
|
827
|
+
|
|
828
|
+
render(
|
|
829
|
+
<AdvancedTable
|
|
830
|
+
columnDefinitions={styledColumnDefs}
|
|
831
|
+
data={{ testid: testId }}
|
|
832
|
+
tableData={MOCK_DATA}
|
|
833
|
+
/>
|
|
834
|
+
);
|
|
835
|
+
|
|
836
|
+
const yearHeader = screen.getByText("Year").closest("th");
|
|
837
|
+
expect(yearHeader).toHaveStyle({
|
|
838
|
+
width: "128px",
|
|
839
|
+
minWidth: "128px",
|
|
840
|
+
maxWidth: "128px",
|
|
841
|
+
});
|
|
842
|
+
});
|
|
843
|
+
|
|
844
|
+
test("columnDefinitions size only locks minSize and maxSize to the same value", () => {
|
|
845
|
+
const styledColumnDefs = [
|
|
846
|
+
{
|
|
847
|
+
accessor: "year",
|
|
848
|
+
label: "Year",
|
|
849
|
+
cellAccessors: ["quarter", "month", "day"],
|
|
850
|
+
},
|
|
851
|
+
{
|
|
852
|
+
accessor: "newEnrollments",
|
|
853
|
+
label: "New Enrollments",
|
|
854
|
+
size: 200,
|
|
855
|
+
},
|
|
856
|
+
{
|
|
857
|
+
accessor: "scheduledMeetings",
|
|
858
|
+
label: "Scheduled Meetings",
|
|
859
|
+
},
|
|
860
|
+
];
|
|
861
|
+
|
|
862
|
+
render(
|
|
863
|
+
<AdvancedTable
|
|
864
|
+
columnDefinitions={styledColumnDefs}
|
|
865
|
+
data={{ testid: testId }}
|
|
866
|
+
tableData={MOCK_DATA}
|
|
867
|
+
/>
|
|
868
|
+
);
|
|
869
|
+
|
|
870
|
+
const enrollmentsHeader = screen.getByText("New Enrollments").closest("th");
|
|
871
|
+
expect(enrollmentsHeader).toHaveStyle({
|
|
872
|
+
width: "200px",
|
|
873
|
+
minWidth: "200px",
|
|
874
|
+
maxWidth: "200px",
|
|
875
|
+
});
|
|
876
|
+
});
|
|
877
|
+
|
|
878
|
+
test("columnDefinitions size, minSize, and maxSize apply layout styles", () => {
|
|
879
|
+
const styledColumnDefs = [
|
|
880
|
+
{
|
|
881
|
+
accessor: "year",
|
|
882
|
+
label: "Year",
|
|
883
|
+
cellAccessors: ["quarter", "month", "day"],
|
|
884
|
+
},
|
|
885
|
+
{
|
|
886
|
+
accessor: "newEnrollments",
|
|
887
|
+
label: "New Enrollments",
|
|
888
|
+
size: 180,
|
|
889
|
+
minSize: 160,
|
|
890
|
+
maxSize: 320,
|
|
891
|
+
},
|
|
892
|
+
{
|
|
893
|
+
accessor: "scheduledMeetings",
|
|
894
|
+
label: "Scheduled Meetings",
|
|
895
|
+
},
|
|
896
|
+
];
|
|
897
|
+
|
|
898
|
+
render(
|
|
899
|
+
<AdvancedTable
|
|
900
|
+
columnDefinitions={styledColumnDefs}
|
|
901
|
+
data={{ testid: testId }}
|
|
902
|
+
tableData={MOCK_DATA}
|
|
903
|
+
/>
|
|
904
|
+
);
|
|
905
|
+
|
|
906
|
+
const enrollmentsHeader = screen.getByText("New Enrollments").closest("th");
|
|
907
|
+
expect(enrollmentsHeader).toHaveStyle({
|
|
908
|
+
width: "180px",
|
|
909
|
+
minWidth: "160px",
|
|
910
|
+
maxWidth: "320px",
|
|
911
|
+
});
|
|
912
|
+
|
|
913
|
+
const enrollmentsCell = screen.getAllByText("20")[0].closest("td");
|
|
914
|
+
expect(enrollmentsCell).toHaveStyle({
|
|
915
|
+
width: "180px",
|
|
916
|
+
minWidth: "160px",
|
|
917
|
+
maxWidth: "320px",
|
|
918
|
+
});
|
|
919
|
+
});
|
|
920
|
+
|
|
777
921
|
test("columnStyling.fontColor sets cell font color", () => {
|
|
778
922
|
const styledColumnDefs = [
|
|
779
923
|
{
|
|
@@ -6,4 +6,10 @@ The `columnStyling` prop is an optional item that can be used within `columnDefi
|
|
|
6
6
|
|
|
7
7
|
3) `fontColor`: This will allow you to control the font color for a given column.
|
|
8
8
|
|
|
9
|
+
4) Column width: optional keys on `columnStyling` are `minWidth`, `width`, and `maxWidth` (numbers = pixels; CSS strings allowed). This example sets `width` on Year for a fixed hierarchy column (see the width doc for `minWidth` and bands).
|
|
10
|
+
|
|
11
|
+
Fixed width: pass `width` only (or TanStack `size` only) and Playbook sets min and max to the same value automatically — you do not need all three for an exact width.
|
|
12
|
+
|
|
13
|
+
See [Column Styling: Width](https://playbook.powerapp.cloud/kits/advanced_table/react#column-styling-width) for the full guide (Playbook ↔ TanStack mapping, floor-only vs bands, and when to use one vs three values).
|
|
14
|
+
|
|
9
15
|
`columnStyling` can be used within the columnDefinition of all the columns or some of them, as shown. Each column has its own individual control in this way.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import AdvancedTable from "../_advanced_table"
|
|
3
|
+
import MOCK_DATA from "./advanced_table_mock_data.json"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Kit doc: compares fixed width, floor-only, TanStack band, and min/preferred/max band.
|
|
7
|
+
*/
|
|
8
|
+
const AdvancedTableColumnStylingWidth = (props) => {
|
|
9
|
+
const columnDefinitions = [
|
|
10
|
+
{
|
|
11
|
+
accessor: "year",
|
|
12
|
+
label: "Year (fixed)",
|
|
13
|
+
cellAccessors: ["quarter", "month", "day"],
|
|
14
|
+
// width alone locks min + max to the same value (128px).
|
|
15
|
+
columnStyling: { width: 128 },
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
accessor: "newEnrollments",
|
|
19
|
+
label: "Enrollments (floor)",
|
|
20
|
+
columnStyling: { minWidth: 160 },
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
accessor: "scheduledMeetings",
|
|
24
|
+
label: "Meetings (TanStack band)",
|
|
25
|
+
size: 200,
|
|
26
|
+
minSize: 160,
|
|
27
|
+
maxSize: 240,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
accessor: "attendanceRate",
|
|
31
|
+
label: "Attendance (min / pref / max)",
|
|
32
|
+
columnStyling: { minWidth: 108, width: 124, maxWidth: 168 },
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
accessor: "completedClasses",
|
|
36
|
+
label: "Completed",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
accessor: "classCompletionRate",
|
|
40
|
+
label: "Completion %",
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
accessor: "graduatedStudents",
|
|
44
|
+
label: "Graduated",
|
|
45
|
+
},
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<AdvancedTable
|
|
50
|
+
columnDefinitions={columnDefinitions}
|
|
51
|
+
tableData={MOCK_DATA}
|
|
52
|
+
{...props}
|
|
53
|
+
/>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export default AdvancedTableColumnStylingWidth
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
AdvancedTable column width is controlled in two equivalent places on each leaf `columnDefinitions` entry. Playbook maps them to inline styles on header and body cells (and forwards numeric values into TanStack Table’s column model).
|
|
2
|
+
|
|
3
|
+
1) Playbook `columnStyling` and TanStack `ColumnDef` use the same three ideas:
|
|
4
|
+
|
|
5
|
+
- Preferred / target width: `columnStyling` `width` maps to TanStack `size` on the same column object.
|
|
6
|
+
- Minimum width (floor): `columnStyling` `minWidth` maps to TanStack `minSize`.
|
|
7
|
+
- Maximum width (ceiling): `columnStyling` `maxWidth` maps to TanStack `maxSize`.
|
|
8
|
+
|
|
9
|
+
Numbers are pixels. You can also pass CSS length strings on `columnStyling` (e.g. `"12rem"`, `"200px"`). TanStack fields accept numbers only.
|
|
10
|
+
|
|
11
|
+
If both APIs set the same axis, `columnStyling` wins for that axis when Playbook builds cell styles.
|
|
12
|
+
|
|
13
|
+
2) Fixed width: set `width` only
|
|
14
|
+
|
|
15
|
+
If you pass only `width` (or only `size`) and do not set `minWidth` / `maxWidth` (or `minSize` / `maxSize`), Playbook treats that as a fixed column: it sets all three to the same value under the hood so you do not have to repeat yourself.
|
|
16
|
+
|
|
17
|
+
```jsx
|
|
18
|
+
columnStyling: { width: 128 }
|
|
19
|
+
// Applied as width, minWidth, and maxWidth: 128px
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```jsx
|
|
23
|
+
size: 200
|
|
24
|
+
// Forwarded as size, minSize, and maxSize: 200
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Use this when the column should stay one width (e.g. a hierarchy column with expand controls).
|
|
28
|
+
|
|
29
|
+
3) Floor only: `minWidth` / `minSize`
|
|
30
|
+
|
|
31
|
+
Set only a minimum when the column may grow with the table or content but must not shrink below a baseline (common fix for horizontal “jump” when rows expand):
|
|
32
|
+
|
|
33
|
+
```jsx
|
|
34
|
+
columnStyling: { minWidth: 160 }
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
4) Flexible band: min + preferred + max
|
|
38
|
+
|
|
39
|
+
Set two or three values when you want a range. CSS uses preferred `width` clamped between `minWidth` and `maxWidth`:
|
|
40
|
+
|
|
41
|
+
- `minWidth`: won’t shrink below this.
|
|
42
|
+
- `width`: preferred size when space allows.
|
|
43
|
+
- `maxWidth`: won’t grow above this.
|
|
44
|
+
|
|
45
|
+
Example from the table below (Attendance): `minWidth: 108`, `width: 124`, `maxWidth: 168` → preferred 124px, allowed between 108 and 168.
|
|
46
|
+
|
|
47
|
+
You only need all three when you want that band. If min and max are omitted, `width` alone is enough for a fixed column.
|
|
48
|
+
|
|
49
|
+
5) TanStack band without `columnStyling`
|
|
50
|
+
|
|
51
|
+
The Meetings column uses only TanStack fields:
|
|
52
|
+
|
|
53
|
+
```jsx
|
|
54
|
+
{ accessor: "scheduledMeetings", size: 200, minSize: 160, maxSize: 240 }
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Playbook applies the same min / preferred / max idea to cell styles. Setting only `size: 200` would lock all three to 200, same as `width: 200` in `columnStyling`.
|
|
58
|
+
|
|
59
|
+
6) What the example table shows
|
|
60
|
+
|
|
61
|
+
- Year (fixed): `columnStyling: { width: 128 }` — locked to 128px.
|
|
62
|
+
- Enrollments (floor): `columnStyling: { minWidth: 160 }` — at least 160px; can grow.
|
|
63
|
+
- Meetings (TanStack band): `size` / `minSize` / `maxSize` — preferred 200px, between 160–240.
|
|
64
|
+
- Attendance (min / pref / max): all three in `columnStyling` — preferred 124px, between 108–168.
|
|
65
|
+
|
|
66
|
+
Grouped columns: put width options on leaf definitions (columns with an `accessor`), not on parent group headers.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<%
|
|
2
|
+
column_definitions = [
|
|
3
|
+
{
|
|
4
|
+
accessor: "year",
|
|
5
|
+
label: "Year",
|
|
6
|
+
cellAccessors: ["quarter", "month", "day"],
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
accessor: "newEnrollments",
|
|
10
|
+
label: "New Enrollments",
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
accessor: "scheduledMeetings",
|
|
14
|
+
label: "Scheduled Meetings",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
accessor: "attendanceRate",
|
|
18
|
+
label: "Attendance Rate",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
accessor: "completedClasses",
|
|
22
|
+
label: "Completed Classes",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
accessor: "classCompletionRate",
|
|
26
|
+
label: "Class Completion Rate",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
accessor: "graduatedStudents",
|
|
30
|
+
label: "Graduated Students",
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
subrow_headers = ["Quarter", "Month", "Day"]
|
|
35
|
+
%>
|
|
36
|
+
|
|
37
|
+
<%= pb_rails("title", props: { size: 4, text: "Normal Structure", margin_bottom: "sm" }) %>
|
|
38
|
+
|
|
39
|
+
<%= pb_rails("advanced_table", props: {
|
|
40
|
+
id: "enable-toggle-expansion-normal",
|
|
41
|
+
table_data: @table_data,
|
|
42
|
+
column_definitions: column_definitions,
|
|
43
|
+
enable_toggle_expansion: "all"
|
|
44
|
+
}) %>
|
|
45
|
+
|
|
46
|
+
<%= pb_rails("title", props: { size: 4, text: "Subcomponent Structure", margin_top: "lg", margin_bottom: "sm" }) %>
|
|
47
|
+
|
|
48
|
+
<%= pb_rails("advanced_table", props: { id: "enable-toggle-expansion-subcomponents" }) do %>
|
|
49
|
+
<%= pb_rails("advanced_table/table_header", props: {
|
|
50
|
+
table_id: "enable-toggle-expansion-subcomponents",
|
|
51
|
+
table_data: @table_data,
|
|
52
|
+
column_definitions: column_definitions,
|
|
53
|
+
enable_toggle_expansion: "all"
|
|
54
|
+
}) %>
|
|
55
|
+
<%= pb_rails("advanced_table/table_body", props: {
|
|
56
|
+
table_id: "enable-toggle-expansion-subcomponents",
|
|
57
|
+
table_data: @table_data,
|
|
58
|
+
column_definitions: column_definitions,
|
|
59
|
+
subrow_headers: subrow_headers,
|
|
60
|
+
enable_toggle_expansion: "all"
|
|
61
|
+
}) %>
|
|
62
|
+
<% end %>
|
data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_enable_toggle_expansion_rails.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
`enable_toggle_expansion` controls where AdvancedTable renders toggle-all expansion controls. It accepts `"header"`, `"all"`, or `"none"` and defaults to `"header"`.
|
|
2
|
+
|
|
3
|
+
When using the normal Rails structure, pass `enable_toggle_expansion` to `advanced_table`. The parent kit renders its own `table_header` and `table_body`, so the prop is passed down automatically.
|
|
4
|
+
|
|
5
|
+
When using the Rails subcomponent structure, pass `enable_toggle_expansion` directly to the subcomponents that need it. `advanced_table/table_header` uses it for the table header toggle-all button. **NOTE**: you must pass `table_data` to `advanced_table/table_header` as well so it can detect whether expandable rows exist. `advanced_table/table_body` uses it for nested subrow header toggle controls, such as when `subrow_headers` is present.
|
|
6
|
+
|
|
7
|
+
Use `"all"` when you want toggle-all controls in both the table header and subrow headers. Use `"header"` when you only want the table header toggle-all control. Use `"none"` to suppress the header toggle-all control.
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import React from "react"
|
|
2
2
|
import AdvancedTable from '../../pb_advanced_table/_advanced_table'
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
const tableData = Array.from({ length: 15 }, (_, index) => ({
|
|
5
|
+
year: String(2020 + index),
|
|
6
|
+
newEnrollments: String(20 + index),
|
|
7
|
+
scheduledMeetings: String(10 + index),
|
|
8
|
+
attendanceRate: `${50 + index}%`,
|
|
9
|
+
completedClasses: String(3 + index),
|
|
10
|
+
classCompletionRate: `${30 + index}%`,
|
|
11
|
+
graduatedStudents: String(19 + index),
|
|
12
|
+
}))
|
|
4
13
|
|
|
5
14
|
const AdvancedTableStickyHeader = (props) => {
|
|
6
15
|
const columnDefinitions = [
|
|
7
16
|
{
|
|
8
17
|
accessor: "year",
|
|
9
18
|
label: "Year",
|
|
10
|
-
cellAccessors: ["quarter", "month", "day"],
|
|
11
19
|
},
|
|
12
20
|
{
|
|
13
21
|
accessor: "newEnrollments",
|
|
@@ -40,11 +48,11 @@ const AdvancedTableStickyHeader = (props) => {
|
|
|
40
48
|
}
|
|
41
49
|
|
|
42
50
|
return (
|
|
43
|
-
<div>
|
|
51
|
+
<div style={{ maxHeight: "320px", overflowY: "auto" }}>
|
|
44
52
|
<AdvancedTable
|
|
45
53
|
columnDefinitions={columnDefinitions}
|
|
46
54
|
responsive="none"
|
|
47
|
-
tableData={
|
|
55
|
+
tableData={tableData}
|
|
48
56
|
tableProps={tableProps}
|
|
49
57
|
{...props}
|
|
50
58
|
/>
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
The `TableProps` prop can also be used to render a sticky header for the Advanced Table.
|
|
2
2
|
|
|
3
|
+
This doc example uses a scroll container with flat rows so sticky behavior is visible in the docs without expanding subrows. Scroll inside the preview to see the header stick.
|
|
4
|
+
|
|
5
|
+
This example builds flat table data inline for the docs preview. For typical `tableData` setup, see [Default (Required Props)](/kits/advanced_table/default/react#advanced_table_default).
|
|
6
|
+
|
|
3
7
|
This doc example showcases how to set a sticky header for a nonresponsive table (see the `responsive` prop set to "none"). To achieve sticky header AND responsive functionality, see the "Sticky Header for Responsive Table" doc example below.
|