playbook_ui 16.9.0.pre.rc.3 → 16.9.0.pre.rc.4
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/docs/_advanced_table_enable_toggle_expansion_rails.html.erb +62 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_enable_toggle_expansion_rails.md +7 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sticky_header.jsx +12 -4
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sticky_header.md +4 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sticky_header_rails.html.erb +16 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sticky_header_rails.md +4 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header.html.erb +16 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header.jsx +12 -5
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header_rails.md +4 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header_react.md +5 -3
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +58 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown.html.erb +2 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +7 -1
- data/app/pb_kits/playbook/pb_select/select.rb +9 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky.html.erb +85 -83
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky.jsx +88 -86
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky.md +3 -1
- data/app/pb_kits/playbook/pb_text_input/text_input.rb +9 -0
- data/app/pb_kits/playbook/pb_time_picker/_time_picker.scss +26 -3
- data/app/pb_kits/playbook/pb_time_picker/docs/_time_picker_default.md +3 -1
- data/app/pb_kits/playbook/pb_time_picker/docs/_time_picker_on_handler.html.erb +24 -0
- data/app/pb_kits/playbook/pb_time_picker/docs/_time_picker_on_handler_rails.md +6 -0
- data/app/pb_kits/playbook/pb_time_picker/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_time_picker/index.ts +771 -30
- data/app/pb_kits/playbook/pb_time_picker/time_picker.html.erb +168 -1
- data/app/pb_kits/playbook/pb_time_picker/time_picker.rb +53 -38
- data/dist/chunks/{_typeahead-DA__Kgp5.js → _typeahead-DKlUinmj.js} +1 -1
- data/dist/chunks/{lazysizes-B7xYodB-.js → time_picker_helper-Bx8nzyM8.js} +1 -1
- data/dist/chunks/vendor.js +4 -4
- data/dist/menu.yml +3 -3
- 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/time_picker_field.rb +6 -3
- data/lib/playbook/version.rb +1 -1
- metadata +9 -5
- /data/app/pb_kits/playbook/pb_time_picker/docs/{_time_picker_on_handler.md → _time_picker_on_handler_react.md} +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f17c4655e2a4b80fd14e4abb8a3c155cf75b89c71c4b6be4b0b5220a2f2fb9ef
|
|
4
|
+
data.tar.gz: 2ad9638177b35d44155813d7436599bf5cf4a962b303eff2acb8d7708c5d70bf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b549ef4f057161685df07f751c2ed6939e0e9f7098776a2d59332cedac1189ac2f05b8e98c22eb978f34a5bd81bec32e1b1c498f3588d637590207b422bcd570
|
|
7
|
+
data.tar.gz: 1ae761f8f4514bbcd3db95149c168c8ebf972b62d5f2e078d0d689f8d2c6197ee80826c372b8bbc2a2c89ecfac51e1bdaf40ad9806f463352789ea98fa2f232a
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<%
|
|
2
|
+
column_definitions = [
|
|
3
|
+
{
|
|
4
|
+
accessor: "year",
|
|
5
|
+
label: "Year",
|
|
6
|
+
cellAccessors: ["quarter", "month", "day"],
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
accessor: "newEnrollments",
|
|
10
|
+
label: "New Enrollments",
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
accessor: "scheduledMeetings",
|
|
14
|
+
label: "Scheduled Meetings",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
accessor: "attendanceRate",
|
|
18
|
+
label: "Attendance Rate",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
accessor: "completedClasses",
|
|
22
|
+
label: "Completed Classes",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
accessor: "classCompletionRate",
|
|
26
|
+
label: "Class Completion Rate",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
accessor: "graduatedStudents",
|
|
30
|
+
label: "Graduated Students",
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
subrow_headers = ["Quarter", "Month", "Day"]
|
|
35
|
+
%>
|
|
36
|
+
|
|
37
|
+
<%= pb_rails("title", props: { size: 4, text: "Normal Structure", margin_bottom: "sm" }) %>
|
|
38
|
+
|
|
39
|
+
<%= pb_rails("advanced_table", props: {
|
|
40
|
+
id: "enable-toggle-expansion-normal",
|
|
41
|
+
table_data: @table_data,
|
|
42
|
+
column_definitions: column_definitions,
|
|
43
|
+
enable_toggle_expansion: "all"
|
|
44
|
+
}) %>
|
|
45
|
+
|
|
46
|
+
<%= pb_rails("title", props: { size: 4, text: "Subcomponent Structure", margin_top: "lg", margin_bottom: "sm" }) %>
|
|
47
|
+
|
|
48
|
+
<%= pb_rails("advanced_table", props: { id: "enable-toggle-expansion-subcomponents" }) do %>
|
|
49
|
+
<%= pb_rails("advanced_table/table_header", props: {
|
|
50
|
+
table_id: "enable-toggle-expansion-subcomponents",
|
|
51
|
+
table_data: @table_data,
|
|
52
|
+
column_definitions: column_definitions,
|
|
53
|
+
enable_toggle_expansion: "all"
|
|
54
|
+
}) %>
|
|
55
|
+
<%= pb_rails("advanced_table/table_body", props: {
|
|
56
|
+
table_id: "enable-toggle-expansion-subcomponents",
|
|
57
|
+
table_data: @table_data,
|
|
58
|
+
column_definitions: column_definitions,
|
|
59
|
+
subrow_headers: subrow_headers,
|
|
60
|
+
enable_toggle_expansion: "all"
|
|
61
|
+
}) %>
|
|
62
|
+
<% end %>
|
data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_enable_toggle_expansion_rails.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
`enable_toggle_expansion` controls where AdvancedTable renders toggle-all expansion controls. It accepts `"header"`, `"all"`, or `"none"` and defaults to `"header"`.
|
|
2
|
+
|
|
3
|
+
When using the normal Rails structure, pass `enable_toggle_expansion` to `advanced_table`. The parent kit renders its own `table_header` and `table_body`, so the prop is passed down automatically.
|
|
4
|
+
|
|
5
|
+
When using the Rails subcomponent structure, pass `enable_toggle_expansion` directly to the subcomponents that need it. `advanced_table/table_header` uses it for the table header toggle-all button. **NOTE**: you must pass `table_data` to `advanced_table/table_header` as well so it can detect whether expandable rows exist. `advanced_table/table_body` uses it for nested subrow header toggle controls, such as when `subrow_headers` is present.
|
|
6
|
+
|
|
7
|
+
Use `"all"` when you want toggle-all controls in both the table header and subrow headers. Use `"header"` when you only want the table header toggle-all control. Use `"none"` to suppress the header toggle-all control.
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import React from "react"
|
|
2
2
|
import AdvancedTable from '../../pb_advanced_table/_advanced_table'
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
const tableData = Array.from({ length: 15 }, (_, index) => ({
|
|
5
|
+
year: String(2020 + index),
|
|
6
|
+
newEnrollments: String(20 + index),
|
|
7
|
+
scheduledMeetings: String(10 + index),
|
|
8
|
+
attendanceRate: `${50 + index}%`,
|
|
9
|
+
completedClasses: String(3 + index),
|
|
10
|
+
classCompletionRate: `${30 + index}%`,
|
|
11
|
+
graduatedStudents: String(19 + index),
|
|
12
|
+
}))
|
|
4
13
|
|
|
5
14
|
const AdvancedTableStickyHeader = (props) => {
|
|
6
15
|
const columnDefinitions = [
|
|
7
16
|
{
|
|
8
17
|
accessor: "year",
|
|
9
18
|
label: "Year",
|
|
10
|
-
cellAccessors: ["quarter", "month", "day"],
|
|
11
19
|
},
|
|
12
20
|
{
|
|
13
21
|
accessor: "newEnrollments",
|
|
@@ -40,11 +48,11 @@ const AdvancedTableStickyHeader = (props) => {
|
|
|
40
48
|
}
|
|
41
49
|
|
|
42
50
|
return (
|
|
43
|
-
<div>
|
|
51
|
+
<div style={{ maxHeight: "320px", overflowY: "auto" }}>
|
|
44
52
|
<AdvancedTable
|
|
45
53
|
columnDefinitions={columnDefinitions}
|
|
46
54
|
responsive="none"
|
|
47
|
-
tableData={
|
|
55
|
+
tableData={tableData}
|
|
48
56
|
tableProps={tableProps}
|
|
49
57
|
{...props}
|
|
50
58
|
/>
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
The `TableProps` prop can also be used to render a sticky header for the Advanced Table.
|
|
2
2
|
|
|
3
|
+
This doc example uses a scroll container with flat rows so sticky behavior is visible in the docs without expanding subrows. Scroll inside the preview to see the header stick.
|
|
4
|
+
|
|
5
|
+
This example builds flat table data inline for the docs preview. For typical `tableData` setup, see [Default (Required Props)](/kits/advanced_table/default/react#advanced_table_default).
|
|
6
|
+
|
|
3
7
|
This doc example showcases how to set a sticky header for a nonresponsive table (see the `responsive` prop set to "none"). To achieve sticky header AND responsive functionality, see the "Sticky Header for Responsive Table" doc example below.
|
data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sticky_header_rails.html.erb
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
{
|
|
3
3
|
accessor: "year",
|
|
4
4
|
label: "Year",
|
|
5
|
-
cellAccessors: ["quarter", "month", "day"],
|
|
6
5
|
},
|
|
7
6
|
{
|
|
8
7
|
accessor: "newEnrollments",
|
|
@@ -30,4 +29,19 @@
|
|
|
30
29
|
}
|
|
31
30
|
] %>
|
|
32
31
|
|
|
33
|
-
|
|
32
|
+
<% table_data = 15.times.map do |index|
|
|
33
|
+
{
|
|
34
|
+
year: (2020 + index).to_s,
|
|
35
|
+
id: (2020 + index).to_s,
|
|
36
|
+
newEnrollments: (20 + index).to_s,
|
|
37
|
+
scheduledMeetings: (10 + index).to_s,
|
|
38
|
+
attendanceRate: "#{50 + index}%",
|
|
39
|
+
completedClasses: (3 + index).to_s,
|
|
40
|
+
classCompletionRate: "#{30 + index}%",
|
|
41
|
+
graduatedStudents: (19 + index).to_s,
|
|
42
|
+
}
|
|
43
|
+
end %>
|
|
44
|
+
|
|
45
|
+
<div style="max-height: 320px; overflow-y: auto;">
|
|
46
|
+
<%= pb_rails("advanced_table", props: { id: "sticky_header_table", table_data: table_data, column_definitions: column_definitions, responsive: "none", table_props: { sticky: true }}) %>
|
|
47
|
+
</div>
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
The `table_props` prop can also be used to render a sticky header for the Advanced Table.
|
|
2
2
|
|
|
3
|
+
This doc example uses a scroll container with flat rows so sticky behavior is visible in the docs without expanding subrows. Scroll inside the preview to see the header stick.
|
|
4
|
+
|
|
5
|
+
This example builds flat table data inline for the docs preview. For typical `table_data` setup, see [Default (Required Props)](/kits/advanced_table/default/rails#advanced_table_beta).
|
|
6
|
+
|
|
3
7
|
This doc example showcases how to set a sticky header for a nonresponsive table (see the `responsive` prop set to "none"). To achieve sticky header AND responsive functionality, see the "[Sticky Header for Responsive Table](https://playbook.powerapp.cloud/kits/advanced_table/react#sticky-header-for-responsive-table)" doc example below.
|
data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header.html.erb
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
{
|
|
3
3
|
accessor: "year",
|
|
4
4
|
label: "Year",
|
|
5
|
-
cellAccessors: ["quarter", "month", "day"],
|
|
6
5
|
},
|
|
7
6
|
{
|
|
8
7
|
accessor: "newEnrollments",
|
|
@@ -30,4 +29,19 @@
|
|
|
30
29
|
}
|
|
31
30
|
] %>
|
|
32
31
|
|
|
33
|
-
|
|
32
|
+
<% table_data = 15.times.map do |index|
|
|
33
|
+
{
|
|
34
|
+
year: (2020 + index).to_s,
|
|
35
|
+
id: (2020 + index).to_s,
|
|
36
|
+
newEnrollments: (20 + index).to_s,
|
|
37
|
+
scheduledMeetings: (10 + index).to_s,
|
|
38
|
+
attendanceRate: "#{50 + index}%",
|
|
39
|
+
completedClasses: (3 + index).to_s,
|
|
40
|
+
classCompletionRate: "#{30 + index}%",
|
|
41
|
+
graduatedStudents: (19 + index).to_s,
|
|
42
|
+
}
|
|
43
|
+
end %>
|
|
44
|
+
|
|
45
|
+
<div style="max-height: 320px; overflow-y: auto;">
|
|
46
|
+
<%= pb_rails("advanced_table", props: { id: "table_props_sticky_table", table_data: table_data, column_definitions: column_definitions, table_props: { sticky: true }}) %>
|
|
47
|
+
</div>
|
data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header.jsx
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import React from "react"
|
|
2
2
|
import AdvancedTable from '../../pb_advanced_table/_advanced_table'
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
const tableData = Array.from({ length: 15 }, (_, index) => ({
|
|
5
|
+
year: String(2020 + index),
|
|
6
|
+
newEnrollments: String(20 + index),
|
|
7
|
+
scheduledMeetings: String(10 + index),
|
|
8
|
+
attendanceRate: `${50 + index}%`,
|
|
9
|
+
completedClasses: String(3 + index),
|
|
10
|
+
classCompletionRate: `${30 + index}%`,
|
|
11
|
+
graduatedStudents: String(19 + index),
|
|
12
|
+
}))
|
|
4
13
|
|
|
5
14
|
const AdvancedTableTablePropsStickyHeader = (props) => {
|
|
6
15
|
const columnDefinitions = [
|
|
7
16
|
{
|
|
8
17
|
accessor: "year",
|
|
9
18
|
label: "Year",
|
|
10
|
-
cellAccessors: ["quarter", "month", "day"],
|
|
11
19
|
},
|
|
12
20
|
{
|
|
13
21
|
accessor: "newEnrollments",
|
|
@@ -40,11 +48,10 @@ const AdvancedTableTablePropsStickyHeader = (props) => {
|
|
|
40
48
|
}
|
|
41
49
|
|
|
42
50
|
return (
|
|
43
|
-
<div>
|
|
51
|
+
<div style={{ maxHeight: "320px", overflowY: "auto" }}>
|
|
44
52
|
<AdvancedTable
|
|
45
53
|
columnDefinitions={columnDefinitions}
|
|
46
|
-
|
|
47
|
-
tableData={MOCK_DATA}
|
|
54
|
+
tableData={tableData}
|
|
48
55
|
tableProps={tableProps}
|
|
49
56
|
{...props}
|
|
50
57
|
/>
|
data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header_rails.md
CHANGED
|
@@ -2,6 +2,10 @@ Create a sticky header that works for responsive Advanced Tables by setting `sti
|
|
|
2
2
|
|
|
3
3
|
**NOTE**: This behavior requires a `max_height` to work. The header is sticky within the table container, allowing for it to work along with the first column stickiness of a responsive table on smaller screen sizes.
|
|
4
4
|
|
|
5
|
+
Scroll inside the table preview to see the header stick.
|
|
6
|
+
|
|
7
|
+
This example builds flat table data inline for the docs preview. For typical `table_data` setup, see [Default (Required Props)](/kits/advanced_table/default/rails#advanced_table_beta).
|
|
8
|
+
|
|
5
9
|
Expand the table above to see this in action.
|
|
6
10
|
|
|
7
11
|
A sticky header on a nonresponsive table is demonstrated in the ["Sticky Header"](https://playbook.powerapp.cloud/kits/advanced_table#sticky-header) doc example above.
|
data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header_react.md
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
Create a sticky header that works for responsive Advanced Tables by setting `sticky: true` via `tableProps` and
|
|
1
|
+
Create a sticky header that works for responsive Advanced Tables by setting `sticky: true` via `tableProps` and wrapping the table in a scroll container (or using `maxHeight`).
|
|
2
2
|
|
|
3
|
-
**NOTE**:
|
|
3
|
+
**NOTE**: The header is sticky within the table scroll area. The live example uses flat rows so you can scroll inside the preview without expanding subrows.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This example builds flat table data inline for the docs preview. For typical `tableData` setup, see [Default (Required Props)](/kits/advanced_table/default/react#advanced_table_default).
|
|
6
|
+
|
|
7
|
+
Expand the table above to see responsive behavior in action.
|
|
6
8
|
|
|
7
9
|
A sticky header on a nonresponsive table is demonstrated in the ["Sticky Header"](https://playbook.powerapp.cloud/kits/advanced_table/react#sticky-header) doc example above.
|
|
@@ -3,6 +3,7 @@ examples:
|
|
|
3
3
|
- advanced_table_beta: Default (Required Props)
|
|
4
4
|
- advanced_table_loading: Loading State
|
|
5
5
|
- advanced_table_beta_subrow_headers: SubRow Headers
|
|
6
|
+
- advanced_table_enable_toggle_expansion_rails: Enable Toggle Expansion
|
|
6
7
|
- advanced_table_collapsible_trail_rails: Collapsible Trail
|
|
7
8
|
- advanced_table_table_props: Table Props
|
|
8
9
|
- advanced_table_sticky_header_rails: Sticky Header
|
|
@@ -21,6 +21,58 @@ import {
|
|
|
21
21
|
handleClickOutside,
|
|
22
22
|
} from "./utilities";
|
|
23
23
|
|
|
24
|
+
function serializeDropdownFilterResetDefault(
|
|
25
|
+
variant: "default" | "subtle" | "quickpick" | undefined,
|
|
26
|
+
multiSelect: boolean,
|
|
27
|
+
defaultValue: GenericObject | GenericObject[] | string | undefined,
|
|
28
|
+
dropdownOptions: GenericObject[] | GenericObject | undefined,
|
|
29
|
+
): string | undefined {
|
|
30
|
+
const optionList: GenericObject[] = Array.isArray(dropdownOptions)
|
|
31
|
+
? dropdownOptions
|
|
32
|
+
: [];
|
|
33
|
+
const optionDefaultId = (option: GenericObject | undefined): string | undefined => {
|
|
34
|
+
if (!option) return undefined;
|
|
35
|
+
|
|
36
|
+
const id = option.id;
|
|
37
|
+
if (id != null && id !== "") return String(id);
|
|
38
|
+
|
|
39
|
+
const matched = optionList.find((listOption: GenericObject) => (
|
|
40
|
+
(option.value != null && listOption.value === option.value) ||
|
|
41
|
+
(option.label != null && listOption.label === option.label)
|
|
42
|
+
));
|
|
43
|
+
|
|
44
|
+
if (matched?.id != null && matched.id !== "") return String(matched.id);
|
|
45
|
+
return undefined;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
if (variant === "quickpick") {
|
|
49
|
+
if (typeof defaultValue === "string" && defaultValue) {
|
|
50
|
+
const matched = optionList.find(
|
|
51
|
+
(opt: GenericObject) => opt.label?.toLowerCase() === defaultValue.toLowerCase()
|
|
52
|
+
);
|
|
53
|
+
if (matched?.id != null && matched.id !== "") return String(matched.id);
|
|
54
|
+
}
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
if (multiSelect) {
|
|
58
|
+
const arr = Array.isArray(defaultValue)
|
|
59
|
+
? defaultValue
|
|
60
|
+
: defaultValue && typeof defaultValue === "object" && Object.keys(defaultValue).length
|
|
61
|
+
? [defaultValue as GenericObject]
|
|
62
|
+
: [];
|
|
63
|
+
if (!arr.length) return undefined;
|
|
64
|
+
const ids = arr
|
|
65
|
+
.map((v) => optionDefaultId(v as GenericObject))
|
|
66
|
+
.filter((id) => id != null && id !== "");
|
|
67
|
+
return ids.length ? ids.join(",") : undefined;
|
|
68
|
+
}
|
|
69
|
+
if (defaultValue && typeof defaultValue === "object" && !Array.isArray(defaultValue)) {
|
|
70
|
+
const id = optionDefaultId(defaultValue as GenericObject);
|
|
71
|
+
if (id) return id;
|
|
72
|
+
}
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
|
|
24
76
|
type CustomQuickPickDate = {
|
|
25
77
|
label: string;
|
|
26
78
|
value: string[] | { timePeriod: string; amount: number };
|
|
@@ -157,6 +209,11 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
|
157
209
|
initialSelected
|
|
158
210
|
);
|
|
159
211
|
|
|
212
|
+
const filterResetDefaultSerialized = useMemo(
|
|
213
|
+
() => serializeDropdownFilterResetDefault(variant, multiSelect, defaultValue, dropdownOptions),
|
|
214
|
+
[variant, multiSelect, defaultValue, dropdownOptions]
|
|
215
|
+
);
|
|
216
|
+
|
|
160
217
|
const [isInputFocused, setIsInputFocused] = useState(false);
|
|
161
218
|
const [hasTriggerSubcomponent, setHasTriggerSubcomponent] = useState(true);
|
|
162
219
|
const [hasContainerSubcomponent, setHasContainerSubcomponent] =
|
|
@@ -432,6 +489,7 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
|
432
489
|
<div {...ariaProps}
|
|
433
490
|
{...dataProps}
|
|
434
491
|
{...htmlProps}
|
|
492
|
+
{...(filterResetDefaultSerialized ? { "data-default-value": filterResetDefaultSerialized } : {})}
|
|
435
493
|
className={classes}
|
|
436
494
|
id={id}
|
|
437
495
|
ref={outerDivRef}
|
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
<% end %>
|
|
13
13
|
<div class="dropdown_wrapper<%= error_class %>" style="position: relative">
|
|
14
14
|
<input
|
|
15
|
+
<% if input_default_value.present? %>
|
|
15
16
|
data-default-value="<%= input_default_value %>"
|
|
17
|
+
<% end %>
|
|
16
18
|
data-dropdown-selected-option
|
|
17
19
|
name="<%= object.name %><%= '[]' if object.multi_select %>"
|
|
18
20
|
style="display: none"
|
|
@@ -51,6 +51,7 @@ test('generated default kit and classname', () => {
|
|
|
51
51
|
const kit = screen.getByTestId(testId)
|
|
52
52
|
expect(kit).toBeInTheDocument()
|
|
53
53
|
expect(kit).toHaveClass('pb_dropdown_default')
|
|
54
|
+
expect(kit).not.toHaveAttribute('data-default-value')
|
|
54
55
|
})
|
|
55
56
|
|
|
56
57
|
test('generated default Trigger and Container when none passed in', () => {
|
|
@@ -433,12 +434,16 @@ test("defaultValue works with multiSelect", () => {
|
|
|
433
434
|
render(
|
|
434
435
|
<Dropdown
|
|
435
436
|
data={{ testid: testId }}
|
|
436
|
-
defaultValue={[
|
|
437
|
+
defaultValue={[
|
|
438
|
+
{ label: options[0].label, value: options[0].value },
|
|
439
|
+
{ label: options[2].label, value: options[2].value },
|
|
440
|
+
]}
|
|
437
441
|
multiSelect
|
|
438
442
|
options={options}
|
|
439
443
|
/>
|
|
440
444
|
)
|
|
441
445
|
const kit = screen.getByTestId(testId)
|
|
446
|
+
expect(kit).toHaveAttribute("data-default-value", "United-states,pakistan")
|
|
442
447
|
expect(kit.querySelectorAll(".pb_form_pill_kit.pb_form_pill_primary")).toHaveLength(2)
|
|
443
448
|
const option2 = Array.from(kit.querySelectorAll(".pb_dropdown_option_list"));
|
|
444
449
|
const firstOpt = options[0].label
|
|
@@ -499,6 +504,7 @@ test("quickpick variant accepts string defaultValue", () => {
|
|
|
499
504
|
const trigger = kit.querySelector('.pb_dropdown_trigger')
|
|
500
505
|
|
|
501
506
|
expect(trigger).toHaveTextContent("This Month")
|
|
507
|
+
expect(kit).toHaveAttribute("data-default-value", "quickpick-this-month")
|
|
502
508
|
})
|
|
503
509
|
|
|
504
510
|
test("quickpick attaches _dropdownRef to DOM element when id is provided", () => {
|
|
@@ -50,9 +50,18 @@ module Playbook
|
|
|
50
50
|
def validation_data
|
|
51
51
|
fields = input_options[:data] || {}
|
|
52
52
|
fields[:message] = validation_message unless validation_message.blank?
|
|
53
|
+
dv = filter_reset_default_value
|
|
54
|
+
fields[:default_value] = dv if dv.present?
|
|
53
55
|
fields
|
|
54
56
|
end
|
|
55
57
|
|
|
58
|
+
def filter_reset_default_value
|
|
59
|
+
s = selected
|
|
60
|
+
return if s.blank?
|
|
61
|
+
|
|
62
|
+
s.join(",")
|
|
63
|
+
end
|
|
64
|
+
|
|
56
65
|
# Same resolved id as the native +<select>+ (+all_attributes[:id]+) for label +for+.
|
|
57
66
|
def select_input_id
|
|
58
67
|
all_attributes[:id].presence
|
|
@@ -1,83 +1,85 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
<
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
<
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
<
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
<
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
<
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
<
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
<
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
<
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
1
|
+
<div style="max-height: 320px; overflow-y: auto;">
|
|
2
|
+
<%= pb_rails("table", props: { sticky: true }) do %>
|
|
3
|
+
<thead>
|
|
4
|
+
<tr>
|
|
5
|
+
<th>Column 1</th>
|
|
6
|
+
<th>Column 2</th>
|
|
7
|
+
<th>Column 3</th>
|
|
8
|
+
<th>Column 4</th>
|
|
9
|
+
<th>Column 5</th>
|
|
10
|
+
</tr>
|
|
11
|
+
</thead>
|
|
12
|
+
<tbody>
|
|
13
|
+
<tr>
|
|
14
|
+
<td>Value 1</td>
|
|
15
|
+
<td>Value 2</td>
|
|
16
|
+
<td>Value 3</td>
|
|
17
|
+
<td>Value 4</td>
|
|
18
|
+
<td>Value 5</td>
|
|
19
|
+
</tr>
|
|
20
|
+
<tr>
|
|
21
|
+
<td>Value 1</td>
|
|
22
|
+
<td>Value 2</td>
|
|
23
|
+
<td>Value 3</td>
|
|
24
|
+
<td>Value 4</td>
|
|
25
|
+
<td>Value 5</td>
|
|
26
|
+
</tr>
|
|
27
|
+
<tr>
|
|
28
|
+
<td>Value 1</td>
|
|
29
|
+
<td>Value 2</td>
|
|
30
|
+
<td>Value 3</td>
|
|
31
|
+
<td>Value 4</td>
|
|
32
|
+
<td>Value 5</td>
|
|
33
|
+
</tr>
|
|
34
|
+
<tr>
|
|
35
|
+
<td>Value 1</td>
|
|
36
|
+
<td>Value 2</td>
|
|
37
|
+
<td>Value 3</td>
|
|
38
|
+
<td>Value 4</td>
|
|
39
|
+
<td>Value 5</td>
|
|
40
|
+
</tr>
|
|
41
|
+
<tr>
|
|
42
|
+
<td>Value 1</td>
|
|
43
|
+
<td>Value 2</td>
|
|
44
|
+
<td>Value 3</td>
|
|
45
|
+
<td>Value 4</td>
|
|
46
|
+
<td>Value 5</td>
|
|
47
|
+
</tr>
|
|
48
|
+
<tr>
|
|
49
|
+
<td>Value 1</td>
|
|
50
|
+
<td>Value 2</td>
|
|
51
|
+
<td>Value 3</td>
|
|
52
|
+
<td>Value 4</td>
|
|
53
|
+
<td>Value 5</td>
|
|
54
|
+
</tr>
|
|
55
|
+
<tr>
|
|
56
|
+
<td>Value 1</td>
|
|
57
|
+
<td>Value 2</td>
|
|
58
|
+
<td>Value 3</td>
|
|
59
|
+
<td>Value 4</td>
|
|
60
|
+
<td>Value 5</td>
|
|
61
|
+
</tr>
|
|
62
|
+
<tr>
|
|
63
|
+
<td>Value 1</td>
|
|
64
|
+
<td>Value 2</td>
|
|
65
|
+
<td>Value 3</td>
|
|
66
|
+
<td>Value 4</td>
|
|
67
|
+
<td>Value 5</td>
|
|
68
|
+
</tr>
|
|
69
|
+
<tr>
|
|
70
|
+
<td>Value 1</td>
|
|
71
|
+
<td>Value 2</td>
|
|
72
|
+
<td>Value 3</td>
|
|
73
|
+
<td>Value 4</td>
|
|
74
|
+
<td>Value 5</td>
|
|
75
|
+
</tr>
|
|
76
|
+
<tr>
|
|
77
|
+
<td>Value 1</td>
|
|
78
|
+
<td>Value 2</td>
|
|
79
|
+
<td>Value 3</td>
|
|
80
|
+
<td>Value 4</td>
|
|
81
|
+
<td>Value 5</td>
|
|
82
|
+
</tr>
|
|
83
|
+
</tbody>
|
|
84
|
+
<% end %>
|
|
85
|
+
</div>
|