@citygross/components 0.16.25 → 0.16.27

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.
@@ -12,6 +12,7 @@ export declare type TModal = {
12
12
  inertSelectors: string[];
13
13
  labelCancel?: string;
14
14
  labelCta?: string;
15
+ noOverlay?: boolean;
15
16
  onClose: () => void;
16
17
  onConfirm: () => void;
17
18
  portalHostSelector: string;
@@ -19,4 +20,4 @@ export declare type TModal = {
19
20
  title: string;
20
21
  variant: EModalVariant;
21
22
  } & React.HTMLAttributes<HTMLDivElement>;
22
- export declare const Modal: ({ children, inertSelectors, labelCancel, labelCta, onClose, onConfirm, portalHostSelector, size, title, variant }: TModal) => React.ReactPortal | null;
23
+ export declare const Modal: ({ children, inertSelectors, labelCancel, labelCta, noOverlay, onClose, onConfirm, portalHostSelector, size, title, variant }: TModal) => React.ReactPortal | null;
@@ -1,9 +1,13 @@
1
1
  /// <reference types="react" />
2
2
  import { type TModal } from './Modal';
3
- export declare const Overlay: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
3
+ declare type TOverlay = Pick<TModal, 'noOverlay'>;
4
+ export declare const Overlay: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, TOverlay, never>;
4
5
  declare type TFrame = Pick<TModal, 'size'>;
5
6
  export declare const Frame: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, TFrame, never>;
6
7
  export declare const Header: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
7
- export declare const Title: import("styled-components").StyledComponent<({ children, color, fontWeight, size, textAlign, ...props }: import("@citygross/typography/build/bodyText/bodyText").TBodyText) => import("react").JSX.Element, import("styled-components").DefaultTheme, {}, never>;
8
- export declare const Footer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
8
+ export declare const Title: import("styled-components").StyledComponent<({ children, lineThrough, color, fontWeight, ...props }: import("@citygross/typography/build/headers/h2/h2").TH2) => import("react").JSX.Element, import("styled-components").DefaultTheme, {}, never>;
9
+ declare type TFooter = {
10
+ rowReverse?: boolean;
11
+ };
12
+ export declare const Footer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, TFooter, never>;
9
13
  export {};
@@ -34,11 +34,9 @@ var getPortalRoot = function (portalHostSelector) {
34
34
  return (_a = hostElement === null || hostElement === void 0 ? void 0 : hostElement.parentElement) !== null && _a !== void 0 ? _a : document.body;
35
35
  };
36
36
  var Modal = function (_a) {
37
- var _b, _c;
38
- var children = _a.children, inertSelectors = _a.inertSelectors, _d = _a.labelCancel, labelCancel = _d === void 0 ? 'Avbryt' : _d, _e = _a.labelCta, labelCta = _e === void 0 ? 'Okej' : _e, onClose = _a.onClose, onConfirm = _a.onConfirm, portalHostSelector = _a.portalHostSelector, _f = _a.size, size = _f === void 0 ? exports.EModalSize.medium : _f, title = _a.title, variant = _a.variant;
37
+ var _b, _c, _d;
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 modalRef = React.useRef(null);
41
- var cancelButtonRef = React.useRef(null);
42
40
  var previouslyFocusedElement = React.useRef(null);
43
41
  var portalRoot = React.useMemo(function () { return getPortalRoot(portalHostSelector); }, [portalHostSelector]);
44
42
  React.useEffect(function () {
@@ -63,16 +61,8 @@ var Modal = function (_a) {
63
61
  return utils.escapeKeyboardEventHandler({ event: event, onEscape: onClose });
64
62
  };
65
63
  document.addEventListener('keydown', handleEscape);
66
- requestAnimationFrame(function () {
67
- var _a, _b;
68
- if (variant === exports.EModalVariant.destructive) {
69
- (_a = cancelButtonRef.current) === null || _a === void 0 ? void 0 : _a.focus();
70
- return;
71
- }
72
- (_b = modalRef.current) === null || _b === void 0 ? void 0 : _b.focus();
73
- });
74
64
  return function () {
75
- restoreInert === null || restoreInert === void 0 ? void 0 : restoreInert();
65
+ restoreInert();
76
66
  body.style.overflow = previousBodyOverflow;
77
67
  html.style.overflow = previousHtmlOverflow;
78
68
  document.removeEventListener('keydown', handleEscape);
@@ -80,19 +70,21 @@ var Modal = function (_a) {
80
70
  previouslyFocusedElement.current.focus();
81
71
  }
82
72
  };
83
- }, [inertSelectors, onClose, variant]);
73
+ }, [inertSelectors, onClose]);
84
74
  if (!portalRoot)
