@tamagui/focus-scope
Advanced tools
Comparing version 1.0.1-beta.108 to 1.0.1-beta.109
@@ -0,36 +1,8 @@ | ||
"use strict"; | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __defProps = Object.defineProperties; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropDescs = Object.getOwnPropertyDescriptors; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
var __spreadValues = (a, b) => { | ||
for (var prop in b || (b = {})) | ||
if (__hasOwnProp.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
if (__getOwnPropSymbols) | ||
for (var prop of __getOwnPropSymbols(b)) { | ||
if (__propIsEnum.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
} | ||
return a; | ||
}; | ||
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); | ||
var __objRest = (source, exclude) => { | ||
var target = {}; | ||
for (var prop in source) | ||
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) | ||
target[prop] = source[prop]; | ||
if (source != null && __getOwnPropSymbols) | ||
for (var prop of __getOwnPropSymbols(source)) { | ||
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) | ||
target[prop] = source[prop]; | ||
} | ||
return target; | ||
}; | ||
var __export = (target, all) => { | ||
@@ -63,13 +35,9 @@ for (var name in all) | ||
const FocusScope = React.forwardRef((props, forwardedRef) => { | ||
const _a = props, { | ||
const { | ||
loop = false, | ||
trapped = false, | ||
onMountAutoFocus: onMountAutoFocusProp, | ||
onUnmountAutoFocus: onUnmountAutoFocusProp | ||
} = _a, scopeProps = __objRest(_a, [ | ||
"loop", | ||
"trapped", | ||
"onMountAutoFocus", | ||
"onUnmountAutoFocus" | ||
]); | ||
onUnmountAutoFocus: onUnmountAutoFocusProp, | ||
...scopeProps | ||
} = props; | ||
const [container, setContainer] = React.useState(null); | ||
@@ -91,3 +59,3 @@ const onMountAutoFocus = (0, import_use_event.useEvent)(onMountAutoFocusProp); | ||
if (trapped) { | ||
let handleFocusIn = function(event) { | ||
let handleFocusIn2 = function(event) { | ||
if (focusScope.paused || !container) | ||
@@ -101,3 +69,3 @@ return; | ||
} | ||
}, handleFocusOut = function(event) { | ||
}, handleFocusOut2 = function(event) { | ||
if (focusScope.paused || !container) | ||
@@ -109,7 +77,8 @@ return; | ||
}; | ||
document.addEventListener("focusin", handleFocusIn); | ||
document.addEventListener("focusout", handleFocusOut); | ||
var handleFocusIn = handleFocusIn2, handleFocusOut = handleFocusOut2; | ||
document.addEventListener("focusin", handleFocusIn2); | ||
document.addEventListener("focusout", handleFocusOut2); | ||
return () => { | ||
document.removeEventListener("focusin", handleFocusIn); | ||
document.removeEventListener("focusout", handleFocusOut); | ||
document.removeEventListener("focusin", handleFocusIn2); | ||
document.removeEventListener("focusout", handleFocusOut2); | ||
}; | ||
@@ -177,8 +146,8 @@ } | ||
const child = React.Children.only(props.children); | ||
return React.cloneElement(child, __spreadProps(__spreadValues({ | ||
tabIndex: -1 | ||
}, scopeProps), { | ||
return React.cloneElement(child, { | ||
tabIndex: -1, | ||
...scopeProps, | ||
ref: composedRefs, | ||
onKeyDown: handleKeyDown | ||
})); | ||
}); | ||
}); | ||
@@ -185,0 +154,0 @@ FocusScope.displayName = FOCUS_SCOPE_NAME; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -2,0 +3,0 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -2,0 +3,0 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -2,0 +3,0 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
@@ -1,32 +0,1 @@ | ||
var __defProp = Object.defineProperty; | ||
var __defProps = Object.defineProperties; | ||
var __getOwnPropDescs = Object.getOwnPropertyDescriptors; | ||
var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
var __spreadValues = (a, b) => { | ||
for (var prop in b || (b = {})) | ||
if (__hasOwnProp.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
if (__getOwnPropSymbols) | ||
for (var prop of __getOwnPropSymbols(b)) { | ||
if (__propIsEnum.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
} | ||
return a; | ||
}; | ||
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); | ||
var __objRest = (source, exclude) => { | ||
var target = {}; | ||
for (var prop in source) | ||
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) | ||
target[prop] = source[prop]; | ||
if (source != null && __getOwnPropSymbols) | ||
for (var prop of __getOwnPropSymbols(source)) { | ||
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) | ||
target[prop] = source[prop]; | ||
} | ||
return target; | ||
}; | ||
import { useComposedRefs } from "@tamagui/compose-refs"; | ||
@@ -40,13 +9,9 @@ import { useEvent } from "@tamagui/use-event"; | ||
const FocusScope = React.forwardRef((props, forwardedRef) => { | ||
const _a = props, { | ||
const { | ||
loop = false, | ||
trapped = false, | ||
onMountAutoFocus: onMountAutoFocusProp, | ||
onUnmountAutoFocus: onUnmountAutoFocusProp | ||
} = _a, scopeProps = __objRest(_a, [ | ||
"loop", | ||
"trapped", | ||
"onMountAutoFocus", | ||
"onUnmountAutoFocus" | ||
]); | ||
onUnmountAutoFocus: onUnmountAutoFocusProp, | ||
...scopeProps | ||
} = props; | ||
const [container, setContainer] = React.useState(null); | ||
@@ -68,3 +33,3 @@ const onMountAutoFocus = useEvent(onMountAutoFocusProp); | ||
if (trapped) { | ||
let handleFocusIn = function(event) { | ||
let handleFocusIn2 = function(event) { | ||
if (focusScope.paused || !container) | ||
@@ -78,3 +43,3 @@ return; | ||
} | ||
}, handleFocusOut = function(event) { | ||
}, handleFocusOut2 = function(event) { | ||
if (focusScope.paused || !container) | ||
@@ -86,7 +51,8 @@ return; | ||
}; | ||
document.addEventListener("focusin", handleFocusIn); | ||
document.addEventListener("focusout", handleFocusOut); | ||
var handleFocusIn = handleFocusIn2, handleFocusOut = handleFocusOut2; | ||
document.addEventListener("focusin", handleFocusIn2); | ||
document.addEventListener("focusout", handleFocusOut2); | ||
return () => { | ||
document.removeEventListener("focusin", handleFocusIn); | ||
document.removeEventListener("focusout", handleFocusOut); | ||
document.removeEventListener("focusin", handleFocusIn2); | ||
document.removeEventListener("focusout", handleFocusOut2); | ||
}; | ||
@@ -154,8 +120,8 @@ } | ||
const child = React.Children.only(props.children); | ||
return React.cloneElement(child, __spreadProps(__spreadValues({ | ||
tabIndex: -1 | ||
}, scopeProps), { | ||
return React.cloneElement(child, { | ||
tabIndex: -1, | ||
...scopeProps, | ||
ref: composedRefs, | ||
onKeyDown: handleKeyDown | ||
})); | ||
}); | ||
}); | ||
@@ -162,0 +128,0 @@ FocusScope.displayName = FOCUS_SCOPE_NAME; |
@@ -32,3 +32,3 @@ import { useComposedRefs } from "@tamagui/compose-refs"; | ||
if (trapped) { | ||
let handleFocusIn = function(event) { | ||
let handleFocusIn2 = function(event) { | ||
if (focusScope.paused || !container) | ||
@@ -42,3 +42,3 @@ return; | ||
} | ||
}, handleFocusOut = function(event) { | ||
}, handleFocusOut2 = function(event) { | ||
if (focusScope.paused || !container) | ||
@@ -50,7 +50,8 @@ return; | ||
}; | ||
document.addEventListener("focusin", handleFocusIn); | ||
document.addEventListener("focusout", handleFocusOut); | ||
var handleFocusIn = handleFocusIn2, handleFocusOut = handleFocusOut2; | ||
document.addEventListener("focusin", handleFocusIn2); | ||
document.addEventListener("focusout", handleFocusOut2); | ||
return () => { | ||
document.removeEventListener("focusin", handleFocusIn); | ||
document.removeEventListener("focusout", handleFocusOut); | ||
document.removeEventListener("focusin", handleFocusIn2); | ||
document.removeEventListener("focusout", handleFocusOut2); | ||
}; | ||
@@ -57,0 +58,0 @@ } |
{ | ||
"name": "@tamagui/focus-scope", | ||
"version": "1.0.1-beta.108", | ||
"version": "1.0.1-beta.109", | ||
"sideEffects": true, | ||
@@ -22,4 +22,4 @@ "source": "src/index.ts", | ||
"dependencies": { | ||
"@tamagui/compose-refs": "^1.0.1-beta.108", | ||
"@tamagui/use-event": "^1.0.1-beta.108" | ||
"@tamagui/compose-refs": "^1.0.1-beta.109", | ||
"@tamagui/use-event": "^1.0.1-beta.109" | ||
}, | ||
@@ -31,3 +31,3 @@ "peerDependencies": { | ||
"devDependencies": { | ||
"@tamagui/build": "^1.0.1-beta.108", | ||
"@tamagui/build": "^1.0.1-beta.109", | ||
"react": "*", | ||
@@ -34,0 +34,0 @@ "react-dom": "*" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
37
93140
1062