playbook_ui 14.16.0.pre.alpha.PBNTR924reacttablecustomheaders6846 → 14.16.0.pre.alpha.PLAY1938completetooltipfloatinguitransition6830

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 (43) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +2 -34
  3. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +2 -2
  4. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +0 -10
  5. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +0 -2
  6. data/app/pb_kits/playbook/pb_advanced_table/index.js +1 -1
  7. data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +2 -4
  8. data/app/pb_kits/playbook/pb_advanced_table/table_header.html.erb +9 -19
  9. data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +1 -38
  10. data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +37 -49
  11. data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +0 -39
  12. data/app/pb_kits/playbook/pb_table/_table.tsx +0 -4
  13. data/app/pb_kits/playbook/pb_table/docs/example.yml +0 -2
  14. data/app/pb_kits/playbook/pb_table/docs/index.js +0 -2
  15. data/app/pb_kits/playbook/pb_table/styles/_headers.scss +0 -76
  16. data/app/pb_kits/playbook/pb_table/subcomponents/_table_head.tsx +1 -11
  17. data/app/pb_kits/playbook/pb_table/subcomponents/_table_header.tsx +1 -11
  18. data/app/pb_kits/playbook/pb_table/subcomponents/_table_row.tsx +0 -5
  19. data/app/pb_kits/playbook/pb_table/table.test.js +0 -17
  20. data/app/pb_kits/playbook/pb_tooltip/index.js +184 -57
  21. data/dist/chunks/{_typeahead-HN7DWIZV.js → _typeahead-BEyzuDQy.js} +3 -3
  22. data/dist/chunks/{_weekday_stacked-CEWwCgZj.js → _weekday_stacked-BWYgED9z.js} +1 -1
  23. data/dist/chunks/lib-BgzBJfYr.js +29 -0
  24. data/dist/chunks/{pb_form_validation-DMajaRt3.js → pb_form_validation-CJD-PyIw.js} +1 -1
  25. data/dist/chunks/vendor.js +1 -1
  26. data/dist/playbook-doc.js +1 -1
  27. data/dist/playbook-rails-react-bindings.js +1 -1
  28. data/dist/playbook-rails.js +1 -1
  29. data/dist/playbook.css +1 -1
  30. data/lib/playbook/version.rb +1 -1
  31. metadata +7 -16
  32. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows.html.erb +0 -39
  33. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_no_subrows.html.erb +0 -33
  34. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_no_subrows_rails.md +0 -1
  35. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_rails.md +0 -6
  36. data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_borderless.jsx +0 -50
  37. data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_borderless_react.md +0 -1
  38. data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_floating.jsx +0 -59
  39. data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_floating_react.md +0 -1
  40. data/app/pb_kits/playbook/pb_tooltip/floating_ui.js +0 -282
  41. data/dist/chunks/lib-Co5y3V4K.js +0 -29
  42. /data/app/pb_kits/playbook/pb_advanced_table/docs/{_advanced_table_selectable_rows_react.md → _advanced_table_selectable_rows.md} +0 -0
  43. /data/app/pb_kits/playbook/pb_advanced_table/docs/{_advanced_table_selectable_rows_no_subrows_react.md → _advanced_table_selectable_rows_no_subrows.md} +0 -0
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Playbook
4
4
  PREVIOUS_VERSION = "14.16.0"
5
- VERSION = "14.16.0.pre.alpha.PBNTR924reacttablecustomheaders6846"
5
+ VERSION = "14.16.0.pre.alpha.PLAY1938completetooltipfloatinguitransition6830"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playbook_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 14.16.0.pre.alpha.PBNTR924reacttablecustomheaders6846
4
+ version: 14.16.0.pre.alpha.PLAY1938completetooltipfloatinguitransition6830
5
5
  platform: ruby
6
6
  authors:
7
7
  - Power UX
@@ -326,18 +326,14 @@ files:
326
326
  - app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_responsive.html.erb