85
75
  return null;
86
- return reactDom.createPortal(React__default["default"].createElement(Modal_styles.Overlay, { onClick: onClose },
87
- React__default["default"].createElement(Modal_styles.Frame, { "aria-labelledby": titleId, "aria-modal": "true", onClick: function (event) { return event.stopPropagation(); }, ref: modalRef, role: variant === exports.EModalVariant.destructive ? 'alertdialog' : 'dialog', size: size },
76
+ var cancelButton = (React__default["default"].createElement(CgButton.CgButton, { onClick: onClose, variant: CgButton_types.EButtonVariant.secondary }, labelCancel));
77
+ return reactDom.createPortal(React__default["default"].createElement(Modal_styles.Overlay, { noOverlay: noOverlay, onClick: onClose },
78
+ React__default["default"].createElement(Modal_styles.Frame, { "aria-labelledby": titleId, "aria-modal": "true", onClick: function (event) { return event.stopPropagation(); }, role: variant === exports.EModalVariant.destructive ? 'alertdialog' : 'dialog', size: size },
88
79
  React__default["default"].createElement(Modal_styles.Header, null,
89
- React__default["default"].createElement(Modal_styles.Title, { fontWeight: "semiBold", id: titleId }, title),
80
+ React__default["default"].createElement(Modal_styles.Title, { color: (_b = designTokens.theme.palette) === null || _b === void 0 ? void 0 : _b.darkest, id: titleId }, title),
90
81
  variant !== exports.EModalVariant.destructive && (React__default["default"].createElement(CgButton.CgButton, { "aria-label": labelCancel, circle: true, onClick: onClose, variant: CgButton_types.EButtonVariant.ghost },
91
- React__default["default"].createElement(icons.Icons.Cross, { "aria-hidden": "true", height: (_b = designTokens.theme.spacings) === null || _b === void 0 ? void 0 : _b.sm2, width: (_c = designTokens.theme.spacings) === null || _c === void 0 ? void 0 : _c.sm2 })))),
82
+ React__default["default"].createElement(icons.Icons.Cross, { "aria-hidden": "true", height: (_c = designTokens.theme.spacings) === null || _c === void 0 ? void 0 : _c.sm2, width: (_d = designTokens.theme.spacings) === null || _d === void 0 ? void 0 : _d.sm2 })))),
92
83
  children,
93
- React__default["default"].createElement(Modal_styles.Footer, null,
84
+ React__default["default"].createElement(Modal_styles.Footer, { rowReverse: variant === exports.EModalVariant.destructive },
85
+ variant === exports.EModalVariant.destructive && cancelButton,
94
86
  React__default["default"].createElement(CgButton.CgButton, { onClick: onConfirm, variant: CgButton_types.EButtonVariant.primary }, labelCta),
95
- variant !== exports.EModalVariant.informational && (React__default["default"].createElement(CgButton.CgButton, { onClick: onClose, ref: cancelButtonRef, variant: CgButton_types.EButtonVariant.secondary }, labelCancel))))), portalRoot);
87
+ variant === exports.EModalVariant.transactional && cancelButton))), portalRoot);
96
88
  };
97
89
 
98
90
  exports.Modal = Modal;
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"Modal.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -12,9 +12,9 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
12
12
  var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
13
13
 
