playbook_ui 14.19.0.pre.alpha.PLAY21297675 → 14.19.0.pre.alpha.play1997dropdownenablepillsinselection7702
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 +1 -11
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableActionBar.tsx +15 -148
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +3 -20
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +13 -23
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +0 -9
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +2 -7
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +0 -4
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +1 -5
- data/app/pb_kits/playbook/pb_advanced_table/scss_partials/advanced_table_sticky_mixin.scss +0 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display.jsx +11 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display.md +1 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display_rails.html.erb +33 -2
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display_rails.md +3 -1
- data/app/pb_kits/playbook/pb_dropdown/index.js +14 -1
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownContainer.tsx +2 -2
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownTrigger.tsx +1 -1
- data/app/pb_kits/playbook/pb_section_separator/_section_separator.tsx +2 -2
- data/dist/chunks/{_typeahead-BPSIWtFT.js → _typeahead-BQV04mOl.js} +3 -3
- data/dist/chunks/_weekday_stacked-BdaYw6Ra.js +45 -0
- data/dist/chunks/{lib-B20MXZcW.js → lib-DwFasxbk.js} +2 -2
- data/dist/chunks/{pb_form_validation-WWvUXPKD.js → pb_form_validation-nnXW3T-3.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +1 -1
- 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/version.rb +1 -1
- metadata +6 -15
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/VisibilityTree.ts +0 -47
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility.jsx +0 -57
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility.md +0 -4
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_custom.jsx +0 -62
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_custom.md +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_multi.jsx +0 -82
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_multi.md +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_with_state.jsx +0 -65
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_with_state.md +0 -1
- data/dist/chunks/_weekday_stacked-BeuPAmxG.js +0 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e1acc819228475b290eaea87ff0b86b2b62cea0c8d53baa8527c2bab9714a3a
|
4
|
+
data.tar.gz: 6ae3b6b23aae3dd4f27fc2b4ffd1c575f6bdfe51710fe5814661e81a36d8d810
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a60e87407b7cdc3186cc515e4a0e783343b7e7257278f8dc3fa711c91447a5c3711911371121e4c3075799c305dc2da709b18f87e10cb9d51825c528ad797dec
|
7
|
+
data.tar.gz: '05912e775970c5b43a34112f4338c7269863c251a10cac6078c1a263db1a11b4d8207e363ab6377f1ea598fb8528bcc23a7d6e73a72c5f930f0b7fc15a276278'
|
@@ -93,17 +93,7 @@ export const RegularTableView = ({
|
|
93
93
|
|
94
94
|
{row.getVisibleCells().map((cell: Cell<GenericObject, unknown>, i: number) => {
|
95
95
|
const isPinnedLeft = columnPinning.left.includes(cell.column.id);
|
96
|
-
const isLastCell = (
|
97
|
-
const parent = cell.column.parent;
|
98
|
-
if (!parent) {
|
99
|
-
const last = row.getVisibleCells().at(-1);
|
100
|
-
return last?.column.id === cell.column.id;
|
101
|
-
}
|
102
|
-
|
103
|
-
const visibleSiblings = parent.columns.filter(col => col.getIsVisible());
|
104
|
-
return visibleSiblings.at(-1)?.id === cell.column.id;
|
105
|
-
})();
|
106
|
-
|
96
|
+
const isLastCell = cell.column.parent?.columns?.at(-1)?.id === cell.column.id;
|
107
97
|
const { column } = cell;
|
108
98
|
return (
|
109
99
|
<td
|
@@ -1,112 +1,25 @@
|
|
1
|
-
import React, { useEffect, useRef
|
2
|
-
|
3
|
-
import AdvancedTableContext from "../Context/AdvancedTableContext";
|
4
|
-
import { buildVisibilityTree } from "../Utilities/VisibilityTree";
|
5
|
-
|
1
|
+
import React, { useEffect, useRef } from "react";
|
6
2
|
import Card from "../../pb_card/_card";
|
7
3
|
import Caption from "../../pb_caption/_caption";
|
8
4
|
import Flex from "../../pb_flex/_flex";
|
9
5
|
import FlexItem from "../../pb_flex/_flex_item";
|
10
|
-
import
|
11
|
-
import DropdownContainer from "../../pb_dropdown/subcomponents/DropdownContainer";
|
12
|
-
import DropdownTrigger from "../../pb_dropdown/subcomponents/DropdownTrigger";
|
13
|
-
import Icon from "../../pb_icon/_icon";
|
14
|
-
import Checkbox from "../../pb_checkbox/_checkbox";
|
15
|
-
import SectionSeparator from "../../pb_section_separator/_section_separator";
|
16
|
-
import Tooltip from "../../pb_tooltip/_tooltip";
|
17
|
-
|
18
|
-
import {
|
19
|
-
showActionBar,
|
20
|
-
hideActionBar,
|
21
|
-
} from "../Utilities/ActionBarAnimationHelper";
|
22
|
-
import { GenericObject } from "../../types";
|
6
|
+
import { showActionBar, hideActionBar } from "../Utilities/ActionBarAnimationHelper";
|
23
7
|
|
24
8
|
interface TableActionBarProps {
|
25
|
-
isVisible: boolean
|
9
|
+
isVisible: boolean;
|
26
10
|
selectedCount: number;
|
27
11
|
actions?: React.ReactNode[] | React.ReactNode;
|
28
|
-
type?: string;
|
29
|
-
}
|
30
|
-
|
31
|
-
interface VisibilityNode {
|
32
|
-
id?: string | undefined;
|
33
|
-
label?: string | undefined;
|
34
|
-
children?: VisibilityNode[];
|
35
12
|
}
|
36
13
|
|
37
14
|
const TableActionBar: React.FC<TableActionBarProps> = ({
|
38
15
|
isVisible,
|
39
16
|
selectedCount,
|
40
|
-
actions
|
41
|
-
type = "row-selection",
|
17
|
+
actions
|
42
18
|
}) => {
|
43
19
|
const cardRef = useRef(null);
|
44
|
-
const { table, columnVisibilityControl, columnDefinitions } =
|
45
|
-
useContext(AdvancedTableContext);
|
46
|
-
|
47
|
-
// ----------- Column visibility logic -----------
|
48
|
-
const includeIds = columnVisibilityControl?.includeIds;
|
49
|
-
const firstLeafId = table.getAllLeafColumns()[0]?.id;
|
50
|
-
// Get the first leaf column ID to exclude it from the visibility tree
|
51
|
-
// This is to avoid showing the first column in the dropdown
|
52
|
-
// as toggling it's visibility breaks the expanded row functionality
|
53
|
-
const tree = buildVisibilityTree(columnDefinitions, includeIds).filter(node => node.id !== firstLeafId);
|
54
|
-
|
55
|
-
const renderLeaf = (id: string, label: string) => {
|
56
|
-
const col = table.getColumn(id);
|
57
|
-
const show = col.getIsVisible();
|
58
|
-
|
59
|
-
return (
|
60
|
-
<Checkbox
|
61
|
-
checked={show}
|
62
|
-
key={id}
|
63
|
-
onChange={() => col.toggleVisibility()}
|
64
|
-
paddingBottom="xs"
|
65
|
-
text={label}
|
66
|
-
/>
|
67
|
-
);
|
68
|
-
};
|
69
|
-
|
70
|
-
const gatherLeafIds = (node: VisibilityNode): string[] =>
|
71
|
-
node.children && node.children.length
|
72
|
-
? node.children.flatMap(gatherLeafIds)
|
73
|
-
: node.id
|
74
|
-
? [node.id]
|
75
|
-
: [];
|
76
|
-
|
77
|
-
const renderGroup = (node: VisibilityNode ) => {
|
78
|
-
const leaves = gatherLeafIds(node);
|
79
|
-
const visibleArray = leaves.map((id) => table.getColumn(id).getIsVisible());
|
80
|
-
const allOn = visibleArray.every(Boolean);
|
81
|
-
const someOn = visibleArray.some(Boolean);
|
82
|
-
|
83
|
-
return (
|
84
|
-
<>
|
85
|
-
<Checkbox
|
86
|
-
checked={allOn}
|
87
|
-
indeterminate={!allOn && someOn}
|
88
|
-
onChange={() =>
|
89
|
-
leaves.forEach((id) =>
|
90
|
-
table.getColumn(id).toggleVisibility(!allOn),
|
91
|
-
)
|
92
|
-
}
|
93
|
-
paddingBottom="xs"
|
94
|
-
text={node.label}
|
95
|
-
/>
|
96
|
-
<Flex flexDirection="column"
|
97
|
-
paddingLeft="lg"
|
98
|
-
>
|
99
|
-
{node?.children?.map((child) =>
|
100
|
-
child.children ? renderGroup(child) : renderLeaf(child.id, child.label),
|
101
|
-
)}
|
102
|
-
</Flex>
|
103
|
-
</>
|
104
|
-
);
|
105
|
-
};
|
106
|
-
// ------------ End of column visibility logic --------
|
107
20
|
|
108
21
|
useEffect(() => {
|
109
|
-
if (cardRef.current
|
22
|
+
if (cardRef.current) {
|
110
23
|
if (isVisible) {
|
111
24
|
showActionBar(cardRef.current);
|
112
25
|
} else {
|
@@ -118,68 +31,22 @@ const TableActionBar: React.FC<TableActionBarProps> = ({
|
|
118
31
|
return (
|
119
32
|
<Card
|
120
33
|
borderNone={!isVisible}
|
121
|
-
className={`${
|
122
|
-
isVisible && "show-action-card row-selection-actions-card"
|
123
|
-
}`}
|
34
|
+
className={`${isVisible && "show-action-card row-selection-actions-card"}`}
|
124
35
|
htmlOptions={{ ref: cardRef as any }}
|
125
36
|
padding={`${isVisible ? "xs" : "none"}`}
|
126
37
|
>
|
127
38
|
<Flex
|
128
39
|
alignItems="center"
|
129
|
-
justify=
|
40
|
+
justify="between"
|
130
41
|
>
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
<FlexItem>{actions}</FlexItem>
|
140
|
-
</>
|
141
|
-
) : (
|
142
|
-
<Dropdown
|
143
|
-
className="column-visibility-dropdown-wrapper"
|
144
|
-
options={columnDefinitions}
|
145
|
-
>
|
146
|
-
<DropdownTrigger>
|
147
|
-
<Tooltip
|
148
|
-
placement='top'
|
149
|
-
text="Column Configuration"
|
150
|
-
zIndex={10}
|
151
|
-
>
|
152
|
-
<Icon
|
153
|
-
color="primary"
|
154
|
-
cursor="pointer"
|
155
|
-
icon="sliders-h"
|
156
|
-
/>
|
157
|
-
</Tooltip>
|
158
|
-
</DropdownTrigger>
|
159
|
-
<DropdownContainer
|
160
|
-
className="column-visibility-dropdown"
|
161
|
-
paddingTop="sm"
|
162
|
-
>
|
163
|
-
<>
|
164
|
-
<Caption
|
165
|
-
paddingBottom="sm"
|
166
|
-
text="Columns Config"
|
167
|
-
textAlign="center"
|
168
|
-
/>
|
169
|
-
<SectionSeparator paddingBottom="xs" />
|
170
|
-
{tree.map((node: VisibilityNode) => (
|
171
|
-
<Flex cursor="pointer"
|
172
|
-
flexDirection="column"
|
173
|
-
key={node.id}
|
174
|
-
paddingX="xs"
|
175
|
-
>
|
176
|
-
{node.children ? renderGroup(node) : renderLeaf(node.id, node.label)}
|
177
|
-
</Flex>
|
178
|
-
))}
|
179
|
-
</>
|
180
|
-
</DropdownContainer>
|
181
|
-
</Dropdown>
|
182
|
-
)}
|
42
|
+
<Caption
|
43
|
+
color="light"
|
44
|
+
paddingLeft="xs"
|
45
|
+
size="xs"
|
46
|
+
>
|
47
|
+
{selectedCount} Selected
|
48
|
+
</Caption>
|
49
|
+
<FlexItem>{actions}</FlexItem>
|
183
50
|
</Flex>
|
184
51
|
</Card>
|
185
52
|
);
|
@@ -79,26 +79,9 @@ export const TableHeaderCell = ({
|
|
79
79
|
header?.column.getLeafColumns().length === 1 &&
|
80
80
|
header?.column.getLeafColumns()[0].id === header.column.id
|
81
81
|
|
82
|
-
const
|
83
|
-
|
84
|
-
(
|
85
|
-
col.columns.some((child: any) => columnHasVisibleLeaf(child)));
|
86
|
-
|
87
|
-
// Check on column position in stack + visibility to add the vertical border
|
88
|
-
const isLastHeaderCell = (() => {
|
89
|
-
if (!header) return false;
|
90
|
-
|
91
|
-
if (header.colSpan > 1 && header.column.parent !== undefined) return true;
|
92
|
-
|
93
|
-
const parent = header.column.parent;
|
94
|
-
|
95
|
-
if (!parent) {
|
96
|
-
const topHeaders = table?.getHeaderGroups()[0].headers.filter((h: any) => columnHasVisibleLeaf(h.column));
|
97
|
-
return topHeaders?.at(-1)?.id === header.id;
|
98
|
-
}
|
99
|
-
const visibleSiblings = parent.columns.filter(columnHasVisibleLeaf);
|
100
|
-
return visibleSiblings.at(-1) === header.column;
|
101
|
-
})();
|
82
|
+
const isLastHeaderCell =
|
83
|
+
header?.column.parent?.columns.at(-1) === header?.column ||
|
84
|
+
(header?.colSpan > 1 && header?.column.parent !== undefined);
|
102
85
|
|
103
86
|
const cellClassName = classnames(
|
104
87
|
"table-header-cells",
|
@@ -26,8 +26,6 @@ interface UseTableStateProps {
|
|
26
26
|
virtualizedRows?: boolean;
|
27
27
|
tableOptions?: GenericObject;
|
28
28
|
onRowSelectionChange?: (arg: RowSelectionState) => void;
|
29
|
-
columnVisibilityControl?: GenericObject;
|
30
|
-
|
31
29
|
}
|
32
30
|
|
33
31
|
export function useTableState({
|
@@ -42,19 +40,16 @@ export function useTableState({
|
|
42
40
|
pagination = false,
|
43
41
|
paginationProps,
|
44
42
|
virtualizedRows = false,
|
45
|
-
tableOptions
|
46
|
-
columnVisibilityControl
|
43
|
+
tableOptions
|
47
44
|
}: UseTableStateProps) {
|
48
45
|
// Create a local state for expanded and setExpanded if expandedControl not used
|
49
46
|
const [localExpanded, setLocalExpanded] = useState({});
|
50
47
|
const [loadingStateRowCount, setLoadingStateRowCount] = useState(initialLoadingRowsCount);
|
51
48
|
const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
|
52
|
-
|
49
|
+
|
53
50
|
// Determine whether to use the prop or the local state
|
54
51
|
const expanded = expandedControl ? expandedControl.value : localExpanded;
|
55
52
|
const setExpanded = expandedControl ? expandedControl.onChange : setLocalExpanded;
|
56
|
-
const columnVisibility = (columnVisibilityControl && columnVisibilityControl.value) ? columnVisibilityControl.value : localColumnVisibility;
|
57
|
-
const setColumnVisibility = (columnVisibilityControl && columnVisibilityControl.onChange) ? columnVisibilityControl.onChange : setLocalColumnVisibility;
|
58
53
|
|
59
54
|
// Virtualized data handling (chunked loading)
|
60
55
|
const fetchSize = 20; // Number of rows per "page"
|
@@ -109,21 +104,17 @@ export function useTableState({
|
|
109
104
|
}]), [columnDefinitions, sortControl]);
|
110
105
|
|
111
106
|
// Custom state based on features enabled
|
112
|
-
const customState = useCallback(() =>
|
113
|
-
|
114
|
-
expanded,
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
selectableRows,
|
124
|
-
rowSelection,
|
125
|
-
columnVisibility,
|
126
|
-
]);
|
107
|
+
const customState = useCallback(() => {
|
108
|
+
if (sortControl && selectableRows) {
|
109
|
+
return { state: { expanded, sorting, rowSelection } };
|
110
|
+
} else if (sortControl) {
|
111
|
+
return { state: { expanded, sorting } };
|
112
|
+
} else if (selectableRows) {
|
113
|
+
return { state: { expanded, rowSelection } };
|
114
|
+
} else {
|
115
|
+
return { state: { expanded } };
|
116
|
+
}
|
117
|
+
}, [expanded, rowSelection, sortControl, selectableRows, sorting]);
|
127
118
|
|
128
119
|
// Pagination configuration
|
129
120
|
const paginationInitializer = useMemo(() => {
|
@@ -154,7 +145,6 @@ export function useTableState({
|
|
154
145
|
sortDescFirst: true,
|
155
146
|
onRowSelectionChange: setRowSelection,
|
156
147
|
getRowId: selectableRows ? row => row.id : undefined,
|
157
|
-
onColumnVisibilityChange: setColumnVisibility,
|
158
148
|
meta: {
|
159
149
|
columnDefinitions
|
160
150
|
},
|
@@ -53,15 +53,6 @@
|
|
53
53
|
width: 100%;
|
54
54
|
}
|
55
55
|
|
56
|
-
.column-visibility-dropdown-wrapper {
|
57
|
-
position: unset !important;
|
58
|
-
}
|
59
|
-
.column-visibility-dropdown {
|
60
|
-
width: unset !important;
|
61
|
-
right: $space_xxs;
|
62
|
-
text-align: left;
|
63
|
-
}
|
64
|
-
|
65
56
|
// Virtualized table styles
|
66
57
|
.virtualized-table-row {
|
67
58
|
display: table !important;
|
@@ -35,7 +35,6 @@ type AdvancedTableProps = {
|
|
35
35
|
className?: string
|
36
36
|
columnDefinitions: GenericObject[]
|
37
37
|
columnGroupBorderColor?: "text_lt_default" | "text_lt_light" | "text_lt_lighter" | "text_dk_default" | "text_dk_light" | "text_dk_lighter"
|
38
|
-
columnVisibilityControl?: GenericObject
|
39
38
|
dark?: boolean
|
40
39
|
data?: { [key: string]: string }
|
41
40
|
enableToggleExpansion?: "all" | "header" | "none"
|
@@ -74,7 +73,6 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
74
73
|
className,
|
75
74
|
columnDefinitions,
|
76
75
|
columnGroupBorderColor,
|
77
|
-
columnVisibilityControl,
|
78
76
|
dark = false,
|
79
77
|
data = {},
|
80
78
|
enableToggleExpansion = "header",
|
@@ -134,8 +132,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
134
132
|
paginationProps,
|
135
133
|
virtualizedRows,
|
136
134
|
tableOptions,
|
137
|
-
onRowSelectionChange
|
138
|
-
columnVisibilityControl,
|
135
|
+
onRowSelectionChange
|
139
136
|
});
|
140
137
|
|
141
138
|
// Initialize table actions
|
@@ -255,7 +252,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
255
252
|
: {};
|
256
253
|
|
257
254
|
// Visibility flag for action bar
|
258
|
-
const isActionBarVisible =
|
255
|
+
const isActionBarVisible = selectableRows && showActionsBar && selectedRowsLength > 0;
|
259
256
|
|
260
257
|
return (
|
261
258
|
<>
|
@@ -289,7 +286,6 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
289
286
|
<AdvancedTableProvider
|
290
287
|
columnDefinitions={columnDefinitions}
|
291
288
|
columnGroupBorderColor={columnGroupBorderColor}
|
292
|
-
columnVisibilityControl={columnVisibilityControl}
|
293
289
|
enableToggleExpansion={enableToggleExpansion}
|
294
290
|
enableVirtualization={virtualizedRows}
|
295
291
|
expandByDepth={expandByDepth}
|
@@ -320,7 +316,6 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
320
316
|
actions={actions}
|
321
317
|
isVisible={isActionBarVisible}
|
322
318
|
selectedCount={selectedRowsLength}
|
323
|
-
type={columnVisibilityControl ? "column-visibility" : "row-selection"}
|
324
319
|
/>
|
325
320
|
|
326
321
|
{/* Main Table */}
|
@@ -47,7 +47,3 @@ examples:
|
|
47
47
|
- advanced_table_selectable_rows_header: Selectable Rows (No Actions Bar)
|
48
48
|
- advanced_table_inline_editing: Inline Cell Editing
|
49
49
|
- advanced_table_fullscreen: Fullscreen
|
50
|
-
- advanced_table_column_visibility: Column Visibility Control
|
51
|
-
- advanced_table_column_visibility_with_state: Column Visibility Control With State
|
52
|
-
- advanced_table_column_visibility_custom: Column Visibility Control with Custom Dropdown
|
53
|
-
- advanced_table_column_visibility_multi: Column Visibility Control with Multi-Header Columns
|
@@ -27,8 +27,4 @@ export { default as AdvancedTableStickyColumns } from './_advanced_table_sticky_
|
|
27
27
|
export { default as AdvancedTableStickyHeader } from './_advanced_table_sticky_header.jsx'
|
28
28
|
export { default as AdvancedTableStickyColumnsAndHeader } from './_advanced_table_sticky_columns_and_header.jsx'
|
29
29
|
export { default as AdvancedTableExpandByDepth } from './_advanced_table_expand_by_depth.jsx'
|
30
|
-
export { default as AdvancedTableColumnBorderColor} from './_advanced_table_column_border_color.jsx'
|
31
|
-
export { default as AdvancedTableColumnVisibility } from './_advanced_table_column_visibility.jsx'
|
32
|
-
export { default as AdvancedTableColumnVisibilityCustom } from './_advanced_table_column_visibility_custom.jsx'
|
33
|
-
export { default as AdvancedTableColumnVisibilityMulti } from './_advanced_table_column_visibility_multi.jsx'
|
34
|
-
export { default as AdvancedTableColumnVisibilityWithState } from './_advanced_table_column_visibility_with_state.jsx'
|
30
|
+
export { default as AdvancedTableColumnBorderColor} from './_advanced_table_column_border_color.jsx'
|
@@ -6,6 +6,7 @@ import Flex from '../../pb_flex/_flex'
|
|
6
6
|
import FlexItem from '../../pb_flex/_flex_item'
|
7
7
|
import Avatar from '../../pb_avatar/_avatar'
|
8
8
|
import User from '../../pb_user/_user'
|
9
|
+
import Body from '../../pb_body/_body'
|
9
10
|
|
10
11
|
const DropdownWithCustomDisplay = (props) => {
|
11
12
|
const [selectedOption, setSelectedOption] = useState();
|
@@ -50,10 +51,20 @@ const DropdownWithCustomDisplay = (props) => {
|
|
50
51
|
<>
|
51
52
|
{
|
52
53
|
selectedOption && (
|
54
|
+
<Flex align="center">
|
53
55
|
<Avatar
|
54
56
|
name={selectedOption.label}
|
55
57
|
size="xs"
|
56
58
|
/>
|
59
|
+
<Body
|
60
|
+
marginX="xs"
|
61
|
+
text={selectedOption.label}
|
62
|
+
/>
|
63
|
+
<Badge
|
64
|
+
text={selectedOption.status}
|
65
|
+
variant={selectedOption.status == "Offline" ? "neutral" : selectedOption.status == "Online" ? "success" : "warning"}
|
66
|
+
/>
|
67
|
+
</Flex>
|
57
68
|
)
|
58
69
|
}
|
59
70
|
</>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
Optionally utilize `customDisplay` on the `Dropdown.Trigger` subcomponent to customize its content after an option is selected.
|
1
|
+
Optionally utilize `customDisplay` on the `Dropdown.Trigger` subcomponent to customize its content after an option is selected. Pass in any combination of kits to create a custom display. When a user clicks on an option, the kits passed into `customDisplay` will display as the selected option.
|
2
2
|
|
3
3
|
The `placeholder` prop can also be used to customize the placeholder text for the default `Dropdown.Trigger`.
|
4
4
|
|
@@ -38,7 +38,11 @@
|
|
38
38
|
|
39
39
|
<%
|
40
40
|
custom_display = capture do
|
41
|
-
pb_rails("
|
41
|
+
pb_rails("flex", props: { align: "center" }) do
|
42
|
+
concat(pb_rails("avatar", props: { name: "", size: "xs", id: "dropdown-avatar" }))
|
43
|
+
concat(pb_rails("body", props: { text: "", size: "xs", margin_x: "xs", id: "dropdown-avatar-name" }))
|
44
|
+
concat(pb_rails("badge", props: { text: "", id: "dropdown-avatar-status" }))
|
45
|
+
end
|
42
46
|
end
|
43
47
|
%>
|
44
48
|
|
@@ -62,4 +66,31 @@
|
|
62
66
|
<% end %>
|
63
67
|
<% end %>
|
64
68
|
<% end %>
|
65
|
-
<% end %>
|
69
|
+
<% end %>
|
70
|
+
|
71
|
+
|
72
|
+
<script>
|
73
|
+
document.addEventListener("pb:dropdown:selected", (e) => {
|
74
|
+
const option = e.detail;
|
75
|
+
const dropdown = e.target;
|
76
|
+
|
77
|
+
const display = dropdown.querySelector("#dropdown_trigger_custom_display");
|
78
|
+
if (!display) return;
|
79
|
+
|
80
|
+
const nameEl = display.querySelector("#dropdown-avatar-name");
|
81
|
+
if (nameEl) nameEl.textContent = option.label;
|
82
|
+
|
83
|
+
const avatarEl = display.querySelector("#dropdown-avatar").querySelector(".avatar_wrapper");
|
84
|
+
const initials = (option.label[0] + option.label.split(" ").pop()[0]).toUpperCase();
|
85
|
+
if (avatarEl) {
|
86
|
+
avatarEl.dataset.name = option.label;
|
87
|
+
avatarEl.setAttribute("data-initials", initials);
|
88
|
+
}
|
89
|
+
const badgeEl = display.querySelector("#dropdown-avatar-status");
|
90
|
+
const variant = option.status === "Online" ? "success" : option.status === "Offline" ? "neutral" : "warning";
|
91
|
+
if (badgeEl) {
|
92
|
+
badgeEl.querySelector("span").textContent = option.status;
|
93
|
+
badgeEl.className = 'pb_badge_kit_' + variant;
|
94
|
+
}
|
95
|
+
});
|
96
|
+
</script>
|
@@ -1,4 +1,6 @@
|
|
1
|
-
Optionally utilize `custom_display` on the `dropdown/dropdown_trigger` subcomponent to customize its content after an option is selected.
|
1
|
+
Optionally utilize `custom_display` on the `dropdown/dropdown_trigger` subcomponent to customize its content after an option is selected. Pass in any combination of kits to create a custom display. When a user clicks on an option, the kits passed into `custom_display` will display as the selected option.
|
2
|
+
|
3
|
+
Make use of a script to help set the custom_display with the correct value. By using the pb:dropdown:selected event listener, you can target the kits with a querySelector and update them dynamically with the values needed to match the selected option. Make sure to add an ID to the kits being passed in.
|
2
4
|
|
3
5
|
The `placeholder` prop can also be used to customize the placeholder text for the default `dropdown/dropdown_trigger`.
|
4
6
|
|
@@ -142,9 +142,22 @@ export default class PbDropdown extends PbEnhancedElement {
|
|
142
142
|
const customDisplayElement = this.element.querySelector(
|
143
143
|
"#dropdown_trigger_custom_display"
|
144
144
|
);
|
145
|
+
|
145
146
|
if (triggerElement) {
|
146
147
|
const selectedLabel = JSON.parse(value).label;
|
147
|
-
|
148
|
+
if (customDisplayElement) {
|
149
|
+
triggerElement.textContent = ""
|
150
|
+
this.element.setAttribute("data-option-selected", value);
|
151
|
+
const selectedObj = JSON.parse(value);
|
152
|
+
this.element.dispatchEvent(
|
153
|
+
new CustomEvent("pb:dropdown:selected", {
|
154
|
+
detail: selectedObj,
|
155
|
+
bubbles: true,
|
156
|
+
})
|
157
|
+
);
|
158
|
+
} else {
|
159
|
+
triggerElement.textContent = selectedLabel
|
160
|
+
}
|
148
161
|
if (customDisplayElement) {
|
149
162
|
customDisplayElement.style.display = "block";
|
150
163
|
customDisplayElement.style.paddingRight = "8px";
|
@@ -6,7 +6,7 @@ import {
|
|
6
6
|
buildDataProps,
|
7
7
|
buildHtmlProps
|
8
8
|
} from "../../utilities/props";
|
9
|
-
import { globalProps
|
9
|
+
import { globalProps } from "../../utilities/globalProps";
|
10
10
|
|
11
11
|
import DropdownContext from "../context";
|
12
12
|
|
@@ -24,7 +24,7 @@ type DropdownContainerProps = {
|
|
24
24
|
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
25
25
|
id?: string;
|
26
26
|
searchbar?: boolean;
|
27
|
-
}
|
27
|
+
};
|
28
28
|
|
29
29
|
const DropdownContainer = (props: DropdownContainerProps) => {
|
30
30
|
const {
|
@@ -2,7 +2,7 @@ import React from 'react'
|
|
2
2
|
import classnames from 'classnames'
|
3
3
|
|
4
4
|
import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../utilities/props'
|
5
|
-
import { globalProps, globalInlineProps
|
5
|
+
import { globalProps, globalInlineProps } from '../utilities/globalProps'
|
6
6
|
|
7
7
|
import Caption from '../pb_caption/_caption'
|
8
8
|
|
@@ -19,7 +19,7 @@ type SectionSeparatorProps = {
|
|
19
19
|
orientation?: "horizontal" | "vertical",
|
20
20
|
text?: string,
|
21
21
|
variant?: "card" | "background",
|
22
|
-
}
|
22
|
+
}
|
23
23
|
|
24
24
|
const SectionSeparator = (props: SectionSeparatorProps): React.ReactElement => {
|
25
25
|
const {
|