playbook_ui 16.3.0 → 16.4.0.pre.alpha.PLAY2846reactadvancedtablecalcheaderpinnedrows15356
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/Components/CustomCell.tsx +17 -4
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +3 -1
- data/app/pb_kits/playbook/pb_advanced_table/Context/AdvancedTableContext.tsx +5 -2
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableActions.ts +21 -9
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +5 -2
- data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx +9 -11
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/ExpansionControlHelpers.tsx +25 -1
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/RowModelUtils.ts +100 -0
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +65 -1
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +12 -2
- 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 +9 -0
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +109 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_cascade_collapse.jsx +50 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_cascade_collapse.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pinned_rows_rails.html.erb +57 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pinned_rows_rails.md +7 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_parent_only.jsx +175 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_parent_only.md +5 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +3 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +3 -1
- data/app/pb_kits/playbook/pb_advanced_table/index.js +130 -29
- data/app/pb_kits/playbook/pb_advanced_table/scss_partials/advanced_table_sticky_mixin.scss +6 -2
- data/app/pb_kits/playbook/pb_advanced_table/table_body.html.erb +21 -4
- data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +115 -9
- data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +3 -1
- data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +12 -1
- data/app/pb_kits/playbook/pb_advanced_table/table_subrow_header.html.erb +4 -1
- data/app/pb_kits/playbook/pb_advanced_table/table_subrow_header.rb +9 -1
- data/app/pb_kits/playbook/pb_button/_button_mixins.scss +6 -1
- data/app/pb_kits/playbook/pb_button/docs/_button_full_width_rails.md +19 -0
- data/app/pb_kits/playbook/pb_button/docs/_button_full_width_react.md +23 -0
- data/app/pb_kits/playbook/pb_circle_icon_button/_circle_icon_button.scss +5 -0
- data/app/pb_kits/playbook/pb_collapsible/index.js +15 -26
- data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +3 -1
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_compound_components.html.erb +1 -1
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_compound_components.jsx +6 -3
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_full_height.html.erb +3 -3
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_full_height.jsx +6 -3
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_full_height_placement.html.erb +3 -3
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_full_height_placement.jsx +6 -3
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +3 -0
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_closing_options_rails.html.erb +16 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_closing_options_rails.md +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_custom_event_type.html.erb +224 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_custom_event_type.md +7 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown.rb +8 -1
- data/app/pb_kits/playbook/pb_dropdown/index.js +255 -46
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownTrigger.tsx +19 -14
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.scss +4 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx +3 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_nav_margin.html.erb +46 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_nav_margin.jsx +42 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_nav_margin_rails.md +1 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_nav_margin_react.md +1 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.rb +7 -1
- data/app/pb_kits/playbook/pb_icon/icon.rb +7 -1
- data/app/pb_kits/playbook/pb_list/_list_mixin.scss +4 -4
- data/app/pb_kits/playbook/pb_multi_level_select/_helper_functions.tsx +1 -1
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +27 -16
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_placeholder.html.erb +109 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_placeholder.jsx +127 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_placeholder.md +1 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.rb +3 -0
- data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.test.jsx +27 -0
- data/app/pb_kits/playbook/pb_popover/docs/_popover_placement.jsx +81 -0
- data/app/pb_kits/playbook/pb_popover/docs/_popover_placement_react.md +1 -0
- data/app/pb_kits/playbook/pb_popover/docs/_popover_position.html.erb +128 -0
- data/app/pb_kits/playbook/pb_popover/docs/_popover_position_rails.md +1 -0
- data/app/pb_kits/playbook/pb_popover/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_popover/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +35 -134
- data/app/pb_kits/playbook/pb_rich_text_editor/_tiptap_editor.tsx +51 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/_trix_editor.tsx +206 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_default.jsx +56 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_default.md +1 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml +13 -21
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/index.js +0 -10
- data/app/pb_kits/playbook/pb_rich_text_editor/inlineFocus.ts +5 -4
- data/app/pb_kits/playbook/pb_selectable_list/_selectable_list.scss +19 -1
- data/app/pb_kits/playbook/pb_table/_table.tsx +24 -21
- data/app/pb_kits/playbook/pb_table/docs/_sections.yml +1 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_external_filter_rails.html.erb +45 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_external_filter_rails.md +39 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_rails.md +2 -1
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_with_card_title_props.jsx +152 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_with_card_title_props.md +17 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_with_card_title_props_rails.html.erb +121 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_with_card_title_props_rails.md +17 -0
- data/app/pb_kits/playbook/pb_table/docs/example.yml +3 -0
- data/app/pb_kits/playbook/pb_table/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_table/table.html.erb +17 -13
- data/app/pb_kits/playbook/pb_table/table.rb +8 -0
- data/app/pb_kits/playbook/pb_table/table.test.js +33 -0
- data/app/pb_kits/playbook/pb_textarea/_textarea.scss +4 -1
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +105 -3
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_highlight.jsx +20 -8
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_highlight.md +3 -0
- data/app/pb_kits/playbook/utilities/_hover.scss +6 -3
- data/app/pb_kits/playbook/utilities/domHelpers.ts +50 -0
- data/dist/chunks/{_pb_line_graph-CKBPxTmM.js → _pb_line_graph-D6s5rymw.js} +1 -1
- data/dist/chunks/_typeahead-BNp_YiTh.js +1 -0
- data/dist/chunks/componentRegistry-DRSp5D_e.js +1 -0
- data/dist/chunks/{globalProps-DLCfJwiU.js → globalProps-Ds_6HBhX.js} +1 -1
- data/dist/chunks/lib-BaO72ugL.js +29 -0
- data/dist/chunks/vendor.js +5 -5
- data/dist/menu.yml +3 -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/pb_forms_helper.rb +3 -0
- data/lib/playbook/version.rb +2 -2
- metadata +42 -32
- data/app/pb_kits/playbook/pb_button/docs/_button_full_width.md +0 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_attributes.html.erb +0 -5
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_attributes.jsx +0 -15
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_default.html.erb +0 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_focus.html.erb +0 -3
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_focus.jsx +0 -17
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_inline.html.erb +0 -6
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_inline.jsx +0 -16
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_label.jsx +0 -28
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_label.md +0 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_preview.html.erb +0 -35
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_preview.jsx +0 -45
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_required_indicator.html.erb +0 -10
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_required_indicator.jsx +0 -22
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_required_indicator.md +0 -3
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_simple.html.erb +0 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_simple.jsx +0 -13
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_sticky.html.erb +0 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_sticky.jsx +0 -15
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_templates.html.erb +0 -115
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_templates.jsx +0 -42
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_toolbar_bottom.html.erb +0 -4
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_toolbar_bottom.jsx +0 -14
- data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.html.erb +0 -5
- data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.rb +0 -63
- data/dist/chunks/_typeahead-B7bktFm6.js +0 -1
- data/dist/chunks/componentRegistry-DzmmLR2x.js +0 -1
- data/dist/chunks/lib-QT_7rPYf.js +0 -29
|
@@ -5,4 +5,5 @@ export { default as FixedConfirmationToastPositions } from './_fixed_confirmatio
|
|
|
5
5
|
export { default as FixedConfirmationToastAutoClose } from './_fixed_confirmation_toast_auto_close.jsx'
|
|
6
6
|
export { default as FixedConfirmationToastChildren } from './_fixed_confirmation_toast_children.jsx'
|
|
7
7
|
export { default as FixedConfirmationToastCustomIcon } from './_fixed_confirmation_toast_custom_icon.jsx'
|
|
8
|
-
export { default as FixedConfirmationToastNoIcon } from './_fixed_confirmation_toast_no_icon.jsx'
|
|
8
|
+
export { default as FixedConfirmationToastNoIcon } from './_fixed_confirmation_toast_no_icon.jsx'
|
|
9
|
+
export { default as FixedConfirmationToastNavMargin } from './_fixed_confirmation_toast_nav_margin.jsx'
|
|
@@ -21,6 +21,8 @@ module Playbook
|
|
|
21
21
|
default: nil
|
|
22
22
|
prop :auto_close, type: Playbook::Props::Number
|
|
23
23
|
prop :icon, type: Playbook::Props::String
|
|
24
|
+
prop :nav_margin_top, type: Playbook::Props::Boolean,
|
|
25
|
+
default: false
|
|
24
26
|
|
|
25
27
|
def show_text?
|
|
26
28
|
text.present?
|
|
@@ -46,6 +48,10 @@ module Playbook
|
|
|
46
48
|
Hash(prop(:data)).merge(auto_close_attribute)
|
|
47
49
|
end
|
|
48
50
|
|
|
51
|
+
def nav_margin_top_class
|
|
52
|
+
nav_margin_top.present? ? " nav_margin_top" : ""
|
|
53
|
+
end
|
|
54
|
+
|
|
49
55
|
def icon_value
|
|
50
56
|
icon || case status
|
|
51
57
|
when "success"
|
|
@@ -65,7 +71,7 @@ module Playbook
|
|
|
65
71
|
|
|
66
72
|
def classname
|
|
67
73
|
default_z_index = z_index.present? ? "" : " z_index_max"
|
|
68
|
-
generate_classname("pb_fixed_confirmation_toast_kit", status, multi_line_class) + close_class + position_class + icon_class + default_z_index
|
|
74
|
+
generate_classname("pb_fixed_confirmation_toast_kit", status, multi_line_class) + close_class + position_class + icon_class + nav_margin_top_class + default_z_index
|
|
69
75
|
end
|
|
70
76
|
end
|
|
71
77
|
end
|
|
@@ -112,7 +112,13 @@ module Playbook
|
|
|
112
112
|
end
|
|
113
113
|
|
|
114
114
|
def render_svg
|
|
115
|
-
|
|
115
|
+
source = asset_path || icon || custom_icon
|
|
116
|
+
content = if source.to_s.include?("://")
|
|
117
|
+
URI.open(source, "User-Agent" => "Playbook-Icon-Kit/1.0 (https://github.com/powerhome/playbook)", &:read) # rubocop:disable Security/Open
|
|
118
|
+
else
|
|
119
|
+
URI.open(source, &:read) # rubocop:disable Security/Open
|
|
120
|
+
end
|
|
121
|
+
doc = Nokogiri::XML(content)
|
|
116
122
|
svg = doc.at_css("svg")
|
|
117
123
|
return "" unless svg
|
|
118
124
|
|
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
width: 20px;
|
|
22
22
|
flex: 0 0 20px;
|
|
23
23
|
text-align: left;
|
|
24
|
-
color: $
|
|
24
|
+
color: $text_lt_lighter;
|
|
25
25
|
font-weight: $bold;
|
|
26
26
|
margin-right: $space-sm;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
li {
|
|
31
|
-
border-bottom: 1px solid $
|
|
31
|
+
border-bottom: 1px solid $border_light;
|
|
32
32
|
padding: $space-sm 0;
|
|
33
33
|
display: flex;
|
|
34
34
|
align-items: left;
|
|
@@ -69,14 +69,14 @@
|
|
|
69
69
|
}
|
|
70
70
|
@mixin pb_list_dark {
|
|
71
71
|
color: $white;
|
|
72
|
-
border-bottom: 1px solid $
|
|
72
|
+
border-bottom: 1px solid $border_dark;
|
|
73
73
|
|
|
74
74
|
&:last-child {
|
|
75
75
|
border-bottom: 0;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
&:before {
|
|
79
|
-
color: $
|
|
79
|
+
color: $text_dk_light;
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
@mixin pb_list_large {
|
|
@@ -102,7 +102,7 @@ export const getDefaultCheckedItems = (
|
|
|
102
102
|
} else {
|
|
103
103
|
const parent = items.find(
|
|
104
104
|
(parentItem: { [key: string]: any }) =>
|
|
105
|
-
parentItem.id === item.
|
|
105
|
+
parentItem.id === item.parent_id
|
|
106
106
|
);
|
|
107
107
|
if (!parent || !parent.checked) {
|
|
108
108
|
checkedDefault.push(item);
|
|
@@ -51,6 +51,7 @@ type MultiLevelSelectProps = {
|
|
|
51
51
|
treeData?: { [key: string]: string }[] | any;
|
|
52
52
|
onChange?: (event: { target: { name?: string; value: any } }) => void;
|
|
53
53
|
onSelect?: (prop: { [key: string]: any }) => void;
|
|
54
|
+
placeholder?: string;
|
|
54
55
|
selectedIds?: string[] | any;
|
|
55
56
|
variant?: "multi" | "single";
|
|
56
57
|
wrapped?: boolean;
|
|
@@ -100,6 +101,7 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>(
|
|
|
100
101
|
treeData,
|
|
101
102
|
onChange = () => null,
|
|
102
103
|
onSelect = () => null,
|
|
104
|
+
placeholder: placeholderText = "Start typing...",
|
|
103
105
|
selectedIds,
|
|
104
106
|
variant = "multi",
|
|
105
107
|
wrapped,
|
|
@@ -179,6 +181,7 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>(
|
|
|
179
181
|
parent_id: string | null = null,
|
|
180
182
|
depth = 0,
|
|
181
183
|
parentDisabled = false,
|
|
184
|
+
ancestorChecked = false
|
|
182
185
|
) => {
|
|
183
186
|
if (!Array.isArray(treeData)) {
|
|
184
187
|
return;
|
|
@@ -188,28 +191,36 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>(
|
|
|
188
191
|
const isDisabled =
|
|
189
192
|
item.disabled || (parentDisabled && !returnAllSelected);
|
|
190
193
|
|
|
194
|
+
const explicitlySelected = Boolean(
|
|
195
|
+
selectedIds && selectedIds?.length && selectedIds.includes(item.id)
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
const checked =
|
|
199
|
+
!isDisabled &&
|
|
200
|
+
(explicitlySelected || (ancestorChecked && !returnAllSelected && variant !== "single"))
|
|
201
|
+
|
|
191
202
|
const newItem = {
|
|
192
203
|
...item,
|
|
193
|
-
checked:
|
|
194
|
-
selectedIds && selectedIds.length && selectedIds.includes(item.id),
|
|
195
|
-
),
|
|
204
|
+
checked: checked,
|
|
196
205
|
parent_id,
|
|
197
206
|
depth,
|
|
198
207
|
disabled: isDisabled,
|
|
199
208
|
};
|
|
200
209
|
if (newItem.children && newItem.children.length > 0) {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
210
|
+
// if this node is checked (by explicit selection or ancestor cascade),
|
|
211
|
+
// and we're in default, cascade to descendants
|
|
212
|
+
const cascadeToChildren =
|
|
213
|
+
checked && !returnAllSelected && variant !== "single"
|
|
214
|
+
|
|
215
|
+
newItem.children = addCheckedAndParentProperty(
|
|
216
|
+
newItem.children,
|
|
217
|
+
selectedIds,
|
|
218
|
+
newItem.id,
|
|
219
|
+
depth + 1,
|
|
220
|
+
isDisabled,
|
|
221
|
+
cascadeToChildren
|
|
222
|
+
)
|
|
223
|
+
}
|
|
213
224
|
return newItem;
|
|
214
225
|
});
|
|
215
226
|
};
|
|
@@ -666,7 +677,7 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>(
|
|
|
666
677
|
? `${itemsSelectedLength()} ${
|
|
667
678
|
itemsSelectedLength() === 1 ? "item" : "items"
|
|
668
679
|
} selected`
|
|
669
|
-
:
|
|
680
|
+
: placeholderText
|
|
670
681
|
}
|
|
671
682
|
required={required}
|
|
672
683
|
value={singleSelectedItem.value || filterItem}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
<%
|
|
2
|
+
tree_base = [{
|
|
3
|
+
label: "Power Home Remodeling",
|
|
4
|
+
value: "powerHomeRemodeling",
|
|
5
|
+
id: "100",
|
|
6
|
+
expanded: true,
|
|
7
|
+
children: [
|
|
8
|
+
{
|
|
9
|
+
label: "People",
|
|
10
|
+
value: "people",
|
|
11
|
+
id: "101",
|
|
12
|
+
expanded: true,
|
|
13
|
+
children: [
|
|
14
|
+
{
|
|
15
|
+
label: "Talent Acquisition",
|
|
16
|
+
value: "talentAcquisition",
|
|
17
|
+
id: "102",
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
label: "Business Affairs",
|
|
21
|
+
value: "business Affairs",
|
|
22
|
+
id: "103",
|
|
23
|
+
children: [
|
|
24
|
+
{
|
|
25
|
+
label: "Initiatives",
|
|
26
|
+
value: "initiatives",
|
|
27
|
+
id: "104",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
label: "Learning & Development",
|
|
31
|
+
value: "learningAndDevelopment",
|
|
32
|
+
id: "105",
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
label: "People Experience",
|
|
38
|
+
value: "peopleExperience",
|
|
39
|
+
id: "106",
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
label: "Contact Center",
|
|
45
|
+
value: "contactCenter",
|
|
46
|
+
id: "107",
|
|
47
|
+
children: [
|
|
48
|
+
{
|
|
49
|
+
label: "Appointment Management",
|
|
50
|
+
value: "appointmentManagement",
|
|
51
|
+
id: "108",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
label: "Customer Service",
|
|
55
|
+
value: "customerService",
|
|
56
|
+
id: "109",
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
label: "Energy",
|
|
60
|
+
value: "energy",
|
|
61
|
+
id: "110",
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
}]
|
|
67
|
+
|
|
68
|
+
prefix_mls_ids = nil
|
|
69
|
+
prefix_mls_ids = ->(nodes, pfx) {
|
|
70
|
+
nodes.map do |n|
|
|
71
|
+
h = n.dup
|
|
72
|
+
h[:id] = "#{pfx}#{n[:id]}"
|
|
73
|
+
h[:children] = prefix_mls_ids.call(n[:children], pfx) if n[:children].present?
|
|
74
|
+
h
|
|
75
|
+
end
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
tree_multi = prefix_mls_ids.call(tree_base, "phm_")
|
|
79
|
+
tree_return_all = prefix_mls_ids.call(tree_base, "phr_")
|
|
80
|
+
tree_single = prefix_mls_ids.call(tree_base, "phs_")
|
|
81
|
+
%>
|
|
82
|
+
|
|
83
|
+
<%= pb_rails("multi_level_select", props: {
|
|
84
|
+
id: "multi-level-select-placeholder-multi-rails",
|
|
85
|
+
label: "Multi (default)",
|
|
86
|
+
margin_bottom: "sm",
|
|
87
|
+
name: "placeholder_multi",
|
|
88
|
+
tree_data: tree_multi,
|
|
89
|
+
placeholder: "Search or choose options…",
|
|
90
|
+
}) %>
|
|
91
|
+
|
|
92
|
+
<%= pb_rails("multi_level_select", props: {
|
|
93
|
+
id: "multi-level-select-placeholder-return-all-rails",
|
|
94
|
+
label: "Multi (return all selected)",
|
|
95
|
+
margin_bottom: "sm",
|
|
96
|
+
name: "placeholder_return_all",
|
|
97
|
+
placeholder: "Departments...",
|
|
98
|
+
return_all_selected: true,
|
|
99
|
+
tree_data: tree_return_all,
|
|
100
|
+
}) %>
|
|
101
|
+
|
|
102
|
+
<%= pb_rails("multi_level_select", props: {
|
|
103
|
+
id: "multi-level-select-placeholder-single-rails",
|
|
104
|
+
label: "Single",
|
|
105
|
+
name: "placeholder_single",
|
|
106
|
+
placeholder: "Select one option…",
|
|
107
|
+
tree_data: tree_single,
|
|
108
|
+
variant: "single",
|
|
109
|
+
}) %>
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import MultiLevelSelect from "../_multi_level_select";
|
|
4
|
+
|
|
5
|
+
const treeTemplate = [
|
|
6
|
+
{
|
|
7
|
+
label: "Power Home Remodeling",
|
|
8
|
+
value: "powerHomeRemodeling",
|
|
9
|
+
id: "powerhome1",
|
|
10
|
+
expanded: true,
|
|
11
|
+
children: [
|
|
12
|
+
{
|
|
13
|
+
label: "People",
|
|
14
|
+
value: "people",
|
|
15
|
+
id: "people1",
|
|
16
|
+
expanded: true,
|
|
17
|
+
children: [
|
|
18
|
+
{
|
|
19
|
+
label: "Talent Acquisition",
|
|
20
|
+
value: "talentAcquisition",
|
|
21
|
+
id: "talent1",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
label: "Business Affairs",
|
|
25
|
+
value: "businessAffairs",
|
|
26
|
+
id: "business1",
|
|
27
|
+
children: [
|
|
28
|
+
{
|
|
29
|
+
label: "Initiatives",
|
|
30
|
+
value: "initiatives",
|
|
31
|
+
id: "initiative1",
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
label: "Learning & Development",
|
|
35
|
+
value: "learningAndDevelopment",
|
|
36
|
+
id: "development1",
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
label: "People Experience",
|
|
42
|
+
value: "peopleExperience",
|
|
43
|
+
id: "experience1",
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
label: "Contact Center",
|
|
49
|
+
value: "contactCenter",
|
|
50
|
+
id: "contact1",
|
|
51
|
+
children: [
|
|
52
|
+
{
|
|
53
|
+
label: "Appointment Management",
|
|
54
|
+
value: "appointmentManagement",
|
|
55
|
+
id: "appointment1",
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
label: "Customer Service",
|
|
59
|
+
value: "customerService",
|
|
60
|
+
id: "customer1",
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
label: "Energy",
|
|
64
|
+
value: "energy",
|
|
65
|
+
id: "energy1",
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
function prefixTreeIds(nodes, prefix) {
|
|
74
|
+
return nodes.map((node) => ({
|
|
75
|
+
...node,
|
|
76
|
+
id: `${prefix}${node.id}`,
|
|
77
|
+
children:
|
|
78
|
+
node.children && node.children.length > 0
|
|
79
|
+
? prefixTreeIds(node.children, prefix)
|
|
80
|
+
: node.children,
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const treeDataMulti = prefixTreeIds(treeTemplate, "phm_");
|
|
85
|
+
const treeDataReturnAll = prefixTreeIds(treeTemplate, "phr_");
|
|
86
|
+
const treeDataSingle = prefixTreeIds(treeTemplate, "phs_");
|
|
87
|
+
|
|
88
|
+
const MultiLevelSelectPlaceholder = () => (
|
|
89
|
+
<>
|
|
90
|
+
<MultiLevelSelect
|
|
91
|
+
id="multi-level-select-placeholder-multi"
|
|
92
|
+
label="Multi (default)"
|
|
93
|
+
marginBottom="sm"
|
|
94
|
+
name="placeholder_multi"
|
|
95
|
+
onSelect={(selectedNodes) =>
|
|
96
|
+
console.log("Multi — default", selectedNodes)
|
|
97
|
+
}
|
|
98
|
+
placeholder="Search or choose options…"
|
|
99
|
+
treeData={treeDataMulti}
|
|
100
|
+
/>
|
|
101
|
+
<MultiLevelSelect
|
|
102
|
+
id="multi-level-select-placeholder-return-all"
|
|
103
|
+
label="Multi (return all selected)"
|
|
104
|
+
marginBottom="sm"
|
|
105
|
+
name="placeholder_return_all"
|
|
106
|
+
onSelect={(selectedNodes) =>
|
|
107
|
+
console.log("Multi — return all selected", selectedNodes)
|
|
108
|
+
}
|
|
109
|
+
placeholder="Departments..."
|
|
110
|
+
returnAllSelected
|
|
111
|
+
treeData={treeDataReturnAll}
|
|
112
|
+
/>
|
|
113
|
+
<MultiLevelSelect
|
|
114
|
+
id="multi-level-select-placeholder-single"
|
|
115
|
+
label="Single"
|
|
116
|
+
name="placeholder_single"
|
|
117
|
+
onSelect={(selectedNodes) =>
|
|
118
|
+
console.log("Single", selectedNodes)
|
|
119
|
+
}
|
|
120
|
+
placeholder="Select one option…"
|
|
121
|
+
treeData={treeDataSingle}
|
|
122
|
+
variant="single"
|
|
123
|
+
/>
|
|
124
|
+
</>
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
export default MultiLevelSelectPlaceholder;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Use the `placeholder` prop to customize the initial text shown in the input when nothing is selected. The default is `Start typing...`.
|
|
@@ -18,6 +18,7 @@ examples:
|
|
|
18
18
|
- multi_level_select_disabled_options_parent: Disabled Parent Option (Return All Selected)
|
|
19
19
|
- multi_level_select_single_disabled: Disabled Options (Single Select)
|
|
20
20
|
- multi_level_select_required_indicator: Required Indicator
|
|
21
|
+
- multi_level_select_placeholder: Placeholder
|
|
21
22
|
|
|
22
23
|
react:
|
|
23
24
|
- multi_level_select_default: Default
|
|
@@ -40,3 +41,4 @@ examples:
|
|
|
40
41
|
- multi_level_select_single_disabled: Disabled Options (Single Select)
|
|
41
42
|
- multi_level_select_required_indicator: Required Indicator
|
|
42
43
|
- multi_level_select_react_reset_key: Reset with Key (React)
|
|
44
|
+
- multi_level_select_placeholder: Placeholder
|
|
@@ -18,3 +18,4 @@ export { default as MultiLevelSelectLabel } from "./_multi_level_select_label.js
|
|
|
18
18
|
export { default as MultiLevelSelectSingleDisabled } from "./_multi_level_select_single_disabled.jsx"
|
|
19
19
|
export { default as MultiLevelSelectRequiredIndicator } from "./_multi_level_select_required_indicator.jsx"
|
|
20
20
|
export { default as MultiLevelSelectReactResetKey } from "./_multi_level_select_react_reset_key.jsx"
|
|
21
|
+
export { default as MultiLevelSelectPlaceholder } from "./_multi_level_select_placeholder.jsx"
|
|
@@ -32,6 +32,8 @@ module Playbook
|
|
|
32
32
|
default: ""
|
|
33
33
|
prop :label, type: Playbook::Props::String,
|
|
34
34
|
default: ""
|
|
35
|
+
prop :placeholder, type: Playbook::Props::String,
|
|
36
|
+
default: "Start typing..."
|
|
35
37
|
prop :required_indicator, type: Playbook::Props::Boolean,
|
|
36
38
|
default: false
|
|
37
39
|
prop :show_checked_children, type: Playbook::Props::Boolean,
|
|
@@ -50,6 +52,7 @@ module Playbook
|
|
|
50
52
|
inputDisplay: input_display,
|
|
51
53
|
name: name,
|
|
52
54
|
label: label,
|
|
55
|
+
placeholder: placeholder,
|
|
53
56
|
treeData: tree_data,
|
|
54
57
|
required: required,
|
|
55
58
|
requiredIndicator: required_indicator,
|
|
@@ -173,6 +173,33 @@ describe('MultiLevelSelect', () => {
|
|
|
173
173
|
expect(label).toHaveTextContent("Select Location")
|
|
174
174
|
expect(label).not.toHaveTextContent("*")
|
|
175
175
|
})
|
|
176
|
+
|
|
177
|
+
test('should use default placeholder when none is passed', () => {
|
|
178
|
+
render(
|
|
179
|
+
<MultiLevelSelect
|
|
180
|
+
data={{ testid: testId }}
|
|
181
|
+
id="mls-placeholder-default"
|
|
182
|
+
treeData={treeData}
|
|
183
|
+
/>
|
|
184
|
+
)
|
|
185
|
+
expect(
|
|
186
|
+
screen.getByPlaceholderText('Start typing...')
|
|
187
|
+
).toBeInTheDocument()
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
test('should use custom placeholder when passed', () => {
|
|
191
|
+
render(
|
|
192
|
+
<MultiLevelSelect
|
|
193
|
+
data={{ testid: testId }}
|
|
194
|
+
id="mls-placeholder-custom"
|
|
195
|
+
placeholder="Choose items…"
|
|
196
|
+
treeData={treeData}
|
|
197
|
+
/>
|
|
198
|
+
)
|
|
199
|
+
expect(
|
|
200
|
+
screen.getByPlaceholderText('Choose items…')
|
|
201
|
+
).toBeInTheDocument()
|
|
202
|
+
})
|
|
176
203
|
})
|
|
177
204
|
|
|
178
205
|
describe('MultiLevelSelect multi variant', () => {
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
|
|
3
|
+
import Button from '../../pb_button/_button'
|
|
4
|
+
import Flex from '../../pb_flex/_flex'
|
|
5
|
+
import PbReactPopover from '../../pb_popover/_popover'
|
|
6
|
+
|
|
7
|
+
const ROWS = [
|
|
8
|
+
[
|
|
9
|
+
{ placement: 'top', label: 'Top' },
|
|
10
|
+
{ placement: 'top-start', label: 'Top start' },
|
|
11
|
+
{ placement: 'top-end', label: 'Top end' },
|
|
12
|
+
],
|
|
13
|
+
[
|
|
14
|
+
{ placement: 'bottom', label: 'Bottom' },
|
|
15
|
+
{ placement: 'bottom-start', label: 'Bottom start' },
|
|
16
|
+
{ placement: 'bottom-end', label: 'Bottom end' },
|
|
17
|
+
],
|
|
18
|
+
[
|
|
19
|
+
{ placement: 'left', label: 'Left' },
|
|
20
|
+
{ placement: 'left-start', label: 'Left start' },
|
|
21
|
+
{ placement: 'left-end', label: 'Left end' },
|
|
22
|
+
],
|
|
23
|
+
[
|
|
24
|
+
{ placement: 'right', label: 'Right' },
|
|
25
|
+
{ placement: 'right-start', label: 'Right start' },
|
|
26
|
+
{ placement: 'right-end', label: 'Right end' },
|
|
27
|
+
],
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
const PopoverPlacement = (props) => {
|
|
31
|
+
const [open, setOpen] = useState({})
|
|
32
|
+
|
|
33
|
+
const isOpen = (placement) => open[placement] === true
|
|
34
|
+
const setOpenFor = (placement) => (value) => setOpen((prev) => ({ ...prev, [placement]: value }))
|
|
35
|
+
const toggle = (placement) => setOpenFor(placement)(!isOpen(placement))
|
|
36
|
+
const handleShouldClose = (placement) => (shouldClose) => {
|
|
37
|
+
if (shouldClose) setOpenFor(placement)(false)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<>
|
|
42
|
+
{ROWS.map((placements, rowIndex) => (
|
|
43
|
+
<Flex
|
|
44
|
+
justify="around"
|
|
45
|
+
key={placements[0].placement}
|
|
46
|
+
marginBottom={rowIndex < ROWS.length - 1 ? 'sm' : undefined}
|
|
47
|
+
orientation="row"
|
|
48
|
+
wrap
|
|
49
|
+
{...props}
|
|
50
|
+
>
|
|
51
|
+
{placements.map(({ placement, label }) => {
|
|
52
|
+
const trigger = (
|
|
53
|
+
<Button
|
|
54
|
+
key={placement}
|
|
55
|
+
onClick={() => toggle(placement)}
|
|
56
|
+
text={label}
|
|
57
|
+
variant="secondary"
|
|
58
|
+
/>
|
|
59
|
+
)
|
|
60
|
+
return (
|
|
61
|
+
<PbReactPopover
|
|
62
|
+
closeOnClick="outside"
|
|
63
|
+
key={placement}
|
|
64
|
+
offset
|
|
65
|
+
placement={placement}
|
|
66
|
+
reference={trigger}
|
|
67
|
+
shouldClosePopover={handleShouldClose(placement)}
|
|
68
|
+
show={isOpen(placement)}
|
|
69
|
+
{...props}
|
|
70
|
+
>
|
|
71
|
+
{`Popover: ${label.toLowerCase()}`}
|
|
72
|
+
</PbReactPopover>
|
|
73
|
+
)
|
|
74
|
+
})}
|
|
75
|
+
</Flex>
|
|
76
|
+
))}
|
|
77
|
+
</>
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export default PopoverPlacement
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Use the `placement` prop to control where the popover appears relative to its trigger. Valid values include `top`, `bottom`, `left`, `right`, and aligned variants such as `top-start`, `top-end`, `bottom-start`, `bottom-end`, `left-start`, `left-end`, `right-start`, and `right-end`.
|