@telia/teddy 0.7.38 → 0.7.39

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.
Files changed (59) hide show
  1. package/dist/components/checkbox-card-group/checkbox-card-group-content.cjs +1 -0
  2. package/dist/components/checkbox-card-group/checkbox-card-group-content.js +1 -0
  3. package/dist/components/checkbox-card-group/checkbox-card-group-indicator.cjs +1 -0
  4. package/dist/components/checkbox-card-group/checkbox-card-group-indicator.js +1 -0
  5. package/dist/components/checkbox-card-group/checkbox-card-group-item-title.cjs +1 -0
  6. package/dist/components/checkbox-card-group/checkbox-card-group-item-title.js +1 -0
  7. package/dist/components/checkbox-card-group/checkbox-card-group-item.cjs +1 -0
  8. package/dist/components/checkbox-card-group/checkbox-card-group-item.js +1 -0
  9. package/dist/components/index.cjs +4 -0
  10. package/dist/components/index.d.ts +1 -0
  11. package/dist/components/index.js +4 -0
  12. package/dist/components/modal/modal-close.cjs +1 -0
  13. package/dist/components/modal/modal-close.js +1 -0
  14. package/dist/components/navigation-menu/navigation-menu.cjs +1 -0
  15. package/dist/components/navigation-menu/navigation-menu.js +1 -0
  16. package/dist/components/radio-card-group/radio-card-group-content.cjs +1 -0
  17. package/dist/components/radio-card-group/radio-card-group-content.js +1 -0
  18. package/dist/components/radio-card-group/radio-card-group-item-title.cjs +1 -0
  19. package/dist/components/radio-card-group/radio-card-group-item-title.js +1 -0
  20. package/dist/components/radio-card-group/radio-card-group-item.cjs +1 -0
  21. package/dist/components/radio-card-group/radio-card-group-item.js +1 -0
  22. package/dist/components/shopping-cart/index.cjs +21 -0
  23. package/dist/components/shopping-cart/index.d.ts +42 -0
  24. package/dist/components/shopping-cart/index.js +21 -0
  25. package/dist/components/shopping-cart/shopping-cart-context.cjs +13 -0
  26. package/dist/components/shopping-cart/shopping-cart-context.d.ts +8 -0
  27. package/dist/components/shopping-cart/shopping-cart-context.js +13 -0
  28. package/dist/components/shopping-cart/shopping-cart-continue.cjs +9 -0
  29. package/dist/components/shopping-cart/shopping-cart-continue.d.ts +8 -0
  30. package/dist/components/shopping-cart/shopping-cart-continue.js +9 -0
  31. package/dist/components/shopping-cart/shopping-cart-disclaimer.cjs +74 -0
  32. package/dist/components/shopping-cart/shopping-cart-disclaimer.d.ts +10 -0
  33. package/dist/components/shopping-cart/shopping-cart-disclaimer.js +74 -0
  34. package/dist/components/shopping-cart/shopping-cart-item.cjs +268 -0
  35. package/dist/components/shopping-cart/shopping-cart-item.d.ts +11 -0
  36. package/dist/components/shopping-cart/shopping-cart-item.js +268 -0
  37. package/dist/components/shopping-cart/shopping-cart-items.cjs +19 -0
  38. package/dist/components/shopping-cart/shopping-cart-items.d.ts +11 -0
  39. package/dist/components/shopping-cart/shopping-cart-items.js +19 -0
  40. package/dist/components/shopping-cart/shopping-cart-payment.cjs +119 -0
  41. package/dist/components/shopping-cart/shopping-cart-payment.d.ts +19 -0
  42. package/dist/components/shopping-cart/shopping-cart-payment.js +119 -0
  43. package/dist/components/shopping-cart/shopping-cart-root.cjs +14 -0
  44. package/dist/components/shopping-cart/shopping-cart-root.d.ts +10 -0
  45. package/dist/components/shopping-cart/shopping-cart-root.js +14 -0
  46. package/dist/components/shopping-cart/types.cjs +30 -0
  47. package/dist/components/shopping-cart/types.d.ts +193 -0
  48. package/dist/components/shopping-cart/types.js +30 -0
  49. package/dist/components/shopping-cart/utils.cjs +62 -0
  50. package/dist/components/shopping-cart/utils.d.ts +6 -0
  51. package/dist/components/shopping-cart/utils.js +62 -0
  52. package/dist/components/textarea/textarea-group.cjs +12 -12
  53. package/dist/components/textarea/textarea-group.js +12 -12
  54. package/dist/main.cjs +4 -0
  55. package/dist/main.js +4 -0
  56. package/dist/shopping-cart.module-BCoLrcMI.cjs +48 -0
  57. package/dist/shopping-cart.module-DA25l2hr.js +49 -0
  58. package/dist/style.css +968 -484
  59. package/package.json +1 -1
