@telia/teddy 0.7.71 → 0.7.73

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,38 +12,39 @@ import { Tooltip } from "../tooltip/index.js";
12
12
  import { CART_ITEM_TYPE } from "./types.js";
13
13
  import { useShoppingCart } from "./shopping-cart-context.js";
14
14
  import { getDiscountPrice, getPrice, defaultFormatPrice } from "./utils.js";
15
- const item = "_item_1xnov_1";
16
- const breakageFeeInfo = "_breakageFeeInfo_1xnov_7";
17
- const nameWrapper = "_nameWrapper_1xnov_26";
18
- const link = "_link_1xnov_33";
19
- const cartLink = "_cartLink_1xnov_51";
20
- const discountDescription = "_discountDescription_1xnov_59";
21
- const name = "_name_1xnov_26";
22
- const nameContainer = "_nameContainer_1xnov_72";
23
- const subtitle = "_subtitle_1xnov_76";
24
- const subtitleRow = "_subtitleRow_1xnov_84";
25
- const subtitlePriceInfo = "_subtitlePriceInfo_1xnov_91";
26
- const quantityPickerWrapper = "_quantityPickerWrapper_1xnov_97";
27
- const pricePer = "_pricePer_1xnov_104";
28
- const quantityPicker = "_quantityPicker_1xnov_97";
29
- const priceContainer = "_priceContainer_1xnov_116";
30
- const priceRow = "_priceRow_1xnov_123";
31
- const priceCost = "_priceCost_1xnov_129";
32
- const priceLabel = "_priceLabel_1xnov_137";
33
- const priceLinethrough = "_priceLinethrough_1xnov_142";
34
- const priceLinethroughDisclaimer = "_priceLinethroughDisclaimer_1xnov_152";
35
- const imageContainer = "_imageContainer_1xnov_161";
36
- const noImageContainer = "_noImageContainer_1xnov_173";
37
- const image = "_image_1xnov_161";
38
- const iconImage = "_iconImage_1xnov_186";
39
- const deleteButtonContainer = "_deleteButtonContainer_1xnov_192";
40
- const uniqueDiscount = "_uniqueDiscount_1xnov_219";
41
- const uniqueDiscountLabel = "_uniqueDiscountLabel_1xnov_226";
42
- const uniqueDiscountPrice = "_uniqueDiscountPrice_1xnov_232";
43
- const onlyInShops = "_onlyInShops_1xnov_237";
44
- const onlyInShopsLabel = "_onlyInShopsLabel_1xnov_244";
45
- const tooltipTrigger = "_tooltipTrigger_1xnov_263";
46
- const priceWrapper = "_priceWrapper_1xnov_271";
15
+ const item = "_item_15muv_1";
16
+ const breakageFeeInfo = "_breakageFeeInfo_15muv_7";
17
+ const nameWrapper = "_nameWrapper_15muv_26";
18
+ const link = "_link_15muv_33";
19
+ const cartLink = "_cartLink_15muv_51";
20
+ const discountDescription = "_discountDescription_15muv_59";
21
+ const name = "_name_15muv_26";
22
+ const nameContainer = "_nameContainer_15muv_72";
23
+ const quantityWrapper = "_quantityWrapper_15muv_76";
24
+ const subtitleRow = "_subtitleRow_15muv_84";
25
+ const subtitlePriceInfo = "_subtitlePriceInfo_15muv_91";
26
+ const quantityPickerWrapper = "_quantityPickerWrapper_15muv_97";
27
+ const pricePer = "_pricePer_15muv_104";
28
+ const quantityPicker = "_quantityPicker_15muv_97";
29
+ const characteristics = "_characteristics_15muv_116";
30
+ const price = "_price_15muv_104";
31
+ const quantityContainer = "_quantityContainer_15muv_126";
32
+ const priceCost = "_priceCost_15muv_133";
33
+ const priceLabel = "_priceLabel_15muv_141";
34
+ const priceLinethrough = "_priceLinethrough_15muv_146";
35
+ const priceLinethroughDisclaimer = "_priceLinethroughDisclaimer_15muv_156";
36
+ const imageContainer = "_imageContainer_15muv_165";
37
+ const noImageContainer = "_noImageContainer_15muv_177";
38
+ const image = "_image_15muv_165";
39
+ const iconImage = "_iconImage_15muv_190";
40
+ const deleteButtonContainer = "_deleteButtonContainer_15muv_196";
41
+ const uniqueDiscount = "_uniqueDiscount_15muv_223";
42
+ const uniqueDiscountLabel = "_uniqueDiscountLabel_15muv_230";
43
+ const uniqueDiscountPrice = "_uniqueDiscountPrice_15muv_236";
44
+ const onlyInShops = "_onlyInShops_15muv_241";
45
+ const onlyInShopsLabel = "_onlyInShopsLabel_15muv_248";
46
+ const tooltipTrigger = "_tooltipTrigger_15muv_267";
47
+ const priceWrapper = "_priceWrapper_15muv_275";
47
48
  const styles = {
48
49
  item,
49
50
  breakageFeeInfo,
@@ -53,14 +54,15 @@ const styles = {
53
54
  discountDescription,
54
55
  name,
55
56
  nameContainer,
56
- subtitle,
57
+ quantityWrapper,
57
58
  subtitleRow,
58
59
  subtitlePriceInfo,
59
60
  quantityPickerWrapper,
60
61
  pricePer,
61
62
  quantityPicker,
62
- priceContainer,
63
- priceRow,
63
+ characteristics,
64
+ price,
65
+ quantityContainer,
64
66
  priceCost,
65
67
  priceLabel,
66
68
  priceLinethrough,
@@ -84,7 +86,7 @@ const QuantityPicker = ({
84
86
  cartItem,
85
87
  shouldShowPricePerUnit,
86
88
  isQuantityModifiable,
87
- price,
89
+ price: price2,
88
90
  discountValueUpfront,
89
91
  discountValueMonthly,
90
92
  hasPaid
@@ -123,7 +125,7 @@ const QuantityPicker = ({
123
125
  ] }),
124
126
  shouldShowPricePerUnit && /* @__PURE__ */ jsxs("span", { className: styles.pricePer, children: [
125
127
  quantity > 1 && !isQuantityModifiable && `${quantity} x `,
126
- `${getPrice(defaultFormatPrice, price, discountValueUpfront, discountValueMonthly, 1)}/stk`
128
+ `${getPrice(defaultFormatPrice, price2, discountValueUpfront, discountValueMonthly, 1)}/stk`
127
129
  ] })
128
130
  ] });
