@dialpad/dialtone-vue 3.222.0 → 3.222.2
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.
- package/dist/common/constants/index.cjs +1 -1
- package/dist/common/constants/index.cjs.map +1 -1
- package/dist/common/constants/index.d.ts +4 -0
- package/dist/common/constants/index.d.ts.map +1 -1
- package/dist/common/constants/index.js +10 -10
- package/dist/common/constants/index.js.map +1 -1
- package/dist/component-documentation.json +1 -1
- package/dist/components/combobox_with_popover/combobox_with_popover.vue.d.ts +18 -18
- package/dist/components/combobox_with_popover/combobox_with_popover.vue.d.ts.map +1 -1
- package/dist/components/dropdown/dropdown.vue.d.ts +18 -18
- package/dist/components/dropdown/dropdown.vue.d.ts.map +1 -1
- package/dist/components/emoji_picker/emoji_picker.vue.d.ts +22 -0
- package/dist/components/emoji_picker/modules/emoji_search.vue.d.ts +22 -0
- package/dist/components/emoji_picker/modules/emoji_search.vue.d.ts.map +1 -1
- package/dist/components/hovercard/hovercard.vue.d.ts +32 -32
- package/dist/components/hovercard/hovercard.vue.d.ts.map +1 -1
- package/dist/components/input/input.vue.d.ts +11 -0
- package/dist/components/input/input.vue.d.ts.map +1 -1
- package/dist/components/modal/modal.vue.d.ts +6 -5
- package/dist/components/modal/modal.vue.d.ts.map +1 -1
- package/dist/components/popover/popover.vue.d.ts +13 -13
- package/dist/components/popover/popover.vue.d.ts.map +1 -1
- package/dist/components/resizable/composables/useResizableGroup.d.ts.map +1 -1
- package/dist/components/rich_text_editor/extensions/variable/VariableComponent.vue.d.ts +24 -13
- package/dist/components/split_button/split_button.vue.d.ts +18 -18
- package/dist/components/tooltip/tooltip.vue.d.ts +8 -8
- package/dist/components/tooltip/tooltip.vue.d.ts.map +1 -1
- package/dist/dialtone-vue.cjs +1 -1
- package/dist/dialtone-vue.js +149 -149
- package/dist/lib/combobox-multi-select/combobox-multi-select.cjs +1 -1
- package/dist/lib/combobox-multi-select/combobox-multi-select.cjs.map +1 -1
- package/dist/lib/combobox-multi-select/combobox-multi-select.js +49 -48
- package/dist/lib/combobox-multi-select/combobox-multi-select.js.map +1 -1
- package/dist/lib/combobox-with-popover/combobox-with-popover.cjs +1 -1
- package/dist/lib/combobox-with-popover/combobox-with-popover.cjs.map +1 -1
- package/dist/lib/combobox-with-popover/combobox-with-popover.js +43 -42
- package/dist/lib/combobox-with-popover/combobox-with-popover.js.map +1 -1
- package/dist/lib/dropdown/dropdown.cjs +1 -1
- package/dist/lib/dropdown/dropdown.cjs.map +1 -1
- package/dist/lib/dropdown/dropdown.js +33 -33
- package/dist/lib/dropdown/dropdown.js.map +1 -1
- package/dist/lib/editor/editor.cjs +1 -1
- package/dist/lib/editor/editor.js +1 -1
- package/dist/lib/hovercard/hovercard.cjs +1 -1
- package/dist/lib/hovercard/hovercard.cjs.map +1 -1
- package/dist/lib/hovercard/hovercard.js +28 -27
- package/dist/lib/hovercard/hovercard.js.map +1 -1
- package/dist/lib/input/input.cjs +1 -1
- package/dist/lib/input/input.cjs.map +1 -1
- package/dist/lib/input/input.js +6 -6
- package/dist/lib/input/input.js.map +1 -1
- package/dist/lib/message-input/index.cjs +1 -1
- package/dist/lib/message-input/index.js +1 -1
- package/dist/lib/message-input/message-input.cjs +1 -1
- package/dist/lib/message-input/message-input.js +1 -1
- package/dist/lib/modal/modal.cjs +1 -1
- package/dist/lib/modal/modal.cjs.map +1 -1
- package/dist/lib/modal/modal.js +61 -58
- package/dist/lib/modal/modal.js.map +1 -1
- package/dist/lib/popover/popover.cjs +1 -1
- package/dist/lib/popover/popover.cjs.map +1 -1
- package/dist/lib/popover/popover.js +76 -75
- package/dist/lib/popover/popover.js.map +1 -1
- package/dist/lib/resizable/index.cjs +1 -1
- package/dist/lib/resizable/index.js +1 -1
- package/dist/lib/resizable/resizable.cjs +1 -1
- package/dist/lib/resizable/resizable.js +1 -1
- package/dist/lib/rich-text-editor/index.cjs +1 -1
- package/dist/lib/rich-text-editor/index.js +1 -1
- package/dist/lib/rich-text-editor/rich-text-editor.cjs +1 -1
- package/dist/lib/rich-text-editor/rich-text-editor.js +1 -1
- package/dist/lib/tooltip/tooltip.cjs +2 -2
- package/dist/lib/tooltip/tooltip.cjs.map +1 -1
- package/dist/lib/tooltip/tooltip.js +30 -29
- package/dist/lib/tooltip/tooltip.js.map +1 -1
- package/dist/{message_input-B47LB7C8.js → message_input-B2fppje7.js} +2 -2
- package/dist/{message_input-B47LB7C8.js.map → message_input-B2fppje7.js.map} +1 -1
- package/dist/{message_input-BCIq_1AD.cjs → message_input-DmLi63dh.cjs} +2 -2
- package/dist/{message_input-BCIq_1AD.cjs.map → message_input-DmLi63dh.cjs.map} +1 -1
- package/dist/recipes/buttons/callbar_button/callbar_button.vue.d.ts +8 -8
- package/dist/recipes/buttons/callbar_button_with_dropdown/callbar_button_with_dropdown.vue.d.ts +26 -26
- package/dist/recipes/buttons/callbar_button_with_popover/callbar_button_with_popover.vue.d.ts +21 -21
- package/dist/recipes/cards/ivr_node/ivr_node.vue.d.ts +18 -18
- package/dist/recipes/conversation_view/editor/EditorToolbarDropdownButton.vue.d.ts +18 -18
- package/dist/recipes/conversation_view/editor/EditorToolbarPopoverButton.vue.d.ts +13 -13
- package/dist/recipes/conversation_view/editor/editor.vue.d.ts +63 -52
- package/dist/recipes/conversation_view/editor/editor.vue.d.ts.map +1 -1
- package/dist/recipes/conversation_view/emoji_row/emoji_row.vue.d.ts +8 -8
- package/dist/recipes/conversation_view/message_input/message_input.vue.d.ts +94 -50
- package/dist/recipes/conversation_view/message_input/message_input.vue.d.ts.map +1 -1
- package/dist/recipes/conversation_view/message_input/message_input_button.vue.d.ts +8 -8
- package/dist/recipes/conversation_view/message_input/message_input_link.vue.d.ts +32 -21
- package/dist/recipes/conversation_view/message_input/message_input_link.vue.d.ts.map +1 -1
- package/dist/recipes/conversation_view/message_input/message_input_topbar.vue.d.ts +8 -8
- package/dist/recipes/leftbar/contact_row/contact_row.vue.d.ts +8 -8
- package/dist/recipes/leftbar/general_row/general_row.vue.d.ts +8 -8
- package/dist/recipes/leftbar/group_row/group_row.vue.d.ts +8 -8
- package/dist/{resizable-aOVGO_Os.cjs → resizable-BOCf9EIc.cjs} +2 -2
- package/dist/{resizable-aOVGO_Os.cjs.map → resizable-BOCf9EIc.cjs.map} +1 -1
- package/dist/{resizable-D4-peBOl.js → resizable-CPaF9dgG.js} +7 -3
- package/dist/{resizable-D4-peBOl.js.map → resizable-CPaF9dgG.js.map} +1 -1
- package/dist/{rich_text_editor-CNFb6tIx.js → rich_text_editor-BhUKyR0E.js} +2 -2
- package/dist/{rich_text_editor-CNFb6tIx.js.map → rich_text_editor-BhUKyR0E.js.map} +1 -1
- package/dist/{rich_text_editor-DRytK1_9.cjs → rich_text_editor-wvONcbYd.cjs} +2 -2
- package/dist/{rich_text_editor-DRytK1_9.cjs.map → rich_text_editor-wvONcbYd.cjs.map} +1 -1
- package/package.json +3 -3
package/dist/lib/modal/modal.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { EVENT_KEYNAMES as e } from "../../common/constants/index.js";
|
|
2
|
-
import { disableRootScrolling as
|
|
3
|
-
import { t as
|
|
4
|
-
import
|
|
5
|
-
import { NOTICE_KINDS as
|
|
6
|
-
import { DialtoneLocalization as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { MODAL_BANNER_KINDS as
|
|
11
|
-
import { Teleport as
|
|
12
|
-
import { DtIconClose as
|
|
1
|
+
import { EVENT_KEYNAMES as e, HTML_ELEMENT_TYPE as t } from "../../common/constants/index.js";
|
|
2
|
+
import { disableRootScrolling as n, enableRootScrolling as r, getUniqueString as i, hasSlotContent as a, returnFirstEl as o } from "../../common/utils/index.js";
|
|
3
|
+
import { t as s } from "../../_plugin-vue_export-helper-BTgDAbhb.js";
|
|
4
|
+
import c from "../../common/mixins/modal.js";
|
|
5
|
+
import { NOTICE_KINDS as l } from "../notice/notice-constants.js";
|
|
6
|
+
import { DialtoneLocalization as u } from "../../localization/index.js";
|
|
7
|
+
import d from "../button/button.js";
|
|
8
|
+
import f from "../../shared/sr_only_close_button.js";
|
|
9
|
+
import p from "../lazy-show/lazy-show.js";
|
|
10
|
+
import { MODAL_BANNER_KINDS as m, MODAL_KIND_MODIFIERS as h, MODAL_SIZE_MODIFIERS as g } from "./modal-constants.js";
|
|
11
|
+
import { Teleport as _, Transition as v, createBlock as y, createCommentVNode as b, createElementBlock as x, createElementVNode as S, createTextVNode as C, createVNode as w, mergeProps as T, normalizeClass as E, openBlock as D, renderSlot as O, resolveComponent as k, toDisplayString as A, toHandlers as j, vShow as M, withCtx as N, withDirectives as P } from "vue";
|
|
12
|
+
import { DtIconClose as F } from "@dialpad/dialtone-icons/vue3";
|
|
13
13
|
//#region components/modal/modal.vue
|
|
14
|
-
var
|
|
14
|
+
var I = {
|
|
15
15
|
compatConfig: { MODE: 3 },
|
|
16
16
|
name: "DtModal",
|
|
17
17
|
components: {
|
|
18
|
-
DtLazyShow:
|
|
19
|
-
DtButton:
|
|
20
|
-
DtIconClose:
|
|
21
|
-
SrOnlyCloseButton:
|
|
18
|
+
DtLazyShow: p,
|
|
19
|
+
DtButton: d,
|
|
20
|
+
DtIconClose: F,
|
|
21
|
+
SrOnlyCloseButton: f
|
|
22
22
|
},
|
|
23
|
-
mixins: [
|
|
23
|
+
mixins: [c],
|
|
24
24
|
props: {
|
|
25
25
|
copy: {
|
|
26
26
|
type: String,
|
|
@@ -33,7 +33,7 @@ var F = {
|
|
|
33
33
|
labelledById: {
|
|
34
34
|
type: String,
|
|
35
35
|
default: function() {
|
|
36
|
-
return
|
|
36
|
+
return i();
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
show: {
|
|
@@ -51,12 +51,12 @@ var F = {
|
|
|
51
51
|
kind: {
|
|
52
52
|
type: String,
|
|
53
53
|
default: "default",
|
|
54
|
-
validator: (e) => Object.keys(
|
|
54
|
+
validator: (e) => Object.keys(h).includes(e)
|
|
55
55
|
},
|
|
56
56
|
size: {
|
|
57
57
|
type: String,
|
|
58
58
|
default: "default",
|
|
59
|
-
validator: (e) => Object.keys(
|
|
59
|
+
validator: (e) => Object.keys(g).includes(e)
|
|
60
60
|
},
|
|
61
61
|
modalClass: {
|
|
62
62
|
type: [
|
|
@@ -86,7 +86,7 @@ var F = {
|
|
|
86
86
|
type: String,
|
|
87
87
|
default: "warning",
|
|
88
88
|
validate(e) {
|
|
89
|
-
return
|
|
89
|
+
return l.includes(e);
|
|
90
90
|
}
|
|
91
91
|
},
|
|
92
92
|
bannerClass: {
|
|
@@ -110,7 +110,7 @@ var F = {
|
|
|
110
110
|
default: !0
|
|
111
111
|
},
|
|
112
112
|
initialFocusElement: {
|
|
113
|
-
type: [String,
|
|
113
|
+
type: [String, t],
|
|
114
114
|
default: "first",
|
|
115
115
|
validator: (e) => e === "first" || e instanceof HTMLElement || e.startsWith("#")
|
|
116
116
|
},
|
|
@@ -126,19 +126,22 @@ var F = {
|
|
|
126
126
|
],
|
|
127
127
|
data() {
|
|
128
128
|
return {
|
|
129
|
-
MODAL_KIND_MODIFIERS:
|
|
130
|
-
MODAL_SIZE_MODIFIERS:
|
|
131
|
-
MODAL_BANNER_KINDS:
|
|
129
|
+
MODAL_KIND_MODIFIERS: h,
|
|
130
|
+
MODAL_SIZE_MODIFIERS: g,
|
|
131
|
+
MODAL_BANNER_KINDS: m,
|
|
132
132
|
EVENT_KEYNAMES: e,
|
|
133
|
-
hasSlotContent:
|
|
134
|
-
i18n: new
|
|
133
|
+
hasSlotContent: a,
|
|
134
|
+
i18n: new u()
|
|
135
135
|
};
|
|
136
136
|
},
|
|
137
137
|
computed: {
|
|
138
138
|
modalListeners() {
|
|
139
139
|
return {
|
|
140
|
+
mousedown: (e) => {
|
|
141
|
+
this._mousedownOnBackdrop = e.target === e.currentTarget;
|
|
142
|
+
},
|
|
140
143
|
click: (e) => {
|
|
141
|
-
this.closeOnClick && e.target === e.currentTarget && this.close(), this.$emit("click", e);
|
|
144
|
+
this.closeOnClick && e.target === e.currentTarget && this._mousedownOnBackdrop && this.close(), this.$emit("click", e);
|
|
142
145
|
},
|
|
143
146
|
keydown: (t) => {
|
|
144
147
|
switch (t.code) {
|
|
@@ -168,17 +171,17 @@ var F = {
|
|
|
168
171
|
return !!this.$slots.footer;
|
|
169
172
|
},
|
|
170
173
|
bannerKindClass() {
|
|
171
|
-
return
|
|
174
|
+
return m[this.bannerKind];
|
|
172
175
|
},
|
|
173
176
|
closeButtonTitle() {
|
|
174
177
|
return this.i18n.$t("DIALTONE_CLOSE_BUTTON");
|
|
175
178
|
}
|
|
176
179
|
},
|
|
177
180
|
watch: { show: { handler(e) {
|
|
178
|
-
e ? (this.previousActiveElement = document.activeElement,
|
|
181
|
+
e ? (this.previousActiveElement = document.activeElement, n(o(this.$refs.modalRoot?.$el || this.$el).getRootNode().host), document.addEventListener("keydown", this._trapFocusGlobalBound)) : (r(o(this.$refs.modalRoot?.$el || this.$el).getRootNode().host), this.previousActiveElement?.focus(), this.previousActiveElement = null, document.removeEventListener("keydown", this._trapFocusGlobalBound));
|
|
179
182
|
} } },
|
|
180
183
|
created() {
|
|
181
|
-
this._trapFocusGlobalBound = (e) => this._trapFocusGlobal(e);
|
|
184
|
+
this._trapFocusGlobalBound = (e) => this._trapFocusGlobal(e), this._mousedownOnBackdrop = !1;
|
|
182
185
|
},
|
|
183
186
|
mounted() {
|
|
184
187
|
this.show && document.addEventListener("keydown", this._trapFocusGlobalBound);
|
|
@@ -206,16 +209,16 @@ var F = {
|
|
|
206
209
|
n && !n.contains(document.activeElement) && (t.preventDefault(), this.focusFirstElement(n));
|
|
207
210
|
}
|
|
208
211
|
}
|
|
209
|
-
},
|
|
212
|
+
}, L = ["aria-describedby", "aria-labelledby"], R = ["id"], z = ["id"], B = {
|
|
210
213
|
key: 4,
|
|
211
214
|
class: "d-modal__footer"
|
|
212
215
|
};
|
|
213
|
-
function
|
|
214
|
-
let o =
|
|
215
|
-
return
|
|
216
|
+
function V(e, t, n, r, i, a) {
|
|
217
|
+
let o = k("sr-only-close-button"), s = k("dt-icon-close"), c = k("dt-button"), l = k("dt-lazy-show");
|
|
218
|
+
return D(), y(_, {
|
|
216
219
|
disabled: !n.appendTo,
|
|
217
220
|
to: n.appendTo
|
|
218
|
-
}, [
|
|
221
|
+
}, [w(l, T({
|
|
219
222
|
ref: "modalRoot",
|
|
220
223
|
transition: "d-zoom",
|
|
221
224
|
show: n.show,
|
|
@@ -227,21 +230,21 @@ function B(e, t, n, r, i, a) {
|
|
|
227
230
|
],
|
|
228
231
|
"data-qa": "dt-modal",
|
|
229
232
|
"aria-hidden": a.open
|
|
230
|
-
},
|
|
231
|
-
default:
|
|
233
|
+
}, j(a.modalListeners)), {
|
|
234
|
+
default: N(() => [n.show && (i.hasSlotContent(e.$slots.banner) || n.bannerTitle) ? (D(), x("div", {
|
|
232
235
|
key: 0,
|
|
233
236
|
"data-qa": "dt-modal-banner",
|
|
234
|
-
class:
|
|
237
|
+
class: E([
|
|
235
238
|
"d-modal__banner",
|
|
236
239
|
n.bannerClass,
|
|
237
240
|
a.bannerKindClass
|
|
238
241
|
])
|
|
239
|
-
}, [
|
|
242
|
+
}, [O(e.$slots, "banner", {}, () => [C(A(n.bannerTitle), 1)])], 2)) : b("", !0), w(v, {
|
|
240
243
|
appear: "",
|
|
241
244
|
name: "d-modal__dialog"
|
|
242
245
|
}, {
|
|
243
|
-
default:
|
|
244
|
-
class:
|
|
246
|
+
default: N(() => [P(S("div", {
|
|
247
|
+
class: E([
|
|
245
248
|
"d-modal__dialog",
|
|
246
249
|
{ "d-modal__dialog--scrollable": n.fixedHeaderFooter },
|
|
247
250
|
n.dialogClass
|
|
@@ -251,31 +254,31 @@ function B(e, t, n, r, i, a) {
|
|
|
251
254
|
"aria-describedby": n.describedById,
|
|
252
255
|
"aria-labelledby": n.labelledById
|
|
253
256
|
}, [
|
|
254
|
-
i.hasSlotContent(e.$slots.header) ? (
|
|
257
|
+
i.hasSlotContent(e.$slots.header) ? (D(), x("div", {
|
|
255
258
|
key: 0,
|
|
256
259
|
id: n.labelledById,
|
|
257
260
|
class: "d-modal__header",
|
|
258
261
|
"data-qa": "dt-modal-title"
|
|
259
|
-
}, [
|
|
262
|
+
}, [O(e.$slots, "header")], 8, R)) : (D(), x("h2", {
|
|
260
263
|
key: 1,
|
|
261
264
|
id: n.labelledById,
|
|
262
265
|
class: "d-modal__header",
|
|
263
266
|
"data-qa": "dt-modal-title"
|
|
264
|
-
},
|
|
265
|
-
i.hasSlotContent(e.$slots.default) ? (
|
|
267
|
+
}, A(n.title), 9, z)),
|
|
268
|
+
i.hasSlotContent(e.$slots.default) ? (D(), x("div", {
|
|
266
269
|
key: 2,
|
|
267
|
-
class:
|
|
270
|
+
class: E(["d-modal__content", n.contentClass]),
|
|
268
271
|
"data-qa": "dt-modal-copy"
|
|
269
|
-
}, [
|
|
272
|
+
}, [O(e.$slots, "default")], 2)) : (D(), x("p", {
|
|
270
273
|
key: 3,
|
|
271
|
-
class:
|
|
274
|
+
class: E(["d-modal__content", n.contentClass]),
|
|
272
275
|
"data-qa": "dt-modal-copy"
|
|
273
|
-
},
|
|
274
|
-
a.hasFooterSlot ? (
|
|
275
|
-
n.hideClose ? (
|
|
276
|
+
}, A(n.copy), 3)),
|
|
277
|
+
a.hasFooterSlot ? (D(), x("footer", B, [O(e.$slots, "footer")])) : b("", !0),
|
|
278
|
+
n.hideClose ? (D(), y(o, {
|
|
276
279
|
key: 5,
|
|
277
280
|
onClose: a.close
|
|
278
|
-
}, null, 8, ["onClose"])) : (
|
|
281
|
+
}, null, 8, ["onClose"])) : (D(), y(c, {
|
|
279
282
|
key: 6,
|
|
280
283
|
class: "d-modal__close",
|
|
281
284
|
"data-qa": "dt-modal-close-button",
|
|
@@ -286,14 +289,14 @@ function B(e, t, n, r, i, a) {
|
|
|
286
289
|
title: a.closeButtonTitle,
|
|
287
290
|
onClick: a.close
|
|
288
291
|
}, {
|
|
289
|
-
icon:
|
|
292
|
+
icon: N(({ iconSize: e }) => [w(s, { size: e }, null, 8, ["size"])]),
|
|
290
293
|
_: 1
|
|
291
294
|
}, 8, [
|
|
292
295
|
"aria-label",
|
|
293
296
|
"title",
|
|
294
297
|
"onClick"
|
|
295
298
|
]))
|
|
296
|
-
], 10,
|
|
299
|
+
], 10, L), [[M, n.show]])]),
|
|
297
300
|
_: 3
|
|
298
301
|
})]),
|
|
299
302
|
_: 3
|
|
@@ -303,8 +306,8 @@ function B(e, t, n, r, i, a) {
|
|
|
303
306
|
"aria-hidden"
|
|
304
307
|
])], 8, ["disabled", "to"]);
|
|
305
308
|
}
|
|
306
|
-
var
|
|
309
|
+
var H = /* @__PURE__ */ s(I, [["render", V]]);
|
|
307
310
|
//#endregion
|
|
308
|
-
export {
|
|
311
|
+
export { H as default };
|
|
309
312
|
|
|
310
313
|
//# sourceMappingURL=modal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.js","names":[],"sources":["../../../components/modal/modal.vue"],"sourcesContent":["<template>\n <teleport\n :disabled=\"!appendTo\"\n :to=\"appendTo\"\n >\n <dt-lazy-show\n ref=\"modalRoot\"\n transition=\"d-zoom\"\n :show=\"show\"\n :class=\"[\n 'd-modal',\n MODAL_KIND_MODIFIERS[kind],\n MODAL_SIZE_MODIFIERS[size],\n modalClass,\n ]\"\n data-qa=\"dt-modal\"\n :aria-hidden=\"open\"\n v-on=\"modalListeners\"\n >\n <div\n v-if=\"show && (hasSlotContent($slots.banner) || bannerTitle)\"\n data-qa=\"dt-modal-banner\"\n :class=\"[\n 'd-modal__banner',\n bannerClass,\n bannerKindClass,\n ]\"\n >\n <!-- @slot Slot for the banner, defaults to bannerTitle prop -->\n <slot name=\"banner\">\n {{ bannerTitle }}\n </slot>\n </div>\n <transition\n appear\n name=\"d-modal__dialog\"\n >\n <div\n v-show=\"show\"\n :class=\"[\n 'd-modal__dialog',\n { 'd-modal__dialog--scrollable': fixedHeaderFooter },\n dialogClass,\n ]\"\n role=\"dialog\"\n aria-modal=\"true\"\n :aria-describedby=\"describedById\"\n :aria-labelledby=\"labelledById\"\n >\n <div\n v-if=\"hasSlotContent($slots.header)\"\n :id=\"labelledById\"\n class=\"d-modal__header\"\n data-qa=\"dt-modal-title\"\n >\n <!-- @slot Slot for dialog header section, taking the place of any \"title\" text prop -->\n <slot name=\"header\" />\n </div>\n <h2\n v-else\n :id=\"labelledById\"\n class=\"d-modal__header\"\n data-qa=\"dt-modal-title\"\n >\n {{ title }}\n </h2>\n <div\n v-if=\"hasSlotContent($slots.default)\"\n :class=\"[\n 'd-modal__content',\n contentClass,\n ]\"\n data-qa=\"dt-modal-copy\"\n >\n <!-- @slot Default slot for dialog body section, taking the place of any \"copy\" text prop -->\n <slot />\n </div>\n <p\n v-else\n :class=\"[\n 'd-modal__content',\n contentClass,\n ]\"\n data-qa=\"dt-modal-copy\"\n >\n {{ copy }}\n </p>\n <footer\n v-if=\"hasFooterSlot\"\n class=\"d-modal__footer\"\n >\n <!-- @slot Slot for dialog footer content, often containing cancel and confirm buttons. -->\n <slot name=\"footer\" />\n </footer>\n <sr-only-close-button\n v-if=\"hideClose\"\n @close=\"close\"\n />\n <dt-button\n v-else\n class=\"d-modal__close\"\n data-qa=\"dt-modal-close-button\"\n size=\"md\"\n kind=\"muted\"\n importance=\"clear\"\n :aria-label=\"closeButtonTitle\"\n :title=\"closeButtonTitle\"\n @click=\"close\"\n >\n <template #icon=\"{ iconSize }\">\n <dt-icon-close\n :size=\"iconSize\"\n />\n </template>\n </dt-button>\n </div>\n </transition>\n </dt-lazy-show>\n </teleport>\n</template>\n\n<script>\n/* eslint-disable max-lines */\nimport { DtButton } from '@/components/button';\nimport { DtIconClose } from '@dialpad/dialtone-icons/vue3';\nimport Modal from '@/common/mixins/modal';\nimport {\n MODAL_BANNER_KINDS,\n MODAL_KIND_MODIFIERS,\n MODAL_SIZE_MODIFIERS,\n} from './modal_constants';\nimport { returnFirstEl, getUniqueString, hasSlotContent, disableRootScrolling, enableRootScrolling } from '@/common/utils';\nimport { DtLazyShow } from '@/components/lazy_show';\nimport { EVENT_KEYNAMES } from '@/common/constants';\nimport SrOnlyCloseButton from '@/common/sr_only_close_button.vue';\nimport { NOTICE_KINDS } from '@/components/notice';\nimport { DialtoneLocalization } from '@/localization';\n\n/**\n * Modals focus the user’s attention exclusively on one task or piece of information\n * via a window that sits on top of the page content.\n * @see https://dialtone.dialpad.com/components/modal.html\n */\nexport default {\n compatConfig: { MODE: 3 },\n name: 'DtModal',\n\n components: {\n DtLazyShow,\n DtButton,\n DtIconClose,\n SrOnlyCloseButton,\n },\n\n mixins: [Modal],\n\n props: {\n /**\n * Body text to display as the modal's main content.\n */\n copy: {\n type: String,\n default: '',\n },\n\n /**\n * Id to use for the dialog's aria-describedby.\n * Recommended only if the dialog content itself isn't enough to give full context,\n * as screen readers should recite the dialog contents by default before any aria-description.\n */\n describedById: {\n type: String,\n default: '',\n },\n\n /**\n * Id to use for the dialog's aria-labelledby.\n */\n labelledById: {\n type: String,\n default: function () { return getUniqueString(); },\n },\n\n /**\n * Whether the modal should be shown.\n * Parent component can sync on this value to control the modal's visibility.\n * @values true, false\n */\n show: {\n type: Boolean,\n default: false,\n },\n\n /**\n * Title text to display in the modal header.\n */\n title: {\n type: String,\n default: '',\n },\n\n /**\n * Title text to display in the modal banner.\n */\n bannerTitle: {\n type: String,\n default: '',\n },\n\n /**\n * The theme of the modal. kind - default or danger,\n * @values default, danger\n */\n kind: {\n type: String,\n default: 'default',\n validator: (k) => Object.keys(MODAL_KIND_MODIFIERS).includes(k),\n },\n\n /**\n * The size of the modal. size - default or full,\n * @values default, full\n */\n size: {\n type: String,\n default: 'default',\n validator: (s) => Object.keys(MODAL_SIZE_MODIFIERS).includes(s),\n },\n\n /**\n * Additional class name for the root modal element.\n * Can accept String, Object, and Array, i.e. has the\n * same API as Vue's built-in handling of the class attribute.\n */\n modalClass: {\n type: [String, Object, Array],\n default: '',\n },\n\n /**\n * Additional class name for the dialog element within the modal.\n * Can accept String, Object, and Array, i.e. has the\n * same API as Vue's built-in handling of the class attribute.\n */\n dialogClass: {\n type: [String, Object, Array],\n default: '',\n },\n\n /**\n * Additional class name for the content element within the modal.\n * Can accept String, Object, and Array, i.e. has the\n * same API as Vue's built-in handling of the class attribute.\n */\n contentClass: {\n type: [String, Object, Array],\n default: '',\n },\n\n /**\n * Sets the color of the banner.\n * @values base, error, info, success, warning\n */\n bannerKind: {\n type: String,\n default: 'warning',\n validate (kind) {\n return NOTICE_KINDS.includes(kind);\n },\n },\n\n /**\n * Additional class name for the banner element within the modal.\n * Can accept String, Object, and Array, i.e. has the\n * same API as Vue's built-in handling of the class attribute.\n */\n bannerClass: {\n type: [String, Object, Array],\n default: '',\n },\n\n /**\n * Hides the close button on the modal\n * @values true, false\n */\n hideClose: {\n type: Boolean,\n default: false,\n },\n\n /**\n * Whether the modal will close when you click outside of the dialog on the overlay.\n * @values true, false\n */\n closeOnClick: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Scrollable modal that allows scroll the modal content keeping the header and footer fixed\n * @values true, false\n */\n fixedHeaderFooter: {\n type: Boolean,\n default: true,\n },\n\n /**\n * The element that is focused when the modal is opened. This can be an\n * HTMLElement within the modal, a string starting with '#' which will\n * find the element by ID. 'first' which will automatically focus\n * the first element, or 'dialog' which will focus the dialog window itself.\n * If the dialog is modal this prop cannot be 'none'.\n */\n initialFocusElement: {\n type: [String, HTMLElement],\n default: 'first',\n validator: initialFocusElement => {\n return initialFocusElement === 'first' ||\n (initialFocusElement instanceof HTMLElement) ||\n initialFocusElement.startsWith('#');\n },\n },\n\n /**\n * A CSS selector string for the element to portal the modal to. If not provided, the modal will be rendered in its default location.\n */\n appendTo: {\n type: String,\n default: undefined,\n },\n },\n\n emits: [\n /**\n * Native button click event\n *\n * @event click\n * @type {PointerEvent | KeyboardEvent}\n */\n 'click',\n\n /**\n * Native keydown event\n *\n * @event keydown\n * @type {KeyboardEvent}\n */\n 'keydown',\n\n /**\n * The modal will emit a \"false\" boolean value for this event when the user performs a modal-closing action.\n * Parent components can sync on this value to create a 2-way binding to control modal visibility.\n *\n * @event update:show\n * @type {Boolean}\n */\n 'update:show',\n ],\n\n data () {\n return {\n MODAL_KIND_MODIFIERS,\n MODAL_SIZE_MODIFIERS,\n MODAL_BANNER_KINDS,\n EVENT_KEYNAMES,\n hasSlotContent,\n i18n: new DialtoneLocalization(),\n };\n },\n\n computed: {\n modalListeners () {\n return {\n click: event => {\n // Handle backdrop clicks for closing modal\n if (this.closeOnClick && event.target === event.currentTarget) {\n this.close();\n }\n\n this.$emit('click', event);\n },\n\n keydown: event => {\n switch (event.code) {\n case EVENT_KEYNAMES.esc:\n case EVENT_KEYNAMES.escape:\n this.close();\n break;\n case EVENT_KEYNAMES.tab:\n this.trapFocus(event);\n break;\n }\n this.$emit('keydown', event);\n },\n\n 'after-enter': async () => {\n this.$emit('update:show', true);\n await this.setFocusAfterTransition();\n },\n\n focusin: event => {\n // Ensure focus stays within modal\n const modalEl = this.$refs.modalRoot?.$el || this.$el;\n if (this.show && modalEl && !modalEl.contains(event.target)) {\n event.preventDefault();\n this.focusFirstElement(modalEl);\n }\n },\n };\n },\n\n open () {\n return `${!this.show}`;\n },\n\n hasFooterSlot () {\n return !!this.$slots.footer;\n },\n\n bannerKindClass () {\n return MODAL_BANNER_KINDS[this.bannerKind];\n },\n\n closeButtonTitle () {\n return this.i18n.$t('DIALTONE_CLOSE_BUTTON');\n },\n },\n\n watch: {\n show: {\n handler (isShowing) {\n if (isShowing) {\n // Set a reference to the previously-active element, to which we'll return focus on modal close.\n this.previousActiveElement = document.activeElement;\n const modalEl = this.$refs.modalRoot?.$el || this.$el;\n disableRootScrolling(returnFirstEl(modalEl).getRootNode().host);\n document.addEventListener('keydown', this._trapFocusGlobalBound);\n } else {\n const modalEl = this.$refs.modalRoot?.$el || this.$el;\n enableRootScrolling(returnFirstEl(modalEl).getRootNode().host);\n // Modal is being hidden, so return focus to the previously active element before clearing the reference.\n this.previousActiveElement?.focus();\n this.previousActiveElement = null;\n document.removeEventListener('keydown', this._trapFocusGlobalBound);\n }\n },\n },\n },\n\n created () {\n this._trapFocusGlobalBound = (e) => this._trapFocusGlobal(e);\n },\n\n mounted () {\n if (this.show) {\n document.addEventListener('keydown', this._trapFocusGlobalBound);\n }\n },\n\n beforeUnmount () {\n document.removeEventListener('keydown', this._trapFocusGlobalBound);\n },\n\n methods: {\n close () {\n this.$emit('update:show', false);\n },\n\n async setFocusAfterTransition () {\n const modalEl = this.$refs.modalRoot?.$el || this.$el;\n if (this.initialFocusElement === 'first') {\n await this.focusFirstElement(modalEl);\n } else if (this.initialFocusElement.startsWith('#')) {\n await this.focusElementById(this.initialFocusElement);\n } else if (this.initialFocusElement instanceof HTMLElement) {\n this.initialFocusElement.focus();\n }\n },\n\n trapFocus (e) {\n if (this.show) {\n const modalEl = this.$refs.modalRoot?.$el || this.$el;\n this.focusTrappedTabPress(e, modalEl);\n }\n },\n\n _trapFocusGlobal (e) {\n if (!this.show || e.code !== EVENT_KEYNAMES.tab) return;\n const modalEl = this.$refs.modalRoot?.$el || this.$el;\n if (modalEl && !modalEl.contains(document.activeElement)) {\n e.preventDefault();\n this.focusFirstElement(modalEl);\n }\n },\n },\n};\n</script>\n"],"mappings":";;;;;;;;;;;;;AA+IA,IAAK,IAAU;CACb,cAAc,EAAE,MAAM,GAAG;CACzB,MAAM;CAEN,YAAY;EACV,YAAA;EACA,UAAA;EACA;EACA,mBAAA;EACD;CAED,QAAQ,CAAC,EAAM;CAEf,OAAO;EAIL,MAAM;GACJ,MAAM;GACN,SAAS;GACV;EAOD,eAAe;GACb,MAAM;GACN,SAAS;GACV;EAKD,cAAc;GACZ,MAAM;GACN,SAAS,WAAY;AAAE,WAAO,GAAiB;;GAChD;EAOD,MAAM;GACJ,MAAM;GACN,SAAS;GACV;EAKD,OAAO;GACL,MAAM;GACN,SAAS;GACV;EAKD,aAAa;GACX,MAAM;GACN,SAAS;GACV;EAMD,MAAM;GACJ,MAAM;GACN,SAAS;GACT,YAAY,MAAM,OAAO,KAAK,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IACV,oBAAkB,EAAA;IAClB,mBAAiB,EAAA;;IAGV,EAAA,eAAe,EAAA,OAAO,OAAM,IAAA,GAAA,EADpC,EAQM,OAAA;;KANH,IAAI,EAAA;KACL,OAAM;KACN,WAAQ;QAGR,EAAsB,EAAA,QAAA,SAAA,CAAA,EAAA,GAAA,EAAA,KAAA,GAAA,EAExB,EAOK,MAAA;;KALF,IAAI,EAAA;KACL,OAAM;KACN,WAAQ;SAEL,EAAA,MAAK,EAAA,GAAA,EAAA;IAGF,EAAA,eAAe,EAAA,OAAO,QAAO,IAAA,GAAA,EADrC,EAUM,OAAA;;KARH,OAAK,EAAA,CAAA,oBAAoD,EAAA,aAAA,CAAA;KAI1D,WAAQ;QAGR,EAAQ,EAAA,QAAA,UAAA,CAAA,EAAA,EAAA,KAAA,GAAA,EAEV,EASI,KAAA;;KAPD,OAAK,EAAA,CAAA,oBAAoD,EAAA,aAAA,CAAA;KAI1D,WAAQ;SAEL,EAAA,KAAI,EAAA,EAAA;IAGD,EAAA,iBAAA,GAAA,EADR,EAMS,UANT,GAMS,CADP,EAAsB,EAAA,QAAA,SAAA,CAAA,CAAA,IAAA,EAAA,IAAA,GAAA;IAGhB,EAAA,aAAA,GAAA,EADR,EAGE,GAAA;;KADC,SAAO,EAAA;sCAEV,EAgBY,GAAA;;KAdV,OAAM;KACN,WAAQ;KACR,MAAK;KACL,MAAK;KACL,YAAW;KACV,cAAY,EAAA;KACZ,OAAO,EAAA;KACP,SAAO,EAAA;;KAEG,MAAI,GAGX,EAHe,kBAAQ,CACzB,EAEE,GAAA,EADC,MAAM,GAAQ,EAAA,MAAA,GAAA,CAAA,OAAA,CAAA,CAAA,CAAA;;;;;;;mBAzEb,EAAA,KAAI,CAAA,CAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"modal.js","names":[],"sources":["../../../components/modal/modal.vue"],"sourcesContent":["<template>\n <teleport\n :disabled=\"!appendTo\"\n :to=\"appendTo\"\n >\n <dt-lazy-show\n ref=\"modalRoot\"\n transition=\"d-zoom\"\n :show=\"show\"\n :class=\"[\n 'd-modal',\n MODAL_KIND_MODIFIERS[kind],\n MODAL_SIZE_MODIFIERS[size],\n modalClass,\n ]\"\n data-qa=\"dt-modal\"\n :aria-hidden=\"open\"\n v-on=\"modalListeners\"\n >\n <div\n v-if=\"show && (hasSlotContent($slots.banner) || bannerTitle)\"\n data-qa=\"dt-modal-banner\"\n :class=\"[\n 'd-modal__banner',\n bannerClass,\n bannerKindClass,\n ]\"\n >\n <!-- @slot Slot for the banner, defaults to bannerTitle prop -->\n <slot name=\"banner\">\n {{ bannerTitle }}\n </slot>\n </div>\n <transition\n appear\n name=\"d-modal__dialog\"\n >\n <div\n v-show=\"show\"\n :class=\"[\n 'd-modal__dialog',\n { 'd-modal__dialog--scrollable': fixedHeaderFooter },\n dialogClass,\n ]\"\n role=\"dialog\"\n aria-modal=\"true\"\n :aria-describedby=\"describedById\"\n :aria-labelledby=\"labelledById\"\n >\n <div\n v-if=\"hasSlotContent($slots.header)\"\n :id=\"labelledById\"\n class=\"d-modal__header\"\n data-qa=\"dt-modal-title\"\n >\n <!-- @slot Slot for dialog header section, taking the place of any \"title\" text prop -->\n <slot name=\"header\" />\n </div>\n <h2\n v-else\n :id=\"labelledById\"\n class=\"d-modal__header\"\n data-qa=\"dt-modal-title\"\n >\n {{ title }}\n </h2>\n <div\n v-if=\"hasSlotContent($slots.default)\"\n :class=\"[\n 'd-modal__content',\n contentClass,\n ]\"\n data-qa=\"dt-modal-copy\"\n >\n <!-- @slot Default slot for dialog body section, taking the place of any \"copy\" text prop -->\n <slot />\n </div>\n <p\n v-else\n :class=\"[\n 'd-modal__content',\n contentClass,\n ]\"\n data-qa=\"dt-modal-copy\"\n >\n {{ copy }}\n </p>\n <footer\n v-if=\"hasFooterSlot\"\n class=\"d-modal__footer\"\n >\n <!-- @slot Slot for dialog footer content, often containing cancel and confirm buttons. -->\n <slot name=\"footer\" />\n </footer>\n <sr-only-close-button\n v-if=\"hideClose\"\n @close=\"close\"\n />\n <dt-button\n v-else\n class=\"d-modal__close\"\n data-qa=\"dt-modal-close-button\"\n size=\"md\"\n kind=\"muted\"\n importance=\"clear\"\n :aria-label=\"closeButtonTitle\"\n :title=\"closeButtonTitle\"\n @click=\"close\"\n >\n <template #icon=\"{ iconSize }\">\n <dt-icon-close\n :size=\"iconSize\"\n />\n </template>\n </dt-button>\n </div>\n </transition>\n </dt-lazy-show>\n </teleport>\n</template>\n\n<script>\n/* eslint-disable max-lines */\nimport { DtButton } from '@/components/button';\nimport { DtIconClose } from '@dialpad/dialtone-icons/vue3';\nimport Modal from '@/common/mixins/modal';\nimport {\n MODAL_BANNER_KINDS,\n MODAL_KIND_MODIFIERS,\n MODAL_SIZE_MODIFIERS,\n} from './modal_constants';\nimport { returnFirstEl, getUniqueString, hasSlotContent, disableRootScrolling, enableRootScrolling } from '@/common/utils';\nimport { DtLazyShow } from '@/components/lazy_show';\nimport { EVENT_KEYNAMES, HTML_ELEMENT_TYPE } from '@/common/constants';\nimport SrOnlyCloseButton from '@/common/sr_only_close_button.vue';\nimport { NOTICE_KINDS } from '@/components/notice';\nimport { DialtoneLocalization } from '@/localization';\n\n/**\n * Modals focus the user’s attention exclusively on one task or piece of information\n * via a window that sits on top of the page content.\n * @see https://dialtone.dialpad.com/components/modal.html\n */\nexport default {\n compatConfig: { MODE: 3 },\n name: 'DtModal',\n\n components: {\n DtLazyShow,\n DtButton,\n DtIconClose,\n SrOnlyCloseButton,\n },\n\n mixins: [Modal],\n\n props: {\n /**\n * Body text to display as the modal's main content.\n */\n copy: {\n type: String,\n default: '',\n },\n\n /**\n * Id to use for the dialog's aria-describedby.\n * Recommended only if the dialog content itself isn't enough to give full context,\n * as screen readers should recite the dialog contents by default before any aria-description.\n */\n describedById: {\n type: String,\n default: '',\n },\n\n /**\n * Id to use for the dialog's aria-labelledby.\n */\n labelledById: {\n type: String,\n default: function () { return getUniqueString(); },\n },\n\n /**\n * Whether the modal should be shown.\n * Parent component can sync on this value to control the modal's visibility.\n * @values true, false\n */\n show: {\n type: Boolean,\n default: false,\n },\n\n /**\n * Title text to display in the modal header.\n */\n title: {\n type: String,\n default: '',\n },\n\n /**\n * Title text to display in the modal banner.\n */\n bannerTitle: {\n type: String,\n default: '',\n },\n\n /**\n * The theme of the modal. kind - default or danger,\n * @values default, danger\n */\n kind: {\n type: String,\n default: 'default',\n validator: (k) => Object.keys(MODAL_KIND_MODIFIERS).includes(k),\n },\n\n /**\n * The size of the modal. size - default or full,\n * @values default, full\n */\n size: {\n type: String,\n default: 'default',\n validator: (s) => Object.keys(MODAL_SIZE_MODIFIERS).includes(s),\n },\n\n /**\n * Additional class name for the root modal element.\n * Can accept String, Object, and Array, i.e. has the\n * same API as Vue's built-in handling of the class attribute.\n */\n modalClass: {\n type: [String, Object, Array],\n default: '',\n },\n\n /**\n * Additional class name for the dialog element within the modal.\n * Can accept String, Object, and Array, i.e. has the\n * same API as Vue's built-in handling of the class attribute.\n */\n dialogClass: {\n type: [String, Object, Array],\n default: '',\n },\n\n /**\n * Additional class name for the content element within the modal.\n * Can accept String, Object, and Array, i.e. has the\n * same API as Vue's built-in handling of the class attribute.\n */\n contentClass: {\n type: [String, Object, Array],\n default: '',\n },\n\n /**\n * Sets the color of the banner.\n * @values base, error, info, success, warning\n */\n bannerKind: {\n type: String,\n default: 'warning',\n validate (kind) {\n return NOTICE_KINDS.includes(kind);\n },\n },\n\n /**\n * Additional class name for the banner element within the modal.\n * Can accept String, Object, and Array, i.e. has the\n * same API as Vue's built-in handling of the class attribute.\n */\n bannerClass: {\n type: [String, Object, Array],\n default: '',\n },\n\n /**\n * Hides the close button on the modal\n * @values true, false\n */\n hideClose: {\n type: Boolean,\n default: false,\n },\n\n /**\n * Whether the modal will close when you click outside of the dialog on the overlay.\n * @values true, false\n */\n closeOnClick: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Scrollable modal that allows scroll the modal content keeping the header and footer fixed\n * @values true, false\n */\n fixedHeaderFooter: {\n type: Boolean,\n default: true,\n },\n\n /**\n * The element that is focused when the modal is opened. This can be an\n * HTMLElement within the modal, a string starting with '#' which will\n * find the element by ID. 'first' which will automatically focus\n * the first element, or 'dialog' which will focus the dialog window itself.\n * If the dialog is modal this prop cannot be 'none'.\n */\n initialFocusElement: {\n type: [String, HTML_ELEMENT_TYPE],\n default: 'first',\n validator: initialFocusElement => {\n return initialFocusElement === 'first' ||\n (initialFocusElement instanceof HTMLElement) ||\n initialFocusElement.startsWith('#');\n },\n },\n\n /**\n * A CSS selector string for the element to portal the modal to. If not provided, the modal will be rendered in its default location.\n */\n appendTo: {\n type: String,\n default: undefined,\n },\n },\n\n emits: [\n /**\n * Native button click event\n *\n * @event click\n * @type {PointerEvent | KeyboardEvent}\n */\n 'click',\n\n /**\n * Native keydown event\n *\n * @event keydown\n * @type {KeyboardEvent}\n */\n 'keydown',\n\n /**\n * The modal will emit a \"false\" boolean value for this event when the user performs a modal-closing action.\n * Parent components can sync on this value to create a 2-way binding to control modal visibility.\n *\n * @event update:show\n * @type {Boolean}\n */\n 'update:show',\n ],\n\n data () {\n return {\n MODAL_KIND_MODIFIERS,\n MODAL_SIZE_MODIFIERS,\n MODAL_BANNER_KINDS,\n EVENT_KEYNAMES,\n hasSlotContent,\n i18n: new DialtoneLocalization(),\n };\n },\n\n computed: {\n modalListeners () {\n return {\n mousedown: event => {\n // Track whether the drag originated on the backdrop so that a drag\n // starting inside the dialog and ending outside doesn't close the modal.\n this._mousedownOnBackdrop = (event.target === event.currentTarget);\n },\n\n click: event => {\n // Handle backdrop clicks for closing modal.\n // Require mousedown to have also started on the backdrop — prevents\n // text-selection drags that end outside from dismissing the modal.\n if (this.closeOnClick && event.target === event.currentTarget && this._mousedownOnBackdrop) {\n this.close();\n }\n\n this.$emit('click', event);\n },\n\n keydown: event => {\n switch (event.code) {\n case EVENT_KEYNAMES.esc:\n case EVENT_KEYNAMES.escape:\n this.close();\n break;\n case EVENT_KEYNAMES.tab:\n this.trapFocus(event);\n break;\n }\n this.$emit('keydown', event);\n },\n\n 'after-enter': async () => {\n this.$emit('update:show', true);\n await this.setFocusAfterTransition();\n },\n\n focusin: event => {\n // Ensure focus stays within modal\n const modalEl = this.$refs.modalRoot?.$el || this.$el;\n if (this.show && modalEl && !modalEl.contains(event.target)) {\n event.preventDefault();\n this.focusFirstElement(modalEl);\n }\n },\n };\n },\n\n open () {\n return `${!this.show}`;\n },\n\n hasFooterSlot () {\n return !!this.$slots.footer;\n },\n\n bannerKindClass () {\n return MODAL_BANNER_KINDS[this.bannerKind];\n },\n\n closeButtonTitle () {\n return this.i18n.$t('DIALTONE_CLOSE_BUTTON');\n },\n },\n\n watch: {\n show: {\n handler (isShowing) {\n if (isShowing) {\n // Set a reference to the previously-active element, to which we'll return focus on modal close.\n this.previousActiveElement = document.activeElement;\n const modalEl = this.$refs.modalRoot?.$el || this.$el;\n disableRootScrolling(returnFirstEl(modalEl).getRootNode().host);\n document.addEventListener('keydown', this._trapFocusGlobalBound);\n } else {\n const modalEl = this.$refs.modalRoot?.$el || this.$el;\n enableRootScrolling(returnFirstEl(modalEl).getRootNode().host);\n // Modal is being hidden, so return focus to the previously active element before clearing the reference.\n this.previousActiveElement?.focus();\n this.previousActiveElement = null;\n document.removeEventListener('keydown', this._trapFocusGlobalBound);\n }\n },\n },\n },\n\n created () {\n this._trapFocusGlobalBound = (e) => this._trapFocusGlobal(e);\n this._mousedownOnBackdrop = false;\n },\n\n mounted () {\n if (this.show) {\n document.addEventListener('keydown', this._trapFocusGlobalBound);\n }\n },\n\n beforeUnmount () {\n document.removeEventListener('keydown', this._trapFocusGlobalBound);\n },\n\n methods: {\n close () {\n this.$emit('update:show', false);\n },\n\n async setFocusAfterTransition () {\n const modalEl = this.$refs.modalRoot?.$el || this.$el;\n if (this.initialFocusElement === 'first') {\n await this.focusFirstElement(modalEl);\n } else if (this.initialFocusElement.startsWith('#')) {\n await this.focusElementById(this.initialFocusElement);\n } else if (this.initialFocusElement instanceof HTMLElement) {\n this.initialFocusElement.focus();\n }\n },\n\n trapFocus (e) {\n if (this.show) {\n const modalEl = this.$refs.modalRoot?.$el || this.$el;\n this.focusTrappedTabPress(e, modalEl);\n }\n },\n\n _trapFocusGlobal (e) {\n if (!this.show || e.code !== EVENT_KEYNAMES.tab) return;\n const modalEl = this.$refs.modalRoot?.$el || this.$el;\n if (modalEl && !modalEl.contains(document.activeElement)) {\n e.preventDefault();\n this.focusFirstElement(modalEl);\n }\n },\n },\n};\n</script>\n"],"mappings":";;;;;;;;;;;;;AA+IA,IAAK,IAAU;CACb,cAAc,EAAE,MAAM,GAAG;CACzB,MAAM;CAEN,YAAY;EACV,YAAA;EACA,UAAA;EACA;EACA,mBAAA;EACD;CAED,QAAQ,CAAC,EAAM;CAEf,OAAO;EAIL,MAAM;GACJ,MAAM;GACN,SAAS;GACV;EAOD,eAAe;GACb,MAAM;GACN,SAAS;GACV;EAKD,cAAc;GACZ,MAAM;GACN,SAAS,WAAY;AAAE,WAAO,GAAiB;;GAChD;EAOD,MAAM;GACJ,MAAM;GACN,SAAS;GACV;EAKD,OAAO;GACL,MAAM;GACN,SAAS;GACV;EAKD,aAAa;GACX,MAAM;GACN,SAAS;GACV;EAMD,MAAM;GACJ,MAAM;GACN,SAAS;GACT,YAAY,MAAM,OAAO,KAAK,EAAqB,CAAC,SAAS,EAAE;GAChE;EAMD,MAAM;GACJ,MAAM;GACN,SAAS;GACT,YAAY,MAAM,OAAO,KAAK,EAAqB,CAAC,SAAS,EAAE;GAChE;EAOD,YAAY;GACV,MAAM;IAAC;IAAQ;IAAQ;IAAM;GAC7B,SAAS;GACV;EAOD,aAAa;GACX,MAAM;IAAC;IAAQ;IAAQ;IAAM;GAC7B,SAAS;GACV;EAOD,cAAc;GACZ,MAAM;IAAC;IAAQ;IAAQ;IAAM;GAC7B,SAAS;GACV;EAMD,YAAY;GACV,MAAM;GACN,SAAS;GACT,SAAU,GAAM;AACd,WAAO,EAAa,SAAS,EAAK;;GAErC;EAOD,aAAa;GACX,MAAM;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,QAAO,IAAA,GAAA,EADrC,EAUM,OAAA;;KARH,OAAK,EAAA,CAAA,oBAAoD,EAAA,aAAA,CAAA;KAI1D,WAAQ;QAGR,EAAQ,EAAA,QAAA,UAAA,CAAA,EAAA,EAAA,KAAA,GAAA,EAEV,EASI,KAAA;;KAPD,OAAK,EAAA,CAAA,oBAAoD,EAAA,aAAA,CAAA;KAI1D,WAAQ;SAEL,EAAA,KAAI,EAAA,EAAA;IAGD,EAAA,iBAAA,GAAA,EADR,EAMS,UANT,GAMS,CADP,EAAsB,EAAA,QAAA,SAAA,CAAA,CAAA,IAAA,EAAA,IAAA,GAAA;IAGhB,EAAA,aAAA,GAAA,EADR,EAGE,GAAA;;KADC,SAAO,EAAA;sCAEV,EAgBY,GAAA;;KAdV,OAAM;KACN,WAAQ;KACR,MAAK;KACL,MAAK;KACL,YAAW;KACV,cAAY,EAAA;KACZ,OAAO,EAAA;KACP,SAAO,EAAA;;KAEG,MAAI,GAGX,EAHe,kBAAQ,CACzB,EAEE,GAAA,EADC,MAAM,GAAQ,EAAA,MAAA,GAAA,CAAA,OAAA,CAAA,CAAA,CAAA;;;;;;;mBAzEb,EAAA,KAAI,CAAA,CAAA,CAAA,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}}),require(`../../chunk-Bmb41Sf3.cjs`);const e=require(`../../common/utils/index.cjs`),t=require(`../../_plugin-vue_export-helper-D8jCH6HB.cjs`),n=require(`../../common/mixins/modal.cjs`),r=require(`../../shared/sr_only_close_button.cjs`),i=require(`../lazy-show/lazy-show.cjs`),a=require(`./tippy-utils.cjs`),o=require(`./popover-constants.cjs`),s=require(`./popover-header-footer.cjs`);let c=require(`vue`);var l={compatConfig:{MODE:3},name:`DtPopover`,components:{SrOnlyCloseButton:r.default,DtLazyShow:i.default,PopoverHeaderFooter:s.default},mixins:[n.default],props:{open:{type:Boolean,default:null},openOnContext:{type:Boolean,default:!1},elementType:{type:String,default:`div`},transition:{type:String,default:`fade`},role:{type:String,default:`dialog`,validator:e=>o.POPOVER_ROLES.includes(e)},ariaLabelledby:{type:String,default:null},ariaLabel:{type:String,default:null},padding:{type:String,default:`large`,validator:e=>Object.keys(o.POPOVER_PADDING_CLASSES).some(t=>t===e)},contentClass:{type:[String,Array,Object],default:``},contentWidth:{type:String,default:``,validator:e=>o.POPOVER_CONTENT_WIDTHS.includes(e)},contentAppear:{type:Boolean,default:null},contentTabindex:{type:Number||null,default:-1},externalAnchor:{type:String,default:``},externalAnchorElement:{type:HTMLElement,default:null},id:{type:String,default(){return e.getUniqueString()}},offset:{type:Array,default:()=>[0,4]},hideOnClick:{type:Boolean,default:!0},modal:{type:Boolean,default:!0},fallbackPlacements:{type:Array,default:()=>[`auto`]},placement:{type:String,default:`bottom-end`},tether:{type:Boolean,default:!0},sticky:{type:[Boolean,String],default:!1,validator:e=>o.POPOVER_STICKY_VALUES.includes(e)},maxHeight:{type:String,default:``},maxWidth:{type:String,default:``},showCloseButton:{type:Boolean,default:!1},headerClass:{type:[String,Array,Object],default:``},footerClass:{type:[String,Array,Object],default:``},dialogClass:{type:[String,Array,Object],default:``},initialFocusElement:{type:[String,HTMLElement],default:`first`,validator:e=>o.POPOVER_INITIAL_FOCUS_STRINGS.includes(e)||e instanceof HTMLElement||e.startsWith(`#`)},openWithArrowKeys:{type:Boolean,default:!1},appendTo:{type:[HTMLElement,String],default:`body`,validator:e=>o.POPOVER_APPEND_TO_VALUES.includes(e)||e instanceof HTMLElement}},emits:[`keydown`,`update:open`,`opened`,`mouseenter-popover`,`mouseleave-popover`,`mouseenter-popover-anchor`,`mouseleave-popover-anchor`],data(){return{POPOVER_PADDING_CLASSES:o.POPOVER_PADDING_CLASSES,POPOVER_HEADER_FOOTER_PADDING_CLASSES:o.POPOVER_HEADER_FOOTER_PADDING_CLASSES,intersectionObserver:null,mutationObserver:null,isOutsideViewport:!1,isOpen:!1,toAppear:!1,anchorEl:null,popoverContentEl:null,hasSlotContent:e.hasSlotContent}},computed:{popoverListeners(){return{keydown:e=>{this.onKeydown(e)},"after-leave":()=>{this.onLeaveTransitionComplete()},"after-enter":()=>{this.onEnterTransitionComplete()}}},calculatedMaxHeight(){return this.isOutsideViewport&&this.modal?`calc(100vh - var(--dt-space-300))`:this.maxHeight},labelledBy(){return this.ariaLabelledby||!this.ariaLabel&&e.getUniqueString(`DtPopover__anchor`)}},watch:{$props:{immediate:!0,deep:!0,handler(){this.validateProps()}},modal(e){this.tip?.setProps({zIndex:e?650:this.calculateAnchorZindex()})},offset(e){this.tip?.setProps({offset:e})},sticky(e){this.tip?.setProps({sticky:e})},fallbackPlacements(){this.tip?.setProps({popperOptions:this.popperOptions()})},tether(){this.tip?.setProps({popperOptions:this.popperOptions()})},externalAnchorElement(){this.updateAnchorEl()},placement(e){this.tip?.setProps({placement:e})},open:{handler:function(e){e!==null&&(this.isOpen=e),e===!0&&(this.toAppear=!0)},immediate:!0},contentAppear:{handler:function(e){e!==null&&(this.toAppear=e)}},isOpen(e,t){e?(this.initTippyInstance(),this.tip?.show()):!e&&t!==e&&(this.removeEventListeners(),this.tip?.hide())}},mounted(){e.warnIfUnmounted(e.returnFirstEl(this.$el),this.$options.name),this.popoverContentEl=e.returnFirstEl(this.$refs.content?.$el),this.updateAnchorEl(),this.mutationObserver=new MutationObserver(this.updateAnchorEl),this.mutationObserver.observe(this.$refs.anchor,{childList:!0}),this.intersectionObserver=new IntersectionObserver(this.hasIntersectedViewport),this.intersectionObserver.observe(this.popoverContentEl)},beforeUnmount(){this._isUnmounting=!0,this.popoverContentEl&&(this.popoverContentEl.style.transition=`none`),this.tip?.destroy(),this.intersectionObserver?.disconnect(),this.mutationObserver?.disconnect(),this.removeReferences(),this.removeEventListeners()},methods:{hasIntersectedViewport(t){let n=t?.[0]?.target;if(!n)return;let r=e.isOutOfViewPort(n);this.isOutsideViewport=r.bottom||r.top},updateAnchorEl(){let e=(this.externalAnchorElement||(this.externalAnchor?this.$refs.anchor.getRootNode().querySelector(`#${this.externalAnchor}`):null))??this.$refs.anchor.children[0];if(e!==this.anchorEl){if(this.anchorEl=e,this.tip?.destroy(),delete this.tip,!this.anchorEl){console.warn(`No anchor found for popover`);return}this.isOpen&&(this.initTippyInstance(),this.tip?.show())}},popperOptions(){return a.getPopperOptions({fallbackPlacements:this.fallbackPlacements,tether:this.tether,hasHideModifierEnabled:!0})},validateProps(){this.modal&&this.initialFocusElement===`none`&&console.error(`If the popover is modal you must set the initialFocusElement prop. Possible values: "dialog", "first", HTMLElement`)},calculateAnchorZindex(){return e.returnFirstEl(this.$el).getRootNode().querySelector(`.d-modal[aria-hidden="false"], .d-modal--transparent[aria-hidden="false"]`)||this.anchorEl?.closest(`.d-zi-drawer`)?650:300},defaultToggleOpen(e){if(!this.openOnContext&&(this.open===null||this.open===void 0)){if(!this.anchorEl?.contains(e.target)&&!this.anchorEl?.isEqualNode(e.target)||this.anchorEl?.disabled)return;this.toggleOpen()}},async onContext(e){this.openOnContext&&(e.preventDefault(),this.isOpen=!0,await this.$nextTick(),this.tip?.setProps({placement:`right-start`,getReferenceClientRect:()=>({width:0,height:0,top:e.clientY,bottom:e.clientY,left:e.clientX,right:e.clientX})}))},toggleOpen(){this.isOpen=!this.isOpen},onArrowKeyPress(e){this.open===null&&(this.openWithArrowKeys&&this.anchorEl?.contains(e.target)&&(this.isOpen||(this.isOpen=!0)),this.$emit(`keydown`,e))},addEventListeners(){window.addEventListener(`dt-popover-close`,this.closePopover),this.contentWidth===`anchor`&&window.addEventListener(`resize`,this.onResize)},removeEventListeners(){window.removeEventListener(`dt-popover-close`,this.closePopover),this.contentWidth===`anchor`&&window.removeEventListener(`resize`,this.onResize)},closePopover(){this.isOpen=!1},preventScrolling(){if(this.modal){let t=this.anchorEl?.closest(`body, .tippy-box`);if(!t)return;t.tagName?.toLowerCase()===`body`?(e.disableRootScrolling(this.anchorEl.getRootNode().host),this.tip?.setProps({offset:this.offset})):t.classList.add(`d-zi-popover`)}},enableScrolling(){let t=this.anchorEl?.closest(`body, .tippy-box`);t&&(t.tagName?.toLowerCase()===`body`?(e.enableRootScrolling(this.anchorEl.getRootNode().host),this.tip?.setProps({offset:this.offset})):t.classList.remove(`d-zi-popover`))},removeReferences(){this.anchorEl=null,this.popoverContentEl=null,this.tip=null},async onShow(){this.contentWidth===`anchor`&&await this.setPopoverContentAnchorWidth(),this.contentWidth===null&&(this.popoverContentEl.style.width=`auto`),this.addEventListeners()},async onLeaveTransitionComplete(){if(!this._isUnmounting){if(this.modal){if(await this.focusFirstElement(this.$refs.anchor),this._isUnmounting||(await this.$nextTick(),this._isUnmounting))return;this.enableScrolling()}this._isUnmounting||(this.tip?.unmount(),this.$emit(`opened`,!1),this.open!==null&&this.$emit(`update:open`,!1))}},async onEnterTransitionComplete(){this._isUnmounting||(this.focusInitialElement(),await this.$nextTick(),!this._isUnmounting&&(this.preventScrolling(),this.$emit(`opened`,!0,this.$refs.popover__content),this.open!==null&&this.$emit(`update:open`,!0)))},focusInitialElement(){this.initialFocusElement===`dialog`&&e.returnFirstEl(this.$refs.content?.$el)?.focus(),this.initialFocusElement.startsWith(`#`)&&this.focusInitialElementById(),this.initialFocusElement===`first`&&this.focusFirstElementIfNeeded(this.$refs.popover__content),this.initialFocusElement instanceof HTMLElement&&this.initialFocusElement.focus()},focusInitialElementById(){let t=e.returnFirstEl(this.$refs.content?.$el)?.querySelector(this.initialFocusElement);t?t.focus():(console.warn(`Could not find the element specified in dt-popover prop "initialFocusElement". Defaulting to focusing the dialog.`),e.returnFirstEl(this.$refs.content?.$el)?.focus())},onResize(){this.closePopover()},onClickOutside(){this.hideOnClick&&(this.popoverContentEl?.querySelector(`.d-popover__anchor--opened`)||this.closePopover())},onKeydown(e){e.key===`Tab`&&this.modal&&this.focusTrappedTabPress(e,this.popoverContentEl),e.key===`Escape`&&this.closePopover(),this.$emit(`keydown`,e)},async setPopoverContentAnchorWidth(){await this.$nextTick(),this.popoverContentEl.style.width=`${this.anchorEl?.clientWidth}px`},focusFirstElementIfNeeded(t){this._getFocusableElements(t,!0).length===0?this.showCloseButton?this.$refs.popover__header?.focusCloseButton():e.returnFirstEl(this.$refs.content?.$el).focus():this.focusFirstElement(t)},getReferenceClientRect(e){let t=this.anchorEl?.getBoundingClientRect();if(this.appendTo!==`root`||e)return t;let n=this.anchorEl?.ownerDocument,r=(n?.defaultView||n?.parentWindow)?.frameElement;if(!r)return t;let i=r.getBoundingClientRect();return{width:t?.width,height:t?.height,top:i?.top+t?.top,left:i?.left+t?.left,right:i?.right+t?.right,bottom:i?.bottom+t?.bottom}},initTippyInstance(){let e=null,t=!1;switch(this.appendTo){case`body`:e=this.anchorEl?.getRootNode()?.querySelector(`body`);break;case`root`:try{e=window.parent.document.body}catch(n){console.error(`Could not attach the popover to iframe parent window: `,n),e=`parent`,t=!0}break;default:e=this.appendTo;break}this.tip?.destroy(),this.tip=a.createTippyPopover(this.anchorEl,{popperOptions:this.popperOptions(),contentElement:this.popoverContentEl,placement:this.placement,offset:this.offset,sticky:this.sticky,appendTo:e,interactive:!0,trigger:`manual`,getReferenceClientRect:()=>this.getReferenceClientRect(t),hideOnClick:!1,zIndex:this.modal?650:this.calculateAnchorZindex(),onClickOutside:this.onClickOutside,onShow:this.onShow})},onMouseEnter(){this.$emit(`mouseenter-popover`)},onMouseLeave(){this.$emit(`mouseleave-popover`)},onMouseEnterAnchor(){this.$emit(`mouseenter-popover-anchor`)},onMouseLeaveAnchor(){this.$emit(`mouseleave-popover-anchor`)}}},u=[`id`,`data-qa`,`tabindex`],d=[`data-qa`];function f(e,t,n,r,i,a){let o=(0,c.resolveComponent)(`popover-header-footer`),s=(0,c.resolveComponent)(`sr-only-close-button`),l=(0,c.resolveComponent)(`dt-lazy-show`);return(0,c.openBlock)(),(0,c.createElementBlock)(`div`,null,[n.modal&&i.isOpen?((0,c.openBlock)(),(0,c.createBlock)(c.Teleport,{key:0,to:`body`},[(0,c.createElementVNode)(`div`,{class:`d-modal--transparent`,"aria-hidden":`false`,onClick:t[0]||(t[0]=(0,c.withModifiers)(()=>{},[`prevent`,`stop`]))})])):(0,c.createCommentVNode)(``,!0),((0,c.openBlock)(),(0,c.createBlock)((0,c.resolveDynamicComponent)(n.elementType),{ref:`popover`,class:(0,c.normalizeClass)([`d-popover`,{"d-popover__anchor--opened":i.isOpen}]),"data-qa":`dt-popover-container`},{default:(0,c.withCtx)(()=>[(0,c.createElementVNode)(`div`,{id:!n.ariaLabelledby&&a.labelledBy,ref:`anchor`,"data-qa":e.$attrs[`data-qa`]?`${e.$attrs[`data-qa`]}-anchor`:`dt-popover-anchor`,tabindex:n.openOnContext?0:void 0,onClickCapture:t[1]||(t[1]=(...e)=>a.defaultToggleOpen&&a.defaultToggleOpen(...e)),onContextmenu:t[2]||(t[2]=(...e)=>a.onContext&&a.onContext(...e)),onKeydown:[t[3]||(t[3]=(0,c.withKeys)((0,c.withModifiers)((...e)=>a.onArrowKeyPress&&a.onArrowKeyPress(...e),[`prevent`]),[`up`])),t[4]||(t[4]=(0,c.withKeys)((0,c.withModifiers)((...e)=>a.onArrowKeyPress&&a.onArrowKeyPress(...e),[`prevent`]),[`down`])),t[6]||(t[6]=(0,c.withKeys)(t=>e.$emit(`keydown`,t),[`enter`])),t[7]||(t[7]=(0,c.withKeys)(t=>e.$emit(`keydown`,t),[`space`]))],onKeydownCapture:t[5]||(t[5]=(0,c.withKeys)((...e)=>a.closePopover&&a.closePopover(...e),[`escape`])),onMouseenter:t[8]||(t[8]=(...e)=>a.onMouseEnter&&a.onMouseEnter(...e)),onMouseleave:t[9]||(t[9]=(...e)=>a.onMouseLeave&&a.onMouseLeave(...e))},[(0,c.renderSlot)(e.$slots,`anchor`,{attrs:{"aria-expanded":i.isOpen.toString(),"aria-controls":n.id,"aria-haspopup":n.role}})],40,u),(0,c.createVNode)(l,(0,c.mergeProps)({id:n.id,ref:`content`,role:n.role,"data-qa":e.$attrs[`data-qa`]?`${e.$attrs[`data-qa`]}__dialog`:`dt-popover`,"aria-hidden":`${!i.isOpen}`,"aria-labelledby":a.labelledBy,"aria-label":n.ariaLabel,"aria-modal":`${!n.modal}`,transition:n.transition,show:i.isOpen,appear:i.toAppear,class:[`d-popover__dialog`,{"d-popover__dialog--modal":n.modal},n.dialogClass],style:{"max-height":a.calculatedMaxHeight,"max-width":n.maxWidth},css:e.$attrs.css,tabindex:n.contentTabindex},(0,c.toHandlers)(a.popoverListeners),{onMouseenter:a.onMouseEnterAnchor,onMouseleave:a.onMouseLeaveAnchor}),{default:(0,c.withCtx)(()=>[i.hasSlotContent(e.$slots.headerContent)||n.showCloseButton?((0,c.openBlock)(),(0,c.createBlock)(o,{key:0,ref:`popover__header`,class:(0,c.normalizeClass)(i.POPOVER_HEADER_FOOTER_PADDING_CLASSES[n.padding]),"content-class":n.headerClass,type:`header`,"show-close-button":n.showCloseButton,onClose:a.closePopover},{content:(0,c.withCtx)(()=>[(0,c.renderSlot)(e.$slots,`headerContent`,{close:a.closePopover})]),_:3},8,[`class`,`content-class`,`show-close-button`,`onClose`])):(0,c.createCommentVNode)(``,!0),(0,c.createElementVNode)(`div`,{ref:`popover__content`,"data-qa":e.$attrs[`data-qa`]?`${e.$attrs[`data-qa`]}-content`:`dt-popover-content`,class:(0,c.normalizeClass)([`d-popover__content`,i.POPOVER_PADDING_CLASSES[n.padding],n.contentClass])},[(0,c.renderSlot)(e.$slots,`content`,{close:a.closePopover})],10,d),i.hasSlotContent(e.$slots.footerContent)?((0,c.openBlock)(),(0,c.createBlock)(o,{key:1,ref:`popover__footer`,type:`footer`,class:(0,c.normalizeClass)(i.POPOVER_HEADER_FOOTER_PADDING_CLASSES[n.padding]),"content-class":n.footerClass},{content:(0,c.withCtx)(()=>[(0,c.renderSlot)(e.$slots,`footerContent`,{close:a.closePopover})]),_:3},8,[`class`,`content-class`])):(0,c.createCommentVNode)(``,!0),n.showCloseButton?(0,c.createCommentVNode)(``,!0):((0,c.openBlock)(),(0,c.createBlock)(s,{key:2,onClose:a.closePopover},null,8,[`onClose`]))]),_:3},16,[`id`,`role`,`data-qa`,`aria-hidden`,`aria-labelledby`,`aria-label`,`aria-modal`,`transition`,`show`,`appear`,`class`,`style`,`css`,`tabindex`,`onMouseenter`,`onMouseleave`])]),_:3},8,[`class`]))])}var p=t.t(l,[[`render`,f]]);exports.default=p;
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}}),require(`../../chunk-Bmb41Sf3.cjs`);const e=require(`../../common/constants/index.cjs`),t=require(`../../common/utils/index.cjs`),n=require(`../../_plugin-vue_export-helper-D8jCH6HB.cjs`),r=require(`../../common/mixins/modal.cjs`),i=require(`../../shared/sr_only_close_button.cjs`),a=require(`../lazy-show/lazy-show.cjs`),o=require(`./tippy-utils.cjs`),s=require(`./popover-constants.cjs`),c=require(`./popover-header-footer.cjs`);let l=require(`vue`);var u={compatConfig:{MODE:3},name:`DtPopover`,components:{SrOnlyCloseButton:i.default,DtLazyShow:a.default,PopoverHeaderFooter:c.default},mixins:[r.default],props:{open:{type:Boolean,default:null},openOnContext:{type:Boolean,default:!1},elementType:{type:String,default:`div`},transition:{type:String,default:`fade`},role:{type:String,default:`dialog`,validator:e=>s.POPOVER_ROLES.includes(e)},ariaLabelledby:{type:String,default:null},ariaLabel:{type:String,default:null},padding:{type:String,default:`large`,validator:e=>Object.keys(s.POPOVER_PADDING_CLASSES).some(t=>t===e)},contentClass:{type:[String,Array,Object],default:``},contentWidth:{type:String,default:``,validator:e=>s.POPOVER_CONTENT_WIDTHS.includes(e)},contentAppear:{type:Boolean,default:null},contentTabindex:{type:Number||null,default:-1},externalAnchor:{type:String,default:``},externalAnchorElement:{type:e.HTML_ELEMENT_TYPE,default:null},id:{type:String,default(){return t.getUniqueString()}},offset:{type:Array,default:()=>[0,4]},hideOnClick:{type:Boolean,default:!0},modal:{type:Boolean,default:!0},fallbackPlacements:{type:Array,default:()=>[`auto`]},placement:{type:String,default:`bottom-end`},tether:{type:Boolean,default:!0},sticky:{type:[Boolean,String],default:!1,validator:e=>s.POPOVER_STICKY_VALUES.includes(e)},maxHeight:{type:String,default:``},maxWidth:{type:String,default:``},showCloseButton:{type:Boolean,default:!1},headerClass:{type:[String,Array,Object],default:``},footerClass:{type:[String,Array,Object],default:``},dialogClass:{type:[String,Array,Object],default:``},initialFocusElement:{type:[String,e.HTML_ELEMENT_TYPE],default:`first`,validator:e=>s.POPOVER_INITIAL_FOCUS_STRINGS.includes(e)||e instanceof HTMLElement||e.startsWith(`#`)},openWithArrowKeys:{type:Boolean,default:!1},appendTo:{type:[e.HTML_ELEMENT_TYPE,String],default:`body`,validator:e=>s.POPOVER_APPEND_TO_VALUES.includes(e)||e instanceof HTMLElement}},emits:[`keydown`,`update:open`,`opened`,`mouseenter-popover`,`mouseleave-popover`,`mouseenter-popover-anchor`,`mouseleave-popover-anchor`],data(){return{POPOVER_PADDING_CLASSES:s.POPOVER_PADDING_CLASSES,POPOVER_HEADER_FOOTER_PADDING_CLASSES:s.POPOVER_HEADER_FOOTER_PADDING_CLASSES,intersectionObserver:null,mutationObserver:null,isOutsideViewport:!1,isOpen:!1,toAppear:!1,anchorEl:null,popoverContentEl:null,hasSlotContent:t.hasSlotContent}},computed:{popoverListeners(){return{keydown:e=>{this.onKeydown(e)},"after-leave":()=>{this.onLeaveTransitionComplete()},"after-enter":()=>{this.onEnterTransitionComplete()}}},calculatedMaxHeight(){return this.isOutsideViewport&&this.modal?`calc(100vh - var(--dt-space-300))`:this.maxHeight},labelledBy(){return this.ariaLabelledby||!this.ariaLabel&&t.getUniqueString(`DtPopover__anchor`)}},watch:{$props:{immediate:!0,deep:!0,handler(){this.validateProps()}},modal(e){this.tip?.setProps({zIndex:e?650:this.calculateAnchorZindex()})},offset(e){this.tip?.setProps({offset:e})},sticky(e){this.tip?.setProps({sticky:e})},fallbackPlacements(){this.tip?.setProps({popperOptions:this.popperOptions()})},tether(){this.tip?.setProps({popperOptions:this.popperOptions()})},externalAnchorElement(){this.updateAnchorEl()},placement(e){this.tip?.setProps({placement:e})},open:{handler:function(e){e!==null&&(this.isOpen=e),e===!0&&(this.toAppear=!0)},immediate:!0},contentAppear:{handler:function(e){e!==null&&(this.toAppear=e)}},isOpen(e,t){e?(this.initTippyInstance(),this.tip?.show()):!e&&t!==e&&(this.removeEventListeners(),this.tip?.hide())}},mounted(){t.warnIfUnmounted(t.returnFirstEl(this.$el),this.$options.name),this.popoverContentEl=t.returnFirstEl(this.$refs.content?.$el),this.updateAnchorEl(),this.mutationObserver=new MutationObserver(this.updateAnchorEl),this.mutationObserver.observe(this.$refs.anchor,{childList:!0}),this.intersectionObserver=new IntersectionObserver(this.hasIntersectedViewport),this.intersectionObserver.observe(this.popoverContentEl)},beforeUnmount(){this._isUnmounting=!0,this.popoverContentEl&&(this.popoverContentEl.style.transition=`none`),this.tip?.destroy(),this.intersectionObserver?.disconnect(),this.mutationObserver?.disconnect(),this.removeReferences(),this.removeEventListeners()},methods:{hasIntersectedViewport(e){let n=e?.[0]?.target;if(!n)return;let r=t.isOutOfViewPort(n);this.isOutsideViewport=r.bottom||r.top},updateAnchorEl(){let e=(this.externalAnchorElement||(this.externalAnchor?this.$refs.anchor.getRootNode().querySelector(`#${this.externalAnchor}`):null))??this.$refs.anchor.children[0];if(e!==this.anchorEl){if(this.anchorEl=e,this.tip?.destroy(),delete this.tip,!this.anchorEl){console.warn(`No anchor found for popover`);return}this.isOpen&&(this.initTippyInstance(),this.tip?.show())}},popperOptions(){return o.getPopperOptions({fallbackPlacements:this.fallbackPlacements,tether:this.tether,hasHideModifierEnabled:!0})},validateProps(){this.modal&&this.initialFocusElement===`none`&&console.error(`If the popover is modal you must set the initialFocusElement prop. Possible values: "dialog", "first", HTMLElement`)},calculateAnchorZindex(){return t.returnFirstEl(this.$el).getRootNode().querySelector(`.d-modal[aria-hidden="false"], .d-modal--transparent[aria-hidden="false"]`)||this.anchorEl?.closest(`.d-zi-drawer`)?650:300},defaultToggleOpen(e){if(!this.openOnContext&&(this.open===null||this.open===void 0)){if(!this.anchorEl?.contains(e.target)&&!this.anchorEl?.isEqualNode(e.target)||this.anchorEl?.disabled)return;this.toggleOpen()}},async onContext(e){this.openOnContext&&(e.preventDefault(),this.isOpen=!0,await this.$nextTick(),this.tip?.setProps({placement:`right-start`,getReferenceClientRect:()=>({width:0,height:0,top:e.clientY,bottom:e.clientY,left:e.clientX,right:e.clientX})}))},toggleOpen(){this.isOpen=!this.isOpen},onArrowKeyPress(e){this.open===null&&(this.openWithArrowKeys&&this.anchorEl?.contains(e.target)&&(this.isOpen||(this.isOpen=!0)),this.$emit(`keydown`,e))},addEventListeners(){window.addEventListener(`dt-popover-close`,this.closePopover),this.contentWidth===`anchor`&&window.addEventListener(`resize`,this.onResize)},removeEventListeners(){window.removeEventListener(`dt-popover-close`,this.closePopover),this.contentWidth===`anchor`&&window.removeEventListener(`resize`,this.onResize)},closePopover(){this.isOpen=!1},preventScrolling(){if(this.modal){let e=this.anchorEl?.closest(`body, .tippy-box`);if(!e)return;e.tagName?.toLowerCase()===`body`?(t.disableRootScrolling(this.anchorEl.getRootNode().host),this.tip?.setProps({offset:this.offset})):e.classList.add(`d-zi-popover`)}},enableScrolling(){let e=this.anchorEl?.closest(`body, .tippy-box`);e&&(e.tagName?.toLowerCase()===`body`?(t.enableRootScrolling(this.anchorEl.getRootNode().host),this.tip?.setProps({offset:this.offset})):e.classList.remove(`d-zi-popover`))},removeReferences(){this.anchorEl=null,this.popoverContentEl=null,this.tip=null},async onShow(){this.contentWidth===`anchor`&&(await this.setPopoverContentAnchorWidth(),this._isUnmounting)||(this.contentWidth===null&&(this.popoverContentEl.style.width=`auto`),this.addEventListeners())},async onLeaveTransitionComplete(){if(!this._isUnmounting){if(this.modal){if(await this.focusFirstElement(this.$refs.anchor),this._isUnmounting||(await this.$nextTick(),this._isUnmounting))return;this.enableScrolling()}this._isUnmounting||(this.tip?.unmount(),this.$emit(`opened`,!1),this.open!==null&&this.$emit(`update:open`,!1))}},async onEnterTransitionComplete(){this._isUnmounting||(this.focusInitialElement(),await this.$nextTick(),!this._isUnmounting&&(this.preventScrolling(),this.$emit(`opened`,!0,this.$refs.popover__content),this.open!==null&&this.$emit(`update:open`,!0)))},focusInitialElement(){this.initialFocusElement===`dialog`&&t.returnFirstEl(this.$refs.content?.$el)?.focus(),this.initialFocusElement.startsWith(`#`)&&this.focusInitialElementById(),this.initialFocusElement===`first`&&this.focusFirstElementIfNeeded(this.$refs.popover__content),this.initialFocusElement instanceof HTMLElement&&this.initialFocusElement.focus()},focusInitialElementById(){let e=t.returnFirstEl(this.$refs.content?.$el)?.querySelector(this.initialFocusElement);e?e.focus():(console.warn(`Could not find the element specified in dt-popover prop "initialFocusElement". Defaulting to focusing the dialog.`),t.returnFirstEl(this.$refs.content?.$el)?.focus())},onResize(){this.closePopover()},onClickOutside(){this.hideOnClick&&(this.popoverContentEl?.querySelector(`.d-popover__anchor--opened`)||this.closePopover())},onKeydown(e){e.key===`Tab`&&this.modal&&this.focusTrappedTabPress(e,this.popoverContentEl),e.key===`Escape`&&this.closePopover(),this.$emit(`keydown`,e)},async setPopoverContentAnchorWidth(){await this.$nextTick(),this.popoverContentEl.style.width=`${this.anchorEl?.clientWidth}px`},focusFirstElementIfNeeded(e){this._getFocusableElements(e,!0).length===0?this.showCloseButton?this.$refs.popover__header?.focusCloseButton():t.returnFirstEl(this.$refs.content?.$el).focus():this.focusFirstElement(e)},getReferenceClientRect(e){let t=this.anchorEl?.getBoundingClientRect();if(this.appendTo!==`root`||e)return t;let n=this.anchorEl?.ownerDocument,r=(n?.defaultView||n?.parentWindow)?.frameElement;if(!r)return t;let i=r.getBoundingClientRect();return{width:t?.width,height:t?.height,top:i?.top+t?.top,left:i?.left+t?.left,right:i?.right+t?.right,bottom:i?.bottom+t?.bottom}},initTippyInstance(){let e=null,t=!1;switch(this.appendTo){case`body`:e=this.anchorEl?.getRootNode()?.querySelector(`body`);break;case`root`:try{e=window.parent.document.body}catch(n){console.error(`Could not attach the popover to iframe parent window: `,n),e=`parent`,t=!0}break;default:e=this.appendTo;break}this.tip?.destroy(),this.tip=o.createTippyPopover(this.anchorEl,{popperOptions:this.popperOptions(),contentElement:this.popoverContentEl,placement:this.placement,offset:this.offset,sticky:this.sticky,appendTo:e,interactive:!0,trigger:`manual`,getReferenceClientRect:()=>this.getReferenceClientRect(t),hideOnClick:!1,zIndex:this.modal?650:this.calculateAnchorZindex(),onClickOutside:this.onClickOutside,onShow:this.onShow})},onMouseEnter(){this.$emit(`mouseenter-popover`)},onMouseLeave(){this.$emit(`mouseleave-popover`)},onMouseEnterAnchor(){this.$emit(`mouseenter-popover-anchor`)},onMouseLeaveAnchor(){this.$emit(`mouseleave-popover-anchor`)}}},d=[`id`,`data-qa`,`tabindex`],f=[`data-qa`];function p(e,t,n,r,i,a){let o=(0,l.resolveComponent)(`popover-header-footer`),s=(0,l.resolveComponent)(`sr-only-close-button`),c=(0,l.resolveComponent)(`dt-lazy-show`);return(0,l.openBlock)(),(0,l.createElementBlock)(`div`,null,[n.modal&&i.isOpen?((0,l.openBlock)(),(0,l.createBlock)(l.Teleport,{key:0,to:`body`},[(0,l.createElementVNode)(`div`,{class:`d-modal--transparent`,"aria-hidden":`false`,onClick:t[0]||(t[0]=(0,l.withModifiers)(()=>{},[`prevent`,`stop`]))})])):(0,l.createCommentVNode)(``,!0),((0,l.openBlock)(),(0,l.createBlock)((0,l.resolveDynamicComponent)(n.elementType),{ref:`popover`,class:(0,l.normalizeClass)([`d-popover`,{"d-popover__anchor--opened":i.isOpen}]),"data-qa":`dt-popover-container`},{default:(0,l.withCtx)(()=>[(0,l.createElementVNode)(`div`,{id:!n.ariaLabelledby&&a.labelledBy,ref:`anchor`,"data-qa":e.$attrs[`data-qa`]?`${e.$attrs[`data-qa`]}-anchor`:`dt-popover-anchor`,tabindex:n.openOnContext?0:void 0,onClickCapture:t[1]||(t[1]=(...e)=>a.defaultToggleOpen&&a.defaultToggleOpen(...e)),onContextmenu:t[2]||(t[2]=(...e)=>a.onContext&&a.onContext(...e)),onKeydown:[t[3]||(t[3]=(0,l.withKeys)((0,l.withModifiers)((...e)=>a.onArrowKeyPress&&a.onArrowKeyPress(...e),[`prevent`]),[`up`])),t[4]||(t[4]=(0,l.withKeys)((0,l.withModifiers)((...e)=>a.onArrowKeyPress&&a.onArrowKeyPress(...e),[`prevent`]),[`down`])),t[6]||(t[6]=(0,l.withKeys)(t=>e.$emit(`keydown`,t),[`enter`])),t[7]||(t[7]=(0,l.withKeys)(t=>e.$emit(`keydown`,t),[`space`]))],onKeydownCapture:t[5]||(t[5]=(0,l.withKeys)((...e)=>a.closePopover&&a.closePopover(...e),[`escape`])),onMouseenter:t[8]||(t[8]=(...e)=>a.onMouseEnter&&a.onMouseEnter(...e)),onMouseleave:t[9]||(t[9]=(...e)=>a.onMouseLeave&&a.onMouseLeave(...e))},[(0,l.renderSlot)(e.$slots,`anchor`,{attrs:{"aria-expanded":i.isOpen.toString(),"aria-controls":n.id,"aria-haspopup":n.role}})],40,d),(0,l.createVNode)(c,(0,l.mergeProps)({id:n.id,ref:`content`,role:n.role,"data-qa":e.$attrs[`data-qa`]?`${e.$attrs[`data-qa`]}__dialog`:`dt-popover`,"aria-hidden":`${!i.isOpen}`,"aria-labelledby":a.labelledBy,"aria-label":n.ariaLabel,"aria-modal":`${!n.modal}`,transition:n.transition,show:i.isOpen,appear:i.toAppear,class:[`d-popover__dialog`,{"d-popover__dialog--modal":n.modal},n.dialogClass],style:{"max-height":a.calculatedMaxHeight,"max-width":n.maxWidth},css:e.$attrs.css,tabindex:n.contentTabindex},(0,l.toHandlers)(a.popoverListeners),{onMouseenter:a.onMouseEnterAnchor,onMouseleave:a.onMouseLeaveAnchor}),{default:(0,l.withCtx)(()=>[i.hasSlotContent(e.$slots.headerContent)||n.showCloseButton?((0,l.openBlock)(),(0,l.createBlock)(o,{key:0,ref:`popover__header`,class:(0,l.normalizeClass)(i.POPOVER_HEADER_FOOTER_PADDING_CLASSES[n.padding]),"content-class":n.headerClass,type:`header`,"show-close-button":n.showCloseButton,onClose:a.closePopover},{content:(0,l.withCtx)(()=>[(0,l.renderSlot)(e.$slots,`headerContent`,{close:a.closePopover})]),_:3},8,[`class`,`content-class`,`show-close-button`,`onClose`])):(0,l.createCommentVNode)(``,!0),(0,l.createElementVNode)(`div`,{ref:`popover__content`,"data-qa":e.$attrs[`data-qa`]?`${e.$attrs[`data-qa`]}-content`:`dt-popover-content`,class:(0,l.normalizeClass)([`d-popover__content`,i.POPOVER_PADDING_CLASSES[n.padding],n.contentClass])},[(0,l.renderSlot)(e.$slots,`content`,{close:a.closePopover})],10,f),i.hasSlotContent(e.$slots.footerContent)?((0,l.openBlock)(),(0,l.createBlock)(o,{key:1,ref:`popover__footer`,type:`footer`,class:(0,l.normalizeClass)(i.POPOVER_HEADER_FOOTER_PADDING_CLASSES[n.padding]),"content-class":n.footerClass},{content:(0,l.withCtx)(()=>[(0,l.renderSlot)(e.$slots,`footerContent`,{close:a.closePopover})]),_:3},8,[`class`,`content-class`])):(0,l.createCommentVNode)(``,!0),n.showCloseButton?(0,l.createCommentVNode)(``,!0):((0,l.openBlock)(),(0,l.createBlock)(s,{key:2,onClose:a.closePopover},null,8,[`onClose`]))]),_:3},16,[`id`,`role`,`data-qa`,`aria-hidden`,`aria-labelledby`,`aria-label`,`aria-modal`,`transition`,`show`,`appear`,`class`,`style`,`css`,`tabindex`,`onMouseenter`,`onMouseleave`])]),_:3},8,[`class`]))])}var m=n.t(u,[[`render`,p]]);exports.default=m;
|
|
2
2
|
//# sourceMappingURL=popover.cjs.map
|