@tapcart/mobile-components 0.7.29 → 0.7.30

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.
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ export declare function useClickOutside(ref: React.RefObject<HTMLElement>, callback: () => void): void;
3
+ //# sourceMappingURL=use-click-outside.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-click-outside.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-click-outside.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,wBAAgB,eAAe,CAAC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAE,IAAI,CAa5F"}
@@ -0,0 +1,16 @@
1
+ "use client";
2
+ import React from 'react';
3
+ export function useClickOutside(ref, callback) {
4
+ React.useEffect(() => {
5
+ const handleClickOutside = (event) => {
6
+ if (ref.current && !ref.current.contains(event.target)) {
7
+ callback();
8
+ }
9
+ };
10
+ document.addEventListener('mousedown', handleClickOutside);
11
+ return () => {
12
+ document.removeEventListener('mousedown', handleClickOutside);
13
+ };
14
+ }, [ref, callback]);
15
+ }
16
+ ;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ declare const useClickOutside: (ref: React.RefObject<HTMLElement>, callback: () => void) => void;
3
+ export default useClickOutside;
4
+ //# sourceMappingURL=use-outside-click.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-outside-click.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-outside-click.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,QAAA,MAAM,eAAe,QAAS,MAAM,SAAS,CAAC,WAAW,CAAC,YAAY,MAAM,IAAI,SAa/E,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -0,0 +1,16 @@
1
+ "use client";
2
+ import React from 'react';
3
+ const useClickOutside = (ref, callback) => {
4
+ React.useEffect(() => {
5
+ const handleClickOutside = (event) => {
6
+ if (ref.current && !ref.current.contains(event.target)) {
7
+ callback();
8
+ }
9
+ };
10
+ document.addEventListener('mousedown', handleClickOutside);
11
+ return () => {
12
+ document.removeEventListener('mousedown', handleClickOutside);
13
+ };
14
+ }, [ref, callback]);
15
+ };
16
+ export default useClickOutside;
@@ -1 +1 @@
1
- {"version":3,"file":"use-recommendations.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-recommendations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAKtD,UAAU,sBAAsB;IAC9B,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACnC,MAAM,EAAE,MAAM,CAAA;CACf;AAED,UAAU,uBAAuB;IAC/B,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,WAAW,EAAE,UAAU,EAAE,CAAA;IACzB,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,SAAS,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE,GAAG,CAAA;CACX;AAOD,QAAA,MAAM,kBAAkB,+BAGrB,sBAAsB,KAAG,uBAgC3B,CAAA;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAA"}
1
+ {"version":3,"file":"use-recommendations.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-recommendations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAKtD,UAAU,sBAAsB;IAC9B,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACnC,MAAM,EAAE,MAAM,CAAA;CACf;AAED,UAAU,uBAAuB;IAC/B,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,WAAW,EAAE,UAAU,EAAE,CAAA;IACzB,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,SAAS,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE,GAAG,CAAA;CACX;AAOD,QAAA,MAAM,kBAAkB,+BAGrB,sBAAsB,KAAG,uBAkC3B,CAAA;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAA"}
@@ -6,6 +6,7 @@ const constructURL = (apiURL) => {
6
6
  return url.toString();
7
7
  };