14
14
  var Overlay = styled__default["default"].div(templateObject_1 || (templateObject_1 = _tslib.__makeTemplateObject(["\n background: ", ";\n box-sizing: border-box;\n display: flex;\n align-items: center;\n justify-content: center;\n inset: 0;\n min-height: 100%;\n overflow-y: auto;\n padding: ", ";\n position: fixed;\n z-index: ", ";\n"], ["\n background: ", ";\n box-sizing: border-box;\n display: flex;\n align-items: center;\n justify-content: center;\n inset: 0;\n min-height: 100%;\n overflow-y: auto;\n padding: ", ";\n position: fixed;\n z-index: ", ";\n"])), function (_a) {
15
- var _b;
16
- var theme = _a.theme;
17
- return (_b = theme.palette) === null || _b === void 0 ? void 0 : _b.darkOverlay;
15
+ var _b, _c;
16
+ var theme = _a.theme, noOverlay = _a.noOverlay;
17
+ return noOverlay ? (_b = theme.palette) === null || _b === void 0 ? void 0 : _b.transparent : (_c = theme.palette) === null || _c === void 0 ? void 0 : _c.darkOverlay;
18
18
  }, function (_a) {
19
19
  var _b, _c, _d;
20
20
  var theme = _a.theme;
@@ -60,12 +60,11 @@ var Header = styled__default["default"].div(templateObject_3 || (templateObject_
60
60
  var theme = _a.theme;
61
61
  return (_b = theme.spacings) === null || _b === void 0 ? void 0 : _b.sm;
62
62
  });
63
- var Title = styled__default["default"](typography.BodyText)(templateObject_4 || (templateObject_4 = _tslib.__makeTemplateObject(["\n font-size: ", "px;\n"], ["\n font-size: ", "px;\n"])), function (_a) {
64
- var _b, _c;
65
- var theme = _a.theme;
66
- return (_c = (_b = theme.typography) === null || _b === void 0 ? void 0 : _b.size) === null || _c === void 0 ? void 0 : _c.s4;
67
- });
68
- var Footer = styled__default["default"].div(templateObject_5 || (templateObject_5 = _tslib.__makeTemplateObject(["\n display: flex;\n gap: ", "px;\n margin-top: ", "px;\n width: 100%;\n\n > * {\n flex: 1 1 0;\n min-width: 0;\n }\n"], ["\n display: flex;\n gap: ", "px;\n margin-top: ", "px;\n width: 100%;\n\n > * {\n flex: 1 1 0;\n min-width: 0;\n }\n"])), function (_a) {
63
+ var Title = styled__default["default"](typography.H2)(templateObject_4 || (templateObject_4 = _tslib.__makeTemplateObject(["\n margin: 0;\n"], ["\n margin: 0;\n"])));
64
+ var Footer = styled__default["default"].div(templateObject_5 || (templateObject_5 = _tslib.__makeTemplateObject(["\n display: flex;\n flex-direction: ", ";\n gap: ", "px;\n margin-top: ", "px;\n width: 100%;\n\n > * {\n flex: 1 1 0;\n min-width: 0;\n }\n"], ["\n display: flex;\n flex-direction: ", ";\n gap: ", "px;\n margin-top: ", "px;\n width: 100%;\n\n > * {\n flex: 1 1 0;\n min-width: 0;\n }\n"])), function (_a) {
65
+ var rowReverse = _a.rowReverse;
66
+ return (rowReverse ? 'row-reverse' : 'row');
67
+ }, function (_a) {
69
68
  var _b;
70
69
  var theme = _a.theme;
71
70
  return (_b = theme.spacings) === null || _b === void 0 ? void 0 : _b.sm;
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.styles.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"Modal.styles.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -535,31 +535,32 @@ var selectKeyboardEventHandler = function (_a) {
535
535
 
536
536
  var toggleInert = function (_a) {
537
537
  var elements = _a.elements, isInert = _a.isInert;
538
- var snapshots = elements
539
- .filter(function (element) { return Boolean(element); })
540
- .map(function (element) { return ({
538
+ var list = elements.filter(function (element) {
539
+ return Boolean(element);
540
+ });
541
+ if (!isInert) {
542
+ list.forEach(function (element) {
543
+ var hadInert = element.hasAttribute('inert');
544
+ if (!hadInert) {
545
+ element.removeAttribute('inert');
546
+ }
547
+ });
548
+ return function () { };
549
+ }
550
+ var snapshots = list.map(function (element) { return ({
541
551
  element: element,
542
- hadInert: element.hasAttribute('inert')
552
+ setByThisCall: !element.hasAttribute('inert')
543
553
  }); });
544
554
  snapshots.forEach(function (_a) {
545
- var element = _a.element, hadInert = _a.hadInert;
546
- if (isInert) {
547
- if (!hadInert) {
548
- element.setAttribute('inert', '');
549
- }
550
- return;
551
- }
552
- if (!hadInert) {
553
- element.removeAttribute('inert');
555
+ var element = _a.element, setByThisCall = _a.setByThisCall;
556
+ if (setByThisCall) {
557
+ element.setAttribute('inert', '');
554
558
  }
555
559
  });
556
560
  return function () {
557
561
  snapshots.forEach(function (_a) {
558
- var element = _a.element, hadInert = _a.hadInert;
559
- if (hadInert) {
560
- element.setAttribute('inert', '');
561
- }
562
- else {
562
+ var element = _a.element, setByThisCall = _a.setByThisCall;
563
+ if (setByThisCall) {
563
564
  element.removeAttribute('inert');
564
565
  }
565
566
  });