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.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +2 -34
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +0 -10
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_advanced_table/index.js +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +2 -4
- data/app/pb_kits/playbook/pb_advanced_table/table_header.html.erb +9 -19
- data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +1 -38
- data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +37 -49
- data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +0 -39
- data/app/pb_kits/playbook/pb_table/_table.tsx +0 -4
- data/app/pb_kits/playbook/pb_table/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_table/docs/index.js +0 -2
- data/app/pb_kits/playbook/pb_table/styles/_headers.scss +0 -76
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_head.tsx +1 -11
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_header.tsx +1 -11
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_row.tsx +0 -5
- data/app/pb_kits/playbook/pb_table/table.test.js +0 -17
- data/app/pb_kits/playbook/pb_tooltip/index.js +184 -57
- data/dist/chunks/{_typeahead-HN7DWIZV.js → _typeahead-BEyzuDQy.js} +3 -3
- data/dist/chunks/{_weekday_stacked-CEWwCgZj.js → _weekday_stacked-BWYgED9z.js} +1 -1
- data/dist/chunks/lib-BgzBJfYr.js +29 -0
- data/dist/chunks/{pb_form_validation-DMajaRt3.js → pb_form_validation-CJD-PyIw.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- 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 +7 -16
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows.html.erb +0 -39
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_no_subrows.html.erb +0 -33
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_no_subrows_rails.md +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_rails.md +0 -6
- data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_borderless.jsx +0 -50
- data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_borderless_react.md +0 -1
- data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_floating.jsx +0 -59
- data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_floating_react.md +0 -1
- data/app/pb_kits/playbook/pb_tooltip/floating_ui.js +0 -282
- data/dist/chunks/lib-Co5y3V4K.js +0 -29
- /data/app/pb_kits/playbook/pb_advanced_table/docs/{_advanced_table_selectable_rows_react.md → _advanced_table_selectable_rows.md} +0 -0
- /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
@@ -167,20 +167,3 @@ test("Should have outerPadding class", () => {
|
|
167
167
|
const kit = renderKit(Table, props, { outerPadding: "sm" })
|
168
168
|
expect(kit).toHaveClass("pb_table table-sm table-responsive-collapse table-card outer_padding_space_sm table-collapse-sm")
|
169
169
|
})
|
170
|
-
|
171
|
-
test("when headerStyle is default", () => {
|
172
|
-
const kit = renderKit(Table, props)
|
173
|
-
expect(kit).toHaveClass("pb_table table-sm table-responsive-collapse table-card table-collapse-sm")
|
174
|
-
expect(kit).not.toHaveClass("header-borderless")
|
175
|
-
expect(kit).not.toHaveClass("header-floating")
|
176
|
-
})
|
177
|
-
|
178
|
-
test("when headerStyle is borderless", () => {
|
179
|
-
const kit = renderKit(Table, props, { headerStyle: "borderless" })
|
180
|
-
expect(kit).toHaveClass("pb_table table-sm table-responsive-collapse table-card header-borderless table-collapse-sm")
|
181
|
-
})
|
182
|
-
|
183
|
-
test("when headerStyle is floating", () => {
|
184
|
-
const kit = renderKit(Table, props, { headerStyle: "floating" })
|
185
|
-
expect(kit).toHaveClass("pb_table table-sm table-responsive-collapse table-card header-floating table-collapse-sm")
|
186
|
-
})
|
@@ -1,22 +1,26 @@
|
|
1
1
|
import PbEnhancedElement from '../pb_enhanced_element'
|
2
|
-
import {
|
3
|
-
|
4
|
-
|
5
|
-
offset,
|
6
|
-
preventOverflow,
|
7
|
-
} from '@popperjs/core'
|
8
|
-
|
9
|
-
const TOOLTIP_OFFSET = [0, 20]
|
2
|
+
import { computePosition, offset, flip, shift, arrow, autoUpdate } from '@floating-ui/dom'
|
3
|
+
|
4
|
+
const TOOLTIP_OFFSET = 20
|
10
5
|
const TOOLTIP_TIMEOUT = 250
|
6
|
+
const SAFE_ZONE_MARGIN = 1
|
11
7
|
|
12
|
-
export default class
|
8
|
+
export default class PbTooltipFloatingUi extends PbEnhancedElement {
|
13
9
|
static get selector() {
|
14
|
-
return '[data-pb-tooltip-kit
|
10
|
+
return '[data-pb-tooltip-kit]'
|
15
11
|
}
|
16
12
|
|
17
13
|
connect() {
|
14
|
+
if (this.tooltipInteraction) {
|
15
|
+
document.addEventListener('mousemove', (e) => {
|
16
|
+
this.lastMouseX = e.clientX
|
17
|
+
this.lastMouseY = e.clientY
|
18
|
+
})
|
19
|
+
}
|
20
|
+
|
18
21
|
this.triggerElements.forEach((trigger) => {
|
19
22
|
const method = this.triggerMethod
|
23
|
+
const interactionEnabled = this.tooltipInteraction
|
20
24
|
|
21
25
|
if (method === 'click') {
|
22
26
|
trigger.addEventListener('click', () => {
|
@@ -24,29 +28,66 @@ export default class PbTooltip extends PbEnhancedElement {
|
|
24
28
|
})
|
25
29
|
} else {
|
26
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
|
27
35
|
this.mouseenterTimeout = setTimeout(() => {
|
28
36
|
this.showTooltip(trigger)
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
clearTimeout(this.mouseenterTimeout)
|
34
|
-
setTimeout(() => {
|
35
|
-
this.hideTooltip()
|
36
|
-
}, 0)
|
37
|
-
}, { once: true })
|
37
|
+
if (interactionEnabled) {
|
38
|
+
this.checkCloseTooltip(trigger)
|
39
|
+
}
|
40
|
+
}, delayOpen)
|
38
41
|
})
|
39
42
|
|
40
|
-
|
43
|
+
trigger.addEventListener('mouseleave', () => {
|
41
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
|
+
}
|
42
61
|
})
|
43
|
-
|
44
|
-
|
45
|
-
|
62
|
+
|
63
|
+
if (interactionEnabled) {
|
64
|
+
this.tooltip.addEventListener('mouseenter', () => {
|
65
|
+
clearSafeZoneListener(this)
|
66
|
+
})
|
67
|
+
|
68
|
+
this.tooltip.addEventListener('mouseleave', () => {
|
69
|
+
this.attachSafeZoneListener()
|
70
|
+
})
|
71
|
+
}
|
46
72
|
}
|
47
73
|
})
|
48
74
|
}
|
49
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
|
+
|
50
91
|
checkCloseTooltip(trigger) {
|
51
92
|
document.querySelector('body').addEventListener('click', ({ target }) => {
|
52
93
|
const isTooltip = target.closest(`#${this.tooltipId}`) === this.tooltip
|
@@ -62,27 +103,46 @@ export default class PbTooltip extends PbEnhancedElement {
|
|
62
103
|
showTooltip(trigger) {
|
63
104
|
if (this.shouldShowTooltip === 'false') return
|
64
105
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
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
|
+
})
|
85
144
|
})
|
145
|
+
|
86
146
|
this.tooltip.classList.add('show')
|
87
147
|
|
88
148
|
if (this.triggerMethod === 'click') {
|
@@ -94,39 +154,50 @@ export default class PbTooltip extends PbEnhancedElement {
|
|
94
154
|
}
|
95
155
|
|
96
156
|
hideTooltip() {
|
157
|
+
if (!this.tooltip) return
|
158
|
+
|
97
159
|
this.tooltip.classList.add('fade_out')
|
98
160
|
setTimeout(() => {
|
99
|
-
if (
|
100
|
-
|
161
|
+
if (this.cleanup) {
|
162
|
+
this.cleanup()
|
163
|
+
this.cleanup = null
|
164
|
+
}
|
101
165
|
this.tooltip.classList.remove('show')
|
102
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 = ''
|
103
174
|
}, TOOLTIP_TIMEOUT)
|
104
175
|
}
|
105
176
|
|
106
177
|
get triggerElements() {
|
107
178
|
let triggerEl
|
108
|
-
|
109
179
|
if (this.triggerElementId) {
|
110
180
|
triggerEl = document.querySelector(`#${this.triggerElementId}`)
|
111
|
-
} else {
|
181
|
+
} else if (this.triggerElementSelector) {
|
112
182
|
const selectorIsId = this.triggerElementSelector.indexOf('#') > -1
|
113
183
|
triggerEl = selectorIsId
|
114
|
-
? document.querySelector(
|
115
|
-
: document.querySelectorAll(
|
184
|
+
? document.querySelector(this.triggerElementSelector)
|
185
|
+
: document.querySelectorAll(this.triggerElementSelector)
|
186
|
+
} else {
|
187
|
+
triggerEl = this.element
|
116
188
|
}
|
117
|
-
|
118
189
|
if (!triggerEl) {
|
119
|
-
console.error('Tooltip Kit:
|
190
|
+
console.error('Tooltip Kit: No valid trigger element found!')
|
120
191
|
return []
|
121
192
|
}
|
122
|
-
|
123
|
-
|
124
|
-
|
193
|
+
if (triggerEl.length === undefined) {
|
194
|
+
triggerEl = [triggerEl]
|
195
|
+
}
|
196
|
+
return triggerEl
|
125
197
|
}
|
126
198
|
|
127
199
|
get tooltip() {
|
128
|
-
return (this._tooltip =
|
129
|
-
this._tooltip || this.element.querySelector(`#${this.tooltipId}`))
|
200
|
+
return (this._tooltip = this._tooltip || this.element.querySelector(`#${this.tooltipId}`))
|
130
201
|
}
|
131
202
|
|
132
203
|
get position() {
|
@@ -152,4 +223,60 @@ export default class PbTooltip extends PbEnhancedElement {
|
|
152
223
|
get triggerMethod() {
|
153
224
|
return this.element.dataset.pbTooltipTriggerMethod || 'hover'
|
154
225
|
}
|
155
|
-
|
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
|
+
}
|