playbook_ui 16.7.0.pre.alpha.PLAY2929typeaheadportaling16241 → 16.7.0.pre.alpha.PLAY2932datepickerinlineproponly16247
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_date_picker/_date_picker.tsx +3 -2
- data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +2 -2
- data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +2 -1
- data/app/pb_kits/playbook/pb_date_picker/date_picker.test.js +31 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_inline.html.erb +0 -2
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_inline.jsx +0 -2
- data/app/pb_kits/playbook/pb_date_picker/docs/_playground.json +1 -3
- data/app/pb_kits/playbook/pb_date_picker/docs/_playground.overrides.json +1 -3
- data/app/pb_kits/playbook/pb_dialog/_dialog.scss +1 -54
- data/app/pb_kits/playbook/pb_dialog/_dialog.tsx +5 -19
- data/app/pb_kits/playbook/pb_dialog/_dialog_context.tsx +2 -8
- data/app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.tsx +1 -1
- data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +0 -4
- data/app/pb_kits/playbook/pb_dialog/dialog.test.jsx +0 -90
- data/app/pb_kits/playbook/pb_popover/_popover.scss +0 -24
- data/app/pb_kits/playbook/pb_popover/_popover.tsx +14 -41
- data/app/pb_kits/playbook/pb_popover/index.ts +3 -7
- data/app/pb_kits/playbook/pb_popover/popover.html.erb +1 -4
- data/app/pb_kits/playbook/pb_popover/popover.test.js +5 -59
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +2 -54
- data/app/pb_kits/playbook/pb_typeahead/kit.schema.json +0 -6
- data/dist/chunks/{_pb_line_graph-Dh79ZQGT.js → _pb_line_graph-D7f-RfJJ.js} +1 -1
- data/dist/chunks/_typeahead-Cl5cZ7Hz.js +1 -0
- data/dist/chunks/{globalProps-sRIRTMgK.js → globalProps-BwwZkfTI.js} +1 -1
- data/dist/chunks/lib-Ch18RlJa.js +29 -0
- data/dist/chunks/vendor.js +4 -4
- 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 +5 -6
- data/app/pb_kits/playbook/utilities/floatingPortalHosts.ts +0 -71
- data/dist/chunks/_typeahead-BB3BOtvQ.js +0 -1
- data/dist/chunks/lib-CzrQ4vLk.js +0 -29
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 565d8cd7eb822030903f71d51b92426f330b7baeecf691207f1a82b3950ff41a
|
|
4
|
+
data.tar.gz: c6478e1ae1e8b441d59206c3abd47a63a1e231eed35eebf357bcd2849e17df0b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bbd0f4ace6597d6849ced75952307d949e895541c6347b56cc9c1777e8972e97e6a0589bfbe66736c23e3f37047356fa221014ce3bcd7b09554bf3e46819200b
|
|
7
|
+
data.tar.gz: f0160cd0552d3c0764ee4c968cd0aa4d921ed85ad396aa33b0ae8d6fb79e66f985d3ef77d9739c325d09095d8807b62ae5dcac2b7d951cb99339367425cd6636
|
|
@@ -180,6 +180,7 @@ const DatePicker = (props: DatePickerProps): React.ReactElement => {
|
|
|
180
180
|
//@ts-ignore
|
|
181
181
|
globalProps(filteredProps),
|
|
182
182
|
error ? 'error' : null,
|
|
183
|
+
inLine && 'inline-date-picker',
|
|
183
184
|
className
|
|
184
185
|
)
|
|
185
186
|
|
|
@@ -262,7 +263,7 @@ const DatePicker = (props: DatePickerProps): React.ReactElement => {
|
|
|
262
263
|
}
|
|
263
264
|
</div>
|
|
264
265
|
|
|
265
|
-
{!hideIcon &&
|
|
266
|
+
{!hideIcon && !inLine &&
|
|
266
267
|
<div
|
|
267
268
|
className={iconWrapperClass()}
|
|
268
269
|
id={`cal-icon-${pickerId}`}
|
|
@@ -274,7 +275,7 @@ const DatePicker = (props: DatePickerProps): React.ReactElement => {
|
|
|
274
275
|
</div>
|
|
275
276
|
}
|
|
276
277
|
|
|
277
|
-
{
|
|
278
|
+
{inLine ?
|
|
278
279
|
<div>
|
|
279
280
|
<div
|
|
280
281
|
className={`${iconWrapperClass()} date-picker-inline-icon-plus`}
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
<input type="hidden" id="<%= "#{object.end_date_id}" %>" name="<%= "#{object.end_date_name}" %>">
|
|
40
40
|
<% end %>
|
|
41
41
|
|
|
42
|
-
<% if !object.hide_icon %>
|
|
42
|
+
<% if !object.hide_icon && !object.inline %>
|
|
43
43
|
<div
|
|
44
44
|
class="<%= object.icon_wrapper_class %>"
|
|
45
45
|
id="cal-icon-<%= object.picker_id %>"
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
<% end %>
|
|
53
53
|
|
|
54
54
|
<!-- Inline -->
|
|
55
|
-
<% if object.
|
|
55
|
+
<% if object.inline %>
|
|
56
56
|
<!-- Plus Icon -->
|
|
57
57
|
<div
|
|
58
58
|
class="<%= object.icon_wrapper_class %> date-picker-inline-icon-plus"
|
|
@@ -92,7 +92,8 @@ module Playbook
|
|
|
92
92
|
|
|
93
93
|
def classname
|
|
94
94
|
default_margin_bottom = margin_bottom.present? ? "" : " mb_sm"
|
|
95
|
-
|
|
95
|
+
inline_class = inline ? " inline-date-picker" : ""
|
|
96
|
+
generate_classname("pb_date_picker_kit") + default_margin_bottom + inline_class
|
|
96
97
|
end
|
|
97
98
|
|
|
98
99
|
def date_picker_config
|
|
@@ -40,6 +40,37 @@ describe('DatePicker Kit', () => {
|
|
|
40
40
|
expect(kit).toHaveClass('pb_date_picker_kit mb_sm')
|
|
41
41
|
})
|
|
42
42
|
|
|
43
|
+
test('inLine alone adds inline-date-picker class and inline control icons, not the calendar icon', () => {
|
|
44
|
+
const testId = 'datepicker-inline-only'
|
|
45
|
+
render(
|
|
46
|
+
<DatePicker
|
|
47
|
+
data={{ testid: testId }}
|
|
48
|
+
inLine
|
|
49
|
+
pickerId="date-picker-inline-only"
|
|
50
|
+
/>
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
const kit = screen.getByTestId(testId)
|
|
54
|
+
expect(kit).toHaveClass('inline-date-picker')
|
|
55
|
+
expect(kit.querySelector('#cal-icon-date-picker-inline-only')).not.toBeInTheDocument()
|
|
56
|
+
expect(kit.querySelector('#date-picker-inline-only-icon-plus')).toBeInTheDocument()
|
|
57
|
+
expect(kit.querySelector('#date-picker-inline-only-angle-down')).toBeInTheDocument()
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
test('hideIcon without inLine does not render inline control icons', () => {
|
|
61
|
+
const testId = 'datepicker-hide-icon-only'
|
|
62
|
+
render(
|
|
63
|
+
<DatePicker
|
|
64
|
+
data={{ testid: testId }}
|
|
65
|
+
hideIcon
|
|
66
|
+
pickerId="date-picker-hide-icon-only"
|
|
67
|
+
/>
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
const kit = screen.getByTestId(testId)
|
|
71
|
+
expect(kit.querySelector('#date-picker-hide-icon-only-icon-plus')).not.toBeInTheDocument()
|
|
72
|
+
})
|
|
73
|
+
|
|
43
74
|
test('shows DatePicker date format m/d/Y', async () => {
|
|
44
75
|
const testId = 'datepicker-date'
|
|
45
76
|
render(
|
|
@@ -151,33 +151,11 @@
|
|
|
151
151
|
border-radius: $border_radius_md;
|
|
152
152
|
max-height: calc(100vh - #{$gutter * 2});
|
|
153
153
|
max-width: calc(100vw - #{$gutter * 2});
|
|
154
|
-
|
|
155
|
-
flex-direction: column;
|
|
156
|
-
min-height: 0;
|
|
157
|
-
overflow: visible;
|
|
154
|
+
overflow: auto;
|
|
158
155
|
animation-name: modalFadeIn;
|
|
159
156
|
animation-duration: $animation-duration;
|
|
160
157
|
outline: none;
|
|
161
158
|
animation-timing-function: $easeInOutQuint;
|
|
162
|
-
|
|
163
|
-
.pb_dialog_scroll_region {
|
|
164
|
-
flex: 1 1 auto;
|
|
165
|
-
min-height: 0;
|
|
166
|
-
overflow: auto;
|
|
167
|
-
-webkit-overflow-scrolling: touch;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
.pb_dialog_floating_root {
|
|
171
|
-
flex: 0 0 auto;
|
|
172
|
-
min-height: 0;
|
|
173
|
-
pointer-events: none;
|
|
174
|
-
position: relative;
|
|
175
|
-
z-index: 1;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
.pb_dialog_floating_root > * {
|
|
179
|
-
pointer-events: auto;
|
|
180
|
-
}
|
|
181
159
|
}
|
|
182
160
|
|
|
183
161
|
// Left placement animations
|
|
@@ -606,35 +584,4 @@
|
|
|
606
584
|
border: none;
|
|
607
585
|
cursor: pointer;
|
|
608
586
|
}
|
|
609
|
-
|
|
610
|
-
// Rails native dialog: scroll region + floating portal host for portaled form inputs
|
|
611
|
-
dialog.pb_dialog_rails:not([open]) {
|
|
612
|
-
display: none !important;
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
.pb_dialog_rails[open] {
|
|
616
|
-
display: flex;
|
|
617
|
-
flex-direction: column;
|
|
618
|
-
min-height: 0;
|
|
619
|
-
overflow: visible;
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
.pb_dialog_scroll_region {
|
|
623
|
-
flex: 1 1 auto;
|
|
624
|
-
min-height: 0;
|
|
625
|
-
overflow: auto;
|
|
626
|
-
-webkit-overflow-scrolling: touch;
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
.pb_dialog_floating_root {
|
|
630
|
-
flex: 0 0 auto;
|
|
631
|
-
min-height: 0;
|
|
632
|
-
pointer-events: none;
|
|
633
|
-
position: relative;
|
|
634
|
-
z-index: 1;
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
.pb_dialog_floating_root > * {
|
|
638
|
-
pointer-events: auto;
|
|
639
|
-
}
|
|
640
587
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable react/jsx-handler-names */
|
|
2
2
|
/* eslint-disable react/no-multi-comp */
|
|
3
3
|
|
|
4
|
-
import React, { useState
|
|
4
|
+
import React, { useState } from "react";
|
|
5
5
|
import classnames from "classnames";
|
|
6
6
|
import Modal from "react-modal";
|
|
7
7
|
|
|
@@ -16,7 +16,7 @@ import DialogBody from "./child_kits/_dialog_body";
|
|
|
16
16
|
import Flex from "../pb_flex/_flex";
|
|
17
17
|
import IconCircle from "../pb_icon_circle/_icon_circle";
|
|
18
18
|
import Title from "../pb_title/_title";
|
|
19
|
-
import { DialogContext
|
|
19
|
+
import { DialogContext } from "./_dialog_context";
|
|
20
20
|
|
|
21
21
|
type DialogProps = {
|
|
22
22
|
aria?: { [key: string]: string };
|
|
@@ -101,20 +101,12 @@ const Dialog = (props: DialogProps): React.ReactElement => {
|
|
|
101
101
|
const [triggerOpened, setTriggerOpened] = useState(false),
|
|
102
102
|
modalIsOpened = trigger ? triggerOpened : opened;
|
|
103
103
|
|
|
104
|
-
const
|
|
105
|
-
useState<HTMLElement | null>(null);
|
|
106
|
-
|
|
107
|
-
const floatingRootRefCallback = useCallback((node: HTMLElement | null) => {
|
|
108
|
-
setSelectMenuPortalTarget(node);
|
|
109
|
-
}, []);
|
|
110
|
-
|
|
111
|
-
const api: DialogContextValue = {
|
|
104
|
+
const api = {
|
|
112
105
|
onClose: trigger
|
|
113
106
|
? function () {
|
|
114
107
|
setTriggerOpened(false);
|
|
115
108
|
}
|
|
116
109
|
: onClose,
|
|
117
|
-
selectMenuPortalTarget,
|
|
118
110
|
};
|
|
119
111
|
|
|
120
112
|
if (trigger) {
|
|
@@ -195,7 +187,7 @@ const Dialog = (props: DialogProps): React.ReactElement => {
|
|
|
195
187
|
shouldCloseOnOverlayClick={shouldCloseOnOverlayClick && !loading}
|
|
196
188
|
style={{ content: dynamicInlineProps }}
|
|
197
189
|
>
|
|
198
|
-
|
|
190
|
+
<>
|
|
199
191
|
{title && !status ? <Dialog.Header closeable={closeable}>{title}</Dialog.Header> : null}
|
|
200
192
|
{!status && text ? <Dialog.Body>{text}</Dialog.Body> : null}
|
|
201
193
|
{status && (
|
|
@@ -246,13 +238,7 @@ const Dialog = (props: DialogProps): React.ReactElement => {
|
|
|
246
238
|
</Dialog.Footer>
|
|
247
239
|
) : null}
|
|
248
240
|
{children}
|
|
249
|
-
|
|
250
|
-
{/* No aria-hidden: portaled form inputs with dropdowns live here and must remain interactive. */}
|
|
251
|
-
<div
|
|
252
|
-
className="pb_dialog_floating_root"
|
|
253
|
-
data-pb-dialog-floating-root="true"
|
|
254
|
-
ref={floatingRootRefCallback}
|
|
255
|
-
/>
|
|
241
|
+
</>
|
|
256
242
|
</Modal>
|
|
257
243
|
</div>
|
|
258
244
|
</DialogContext.Provider>
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import React from
|
|
1
|
+
import React from 'react'
|
|
2
2
|
|
|
3
|
-
export
|
|
4
|
-
onClose?: () => void
|
|
5
|
-
// Mount point for form inputs with dropdowns so they escape dialog scroll/overflow.
|
|
6
|
-
selectMenuPortalTarget?: HTMLElement | null
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const DialogContext = React.createContext<DialogContextValue | null>(null)
|
|
3
|
+
export const DialogContext = React.createContext(null)
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
<% end %>
|
|
14
14
|
>
|
|
15
15
|
<%= pb_content_tag(:dialog, role: "dialog", "aria-modal": "true", "aria-label": "Dialog") do %>
|
|
16
|
-
<div class="pb_dialog_scroll_region">
|
|
17
16
|
<% if object.status === "" && object.title %>
|
|
18
17
|
<%= pb_rails("dialog/dialog_header", props: { title: object.title, id: object.id, closeable: object.closeable }) %>
|
|
19
18
|
<% end %>
|
|
@@ -45,8 +44,5 @@
|
|
|
45
44
|
<% end %>
|
|
46
45
|
|
|
47
46
|
<%= content %>
|
|
48
|
-
</div>
|
|
49
|
-
<%# No aria-hidden: portaled form inputs with dropdowns live here and must remain interactive. %>
|
|
50
|
-
<div class="pb_dialog_floating_root" data-pb-dialog-floating-root="true"></div>
|
|
51
47
|
<% end %>
|
|
52
48
|
</div>
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import React, {useState} from 'react'
|
|
2
2
|
import { render, cleanup, waitFor, fireEvent, screen } from "../utilities/test-utils";
|
|
3
3
|
import { Dialog, Button } from 'playbook-ui'
|
|
4
|
-
import {
|
|
5
|
-
resolveDialogFloatingPortalHost,
|
|
6
|
-
resolveTypeaheadMenuPortalHost,
|
|
7
|
-
} from "../utilities/floatingPortalHosts"
|
|
8
4
|
|
|
9
5
|
const text="Hello Body Text, Nice to meet ya."
|
|
10
6
|
const title="Header Title is the Title Prop"
|
|
@@ -51,23 +47,6 @@ test('renders the component when clicked', async () => {
|
|
|
51
47
|
cleanup()
|
|
52
48
|
})
|
|
53
49
|
|
|
54
|
-
test('renders scroll region and floating root for portaled inputs (Typeahead, etc.)', async () => {
|
|
55
|
-
const { queryByText } = render(<DialogTest />)
|
|
56
|
-
|
|
57
|
-
fireEvent.click(queryByText('Open Dialog'))
|
|
58
|
-
|
|
59
|
-
await waitFor(() =>
|
|
60
|
-
expect(queryByText("Header Title is the Title Prop")).toBeInTheDocument(),
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
expect(document.querySelector('.pb_dialog_scroll_region')).toBeInTheDocument()
|
|
64
|
-
expect(
|
|
65
|
-
document.querySelector('[data-pb-dialog-floating-root="true"]'),
|
|
66
|
-
).toBeInTheDocument()
|
|
67
|
-
|
|
68
|
-
cleanup()
|
|
69
|
-
})
|
|
70
|
-
|
|
71
50
|
test("renders the title and body text", async () => {
|
|
72
51
|
|
|
73
52
|
const { queryByText } = render(<DialogTest />);
|
|
@@ -164,72 +143,3 @@ test('renders dialog without close button when closeable is false', async () =>
|
|
|
164
143
|
|
|
165
144
|
cleanup()
|
|
166
145
|
})
|
|
167
|
-
|
|
168
|
-
describe('Dialog floating portal host (Typeahead)', () => {
|
|
169
|
-
beforeEach(() => {
|
|
170
|
-
document.body.innerHTML = ''
|
|
171
|
-
})
|
|
172
|
-
|
|
173
|
-
test('resolveDialogFloatingPortalHost returns null outside dialog, modal, or popover', () => {
|
|
174
|
-
const div = document.createElement('div')
|
|
175
|
-
document.body.appendChild(div)
|
|
176
|
-
expect(resolveDialogFloatingPortalHost(div)).toBeNull()
|
|
177
|
-
})
|
|
178
|
-
|
|
179
|
-
test('resolveDialogFloatingPortalHost returns floating root inside native dialog', () => {
|
|
180
|
-
const dialog = document.createElement('dialog')
|
|
181
|
-
const scroll = document.createElement('div')
|
|
182
|
-
scroll.className = 'pb_dialog_scroll_region'
|
|
183
|
-
const floating = document.createElement('div')
|
|
184
|
-
floating.setAttribute('data-pb-dialog-floating-root', 'true')
|
|
185
|
-
const inner = document.createElement('div')
|
|
186
|
-
dialog.appendChild(scroll)
|
|
187
|
-
dialog.appendChild(floating)
|
|
188
|
-
dialog.appendChild(inner)
|
|
189
|
-
document.body.appendChild(dialog)
|
|
190
|
-
|
|
191
|
-
expect(resolveDialogFloatingPortalHost(inner)).toBe(floating)
|
|
192
|
-
})
|
|
193
|
-
|
|
194
|
-
test('resolveDialogFloatingPortalHost falls back to dialog when floating root missing', () => {
|
|
195
|
-
const dialog = document.createElement('dialog')
|
|
196
|
-
const inner = document.createElement('div')
|
|
197
|
-
dialog.appendChild(inner)
|
|
198
|
-
document.body.appendChild(dialog)
|
|
199
|
-
|
|
200
|
-
expect(resolveDialogFloatingPortalHost(inner)).toBe(dialog)
|
|
201
|
-
})
|
|
202
|
-
|
|
203
|
-
test('resolveDialogFloatingPortalHost returns floating root inside .pb_dialog', () => {
|
|
204
|
-
const shell = document.createElement('div')
|
|
205
|
-
shell.className = 'pb_dialog'
|
|
206
|
-
const floating = document.createElement('div')
|
|
207
|
-
floating.setAttribute('data-pb-dialog-floating-root', 'true')
|
|
208
|
-
const inner = document.createElement('div')
|
|
209
|
-
shell.appendChild(floating)
|
|
210
|
-
shell.appendChild(inner)
|
|
211
|
-
document.body.appendChild(shell)
|
|
212
|
-
|
|
213
|
-
expect(resolveDialogFloatingPortalHost(inner)).toBe(floating)
|
|
214
|
-
})
|
|
215
|
-
|
|
216
|
-
test('resolveTypeaheadMenuPortalHost uses dialog floating root when inside dialog', () => {
|
|
217
|
-
const dialog = document.createElement('dialog')
|
|
218
|
-
const floating = document.createElement('div')
|
|
219
|
-
floating.setAttribute('data-pb-dialog-floating-root', 'true')
|
|
220
|
-
const kit = document.createElement('div')
|
|
221
|
-
dialog.appendChild(floating)
|
|
222
|
-
dialog.appendChild(kit)
|
|
223
|
-
document.body.appendChild(dialog)
|
|
224
|
-
|
|
225
|
-
expect(resolveTypeaheadMenuPortalHost(kit, null)).toBe(floating)
|
|
226
|
-
})
|
|
227
|
-
|
|
228
|
-
test('resolveTypeaheadMenuPortalHost uses context target when host not in tree', () => {
|
|
229
|
-
const host = document.createElement('div')
|
|
230
|
-
const kit = document.createElement('div')
|
|
231
|
-
document.body.appendChild(kit)
|
|
232
|
-
|
|
233
|
-
expect(resolveTypeaheadMenuPortalHost(kit, host)).toBe(host)
|
|
234
|
-
})
|
|
235
|
-
})
|
|
@@ -47,31 +47,7 @@
|
|
|
47
47
|
background-color: $white;
|
|
48
48
|
border: 0;
|
|
49
49
|
box-shadow: $shadow_deeper;
|
|
50
|
-
display: flex;
|
|
51
|
-
flex-direction: column;
|
|
52
|
-
min-height: 0;
|
|
53
|
-
max-height: inherit;
|
|
54
50
|
}
|
|
55
|
-
|
|
56
|
-
.pb_popover_scroll_region {
|
|
57
|
-
flex: 1 1 auto;
|
|
58
|
-
min-height: 0;
|
|
59
|
-
overflow: auto;
|
|
60
|
-
-webkit-overflow-scrolling: touch;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.pb_popover_floating_root {
|
|
64
|
-
flex: 0 0 auto;
|
|
65
|
-
min-height: 0;
|
|
66
|
-
pointer-events: none;
|
|
67
|
-
position: relative;
|
|
68
|
-
z-index: 1;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.pb_popover_floating_root > * {
|
|
72
|
-
pointer-events: auto;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
51
|
.overflow_handling {
|
|
76
52
|
overflow: auto;
|
|
77
53
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable react/no-multi-comp */
|
|
2
|
-
import React, {
|
|
2
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
3
3
|
import ReactDOM from "react-dom";
|
|
4
4
|
import {
|
|
5
5
|
Popper,
|
|
@@ -20,8 +20,6 @@ import {
|
|
|
20
20
|
import classnames from "classnames";
|
|
21
21
|
import { globalProps, GlobalProps } from "../utilities/globalProps";
|
|
22
22
|
import { uniqueId } from '../utilities/object';
|
|
23
|
-
import { DialogContext, DialogContextValue } from "../pb_dialog/_dialog_context";
|
|
24
|
-
import { targetIsInsidePortaledFloatingKit } from "../utilities/floatingPortalHosts";
|
|
25
23
|
|
|
26
24
|
type ModifiedGlobalProps = Omit<GlobalProps, 'minWidth' | 'maxHeight' | 'minHeight'>
|
|
27
25
|
|
|
@@ -114,17 +112,6 @@ const Popover = (props: PbPopoverProps) => {
|
|
|
114
112
|
: filteredGlobalProps
|
|
115
113
|
const overflowHandling = maxHeight || maxWidth ? "overflow_handling" : "";
|
|
116
114
|
const zIndexStyle = zIndex ? { zIndex: zIndex } : {};
|
|
117
|
-
|
|
118
|
-
const [selectMenuPortalTarget, setSelectMenuPortalTarget] =
|
|
119
|
-
useState<HTMLElement | null>(null);
|
|
120
|
-
const floatingRootRef = useCallback((node: HTMLElement | null) => {
|
|
121
|
-
setSelectMenuPortalTarget(node);
|
|
122
|
-
}, []);
|
|
123
|
-
|
|
124
|
-
const menuPortalApi: DialogContextValue = useMemo(
|
|
125
|
-
() => ({ selectMenuPortalTarget }),
|
|
126
|
-
[selectMenuPortalTarget],
|
|
127
|
-
);
|
|
128
115
|
const widthHeightStyles = () => {
|
|
129
116
|
return Object.assign(
|
|
130
117
|
{},
|
|
@@ -165,28 +152,17 @@ const Popover = (props: PbPopoverProps) => {
|
|
|
165
152
|
<div
|
|
166
153
|
className={classnames(`${buildCss("pb_popover_tooltip")} show`)}
|
|
167
154
|
>
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
>
|
|
180
|
-
{children}
|
|
181
|
-
</div>
|
|
182
|
-
<div
|
|
183
|
-
aria-hidden="true"
|
|
184
|
-
className="pb_popover_floating_root"
|
|
185
|
-
data-pb-dialog-floating-root="true"
|
|
186
|
-
ref={floatingRootRef}
|
|
187
|
-
/>
|
|
188
|
-
</DialogContext.Provider>
|
|
189
|
-
</div>
|
|
155
|
+
<div
|
|
156
|
+
className={classnames(
|
|
157
|
+
"pb_popover_body",
|
|
158
|
+
popoverSpacing,
|
|
159
|
+
overflowHandling
|
|
160
|
+
)}
|
|
161
|
+
id={targetId}
|
|
162
|
+
style={widthHeightStyles()}
|
|
163
|
+
>
|
|
164
|
+
{children}
|
|
165
|
+
</div>
|
|
190
166
|
</div>
|
|
191
167
|
</div>
|
|
192
168
|
);
|
|
@@ -238,8 +214,7 @@ const PbReactPopover = (props: PbPopoverProps): React.ReactElement => {
|
|
|
238
214
|
const target = e.target as HTMLElement
|
|
239
215
|
|
|
240
216
|
const targetIsPopover =
|
|
241
|
-
target.closest("#" + targetId) !== null
|
|
242
|
-
targetIsInsidePortaledFloatingKit(target);
|
|
217
|
+
target.closest("#" + targetId) !== null;
|
|
243
218
|
const targetIsReference =
|
|
244
219
|
target.closest("#reference-" + targetId) !== null;
|
|
245
220
|
|
|
@@ -252,11 +227,9 @@ const PbReactPopover = (props: PbPopoverProps): React.ReactElement => {
|
|
|
252
227
|
if (!targetIsPopover && !targetIsReference) shouldClose();
|
|
253
228
|
break;
|
|
254
229
|
case "inside":
|
|
255
|
-
if (targetIsInsidePortaledFloatingKit(target)) return
|
|
256
230
|
if (targetIsPopover) shouldClose();
|
|
257
231
|
break;
|
|
258
232
|
case "any":
|
|
259
|
-
if (targetIsInsidePortaledFloatingKit(target)) return
|
|
260
233
|
if (targetIsPopover || !targetIsPopover && !targetIsReference) shouldClose();
|
|
261
234
|
break;
|
|
262
235
|
}
|
|
@@ -314,7 +287,7 @@ const PbReactPopover = (props: PbPopoverProps): React.ReactElement => {
|
|
|
314
287
|
)}
|
|
315
288
|
</>
|
|
316
289
|
) : (
|
|
317
|
-
popoverComponent
|
|
290
|
+
{ popoverComponent }
|
|
318
291
|
))}
|
|
319
292
|
</>
|
|
320
293
|
</PopperManager>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import PbEnhancedElement from '../pb_enhanced_element'
|
|
2
2
|
import { createPopper, Instance, Placement } from '@popperjs/core'
|
|
3
|
-
import { targetIsInsidePortaledFloatingKit } from '../utilities/floatingPortalHosts'
|
|
4
3
|
|
|
5
4
|
const POPOVER_OFFSET_Y = [0, 20]
|
|
6
5
|
|
|
@@ -62,20 +61,17 @@ export default class PbPopover extends PbEnhancedElement {
|
|
|
62
61
|
|
|
63
62
|
checkCloseTooltip() {
|
|
64
63
|
document.querySelector('body').addEventListener('click', ({ target } ) => {
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
const isTriggerElement = t.closest(`#${this.triggerElementId}`) !== null
|
|
68
|
-
const isPortaledKit = targetIsInsidePortaledFloatingKit(t)
|
|
64
|
+
const isTooltipElement = (target as HTMLElement).closest(`#${this.tooltipId}`) !== null
|
|
65
|
+
const isTriggerElement = (target as HTMLElement).closest(`#${this.triggerElementId}`) !== null
|
|
69
66
|
|
|
70
67
|
switch (this.closeOnClick) {
|
|
71
68
|
case 'any':
|
|
72
|
-
if (isPortaledKit) return
|
|
73
69
|
if (isTooltipElement || !isTooltipElement && !isTriggerElement) {
|
|
74
70
|
this.hideTooltip()
|
|
75
71
|
}
|
|
76
72
|
break
|
|
77
73
|
case 'outside':
|
|
78
|
-
if (!isTooltipElement && !isTriggerElement
|
|
74
|
+
if (!isTooltipElement && !isTriggerElement) {
|
|
79
75
|
this.hideTooltip()
|
|
80
76
|
}
|
|
81
77
|
break
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
<%= pb_content_tag do %>
|
|
2
2
|
<div class="pb_popover_tooltip hide" id="<%= object.tooltip_id %>" role="tooltip" style="<%= object.z_index_helper %>">
|
|
3
3
|
<div class="pb_popover_body <%= object.width_height_class_helper %> <%= object.popover_spacing_helper %>" style="<%= object.width_height_helper %>">
|
|
4
|
-
|
|
5
|
-
<%= content.presence %>
|
|
6
|
-
</div>
|
|
7
|
-
<div class="pb_popover_floating_root" data-pb-dialog-floating-root="true" aria-hidden="true"></div>
|
|
4
|
+
<%= content.presence %>
|
|
8
5
|
</div>
|
|
9
6
|
</div>
|
|
10
7
|
<% end %>
|