327
327
  - app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_responsive.jsx
328
328
  - app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_responsive.md
329
- - app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows.html.erb
330
329
  - app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows.jsx
330
+ - app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows.md
331
331
  - app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_actions.jsx
332
332
  - app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_actions.md
333
333
  - app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_header.jsx
334
334
  - app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_header.md
335
- - app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_no_subrows.html.erb
336
335
  - app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_no_subrows.jsx
337
- - app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_no_subrows_rails.md
338
- - app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_no_subrows_react.md
339
- - app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_rails.md
340
- - app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_react.md
336
+ - app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_no_subrows.md
341
337
  - app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort.jsx
342
338
  - app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort.md
343
339
  - app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_control.jsx
@@ -2860,10 +2856,6 @@ files:
2860
2856
  - app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_table.md
2861
2857
  - app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_table_rails.html.erb
2862
2858
  - app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_table_rails.md
2863
- - app/pb_kits/playbook/pb_table/docs/_table_with_header_style_borderless.jsx
2864
- - app/pb_kits/playbook/pb_table/docs/_table_with_header_style_borderless_react.md
2865
- - app/pb_kits/playbook/pb_table/docs/_table_with_header_style_floating.jsx
2866
- - app/pb_kits/playbook/pb_table/docs/_table_with_header_style_floating_react.md
2867
2859
  - app/pb_kits/playbook/pb_table/docs/_table_with_selectable_rows.html.erb
2868
2860
  - app/pb_kits/playbook/pb_table/docs/_table_with_selectable_rows.jsx
2869
2861
  - app/pb_kits/playbook/pb_table/docs/_table_with_selectable_rows.md
@@ -3195,7 +3187,6 @@ files:
3195
3187
  - app/pb_kits/playbook/pb_tooltip/docs/_tooltip_with_icon_circle.html.erb
3196
3188
  - app/pb_kits/playbook/pb_tooltip/docs/example.yml
3197
3189
  - app/pb_kits/playbook/pb_tooltip/docs/index.js
3198
- - app/pb_kits/playbook/pb_tooltip/floating_ui.js
3199
3190
  - app/pb_kits/playbook/pb_tooltip/index.js
3200
3191
  - app/pb_kits/playbook/pb_tooltip/tooltip.html.erb
3201
3192
  - app/pb_kits/playbook/pb_tooltip/tooltip.rb
@@ -3461,11 +3452,11 @@ files:
3461
3452
  - app/pb_kits/playbook/utilities/test/globalProps/truncate.test.js
3462
3453
  - app/pb_kits/playbook/utilities/text.ts
3463
3454
  - app/pb_kits/playbook/utilities/validEmojiChecker.ts
3464
- - dist/chunks/_typeahead-HN7DWIZV.js
3465
- - dist/chunks/_weekday_stacked-CEWwCgZj.js
3455
+ - dist/chunks/_typeahead-BEyzuDQy.js
3456
+ - dist/chunks/_weekday_stacked-BWYgED9z.js
3466
3457
  - dist/chunks/lazysizes-B7xYodB-.js
3467
- - dist/chunks/lib-Co5y3V4K.js
3468
- - dist/chunks/pb_form_validation-DMajaRt3.js
3458
+ - dist/chunks/lib-BgzBJfYr.js
3459
+ - dist/chunks/pb_form_validation-CJD-PyIw.js
3469
3460
  - dist/chunks/vendor.js
3470
3461
  - dist/menu.yml
3471
3462
  - dist/playbook-doc.js
