@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.
- package/dist/components/input/input-group.cjs +10 -10
- package/dist/components/input/input-group.js +10 -10
- package/dist/components/shopping-cart/shopping-cart-item.cjs +121 -102
- package/dist/components/shopping-cart/shopping-cart-item.js +121 -102
- package/dist/teddy.css +1 -1
- package/package.json +1 -1
|
@@ -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 = "
|
|
16
|
-
const breakageFeeInfo = "
|
|
17
|
-
const nameWrapper = "
|
|
18
|
-
const link = "
|
|
19
|
-
const cartLink = "
|
|
20
|
-
const discountDescription = "
|
|
21
|
-
const name = "
|
|
22
|
-
const nameContainer = "
|
|
23
|
-
const
|
|
24
|
-
const subtitleRow = "
|
|
25
|
-
const subtitlePriceInfo = "
|
|
26
|
-
const quantityPickerWrapper = "
|
|
27
|
-
const pricePer = "
|
|
28
|
-
const quantityPicker = "
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
const
|
|
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
|
-
|
|
57
|
+
quantityWrapper,
|
|
57
58
|
subtitleRow,
|
|
58
59
|
subtitlePriceInfo,
|
|
59
60
|
quantityPickerWrapper,
|
|
60
61
|
pricePer,
|
|
61
62
|
quantityPicker,
|
|
62
|
-
|
|
63
|
-
|
|
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,
|
|
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
|
|
147
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
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
|
|
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", {
|
|
163
|
-
/* @__PURE__ */ jsxs("div", { className: styles.
|
|
164
|
-
/* @__PURE__ */ jsxs("div", { className: styles.
|
|
165
|
-
/* @__PURE__ */
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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
|
-
((
|
|
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 }) =>
|
|
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
|
-
|
|
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__ */
|
|
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
|