@citygross/components 0.16.24 → 0.16.26

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.
@@ -62,7 +62,7 @@ function CartSummary(_a) {
62
62
  ? pickingFeeFromLabel.trim()
63
63
  : undefined;
64
64
  var chargeColor = charge.color;
65
- return (React.createElement(CartLine, { key: charge.name, role: "listitem" },
65
+ return (React.createElement(CartLine, null,
66
66
  React.createElement(LabelWrapper, null,
67
67
  React.createElement(BodyText, null, baseChargeName),
68
68
  charge.info && (React.createElement(Fragment, null,
@@ -82,8 +82,8 @@ function CartSummary(_a) {
82
82
  cartSummary.title && (React.createElement(CartSummaryTitle, null,
83
83
  React.createElement(BodyText, { fontWeight: "semiBold" }, cartSummary.title),
84
84
  React.createElement(BodyText, null, cartSummary.subtitle))),
85
- React.createElement(CartSummaryContent, { title: cartSummary.title, role: "list", "aria-label": "Ordersammanfattning" },
86
- ((groceries === null || groceries === void 0 ? void 0 : groceries.length) > 0 || (cateredMeals === null || cateredMeals === void 0 ? void 0 : cateredMeals.length) > 0) && (React.createElement(CartLine, { role: "listitem" },
85
+ React.createElement(CartSummaryContent, { title: cartSummary.title, role: "group", "aria-label": "Ordersammanfattning" },
86
+ ((groceries === null || groceries === void 0 ? void 0 : groceries.length) > 0 || (cateredMeals === null || cateredMeals === void 0 ? void 0 : cateredMeals.length) > 0) && (React.createElement(CartLine, null,
87
87
  React.createElement(BodyText, { fontWeight: "medium" },
88
88
  itemsLabel,
89
89
  React.createElement(QuantitySpan, null, " (".concat(((_h = sumOfGroceries === null || sumOfGroceries === void 0 ? void 0 : sumOfGroceries.quantity) !== null && _h !== void 0 ? _h : 0) + ((_j = sumOfCateredMeals === null || sumOfCateredMeals === void 0 ? void 0 : sumOfCateredMeals.quantity) !== null && _j !== void 0 ? _j : 0), ")"))),
@@ -91,7 +91,7 @@ function CartSummary(_a) {
91
91
  (sumOfGroceries === null || sumOfGroceries === void 0 ? void 0 : sumOfGroceries.cancelledAmount) > 0 && (React.createElement(BodyText, { lineThrough: true, color: (_k = theme_1 === null || theme_1 === void 0 ? void 0 : theme_1.palette) === null || _k === void 0 ? void 0 : _k.dark }, formatPrice(((_l = sumOfGroceries === null || sumOfGroceries === void 0 ? void 0 : sumOfGroceries.cancelledAmount) !== null && _l !== void 0 ? _l : 0) +
92
92
  ((_m = sumOfCateredMeals === null || sumOfCateredMeals === void 0 ? void 0 : sumOfCateredMeals.cancelledAmount) !== null && _m !== void 0 ? _m : 0)))),
93
93
  React.createElement(BodyText, null, formatPrice(sumOfGroceries.amount + sumOfCateredMeals.amount))))),
94
- bags.length > 0 && (React.createElement(CartLine, { role: "listitem" },
94
+ bags.length > 0 && (React.createElement(CartLine, null,
95
95
  React.createElement(BodyText, null,
96
96
  "Matkassar",
97
97
  React.createElement(QuantitySpan, null,
@@ -101,12 +101,12 @@ function CartSummary(_a) {
101
101
  React.createElement(AmountWrapper, null,
102
102
  sumOfBags.cancelledAmount > 0 && (React.createElement(BodyText, { lineThrough: true, color: (_o = theme_1 === null || theme_1 === void 0 ? void 0 : theme_1.palette) === null || _o === void 0 ? void 0 : _o.dark }, formatPrice(sumOfBags.cancelledAmount))),
103
103
  React.createElement(BodyText, { fontWeight: "semiBold" }, formatPrice(sumOfBags.amount))))),
104
- (charges === null || charges === void 0 ? void 0 : charges.length) > 0 && (React.createElement(ChargesContainer, { role: "presentation" }, charges === null || charges === void 0 ? void 0 : charges.map(function (charge) { return (React.createElement(ChargeLine, { key: charge.name, charge: charge })); }))),
105
- React.createElement(ChargesContainer, { role: "presentation" },
106
- React.createElement(CartLine, { role: "listitem" },
104
+ (charges === null || charges === void 0 ? void 0 : charges.length) > 0 && (React.createElement(ChargesContainer, null, charges === null || charges === void 0 ? void 0 : charges.map(function (charge) { return (React.createElement(ChargeLine, { key: charge.name, charge: charge })); }))),
105
+ React.createElement(ChargesContainer, null,
106
+ React.createElement(CartLine, null,
107
107
  React.createElement(BodyText, { fontWeight: "semiBold" }, totalLabel),
108
108
  React.createElement(BodyText, { fontWeight: "semiBold" }, formatPrice(cartSummary.totalAmount))),
109
- cartSummary.totalDiscount > 0 && (React.createElement(CartLine, { role: "listitem" },
109
+ cartSummary.totalDiscount > 0 && (React.createElement(CartLine, null,
110
110
  React.createElement(BodyText, { size: TextTypes.TextSize.SMALL }, saveLabel),
111
111
  React.createElement(BodyText, { color: (_p = theme_1 === null || theme_1 === void 0 ? void 0 : theme_1.palette) === null || _p === void 0 ? void 0 : _p.alertRed, size: TextTypes.TextSize.SMALL }, formatPrice(cartSummary.totalDiscount)))))))));
112
112
  }
@@ -2,9 +2,10 @@ import React, { useId, useRef, useMemo, useEffect } 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 { H2 } from '@citygross/typography';
5
6
  import { toggleInert, escapeKeyboardEventHandler } from '@citygross/utils';
6
7
  import { CgButton } from '../CgButton/CgButton.js';
7
- import { Overlay, Frame, Header, Title, Footer } from './Modal.styles.js';
8
+ import { Overlay, Frame, Header, Footer } from './Modal.styles.js';
8
9
  import { EButtonVariant } from '../CgButton/CgButton.types.js';
9
10
 
10
11
  var EModalSize;
@@ -26,8 +27,8 @@ var getPortalRoot = function (portalHostSelector) {
26
27
  return (_a = hostElement === null || hostElement === void 0 ? void 0 : hostElement.parentElement) !== null && _a !== void 0 ? _a : document.body;
27
28
  };
28
29
  var Modal = function (_a) {
29
- var _b, _c;
30
- 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 ? EModalSize.medium : _f, title = _a.title, variant = _a.variant;
30
+ var _b, _c, _d;
31
+ 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
32
  var titleId = useId();
32
33
  var modalRef = useRef(null);
33
34
  var cancelButtonRef = useRef(null);
@@ -64,7 +65,7 @@ var Modal = function (_a) {
64
65
  (_b = modalRef.current) === null || _b === void 0 ? void 0 : _b.focus();
65
66
  });
66
67
  return function () {
67
- restoreInert === null || restoreInert === void 0 ? void 0 : restoreInert();
68
+ restoreInert();
68
69
  body.style.overflow = previousBodyOverflow;
69
70
  html.style.overflow = previousHtmlOverflow;
70
71
  document.removeEventListener('keydown', handleEscape);
@@ -75,12 +76,12 @@ var Modal = function (_a) {
75
76
  }, [inertSelectors, onClose, variant]);
76
77
  if (!portalRoot)
77
78
  return null;
78
- return createPortal(React.createElement(Overlay, { onClick: onClose },
79
+ return createPortal(React.createElement(Overlay, { noOverlay: noOverlay, onClick: onClose },
79
80
  React.createElement(Frame, { "aria-labelledby": titleId, "aria-modal": "true", onClick: function (event) { return event.stopPropagation(); }, ref: modalRef, role: variant === EModalVariant.destructive ? 'alertdialog' : 'dialog', size: size },
80
81
  React.createElement(Header, null,
81
- React.createElement(Title, { fontWeight: "semiBold", id: titleId }, title),
82
+ React.createElement(H2, { color: (_b = theme.palette) === null || _b === void 0 ? void 0 : _b.darkest, id: titleId }, title),
82
83
  variant !== EModalVariant.destructive && (React.createElement(CgButton, { "aria-label": labelCancel, circle: true, onClick: onClose, variant: EButtonVariant.ghost },
83
- React.createElement(Icons.Cross, { "aria-hidden": "true", height: (_b = theme.spacings) === null || _b === void 0 ? void 0 : _b.sm2, width: (_c = theme.spacings) === null || _c === void 0 ? void 0 : _c.sm2 })))),
84
+ React.createElement(Icons.Cross, { "aria-hidden": "true", height: (_c = theme.spacings) === null || _c === void 0 ? void 0 : _c.sm2, width: (_d = theme.spacings) === null || _d === void 0 ? void 0 : _d.sm2 })))),
84
85
  children,
85
86
  React.createElement(Footer, null,
86
87
  React.createElement(CgButton, { onClick: onConfirm, variant: EButtonVariant.primary }, labelCta),
@@ -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,11 @@
1
1
  import { __makeTemplateObject } from '../../../../_virtual/_tslib.js';
2
- import { BodyText } from '@citygross/typography';
3
2
  import styled from 'styled-components';
4
3
  import { EModalSize } from './Modal.js';
5
4
 
6
5
  var Overlay = styled.div(templateObject_1 || (templateObject_1 = __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) {
7
- var _b;
8
- var theme = _a.theme;
9
- return (_b = theme.palette) === null || _b === void 0 ? void 0 : _b.darkOverlay;
6
+ var _b, _c;
7
+ var theme = _a.theme, noOverlay = _a.noOverlay;
8
+ return noOverlay ? (_b = theme.palette) === null || _b === void 0 ? void 0 : _b.transparent : (_c = theme.palette) === null || _c === void 0 ? void 0 : _c.darkOverlay;
10
9
  }, function (_a) {
11
10
  var _b, _c, _d;
12
11
  var theme = _a.theme;
@@ -52,12 +51,7 @@ var Header = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateOb
52
51
  var theme = _a.theme;
53
52
  return (_b = theme.spacings) === null || _b === void 0 ? void 0 : _b.sm;
54
53
  });
55
- var Title = styled(BodyText)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n font-size: ", "px;\n"], ["\n font-size: ", "px;\n"])), function (_a) {
56
- var _b, _c;
57
- var theme = _a.theme;
58
- return (_c = (_b = theme.typography) === null || _b === void 0 ? void 0 : _b.size) === null || _c === void 0 ? void 0 : _c.s4;
59
- });
60
- var Footer = styled.div(templateObject_5 || (templateObject_5 = __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) {
54
+ var Footer = styled.div(templateObject_4 || (templateObject_4 = __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) {
61
55
  var _b;
62
56
  var theme = _a.theme;
63
57
  return (_b = theme.spacings) === null || _b === void 0 ? void 0 : _b.sm;
@@ -66,7 +60,7 @@ var Footer = styled.div(templateObject_5 || (templateObject_5 = __makeTemplateOb
66
60
  var theme = _a.theme;
67
61
  return (_b = theme.spacings) === null || _b === void 0 ? void 0 : _b.lg;
68
62
  });
69
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
63
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
70
64
 
71
- export { Footer, Frame, Header, Overlay, Title };
65
+ export { Footer, Frame, Header, Overlay };
72
66
  //# sourceMappingURL=Modal.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.styles.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"Modal.styles.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -528,31 +528,32 @@ var selectKeyboardEventHandler = function (_a) {
528
528
 
529
529
  var toggleInert = function (_a) {
530
530
  var elements = _a.elements, isInert = _a.isInert;
531
- var snapshots = elements
532
- .filter(function (element) { return Boolean(element); })
533
- .map(function (element) { return ({
531
+ var list = elements.filter(function (element) {
532
+ return Boolean(element);
533
+ });
534
+ if (!isInert) {
535
+ list.forEach(function (element) {
536
+ var hadInert = element.hasAttribute('inert');
537
+ if (!hadInert) {
538
+ element.removeAttribute('inert');
539
+ }
540
+ });
541
+ return function () { };
542
+ }
543
+ var snapshots = list.map(function (element) { return ({
534
544
  element: element,
535
- hadInert: element.hasAttribute('inert')
545
+ setByThisCall: !element.hasAttribute('inert')
536
546
  }); });
537
547
  snapshots.forEach(function (_a) {
538
- var element = _a.element, hadInert = _a.hadInert;
539
- if (isInert) {
540
- if (!hadInert) {
541
- element.setAttribute('inert', '');
542
- }
543
- return;
544
- }
545
- if (!hadInert) {
546
- element.removeAttribute('inert');
548
+ var element = _a.element, setByThisCall = _a.setByThisCall;
549
+ if (setByThisCall) {
550
+ element.setAttribute('inert', '');
547
551
  }
548
552
  });
549
553
  return function () {
550
554
  snapshots.forEach(function (_a) {
551
- var element = _a.element, hadInert = _a.hadInert;
552
- if (hadInert) {
553
- element.setAttribute('inert', '');
554
- }
555
- else {
555
+ var element = _a.element, setByThisCall = _a.setByThisCall;
556
+ if (setByThisCall) {
556
557
  element.removeAttribute('inert');
557
558
  }
558
559
  });