@tapcart/mobile-components 0.8.24 → 0.8.26
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/hooks/use-collection.d.ts +3 -1
- package/dist/components/hooks/use-collection.d.ts.map +1 -1
- package/dist/components/hooks/use-collection.js +20 -2
- package/dist/components/libs/loyalty/YotpoLoyalty.d.ts.map +1 -1
- package/dist/components/libs/loyalty/YotpoLoyalty.js +20 -1
- package/dist/components/ui/button.d.ts.map +1 -1
- package/dist/components/ui/button.js +5 -1
- package/package.json +1 -1
|
@@ -8,11 +8,13 @@ interface UseCollectionProps {
|
|
|
8
8
|
language: string;
|
|
9
9
|
getCollections?: boolean;
|
|
10
10
|
limit?: number;
|
|
11
|
+
fetchMaxProduct?: boolean;
|
|
11
12
|
metafields?: string;
|
|
12
13
|
}
|
|
13
|
-
export declare const useCollection: ({ apiUrl, appId, collectionId, collectionHandle, collectionIdList, language, limit, getCollections, metafields, }: UseCollectionProps) => {
|
|
14
|
+
export declare const useCollection: ({ apiUrl, appId, collectionId, collectionHandle, collectionIdList, language, limit, getCollections, metafields, fetchMaxProduct, }: UseCollectionProps) => {
|
|
14
15
|
collections: Collection[];
|
|
15
16
|
specificCollection: Collection | null;
|
|
17
|
+
maxProductCollection: Collection | null;
|
|
16
18
|
loading: boolean;
|
|
17
19
|
error: string | null;
|
|
18
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-collection.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-collection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAG7C,UAAU,kBAAkB;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;
|
|
1
|
+
{"version":3,"file":"use-collection.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-collection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAG7C,UAAU,kBAAkB;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AA2GD,eAAO,MAAM,aAAa,uIAWvB,kBAAkB;;;;;;CA8EpB,CAAA"}
|
|
@@ -43,14 +43,26 @@ const fetchAllCollections = (apiUrl, setError, limit = 100) => __awaiter(void 0,
|
|
|
43
43
|
}).toString();
|
|
44
44
|
return yield fetchWrapper(`${apiUrl}/collections/by-app-id?${limitParam}`, setError);
|
|
45
45
|
});
|
|
46
|
-
|
|
46
|
+
const fetchCollectionWithMaxProduct = (apiUrl, setError, limit = 100) => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
+
const params = new URLSearchParams({
|
|
48
|
+
limit: `${limit}`,
|
|
49
|
+
fetchMaxProduct: "true",
|
|
50
|
+
}).toString();
|
|
51
|
+
return yield fetchWrapper(`${apiUrl}/collections/by-app-id?${params}`, setError);
|
|
52
|
+
});
|
|
53
|
+
export const useCollection = ({ apiUrl, appId, collectionId, collectionHandle, collectionIdList, language, limit = 100, getCollections = false, metafields, fetchMaxProduct = false, }) => {
|
|
47
54
|
const [collections, setCollections] = useState([]);
|
|
48
55
|
const [specificCollection, setSpecificCollection] = useState(null);
|
|
56
|
+
const [maxProductCollection, setMaxProductCollection] = useState(null);
|
|
49
57
|
const [loading, setLoading] = useState(true);
|
|
50
58
|
const [error, setError] = useState(null);
|
|
51
59
|
useEffect(() => {
|
|
52
60
|
const fetchAllOrSumCollections = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
61
|
try {
|
|
62
|
+
if (fetchMaxProduct) {
|
|
63
|
+
const collection = yield fetchCollectionWithMaxProduct(apiUrl, setError, limit);
|
|
64
|
+
return setMaxProductCollection(collection);
|
|
65
|
+
}
|
|
54
66
|
if (getCollections) {
|
|
55
67
|
const collections = yield fetchAllCollections(apiUrl, setError, limit);
|
|
56
68
|
return setCollections(collections !== null && collections !== void 0 ? collections : []);
|
|
@@ -85,5 +97,11 @@ export const useCollection = ({ apiUrl, appId, collectionId, collectionHandle, c
|
|
|
85
97
|
collectionIdList,
|
|
86
98
|
metafields,
|
|
87
99
|
]);
|
|
88
|
-
return {
|
|
100
|
+
return {
|
|
101
|
+
collections,
|
|
102
|
+
specificCollection,
|
|
103
|
+
maxProductCollection,
|
|
104
|
+
loading,
|
|
105
|
+
error,
|
|
106
|
+
};
|
|
89
107
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YotpoLoyalty.d.ts","sourceRoot":"","sources":["../../../../components/libs/loyalty/YotpoLoyalty.tsx"],"names":[],"mappings":"AAAA,OAAO,cAAc,EAAE,EACrB,eAAe,EACf,aAAa,EACb,aAAa,EACb,eAAe,EACf,WAAW,EACX,eAAe,EAChB,MAAM,kBAAkB,CAAA;AAEzB,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,cAAc;IACtD,OAAO,EAAE,MAAM,CAAU;;IAOnB,cAAc,IAAI,OAAO,CAAC,eAAe,CAAC;IAa1C,WAAW,IAAI,OAAO,CAAC,eAAe,CAAC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GAAG,IAAI,CAAC;IAyBnD,kBAAkB,IAAI,OAAO,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC;IAqCvD,eAAe,IAAI,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IA2B9C,QAAQ,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAsDlC,cAAc,IAAI,OAAO,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC;IAiCnD,YAAY,IAAI,OAAO,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC;CAqBxD"}
|
|
@@ -340,7 +340,7 @@ export default class YotpoLoyalty extends LoyaltyAdapter {
|
|
|
340
340
|
});
|
|
341
341
|
}
|
|
342
342
|
getActivityHistory() {
|
|
343
|
-
var _a;
|
|
343
|
+
var _a, _b, _c;
|
|
344
344
|
return __awaiter(this, void 0, void 0, function* () {
|
|
345
345
|
if (!this.customer) {
|
|
346
346
|
console.error("No customer found");
|
|
@@ -350,12 +350,31 @@ export default class YotpoLoyalty extends LoyaltyAdapter {
|
|
|
350
350
|
return [
|
|
351
351
|
{
|
|
352
352
|
id: "activity-3",
|
|
353
|
+
title: "Made a purchase",
|
|
353
354
|
type: "purchase",
|
|
354
355
|
points: 100,
|
|
355
356
|
customerId: (_a = this.customer) === null || _a === void 0 ? void 0 : _a.id,
|
|
356
357
|
status: "completed",
|
|
357
358
|
createdAt: new Date(),
|
|
358
359
|
},
|
|
360
|
+
{
|
|
361
|
+
id: "activity-1",
|
|
362
|
+
title: "Free shipping",
|
|
363
|
+
type: "redeem",
|
|
364
|
+
points: -1500,
|
|
365
|
+
customerId: (_b = this.customer) === null || _b === void 0 ? void 0 : _b.id,
|
|
366
|
+
status: "completed",
|
|
367
|
+
createdAt: new Date(),
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
id: "activity-2",
|
|
371
|
+
title: "Free product",
|
|
372
|
+
type: "redeem",
|
|
373
|
+
points: -1500,
|
|
374
|
+
customerId: (_c = this.customer) === null || _c === void 0 ? void 0 : _c.id,
|
|
375
|
+
status: "pending",
|
|
376
|
+
createdAt: new Date(),
|
|
377
|
+
},
|
|
359
378
|
];
|
|
360
379
|
}
|
|
361
380
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../components/ui/button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAGL,KAAK,EAEL,SAAS,EAET,oBAAoB,EACrB,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../components/ui/button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAGL,KAAK,EAEL,SAAS,EAET,oBAAoB,EACrB,MAAM,iBAAiB,CAAA;AAMxB,QAAA,MAAM,cAAc;;;mFAgCnB,CAAA;AAwCD,MAAM,WAAW,WACf,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EACnD,YAAY,CAAC,OAAO,cAAc,CAAC;IACrC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,UAAU,CAAC,EAAE,KAAK,CAAC,aAAa,GAAG,SAAS,CAAA;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,CAAA;IACvD,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IAC/B,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAA;CAC9D;AAED,QAAA,MAAM,MAAM,uFA0GX,CAAA;AAGD,QAAA,MAAM,cAAc,iBACJ,SAAS,GACrB,oBAAoB,GAAG;IACrB,SAAS,EAAE,KAAK,CAAA;IAChB,WAAW,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;IAC5B,gBAAgB,EAAE,OAAO,CAAA;CAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkBJ,CAAA;AAED,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -16,6 +16,8 @@ import { cva } from "class-variance-authority";
|
|
|
16
16
|
import { cn, getColor, getTextStyle, getBackgroundAndPaddingStyle, } from "../../lib/utils";
|
|
17
17
|
import { Icon } from "./icon";
|
|
18
18
|
import { Text } from "./text";
|
|
19
|
+
import { useTap } from "./tap";
|
|
20
|
+
import { useMergeRefs } from "../hooks/use-merge-refs";
|
|
19
21
|
const buttonVariants = cva("w-full flex rounded items-center justify-center transition-colors disabled:bg-stateColors-disabled disabled:border-stateColors-disabled disabled:pointer-events-none ring-offset-background overflow-elipse whitespace-nowrap truncate disabled:opacity-70 cursor-pointer", {
|
|
20
22
|
variants: {
|
|
21
23
|
size: {
|
|
@@ -80,6 +82,8 @@ const labelVariants = cva("truncate", {
|
|
|
80
82
|
});
|
|
81
83
|
const Button = React.forwardRef((_a, ref) => {
|
|
82
84
|
var { className, labelClassName, labelStyle, variant, size, asChild = false, loading, icon, iconColor, iconStrokeColor, iconPosition, iconSize, iconUrl, iconClassName, onClick } = _a, props = __rest(_a, ["className", "labelClassName", "labelStyle", "variant", "size", "asChild", "loading", "icon", "iconColor", "iconStrokeColor", "iconPosition", "iconSize", "iconUrl", "iconClassName", "onClick"]);
|
|
85
|
+
const { onTap, isPressed, ref: tapRef } = useTap();
|
|
86
|
+
const mergedRef = useMergeRefs(ref, tapRef);
|
|
83
87
|
const Comp = asChild ? Slot : "button";
|
|
84
88
|
const IconButton = () => icon || iconUrl ? (_jsx(Icon, { name: icon, url: iconUrl, size: "sm", style: { color: iconColor } })) : null;
|
|
85
89
|
// TODO: need to refactor icon sizing. This isnt extensible.
|
|
@@ -91,7 +95,7 @@ const Button = React.forwardRef((_a, ref) => {
|
|
|
91
95
|
return (_jsx(Comp, Object.assign({ className: cn(buttonVariants({ variant, size }), className, {
|
|
92
96
|
"pointer-events-none": loading,
|
|
93
97
|
"flex-row-reverse": (icon || iconUrl) && iconPosition === "right",
|
|
94
|
-
}), ref:
|
|
98
|
+
}), ref: mergedRef, onClick: onTap(onClick) }, props, { children: loading ? (_jsx(LoadingButton, {})) : typeof props.children === "object" &&
|
|
95
99
|
React.isValidElement(props.children) ? ( // if children are passed as a valid React element
|
|
96
100
|
props.children // render it
|
|
97
101
|
) : // otherwise use props
|