playbook_ui 14.13.0 → 14.14.0.pre.alpha.PBNTR866finalizecssendlessscroll6462

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.
Files changed (187) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +0 -1
  3. data/app/pb_kits/playbook/pb_advanced_table/Components/RegularTableView.tsx +127 -0
  4. data/app/pb_kits/playbook/pb_advanced_table/Components/TableActionBar.tsx +55 -0
  5. data/app/pb_kits/playbook/pb_advanced_table/Components/TablePagination.tsx +33 -0
  6. data/app/pb_kits/playbook/pb_advanced_table/Components/VirtualizedTableView.tsx +275 -0
  7. data/app/pb_kits/playbook/pb_advanced_table/Context/AdvancedTableContext.tsx +143 -3
  8. data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableActions.ts +66 -0
  9. data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +195 -0
  10. data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableBody.tsx +45 -99
  11. data/app/pb_kits/playbook/pb_advanced_table/Utilities/CellRendererUtils.tsx +73 -0
  12. data/app/pb_kits/playbook/pb_advanced_table/Utilities/RowUtils.ts +52 -0
  13. data/app/pb_kits/playbook/pb_advanced_table/Utilities/TableContainerStyles.ts +80 -0
  14. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +129 -7
  15. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +153 -298
  16. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +8 -1
  17. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers_custom_cell.jsx +75 -0
  18. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_infinite_scroll.jsx +50 -0
  19. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.html.erb +1 -1
  20. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_rails.md +3 -1
  21. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_react.md +1 -1
  22. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header.html.erb +33 -0
  23. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header_rails.md +3 -0
  24. data/app/pb_kits/playbook/pb_advanced_table/docs/advanced_table_mock_data_infinite_scroll.json +152002 -0
  25. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +4 -1
  26. data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +3 -1
  27. data/app/pb_kits/playbook/pb_bar_graph/BarGraphStyles.scss +58 -0
  28. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_pb_styles.jsx +64 -0
  29. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_pb_styles.md +1 -0
  30. data/app/pb_kits/playbook/pb_bar_graph/docs/example.yml +1 -0
  31. data/app/pb_kits/playbook/pb_bar_graph/docs/index.js +1 -0
  32. data/app/pb_kits/playbook/pb_checkbox/_checkbox.tsx +17 -8
  33. data/app/pb_kits/playbook/pb_checkbox/checkbox.test.js +16 -0
  34. data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_react_hook.jsx +69 -0
  35. data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_react_hook.md +1 -0
  36. data/app/pb_kits/playbook/pb_checkbox/docs/example.yml +2 -1
  37. data/app/pb_kits/playbook/pb_checkbox/docs/index.js +1 -0
  38. data/app/pb_kits/playbook/pb_currency/_currency.tsx +46 -31
  39. data/app/pb_kits/playbook/pb_currency/currency.html.erb +15 -8
  40. data/app/pb_kits/playbook/pb_currency/currency.rb +17 -2
  41. data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display.html.erb +22 -0
  42. data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display.jsx +34 -0
  43. data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display_rails.md +1 -0
  44. data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display_react.md +1 -0
  45. data/app/pb_kits/playbook/pb_currency/docs/example.yml +2 -0
  46. data/app/pb_kits/playbook/pb_currency/docs/index.js +2 -1
  47. data/app/pb_kits/playbook/pb_date_picker/_date_picker.tsx +3 -1
  48. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_table.html.erb +2 -2
  49. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_table.md +4 -1
  50. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_table_react.jsx +90 -0
  51. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_table_react.md +5 -0
  52. data/app/pb_kits/playbook/pb_draggable/docs/example.yml +2 -0
  53. data/app/pb_kits/playbook/pb_draggable/docs/index.js +2 -1
  54. data/app/pb_kits/playbook/pb_draggable/subcomponents/DraggableContainer.tsx +7 -4
  55. data/app/pb_kits/playbook/pb_draggable/subcomponents/DraggableItem.tsx +6 -3
  56. data/app/pb_kits/playbook/pb_drawer/_drawer.scss +32 -8
  57. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_behavior.html.erb +8 -0
  58. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_borders.html.erb +33 -0
  59. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_breakpoints.html.erb +0 -0
  60. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_default.html.erb +20 -1
  61. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_menu.html.erb +24 -0
  62. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.html.erb +21 -0
  63. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.md +1 -0
  64. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_sizes.html.erb +49 -0
  65. data/app/pb_kits/playbook/pb_drawer/docs/example.yml +5 -0
  66. data/app/pb_kits/playbook/pb_drawer/drawer.html.erb +20 -12
  67. data/app/pb_kits/playbook/pb_drawer/drawer.rb +49 -1
  68. data/app/pb_kits/playbook/pb_drawer/index.js +257 -0
  69. data/app/pb_kits/playbook/pb_form/docs/_form_form_with.html.erb +1 -0
  70. data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +2 -1
  71. data/app/pb_kits/playbook/pb_icon_button/_icon_button.tsx +71 -0
  72. data/app/pb_kits/playbook/pb_icon_button/docs/_icon_button_default.html.erb +1 -2
  73. data/app/pb_kits/playbook/pb_icon_button/docs/_icon_button_default.jsx +17 -0
  74. data/app/pb_kits/playbook/pb_icon_button/docs/_icon_button_sizes.html.erb +27 -0
  75. data/app/pb_kits/playbook/pb_icon_button/docs/_icon_button_sizes.jsx +61 -0
  76. data/app/pb_kits/playbook/pb_icon_button/docs/example.yml +5 -3
  77. data/app/pb_kits/playbook/pb_icon_button/docs/index.js +2 -0
  78. data/app/pb_kits/playbook/pb_icon_button/icon_button.html.erb +1 -1
  79. data/app/pb_kits/playbook/pb_icon_button/icon_button.rb +3 -0
  80. data/app/pb_kits/playbook/pb_icon_button/icon_button.test.jsx +39 -0
  81. data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.html.erb +1 -6
  82. data/app/pb_kits/playbook/pb_nav/item.html.erb +7 -19
  83. data/app/pb_kits/playbook/pb_nav/nav.html.erb +3 -8
  84. data/app/pb_kits/playbook/pb_online_status/online_status.html.erb +1 -6
  85. data/app/pb_kits/playbook/pb_overlay/_overlay.scss +13 -0
  86. data/app/pb_kits/playbook/pb_overlay/_overlay.tsx +11 -1
  87. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar.html.erb +11 -0
  88. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar.jsx +37 -0
  89. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar_rails.md +1 -0
  90. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar_react.md +1 -0
  91. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional.html.erb +11 -0
  92. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional.jsx +37 -0
  93. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional.md +1 -0
  94. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional_react.md +1 -0
  95. data/app/pb_kits/playbook/pb_overlay/docs/example.yml +4 -0
  96. data/app/pb_kits/playbook/pb_overlay/docs/index.js +2 -0
  97. data/app/pb_kits/playbook/pb_overlay/index.js +61 -0
  98. data/app/pb_kits/playbook/pb_overlay/overlay.html.erb +5 -3
  99. data/app/pb_kits/playbook/pb_overlay/overlay.rb +16 -1
  100. data/app/pb_kits/playbook/pb_overlay/overlay.test.jsx +12 -0
  101. data/app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_token.tsx +48 -10
  102. data/app/pb_kits/playbook/pb_popover/popover.html.erb +1 -6
  103. data/app/pb_kits/playbook/pb_progress_pills/_progress_pills.scss +6 -1
  104. data/app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx +7 -5
  105. data/app/pb_kits/playbook/pb_progress_pills/docs/_progress_pills_default.html.erb +1 -0
  106. data/app/pb_kits/playbook/pb_progress_pills/docs/_progress_pills_default.jsx +7 -0
  107. data/app/pb_kits/playbook/pb_progress_pills/docs/_progress_pills_default.md +1 -0
  108. data/app/pb_kits/playbook/pb_progress_pills/docs/_progress_pills_full_width.html.erb +1 -0
  109. data/app/pb_kits/playbook/pb_progress_pills/docs/_progress_pills_full_width.jsx +18 -0
  110. data/app/pb_kits/playbook/pb_progress_pills/docs/_progress_pills_full_width_rails.md +1 -0
  111. data/app/pb_kits/playbook/pb_progress_pills/docs/_progress_pills_full_width_react.md +1 -0
  112. data/app/pb_kits/playbook/pb_progress_pills/docs/example.yml +2 -0
  113. data/app/pb_kits/playbook/pb_progress_pills/docs/index.js +1 -0
  114. data/app/pb_kits/playbook/pb_progress_pills/progress_pills.html.erb +2 -7
  115. data/app/pb_kits/playbook/pb_progress_pills/progress_pills.rb +6 -0
  116. data/app/pb_kits/playbook/pb_progress_pills/progress_pills.test.js +26 -1
  117. data/app/pb_kits/playbook/pb_progress_simple/progress_simple.html.erb +1 -5
  118. data/app/pb_kits/playbook/pb_progress_step/progress_step.html.erb +1 -5
  119. data/app/pb_kits/playbook/pb_progress_step/progress_step_item.html.erb +3 -7
  120. data/app/pb_kits/playbook/pb_radio/radio.html.erb +6 -11
  121. data/app/pb_kits/playbook/pb_select/index.js +38 -0
  122. data/app/pb_kits/playbook/pb_select/select.rb +8 -0
  123. data/app/pb_kits/playbook/pb_table/docs/_table_with_clickable_rows.html.erb +47 -0
  124. data/app/pb_kits/playbook/pb_table/docs/_table_with_clickable_rows.jsx +88 -0
  125. data/app/pb_kits/playbook/pb_table/docs/_table_with_clickable_rows.md +1 -0
  126. data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible.jsx +1 -1
  127. data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_custom_click.html.erb +51 -0
  128. data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_custom_click_rails.md +2 -0
  129. data/app/pb_kits/playbook/pb_table/docs/_table_with_selectable_rows.html.erb +96 -0
  130. data/app/pb_kits/playbook/pb_table/docs/_table_with_selectable_rows.jsx +101 -0
  131. data/app/pb_kits/playbook/pb_table/docs/_table_with_selectable_rows.md +1 -0
  132. data/app/pb_kits/playbook/pb_table/docs/example.yml +5 -0
  133. data/app/pb_kits/playbook/pb_table/docs/index.js +3 -1
  134. data/app/pb_kits/playbook/pb_table/index.ts +41 -9
  135. data/app/pb_kits/playbook/pb_table/styles/_collapsible.scss +4 -0
  136. data/app/pb_kits/playbook/pb_table/subcomponents/_table_body.tsx +29 -2
  137. data/app/pb_kits/playbook/pb_table/subcomponents/_table_row.tsx +31 -3
  138. data/app/pb_kits/playbook/pb_table/table_body.html.erb +13 -7
  139. data/app/pb_kits/playbook/pb_table/table_body.rb +2 -0
  140. data/app/pb_kits/playbook/pb_table/table_row.html.erb +14 -7
  141. data/app/pb_kits/playbook/pb_table/table_row.rb +14 -1
  142. data/app/pb_kits/playbook/pb_text_input/docs/_text_input_mask.html.erb +14 -0
  143. data/app/pb_kits/playbook/pb_text_input/index.js +9 -0
  144. data/app/pb_kits/playbook/pb_text_input/text_input.rb +5 -2
  145. data/app/pb_kits/playbook/pb_tooltip/_tooltip.scss +0 -3
  146. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_delay_rails.html.erb +39 -0
  147. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_delay_rails.md +3 -0
  148. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_interaction.html.erb +26 -0
  149. data/app/pb_kits/playbook/pb_tooltip/docs/example.yml +2 -0
  150. data/app/pb_kits/playbook/pb_tooltip/floating_ui.js +282 -0
  151. data/app/pb_kits/playbook/pb_tooltip/index.js +2 -2
  152. data/app/pb_kits/playbook/pb_tooltip/tooltip.rb +10 -2
  153. data/dist/chunks/_typeahead-B1p_cPQJ.js +36 -0
  154. data/dist/chunks/_weekday_stacked-DTN9JLqd.js +45 -0
  155. data/dist/chunks/lazysizes-B7xYodB-.js +1 -0
  156. data/dist/chunks/{lib-DjpLC8uO.js → lib-Fr78pbpF.js} +2 -2
  157. data/dist/chunks/{pb_form_validation-S56UaHZl.js → pb_form_validation-CN51bfsD.js} +1 -1
  158. data/dist/chunks/vendor.js +1 -1
  159. data/dist/menu.yml +3 -10
  160. data/dist/playbook-doc.js +1 -1
  161. data/dist/playbook-rails-react-bindings.js +1 -1
  162. data/dist/playbook-rails.js +1 -1
  163. data/dist/playbook.css +1 -1
  164. data/lib/playbook/forms/builder/time_zone_select_field.rb +19 -0
  165. data/lib/playbook/forms/builder.rb +1 -0
  166. data/lib/playbook/version.rb +2 -2
  167. metadata +75 -24
  168. data/app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.scss +0 -66
  169. data/app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.tsx +0 -98
  170. data/app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.html.erb +0 -28
  171. data/app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.rb +0 -42
  172. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_actions.html.erb +0 -19
  173. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_actions.jsx +0 -26
  174. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_default.html.erb +0 -10
  175. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_default.jsx +0 -17
  176. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_on_click.jsx +0 -19
  177. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_onclick.html.erb +0 -16
  178. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_placement.html.erb +0 -35
  179. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_placement.jsx +0 -42
  180. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_tooltip.html.erb +0 -13
  181. data/app/pb_kits/playbook/pb_avatar_action_button/docs/example.yml +0 -15
  182. data/app/pb_kits/playbook/pb_avatar_action_button/docs/index.js +0 -4
  183. data/app/pb_kits/playbook/pb_avatar_action_button/pb_avatar_action_button.test.js +0 -31
  184. data/dist/chunks/_typeahead-btjo1UN5.js +0 -36
  185. data/dist/chunks/_weekday_stacked-DeYS_l8v.js +0 -45
  186. data/dist/chunks/lazysizes-DHz07jlL.js +0 -1
  187. /data/app/pb_kits/playbook/pb_table/docs/{_table_with_collapsible_with_custom_click.md → _table_with_collapsible_with_custom_click_react.md} +0 -0
@@ -0,0 +1,282 @@
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
+ }
@@ -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="true"][data-pb-tooltip-interaction="false"]:not([data-pb-tooltip-delay-open]):not([data-pb-tooltip-delay-close])'
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,6 +7,10 @@ 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
10
14
  prop :dark, type: Playbook::Props::Boolean,
11
15
  default: false
12
16
  prop :trigger_method, type: Playbook::Props::Enum,
@@ -18,15 +22,19 @@ module Playbook
18
22
  end
19
23
 
20
24
  def data
21
- Hash(values[:data]).merge(
25
+ data = Hash(values[:data]).merge(
22
26
  pb_tooltip_kit: true,
23
27
  pb_tooltip_position: position,
24
28
  pb_tooltip_trigger_element_selector: trigger_element_selector,
25
29
  pb_tooltip_trigger_element_id: trigger_element_id,
26
30
  pb_tooltip_tooltip_id: tooltip_id,
27
31
  pb_tooltip_show_tooltip: true,
28
- pb_tooltip_trigger_method: trigger_method
32
+ pb_tooltip_trigger_method: trigger_method,
33
+ pb_tooltip_interaction: interaction
29
34
  )
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
30
38
  end
31
39
 
32
40
  private