129
131
  };
@@ -143,69 +145,35 @@ const CartItemImage = ({ cartItem }) => {
143
145
  };
144
146
  return /* @__PURE__ */ jsx("div", { className: styles.imageContainer, children: cartItem.href ? /* @__PURE__ */ jsx(Link, { href: cartItem.href, "aria-label": cartItem.name, variant: "navigation", className: styles.cartLink, children: renderImage() }) : renderImage() });
145
147
  };
146
- const CartItemPriceDisplay = ({ cartItem, hasPaid, onChangeQuantity }) => {
147
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
148
+ const CartItemDetails = ({ cartItem, hasPaid, onChangeQuantity }) => {
149
+ var _a, _b, _c, _d, _e, _f, _g, _h;
148
150
  const { formatPrice, readonly } = useShoppingCart();
149
151
  const quantity = ((_a = cartItem.quantity) == null ? void 0 : _a.value) ?? 1;
150
152
  const isQuantityModifiable = !!((_b = cartItem.quantity) == null ? void 0 : _b.modifiable);
151
153
  const shouldShowPricePerUnit = (!!cartItem.price.upfront || !!cartItem.price.firstInvoice) && quantity > 1;
152
154
  const isManualDiscount = (_c = cartItem.discount) == null ? void 0 : _c.isManualDiscount;
153
155
  const discountValueUpfront = isManualDiscount ? 0 : ((_e = (_d = cartItem.discount) == null ? void 0 : _d.value) == null ? void 0 : _e.upfront) || 0;
154
- const isLease = cartItem.leaseMonths === 0 || !!cartItem.leaseMonths;
155
- const hasSubscription = !!((_f = cartItem.items) == null ? void 0 : _f.find((item2) => item2.type.includes("SUBSCRIPTION")));
156
- const discountValueMonthly = ((_h = (_g = cartItem.discount) == null ? void 0 : _g.value) == null ? void 0 : _h.monthly) || 0;
157
- const discountPrice = getDiscountPrice(cartItem.price, quantity) || "";
158
- const price = getPrice(formatPrice, cartItem.price, discountValueUpfront, discountValueMonthly, quantity);
159
- const discountPriceText = ((_i = cartItem.discount) == null ? void 0 : _i.handsetDiscountText) || "";
156
+ const discountValueMonthly = ((_g = (_f = cartItem.discount) == null ? void 0 : _f.value) == null ? void 0 : _g.monthly) || 0;
160
157
  const subtitles = (Array.isArray(cartItem.subtitle) ? cartItem.subtitle : [cartItem.subtitle]).filter(Boolean);
161
158
  const suppressSubtitles = cartItem.type === CART_ITEM_TYPE.SUBSCRIPTION ? true : void 0;
162
- return /* @__PURE__ */ jsxs("div", { className: styles.price, children: [
163
- /* @__PURE__ */ jsxs("div", { className: styles.priceContainer, children: [
164
- /* @__PURE__ */ jsxs("div", { className: styles.priceRow, children: [
165
- /* @__PURE__ */ jsxs("div", { className: styles.subtitle, children: [
166
- subtitles.length > 0 ? /* @__PURE__ */ jsx(
167
- "div",
168
- {
169
- "data-hj-suppress": suppressSubtitles,
170
- className: "paragraph",
171
- dangerouslySetInnerHTML: {
172
- __html: typeof subtitles[0] === "string" ? subtitles[0] : subtitles[0].description
173
- }
174
- }
175
- ) : /* @__PURE__ */ jsx("span", {}),
176
- quantity > 1 && !shouldShowPricePerUnit && /* @__PURE__ */ jsx("span", { children: `${quantity} stk` }),
177
- isQuantityModifiable && !readonly && /* @__PURE__ */ jsx(
178
- QuantityPicker,
179
- {
180
- quantity,
181
- onChangeQuantity,
182
- cartItem,
183
- shouldShowPricePerUnit,
184
- isQuantityModifiable,
185
- price: cartItem.price,
186
- discountValueUpfront,
187
- discountValueMonthly,
188
- hasPaid
189
- }
190
- )
191
- ] }),
192
- /* @__PURE__ */ jsx("div", { style: { position: "relative" }, children: /* @__PURE__ */ jsxs("span", { className: styles.priceCost, children: [
193
- /* @__PURE__ */ jsxs("div", { className: styles.priceWrapper, children: [
194
- discountPriceText && /* @__PURE__ */ jsxs(Tooltip, { defaultOpen: true, children: [
195
- /* @__PURE__ */ jsx(Tooltip.Trigger, { className: styles.tooltipTrigger }),
196
- /* @__PURE__ */ jsx(Tooltip.Content, { children: /* @__PURE__ */ jsx(Text, { variant: "paragraph-100", dangerouslySetInnerHTML: { __html: discountPriceText } }) })
197
- ] }),
198
- /* @__PURE__ */ jsxs("span", { className: styles.priceLabel, children: [
199
- /* @__PURE__ */ jsx("span", { children: isLease && !hasSubscription && "fra " }),
200
- /* @__PURE__ */ jsx("span", { children: price }),
201
- /* @__PURE__ */ jsx("span", { children: cartItem.price.monthly ? "/md." : "" })
202
- ] })
203
- ] }),
204
- discountPrice && formatPrice(discountPrice) !== price && /* @__PURE__ */ jsxs(Fragment, { children: [
205
- /* @__PURE__ */ jsx("span", { className: styles.priceLinethroughDisclaimer, children: "ord. pris:" }),
206
- /* @__PURE__ */ jsx("span", { className: styles.priceLinethrough, children: cartItem.price.monthly ? formatPrice(discountPrice) + "/md." : formatPrice(discountPrice) })
207
- ] })
208
- ] }) })
159
+ return /* @__PURE__ */ jsxs("div", { children: [
160
+ /* @__PURE__ */ jsxs("div", { className: styles.quantityContainer, children: [
161
+ /* @__PURE__ */ jsxs("div", { className: styles.quantityWrapper, children: [
162
+ quantity > 1 && !shouldShowPricePerUnit && /* @__PURE__ */ jsx("span", { children: `${quantity} stk` }),
163
+ isQuantityModifiable && !readonly && /* @__PURE__ */ jsx(
164
+ QuantityPicker,
165
+ {
166
+ quantity,
167
+ onChangeQuantity,
168
+ cartItem,
169
+ shouldShowPricePerUnit,
170
+ isQuantityModifiable,
171
+ price: cartItem.price,
172
+ discountValueUpfront,
173
+ discountValueMonthly,
174
+ hasPaid
175
+ }
176
+ )
209
177
  ] }),
210
178
  subtitles.slice(1).map((sub, index) => {
211
179
  const description = typeof sub === "string" ? sub : sub.description;
@@ -231,7 +199,7 @@ const CartItemPriceDisplay = ({ cartItem, hasPaid, onChangeQuantity }) => {
231
199
  /* @__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." }) })
232
200
  ] })
233
201
  ] }),
234
- ((_j = cartItem.discount) == null ? void 0 : _j.isManualDiscount) && /* @__PURE__ */ jsxs("div", { className: styles.uniqueDiscount, children: [
202
+ ((_h = cartItem.discount) == null ? void 0 : _h.isManualDiscount) && /* @__PURE__ */ jsxs("div", { className: styles.uniqueDiscount, children: [
235
203
  /* @__PURE__ */ jsx("span", { className: styles.uniqueDiscountLabel, children: cartItem.discount.name }),
236
204
  (cartItem.discount.value.upfront || 0) > 0 && /* @__PURE__ */ jsxs("span", { className: styles.uniqueDiscountPrice, children: [
237
205
  "-",
@@ -254,8 +222,8 @@ const CartItemDiscountBadges = ({ cartItem }) => {
254
222
  `${discount.id}-${index}`
255
223
  )) });
256
224
  };
257
- const CartItemName = ({ cartItem }) => /* @__PURE__ */ jsxs(Fragment, { children: [
258
- /* @__PURE__ */ jsxs("div", { className: styles.nameWrapper, children: [
225
+ const CartItemName = ({ cartItem }) => {
226
+ return /* @__PURE__ */ jsxs("div", { className: styles.nameWrapper, children: [
259
227
  /* @__PURE__ */ jsxs("div", { className: styles.link, children: [
260
228
  cartItem.lineThrough && /* @__PURE__ */ jsx("span", { className: styles.priceLinethrough, children: cartItem.lineThrough }),
261
229
  cartItem.href ? /* @__PURE__ */ jsx(Link, { href: cartItem.href, variant: "navigation", className: styles.cartLink, children: cartItem.name }) : cartItem.name,
@@ -265,22 +233,36 @@ const CartItemName = ({ cartItem }) => /* @__PURE__ */ jsxs(Fragment, { children
265
233
  ] })
266
234
  ] }),
267
235
  /* @__PURE__ */ jsx(CartItemDiscountBadges, { cartItem })
268
- ] }),
269
- cartItem.color && /* @__PURE__ */ jsxs(Text, { variant: "paragraph-100", mb: "200", children: [
270
- cartItem.color,
271
- cartItem.modelSize ? ", " + cartItem.modelSize : ""
272
- ] })
273
- ] });
236
+ ] });
237
+ };
274
238
  const Item = ({ cartItem, onChangeQuantity, onRemoveItem, className }) => {
275
239
  var _a;
276
240
  const { hasPaid, isAllowedToDelete, readonly } = useShoppingCart();
277
241
  const isRemovable = !!((_a = cartItem.quantity) == null ? void 0 : _a.removable);
242
+ const subtitles = (Array.isArray(cartItem.subtitle) ? cartItem.subtitle : [cartItem.subtitle]).filter(Boolean);
243
+ const suppressSubtitles = cartItem.type === CART_ITEM_TYPE.SUBSCRIPTION ? true : void 0;
278
244
  return /* @__PURE__ */ jsxs("div", { className: clsx(styles.item, className), children: [
279
245
  /* @__PURE__ */ jsxs("div", { className: styles.nameContainer, children: [
280
246
  /* @__PURE__ */ jsx(CartItemImage, { cartItem }),
281
247
  /* @__PURE__ */ jsxs("div", { className: styles.name, children: [
282
248
  /* @__PURE__ */ jsx(CartItemName, { cartItem }),
283
- /* @__PURE__ */ jsx(CartItemPriceDisplay, { cartItem, onChangeQuantity, hasPaid })
249
+ /* @__PURE__ */ jsxs("div", { className: styles.characteristics, children: [
250
+ /* @__PURE__ */ jsxs("div", { children: [
251
+ /* @__PURE__ */ jsx(Characteristics, { cartItem }),
252
+ subtitles.length > 0 ? /* @__PURE__ */ jsx(
253
+ "div",
254
+ {
255
+ "data-hj-suppress": suppressSubtitles,
256
+ className: styles.subtitle,
257
+ dangerouslySetInnerHTML: {
258
+ __html: typeof subtitles[0] === "string" ? subtitles[0] : subtitles[0].description
259
+ }
260
+ }
261
+ ) : /* @__PURE__ */ jsx("span", {})
262
+ ] }),
263
+ /* @__PURE__ */ jsx(Price, { cartItem })
264
+ ] }),
265
+ /* @__PURE__ */ jsx(CartItemDetails, { cartItem, onChangeQuantity, hasPaid })
284
266
  ] })
285
267
  ] }),
286
268
  isRemovable && isAllowedToDelete && !readonly && /* @__PURE__ */ jsx(
@@ -295,6 +277,43 @@ const Item = ({ cartItem, onChangeQuantity, onRemoveItem, className }) => {
295
277
  )
296
278
  ] });
297
279
  };
280
+ const Price = ({ cartItem }) => {
281
+ var _a, _b, _c, _d, _e, _f, _g, _h;
282
+ const { formatPrice } = useShoppingCart();
283
+ const quantity = ((_a = cartItem.quantity) == null ? void 0 : _a.value) ?? 1;
284
+ const isLease = cartItem.leaseMonths === 0 || !!cartItem.leaseMonths;
285
+ const hasSubscription = !!((_b = cartItem.items) == null ? void 0 : _b.find((item2) => item2.type.includes("SUBSCRIPTION")));
286
+ const isManualDiscount = (_c = cartItem.discount) == null ? void 0 : _c.isManualDiscount;
287
+ const discountValueMonthly = ((_e = (_d = cartItem.discount) == null ? void 0 : _d.value) == null ? void 0 : _e.monthly) || 0;
288
+ const discountValueUpfront = isManualDiscount ? 0 : ((_g = (_f = cartItem.discount) == null ? void 0 : _f.value) == null ? void 0 : _g.upfront) || 0;
289
+ const discountPrice = getDiscountPrice(cartItem.price, quantity) || "";
290
+ const price2 = getPrice(formatPrice, cartItem.price, discountValueUpfront, discountValueMonthly, quantity);
291
+ const discountPriceText = ((_h = cartItem.discount) == null ? void 0 : _h.handsetDiscountText) || "";
292
+ return /* @__PURE__ */ jsx("div", { className: styles.price, children: /* @__PURE__ */ jsxs("span", { className: styles.priceCost, children: [
293
+ /* @__PURE__ */ jsxs("div", { className: styles.priceWrapper, children: [
294
+ discountPriceText && /* @__PURE__ */ jsxs(Tooltip, { defaultOpen: true, children: [
295
+ /* @__PURE__ */ jsx(Tooltip.Trigger, { className: styles.tooltipTrigger }),
296
+ /* @__PURE__ */ jsx(Tooltip.Content, { children: /* @__PURE__ */ jsx(Text, { variant: "paragraph-100", dangerouslySetInnerHTML: { __html: discountPriceText } }) })
297
+ ] }),
298
+ /* @__PURE__ */ jsxs("span", { className: styles.priceLabel, children: [
299
+ /* @__PURE__ */ jsx("span", { children: isLease && !hasSubscription && "fra " }),
300
+ /* @__PURE__ */ jsx("span", { children: price2 }),
301
+ /* @__PURE__ */ jsx("span", { children: cartItem.price.monthly ? "/md." : "" })
302
+ ] })
303
+ ] }),
304
+ discountPrice && formatPrice(discountPrice) !== price2 && /* @__PURE__ */ jsxs(Fragment, { children: [
305
+ /* @__PURE__ */ jsx("span", { className: styles.priceLinethroughDisclaimer, children: "ord. pris:" }),
306
+ /* @__PURE__ */ jsx("span", { className: styles.priceLinethrough, children: cartItem.price.monthly ? formatPrice(discountPrice) + "/md." : formatPrice(discountPrice) })
307
+ ] })
308
+ ] }) });
309
+ };
310
+ const Characteristics = ({ cartItem }) => {
311
+ if (!cartItem.color) return null;
312
+ return /* @__PURE__ */ jsxs(Text, { variant: "paragraph-100", mb: "100", children: [
313
+ cartItem.color,
314
+ cartItem.modelSize ? ", " + cartItem.modelSize : ""
315
+ ] });
316
+ };
298
317
  Item.displayName = "Item";
299
318
  export {
300
319
  Item