playbook_ui 14.14.0 → 14.15.0.pre.alpha.PBNTR617addgriddisplayglobalprop6700
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/RegularTableView.tsx +127 -0
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableActionBar.tsx +55 -0
- data/app/pb_kits/playbook/pb_advanced_table/Components/TablePagination.tsx +33 -0
- data/app/pb_kits/playbook/pb_advanced_table/Components/VirtualizedTableView.tsx +275 -0
- data/app/pb_kits/playbook/pb_advanced_table/Context/AdvancedTableContext.tsx +143 -3
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableActions.ts +66 -0
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +195 -0
- data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableBody.tsx +45 -99
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/CellRendererUtils.tsx +73 -0
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/RowUtils.ts +52 -0
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/TableContainerStyles.ts +80 -0
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +130 -7
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +153 -299
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_infinite_scroll.jsx +50 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_editing.jsx +102 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_editing.md +4 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/advanced_table_mock_data_infinite_scroll.json +152002 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +2 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_card/_card.tsx +2 -1
- data/app/pb_kits/playbook/pb_currency/_currency.tsx +46 -31
- data/app/pb_kits/playbook/pb_currency/currency.html.erb +15 -8
- data/app/pb_kits/playbook/pb_currency/currency.rb +17 -2
- data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display.html.erb +22 -0
- data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display.jsx +34 -0
- data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display_rails.md +1 -0
- data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display_react.md +1 -0
- data/app/pb_kits/playbook/pb_currency/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_currency/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +4 -1
- data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +2 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_hooks.md +3 -1
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.html.erb +39 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_close.html.erb +39 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_date_picker/index.ts +38 -0
- data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +5 -6
- data/app/pb_kits/playbook/pb_dialog/dialogHelper.js +2 -0
- data/app/pb_kits/playbook/pb_dialog/index.js +75 -0
- data/app/pb_kits/playbook/pb_drawer/_drawer.scss +43 -3
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_behavior.html.erb +8 -0
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_borders.html.erb +33 -0
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_borders.jsx +3 -3
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_breakpoints.html.erb +0 -0
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_breakpoints.jsx +20 -37
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_default.html.erb +20 -1
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_menu.html.erb +24 -0
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_menu.jsx +6 -6
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.html.erb +21 -0
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.jsx +1 -0
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.md +1 -0
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_sizes.html.erb +49 -0
- data/app/pb_kits/playbook/pb_drawer/docs/example.yml +6 -0
- data/app/pb_kits/playbook/pb_drawer/drawer.html.erb +20 -12
- data/app/pb_kits/playbook/pb_drawer/drawer.rb +49 -1
- data/app/pb_kits/playbook/pb_drawer/index.js +257 -0
- data/app/pb_kits/playbook/pb_filter/Filter/CurrentFilters.tsx +5 -4
- data/app/pb_kits/playbook/pb_filter/Filter/FilterSingle.tsx +2 -2
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with.html.erb +2 -1
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +4 -3
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +9 -2
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +4 -0
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_wrapped.html.erb +40 -0
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_wrapped.jsx +50 -0
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_wrapped.md +3 -0
- data/app/pb_kits/playbook/pb_form_pill/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_form_pill/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_form_pill/form_pill.rb +7 -1
- data/app/pb_kits/playbook/pb_icon_button/_icon_button.tsx +71 -0
- data/app/pb_kits/playbook/pb_icon_button/docs/_icon_button_default.jsx +17 -0
- data/app/pb_kits/playbook/pb_icon_button/docs/_icon_button_sizes.jsx +61 -0
- data/app/pb_kits/playbook/pb_icon_button/docs/example.yml +4 -0
- data/app/pb_kits/playbook/pb_icon_button/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_icon_button/icon_button.html.erb +1 -1
- data/app/pb_kits/playbook/pb_icon_button/icon_button.test.jsx +39 -0
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.scss +7 -0
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +45 -8
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_disabled.html.erb +72 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_disabled.jsx +91 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_react_hook.jsx +91 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_react_hook.md +1 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +3 -1
- data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.rb +7 -1
- data/app/pb_kits/playbook/pb_overlay/_overlay.scss +13 -0
- data/app/pb_kits/playbook/pb_overlay/_overlay.tsx +7 -1
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar.html.erb +11 -0
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar.jsx +37 -0
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar_rails.md +1 -0
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar_react.md +1 -0
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional.html.erb +11 -0
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional.md +1 -0
- data/app/pb_kits/playbook/pb_overlay/docs/example.yml +3 -0
- data/app/pb_kits/playbook/pb_overlay/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_overlay/index.js +61 -0
- data/app/pb_kits/playbook/pb_overlay/overlay.html.erb +5 -3
- data/app/pb_kits/playbook/pb_overlay/overlay.rb +16 -1
- data/app/pb_kits/playbook/pb_overlay/overlay.test.jsx +12 -0
- data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +6 -0
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_default.html.erb +1 -1
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_hidden_inputs.html.erb +5 -0
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_hidden_inputs.md +1 -0
- data/app/pb_kits/playbook/pb_phone_number_input/docs/example.yml +3 -1
- data/app/pb_kits/playbook/pb_phone_number_input/phone_number_input.rb +3 -0
- data/app/pb_kits/playbook/pb_popover/_popover.tsx +2 -2
- data/app/pb_kits/playbook/pb_popover/popover.test.js +1 -1
- data/app/pb_kits/playbook/pb_progress_step/progress_step_item.html.erb +2 -2
- data/app/pb_kits/playbook/pb_radio/_radio.tsx +85 -74
- data/app/pb_kits/playbook/pb_radio/docs/_radio_react_hook.jsx +60 -0
- data/app/pb_kits/playbook/pb_radio/docs/_radio_react_hook.md +1 -0
- data/app/pb_kits/playbook/pb_radio/docs/example.yml +2 -1
- data/app/pb_kits/playbook/pb_radio/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_radio/radio.test.js +16 -0
- data/app/pb_kits/playbook/pb_select/docs/_select_react_hook.jsx +58 -0
- data/app/pb_kits/playbook/pb_select/docs/_select_react_hook.md +1 -0
- data/app/pb_kits/playbook/pb_select/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_select/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_select/index.js +38 -0
- data/app/pb_kits/playbook/pb_select/select.html.erb +3 -5
- data/app/pb_kits/playbook/pb_select/select.rb +8 -0
- data/app/pb_kits/playbook/pb_selectable_card/selectable_card.html.erb +1 -5
- data/app/pb_kits/playbook/pb_selectable_card_icon/selectable_card_icon.html.erb +1 -4
- data/app/pb_kits/playbook/pb_selectable_icon/selectable_icon.html.erb +1 -5
- data/app/pb_kits/playbook/pb_text_input/inputMask.ts +2 -3
- data/app/pb_kits/playbook/pb_timeline/_timeline.scss +2 -2
- data/app/pb_kits/playbook/pb_title/_title.scss +32 -0
- data/app/pb_kits/playbook/pb_title/_title.tsx +10 -1
- data/app/pb_kits/playbook/pb_title/docs/_title_default.html.erb +1 -2
- data/app/pb_kits/playbook/pb_title/docs/_title_default.jsx +1 -1
- data/app/pb_kits/playbook/pb_title/docs/_title_display_size.html.erb +7 -0
- data/app/pb_kits/playbook/pb_title/docs/_title_display_size.jsx +54 -0
- data/app/pb_kits/playbook/pb_title/docs/_title_display_size.md +1 -0
- data/app/pb_kits/playbook/pb_title/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_title/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_title/title.rb +10 -1
- data/app/pb_kits/playbook/pb_tooltip/_tooltip.scss +0 -3
- data/app/pb_kits/playbook/pb_tooltip/_tooltip.tsx +25 -0
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_delay_rails.html.erb +39 -0
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_delay_rails.md +3 -0
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_icon_rails.html.erb +22 -0
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_interaction.html.erb +26 -0
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_sizing.jsx +69 -0
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_sizing.md +3 -0
- data/app/pb_kits/playbook/pb_tooltip/docs/example.yml +4 -1
- data/app/pb_kits/playbook/pb_tooltip/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_tooltip/floating_ui.js +282 -0
- data/app/pb_kits/playbook/pb_tooltip/index.js +2 -2
- data/app/pb_kits/playbook/pb_tooltip/tooltip.rb +10 -2
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +51 -5
- data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +5 -1
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options.html.erb +45 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options.md +5 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options_pure_rails.html.erb +33 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options_pure_rails.md +3 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_react_hook.jsx +66 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_react_hook.md +1 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_custom_options.jsx +1 -1
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_users.jsx +1 -1
- data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +3 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_typeahead/index.ts +61 -8
- data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +17 -2
- data/app/pb_kits/playbook/tokens/_display.scss +3 -1
- data/app/pb_kits/playbook/utilities/_display.scss +6 -1
- data/app/pb_kits/playbook/utilities/object.test.js +99 -0
- data/app/pb_kits/playbook/utilities/object.ts +29 -1
- data/app/pb_kits/playbook/utilities/test/globalProps/display.test.js +1 -1
- data/dist/chunks/_typeahead-B8f4HM8I.js +36 -0
- data/dist/chunks/_weekday_stacked-BVO5G6au.js +45 -0
- data/dist/chunks/lazysizes-B7xYodB-.js +1 -0
- data/dist/chunks/{lib-D3us1bGD.js → lib-5OzNgeeu.js} +2 -2
- data/dist/chunks/{pb_form_validation-BpihMSOQ.js → pb_form_validation-DGhKbZtO.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +4 -4
- 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/display.rb +2 -2
- data/lib/playbook/forms/builder/time_zone_select_field.rb +19 -0
- data/lib/playbook/forms/builder.rb +1 -0
- data/lib/playbook/version.rb +2 -2
- metadata +80 -8
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_icon.erb +0 -10
- data/dist/chunks/_typeahead-PqkcDf1H.js +0 -36
- data/dist/chunks/_weekday_stacked-B_pw5Znc.js +0 -45
- data/dist/chunks/lazysizes-DHz07jlL.js +0 -1
@@ -0,0 +1,61 @@
|
|
1
|
+
import PbEnhancedElement from '../pb_enhanced_element'
|
2
|
+
|
3
|
+
const OVERLAY_SELECTOR = '[data-pb-overlay]'
|
4
|
+
const OVERLAY_SCROLL_ELEMENT = '[data-overlay-scroll-element]'
|
5
|
+
const PREVIOUS_OVERLAY_CLASSNAME = '[data-previous-overlay-classname]'
|
6
|
+
const SUBSEQUENT_OVERLAY_CLASSNAME = '[data-subsequent-overlay-classname]'
|
7
|
+
|
8
|
+
export default class PbOverlay extends PbEnhancedElement {
|
9
|
+
static get selector() {
|
10
|
+
return OVERLAY_SELECTOR
|
11
|
+
}
|
12
|
+
|
13
|
+
get target() {
|
14
|
+
return this.element.querySelector(OVERLAY_SCROLL_ELEMENT).children[0]
|
15
|
+
}
|
16
|
+
|
17
|
+
connect() {
|
18
|
+
this.handleOverlayDynamic()
|
19
|
+
}
|
20
|
+
|
21
|
+
handleOverlayDynamic() {
|
22
|
+
const isOverlayDynamic = this.element.dataset?.overlayDynamic
|
23
|
+
|
24
|
+
if (isOverlayDynamic) {
|
25
|
+
const previousOverlayElement = this.element.querySelector(PREVIOUS_OVERLAY_CLASSNAME)
|
26
|
+
const previousOverlayClassname = previousOverlayElement?.dataset?.previousOverlayClassname
|
27
|
+
const subsequentOverlayElement = this.element.querySelector(SUBSEQUENT_OVERLAY_CLASSNAME)
|
28
|
+
const subsequentOverlayClassname = subsequentOverlayElement?.dataset?.subsequentOverlayClassname
|
29
|
+
|
30
|
+
const handleScrollChange = (target) => {
|
31
|
+
const { scrollLeft, scrollWidth, clientWidth } = target
|
32
|
+
const isScrollAtStart = scrollLeft === 0
|
33
|
+
const isScrollAtEnd = scrollLeft + clientWidth >= scrollWidth - 1
|
34
|
+
|
35
|
+
if (isScrollAtStart) {
|
36
|
+
previousOverlayElement.classList.remove(previousOverlayClassname)
|
37
|
+
} else {
|
38
|
+
previousOverlayElement.classList.add(previousOverlayClassname)
|
39
|
+
}
|
40
|
+
|
41
|
+
if (isScrollAtEnd) {
|
42
|
+
subsequentOverlayElement.classList.remove(subsequentOverlayClassname)
|
43
|
+
} else {
|
44
|
+
subsequentOverlayElement.classList.add(subsequentOverlayClassname)
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
this.target.addEventListener('scroll', (event) => {
|
49
|
+
handleScrollChange(event.target)
|
50
|
+
})
|
51
|
+
|
52
|
+
handleScrollChange(this.target)
|
53
|
+
}
|
54
|
+
}
|
55
|
+
|
56
|
+
disconnect() {
|
57
|
+
if (this.element.dataset?.overlayDynamic) {
|
58
|
+
this.target.removeEventListener('scroll')
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}
|
@@ -16,12 +16,14 @@ id: object.id,
|
|
16
16
|
<% end %>
|
17
17
|
|
18
18
|
<% else %>
|
19
|
-
<div class="<%= previous_overlay_class_name %>"></div>
|
19
|
+
<div class="<%= previous_overlay_class_name %>" data-previous-overlay-classname="<%= previous_overlay_class_name %>"></div>
|
20
20
|
|
21
|
-
|
21
|
+
<div data-overlay-scroll-element="true">
|
22
|
+
<%= content.presence %>
|
23
|
+
</div>
|
22
24
|
|
23
25
|
<% if has_subsequent_overlay %>
|
24
|
-
<div class="<%= subsequent_overlay_class_name %>"></div>
|
26
|
+
<div class="<%= subsequent_overlay_class_name %>" data-subsequent-overlay-classname="<%= subsequent_overlay_class_name %>"></div>
|
25
27
|
<% end %>
|
26
28
|
<% end %>
|
27
29
|
<% end %>
|
@@ -8,9 +8,13 @@ module Playbook
|
|
8
8
|
default: "card_light"
|
9
9
|
prop :layout, type: Playbook::Props::HashProp,
|
10
10
|
default: { "bottom": "full" }
|
11
|
+
prop :dynamic, type: Playbook::Props::Boolean,
|
12
|
+
default: false
|
13
|
+
prop :scroll_bar_none, type: Playbook::Props::Boolean,
|
14
|
+
default: false
|
11
15
|
|
12
16
|
def classname
|
13
|
-
generate_classname("pb_overlay")
|
17
|
+
generate_classname("pb_overlay", hide_scroll_bar_class)
|
14
18
|
end
|
15
19
|
|
16
20
|
def position
|
@@ -105,6 +109,17 @@ module Playbook
|
|
105
109
|
"bg_dark": "#0a0527",
|
106
110
|
}
|
107
111
|
end
|
112
|
+
|
113
|
+
def data_attributes
|
114
|
+
data ||= {}
|
115
|
+
data.merge!("data-pb-overlay" => true)
|
116
|
+
data.merge!("data-overlay-dynamic" => true) if dynamic
|
117
|
+
data
|
118
|
+
end
|
119
|
+
|
120
|
+
def hide_scroll_bar_class
|
121
|
+
scroll_bar_none ? " overlay-hide-scrollbar" : ""
|
122
|
+
end
|
108
123
|
end
|
109
124
|
end
|
110
125
|
end
|
@@ -64,3 +64,15 @@ test('should render children', () => {
|
|
64
64
|
const kit = screen.getByTestId(testId)
|
65
65
|
expect(kit).toHaveTextContent(props.children)
|
66
66
|
})
|
67
|
+
|
68
|
+
test('should add overlay-hide-scrollbar class when scrollBarNone is true', () => {
|
69
|
+
const props = {
|
70
|
+
children,
|
71
|
+
data: { testid: testId },
|
72
|
+
scrollBarNone: true
|
73
|
+
}
|
74
|
+
|
75
|
+
render(<Overlay {...props} />)
|
76
|
+
const kit = screen.getByTestId(testId)
|
77
|
+
expect(kit).toHaveClass('overlay-hide-scrollbar')
|
78
|
+
})
|
@@ -23,6 +23,7 @@ type PhoneNumberInputProps = {
|
|
23
23
|
data?: { [key: string]: string },
|
24
24
|
disabled?: boolean,
|
25
25
|
error?: string,
|
26
|
+
hiddenInputs?: boolean,
|
26
27
|
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
27
28
|
id?: string,
|
28
29
|
initialCountry?: string,
|
@@ -72,6 +73,7 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.MutableRefOb
|
|
72
73
|
dark = false,
|
73
74
|
data = {},
|
74
75
|
disabled = false,
|
76
|
+
hiddenInputs = false,
|
75
77
|
htmlOptions = {},
|
76
78
|
id = "",
|
77
79
|
initialCountry = "",
|
@@ -243,6 +245,10 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.MutableRefOb
|
|
243
245
|
countrySearch: false,
|
244
246
|
fixDropdownWidth: false,
|
245
247
|
formatAsYouType: formatAsYouType,
|
248
|
+
hiddenInput: hiddenInputs ? () => ({
|
249
|
+
phone: `${name}_full`,
|
250
|
+
country: `${name}_country_code`,
|
251
|
+
}) : null,
|
246
252
|
})
|
247
253
|
|
248
254
|
itiRef.current = telInputInit;
|
@@ -0,0 +1 @@
|
|
1
|
+
The `hidden_inputs` boolean prop generates two hidden input fields, {field_name}_full and {field_name}_country_code. The value passed when the form is submitted contains the full phone number including the country code. Because it requires the submission of a form to function, only use this prop on Rails phone number elements within html form tags `<form>/<form>` or [pb_forms](https://playbook.powerapp.cloud/kits/form). Read the [intl-tel-input](https://intl-tel-input.com/examples/hidden-input.html) docs for more information.
|
@@ -16,4 +16,6 @@ examples:
|
|
16
16
|
- phone_number_input_initial_country: Initial Country
|
17
17
|
- phone_number_input_only_countries: Limited Countries
|
18
18
|
- phone_number_input_validation: Form Validation
|
19
|
-
- phone_number_input_format: Format as You Type
|
19
|
+
- phone_number_input_format: Format as You Type
|
20
|
+
- phone_number_input_hidden_inputs: Hidden Inputs
|
21
|
+
|
@@ -23,6 +23,8 @@ module Playbook
|
|
23
23
|
default: ""
|
24
24
|
prop :format_as_you_type, type: Playbook::Props::Boolean,
|
25
25
|
default: false
|
26
|
+
prop :hidden_inputs, type: Playbook::Props::Boolean,
|
27
|
+
default: false
|
26
28
|
|
27
29
|
def classname
|
28
30
|
generate_classname("pb_phone_number_input")
|
@@ -35,6 +37,7 @@ module Playbook
|
|
35
37
|
disabled: disabled,
|
36
38
|
error: error,
|
37
39
|
formatAsYouType: format_as_you_type,
|
40
|
+
hiddenInputs: hidden_inputs,
|
38
41
|
initialCountry: initial_country,
|
39
42
|
label: label,
|
40
43
|
name: name,
|
@@ -19,7 +19,7 @@ import {
|
|
19
19
|
|
20
20
|
import classnames from "classnames";
|
21
21
|
import { globalProps, GlobalProps } from "../utilities/globalProps";
|
22
|
-
import { uniqueId } from '
|
22
|
+
import { uniqueId } from '../utilities/object';
|
23
23
|
|
24
24
|
type ModifiedGlobalProps = Omit<GlobalProps, 'minWidth' | 'maxHeight' | 'minHeight'>
|
25
25
|
|
@@ -84,7 +84,7 @@ const Popover = (props: PbPopoverProps) => {
|
|
84
84
|
} = props;
|
85
85
|
|
86
86
|
const items = globalProps(props).split(' ')
|
87
|
-
const filteredItems = items.filter(item => !item.includes('
|
87
|
+
const filteredItems = items.filter(item => !item.includes('min-width') && !item.includes('width'))
|
88
88
|
const filteredGlobalProps = filteredItems.join(' ')
|
89
89
|
const popoverSpacing =
|
90
90
|
filteredGlobalProps.includes("dark") || !filteredGlobalProps
|
@@ -181,7 +181,7 @@ const PopoverTestClicktoClose3 = () => {
|
|
181
181
|
const btn = screen.getByText(/click me/i)
|
182
182
|
fireEvent.click(btn);
|
183
183
|
const kit = screen.getByText("Click Anywhere");
|
184
|
-
expect(kit).toHaveClass("pb_popover_body
|
184
|
+
expect(kit).toHaveClass("pb_popover_body p_sm overflow_handling");
|
185
185
|
});
|
186
186
|
|
187
187
|
test("closes Popover on click anywhere", async () => {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<%= pb_content_tag(:li) do %>
|
2
|
-
<div class="box" style="max-width: min-content;"
|
3
|
-
<div class="circle">
|
2
|
+
<div class="box" style="max-width: min-content;">
|
3
|
+
<div class="circle" id="<%= object.tooltip_trigger_class %>" >
|
4
4
|
<%= pb_rails("icon", props: { icon: object.icon, size: "xs" }) if object.icon.present? %>
|
5
5
|
</div>
|
6
6
|
<% if object.tooltip.present? %>
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
import React, { forwardRef, useRef } from 'react'
|
1
|
+
import React, { useRef, forwardRef } from 'react'
|
4
2
|
import Body from '../pb_body/_body'
|
5
3
|
import Flex from '../pb_flex/_flex'
|
6
4
|
import classnames from 'classnames'
|
@@ -10,7 +8,7 @@ import { globalProps, GlobalProps } from '../utilities/globalProps'
|
|
10
8
|
type RadioProps = {
|
11
9
|
aria?: { [key: string]: string },
|
12
10
|
alignment?: string,
|
13
|
-
checked?: boolean,
|
11
|
+
checked?: boolean, // removed default assignment here
|
14
12
|
children?: React.ReactChild[] | React.ReactChild,
|
15
13
|
customChildren?: boolean,
|
16
14
|
className?: string,
|
@@ -24,10 +22,10 @@ type RadioProps = {
|
|
24
22
|
name?: string,
|
25
23
|
value?: string,
|
26
24
|
text?: string,
|
27
|
-
onChange
|
25
|
+
onChange?: (event: React.FormEvent<HTMLInputElement> | null) => void,
|
28
26
|
} & GlobalProps
|
29
27
|
|
30
|
-
const Radio = ({
|
28
|
+
const Radio = forwardRef<HTMLInputElement, RadioProps>(({
|
31
29
|
aria = {},
|
32
30
|
alignment,
|
33
31
|
children,
|
@@ -43,110 +41,123 @@ const Radio = ({
|
|
43
41
|
name = 'radio_name',
|
44
42
|
text = 'Radio Text',
|
45
43
|
value = 'radio_text',
|
44
|
+
checked,
|
46
45
|
onChange = () => { void 0 },
|
47
46
|
...props
|
48
|
-
}
|
49
|
-
const
|
47
|
+
}, ref) => {
|
48
|
+
const internalRef = useRef<HTMLInputElement>(null)
|
49
|
+
const setRefs = (el: HTMLInputElement) => {
|
50
|
+
internalRef.current = el
|
51
|
+
if (typeof ref === 'function') {
|
52
|
+
ref(el)
|
53
|
+
} else if (ref) {
|
54
|
+
(ref as React.MutableRefObject<HTMLInputElement | null>).current = el
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
const ariaProps = buildAriaProps(aria)
|
59
|
+
const dataProps = buildDataProps(data)
|
60
|
+
const htmlProps = buildHtmlProps(htmlOptions)
|
50
61
|
|
51
|
-
const ariaProps = buildAriaProps(aria);
|
52
|
-
const dataProps = buildDataProps(data);
|
53
|
-
const htmlProps = buildHtmlProps(htmlOptions);
|
54
62
|
const classes = classnames(
|
55
63
|
buildCss('pb_radio_kit', alignment),
|
56
64
|
dark ? 'dark' : null,
|
57
65
|
error ? 'error' : null,
|
58
66
|
globalProps(props),
|
59
67
|
className
|
60
|
-
)
|
68
|
+
)
|
61
69
|
|
62
70
|
const classesCustom = classnames(
|
63
71
|
dark ? 'dark' : null,
|
64
72
|
error ? 'error' : null,
|
65
73
|
globalProps(props),
|
66
74
|
className
|
67
|
-
)
|
75
|
+
)
|
76
|
+
|
77
|
+
const checkedProps = checked !== undefined ? { checked } : {}
|
68
78
|
|
69
|
-
const displayRadio = (
|
70
|
-
if (children && customChildren
|
71
|
-
return
|
79
|
+
const displayRadio = (inputProps: any) => {
|
80
|
+
if (children && customChildren === false)
|
81
|
+
return children
|
72
82
|
else
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
83
|
+
return (
|
84
|
+
<input
|
85
|
+
{...checkedProps}
|
86
|
+
disabled={disabled}
|
87
|
+
id={id}
|
88
|
+
name={name}
|
89
|
+
onChange={onChange}
|
90
|
+
ref={setRefs}
|
91
|
+
type="radio"
|
92
|
+
value={value}
|
93
|
+
{...inputProps}
|
94
|
+
/>
|
95
|
+
)
|
96
|
+
}
|
86
97
|
|
87
98
|
const handleContainerClick = (event: React.MouseEvent<HTMLDivElement, MouseEvent> | undefined) => {
|
88
99
|
if (event) {
|
89
|
-
const target = event.target as HTMLElement
|
100
|
+
const target = event.target as HTMLElement
|
90
101
|
if (
|
91
102
|
target.id === 'pb-radio-children-wrapper' ||
|
92
103
|
target.closest('#pb-radio-children-wrapper')
|
93
104
|
) {
|
94
|
-
|
105
|
+
internalRef.current?.click()
|
95
106
|
}
|
96
107
|
}
|
97
|
-
}
|
108
|
+
}
|
98
109
|
|
99
|
-
return (
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
>
|
116
|
-
<label className={buildCss('pb_radio_kit', alignment)}>
|
110
|
+
return customChildren ? (
|
111
|
+
<Flex
|
112
|
+
{...ariaProps}
|
113
|
+
{...dataProps}
|
114
|
+
{...htmlProps}
|
115
|
+
align="center"
|
116
|
+
className={classesCustom}
|
117
|
+
cursor="pointer"
|
118
|
+
htmlFor={id}
|
119
|
+
htmlOptions={{
|
120
|
+
onClick: ((event: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
|
121
|
+
handleContainerClick(event)
|
122
|
+
}) as unknown as () => void
|
123
|
+
}}
|
124
|
+
id="radio-container"
|
125
|
+
>
|
126
|
+
<label className={buildCss('pb_radio_kit', alignment)}>
|
117
127
|
<input
|
128
|
+
{...checkedProps}
|
118
129
|
disabled={disabled}
|
119
130
|
id={id}
|
120
131
|
name={name}
|
121
132
|
onChange={onChange}
|
122
|
-
ref={
|
133
|
+
ref={setRefs}
|
123
134
|
type="radio"
|
124
135
|
value={value}
|
125
136
|
{...props}
|
126
137
|
/>
|
127
|
-
<span className="pb_radio_button" />
|
128
|
-
</label>
|
129
|
-
<div id="pb-radio-children-wrapper"> {children} </div>
|
130
|
-
</Flex>
|
131
|
-
) : (
|
132
|
-
<label
|
133
|
-
{...ariaProps}
|
134
|
-
{...dataProps}
|
135
|
-
{...htmlProps}
|
136
|
-
className={classes}
|
137
|
-
htmlFor={id}
|
138
|
-
>
|
139
|
-
<>{displayRadio(props)}</>
|
140
138
|
<span className="pb_radio_button" />
|
141
|
-
<Body
|
142
|
-
dark={dark}
|
143
|
-
status={error ? 'negative' : null}
|
144
|
-
text={label}
|
145
|
-
variant={null}
|
146
|
-
/>
|
147
139
|
</label>
|
148
|
-
|
149
|
-
|
150
|
-
|
140
|
+
<div id="pb-radio-children-wrapper"> {children} </div>
|
141
|
+
</Flex>
|
142
|
+
) : (
|
143
|
+
<label
|
144
|
+
{...ariaProps}
|
145
|
+
{...dataProps}
|
146
|
+
{...htmlProps}
|
147
|
+
className={classes}
|
148
|
+
htmlFor={id}
|
149
|
+
>
|
150
|
+
{displayRadio(props)}
|
151
|
+
<span className="pb_radio_button" />
|
152
|
+
<Body
|
153
|
+
dark={dark}
|
154
|
+
status={error ? 'negative' : null}
|
155
|
+
text={label}
|
156
|
+
variant={null}
|
157
|
+
/>
|
158
|
+
</label>
|
159
|
+
)
|
160
|
+
})
|
151
161
|
|
152
|
-
|
162
|
+
Radio.displayName = "Radio"
|
163
|
+
export default Radio
|
@@ -0,0 +1,60 @@
|
|
1
|
+
import React from "react"
|
2
|
+
import { useForm } from "react-hook-form"
|
3
|
+
import { Radio, Flex, Body } from "playbook-ui"
|
4
|
+
|
5
|
+
const RadioReactHook = () => {
|
6
|
+
const { register, watch } = useForm({
|
7
|
+
defaultValues: {
|
8
|
+
size: "Small",
|
9
|
+
},
|
10
|
+
})
|
11
|
+
|
12
|
+
const selectedSize = watch("size", "Small")
|
13
|
+
|
14
|
+
return (
|
15
|
+
<Flex orientation="row">
|
16
|
+
<Flex
|
17
|
+
align="start"
|
18
|
+
orientation="column"
|
19
|
+
paddingRight="lg"
|
20
|
+
>
|
21
|
+
<Radio
|
22
|
+
alignment="left"
|
23
|
+
label="Small"
|
24
|
+
marginBottom='sm'
|
25
|
+
name="size"
|
26
|
+
value="Small"
|
27
|
+
{...register("size")}
|
28
|
+
/>
|
29
|
+
<br />
|
30
|
+
<Radio
|
31
|
+
alignment="left"
|
32
|
+
label="Medium"
|
33
|
+
marginBottom='sm'
|
34
|
+
name="size"
|
35
|
+
value="Medium"
|
36
|
+
{...register("size")}
|
37
|
+
/>
|
38
|
+
<br />
|
39
|
+
<Radio
|
40
|
+
alignment="left"
|
41
|
+
label="Large"
|
42
|
+
marginBottom='sm'
|
43
|
+
name="size"
|
44
|
+
value="Large"
|
45
|
+
{...register("size")}
|
46
|
+
/>
|
47
|
+
</Flex>
|
48
|
+
<Flex
|
49
|
+
align="start"
|
50
|
+
orientation="column"
|
51
|
+
>
|
52
|
+
<Body
|
53
|
+
text={`Selected Size: ${selectedSize}`}
|
54
|
+
/>
|
55
|
+
</Flex>
|
56
|
+
</Flex>
|
57
|
+
)
|
58
|
+
}
|
59
|
+
|
60
|
+
export default RadioReactHook
|
@@ -0,0 +1 @@
|
|
1
|
+
You can pass react hook props to the radio kit.
|
@@ -16,6 +16,7 @@ examples:
|
|
16
16
|
- radio_alignment: Alignment
|
17
17
|
- radio_disabled: Disabled
|
18
18
|
- radio_custom_children: Custom Children
|
19
|
+
- radio_react_hook: React Hook Form
|
19
20
|
|
20
21
|
swift:
|
21
22
|
- radio_default_swift: Default
|
@@ -26,4 +27,4 @@ examples:
|
|
26
27
|
- radio_spacing_swift: Spacing
|
27
28
|
- radio_padding_swift: Padding
|
28
29
|
- radio_subtitle_swift: Subtitle
|
29
|
-
- radio_props_swift: ""
|
30
|
+
- radio_props_swift: ""
|
@@ -4,3 +4,4 @@ export { default as RadioError } from './_radio_error.jsx'
|
|
4
4
|
export { default as RadioAlignment } from './_radio_alignment.jsx'
|
5
5
|
export { default as RadioDisabled } from './_radio_disabled.jsx'
|
6
6
|
export { default as RadioCustomChildren } from './_radio_custom_children.jsx'
|
7
|
+
export { default as RadioReactHook } from './_radio_react_hook.jsx'
|
@@ -86,3 +86,19 @@ test('has disabled attribute', () => {
|
|
86
86
|
expect(input).toHaveAttribute('disabled')
|
87
87
|
})
|
88
88
|
|
89
|
+
|
90
|
+
test('has ref in the input element', () => {
|
91
|
+
const ref = React.createRef()
|
92
|
+
render(
|
93
|
+
<Radio
|
94
|
+
data={{ testid: testId }}
|
95
|
+
name="Radio-name"
|
96
|
+
ref={ref}
|
97
|
+
text="Radio"
|
98
|
+
value="radio value"
|
99
|
+
/>
|
100
|
+
)
|
101
|
+
|
102
|
+
expect(ref.current).not.toBeNull()
|
103
|
+
expect(ref.current?.tagName).toBe('INPUT')
|
104
|
+
})
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import React, { useState } from "react"
|
2
|
+
import { useForm } from "react-hook-form"
|
3
|
+
import { Button, Body, Select } from "playbook-ui"
|
4
|
+
|
5
|
+
const SelectReactHook = (props) => {
|
6
|
+
const { register, handleSubmit, formState: { errors } } = useForm({
|
7
|
+
defaultValues: {
|
8
|
+
food: '',
|
9
|
+
},
|
10
|
+
})
|
11
|
+
|
12
|
+
const [submittedData, setSubmittedData] = useState({
|
13
|
+
food: '',
|
14
|
+
})
|
15
|
+
|
16
|
+
const onSubmit = (data) => {
|
17
|
+
setSubmittedData(data)
|
18
|
+
}
|
19
|
+
|
20
|
+
const options = [
|
21
|
+
{
|
22
|
+
value: 1,
|
23
|
+
text: 'Burgers',
|
24
|
+
},
|
25
|
+
{
|
26
|
+
value: 2,
|
27
|
+
text: 'Pizza',
|
28
|
+
},
|
29
|
+
{
|
30
|
+
value: 3,
|
31
|
+
text: 'Tacos',
|
32
|
+
},
|
33
|
+
]
|
34
|
+
|
35
|
+
return (
|
36
|
+
<>
|
37
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
38
|
+
<Select
|
39
|
+
{...props}
|
40
|
+
{...register("food", { required: true })}
|
41
|
+
error={errors.food ? "Please select a food." : null}
|
42
|
+
label="Favorite Food"
|
43
|
+
options={options}
|
44
|
+
/>
|
45
|
+
<br />
|
46
|
+
<Button htmlType="submit"
|
47
|
+
marginTop="sm"
|
48
|
+
text="Submit"
|
49
|
+
/>
|
50
|
+
</form>
|
51
|
+
<Body padding="xs"
|
52
|
+
text={`Food: ${submittedData.food}`}
|
53
|
+
/>
|
54
|
+
</>
|
55
|
+
)
|
56
|
+
}
|
57
|
+
|
58
|
+
export default SelectReactHook
|
@@ -0,0 +1 @@
|
|
1
|
+
You can pass react-hook-form props to a select kit. You can use `register` which will make the value available for both the form validation and submission.
|
@@ -10,3 +10,4 @@ export { default as SelectInline } from './_select_inline.jsx'
|
|
10
10
|
export { default as SelectInlineShowArrow } from './_select_inline_show_arrow.jsx'
|
11
11
|
export { default as SelectInlineCompact } from './_select_inline_compact.jsx'
|
12
12
|
export { default as SelectMultiple } from './_select_multiple.jsx'
|
13
|
+
export { default as SelectReactHook } from './_select_react_hook.jsx'
|