playbook_ui 16.3.0 → 16.4.0.pre.rc.0

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.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/Components/CustomCell.tsx +17 -4
  3. data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +3 -1
  4. data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableActions.ts +21 -9
  5. data/app/pb_kits/playbook/pb_advanced_table/Utilities/ExpansionControlHelpers.tsx +25 -1
  6. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +5 -1
  7. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +74 -1
  8. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_cascade_collapse.jsx +50 -0
  9. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_cascade_collapse.md +1 -0
  10. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +1 -0
  11. data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +2 -1
  12. data/app/pb_kits/playbook/pb_table/_table.tsx +24 -21
  13. data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_with_card_title_props.jsx +152 -0
  14. data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_with_card_title_props.md +17 -0
  15. data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_with_card_title_props_rails.html.erb +121 -0
  16. data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_with_card_title_props_rails.md +17 -0
  17. data/app/pb_kits/playbook/pb_table/docs/example.yml +2 -0
  18. data/app/pb_kits/playbook/pb_table/docs/index.js +1 -0
  19. data/app/pb_kits/playbook/pb_table/table.html.erb +12 -11
  20. data/app/pb_kits/playbook/pb_table/table.rb +4 -0
  21. data/app/pb_kits/playbook/pb_table/table.test.js +33 -0
  22. data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +105 -3
  23. data/dist/chunks/{_pb_line_graph-CKBPxTmM.js → _pb_line_graph-BGY7jEks.js} +1 -1
  24. data/dist/chunks/_typeahead-tG1K5JPP.js +1 -0
  25. data/dist/chunks/componentRegistry-DRSp5D_e.js +1 -0
  26. data/dist/chunks/{globalProps-DLCfJwiU.js → globalProps-CK2YuA9O.js} +1 -1
  27. data/dist/chunks/{lib-QT_7rPYf.js → lib-DspaUdlc.js} +2 -2
  28. data/dist/chunks/vendor.js +4 -4
  29. data/dist/menu.yml +1 -1
  30. data/dist/playbook-rails-react-bindings.js +1 -1
  31. data/dist/playbook-rails.js +1 -1
  32. data/lib/playbook/pb_forms_helper.rb +3 -0
  33. data/lib/playbook/version.rb +2 -2
  34. metadata +13 -7
  35. data/dist/chunks/_typeahead-B7bktFm6.js +0 -1
  36. data/dist/chunks/componentRegistry-DzmmLR2x.js +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6ab403f777f646b3d7d608303239044ad0a7740e582035beccb22ddff5a24ce1
4
- data.tar.gz: d4dc694b6f85c099e9b6f53d512e8fa0adc96a428a9c0d5699745594c6cd2d93
3
+ metadata.gz: 0f7d056170ce6b317f95c9d7ad73a63c8f7f3210c6cd02d17414534b2bff7c80
4
+ data.tar.gz: f2cb5edafbb6d1fb4ffacc6985d1422f5e3ce14930195b01dc9e08b8e41dd691
5
5
  SHA512:
6
- metadata.gz: ccb47fdb993c29446e42924ae80737f6f33d20ee3b9f6fb5ffe35fbfd97431edbb1743e958b418021030ec02f116eaf7de26675bf3d792e08ec4c7a25ee4ba0e
7
- data.tar.gz: a85463fbd073388ae9218fa64b56fa72b857883a1bf635154a5ba168cccbaea2d45e8f626b463d53042fded52f26556f87da8429f9b3e8ad742dac50324b7b9f
6
+ metadata.gz: 802232b2891b04f6890eec0e1810274a5faab50b2bba3067ccb7bc393226e70239733f941db20c0deba832bddc8591aad4782c66367389c823a7347eb1399169
7
+ data.tar.gz: 60a018fbfc411d74df9c01f63d419a2950069cd9cf21b90a1655baa7dcbc6690f22a67755120640e6215af7f7665dea8709bd866e58e5e3d4075cfc53d401c23
@@ -11,6 +11,7 @@ import Icon from "../../pb_icon/_icon"
11
11
  import Checkbox from "../../pb_checkbox/_checkbox"
12
12
 
13
13
  import AdvancedTableContext from "../Context/AdvancedTableContext"
14
+ import { getDescendantRowIds } from "../Utilities/ExpansionControlHelpers"
14
15
 
