@shopbb/helium 0.6.4 → 0.7.0
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/AddToCartButton.d.ts +17 -22
- package/dist/components/AddToCartButton.d.ts.map +1 -1
- package/dist/components/AddToCartButton.js +8 -45
- package/dist/components/AddToCartButton.js.map +1 -1
- package/dist/components/AddressForm.d.ts +42 -18
- package/dist/components/AddressForm.d.ts.map +1 -1
- package/dist/components/AddressForm.js +23 -20
- package/dist/components/AddressForm.js.map +1 -1
- package/dist/components/AddressList.d.ts +34 -17
- package/dist/components/AddressList.d.ts.map +1 -1
- package/dist/components/AddressList.js +7 -21
- package/dist/components/AddressList.js.map +1 -1
- package/dist/components/AddressPicker.d.ts +14 -16
- package/dist/components/AddressPicker.d.ts.map +1 -1
- package/dist/components/AddressPicker.js +10 -26
- package/dist/components/AddressPicker.js.map +1 -1
- package/dist/components/AnalyticsProvider.d.ts +5 -2
- package/dist/components/AnalyticsProvider.d.ts.map +1 -1
- package/dist/components/AnalyticsProvider.js +13 -11
- package/dist/components/AnalyticsProvider.js.map +1 -1
- package/dist/components/BuyNowButton.d.ts +7 -24
- package/dist/components/BuyNowButton.d.ts.map +1 -1
- package/dist/components/BuyNowButton.js +9 -43
- package/dist/components/BuyNowButton.js.map +1 -1
- package/dist/components/CartCheckoutButton.d.ts +10 -21
- package/dist/components/CartCheckoutButton.d.ts.map +1 -1
- package/dist/components/CartCheckoutButton.js +6 -11
- package/dist/components/CartCheckoutButton.js.map +1 -1
- package/dist/components/CartCost.d.ts +15 -23
- package/dist/components/CartCost.d.ts.map +1 -1
- package/dist/components/CartCost.js +1 -3
- package/dist/components/CartCost.js.map +1 -1
- package/dist/components/CartForm.d.ts +30 -102
- package/dist/components/CartForm.d.ts.map +1 -1
- package/dist/components/CartForm.js +32 -172
- package/dist/components/CartForm.js.map +1 -1
- package/dist/components/DiscountComponents.d.ts +67 -17
- package/dist/components/DiscountComponents.d.ts.map +1 -1
- package/dist/components/DiscountComponents.js +28 -74
- package/dist/components/DiscountComponents.js.map +1 -1
- package/dist/components/DiscountSelector.d.ts +50 -15
- package/dist/components/DiscountSelector.d.ts.map +1 -1
- package/dist/components/DiscountSelector.js +16 -44
- package/dist/components/DiscountSelector.js.map +1 -1
- package/dist/components/hooks/useOptimisticCart.d.ts +36 -37
- package/dist/components/hooks/useOptimisticCart.d.ts.map +1 -1
- package/dist/components/hooks/useOptimisticCart.js +95 -127
- package/dist/components/hooks/useOptimisticCart.js.map +1 -1
- package/dist/components/index.d.ts +24 -45
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +21 -37
- package/dist/components/index.js.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -10
- package/src/components/AddToCartButton.tsx +34 -92
- package/src/components/AddressForm.tsx +56 -26
- package/src/components/AddressList.tsx +42 -33
- package/src/components/AddressPicker.tsx +19 -29
- package/src/components/AnalyticsProvider.tsx +18 -13
- package/src/components/BuyNowButton.tsx +28 -93
- package/src/components/CartCheckoutButton.tsx +16 -33
- package/src/components/CartCost.tsx +16 -28
- package/src/components/CartForm.tsx +87 -231
- package/src/components/DiscountComponents.tsx +94 -100
- package/src/components/DiscountSelector.tsx +68 -49
- package/src/components/hooks/useOptimisticCart.ts +122 -156
- package/src/components/index.ts +51 -99
- package/src/index.ts +0 -2
- /package/src/components/{AddressBookProvider.tsx → AddressBookProvider.tsx.deleted-0.7} +0 -0
- /package/src/components/{CartLineQuantityAdjustButton.tsx → CartLineQuantityAdjustButton.tsx.deleted-0.7} +0 -0
- /package/src/components/{CartProvider.tsx → CartProvider.tsx.deleted-0.7} +0 -0
- /package/src/components/{DiscountProvider.tsx → DiscountProvider.tsx.deleted-0.7} +0 -0
- /package/src/components/hooks/{useMounted.ts → useMounted.ts.deleted-0.7} +0 -0
- /package/src/{handleCartFormAction.ts → handleCartFormAction.ts.deleted-0.7} +0 -0
|
@@ -1,146 +1,114 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* useOptimisticCart —
|
|
2
|
+
* useOptimisticCart — 严格对齐 Shopify Hydrogen
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* 的 cart 视图。让 UI 在网络回来之前立刻反应用户操作(数量+1 / 删除等)。
|
|
4
|
+
* 源文件参考:packages/hydrogen/src/cart/optimistic/useOptimisticCart.tsx
|
|
6
5
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* // cart 看起来已经"立刻应用了",但 fetcher 还在跑后端
|
|
6
|
+
* 核心:用 RR7 `useFetchers()` 拿当前所有 in-flight fetcher,遍历它们的 formData
|
|
7
|
+
* 用 CartForm.getFormInput 解析出 action/inputs,合并到 actualCart 上。
|
|
10
8
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
9
|
+
* 用法:
|
|
10
|
+
* const data = useLoaderData<typeof loader>();
|
|
11
|
+
* const cart = useOptimisticCart(data.cart);
|
|
12
|
+
* // cart 包含 isOptimistic 字段、cart.lines 包含 in-flight 添加的 line(也带 isOptimistic)
|
|
15
13
|
*
|
|
16
|
-
*
|
|
17
|
-
* -
|
|
18
|
-
* -
|
|
19
|
-
* - 不持久化(页面刷新清空)
|
|
14
|
+
* 与之前 helium 0.6.x 区别:
|
|
15
|
+
* - 删除自造 pendingStore 全局变量
|
|
16
|
+
* - 直接用 RR7 useFetchers()
|
|
20
17
|
*/
|
|
21
|
-
import
|
|
22
|
-
import {
|
|
23
|
-
// 关键:snapshot 必须是稳定引用,否则 useSyncExternalStore 每次比对都觉得变了 →
|
|
24
|
-
// 无限 re-render(React #185)+ hydration mismatch(#418/#423)
|
|
25
|
-
const EMPTY_SNAPSHOT = [];
|
|
26
|
-
const pendingStore = {
|
|
27
|
-
items: new Map(),
|
|
28
|
-
listeners: new Set(),
|
|
29
|
-
cachedSnapshot: EMPTY_SNAPSHOT,
|
|
30
|
-
add(m) {
|
|
31
|
-
this.items.set(m.id, m);
|
|
32
|
-
this.cachedSnapshot = Array.from(this.items.values());
|
|
33
|
-
this.notify();
|
|
34
|
-
},
|
|
35
|
-
remove(id) {
|
|
36
|
-
if (this.items.delete(id)) {
|
|
37
|
-
this.cachedSnapshot = this.items.size === 0 ? EMPTY_SNAPSHOT : Array.from(this.items.values());
|
|
38
|
-
this.notify();
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
list() {
|
|
42
|
-
// 返回稳定引用(只在 add/remove 时改变)— 满足 useSyncExternalStore 契约
|
|
43
|
-
return this.cachedSnapshot;
|
|
44
|
-
},
|
|
45
|
-
subscribe(fn) {
|
|
46
|
-
this.listeners.add(fn);
|
|
47
|
-
return () => { this.listeners.delete(fn); };
|
|
48
|
-
},
|
|
49
|
-
notify() {
|
|
50
|
-
for (const fn of this.listeners)
|
|
51
|
-
fn();
|
|
52
|
-
},
|
|
53
|
-
};
|
|
18
|
+
import { useFetchers } from 'react-router';
|
|
19
|
+
import { CartForm } from '../CartForm';
|
|
54
20
|
/**
|
|
55
|
-
*
|
|
21
|
+
* 给 optimistic line 一个临时 id。Hydrogen 用 `gid://shopify/CartLine/optimistic-<variantId>`。
|
|
22
|
+
* 我们 shopbb 也用类似前缀。
|
|
56
23
|
*/
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return () => pendingStore.remove(m.id);
|
|
24
|
+
function getOptimisticLineId(variantId) {
|
|
25
|
+
return `optimistic-${variantId}`;
|
|
60
26
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
if (optimisticLines.length === 0)
|
|
88
|
-
return null;
|
|
89
|
-
return {
|
|
90
|
-
isOptimistic: true,
|
|
91
|
-
totalQuantity: optimisticLines.reduce((s, l) => s + l.quantity, 0),
|
|
92
|
-
lines: { nodes: optimisticLines },
|
|
93
|
-
};
|
|
27
|
+
function isOptimisticLineId(id) {
|
|
28
|
+
return id.startsWith('optimistic-');
|
|
29
|
+
}
|
|
30
|
+
export function useOptimisticCart(cart) {
|
|
31
|
+
const fetchers = useFetchers();
|
|
32
|
+
if (!fetchers || !fetchers.length) {
|
|
33
|
+
return cart;
|
|
34
|
+
}
|
|
35
|
+
// 用 structuredClone 拷贝 cart(不污染 useLoaderData 的引用)
|
|
36
|
+
const optimisticCart = cart?.lines
|
|
37
|
+
? (typeof structuredClone === 'function' ? structuredClone(cart) : JSON.parse(JSON.stringify(cart)))
|
|
38
|
+
: { lines: { nodes: [] } };
|
|
39
|
+
const cartLines = optimisticCart.lines?.nodes ?? [];
|
|
40
|
+
let isOptimistic = false;
|
|
41
|
+
for (const { formData } of fetchers) {
|
|
42
|
+
if (!formData)
|
|
43
|
+
continue;
|
|
44
|
+
let cartFormData;
|
|
45
|
+
try {
|
|
46
|
+
cartFormData = CartForm.getFormInput(formData);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
continue;
|
|
94
50
|
}
|
|
95
|
-
if (
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
51
|
+
if (!cartFormData?.action)
|
|
52
|
+
continue;
|
|
53
|
+
if (cartFormData.action === CartForm.ACTIONS.LinesAdd) {
|
|
54
|
+
const lines = cartFormData.inputs?.lines ?? [];
|
|
55
|
+
for (const input of lines) {
|
|
56
|
+
if (!input.selectedVariant) {
|
|
57
|
+
// 没传 selectedVariant,无法 optimistic 显示具体信息 — Hydrogen 的约束相同
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const variantId = input.selectedVariant?.id;
|
|
61
|
+
const existingLine = cartLines.find((line) => line.merchandise?.id === variantId);
|
|
62
|
+
isOptimistic = true;
|
|
63
|
+
if (existingLine) {
|
|
64
|
+
existingLine.quantity = (existingLine.quantity || 1) + (input.quantity || 1);
|
|
65
|
+
existingLine.isOptimistic = true;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
cartLines.unshift({
|
|
69
|
+
id: getOptimisticLineId(variantId),
|
|
70
|
+
merchandise: input.selectedVariant,
|
|
71
|
+
quantity: input.quantity || 1,
|
|
72
|
+
isOptimistic: true,
|
|
73
|
+
});
|
|
119
74
|
}
|
|
120
75
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
76
|
+
}
|
|
77
|
+
else if (cartFormData.action === CartForm.ACTIONS.LinesRemove) {
|
|
78
|
+
const lineIds = cartFormData.inputs?.lineIds ?? [];
|
|
79
|
+
for (const lineId of lineIds) {
|
|
80
|
+
const idx = cartLines.findIndex((line) => line.id === lineId);
|
|
81
|
+
if (idx !== -1) {
|
|
82
|
+
if (isOptimisticLineId(cartLines[idx].id))
|
|
83
|
+
continue;
|
|
84
|
+
cartLines.splice(idx, 1);
|
|
85
|
+
isOptimistic = true;
|
|
127
86
|
}
|
|
128
87
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
88
|
+
}
|
|
89
|
+
else if (cartFormData.action === CartForm.ACTIONS.LinesUpdate) {
|
|
90
|
+
const lines = cartFormData.inputs?.lines ?? [];
|
|
91
|
+
for (const line of lines) {
|
|
92
|
+
const idx = cartLines.findIndex((optimisticLine) => line.id === optimisticLine.id);
|
|
93
|
+
if (idx > -1) {
|
|
94
|
+
if (isOptimisticLineId(cartLines[idx].id))
|
|
95
|
+
continue;
|
|
96
|
+
cartLines[idx].quantity = line.quantity;
|
|
97
|
+
if (cartLines[idx].quantity === 0)
|
|
98
|
+
cartLines.splice(idx, 1);
|
|
99
|
+
isOptimistic = true;
|
|
134
100
|
}
|
|
135
101
|
}
|
|
136
102
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
103
|
+
}
|
|
104
|
+
if (isOptimistic)
|
|
105
|
+
optimisticCart.isOptimistic = isOptimistic;
|
|
106
|
+
optimisticCart.totalQuantity = cartLines.reduce((sum, line) => sum + (line.quantity || 0), 0);
|
|
107
|
+
optimisticCart.lines = { ...optimisticCart.lines, nodes: cartLines };
|
|
108
|
+
return optimisticCart;
|
|
109
|
+
}
|
|
110
|
+
// 旧 API 兼容(pendingStore 已废弃)
|
|
111
|
+
export function __registerPendingMutation() {
|
|
112
|
+
return () => { };
|
|
145
113
|
}
|
|
146
114
|
//# sourceMappingURL=useOptimisticCart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOptimisticCart.js","sourceRoot":"","sources":["../../../src/components/hooks/useOptimisticCart.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"useOptimisticCart.js","sourceRoot":"","sources":["../../../src/components/hooks/useOptimisticCart.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAsB,MAAM,aAAa,CAAC;AAsB3D;;;GAGG;AACH,SAAS,mBAAmB,CAAC,SAAiB;IAC5C,OAAO,cAAc,SAA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,CAAC;IAErE,OAAO,cAA6C,CAAC;AACvD,CAAC;AAED,6BAA6B;AAC7B,MAAM,UAAU,yBAAyB;IACvC,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -1,76 +1,55 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @shopbb/helium/components — 商家用 React 组件
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* Money, Image, ProductPrice,
|
|
9
|
-
* AddToCartButton, CartLineQuantityAdjustButton,
|
|
10
|
-
* VariantSelector, ProductOptionsProvider, useProductOptions,
|
|
11
|
-
* Analytics,
|
|
12
|
-
* } from '@shopbb/helium/components';
|
|
13
|
-
*
|
|
14
|
-
* 设计原则:
|
|
15
|
-
* - 无样式:组件只管行为 + 语义化 DOM,样式商家自己写
|
|
16
|
-
* - data-* 钩子:方便选择器
|
|
17
|
-
* - 对齐 Shopify Hydrogen 同名组件的 API,迁移成本低
|
|
18
|
-
* - Provider 链:<ShopProvider> > <CartProvider> > <AnalyticsProvider> > App
|
|
19
|
-
* 组件优先从 Provider 拿;Provider 缺省时回退到 props 或 noop
|
|
4
|
+
* 0.7 起严格对齐 Shopify Hydrogen 设计原则:
|
|
5
|
+
* - 数据流:服务端 loader → useLoaderData → 组件 props(不通过 Provider)
|
|
6
|
+
* - mutation:<CartForm> + RR7 useFetcher(自动 revalidate loader)
|
|
7
|
+
* - 删除 CartProvider / DiscountProvider / AddressBookProvider
|
|
20
8
|
*/
|
|
21
9
|
export { ShopProvider, useShop, useShopOptional } from './ShopProvider';
|
|
22
10
|
export type { ShopContextValue, ShopProviderProps } from './ShopProvider';
|
|
23
11
|
export { ShopProvider as ShopifyProvider } from './ShopProvider';
|
|
24
12
|
export type { ShopProviderProps as ShopifyProviderProps } from './ShopProvider';
|
|
25
|
-
export { CartProvider, useCart, useCartOptional } from './CartProvider';
|
|
26
|
-
export type { Cart, CartLine, CartLineMerchandise, CartStatus, CartUserError, CartContextValue, CartProviderProps, } from './CartProvider';
|
|
27
13
|
export { ProductOptionsProvider, useProductOptions, } from './ProductOptionsProvider';
|
|
28
14
|
export type { ProductOptionsContextValue, ProductOptionsProviderProps, ProductOptionItem, } from './ProductOptionsProvider';
|
|
29
15
|
export { AnalyticsProvider, useAnalytics, Analytics } from './AnalyticsProvider';
|
|
30
16
|
export type { AnalyticsEvent, AnalyticsContextValue, AnalyticsProviderProps } from './AnalyticsProvider';
|
|
17
|
+
export { CartLineProvider, useCartLine, useCartLineOptional } from './CartLineProvider';
|
|
18
|
+
export type { CartLineProviderProps, CartLineLike } from './CartLineProvider';
|
|
31
19
|
export { Money } from './Money';
|
|
32
20
|
export type { MoneyProps, MoneyData, MoneyMeasurement } from './Money';
|
|
33
21
|
export { Image } from './Image';
|
|
34
22
|
export type { ImageProps, ImageData } from './Image';
|
|
35
23
|
export { ProductPrice } from './ProductPrice';
|
|
36
24
|
export type { ProductPriceProps } from './ProductPrice';
|
|
37
|
-
export { AddToCartButton } from './AddToCartButton';
|
|
38
|
-
export type { AddToCartButtonProps } from './AddToCartButton';
|
|
39
|
-
export { CartLineQuantityAdjustButton } from './CartLineQuantityAdjustButton';
|
|
40
|
-
export type { CartLineQuantityAdjustButtonProps } from './CartLineQuantityAdjustButton';
|
|
41
25
|
export { VariantSelector } from './VariantSelector';
|
|
42
26
|
export type { VariantSelectorProps, VariantSelectorRenderProps, VariantOption, } from './VariantSelector';
|
|
43
|
-
export { AddressBookProvider, useAddressBook, useAddressBookOptional, } from './AddressBookProvider';
|
|
44
|
-
export type { Address, AddressInput, AddressBookStatus, AddressBookUserError, AddressBookContextValue, AddressBookProviderProps, } from './AddressBookProvider';
|
|
45
|
-
export { AddressList } from './AddressList';
|
|
46
|
-
export type { AddressListProps, AddressListItemActions } from './AddressList';
|
|
47
|
-
export { AddressForm } from './AddressForm';
|
|
48
|
-
export type { AddressFormProps, AddressFormI18n } from './AddressForm';
|
|
49
|
-
export { AddressPicker } from './AddressPicker';
|
|
50
|
-
export type { AddressPickerProps } from './AddressPicker';
|
|
51
|
-
export { DiscountProvider, useDiscounts, useDiscountsOptional, useProductDiscounts, } from './DiscountProvider';
|
|
52
|
-
export type { Discount, DiscountClaim, DiscountValueType, DiscountValuePercentage, DiscountValueAmount, DiscountValueFreeShipping, CartDiscountCode, CartDiscountAllocation, DiscountUserError, DiscountContextValue, DiscountProviderProps, } from './DiscountProvider';
|
|
53
|
-
export { AppliedDiscountList, ClaimableDiscountList, DiscountClaimButton, MyDiscountList, } from './DiscountComponents';
|
|
54
|
-
export type { AppliedDiscountListProps, ClaimableDiscountListProps, DiscountClaimButtonProps, MyDiscountListProps, } from './DiscountComponents';
|
|
55
|
-
export { DiscountSelector } from './DiscountSelector';
|
|
56
|
-
export type { DiscountSelectorProps } from './DiscountSelector';
|
|
57
|
-
export { useMounted } from './hooks/useMounted';
|
|
58
|
-
export { useOptimisticCart } from './hooks/useOptimisticCart';
|
|
59
|
-
export type { OptimisticCart, OptimisticCartLine, PendingMutation } from './hooks/useOptimisticCart';
|
|
60
|
-
export { useMoney } from './hooks/useMoney';
|
|
61
|
-
export type { MoneyV2, MoneyParts } from './hooks/useMoney';
|
|
62
|
-
export { CartForm, CART_FORM_ACTIONS, useFetcher } from './CartForm';
|
|
63
|
-
export type { CartFormProps, CartFormInput, CartFormFetcher, CartFormAction, CartLineInput, CartLineUpdateInput, } from './CartForm';
|
|
64
|
-
export { CartLineProvider, useCartLine, useCartLineOptional } from './CartLineProvider';
|
|
65
|
-
export type { CartLineProviderProps, CartLineLike } from './CartLineProvider';
|
|
66
27
|
export { CartLineQuantity } from './CartLineQuantity';
|
|
67
28
|
export type { CartLineQuantityProps } from './CartLineQuantity';
|
|
68
29
|
export { CartCost } from './CartCost';
|
|
69
30
|
export type { CartCostProps, MoneyValue } from './CartCost';
|
|
70
31
|
export { CartCheckoutButton } from './CartCheckoutButton';
|
|
71
32
|
export type { CartCheckoutButtonProps } from './CartCheckoutButton';
|
|
33
|
+
export { CartForm, CART_FORM_ACTIONS, useFetcher } from './CartForm';
|
|
34
|
+
export type { CartFormProps, CartFormInput, CartFormFetcher, CartFormAction, CartLineInput, CartLineUpdateInput, FetcherWithComponents, } from './CartForm';
|
|
35
|
+
export { AddToCartButton } from './AddToCartButton';
|
|
36
|
+
export type { AddToCartButtonProps } from './AddToCartButton';
|
|
72
37
|
export { BuyNowButton } from './BuyNowButton';
|
|
73
38
|
export type { BuyNowButtonProps } from './BuyNowButton';
|
|
39
|
+
export { useOptimisticCart } from './hooks/useOptimisticCart';
|
|
40
|
+
export type { OptimisticCart, OptimisticCartLine, PendingMutation } from './hooks/useOptimisticCart';
|
|
41
|
+
export { useMoney } from './hooks/useMoney';
|
|
42
|
+
export type { MoneyV2, MoneyParts } from './hooks/useMoney';
|
|
43
|
+
export { AddressList } from './AddressList';
|
|
44
|
+
export type { AddressListProps, AddressListItemActions, Address } from './AddressList';
|
|
45
|
+
export { AddressForm } from './AddressForm';
|
|
46
|
+
export type { AddressFormProps, AddressFormI18n, AddressInput, AddressBookUserError, AddressFormSubmitResult } from './AddressForm';
|
|
47
|
+
export { AddressPicker } from './AddressPicker';
|
|
48
|
+
export type { AddressPickerProps } from './AddressPicker';
|
|
49
|
+
export { AppliedDiscountList, ClaimableDiscountList, DiscountClaimButton, MyDiscountList, } from './DiscountComponents';
|
|
50
|
+
export type { AppliedDiscountListProps, ClaimableDiscountListProps, DiscountClaimButtonProps, MyDiscountListProps, Discount, DiscountClaim, DiscountValueType, DiscountValuePercentage, DiscountValueAmount, DiscountValueFreeShipping, DiscountAllocation, } from './DiscountComponents';
|
|
51
|
+
export { DiscountSelector } from './DiscountSelector';
|
|
52
|
+
export type { DiscountSelectorProps, AppliedDiscountClaim, } from './DiscountSelector';
|
|
74
53
|
export { RichText } from './RichText';
|
|
75
54
|
export type { RichTextProps, RichTextNode, RichTextComponents } from './RichText';
|
|
76
55
|
export { Pagination, getPaginationVariables } from './Pagination';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACxE,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EAAE,YAAY,IAAI,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjE,YAAY,EAAE,iBAAiB,IAAI,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEhF,OAAO,EACL,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACV,0BAA0B,EAC1B,2BAA2B,EAC3B,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACjF,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAGzG,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACxF,YAAY,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAG9E,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEvE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,YAAY,EAAE,iBAAiB,EA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CAAC;AAC7C,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/components/index.js
CHANGED
|
@@ -1,58 +1,42 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @shopbb/helium/components — 商家用 React 组件
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* Money, Image, ProductPrice,
|
|
9
|
-
* AddToCartButton, CartLineQuantityAdjustButton,
|
|
10
|
-
* VariantSelector, ProductOptionsProvider, useProductOptions,
|
|
11
|
-
* Analytics,
|
|
12
|
-
* } from '@shopbb/helium/components';
|
|
13
|
-
*
|
|
14
|
-
* 设计原则:
|
|
15
|
-
* - 无样式:组件只管行为 + 语义化 DOM,样式商家自己写
|
|
16
|
-
* - data-* 钩子:方便选择器
|
|
17
|
-
* - 对齐 Shopify Hydrogen 同名组件的 API,迁移成本低
|
|
18
|
-
* - Provider 链:<ShopProvider> > <CartProvider> > <AnalyticsProvider> > App
|
|
19
|
-
* 组件优先从 Provider 拿;Provider 缺省时回退到 props 或 noop
|
|
4
|
+
* 0.7 起严格对齐 Shopify Hydrogen 设计原则:
|
|
5
|
+
* - 数据流:服务端 loader → useLoaderData → 组件 props(不通过 Provider)
|
|
6
|
+
* - mutation:<CartForm> + RR7 useFetcher(自动 revalidate loader)
|
|
7
|
+
* - 删除 CartProvider / DiscountProvider / AddressBookProvider
|
|
20
8
|
*/
|
|
21
|
-
// Providers + hooks
|
|
9
|
+
// Providers + hooks(保留:仅 Shop / ProductOptions / CartLine / Analytics,对齐 Hydrogen)
|
|
22
10
|
export { ShopProvider, useShop, useShopOptional } from './ShopProvider';
|
|
23
|
-
// Hydrogen-compatible alias: <ShopifyProvider> 在我们叫 <ShopProvider>,提供别名让 Hydrogen 代码无痛迁移
|
|
24
11
|
export { ShopProvider as ShopifyProvider } from './ShopProvider';
|
|
25
|
-
export { CartProvider, useCart, useCartOptional } from './CartProvider';
|
|
26
12
|
export { ProductOptionsProvider, useProductOptions, } from './ProductOptionsProvider';
|
|
27
13
|
export { AnalyticsProvider, useAnalytics, Analytics } from './AnalyticsProvider';
|
|
14
|
+
// CartLine context(Hydrogen 标准:cart line 子组件用 useCartLine 拿当前 line)
|
|
15
|
+
export { CartLineProvider, useCartLine, useCartLineOptional } from './CartLineProvider';
|
|
28
16
|
// 展示型组件
|
|
29
17
|
export { Money } from './Money';
|
|
30
18
|
export { Image } from './Image';
|
|
31
19
|
export { ProductPrice } from './ProductPrice';
|
|
32
|
-
export { AddToCartButton } from './AddToCartButton';
|
|
33
|
-
export { CartLineQuantityAdjustButton } from './CartLineQuantityAdjustButton';
|
|
34
20
|
export { VariantSelector } from './VariantSelector';
|
|
35
|
-
|
|
36
|
-
export {
|
|
21
|
+
export { CartLineQuantity } from './CartLineQuantity';
|
|
22
|
+
export { CartCost } from './CartCost';
|
|
23
|
+
export { CartCheckoutButton } from './CartCheckoutButton';
|
|
24
|
+
// CartForm + useFetcher 透传(Hydrogen 标准)
|
|
25
|
+
export { CartForm, CART_FORM_ACTIONS, useFetcher } from './CartForm';
|
|
26
|
+
// 按钮组件(内部用 CartForm)
|
|
27
|
+
export { AddToCartButton } from './AddToCartButton';
|
|
28
|
+
export { BuyNowButton } from './BuyNowButton';
|
|
29
|
+
// useOptimisticCart — 用 RR7 useFetchers() 实现(对齐 Hydrogen)
|
|
30
|
+
export { useOptimisticCart } from './hooks/useOptimisticCart';
|
|
31
|
+
// useMoney hook
|
|
32
|
+
export { useMoney } from './hooks/useMoney';
|
|
33
|
+
// 地址簿(接 props,不再用 Provider)
|
|
37
34
|
export { AddressList } from './AddressList';
|
|
38
35
|
export { AddressForm } from './AddressForm';
|
|
39
36
|
export { AddressPicker } from './AddressPicker';
|
|
40
|
-
//
|
|
41
|
-
export { DiscountProvider, useDiscounts, useDiscountsOptional, useProductDiscounts, } from './DiscountProvider';
|
|
37
|
+
// 优惠券(接 props,不再用 Provider)
|
|
42
38
|
export { AppliedDiscountList, ClaimableDiscountList, DiscountClaimButton, MyDiscountList, } from './DiscountComponents';
|
|
43
39
|
export { DiscountSelector } from './DiscountSelector';
|
|
44
|
-
// SSR / hydrate 辅助 hook
|
|
45
|
-
export { useMounted } from './hooks/useMounted';
|
|
46
|
-
export { useOptimisticCart } from './hooks/useOptimisticCart';
|
|
47
|
-
export { useMoney } from './hooks/useMoney';
|
|
48
|
-
// CartForm — Hydrogen-compatible form-based cart mutation API
|
|
49
|
-
export { CartForm, CART_FORM_ACTIONS, useFetcher } from './CartForm';
|
|
50
|
-
// Cart line context + 子组件
|
|
51
|
-
export { CartLineProvider, useCartLine, useCartLineOptional } from './CartLineProvider';
|
|
52
|
-
export { CartLineQuantity } from './CartLineQuantity';
|
|
53
|
-
export { CartCost } from './CartCost';
|
|
54
|
-
export { CartCheckoutButton } from './CartCheckoutButton';
|
|
55
|
-
export { BuyNowButton } from './BuyNowButton';
|
|
56
40
|
// Rich text
|
|
57
41
|
export { RichText } from './RichText';
|
|
58
42
|
// Pagination
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,mFAAmF;AACnF,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAExE,OAAO,EAAE,YAAY,IAAI,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGjE,OAAO,EACL,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGjF,oEAAoE;AACpE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAGxF,QAAQ;AACR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B,OAAO;AACP,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -17,8 +17,6 @@ export { createStorefrontClient } from './createStorefrontClient';
|
|
|
17
17
|
export { createCartHandler, DEFAULT_CART_FRAGMENT } from './createCartHandler';
|
|
18
18
|
export { cartGetIdDefault, cartSetIdDefault } from './cart-id';
|
|
19
19
|
export type { CartSetIdOptions } from './cart-id';
|
|
20
|
-
export { handleCartFormAction } from './handleCartFormAction';
|
|
21
|
-
export type { HandleCartFormActionOptions } from './handleCartFormAction';
|
|
22
20
|
export { CacheNone, CacheShort, CacheLong, CacheCustom } from './cache';
|
|
23
21
|
export { createWithCache, InMemoryCache } from './cache/withCache';
|
|
24
22
|
export type { WithCache, WithCacheOptions, CacheKey } from './cache/withCache';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC/D,YAAY,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE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,YAAY,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAG9E,YAAY,EACV,aAAa,EACb,gBAAgB,EAChB,uBAAuB,EACvB,YAAY,EACZ,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,oBAAoB,GACrB,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -16,7 +16,6 @@ export { createHeliumContext } from './createHeliumContext';
|
|
|
16
16
|
export { createStorefrontClient } from './createStorefrontClient';
|
|
17
17
|
export { createCartHandler, DEFAULT_CART_FRAGMENT } from './createCartHandler';
|
|
18
18
|
export { cartGetIdDefault, cartSetIdDefault } from './cart-id';
|
|
19
|
-
export { handleCartFormAction } from './handleCartFormAction';
|
|
20
19
|
export { CacheNone, CacheShort, CacheLong, CacheCustom } from './cache';
|
|
21
20
|
// 服务端工具
|
|
22
21
|
export { createWithCache, InMemoryCache } from './cache/withCache';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE/D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE/D,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAExE,QAAQ;AACR,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,2BAA2B,EAAE,MAAM,wCAAwC,CAAC;AAErF,OAAO,EAAE,2BAA2B,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEzF,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAKhE,KAAK;AACL,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopbb/helium",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "shopbb storefront framework — components, React SSR, GraphQL client, cart handler, cache for Cloudflare Workers",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -49,15 +49,8 @@
|
|
|
49
49
|
"repository": "https://github.com/shopbb/shopbb",
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"react": ">=18",
|
|
52
|
-
"react-dom": ">=18"
|
|
53
|
-
|
|
54
|
-
"peerDependenciesMeta": {
|
|
55
|
-
"react": {
|
|
56
|
-
"optional": true
|
|
57
|
-
},
|
|
58
|
-
"react-dom": {
|
|
59
|
-
"optional": true
|
|
60
|
-
}
|
|
52
|
+
"react-dom": ">=18",
|
|
53
|
+
"react-router": ">=7"
|
|
61
54
|
},
|
|
62
55
|
"devDependencies": {
|
|
63
56
|
"@cloudflare/workers-types": "^4.20240117.0",
|
|
@@ -65,6 +58,7 @@
|
|
|
65
58
|
"@types/react-dom": "^18",
|
|
66
59
|
"react": "^18.3.0",
|
|
67
60
|
"react-dom": "^18.3.0",
|
|
61
|
+
"react-router": "^7.0.0",
|
|
68
62
|
"typescript": "^5.3.3"
|
|
69
63
|
},
|
|
70
64
|
"engines": {
|