playbook_ui 16.8.0.pre.alpha.play293416882 → 16.8.0.pre.alpha.play299216890
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_date_picker/_date_picker.tsx +3 -0
- data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +3 -0
- data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +10 -2
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_year_asc.html.erb +1 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_year_asc.jsx +15 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_year_asc.md +1 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/_playground.json +1 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_date_picker/kit.schema.json +8 -0
- data/app/pb_kits/playbook/pb_filter/Filter/CurrentFilters.tsx +28 -55
- data/app/pb_kits/playbook/pb_filter/Filter/FilterDouble.tsx +1 -4
- data/app/pb_kits/playbook/pb_filter/Filter/FilterSingle.tsx +1 -4
- data/app/pb_kits/playbook/pb_filter/_filter.scss +1 -88
- data/app/pb_kits/playbook/pb_filter/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_filter/docs/index.js +1 -2
- data/app/pb_kits/playbook/pb_filter/filter.html.erb +3 -80
- data/app/pb_kits/playbook/pb_filter/filter.rb +0 -71
- data/app/pb_kits/playbook/pb_filter/filter.test.js +0 -78
- data/app/pb_kits/playbook/pb_filter/kit.schema.json +0 -6
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_playground.json +4 -1
- data/dist/chunks/{_pb_line_graph-D8koup5H.js → _pb_line_graph-D_5Qj7RV.js} +1 -1
- data/dist/chunks/{_typeahead-BU-3yCgY.js → _typeahead-CZnwqRbP.js} +2 -2
- data/dist/chunks/{globalProps-dmEeu7jO.js → globalProps-4JfvDJOJ.js} +1 -1
- data/dist/chunks/lib-LYU8yq_z.js +29 -0
- data/dist/chunks/vendor.js +5 -5
- 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 +8 -11
- data/app/pb_kits/playbook/pb_filter/Filter/InteractiveFilter.tsx +0 -277
- data/app/pb_kits/playbook/pb_filter/docs/_filter_interactive.html.erb +0 -116
- data/app/pb_kits/playbook/pb_filter/docs/_filter_interactive.md +0 -12
- data/app/pb_kits/playbook/pb_filter/docs/_filter_interactive_react.jsx +0 -153
- data/app/pb_kits/playbook/pb_filter/docs/_filter_interactive_react.md +0 -10
- data/app/pb_kits/playbook/pb_filter/index.ts +0 -349
- data/dist/chunks/lib-CpaLlY1W.js +0 -29
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 55ce3fc93b65b84a7675452fc441dc46474669968c56a5170511fbab48f609a7
|
|
4
|
+
data.tar.gz: 3845a85642d2eca81306da516098d47e091e14c96f287b31cbaa9314371b23be
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6c35e16d11f45e25d82a5d945a755500eb142007a0d420f9b20c05f0941eb9a9629ddbc79c226e0eb996ec8a99dee17eb17a4115ebe40854a9bf15fa36367880
|
|
7
|
+
data.tar.gz: 53cef8d58713fd21817e3a37cc85f728610dc1700017a19e57e5abae1148b1d7a581fcc015023a32c5fe87b46756fb6292024deca70999605ee7be0116adc6b7
|
|
@@ -87,6 +87,7 @@ type DatePickerProps = {
|
|
|
87
87
|
thisRangesEndToday?: boolean,
|
|
88
88
|
timeFormat?: string,
|
|
89
89
|
type?: string,
|
|
90
|
+
yearAscending?: boolean,
|
|
90
91
|
yearRange?: number[],
|
|
91
92
|
controlsStartId?: string,
|
|
92
93
|
controlsEndId?: string,
|
|
@@ -140,6 +141,7 @@ const DatePicker = (props: DatePickerProps): React.ReactElement => {
|
|
|
140
141
|
showTimezone = false,
|
|
141
142
|
staticPosition = true,
|
|
142
143
|
thisRangesEndToday = false,
|
|
144
|
+
yearAscending = false,
|
|
143
145
|
yearRange = [1900, 2100],
|
|
144
146
|
controlsStartId,
|
|
145
147
|
controlsEndId,
|
|
@@ -199,6 +201,7 @@ const DatePicker = (props: DatePickerProps): React.ReactElement => {
|
|
|
199
201
|
showTimezone,
|
|
200
202
|
staticPosition,
|
|
201
203
|
thisRangesEndToday,
|
|
204
|
+
yearAscending,
|
|
202
205
|
yearRange,
|
|
203
206
|
controlsStartId,
|
|
204
207
|
controlsEndId,
|
|
@@ -89,6 +89,8 @@ module Playbook
|
|
|
89
89
|
default: ""
|
|
90
90
|
prop :cursor, type: Playbook::Props::String,
|
|
91
91
|
default: "pointer"
|
|
92
|
+
prop :year_ascending, type: Playbook::Props::Boolean,
|
|
93
|
+
default: false
|
|
92
94
|
|
|
93
95
|
def classname
|
|
94
96
|
default_margin_bottom = margin_bottom.present? ? "" : " mb_sm"
|
|
@@ -122,6 +124,7 @@ module Playbook
|
|
|
122
124
|
staticPosition: static_position,
|
|
123
125
|
thisRangesEndToday: this_ranges_end_today,
|
|
124
126
|
yearRange: year_range,
|
|
127
|
+
yearAscending: year_ascending,
|
|
125
128
|
controlsStartId: controls_start_id,
|
|
126
129
|
controlsEndId: controls_end_id,
|
|
127
130
|
syncStartWith: sync_start_with,
|
|
@@ -32,6 +32,7 @@ type DatePickerConfig = {
|
|
|
32
32
|
thisRangesEndToday?: boolean,
|
|
33
33
|
timeCaption?: string,
|
|
34
34
|
timeFormat?: string,
|
|
35
|
+
yearAscending?: boolean,
|
|
35
36
|
yearRange: number[],
|
|
36
37
|
controlsStartId?: string,
|
|
37
38
|
controlsEndId?: string,
|
|
@@ -70,6 +71,7 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
|
|
|
70
71
|
thisRangesEndToday = false,
|
|
71
72
|
timeCaption = 'Select Time',
|
|
72
73
|
timeFormat = 'at h:i K',
|
|
74
|
+
yearAscending,
|
|
73
75
|
yearRange,
|
|
74
76
|
controlsStartId,
|
|
75
77
|
controlsEndId,
|
|
@@ -515,8 +517,14 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
|
|
|
515
517
|
|
|
516
518
|
// create html option tags for desired years
|
|
517
519
|
let years = ''
|
|
518
|
-
|
|
519
|
-
|
|
520
|
+
if (yearAscending) {
|
|
521
|
+
for (let year = setMinYear; year <= setMaxYear; year++) {
|
|
522
|
+
years += `<option value="${year}">${year}</option>`
|
|
523
|
+
}
|
|
524
|
+
} else {
|
|
525
|
+
for (let year = setMaxYear; year >= setMinYear; year--) {
|
|
526
|
+
years += `<option value="${year}">${year}</option>`
|
|
527
|
+
}
|
|
520
528
|
}
|
|
521
529
|
|
|
522
530
|
// variablize each dropdown selector
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= pb_rails("date_picker", props: { picker_id: "date-picker-date-asc", year_ascending: true}) %>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import DatePicker from '../_date_picker'
|
|
4
|
+
|
|
5
|
+
const DatePickerYearAsc = (props) => (
|
|
6
|
+
<div>
|
|
7
|
+
<DatePicker
|
|
8
|
+
pickerId="date-picker-date-asc"
|
|
9
|
+
yearAscending
|
|
10
|
+
{...props}
|
|
11
|
+
/>
|
|
12
|
+
</div>
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
export default DatePickerYearAsc
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
`yearAscending`/`year_ascending` is a boolean prop that if set to true, will render the years in the year dropdown in chronological order. This prop is set to false by default.
|
|
@@ -23,6 +23,7 @@ examples:
|
|
|
23
23
|
- date_picker_flatpickr_methods: Flatpickr Methods
|
|
24
24
|
- date_picker_hooks: Hooks
|
|
25
25
|
- date_picker_year_range: Year Range
|
|
26
|
+
- date_picker_year_asc: Year Ascending
|
|
26
27
|
- date_picker_anti_patterns: Anti-Patterns
|
|
27
28
|
- date_picker_margin_bottom: Margin Bottom
|
|
28
29
|
- date_picker_inline: Inline
|
|
@@ -58,6 +59,7 @@ examples:
|
|
|
58
59
|
- date_picker_flatpickr_methods: Flatpickr Methods
|
|
59
60
|
- date_picker_hooks: Hooks
|
|
60
61
|
- date_picker_year_range: Year Range
|
|
62
|
+
- date_picker_year_asc: Year Ascending
|
|
61
63
|
- date_picker_margin_bottom: Margin Bottom
|
|
62
64
|
- date_picker_inline: Inline
|
|
63
65
|
- date_picker_month_and_year: Month & Year Only
|
|
@@ -30,3 +30,4 @@ export { default as DatePickerRangePattern } from './_date_picker_range_pattern'
|
|
|
30
30
|
export { default as DatePickerAndDropdownRange } from './_date_picker_and_dropdown_range.jsx'
|
|
31
31
|
export { default as DatePickerRequiredIndicator } from "./_date_picker_required_indicator.jsx";
|
|
32
32
|
export { default as DatePickerDialogSubmission } from "./_date_picker_dialog_submission.jsx";
|
|
33
|
+
export { default as DatePickerYearAsc } from './_date_picker_year_asc.jsx'
|
|
@@ -1,32 +1,22 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react'
|
|
2
2
|
import { isEmpty, omitBy, map } from '../../utilities/object'
|
|
3
3
|
|
|
4
4
|
import Body from '../../pb_body/_body'
|
|
5
5
|
import Caption from '../../pb_caption/_caption'
|
|
6
6
|
import Title from '../../pb_title/_title'
|
|
7
|
-
import InteractiveFilter, { InteractiveFilterConfig } from './InteractiveFilter'
|
|
8
7
|
|
|
9
8
|
export type FilterDescription = {
|
|
10
9
|
[key: string]: string | null | boolean,
|
|
11
10
|
}
|
|
12
11
|
|
|
13
|
-
export type InteractiveFilters = {
|
|
14
|
-
[key: string]: InteractiveFilterConfig,
|
|
15
|
-
}
|
|
16
|
-
|
|
17
12
|
export type CurrentFiltersProps = {
|
|
18
13
|
dark: boolean,
|
|
19
14
|
filters: FilterDescription,
|
|
20
|
-
interactiveFilters?: InteractiveFilters,
|
|
21
15
|
}
|
|
22
16
|
|
|
23
17
|
const hiddenFilters = (value: any) => isEmpty(value) && value !== true
|
|
24
18
|
|
|
25
|
-
const CurrentFilters = ({
|
|
26
|
-
dark,
|
|
27
|
-
filters,
|
|
28
|
-
interactiveFilters = {},
|
|
29
|
-
}: CurrentFiltersProps): React.ReactElement => {
|
|
19
|
+
const CurrentFilters = ({ dark, filters }: CurrentFiltersProps): React.ReactElement => {
|
|
30
20
|
const displayableFilters = omitBy(filters, hiddenFilters)
|
|
31
21
|
|
|
32
22
|
return (
|
|
@@ -45,50 +35,33 @@ const CurrentFilters = ({
|
|
|
45
35
|
{ !isEmpty(filters) &&
|
|
46
36
|
<div className="filters">
|
|
47
37
|
<div className="left_gradient" />
|
|
48
|
-
{map(displayableFilters, (value, name) =>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
dark={dark}
|
|
72
|
-
size={4}
|
|
73
|
-
tag="h4"
|
|
74
|
-
text={`${name}`}
|
|
75
|
-
/> :
|
|
76
|
-
<div>
|
|
77
|
-
<Caption
|
|
78
|
-
dark={dark}
|
|
79
|
-
text={`${name}`}
|
|
80
|
-
/>
|
|
81
|
-
<Title
|
|
82
|
-
dark={dark}
|
|
83
|
-
size={4}
|
|
84
|
-
tag="h4"
|
|
85
|
-
text={value}
|
|
86
|
-
/>
|
|
87
|
-
</div>
|
|
88
|
-
}
|
|
38
|
+
{map(displayableFilters, (value, name) => (
|
|
39
|
+
<div
|
|
40
|
+
className="filter"
|
|
41
|
+
key={`filter-${name}`}
|
|
42
|
+
>
|
|
43
|
+
{ value === true ?
|
|
44
|
+
<Title
|
|
45
|
+
dark={dark}
|
|
46
|
+
size={4}
|
|
47
|
+
tag="h4"
|
|
48
|
+
text={`${name}`}
|
|
49
|
+
/> :
|
|
50
|
+
<div>
|
|
51
|
+
<Caption
|
|
52
|
+
dark={dark}
|
|
53
|
+
text={`${name}`}
|
|
54
|
+
/>
|
|
55
|
+
<Title
|
|
56
|
+
dark={dark}
|
|
57
|
+
size={4}
|
|
58
|
+
tag="h4"
|
|
59
|
+
text={value}
|
|
60
|
+
/>
|
|
89
61
|
</div>
|
|
90
|
-
|
|
91
|
-
|
|
62
|
+
}
|
|
63
|
+
</div>
|
|
64
|
+
))}
|
|
92
65
|
<div className="right_gradient" />
|
|
93
66
|
</div>
|
|
94
67
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
|
|
3
|
-
import CurrentFilters, { FilterDescription
|
|
3
|
+
import CurrentFilters, { FilterDescription } from './CurrentFilters'
|
|
4
4
|
import FilterBackground, { FilterBackgroundProps } from './FilterBackground'
|
|
5
5
|
import FiltersPopover from './FiltersPopover'
|
|
6
6
|
import ResultsCount from './ResultsCount'
|
|
@@ -17,7 +17,6 @@ import SectionSeparator from '../../pb_section_separator/_section_separator'
|
|
|
17
17
|
export type FilterDoubleProps = {
|
|
18
18
|
children?: React.ReactChild[] | React.ReactChild,
|
|
19
19
|
filters?: FilterDescription,
|
|
20
|
-
interactiveFilters?: InteractiveFilters,
|
|
21
20
|
onSortChange?: SortingChangeCallback,
|
|
22
21
|
results?: number,
|
|
23
22
|
sortOptions?: SortOptions,
|
|
@@ -29,7 +28,6 @@ const FilterDouble = ({
|
|
|
29
28
|
sortOptions,
|
|
30
29
|
sortValue,
|
|
31
30
|
filters,
|
|
32
|
-
interactiveFilters,
|
|
33
31
|
results,
|
|
34
32
|
children,
|
|
35
33
|
dark,
|
|
@@ -59,7 +57,6 @@ const FilterDouble = ({
|
|
|
59
57
|
<CurrentFilters
|
|
60
58
|
dark={dark}
|
|
61
59
|
filters={filters}
|
|
62
|
-
interactiveFilters={interactiveFilters}
|
|
63
60
|
/>
|
|
64
61
|
</Flex>
|
|
65
62
|
<SectionSeparator dark={dark} />
|
|
@@ -3,7 +3,7 @@ import { isEmpty } from '../../utilities/object'
|
|
|
3
3
|
|
|
4
4
|
import Flex from '../../pb_flex/_flex'
|
|
5
5
|
|
|
6
|
-
import CurrentFilters, { FilterDescription
|
|
6
|
+
import CurrentFilters, { FilterDescription } from './CurrentFilters'
|
|
7
7
|
import FilterBackground, { FilterBackgroundProps } from './FilterBackground'
|
|
8
8
|
import FiltersPopover from './FiltersPopover'
|
|
9
9
|
import ResultsCount from './ResultsCount'
|
|
@@ -16,7 +16,6 @@ import SortMenu, {
|
|
|
16
16
|
export type FilterSingleProps = {
|
|
17
17
|
children?: React.ReactChild[] | React.ReactChild,
|
|
18
18
|
filters?: FilterDescription,
|
|
19
|
-
interactiveFilters?: InteractiveFilters,
|
|
20
19
|
onSortChange?: SortingChangeCallback,
|
|
21
20
|
results?: number,
|
|
22
21
|
sortOptions?: SortOptions,
|
|
@@ -28,7 +27,6 @@ const FilterSingle = ({
|
|
|
28
27
|
sortOptions,
|
|
29
28
|
sortValue,
|
|
30
29
|
filters,
|
|
31
|
-
interactiveFilters,
|
|
32
30
|
results,
|
|
33
31
|
children,
|
|
34
32
|
dark,
|
|
@@ -62,7 +60,6 @@ const FilterSingle = ({
|
|
|
62
60
|
<CurrentFilters
|
|
63
61
|
dark={dark}
|
|
64
62
|
filters={filters}
|
|
65
|
-
interactiveFilters={interactiveFilters}
|
|
66
63
|
/>
|
|
67
64
|
</>
|
|
68
65
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
@import "../tokens/spacing";
|
|
2
2
|
@import "../tokens/colors";
|
|
3
|
-
@import "../tokens/border_radius";
|
|
4
3
|
|
|
5
4
|
.pb_filter_sort_menu {
|
|
6
5
|
li {
|
|
@@ -71,26 +70,6 @@
|
|
|
71
70
|
padding-right: $space_xs;
|
|
72
71
|
border-right: 1px solid $border_light !important;
|
|
73
72
|
}
|
|
74
|
-
|
|
75
|
-
.filter.interactive {
|
|
76
|
-
padding-top: 2px;
|
|
77
|
-
padding-bottom: 2px;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Interactive filter chip: clickable button that opens a popover whose
|
|
82
|
-
// contents are the editor for that filter type.
|
|
83
|
-
.pb_interactive_filter_trigger {
|
|
84
|
-
background: transparent;
|
|
85
|
-
border: none;
|
|
86
|
-
cursor: pointer;
|
|
87
|
-
border-radius: 4px;
|
|
88
|
-
text-align: left;
|
|
89
|
-
|
|
90
|
-
&:focus-visible {
|
|
91
|
-
outline: $primary solid 2px;
|
|
92
|
-
outline-offset: -1px;
|
|
93
|
-
}
|
|
94
73
|
}
|
|
95
74
|
|
|
96
75
|
.maskContainer::after {
|
|
@@ -124,70 +103,4 @@
|
|
|
124
103
|
opacity:0;
|
|
125
104
|
}
|
|
126
105
|
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
.pb_popover_tooltip.pb_interactive_filter_editor {
|
|
130
|
-
position: fixed;
|
|
131
|
-
top: 0;
|
|
132
|
-
left: 0;
|
|
133
|
-
margin: 0;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// Popover contents for an interactive filter.
|
|
137
|
-
.pb_interactive_filter_editor {
|
|
138
|
-
min-width: 220px;
|
|
139
|
-
|
|
140
|
-
.pb_date_picker_kit {
|
|
141
|
-
margin-bottom: 0 !important;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// Select editor: option list. (Native HTML <select> can't be auto-opened
|
|
145
|
-
// without a user gesture in modern browsers, so we render options
|
|
146
|
-
// directly — one click on the chip = options visible.)
|
|
147
|
-
.pb_interactive_filter_options {
|
|
148
|
-
list-style: none;
|
|
149
|
-
margin: 0;
|
|
150
|
-
padding: 0;
|
|
151
|
-
border-radius: $border_rad_heavier;
|
|
152
|
-
border: 1px solid $border_light;
|
|
153
|
-
max-height: 280px;
|
|
154
|
-
overflow-y: auto;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
.pb_interactive_filter_option {
|
|
158
|
-
display: flex;
|
|
159
|
-
align-items: center;
|
|
160
|
-
justify-content: space-between;
|
|
161
|
-
gap: $space_xs;
|
|
162
|
-
padding: $space_xs $space_sm;
|
|
163
|
-
cursor: pointer;
|
|
164
|
-
font-size: $font_base;
|
|
165
|
-
color: $text_lt_default;
|
|
166
|
-
transition: background-color 0.15s ease;
|
|
167
|
-
border-bottom: 1px solid $border_light;
|
|
168
|
-
&:last-child {
|
|
169
|
-
border-bottom: none;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
&:hover {
|
|
173
|
-
background-color: rgba($primary, 0.08);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
&.active {
|
|
177
|
-
background-color: $primary;
|
|
178
|
-
color: $white;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
&.pb_interactive_filter_editor--date-picker {
|
|
183
|
-
// flatpickr inline mode renders directly into our wrapper; suppress its
|
|
184
|
-
// own shadow since the popover already provides the floating surface.
|
|
185
|
-
.flatpickr-calendar {
|
|
186
|
-
box-shadow: none;
|
|
187
|
-
}
|
|
188
|
-
.flatpickr-calendar.inline {
|
|
189
|
-
position: static;
|
|
190
|
-
top: 0;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
106
|
+
}
|
|
@@ -12,7 +12,6 @@ examples:
|
|
|
12
12
|
- filter_placement: Filter Placement
|
|
13
13
|
- filter_popover_props: Popover Props
|
|
14
14
|
- filter_within_turbo_frames: Within Turbo Frames
|
|
15
|
-
- filter_interactive: Interactive Applied Filters
|
|
16
15
|
|
|
17
16
|
react:
|
|
18
17
|
- filter_default: Default
|
|
@@ -26,5 +25,4 @@ examples:
|
|
|
26
25
|
- filter_placement: Filter Placement
|
|
27
26
|
- filter_popover_props: Popover Props
|
|
28
27
|
- filter_sidebar: Sidebar
|
|
29
|
-
- filter_interactive_react: Interactive Applied Filters
|
|
30
28
|
|
|
@@ -8,5 +8,4 @@ export { default as FilterMaxWidth } from './_filter_max_width.jsx'
|
|
|
8
8
|
export { default as FilterMaxHeight } from './_filter_max_height.jsx'
|
|
9
9
|
export { default as FilterPlacement } from './_filter_placement.jsx'
|
|
10
10
|
export { default as FilterPopoverProps } from './_filter_popover_props.jsx'
|
|
11
|
-
export { default as FilterSidebar } from './_filter_sidebar.jsx'
|
|
12
|
-
export { default as FilterInteractiveReact } from './_filter_interactive_react.jsx'
|
|
11
|
+
export { default as FilterSidebar } from './_filter_sidebar.jsx'
|
|
@@ -18,87 +18,10 @@
|
|
|
18
18
|
</div>
|
|
19
19
|
<% end %>
|
|
20
20
|
<% object.filters&.each do |filter| %>
|
|
21
|
-
<%
|
|
22
|
-
<% interactive_config = object.interactive_config_for(filter[:name]) %>
|
|
23
|
-
<% if interactive_config.present? %>
|
|
24
|
-
<%
|
|
25
|
-
chip_id = "pb-interactive-filter-#{object.id || 'kit'}-#{filter[:name].to_s.parameterize}"
|
|
26
|
-
popover_id = "#{chip_id}-popover"
|
|
27
|
-
type = object.interactive_value(interactive_config, :type).to_s
|
|
28
|
-
display_value = object.interactive_display_value(interactive_config, filter[:value])
|
|
29
|
-
is_date_picker = type == "date-picker"
|
|
30
|
-
is_options = %w[select dropdown].include?(type)
|
|
31
|
-
|
|
32
|
-
chip_data_attrs = {
|
|
33
|
-
"pb-interactive-filter" => "true",
|
|
34
|
-
"pb-filter-name" => filter[:name],
|
|
35
|
-
"pb-filter-type" => type,
|
|
36
|
-
"pb-filter-popover-id" => popover_id,
|
|
37
|
-
"pb-filter-target" => object.interactive_value(interactive_config, :target_input),
|
|
38
|
-
"pb-filter-value" => filter[:value],
|
|
39
|
-
"pb-filter-auto-submit" => object.interactive_value(interactive_config, :auto_submit),
|
|
40
|
-
}
|
|
41
|
-
if is_date_picker
|
|
42
|
-
chip_data_attrs.merge!(
|
|
43
|
-
"pb-filter-date-format" => object.interactive_value(interactive_config, :format),
|
|
44
|
-
"pb-filter-date-mode" => object.interactive_value(interactive_config, :mode),
|
|
45
|
-
"pb-filter-date-min" => object.interactive_value(interactive_config, :min_date),
|
|
46
|
-
"pb-filter-date-max" => object.interactive_value(interactive_config, :max_date),
|
|
47
|
-
)
|
|
48
|
-
end
|
|
49
|
-
%>
|
|
50
|
-
<div class="filter interactive">
|
|
51
|
-
<button type="button"
|
|
52
|
-
class="pb_interactive_filter_trigger"
|
|
53
|
-
id="<%= chip_id %>"
|
|
54
|
-
<%= chip_data_attrs.compact_blank.map { |k, v| "data-#{k}=\"#{ERB::Util.html_escape(v)}\"" }.join(" ").html_safe %>>
|
|
55
|
-
<div class="pb_interactive_filter_text">
|
|
56
|
-
<%= pb_rails("caption", props: { text: filter[:name] }) %>
|
|
57
|
-
<%= pb_rails("flex", props: { align_items: "center", gap: "xxs" }) do %>
|
|
58
|
-
<%= pb_rails("title", props: {
|
|
59
|
-
text: display_value.presence || "—",
|
|
60
|
-
size: 4,
|
|
61
|
-
data: { "pb-filter-value-display" => true },
|
|
62
|
-
}) %>
|
|
63
|
-
<%= pb_rails("icon", props: { icon: "angle-down", fixed_width: true, size: "xs", color: "primary" }) %>
|
|
64
|
-
<% end %>
|
|
65
|
-
</div>
|
|
66
|
-
</button>
|
|
67
|
-
|
|
68
|
-
<%# Popover tooltip is moved to <body> in index.ts (connect)
|
|
69
|
-
to escape the filter row's overflow-x clipping. We
|
|
70
|
-
reuse pb_popover's CSS classes for visual consistency
|
|
71
|
-
rather than using the popover kit directly because
|
|
72
|
-
that kit doesn't portal its tooltip out of its DOM
|
|
73
|
-
parent. %>
|
|
74
|
-
<div class="pb_popover_tooltip hide pb_interactive_filter_editor pb_interactive_filter_editor--<%= type %>" id="<%= popover_id %>" role="tooltip">
|
|
75
|
-
<div class="pb_popover_body">
|
|
76
|
-
<% if is_options %>
|
|
77
|
-
<ul class="pb_interactive_filter_options" role="listbox">
|
|
78
|
-
<% object.interactive_options(interactive_config).each do |opt| %>
|
|
79
|
-
<% opt_value = object.interactive_option_value(interactive_config, opt) %>
|
|
80
|
-
<% is_active = opt_value.to_s == filter[:value].to_s %>
|
|
81
|
-
<% opt_label = object.interactive_option_label(opt, opt_value) %>
|
|
82
|
-
<li class="pb_interactive_filter_option<%= ' active' if is_active %>"
|
|
83
|
-
tabindex="0"
|
|
84
|
-
role="option"
|
|
85
|
-
aria-selected="<%= is_active %>"
|
|
86
|
-
data-pb-filter-option-value="<%= opt_value %>"
|
|
87
|
-
data-pb-filter-option-label="<%= opt_label %>">
|
|
88
|
-
<span><%= opt_label %></span>
|
|
89
|
-
</li>
|
|
90
|
-
<% end %>
|
|
91
|
-
</ul>
|
|
92
|
-
<% elsif is_date_picker %>
|
|
93
|
-
<div data-pb-filter-date-mount></div>
|
|
94
|
-
<% end %>
|
|
95
|
-
</div>
|
|
96
|
-
</div>
|
|
97
|
-
</div>
|
|
98
|
-
<% else %>
|
|
21
|
+
<% if filter[:name].present? %>
|
|
99
22
|
<div class="filter">
|
|
100
|
-
<%= pb_rails("caption", props: { text: filter[:name]
|
|
101
|
-
<%= pb_rails("title", props: { size: 4, tag:
|
|
23
|
+
<%= pb_rails("caption", props: { text: filter[:name]}) %>
|
|
24
|
+
<%= pb_rails("title", props: { size: 4, tag:"h4", text: filter[:value]}) %>
|
|
102
25
|
</div>
|
|
103
26
|
<% end %>
|
|
104
27
|
<% end %>
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative "../pb_dropdown/quickpick_helper"
|
|
4
|
-
|
|
5
3
|
module Playbook
|
|
6
4
|
module PbFilter
|
|
7
5
|
class Filter < Playbook::KitBase
|
|
@@ -19,64 +17,11 @@ module Playbook
|
|
|
19
17
|
default: "bottom-start"
|
|
20
18
|
prop :popover_props, type: Playbook::Props::HashProp,
|
|
21
19
|
default: {}
|
|
22
|
-
prop :interactive_filters, type: Playbook::Props::HashArray, default: []
|
|
23
20
|
|
|
24
21
|
def classname
|
|
25
22
|
generate_classname("pb_filter_kit").rstrip
|
|
26
23
|
end
|
|
27
24
|
|
|
28
|
-
def interactive_config_for(filter_name)
|
|
29
|
-
interactive_filters_index[filter_name.to_s]
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def interactive_value(config, key)
|
|
33
|
-
return nil if config.nil?
|
|
34
|
-
|
|
35
|
-
config[key]
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def interactive_options(config)
|
|
39
|
-
return [] if config.nil?
|
|
40
|
-
|
|
41
|
-
config = config.with_indifferent_access
|
|
42
|
-
if interactive_quickpick?(config) && Array(config[:options]).blank?
|
|
43
|
-
return Playbook::PbDropdown::QuickpickHelper.get_quickpick_options(
|
|
44
|
-
range_ends_today: config[:range_ends_today] || false,
|
|
45
|
-
custom_quick_pick_dates: config[:custom_quick_pick_dates] || {}
|
|
46
|
-
)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
Array(config[:options])
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def interactive_option_value(config, option)
|
|
53
|
-
config = config.with_indifferent_access
|
|
54
|
-
option = option.with_indifferent_access
|
|
55
|
-
|
|
56
|
-
if config[:type].to_s == "dropdown"
|
|
57
|
-
option[:id] || option[:value] || option[:label]
|
|
58
|
-
else
|
|
59
|
-
option[:value] || option[:text] || option[:label]
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def interactive_option_label(option, fallback = nil)
|
|
64
|
-
option = option.with_indifferent_access
|
|
65
|
-
option[:label] || option[:text] || fallback
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def interactive_display_value(config, raw_value)
|
|
69
|
-
return raw_value if config.nil?
|
|
70
|
-
return raw_value unless %w[select dropdown].include?(config[:type].to_s)
|
|
71
|
-
|
|
72
|
-
match = interactive_options(config).find do |opt|
|
|
73
|
-
interactive_option_value(config, opt).to_s == raw_value.to_s
|
|
74
|
-
end
|
|
75
|
-
return raw_value unless match
|
|
76
|
-
|
|
77
|
-
interactive_option_label(match, raw_value)
|
|
78
|
-
end
|
|
79
|
-
|
|
80
25
|
def result_text
|
|
81
26
|
case results
|
|
82
27
|
when 1
|
|
@@ -106,22 +51,6 @@ module Playbook
|
|
|
106
51
|
""
|
|
107
52
|
end
|
|
108
53
|
end
|
|
109
|
-
|
|
110
|
-
private
|
|
111
|
-
|
|
112
|
-
def interactive_filters_index
|
|
113
|
-
@interactive_filters_index ||= Array(interactive_filters).each_with_object({}) do |entry, acc|
|
|
114
|
-
next unless entry.is_a?(Hash)
|
|
115
|
-
|
|
116
|
-
config = entry.with_indifferent_access
|
|
117
|
-
name = config[:name].to_s
|
|
118
|
-
acc[name] = config if name.present?
|
|
119
|
-
end
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
def interactive_quickpick?(config)
|
|
123
|
-
config[:type].to_s == "dropdown" && config[:variant].to_s == "quickpick"
|
|
124
|
-
end
|
|
125
54
|
end
|
|
126
55
|
end
|
|
127
56
|
end
|