@adamjanicki/ui 1.2.4 → 1.2.5
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/components/Layer/Layer.d.ts +8 -4
- package/components/Layer/Layer.js +28 -9
- package/components/Layer/index.d.ts +2 -1
- package/components/Layer/index.js +2 -1
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
type
|
|
2
|
+
type LayerProps = {
|
|
3
3
|
/**
|
|
4
4
|
* Callback that fires when the user clicks outside the layer
|
|
5
5
|
*/
|
|
@@ -22,10 +22,13 @@ type Props = {
|
|
|
22
22
|
* @default false
|
|
23
23
|
*/
|
|
24
24
|
disableEscape?: boolean;
|
|
25
|
+
};
|
|
26
|
+
type AnimatedLayerProps = LayerProps & {
|
|
25
27
|
/**
|
|
26
|
-
* [Optional] Config for visibility
|
|
28
|
+
* [Optional] Config for visibility, including styles and class names
|
|
29
|
+
* Set the `transition` property on the `style` prop to animate the layer
|
|
27
30
|
*/
|
|
28
|
-
visibility
|
|
31
|
+
visibility: {
|
|
29
32
|
visible: boolean;
|
|
30
33
|
invisibleStyle?: React.CSSProperties;
|
|
31
34
|
visibleStyle?: React.CSSProperties;
|
|
@@ -33,5 +36,6 @@ type Props = {
|
|
|
33
36
|
visibleClassName?: string;
|
|
34
37
|
};
|
|
35
38
|
};
|
|
36
|
-
declare const Layer: ({ onClose, children, style, className, disableEscape,
|
|
39
|
+
declare const Layer: ({ onClose, children, style, className, disableEscape, }: LayerProps) => JSX.Element;
|
|
40
|
+
export declare const AnimatedLayer: ({ visibility, className, style, ...props }: AnimatedLayerProps) => JSX.Element;
|
|
37
41
|
export default Layer;
|
|
@@ -9,19 +9,24 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
12
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
24
|
import React, { useEffect } from "react";
|
|
14
25
|
import { useFocusTrap, useScrollLock } from "../../hooks";
|
|
15
26
|
import { classNames } from "../../utils/util";
|
|
16
27
|
var Layer = function (_a) {
|
|
17
|
-
var onClose = _a.onClose, children = _a.children,
|
|
18
|
-
var
|
|
19
|
-
zIndex: -1,
|
|
20
|
-
opacity: 0,
|
|
21
|
-
pointerEvents: "none",
|
|
22
|
-
userSelect: "none",
|
|
23
|
-
} : _e, _f = visibility.visibleStyle, visibleStyle = _f === void 0 ? { opacity: 1 } : _f, invisibleClassName = visibility.invisibleClassName, visibleClassName = visibility.visibleClassName;
|
|
24
|
-
var _g = useScrollLock(), lock = _g.lock, unlock = _g.unlock;
|
|
28
|
+
var onClose = _a.onClose, children = _a.children, style = _a.style, className = _a.className, _b = _a.disableEscape, disableEscape = _b === void 0 ? false : _b;
|
|
29
|
+
var _c = useScrollLock(), lock = _c.lock, unlock = _c.unlock;
|
|
25
30
|
var focusRef = useFocusTrap(true);
|
|
26
31
|
useEffect(function () {
|
|
27
32
|
var handleEscape = function (event) {
|
|
@@ -40,7 +45,7 @@ var Layer = function (_a) {
|
|
|
40
45
|
lock();
|
|
41
46
|
return unlock;
|
|
42
47
|
}, [lock, unlock]);
|
|
43
|
-
return (_jsx("div", { className: classNames("ajui-layer-backdrop", className
|
|
48
|
+
return (_jsx("div", { className: classNames("ajui-layer-backdrop", className), style: style, onClick: onClose, children: React.cloneElement(children, {
|
|
44
49
|
ref: focusRef,
|
|
45
50
|
onClick: function (e) {
|
|
46
51
|
var _a, _b;
|
|
@@ -49,4 +54,18 @@ var Layer = function (_a) {
|
|
|
49
54
|
},
|
|
50
55
|
}) }));
|
|
51
56
|
};
|
|
57
|
+
var defaultInvisibleStyle = {
|
|
58
|
+
zIndex: -1,
|
|
59
|
+
opacity: 0,
|
|
60
|
+
pointerEvents: "none",
|
|
61
|
+
userSelect: "none",
|
|
62
|
+
};
|
|
63
|
+
var defaultVisibleStyle = { opacity: 1 };
|
|
64
|
+
export var AnimatedLayer = function (_a) {
|
|
65
|
+
var visibility = _a.visibility, className = _a.className, _b = _a.style, style = _b === void 0 ? {} : _b, props = __rest(_a, ["visibility", "className", "style"]);
|
|
66
|
+
var visible = visibility.visible, _c = visibility.invisibleStyle, invisibleStyle = _c === void 0 ? defaultInvisibleStyle : _c, _d = visibility.visibleStyle, visibleStyle = _d === void 0 ? defaultVisibleStyle : _d, invisibleClassName = visibility.invisibleClassName, visibleClassName = visibility.visibleClassName;
|
|
67
|
+
var mergedStyle = __assign(__assign({}, style), (visible ? visibleStyle : invisibleStyle));
|
|
68
|
+
var mergedClassName = classNames(className, visible ? visibleClassName : invisibleClassName);
|
|
69
|
+
return _jsx(Layer, __assign({}, props, { style: mergedStyle, className: mergedClassName }));
|
|
70
|
+
};
|
|
52
71
|
export default Layer;
|
package/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export { default as Badge } from "./components/Badge";
|
|
|
9
9
|
export { default as Banner } from "./components/Banner";
|
|
10
10
|
export { default as Select } from "./components/Select";
|
|
11
11
|
export { default as ClickOutside } from "./components/ClickOutside";
|
|
12
|
+
export * from "./components/Layer";
|
|
12
13
|
export { default as Layer } from "./components/Layer";
|
|
13
14
|
export { default as Spinner } from "./components/Spinner";
|
|
14
15
|
export * from "./hooks";
|
package/index.js
CHANGED
|
@@ -10,6 +10,7 @@ export { default as Badge } from "./components/Badge";
|
|
|
10
10
|
export { default as Banner } from "./components/Banner";
|
|
11
11
|
export { default as Select } from "./components/Select";
|
|
12
12
|
export { default as ClickOutside } from "./components/ClickOutside";
|
|
13
|
+
export * from "./components/Layer";
|
|
13
14
|
export { default as Layer } from "./components/Layer";
|
|
14
15
|
export { default as Spinner } from "./components/Spinner";
|
|
15
16
|
// Hooks
|