playbook_ui 15.6.0 → 15.7.0.pre.rc.1
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_card/docs/_card_header.md +1 -1
- data/app/pb_kits/playbook/pb_card/docs/_card_highlight.md +1 -1
- data/app/pb_kits/playbook/pb_collapsible/__snapshots__/collapsible.test.js.snap +2 -2
- data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleIcon.tsx +10 -8
- data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_icons.jsx +0 -1
- data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_state.jsx +0 -3
- data/app/pb_kits/playbook/pb_date_picker/date_picker.test.js +24 -0
- data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +181 -3
- data/app/pb_kits/playbook/pb_distribution_bar/docs/_distribution_bar_custom_colors.md +1 -1
- data/app/pb_kits/playbook/pb_draggable/context/index.tsx +316 -15
- data/app/pb_kits/playbook/pb_draggable/context/types.ts +1 -1
- data/app/pb_kits/playbook/pb_filter/Filter/FilterBackground.tsx +3 -3
- data/app/pb_kits/playbook/pb_radio/docs/_radio_error.md +1 -1
- data/app/pb_kits/playbook/pb_select/_select.tsx +8 -3
- data/app/pb_kits/playbook/pb_select/docs/_select_error.md +1 -1
- data/app/pb_kits/playbook/pb_select/docs/_select_input_options.html.erb +16 -0
- data/app/pb_kits/playbook/pb_select/docs/_select_input_options.jsx +30 -0
- data/app/pb_kits/playbook/pb_select/docs/_select_input_options.md +1 -0
- data/app/pb_kits/playbook/pb_select/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_select/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_select/select.html.erb +2 -2
- data/app/pb_kits/playbook/pb_select/select.rb +3 -1
- data/app/pb_kits/playbook/pb_select/select.test.js +23 -0
- data/app/pb_kits/playbook/pb_table/_table.tsx +187 -33
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant.jsx +134 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant.md +34 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_rails.html.erb +101 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_rails.md +33 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_with_pagination.jsx +180 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_with_pagination.md +3 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_with_pagination_rails.html.erb +122 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_with_pagination_rails.md +3 -0
- data/app/pb_kits/playbook/pb_table/docs/example.yml +4 -0
- data/app/pb_kits/playbook/pb_table/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_table/table.html.erb +68 -12
- data/app/pb_kits/playbook/pb_table/table.rb +22 -3
- data/app/pb_kits/playbook/pb_table/table.test.js +143 -0
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_error.md +1 -1
- data/app/pb_kits/playbook/pb_textarea/docs/_textarea_error.md +1 -1
- data/app/pb_kits/playbook/pb_timeline/_item.tsx +3 -0
- data/app/pb_kits/playbook/pb_timeline/docs/_timeline_show_current_year.html.erb +60 -0
- data/app/pb_kits/playbook/pb_timeline/docs/_timeline_show_current_year.jsx +118 -0
- data/app/pb_kits/playbook/pb_timeline/docs/_timeline_show_current_year.md +1 -0
- data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_date.md +1 -1
- data/app/pb_kits/playbook/pb_timeline/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_timeline/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_timeline/item.html.erb +1 -1
- data/app/pb_kits/playbook/pb_timeline/item.rb +2 -0
- data/app/pb_kits/playbook/pb_timeline/label.html.erb +2 -1
- data/app/pb_kits/playbook/pb_timeline/label.rb +2 -0
- data/app/pb_kits/playbook/pb_timeline/subcomponents/Label.tsx +3 -0
- data/app/pb_kits/playbook/pb_timeline/timeline.test.js +51 -0
- data/app/pb_kits/playbook/tokens/_colors.scss +2 -1
- data/app/pb_kits/playbook/utilities/deprecated.ts +73 -0
- data/dist/chunks/_typeahead-CHwm9MTE.js +6 -0
- data/dist/chunks/lib-Cugvy62C.js +29 -0
- data/dist/chunks/vendor.js +2 -2
- 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/collection_select_field.rb +9 -1
- data/lib/playbook/forms/builder/select_field.rb +9 -1
- data/lib/playbook/forms/builder/time_zone_select_field.rb +9 -1
- data/lib/playbook/pb_kit_helper.rb +35 -0
- data/lib/playbook/version.rb +2 -2
- metadata +19 -4
- data/dist/chunks/_typeahead-DecTL7bt.js +0 -6
- data/dist/chunks/lib-Dk4GKPut.js +0 -29
|
@@ -10,6 +10,11 @@ import {
|
|
|
10
10
|
TableCell,
|
|
11
11
|
} from "./subcomponents";
|
|
12
12
|
import { addDataTitle } from './utilities/addDataTitle'
|
|
13
|
+
import Card from '../pb_card/_card'
|
|
14
|
+
import Flex from '../pb_flex/_flex'
|
|
15
|
+
import Title from '../pb_title/_title'
|
|
16
|
+
import SectionSeparator from '../pb_section_separator/_section_separator'
|
|
17
|
+
import Filter from '../pb_filter/_filter'
|
|
13
18
|
|
|
14
19
|
type TableProps = {
|
|
15
20
|
aria?: { [key: string]: string },
|
|
@@ -21,10 +26,13 @@ type TableProps = {
|
|
|
21
26
|
data?: { [key: string]: string },
|
|
22
27
|
dataTable: boolean,
|
|
23
28
|
disableHover?: boolean,
|
|
29
|
+
filterProps?: { [key: string]: any },
|
|
30
|
+
filterContent?: any,
|
|
24
31
|
headerStyle?: "default" | "borderless" | "floating"
|
|
25
32
|
htmlOptions?: { [key: string]: string | number | boolean | (() => void) },
|
|
26
33
|
id?: string,
|
|
27
34
|
outerPadding?: "none" | "xxs" | "xs" | "sm" | "md" | "lg" | "xl",
|
|
35
|
+
pagination?: React.ReactElement,
|
|
28
36
|
responsive?: "collapse" | "scroll" | "none",
|
|
29
37
|
singleLine?: boolean,
|
|
30
38
|
size?: "sm" | "md" | "lg",
|
|
@@ -33,24 +41,32 @@ type TableProps = {
|
|
|
33
41
|
stickyRightColumn?: string[],
|
|
34
42
|
striped?: boolean,
|
|
35
43
|
tag?: "table" | "div",
|
|
44
|
+
title?: string,
|
|
45
|
+
variant?: "default" | "withFilter",
|
|
36
46
|
verticalBorder?: boolean,
|
|
37
47
|
} & GlobalProps
|
|
38
48
|
|
|
49
|
+
type AllSizes = "none" | "xxs" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl" | "auto" | "initial" | "inherit"
|
|
50
|
+
|
|
39
51
|
const Table = (props: TableProps): React.ReactElement => {
|
|
40
52
|
const {
|
|
41
53
|
aria = {},
|
|
54
|
+
variant = 'default',
|
|
42
55
|
children,
|
|
43
56
|
className,
|
|
44
|
-
collapse = 'sm',
|
|
57
|
+
collapse = variant === 'withFilter' ? 'md' : 'sm',
|
|
45
58
|
container = true,
|
|
46
59
|
dark,
|
|
47
60
|
data = {},
|
|
48
61
|
dataTable = false,
|
|
49
62
|
disableHover = false,
|
|
63
|
+
filterProps = {},
|
|
64
|
+
filterContent,
|
|
50
65
|
headerStyle = "default",
|
|
51
66
|
htmlOptions = {},
|
|
52
67
|
id,
|
|
53
68
|
outerPadding = '',
|
|
69
|
+
pagination,
|
|
54
70
|
responsive = 'collapse',
|
|
55
71
|
singleLine = false,
|
|
56
72
|
size = 'sm',
|
|
@@ -59,6 +75,7 @@ const Table = (props: TableProps): React.ReactElement => {
|
|
|
59
75
|
stickyRightColumn= [],
|
|
60
76
|
striped = false,
|
|
61
77
|
tag = 'table',
|
|
78
|
+
title,
|
|
62
79
|
verticalBorder = false,
|
|
63
80
|
} = props
|
|
64
81
|
|
|
@@ -73,12 +90,15 @@ const Table = (props: TableProps): React.ReactElement => {
|
|
|
73
90
|
const dynamicInlineProps = globalInlineProps(props)
|
|
74
91
|
const stickyRightColumnReversed = stickyRightColumn.reverse()
|
|
75
92
|
|
|
93
|
+
const isFilterVariant = variant === 'withFilter'
|
|
94
|
+
const effectiveContainer = isFilterVariant ? false : container
|
|
95
|
+
|
|
76
96
|
const classNames = classnames(
|
|
77
97
|
'pb_table',
|
|
78
98
|
`table-${size}`,
|
|
79
99
|
`table-responsive-${responsive}`,
|
|
80
100
|
{
|
|
81
|
-
'table-card':
|
|
101
|
+
'table-card': effectiveContainer,
|
|
82
102
|
'table-dark': dark,
|
|
83
103
|
'data_table': dataTable,
|
|
84
104
|
'single-line': singleLine,
|
|
@@ -205,36 +225,70 @@ const Table = (props: TableProps): React.ReactElement => {
|
|
|
205
225
|
addDataTitle()
|
|
206
226
|
}, [])
|
|
207
227
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
228
|
+
// ------------ Default Table (non-filter variant rendering) ------------
|
|
229
|
+
const renderTable = () => {
|
|
230
|
+
const tableElement = responsive === 'scroll' ? (
|
|
231
|
+
<div className='table-responsive-scroll'>
|
|
232
|
+
{isTableTag ? (
|
|
233
|
+
<table
|
|
234
|
+
{...ariaProps}
|
|
235
|
+
{...dataProps}
|
|
236
|
+
{...htmlProps}
|
|
237
|
+
className={classNames}
|
|
238
|
+
id={id}
|
|
239
|
+
style={dynamicInlineProps}
|
|
240
|
+
>
|
|
241
|
+
{children}
|
|
242
|
+
</table>
|
|
243
|
+
) : (
|
|
244
|
+
<div
|
|
245
|
+
{...ariaProps}
|
|
246
|
+
{...dataProps}
|
|
247
|
+
{...htmlProps}
|
|
248
|
+
className={classNames}
|
|
249
|
+
id={id}
|
|
250
|
+
style={dynamicInlineProps}
|
|
251
|
+
>
|
|
252
|
+
{children}
|
|
253
|
+
</div>
|
|
254
|
+
)}
|
|
255
|
+
</div>
|
|
256
|
+
) : (
|
|
257
|
+
isTableTag ? (
|
|
258
|
+
<table
|
|
259
|
+
{...ariaProps}
|
|
260
|
+
{...dataProps}
|
|
261
|
+
{...htmlProps}
|
|
262
|
+
className={classNames}
|
|
263
|
+
id={id}
|
|
264
|
+
style={dynamicInlineProps}
|
|
265
|
+
>
|
|
266
|
+
{children}
|
|
267
|
+
</table>
|
|
236
268
|
) : (
|
|
237
|
-
|
|
269
|
+
<div
|
|
270
|
+
{...ariaProps}
|
|
271
|
+
{...dataProps}
|
|
272
|
+
{...htmlProps}
|
|
273
|
+
className={classNames}
|
|
274
|
+
id={id}
|
|
275
|
+
style={dynamicInlineProps}
|
|
276
|
+
>
|
|
277
|
+
{children}
|
|
278
|
+
</div>
|
|
279
|
+
)
|
|
280
|
+
)
|
|
281
|
+
|
|
282
|
+
return tableElement
|
|
283
|
+
}
|
|
284
|
+
// ------------ End Default Table (non-filter variant rendering) ------------
|
|
285
|
+
|
|
286
|
+
// ------------ variant = 'withFilter' rendering ------------
|
|
287
|
+
const renderCardVariant = () => {
|
|
288
|
+
// Render table element
|
|
289
|
+
const tableElement = responsive === 'scroll' ? (
|
|
290
|
+
<div className='table-responsive-scroll'>
|
|
291
|
+
{isTableTag ? (
|
|
238
292
|
<table
|
|
239
293
|
{...ariaProps}
|
|
240
294
|
{...dataProps}
|
|
@@ -256,8 +310,108 @@ const Table = (props: TableProps): React.ReactElement => {
|
|
|
256
310
|
>
|
|
257
311
|
{children}
|
|
258
312
|
</div>
|
|
259
|
-
)
|
|
260
|
-
|
|
313
|
+
)}
|
|
314
|
+
</div>
|
|
315
|
+
) : (
|
|
316
|
+
isTableTag ? (
|
|
317
|
+
<table
|
|
318
|
+
{...ariaProps}
|
|
319
|
+
{...dataProps}
|
|
320
|
+
{...htmlProps}
|
|
321
|
+
className={classNames}
|
|
322
|
+
id={id}
|
|
323
|
+
style={dynamicInlineProps}
|
|
324
|
+
>
|
|
325
|
+
{children}
|
|
326
|
+
</table>
|
|
327
|
+
) : (
|
|
328
|
+
<div
|
|
329
|
+
{...ariaProps}
|
|
330
|
+
{...dataProps}
|
|
331
|
+
{...htmlProps}
|
|
332
|
+
className={classNames}
|
|
333
|
+
id={id}
|
|
334
|
+
style={dynamicInlineProps}
|
|
335
|
+
>
|
|
336
|
+
{children}
|
|
337
|
+
</div>
|
|
338
|
+
)
|
|
339
|
+
)
|
|
340
|
+
|
|
341
|
+
// Default filter props that CAN be overridden (All props from Filter kit CAN be used, but these are the ones we set as defaults)
|
|
342
|
+
const defaultFilterProps = {
|
|
343
|
+
background: false,
|
|
344
|
+
maxHeight: "50vh",
|
|
345
|
+
minWidth: "xs",
|
|
346
|
+
popoverProps: { width: "350px" },
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// Merge default props with user-provided props (user props override defaults)
|
|
350
|
+
const mergedFilterProps = { ...defaultFilterProps, ...filterProps }
|
|
351
|
+
|
|
352
|
+
return (
|
|
353
|
+
<>
|
|
354
|
+
{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}
|
|
366
|
+
text={title}
|
|
367
|
+
/>
|
|
368
|
+
)}
|
|
369
|
+
<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"
|
|
379
|
+
>
|
|
380
|
+
<Flex
|
|
381
|
+
align="stretch"
|
|
382
|
+
flexDirection="column"
|
|
383
|
+
gap="none"
|
|
384
|
+
>
|
|
385
|
+
{filterContent && (
|
|
386
|
+
<Filter {...mergedFilterProps}>
|
|
387
|
+
{filterContent}
|
|
388
|
+
</Filter>
|
|
389
|
+
)}
|
|
390
|
+
{filterContent && <SectionSeparator />}
|
|
391
|
+
{pagination && (
|
|
392
|
+
<>
|
|
393
|
+
{pagination}
|
|
394
|
+
<SectionSeparator />
|
|
395
|
+
</>
|
|
396
|
+
)}
|
|
397
|
+
{tableElement}
|
|
398
|
+
{pagination && (
|
|
399
|
+
<>
|
|
400
|
+
{pagination}
|
|
401
|
+
</>
|
|
402
|
+
)}
|
|
403
|
+
</Flex>
|
|
404
|
+
</Card>
|
|
405
|
+
</>
|
|
406
|
+
)
|
|
407
|
+
}
|
|
408
|
+
// ------------ End variant = 'withFilter' rendering ------------
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
return (
|
|
413
|
+
<>
|
|
414
|
+
{isFilterVariant ? renderCardVariant() : renderTable()}
|
|
261
415
|
</>
|
|
262
416
|
)
|
|
263
417
|
}
|
|
@@ -0,0 +1,134 @@
|
|
|
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 TableWithFilterVariant = () => {
|
|
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
|
+
filterContent={filterContent}
|
|
82
|
+
filterProps={{
|
|
83
|
+
results: 50,
|
|
84
|
+
sortOptions: {
|
|
85
|
+
territory_id: "Territory ID",
|
|
86
|
+
first_name: "Name",
|
|
87
|
+
started_on: "Start Date",
|
|
88
|
+
department_name: "Department",
|
|
89
|
+
title_name: "Title",
|
|
90
|
+
branch_branch_name: "Branch",
|
|
91
|
+
},
|
|
92
|
+
sortValue: [{ name: 'started_on', dir: 'asc' }],
|
|
93
|
+
}}
|
|
94
|
+
title="Table Title Here"
|
|
95
|
+
variant="withFilter"
|
|
96
|
+
>
|
|
97
|
+
<Table.Head>
|
|
98
|
+
<Table.Row>
|
|
99
|
+
<Table.Header>{'Territory ID'}</Table.Header>
|
|
100
|
+
<Table.Header>{'Name'}</Table.Header>
|
|
101
|
+
<Table.Header>{'Title'}</Table.Header>
|
|
102
|
+
<Table.Header>{'Department'}</Table.Header>
|
|
103
|
+
<Table.Header>{'Branch'}</Table.Header>
|
|
104
|
+
<Table.Header textAlign="right">{'Start Date'}</Table.Header>
|
|
105
|
+
</Table.Row>
|
|
106
|
+
</Table.Head>
|
|
107
|
+
<Table.Body>
|
|
108
|
+
{users.map((user) => (
|
|
109
|
+
<Table.Row key={user.id}>
|
|
110
|
+
<Table.Cell
|
|
111
|
+
marginX={{ xs: "sm" }}
|
|
112
|
+
numberSpacing="tabular"
|
|
113
|
+
>
|
|
114
|
+
{user.id}
|
|
115
|
+
</Table.Cell>
|
|
116
|
+
<Table.Cell marginX={{ xs: "sm" }}>{user.name}</Table.Cell>
|
|
117
|
+
<Table.Cell marginX={{ xs: "sm" }}>{user.title}</Table.Cell>
|
|
118
|
+
<Table.Cell marginX={{ xs: "sm" }}>{user.department}</Table.Cell>
|
|
119
|
+
<Table.Cell marginX={{ xs: "sm" }}>{user.branch}</Table.Cell>
|
|
120
|
+
<Table.Cell marginX={{ xs: "sm" }}>
|
|
121
|
+
<DateKit
|
|
122
|
+
alignment="right"
|
|
123
|
+
showCurrentYear
|
|
124
|
+
value={user.startDate}
|
|
125
|
+
/>
|
|
126
|
+
</Table.Cell>
|
|
127
|
+
</Table.Row>
|
|
128
|
+
))}
|
|
129
|
+
</Table.Body>
|
|
130
|
+
</Table>
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export default TableWithFilterVariant
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Set the `variant` prop to `withFilter` to render a Table with a filter. The variant automatically handles:
|
|
2
|
+
|
|
3
|
+
- Card wrapper with standard responsive margins
|
|
4
|
+
- Optional `title` prop to render title above the card
|
|
5
|
+
- Filter component rendering with Design defaults
|
|
6
|
+
- SectionSeparator between filter and table
|
|
7
|
+
- Flex layout for proper alignment
|
|
8
|
+
|
|
9
|
+
#### Required Props
|
|
10
|
+
|
|
11
|
+
- `variant="withFilter"`: Enables the filter variant
|
|
12
|
+
- `filterContent`: A function that receives `{ closePopover }` and returns the filter's body content (inputs, buttons, etc.). Use this to pass in all input kits, etc needed inside the Filter itself.
|
|
13
|
+
- `filterProps`: An object containing Filter-specific props like `results`, `sortOptions`, `sortValue`, etc.
|
|
14
|
+
|
|
15
|
+
#### Optional Props
|
|
16
|
+
|
|
17
|
+
- `title`: Displays a title above the card
|
|
18
|
+
- All standard Table props (`size`, `collapse`, etc.) can be used, but defaults are already set to match Design guidelines
|
|
19
|
+
- All standard Filter props can be used, but defaults are already set to match Design guidelines.
|
|
20
|
+
|
|
21
|
+
#### Default Filter Props
|
|
22
|
+
|
|
23
|
+
The Table kit automatically sets these Filter defaults (which you can override via `filterProps`):
|
|
24
|
+
|
|
25
|
+
- `background={false}`
|
|
26
|
+
- `maxHeight="50vh"`
|
|
27
|
+
- `minWidth="xs"`
|
|
28
|
+
- `popoverProps={{ width: "350px" }}`
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
**IMPORTANT NOTE**:
|
|
32
|
+
The purpose of this variant is to provide an easy way to set up a Table with a Filter with Design standards applied by default.
|
|
33
|
+
|
|
34
|
+
If you are looking for more customization than this embedded variant provides, you may be better served by using the individual kits as demonstrated in our Table Filter Card Building Block [here](https://playbook.powerapp.cloud/building_blocks/table_filter_card/react).
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
<% users = [
|
|
2
|
+
{ id: 1, name: "Jennifer", title: "Associate Scrum Master", department: "Business Technology", branch: "Philadelphia", start_date: Date.new(2025, 1, 1) },
|
|
3
|
+
{ id: 2, name: "Nick", title: "UX Engineer II", department: "Business Technology", branch: "Philadelphia", start_date: Date.new(2025, 1, 2) },
|
|
4
|
+
{ id: 3, name: "Nida", title: "Senior UX Engineer", department: "Business Technology", branch: "Philadelphia", start_date: Date.new(2025, 1, 3) },
|
|
5
|
+
{ id: 4, name: "Justin", title: "Director of User Experience Engineering", department: "Business Technology", branch: "Philadelphia", start_date: Date.new(2025, 1, 4) },
|
|
6
|
+
{ id: 5, name: "Edward", title: "UX Designer II", department: "Business Technology", branch: "Philadelphia", start_date: Date.new(2025, 1, 5) },
|
|
7
|
+
{ id: 6, name: "Elisa", title: "UX Engineer", department: "Business Technology", branch: "Philadelphia", start_date: Date.new(2025, 1, 6) },
|
|
8
|
+
{ id: 7, name: "Gary", title: "UX Engineer", department: "Business Technology", branch: "Philadelphia", start_date: Date.new(2025, 1, 7) },
|
|
9
|
+
{ id: 8, name: "Barkley", title: "Nitro Quality Ninja", department: "Business Technology", branch: "Philadelphia", start_date: Date.new(2025, 1, 8) },
|
|
10
|
+
{ id: 9, name: "Aaron", title: "Associate Nitro Quality Ninja", department: "Business Technology", branch: "Philadelphia", start_date: Date.new(2025, 1, 9) },
|
|
11
|
+
] %>
|
|
12
|
+
|
|
13
|
+
<% filter_content =
|
|
14
|
+
pb_rails("text_input", props: {
|
|
15
|
+
label: "Territory ID",
|
|
16
|
+
placeholder: "Enter Territory ID"
|
|
17
|
+
}) +
|
|
18
|
+
pb_rails("typeahead", props: {
|
|
19
|
+
label: "Title",
|
|
20
|
+
options: [
|
|
21
|
+
{ label: "Senior UX Engineer", value: "senior-ux-engineer" },
|
|
22
|
+
{ label: "UX Engineer", value: "ux-engineer" },
|
|
23
|
+
{ label: "UX Designer", value: "ux-designer" }
|
|
24
|
+
]
|
|
25
|
+
}) +
|
|
26
|
+
pb_rails("select", props: {
|
|
27
|
+
blank_selection: "All Departments",
|
|
28
|
+
label: "Department",
|
|
29
|
+
options: [
|
|
30
|
+
{ value: "Business Technology", text: "Business Technology" },
|
|
31
|
+
{ value: "Customer Development", text: "Customer Development" },
|
|
32
|
+
{ value: "Talent Acquisition", text: "Talent Acquisition" }
|
|
33
|
+
]
|
|
34
|
+
}) +
|
|
35
|
+
pb_rails("dropdown", props: {
|
|
36
|
+
label: "Branch",
|
|
37
|
+
options: [
|
|
38
|
+
{ label: "Philadelphia", value: "philadelphia" },
|
|
39
|
+
{ label: "New York", value: "new-york" },
|
|
40
|
+
{ label: "Austin", value: "austin" }
|
|
41
|
+
]
|
|
42
|
+
}) +
|
|
43
|
+
pb_rails("date_picker", props: {
|
|
44
|
+
label: "Start Date",
|
|
45
|
+
padding_y: "sm",
|
|
46
|
+
picker_id: "startedOn"
|
|
47
|
+
}) +
|
|
48
|
+
pb_rails("flex", props: { spacing: "between" }) do
|
|
49
|
+
pb_rails("button", props: {
|
|
50
|
+
text: "Filter",
|
|
51
|
+
}) +
|
|
52
|
+
pb_rails("button", props: {
|
|
53
|
+
text: "Defaults",
|
|
54
|
+
variant: "secondary"
|
|
55
|
+
})
|
|
56
|
+
end
|
|
57
|
+
%>
|
|
58
|
+
|
|
59
|
+
<%= pb_rails("table", props: {
|
|
60
|
+
variant: "with_filter",
|
|
61
|
+
title: "Table Title Here",
|
|
62
|
+
filter_content: filter_content,
|
|
63
|
+
filter_props: {
|
|
64
|
+
id: "user-table-filters-1",
|
|
65
|
+
results: 9,
|
|
66
|
+
sort_menu: [
|
|
67
|
+
{ item: "Start Date", link: "?q[sorts]=started_on+asc", active: true, direction: "asc" },
|
|
68
|
+
{ item: "First Name", link: "?q[sorts]=name+asc", active: false },
|
|
69
|
+
{ item: "Title", link: "?q[sorts]=title+asc", active: false },
|
|
70
|
+
{ item: "Department", link: "?q[sorts]=department+asc", active: false },
|
|
71
|
+
{ item: "Branch", link: "?q[sorts]=branch+asc", active: false },
|
|
72
|
+
{ item: "Territory ID", link: "?q[sorts]=territory_id+asc", active: false },
|
|
73
|
+
],
|
|
74
|
+
}
|
|
75
|
+
}) do %>
|
|
76
|
+
<%= pb_rails("table/table_head") do %>
|
|
77
|
+
<%= pb_rails("table/table_row") do %>
|
|
78
|
+
<%= pb_rails("table/table_header", props: { text: "Territory ID" }) %>
|
|
79
|
+
<%= pb_rails("table/table_header", props: { text: "Name" }) %>
|
|
80
|
+
<%= pb_rails("table/table_header", props: { text: "Title" }) %>
|
|
81
|
+
<%= pb_rails("table/table_header", props: { text: "Department" }) %>
|
|
82
|
+
<%= pb_rails("table/table_header", props: { text: "Branch" }) %>
|
|
83
|
+
<%= pb_rails("table/table_header", props: { text: "Start Date", text_align: "right" }) %>
|
|
84
|
+
<% end %>
|
|
85
|
+
<% end %>
|
|
86
|
+
|
|
87
|
+
<%= pb_rails("table/table_body") do %>
|
|
88
|
+
<% users.each do |user| %>
|
|
89
|
+
<%= pb_rails("table/table_row") do %>
|
|
90
|
+
<%= pb_rails("table/table_cell", props: { margin_x: { xs: "sm" }, number_spacing: "tabular" }) { user[:id].to_s } %>
|
|
91
|
+
<%= pb_rails("table/table_cell", props: { margin_x: { xs: "sm" } }) { user[:name] } %>
|
|
92
|
+
<%= pb_rails("table/table_cell", props: { margin_x: { xs: "sm" } }) { user[:title] } %>
|
|
93
|
+
<%= pb_rails("table/table_cell", props: { margin_x: { xs: "sm" } }) { user[:department] } %>
|
|
94
|
+
<%= pb_rails("table/table_cell", props: { margin_x: { xs: "sm" } }) { user[:branch] } %>
|
|
95
|
+
<%= pb_rails("table/table_cell", props: { margin_x: { xs: "sm" } }) do %>
|
|
96
|
+
<%= pb_rails("date", props: {alignment: "right", date: user[:start_date].to_s, show_current_year: true } ) %>
|
|
97
|
+
<% end %>
|
|
98
|
+
<% end %>
|
|
99
|
+
<% end %>
|
|
100
|
+
<% end %>
|
|
101
|
+
<% end %>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
Set the `variant` prop to `with_filter` to render a Table with a filter. The variant automatically handles:
|
|
2
|
+
|
|
3
|
+
- Card wrapper with standard responsive margins
|
|
4
|
+
- Optional `title` prop to render title above the card
|
|
5
|
+
- Filter component rendering with Design defaults
|
|
6
|
+
- SectionSeparator between filter and table
|
|
7
|
+
- Flex layout for proper alignment
|
|
8
|
+
|
|
9
|
+
#### Required Props
|
|
10
|
+
|
|
11
|
+
- `variant: "with_filter"`: Enables the filter variant
|
|
12
|
+
- `filter_content`: The filter's body content (inputs, buttons, etc.) built with `pb_rails` string concatenation
|
|
13
|
+
- `filter_props`: A hash containing Filter-specific props like `results`, `sort_menu`, etc.
|
|
14
|
+
|
|
15
|
+
#### Optional Props
|
|
16
|
+
|
|
17
|
+
- `title`: Displays a title above the card
|
|
18
|
+
- All standard Table props (`size`, `collapse`, etc.) can be used, but defaults are already set to match Design guidelines
|
|
19
|
+
|
|
20
|
+
#### Default Filter Props
|
|
21
|
+
|
|
22
|
+
The Table kit automatically sets these Filter defaults (which you can override via `filter_props`):
|
|
23
|
+
|
|
24
|
+
- `background: false`
|
|
25
|
+
- `max_height: "50vh"`
|
|
26
|
+
- `min_width: "xs"`
|
|
27
|
+
- `popover_props: { width: "350px" }`
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
**IMPORTANT NOTE**:
|
|
31
|
+
The purpose of this variant is to provide an easy way to set up a Table with a Filter with Design standards applied by default.
|
|
32
|
+
|
|
33
|
+
If you are looking for more customization than this embedded variant provides, you may be better served by using the individual kits as demonstrating in our Table Filter Card Building Block as seen [here](https://playbook.powerapp.cloud/building_blocks/table_filter_card/rails).
|