@chakra-ui/live-region
Advanced tools
Comparing version 1.0.0-rc.5 to 1.0.0-rc.6
@@ -6,2 +6,10 @@ # Change Log | ||
# 1.0.0-rc.6 (2020-10-25) | ||
**Note:** Version bump only for package @chakra-ui/live-region | ||
# 1.0.0-rc.5 (2020-09-27) | ||
@@ -8,0 +16,0 @@ |
@@ -9,2 +9,3 @@ "use strict"; | ||
if (key === "default" || key === "__esModule") return; | ||
if (key in exports && exports[key] === _liveRegion[key]) return; | ||
exports[key] = _liveRegion[key]; | ||
@@ -17,4 +18,5 @@ }); | ||
if (key === "default" || key === "__esModule") return; | ||
if (key in exports && exports[key] === _useLiveRegion[key]) return; | ||
exports[key] = _useLiveRegion[key]; | ||
}); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
exports.__esModule = true; | ||
exports["default"] = exports.LiveRegion = void 0; | ||
exports.LiveRegion = void 0; | ||
var _utils = require("@chakra-ui/utils"); | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
@@ -19,3 +21,6 @@ | ||
this.parentNode = this.options.parentNode; | ||
this.parentNode.appendChild(this.region); | ||
if (this.region) { | ||
this.parentNode.appendChild(this.region); | ||
} | ||
} | ||
@@ -27,13 +32,20 @@ | ||
this.clear(); | ||
this.region.innerText = message; | ||
if (this.region) { | ||
this.region.innerText = message; | ||
} | ||
}; | ||
_proto.destroy = function destroy() { | ||
var _this$region$parentNo; | ||
if (this.region) { | ||
var _this$region$parentNo; | ||
(_this$region$parentNo = this.region.parentNode) == null ? void 0 : _this$region$parentNo.removeChild(this.region); | ||
(_this$region$parentNo = this.region.parentNode) == null ? void 0 : _this$region$parentNo.removeChild(this.region); | ||
} | ||
}; | ||
_proto.clear = function clear() { | ||
this.region.innerText = ""; | ||
if (this.region) { | ||
this.region.innerText = ""; | ||
} | ||
}; | ||
@@ -53,3 +65,3 @@ | ||
id: "chakra-a11y-live-region", | ||
parentNode: document.body | ||
parentNode: _utils.isBrowser ? document.body : undefined | ||
}; | ||
@@ -65,11 +77,11 @@ | ||
function getRegion(options) { | ||
var region = document.getElementById(options.id); | ||
var region = _utils.isBrowser ? document.getElementById(options.id) : null; | ||
if (region) return region; | ||
if (region) { | ||
return region; | ||
} else { | ||
if (_utils.isBrowser) { | ||
region = document.createElement("div"); | ||
setup(region, options); | ||
return region; | ||
} | ||
return region; | ||
} | ||
@@ -96,5 +108,2 @@ | ||
} | ||
var _default = LiveRegion; | ||
exports["default"] = _default; | ||
//# sourceMappingURL=live-region.js.map |
@@ -9,6 +9,4 @@ "use strict"; | ||
var _liveRegion = _interopRequireDefault(require("./live-region")); | ||
var _liveRegion = require("./live-region"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } | ||
@@ -20,3 +18,3 @@ | ||
var _React$useState = React.useState(function () { | ||
return new _liveRegion["default"](options); | ||
return new _liveRegion.LiveRegion(options); | ||
}), | ||
@@ -23,0 +21,0 @@ liveRegion = _React$useState[0]; |
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
import { isBrowser } from "@chakra-ui/utils"; | ||
export class LiveRegion { | ||
@@ -14,3 +15,6 @@ constructor(options) { | ||
this.parentNode = this.options.parentNode; | ||
this.parentNode.appendChild(this.region); | ||
if (this.region) { | ||
this.parentNode.appendChild(this.region); | ||
} | ||
} | ||
@@ -20,13 +24,20 @@ | ||
this.clear(); | ||
this.region.innerText = message; | ||
if (this.region) { | ||
this.region.innerText = message; | ||
} | ||
} | ||
destroy() { | ||
var _this$region$parentNo; | ||
if (this.region) { | ||
var _this$region$parentNo; | ||
(_this$region$parentNo = this.region.parentNode) == null ? void 0 : _this$region$parentNo.removeChild(this.region); | ||
(_this$region$parentNo = this.region.parentNode) == null ? void 0 : _this$region$parentNo.removeChild(this.region); | ||
} | ||
} | ||
clear() { | ||
this.region.innerText = ""; | ||
if (this.region) { | ||
this.region.innerText = ""; | ||
} | ||
} | ||
@@ -43,3 +54,3 @@ | ||
id: "chakra-a11y-live-region", | ||
parentNode: document.body | ||
parentNode: isBrowser ? document.body : undefined | ||
}; | ||
@@ -55,11 +66,11 @@ | ||
function getRegion(options) { | ||
var region = document.getElementById(options.id); | ||
var region = isBrowser ? document.getElementById(options.id) : null; | ||
if (region) return region; | ||
if (region) { | ||
return region; | ||
} else { | ||
if (isBrowser) { | ||
region = document.createElement("div"); | ||
setup(region, options); | ||
return region; | ||
} | ||
return region; | ||
} | ||
@@ -86,4 +97,2 @@ | ||
} | ||
export default LiveRegion; | ||
//# sourceMappingURL=live-region.js.map |
import * as React from "react"; | ||
import LiveRegion from "./live-region"; | ||
import { LiveRegion } from "./live-region"; | ||
export function useLiveRegion(options) { | ||
var [liveRegion] = React.useState(() => { | ||
return new LiveRegion(options); | ||
}); | ||
var [liveRegion] = React.useState(() => new LiveRegion(options)); | ||
React.useEffect(() => { | ||
@@ -8,0 +6,0 @@ return () => { |
@@ -43,3 +43,3 @@ /// <reference types="react" /> | ||
export declare class LiveRegion { | ||
region: HTMLElement; | ||
region: HTMLElement | null; | ||
options: Required<LiveRegionOptions>; | ||
@@ -52,2 +52,1 @@ parentNode: HTMLElement; | ||
} | ||
export default LiveRegion; |
@@ -1,3 +0,3 @@ | ||
import LiveRegion, { LiveRegionOptions } from "./live-region"; | ||
import { LiveRegion, LiveRegionOptions } from "./live-region"; | ||
export declare function useLiveRegion(options?: LiveRegionOptions): LiveRegion; | ||
export default useLiveRegion; |
{ | ||
"name": "@chakra-ui/live-region", | ||
"version": "1.0.0-rc.5", | ||
"version": "1.0.0-rc.6", | ||
"description": "Aria live region for React components", | ||
@@ -22,2 +22,8 @@ "keywords": [ | ||
"typings": "dist/types/index.d.ts", | ||
"exports": { | ||
".": { | ||
"require": "./dist/cjs/index.js", | ||
"default": "./dist/esm/index.js" | ||
} | ||
}, | ||
"files": [ | ||
@@ -50,6 +56,9 @@ "dist" | ||
}, | ||
"dependencies": { | ||
"@chakra-ui/utils": "1.0.0-rc.6" | ||
}, | ||
"peerDependencies": { | ||
"react": "16.x" | ||
"react": "16.x || 17.x" | ||
}, | ||
"gitHead": "b5c8482b778b19f27ea1d6c8ab6d5ed39c664afa" | ||
"gitHead": "e55b45840d1edc821ad0bb45632535333be5bb86" | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31922
261
2
+ Added@chakra-ui/utils@1.0.0-rc.6
+ Added@chakra-ui/utils@1.0.0-rc.6(transitive)
+ Added@types/lodash@4.17.7(transitive)
+ Added@types/lodash.mergewith@4.6.6(transitive)
+ Added@types/object-assign@4.0.30(transitive)
+ Addedcss-box-model@1.2.1(transitive)
+ Addedlodash.mergewith@4.6.2(transitive)
+ Addedreact@17.0.2(transitive)
+ Addedtiny-invariant@1.3.3(transitive)
- Removedprop-types@15.8.1(transitive)
- Removedreact@16.14.0(transitive)
- Removedreact-is@16.13.1(transitive)