@fire-spark/react-ui 0.0.1
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/cart.d.ts +286 -0
- package/dist/cart.js +293 -0
- package/dist/category-nav.d.ts +37 -0
- package/dist/category-nav.js +39 -0
- package/dist/category.d.ts +95 -0
- package/dist/category.js +97 -0
- package/dist/checkout.d.ts +316 -0
- package/dist/checkout.js +333 -0
- package/dist/cn-Ccejyh36.js +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/menu.d.ts +47 -0
- package/dist/menu.js +49 -0
- package/dist/product-card.d.ts +100 -0
- package/dist/product-card.js +108 -0
- package/dist/product-detail.d.ts +241 -0
- package/dist/product-detail.js +291 -0
- package/dist/use-active-category.d.ts +15 -0
- package/dist/use-active-category.js +89 -0
- package/package.json +121 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { t as cn } from "./cn-Ccejyh36.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
//#region src/product-card.tsx
|
|
4
|
+
const ProductCard = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("div", {
|
|
5
|
+
ref,
|
|
6
|
+
className: cn("bg-card text-card-foreground @container/product-card flex h-full min-w-0 w-full overflow-hidden rounded-xl border shadow-sm", className),
|
|
7
|
+
...props
|
|
8
|
+
});
|
|
9
|
+
ProductCard.displayName = "ProductCard";
|
|
10
|
+
const ProductCardContent = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("div", {
|
|
11
|
+
ref,
|
|
12
|
+
className: cn("ProductCardContent flex min-h-28 min-w-0 flex-1 flex-col justify-center gap-1 p-2 @min-[20rem]/product-card:gap-1.5 @min-[20rem]/product-card:p-4", className),
|
|
13
|
+
...props
|
|
14
|
+
});
|
|
15
|
+
ProductCardContent.displayName = "ProductCardContent";
|
|
16
|
+
const ProductCardMedia = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("div", {
|
|
17
|
+
ref,
|
|
18
|
+
className: cn("bg-muted relative size-[164px] shrink-0 self-center overflow-hidden", className),
|
|
19
|
+
...props
|
|
20
|
+
});
|
|
21
|
+
ProductCardMedia.displayName = "ProductCardMedia";
|
|
22
|
+
const ProductCardImageSlot = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("div", {
|
|
23
|
+
ref,
|
|
24
|
+
className: cn("size-full", className),
|
|
25
|
+
...props
|
|
26
|
+
});
|
|
27
|
+
ProductCardImageSlot.displayName = "ProductCardImageSlot";
|
|
28
|
+
const ProductCardImage = ({ ref, className, alt = "", ...props }) => /* @__PURE__ */ jsx(ProductCardImageSlot, { children: /* @__PURE__ */ jsx("img", {
|
|
29
|
+
ref,
|
|
30
|
+
alt,
|
|
31
|
+
className: cn("size-full object-cover", className),
|
|
32
|
+
...props
|
|
33
|
+
}) });
|
|
34
|
+
ProductCardImage.displayName = "ProductCardImage";
|
|
35
|
+
const ProductCardHeader = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("div", {
|
|
36
|
+
ref,
|
|
37
|
+
className: cn("flex flex-col gap-1", className),
|
|
38
|
+
...props
|
|
39
|
+
});
|
|
40
|
+
ProductCardHeader.displayName = "ProductCardHeader";
|
|
41
|
+
const ProductCardTitle = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("h3", {
|
|
42
|
+
ref,
|
|
43
|
+
className: cn("line-clamp-1 min-h-[1lh] min-w-0 text-sm leading-snug font-semibold tracking-tight @min-[20rem]/product-card:text-base", className),
|
|
44
|
+
...props
|
|
45
|
+
});
|
|
46
|
+
ProductCardTitle.displayName = "ProductCardTitle";
|
|
47
|
+
const ProductCardMeta = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("div", {
|
|
48
|
+
ref,
|
|
49
|
+
className: cn("text-foreground flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-0.5 text-xs @min-[20rem]/product-card:text-sm", className),
|
|
50
|
+
...props
|
|
51
|
+
});
|
|
52
|
+
ProductCardMeta.displayName = "ProductCardMeta";
|
|
53
|
+
const ProductCardDescription = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("p", {
|
|
54
|
+
ref,
|
|
55
|
+
className: cn("text-muted-foreground line-clamp-2 min-h-[2lh] min-w-0 text-xs leading-snug @min-[20rem]/product-card:text-sm", className),
|
|
56
|
+
...props
|
|
57
|
+
});
|
|
58
|
+
ProductCardDescription.displayName = "ProductCardDescription";
|
|
59
|
+
const ProductCardFooter = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("div", {
|
|
60
|
+
ref,
|
|
61
|
+
className: cn("mt-auto flex flex-wrap items-center gap-2 pt-1", className),
|
|
62
|
+
...props
|
|
63
|
+
});
|
|
64
|
+
ProductCardFooter.displayName = "ProductCardFooter";
|
|
65
|
+
const ProductCardPrice = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("span", {
|
|
66
|
+
ref,
|
|
67
|
+
className: cn("text-base font-semibold tabular-nums", className),
|
|
68
|
+
...props
|
|
69
|
+
});
|
|
70
|
+
ProductCardPrice.displayName = "ProductCardPrice";
|
|
71
|
+
const ProductCardAnchorPrice = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("span", {
|
|
72
|
+
ref,
|
|
73
|
+
className: cn("text-muted-foreground text-sm tabular-nums line-through", className),
|
|
74
|
+
...props
|
|
75
|
+
});
|
|
76
|
+
ProductCardAnchorPrice.displayName = "ProductCardAnchorPrice";
|
|
77
|
+
const ProductCardRating = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("span", {
|
|
78
|
+
ref,
|
|
79
|
+
className: cn("inline-flex items-center gap-1 text-sm font-medium", className),
|
|
80
|
+
...props
|
|
81
|
+
});
|
|
82
|
+
ProductCardRating.displayName = "ProductCardRating";
|
|
83
|
+
const ProductCardBadge = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("span", {
|
|
84
|
+
ref,
|
|
85
|
+
className: cn("bg-secondary text-secondary-foreground inline-flex items-center rounded-md px-2 py-0.5 text-xs font-medium", className),
|
|
86
|
+
...props
|
|
87
|
+
});
|
|
88
|
+
ProductCardBadge.displayName = "ProductCardBadge";
|
|
89
|
+
const ProductCardDiscount = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("span", {
|
|
90
|
+
ref,
|
|
91
|
+
className: cn("inline-flex w-fit items-center rounded-full bg-red-600 px-2 py-0.5 text-xs font-semibold text-white", className),
|
|
92
|
+
...props
|
|
93
|
+
});
|
|
94
|
+
ProductCardDiscount.displayName = "ProductCardDiscount";
|
|
95
|
+
const ProductCardAddButton = ({ ref, className, type = "button", children, ...props }) => /* @__PURE__ */ jsx("button", {
|
|
96
|
+
ref,
|
|
97
|
+
type,
|
|
98
|
+
className: cn("bg-background absolute right-2 bottom-2 z-10 flex size-8 items-center justify-center rounded-full border shadow-md transition-colors hover:bg-accent", className),
|
|
99
|
+
...props,
|
|
100
|
+
children: children ?? /* @__PURE__ */ jsx("span", {
|
|
101
|
+
"aria-hidden": true,
|
|
102
|
+
className: "text-lg leading-none font-medium",
|
|
103
|
+
children: "+"
|
|
104
|
+
})
|
|
105
|
+
});
|
|
106
|
+
ProductCardAddButton.displayName = "ProductCardAddButton";
|
|
107
|
+
//#endregion
|
|
108
|
+
export { ProductCard, ProductCardAddButton, ProductCardAnchorPrice, ProductCardBadge, ProductCardContent, ProductCardDescription, ProductCardDiscount, ProductCardFooter, ProductCardHeader, ProductCardImage, ProductCardImageSlot, ProductCardMedia, ProductCardMeta, ProductCardPrice, ProductCardRating, ProductCardTitle };
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { ButtonHTMLAttributes, HTMLAttributes, ImgHTMLAttributes, ReactNode } from "react";
|
|
2
|
+
//#region src/product-detail.d.ts
|
|
3
|
+
type ProductDetailQuantities = Record<string, Record<string, number>>;
|
|
4
|
+
type ProductDetailState = {
|
|
5
|
+
quantities: ProductDetailQuantities;
|
|
6
|
+
viewStack: string[];
|
|
7
|
+
};
|
|
8
|
+
type ProductDetailActions = {
|
|
9
|
+
selectSingle: (groupId: string, modifierId: string) => void;
|
|
10
|
+
toggleModifier: (groupId: string, modifierId: string) => void;
|
|
11
|
+
setQuantity: (groupId: string, modifierId: string, quantity: number) => void;
|
|
12
|
+
clearGroup: (groupId: string) => void;
|
|
13
|
+
pushView: (viewId: string) => void;
|
|
14
|
+
popView: () => void;
|
|
15
|
+
reset: () => void;
|
|
16
|
+
};
|
|
17
|
+
type ProductDetailContextMeta = {
|
|
18
|
+
productId?: string;
|
|
19
|
+
};
|
|
20
|
+
type ProductDetailContextValue = {
|
|
21
|
+
state: ProductDetailState;
|
|
22
|
+
actions: ProductDetailActions;
|
|
23
|
+
meta: ProductDetailContextMeta;
|
|
24
|
+
};
|
|
25
|
+
declare const useProductDetail: () => ProductDetailContextValue;
|
|
26
|
+
type ProductDetailProviderProps = {
|
|
27
|
+
children: ReactNode;
|
|
28
|
+
productId?: string;
|
|
29
|
+
initialQuantities?: ProductDetailQuantities;
|
|
30
|
+
};
|
|
31
|
+
declare function ProductDetailProvider({ children, productId, initialQuantities }: ProductDetailProviderProps): import("react").JSX.Element;
|
|
32
|
+
declare namespace ProductDetailProvider {
|
|
33
|
+
var displayName: string;
|
|
34
|
+
}
|
|
35
|
+
declare function ProductDetail({ ref, className, ...props }: HTMLAttributes<HTMLDivElement> & {
|
|
36
|
+
ref?: React.RefObject<HTMLDivElement | null>;
|
|
37
|
+
}): import("react").JSX.Element;
|
|
38
|
+
declare namespace ProductDetail {
|
|
39
|
+
var displayName: string;
|
|
40
|
+
}
|
|
41
|
+
declare function ProductDetailBody({ ref, className, ...props }: HTMLAttributes<HTMLDivElement> & {
|
|
42
|
+
ref?: React.RefObject<HTMLDivElement | null>;
|
|
43
|
+
}): import("react").JSX.Element;
|
|
44
|
+
declare namespace ProductDetailBody {
|
|
45
|
+
var displayName: string;
|
|
46
|
+
}
|
|
47
|
+
declare function ProductDetailLayout({ ref, className, ...props }: HTMLAttributes<HTMLDivElement> & {
|
|
48
|
+
ref?: React.RefObject<HTMLDivElement | null>;
|
|
49
|
+
}): import("react").JSX.Element;
|
|
50
|
+
declare namespace ProductDetailLayout {
|
|
51
|
+
var displayName: string;
|
|
52
|
+
}
|
|
53
|
+
declare function ProductDetailMedia({ ref, className, ...props }: HTMLAttributes<HTMLDivElement> & {
|
|
54
|
+
ref?: React.RefObject<HTMLDivElement | null>;
|
|
55
|
+
}): import("react").JSX.Element;
|
|
56
|
+
declare namespace ProductDetailMedia {
|
|
57
|
+
var displayName: string;
|
|
58
|
+
}
|
|
59
|
+
declare function ProductDetailImageSlot({ ref, className, ...props }: HTMLAttributes<HTMLDivElement> & {
|
|
60
|
+
ref?: React.RefObject<HTMLDivElement | null>;
|
|
61
|
+
}): import("react").JSX.Element;
|
|
62
|
+
declare namespace ProductDetailImageSlot {
|
|
63
|
+
var displayName: string;
|
|
64
|
+
}
|
|
65
|
+
declare function ProductDetailImage({ ref, className, alt, ...props }: ImgHTMLAttributes<HTMLImageElement> & {
|
|
66
|
+
ref?: React.RefObject<HTMLImageElement | null>;
|
|
67
|
+
}): import("react").JSX.Element;
|
|
68
|
+
declare namespace ProductDetailImage {
|
|
69
|
+
var displayName: string;
|
|
70
|
+
}
|
|
71
|
+
declare function ProductDetailPanel({ ref, className, ...props }: HTMLAttributes<HTMLDivElement> & {
|
|
72
|
+
ref?: React.RefObject<HTMLDivElement | null>;
|
|
73
|
+
}): import("react").JSX.Element;
|
|
74
|
+
declare namespace ProductDetailPanel {
|
|
75
|
+
var displayName: string;
|
|
76
|
+
}
|
|
77
|
+
declare function ProductDetailHeader({ ref, className, ...props }: HTMLAttributes<HTMLDivElement> & {
|
|
78
|
+
ref?: React.RefObject<HTMLDivElement | null>;
|
|
79
|
+
}): import("react").JSX.Element;
|
|
80
|
+
declare namespace ProductDetailHeader {
|
|
81
|
+
var displayName: string;
|
|
82
|
+
}
|
|
83
|
+
declare function ProductDetailTitle({ ref, className, ...props }: HTMLAttributes<HTMLHeadingElement> & {
|
|
84
|
+
ref?: React.RefObject<HTMLHeadingElement | null>;
|
|
85
|
+
}): import("react").JSX.Element;
|
|
86
|
+
declare namespace ProductDetailTitle {
|
|
87
|
+
var displayName: string;
|
|
88
|
+
}
|
|
89
|
+
declare function ProductDetailMeta({ ref, className, ...props }: HTMLAttributes<HTMLDivElement> & {
|
|
90
|
+
ref?: React.RefObject<HTMLDivElement | null>;
|
|
91
|
+
}): import("react").JSX.Element;
|
|
92
|
+
declare namespace ProductDetailMeta {
|
|
93
|
+
var displayName: string;
|
|
94
|
+
}
|
|
95
|
+
declare function ProductDetailPrice({ ref, className, ...props }: HTMLAttributes<HTMLSpanElement> & {
|
|
96
|
+
ref?: React.RefObject<HTMLSpanElement | null>;
|
|
97
|
+
}): import("react").JSX.Element;
|
|
98
|
+
declare namespace ProductDetailPrice {
|
|
99
|
+
var displayName: string;
|
|
100
|
+
}
|
|
101
|
+
declare function ProductDetailAnchorPrice({ ref, className, ...props }: HTMLAttributes<HTMLSpanElement> & {
|
|
102
|
+
ref?: React.RefObject<HTMLSpanElement | null>;
|
|
103
|
+
}): import("react").JSX.Element;
|
|
104
|
+
declare namespace ProductDetailAnchorPrice {
|
|
105
|
+
var displayName: string;
|
|
106
|
+
}
|
|
107
|
+
declare function ProductDetailDiscount({ ref, className, ...props }: HTMLAttributes<HTMLSpanElement> & {
|
|
108
|
+
ref?: React.RefObject<HTMLSpanElement | null>;
|
|
109
|
+
}): import("react").JSX.Element;
|
|
110
|
+
declare namespace ProductDetailDiscount {
|
|
111
|
+
var displayName: string;
|
|
112
|
+
}
|
|
113
|
+
declare function ProductDetailDescription({ ref, className, ...props }: HTMLAttributes<HTMLParagraphElement> & {
|
|
114
|
+
ref?: React.RefObject<HTMLParagraphElement | null>;
|
|
115
|
+
}): import("react").JSX.Element;
|
|
116
|
+
declare namespace ProductDetailDescription {
|
|
117
|
+
var displayName: string;
|
|
118
|
+
}
|
|
119
|
+
declare function ProductDetailBadge({ ref, className, ...props }: HTMLAttributes<HTMLSpanElement> & {
|
|
120
|
+
ref?: React.RefObject<HTMLSpanElement | null>;
|
|
121
|
+
}): import("react").JSX.Element;
|
|
122
|
+
declare namespace ProductDetailBadge {
|
|
123
|
+
var displayName: string;
|
|
124
|
+
}
|
|
125
|
+
declare function ProductDetailGroups({ ref, className, ...props }: HTMLAttributes<HTMLDivElement> & {
|
|
126
|
+
ref?: React.RefObject<HTMLDivElement | null>;
|
|
127
|
+
}): import("react").JSX.Element;
|
|
128
|
+
declare namespace ProductDetailGroups {
|
|
129
|
+
var displayName: string;
|
|
130
|
+
}
|
|
131
|
+
declare function ProductDetailGroup({ ref, className, ...props }: HTMLAttributes<HTMLElement> & {
|
|
132
|
+
ref?: React.RefObject<HTMLElement | null>;
|
|
133
|
+
}): import("react").JSX.Element;
|
|
134
|
+
declare namespace ProductDetailGroup {
|
|
135
|
+
var displayName: string;
|
|
136
|
+
}
|
|
137
|
+
declare function ProductDetailGroupHeader({ ref, className, ...props }: HTMLAttributes<HTMLDivElement> & {
|
|
138
|
+
ref?: React.RefObject<HTMLDivElement | null>;
|
|
139
|
+
}): import("react").JSX.Element;
|
|
140
|
+
declare namespace ProductDetailGroupHeader {
|
|
141
|
+
var displayName: string;
|
|
142
|
+
}
|
|
143
|
+
declare function ProductDetailGroupTitle({ ref, className, ...props }: HTMLAttributes<HTMLHeadingElement> & {
|
|
144
|
+
ref?: React.RefObject<HTMLHeadingElement | null>;
|
|
145
|
+
}): import("react").JSX.Element;
|
|
146
|
+
declare namespace ProductDetailGroupTitle {
|
|
147
|
+
var displayName: string;
|
|
148
|
+
}
|
|
149
|
+
declare function ProductDetailGroupHint({ ref, className, ...props }: HTMLAttributes<HTMLParagraphElement> & {
|
|
150
|
+
ref?: React.RefObject<HTMLParagraphElement | null>;
|
|
151
|
+
}): import("react").JSX.Element;
|
|
152
|
+
declare namespace ProductDetailGroupHint {
|
|
153
|
+
var displayName: string;
|
|
154
|
+
}
|
|
155
|
+
declare function ProductDetailGroupDescription({ ref, className, ...props }: HTMLAttributes<HTMLParagraphElement> & {
|
|
156
|
+
ref?: React.RefObject<HTMLParagraphElement | null>;
|
|
157
|
+
}): import("react").JSX.Element;
|
|
158
|
+
declare namespace ProductDetailGroupDescription {
|
|
159
|
+
var displayName: string;
|
|
160
|
+
}
|
|
161
|
+
declare function ProductDetailGroupRequired({ ref, className, ...props }: HTMLAttributes<HTMLSpanElement> & {
|
|
162
|
+
ref?: React.RefObject<HTMLSpanElement | null>;
|
|
163
|
+
}): import("react").JSX.Element;
|
|
164
|
+
declare namespace ProductDetailGroupRequired {
|
|
165
|
+
var displayName: string;
|
|
166
|
+
}
|
|
167
|
+
declare function ProductDetailOptions({ ref, className, ...props }: HTMLAttributes<HTMLUListElement> & {
|
|
168
|
+
ref?: React.RefObject<HTMLUListElement | null>;
|
|
169
|
+
}): import("react").JSX.Element;
|
|
170
|
+
declare namespace ProductDetailOptions {
|
|
171
|
+
var displayName: string;
|
|
172
|
+
}
|
|
173
|
+
declare function ProductDetailOption({ ref, className, selected, ...props }: HTMLAttributes<HTMLLIElement> & {
|
|
174
|
+
ref?: React.RefObject<HTMLLIElement | null>;
|
|
175
|
+
selected?: boolean;
|
|
176
|
+
}): import("react").JSX.Element;
|
|
177
|
+
declare namespace ProductDetailOption {
|
|
178
|
+
var displayName: string;
|
|
179
|
+
}
|
|
180
|
+
declare function ProductDetailOptionLabel({ ref, className, ...props }: HTMLAttributes<HTMLDivElement> & {
|
|
181
|
+
ref?: React.RefObject<HTMLDivElement | null>;
|
|
182
|
+
}): import("react").JSX.Element;
|
|
183
|
+
declare namespace ProductDetailOptionLabel {
|
|
184
|
+
var displayName: string;
|
|
185
|
+
}
|
|
186
|
+
declare function ProductDetailOptionName({ ref, className, ...props }: HTMLAttributes<HTMLParagraphElement> & {
|
|
187
|
+
ref?: React.RefObject<HTMLParagraphElement | null>;
|
|
188
|
+
}): import("react").JSX.Element;
|
|
189
|
+
declare namespace ProductDetailOptionName {
|
|
190
|
+
var displayName: string;
|
|
191
|
+
}
|
|
192
|
+
declare function ProductDetailOptionPrice({ ref, className, ...props }: HTMLAttributes<HTMLParagraphElement> & {
|
|
193
|
+
ref?: React.RefObject<HTMLParagraphElement | null>;
|
|
194
|
+
}): import("react").JSX.Element;
|
|
195
|
+
declare namespace ProductDetailOptionPrice {
|
|
196
|
+
var displayName: string;
|
|
197
|
+
}
|
|
198
|
+
declare function ProductDetailOptionControl({ ref, className, ...props }: HTMLAttributes<HTMLSpanElement> & {
|
|
199
|
+
ref?: React.RefObject<HTMLSpanElement | null>;
|
|
200
|
+
}): import("react").JSX.Element;
|
|
201
|
+
declare namespace ProductDetailOptionControl {
|
|
202
|
+
var displayName: string;
|
|
203
|
+
}
|
|
204
|
+
declare function ProductDetailBack({ ref, className, type, ...props }: ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
205
|
+
ref?: React.RefObject<HTMLButtonElement | null>;
|
|
206
|
+
}): import("react").JSX.Element;
|
|
207
|
+
declare namespace ProductDetailBack {
|
|
208
|
+
var displayName: string;
|
|
209
|
+
}
|
|
210
|
+
declare function ProductDetailRelated({ ref, className, ...props }: HTMLAttributes<HTMLElement> & {
|
|
211
|
+
ref?: React.RefObject<HTMLElement | null>;
|
|
212
|
+
}): import("react").JSX.Element;
|
|
213
|
+
declare namespace ProductDetailRelated {
|
|
214
|
+
var displayName: string;
|
|
215
|
+
}
|
|
216
|
+
declare function ProductDetailRelatedTitle({ ref, className, ...props }: HTMLAttributes<HTMLHeadingElement> & {
|
|
217
|
+
ref?: React.RefObject<HTMLHeadingElement | null>;
|
|
218
|
+
}): import("react").JSX.Element;
|
|
219
|
+
declare namespace ProductDetailRelatedTitle {
|
|
220
|
+
var displayName: string;
|
|
221
|
+
}
|
|
222
|
+
declare function ProductDetailRelatedGrid({ ref, className, ...props }: HTMLAttributes<HTMLDivElement> & {
|
|
223
|
+
ref?: React.RefObject<HTMLDivElement | null>;
|
|
224
|
+
}): import("react").JSX.Element;
|
|
225
|
+
declare namespace ProductDetailRelatedGrid {
|
|
226
|
+
var displayName: string;
|
|
227
|
+
}
|
|
228
|
+
declare function ProductDetailFooter({ ref, className, ...props }: HTMLAttributes<HTMLDivElement> & {
|
|
229
|
+
ref?: React.RefObject<HTMLDivElement | null>;
|
|
230
|
+
}): import("react").JSX.Element;
|
|
231
|
+
declare namespace ProductDetailFooter {
|
|
232
|
+
var displayName: string;
|
|
233
|
+
}
|
|
234
|
+
declare function ProductDetailSubmit({ ref, className, type, ...props }: ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
235
|
+
ref?: React.RefObject<HTMLButtonElement | null>;
|
|
236
|
+
}): import("react").JSX.Element;
|
|
237
|
+
declare namespace ProductDetailSubmit {
|
|
238
|
+
var displayName: string;
|
|
239
|
+
}
|
|
240
|
+
//#endregion
|
|
241
|
+
export { ProductDetail, type ProductDetailActions, ProductDetailAnchorPrice, ProductDetailBack, ProductDetailBadge, ProductDetailBody, type ProductDetailContextMeta, type ProductDetailContextValue, ProductDetailDescription, ProductDetailDiscount, ProductDetailFooter, ProductDetailGroup, ProductDetailGroupDescription, ProductDetailGroupHeader, ProductDetailGroupHint, ProductDetailGroupRequired, ProductDetailGroupTitle, ProductDetailGroups, ProductDetailHeader, ProductDetailImage, ProductDetailImageSlot, ProductDetailLayout, ProductDetailMedia, ProductDetailMeta, ProductDetailOption, ProductDetailOptionControl, ProductDetailOptionLabel, ProductDetailOptionName, ProductDetailOptionPrice, ProductDetailOptions, ProductDetailPanel, ProductDetailPrice, ProductDetailProvider, type ProductDetailProviderProps, type ProductDetailQuantities, ProductDetailRelated, ProductDetailRelatedGrid, ProductDetailRelatedTitle, type ProductDetailState, ProductDetailSubmit, ProductDetailTitle, useProductDetail };
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as cn } from "./cn-Ccejyh36.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { createContext, use, useState } from "react";
|
|
5
|
+
//#region src/product-detail.tsx
|
|
6
|
+
const ProductDetailContext = createContext(null);
|
|
7
|
+
const useProductDetail = () => {
|
|
8
|
+
const value = use(ProductDetailContext);
|
|
9
|
+
if (!value) throw new Error("useProductDetail must be used within ProductDetailProvider");
|
|
10
|
+
return value;
|
|
11
|
+
};
|
|
12
|
+
const ProductDetailProvider = ({ children, productId, initialQuantities = {} }) => {
|
|
13
|
+
const [quantities, setQuantities] = useState(initialQuantities);
|
|
14
|
+
const [viewStack, setViewStack] = useState([]);
|
|
15
|
+
const selectSingle = (groupId, modifierId) => {
|
|
16
|
+
setQuantities((current) => ({
|
|
17
|
+
...current,
|
|
18
|
+
[groupId]: { [modifierId]: 1 }
|
|
19
|
+
}));
|
|
20
|
+
};
|
|
21
|
+
const toggleModifier = (groupId, modifierId) => {
|
|
22
|
+
setQuantities((current) => {
|
|
23
|
+
const group = { ...current[groupId] ?? {} };
|
|
24
|
+
if ((group[modifierId] ?? 0) > 0) delete group[modifierId];
|
|
25
|
+
else group[modifierId] = 1;
|
|
26
|
+
return {
|
|
27
|
+
...current,
|
|
28
|
+
[groupId]: group
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
const setQuantity = (groupId, modifierId, quantity) => {
|
|
33
|
+
setQuantities((current) => {
|
|
34
|
+
const group = { ...current[groupId] ?? {} };
|
|
35
|
+
const next = Math.max(0, Math.floor(quantity));
|
|
36
|
+
if (next <= 0) delete group[modifierId];
|
|
37
|
+
else group[modifierId] = next;
|
|
38
|
+
return {
|
|
39
|
+
...current,
|
|
40
|
+
[groupId]: group
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
const clearGroup = (groupId) => {
|
|
45
|
+
setQuantities((current) => ({
|
|
46
|
+
...current,
|
|
47
|
+
[groupId]: {}
|
|
48
|
+
}));
|
|
49
|
+
};
|
|
50
|
+
const pushView = (viewId) => {
|
|
51
|
+
setViewStack((current) => [...current, viewId]);
|
|
52
|
+
};
|
|
53
|
+
const popView = () => {
|
|
54
|
+
setViewStack((current) => current.slice(0, -1));
|
|
55
|
+
};
|
|
56
|
+
const reset = () => {
|
|
57
|
+
setQuantities(initialQuantities);
|
|
58
|
+
setViewStack([]);
|
|
59
|
+
};
|
|
60
|
+
return /* @__PURE__ */ jsx(ProductDetailContext, {
|
|
61
|
+
value: {
|
|
62
|
+
state: {
|
|
63
|
+
quantities,
|
|
64
|
+
viewStack
|
|
65
|
+
},
|
|
66
|
+
actions: {
|
|
67
|
+
selectSingle,
|
|
68
|
+
toggleModifier,
|
|
69
|
+
setQuantity,
|
|
70
|
+
clearGroup,
|
|
71
|
+
pushView,
|
|
72
|
+
popView,
|
|
73
|
+
reset
|
|
74
|
+
},
|
|
75
|
+
meta: { productId }
|
|
76
|
+
},
|
|
77
|
+
children
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
ProductDetailProvider.displayName = "ProductDetailProvider";
|
|
81
|
+
const ProductDetail = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("div", {
|
|
82
|
+
ref,
|
|
83
|
+
className: cn("@container/product-detail flex min-h-0 flex-1 flex-col", className),
|
|
84
|
+
...props
|
|
85
|
+
});
|
|
86
|
+
ProductDetail.displayName = "ProductDetail";
|
|
87
|
+
const ProductDetailBody = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("div", {
|
|
88
|
+
ref,
|
|
89
|
+
className: cn("-mx-6 min-h-0 flex-1 overflow-y-auto @min-[36rem]/product-detail:px-6", className),
|
|
90
|
+
...props
|
|
91
|
+
});
|
|
92
|
+
ProductDetailBody.displayName = "ProductDetailBody";
|
|
93
|
+
const ProductDetailLayout = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("div", {
|
|
94
|
+
ref,
|
|
95
|
+
className: cn("grid min-w-0 gap-4 @min-[36rem]/product-detail:grid-cols-[minmax(0,1fr)_minmax(0,1.15fr)] @min-[36rem]/product-detail:gap-6", className),
|
|
96
|
+
...props
|
|
97
|
+
});
|
|
98
|
+
ProductDetailLayout.displayName = "ProductDetailLayout";
|
|
99
|
+
const ProductDetailMedia = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("div", {
|
|
100
|
+
ref,
|
|
101
|
+
className: cn("bg-muted relative aspect-[3/2] w-full min-w-0 overflow-hidden @min-[36rem]/product-detail:aspect-square @min-[36rem]/product-detail:sticky @min-[36rem]/product-detail:top-0 @min-[36rem]/product-detail:self-start", className),
|
|
102
|
+
...props
|
|
103
|
+
});
|
|
104
|
+
ProductDetailMedia.displayName = "ProductDetailMedia";
|
|
105
|
+
const ProductDetailImageSlot = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("div", {
|
|
106
|
+
ref,
|
|
107
|
+
className: cn("absolute inset-0", className),
|
|
108
|
+
...props
|
|
109
|
+
});
|
|
110
|
+
ProductDetailImageSlot.displayName = "ProductDetailImageSlot";
|
|
111
|
+
const ProductDetailImage = ({ ref, className, alt = "", ...props }) => /* @__PURE__ */ jsx(ProductDetailImageSlot, { children: /* @__PURE__ */ jsx("img", {
|
|
112
|
+
ref,
|
|
113
|
+
alt,
|
|
114
|
+
className: cn("size-full object-cover", className),
|
|
115
|
+
...props
|
|
116
|
+
}) });
|
|
117
|
+
ProductDetailImage.displayName = "ProductDetailImage";
|
|
118
|
+
const ProductDetailPanel = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("div", {
|
|
119
|
+
ref,
|
|
120
|
+
className: cn("flex min-w-0 flex-col px-6 @min-[36rem]/product-detail:px-0", className),
|
|
121
|
+
...props
|
|
122
|
+
});
|
|
123
|
+
ProductDetailPanel.displayName = "ProductDetailPanel";
|
|
124
|
+
const ProductDetailHeader = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("div", {
|
|
125
|
+
ref,
|
|
126
|
+
className: cn("flex flex-col gap-3 pt-6 pr-8 pb-2", className),
|
|
127
|
+
...props
|
|
128
|
+
});
|
|
129
|
+
ProductDetailHeader.displayName = "ProductDetailHeader";
|
|
130
|
+
const ProductDetailTitle = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("h2", {
|
|
131
|
+
ref,
|
|
132
|
+
className: cn("text-2xl leading-tight font-bold tracking-tight sm:text-3xl", className),
|
|
133
|
+
...props
|
|
134
|
+
});
|
|
135
|
+
ProductDetailTitle.displayName = "ProductDetailTitle";
|
|
136
|
+
const ProductDetailMeta = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("div", {
|
|
137
|
+
ref,
|
|
138
|
+
className: cn("flex flex-wrap items-center gap-2", className),
|
|
139
|
+
...props
|
|
140
|
+
});
|
|
141
|
+
ProductDetailMeta.displayName = "ProductDetailMeta";
|
|
142
|
+
const ProductDetailPrice = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("span", {
|
|
143
|
+
ref,
|
|
144
|
+
className: cn("text-base font-semibold tabular-nums sm:text-lg", className),
|
|
145
|
+
...props
|
|
146
|
+
});
|
|
147
|
+
ProductDetailPrice.displayName = "ProductDetailPrice";
|
|
148
|
+
const ProductDetailAnchorPrice = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("span", {
|
|
149
|
+
ref,
|
|
150
|
+
className: cn("text-muted-foreground text-sm tabular-nums line-through", className),
|
|
151
|
+
...props
|
|
152
|
+
});
|
|
153
|
+
ProductDetailAnchorPrice.displayName = "ProductDetailAnchorPrice";
|
|
154
|
+
const ProductDetailDiscount = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("span", {
|
|
155
|
+
ref,
|
|
156
|
+
className: cn("inline-flex w-fit items-center rounded-full bg-red-600 px-2 py-0.5 text-xs font-semibold text-white", className),
|
|
157
|
+
...props
|
|
158
|
+
});
|
|
159
|
+
ProductDetailDiscount.displayName = "ProductDetailDiscount";
|
|
160
|
+
const ProductDetailDescription = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("p", {
|
|
161
|
+
ref,
|
|
162
|
+
className: cn("text-muted-foreground text-sm leading-relaxed", className),
|
|
163
|
+
...props
|
|
164
|
+
});
|
|
165
|
+
ProductDetailDescription.displayName = "ProductDetailDescription";
|
|
166
|
+
const ProductDetailBadge = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("span", {
|
|
167
|
+
ref,
|
|
168
|
+
className: cn("bg-muted text-foreground inline-flex w-fit items-center rounded-full px-2.5 py-1 text-xs font-medium", className),
|
|
169
|
+
...props
|
|
170
|
+
});
|
|
171
|
+
ProductDetailBadge.displayName = "ProductDetailBadge";
|
|
172
|
+
const ProductDetailGroups = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("div", {
|
|
173
|
+
ref,
|
|
174
|
+
className: cn("flex flex-col gap-8 py-6", className),
|
|
175
|
+
...props
|
|
176
|
+
});
|
|
177
|
+
ProductDetailGroups.displayName = "ProductDetailGroups";
|
|
178
|
+
const ProductDetailGroup = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("section", {
|
|
179
|
+
ref,
|
|
180
|
+
className: cn("flex flex-col gap-3", className),
|
|
181
|
+
...props
|
|
182
|
+
});
|
|
183
|
+
ProductDetailGroup.displayName = "ProductDetailGroup";
|
|
184
|
+
const ProductDetailGroupHeader = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("div", {
|
|
185
|
+
ref,
|
|
186
|
+
className: cn("flex items-start justify-between gap-3", className),
|
|
187
|
+
...props
|
|
188
|
+
});
|
|
189
|
+
ProductDetailGroupHeader.displayName = "ProductDetailGroupHeader";
|
|
190
|
+
const ProductDetailGroupTitle = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("h3", {
|
|
191
|
+
ref,
|
|
192
|
+
className: cn("text-base font-semibold tracking-tight", className),
|
|
193
|
+
...props
|
|
194
|
+
});
|
|
195
|
+
ProductDetailGroupTitle.displayName = "ProductDetailGroupTitle";
|
|
196
|
+
const ProductDetailGroupHint = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("p", {
|
|
197
|
+
ref,
|
|
198
|
+
className: cn("text-muted-foreground mt-0.5 text-sm", className),
|
|
199
|
+
...props
|
|
200
|
+
});
|
|
201
|
+
ProductDetailGroupHint.displayName = "ProductDetailGroupHint";
|
|
202
|
+
const ProductDetailGroupDescription = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("p", {
|
|
203
|
+
ref,
|
|
204
|
+
className: cn("text-muted-foreground mt-1 text-xs", className),
|
|
205
|
+
...props
|
|
206
|
+
});
|
|
207
|
+
ProductDetailGroupDescription.displayName = "ProductDetailGroupDescription";
|
|
208
|
+
const ProductDetailGroupRequired = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("span", {
|
|
209
|
+
ref,
|
|
210
|
+
className: cn("bg-muted text-foreground shrink-0 rounded-full px-2.5 py-1 text-xs font-medium", className),
|
|
211
|
+
...props
|
|
212
|
+
});
|
|
213
|
+
ProductDetailGroupRequired.displayName = "ProductDetailGroupRequired";
|
|
214
|
+
const ProductDetailOptions = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("ul", {
|
|
215
|
+
ref,
|
|
216
|
+
className: cn("divide-border flex flex-col divide-y rounded-xl border", className),
|
|
217
|
+
...props
|
|
218
|
+
});
|
|
219
|
+
ProductDetailOptions.displayName = "ProductDetailOptions";
|
|
220
|
+
const ProductDetailOption = ({ ref, className, selected = false, ...props }) => /* @__PURE__ */ jsx("li", {
|
|
221
|
+
ref,
|
|
222
|
+
"data-selected": selected ? "true" : "false",
|
|
223
|
+
className: cn("flex cursor-pointer items-center justify-between gap-3 px-4 py-3", className),
|
|
224
|
+
...props
|
|
225
|
+
});
|
|
226
|
+
ProductDetailOption.displayName = "ProductDetailOption";
|
|
227
|
+
const ProductDetailOptionLabel = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("div", {
|
|
228
|
+
ref,
|
|
229
|
+
className: cn("min-w-0 flex-1", className),
|
|
230
|
+
...props
|
|
231
|
+
});
|
|
232
|
+
ProductDetailOptionLabel.displayName = "ProductDetailOptionLabel";
|
|
233
|
+
const ProductDetailOptionName = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("p", {
|
|
234
|
+
ref,
|
|
235
|
+
className: cn("truncate text-sm font-medium", className),
|
|
236
|
+
...props
|
|
237
|
+
});
|
|
238
|
+
ProductDetailOptionName.displayName = "ProductDetailOptionName";
|
|
239
|
+
const ProductDetailOptionPrice = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("p", {
|
|
240
|
+
ref,
|
|
241
|
+
className: cn("text-muted-foreground text-sm tabular-nums", className),
|
|
242
|
+
...props
|
|
243
|
+
});
|
|
244
|
+
ProductDetailOptionPrice.displayName = "ProductDetailOptionPrice";
|
|
245
|
+
/** Slot for your own radio / checkbox / stepper — no built-in controls. */
|
|
246
|
+
const ProductDetailOptionControl = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("span", {
|
|
247
|
+
ref,
|
|
248
|
+
className: cn("flex shrink-0 items-center gap-2", className),
|
|
249
|
+
...props
|
|
250
|
+
});
|
|
251
|
+
ProductDetailOptionControl.displayName = "ProductDetailOptionControl";
|
|
252
|
+
const ProductDetailBack = ({ ref, className, type = "button", ...props }) => /* @__PURE__ */ jsx("button", {
|
|
253
|
+
ref,
|
|
254
|
+
type,
|
|
255
|
+
className: cn("text-muted-foreground hover:text-foreground -ml-1 w-fit px-1 py-0.5 text-sm font-medium", className),
|
|
256
|
+
...props
|
|
257
|
+
});
|
|
258
|
+
ProductDetailBack.displayName = "ProductDetailBack";
|
|
259
|
+
const ProductDetailRelated = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("section", {
|
|
260
|
+
ref,
|
|
261
|
+
className: cn("flex flex-col gap-4 border-t px-6 py-6 @min-[36rem]/product-detail:px-0", className),
|
|
262
|
+
...props
|
|
263
|
+
});
|
|
264
|
+
ProductDetailRelated.displayName = "ProductDetailRelated";
|
|
265
|
+
const ProductDetailRelatedTitle = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("h3", {
|
|
266
|
+
ref,
|
|
267
|
+
className: cn("text-base font-semibold tracking-tight sm:text-lg", className),
|
|
268
|
+
...props
|
|
269
|
+
});
|
|
270
|
+
ProductDetailRelatedTitle.displayName = "ProductDetailRelatedTitle";
|
|
271
|
+
const ProductDetailRelatedGrid = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("div", {
|
|
272
|
+
ref,
|
|
273
|
+
className: cn("grid gap-3 @min-[36rem]/product-detail:grid-cols-2", className),
|
|
274
|
+
...props
|
|
275
|
+
});
|
|
276
|
+
ProductDetailRelatedGrid.displayName = "ProductDetailRelatedGrid";
|
|
277
|
+
const ProductDetailFooter = ({ ref, className, ...props }) => /* @__PURE__ */ jsx("div", {
|
|
278
|
+
ref,
|
|
279
|
+
className: cn("bg-background shrink-0 border-t py-4 sm:py-5", className),
|
|
280
|
+
...props
|
|
281
|
+
});
|
|
282
|
+
ProductDetailFooter.displayName = "ProductDetailFooter";
|
|
283
|
+
const ProductDetailSubmit = ({ ref, className, type = "button", ...props }) => /* @__PURE__ */ jsx("button", {
|
|
284
|
+
ref,
|
|
285
|
+
type,
|
|
286
|
+
className: cn("bg-foreground text-background hover:bg-foreground/90 flex w-full items-center justify-center rounded-full px-4 py-3 text-sm font-semibold transition-colors disabled:pointer-events-none disabled:opacity-50", className),
|
|
287
|
+
...props
|
|
288
|
+
});
|
|
289
|
+
ProductDetailSubmit.displayName = "ProductDetailSubmit";
|
|
290
|
+
//#endregion
|
|
291
|
+
export { ProductDetail, ProductDetailAnchorPrice, ProductDetailBack, ProductDetailBadge, ProductDetailBody, ProductDetailDescription, ProductDetailDiscount, ProductDetailFooter, ProductDetailGroup, ProductDetailGroupDescription, ProductDetailGroupHeader, ProductDetailGroupHint, ProductDetailGroupRequired, ProductDetailGroupTitle, ProductDetailGroups, ProductDetailHeader, ProductDetailImage, ProductDetailImageSlot, ProductDetailLayout, ProductDetailMedia, ProductDetailMeta, ProductDetailOption, ProductDetailOptionControl, ProductDetailOptionLabel, ProductDetailOptionName, ProductDetailOptionPrice, ProductDetailOptions, ProductDetailPanel, ProductDetailPrice, ProductDetailProvider, ProductDetailRelated, ProductDetailRelatedGrid, ProductDetailRelatedTitle, ProductDetailSubmit, ProductDetailTitle, useProductDetail };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/use-active-category.d.ts
|
|
2
|
+
type UseActiveCategoryOptions = {
|
|
3
|
+
categoryIds: readonly string[];
|
|
4
|
+
/** Scroll container. Defaults to the window. */
|
|
5
|
+
root?: Element | null;
|
|
6
|
+
/** Pixels from the top of the scroll viewport used as the “current” line. */
|
|
7
|
+
offset?: number;
|
|
8
|
+
};
|
|
9
|
+
declare const useActiveCategory: (options: UseActiveCategoryOptions) => {
|
|
10
|
+
activeCategoryId: string;
|
|
11
|
+
setActiveCategoryId: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
12
|
+
selectCategory: (categoryId: string) => void;
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
export { UseActiveCategoryOptions, useActiveCategory };
|