@vueuse/integrations 6.4.1 → 6.5.3

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/useFocusTrap.cjs CHANGED
@@ -2,113 +2,87 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var shared = require('@vueuse/shared');
5
+ var core = require('@vueuse/core');
6
6
  var vueDemi = require('vue-demi');
7
7
  var focusTrap = require('focus-trap');
8
8
 
9
- /*! *****************************************************************************
10
- Copyright (c) Microsoft Corporation.
11
-
12
- Permission to use, copy, modify, and/or distribute this software for any
13
- purpose with or without fee is hereby granted.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
16
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
17
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
18
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
19
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
20
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21
- PERFORMANCE OF THIS SOFTWARE.
22
- ***************************************************************************** */
23
-
24
- function __rest(s, e) {
25
- var t = {};
26
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
27
- t[p] = s[p];
28
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
29
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
30
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
31
- t[p[i]] = s[p[i]];
32
- }
33
- return t;
34
- }
35
-
36
- /**
37
- * Get the dom element of a ref of element or Vue component instance
38
- *
39
- * @param elRef
40
- */
41
- function unrefElement(elRef) {
42
- var _a, _b;
43
- const plain = vueDemi.unref(elRef);
44
- return (_b = (_a = plain) === null || _a === void 0 ? void 0 : _a.$el) !== null && _b !== void 0 ? _b : plain;
45
- }
46
-
47
- var SwipeDirection;
48
- (function (SwipeDirection) {
49
- SwipeDirection["UP"] = "UP";
50
- SwipeDirection["RIGHT"] = "RIGHT";
51
- SwipeDirection["DOWN"] = "DOWN";
52
- SwipeDirection["LEFT"] = "LEFT";
53
- SwipeDirection["NONE"] = "NONE";
54
- })(SwipeDirection || (SwipeDirection = {}));
55
-
56
- /**
57
- * Reactive focus-trap
58
- *
59
- * @see https://vueuse.org/useFocusTrap
60
- * @param target The target element to trap focus within
61
- * @param options Focus trap options
62
- * @param autoFocus Focus trap automatically when mounted
63
- */
64
- function useFocusTrap(target, options = {}) {
65
- let trap;
66
- const { immediate } = options, focusTrapOptions = __rest(options, ["immediate"]);
67
- const hasFocus = vueDemi.ref(false);
68
- const isPaused = vueDemi.ref(false);
69
- const activate = (opts) => trap && trap.activate(opts);
70
- const deactivate = (opts) => trap && trap.deactivate(opts);
71
- const pause = () => {
72
- if (trap) {
73
- trap.pause();
74
- isPaused.value = true;
75
- }
76
- };
77
- const unpause = () => {
78
- if (trap) {
79
- trap.unpause();
80
- isPaused.value = false;
81
- }
82
- };
83
- vueDemi.watch(() => unrefElement(target), (el) => {
84
- if (!el)
85
- return;
86
- trap = focusTrap.createFocusTrap(el, Object.assign(Object.assign({}, focusTrapOptions), { onActivate() {
87
- hasFocus.value = true;
88
- // Apply if user provided onActivate option
89
- if (options.onActivate)
90
- options.onActivate();
91
- },
92
- onDeactivate() {
93
- hasFocus.value = false;
94
- // Apply if user provided onDeactivate option
95
- if (options.onDeactivate)
96
- options.onDeactivate();
97
- } }));
98
- // Focus if immediate is set to true
99
- if (immediate)
100
- activate();
101
- }, { flush: 'post' });
102
- // Cleanup on unmount
103
- shared.tryOnScopeDispose(() => deactivate());
104
- return {
105
- hasFocus,
106
- isPaused,
107
- activate,
108
- deactivate,
109
- pause,
110
- unpause,
111
- };
9
+ var __defProp = Object.defineProperty;
10
+ var __defProps = Object.defineProperties;
11
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
12
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
15
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
16
+ var __spreadValues = (a, b) => {
17
+ for (var prop in b || (b = {}))
18
+ if (__hasOwnProp.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ if (__getOwnPropSymbols)
21
+ for (var prop of __getOwnPropSymbols(b)) {
22
+ if (__propIsEnum.call(b, prop))
23
+ __defNormalProp(a, prop, b[prop]);
24
+ }
25
+ return a;
26
+ };
27
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
28
+ var __objRest = (source, exclude) => {
29
+ var target = {};
30
+ for (var prop in source)
31
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
32
+ target[prop] = source[prop];
33
+ if (source != null && __getOwnPropSymbols)
34
+ for (var prop of __getOwnPropSymbols(source)) {
35
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
36
+ target[prop] = source[prop];
37
+ }
38
+ return target;
39
+ };
40
+ function useFocusTrap(target, options = {}) {
41
+ let trap;
42
+ const _a = options, { immediate } = _a, focusTrapOptions = __objRest(_a, ["immediate"]);
43
+ const hasFocus = vueDemi.ref(false);
44
+ const isPaused = vueDemi.ref(false);
45
+ const activate = (opts) => trap && trap.activate(opts);
46
+ const deactivate = (opts) => trap && trap.deactivate(opts);
47
+ const pause = () => {
48
+ if (trap) {
49
+ trap.pause();
50
+ isPaused.value = true;
51
+ }
52
+ };
53
+ const unpause = () => {
54
+ if (trap) {
55
+ trap.unpause();
56
+ isPaused.value = false;
57
+ }
58
+ };
59
+ vueDemi.watch(() => core.unrefElement(target), (el) => {
60
+ if (!el)
61
+ return;
62
+ trap = focusTrap.createFocusTrap(el, __spreadProps(__spreadValues({}, focusTrapOptions), {
63
+ onActivate() {
64
+ hasFocus.value = true;
65
+ if (options.onActivate)
66
+ options.onActivate();
67
+ },
68
+ onDeactivate() {
69
+ hasFocus.value = false;
70
+ if (options.onDeactivate)
71
+ options.onDeactivate();
72
+ }
73
+ }));
74
+ if (immediate)
75
+ activate();
76
+ }, { flush: "post" });
77
+ core.tryOnScopeDispose(() => deactivate());
78
+ return {
79
+ hasFocus,
80
+ isPaused,
81
+ activate,
82
+ deactivate,
83
+ pause,
84
+ unpause
85
+ };
112
86
  }
113
87
 
114
88
  exports.useFocusTrap = useFocusTrap;
@@ -59,116 +59,90 @@
59
59
  window.VueDemi = VueDemi
60
60
  })(window)