@@ -0,0 +1,268 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ require("../../assets/sprite.6511e521-teddy.svg");
5
+ const components_icon_icon = require("../icon/icon.cjs");
6
+ const components_text_text = require("../text/text.cjs");
7
+ const components_link_link = require("../link/link.cjs");
8
+ const components_button_button = require("../button/button.cjs");
9
+ const components_badge_badge = require("../badge/badge.cjs");
10
+ require("../badge/alert-badge.cjs");
11
+ require("../badge/counter-badge.cjs");
12
+ const components_tooltip_index = require("../tooltip/index.cjs");
13
+ const components_shoppingCart_types = require("./types.cjs");
14
+ const components_shoppingCart_shoppingCartContext = require("./shopping-cart-context.cjs");
15
+ const components_shoppingCart_utils = require("./utils.cjs");
16
+ const item = "_item_kjt5a_1";
17
+ const breakageFeeInfo = "_breakageFeeInfo_kjt5a_7";
18
+ const nameWrapper = "_nameWrapper_kjt5a_26";
19
+ const link = "_link_kjt5a_33";
20
+ const discountDescription = "_discountDescription_kjt5a_51";
21
+ const name = "_name_kjt5a_26";
22
+ const nameContainer = "_nameContainer_kjt5a_64";
23
+ const subtitle = "_subtitle_kjt5a_68";
24
+ const quantityPickerWrapper = "_quantityPickerWrapper_kjt5a_76";
25
+ const pricePer = "_pricePer_kjt5a_83";
26
+ const quantityPicker = "_quantityPicker_kjt5a_76";
27
+ const priceContainer = "_priceContainer_kjt5a_95";
28
+ const priceCost = "_priceCost_kjt5a_101";
29
+ const priceLabel = "_priceLabel_kjt5a_109";
30
+ const priceLinethrough = "_priceLinethrough_kjt5a_114";
31
+ const priceLinethroughDisclaimer = "_priceLinethroughDisclaimer_kjt5a_124";
32
+ const imageContainer = "_imageContainer_kjt5a_133";
33
+ const noImageContainer = "_noImageContainer_kjt5a_145";
34
+ const image = "_image_kjt5a_133";
35
+ const iconImage = "_iconImage_kjt5a_158";
36
+ const deleteButtonContainer = "_deleteButtonContainer_kjt5a_164";
37
+ const uniqueDiscount = "_uniqueDiscount_kjt5a_191";
38
+ const uniqueDiscountLabel = "_uniqueDiscountLabel_kjt5a_198";
39
+ const uniqueDiscountPrice = "_uniqueDiscountPrice_kjt5a_204";
40
+ const onlyInShops = "_onlyInShops_kjt5a_209";
41
+ const onlyInShopsLabel = "_onlyInShopsLabel_kjt5a_216";
42
+ const tooltipTrigger = "_tooltipTrigger_kjt5a_235";
43
+ const priceWithTooltip = "_priceWithTooltip_kjt5a_243";
44
+ const cartLink = "_cartLink_kjt5a_248";
45
+ const styles = {
46
+ item,
47
+ breakageFeeInfo,
48
+ nameWrapper,
49
+ link,
50
+ discountDescription,
51
+ name,
52
+ nameContainer,
53
+ subtitle,
54
+ quantityPickerWrapper,
55
+ pricePer,
56
+ quantityPicker,
57
+ priceContainer,
58
+ priceCost,
59
+ priceLabel,
60
+ priceLinethrough,
61
+ priceLinethroughDisclaimer,
62
+ imageContainer,
63
+ noImageContainer,
64
+ image,
65
+ iconImage,
66
+ deleteButtonContainer,
67
+ uniqueDiscount,
68
+ uniqueDiscountLabel,
69
+ uniqueDiscountPrice,
70
+ onlyInShops,
71
+ onlyInShopsLabel,
72
+ tooltipTrigger,
73
+ priceWithTooltip,
74
+ cartLink
75
+ };
76
+ const QuantityPicker = ({
77
+ quantity,
78
+ onChangeQuantity,
79
+ cartItem,
80
+ shouldShowPricePerUnit,
81
+ isQuantityModifiable,
82
+ price,
83
+ discountValueUpfront,
84
+ discountValueMonthly,
85
+ hasPaid
86
+ }) => {
87
+ const minQuantity = 1;
88
+ const maxQuantity = 10;
89
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles.quantityPickerWrapper, children: [
90
+ !hasPaid && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles.quantityPicker, children: [
91
+ /* @__PURE__ */ jsxRuntime.jsx(
92
+ components_button_button.Button,
93
+ {
94
+ type: "button",
95
+ variant: "secondary",
96
+ size: "sm",
97
+ iconOnly: true,
98
+ "aria-label": "Reduser antall",
99
+ disabled: quantity <= minQuantity,
100
+ onClick: () => onChangeQuantity(cartItem, quantity - 1),
101
+ children: /* @__PURE__ */ jsxRuntime.jsx(components_icon_icon.Icon, { name: "minus" })
102
+ }
103
+ ),
104
+ /* @__PURE__ */ jsxRuntime.jsx(components_text_text.Text, { variant: "paragraph-100", children: quantity }),
105
+ /* @__PURE__ */ jsxRuntime.jsx(
106
+ components_button_button.Button,
107
+ {
108
+ type: "button",
109
+ variant: "secondary",
110
+ size: "sm",
111
+ iconOnly: true,
112
+ "aria-label": "Øk antall",
113
+ disabled: quantity >= maxQuantity,
114
+ onClick: () => onChangeQuantity(cartItem, quantity + 1),
115
+ children: /* @__PURE__ */ jsxRuntime.jsx(components_icon_icon.Icon, { name: "plus" })
116
+ }
117
+ )
118
+ ] }),
119
+ shouldShowPricePerUnit && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: styles.pricePer, children: [
120
+ quantity > 1 && !isQuantityModifiable && `${quantity} x `,
121
+ `${components_shoppingCart_utils.getPrice(components_shoppingCart_utils.defaultFormatPrice, price, discountValueUpfront, discountValueMonthly, 1)}/stk`
122
+ ] })
123
+ ] });
124
+ };
125
+ const CartItemImage = ({ cartItem }) => {
126
+ if (!cartItem.image) {
127
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles.noImageContainer });
128
+ }
129
+ const renderImage = () => {
130
+ var _a, _b;
131
+ if ((_a = cartItem.image) == null ? void 0 : _a.url) {
132
+ return /* @__PURE__ */ jsxRuntime.jsx("img", { className: styles.image, src: `${cartItem.image.url}?w=44&h=75`, alt: "" });
133
+ }
134
+ if ((_b = cartItem.image) == null ? void 0 : _b.icon) {
135
+ return /* @__PURE__ */ jsxRuntime.jsx(components_icon_icon.Icon, { className: styles.iconImage, name: cartItem.image.icon });
136
+ }
137
+ return null;
138
+ };
139
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles.imageContainer, children: cartItem.href ? /* @__PURE__ */ jsxRuntime.jsx(components_link_link.Link, { href: cartItem.href, variant: "navigation", className: styles.cartLink, children: renderImage() }) : renderImage() });
140
+ };
141
+ const CartItemPriceDisplay = ({ cartItem, hasPaid, onChangeQuantity }) => {
142
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
143
+ const { formatPrice } = components_shoppingCart_shoppingCartContext.useShoppingCart();
144
+ const quantity = ((_a = cartItem.quantity) == null ? void 0 : _a.value) ?? 1;
145
+ const isQuantityModifiable = !!((_b = cartItem.quantity) == null ? void 0 : _b.modifiable);
146
+ const shouldShowPricePerUnit = (!!cartItem.price.upfront || !!cartItem.price.firstInvoice) && quantity > 1;
147
+ const isManualDiscount = (_c = cartItem.discount) == null ? void 0 : _c.isManualDiscount;
148
+ const discountValueUpfront = isManualDiscount ? 0 : ((_e = (_d = cartItem.discount) == null ? void 0 : _d.value) == null ? void 0 : _e.upfront) || 0;
149
+ const isLease = cartItem.leaseMonths === 0 || !!cartItem.leaseMonths;
150
+ const hasSubscription = !!((_f = cartItem.items) == null ? void 0 : _f.find((item2) => item2.type.includes("SUBSCRIPTION")));
151
+ const discountValueMonthly = ((_h = (_g = cartItem.discount) == null ? void 0 : _g.value) == null ? void 0 : _h.monthly) || 0;
152
+ const discountPrice = components_shoppingCart_utils.getDiscountPrice(cartItem.price, quantity) || "";
153
+ const price = components_shoppingCart_utils.getPrice(formatPrice, cartItem.price, discountValueUpfront, discountValueMonthly, quantity);
154
+ const discountPriceText = ((_i = cartItem.discount) == null ? void 0 : _i.handsetDiscountText) || "";
155
+ const subtitles = (Array.isArray(cartItem.subtitle) ? cartItem.subtitle : [cartItem.subtitle]).filter(
156
+ Boolean
157
+ );
158
+ const suppressSubtitles = cartItem.type === components_shoppingCart_types.CART_ITEM_TYPE.SUBSCRIPTION ? true : void 0;
159
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles.price, children: [
160
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles.priceContainer, children: [
161
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles.subtitle, children: [
162
+ subtitles.length > 0 ? subtitles.map((sub) => /* @__PURE__ */ jsxRuntime.jsx(
163
+ "div",
164
+ {
165
+ "data-hj-suppress": suppressSubtitles,
166
+ className: "paragraph",
167
+ dangerouslySetInnerHTML: { __html: sub }
168
+ },
169
+ `${cartItem.bundleId}-${cartItem.id}-${sub}`
170
+ )) : /* @__PURE__ */ jsxRuntime.jsx("span", {}),
171
+ quantity > 1 && !shouldShowPricePerUnit && /* @__PURE__ */ jsxRuntime.jsx("span", { children: `${quantity} stk` }),
172
+ isQuantityModifiable && /* @__PURE__ */ jsxRuntime.jsx(
173
+ QuantityPicker,
174
+ {
175
+ quantity,
176
+ onChangeQuantity,
177
+ cartItem,
178
+ shouldShowPricePerUnit,
179
+ isQuantityModifiable,
180
+ price: cartItem.price,
181
+ discountValueUpfront,
182
+ discountValueMonthly,
183
+ hasPaid
184
+ }
185
+ )
186
+ ] }),
187
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { position: "relative" }, children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: styles.priceCost, children: [
188
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles.priceWithTooltip, children: [
189
+ discountPriceText && /* @__PURE__ */ jsxRuntime.jsxs(components_tooltip_index.Tooltip, { defaultOpen: true, children: [
190
+ /* @__PURE__ */ jsxRuntime.jsx(components_tooltip_index.Tooltip.Trigger, { className: styles.tooltipTrigger }),
191
+ /* @__PURE__ */ jsxRuntime.jsx(components_tooltip_index.Tooltip.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(components_text_text.Text, { variant: "paragraph-100", dangerouslySetInnerHTML: { __html: discountPriceText } }) })
192
+ ] }),
193
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: styles.priceLabel, children: [
194
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: isLease && !hasSubscription && "fra " }),
195
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: price }),
196
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: cartItem.price.monthly ? "/md." : "" })
197
+ ] })
198
+ ] }),
199
+ discountPrice && formatPrice(discountPrice) !== price && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
200
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles.priceLinethroughDisclaimer, children: "ord. pris:" }),
201
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles.priceLinethrough, children: cartItem.price.monthly ? formatPrice(discountPrice) + "/md." : formatPrice(discountPrice) })
202
+ ] })
203
+ ] }) })
204
+ ] }),
205
+ cartItem.onlyAvailableInShops && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles.onlyInShops, children: [
206
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles.onlyInShopsLabel, children: "Hentes i butikk" }),
207
+ /* @__PURE__ */ jsxRuntime.jsxs(components_tooltip_index.Tooltip, { children: [
208
+ /* @__PURE__ */ jsxRuntime.jsx(components_tooltip_index.Tooltip.Trigger, { className: styles.tooltipTrigger }),
209
+ /* @__PURE__ */ jsxRuntime.jsx(components_tooltip_index.Tooltip.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(components_text_text.Text, { variant: "paragraph-100", children: "Varen må hentes i butikk. Kan ikke kombineres med varer som ikke finnes i samme butikk." }) })
210
+ ] })
211
+ ] }),
212
+ ((_j = cartItem.discount) == null ? void 0 : _j.isManualDiscount) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles.uniqueDiscount, children: [
213
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles.uniqueDiscountLabel, children: cartItem.discount.name }),
214
+ (cartItem.discount.value.upfront || 0) > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: styles.uniqueDiscountPrice, children: [
215
+ "-",
216
+ formatPrice(cartItem.discount.value.upfront)
217
+ ] })
218
+ ] })
219
+ ] });
220
+ };
221
+ const CartItemDiscountBadges = ({ cartItem }) => {
222
+ var _a;
223
+ const discounts = ((_a = cartItem.discount) == null ? void 0 : _a.types) || [];
224
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: discounts.map((discount, index) => /* @__PURE__ */ jsxRuntime.jsx(
225
+ components_badge_badge.Badge,
226
+ {
227
+ className: styles.discountDescription,
228
+ variant: discount.badgeVariant ?? "neutral",
229
+ hideIcon: true,
230
+ children: discount.text
231
+ },
232
+ `${discount.id}-${index}`
233
+ )) });
234
+ };
235
+ const CartItemName = ({ cartItem }) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
236
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles.nameWrapper, children: [
237
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles.link, children: [
238
+ cartItem.lineThrough && /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles.priceLinethrough, children: cartItem.lineThrough }),
239
+ cartItem.href ? /* @__PURE__ */ jsxRuntime.jsx(components_link_link.Link, { href: cartItem.href, variant: "navigation", className: styles.cartLink, children: cartItem.name }) : cartItem.name,
240
+ cartItem.type === "BREAKAGE_FEE" && /* @__PURE__ */ jsxRuntime.jsxs(components_tooltip_index.Tooltip, { children: [
241
+ /* @__PURE__ */ jsxRuntime.jsx(components_tooltip_index.Tooltip.Trigger, { className: styles.tooltipTrigger }),
242
+ /* @__PURE__ */ jsxRuntime.jsx(components_tooltip_index.Tooltip.Content, { className: styles.breakageFeeInfo, children: /* @__PURE__ */ jsxRuntime.jsx(components_text_text.Text, { variant: "paragraph-100", children: "Bruddgebyret er lik totalrabatten du får i kampanjen. Bruddgebyret reduseres månedlig ut avtaletiden, regnet fra når avtalen er inngått. Beløpet kommer på neste faktura." }) })
243
+ ] })
244
+ ] }),
245
+ /* @__PURE__ */ jsxRuntime.jsx(CartItemDiscountBadges, { cartItem })
246
+ ] }),
247
+ cartItem.color && /* @__PURE__ */ jsxRuntime.jsxs(components_text_text.Text, { variant: "paragraph-100", mb: "200", children: [
248
+ cartItem.color,
249
+ cartItem.modelSize ? ", " + cartItem.modelSize : ""
250
+ ] })
251
+ ] });
252
+ const Item = ({ cartItem, onChangeQuantity, onRemoveItem }) => {
253
+ var _a;
254
+ const { hasPaid, isAllowedToDelete } = components_shoppingCart_shoppingCartContext.useShoppingCart();
255
+ const isRemovable = !!((_a = cartItem.quantity) == null ? void 0 : _a.removable);
256
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles.item, children: [
257
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles.nameContainer, children: [
258
+ /* @__PURE__ */ jsxRuntime.jsx(CartItemImage, { cartItem }),
259
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles.name, children: [
260
+ /* @__PURE__ */ jsxRuntime.jsx(CartItemName, { cartItem }),
261
+ /* @__PURE__ */ jsxRuntime.jsx(CartItemPriceDisplay, { cartItem, onChangeQuantity, hasPaid })
262
+ ] })
263
+ ] }),
264
+ isRemovable && isAllowedToDelete && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: () => onRemoveItem(cartItem), className: styles.deleteButtonContainer, children: /* @__PURE__ */ jsxRuntime.jsx(components_icon_icon.Icon, { name: "remove" }) })
265
+ ] });
266
+ };
267
+ Item.displayName = "Item";
268
+ exports.Item = Item;
@@ -0,0 +1,11 @@
1
+ import { CartItem } from './types';
2
+
3
+ export interface ItemProps {
4
+ cartItem: CartItem;
5
+ onChangeQuantity: (cartItem: CartItem, quantity: number) => void;
6
+ onRemoveItem: (cartItem: CartItem) => void;
7
+ }
8
+ export declare const Item: {
9
+ ({ cartItem, onChangeQuantity, onRemoveItem }: ItemProps): import("react/jsx-runtime").JSX.Element;
10
+ displayName: string;
11
+ };
@@ -0,0 +1,268 @@
1
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
+ import "../../assets/sprite.6511e521-teddy.svg";
3
+ import { Icon } from "../icon/icon.js";
4
+ import { Text } from "../text/text.js";
5
+ import { Link } from "../link/link.js";
6
+ import { Button } from "../button/button.js";
7
+ import { Badge } from "../badge/badge.js";
8
+ import "../badge/alert-badge.js";
9
+ import "../badge/counter-badge.js";
10
+ import { Tooltip } from "../tooltip/index.js";
11
+ import { CART_ITEM_TYPE } from "./types.js";
12
+ import { useShoppingCart } from "./shopping-cart-context.js";
13
+ import { getDiscountPrice, getPrice, defaultFormatPrice } from "./utils.js";
14
+ const item = "_item_kjt5a_1";
15
+ const breakageFeeInfo = "_breakageFeeInfo_kjt5a_7";
16
+ const nameWrapper = "_nameWrapper_kjt5a_26";
17
+ const link = "_link_kjt5a_33";
18
+ const discountDescription = "_discountDescription_kjt5a_51";
19
+ const name = "_name_kjt5a_26";
20
+ const nameContainer = "_nameContainer_kjt5a_64";
21
+ const subtitle = "_subtitle_kjt5a_68";
22
+ const quantityPickerWrapper = "_quantityPickerWrapper_kjt5a_76";
23
+ const pricePer = "_pricePer_kjt5a_83";
24
+ const quantityPicker = "_quantityPicker_kjt5a_76";
25
+ const priceContainer = "_priceContainer_kjt5a_95";
26
+ const priceCost = "_priceCost_kjt5a_101";
27
+ const priceLabel = "_priceLabel_kjt5a_109";
28
+ const priceLinethrough = "_priceLinethrough_kjt5a_114";
29
+ const priceLinethroughDisclaimer = "_priceLinethroughDisclaimer_kjt5a_124";
30
+ const imageContainer = "_imageContainer_kjt5a_133";
31
+ const noImageContainer = "_noImageContainer_kjt5a_145";
32
+ const image = "_image_kjt5a_133";
33
+ const iconImage = "_iconImage_kjt5a_158";
34
+ const deleteButtonContainer = "_deleteButtonContainer_kjt5a_164";
35
+ const uniqueDiscount = "_uniqueDiscount_kjt5a_191";
36
+ const uniqueDiscountLabel = "_uniqueDiscountLabel_kjt5a_198";
37
+ const uniqueDiscountPrice = "_uniqueDiscountPrice_kjt5a_204";
38
+ const onlyInShops = "_onlyInShops_kjt5a_209";
39
+ const onlyInShopsLabel = "_onlyInShopsLabel_kjt5a_216";
40
+ const tooltipTrigger = "_tooltipTrigger_kjt5a_235";
41
+ const priceWithTooltip = "_priceWithTooltip_kjt5a_243";
42
+ const cartLink = "_cartLink_kjt5a_248";
43
+ const styles = {
44
+ item,
45
+ breakageFeeInfo,
46
+ nameWrapper,
47
+ link,
48
+ discountDescription,
49
+ name,
50
+ nameContainer,
51
+ subtitle,
52
+ quantityPickerWrapper,
53
+ pricePer,
54
+ quantityPicker,
55
+ priceContainer,
56
+ priceCost,
57
+ priceLabel,
58
+ priceLinethrough,
59
+ priceLinethroughDisclaimer,
60
+ imageContainer,
61
+ noImageContainer,
62
+ image,
63
+ iconImage,
64
+ deleteButtonContainer,
65
+ uniqueDiscount,
66
+ uniqueDiscountLabel,
67
+ uniqueDiscountPrice,
68
+ onlyInShops,
69
+ onlyInShopsLabel,
70
+ tooltipTrigger,
71
+ priceWithTooltip,
72
+ cartLink
73
+ };
74
+ const QuantityPicker = ({
75
+ quantity,
76
+ onChangeQuantity,
77
+ cartItem,
78
+ shouldShowPricePerUnit,
79
+ isQuantityModifiable,
80
+ price,
81
+ discountValueUpfront,
82
+ discountValueMonthly,
83
+ hasPaid
84
+ }) => {
85
+ const minQuantity = 1;
86
+ const maxQuantity = 10;
87
+ return /* @__PURE__ */ jsxs("div", { className: styles.quantityPickerWrapper, children: [
88
+ !hasPaid && /* @__PURE__ */ jsxs("div", { className: styles.quantityPicker, children: [
89
+ /* @__PURE__ */ jsx(
90
+ Button,
91
+ {
92
+ type: "button",
93
+ variant: "secondary",
94
+ size: "sm",
95
+ iconOnly: true,
96
+ "aria-label": "Reduser antall",
97
+ disabled: quantity <= minQuantity,
98
+ onClick: () => onChangeQuantity(cartItem, quantity - 1),
99
+ children: /* @__PURE__ */ jsx(Icon, { name: "minus" })
100
+ }
101
+ ),
102
+ /* @__PURE__ */ jsx(Text, { variant: "paragraph-100", children: quantity }),
103
+ /* @__PURE__ */ jsx(
104
+ Button,
105
+ {
106
+ type: "button",
107
+ variant: "secondary",
108
+ size: "sm",
109
+ iconOnly: true,
110
+ "aria-label": "Øk antall",
111
+ disabled: quantity >= maxQuantity,
112
+ onClick: () => onChangeQuantity(cartItem, quantity + 1),
113
+ children: /* @__PURE__ */ jsx(Icon, { name: "plus" })
114
+ }
115
+ )
116
+ ] }),
117
+ shouldShowPricePerUnit && /* @__PURE__ */ jsxs("span", { className: styles.pricePer, children: [
118
+ quantity > 1 && !isQuantityModifiable && `${quantity} x `,
119
+ `${getPrice(defaultFormatPrice, price, discountValueUpfront, discountValueMonthly, 1)}/stk`
120
+ ] })
121
+ ] });
122
+ };
123
+ const CartItemImage = ({ cartItem }) => {
124
+ if (!cartItem.image) {
125
+ return /* @__PURE__ */ jsx("div", { className: styles.noImageContainer });
126
+ }
127
+ const renderImage = () => {
128
+ var _a, _b;
129
+ if ((_a = cartItem.image) == null ? void 0 : _a.url) {
130
+ return /* @__PURE__ */ jsx("img", { className: styles.image, src: `${cartItem.image.url}?w=44&h=75`, alt: "" });
131
+ }
132
+ if ((_b = cartItem.image) == null ? void 0 : _b.icon) {
133
+ return /* @__PURE__ */ jsx(Icon, { className: styles.iconImage, name: cartItem.image.icon });
134
+ }
135
+ return null;
136
+ };
137
+ return /* @__PURE__ */ jsx("div", { className: styles.imageContainer, children: cartItem.href ? /* @__PURE__ */ jsx(Link, { href: cartItem.href, variant: "navigation", className: styles.cartLink, children: renderImage() }) : renderImage() });
138
+ };
139
+ const CartItemPriceDisplay = ({ cartItem, hasPaid, onChangeQuantity }) => {
140
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
141
+ const { formatPrice } = useShoppingCart();
142
+ const quantity = ((_a = cartItem.quantity) == null ? void 0 : _a.value) ?? 1;
143
+ const isQuantityModifiable = !!((_b = cartItem.quantity) == null ? void 0 : _b.modifiable);
144
+ const shouldShowPricePerUnit = (!!cartItem.price.upfront || !!cartItem.price.firstInvoice) && quantity > 1;
145
+ const isManualDiscount = (_c = cartItem.discount) == null ? void 0 : _c.isManualDiscount;
146
+ const discountValueUpfront = isManualDiscount ? 0 : ((_e = (_d = cartItem.discount) == null ? void 0 : _d.value) == null ? void 0 : _e.upfront) || 0;
147
+ const isLease = cartItem.leaseMonths === 0 || !!cartItem.leaseMonths;
148
+ const hasSubscription = !!((_f = cartItem.items) == null ? void 0 : _f.find((item2) => item2.type.includes("SUBSCRIPTION")));
149
+ const discountValueMonthly = ((_h = (_g = cartItem.discount) == null ? void 0 : _g.value) == null ? void 0 : _h.monthly) || 0;
150
+ const discountPrice = getDiscountPrice(cartItem.price, quantity) || "";
151
+ const price = getPrice(formatPrice, cartItem.price, discountValueUpfront, discountValueMonthly, quantity);
152
+ const discountPriceText = ((_i = cartItem.discount) == null ? void 0 : _i.handsetDiscountText) || "";
153
+ const subtitles = (Array.isArray(cartItem.subtitle) ? cartItem.subtitle : [cartItem.subtitle]).filter(
154
+ Boolean
155
+ );
156
+ const suppressSubtitles = cartItem.type === CART_ITEM_TYPE.SUBSCRIPTION ? true : void 0;
157
+ return /* @__PURE__ */ jsxs("div", { className: styles.price, children: [
158
+ /* @__PURE__ */ jsxs("div", { className: styles.priceContainer, children: [
159
+ /* @__PURE__ */ jsxs("div", { className: styles.subtitle, children: [
160
+ subtitles.length > 0 ? subtitles.map((sub) => /* @__PURE__ */ jsx(
161
+ "div",
162
+ {
163
+ "data-hj-suppress": suppressSubtitles,
164
+ className: "paragraph",
165
+ dangerouslySetInnerHTML: { __html: sub }
166
+ },
167
+ `${cartItem.bundleId}-${cartItem.id}-${sub}`
168
+ )) : /* @__PURE__ */ jsx("span", {}),
169
+ quantity > 1 && !shouldShowPricePerUnit && /* @__PURE__ */ jsx("span", { children: `${quantity} stk` }),
170
+ isQuantityModifiable && /* @__PURE__ */ jsx(
171
+ QuantityPicker,
172
+ {
173
+ quantity,
174
+ onChangeQuantity,
175
+ cartItem,
176
+ shouldShowPricePerUnit,
177
+ isQuantityModifiable,
178
+ price: cartItem.price,
179
+ discountValueUpfront,
180
+ discountValueMonthly,
181
+ hasPaid
182
+ }
183
+ )
184
+ ] }),
185
+ /* @__PURE__ */ jsx("div", { style: { position: "relative" }, children: /* @__PURE__ */ jsxs("span", { className: styles.priceCost, children: [
186
+ /* @__PURE__ */ jsxs("div", { className: styles.priceWithTooltip, children: [
187
+ discountPriceText && /* @__PURE__ */ jsxs(Tooltip, { defaultOpen: true, children: [
188
+ /* @__PURE__ */ jsx(Tooltip.Trigger, { className: styles.tooltipTrigger }),
189
+ /* @__PURE__ */ jsx(Tooltip.Content, { children: /* @__PURE__ */ jsx(Text, { variant: "paragraph-100", dangerouslySetInnerHTML: { __html: discountPriceText } }) })
190
+ ] }),
191
+ /* @__PURE__ */ jsxs("span", { className: styles.priceLabel, children: [
192
+ /* @__PURE__ */ jsx("span", { children: isLease && !hasSubscription && "fra " }),
193
+ /* @__PURE__ */ jsx("span", { children: price }),
194
+ /* @__PURE__ */ jsx("span", { children: cartItem.price.monthly ? "/md." : "" })
195
+ ] })
196
+ ] }),
197
+ discountPrice && formatPrice(discountPrice) !== price && /* @__PURE__ */ jsxs(Fragment, { children: [
198
+ /* @__PURE__ */ jsx("span", { className: styles.priceLinethroughDisclaimer, children: "ord. pris:" }),
199
+ /* @__PURE__ */ jsx("span", { className: styles.priceLinethrough, children: cartItem.price.monthly ? formatPrice(discountPrice) + "/md." : formatPrice(discountPrice) })
200
+ ] })
201
+ ] }) })
202
+ ] }),
203
+ cartItem.onlyAvailableInShops && /* @__PURE__ */ jsxs("div", { className: styles.onlyInShops, children: [
204
+ /* @__PURE__ */ jsx("span", { className: styles.onlyInShopsLabel, children: "Hentes i butikk" }),
205
+ /* @__PURE__ */ jsxs(Tooltip, { children: [
206
+ /* @__PURE__ */ jsx(Tooltip.Trigger, { className: styles.tooltipTrigger }),
207
+ /* @__PURE__ */ jsx(Tooltip.Content, { children: /* @__PURE__ */ jsx(Text, { variant: "paragraph-100", children: "Varen må hentes i butikk. Kan ikke kombineres med varer som ikke finnes i samme butikk." }) })
208
+ ] })
209
+ ] }),
210
+ ((_j = cartItem.discount) == null ? void 0 : _j.isManualDiscount) && /* @__PURE__ */ jsxs("div", { className: styles.uniqueDiscount, children: [
211
+ /* @__PURE__ */ jsx("span", { className: styles.uniqueDiscountLabel, children: cartItem.discount.name }),
212
+ (cartItem.discount.value.upfront || 0) > 0 && /* @__PURE__ */ jsxs("span", { className: styles.uniqueDiscountPrice, children: [
213
+ "-",
214
+ formatPrice(cartItem.discount.value.upfront)
215
+ ] })
216
+ ] })
217
+ ] });
218
+ };
219
+ const CartItemDiscountBadges = ({ cartItem }) => {
220
+ var _a;
221
+ const discounts = ((_a = cartItem.discount) == null ? void 0 : _a.types) || [];
222
+ return /* @__PURE__ */ jsx(Fragment, { children: discounts.map((discount, index) => /* @__PURE__ */ jsx(
223
+ Badge,
224
+ {
225
+ className: styles.discountDescription,
226
+ variant: discount.badgeVariant ?? "neutral",
227
+ hideIcon: true,
228
+ children: discount.text
229
+ },
230
+ `${discount.id}-${index}`
231
+ )) });
232
+ };
233
+ const CartItemName = ({ cartItem }) => /* @__PURE__ */ jsxs(Fragment, { children: [
234
+ /* @__PURE__ */ jsxs("div", { className: styles.nameWrapper, children: [
235
+ /* @__PURE__ */ jsxs("div", { className: styles.link, children: [
236
+ cartItem.lineThrough && /* @__PURE__ */ jsx("span", { className: styles.priceLinethrough, children: cartItem.lineThrough }),
237
+ cartItem.href ? /* @__PURE__ */ jsx(Link, { href: cartItem.href, variant: "navigation", className: styles.cartLink, children: cartItem.name }) : cartItem.name,
238
+ cartItem.type === "BREAKAGE_FEE" && /* @__PURE__ */ jsxs(Tooltip, { children: [
239
+ /* @__PURE__ */ jsx(Tooltip.Trigger, { className: styles.tooltipTrigger }),
240
+ /* @__PURE__ */ jsx(Tooltip.Content, { className: styles.breakageFeeInfo, children: /* @__PURE__ */ jsx(Text, { variant: "paragraph-100", children: "Bruddgebyret er lik totalrabatten du får i kampanjen. Bruddgebyret reduseres månedlig ut avtaletiden, regnet fra når avtalen er inngått. Beløpet kommer på neste faktura." }) })
241
+ ] })
242
+ ] }),
243
+ /* @__PURE__ */ jsx(CartItemDiscountBadges, { cartItem })
244
+ ] }),
245
+ cartItem.color && /* @__PURE__ */ jsxs(Text, { variant: "paragraph-100", mb: "200", children: [
246
+ cartItem.color,
247
+ cartItem.modelSize ? ", " + cartItem.modelSize : ""
248
+ ] })
249
+ ] });
250
+ const Item = ({ cartItem, onChangeQuantity, onRemoveItem }) => {
251
+ var _a;
252
+ const { hasPaid, isAllowedToDelete } = useShoppingCart();
253
+ const isRemovable = !!((_a = cartItem.quantity) == null ? void 0 : _a.removable);
254
+ return /* @__PURE__ */ jsxs("div", { className: styles.item, children: [
255
+ /* @__PURE__ */ jsxs("div", { className: styles.nameContainer, children: [
256
+ /* @__PURE__ */ jsx(CartItemImage, { cartItem }),
257
+ /* @__PURE__ */ jsxs("div", { className: styles.name, children: [
258
+ /* @__PURE__ */ jsx(CartItemName, { cartItem }),
259
+ /* @__PURE__ */ jsx(CartItemPriceDisplay, { cartItem, onChangeQuantity, hasPaid })
260
+ ] })
261
+ ] }),
262
+ isRemovable && isAllowedToDelete && /* @__PURE__ */ jsx("button", { type: "button", onClick: () => onRemoveItem(cartItem), className: styles.deleteButtonContainer, children: /* @__PURE__ */ jsx(Icon, { name: "remove" }) })
263
+ ] });
264
+ };
265
+ Item.displayName = "Item";
266
+ export {
267
+ Item
268
+ };
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const React = require("react");
5
+ const components_shoppingCart_shoppingCartItem = require("./shopping-cart-item.cjs");
6
+ const shoppingCart_module = require("../../shopping-cart.module-BCoLrcMI.cjs");
7
+ const components_shoppingCart_utils = require("./utils.cjs");
8
+ const ItemGroup = ({ cartItem, onChangeQuantity, onRemoveItem }) => {
9
+ const renderCartItem = (item) => /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
10
+ /* @__PURE__ */ jsxRuntime.jsx(components_shoppingCart_shoppingCartItem.Item, { cartItem: item, onChangeQuantity, onRemoveItem }),
11
+ item.items && item.items.length > 0 && components_shoppingCart_utils.sortByType(item.items).map((subItem) => renderCartItem(subItem))
12
+ ] }, item.id);
13
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: shoppingCart_module.styles.sectionBody, children: renderCartItem(cartItem) });
14
+ };
15
+ const Items = ({ cartItems, onChangeQuantity, onRemoveItem }) => {
16
+ return /* @__PURE__ */ jsxRuntime.jsx("section", { children: components_shoppingCart_utils.sortByType(cartItems).map((item) => /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(ItemGroup, { cartItem: item, onChangeQuantity, onRemoveItem }) }, `${item.id}-${item.bundleId}`)) });
17
+ };
18
+ Items.displayName = "Items";
19
+ exports.Items = Items;
@@ -0,0 +1,11 @@
1
+ import { CartItem } from './types';
2
+
3
+ export interface ItemsProps {
4
+ cartItems: CartItem[];
5
+ onChangeQuantity: (item: CartItem, quantity: number) => void;
6
+ onRemoveItem: (item: CartItem) => void;
7
+ }
8
+ export declare const Items: {
9
+ ({ cartItems, onChangeQuantity, onRemoveItem }: ItemsProps): import("react/jsx-runtime").JSX.Element;
10
+ displayName: string;
11
+ };
@@ -0,0 +1,19 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Fragment } from "react";
3
+ import { Item } from "./shopping-cart-item.js";
4
+ import { s as styles } from "../../shopping-cart.module-DA25l2hr.js";
5
+ import { sortByType } from "./utils.js";
6
+ const ItemGroup = ({ cartItem, onChangeQuantity, onRemoveItem }) => {
7
+ const renderCartItem = (item) => /* @__PURE__ */ jsxs(Fragment, { children: [
8
+ /* @__PURE__ */ jsx(Item, { cartItem: item, onChangeQuantity, onRemoveItem }),
9
+ item.items && item.items.length > 0 && sortByType(item.items).map((subItem) => renderCartItem(subItem))
10
+ ] }, item.id);
11
+ return /* @__PURE__ */ jsx("div", { className: styles.sectionBody, children: renderCartItem(cartItem) });
12
+ };
13
+ const Items = ({ cartItems, onChangeQuantity, onRemoveItem }) => {
14
+ return /* @__PURE__ */ jsx("section", { children: sortByType(cartItems).map((item) => /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(ItemGroup, { cartItem: item, onChangeQuantity, onRemoveItem }) }, `${item.id}-${item.bundleId}`)) });
15
+ };
16
+ Items.displayName = "Items";
17
+ export {
18
+ Items
19
+ };