playbook_ui 14.14.0.pre.alpha.PBNTR907reactfilterpopoverpropswidthbug6557 → 14.14.0.pre.alpha.pbntr500currencykithandlingofnullvalues6275
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/Context/AdvancedTableContext.tsx +3 -143
- data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableBody.tsx +99 -45
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +7 -123
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +299 -153
- data/app/pb_kits/playbook/pb_card/_card.tsx +1 -2
- data/app/pb_kits/playbook/pb_currency/_currency.tsx +2 -1
- data/app/pb_kits/playbook/pb_currency/currency.html.erb +1 -1
- data/app/pb_kits/playbook/pb_currency/currency.rb +2 -14
- data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display.html.erb +1 -3
- data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +1 -4
- data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +0 -2
- data/app/pb_kits/playbook/pb_drawer/_drawer.scss +3 -43
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_borders.jsx +3 -3
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_breakpoints.jsx +37 -20
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_default.html.erb +1 -20
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_menu.jsx +6 -6
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.jsx +0 -1
- data/app/pb_kits/playbook/pb_drawer/docs/example.yml +0 -6
- data/app/pb_kits/playbook/pb_drawer/drawer.html.erb +12 -20
- data/app/pb_kits/playbook/pb_drawer/drawer.rb +1 -49
- data/app/pb_kits/playbook/pb_filter/Filter/CurrentFilters.tsx +4 -5
- data/app/pb_kits/playbook/pb_filter/Filter/FilterSingle.tsx +2 -2
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +2 -2
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +2 -9
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +0 -4
- data/app/pb_kits/playbook/pb_form_pill/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_form_pill/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_form_pill/form_pill.rb +1 -7
- data/app/pb_kits/playbook/pb_icon_button/docs/example.yml +0 -4
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.scss +0 -7
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +3 -13
- data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +1 -2
- data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.rb +0 -6
- data/app/pb_kits/playbook/pb_overlay/_overlay.scss +0 -13
- data/app/pb_kits/playbook/pb_overlay/_overlay.tsx +1 -7
- data/app/pb_kits/playbook/pb_overlay/docs/example.yml +0 -3
- data/app/pb_kits/playbook/pb_overlay/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_overlay/overlay.html.erb +3 -5
- data/app/pb_kits/playbook/pb_overlay/overlay.rb +1 -16
- data/app/pb_kits/playbook/pb_overlay/overlay.test.jsx +0 -12
- 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 +74 -85
- data/app/pb_kits/playbook/pb_radio/docs/example.yml +1 -2
- data/app/pb_kits/playbook/pb_radio/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_radio/radio.test.js +0 -16
- data/app/pb_kits/playbook/pb_select/docs/example.yml +0 -1
- data/app/pb_kits/playbook/pb_select/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_select/select.html.erb +5 -3
- data/app/pb_kits/playbook/pb_select/select.rb +0 -8
- data/app/pb_kits/playbook/pb_selectable_card/selectable_card.html.erb +5 -1
- data/app/pb_kits/playbook/pb_selectable_card_icon/selectable_card_icon.html.erb +4 -1
- data/app/pb_kits/playbook/pb_selectable_icon/selectable_icon.html.erb +5 -1
- data/app/pb_kits/playbook/pb_timeline/_timeline.scss +2 -2
- data/app/pb_kits/playbook/pb_title/_title.scss +0 -32
- data/app/pb_kits/playbook/pb_title/_title.tsx +1 -10
- data/app/pb_kits/playbook/pb_title/docs/_title_default.html.erb +2 -1
- data/app/pb_kits/playbook/pb_title/docs/_title_default.jsx +1 -1
- data/app/pb_kits/playbook/pb_title/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_title/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_title/title.rb +1 -10
- data/app/pb_kits/playbook/pb_tooltip/_tooltip.scss +3 -0
- data/app/pb_kits/playbook/pb_tooltip/_tooltip.tsx +0 -25
- data/app/pb_kits/playbook/pb_tooltip/docs/example.yml +1 -3
- data/app/pb_kits/playbook/pb_tooltip/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_tooltip/index.js +2 -2
- data/app/pb_kits/playbook/pb_tooltip/tooltip.rb +2 -10
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +2 -36
- data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +1 -5
- data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_typeahead/index.ts +8 -61
- data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +2 -17
- data/app/pb_kits/playbook/utilities/object.ts +1 -29
- data/dist/chunks/_typeahead-PqkcDf1H.js +36 -0
- data/dist/chunks/_weekday_stacked-BhC8Xp9l.js +45 -0
- data/dist/chunks/{lib-5OzNgeeu.js → lib-D3us1bGD.js} +2 -2
- data/dist/chunks/{pb_form_validation-DGhKbZtO.js → pb_form_validation-BpihMSOQ.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +3 -3
- 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/version.rb +1 -1
- metadata +6 -64
- data/app/pb_kits/playbook/pb_advanced_table/Components/RegularTableView.tsx +0 -127
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableActionBar.tsx +0 -55
- data/app/pb_kits/playbook/pb_advanced_table/Components/TablePagination.tsx +0 -33
- data/app/pb_kits/playbook/pb_advanced_table/Components/VirtualizedTableView.tsx +0 -275
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableActions.ts +0 -66
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +0 -195
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/CellRendererUtils.tsx +0 -73
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/RowUtils.ts +0 -52
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/TableContainerStyles.ts +0 -80
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_infinite_scroll.jsx +0 -50
- data/app/pb_kits/playbook/pb_advanced_table/docs/advanced_table_mock_data_infinite_scroll.json +0 -152002
- data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display_rails.md +0 -1
- data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display_react.md +0 -1
- data/app/pb_kits/playbook/pb_date_picker/index.ts +0 -38
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_behavior.html.erb +0 -8
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_borders.html.erb +0 -33
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_breakpoints.html.erb +0 -0
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_menu.html.erb +0 -24
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.html.erb +0 -21
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.md +0 -1
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_sizes.html.erb +0 -49
- data/app/pb_kits/playbook/pb_drawer/index.js +0 -257
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_wrapped.html.erb +0 -40
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_wrapped.jsx +0 -50
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_wrapped.md +0 -3
- data/app/pb_kits/playbook/pb_icon_button/_icon_button.tsx +0 -71
- data/app/pb_kits/playbook/pb_icon_button/docs/_icon_button_default.jsx +0 -17
- data/app/pb_kits/playbook/pb_icon_button/docs/_icon_button_sizes.jsx +0 -61
- data/app/pb_kits/playbook/pb_icon_button/docs/index.js +0 -2
- data/app/pb_kits/playbook/pb_icon_button/icon_button.test.jsx +0 -39
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_disabled.html.erb +0 -72
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_disabled.jsx +0 -91
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar.html.erb +0 -11
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar.jsx +0 -37
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar_rails.md +0 -1
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar_react.md +0 -1
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional.html.erb +0 -11
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional.md +0 -1
- data/app/pb_kits/playbook/pb_overlay/index.js +0 -61
- data/app/pb_kits/playbook/pb_radio/docs/_radio_react_hook.jsx +0 -60
- data/app/pb_kits/playbook/pb_radio/docs/_radio_react_hook.md +0 -1
- data/app/pb_kits/playbook/pb_select/docs/_select_react_hook.jsx +0 -58
- data/app/pb_kits/playbook/pb_select/docs/_select_react_hook.md +0 -1
- data/app/pb_kits/playbook/pb_select/index.js +0 -38
- data/app/pb_kits/playbook/pb_title/docs/_title_display_size.html.erb +0 -7
- data/app/pb_kits/playbook/pb_title/docs/_title_display_size.jsx +0 -54
- data/app/pb_kits/playbook/pb_title/docs/_title_display_size.md +0 -1
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_delay_rails.html.erb +0 -39
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_delay_rails.md +0 -3
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_interaction.html.erb +0 -26
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_sizing.jsx +0 -69
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_sizing.md +0 -3
- data/app/pb_kits/playbook/pb_tooltip/floating_ui.js +0 -282
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options.html.erb +0 -45
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options.md +0 -5
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options_pure_rails.html.erb +0 -33
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options_pure_rails.md +0 -3
- data/app/pb_kits/playbook/utilities/object.test.js +0 -99
- data/dist/chunks/_typeahead-F4bG5YsC.js +0 -36
- data/dist/chunks/_weekday_stacked-CaWVQMMq.js +0 -45
@@ -1,9 +1,10 @@
|
|
1
1
|
<%= pb_rails("title", props: {
|
2
|
-
margin_bottom: "md"
|
3
2
|
}) do %>
|
4
3
|
Default Title
|
5
4
|
<% end %>
|
6
5
|
|
6
|
+
<br/>
|
7
|
+
|
7
8
|
<%= pb_rails("title", props: { text: "Title 1", tag: "h1", size: 1 }) %>
|
8
9
|
<%= pb_rails("title", props: { text: "Title 2", tag: "h2", size: 2 }) %>
|
9
10
|
<%= pb_rails("title", props: { text: "Title 3", tag: "h3", size: 3 }) %>
|
@@ -5,7 +5,6 @@ examples:
|
|
5
5
|
- title_colors: Colors
|
6
6
|
- title_responsive: Responsive
|
7
7
|
- title_truncate: Truncate
|
8
|
-
- title_display_size: Display Size
|
9
8
|
|
10
9
|
react:
|
11
10
|
- title_default: Default UI
|
@@ -13,4 +12,3 @@ examples:
|
|
13
12
|
- title_colors: Colors
|
14
13
|
- title_responsive: Responsive
|
15
14
|
- title_truncate: Truncate
|
16
|
-
- title_display_size: Display Size
|
@@ -3,4 +3,3 @@ export { default as TitleLightWeight } from './_title_light_weight.jsx'
|
|
3
3
|
export { default as TitleColors } from './_title_colors.jsx'
|
4
4
|
export { default as TitleResponsive } from './_title_responsive.jsx'
|
5
5
|
export { default as TitleTruncate } from './_title_truncate.jsx'
|
6
|
-
export { default as TitleDisplaySize } from './_title_display_size.jsx'
|
@@ -16,15 +16,12 @@ module Playbook
|
|
16
16
|
default: nil,
|
17
17
|
deprecated: true
|
18
18
|
prop :bold, type: Playbook::Props::Boolean, default: true
|
19
|
-
prop :display_size, type: Playbook::Props::Enum,
|
20
|
-
values: [nil, "xs", "sm", "md", "lg", "xl", "xxl"],
|
21
|
-
default: nil
|
22
19
|
|
23
20
|
def classname
|
24
21
|
if is_size_responsive
|
25
22
|
generate_classname("pb_title_kit", variant, color, is_bold) + generate_responsive_size_classname
|
26
23
|
else
|
27
|
-
generate_classname("pb_title_kit", size, variant, color, is_bold)
|
24
|
+
generate_classname("pb_title_kit", size, variant, color, is_bold)
|
28
25
|
end
|
29
26
|
end
|
30
27
|
|
@@ -32,12 +29,6 @@ module Playbook
|
|
32
29
|
bold ? nil : "thin"
|
33
30
|
end
|
34
31
|
|
35
|
-
def generate_display_size
|
36
|
-
return "" if display_size.nil?
|
37
|
-
|
38
|
-
" pb_title_kit_dynamic_#{display_size}"
|
39
|
-
end
|
40
|
-
|
41
32
|
def is_size_responsive
|
42
33
|
try(:size).is_a?(::Hash)
|
43
34
|
end
|
@@ -141,6 +141,7 @@ $tooltip_shadow: rgba(60, 106, 172, 0.18);
|
|
141
141
|
|
142
142
|
&[data-popper-placement="right"] {
|
143
143
|
box-shadow: -8px 0 28px 0 $tooltip_shadow;
|
144
|
+
margin: 0 0 0 $space_sm;
|
144
145
|
.arrow {
|
145
146
|
left: -18px;
|
146
147
|
right: auto;
|
@@ -155,6 +156,7 @@ $tooltip_shadow: rgba(60, 106, 172, 0.18);
|
|
155
156
|
|
156
157
|
&[data-popper-placement="bottom"] {
|
157
158
|
box-shadow: 0 -12px 28px 0 $tooltip_shadow;
|
159
|
+
margin: $space_sm 0 0 0;
|
158
160
|
.arrow {
|
159
161
|
top: -18px;
|
160
162
|
margin-bottom: 0;
|
@@ -167,6 +169,7 @@ $tooltip_shadow: rgba(60, 106, 172, 0.18);
|
|
167
169
|
|
168
170
|
&[data-popper-placement="left"] {
|
169
171
|
box-shadow: 8px 0 28px 0 $tooltip_shadow;
|
172
|
+
margin: 0 $space_sm 0 0;
|
170
173
|
.arrow {
|
171
174
|
margin-bottom: 0;
|
172
175
|
right: -18px;
|
@@ -25,18 +25,12 @@ type TooltipProps = {
|
|
25
25
|
children: JSX.Element,
|
26
26
|
data?: { [key: string]: string },
|
27
27
|
delay?: number | Partial<{open: number; close: number}>,
|
28
|
-
height?: string,
|
29
28
|
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
30
29
|
icon?: string,
|
31
30
|
interaction?: boolean,
|
32
|
-
maxHeight?: string,
|
33
|
-
maxWidth?: string,
|
34
|
-
minHeight?: string,
|
35
|
-
minWidth?: string,
|
36
31
|
placement?: Placement,
|
37
32
|
position?: "absolute" | "fixed";
|
38
33
|
text: string,
|
39
|
-
width: string,
|
40
34
|
showTooltip?: boolean,
|
41
35
|
forceOpenTooltip?: boolean,
|
42
36
|
} & GlobalProps
|
@@ -48,19 +42,13 @@ const Tooltip = forwardRef((props: TooltipProps, ref: ForwardedRef<unknown>): Re
|
|
48
42
|
children,
|
49
43
|
data = {},
|
50
44
|
delay = 0,
|
51
|
-
height,
|
52
45
|
htmlOptions = {},
|
53
46
|
icon = null,
|
54
47
|
interaction = false,
|
55
|
-
maxHeight,
|
56
|
-
maxWidth,
|
57
|
-
minHeight,
|
58
|
-
minWidth,
|
59
48
|
placement: preferredPlacement = "top",
|
60
49
|
position = "absolute",
|
61
50
|
text,
|
62
51
|
showTooltip = true,
|
63
|
-
width,
|
64
52
|
zIndex,
|
65
53
|
forceOpenTooltip = false,
|
66
54
|
...rest
|
@@ -127,18 +115,6 @@ const Tooltip = forwardRef((props: TooltipProps, ref: ForwardedRef<unknown>): Re
|
|
127
115
|
top: "bottom",
|
128
116
|
}[placement.split("-")[0]]
|
129
117
|
|
130
|
-
const tooltipSizing = () => {
|
131
|
-
return Object.assign(
|
132
|
-
{},
|
133
|
-
height ? { height: height } : {},
|
134
|
-
maxHeight ? { maxHeight: maxHeight } : {},
|
135
|
-
maxWidth ? { maxWidth: maxWidth } : {},
|
136
|
-
minHeight ? { minHeight: minHeight } : {},
|
137
|
-
minWidth ? { minWidth: minWidth } : {},
|
138
|
-
width ? { width: width } : {}
|
139
|
-
);
|
140
|
-
};
|
141
|
-
|
142
118
|
return (
|
143
119
|
<>
|
144
120
|
<div
|
@@ -168,7 +144,6 @@ const Tooltip = forwardRef((props: TooltipProps, ref: ForwardedRef<unknown>): Re
|
|
168
144
|
ref: refs.setFloating,
|
169
145
|
role: "tooltip",
|
170
146
|
style: {
|
171
|
-
...tooltipSizing(),
|
172
147
|
position: strategy,
|
173
148
|
top: y ?? 0,
|
174
149
|
left: x ?? 0,
|
@@ -2,17 +2,15 @@ examples:
|
|
2
2
|
|
3
3
|
rails:
|
4
4
|
- tooltip_default: Default
|
5
|
-
- tooltip_interaction: Content Interaction
|
6
5
|
- tooltip_selectors: Using Common Selectors
|
7
6
|
- tooltip_with_icon_circle: Icon Circle Tooltip
|
8
|
-
- tooltip_delay_rails: Delay
|
9
7
|
- tooltip_show_tooltip: Show Tooltip
|
10
8
|
|
11
9
|
react:
|
12
10
|
- tooltip_default_react: Default
|
13
11
|
- tooltip_interaction: Content Interaction
|
14
12
|
- tooltip_margin: Margin
|
15
|
-
- tooltip_sizing: Tooltip Sizing
|
16
13
|
- tooltip_icon: Tooltip with Icon
|
17
14
|
- tooltip_delay: Delay
|
18
15
|
- tooltip_show_tooltip_react: Show Tooltip
|
16
|
+
|
@@ -1,7 +1,6 @@
|
|
1
1
|
export { default as TooltipDefaultReact } from './_tooltip_default_react'
|
2
2
|
export { default as TooltipInteraction } from './_tooltip_interaction'
|
3
3
|
export { default as TooltipMargin } from './_tooltip_margin'
|
4
|
-
export { default as TooltipSizing } from './_tooltip_sizing'
|
5
4
|
export { default as TooltipIcon } from './_tooltip_icon'
|
6
5
|
export { default as TooltipDelay } from './_tooltip_delay'
|
7
6
|
export { default as TooltipShowTooltipReact } from './_tooltip_show_tooltip_react'
|
@@ -11,7 +11,7 @@ const TOOLTIP_TIMEOUT = 250
|
|
11
11
|
|
12
12
|
export default class PbTooltip extends PbEnhancedElement {
|
13
13
|
static get selector() {
|
14
|
-
return '[data-pb-tooltip-kit
|
14
|
+
return '[data-pb-tooltip-kit]'
|
15
15
|
}
|
16
16
|
|
17
17
|
connect() {
|
@@ -152,4 +152,4 @@ export default class PbTooltip extends PbEnhancedElement {
|
|
152
152
|
get triggerMethod() {
|
153
153
|
return this.element.dataset.pbTooltipTriggerMethod || 'hover'
|
154
154
|
}
|
155
|
-
}
|
155
|
+
}
|
@@ -7,10 +7,6 @@ module Playbook
|
|
7
7
|
prop :trigger_element_selector
|
8
8
|
prop :trigger_element_id, deprecated: true
|
9
9
|
prop :tooltip_id
|
10
|
-
prop :interaction, type: Playbook::Props::Boolean,
|
11
|
-
default: false
|
12
|
-
prop :delay_open
|
13
|
-
prop :delay_close
|
14
10
|
prop :dark, type: Playbook::Props::Boolean,
|
15
11
|
default: false
|
16
12
|
prop :trigger_method, type: Playbook::Props::Enum,
|
@@ -22,19 +18,15 @@ module Playbook
|
|
22
18
|
end
|
23
19
|
|
24
20
|
def data
|
25
|
-
|
21
|
+
Hash(values[:data]).merge(
|
26
22
|
pb_tooltip_kit: true,
|
27
23
|
pb_tooltip_position: position,
|
28
24
|
pb_tooltip_trigger_element_selector: trigger_element_selector,
|
29
25
|
pb_tooltip_trigger_element_id: trigger_element_id,
|
30
26
|
pb_tooltip_tooltip_id: tooltip_id,
|
31
27
|
pb_tooltip_show_tooltip: true,
|
32
|
-
pb_tooltip_trigger_method: trigger_method
|
33
|
-
pb_tooltip_interaction: interaction
|
28
|
+
pb_tooltip_trigger_method: trigger_method
|
34
29
|
)
|
35
|
-
data = data.merge(pb_tooltip_delay_open: delay_open) if delay_open
|
36
|
-
data = data.merge(pb_tooltip_delay_close: delay_close) if delay_close
|
37
|
-
data
|
38
30
|
end
|
39
31
|
|
40
32
|
private
|
@@ -1,10 +1,9 @@
|
|
1
|
-
import React
|
1
|
+
import React from 'react'
|
2
2
|
import Select from 'react-select'
|
3
3
|
import AsyncSelect from 'react-select/async'
|
4
4
|
import CreateableSelect from 'react-select/creatable'
|
5
5
|
import AsyncCreateableSelect from 'react-select/async-creatable'
|
6
|
-
import { get, isString, uniqueId } from '
|
7
|
-
|
6
|
+
import { get, isString, uniqueId } from 'lodash'
|
8
7
|
import { globalProps, GlobalProps } from '../utilities/globalProps'
|
9
8
|
import classnames from 'classnames'
|
10
9
|
|
@@ -46,12 +45,8 @@ type TypeaheadProps = {
|
|
46
45
|
getOptionLabel?: string | (() => string),
|
47
46
|
getOptionValue?: string | (() => string),
|
48
47
|
name?: string,
|
49
|
-
options?: Array<{ label: string; value?: string }>,
|
50
48
|
marginBottom?: "none" | "xxs" | "xs" | "sm" | "md" | "lg" | "xl",
|
51
49
|
pillColor?: "primary" | "neutral" | "success" | "warning" | "error" | "info" | "data_1" | "data_2" | "data_3" | "data_4" | "data_5" | "data_6" | "data_7" | "data_8" | "windows" | "siding" | "roofing" | "doors" | "gutters" | "solar" | "insulation" | "accessories",
|
52
|
-
optionsByContext?: Record<string, Array<{ label: string; value?: string }>>
|
53
|
-
searchContextSelector?: string,
|
54
|
-
clearOnContextChange?: boolean,
|
55
50
|
} & GlobalProps
|
56
51
|
|
57
52
|
export type SelectValueType = {
|
@@ -86,9 +81,6 @@ const Typeahead = ({
|
|
86
81
|
loadOptions = noop,
|
87
82
|
marginBottom = "sm",
|
88
83
|
pillColor,
|
89
|
-
optionsByContext = {},
|
90
|
-
searchContextSelector,
|
91
|
-
clearOnContextChange = false,
|
92
84
|
...props
|
93
85
|
}: TypeaheadProps) => {
|
94
86
|
const selectProps = {
|
@@ -123,32 +115,6 @@ const Typeahead = ({
|
|
123
115
|
...props,
|
124
116
|
}
|
125
117
|
|
126
|
-
const [contextValue, setContextValue] = useState("")
|
127
|
-
|
128
|
-
useEffect(() => {
|
129
|
-
if (searchContextSelector) {
|
130
|
-
const searchContextElement = document.getElementById(searchContextSelector)
|
131
|
-
|
132
|
-
setContextValue((searchContextElement as HTMLInputElement)?.value)
|
133
|
-
const handleContextChange = (e: Event) => {
|
134
|
-
const target = e.target as HTMLInputElement;
|
135
|
-
setContextValue(target.value);
|
136
|
-
if (clearOnContextChange) document.dispatchEvent(new CustomEvent(`pb-typeahead-kit-${selectProps.id}:clear`))
|
137
|
-
}
|
138
|
-
|
139
|
-
if (searchContextElement) searchContextElement.addEventListener('change', handleContextChange)
|
140
|
-
|
141
|
-
return () => {
|
142
|
-
if (searchContextElement) searchContextElement.removeEventListener('change', handleContextChange)
|
143
|
-
}
|
144
|
-
}
|
145
|
-
}, [searchContextSelector])
|
146
|
-
|
147
|
-
const contextArray = optionsByContext[contextValue]
|
148
|
-
if (Array.isArray(contextArray) && contextArray.length > 0) {
|
149
|
-
selectProps.options = contextArray
|
150
|
-
}
|
151
|
-
|
152
118
|
const Tag = (
|
153
119
|
createable
|
154
120
|
? (async ? AsyncCreateableSelect : CreateableSelect)
|
@@ -8,17 +8,15 @@ import { SelectValueType } from '../_typeahead'
|
|
8
8
|
type Props = {
|
9
9
|
data: SelectValueType,
|
10
10
|
multiValueTemplate: any,
|
11
|
-
wrapped?: boolean,
|
12
11
|
pillColor?: "primary" | "neutral" | "success" | "warning" | "error" | "info" | "data_1" | "data_2" | "data_3" | "data_4" | "data_5" | "data_6" | "data_7" | "data_8" | "windows" | "siding" | "roofing" | "doors" | "gutters" | "solar" | "insulation" | "accessories",
|
13
12
|
removeProps: any,
|
14
13
|
selectProps: any,
|
15
14
|
}
|
16
15
|
|
17
|
-
|
18
16
|
const MultiValue = (props: Props) => {
|
19
17
|
const { removeProps } = props
|
20
18
|
const { imageUrl, label } = props.data
|
21
|
-
const { dark, multiKit, pillColor, truncate
|
19
|
+
const { dark, multiKit, pillColor, truncate } = props.selectProps
|
22
20
|
|
23
21
|
const formPillProps = {
|
24
22
|
marginRight: 'xs',
|
@@ -54,7 +52,6 @@ const MultiValue = (props: Props) => {
|
|
54
52
|
size={multiKit === 'smallPill' ? 'small' : ''}
|
55
53
|
text=''
|
56
54
|
truncate={truncate}
|
57
|
-
wrapped={wrapped}
|
58
55
|
{...props}
|
59
56
|
/>
|
60
57
|
}
|
@@ -69,7 +66,6 @@ const MultiValue = (props: Props) => {
|
|
69
66
|
size={multiKit === 'smallPill' ? 'small' : ''}
|
70
67
|
text={label}
|
71
68
|
truncate={truncate}
|
72
|
-
wrapped={wrapped}
|
73
69
|
{...props}
|
74
70
|
/>
|
75
71
|
}
|
@@ -12,8 +12,6 @@ examples:
|
|
12
12
|
- typeahead_margin_bottom: Margin Bottom
|
13
13
|
- typeahead_with_pills_color: With Pills (Custom Color)
|
14
14
|
- typeahead_truncated_text: Truncated Text
|
15
|
-
- typeahead_dynamic_options: Dynamic Options
|
16
|
-
- typeahead_dynamic_options_pure_rails: Dynamic Options (Pure Rails)
|
17
15
|
|
18
16
|
react:
|
19
17
|
- typeahead_default: Default
|
@@ -20,34 +20,6 @@ export default class PbTypeahead extends PbEnhancedElement {
|
|
20
20
|
this.searchInput.addEventListener('focus', () => this.debouncedSearch())
|
21
21
|
this.searchInput.addEventListener('input', () => this.debouncedSearch())
|
22
22
|
this.resultsElement.addEventListener('click', (event: MouseEvent) => this.optionSelected(event))
|
23
|
-
|
24
|
-
if (this.clearOnContextChange && this.searchContextElement) {
|
25
|
-
this.searchContextElement.addEventListener('change', () => {
|
26
|
-
this.searchInputClear()
|
27
|
-
this.resultsCacheClear()
|
28
|
-
this.clearResults()
|
29
|
-
})
|
30
|
-
}
|
31
|
-
}
|
32
|
-
|
33
|
-
get optionsByContext() {
|
34
|
-
return (this.element as HTMLElement).dataset.pbTypeaheadKitOptionsByContext
|
35
|
-
? JSON.parse((this.element as HTMLElement).dataset.pbTypeaheadKitOptionsByContext)
|
36
|
-
: null
|
37
|
-
}
|
38
|
-
|
39
|
-
get searchContextElement() {
|
40
|
-
const selector = (this.element as HTMLElement).dataset.pbTypeaheadKitSearchContextSelector
|
41
|
-
if (!selector) return null
|
42
|
-
|
43
|
-
const found = this.element.parentNode?.querySelector(`#${selector}`)
|
44
|
-
|| this.element.closest(selector)
|
45
|
-
|
46
|
-
return found || null
|
47
|
-
}
|
48
|
-
|
49
|
-
get clearOnContextChange() {
|
50
|
-
return (this.element as HTMLElement).dataset.pbTypeaheadKitClearOnContextChange === 'true'
|
51
23
|
}
|
52
24
|
|
53
25
|
handleKeydown(event: KeyboardEvent) {
|
@@ -68,32 +40,14 @@ export default class PbTypeahead extends PbEnhancedElement {
|
|
68
40
|
|
69
41
|
const searchTerm = this.searchTerm
|
70
42
|
const searchContext = this.searchContext
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
&& obj.label.toLowerCase().includes(searchTerm.toLowerCase())
|
78
|
-
})
|
79
|
-
|
80
|
-
const optionFragments = filteredResults.map((obj: { label: string, value: string }) => {
|
81
|
-
const singleOption = document.createDocumentFragment()
|
82
|
-
singleOption.appendChild(document.createTextNode(obj.label))
|
83
|
-
return singleOption
|
84
|
-
})
|
85
|
-
|
86
|
-
this.resultsCacheUpdate(searchTerm, searchContext, optionFragments)
|
87
|
-
} else {
|
88
|
-
const search = {
|
89
|
-
searchingFor: searchTerm,
|
90
|
-
searchingContext: searchContext,
|
91
|
-
setResults: (results: Array<DocumentFragment>) => {
|
92
|
-
this.resultsCacheUpdate(searchTerm, searchContext, results)
|
93
|
-
},
|
94
|
-
}
|
95
|
-
this.element.dispatchEvent(new CustomEvent('pb-typeahead-kit-search', { bubbles: true, detail: search }))
|
43
|
+
const search = {
|
44
|
+
searchingFor: searchTerm,
|
45
|
+
searchingContext: searchContext,
|
46
|
+
setResults: (results: Array<DocumentFragment>) => {
|
47
|
+
this.resultsCacheUpdate(searchTerm, searchContext, results)
|
48
|
+
},
|
96
49
|
}
|
50
|
+
this.element.dispatchEvent(new CustomEvent('pb-typeahead-kit-search', { bubbles: true, detail: search }))
|
97
51
|
}
|
98
52
|
|
99
53
|
resultsCacheUpdate(searchTerm: string, searchContext: string, results: Array<DocumentFragment>) {
|
@@ -133,15 +87,11 @@ export default class PbTypeahead extends PbEnhancedElement {
|
|
133
87
|
const resultOption = (event.target as Element).closest('[data-result-option-item]')
|
134
88
|
if (!resultOption) return
|
135
89
|
|
136
|
-
const selectedText = resultOption.textContent.trim()
|
137
|
-
|
138
90
|
this._validSelection = true
|
139
91
|
this.removeValidationError()
|
140
92
|
|
141
|
-
if (this.searchContextElement) this.searchInput.value = selectedText
|
142
|
-
|
143
93
|
this.resultsCacheClear()
|
144
|
-
|
94
|
+
this.searchInputClear()
|
145
95
|
this.clearResults()
|
146
96
|
|
147
97
|
this.element.dispatchEvent(new CustomEvent('pb-typeahead-kit-result-option-selected', { bubbles: true, detail: { selected: resultOption, typeahead: this } }))
|
@@ -223,9 +173,6 @@ export default class PbTypeahead extends PbEnhancedElement {
|
|
223
173
|
this.element.parentNode.querySelector(selector) ||
|
224
174
|
this.element.closest(selector)
|
225
175
|
) as HTMLInputElement).value
|
226
|
-
else if (this.searchContextElement) {
|
227
|
-
return (this.searchContextElement as HTMLInputElement).value
|
228
|
-
}
|
229
176
|
|
230
177
|
return null
|
231
178
|
}
|
@@ -44,14 +44,6 @@ module Playbook
|
|
44
44
|
default: false
|
45
45
|
prop :validation, type: Playbook::Props::HashProp,
|
46
46
|
default: {}
|
47
|
-
prop :wrapped, type: Playbook::Props::Boolean,
|
48
|
-
default: false
|
49
|
-
prop :clear_on_context_change, type: Playbook::Props::Boolean,
|
50
|
-
default: true
|
51
|
-
prop :options_by_context, type: Playbook::Props::HashProp,
|
52
|
-
default: {}
|
53
|
-
prop :search_context_selector, type: Playbook::Props::String,
|
54
|
-
default: nil
|
55
47
|
|
56
48
|
def classname
|
57
49
|
default_margin_bottom = margin_bottom.present? ? "" : " mb_sm"
|
@@ -66,15 +58,12 @@ module Playbook
|
|
66
58
|
Hash(values[:data]).merge(
|
67
59
|
pb_typeahead_kit: true,
|
68
60
|
pb_typeahead_kit_search_term_minimum_length: search_term_minimum_length,
|
69
|
-
pb_typeahead_kit_search_debounce_timeout: search_debounce_timeout
|
70
|
-
pb_typeahead_kit_clear_on_context_change: clear_on_context_change,
|
71
|
-
pb_typeahead_kit_search_context_selector: search_context_selector,
|
72
|
-
pb_typeahead_kit_options_by_context: options_by_context.to_json
|
61
|
+
pb_typeahead_kit_search_debounce_timeout: search_debounce_timeout
|
73
62
|
)
|
74
63
|
end
|
75
64
|
|
76
65
|
def is_react?
|
77
|
-
pills || !is_multi
|
66
|
+
pills || !is_multi
|
78
67
|
end
|
79
68
|
|
80
69
|
def typeahead_react_options
|
@@ -96,10 +85,6 @@ module Playbook
|
|
96
85
|
placeholder: placeholder,
|
97
86
|
plusIcon: plus_icon,
|
98
87
|
truncate: truncate,
|
99
|
-
wrapped: wrapped,
|
100
|
-
searchContextSelector: search_context_selector,
|
101
|
-
optionsByContext: options_by_context,
|
102
|
-
clearOnContextChange: clear_on_context_change,
|
103
88
|
}
|
104
89
|
|
105
90
|
base_options[:getOptionLabel] = get_option_label if get_option_label.present?
|
@@ -1,31 +1,3 @@
|
|
1
1
|
/* 🛠️ Any commonly used lodash functions can be added here. 🤙 */
|
2
2
|
|
3
|
-
export const isEmpty = (obj:
|
4
|
-
|
5
|
-
export const get = <T, R = any>(obj: T, path: string, defaultValue?: R): R | any => {
|
6
|
-
const travel = (regexp: RegExp): any =>
|
7
|
-
String.prototype.split
|
8
|
-
.call(path, regexp)
|
9
|
-
.filter(Boolean)
|
10
|
-
.reduce((res: any, key: string) => (res !== null && res !== undefined ? res[key] : res), obj)
|
11
|
-
const result = travel(/[,[\]]+?/) || travel(/[,[\].]+?/)
|
12
|
-
return result === undefined || result === obj ? defaultValue : result
|
13
|
-
}
|
14
|
-
|
15
|
-
export const isString = (str: unknown): str is string =>
|
16
|
-
str != null && typeof (str as any).valueOf() === "string"
|
17
|
-
|
18
|
-
export const uniqueId: (prefix?: string) => string = (() => {
|
19
|
-
let counter = 0
|
20
|
-
return (prefix = '') => `${prefix}${++counter}`
|
21
|
-
})()
|
22
|
-
|
23
|
-
export const omitBy = (obj: Record<string, any>, predicate: (value: any, key: string) => boolean) => {
|
24
|
-
if (obj === null || typeof obj !== 'object') return {}
|
25
|
-
return Object.keys(obj).reduce((result: Record<string, any>, key: string) => {
|
26
|
-
if (!predicate(obj[key], key)) {
|
27
|
-
result[key] = obj[key];
|
28
|
-
}
|
29
|
-
return result;
|
30
|
-
}, {})
|
31
|
-
}
|
3
|
+
export const isEmpty = (obj: Record<string, unknown>): boolean => Object.keys(obj).length < 1
|