@tapcart/mobile-components 0.7.44 → 0.7.46

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.
Files changed (32) hide show
  1. package/dist/components/hooks/use-block-conditional-rendering.d.ts +1 -1
  2. package/dist/components/hooks/use-block-conditional-rendering.d.ts.map +1 -1
  3. package/dist/components/hooks/use-block-conditional-rendering.js +1 -1
  4. package/dist/components/hooks/use-customer.d.ts +10 -0
  5. package/dist/components/hooks/use-customer.d.ts.map +1 -0
  6. package/dist/components/hooks/use-customer.js +24 -0
  7. package/dist/components/hooks/use-mock-cart.d.ts +61 -0
  8. package/dist/components/hooks/use-mock-cart.d.ts.map +1 -0
  9. package/dist/components/hooks/use-mock-cart.js +93 -0
  10. package/dist/components/ui/apple-pay-button.d.ts +29 -0
  11. package/dist/components/ui/apple-pay-button.d.ts.map +1 -0
  12. package/dist/components/ui/apple-pay-button.js +144 -0
  13. package/dist/index.d.ts +3 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +3 -0
  16. package/dist/styles.css +9 -0
  17. package/package.json +3 -1
  18. package/dist/components/ThemeProvider.d.ts +0 -3
  19. package/dist/components/ThemeProvider.d.ts.map +0 -1
  20. package/dist/components/ThemeProvider.js +0 -18
  21. package/dist/components/ThemeToggle.d.ts +0 -2
  22. package/dist/components/ThemeToggle.d.ts.map +0 -1
  23. package/dist/components/ThemeToggle.js +0 -8
  24. package/dist/components/hooks/use-block-conditionals.d.ts +0 -2
  25. package/dist/components/hooks/use-block-conditionals.d.ts.map +0 -1
  26. package/dist/components/hooks/use-block-conditionals.js +0 -2
  27. package/dist/components/ui/input.d.ts +0 -17
  28. package/dist/components/ui/input.d.ts.map +0 -1
  29. package/dist/components/ui/input.js +0 -35
  30. package/dist/components/ui/product-grid.d.ts +0 -15
  31. package/dist/components/ui/product-grid.d.ts.map +0 -1
  32. package/dist/components/ui/product-grid.js +0 -22
@@ -1,5 +1,5 @@
1
1
  import { PhoenixBlock } from "app-studio-types";
