@voicenter-team/voicenter-ui-plus 3.0.4 → 3.0.5

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.
@@ -7,7 +7,8 @@ import _sfc_main$3 from "../VcPopover/VcConfirmPopover.vue.mjs";
7
7
  const _sfc_main = /* @__PURE__ */ defineComponent({
8
8
  __name: "VcPluginOverlays",
9
9
  props: {
10
- notifications: { default: "default" }
10
+ notifications: { default: "default" },
11
+ appendTo: { default: "body" }
11
12
  },
12
13
  setup(__props) {
13
14
  const props = __props;
@@ -22,16 +23,20 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
22
23
  }
23
24
  return (_ctx, _cache) => {
24
25
  return openBlock(), createElementBlock(Fragment, null, [
25
- shouldRenderDefaultNotification.value ? (openBlock(), createBlock(_sfc_main$1, { key: 0 })) : createCommentVNode("", true),
26
+ shouldRenderDefaultNotification.value ? (openBlock(), createBlock(_sfc_main$1, {
27
+ key: 0,
28
+ "teleported-to": __props.appendTo
29
+ }, null, 8, ["teleported-to"])) : createCommentVNode("", true),
26
30
  (openBlock(true), createElementBlock(Fragment, null, renderList(notificationHosts.value, (item, index) => {
27
31
  return openBlock(), createBlock(_sfc_main$1, {
28
32
  key: notificationHostKey(item, index),
29
33
  group: item.group,
30
- position: item.position
31
- }, null, 8, ["group", "position"]);
34
+ position: item.position,
35
+ "teleported-to": __props.appendTo
36
+ }, null, 8, ["group", "position", "teleported-to"]);
32
37
  }), 128)),
33
- createVNode(_sfc_main$2),
34
- createVNode(_sfc_main$3)
38
+ createVNode(_sfc_main$2, { "append-to": __props.appendTo }, null, 8, ["append-to"]),
39
+ createVNode(_sfc_main$3, { "append-to": __props.appendTo }, null, 8, ["append-to"])
35
40
  ], 64);
36
41
  };
37
42
  }
@@ -21,7 +21,8 @@ const DEFAULT_PLACEMENT = "bottom-start";
21
21
  const _sfc_main = /* @__PURE__ */ defineComponent({
22
22
  __name: "VcConfirmPopover",
23
23
  props: {
24
- options: { default: () => ({}) }
24
+ options: { default: () => ({}) },
25
+ appendTo: { default: "body" }
25
26
  },
26
27
  emits: ["close", "confirm"],
27
28
  setup(__props, { expose: __expose, emit: __emit }) {
@@ -170,6 +171,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
170
171
  placement: placement.value,
171
172
  "popper-class": [BASE_CLASS, popoverOptions.value.popoverClass].join(" "),
172
173
  teleported: popoverOptions.value.teleported,
174
+ "append-to": __props.appendTo,
173
175
  "gpu-acceleration": false,
174
176
  "stop-popper-mouse-event": popoverOptions.value.mouseEvent,
175
177
  offset: popoverOptions.value.offset,
@@ -233,7 +235,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
233
235
  ])
234
236
  ]),
235
237
  _: 1
236
- }, 8, ["visible", "virtual-ref", "effect", "persistent", "placement", "popper-class", "teleported", "stop-popper-mouse-event", "offset", "hide-after"])) : createCommentVNode("", true);
238
+ }, 8, ["visible", "virtual-ref", "effect", "persistent", "placement", "popper-class", "teleported", "append-to", "stop-popper-mouse-event", "offset", "hide-after"])) : createCommentVNode("", true);
237
239
  };
238
240
  }
239
241
  });
@@ -323,9 +323,15 @@ const install = function installCore(app, config) {
323
323
  }
324
324
  loadTextFont();
325
325
  if ((config == null ? void 0 : config.mountOverlays) !== false) {
326
- mountPluginOverlays(app, _sfc_main$y, {
327
- notifications: (config == null ? void 0 : config.overlayNotifications) ?? "default"
328
- });
326
+ mountPluginOverlays(
327
+ app,
328
+ _sfc_main$y,
329
+ {
330
+ notifications: (config == null ? void 0 : config.overlayNotifications) ?? "default",
331
+ appendTo: (config == null ? void 0 : config.overlayAppendTo) ?? "body"
332
+ },
333
+ config == null ? void 0 : config.overlayContainer
334
+ );
329
335
  }
330
336
  };