@@ -1,39 +0,0 @@
1
- <% column_definitions = [
2
- {
3
- accessor: "year",
4
- label: "Year",
5
- cellAccessors: ["quarter", "month", "day"],
6
- },
7
- {
8
- accessor: "newEnrollments",
9
- label: "New Enrollments",
10
- },
11
- {
12
- accessor: "scheduledMeetings",
13
- label: "Scheduled Meetings",
14
- },
15
- {
16
- accessor: "attendanceRate",
17
- label: "Attendance Rate",
18
- },
19
- {
20
- accessor: "completedClasses",
21
- label: "Completed Classes",
22
- },
23
- {
24
- accessor: "classCompletionRate",
25
- label: "Class Completion Rate",
26
- },
27
- {
28
- accessor: "graduatedStudents",
29
- label: "Graduated Students",
30
- }
31
- ]
32
-
33
- subrow_headers = ["Quarter", "Month", "Day"]
34
- %>
35
-
36
- <%= pb_rails("advanced_table", props: { id: "selectable_rows", table_data: @table_data_with_id, column_definitions: column_definitions, selectable_rows: true }) do %>
37
- <%= pb_rails("advanced_table/table_header", props: { column_definitions: column_definitions, selectable_rows: true }) %>
38
- <%= pb_rails("advanced_table/table_body", props: { id: "selectable_rows", table_data: @table_data_with_id, column_definitions: column_definitions, subrow_headers: subrow_headers, enable_toggle_expansion: "all", selectable_rows: true }) %>
39
- <% end %>
@@ -1,33 +0,0 @@
1
- <% column_definitions = [
2
- {
3
- accessor: "year",
4
- label: "Year",
5
- cellAccessors: ["quarter", "month", "day"],
6
- },
7
- {
8
- accessor: "newEnrollments",
9
- label: "New Enrollments",
10
- },
11
- {
12
- accessor: "scheduledMeetings",
13
- label: "Scheduled Meetings",
14
- },
15
- {
16
- accessor: "attendanceRate",
17
- label: "Attendance Rate",
18
- },
19
- {
20
- accessor: "completedClasses",
21
- label: "Completed Classes",
22
- },
23
- {
24
- accessor: "classCompletionRate",
25
- label: "Class Completion Rate",
26
- },
27
- {
28
- accessor: "graduatedStudents",
29
- label: "Graduated Students",
30
- }
31
- ] %>
32
-
33
- <%= pb_rails("advanced_table", props: { id: "selectable_rows_no_subrows", table_data: @table_data_no_subrows, column_definitions: column_definitions, selectable_rows: true, enable_toggle_expansion: "none", }) %>
@@ -1 +0,0 @@
1
- `selectable_rows` can also be used with tables without nested row data. Set `enable_toggle_expansion: none` to adjust the Advanced Table styling to fit a table without subrows.
@@ -1,6 +0,0 @@
1
- `selectable_rows` is a boolean prop that if present will add checkboxes to all rows that will allow for selecting rows.
2
-
3
- When a parent row is clicked, it will check all nested children rows, Children rows can be manually checked or unchecked as well.
4
-
5
- __ALERT TO DEVS__: UPDATE THIS PARAGRAPH IN THE FOLLOW UP STORY WHEN CHECKBOX FUNCTIONALITY IS SET PLEASE
6
- The `onRowSelectionChange` prop returns an array of ids of all Rows that have been selected. Open the console on this example and check and uncheck checkboxes to see this is action! __NOTE__: Each object within the `tableData`Array must contain a unique id in order to attach an id to all Rows for this to function.
@@ -1,50 +0,0 @@
1
- import React from 'react'
2
-
3
- import Table from '../../pb_table/_table'
4
-
5
- const TableWithHeaderStyleBorderless = (props) => {
6
- return (
7
- <>
8
- <Table
9
- headerStyle="borderless"
10
- size="sm"
11
- {...props}
12
- >
13
- <thead>
14
- <tr>
15
- <th>{'Column 1'}</th>
16
- <th>{'Column 2'}</th>
17
- <th>{'Column 3'}</th>
18
- <th>{'Column 4'}</th>
19
- <th>{'Column 5'}</th>
20
- </tr>
21
- </thead>
22
- <tbody>
23
- <tr>
24
- <td>{'Value 1'}</td>
25
- <td>{'Value 2'}</td>
26
- <td>{'Value 3'}</td>
27
- <td>{'Value 4'}</td>
28
- <td>{'Value 5'}</td>
29
- </tr>
30
- <tr>
31
- <td>{'Value 1'}</td>
32
- <td>{'Value 2'}</td>
33
- <td>{'Value 3'}</td>
34
- <td>{'Value 4'}</td>
35
- <td>{'Value 5'}</td>
36
- </tr>
37
- <tr>
38
- <td>{'Value 1'}</td>
39
- <td>{'Value 2'}</td>
40
- <td>{'Value 3'}</td>
41
- <td>{'Value 4'}</td>
42
- <td>{'Value 5'}</td>
43
- </tr>
44
- </tbody>
45
- </Table>
46
- </>
47
- )
48
- }
49
-
50
- export default TableWithHeaderStyleBorderless
@@ -1 +0,0 @@
1
- Customize your header by removing the header borders with the `headerStyle="borderless"` prop.
@@ -1,59 +0,0 @@
1
- import React from 'react'
2
-
3
- import Background from '../../pb_background/_background'
4
- import Card from '../../pb_card/_card'
5
- import Table from '../../pb_table/_table'
6
-
7
- const TableWithHeaderStyleFloating = (props) => {
8
- return (
9
- <>
10
- <Card background="light"
11
- {...props}
12
- >
13
- <Table
14
- headerStyle="floating"
15
- size="sm"
16
- {...props}
17
- >
18
- <Table.Head>
19
- <Background backgroundColor="light"
20
- tag="tr"
21
- {...props}
22
- >
23
- <Table.Header>{'Column 1'}</Table.Header>
24
- <Table.Header>{'Column 2'}</Table.Header>
25
- <Table.Header>{'Column 3'}</Table.Header>
26
- <Table.Header>{'Column 4'}</Table.Header>
27
- <Table.Header>{'Column 5'}</Table.Header>
28
- </Background>
29
- </Table.Head>
30
- <Table.Body>
31
- <Table.Row>
32
- <Table.Cell>{'Value 1'}</Table.Cell>
33
- <Table.Cell>{'Value 2'}</Table.Cell>
34
- <Table.Cell>{'Value 3'}</Table.Cell>
35
- <Table.Cell>{'Value 4'}</Table.Cell>
36
- <Table.Cell>{'Value 5'}</Table.Cell>
37
- </Table.Row>
38
- <Table.Row>
39
- <Table.Cell>{'Value 1'}</Table.Cell>
40
- <Table.Cell>{'Value 2'}</Table.Cell>
41
- <Table.Cell>{'Value 3'}</Table.Cell>
42
- <Table.Cell>{'Value 4'}</Table.Cell>
43
- <Table.Cell>{'Value 5'}</Table.Cell>
44
- </Table.Row>
45
- <Table.Row>
46
- <Table.Cell>{'Value 1'}</Table.Cell>
47
- <Table.Cell>{'Value 2'}</Table.Cell>
48
- <Table.Cell>{'Value 3'}</Table.Cell>
49
- <Table.Cell>{'Value 4'}</Table.Cell>
50
- <Table.Cell>{'Value 5'}</Table.Cell>
51
- </Table.Row>
52
- </Table.Body>
53
- </Table>
54
- </Card>
55
- </>
56
- )
57
- }
58
-
59
- export default TableWithHeaderStyleFloating
@@ -1 +0,0 @@
1
- Further customize your header by using the [table with background kit](https://playbook.powerapp.cloud/kits/table/react#table-with-background-kit) logic to give your table header a custom background color. Use the `headerStyle="floating"` prop to visually nest the borderless table within a card or collapsible with a matching background color (the `backgroundColor` passed to Background kit should match the `backgroundColor` for the element in which it is nested).
@@ -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
- }