2
- export declare const useConditionals: (_props: {
2
+ export declare const useBlockConditionalRendering: (_props: {
3
3
  appId: string;
4
4
  apiUrl: string;
5
5
  }, _block: PhoenixBlock) => {
@@ -1 +1 @@
1
- {"version":3,"file":"use-block-conditional-rendering.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-block-conditional-rendering.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,YAAY,EAGb,MAAM,kBAAkB,CAAA;AAezB,eAAO,MAAM,eAAe,WAClB;IACN,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf,UACO,YAAY;;;CAyJrB,CAAA"}
1
+ {"version":3,"file":"use-block-conditional-rendering.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-block-conditional-rendering.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,YAAY,EAGb,MAAM,kBAAkB,CAAA;AAezB,eAAO,MAAM,4BAA4B,WAC/B;IACN,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf,UACO,YAAY;;;CAyJrB,CAAA"}
@@ -17,7 +17,7 @@ import { useSearchParams } from "next/navigation";
17
17
  //@ts-expect-error
18
18
  import { useVariables } from "@tapcart/webbridge-react";
19
19
  import { gidFromId, countNumberOfTagsInState, getEnvState, shouldShowBlock, } from "../../lib/utils";
20
- export const useConditionals = (_props, _block) => {
20
+ export const useBlockConditionalRendering = (_props, _block) => {
21
21
  var _a, _b, _c, _d, _e, _f;
22
22
  const _g = ((_a = _block === null || _block === void 0 ? void 0 : _block.visibilityConditions) === null || _a === void 0 ? void 0 : _a.conditions) || {}, { enabled: isEnabled = false, exclude: isInverse = false } = _g, restOfProps = __rest(_g, ["enabled", "exclude"]);
23
23
  let shouldShow = true;
@@ -0,0 +1,10 @@
1
+ type Customer = {
2
+ isAuthenticated: boolean;
3
+ };
4
+ type UseCustomerProps = {};
5
+ type UseCustomerReturn = {
6
+ customer: Customer;
7
+ };
8
+ export declare const useCustomer: (props: UseCustomerProps | null) => UseCustomerReturn;
9
+ export {};
10
+ //# sourceMappingURL=use-customer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-customer.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-customer.ts"],"names":[],"mappings":"AAWA,KAAK,QAAQ,GAAG;IACd,eAAe,EAAE,OAAO,CAAA;CACzB,CAAA;AAGD,KAAK,gBAAgB,GAAG,EAAE,CAAA;AAE1B,KAAK,iBAAiB,GAAG;IACvB,QAAQ,EAAE,QAAQ,CAAA;CACnB,CAAA;AAED,eAAO,MAAM,WAAW,UACf,gBAAgB,GAAG,IAAI,KAC7B,iBAuBF,CAAA"}
@@ -0,0 +1,24 @@
1
+ "use client";
2
+ import { useState, useEffect } from "react";
3
+ // @ts-ignore -- webbridge-react is not typed (yet)
4
+ import { useActions } from "@tapcart/webbridge-react";
5
+ export const useCustomer = (props) => {
6
+ const [isAuthenticated, setIsAuthenticated] = useState(false);
7
+ const [customer, setCustomer] = useState({});
8
+ const actions = useActions();
9
+ // verify customer
10
+ useEffect(() => {
11
+ try {
12
+ // webbridge method to get customerIdentity
13
+ actions.getCustomerIdentity(null, {
14
+ onSuccess: (user) => setIsAuthenticated(!!(user === null || user === void 0 ? void 0 : user.email)),
15
+ });
16
+ }
17
+ catch (e) {
18
+ console.log("unable to get customer identity ", e);
19
+ }
20
+ }, [actions]);
21
+ return {
22
+ customer: Object.assign({ isAuthenticated }, customer),
23
+ };
24
+ };
@@ -0,0 +1,61 @@
1
+ import { Product } from "app-studio-types";
2
+ type UseMockCartParams = {
3
+ apiUrl: string;
4
+ appId: string;
5
+ enabled: boolean;
6
+ limit?: number;
7
+ };
8
+ export declare const useMockCart: ({ apiUrl, appId, enabled, limit, }: UseMockCartParams) => {
9
+ error: {
10
+ message: string;
11
+ };
12
+ isLoading: boolean;
13
+ cart: {};
14
+ } | {
15
+ error: any;
16
+ isLoading: boolean;
17
+ cart: {
18
+ subtotal: number;
19
+ items: {
20
+ discounts: Record<string, string | number>[];
21
+ productId: string;
22
+ quantity: number;
23
+ variantId: string;
24
+ productDetails: Product;
25
+ variantDetails: import("app-studio-types").ProductVariant;
26
+ cost: {
27
+ totalAmount: {
28
+ amount: string;
29
+ currencyCode: string;
30
+ };
31
+ };
32
+ sellingPlanAllocation: {
33
+ priceAdjustments: {
34
+ perDeliveryPrice: {
35
+ amount: number;
36
+ currencyCode: string;
37
+ };
38
+ price: {
39
+ amount: number;
40
+ currencyCode: string;
41
+ };
42
+ };
43
+ sellingPlan: {
44
+ id: string;
45
+ name: string;
46
+ recurringDeliveries: boolean;
47
+ };
48
+ } | undefined;
49
+ }[];
50
+ attributes: {
51
+ key: string;
52
+ value: string;
53
+ }[];
54
+ currency: string;
55
+ discounts: string[];
56
+ id: string;
57
+ note: string;
58
+ };
59
+ };
60
+ export {};
61
+ //# sourceMappingURL=use-mock-cart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-mock-cart.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-mock-cart.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAqF1C,KAAK,iBAAiB,GAAG;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,eAAO,MAAM,WAAW,uCAKrB,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BnB,CAAA"}
@@ -0,0 +1,93 @@
1
+ "use client";
2
+ import { getIdFromGid } from "../../lib/utils";
3
+ import { useProducts } from "./use-products";
4
+ const cartMock = {
5
+ attributes: [{ key: "tapcart_id", value: "123" }],
6
+ currency: "USD",
7
+ discounts: ["10_OFF_ORDER"],
8
+ id: "456?key=789",
9
+ items: [],
10
+ note: "this is a mock cart",
11
+ subtotal: 0,
12
+ };
13
+ const transformCart = ({ products, cartOrigin = cartMock, }) => {
14
+ let subtotal = cartOrigin.subtotal;
15
+ const items = products.map((product, i) => {
16
+ const variant = product.variants[0];
17
+ const price = parseInt(variant.price.amount);
18
+ const productId = getIdFromGid(product.id);
19
+ const variantId = getIdFromGid(variant.id);
20
+ const discounts = [];
21
+ const cost = {
22
+ totalAmount: {
23
+ amount: price.toString(),
24
+ currencyCode: "USD",
25
+ },
26
+ };
27
+ subtotal += price;
28
+ let sellingPlanAllocation;
29
+ if (i === 0) {
30
+ const discount = price / 10;
31
+ subtotal -= discount;
32
+ discounts.push({
33
+ amount: parseInt(variant.price.amount) / 10,
34
+ code: "10_OFF_PRODUCT",
35
+ type: "code",
36
+ });
37
+ sellingPlanAllocation = {
38
+ priceAdjustments: {
39
+ perDeliveryPrice: {
40
+ amount: price,
41
+ currencyCode: "USD",
42
+ },
43
+ price: {
44
+ amount: price,
45
+ currencyCode: "USD",
46
+ },
47
+ },
48
+ sellingPlan: {
49
+ id: "gid://shopify/SellingPlan/123",
50
+ name: "Delivery every 30 Days",
51
+ recurringDeliveries: true,
52
+ },
53
+ };
54
+ }
55
+ return {
56
+ discounts,
57
+ productId,
58
+ quantity: 1,
59
+ variantId,
60
+ productDetails: product,
61
+ variantDetails: variant,
62
+ cost,
63
+ sellingPlanAllocation,
64
+ };
65
+ });
66
+ return Object.assign(Object.assign({}, cartOrigin), { subtotal,
67
+ items });
68
+ };
69
+ export const useMockCart = ({ apiUrl, appId, enabled = true, limit = 1, }) => {
70
+ const { products, error: productsError, isLoading: productsLoading, } = useProducts({
71
+ productIds: [],
72
+ productHandles: [],
73
+ baseURL: apiUrl,
74
+ queryVariables: {
75
+ appId,
76
+ limit,
77
+ },
78
+ mock: enabled,
79
+ onlyAvailableProducts: true,
80
+ });
81
+ if (!enabled)
82
+ return {
83
+ error: { message: "cart mock skipped" },
84
+ isLoading: false,
85
+ cart: {},
86
+ };
87
+ const cart = transformCart({ products });
88
+ return {
89
+ error: productsError,
90
+ isLoading: productsLoading,
91
+ cart,
92
+ };
93
+ };
@@ -0,0 +1,29 @@
1
+ /// <reference types="applepayjs" />
2
+ import * as React from "react";
3
+ export type ApplePayButtonType = "plain" | "add-money" | "book" | "buy" | "check-out" | "continue" | "contribute" | "donate" | "order" | "pay" | "reload" | "rent" | "set-up" | "subscribe" | "support" | "tip" | "top-up";
4
+ export type ApplePayButtonStyle = "black" | "white" | "white-outline";
5
+ export interface ApplePayButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
6
+ displayName: string;
7
+ amount: number;
8
+ requiredBillingContactFields?: ApplePayJS.ApplePayContactField[];
9
+ requiredShippingContactFields?: ApplePayJS.ApplePayContactField[];
10
+ startSessionURL: string;
11
+ appId: string;
12
+ domainName: string;
13
+ countryCode?: string;
14
+ currencyCode?: string;
15
+ merchantCapabilities?: ApplePayJS.ApplePayMerchantCapability[];
16
+ supportedNetworks?: string[];
17
+ buttonType?: ApplePayButtonType;
18
+ buttonStyle?: ApplePayButtonStyle;
19
+ onPaymentAuthorized?: (paymentData: ApplePayJS.ApplePayPayment) => Promise<void>;
20
+ onShippingContactSelected?: (shippingContact: ApplePayJS.ApplePayPaymentContact) => Promise<ApplePayJS.ApplePayShippingMethodUpdate>;
21
+ onShippingMethodSelected?: (shippingMethod: ApplePayJS.ApplePayShippingMethod) => ApplePayJS.ApplePayShippingMethodUpdate;
22
+ onPaymentCancelled?: () => void;
23
+ }
24
+ declare const ApplePayButton: {
25
+ ({ displayName, amount, requiredBillingContactFields, requiredShippingContactFields, startSessionURL, appId, domainName, countryCode, currencyCode, merchantCapabilities, supportedNetworks, buttonType, buttonStyle, onPaymentAuthorized, onShippingContactSelected, onShippingMethodSelected, onPaymentCancelled, }: ApplePayButtonProps): import("react/jsx-runtime").JSX.Element;
26
+ displayName: string;
27
+ };
28
+ export { ApplePayButton };
29
+ //# sourceMappingURL=apple-pay-button.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apple-pay-button.d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E,CACzB,cAAc,EAAE,UAAU,CAAC,sBAAsB,KAC9C,UAAU,CAAC,4BAA4B,CAAA;IAC5C,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAA;CAChC;AAED,QAAA,MAAM,cAAc;2TAkBjB,mBAAmB;;CAyLrB,CAAA;AAID,OAAO,EAAE,cAAc,EAAE,CAAA"}
@@ -0,0 +1,144 @@
1
+ "use client";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
+ import * as React from "react";
13
+ import ApplePayButtonComponent from "apple-pay-button";
14
+ const ApplePayButton = ({ displayName, amount, requiredBillingContactFields = ["name", "postalAddress", "phone", "email"], requiredShippingContactFields = ["name", "postalAddress", "phone", "email"], startSessionURL, appId, domainName, countryCode = "US", currencyCode = "USD", merchantCapabilities = ["supports3DS"], supportedNetworks = ["visa", "masterCard", "amex", "discover"], buttonType = "plain", buttonStyle = "white-outline", onPaymentAuthorized, onShippingContactSelected, onShippingMethodSelected, onPaymentCancelled, }) => {
15
+ const [paymentDataResult, setPaymentDataResult] = React.useState("");
16
+ const onClick = () => {
17
+ const applePayRequest = {
18
+ countryCode,
19
+ currencyCode,
20
+ merchantCapabilities,
21
+ supportedNetworks,
22
+ total: {
23
+ label: displayName,
24
+ type: "final",
25
+ amount: amount.toString(),
26
+ },
27
+ requiredShippingContactFields,
28
+ requiredBillingContactFields,
29
+ };
30
+ const session = new ApplePaySession(3, applePayRequest);
31
+ handleEventsForApplePay(session);
32
+ session.begin();
33
+ };
34
+ const defaultFetcher = (url, body) => fetch(url, {
35
+ method: body ? "POST" : "GET",
36
+ headers: {
37
+ "Content-Type": "application/json",
38
+ },
39
+ body: body ? JSON.stringify(body) : undefined,
40
+ }).then((res) => res.json());
41
+ const validateMerchant = (validationURL, appId, domainName, displayName) => __awaiter(void 0, void 0, void 0, function* () {
42
+ let url = startSessionURL;
43
+ let body = {
44
+ validationURL,
45
+ appId,
46
+ domainName,
47
+ displayName,
48
+ };
49
+ console.log("request body", body);
50
+ const response = yield defaultFetcher(url, body);
51
+ return response.data;
52
+ });
53
+ const handleEventsForApplePay = (session) => {
54
+ session.onvalidatemerchant = (event) => __awaiter(void 0, void 0, void 0, function* () {
55
+ const response = yield validateMerchant(event.validationURL, appId, domainName, displayName);
56
+ if (response) {
57
+ session.completeMerchantValidation(response);
58
+ }
59
+ else {
60
+ console.error("Error during validating merchant");
61
+ }
62
+ });
63
+ session.onpaymentmethodselected = (event) => {
64
+ const update = {
65
+ newTotal: {
66
+ label: displayName,
67
+ type: "final",
68
+ amount: amount.toString(),
69
+ },
70
+ };
71
+ session.completePaymentMethodSelection(update);
72
+ };
73
+ session.onshippingmethodselected = (event) => {
74
+ const shippingMethod = event.shippingMethod;
75
+ let update = {
76
+ newTotal: {
77
+ label: displayName,
78
+ type: "final",
79
+ amount: amount.toString(),
80
+ },
81
+ };
82
+ if (onShippingMethodSelected) {
83
+ update = onShippingMethodSelected(shippingMethod);
84
+ }
85
+ session.completeShippingMethodSelection(update);
86
+ };
87
+ session.onshippingcontactselected = (event) => __awaiter(void 0, void 0, void 0, function* () {
88
+ const shippingContact = event.shippingContact;
89
+ let update = {
90
+ newTotal: {
91
+ label: displayName,
92
+ type: "final",
93
+ amount: amount.toString(),
94
+ },
95
+ };
96
+ if (onShippingContactSelected) {
97
+ update = yield onShippingContactSelected(shippingContact);
98
+ }
99
+ session.completeShippingContactSelection(update);
100
+ });
101
+ session.onpaymentauthorized = (event) => __awaiter(void 0, void 0, void 0, function* () {
102
+ const paymentData = event.payment;
103
+ try {
104
+ if (onPaymentAuthorized) {
105
+ yield onPaymentAuthorized(paymentData);
106
+ }
107
+ if (paymentData.token) {
108
+ const paymentDataJson = JSON.stringify(paymentData.token, null, 2);
109
+ console.log("paymentData", paymentDataJson);
110
+ setPaymentDataResult(paymentDataJson);
111
+ const result = {
112
+ status: ApplePaySession.STATUS_SUCCESS,
113
+ };
114
+ session.completePayment(result);
115
+ }
116
+ else {
117
+ const result = {
118
+ status: ApplePaySession.STATUS_FAILURE,
119
+ };
120
+ session.completePayment(result);
121
+ }
122
+ }
123
+ catch (error) {
124
+ console.error("Payment authorization failed:", error);
125
+ const result = {
126
+ status: ApplePaySession.STATUS_FAILURE,
127
+ };
128
+ session.completePayment(result);
129
+ }
130
+ });
131
+ session.oncancel = (event) => {
132
+ if (onPaymentCancelled) {
133
+ onPaymentCancelled();
134
+ }
135
+ console.log("Session Cancelled.");
136
+ };
137
+ };
138
+ return (_jsxs("div", { children: [_jsx("div", Object.assign({ className: "flex flex-row justify-center items-center pt-40" }, { children: _jsx(ApplePayButtonComponent, { onClick: onClick, style: {
139
+ height: "48px",
140
+ borderRadius: "4px",
141
+ }, type: buttonType, buttonStyle: buttonStyle }) })), _jsx("div", Object.assign({ className: "w-100 overflow-auto" }, { children: _jsx("pre", Object.assign({ className: "whitespace-pre-wrap break-words" }, { children: paymentDataResult })) }))] }));
142
+ };
143
+ ApplePayButton.displayName = "ApplePayButton";
144
+ export { ApplePayButton };
package/dist/index.d.ts CHANGED
@@ -10,7 +10,10 @@ export * from "./components/hooks/use-sort-filter";
10
10
  export * from "./components/hooks/use-product-options";
11
11
  export * from "./components/hooks/use-shop";
12
12
  export * from "./components/hooks/use-mock-products";
13
+ export * from "./components/hooks/use-block-conditional-rendering";
14
+ export * from "./components/hooks/use-mock-cart";
13
15
  export * from "./components/ui/accordion";
16
+ export * from "./components/ui/apple-pay-button";
14
17
  export * from "./components/ui/aspect-ratio";
15
18
  export * from "./components/ui/badge";
16
19
  export * from "./components/ui/button";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,EAAE,EACF,GAAG,EACH,QAAQ,EACR,4BAA4B,EAC5B,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,yBAAyB,EACzB,4BAA4B,EAC5B,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,4BAA4B,EAC5B,eAAe,EACf,cAAc,EACd,SAAS,EACT,4BAA4B,GAC7B,MAAM,aAAa,CAAA;AACpB,cAAc,2CAA2C,CAAA;AACzD,cAAc,mCAAmC,CAAA;AACjD,cAAc,wCAAwC,CAAA;AACtD,cAAc,wCAAwC,CAAA;AACtD,cAAc,iCAAiC,CAAA;AAC/C,cAAc,sCAAsC,CAAA;AACpD,cAAc,yCAAyC,CAAA;AACvD,cAAc,oCAAoC,CAAA;AAClD,cAAc,wCAAwC,CAAA;AACtD,cAAc,6BAA6B,CAAA;AAC3C,cAAc,sCAAsC,CAAA;AACpD,cAAc,2BAA2B,CAAA;AACzC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA;AACtC,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA;AACxC,cAAc,sBAAsB,CAAA;AACpC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,2BAA2B,CAAA;AACzC,cAAc,wBAAwB,CAAA;AACtC,cAAc,0BAA0B,CAAA;AACxC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,0BAA0B,CAAA;AACxC,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA;AACpC,c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AA;AAC5C,cAAc,iCAAiC,CAAA;AAC/C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,2BAA2B,CAAA;AACzC,cAAc,2BAA2B,CAAA;AACzC,cAAc,0BAA0B,CAAA;AACxC,cAAc,wBAAwB,CAAA;AACtC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,8BAA8B,CAAA;AAC5C,cAAc,wBAAwB,CAAA;AACtC,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA;AACpC,cAAc,0BAA0B,CAAA;AACxC,cAAc,uBAAuB,CAAA;AACrC,cAAc,yBAAyB,CAAA;AACvC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,wBAAwB,CAAA;AACtC,cAAc,2BAA2B,CAAA;AACzC,cAAc,uBAAuB,CAAA;AACrC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,0BAA0B,CAAA;AACxC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,sBAAsB,CAAA;AACpC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,kDAAkD,CAAA;AAChE,cAAc,gCAAgC,CAAA;AAC9C,cAAc,oCAAoC,CAAA;AAClD,cAAc,mCAAmC,CAAA;AACjD,cAAc,aAAa,CAAA;AAC3B,cAAc,6CAA6C,CAAA;AAC3D,cAAc,kDAAkD,CAAA;AAChE,cAAc,qBAAqB,CAAA"}
package/dist/index.js CHANGED
@@ -11,7 +11,10 @@ export * from "./components/hooks/use-sort-filter";
11
11
  export * from "./components/hooks/use-product-options";
12
12
  export * from "./components/hooks/use-shop";
13
13
  export * from "./components/hooks/use-mock-products";
14
+ export * from "./components/hooks/use-block-conditional-rendering";
15
+ export * from "./components/hooks/use-mock-cart";
14
16
  export * from "./components/ui/accordion";
17
+ export * from "./components/ui/apple-pay-button";
15
18
  export * from "./components/ui/aspect-ratio";
16
19
  export * from "./components/ui/badge";
17
20
  export * from "./components/ui/button";
package/dist/styles.css CHANGED
@@ -1373,6 +1373,9 @@ video {
1373
1373
  .self-center {
1374
1374
  align-self: center;
1375
1375
  }
1376
+ .overflow-auto {
1377
+ overflow: auto;
1378
+ }
1376
1379
  .overflow-hidden {
1377
1380
  overflow: hidden;
1378
1381
  }
@@ -1399,6 +1402,9 @@ video {
1399
1402
  .whitespace-nowrap {
1400
1403
  white-space: nowrap;
1401
1404
  }
1405
+ .whitespace-pre-wrap {
1406
+ white-space: pre-wrap;
1407
+ }
1402
1408
  .break-words {
1403
1409
  overflow-wrap: break-word;
1404
1410
  }
@@ -1758,6 +1764,9 @@ video {
1758
1764
  .pt-4 {
1759
1765
  padding-top: 1rem;
1760
1766
  }
1767
+ .pt-40 {
1768
+ padding-top: 10rem;
1769
+ }
1761
1770
  .pt-5 {
1762
1771
  padding-top: 1.25rem;
1763
1772
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapcart/mobile-components",
3
- "version": "0.7.44",
3
+ "version": "0.7.46",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "style": "dist/styles.css",
@@ -29,6 +29,7 @@
29
29
  "react-dom": "^17.0.2 || ^18.0.0"
30
30
  },
31
31
  "devDependencies": {
32
+ "@types/applepayjs": "^14.0.9",
32
33
  "@types/jest": "^29.5.14",
33
34
  "@types/lodash": "4.17.5",
34
35
  "@types/react": "^18.2.0",
@@ -69,6 +70,7 @@
69
70
  "@radix-ui/react-toggle-group": "^1.0.4",
70
71
  "@tabler/icons-react": "^3.2.0",
71
72
  "@tapcart/webbridge-react": "^1.13.0",
73
+ "apple-pay-button": "^1.1.7",
72
74
  "class-variance-authority": "^0.6.0",
73
75
  "clsx": "^1.2.1",
74
76
  "dayjs": "^1.11.13",
@@ -1,3 +0,0 @@
1
- import { ThemeProviderProps } from "next-themes/dist/types";
2
- export declare function ThemeProvider({ children, ...props }: ThemeProviderProps): import("react/jsx-runtime").JSX.Element;
3
- //# sourceMappingURL=ThemeProvider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../../components/ThemeProvider.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAE3D,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,kBAAkB,2CAEvE"}
@@ -1,18 +0,0 @@
1
- "use client";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
- import { jsx as _jsx } from "react/jsx-runtime";
14
- import { ThemeProvider as NextThemesProvider } from "next-themes";
15
- export function ThemeProvider(_a) {
16
- var { children } = _a, props = __rest(_a, ["children"]);
17
- return _jsx(NextThemesProvider, Object.assign({}, props, { children: children }));
18
- }
@@ -1,2 +0,0 @@
1
- export declare function ThemeToggle(): import("react/jsx-runtime").JSX.Element;
2
- //# sourceMappingURL=ThemeToggle.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ThemeToggle.d.ts","sourceRoot":"","sources":["../../components/ThemeToggle.tsx"],"names":[],"mappings":"AAOA,wBAAgB,WAAW,4CAc1B"}
@@ -1,8 +0,0 @@
1
- "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useTheme } from "next-themes";
4
- import { Button } from "../components/ui/button";
5
- export function ThemeToggle() {
6
- const { setTheme, theme } = useTheme();
7
- return (_jsxs(Button, Object.assign({ variant: "ghost", size: "sm", onClick: () => setTheme(theme === "light" ? "dark" : "light") }, { children: [_jsx("div", { className: "rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" }), _jsx("div", { className: "absolute rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" }), _jsx("span", Object.assign({ className: "sr-only" }, { children: "Toggle theme" }))] })));
8
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=use-block-conditionals.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-block-conditionals.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-block-conditionals.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- "use client";
2
- export {};
@@ -1,17 +0,0 @@
1
- import * as React from "react";
2
- import { type VariantProps } from "class-variance-authority";
3
- declare const inputVariants: (props?: ({
4
- error?: boolean | null | undefined;
5
- } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
6
- export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange">, VariantProps<typeof inputVariants> {
7
- id: string;
8
- label?: string;
9
- icon?: string;
10
- asChild?: boolean;
11
- value: string;
12
- placeholder: string;
13
- onChange: (_: string) => void;
14
- }
15
- declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
16
- export { Input };
17
- //# sourceMappingURL=input.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../components/ui/input.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAIjE,QAAA,MAAM,aAAa;;mFAalB,CAAA;AAED,MAAM,WAAW,UACf,SAAQ,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,UAAU,CAAC,EACnE,YAAY,CAAC,OAAO,aAAa,CAAC;IACpC,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;CAC9B;AAED,QAAA,MAAM,KAAK,qFAkDV,CAAA;AAGD,OAAO,EAAE,KAAK,EAAE,CAAA"}
@@ -1,35 +0,0 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
- import * as React from "react";
14
- import { Slot } from "@radix-ui/react-slot";
15
- import { cva } from "class-variance-authority";
16
- import { cn } from "../../lib/utils";
17
- import { Icon } from "./icon";
18
- const inputVariants = cva("flex h-14 w-full rounded border border-coreColors-dividingLines bg-coreColors-inputBackground px-4 pt-5 pb-2 placeholder-shown:p-4 text-textColors-primaryColor text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-textColors-secondaryColor focus-visible:outline-none focus-visible:ring-0 disabled:cursor-not-allowed disabled:opacity-50 focus:border-coreColors-brandColorPrimary peer data-[icon=true]:pr-10", {
19
- variants: {
20
- error: {
21
- true: "border-stateColors-error text-stateColors-error placeholder:text-stateColors-error focus:border-stateColors-error [&+label]:text-stateColors-error",
22
- false: "",
23
- },
24
- },
25
- defaultVariants: {
26
- error: false,
27
- },
28
- });
29
- const Input = React.forwardRef((_a, ref) => {
30
- var { className, error = false, id, type, label, icon, asChild, value, placeholder, onChange } = _a, props = __rest(_a, ["className", "error", "id", "type", "label", "icon", "asChild", "value", "placeholder", "onChange"]);
31
- const Comp = asChild ? Slot : "div";
32
- return (_jsxs(Comp, Object.assign({ className: "relative group" }, { children: [_jsx("input", Object.assign({ placeholder: placeholder, value: value, onChange: (e) => onChange(e.target.value), id: id, type: type, className: cn(inputVariants({ error }), className), "data-icon": !!icon, ref: ref }, props)), label ? (_jsx("label", Object.assign({ htmlFor: id, className: "absolute text-[10px] text-textColors-secondaryColor group-active:text-coreColors-brandColorPrimary top-2 z-10 h-4 origin-[0] start-4 opacity-100 peer-placeholder-shown:opacity-0" }, { children: label }))) : null, icon ? (_jsx(Icon, { name: icon, "data-error": error, size: "sm", className: "absolute w-5 aspect-square fill-current text-textColors-secondaryColor top-[18px] z-10 origin-[0] end-4 peer-pr-8 icon data-[error=true]:text-stateColors-error" })) : null] })));
33
- });
34
- Input.displayName = "Input";
35
- export { Input };
@@ -1,15 +0,0 @@
1
- type Product = any;
2
- interface PageData {
3
- products: Product[];
4
- cursorBlob?: string;
5
- filtersData: any;
6
- }
7
- interface ProductGridItemsProps {
8
- initialData: PageData;
9
- loadMoreProducts: (params: any) => Promise<PageData>;
10
- queryVariables: Record<string, any>;
11
- config: Record<string, any>;
12
- }
13
- declare function ProductGrid({ loadMoreProducts, initialData, queryVariables, config, }: ProductGridItemsProps): import("react/jsx-runtime").JSX.Element;
14
- export { ProductGrid };
15
- //# sourceMappingURL=product-grid.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"product-grid.d.ts","sourceRoot":"","sources":["../../../components/ui/product-grid.tsx"],"names":[],"mappings":"AAkBA,KAAK,OAAO,GAAG,GAAG,CAAA;AAClB,UAAU,QAAQ;IAChB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,GAAG,CAAA;CACjB;AAED,UAAU,qBAAqB;IAC7B,WAAW,EAAE,QAAQ,CAAA;IACrB,gBAAgB,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;IACpD,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAC5B;AAED,iBAAS,WAAW,CAAC,EACnB,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,MAAM,GACP,EAAE,qBAAqB,2CAmCvB;AAED,OAAO,EAAE,WAAW,EAAE,CAAA"}
@@ -1,22 +0,0 @@
1
- "use client";
2
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useInfiniteScroll } from "../hooks/use-infinite-scroll";
4
- import { ProductCard } from "./product-card";
5
- const Loader = () => (_jsx("div", Object.assign({ className: "grid-cols-2 lg:grid-cols-3" }, { children: Array(4)
6
- .fill(0)
7
- .map((_, index) => (_jsx("div", { className: "aspect-[2/3] animate-pulse bg-neutral-100 dark:bg-neutral-900" }, index))) })));
8
- function ProductGrid({ loadMoreProducts, initialData, queryVariables, config, }) {
9
- const { data, error, isLoadingInitialData, isLoadingMore, isEmpty, isReachingEnd, ref, products, } = useInfiniteScroll({
10
- initialData,
11
- loadMoreProducts,
12
- queryVariables,
13
- });
14
- if (error)
15
- return _jsx("div", { children: "Failed to load data" });
16
- if (isLoadingInitialData)
17
- return _jsx(Loader, {});
18
- return (_jsxs(_Fragment, { children: [_jsx("div", Object.assign({ className: "grid-cols-2 lg:grid-cols-3" }, { children: products.map((product, i) => (_jsx(ProductCard, {
19
- // @ts-expect-error
20
- product: product, config: config, isLoading: false }, product.handle))) })), isLoadingMore ? _jsx(Loader, {}) : _jsx("div", { ref: ref })] }));
21
- }
22
- export { ProductGrid };