@nulogy/components 8.15.3 → 8.16.0
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/dist/main.js +41 -14
- package/dist/main.module.js +41 -14
- package/dist/src/Layout/Sidebar.d.ts +9 -4
- package/dist/src/Layout/Sidebar.story.d.ts +4 -0
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -41989,6 +41989,14 @@
|
|
|
41989
41989
|
}, children));
|
|
41990
41990
|
};
|
|
41991
41991
|
|
|
41992
|
+
var sidebarWidths = {
|
|
41993
|
+
xs: "400px",
|
|
41994
|
+
s: "520px",
|
|
41995
|
+
m: "640px",
|
|
41996
|
+
l: "768px",
|
|
41997
|
+
xl: "1024px"
|
|
41998
|
+
};
|
|
41999
|
+
|
|
41992
42000
|
var focusFirstElement = function focusFirstElement() {
|
|
41993
42001
|
var FOCUSABLE_EL_SELECTOR = "button, a[href], select, textarea, input, [tabindex]:not([tabindex='-1'])";
|
|
41994
42002
|
var focusable = document.querySelectorAll(FOCUSABLE_EL_SELECTOR);
|
|
@@ -42030,11 +42038,13 @@
|
|
|
42030
42038
|
});
|
|
42031
42039
|
};
|
|
42032
42040
|
|
|
42033
|
-
|
|
42041
|
+
function Sidebar(_a) {
|
|
42042
|
+
var _b;
|
|
42043
|
+
|
|
42034
42044
|
var _a$p = _a.p,
|
|
42035
|
-
p = _a$p === void 0 ? "
|
|
42045
|
+
p = _a$p === void 0 ? "x2" : _a$p,
|
|
42036
42046
|
_a$width = _a.width,
|
|
42037
|
-
width = _a$width === void 0 ? "
|
|
42047
|
+
width = _a$width === void 0 ? "xs" : _a$width,
|
|
42038
42048
|
children = _a.children,
|
|
42039
42049
|
onClose = _a.onClose,
|
|
42040
42050
|
title = _a.title,
|
|
@@ -42058,8 +42068,11 @@
|
|
|
42058
42068
|
disableScroll = _a$disableScroll === void 0 ? true : _a$disableScroll,
|
|
42059
42069
|
_a$hideCloseButton = _a.hideCloseButton,
|
|
42060
42070
|
hideCloseButton = _a$hideCloseButton === void 0 ? false : _a$hideCloseButton,
|
|
42061
|
-
zIndex = _a.zIndex,
|
|
42062
|
-
|
|
42071
|
+
_a$zIndex = _a.zIndex,
|
|
42072
|
+
zIndex = _a$zIndex === void 0 ? "sidebar" : _a$zIndex,
|
|
42073
|
+
helpText = _a.helpText,
|
|
42074
|
+
renderHelpText = _a.renderHelpText,
|
|
42075
|
+
props = __rest(_a, ["p", "width", "children", "onClose", "title", "isOpen", "footer", "closeButtonTestId", "closeButtonAriaLabel", "offset", "triggerRef", "duration", "top", "closeOnOutsideClick", "overlay", "disableScroll", "hideCloseButton", "zIndex", "helpText", "renderHelpText"]);
|
|
42063
42076
|
|
|
42064
42077
|
var closeButton = React.useRef(null);
|
|
42065
42078
|
|
|
@@ -42072,7 +42085,10 @@
|
|
|
42072
42085
|
|
|
42073
42086
|
var sideBarRef = React.useRef(null);
|
|
42074
42087
|
var contentRef = React.useRef(null);
|
|
42088
|
+
var selectedWidth = (_b = sidebarWidths[width]) !== null && _b !== void 0 ? _b : width;
|
|
42075
42089
|
React.useEffect(function () {
|
|
42090
|
+
var _a;
|
|
42091
|
+
|
|
42076
42092
|
if (closeButton.current && isOpen) {
|
|
42077
42093
|
if (closeButton && closeButton.current) {
|
|
42078
42094
|
closeButton.current.focus();
|
|
@@ -42081,7 +42097,7 @@
|
|
|
42081
42097
|
}
|
|
42082
42098
|
} else if (shouldUpdateFocus) {
|
|
42083
42099
|
if (triggerRef) {
|
|
42084
|
-
triggerRef.current.focus();
|
|
42100
|
+
(_a = triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
42085
42101
|
} else {
|
|
42086
42102
|
focusFirstElement();
|
|
42087
42103
|
}
|
|
@@ -42141,11 +42157,11 @@
|
|
|
42141
42157
|
position: "fixed",
|
|
42142
42158
|
top: top,
|
|
42143
42159
|
right: offset,
|
|
42144
|
-
width: typeof
|
|
42160
|
+
width: typeof selectedWidth === "string" ? {
|
|
42145
42161
|
default: "100%",
|
|
42146
|
-
small:
|
|
42147
|
-
} :
|
|
42148
|
-
zIndex: zIndex
|
|
42162
|
+
small: selectedWidth
|
|
42163
|
+
} : selectedWidth,
|
|
42164
|
+
zIndex: zIndex,
|
|
42149
42165
|
ref: sideBarRef
|
|
42150
42166
|
}, props), /*#__PURE__*/React__default["default"].createElement(Flex, {
|
|
42151
42167
|
p: p,
|
|
@@ -42157,9 +42173,14 @@
|
|
|
42157
42173
|
overflowBehaviour: "contain"
|
|
42158
42174
|
}
|
|
42159
42175
|
}, /*#__PURE__*/React__default["default"].createElement(Flex, {
|
|
42160
|
-
|
|
42161
|
-
alignItems: "flex-start",
|
|
42176
|
+
flexDirection: "column",
|
|
42162
42177
|
pb: "x3"
|
|
42178
|
+
}, /*#__PURE__*/React__default["default"].createElement(Flex, {
|
|
42179
|
+
flexDirection: "column",
|
|
42180
|
+
pb: "x2"
|
|
42181
|
+
}, /*#__PURE__*/React__default["default"].createElement(Flex, {
|
|
42182
|
+
justifyContent: "space-between",
|
|
42183
|
+
alignItems: "flex-start"
|
|
42163
42184
|
}, title && /*#__PURE__*/React__default["default"].createElement(Flex, {
|
|
42164
42185
|
alignItems: "center",
|
|
42165
42186
|
height: "100%"
|
|
@@ -42174,7 +42195,13 @@
|
|
|
42174
42195
|
onClick: onClose,
|
|
42175
42196
|
"data-testid": closeButtonTestId,
|
|
42176
42197
|
"aria-label": closeButtonAriaLabel || t("close")
|
|
42177
|
-
}))), /*#__PURE__*/React__default["default"].createElement(
|
|
42198
|
+
}))), renderHelpText ? renderHelpText() : helpText && /*#__PURE__*/React__default["default"].createElement(Text, {
|
|
42199
|
+
pt: "x1",
|
|
42200
|
+
color: "midGrey"
|
|
42201
|
+
}, helpText)), /*#__PURE__*/React__default["default"].createElement(Divider$1, {
|
|
42202
|
+
m: "0 -8px",
|
|
42203
|
+
width: "calc(100% + 16px)"
|
|
42204
|
+
})), /*#__PURE__*/React__default["default"].createElement(AnimatedBox, {
|
|
42178
42205
|
variants: childVariants,
|
|
42179
42206
|
animate: isOpen ? "open" : "closed",
|
|
42180
42207
|
flexGrow: 1,
|
|
@@ -42192,7 +42219,7 @@
|
|
|
42192
42219
|
}, footer), overlay && disableScroll && isOpen && /*#__PURE__*/React__default["default"].createElement(PreventBodyElementScrolling, {
|
|
42193
42220
|
scrollRef: sideBarRef
|
|
42194
42221
|
})));
|
|
42195
|
-
}
|
|
42222
|
+
}
|
|
42196
42223
|
|
|
42197
42224
|
var LoadingAnimation = function LoadingAnimation(_ref) {
|
|
42198
42225
|
var inactive = _ref.inactive;
|
package/dist/main.module.js
CHANGED
|
@@ -41966,6 +41966,14 @@ var Page = function Page(_a) {
|
|
|
41966
41966
|
}, children));
|
|
41967
41967
|
};
|
|
41968
41968
|
|
|
41969
|
+
var sidebarWidths = {
|
|
41970
|
+
xs: "400px",
|
|
41971
|
+
s: "520px",
|
|
41972
|
+
m: "640px",
|
|
41973
|
+
l: "768px",
|
|
41974
|
+
xl: "1024px"
|
|
41975
|
+
};
|
|
41976
|
+
|
|
41969
41977
|
var focusFirstElement = function focusFirstElement() {
|
|
41970
41978
|
var FOCUSABLE_EL_SELECTOR = "button, a[href], select, textarea, input, [tabindex]:not([tabindex='-1'])";
|
|
41971
41979
|
var focusable = document.querySelectorAll(FOCUSABLE_EL_SELECTOR);
|
|
@@ -42007,11 +42015,13 @@ var SidebarOverlay = function SidebarOverlay(_ref) {
|
|
|
42007
42015
|
});
|
|
42008
42016
|
};
|
|
42009
42017
|
|
|
42010
|
-
|
|
42018
|
+
function Sidebar(_a) {
|
|
42019
|
+
var _b;
|
|
42020
|
+
|
|
42011
42021
|
var _a$p = _a.p,
|
|
42012
|
-
p = _a$p === void 0 ? "
|
|
42022
|
+
p = _a$p === void 0 ? "x2" : _a$p,
|
|
42013
42023
|
_a$width = _a.width,
|
|
42014
|
-
width = _a$width === void 0 ? "
|
|
42024
|
+
width = _a$width === void 0 ? "xs" : _a$width,
|
|
42015
42025
|
children = _a.children,
|
|
42016
42026
|
onClose = _a.onClose,
|
|
42017
42027
|
title = _a.title,
|
|
@@ -42035,8 +42045,11 @@ var Sidebar = function Sidebar(_a) {
|
|
|
42035
42045
|
disableScroll = _a$disableScroll === void 0 ? true : _a$disableScroll,
|
|
42036
42046
|
_a$hideCloseButton = _a.hideCloseButton,
|
|
42037
42047
|
hideCloseButton = _a$hideCloseButton === void 0 ? false : _a$hideCloseButton,
|
|
42038
|
-
zIndex = _a.zIndex,
|
|
42039
|
-
|
|
42048
|
+
_a$zIndex = _a.zIndex,
|
|
42049
|
+
zIndex = _a$zIndex === void 0 ? "sidebar" : _a$zIndex,
|
|
42050
|
+
helpText = _a.helpText,
|
|
42051
|
+
renderHelpText = _a.renderHelpText,
|
|
42052
|
+
props = __rest(_a, ["p", "width", "children", "onClose", "title", "isOpen", "footer", "closeButtonTestId", "closeButtonAriaLabel", "offset", "triggerRef", "duration", "top", "closeOnOutsideClick", "overlay", "disableScroll", "hideCloseButton", "zIndex", "helpText", "renderHelpText"]);
|
|
42040
42053
|
|
|
42041
42054
|
var closeButton = useRef(null);
|
|
42042
42055
|
|
|
@@ -42049,7 +42062,10 @@ var Sidebar = function Sidebar(_a) {
|
|
|
42049
42062
|
|
|
42050
42063
|
var sideBarRef = useRef(null);
|
|
42051
42064
|
var contentRef = useRef(null);
|
|
42065
|
+
var selectedWidth = (_b = sidebarWidths[width]) !== null && _b !== void 0 ? _b : width;
|
|
42052
42066
|
useEffect(function () {
|
|
42067
|
+
var _a;
|
|
42068
|
+
|
|
42053
42069
|
if (closeButton.current && isOpen) {
|
|
42054
42070
|
if (closeButton && closeButton.current) {
|
|
42055
42071
|
closeButton.current.focus();
|
|
@@ -42058,7 +42074,7 @@ var Sidebar = function Sidebar(_a) {
|
|
|
42058
42074
|
}
|
|
42059
42075
|
} else if (shouldUpdateFocus) {
|
|
42060
42076
|
if (triggerRef) {
|
|
42061
|
-
triggerRef.current.focus();
|
|
42077
|
+
(_a = triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
42062
42078
|
} else {
|
|
42063
42079
|
focusFirstElement();
|
|
42064
42080
|
}
|
|
@@ -42118,11 +42134,11 @@ var Sidebar = function Sidebar(_a) {
|
|
|
42118
42134
|
position: "fixed",
|
|
42119
42135
|
top: top,
|
|
42120
42136
|
right: offset,
|
|
42121
|
-
width: typeof
|
|
42137
|
+
width: typeof selectedWidth === "string" ? {
|
|
42122
42138
|
default: "100%",
|
|
42123
|
-
small:
|
|
42124
|
-
} :
|
|
42125
|
-
zIndex: zIndex
|
|
42139
|
+
small: selectedWidth
|
|
42140
|
+
} : selectedWidth,
|
|
42141
|
+
zIndex: zIndex,
|
|
42126
42142
|
ref: sideBarRef
|
|
42127
42143
|
}, props), /*#__PURE__*/React__default.createElement(Flex, {
|
|
42128
42144
|
p: p,
|
|
@@ -42134,9 +42150,14 @@ var Sidebar = function Sidebar(_a) {
|
|
|
42134
42150
|
overflowBehaviour: "contain"
|
|
42135
42151
|
}
|
|
42136
42152
|
}, /*#__PURE__*/React__default.createElement(Flex, {
|
|
42137
|
-
|
|
42138
|
-
alignItems: "flex-start",
|
|
42153
|
+
flexDirection: "column",
|
|
42139
42154
|
pb: "x3"
|
|
42155
|
+
}, /*#__PURE__*/React__default.createElement(Flex, {
|
|
42156
|
+
flexDirection: "column",
|
|
42157
|
+
pb: "x2"
|
|
42158
|
+
}, /*#__PURE__*/React__default.createElement(Flex, {
|
|
42159
|
+
justifyContent: "space-between",
|
|
42160
|
+
alignItems: "flex-start"
|
|
42140
42161
|
}, title && /*#__PURE__*/React__default.createElement(Flex, {
|
|
42141
42162
|
alignItems: "center",
|
|
42142
42163
|
height: "100%"
|
|
@@ -42151,7 +42172,13 @@ var Sidebar = function Sidebar(_a) {
|
|
|
42151
42172
|
onClick: onClose,
|
|
42152
42173
|
"data-testid": closeButtonTestId,
|
|
42153
42174
|
"aria-label": closeButtonAriaLabel || t("close")
|
|
42154
|
-
}))), /*#__PURE__*/React__default.createElement(
|
|
42175
|
+
}))), renderHelpText ? renderHelpText() : helpText && /*#__PURE__*/React__default.createElement(Text, {
|
|
42176
|
+
pt: "x1",
|
|
42177
|
+
color: "midGrey"
|
|
42178
|
+
}, helpText)), /*#__PURE__*/React__default.createElement(Divider$1, {
|
|
42179
|
+
m: "0 -8px",
|
|
42180
|
+
width: "calc(100% + 16px)"
|
|
42181
|
+
})), /*#__PURE__*/React__default.createElement(AnimatedBox, {
|
|
42155
42182
|
variants: childVariants,
|
|
42156
42183
|
animate: isOpen ? "open" : "closed",
|
|
42157
42184
|
flexGrow: 1,
|
|
@@ -42169,7 +42196,7 @@ var Sidebar = function Sidebar(_a) {
|
|
|
42169
42196
|
}, footer), overlay && disableScroll && isOpen && /*#__PURE__*/React__default.createElement(PreventBodyElementScrolling, {
|
|
42170
42197
|
scrollRef: sideBarRef
|
|
42171
42198
|
})));
|
|
42172
|
-
}
|
|
42199
|
+
}
|
|
42173
42200
|
|
|
42174
42201
|
var LoadingAnimation = function LoadingAnimation(_ref) {
|
|
42175
42202
|
var inactive = _ref.inactive;
|
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
import React, { RefObject } from "react";
|
|
2
2
|
import { AnimatedBoxProps } from "../Box/Box";
|
|
3
|
-
type
|
|
3
|
+
type PredefinedSidebarWidth = "xs" | "s" | "m" | "l" | "xl";
|
|
4
|
+
type SidebarWidth = PredefinedSidebarWidth | (string & {});
|
|
5
|
+
type SidebarProps = Omit<AnimatedBoxProps, "width"> & {
|
|
4
6
|
children?: React.ReactNode;
|
|
5
|
-
onClose?: (
|
|
7
|
+
onClose?: () => void;
|
|
6
8
|
title?: string;
|
|
7
9
|
isOpen?: boolean;
|
|
8
10
|
footer?: React.ReactNode;
|
|
9
11
|
closeButtonTestId?: string;
|
|
10
12
|
closeButtonAriaLabel?: string;
|
|
11
13
|
offset?: string;
|
|
12
|
-
triggerRef?: RefObject<
|
|
14
|
+
triggerRef?: RefObject<HTMLInputElement | HTMLButtonElement>;
|
|
13
15
|
duration?: number;
|
|
14
16
|
closeOnOutsideClick?: boolean;
|
|
15
17
|
overlay?: boolean;
|
|
16
18
|
disableScroll?: boolean;
|
|
17
19
|
hideCloseButton?: boolean;
|
|
20
|
+
width?: SidebarWidth;
|
|
21
|
+
helpText?: React.ReactNode;
|
|
22
|
+
renderHelpText?: () => React.ReactNode;
|
|
18
23
|
};
|
|
19
|
-
declare
|
|
24
|
+
declare function Sidebar({ p, width, children, onClose, title, isOpen, footer, closeButtonTestId, closeButtonAriaLabel, offset, triggerRef, duration, top, closeOnOutsideClick, overlay, disableScroll, hideCloseButton, zIndex, helpText, renderHelpText, ...props }: SidebarProps): React.JSX.Element;
|
|
20
25
|
export default Sidebar;
|
|
@@ -16,3 +16,7 @@ export declare const WithCustomOffset: () => React.JSX.Element;
|
|
|
16
16
|
export declare const DontCloseOnOutsideClick: () => React.JSX.Element;
|
|
17
17
|
export declare const WithoutCloseButton: () => React.JSX.Element;
|
|
18
18
|
export declare const WithALongTitle: () => React.JSX.Element;
|
|
19
|
+
export declare const WithDifferentWidths: () => React.JSX.Element;
|
|
20
|
+
export declare const WithHelpText: () => React.JSX.Element;
|
|
21
|
+
export declare const WithOtherElementsInHelpText: () => React.JSX.Element;
|
|
22
|
+
export declare const WithARenderedHelpText: () => React.JSX.Element;
|