8
8
  const useRecommendations = ({ queryVariables, apiURL }) => {
9
+ var _a;
9
10
  const searchParams = useSearchParams();
10
11
  const recommendation = (searchParams === null || searchParams === void 0 ? void 0 : searchParams.get('recommendation')) || "*";
11
12
  const fetcher = (body) => fetch(constructURL(apiURL), {
@@ -20,9 +21,10 @@ const useRecommendations = ({ queryVariables, apiURL }) => {
20
21
  revalidateOnFocus: false,
21
22
  revalidateOnReconnect: false,
22
23
  });
24
+ const collections = (_a = data === null || data === void 0 ? void 0 : data.collections) === null || _a === void 0 ? void 0 : _a.filter((obj) => obj.handle !== 'empty-collection');
23
25
  return {
24
26
  products: data === null || data === void 0 ? void 0 : data.products,
25
- collections: data === null || data === void 0 ? void 0 : data.collections,
27
+ collections: recommendation === "*" ? [] : collections,
26
28
  searches: data === null || data === void 0 ? void 0 : data.searches,
27
29
  isLoading: isLoading,
28
30
  error: error
@@ -7,7 +7,7 @@ function Price({ price, priceHigh, priceRanges = false, isSale = false, compareA
7
7
  const ProductPrice = () => {
8
8
  const priceStyles = (!isSale || !compareAtPrice) ? standardStyles : saleStyles;
9
9
  const colorClass = isSale ? 'text-textColors-salePriceText' : 'text-textColors-priceText';
10
- return (_jsx(Text, Object.assign({ className: `${colorClass} flex-shrink-0 w-full`, style: { fontSize: `${fontSize}px` } }, { children: _jsxs("span", Object.assign({ className: "flex-grow min-w-[fit-content] break-all" }, { children: [_jsx(Money, { price: price, currency: currency, locale: locale, styles: priceStyles, hideZeroCents: hideZeroCents }), priceRanges && priceHigh !== undefined && _jsx(Spacer, {}), priceRanges && priceHigh !== undefined && (_jsx(Money, { price: priceHigh, currency: currency, locale: locale, styles: priceStyles, hideZeroCents: hideZeroCents }))] })) })));
10
+ return (_jsx(Text, Object.assign({ className: `${colorClass} flex-shrink-0 max-w-full`, style: { fontSize: `${fontSize}px` } }, { children: _jsxs("span", Object.assign({ className: "flex-grow min-w-[fit-content] break-all" }, { children: [_jsx(Money, { price: price, currency: currency, locale: locale, styles: priceStyles, hideZeroCents: hideZeroCents }), priceRanges && priceHigh !== undefined && _jsx(Spacer, {}), priceRanges && priceHigh !== undefined && (_jsx(Money, { price: priceHigh, currency: currency, locale: locale, styles: priceStyles, hideZeroCents: hideZeroCents }))] })) })));
11
11
  };
12
12
  const StrikeThroughPrice = () => {
13
13
  if (!isSale || !compareAtPrice)
package/dist/styles.css CHANGED
@@ -828,6 +828,9 @@ video {
828
828
  .mb-3 {
829
829
  margin-bottom: 0.75rem;
830
830
  }
831
+ .mb-4 {
832
+ margin-bottom: 1rem;
833
+ }
831
834
  .mb-6 {
832
835
  margin-bottom: 1.5rem;
833
836
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapcart/mobile-components",
3
- "version": "0.7.29",
3
+ "version": "0.7.30",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "style": "dist/styles.css",
@@ -11,18 +11,6 @@
11
11
  "license": "SEE LICENSE IN LICENSE.md",
12
12
  "author": "Tapcart Inc.",
13
13
  "homepage": "https://tapcart.com",
14
- "scripts": {
15
- "lint": "eslint \"**/*.ts*\"",
16
- "ui:add": "pnpm dlx shadcn-ui@latest add",
17
- "build:styles": "postcss styles/globals.css -o dist/styles.css",
18
- "build:ts": "tsc -p tsconfig.json && tsc-alias",
19
- "build": "pnpm run build:ts && pnpm run build:styles",
20
- "dev:ts": "tsc -w -p tsconfig.json",
21
- "dev:styles": "npx tailwindcss -i styles/globals.css -o dist/styles.css --watch",
22
- "dev": "concurrently \"pnpm run dev:ts\" \"pnpm run dev:styles\"",
23
- "test": "jest",
24
- "test:watch": "jest --watch"
25
- },
26
14
  "peerDependencies": {
27
15
  "react": "^17.0.2 || ^18.0.0",
28
16
  "react-dom": "^17.0.2 || ^18.0.0"
@@ -32,21 +20,21 @@
32
20
  "@types/lodash": "4.17.5",
33
21
  "@types/react": "^18.2.0",
34
22
  "@types/react-dom": "^18.2.0",
35
- "app-studio-types": "workspace:*",
36
23
  "autoprefixer": "^10.4.14",
37
24
  "chokidar-cli": "^3.0.0",
38
25
  "concurrently": "^8.2.2",
39
26
  "eslint": "^7.32.0",
40
- "eslint-config-custom": "workspace:*",
41
27
  "jest": "^29.7.0",
42
28
  "jest-environment-jsdom": "^29.7.0",
43
29
  "postcss": "^8.4.24",
44
30
  "tailwindcss": "^3.3.2",
45
31
  "ts-jest": "^29.2.5",
46
32
  "tsc-alias": "^1.8.10",
47
- "tsconfig": "workspace:*",
48
33
  "typescript": "^4.5.2",
49
- "@testing-library/react-hooks": "^8.0.1"
34
+ "@testing-library/react-hooks": "^8.0.1",
35
+ "app-studio-types": "0.0.5",
36
+ "eslint-config-custom": "0.0.0",
37
+ "tsconfig": "0.0.0"
50
38
  },
51
39
  "dependencies": {
52
40
  "@radix-ui/react-accordion": "^1.1.2",
@@ -83,5 +71,17 @@
83
71
  "tailwind-merge": "^1.13.2",
84
72
  "tailwindcss-animate": "^1.0.6",
85
73
  "vaul": "0.9.1"
74
+ },
75
+ "scripts": {
76
+ "lint": "eslint \"**/*.ts*\"",
77
+ "ui:add": "pnpm dlx shadcn-ui@latest add",
78
+ "build:styles": "postcss styles/globals.css -o dist/styles.css",
79
+ "build:ts": "tsc -p tsconfig.json && tsc-alias",
80
+ "build": "pnpm run build:ts && pnpm run build:styles",
81
+ "dev:ts": "tsc -w -p tsconfig.json",
82
+ "dev:styles": "npx tailwindcss -i styles/globals.css -o dist/styles.css --watch",
83
+ "dev": "concurrently \"pnpm run dev:ts\" \"pnpm run dev:styles\"",
84
+ "test": "jest",
85
+ "test:watch": "jest --watch"
86
86
  }
87
- }
87
+ }
@@ -1,10 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,24 +0,0 @@
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
- };
@@ -1,24 +0,0 @@
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
- startSessionURL: string;
9
- appId: string;
10
- domainName: string;
11
- countryCode?: string;
12
- currencyCode?: string;
13
- merchantCapabilities?: ApplePayJS.ApplePayMerchantCapability[];
14
- supportedNetworks?: string[];
15
- buttonType?: ApplePayButtonType;
16
- buttonStyle?: ApplePayButtonStyle;
17
- onPaymentAuthorized?: (paymentData: ApplePayJS.ApplePayPayment) => void;
18
- }
19
- declare const ApplePayButton: {
20
- ({ displayName, amount, startSessionURL, appId, domainName, countryCode, currencyCode, merchantCapabilities, supportedNetworks, buttonType, buttonStyle, onPaymentAuthorized, }: ApplePayButtonProps): import("react/jsx-runtime").JSX.Element;
21
- displayName: string;
22
- };
23
- export { ApplePayButton };
24
- //# sourceMappingURL=apple-pay-button.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"apple-pay-button.d.ts","sourceRoot":"","sources":["../../../components/ui/apple-pay-button.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,WAAW,GAAG,MAAM,GAAG,KAAK,GAAG,WAAW,GAAG,UAAU,GAAG,YAAY,GAAG,QAAQ,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,GAAG,KAAK,GAAG,QAAQ,CAAC;AAE3N,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,OAAO,GAAG,eAAe,CAAA;AAErE,MAAM,WAAW,mBACf,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC;IACrD,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,UAAU,CAAC,0BAA0B,EAAE,CAAC;IAC/D,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,UAAU,CAAC,EAAE,kBAAkB,CAAC;IAChC,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAClC,mBAAmB,CAAC,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC,eAAe,KAAK,IAAI,CAAC;CACzE;AAED,QAAA,MAAM,cAAc;qLAcf,mBAAmB;;CA2IvB,CAAA;AAID,OAAO,EAAE,cAAc,EAAE,CAAA"}
@@ -1,121 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
- import * as React from "react";
12
- import ApplePayButtonComponent from 'apple-pay-button';
13
- const ApplePayButton = ({ displayName, amount, startSessionURL, appId, domainName, countryCode = 'US', currencyCode = 'USD', merchantCapabilities = ["supports3DS"], supportedNetworks = ["visa", "masterCard", "amex", "discover"], buttonType = 'plain', buttonStyle = 'white-outline', onPaymentAuthorized, }) => {
14
- const [paymentDataResult, setPaymentDataResult] = React.useState("");
15
- const onClick = () => {
16
- const applePayRequest = {
17
- countryCode,
18
- currencyCode,
19
- merchantCapabilities,
20
- supportedNetworks,
21
- total: {
22
- label: displayName,
23
- type: "final",
24
- amount: amount.toString(),
25
- }
26
- };
27
- const session = new ApplePaySession(3, applePayRequest);
28
- handleEventsForApplePay(session);
29
- session.begin();
30
- };
31
- const defaultFetcher = (url, body) => fetch(url, {
32
- method: body ? "POST" : "GET",
33
- headers: {
34
- "Content-Type": "application/json",
35
- },
36
- body: body ? JSON.stringify(body) : undefined,
37
- }).then((res) => res.json());
38
- const validateMerchant = (validationURL, appId, domainName, displayName) => __awaiter(void 0, void 0, void 0, function* () {
39
- let url = startSessionURL;
40
- let body = {
41
- validationURL,
42
- appId,
43
- domainName,
44
- displayName
45
- };
46
- console.log("request body", body);
47
- const response = yield defaultFetcher(url, body);
48
- return response.data;
49
- });
50
- const handleEventsForApplePay = (session) => {
51
- session.onvalidatemerchant = (event) => __awaiter(void 0, void 0, void 0, function* () {
52
- const response = yield validateMerchant(event.validationURL, appId, domainName, displayName);
53
- if (response) {
54
- session.completeMerchantValidation(response);
55
- }
56
- else {
57
- console.error("Error during validating merchant");
58
- }
59
- });
60
- session.onpaymentmethodselected = (event) => {
61
- const update = {
62
- newTotal: {
63
- label: displayName,
64
- type: "final",
65
- amount: amount.toString(),
66
- }
67
- };
68
- session.completePaymentMethodSelection(update);
69
- };
70
- session.onshippingmethodselected = (event) => {
71
- const update = {
72
- newTotal: {
73
- label: displayName,
74
- type: "final",
75
- amount: amount.toString(),
76
- }
77
- };
78
- session.completeShippingMethodSelection(update);
79
- };
80
- session.onshippingcontactselected = (event) => {
81
- const update = {
82
- newTotal: {
83
- label: displayName,
84
- type: "final",
85
- amount: amount.toString(),
86
- }
87
- };
88
- session.completeShippingContactSelection(update);
89
- };
90
- session.onpaymentauthorized = (event) => __awaiter(void 0, void 0, void 0, function* () {
91
- const paymentData = event.payment;
92
- if (onPaymentAuthorized) { // Call the callback if provided
93
- onPaymentAuthorized(paymentData);
94
- }
95
- if (paymentData.token) {
96
- const paymentDataJson = JSON.stringify(paymentData.token, null, 2);
97
- console.log("paymentData", paymentDataJson);
98
- setPaymentDataResult(paymentDataJson);
99
- const result = {
100
- status: ApplePaySession.STATUS_SUCCESS,
101
- };
102
- session.completePayment(result);
103
- }
104
- else {
105
- const result = {
106
- status: ApplePaySession.STATUS_FAILURE,
107
- };
108
- session.completePayment(result);
109
- }
110
- });
111
- session.oncancel = (event) => {
112
- console.log("Session Cancelled.");
113
- };
114
- };
115
- return (_jsxs("div", { children: [_jsx("div", Object.assign({ className: "flex flex-row justify-center items-center pt-40" }, { children: _jsx(ApplePayButtonComponent, { onClick: onClick, style: {
116
- height: "48px",
117
- borderRadius: '4px',
118
- }, 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 })) }))] }));
119
- };
120
- ApplePayButton.displayName = "ApplePayButton";
121
- export { ApplePayButton };