@citygross/components 0.17.10 → 0.17.12
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/build/@types/components/WarningLabel/WarningLabel.styles.d.ts +0 -1
- package/build/cjs/components/src/components/AvailabilityLabel/AvailabilityLabel.js +1 -1
- package/build/cjs/components/src/components/Modal/Modal.js +17 -5
- package/build/cjs/components/src/components/Modal/Modal.js.map +1 -1
- package/build/cjs/components/src/components/WarningLabel/WarningLabel.js +1 -1
- package/build/cjs/components/src/components/WarningLabel/WarningLabel.styles.js +1 -4
- package/build/cjs/components/src/components/WarningLabel/WarningLabel.styles.js.map +1 -1
- package/build/es/components/src/components/AvailabilityLabel/AvailabilityLabel.js +1 -1
- package/build/es/components/src/components/Modal/Modal.js +19 -7
- package/build/es/components/src/components/Modal/Modal.js.map +1 -1
- package/build/es/components/src/components/WarningLabel/WarningLabel.js +3 -3
- package/build/es/components/src/components/WarningLabel/WarningLabel.styles.js +2 -4
- package/build/es/components/src/components/WarningLabel/WarningLabel.styles.js.map +1 -1
- package/package.json +2 -2
|
@@ -5,4 +5,3 @@ export declare type TWarningIndicator = {
|
|
|
5
5
|
};
|
|
6
6
|
export declare const WarningIndicator: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, TWarningIndicator, never>;
|
|
7
7
|
export declare const IconWrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
8
|
-
export declare const BodyTextStyled: import("styled-components").StyledComponent<({ as, children, color, fontWeight, size, textAlign, ...props }: import("@citygross/typography").TBodyText) => import("react").JSX.Element, import("styled-components").DefaultTheme, {}, never>;
|
|
@@ -14,7 +14,7 @@ var AvailabilityLabel = function (_a) {
|
|
|
14
14
|
var label = _a.label, _b = _a.textSize, textSize = _b === void 0 ? typography.TextTypes.TextSize.EXTRASMALL : _b;
|
|
15
15
|
return (React__default["default"].createElement(AvailabilityLabel_styles.Root, null,
|
|
16
16
|
React__default["default"].createElement(AvailabilityLabel_styles.Dot, null),
|
|
17
|
-
React__default["default"].createElement(typography.BodyText, { size: textSize }, label)));
|
|
17
|
+
React__default["default"].createElement(typography.BodyText, { size: textSize, as: "span" }, label)));
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
exports.AvailabilityLabel = AvailabilityLabel;
|
|
@@ -37,18 +37,21 @@ var Modal = function (_a) {
|
|
|
37
37
|
var _b, _c, _d;
|
|
38
38
|
var children = _a.children, inertSelectors = _a.inertSelectors, _e = _a.labelCancel, labelCancel = _e === void 0 ? 'Avbryt' : _e, _f = _a.labelCta, labelCta = _f === void 0 ? 'Okej' : _f, _g = _a.noOverlay, noOverlay = _g === void 0 ? false : _g, onClose = _a.onClose, onConfirm = _a.onConfirm, portalHostSelector = _a.portalHostSelector, _h = _a.size, size = _h === void 0 ? exports.EModalSize.medium : _h, title = _a.title, variant = _a.variant;
|
|
39
39
|
var titleId = React.useId();
|
|
40
|
+
var dialogRef = React.useRef(null);
|
|
40
41
|
var previouslyFocusedElement = React.useRef(null);
|
|
42
|
+
var onCloseRef = React.useRef(onClose);
|
|
43
|
+
onCloseRef.current = onClose;
|
|
41
44
|
var portalRoot = React.useMemo(function () { return getPortalRoot(portalHostSelector); }, [portalHostSelector]);
|
|
42
|
-
React.
|
|
45
|
+
React.useLayoutEffect(function () {
|
|
43
46
|
if (typeof document === 'undefined')
|
|
44
47
|
return;
|
|
48
|
+
previouslyFocusedElement.current = document.activeElement;
|
|
45
49
|
var inertElements = Array.from(new Set(inertSelectors.flatMap(function (id) {
|
|
46
50
|
var element = document.getElementById(id);
|
|
47
51
|
return element ? [element] : [];
|
|
48
52
|
})));
|
|
49
53
|
var body = document.body;
|
|
50
54
|
var html = document.documentElement;
|
|
51
|
-
previouslyFocusedElement.current = document.activeElement;
|
|
52
55
|
var restoreInert = utils.toggleInert({
|
|
53
56
|
elements: inertElements,
|
|
54
57
|
isInert: true
|
|
@@ -58,8 +61,17 @@ var Modal = function (_a) {
|
|
|
58
61
|
body.style.overflow = 'hidden';
|
|
59
62
|
html.style.overflow = 'hidden';
|
|
60
63
|
var handleEscape = function (event) {
|
|
61
|
-
return utils.escapeKeyboardEventHandler({
|
|
64
|
+
return utils.escapeKeyboardEventHandler({
|
|
65
|
+
event: event,
|
|
66
|
+
onEscape: function () {
|
|
67
|
+
var _a;
|
|
68
|
+
(_a = onCloseRef.current) === null || _a === void 0 ? void 0 : _a.call(onCloseRef);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
62
71
|
};
|
|
72
|
+
var root = dialogRef.current;
|
|
73
|
+
var first = root === null || root === void 0 ? void 0 : root.querySelector(utils.focusableSelectors);
|
|
74
|
+
first === null || first === void 0 ? void 0 : first.focus();
|
|
63
75
|
document.addEventListener('keydown', handleEscape);
|
|
64
76
|
return function () {
|
|
65
77
|
restoreInert();
|
|
@@ -70,7 +82,7 @@ var Modal = function (_a) {
|
|
|
70
82
|
previouslyFocusedElement.current.focus();
|
|
71
83
|
}
|
|
72
84
|
};
|
|
73
|
-
}, [inertSelectors
|
|
85
|
+
}, [inertSelectors]);
|
|
74
86
|
if (!portalRoot)
|
|
75
87
|
return null;
|
|
76
88
|
var cancelButton = (React__default["default"].createElement(CgButton.CgButton, { onClick: onClose, variant: CgButton_types.EButtonVariant.secondary }, labelCancel));
|
|
@@ -80,7 +92,7 @@ var Modal = function (_a) {
|
|
|
80
92
|
}
|
|
81
93
|
};
|
|
82
94
|
return reactDom.createPortal(React__default["default"].createElement(Modal_styles.Overlay, { noOverlay: noOverlay, onMouseDown: handleBackdropMouseDown },
|
|
83
|
-
React__default["default"].createElement(Modal_styles.Frame, { "aria-labelledby": titleId, "aria-modal": "true", role: variant === exports.EModalVariant.destructive ? 'alertdialog' : 'dialog', size: size },
|
|
95
|
+
React__default["default"].createElement(Modal_styles.Frame, { ref: dialogRef, "aria-labelledby": titleId, "aria-modal": "true", role: variant === exports.EModalVariant.destructive ? 'alertdialog' : 'dialog', size: size },
|
|
84
96
|
React__default["default"].createElement(Modal_styles.Header, null,
|
|
85
97
|
React__default["default"].createElement(Modal_styles.Title, { color: (_b = designTokens.theme.palette) === null || _b === void 0 ? void 0 : _b.darkest, id: titleId }, title),
|
|
86
98
|
variant !== exports.EModalVariant.destructive && (React__default["default"].createElement(CgButton.CgButton, { "aria-label": labelCancel, circle: true, onClick: onClose, variant: CgButton_types.EButtonVariant.ghost },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Modal.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -14,7 +14,7 @@ function WarningLabel(_a) {
|
|
|
14
14
|
var text = _a.text, background = _a.background, icon = _a.icon;
|
|
15
15
|
return (React__default["default"].createElement(WarningLabel_styles.WarningIndicator, { background: background },
|
|
16
16
|
icon && React__default["default"].createElement(WarningLabel_styles.IconWrapper, null, icon),
|
|
17
|
-
React__default["default"].createElement(
|
|
17
|
+
React__default["default"].createElement(typography.BodyText, { size: typography.TextTypes.TextSize.TINY }, text)));
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
exports.WarningLabel = WarningLabel;
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var _tslib = require('../../../../_virtual/_tslib.js');
|
|
6
|
-
var typography = require('@citygross/typography');
|
|
7
6
|
var styled = require('styled-components');
|
|
8
7
|
|
|
9
8
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -12,10 +11,8 @@ var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
|
12
11
|
|
|
13
12
|
var WarningIndicator = styled__default["default"].div(templateObject_1 || (templateObject_1 = _tslib.__makeTemplateObject(["\n padding: ", "px\n ", "px;\n background-color: ", ";\n border-radius: ", "px;\n position: relative;\n display: flex;\n align-items: flex-start;\n gap: ", "px;\n width: fit-content;\n"], ["\n padding: ", "px\n ", "px;\n background-color: ", ";\n border-radius: ", "px;\n position: relative;\n display: flex;\n align-items: flex-start;\n gap: ", "px;\n width: fit-content;\n"])), function (props) { var _a; return (_a = props.theme.spacings) === null || _a === void 0 ? void 0 : _a.xxs; }, function (props) { var _a; return (_a = props.theme.spacings) === null || _a === void 0 ? void 0 : _a.xs; }, function (props) { return props.background; }, function (props) { var _a; return (_a = props.theme.attributes) === null || _a === void 0 ? void 0 : _a.borderRadius.big; }, function (props) { var _a; return (_a = props.theme.spacings) === null || _a === void 0 ? void 0 : _a.xxs; });
|
|
14
13
|
var IconWrapper = styled__default["default"].div(templateObject_2 || (templateObject_2 = _tslib.__makeTemplateObject(["\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n"], ["\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n"])));
|
|
15
|
-
var
|
|
16
|
-
var templateObject_1, templateObject_2, templateObject_3;
|
|
14
|
+
var templateObject_1, templateObject_2;
|
|
17
15
|
|
|
18
|
-
exports.BodyTextStyled = BodyTextStyled;
|
|
19
16
|
exports.IconWrapper = IconWrapper;
|
|
20
17
|
exports.WarningIndicator = WarningIndicator;
|
|
21
18
|
//# sourceMappingURL=WarningLabel.styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WarningLabel.styles.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"WarningLabel.styles.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
|
|
@@ -6,7 +6,7 @@ var AvailabilityLabel = function (_a) {
|
|
|
6
6
|
var label = _a.label, _b = _a.textSize, textSize = _b === void 0 ? TextTypes.TextSize.EXTRASMALL : _b;
|
|
7
7
|
return (React.createElement(Root, null,
|
|
8
8
|
React.createElement(Dot, null),
|
|
9
|
-
React.createElement(BodyText, { size: textSize }, label)));
|
|
9
|
+
React.createElement(BodyText, { size: textSize, as: "span" }, label)));
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export { AvailabilityLabel };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React, { useId, useRef, useMemo,
|
|
1
|
+
import React, { useId, useRef, useMemo, useLayoutEffect } from 'react';
|
|
2
2
|
import { createPortal } from 'react-dom';
|
|
3
3
|
import { theme } from '@citygross/design-tokens';
|
|
4
4
|
import { Icons } from '@citygross/icons';
|
|
5
|
-
import { toggleInert, escapeKeyboardEventHandler } from '@citygross/utils';
|
|
5
|
+
import { toggleInert, focusableSelectors, escapeKeyboardEventHandler } from '@citygross/utils';
|
|
6
6
|
import { CgButton } from '../CgButton/CgButton.js';
|
|
7
7
|
import { Overlay, Frame, Header, Title, Footer } from './Modal.styles.js';
|
|
8
8
|
import { EButtonVariant } from '../CgButton/CgButton.types.js';
|
|
@@ -29,18 +29,21 @@ var Modal = function (_a) {
|
|
|
29
29
|
var _b, _c, _d;
|
|
30
30
|
var children = _a.children, inertSelectors = _a.inertSelectors, _e = _a.labelCancel, labelCancel = _e === void 0 ? 'Avbryt' : _e, _f = _a.labelCta, labelCta = _f === void 0 ? 'Okej' : _f, _g = _a.noOverlay, noOverlay = _g === void 0 ? false : _g, onClose = _a.onClose, onConfirm = _a.onConfirm, portalHostSelector = _a.portalHostSelector, _h = _a.size, size = _h === void 0 ? EModalSize.medium : _h, title = _a.title, variant = _a.variant;
|
|
31
31
|
var titleId = useId();
|
|
32
|
+
var dialogRef = useRef(null);
|
|
32
33
|
var previouslyFocusedElement = useRef(null);
|
|
34
|
+
var onCloseRef = useRef(onClose);
|
|
35
|
+
onCloseRef.current = onClose;
|
|
33
36
|
var portalRoot = useMemo(function () { return getPortalRoot(portalHostSelector); }, [portalHostSelector]);
|
|
34
|
-
|
|
37
|
+
useLayoutEffect(function () {
|
|
35
38
|
if (typeof document === 'undefined')
|
|
36
39
|
return;
|
|
40
|
+
previouslyFocusedElement.current = document.activeElement;
|
|
37
41
|
var inertElements = Array.from(new Set(inertSelectors.flatMap(function (id) {
|
|
38
42
|
var element = document.getElementById(id);
|
|
39
43
|
return element ? [element] : [];
|
|
40
44
|
})));
|
|
41
45
|
var body = document.body;
|
|
42
46
|
var html = document.documentElement;
|
|
43
|
-
previouslyFocusedElement.current = document.activeElement;
|
|
44
47
|
var restoreInert = toggleInert({
|
|
45
48
|
elements: inertElements,
|
|
46
49
|
isInert: true
|
|
@@ -50,8 +53,17 @@ var Modal = function (_a) {
|
|
|
50
53
|
body.style.overflow = 'hidden';
|
|
51
54
|
html.style.overflow = 'hidden';
|
|
52
55
|
var handleEscape = function (event) {
|
|
53
|
-
return escapeKeyboardEventHandler({
|
|
56
|
+
return escapeKeyboardEventHandler({
|
|
57
|
+
event: event,
|
|
58
|
+
onEscape: function () {
|
|
59
|
+
var _a;
|
|
60
|
+
(_a = onCloseRef.current) === null || _a === void 0 ? void 0 : _a.call(onCloseRef);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
54
63
|
};
|
|
64
|
+
var root = dialogRef.current;
|
|
65
|
+
var first = root === null || root === void 0 ? void 0 : root.querySelector(focusableSelectors);
|
|
66
|
+
first === null || first === void 0 ? void 0 : first.focus();
|
|
55
67
|
document.addEventListener('keydown', handleEscape);
|
|
56
68
|
return function () {
|
|
57
69
|
restoreInert();
|
|
@@ -62,7 +74,7 @@ var Modal = function (_a) {
|
|
|
62
74
|
previouslyFocusedElement.current.focus();
|
|
63
75
|
}
|
|
64
76
|
};
|
|
65
|
-
}, [inertSelectors
|
|
77
|
+
}, [inertSelectors]);
|
|
66
78
|
if (!portalRoot)
|
|
67
79
|
return null;
|
|
68
80
|
var cancelButton = (React.createElement(CgButton, { onClick: onClose, variant: EButtonVariant.secondary }, labelCancel));
|
|
@@ -72,7 +84,7 @@ var Modal = function (_a) {
|
|
|
72
84
|
}
|
|
73
85
|
};
|
|
74
86
|
return createPortal(React.createElement(Overlay, { noOverlay: noOverlay, onMouseDown: handleBackdropMouseDown },
|
|
75
|
-
React.createElement(Frame, { "aria-labelledby": titleId, "aria-modal": "true", role: variant === EModalVariant.destructive ? 'alertdialog' : 'dialog', size: size },
|
|
87
|
+
React.createElement(Frame, { ref: dialogRef, "aria-labelledby": titleId, "aria-modal": "true", role: variant === EModalVariant.destructive ? 'alertdialog' : 'dialog', size: size },
|
|
76
88
|
React.createElement(Header, null,
|
|
77
89
|
React.createElement(Title, { color: (_b = theme.palette) === null || _b === void 0 ? void 0 : _b.darkest, id: titleId }, title),
|
|
78
90
|
variant !== EModalVariant.destructive && (React.createElement(CgButton, { "aria-label": labelCancel, circle: true, onClick: onClose, variant: EButtonVariant.ghost },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Modal.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { TextTypes } from '@citygross/typography';
|
|
3
|
-
import { WarningIndicator, IconWrapper
|
|
2
|
+
import { BodyText, TextTypes } from '@citygross/typography';
|
|
3
|
+
import { WarningIndicator, IconWrapper } from './WarningLabel.styles.js';
|
|
4
4
|
|
|
5
5
|
function WarningLabel(_a) {
|
|
6
6
|
var text = _a.text, background = _a.background, icon = _a.icon;
|
|
7
7
|
return (React.createElement(WarningIndicator, { background: background },
|
|
8
8
|
icon && React.createElement(IconWrapper, null, icon),
|
|
9
|
-
React.createElement(
|
|
9
|
+
React.createElement(BodyText, { size: TextTypes.TextSize.TINY }, text)));
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export { WarningLabel };
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { __makeTemplateObject } from '../../../../_virtual/_tslib.js';
|
|
2
|
-
import { BodyText } from '@citygross/typography';
|
|
3
2
|
import styled from 'styled-components';
|
|
4
3
|
|
|
5
4
|
var WarningIndicator = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding: ", "px\n ", "px;\n background-color: ", ";\n border-radius: ", "px;\n position: relative;\n display: flex;\n align-items: flex-start;\n gap: ", "px;\n width: fit-content;\n"], ["\n padding: ", "px\n ", "px;\n background-color: ", ";\n border-radius: ", "px;\n position: relative;\n display: flex;\n align-items: flex-start;\n gap: ", "px;\n width: fit-content;\n"])), function (props) { var _a; return (_a = props.theme.spacings) === null || _a === void 0 ? void 0 : _a.xxs; }, function (props) { var _a; return (_a = props.theme.spacings) === null || _a === void 0 ? void 0 : _a.xs; }, function (props) { return props.background; }, function (props) { var _a; return (_a = props.theme.attributes) === null || _a === void 0 ? void 0 : _a.borderRadius.big; }, function (props) { var _a; return (_a = props.theme.spacings) === null || _a === void 0 ? void 0 : _a.xxs; });
|
|
6
5
|
var IconWrapper = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n"], ["\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n"])));
|
|
7
|
-
var
|
|
8
|
-
var templateObject_1, templateObject_2, templateObject_3;
|
|
6
|
+
var templateObject_1, templateObject_2;
|
|
9
7
|
|
|
10
|
-
export {
|
|
8
|
+
export { IconWrapper, WarningIndicator };
|
|
11
9
|
//# sourceMappingURL=WarningLabel.styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WarningLabel.styles.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"WarningLabel.styles.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@citygross/components",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.12",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./build/cjs/components/src/index.js",
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"react-slick": "^0.30.1",
|
|
77
77
|
"slick-carousel": "^1.8.1"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "3d6105e54543744d45aef0c455fbf83ce788d1e4"
|
|
80
80
|
}
|