@adamjanicki/ui 1.5.2 → 1.5.4
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
type
|
|
2
|
+
type Props = {
|
|
3
3
|
/**
|
|
4
4
|
* Callback that fires when the user clicks outside the layer
|
|
5
5
|
*/
|
|
@@ -27,6 +27,11 @@ type LayerProps = {
|
|
|
27
27
|
* @default false
|
|
28
28
|
*/
|
|
29
29
|
returnFocusOnEscape?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* [Optional] disable the scroll lock behavior of the layer
|
|
32
|
+
* @default false
|
|
33
|
+
*/
|
|
34
|
+
disableScrollLock?: boolean;
|
|
30
35
|
};
|
|
31
|
-
declare const Layer: ({ returnFocusOnEscape, ...props }:
|
|
36
|
+
declare const Layer: ({ returnFocusOnEscape, disableScrollLock, ...props }: Props) => JSX.Element;
|
|
32
37
|
export default Layer;
|
|
@@ -50,9 +50,9 @@ var BaseLayer = function (_a) {
|
|
|
50
50
|
}) }));
|
|
51
51
|
};
|
|
52
52
|
var Layer = function (_a) {
|
|
53
|
-
var
|
|
53
|
+
var returnFocusOnEscape = _a.returnFocusOnEscape, disableScrollLock = _a.disableScrollLock, props = __rest(_a, ["returnFocusOnEscape", "disableScrollLock"]);
|
|
54
54
|
// Lock and unlock on mount and unmount
|
|
55
|
-
useScrollLock();
|
|
55
|
+
useScrollLock(!disableScrollLock);
|
|
56
56
|
useEffect(function () {
|
|
57
57
|
return function () {
|
|
58
58
|
var _a;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Assert a condition
|
|
3
|
+
*
|
|
4
|
+
* @param predicate the condition to assert
|
|
5
|
+
* @param message optional error message
|
|
6
|
+
*/
|
|
7
|
+
export default function assert<T>(predicate: T, message?: string): void;
|
|
8
|
+
/**
|
|
9
|
+
* Assert a value is defined
|
|
10
|
+
*
|
|
11
|
+
* @param value the value to assert presence of
|
|
12
|
+
* @param message optional error message
|
|
13
|
+
* @returns the present value
|
|
14
|
+
*/
|
|
15
|
+
export declare function assertDefined<T>(value: T | undefined, message?: string): T;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Assert a condition
|
|
3
|
+
*
|
|
4
|
+
* @param predicate the condition to assert
|
|
5
|
+
* @param message optional error message
|
|
6
|
+
*/
|
|
7
|
+
export default function assert(predicate, message) {
|
|
8
|
+
if (!predicate) {
|
|
9
|
+
throw new Error(message || "Assertion error");
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Assert a value is defined
|
|
14
|
+
*
|
|
15
|
+
* @param value the value to assert presence of
|
|
16
|
+
* @param message optional error message
|
|
17
|
+
* @returns the present value
|
|
18
|
+
*/
|
|
19
|
+
export function assertDefined(value, message) {
|
|
20
|
+
if (value === undefined) {
|
|
21
|
+
throw new Error(message || "Unexpected undefined value");
|
|
22
|
+
}
|
|
23
|
+
return value;
|
|
24
|
+
}
|
package/functions/index.d.ts
CHANGED
package/functions/index.js
CHANGED
package/hooks/useScrollToHash.js
CHANGED
|
@@ -11,7 +11,6 @@ var useScrollToHash = function (config) {
|
|
|
11
11
|
if (!active || (hash === null || hash === void 0 ? void 0 : hash.length) <= 1)
|
|
12
12
|
return;
|
|
13
13
|
var id = hash.substring(1);
|
|
14
|
-
scrollToId(id, behavior);
|
|
15
14
|
if (delay !== undefined) {
|
|
16
15
|
var timeout_1 = setTimeout(function () { return scrollToId(id, behavior); }, delay);
|
|
17
16
|
return function () { return clearTimeout(timeout_1); };
|