@v-c/dialog 1.1.1 → 1.2.0

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.
@@ -345,6 +345,11 @@ var Panel = /* @__PURE__ */ defineComponent((props, { expose, slots }) => {
345
345
  required: false,
346
346
  default: void 0
347
347
  },
348
+ scrollLock: {
349
+ type: Boolean,
350
+ required: false,
351
+ default: void 0
352
+ },
348
353
  panelRef: {
349
354
  required: false,
350
355
  default: void 0
@@ -306,6 +306,11 @@ var Content = /* @__PURE__ */ defineComponent((props, { slots }) => {
306
306
  required: false,
307
307
  default: void 0
308
308
  },
309
+ scrollLock: {
310
+ type: Boolean,
311
+ required: false,
312
+ default: void 0
313
+ },
309
314
  panelRef: {
310
315
  required: false,
311
316
  default: void 0
@@ -353,6 +353,11 @@ var Dialog = /* @__PURE__ */ defineComponent((props, { expose, slots }) => {
353
353
  required: false,
354
354
  default: void 0
355
355
  },
356
+ scrollLock: {
357
+ type: Boolean,
358
+ required: false,
359
+ default: void 0
360
+ },
356
361
  panelRef: {
357
362
  required: false,
358
363
  default: void 0
@@ -17,15 +17,16 @@ var DialogWrap = /* @__PURE__ */ defineComponent((props, { slots }) => {
17
17
  if (props.visible) animatedVisible.value = true;
18
18
  }, { immediate: true });
19
19
  return () => {
20
- const { visible, getContainer, forceRender, destroyOnHidden = false, afterClose } = props;
20
+ const { visible, getContainer, forceRender, destroyOnHidden = false, scrollLock = true, afterClose } = props;
21
+ const { scrollLock: _, ...restProps } = props;
21
22
  if (!forceRender && destroyOnHidden && !animatedVisible.value) return null;
22
23
  return createVNode(Portal, {
23
24
  "open": visible || forceRender || animatedVisible.value,
24
25
  "autoDestroy": false,
25
26
  "onEsc": onEsc,
26
27
  "getContainer": getContainer,
27
- "autoLock": visible || animatedVisible.value
28
- }, { default: () => [createVNode(Dialog, mergeProps(props, {
28
+ "autoLock": scrollLock && (visible || animatedVisible.value)
29
+ }, { default: () => [createVNode(Dialog, mergeProps(restProps, {
29
30
  "destroyOnHidden": destroyOnHidden,
30
31
  "afterClose": () => {
31
32
  (props.closable && typeof props.closable === "object" ? props.closable : {}).afterClose?.();
@@ -268,6 +269,11 @@ var DialogWrap = /* @__PURE__ */ defineComponent((props, { slots }) => {
268
269
  required: false,
269
270
  default: void 0
270
271
  },
272
+ scrollLock: {
273
+ type: Boolean,
274
+ required: false,
275
+ default: void 0
276
+ },
271
277
  panelRef: {
272
278
  required: false,
273
279
  default: void 0
@@ -4,11 +4,11 @@ import { CSSProperties } from 'vue';
4
4
  export type SemanticName = 'header' | 'body' | 'footer' | 'container' | 'title' | 'wrapper' | 'mask' | 'close';
5
5
  export type ModalClassNames = Partial<Record<SemanticName, string>>;
6
6
  export type ModalStyles = Partial<Record<SemanticName, CSSProperties>>;
7
- export type ClosableType = {
7
+ export interface ClosableType {
8
8
  closeIcon?: VueNode;
9
9
  disabled?: boolean;
10
10
  afterClose?: () => any;
11
- };
11
+ }
12
12
  export interface IDialogPropTypes {
13
13
  className?: string;
14
14
  keyboard?: boolean;
@@ -53,5 +53,7 @@ export interface IDialogPropTypes {
53
53
  forceRender?: boolean;
54
54
  focusTriggerAfterClose?: boolean;
55
55
  focusTrap?: boolean;
56
+ /** Control whether to lock body scroll when modal opens. Default is true. */
57
+ scrollLock?: boolean;
56
58
  panelRef?: any;
57
59
  }
package/dist/util.js CHANGED
@@ -5,6 +5,7 @@ function getMotionName(prefixCls, transitionName, animationName) {
5
5
  return motionName;
6
6
  }
7
7
  function getScroll(w, top) {
8
+ if (!w) return 0;
8
9
  let ret = w[`page${top ? "Y" : "X"}Offset`];
9
10
  const method = `scroll${top ? "Top" : "Left"}`;
10
11
  if (typeof ret !== "number") {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@v-c/dialog",
3
3
  "type": "module",
4
- "version": "1.1.1",
4
+ "version": "1.2.0",
5
5
  "exports": {
6
6
  ".": {
7
7
  "types": "./dist/index.d.ts",
@@ -25,8 +25,8 @@
25
25
  "vue": "^3.0.0"
26
26
  },
27
27
  "dependencies": {
28
- "@v-c/util": "^1.0.19",
29
- "@v-c/portal": "^1.0.8"
28
+ "@v-c/portal": "^1.0.8",
29
+ "@v-c/util": "^1.0.19"
30
30
  },
31
31
  "scripts": {
32
32
  "build": "vite build",