playbook_ui 14.14.0.pre.alpha.play1853typeaheadreacthookform6461 → 14.14.0.pre.alpha.play1868dependencyremovallodash6286
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_card/_card.tsx +2 -1
- data/app/pb_kits/playbook/pb_currency/_currency.tsx +31 -46
- data/app/pb_kits/playbook/pb_currency/currency.html.erb +8 -15
- data/app/pb_kits/playbook/pb_currency/currency.rb +2 -17
- data/app/pb_kits/playbook/pb_currency/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_currency/docs/index.js +1 -2
- data/app/pb_kits/playbook/pb_drawer/_drawer.scss +8 -32
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_default.html.erb +1 -20
- data/app/pb_kits/playbook/pb_drawer/docs/example.yml +0 -5
- 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 -4
- 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 +1 -1
- 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_select/select.rb +0 -8
- data/app/pb_kits/playbook/pb_tooltip/_tooltip.scss +3 -0
- data/app/pb_kits/playbook/pb_tooltip/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_tooltip/index.js +1 -1
- data/app/pb_kits/playbook/pb_tooltip/tooltip.rb +2 -10
- data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.tsx +5 -4
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +6 -17
- 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 +0 -1
- data/app/pb_kits/playbook/pb_typeahead/docs/index.js +0 -1
- data/app/pb_kits/playbook/utilities/object.ts +82 -1
- data/dist/chunks/_typeahead-CHxdYnAw.js +36 -0
- data/dist/chunks/_weekday_stacked-D2tZHCNS.js +45 -0
- data/dist/chunks/{lib-Fr78pbpF.js → lib-CrrD678a.js} +2 -2
- data/dist/chunks/{pb_form_validation-CN51bfsD.js → pb_form_validation-BbWhQeoO.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +2 -2
- 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 -32
- data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display.html.erb +0 -22
- data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display.jsx +0 -34
- 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_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_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_select/index.js +0 -38
- 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/floating_ui.js +0 -282
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_react_hook.jsx +0 -66
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_react_hook.md +0 -1
- data/dist/chunks/_typeahead-CFU6u471.js +0 -36
- data/dist/chunks/_weekday_stacked-B0sOSO9C.js +0 -45
data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional.html.erb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
<%= pb_rails("overlay", props: { layout: { "x": "xl" }, color: "card_light", dynamic: true }) do %>
|
2
|
-
<%= pb_rails("flex", props: { column_gap: "lg", orientation: "row", overflow_x: "auto" }) do %>
|
3
|
-
<% 15.times do %>
|
4
|
-
<%= pb_rails("flex/flex_item") do %>
|
5
|
-
<%= pb_rails("card") do %>
|
6
|
-
Card content
|
7
|
-
<% end %>
|
8
|
-
<% end %>
|
9
|
-
<% end %>
|
10
|
-
<% end %>
|
11
|
-
<% end %>
|
@@ -1 +0,0 @@
|
|
1
|
-
Pass the `dynamic` prop to make the overlay render while the scrollbar isn't at either end on the scrollbar.
|
@@ -1,61 +0,0 @@
|
|
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
|
-
}
|
@@ -1,38 +0,0 @@
|
|
1
|
-
import PbEnhancedElement from "../pb_enhanced_element";
|
2
|
-
|
3
|
-
const SELECT_WRAPPER_SELECTOR = "[data-pb-select]";
|
4
|
-
const SELECT_VALIDATION_MESSAGE_CLASS = ".pb_body_kit_negative";
|
5
|
-
|
6
|
-
export default class PbSelect extends PbEnhancedElement {
|
7
|
-
static get selector() {
|
8
|
-
return SELECT_WRAPPER_SELECTOR;
|
9
|
-
}
|
10
|
-
|
11
|
-
connect() {
|
12
|
-
this.setValidationMessage();
|
13
|
-
}
|
14
|
-
|
15
|
-
setValidationMessage() {
|
16
|
-
const validationMessage = this.element.dataset?.validationMessage;
|
17
|
-
|
18
|
-
if (validationMessage) {
|
19
|
-
const selectElement = this.element.querySelector("select");
|
20
|
-
const setErrorTextContent = (text, timeout) => {
|
21
|
-
setTimeout(() => {
|
22
|
-
const errorMessageElement = this.element.querySelector(SELECT_VALIDATION_MESSAGE_CLASS);
|
23
|
-
if (errorMessageElement) {
|
24
|
-
errorMessageElement.textContent = text;
|
25
|
-
} else {
|
26
|
-
setErrorTextContent(text, 100);
|
27
|
-
}
|
28
|
-
}, timeout);
|
29
|
-
};
|
30
|
-
|
31
|
-
selectElement.addEventListener("change", (e) => {
|
32
|
-
if (!e.target.checkValidity()) {
|
33
|
-
setErrorTextContent(validationMessage, 300);
|
34
|
-
}
|
35
|
-
});
|
36
|
-
}
|
37
|
-
}
|
38
|
-
}
|
@@ -1,39 +0,0 @@
|
|
1
|
-
<%= pb_rails("flex", props: { orientation: "row", gap: "md" }) do %>
|
2
|
-
<%= pb_rails("flex/flex_item", props: {margin_top: "md"}) do %>
|
3
|
-
<%= pb_rails("button", props: {classname: "tooltip-delay", text: "1s delay"}) %>
|
4
|
-
<% end %>
|
5
|
-
|
6
|
-
<%= pb_rails("flex/flex_item", props: {margin_top: "md"}) do %>
|
7
|
-
<%= pb_rails("button", props: {classname: "tooltip-open-delay", text: "Open only"}) %>
|
8
|
-
<% end %>
|
9
|
-
|
10
|
-
<%= pb_rails("flex/flex_item", props: {margin_top: "md"}) do %>
|
11
|
-
<%= pb_rails("button", props: {classname: "tooltip-close-delay", text: "Close only"}) %>
|
12
|
-
<% end %>
|
13
|
-
|
14
|
-
<%= pb_rails("tooltip", props: {
|
15
|
-
trigger_element_selector: ".tooltip-delay",
|
16
|
-
tooltip_id: "delay-tooltip",
|
17
|
-
position: 'top',
|
18
|
-
delay_open: 1000,
|
19
|
-
delay_close: 1000
|
20
|
-
}) do %>
|
21
|
-
1s open/close delay
|
22
|
-
<% end %>
|
23
|
-
<%= pb_rails("tooltip", props: {
|
24
|
-
trigger_element_selector: ".tooltip-open-delay",
|
25
|
-
tooltip_id: "open-tooltip",
|
26
|
-
position: 'top',
|
27
|
-
delay_open: 1000
|
28
|
-
}) do %>
|
29
|
-
1s open delay
|
30
|
-
<% end %>
|
31
|
-
<%= pb_rails("tooltip", props: {
|
32
|
-
trigger_element_selector: ".tooltip-close-delay",
|
33
|
-
tooltip_id: "close-tooltip",
|
34
|
-
position: 'top',
|
35
|
-
delay_close: 1000
|
36
|
-
}) do %>
|
37
|
-
1s close delay
|
38
|
-
<% end %>
|
39
|
-
<% end %>
|
@@ -1,26 +0,0 @@
|
|
1
|
-
<%= pb_rails("flex", props: { gap: "md", wrap: true }) do %>
|
2
|
-
<%= pb_rails("flex/flex_item") do %>
|
3
|
-
<%= pb_rails("button", props: { text: "With Interaction", id: "tooltip-interaction"}) %>
|
4
|
-
|
5
|
-
<%= pb_rails("tooltip", props: {
|
6
|
-
trigger_element_selector: "#tooltip-interaction",
|
7
|
-
tooltip_id: "tooltip-with-interaction",
|
8
|
-
position: 'top',
|
9
|
-
interaction: true
|
10
|
-
}) do %>
|
11
|
-
You can copy me
|
12
|
-
<% end %>
|
13
|
-
<% end %>
|
14
|
-
|
15
|
-
<%= pb_rails("flex/flex_item") do %>
|
16
|
-
<%= pb_rails("button", props: { text: "No Interaction", id: "tooltip-no-interaction"}) %>
|
17
|
-
|
18
|
-
<%= pb_rails("tooltip", props: {
|
19
|
-
trigger_element_selector: "#tooltip-no-interaction",
|
20
|
-
tooltip_id: "tooltip-without-interaction",
|
21
|
-
position: 'top',
|
22
|
-
}) do %>
|
23
|
-
I'm just a regular tooltip
|
24
|
-
<% end %>
|
25
|
-
<% end %>
|
26
|
-
<% end %>
|
@@ -1,282 +0,0 @@
|
|
1
|
-
import PbEnhancedElement from '../pb_enhanced_element'
|
2
|
-
import { computePosition, offset, flip, shift, arrow, autoUpdate } from '@floating-ui/dom'
|
3
|
-
|
4
|
-
const TOOLTIP_OFFSET = 20
|
5
|
-
const TOOLTIP_TIMEOUT = 250
|
6
|
-
const SAFE_ZONE_MARGIN = 1
|
7
|
-
|
8
|
-
export default class PbTooltipFloatingUi extends PbEnhancedElement {
|
9
|
-
static get selector() {
|
10
|
-
return '[data-pb-tooltip-kit="true"][data-pb-tooltip-delay-open], [data-pb-tooltip-kit="true"][data-pb-tooltip-delay-close], [data-pb-tooltip-kit="true"][data-pb-tooltip-interaction="true"]'
|
11
|
-
}
|
12
|
-
|
13
|
-
connect() {
|
14
|
-
if (this.tooltipInteraction) {
|
15
|
-
document.addEventListener('mousemove', (e) => {
|
16
|
-
this.lastMouseX = e.clientX
|
17
|
-
this.lastMouseY = e.clientY
|
18
|
-
})
|
19
|
-
}
|
20
|
-
|
21
|
-
this.triggerElements.forEach((trigger) => {
|
22
|
-
const method = this.triggerMethod
|
23
|
-
const interactionEnabled = this.tooltipInteraction
|
24
|
-
|
25
|
-
if (method === 'click') {
|
26
|
-
trigger.addEventListener('click', () => {
|
27
|
-
this.showTooltip(trigger)
|
28
|
-
})
|
29
|
-
} else {
|
30
|
-
trigger.addEventListener('mouseenter', () => {
|
31
|
-
clearSafeZoneListener(this)
|
32
|
-
clearTimeout(this.mouseleaveTimeout)
|
33
|
-
this.currentTrigger = trigger
|
34
|
-
const delayOpen = this.delayOpen ? parseInt(this.delayOpen) : TOOLTIP_TIMEOUT
|
35
|
-
this.mouseenterTimeout = setTimeout(() => {
|
36
|
-
this.showTooltip(trigger)
|
37
|
-
if (interactionEnabled) {
|
38
|
-
this.checkCloseTooltip(trigger)
|
39
|
-
}
|
40
|
-
}, delayOpen)
|
41
|
-
})
|
42
|
-
|
43
|
-
trigger.addEventListener('mouseleave', () => {
|
44
|
-
clearTimeout(this.mouseenterTimeout)
|
45
|
-
if (this.delayClose) {
|
46
|
-
const delayClose = parseInt(this.delayClose)
|
47
|
-
this.mouseleaveTimeout = setTimeout(() => {
|
48
|
-
if (interactionEnabled) {
|
49
|
-
this.attachSafeZoneListener()
|
50
|
-
} else {
|
51
|
-
this.hideTooltip()
|
52
|
-
}
|
53
|
-
}, delayClose)
|
54
|
-
} else {
|
55
|
-
if (interactionEnabled) {
|
56
|
-
this.attachSafeZoneListener()
|
57
|
-
} else {
|
58
|
-
this.hideTooltip()
|
59
|
-
}
|
60
|
-
}
|
61
|
-
})
|
62
|
-
|
63
|
-
if (interactionEnabled) {
|
64
|
-
this.tooltip.addEventListener('mouseenter', () => {
|
65
|
-
clearSafeZoneListener(this)
|
66
|
-
})
|
67
|
-
|
68
|
-
this.tooltip.addEventListener('mouseleave', () => {
|
69
|
-
this.attachSafeZoneListener()
|
70
|
-
})
|
71
|
-
}
|
72
|
-
}
|
73
|
-
})
|
74
|
-
}
|
75
|
-
|
76
|
-
attachSafeZoneListener() {
|
77
|
-
clearSafeZoneListener(this)
|
78
|
-
this.safeZoneHandler = (e) => {
|
79
|
-
if (!this.currentTrigger) return
|
80
|
-
const triggerRect = this.currentTrigger.getBoundingClientRect()
|
81
|
-
const tooltipRect = this.tooltip.getBoundingClientRect()
|
82
|
-
const safeRect = getSafeZone(triggerRect, tooltipRect, this.position, SAFE_ZONE_MARGIN)
|
83
|
-
if (!isPointInsideRect(e.clientX, e.clientY, safeRect)) {
|
84
|
-
this.hideTooltip()
|
85
|
-
clearSafeZoneListener(this)
|
86
|
-
}
|
87
|
-
}
|
88
|
-
document.addEventListener('mousemove', this.safeZoneHandler)
|
89
|
-
}
|
90
|
-
|
91
|
-
checkCloseTooltip(trigger) {
|
92
|
-
document.querySelector('body').addEventListener('click', ({ target }) => {
|
93
|
-
const isTooltip = target.closest(`#${this.tooltipId}`) === this.tooltip
|
94
|
-
const isTrigger = target.closest(this.triggerElementSelector) === trigger
|
95
|
-
if (isTrigger || isTooltip) {
|
96
|
-
this.checkCloseTooltip(trigger)
|
97
|
-
} else {
|
98
|
-
this.hideTooltip()
|
99
|
-
}
|
100
|
-
}, { once: true })
|
101
|
-
}
|
102
|
-
|
103
|
-
showTooltip(trigger) {
|
104
|
-
if (this.shouldShowTooltip === 'false') return
|
105
|
-
|
106
|
-
clearSafeZoneListener(this)
|
107
|
-
|
108
|
-
this.tooltip.style.opacity = '1'
|
109
|
-
this.tooltip.style.visibility = 'visible'
|
110
|
-
this.tooltip.style.pointerEvents = 'auto'
|
111
|
-
|
112
|
-
if (this.cleanup) {
|
113
|
-
this.cleanup()
|
114
|
-
}
|
115
|
-
|
116
|
-
const arrowElement = document.querySelector(`#${this.tooltipId}-arrow`)
|
117
|
-
|
118
|
-
this.cleanup = autoUpdate(trigger, this.tooltip, () => {
|
119
|
-
computePosition(trigger, this.tooltip, {
|
120
|
-
placement: this.position,
|
121
|
-
strategy: 'fixed',
|
122
|
-
middleware: [
|
123
|
-
offset({ mainAxis: TOOLTIP_OFFSET, crossAxis: 0 }),
|
124
|
-
flip(),
|
125
|
-
shift(),
|
126
|
-
arrow({ element: arrowElement })
|
127
|
-
],
|
128
|
-
}).then(({ x, y, placement, middlewareData }) => {
|
129
|
-
Object.assign(this.tooltip.style, {
|
130
|
-
left: `${x}px`,
|
131
|
-
top: `${y}px`,
|
132
|
-
position: 'fixed'
|
133
|
-
})
|
134
|
-
this.tooltip.setAttribute('data-popper-placement', placement)
|
135
|
-
if (arrowElement && middlewareData.arrow) {
|
136
|
-
const { x: arrowX, y: arrowY } = middlewareData.arrow
|
137
|
-
Object.assign(arrowElement.style, {
|
138
|
-
left: arrowX != null ? `${arrowX}px` : '',
|
139
|
-
top: arrowY != null ? `${arrowY}px` : '',
|
140
|
-
position: 'absolute'
|
141
|
-
})
|
142
|
-
}
|
143
|
-
})
|
144
|
-
})
|
145
|
-
|
146
|
-
this.tooltip.classList.add('show')
|
147
|
-
|
148
|
-
if (this.triggerMethod === 'click') {
|
149
|
-
clearTimeout(this.autoHideTimeout)
|
150
|
-
this.autoHideTimeout = setTimeout(() => {
|
151
|
-
this.hideTooltip()
|
152
|
-
}, 1000)
|
153
|
-
}
|
154
|
-
}
|
155
|
-
|
156
|
-
hideTooltip() {
|
157
|
-
if (!this.tooltip) return
|
158
|
-
|
159
|
-
this.tooltip.classList.add('fade_out')
|
160
|
-
setTimeout(() => {
|
161
|
-
if (this.cleanup) {
|
162
|
-
this.cleanup()
|
163
|
-
this.cleanup = null
|
164
|
-
}
|
165
|
-
this.tooltip.classList.remove('show')
|
166
|
-
this.tooltip.classList.remove('fade_out')
|
167
|
-
this.tooltip.style.opacity = '0'
|
168
|
-
this.tooltip.style.visibility = 'hidden'
|
169
|
-
this.tooltip.style.pointerEvents = 'none'
|
170
|
-
this.tooltip.style.position = ''
|
171
|
-
this.tooltip.style.top = ''
|
172
|
-
this.tooltip.style.left = ''
|
173
|
-
this.tooltip.style.transform = ''
|
174
|
-
}, TOOLTIP_TIMEOUT)
|
175
|
-
}
|
176
|
-
|
177
|
-
get triggerElements() {
|
178
|
-
let triggerEl
|
179
|
-
if (this.triggerElementId) {
|
180
|
-
triggerEl = document.querySelector(`#${this.triggerElementId}`)
|
181
|
-
} else if (this.triggerElementSelector) {
|
182
|
-
const selectorIsId = this.triggerElementSelector.indexOf('#') > -1
|
183
|
-
triggerEl = selectorIsId
|
184
|
-
? document.querySelector(this.triggerElementSelector)
|
185
|
-
: document.querySelectorAll(this.triggerElementSelector)
|
186
|
-
} else {
|
187
|
-
triggerEl = this.element
|
188
|
-
}
|
189
|
-
if (!triggerEl) {
|
190
|
-
console.error('Tooltip Kit: No valid trigger element found!')
|
191
|
-
return []
|
192
|
-
}
|
193
|
-
if (triggerEl.length === undefined) {
|
194
|
-
triggerEl = [triggerEl]
|
195
|
-
}
|
196
|
-
return triggerEl
|
197
|
-
}
|
198
|
-
|
199
|
-
get tooltip() {
|
200
|
-
return (this._tooltip = this._tooltip || this.element.querySelector(`#${this.tooltipId}`))
|
201
|
-
}
|
202
|
-
|
203
|
-
get position() {
|
204
|
-
return this.element.dataset.pbTooltipPosition
|
205
|
-
}
|
206
|
-
|
207
|
-
get triggerElementId() {
|
208
|
-
return this.element.dataset.pbTooltipTriggerElementId
|
209
|
-
}
|
210
|
-
|
211
|
-
get tooltipId() {
|
212
|
-
return this.element.dataset.pbTooltipTooltipId
|
213
|
-
}
|
214
|
-
|
215
|
-
get triggerElementSelector() {
|
216
|
-
return this.element.dataset.pbTooltipTriggerElementSelector
|
217
|
-
}
|
218
|
-
|
219
|
-
get shouldShowTooltip() {
|
220
|
-
return this.element.dataset.pbTooltipShowTooltip
|
221
|
-
}
|
222
|
-
|
223
|
-
get triggerMethod() {
|
224
|
-
return this.element.dataset.pbTooltipTriggerMethod || 'hover'
|
225
|
-
}
|
226
|
-
|
227
|
-
get tooltipInteraction() {
|
228
|
-
return this.element.dataset.pbTooltipInteraction === 'true'
|
229
|
-
}
|
230
|
-
|
231
|
-
get delayOpen() {
|
232
|
-
return this.element.dataset.pbTooltipDelayOpen
|
233
|
-
}
|
234
|
-
|
235
|
-
get delayClose() {
|
236
|
-
return this.element.dataset.pbTooltipDelayClose
|
237
|
-
}
|
238
|
-
}
|
239
|
-
|
240
|
-
function clearSafeZoneListener(context) {
|
241
|
-
if (context.safeZoneHandler) {
|
242
|
-
document.removeEventListener('mousemove', context.safeZoneHandler)
|
243
|
-
context.safeZoneHandler = null
|
244
|
-
}
|
245
|
-
}
|
246
|
-
|
247
|
-
function getSafeZone(triggerRect, tooltipRect, placement, margin) {
|
248
|
-
let safeRect = {}
|
249
|
-
if (placement.startsWith('top')) {
|
250
|
-
safeRect.left = triggerRect.left - margin
|
251
|
-
safeRect.right = triggerRect.right + margin
|
252
|
-
safeRect.top = tooltipRect.bottom - margin
|
253
|
-
safeRect.bottom = triggerRect.top + margin
|
254
|
-
} else if (placement.startsWith('bottom')) {
|
255
|
-
safeRect.left = triggerRect.left - margin
|
256
|
-
safeRect.right = triggerRect.right + margin
|
257
|
-
safeRect.top = triggerRect.bottom - margin
|
258
|
-
safeRect.bottom = tooltipRect.top + margin
|
259
|
-
} else if (placement.startsWith('left')) {
|
260
|
-
safeRect.top = triggerRect.top - margin
|
261
|
-
safeRect.bottom = triggerRect.bottom + margin
|
262
|
-
safeRect.left = tooltipRect.right - margin
|
263
|
-
safeRect.right = triggerRect.left + margin
|
264
|
-
} else if (placement.startsWith('right')) {
|
265
|
-
safeRect.top = triggerRect.top - margin
|
266
|
-
safeRect.bottom = triggerRect.bottom + margin
|
267
|
-
safeRect.left = triggerRect.right - margin
|
268
|
-
safeRect.right = tooltipRect.left + margin
|
269
|
-
} else {
|
270
|
-
safeRect = {
|
271
|
-
left: triggerRect.left - margin,
|
272
|
-
right: triggerRect.right + margin,
|
273
|
-
top: triggerRect.top - margin,
|
274
|
-
bottom: triggerRect.bottom + margin,
|
275
|
-
}
|
276
|
-
}
|
277
|
-
return safeRect
|
278
|
-
}
|
279
|
-
|
280
|
-
function isPointInsideRect(x, y, rect) {
|
281
|
-
return x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom
|
282
|
-
}
|
@@ -1,66 +0,0 @@
|
|
1
|
-
import React from 'react'
|
2
|
-
|
3
|
-
import { Typeahead, Title } from 'playbook-ui'
|
4
|
-
import { useForm } from 'react-hook-form'
|
5
|
-
|
6
|
-
const languages = [
|
7
|
-
{ label: 'JavaScript', value: '1995', category: 'Web Development' },
|
8
|
-
{ label: 'Python', value: '1991', category: 'General Purpose' },
|
9
|
-
{ label: 'Java', value: '1995', category: 'Enterprise' },
|
10
|
-
{ label: 'C++', value: '1985', category: 'Systems Programming' },
|
11
|
-
{ label: 'Go', value: '2009', category: 'Systems Programming' },
|
12
|
-
{ label: 'Rust', value: '2010', category: 'Systems Programming' },
|
13
|
-
{ label: 'Swift', value: '2014', category: 'Mobile Development' },
|
14
|
-
{ label: 'Kotlin', value: '2011', category: 'Mobile Development' },
|
15
|
-
{ label: 'Ruby', value: '1995', category: 'General Purpose' },
|
16
|
-
{ label: 'PHP', value: '1995', category: 'Web Development' },
|
17
|
-
]
|
18
|
-
|
19
|
-
const colors = [
|
20
|
-
{ label: 'Orange', value: '#FFA500' },
|
21
|
-
{ label: 'Red', value: '#FF0000' },
|
22
|
-
{ label: 'Green', value: '#00FF00' },
|
23
|
-
{ label: 'Blue', value: '#0000FF' },
|
24
|
-
]
|
25
|
-
|
26
|
-
const TypeaheadReactHook = (props) => {
|
27
|
-
const { register, watch } = useForm()
|
28
|
-
|
29
|
-
const selectedLanguages = watch('languages')
|
30
|
-
const selectedColor = watch('color')
|
31
|
-
|
32
|
-
return (
|
33
|
-
<>
|
34
|
-
<Typeahead
|
35
|
-
isMulti
|
36
|
-
label="Multi Select Languages"
|
37
|
-
multiKit="language"
|
38
|
-
options={languages}
|
39
|
-
{...props}
|
40
|
-
{...register('languages')}
|
41
|
-
/>
|
42
|
-
<Title
|
43
|
-
size={4}
|
44
|
-
text='Selected Languages'
|
45
|
-
/>
|
46
|
-
{selectedLanguages && selectedLanguages.map(language => (
|
47
|
-
<p key={language.label}>{`${language.label} - ${language.value} - ${language.category}`}</p>
|
48
|
-
))}
|
49
|
-
|
50
|
-
<Typeahead
|
51
|
-
label="Colors"
|
52
|
-
marginTop="lg"
|
53
|
-
options={colors}
|
54
|
-
{...props}
|
55
|
-
{...register('color')}
|
56
|
-
/>
|
57
|
-
<Title
|
58
|
-
size={4}
|
59
|
-
text='Selected Color'
|
60
|
-
/>
|
61
|
-
<p>{ selectedColor && `${selectedColor.label} - ${selectedColor.value}`}</p>
|
62
|
-
</>
|
63
|
-
)
|
64
|
-
}
|
65
|
-
|
66
|
-
export default TypeaheadReactHook
|
@@ -1 +0,0 @@
|
|
1
|
-
You can pass `react-hook-form` props to the Typeahead kit.
|