@ikas/code-components-mcp 1.4.0-beta.23 → 1.4.0-beta.231
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/data/framework.json +191 -78
- package/data/migration.json +10 -4
- package/data/section-templates/account-info-section/children/AccountFavorites/ikas-config-snippet.json +13 -0
- package/data/section-templates/account-info-section/children/AccountOrders/index.tsx +1 -1
- package/data/section-templates/account-info-section/ikas-config-snippet.json +19 -0
- package/data/section-templates/add-to-cart/ikas-config-snippet.json +17 -0
- package/data/section-templates/add-to-cart/index.tsx +16 -2
- package/data/section-templates/add-to-cart/sub-components/QuantitySelector/index.tsx +11 -3
- package/data/section-templates/add-to-cart/utils/cartLimits.ts +24 -0
- package/data/section-templates/blog-home-section/ikas-config-snippet.json +2 -0
- package/data/section-templates/blog-home-section/index.tsx +2 -1
- package/data/section-templates/blog-post-section/ikas-config-snippet.json +2 -0
- package/data/section-templates/blog-post-section/index.tsx +3 -2
- package/data/section-templates/bundle-products/hooks/useBundleProducts.ts +7 -6
- package/data/section-templates/bundle-products/ikas-config-snippet.json +20 -0
- package/data/section-templates/cart-section/components/EmptyState/index.tsx +1 -1
- package/data/section-templates/cart-section/sub-components/CartItem/index.tsx +66 -24
- package/data/section-templates/cart-section/sub-components/CartItem/styles.css +14 -0
- package/data/section-templates/cart-section/sub-components/QuantitySelector/index.tsx +11 -3
- package/data/section-templates/cart-section/utils/cartLimits.ts +24 -0
- package/data/section-templates/cart-section/utils/cartLineLimits.ts +100 -0
- package/data/section-templates/category-images-section/children/CategoryImageItem/ikas-config-snippet.json +4 -0
- package/data/section-templates/category-images-section/ikas-config-snippet.json +15 -0
- package/data/section-templates/category-list-section/children/CardProductName/ikas-config-snippet.json +2 -1
- package/data/section-templates/category-list-section/ikas-config-snippet.json +21 -0
- package/data/section-templates/category-list-section/index.tsx +2 -1
- package/data/section-templates/component-renderer/additional/ProductDetail/index.tsx +5 -1
- package/data/section-templates/component-renderer/ikas-config-snippet.json +13 -0
- package/data/section-templates/favorites/ikas-config-snippet.json +18 -1
- package/data/section-templates/features-section/ikas-config-snippet.json +13 -0
- package/data/section-templates/footer-section/ikas-config-snippet.json +15 -0
- package/data/section-templates/forgot-password-section/components/ForgotPasswordForm/index.tsx +1 -1
- package/data/section-templates/header-section/children/Announcements/ikas-config-snippet.json +7 -0
- package/data/section-templates/header-section/children/CookieBar/ikas-config-snippet.json +3 -0
- package/data/section-templates/header-section/children/Navbar/components/CartSidebar/index.tsx +2 -1
- package/data/section-templates/header-section/children/Navbar/components/SearchModal/index.tsx +2 -1
- package/data/section-templates/header-section/children/Navbar/ikas-config-snippet.json +27 -0
- package/data/section-templates/header-section/children/Navbar/index.tsx +6 -5
- package/data/section-templates/header-section/ikas-config-snippet.json +13 -0
- package/data/section-templates/header-section/sub-components/CartItem/index.tsx +66 -24
- package/data/section-templates/header-section/sub-components/CartItem/styles.css +14 -0
- package/data/section-templates/header-section/sub-components/QuantitySelector/index.tsx +11 -3
- package/data/section-templates/header-section/utils/cartLimits.ts +24 -0
- package/data/section-templates/header-section/utils/cartLineLimits.ts +100 -0
- package/data/section-templates/hero-slider-section/children/HeroSliderItem/ikas-config-snippet.json +18 -0
- package/data/section-templates/hero-slider-section/children/HeroSliderItem/index.tsx +12 -7
- package/data/section-templates/hero-slider-section/ikas-config-snippet.json +13 -0
- package/data/section-templates/image-handling/ikas-config-snippet.json +53 -0
- package/data/section-templates/image-handling/index.tsx +5 -1
- package/data/section-templates/login-section/ikas-config-snippet.json +2 -0
- package/data/section-templates/navigation/components/CartSidebar/index.tsx +2 -1
- package/data/section-templates/navigation/components/SearchModal/index.tsx +2 -1
- package/data/section-templates/navigation/ikas-config-snippet.json +27 -0
- package/data/section-templates/navigation/index.tsx +6 -5
- package/data/section-templates/navigation/sub-components/CartItem/index.tsx +66 -24
- package/data/section-templates/navigation/sub-components/CartItem/styles.css +14 -0
- package/data/section-templates/navigation/sub-components/QuantitySelector/index.tsx +11 -3
- package/data/section-templates/navigation/utils/cartLimits.ts +24 -0
- package/data/section-templates/navigation/utils/cartLineLimits.ts +100 -0
- package/data/section-templates/product-detail-section/children/ProductDetailAddToCart/ikas-config-snippet.json +17 -0
- package/data/section-templates/product-detail-section/children/ProductDetailAddToCart/index.tsx +16 -2
- package/data/section-templates/product-detail-section/children/ProductDetailBackInStock/components/BackInStockForm/index.tsx +92 -0
- package/data/section-templates/product-detail-section/children/ProductDetailBackInStock/ikas-config-snippet.json +175 -0
- package/data/section-templates/product-detail-section/children/ProductDetailBackInStock/index.tsx +141 -0
- package/data/section-templates/product-detail-section/children/ProductDetailBackInStock/styles.css +47 -0
- package/data/section-templates/product-detail-section/children/ProductDetailBackInStock/types.ts +25 -0
- package/data/section-templates/product-detail-section/children/ProductDetailBundleFurniture/ikas-config-snippet.json +18 -0
- package/data/section-templates/product-detail-section/children/ProductDetailBundleProduct/ikas-config-snippet.json +20 -0
- package/data/section-templates/product-detail-section/children/ProductDetailDescription/ikas-config-snippet.json +27 -0
- package/data/section-templates/product-detail-section/children/ProductDetailFeatures/ikas-config-snippet.json +29 -0
- package/data/section-templates/product-detail-section/children/ProductDetailNameFavorite/ikas-config-snippet.json +18 -1
- package/data/section-templates/product-detail-section/children/ProductDetailOffer/ikas-config-snippet.json +20 -0
- package/data/section-templates/product-detail-section/children/ProductDetailOptionSet/ikas-config-snippet.json +16 -0
- package/data/section-templates/product-detail-section/children/ProductDetailPrices/ikas-config-snippet.json +16 -0
- package/data/section-templates/product-detail-section/children/ProductDetailProductGroup/ikas-config-snippet.json +16 -0
- package/data/section-templates/product-detail-section/children/ProductDetailSku/ikas-config-snippet.json +16 -0
- package/data/section-templates/product-detail-section/children/ProductDetailVariant/ikas-config-snippet.json +17 -0
- package/data/section-templates/product-detail-section/hooks/useBundleProducts.ts +7 -6
- package/data/section-templates/product-detail-section/ikas-config-snippet.json +53 -0
- package/data/section-templates/product-detail-section/index.tsx +5 -1
- package/data/section-templates/product-detail-section/sub-components/Modal/index.tsx +120 -0
- package/data/section-templates/product-detail-section/sub-components/Modal/styles.css +70 -0
- package/data/section-templates/product-detail-section/sub-components/QuantitySelector/index.tsx +11 -3
- package/data/section-templates/product-detail-section/utils/cartLimits.ts +24 -0
- package/data/section-templates/product-pricing/ikas-config-snippet.json +16 -0
- package/data/section-templates/product-slider-section/children/CardProductName/ikas-config-snippet.json +2 -1
- package/data/section-templates/product-slider-section/ikas-config-snippet.json +17 -0
- package/data/section-templates/register-section/ikas-config-snippet.json +2 -0
- package/data/section-templates/variant-selection/ikas-config-snippet.json +17 -0
- package/data/storefront-api.json +1046 -80
- package/data/storefront-types.json +9868 -6037
- package/dist/index.js +2578 -257
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -9,15 +9,16 @@ import {
|
|
|
9
9
|
cartStore,
|
|
10
10
|
waitForCartStoreInit,
|
|
11
11
|
} from "@ikas/bp-storefront";
|
|
12
|
-
import { runInAction } from "mobx";
|
|
13
12
|
import { adjustBundleProductQuantity } from "../utils/bundle";
|
|
14
13
|
|
|
14
|
+
// No mobx action wrapper needed: adjustments go through the public
|
|
15
|
+
// setBundleProductQuantity API (plain mutation, same as the SDK's own usage
|
|
16
|
+
// examples), and keeping the theme free of direct mobx imports lets the
|
|
17
|
+
// scaffold install cleanly under pnpm's strict node_modules layout.
|
|
15
18
|
function adjustBundleQuantities(products: IkasBundleProduct[]) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
});
|
|
19
|
+
for (const bp of products) {
|
|
20
|
+
adjustBundleProductQuantity(bp);
|
|
21
|
+
}
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
export function useBundleProducts(product: IkasProduct | null | undefined) {
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"displayName": "Aspect Ratio",
|
|
17
17
|
"type": "ENUM",
|
|
18
18
|
"required": false,
|
|
19
|
+
"defaultValue": "Square",
|
|
19
20
|
"groupId": "image-settings",
|
|
20
21
|
"enumTypeId": "{{ENUM_ID:AspectRatio}}"
|
|
21
22
|
},
|
|
@@ -24,6 +25,7 @@
|
|
|
24
25
|
"displayName": "Image Fit",
|
|
25
26
|
"type": "ENUM",
|
|
26
27
|
"required": false,
|
|
28
|
+
"defaultValue": "Cover",
|
|
27
29
|
"groupId": "image-settings",
|
|
28
30
|
"enumTypeId": "{{ENUM_ID:ObjectFit}}"
|
|
29
31
|
},
|
|
@@ -32,6 +34,46 @@
|
|
|
32
34
|
"displayName": "Info Components",
|
|
33
35
|
"type": "COMPONENT_LIST",
|
|
34
36
|
"required": false,
|
|
37
|
+
"defaultValue": {
|
|
38
|
+
"components": [
|
|
39
|
+
{
|
|
40
|
+
"codeComponentId": "nb34u3yu-product-detail-name-favorite"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"codeComponentId": "nb34u3yu-product-detail-sku"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"codeComponentId": "nb34u3yu-product-detail-prices"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"codeComponentId": "nb34u3yu-product-detail-product-group"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"codeComponentId": "nb34u3yu-product-detail-bundle-product"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"codeComponentId": "nb34u3yu-product-detail-variant"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"codeComponentId": "nb34u3yu-product-detail-option-set"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"codeComponentId": "nb34u3yu-product-detail-add-to-cart"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"codeComponentId": "nb34u3yu-product-detail-back-in-stock"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"codeComponentId": "nb34u3yu-product-detail-offer"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"codeComponentId": "nb34u3yu-product-detail-features"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"codeComponentId": "nb34u3yu-product-detail-description"
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
},
|
|
35
77
|
"filteredComponentIds": [
|
|
36
78
|
"<id-of-ProductDetailNameFavorite>",
|
|
37
79
|
"<id-of-ProductDetailSku>",
|
|
@@ -39,6 +81,7 @@
|
|
|
39
81
|
"<id-of-ProductDetailProductGroup>",
|
|
40
82
|
"<id-of-ProductDetailVariant>",
|
|
41
83
|
"<id-of-ProductDetailAddToCart>",
|
|
84
|
+
"<id-of-ProductDetailBackInStock>",
|
|
42
85
|
"<id-of-ProductDetailFeatures>",
|
|
43
86
|
"<id-of-ProductDetailDescription>",
|
|
44
87
|
"<id-of-ProductDetailBundleProduct>",
|
|
@@ -51,6 +94,16 @@
|
|
|
51
94
|
"displayName": "Sub Components",
|
|
52
95
|
"type": "COMPONENT_LIST",
|
|
53
96
|
"required": false,
|
|
97
|
+
"defaultValue": {
|
|
98
|
+
"components": [
|
|
99
|
+
{
|
|
100
|
+
"codeComponentId": "nb34u3yu-product-detail-bundle-furniture"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"codeComponentId": "nb34u3yu-product-detail-offer"
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
},
|
|
54
107
|
"filteredComponentIds": [
|
|
55
108
|
"<id-of-ProductDetailBundleFurniture>",
|
|
56
109
|
"<id-of-ProductDetailOffer>"
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
IkasImage,
|
|
7
7
|
isNotEmpty,
|
|
8
8
|
IkasComponentRenderer,
|
|
9
|
+
withRoutePrefix,
|
|
9
10
|
} from "@ikas/bp-storefront";
|
|
10
11
|
import { Props } from "./types";
|
|
11
12
|
import Breadcrumb from "../../sub-components/Breadcrumb";
|
|
@@ -42,7 +43,10 @@ export function ProductDetail(props: Props) {
|
|
|
42
43
|
<div className="kombos-container kombos-pd__container">
|
|
43
44
|
<Breadcrumb
|
|
44
45
|
items={[
|
|
45
|
-
{
|
|
46
|
+
{
|
|
47
|
+
label: homepageText,
|
|
48
|
+
href: withRoutePrefix("/"),
|
|
49
|
+
} as BreadcrumbItem,
|
|
46
50
|
...(isNotEmpty(categoryPath)
|
|
47
51
|
? categoryPath.map(
|
|
48
52
|
(pathItem: any) =>
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { useState, useEffect, useRef, useId } from "preact/hooks";
|
|
2
|
+
import { createPortal } from "preact/compat";
|
|
3
|
+
import type { ComponentChildren } from "preact";
|
|
4
|
+
import { useScrollLock } from "../../hooks/useScrollLock";
|
|
5
|
+
import { cx } from "../../utils/cx";
|
|
6
|
+
import { XSVG } from "../icons";
|
|
7
|
+
import Button, { type ButtonProps } from "../Button";
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
onClose: () => void;
|
|
11
|
+
title: string;
|
|
12
|
+
maxWidth?: string;
|
|
13
|
+
children: ComponentChildren;
|
|
14
|
+
className?: string;
|
|
15
|
+
okText?: string;
|
|
16
|
+
cancelText?: string;
|
|
17
|
+
onOk?: (e: Event) => void;
|
|
18
|
+
okButtonProps?: ButtonProps;
|
|
19
|
+
cancelButtonProps?: ButtonProps;
|
|
20
|
+
footer?: ComponentChildren | null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default function Modal({
|
|
24
|
+
onClose,
|
|
25
|
+
title,
|
|
26
|
+
maxWidth = "37.5rem",
|
|
27
|
+
children,
|
|
28
|
+
className,
|
|
29
|
+
okText,
|
|
30
|
+
cancelText,
|
|
31
|
+
onOk,
|
|
32
|
+
okButtonProps,
|
|
33
|
+
cancelButtonProps,
|
|
34
|
+
footer,
|
|
35
|
+
}: Props) {
|
|
36
|
+
const titleId = useId();
|
|
37
|
+
const [visible, setVisible] = useState(false);
|
|
38
|
+
const onCloseRef = useRef(onClose);
|
|
39
|
+
onCloseRef.current = onClose;
|
|
40
|
+
|
|
41
|
+
const handleCloseRef = useRef(() => {});
|
|
42
|
+
handleCloseRef.current = () => {
|
|
43
|
+
setVisible(false);
|
|
44
|
+
setTimeout(() => onCloseRef.current(), 300);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
useScrollLock();
|
|
48
|
+
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
const rafId = requestAnimationFrame(() => setVisible(true));
|
|
51
|
+
return () => cancelAnimationFrame(rafId);
|
|
52
|
+
}, []);
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
const handleKeyDown = (e: KeyboardEvent) => {
|
|
56
|
+
if (e.key === "Escape") handleCloseRef.current();
|
|
57
|
+
};
|
|
58
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
59
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
60
|
+
}, []);
|
|
61
|
+
|
|
62
|
+
return createPortal(
|
|
63
|
+
<div
|
|
64
|
+
className={cx("kombos-modal", visible && "kombos-modal--open", className)}
|
|
65
|
+
role="dialog"
|
|
66
|
+
aria-modal="true"
|
|
67
|
+
aria-labelledby={titleId}
|
|
68
|
+
>
|
|
69
|
+
<div className="kombos-modal__panel" style={{ maxWidth }}>
|
|
70
|
+
<div className="kombos-modal__header">
|
|
71
|
+
<h2 id={titleId} className="kombos-modal__title text-md-medium">
|
|
72
|
+
{title}
|
|
73
|
+
</h2>
|
|
74
|
+
<button
|
|
75
|
+
type="button"
|
|
76
|
+
className="kombos-modal__close"
|
|
77
|
+
onClick={() => handleCloseRef.current()}
|
|
78
|
+
aria-label="Close"
|
|
79
|
+
>
|
|
80
|
+
<XSVG />
|
|
81
|
+
</button>
|
|
82
|
+
</div>
|
|
83
|
+
|
|
84
|
+
<div className="kombos-modal__body">{children}</div>
|
|
85
|
+
|
|
86
|
+
{footer !== null &&
|
|
87
|
+
(footer !== undefined ? (
|
|
88
|
+
<div className="kombos-modal__footer">{footer}</div>
|
|
89
|
+
) : (
|
|
90
|
+
(cancelText || okText) && (
|
|
91
|
+
<div className="kombos-modal__footer">
|
|
92
|
+
{cancelText && (
|
|
93
|
+
<Button
|
|
94
|
+
variant="secondary"
|
|
95
|
+
size="s"
|
|
96
|
+
type="button"
|
|
97
|
+
onClick={() => handleCloseRef.current()}
|
|
98
|
+
{...cancelButtonProps}
|
|
99
|
+
>
|
|
100
|
+
{cancelText}
|
|
101
|
+
</Button>
|
|
102
|
+
)}
|
|
103
|
+
{okText && (
|
|
104
|
+
<Button
|
|
105
|
+
variant="primary"
|
|
106
|
+
size="s"
|
|
107
|
+
onClick={onOk}
|
|
108
|
+
{...okButtonProps}
|
|
109
|
+
>
|
|
110
|
+
{okText}
|
|
111
|
+
</Button>
|
|
112
|
+
)}
|
|
113
|
+
</div>
|
|
114
|
+
)
|
|
115
|
+
))}
|
|
116
|
+
</div>
|
|
117
|
+
</div>,
|
|
118
|
+
document.body,
|
|
119
|
+
);
|
|
120
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/* ── Modal ── */
|
|
2
|
+
.kombos-modal {
|
|
3
|
+
position: fixed;
|
|
4
|
+
inset: 0;
|
|
5
|
+
z-index: var(--kombos-z-overlay);
|
|
6
|
+
background: rgba(0, 0, 0, 0.35);
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
opacity: 0;
|
|
11
|
+
transition: opacity 0.3s;
|
|
12
|
+
padding: 1rem;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.kombos-modal--open {
|
|
16
|
+
opacity: 1;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.kombos-modal__panel {
|
|
20
|
+
background: var(--kombos-white);
|
|
21
|
+
border-radius: 6px;
|
|
22
|
+
width: 100%;
|
|
23
|
+
max-height: 90vh;
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
transform: translateY(1rem);
|
|
27
|
+
transition: transform 0.3s;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.kombos-modal--open .kombos-modal__panel {
|
|
31
|
+
transform: translateY(0);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.kombos-modal__header {
|
|
35
|
+
display: flex;
|
|
36
|
+
justify-content: space-between;
|
|
37
|
+
align-items: center;
|
|
38
|
+
background: var(--kombos-white);
|
|
39
|
+
padding: 1.5rem;
|
|
40
|
+
border-bottom: 1px solid var(--kombos-gray-200);
|
|
41
|
+
border-radius: 6px 6px 0 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.kombos-modal__title {
|
|
45
|
+
color: var(--kombos-gray-900);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.kombos-modal__close {
|
|
49
|
+
background: none;
|
|
50
|
+
border: none;
|
|
51
|
+
cursor: pointer;
|
|
52
|
+
padding: 0;
|
|
53
|
+
color: var(--kombos-gray-700);
|
|
54
|
+
font-size: 1.25rem;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.kombos-modal__body {
|
|
58
|
+
padding: 1.5rem;
|
|
59
|
+
overflow-y: auto;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.kombos-modal__footer {
|
|
63
|
+
background: var(--kombos-white);
|
|
64
|
+
padding: 1.5rem;
|
|
65
|
+
border-top: 1px solid var(--kombos-gray-200);
|
|
66
|
+
border-radius: 0 0 6px 6px;
|
|
67
|
+
display: flex;
|
|
68
|
+
gap: 0.75rem;
|
|
69
|
+
justify-content: flex-end;
|
|
70
|
+
}
|
package/data/section-templates/product-detail-section/sub-components/QuantitySelector/index.tsx
CHANGED
|
@@ -5,20 +5,27 @@ interface Props {
|
|
|
5
5
|
value: number;
|
|
6
6
|
onChange: (value: number) => void;
|
|
7
7
|
size?: "default" | "sm";
|
|
8
|
+
min?: number;
|
|
9
|
+
max?: number;
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
export default function QuantitySelector({
|
|
11
13
|
value,
|
|
12
14
|
onChange,
|
|
13
15
|
size = "default",
|
|
16
|
+
min = 1,
|
|
17
|
+
max,
|
|
14
18
|
}: Props) {
|
|
19
|
+
const canDecrease = value > min;
|
|
20
|
+
const canIncrease = max == null || value < max;
|
|
21
|
+
|
|
15
22
|
return (
|
|
16
23
|
<div className={cx("kombos-pd__qty", size === "sm" && "kombos-pd__qty--sm")}>
|
|
17
24
|
<button
|
|
18
25
|
type="button"
|
|
19
26
|
className="kombos-pd__qty-btn"
|
|
20
|
-
onClick={() => onChange(Math.max(
|
|
21
|
-
disabled={
|
|
27
|
+
onClick={() => onChange(Math.max(min, value - 1))}
|
|
28
|
+
disabled={!canDecrease}
|
|
22
29
|
aria-label="Decrease quantity"
|
|
23
30
|
>
|
|
24
31
|
<MinusSVG />
|
|
@@ -31,7 +38,8 @@ export default function QuantitySelector({
|
|
|
31
38
|
<button
|
|
32
39
|
type="button"
|
|
33
40
|
className="kombos-pd__qty-btn"
|
|
34
|
-
onClick={() => onChange(value + 1)}
|
|
41
|
+
onClick={() => onChange(max == null ? value + 1 : Math.min(max, value + 1))}
|
|
42
|
+
disabled={!canIncrease}
|
|
35
43
|
aria-label="Increase quantity"
|
|
36
44
|
>
|
|
37
45
|
<PlusSVG />
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IkasProduct, IkasStorefrontConfig } from "@ikas/bp-storefront";
|
|
2
|
+
|
|
3
|
+
export interface CartQuantityLimits {
|
|
4
|
+
min: number;
|
|
5
|
+
max?: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Resolve the per-cart quantity limits for a product from its active sales
|
|
10
|
+
* channel. Falls back to a minimum of 1 and no maximum when the channel or its
|
|
11
|
+
* limits are not set. `addItemToCart` clamps to the same limits internally only
|
|
12
|
+
* when it creates a NEW cart line — incrementing an existing line goes through
|
|
13
|
+
* `changeItemQuantity`, which never clamps — so enforcing these in the stepper
|
|
14
|
+
* is the only guard that covers both paths.
|
|
15
|
+
*/
|
|
16
|
+
export function getProductCartLimits(product: IkasProduct): CartQuantityLimits {
|
|
17
|
+
const channel = product.salesChannels?.find(
|
|
18
|
+
(sc) => sc.id === IkasStorefrontConfig.salesChannelId,
|
|
19
|
+
);
|
|
20
|
+
return {
|
|
21
|
+
min: channel?.minQuantityPerCart ?? 1,
|
|
22
|
+
max: channel?.maxQuantityPerCart ?? undefined,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
"displayName": "Top Spacing",
|
|
17
17
|
"type": "TYPE",
|
|
18
18
|
"required": false,
|
|
19
|
+
"defaultValue": {
|
|
20
|
+
"value": 0,
|
|
21
|
+
"unit": "px"
|
|
22
|
+
},
|
|
19
23
|
"groupId": "mobile",
|
|
20
24
|
"typeId": "@ikas/bp-storefront-models-MarginTopStyleType"
|
|
21
25
|
},
|
|
@@ -24,6 +28,10 @@
|
|
|
24
28
|
"displayName": "Bottom Spacing",
|
|
25
29
|
"type": "TYPE",
|
|
26
30
|
"required": false,
|
|
31
|
+
"defaultValue": {
|
|
32
|
+
"value": 0,
|
|
33
|
+
"unit": "px"
|
|
34
|
+
},
|
|
27
35
|
"groupId": "mobile",
|
|
28
36
|
"typeId": "@ikas/bp-storefront-models-MarginBottomStyleType"
|
|
29
37
|
},
|
|
@@ -32,6 +40,10 @@
|
|
|
32
40
|
"displayName": "Top Spacing",
|
|
33
41
|
"type": "TYPE",
|
|
34
42
|
"required": false,
|
|
43
|
+
"defaultValue": {
|
|
44
|
+
"value": 0,
|
|
45
|
+
"unit": "px"
|
|
46
|
+
},
|
|
35
47
|
"groupId": "desktop",
|
|
36
48
|
"typeId": "@ikas/bp-storefront-models-MarginTopStyleType"
|
|
37
49
|
},
|
|
@@ -40,6 +52,10 @@
|
|
|
40
52
|
"displayName": "Bottom Spacing",
|
|
41
53
|
"type": "TYPE",
|
|
42
54
|
"required": false,
|
|
55
|
+
"defaultValue": {
|
|
56
|
+
"value": 0,
|
|
57
|
+
"unit": "px"
|
|
58
|
+
},
|
|
43
59
|
"groupId": "desktop",
|
|
44
60
|
"typeId": "@ikas/bp-storefront-models-MarginBottomStyleType"
|
|
45
61
|
}
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
"displayName": "Column Count",
|
|
58
58
|
"type": "ENUM",
|
|
59
59
|
"required": false,
|
|
60
|
+
"defaultValue": "Four",
|
|
60
61
|
"groupId": "appearance",
|
|
61
62
|
"enumTypeId": "{{ENUM_ID:NumberOfColumns}}"
|
|
62
63
|
},
|
|
@@ -65,6 +66,7 @@
|
|
|
65
66
|
"displayName": "Aspect Ratio",
|
|
66
67
|
"type": "ENUM",
|
|
67
68
|
"required": false,
|
|
69
|
+
"defaultValue": "Square",
|
|
68
70
|
"groupId": "appearance",
|
|
69
71
|
"enumTypeId": "{{ENUM_ID:AspectRatio}}"
|
|
70
72
|
},
|
|
@@ -73,6 +75,7 @@
|
|
|
73
75
|
"displayName": "Image Fit",
|
|
74
76
|
"type": "ENUM",
|
|
75
77
|
"required": false,
|
|
78
|
+
"defaultValue": "Cover",
|
|
76
79
|
"groupId": "appearance",
|
|
77
80
|
"enumTypeId": "{{ENUM_ID:ObjectFit}}"
|
|
78
81
|
},
|
|
@@ -81,6 +84,7 @@
|
|
|
81
84
|
"displayName": "Hide Add to Cart Button",
|
|
82
85
|
"type": "BOOLEAN",
|
|
83
86
|
"required": false,
|
|
87
|
+
"defaultValue": false,
|
|
84
88
|
"groupId": "appearance"
|
|
85
89
|
},
|
|
86
90
|
{
|
|
@@ -88,6 +92,19 @@
|
|
|
88
92
|
"displayName": "Components",
|
|
89
93
|
"type": "COMPONENT_LIST",
|
|
90
94
|
"required": false,
|
|
95
|
+
"defaultValue": {
|
|
96
|
+
"components": [
|
|
97
|
+
{
|
|
98
|
+
"codeComponentId": "nb34u3yu-card-product-name"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"codeComponentId": "nb34u3yu-card-product-variants"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"codeComponentId": "nb34u3yu-card-product-price"
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
},
|
|
91
108
|
"privateVarMap": {
|
|
92
109
|
"product": {
|
|
93
110
|
"id": "pvm_1772803530689_1",
|
|
@@ -142,6 +142,7 @@
|
|
|
142
142
|
"displayName": "Google Login",
|
|
143
143
|
"type": "BOOLEAN",
|
|
144
144
|
"required": false,
|
|
145
|
+
"defaultValue": false,
|
|
145
146
|
"groupId": "google"
|
|
146
147
|
},
|
|
147
148
|
{
|
|
@@ -157,6 +158,7 @@
|
|
|
157
158
|
"displayName": "Facebook Login",
|
|
158
159
|
"type": "BOOLEAN",
|
|
159
160
|
"required": false,
|
|
161
|
+
"defaultValue": false,
|
|
160
162
|
"groupId": "facebook"
|
|
161
163
|
},
|
|
162
164
|
{
|
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
"displayName": "Top Spacing",
|
|
17
17
|
"type": "TYPE",
|
|
18
18
|
"required": false,
|
|
19
|
+
"defaultValue": {
|
|
20
|
+
"value": 0,
|
|
21
|
+
"unit": "px"
|
|
22
|
+
},
|
|
19
23
|
"groupId": "mobile",
|
|
20
24
|
"typeId": "@ikas/bp-storefront-models-MarginTopStyleType"
|
|
21
25
|
},
|
|
@@ -24,6 +28,10 @@
|
|
|
24
28
|
"displayName": "Bottom Spacing",
|
|
25
29
|
"type": "TYPE",
|
|
26
30
|
"required": false,
|
|
31
|
+
"defaultValue": {
|
|
32
|
+
"value": 0,
|
|
33
|
+
"unit": "px"
|
|
34
|
+
},
|
|
27
35
|
"groupId": "mobile",
|
|
28
36
|
"typeId": "@ikas/bp-storefront-models-MarginBottomStyleType"
|
|
29
37
|
},
|
|
@@ -32,6 +40,10 @@
|
|
|
32
40
|
"displayName": "Top Spacing",
|
|
33
41
|
"type": "TYPE",
|
|
34
42
|
"required": false,
|
|
43
|
+
"defaultValue": {
|
|
44
|
+
"value": 0,
|
|
45
|
+
"unit": "px"
|
|
46
|
+
},
|
|
35
47
|
"groupId": "desktop",
|
|
36
48
|
"typeId": "@ikas/bp-storefront-models-MarginTopStyleType"
|
|
37
49
|
},
|
|
@@ -40,6 +52,10 @@
|
|
|
40
52
|
"displayName": "Bottom Spacing",
|
|
41
53
|
"type": "TYPE",
|
|
42
54
|
"required": false,
|
|
55
|
+
"defaultValue": {
|
|
56
|
+
"value": 0,
|
|
57
|
+
"unit": "px"
|
|
58
|
+
},
|
|
43
59
|
"groupId": "desktop",
|
|
44
60
|
"typeId": "@ikas/bp-storefront-models-MarginBottomStyleType"
|
|
45
61
|
},
|
|
@@ -48,6 +64,7 @@
|
|
|
48
64
|
"displayName": "Image Variant",
|
|
49
65
|
"type": "BOOLEAN",
|
|
50
66
|
"required": false,
|
|
67
|
+
"defaultValue": false,
|
|
51
68
|
"description": "Use product images for color variant."
|
|
52
69
|
}
|
|
53
70
|
],
|