15
16
  interface CustomCellProps {
16
17
  getValue?: Getter<string>
@@ -31,13 +32,25 @@ export const CustomCell = ({
31
32
  selectableRows,
32
33
  customStyle = {},
33
34
  }: CustomCellProps & GlobalProps) => {
34
- const { setExpanded, expanded, expandedControl, inlineRowLoading, hasAnySubRows } = useContext(AdvancedTableContext);
35
+ const { setExpanded, expanded, expandedControl, inlineRowLoading, hasAnySubRows, cascadeCollapse } = useContext(AdvancedTableContext);
35
36
 
36
37
  const handleOnExpand = (row: Row<GenericObject>) => {
37
38
  onRowToggleClick && onRowToggleClick(row);
38
-
39
- if (!expandedControl) {
40
- setExpanded({ ...expanded, [row.id]: !row.getIsExpanded() });
39
+
40
+ const willBeExpanded = !row.getIsExpanded();
41
+ if (willBeExpanded) {
42
+ if (!expandedControl) {
43
+ setExpanded({ ...expanded, [row.id]: true });
44
+ }
45
+ } else {
46
+ if (cascadeCollapse) {
47
+ const idsToRemove = new Set([row.id, ...getDescendantRowIds(row)]);
48
+ const nextExpanded = { ...expanded };
49
+ idsToRemove.forEach((id) => delete nextExpanded[id]);
50
+ setExpanded(nextExpanded);
51
+ } else if (!expandedControl) {
52
+ setExpanded({ ...expanded, [row.id]: false });
53
+ }
41
54
  }
42
55
  };
43
56
 
@@ -63,6 +63,7 @@ export const TableHeaderCell = ({
63
63
  stickyLeftColumn,
64
64
  inlineRowLoading,
65
65
  isActionBarVisible,
66
+ cascadeCollapse,
66
67
  } = useContext(AdvancedTableContext);
67
68
 
68
69
  type justifyTypes = "none" | "center" | "start" | "end" | "between" | "around" | "evenly"
@@ -182,7 +183,8 @@ const isToggleExpansionEnabled =
182
183
  table.getRowModel(),
183
184
  expanded,
184
185
  undefined,
185
- depth
186
+ depth,
187
+ cascadeCollapse
186
188
  )
187
189
  setExpanded(updated)
188
190
  }
@@ -12,6 +12,7 @@ interface UseTableActionsProps {
12
12
  inlineRowLoading?: boolean;
13
13
  localPagination?: { pageIndex: number; pageSize: number };
14
14
  setLocalPagination?: (pagination: { pageIndex: number; pageSize: number }) => void;
15
+ cascadeCollapse?: boolean;
15
16
  }
16
17
 
17
18
  export function useTableActions({
@@ -22,7 +23,8 @@ export function useTableActions({
22
23
  onRowSelectionChange,
23
24
  inlineRowLoading = false,
24
25
  localPagination,
25
- setLocalPagination
26
+ setLocalPagination,
27
+ cascadeCollapse = false
26
28
  }: UseTableActionsProps) {
27
29
 
28
30
  // State to achieve 1 second delay before fetching more rows
@@ -32,15 +34,25 @@ export function useTableActions({
32
34
  // Handle expand/collapse
33
35
  const handleExpandOrCollapse = useCallback(async (row: Row<GenericObject>) => {
34
36
  if (onToggleExpansionClick) onToggleExpansionClick(row)
35
- const updatedExpandedState = await updateExpandAndCollapseState(
36
- table.getRowModel(),
37
- expanded,
38
- row?.parentId,
39
- undefined
40
- )
41
37
 
42
- setExpanded(updatedExpandedState)
43
- }, [expanded, setExpanded, onToggleExpansionClick, table]);
38
+ const anyTopLevelExpanded = table.getRowModel().rows.some((r: Row<GenericObject>) => r.getIsExpanded())
39
+ const isHeaderCollapseAll = row == null && anyTopLevelExpanded
40
+
41
+ if (cascadeCollapse && isHeaderCollapseAll) {
42
+ setExpanded({})
43
+ return
44
+ }
45
+
46
+ const updatedExpandedState = await updateExpandAndCollapseState(
47
+ table.getRowModel(),
48
+ expanded,
49
+ row?.parentId,
50
+ undefined,
51
+ cascadeCollapse
52
+ )
53
+
54
+ setExpanded(updatedExpandedState)
55
+ }, [expanded, setExpanded, onToggleExpansionClick, table, cascadeCollapse]);
44
56
 
45
57
  // Handle pagination
46
58
  const onPageChange = useCallback((page: number) => {
@@ -11,11 +11,21 @@ const filterExpandableRows = (expandedState: Record<string, boolean>) => {
11
11
  return expandedState
12
12
  }
13
13
 
14
+ export const getDescendantRowIds = (row: Row<GenericObject>): string[] => {
15
+ const ids: string[] = []
16
+ for (const sub of row.subRows || []) {
17
+ ids.push(sub.id)
18
+ ids.push(...getDescendantRowIds(sub))
19
+ }
20
+ return ids
21
+ }
22
+
14
23
  export const updateExpandAndCollapseState = (
15
24
  tableRows: RowModel<GenericObject>,
16
25
  expanded: Record<string, boolean>,
17
26
  targetParent?: string,
18
27
  targetDepth?: number,
28
+ cascadeCollapse?: boolean,
19
29
  ) => {
20
30
  const updateExpandedRows: Record<string, boolean> = {};
21
31
  const rows = targetDepth !== undefined ? tableRows.flatRows : tableRows.rows;
@@ -51,8 +61,22 @@ export const updateExpandAndCollapseState = (
51
61
  }
52
62
  }
53
63
 
54
- return filterExpandableRows({
64
+ const updatedExpandedState = filterExpandableRows({
55
65
  ...(expanded as ExpandedStateObject),
56
66
  ...updateExpandedRows,
57
67
  });
68
+
69
+ if (cascadeCollapse && !isExpandAction) {
70
+ const idsToRemove = new Set<string>();
71
+ for (const row of rowsToToggle) {
72
+ const shouldUpdate =
73
+ targetDepth === undefined ? true : row.depth === targetDepth;
74
+ if (shouldUpdate) {
75
+ getDescendantRowIds(row).forEach((id) => idsToRemove.add(id));
76
+ }
77
+ }
78
+ idsToRemove.forEach((id) => delete updatedExpandedState[id]);
79
+ }
80
+
81
+ return updatedExpandedState;
58
82
  };
@@ -31,6 +31,7 @@ type FullscreenControls = {
31
31
  type AdvancedTableProps = {
32
32
  aria?: { [key: string]: string }
33
33
  actions?: React.ReactNode[] | React.ReactNode
34
+ cascadeCollapse?: boolean
34
35
  children?: React.ReactNode | React.ReactNode[]
35
36
  className?: string
36
37
  columnDefinitions: GenericObject[]
@@ -80,6 +81,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
80
81
  const {
81
82
  aria = {},
82
83
  actions,
84
+ cascadeCollapse = false,
83
85
  children,
84
86
  className,
85
87
  columnDefinitions,
@@ -173,7 +175,8 @@ const AdvancedTable = (props: AdvancedTableProps) => {
173
175
  onRowSelectionChange,
174
176
  inlineRowLoading,
175
177
  localPagination,
176
- setLocalPagination
178
+ setLocalPagination,
179
+ cascadeCollapse
177
180
  });
178
181
 
179
182
  // Set table row count for loading state
@@ -339,6 +342,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
339
342
  >
340
343
  {renderFullscreenHeader()}
341
344
  <AdvancedTableProvider
345
+ cascadeCollapse={cascadeCollapse}
342
346
  columnDefinitions={columnDefinitions}
343
347
  columnGroupBorderColor={columnGroupBorderColor}
344
348
  columnVisibilityControl={columnVisibilityControl}
@@ -1015,4 +1015,77 @@ test("columnStyling.headerFontColor works as excpected", () => {
1015
1015
 
1016
1016
  const firstEnrollmentHeader = screen.getAllByText("New Enrollments")[0].closest("th");
1017
1017
  expect(firstEnrollmentHeader).toHaveStyle({ color: colors.white });
1018
- });
1018
+ });
1019
+
1020
+ test("cascadeCollapse=false (default) preserves existing behavior when parent is re-expanded", () => {
1021
+ render(
1022
+ <AdvancedTable
1023
+ columnDefinitions={columnDefinitions}
1024
+ data={{ testid: testId }}
1025
+ tableData={MOCK_DATA}
1026
+ />
1027
+ )
1028
+
1029
+ const kit = screen.getByTestId(testId)
1030
+ const getParentExpandButton = () => kit.querySelector("tbody tr .gray-icon.expand-toggle-icon")
1031
+ const parentButton = getParentExpandButton()
1032
+ expect(parentButton).toBeInTheDocument()
1033
+ parentButton.click()
1034
+ let subRow = kit.querySelector(".pb-bg-row-white.depth-sub-row-1")
1035
+ expect(subRow).toBeInTheDocument()
1036
+ getParentExpandButton().click()
1037
+ subRow = kit.querySelector(".pb-bg-row-white.depth-sub-row-1")
1038
+ expect(subRow).not.toBeInTheDocument()
1039
+ getParentExpandButton().click()
1040
+ subRow = kit.querySelector(".pb-bg-row-white.depth-sub-row-1")
1041
+ expect(subRow).toBeInTheDocument()
1042
+ })
1043
+
1044
+ test("cascadeCollapse=true collapses all descendants when parent is collapsed", () => {
1045
+ render(
1046
+ <AdvancedTable
1047
+ cascadeCollapse
1048
+ columnDefinitions={columnDefinitions}
1049
+ data={{ testid: testId }}
1050
+ tableData={MOCK_DATA}
1051
+ />
1052
+ )
1053
+
1054
+ const kit = screen.getByTestId(testId)
1055
+ const getParentExpandButton = () => kit.querySelector("tbody tr .gray-icon.expand-toggle-icon")
1056
+ const parentButton = getParentExpandButton()
1057
+ expect(parentButton).toBeInTheDocument()
1058
+ parentButton.click()
1059
+ expect(kit.querySelector(".depth-sub-row-1")).toBeInTheDocument()
1060
+ getParentExpandButton().click()
1061
+ expect(kit.querySelector(".depth-sub-row-1")).not.toBeInTheDocument()
1062
+ getParentExpandButton().click()
1063
+ expect(kit.querySelector(".depth-sub-row-1")).toBeInTheDocument()
1064
+ })
1065
+
1066
+ test("cascadeCollapse=true with header toggle all: collapse all then expand all shows only direct children", async () => {
1067
+ render(
1068
+ <AdvancedTable
1069
+ cascadeCollapse
1070
+ columnDefinitions={columnDefinitions}
1071
+ data={{ testid: testId }}
1072
+ tableData={MOCK_DATA}
1073
+ />
1074
+ )
1075
+
1076
+ const kit = screen.getByTestId(testId)
1077
+ const toggleAllButton = kit.querySelector(".gray-icon.toggle-all-icon")
1078
+ expect(toggleAllButton).toBeInTheDocument()
1079
+ toggleAllButton.click()
1080
+ await waitFor(() => {
1081
+ expect(kit.querySelector(".depth-sub-row-1")).toBeInTheDocument()
1082
+ })
1083
+ toggleAllButton.click()
1084
+ await waitFor(() => {
1085
+ expect(kit.querySelector(".depth-sub-row-1")).not.toBeInTheDocument()
1086
+ })
1087
+ toggleAllButton.click()
1088
+ await waitFor(() => {
1089
+ expect(kit.querySelector(".depth-sub-row-1")).toBeInTheDocument()
1090
+ })
1091
+ })
@@ -0,0 +1,50 @@
1
+ import React from "react"
2
+ import AdvancedTable from '../../pb_advanced_table/_advanced_table'
3
+ import MOCK_DATA from "./advanced_table_mock_data.json"
4
+
5
+ const AdvancedTableCascadeCollapse = (props) => {
6
+ const columnDefinitions = [
7
+ {
8
+ accessor: "year",
9
+ label: "Year",
10
+ cellAccessors: ["quarter", "month", "day"],
11
+ },
12
+ {
13
+ accessor: "newEnrollments",
14
+ label: "New Enrollments",
15
+ },
16
+ {
17
+ accessor: "scheduledMeetings",
18
+ label: "Scheduled Meetings",
19
+ },
20
+ {
21
+ accessor: "attendanceRate",
22
+ label: "Attendance Rate",
23
+ },
24
+ {
25
+ accessor: "completedClasses",
26
+ label: "Completed Classes",
27
+ },
28
+ {
29
+ accessor: "classCompletionRate",
30
+ label: "Class Completion Rate",
31
+ },
32
+ {
33
+ accessor: "graduatedStudents",
34
+ label: "Graduated Students",
35
+ },
36
+ ]
37
+
38
+ return (
39
+ <div>
40
+ <AdvancedTable
41
+ cascadeCollapse
42
+ columnDefinitions={columnDefinitions}
43
+ tableData={MOCK_DATA}
44
+ {...props}
45
+ />
46
+ </div>
47
+ )
48
+ }
49
+
50
+ export default AdvancedTableCascadeCollapse
@@ -0,0 +1 @@
1
+ `cascadeCollapse` is an optional prop that is set to 'false' by default. If set to 'true', collapsing any parent row itself or by using the toggle exapansion buttons in any header or subheader row also collapses all descendants and clears their expansion state. Re-expanding then shows only direct children until the user expands deeper levels again.
@@ -42,6 +42,7 @@ examples:
42
42
  - advanced_table_expanded_control: Expanded Control
43
43
  - advanced_table_expand_by_depth: Expand by Depth
44
44
  - advanced_table_subrow_headers: SubRow Headers
45
+ - advanced_table_cascade_collapse: Cascade Collapse
45
46
  - advanced_table_collapsible_trail: Collapsible Trail
46
47
  - advanced_table_table_options: Table Options
47
48
  - advanced_table_table_props: Table Props
@@ -48,4 +48,5 @@ export { default as AdvancedTablePaddingControl } from './_advanced_table_paddin
48
48
  export { default as AdvancedTablePaddingControlPerRow } from './_advanced_table_padding_control_per_row.jsx'
49
49
  export { default as AdvancedTableColumnStylingBackground } from './_advanced_table_column_styling_background.jsx'
50
50
  export { default as AdvancedTableColumnStylingBackgroundMulti } from './_advanced_table_column_styling_background_multi.jsx'
51
- export { default as AdvancedTableColumnStylingBackgroundCustom } from './_advanced_table_column_styling_background_custom.jsx'
51
+ export { default as AdvancedTableColumnStylingBackgroundCustom } from './_advanced_table_column_styling_background_custom.jsx'
52
+ export { default as AdvancedTableCascadeCollapse } from './_advanced_table_cascade_collapse.jsx'
@@ -20,6 +20,7 @@ type TableProps = {
20
20
  aria?: { [key: string]: string },
21
21
  children: React.ReactNode[] | React.ReactNode,
22
22
  className: string,
23
+ cardProps?: { [key: string]: any },
23
24
  collapse?: "sm" | "md" | "lg",
24
25
  container?: boolean,
25
26
  dark?: boolean,
@@ -42,6 +43,7 @@ type TableProps = {
42
43
  striped?: boolean,
43
44
  tag?: "table" | "div",
44
45
  title?: string,
46
+ titleProps?: { [key: string]: any },
45
47
  variant?: "default" | "withFilter",
46
48
  verticalBorder?: boolean,
47
49
  } & GlobalProps
@@ -52,6 +54,8 @@ const Table = (props: TableProps): React.ReactElement => {
52
54
  const {
53
55
  aria = {},
54
56
  variant = 'default',
57
+ cardProps = {},
58
+ titleProps = {},
55
59
  children,
56
60
  className,
57
61
  collapse = variant === 'withFilter' ? 'md' : 'sm',
@@ -348,34 +352,33 @@ const Table = (props: TableProps): React.ReactElement => {
348
352
 
349
353
  // Merge default props with user-provided props (user props override defaults)
350
354
  const mergedFilterProps = { ...defaultFilterProps, ...filterProps }
355
+
356
+ // Default card props that CAN be overridden (All props from Card kit CAN be used, but these are the ones we set as defaults)
357
+ const defaultCardProps: { [key: string]: any } = {
358
+ padding: "none",
359
+ }
360
+
361
+ // Merge default props with user-provided props (user props override defaults)
362
+ const mergedCardProps = { ...defaultCardProps, ...cardProps }
363
+
364
+ // Default title props that CAN be overridden (All props from Title kit CAN be used, but these are the ones we set as defaults)
365
+ const defaultTitleProps: { [key: string]: any } = {
366
+ size: 3,
367
+ paddingY: "md",
368
+ }
369
+
370
+ // Merge default props with user-provided props (user props override defaults)
371
+ const mergedTitleProps = { ...defaultTitleProps, ...titleProps }
351
372
 
352
373
  return (
353
374
  <>
354
375
  {title && (
355
- <Title
356
- paddingLeft={{
357
- xs: "sm",
358
- sm: "sm",
359
- md: "xl",
360
- lg: "xl",
361
- xl: "xl",
362
- default: "xl",
363
- } as any}
364
- paddingY="md"
365
- size={3}
376
+ <Title {...mergedTitleProps}
366
377
  text={title}
367
- />
378
+ />
368
379
  )}
369
380
  <Card
370
- marginX={{
371
- xs: "sm",
372
- sm: "sm",
373
- md: "xl",
374
- lg: "xl",
375
- xl: "xl",
376
- default: "xl",
377
- } as any}
378
- padding="none"
381
+ {...mergedCardProps}
379
382
  >
380
383
  <Flex
381
384
  align="stretch"
@@ -0,0 +1,152 @@
1
+ import React, { useState } from "react"
2
+ import { Button, Date as DateKit, DatePicker, Dropdown, Select, Table, TextInput, Typeahead, Flex } from "playbook-ui"
3
+
4
+ // Mock Data for Table
5
+ const users = [
6
+ { id: 1, name: "Jennifer", title: "Associate Scrum Master", department: "Business Technology", branch: "Philadelphia", startDate: "2025-01-01" },
7
+ { id: 2, name: "Nick", title: "UX Engineer II", department: "Business Technology", branch: "Philadelphia", startDate: "2025-01-02" },
8
+ { id: 3, name: "Nida", title: "Senior UX Engineer", department: "Business Technology", branch: "Philadelphia", startDate: "2025-01-03" },
9
+ { id: 4, name: "Justin", title: "Director of User Experience Engineering", department: "Business Technology", branch: "Philadelphia", startDate: "2025-01-04" },
10
+ { id: 5, name: "Edward", title: "UX Designer II", department: "Business Technology", branch: "Philadelphia", startDate: "2025-01-05" },
11
+ { id: 6, name: "Elisa", title: "UX Engineer", department: "Business Technology", branch: "Philadelphia", startDate: "2025-01-06" },
12
+ { id: 7, name: "Gary", title: "UX Engineer", department: "Business Technology", branch: "Philadelphia", startDate: "2025-01-07" },
13
+ { id: 8, name: "Barkley", title: "Nitro Quality Ninja", department: "Business Technology", branch: "Philadelphia", startDate: "2025-01-08" },
14
+ { id: 9, name: "Aaron", title: "Associate Nitro Quality Ninja", department: "Business Technology", branch: "Philadelphia", startDate: "2025-01-09" },
15
+ ]
16
+
17
+ const TableWithFilterWithCardTitleProps = () => {
18
+ const [territory, setTerritory] = useState("")
19
+
20
+ // --------Filter content example ------
21
+ const filterContent = ({ closePopover }) => (
22
+ <>
23
+ <TextInput
24
+ label="Territory ID"
25
+ onChange={event => setTerritory(event.target.value)}
26
+ value={territory}
27
+ />
28
+
29
+ <Typeahead
30
+ label="Title"
31
+ options={[
32
+ { key: "senior-ux-engineer", label: "Senior UX Engineer", value: "senior-ux-engineer" },
33
+ { key: "ux-engineer", label: "UX Engineer", value: "ux-engineer" },
34
+ { key: "ux-designer", label: "UX Designer", value: "ux-designer" }
35
+ ]}
36
+ />
37
+
38
+ <Select
39
+ blankSelection="All Departments"
40
+ label="Department"
41
+ options={[
42
+ { value: "Business Technology", label: "Business Technology", key: "business-technology" },
43
+ { value: "Customer Development", label: "Customer Development", key: "customer-development" },
44
+ { value: "Talent Acquisition", label: "Talent Acquisition", key: "talent-acquisition" }
45
+ ]}
46
+ />
47
+
48
+ <Dropdown
49
+ label="Branch"
50
+ options={[
51
+ { key: "Philadelphia", label: "Philadelphia", value: "philadelphia" },
52
+ { key: "New York", label: "New York", value: "new-york" },
53
+ { key: "Austin", label: "Austin", value: "austin" }
54
+ ]}
55
+ />
56
+
57
+ <DatePicker
58
+ label="Start Date"
59
+ paddingY="sm"
60
+ pickerId="startedOn"
61
+ />
62
+ <Flex spacing="between">
63
+ <Button
64
+ onClick={() => {
65
+ alert("No filtering functionality - just a pattern demo!")
66
+ closePopover()
67
+ }}
68
+ text="Filter"
69
+ />
70
+ <Button
71
+ text="Defaults"
72
+ variant="secondary"
73
+ />
74
+ </Flex>
75
+ </>
76
+ )
77
+ // -------End Filter content example ------
78
+
79
+ return (
80
+ <Table
81
+ cardProps={{marginX: {
82
+ xs: "sm",
83
+ sm: "sm",
84
+ md: "xl",
85
+ lg: "xl",
86
+ xl: "xl",
87
+ default: "xl",
88
+ }}}
89
+ filterContent={filterContent}
90
+ filterProps={{
91
+ results: 50,
92
+ sortOptions: {
93
+ territory_id: "Territory ID",
94
+ first_name: "Name",
95
+ started_on: "Start Date",
96
+ department_name: "Department",
97
+ title_name: "Title",
98
+ branch_branch_name: "Branch",
99
+ },
100
+ sortValue: [{ name: 'started_on', dir: 'asc' }],
101
+ }}
102
+ title="Table Title Here"
103
+ titleProps={{
104
+ paddingLeft:{
105
+ xs: "sm",
106
+ sm: "sm",
107
+ md: "xl",
108
+ lg: "xl",
109
+ xl: "xl",
110
+ default: "xl",
111
+ }
112
+ }}
113
+ variant="withFilter"
114
+ >
115
+ <Table.Head>
116
+ <Table.Row>
117
+ <Table.Header>{'Territory ID'}</Table.Header>
118
+ <Table.Header>{'Name'}</Table.Header>
119
+ <Table.Header>{'Title'}</Table.Header>
120
+ <Table.Header>{'Department'}</Table.Header>
121
+ <Table.Header>{'Branch'}</Table.Header>
122
+ <Table.Header textAlign="right">{'Start Date'}</Table.Header>
123
+ </Table.Row>
124
+ </Table.Head>
125
+ <Table.Body>
126
+ {users.map((user) => (
127
+ <Table.Row key={user.id}>
128
+ <Table.Cell
129
+ marginX={{ xs: "sm" }}
130
+ numberSpacing="tabular"
131
+ >
132
+ {user.id}
133
+ </Table.Cell>
134
+ <Table.Cell marginX={{ xs: "sm" }}>{user.name}</Table.Cell>
135
+ <Table.Cell marginX={{ xs: "sm" }}>{user.title}</Table.Cell>
136
+ <Table.Cell marginX={{ xs: "sm" }}>{user.department}</Table.Cell>
137
+ <Table.Cell marginX={{ xs: "sm" }}>{user.branch}</Table.Cell>
138
+ <Table.Cell marginX={{ xs: "sm" }}>
139
+ <DateKit
140
+ alignment="right"
141
+ showCurrentYear
142
+ value={user.startDate}
143
+ />
144
+ </Table.Cell>
145
+ </Table.Row>
146
+ ))}
147
+ </Table.Body>
148
+ </Table>
149
+ )
150
+ }
151
+
152
+ export default TableWithFilterWithCardTitleProps
@@ -0,0 +1,17 @@
1
+ The `withFilter` variant also offers 2 additional optional props:
2
+
3
+ `cardProps`: An object containing Card-specific props.
4
+ `titleProps`: An object containing Title-specific props.
5
+
6
+ #### Default Card Props
7
+
8
+ The Table kit automatically sets these Card defaults (which you can override via `cardProps`):
9
+
10
+ - `padding="none"`
11
+
12
+ #### Default Title Props
13
+
14
+ The Table kit automatically sets these Title defaults (which you can override via `titleProps`):
15
+
16
+ - `size={3}`
17
+ - `paddingY="md"`