playbook_ui 14.16.0.pre.rc.6 → 14.17.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.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +34 -2
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +86 -84
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +10 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination.jsx +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows.html.erb +39 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_no_subrows.html.erb +33 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_no_subrows_rails.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_rails.md +6 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_advanced_table/index.js +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +4 -2
- data/app/pb_kits/playbook/pb_advanced_table/table_header.html.erb +19 -9
- data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +38 -1
- data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +49 -37
- data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +39 -0
- data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.tsx +1 -1
- data/app/pb_kits/playbook/pb_button/_button.scss +5 -5
- data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.tsx +1 -1
- data/app/pb_kits/playbook/pb_draggable/_draggable.scss +115 -5
- data/app/pb_kits/playbook/pb_draggable/_draggable.tsx +6 -4
- data/app/pb_kits/playbook/pb_draggable/context/index.tsx +35 -9
- data/app/pb_kits/playbook/pb_draggable/context/types.ts +35 -28
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones.jsx +184 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones.md +5 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones_colors.jsx +97 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones_colors.md +1 -0
- data/app/pb_kits/playbook/pb_draggable/subcomponents/DraggableContainer.tsx +11 -2
- data/app/pb_kits/playbook/pb_draggable/subcomponents/DraggableItem.tsx +65 -6
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_breakpoints.html.erb +3 -0
- data/app/pb_kits/playbook/pb_drawer/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_filter/Filter/SortMenu.tsx +2 -1
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.scss +2 -2
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with.html.erb +67 -0
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +67 -0
- data/app/pb_kits/playbook/pb_gauge/_gauge.tsx +1 -1
- data/app/pb_kits/playbook/pb_icon/_icon.scss +8 -1
- data/app/pb_kits/playbook/pb_icon/docs/_icon_color.html.erb +10 -4
- data/app/pb_kits/playbook/pb_icon/docs/_icon_color.jsx +49 -24
- data/app/pb_kits/playbook/pb_icon_button/_icon_button.tsx +4 -1
- data/app/pb_kits/playbook/pb_icon_button/docs/_icon_button_click.jsx +13 -0
- data/app/pb_kits/playbook/pb_icon_button/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_icon_button/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_lightbox/Carousel/Slide.tsx +1 -1
- data/app/pb_kits/playbook/pb_lightbox/Carousel/Slides.tsx +1 -1
- data/app/pb_kits/playbook/pb_lightbox/Carousel/Thumbnails.tsx +1 -1
- data/app/pb_kits/playbook/pb_line_graph/_line_graph.tsx +1 -1
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.scss +23 -0
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +26 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_error.html.erb +72 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_error.jsx +97 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_label.html.erb +71 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_label.jsx +91 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +4 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +3 -1
- data/app/pb_kits/playbook/pb_multi_level_select/index.js +105 -0
- data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.rb +10 -0
- data/app/pb_kits/playbook/pb_nav/_nav.scss +5 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +29 -11
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_default.html.erb +1 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.html.erb +4 -4
- data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.rb +2 -0
- data/app/pb_kits/playbook/pb_table/_table.tsx +4 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_borderless.jsx +50 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_borderless_react.md +1 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_floating.jsx +59 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_floating_react.md +1 -0
- data/app/pb_kits/playbook/pb_table/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_table/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_table/styles/_headers.scss +76 -0
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_head.tsx +11 -1
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_header.tsx +11 -1
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_row.tsx +5 -0
- data/app/pb_kits/playbook/pb_table/table.test.js +17 -0
- data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.tsx +1 -1
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.scss +4 -0
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +3 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_disabled.html.erb +19 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_disabled.jsx +23 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +3 -0
- data/app/pb_kits/playbook/pb_user/_user.tsx +78 -13
- data/app/pb_kits/playbook/pb_user/docs/_user_font_options.html.erb +22 -0
- data/app/pb_kits/playbook/pb_user/docs/_user_font_options.jsx +40 -0
- data/app/pb_kits/playbook/pb_user/docs/_user_font_options_rails.md +5 -0
- data/app/pb_kits/playbook/pb_user/docs/_user_font_options_react.md +5 -0
- data/app/pb_kits/playbook/pb_user/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_user/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_user/user.html.erb +27 -6
- data/app/pb_kits/playbook/pb_user/user.rb +17 -1
- data/app/pb_kits/playbook/pb_user/user.test.js +182 -1
- data/app/pb_kits/playbook/tokens/_colors.scss +1 -4
- data/app/pb_kits/playbook/utilities/object.test.js +139 -1
- data/app/pb_kits/playbook/utilities/object.ts +86 -0
- data/app/pb_kits/playbook/utilities/text.ts +1 -1
- data/dist/chunks/_typeahead-N-EFroAX.js +22 -0
- data/dist/chunks/_weekday_stacked-Db780bKR.js +45 -0
- data/dist/chunks/{lib-BeKPJYlk.js → lib-Co5y3V4K.js} +2 -2
- data/dist/chunks/{pb_form_validation-BvDxpfs-.js → pb_form_validation-DMajaRt3.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +1 -1
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/forms/builder/multi_level_select_field.rb +2 -0
- data/lib/playbook/version.rb +2 -2
- metadata +32 -8
- data/dist/chunks/_typeahead-CRAPc8k-.js +0 -22
- data/dist/chunks/_weekday_stacked-T0kFfioG.js +0 -45
- /data/app/pb_kits/playbook/pb_advanced_table/docs/{_advanced_table_selectable_rows_no_subrows.md → _advanced_table_selectable_rows_no_subrows_react.md} +0 -0
- /data/app/pb_kits/playbook/pb_advanced_table/docs/{_advanced_table_selectable_rows.md → _advanced_table_selectable_rows_react.md} +0 -0
@@ -10,6 +10,16 @@
|
|
10
10
|
.pb_multi_level_select {
|
11
11
|
font-family: $font-family-base;
|
12
12
|
|
13
|
+
&.error {
|
14
|
+
.wrapper {
|
15
|
+
.input_wrapper {
|
16
|
+
border-color: $error;
|
17
|
+
}
|
18
|
+
}
|
19
|
+
[class*=pb_body_kit_negative] {
|
20
|
+
margin-top: $space_xxs;
|
21
|
+
}
|
22
|
+
}
|
13
23
|
.wrapper {
|
14
24
|
position: relative;
|
15
25
|
|
@@ -92,4 +102,17 @@
|
|
92
102
|
.open {
|
93
103
|
display: block;
|
94
104
|
}
|
105
|
+
|
106
|
+
&.dark {
|
107
|
+
&.error {
|
108
|
+
.wrapper {
|
109
|
+
.input_wrapper {
|
110
|
+
border-color: $error_dark;
|
111
|
+
}
|
112
|
+
}
|
113
|
+
[class*=pb_body_kit_negative] {
|
114
|
+
color: $error_dark;
|
115
|
+
}
|
116
|
+
}
|
117
|
+
}
|
95
118
|
}
|
@@ -9,6 +9,8 @@ import {
|
|
9
9
|
} from "../utilities/props";
|
10
10
|
import Icon from "../pb_icon/_icon";
|
11
11
|
import FormPill from "../pb_form_pill/_form_pill";
|
12
|
+
import Body from "../pb_body/_body";
|
13
|
+
import Caption from "../pb_caption/_caption";
|
12
14
|
import { cloneDeep } from "lodash";
|
13
15
|
import MultiLevelSelectOptions from "./multi_level_select_options";
|
14
16
|
import MultiLevelSelectContext from "./context";
|
@@ -35,11 +37,14 @@ type MultiLevelSelectProps = {
|
|
35
37
|
className?: string
|
36
38
|
data?: { [key: string]: string }
|
37
39
|
disabled?: boolean
|
40
|
+
error?: string
|
38
41
|
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
39
42
|
id?: string
|
40
43
|
inputDisplay?: "pills" | "none"
|
41
44
|
inputName?: string
|
45
|
+
label?: string
|
42
46
|
name?: string
|
47
|
+
required?: boolean
|
43
48
|
returnAllSelected?: boolean
|
44
49
|
treeData?: { [key: string]: string; }[] | any
|
45
50
|
onChange?: (event: { target: { name?: string; value: any } }) => void
|
@@ -56,11 +61,14 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>((pr
|
|
56
61
|
className,
|
57
62
|
data = {},
|
58
63
|
disabled = false,
|
64
|
+
error,
|
59
65
|
htmlOptions = {},
|
60
66
|
id,
|
61
67
|
inputDisplay = "pills",
|
62
68
|
inputName,
|
63
69
|
name,
|
70
|
+
label,
|
71
|
+
required = false,
|
64
72
|
returnAllSelected = false,
|
65
73
|
treeData,
|
66
74
|
onChange = () => null,
|
@@ -77,6 +85,7 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>((pr
|
|
77
85
|
const htmlProps = buildHtmlProps(htmlOptions);
|
78
86
|
const classes = classnames(
|
79
87
|
buildCss("pb_multi_level_select"),
|
88
|
+
error && "error",
|
80
89
|
globalProps(props),
|
81
90
|
className
|
82
91
|
);
|
@@ -439,6 +448,12 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>((pr
|
|
439
448
|
className={classes}
|
440
449
|
id={id}
|
441
450
|
>
|
451
|
+
{label &&
|
452
|
+
<Caption
|
453
|
+
marginBottom="xs"
|
454
|
+
text={label}
|
455
|
+
/>
|
456
|
+
}
|
442
457
|
<MultiLevelSelectContext.Provider value={{
|
443
458
|
variant,
|
444
459
|
inputName,
|
@@ -462,6 +477,7 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>((pr
|
|
462
477
|
disabled={disabled}
|
463
478
|
key={selectedItem.id}
|
464
479
|
name={`${name}[]`}
|
480
|
+
required={required}
|
465
481
|
type="hidden"
|
466
482
|
value={selectedItem.id}
|
467
483
|
/>
|
@@ -476,6 +492,7 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>((pr
|
|
476
492
|
disabled={disabled}
|
477
493
|
key={item.id}
|
478
494
|
name={`${name}[]`}
|
495
|
+
required={required}
|
479
496
|
type="hidden"
|
480
497
|
value={item.id}
|
481
498
|
/>
|
@@ -488,6 +505,7 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>((pr
|
|
488
505
|
disabled={disabled}
|
489
506
|
key={item.id}
|
490
507
|
name={`${name}[]`}
|
508
|
+
required={required}
|
491
509
|
type="hidden"
|
492
510
|
value={item.id}
|
493
511
|
/>
|
@@ -548,6 +566,7 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>((pr
|
|
548
566
|
} selected`
|
549
567
|
: "Start typing..."
|
550
568
|
}
|
569
|
+
required={required}
|
551
570
|
value={singleSelectedItem.value || filterItem}
|
552
571
|
/>
|
553
572
|
</div>
|
@@ -580,6 +599,13 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>((pr
|
|
580
599
|
</div>
|
581
600
|
</div>
|
582
601
|
</MultiLevelSelectContext.Provider>
|
602
|
+
{error &&
|
603
|
+
<Body
|
604
|
+
dark={props.dark}
|
605
|
+
status="negative"
|
606
|
+
text={error}
|
607
|
+
/>
|
608
|
+
}
|
583
609
|
</div>
|
584
610
|
);
|
585
611
|
}) as MultiLevelSelectComponent;
|
@@ -0,0 +1,72 @@
|
|
1
|
+
<% treeData = [{
|
2
|
+
label: "Power Home Remodeling",
|
3
|
+
value: "Power Home Remodeling",
|
4
|
+
id: "100",
|
5
|
+
expanded: true,
|
6
|
+
children: [
|
7
|
+
{
|
8
|
+
label: "People",
|
9
|
+
value: "People",
|
10
|
+
id: "101",
|
11
|
+
expanded: true,
|
12
|
+
children: [
|
13
|
+
{
|
14
|
+
label: "Talent Acquisition",
|
15
|
+
value: "Talent Acquisition",
|
16
|
+
id: "102",
|
17
|
+
},
|
18
|
+
{
|
19
|
+
label: "Business Affairs",
|
20
|
+
value: "Business Affairs",
|
21
|
+
id: "103",
|
22
|
+
children: [
|
23
|
+
{
|
24
|
+
label: "Initiatives",
|
25
|
+
value: "Initiatives",
|
26
|
+
id: "104",
|
27
|
+
},
|
28
|
+
{
|
29
|
+
label: "Learning & Development",
|
30
|
+
value: "Learning & Development",
|
31
|
+
id: "105",
|
32
|
+
},
|
33
|
+
],
|
34
|
+
},
|
35
|
+
{
|
36
|
+
label: "People Experience",
|
37
|
+
value: "People Experience",
|
38
|
+
id: "106",
|
39
|
+
},
|
40
|
+
],
|
41
|
+
},
|
42
|
+
{
|
43
|
+
label: "Contact Center",
|
44
|
+
value: "Contact Center",
|
45
|
+
id: "107",
|
46
|
+
children: [
|
47
|
+
{
|
48
|
+
label: "Appointment Management",
|
49
|
+
value: "Appointment Management",
|
50
|
+
id: "108",
|
51
|
+
},
|
52
|
+
{
|
53
|
+
label: "Customer Service",
|
54
|
+
value: "Customer Service",
|
55
|
+
id: "109",
|
56
|
+
},
|
57
|
+
{
|
58
|
+
label: "Energy",
|
59
|
+
value: "Energy",
|
60
|
+
id: "110",
|
61
|
+
},
|
62
|
+
],
|
63
|
+
},
|
64
|
+
],
|
65
|
+
}] %>
|
66
|
+
|
67
|
+
<%= pb_rails("multi_level_select", props: {
|
68
|
+
error: "Please make a valid selection",
|
69
|
+
id: "multi-level-select-error-rails",
|
70
|
+
name: "my_array",
|
71
|
+
tree_data: treeData
|
72
|
+
}) %>
|
@@ -0,0 +1,97 @@
|
|
1
|
+
import React, { useState, useEffect } from "react";
|
2
|
+
import MultiLevelSelect from "../_multi_level_select";
|
3
|
+
|
4
|
+
const treeData = [
|
5
|
+
{
|
6
|
+
label: "Power Home Remodeling",
|
7
|
+
value: "Power Home Remodeling",
|
8
|
+
id: "powerhome1",
|
9
|
+
expanded: true,
|
10
|
+
children: [
|
11
|
+
{
|
12
|
+
label: "People",
|
13
|
+
value: "People",
|
14
|
+
id: "people1",
|
15
|
+
expanded: true,
|
16
|
+
children: [
|
17
|
+
{
|
18
|
+
label: "Talent Acquisition",
|
19
|
+
value: "Talent Acquisition",
|
20
|
+
id: "talent1",
|
21
|
+
},
|
22
|
+
{
|
23
|
+
label: "Business Affairs",
|
24
|
+
value: "Business Affairs",
|
25
|
+
id: "business1",
|
26
|
+
children: [
|
27
|
+
{
|
28
|
+
label: "Initiatives",
|
29
|
+
value: "Initiatives",
|
30
|
+
id: "initiative1",
|
31
|
+
},
|
32
|
+
{
|
33
|
+
label: "Learning & Development",
|
34
|
+
value: "Learning & Development",
|
35
|
+
id: "development1",
|
36
|
+
},
|
37
|
+
],
|
38
|
+
},
|
39
|
+
{
|
40
|
+
label: "People Experience",
|
41
|
+
value: "People Experience",
|
42
|
+
id: "experience1",
|
43
|
+
},
|
44
|
+
],
|
45
|
+
},
|
46
|
+
{
|
47
|
+
label: "Contact Center",
|
48
|
+
value: "Contact Center",
|
49
|
+
id: "contact1",
|
50
|
+
children: [
|
51
|
+
{
|
52
|
+
label: "Appointment Management",
|
53
|
+
value: "Appointment Management",
|
54
|
+
id: "appointment1",
|
55
|
+
},
|
56
|
+
{
|
57
|
+
label: "Customer Service",
|
58
|
+
value: "Customer Service",
|
59
|
+
id: "customer1",
|
60
|
+
},
|
61
|
+
{
|
62
|
+
label: "Energy",
|
63
|
+
value: "Energy",
|
64
|
+
id: "energy1",
|
65
|
+
},
|
66
|
+
],
|
67
|
+
},
|
68
|
+
],
|
69
|
+
},
|
70
|
+
];
|
71
|
+
|
72
|
+
const MultiLevelSelectError = (props) => {
|
73
|
+
const [selectedItems, setSelectedItems] = useState([]);
|
74
|
+
const [errorState, setErrorState] = useState("Please make a valid selection");
|
75
|
+
|
76
|
+
useEffect(() => {
|
77
|
+
if (selectedItems.length === 0) {
|
78
|
+
setErrorState("Please make a valid selection");
|
79
|
+
} else {
|
80
|
+
setErrorState(null);
|
81
|
+
}
|
82
|
+
}, [selectedItems]);
|
83
|
+
|
84
|
+
return (
|
85
|
+
<div>
|
86
|
+
<MultiLevelSelect
|
87
|
+
error={errorState}
|
88
|
+
id="multiselect-error"
|
89
|
+
onSelect={(selectedNodes) => setSelectedItems(selectedNodes)}
|
90
|
+
treeData={treeData}
|
91
|
+
{...props}
|
92
|
+
/>
|
93
|
+
</div>
|
94
|
+
);
|
95
|
+
};
|
96
|
+
|
97
|
+
export default MultiLevelSelectError;
|
@@ -0,0 +1,71 @@
|
|
1
|
+
<% treeData = [{
|
2
|
+
label: "Power Home Remodeling",
|
3
|
+
value: "Power Home Remodeling",
|
4
|
+
id: "100",
|
5
|
+
expanded: true,
|
6
|
+
children: [
|
7
|
+
{
|
8
|
+
label: "People",
|
9
|
+
value: "People",
|
10
|
+
id: "101",
|
11
|
+
expanded: true,
|
12
|
+
children: [
|
13
|
+
{
|
14
|
+
label: "Talent Acquisition",
|
15
|
+
value: "Talent Acquisition",
|
16
|
+
id: "102",
|
17
|
+
},
|
18
|
+
{
|
19
|
+
label: "Business Affairs",
|
20
|
+
value: "Business Affairs",
|
21
|
+
id: "103",
|
22
|
+
children: [
|
23
|
+
{
|
24
|
+
label: "Initiatives",
|
25
|
+
value: "Initiatives",
|
26
|
+
id: "104",
|
27
|
+
},
|
28
|
+
{
|
29
|
+
label: "Learning & Development",
|
30
|
+
value: "Learning & Development",
|
31
|
+
id: "105",
|
32
|
+
},
|
33
|
+
],
|
34
|
+
},
|
35
|
+
{
|
36
|
+
label: "People Experience",
|
37
|
+
value: "People Experience",
|
38
|
+
id: "106",
|
39
|
+
},
|
40
|
+
],
|
41
|
+
},
|
42
|
+
{
|
43
|
+
label: "Contact Center",
|
44
|
+
value: "Contact Center",
|
45
|
+
id: "107",
|
46
|
+
children: [
|
47
|
+
{
|
48
|
+
label: "Appointment Management",
|
49
|
+
value: "Appointment Management",
|
50
|
+
id: "108",
|
51
|
+
},
|
52
|
+
{
|
53
|
+
label: "Customer Service",
|
54
|
+
value: "Customer Service",
|
55
|
+
id: "109",
|
56
|
+
},
|
57
|
+
{
|
58
|
+
label: "Energy",
|
59
|
+
value: "Energy",
|
60
|
+
id: "110",
|
61
|
+
},
|
62
|
+
],
|
63
|
+
},
|
64
|
+
],
|
65
|
+
}] %>
|
66
|
+
|
67
|
+
<%= pb_rails("multi_level_select", props: {
|
68
|
+
id: "multi-level-select-label-rails",
|
69
|
+
label: "Select a department",
|
70
|
+
tree_data: treeData
|
71
|
+
}) %>
|
@@ -0,0 +1,91 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import MultiLevelSelect from "../_multi_level_select";
|
3
|
+
|
4
|
+
const treeData = [
|
5
|
+
{
|
6
|
+
label: "Power Home Remodeling",
|
7
|
+
value: "Power Home Remodeling",
|
8
|
+
id: "powerhome1",
|
9
|
+
expanded: true,
|
10
|
+
children: [
|
11
|
+
{
|
12
|
+
label: "People",
|
13
|
+
value: "People",
|
14
|
+
id: "people1",
|
15
|
+
expanded: true,
|
16
|
+
children: [
|
17
|
+
{
|
18
|
+
label: "Talent Acquisition",
|
19
|
+
value: "Talent Acquisition",
|
20
|
+
id: "talent1",
|
21
|
+
},
|
22
|
+
{
|
23
|
+
label: "Business Affairs",
|
24
|
+
value: "Business Affairs",
|
25
|
+
id: "business1",
|
26
|
+
children: [
|
27
|
+
{
|
28
|
+
label: "Initiatives",
|
29
|
+
value: "Initiatives",
|
30
|
+
id: "initiative1",
|
31
|
+
},
|
32
|
+
{
|
33
|
+
label: "Learning & Development",
|
34
|
+
value: "Learning & Development",
|
35
|
+
id: "development1",
|
36
|
+
},
|
37
|
+
],
|
38
|
+
},
|
39
|
+
{
|
40
|
+
label: "People Experience",
|
41
|
+
value: "People Experience",
|
42
|
+
id: "experience1",
|
43
|
+
},
|
44
|
+
],
|
45
|
+
},
|
46
|
+
{
|
47
|
+
label: "Contact Center",
|
48
|
+
value: "Contact Center",
|
49
|
+
id: "contact1",
|
50
|
+
children: [
|
51
|
+
{
|
52
|
+
label: "Appointment Management",
|
53
|
+
value: "Appointment Management",
|
54
|
+
id: "appointment1",
|
55
|
+
},
|
56
|
+
{
|
57
|
+
label: "Customer Service",
|
58
|
+
value: "Customer Service",
|
59
|
+
id: "customer1",
|
60
|
+
},
|
61
|
+
{
|
62
|
+
label: "Energy",
|
63
|
+
value: "Energy",
|
64
|
+
id: "energy1",
|
65
|
+
},
|
66
|
+
],
|
67
|
+
},
|
68
|
+
],
|
69
|
+
},
|
70
|
+
];
|
71
|
+
|
72
|
+
const MultiLevelSelectDefault = (props) => {
|
73
|
+
return (
|
74
|
+
<div>
|
75
|
+
<MultiLevelSelect
|
76
|
+
id='multiselect-label'
|
77
|
+
label="Select a Department"
|
78
|
+
onSelect={(selectedNodes) =>
|
79
|
+
console.log(
|
80
|
+
"Selected Items",
|
81
|
+
selectedNodes
|
82
|
+
)
|
83
|
+
}
|
84
|
+
treeData={treeData}
|
85
|
+
{...props}
|
86
|
+
/>
|
87
|
+
</div>
|
88
|
+
)
|
89
|
+
};
|
90
|
+
|
91
|
+
export default MultiLevelSelectDefault;
|
@@ -8,6 +8,8 @@ examples:
|
|
8
8
|
- multi_level_select_with_form: With Form
|
9
9
|
- multi_level_select_color: With Pills (Custom Color)
|
10
10
|
- multi_level_select_reset: Reset Selection
|
11
|
+
- multi_level_select_label: With Label
|
12
|
+
- multi_level_select_error: Error
|
11
13
|
- multi_level_select_disabled: Disabled Input
|
12
14
|
- multi_level_select_disabled_options_default: Disabled Options (Default)
|
13
15
|
- multi_level_select_disabled_options: Disabled Options (Return All Selected)
|
@@ -24,6 +26,8 @@ examples:
|
|
24
26
|
- multi_level_select_color: With Pills (Custom Color)
|
25
27
|
- multi_level_select_with_children: Checkboxes With Children
|
26
28
|
- multi_level_select_with_children_with_radios: Single Select With Children
|
29
|
+
- multi_level_select_label: With Label
|
30
|
+
- multi_level_select_error: Error
|
27
31
|
- multi_level_select_disabled: Disabled Input
|
28
32
|
- multi_level_select_disabled_options_default: Disabled Options (Default)
|
29
33
|
- multi_level_select_disabled_options: Disabled Options (Return All Selected)
|
@@ -8,7 +8,9 @@ export { default as MultiLevelSelectWithChildren } from './_multi_level_select_w
|
|
8
8
|
export { default as MultiLevelSelectWithChildrenWithRadios } from './_multi_level_select_with_children_with_radios.jsx'
|
9
9
|
export { default as MultiLevelSelectDisabled } from './_multi_level_select_disabled.jsx'
|
10
10
|
export { default as MultiLevelSelectReactHook } from './_multi_level_select_react_hook.jsx'
|
11
|
+
export { default as MultiLevelSelectError } from './_multi_level_select_error.jsx'
|
11
12
|
export { default as MultiLevelSelectDisabledOptions } from './_multi_level_select_disabled_options.jsx'
|
12
13
|
export { default as MultiLevelSelectDisabledOptionsParent } from './_multi_level_select_disabled_options_parent.jsx'
|
13
14
|
export { default as MultiLevelSelectDisabledOptionsParentDefault } from './_multi_level_select_disabled_options_parent_default.jsx'
|
14
|
-
export { default as MultiLevelSelectDisabledOptionsDefault } from './_multi_level_select_disabled_options_default.jsx'
|
15
|
+
export { default as MultiLevelSelectDisabledOptionsDefault } from './_multi_level_select_disabled_options_default.jsx'
|
16
|
+
export { default as MultiLevelSelectLabel } from './_multi_level_select_label.jsx'
|
@@ -0,0 +1,105 @@
|
|
1
|
+
import PbEnhancedElement from "../pb_enhanced_element";
|
2
|
+
|
3
|
+
const MULTI_LEVEL_SELECT_SELECTOR = "[data-multi_level_select_form]";
|
4
|
+
|
5
|
+
export default class PbMultiLevelSelect extends PbEnhancedElement {
|
6
|
+
static get selector() {
|
7
|
+
return MULTI_LEVEL_SELECT_SELECTOR;
|
8
|
+
}
|
9
|
+
|
10
|
+
get target() {
|
11
|
+
return this.element.querySelector(".pb_body_kit_negative");
|
12
|
+
}
|
13
|
+
|
14
|
+
connect() {
|
15
|
+
this.addEventListeners();
|
16
|
+
this.observeHiddenInputs();
|
17
|
+
this.observeRogueErrorInsideInnerContainer();
|
18
|
+
}
|
19
|
+
|
20
|
+
addEventListeners() {
|
21
|
+
const inputElement = this.element.querySelector("input");
|
22
|
+
|
23
|
+
inputElement.addEventListener("invalid", () => {
|
24
|
+
this.handleErrorLabel(300);
|
25
|
+
});
|
26
|
+
inputElement.addEventListener("blur", () => {
|
27
|
+
this.justBlurred = true;
|
28
|
+
|
29
|
+
setTimeout(() => {
|
30
|
+
this.justBlurred = false;
|
31
|
+
}, 300);
|
32
|
+
});
|
33
|
+
}
|
34
|
+
|
35
|
+
handleErrorLabel(delay) {
|
36
|
+
setTimeout(() => {
|
37
|
+
const errorLabelElement = this.target;
|
38
|
+
const wrapper = this.element.querySelector(".wrapper");
|
39
|
+
|
40
|
+
if (errorLabelElement) {
|
41
|
+
errorLabelElement.remove();
|
42
|
+
if (wrapper) {
|
43
|
+
if (wrapper.querySelector(".pb_body_kit_negative")) {
|
44
|
+
wrapper.querySelector(".pb_body_kit_negative").remove();
|
45
|
+
}
|
46
|
+
wrapper.appendChild(errorLabelElement);
|
47
|
+
}
|
48
|
+
this.element.classList.add("error");
|
49
|
+
} else {
|
50
|
+
this.handleErrorLabel(100);
|
51
|
+
}
|
52
|
+
}, delay);
|
53
|
+
}
|
54
|
+
|
55
|
+
observeHiddenInputs() {
|
56
|
+
const container = this.element.querySelector(".input_inner_container");
|
57
|
+
if (!container) return;
|
58
|
+
|
59
|
+
this.mutationObserver = new MutationObserver(() => {
|
60
|
+
const hiddenInputs = container.querySelectorAll('input[type="hidden"]');
|
61
|
+
if (hiddenInputs.length > 0) {
|
62
|
+
// At least one hidden input exists, so clear the error
|
63
|
+
this.clearError();
|
64
|
+
}
|
65
|
+
});
|
66
|
+
|
67
|
+
this.mutationObserver.observe(container, {
|
68
|
+
childList: true,
|
69
|
+
});
|
70
|
+
}
|
71
|
+
|
72
|
+
observeRogueErrorInsideInnerContainer() {
|
73
|
+
const container = this.element.querySelector(".input_inner_container");
|
74
|
+
|
75
|
+
this.rogueErrorObserver = new MutationObserver((mutations) => {
|
76
|
+
for (const mutation of mutations) {
|
77
|
+
for (const node of mutation.addedNodes) {
|
78
|
+
if (
|
79
|
+
node.nodeType === Node.ELEMENT_NODE &&
|
80
|
+
node.classList.contains("pb_body_kit_negative")
|
81
|
+
) {
|
82
|
+
if (this.justBlurred) {
|
83
|
+
node.remove();
|
84
|
+
}
|
85
|
+
}
|
86
|
+
}
|
87
|
+
}
|
88
|
+
});
|
89
|
+
|
90
|
+
this.rogueErrorObserver.observe(container, {
|
91
|
+
childList: true,
|
92
|
+
subtree: true,
|
93
|
+
});
|
94
|
+
}
|
95
|
+
|
96
|
+
clearError(e) {
|
97
|
+
const errorLabelElement = this.target;
|
98
|
+
|
99
|
+
if (errorLabelElement) {
|
100
|
+
errorLabelElement.remove();
|
101
|
+
this.element.classList.remove("error");
|
102
|
+
this.element.querySelector("input").value = e.detail.value;
|
103
|
+
}
|
104
|
+
}
|
105
|
+
}
|
@@ -26,6 +26,12 @@ module Playbook
|
|
26
26
|
default: false
|
27
27
|
prop :disabled, type: Playbook::Props::Boolean,
|
28
28
|
default: false
|
29
|
+
prop :required, type: Playbook::Props::Boolean,
|
30
|
+
default: false
|
31
|
+
prop :error, type: Playbook::Props::String,
|
32
|
+
default: ""
|
33
|
+
prop :label, type: Playbook::Props::String,
|
34
|
+
default: ""
|
29
35
|
|
30
36
|
def classname
|
31
37
|
generate_classname("pb_multi_level_select")
|
@@ -33,11 +39,15 @@ module Playbook
|
|
33
39
|
|
34
40
|
def multi_level_select_options
|
35
41
|
{
|
42
|
+
data: data,
|
36
43
|
disabled: disabled,
|
44
|
+
error: error,
|
37
45
|
id: id,
|
38
46
|
inputDisplay: input_display,
|
39
47
|
name: name,
|
48
|
+
label: label,
|
40
49
|
treeData: tree_data,
|
50
|
+
required: required,
|
41
51
|
returnAllSelected: return_all_selected,
|
42
52
|
selectedIds: selected_ids,
|
43
53
|
inputName: input_name,
|