331
337
  export {
Binary file
Binary file
@@ -1,12 +1,16 @@
1
1
  import type { OverlayNotificationsConfig } from '../../types/Overlay.types';
2
2
  interface IProps {
3
3
  notifications?: OverlayNotificationsConfig;
4
+ appendTo?: string | HTMLElement;
4
5
  }
5
6
  declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<IProps>, {
6
7
  notifications: string;
8
+ appendTo: string;
7
9
  }>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<IProps>, {
8
10
  notifications: string;
11
+ appendTo: string;
9
12
  }>>> & Readonly<{}>, {
13
+ appendTo: string | HTMLElement;
10
14
  notifications: OverlayNotificationsConfig;
11
15
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
12
16
  export default _default;
@@ -2,12 +2,18 @@ import { TPopConfirmOptions } from '../../types';
2
2
  import type { TIcon } from '../../types/icons.types';
3
3
  interface IProps {
4
4
  options?: TPopConfirmOptions;
5
+ /**
6
+ * Teleport target for the popover content. Defaults to `'body'`. Pass an
7
+ * element inside a shadow root so the popover renders within the shadow DOM.
8
+ */
9
+ appendTo?: string | HTMLElement;
5
10
  }
6
11
  declare function clickOutside(evt: Event): void;
7
12
  declare function onCancel(): void;
8
13
  declare function onConfirm(): void;
9
14
  declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<IProps>, {
10
15
  options: () => {};
16
+ appendTo: string;
11
17
  }>>, {
12
18
  onConfirm: typeof onConfirm;
13
19
  onCancel: typeof onCancel;
@@ -29,11 +35,13 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
29
35
  confirm: () => void;
30
36
  }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<IProps>, {
31
37
  options: () => {};
38
+ appendTo: string;
32
39
  }>>> & Readonly<{
33
40
  onConfirm?: (() => any) | undefined;
34
41
  onClose?: (() => any) | undefined;
35
42
  }>, {
36
43
  options: TPopConfirmOptions;
44
+ appendTo: string | HTMLElement;
37
45
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
38
46
  export default _default;
39
47
  type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
@@ -25,4 +25,19 @@ export declare type UIConfig = {
25
25
  * - array — multiple `{ group, position }` hosts (pass matching `group` in `$notify.add`)
26
26
  */
27
27
  overlayNotifications?: OverlayNotificationsConfig;
28
+ /**
29
+ * Teleport target for the auto-mounted overlays (confirm modal, confirm
30
+ * popover, notifications). Defaults to `'body'`. Pass an element inside a
31
+ * shadow root (custom-element / web-component hosts) so the overlays render
32
+ * INSIDE the shadow DOM and pick up its scoped styles, instead of escaping
33
+ * to `document.body`.
34
+ */
35
+ overlayAppendTo?: string | HTMLElement;
36
+ /**
37
+ * Where to append the overlay host element that `VcPluginOverlays` mounts
38
+ * into. Defaults to `document.body`. For shadow-DOM hosts pass the shadow
39
+ * root (or an element inside it) so the overlay host itself lives within
40
+ * the shadow tree.
41
+ */
42
+ overlayContainer?: Element | DocumentFragment;
28
43
  };
@@ -12,4 +12,11 @@ export type OverlayNotificationHost = {
12
12
  export type OverlayNotificationsConfig = 'default' | 'none' | OverlayNotificationHost[];
13
13
  export type VcPluginOverlaysProps = {
14
14
  notifications?: OverlayNotificationsConfig;
15
+ /**
16
+ * Teleport target for the overlay hosts (confirm modal, confirm popover,
17
+ * notifications). Defaults to `'body'`. Pass an element inside a shadow
18
+ * root so the overlays render INSIDE the shadow DOM (custom-element hosts)
19
+ * and inherit its scoped styles.
20
+ */
21
+ appendTo?: string | HTMLElement;
15
22
  };
@@ -1,10 +1,16 @@
1
1
  import type { App, Component } from 'vue';
2
2
  /**
3
3
  * Mounts singleton overlay components (confirm modal/popover, notifications)
4
- * into `document.body` with the consumer app's context so globally registered
5
- * components, directives, i18n, and provide/inject all resolve correctly.
4
+ * with the consumer app's context so globally registered components,
5
+ * directives, i18n, and provide/inject all resolve correctly.
6
+ *
7
+ * The host element is appended to `container` (defaults to `document.body`).
8
+ * For shadow-DOM / custom-element hosts pass the shadow root (or an element
9
+ * inside it) so the overlays live within the shadow tree and inherit its
10
+ * scoped styles — pair it with the `appendTo` prop so the teleported content
11
+ * stays inside the same root.
6
12
  *
7
13
  * Plugin mode calls this automatically. Tree-shake consumers can either mount
8
14
  * `<VcPluginOverlays />` in App.vue or call this helper after `createApp`.
9
15
  */
10
- export declare function mountPluginOverlays(app: App, component: Component, props?: Record<string, unknown>): () => void;
16
+ export declare function mountPluginOverlays(app: App, component: Component, props?: Record<string, unknown>, container?: Element | DocumentFragment): () => void;
@@ -1,22 +1,24 @@
1
1
  import { createVNode, render } from "vue";
2
2
  const HOST_ATTR = "data-vc-plugin-overlays";
3
- function mountPluginOverlays(app, component, props) {
3
+ function mountPluginOverlays(app, component, props, container) {
4
4
  if (typeof document === "undefined") {
5
5
  return () => {
6
6
  };
7
7
  }
8
- let container = document.querySelector(`[${HOST_ATTR}]`);
9
- if (!container) {
10
- container = document.createElement("div");
11
- container.setAttribute(HOST_ATTR, "");
12
- document.body.appendChild(container);
8
+ const mountRoot = container ?? document.body;
9
+ let existingHost = mountRoot.querySelector(`[${HOST_ATTR}]`);
10
+ if (!existingHost) {
11
+ existingHost = document.createElement("div");
12
+ existingHost.setAttribute(HOST_ATTR, "");
13
+ mountRoot.appendChild(existingHost);
13
14
  }
15
+ const host = existingHost;
14
16
  const vnode = createVNode(component, props);
15
17
  vnode.appContext = app._context;
16
- render(vnode, container);
18
+ render(vnode, host);
17
19
  return () => {
18
- render(null, container);
19
- container.remove();
20
+ render(null, host);
21
+ host.remove();
20
22
  };
21
23
  }
22
24
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voicenter-team/voicenter-ui-plus",
3
- "version": "3.0.4",
3
+ "version": "3.0.5",
4
4
  "scripts": {
5
5
  "dev": "vite",
6
6
  "build": "vite build",