61
61
  ;
62
- ;(function (exports, shared, vueDemi, focusTrap) {
63
- 'use strict';
62
+ ;(function (exports, core, vueDemi, focusTrap) {
63
+ 'use strict';
64
64
 
65
- /*! *****************************************************************************
66
- Copyright (c) Microsoft Corporation.
67
-
68
- Permission to use, copy, modify, and/or distribute this software for any
69
- purpose with or without fee is hereby granted.
70
-
71
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
72
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
73
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
74
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
75
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
76
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
77
- PERFORMANCE OF THIS SOFTWARE.
78
- ***************************************************************************** */
79
-
80
- function __rest(s, e) {
81
- var t = {};
82
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
83
- t[p] = s[p];
84
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
85
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
86
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
87
- t[p[i]] = s[p[i]];
88
- }
89
- return t;
90
- }
91
-
92
- /**
93
- * Get the dom element of a ref of element or Vue component instance
94
- *
95
- * @param elRef
96
- */
97
- function unrefElement(elRef) {
98
- var _a, _b;
99
- const plain = vueDemi.unref(elRef);
100
- return (_b = (_a = plain) === null || _a === void 0 ? void 0 : _a.$el) !== null && _b !== void 0 ? _b : plain;
101
- }
102
-
103
- var SwipeDirection;
104
- (function (SwipeDirection) {
105
- SwipeDirection["UP"] = "UP";
106
- SwipeDirection["RIGHT"] = "RIGHT";
107
- SwipeDirection["DOWN"] = "DOWN";
108
- SwipeDirection["LEFT"] = "LEFT";
109
- SwipeDirection["NONE"] = "NONE";
110
- })(SwipeDirection || (SwipeDirection = {}));
111
-
112
- /**
113
- * Reactive focus-trap
114
- *
115
- * @see https://vueuse.org/useFocusTrap
116
- * @param target The target element to trap focus within
117
- * @param options Focus trap options
118
- * @param autoFocus Focus trap automatically when mounted
119
- */
120
- function useFocusTrap(target, options = {}) {
121
- let trap;
122
- const { immediate } = options, focusTrapOptions = __rest(options, ["immediate"]);
123
- const hasFocus = vueDemi.ref(false);
124
- const isPaused = vueDemi.ref(false);
125
- const activate = (opts) => trap && trap.activate(opts);
126
- const deactivate = (opts) => trap && trap.deactivate(opts);
127
- const pause = () => {
128
- if (trap) {
129
- trap.pause();
130
- isPaused.value = true;
131
- }
132
- };
133
- const unpause = () => {
134
- if (trap) {
135
- trap.unpause();
136
- isPaused.value = false;
137
- }
138
- };
139
- vueDemi.watch(() => unrefElement(target), (el) => {
140
- if (!el)
141
- return;
142
- trap = focusTrap.createFocusTrap(el, Object.assign(Object.assign({}, focusTrapOptions), { onActivate() {
143
- hasFocus.value = true;
144
- // Apply if user provided onActivate option
145
- if (options.onActivate)
146
- options.onActivate();
147
- },
148
- onDeactivate() {
149
- hasFocus.value = false;
150
- // Apply if user provided onDeactivate option
151
- if (options.onDeactivate)
152
- options.onDeactivate();
153
- } }));
154
- // Focus if immediate is set to true
155
- if (immediate)
156
- activate();
157
- }, { flush: 'post' });
158
- // Cleanup on unmount
159
- shared.tryOnScopeDispose(() => deactivate());
160
- return {
161
- hasFocus,
162
- isPaused,
163
- activate,
164
- deactivate,
165
- pause,
166
- unpause,
167
- };
168
- }
65
+ var __defProp = Object.defineProperty;
66
+ var __defProps = Object.defineProperties;
67
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
68
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
69
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
70
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
71
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
72
+ var __spreadValues = (a, b) => {
73
+ for (var prop in b || (b = {}))
74
+ if (__hasOwnProp.call(b, prop))
75
+ __defNormalProp(a, prop, b[prop]);
76
+ if (__getOwnPropSymbols)
77
+ for (var prop of __getOwnPropSymbols(b)) {
78
+ if (__propIsEnum.call(b, prop))
79
+ __defNormalProp(a, prop, b[prop]);
80
+ }
81
+ return a;
82
+ };
83
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
84
+ var __objRest = (source, exclude) => {
85
+ var target = {};
86
+ for (var prop in source)
87
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
88
+ target[prop] = source[prop];
89
+ if (source != null && __getOwnPropSymbols)
90
+ for (var prop of __getOwnPropSymbols(source)) {
91
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
92
+ target[prop] = source[prop];
93
+ }
94
+ return target;
95
+ };
96
+ function useFocusTrap(target, options = {}) {
97
+ let trap;
98
+ const _a = options, { immediate } = _a, focusTrapOptions = __objRest(_a, ["immediate"]);
99
+ const hasFocus = vueDemi.ref(false);
100
+ const isPaused = vueDemi.ref(false);
101
+ const activate = (opts) => trap && trap.activate(opts);
102
+ const deactivate = (opts) => trap && trap.deactivate(opts);
103
+ const pause = () => {
104
+ if (trap) {
105
+ trap.pause();
106
+ isPaused.value = true;
107
+ }
108
+ };
109
+ const unpause = () => {
110
+ if (trap) {
111
+ trap.unpause();
112
+ isPaused.value = false;
113
+ }
114
+ };
115
+ vueDemi.watch(() => core.unrefElement(target), (el) => {
116
+ if (!el)
117
+ return;
118
+ trap = focusTrap.createFocusTrap(el, __spreadProps(__spreadValues({}, focusTrapOptions), {
119
+ onActivate() {
120
+ hasFocus.value = true;
121
+ if (options.onActivate)
122
+ options.onActivate();
123
+ },
124
+ onDeactivate() {
125
+ hasFocus.value = false;
126
+ if (options.onDeactivate)
127
+ options.onDeactivate();
128
+ }
129
+ }));
130
+ if (immediate)
131
+ activate();
132
+ }, { flush: "post" });
133
+ core.tryOnScopeDispose(() => deactivate());
134
+ return {
135
+ hasFocus,
136
+ isPaused,
137
+ activate,
138
+ deactivate,
139
+ pause,
140
+ unpause
141
+ };
142
+ }
169
143
 
170
- exports.useFocusTrap = useFocusTrap;
144
+ exports.useFocusTrap = useFocusTrap;
171
145
 
172
- Object.defineProperty(exports, '__esModule', { value: true });
146
+ Object.defineProperty(exports, '__esModule', { value: true });
173
147
 
174
- }(this.VueUse = this.VueUse || {}, VueUse, VueDemi, focusTrap));
148
+ })(this.VueUse = this.VueUse || {}, VueUse, VueDemi, focusTrap);
@@ -1 +1 @@
1
- !function(e){if(!e.VueDemi){var i={},o=e.Vue;if(o)if("2."===o.version.slice(0,2)){var t=e.VueCompositionAPI;if(t){for(var n in t)i[n]=t[n];i.isVue2=!0,i.isVue3=!1,i.install=function(){},i.Vue=o,i.Vue2=o,i.version=o.version}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.")}else if("3."===o.version.slice(0,2)){for(var n in o)i[n]=o[n];i.isVue2=!1,i.isVue3=!0,i.install=function(){},i.Vue=o,i.Vue2=void 0,i.version=o.version,i.set=function(e,i,o){return Array.isArray(e)?(e.length=Math.max(e.length,i),e.splice(i,1,o),o):(e[i]=o,o)},i.del=function(e,i){Array.isArray(e)?e.splice(i,1):delete e[i]}}else console.error("[vue-demi] Vue version "+o.version+" is unsupported.");else console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.");e.VueDemi=i}}(window),function(e,i,o,t){"use strict";var n;!function(e){e.UP="UP",e.RIGHT="RIGHT",e.DOWN="DOWN",e.LEFT="LEFT",e.NONE="NONE"}(n||(n={})),e.useFocusTrap=function(e,n={}){let r;const{immediate:s}=n,u=function(e,i){var o={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&i.indexOf(t)<0&&(o[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(t=Object.getOwnPropertySymbols(e);n<t.length;n++)i.indexOf(t[n])<0&&Object.prototype.propertyIsEnumerable.call(e,t[n])&&(o[t[n]]=e[t[n]])}return o}(n,["immediate"]),a=o.ref(!1),c=o.ref(!1),l=e=>r&&r.activate(e),v=e=>r&&r.deactivate(e);return o.watch((()=>function(e){var i,t;const n=o.unref(e);return null!==(t=null===(i=n)||void 0===i?void 0:i.$el)&&void 0!==t?t:n}(e)),(e=>{e&&(r=t.createFocusTrap(e,Object.assign(Object.assign({},u),{onActivate(){a.value=!0,n.onActivate&&n.onActivate()},onDeactivate(){a.value=!1,n.onDeactivate&&n.onDeactivate()}})),s&&l())}),{flush:"post"}),i.tryOnScopeDispose((()=>v())),{hasFocus:a,isPaused:c,activate:l,deactivate:v,pause:()=>{r&&(r.pause(),c.value=!0)},unpause:()=>{r&&(r.unpause(),c.value=!1)}}},Object.defineProperty(e,"__esModule",{value:!0})}(this.VueUse=this.VueUse||{},VueUse,VueDemi,focusTrap);
1
+ (function(f){if(!f.VueDemi){var i={},s=f.Vue;if(s)if(s.version.slice(0,2)==="2."){var v=f.VueCompositionAPI;if(v){for(var c in v)i[c]=v[c];i.isVue2=!0,i.isVue3=!1,i.install=function(){},i.Vue=s,i.Vue2=s,i.version=s.version}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.")}else if(s.version.slice(0,2)==="3."){for(var c in s)i[c]=s[c];i.isVue2=!1,i.isVue3=!0,i.install=function(){},i.Vue=s,i.Vue2=void 0,i.version=s.version,i.set=function(a,o,u){return Array.isArray(a)?(a.length=Math.max(a.length,o),a.splice(o,1,u),u):(a[o]=u,u)},i.del=function(a,o){if(Array.isArray(a)){a.splice(o,1);return}delete a[o]}}else console.error("[vue-demi] Vue version "+s.version+" is unsupported.");else console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.");f.VueDemi=i}})(window),function(f,i,s,v){"use strict";var c=Object.defineProperty,a=Object.defineProperties,o=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,_=Object.prototype.hasOwnProperty,m=Object.prototype.propertyIsEnumerable,V=(t,r,e)=>r in t?c(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,b=(t,r)=>{for(var e in r||(r={}))_.call(r,e)&&V(t,e,r[e]);if(u)for(var e of u(r))m.call(r,e)&&V(t,e,r[e]);return t},h=(t,r)=>a(t,o(r)),y=(t,r)=>{var e={};for(var n in t)_.call(t,n)&&r.indexOf(n)<0&&(e[n]=t[n]);if(t!=null&&u)for(var n of u(t))r.indexOf(n)<0&&m.call(t,n)&&(e[n]=t[n]);return e};function D(t,r={}){let e;const n=r,{immediate:A}=n,j=y(n,["immediate"]),p=s.ref(!1),d=s.ref(!1),O=l=>e&&e.activate(l),P=l=>e&&e.deactivate(l),T=()=>{e&&(e.pause(),d.value=!0)},w=()=>{e&&(e.unpause(),d.value=!1)};return s.watch(()=>i.unrefElement(t),l=>{!l||(e=v.createFocusTrap(l,h(b({},j),{onActivate(){p.value=!0,r.onActivate&&r.onActivate()},onDeactivate(){p.value=!1,r.onDeactivate&&r.onDeactivate()}})),A&&O())},{flush:"post"}),i.tryOnScopeDispose(()=>P()),{hasFocus:p,isPaused:d,activate:O,deactivate:P,pause:T,unpause:w}}f.useFocusTrap=D,Object.defineProperty(f,"__esModule",{value:!0})}(this.VueUse=this.VueUse||{},VueUse,VueDemi,focusTrap);
package/useFocusTrap.mjs CHANGED
@@ -1,110 +1,84 @@
1
- import { tryOnScopeDispose } from '@vueuse/shared';
2
- import { unref, ref, watch } from 'vue-demi';
1
+ import { unrefElement, tryOnScopeDispose } from '@vueuse/core';
2
+ import { ref, watch } from 'vue-demi';
3
3
  import { createFocusTrap } from 'focus-trap';
4
4
 
5
- /*! *****************************************************************************
6
- Copyright (c) Microsoft Corporation.
7
-
8
- Permission to use, copy, modify, and/or distribute this software for any
9
- purpose with or without fee is hereby granted.
10
-
11
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17
- PERFORMANCE OF THIS SOFTWARE.
18
- ***************************************************************************** */
19
-
20
- function __rest(s, e) {
21
- var t = {};
22
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
23
- t[p] = s[p];
24
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
25
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
26
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
27
- t[p[i]] = s[p[i]];
28
- }
29
- return t;
30
- }
31
-
32
- /**
33
- * Get the dom element of a ref of element or Vue component instance
34
- *
35
- * @param elRef
36
- */
37
- function unrefElement(elRef) {
38
- var _a, _b;
39
- const plain = unref(elRef);
40
- return (_b = (_a = plain) === null || _a === void 0 ? void 0 : _a.$el) !== null && _b !== void 0 ? _b : plain;
41
- }
42
-
43
- var SwipeDirection;
44
- (function (SwipeDirection) {
45
- SwipeDirection["UP"] = "UP";
46
- SwipeDirection["RIGHT"] = "RIGHT";
47
- SwipeDirection["DOWN"] = "DOWN";
48
- SwipeDirection["LEFT"] = "LEFT";
49
- SwipeDirection["NONE"] = "NONE";
50
- })(SwipeDirection || (SwipeDirection = {}));
51
-
52
- /**
53
- * Reactive focus-trap
54
- *
55
- * @see https://vueuse.org/useFocusTrap
56
- * @param target The target element to trap focus within
57
- * @param options Focus trap options
58
- * @param autoFocus Focus trap automatically when mounted
59
- */
60
- function useFocusTrap(target, options = {}) {
61
- let trap;
62
- const { immediate } = options, focusTrapOptions = __rest(options, ["immediate"]);
63
- const hasFocus = ref(false);
64
- const isPaused = ref(false);
65
- const activate = (opts) => trap && trap.activate(opts);
66
- const deactivate = (opts) => trap && trap.deactivate(opts);
67
- const pause = () => {
68
- if (trap) {
69
- trap.pause();
70
- isPaused.value = true;
71
- }
72
- };
73
- const unpause = () => {
74
- if (trap) {
75
- trap.unpause();
76
- isPaused.value = false;
77
- }
78
- };
79
- watch(() => unrefElement(target), (el) => {
80
- if (!el)
81
- return;
82
- trap = createFocusTrap(el, Object.assign(Object.assign({}, focusTrapOptions), { onActivate() {
83
- hasFocus.value = true;
84
- // Apply if user provided onActivate option
85
- if (options.onActivate)
86
- options.onActivate();
87
- },
88
- onDeactivate() {
89
- hasFocus.value = false;
90
- // Apply if user provided onDeactivate option
91
- if (options.onDeactivate)
92
- options.onDeactivate();
93
- } }));
94
- // Focus if immediate is set to true
95
- if (immediate)
96
- activate();
97
- }, { flush: 'post' });
98
- // Cleanup on unmount
99
- tryOnScopeDispose(() => deactivate());
100
- return {
101
- hasFocus,
102
- isPaused,
103
- activate,
104
- deactivate,
105
- pause,
106
- unpause,
107
- };
5
+ var __defProp = Object.defineProperty;
6
+ var __defProps = Object.defineProperties;
7
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
22
+ };
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
+ var __objRest = (source, exclude) => {
25
+ var target = {};
26
+ for (var prop in source)
27
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
28
+ target[prop] = source[prop];
29
+ if (source != null && __getOwnPropSymbols)
30
+ for (var prop of __getOwnPropSymbols(source)) {
31
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
32
+ target[prop] = source[prop];
33
+ }
34
+ return target;
35
+ };
36
+ function useFocusTrap(target, options = {}) {
37
+ let trap;
38
+ const _a = options, { immediate } = _a, focusTrapOptions = __objRest(_a, ["immediate"]);
39
+ const hasFocus = ref(false);
40
+ const isPaused = ref(false);
41
+ const activate = (opts) => trap && trap.activate(opts);
42
+ const deactivate = (opts) => trap && trap.deactivate(opts);
43
+ const pause = () => {
44
+ if (trap) {
45
+ trap.pause();
46
+ isPaused.value = true;
47
+ }
48
+ };
49
+ const unpause = () => {
50
+ if (trap) {
51
+ trap.unpause();
52
+ isPaused.value = false;
53
+ }
54
+ };
55
+ watch(() => unrefElement(target), (el) => {
56
+ if (!el)
57
+ return;
58
+ trap = createFocusTrap(el, __spreadProps(__spreadValues({}, focusTrapOptions), {
59
+ onActivate() {
60
+ hasFocus.value = true;
61
+ if (options.onActivate)
62
+ options.onActivate();
63
+ },
64
+ onDeactivate() {
65
+ hasFocus.value = false;
66
+ if (options.onDeactivate)
67
+ options.onDeactivate();
68
+ }
69
+ }));
70
+ if (immediate)
71
+ activate();
72
+ }, { flush: "post" });
73
+ tryOnScopeDispose(() => deactivate());
74
+ return {
75
+ hasFocus,
76
+ isPaused,
77
+ activate,
78
+ deactivate,
79
+ pause,
80
+ unpause
81
+ };
108
82
  }
109
83
 
110
84
  export { useFocusTrap };