@tapcart/mobile-components 0.7.17 → 0.7.19
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-customer.d.ts +10 -0
- package/dist/components/hooks/use-customer.d.ts.map +1 -0
- package/dist/components/hooks/use-customer.js +24 -0
- package/dist/components/ui/Input/input.d.ts.map +1 -1
- package/dist/components/ui/Input/input.js +7 -1
- package/dist/components/ui/apple-pay-button.d.ts +6 -0
- package/dist/components/ui/apple-pay-button.d.ts.map +1 -0
- package/dist/components/ui/apple-pay-button.js +144 -0
- package/dist/components/ui/money.d.ts.map +1 -1
- package/dist/components/ui/money.js +7 -1
- package/package.json +18 -18
- package/dist/components/hooks/use-click-outside.d.ts +0 -3
- package/dist/components/hooks/use-click-outside.d.ts.map +0 -1
- package/dist/components/hooks/use-click-outside.js +0 -16
- package/dist/components/hooks/use-outside-click.d.ts +0 -4
- package/dist/components/hooks/use-outside-click.d.ts.map +0 -1
- package/dist/components/hooks/use-outside-click.js +0 -16
|
@@ -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
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../../components/ui/Input/input.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../../components/ui/Input/input.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAMxD,QAAA,MAAM,KAAK,qFAwKV,CAAA;AAGD,OAAO,EAAE,KAAK,EAAE,CAAA"}
|
|
@@ -14,9 +14,15 @@ import * as React from "react";
|
|
|
14
14
|
import { inputVariants, useInput } from "./useInput";
|
|
15
15
|
import { cn } from "../../../lib/utils";
|
|
16
16
|
import { Icon } from "../icon";
|
|
17
|
+
import { getTextTranslation, useTranslation, } from "../../contexts/translation-context";
|
|
17
18
|
const Input = React.forwardRef((_a, ref) => {
|
|
18
19
|
var { className, error = false, id, type, label, asChild, value, onChange, icon, iconUrl, iconPosition = "right", // Default to "right" for backward compatibility
|
|
19
20
|
iconColor, placeholder, placeholderFont, placeholderFontWeight, placeholderFontSize, placeholderTextAlign, placeholderTextColor, placeholderUpperCase, inputPadding, backgroundColor, borderRadius, inputBorderColor, borderSides, inputSpacing } = _a, props = __rest(_a, ["className", "error", "id", "type", "label", "asChild", "value", "onChange", "icon", "iconUrl", "iconPosition", "iconColor", "placeholder", "placeholderFont", "placeholderFontWeight", "placeholderFontSize", "placeholderTextAlign", "placeholderTextColor", "placeholderUpperCase", "inputPadding", "backgroundColor", "borderRadius", "inputBorderColor", "borderSides", "inputSpacing"]);
|
|
21
|
+
const translations = useTranslation();
|
|
22
|
+
const translatedPlaceholder = getTextTranslation({
|
|
23
|
+
text: placeholder,
|
|
24
|
+
translations,
|
|
25
|
+
});
|
|
20
26
|
const { Comp, inputPaddingRight, inputPaddingLeft, borderStyle, borderRadiusStyle, iconLeftPadding, iconRightPadding, iconTopPadding, iconBottomPadding, placeholderTextColorStyle, iconColorStyle, inputBgColor, inputBorderColorStyle, } = useInput({
|
|
21
27
|
asChild,
|
|
22
28
|
icon,
|
|
@@ -44,7 +50,7 @@ const Input = React.forwardRef((_a, ref) => {
|
|
|
44
50
|
} })), _jsx("style", { children: `
|
|
45
51
|
.custom-placeholder-value::placeholder {
|
|
46
52
|
color: ${placeholderTextColorStyle};
|
|
47
|
-
}` }), _jsx("input", Object.assign({ placeholder: placeholder, value: value, onChange: (e) => onChange(e.target.value), id: id, type: type, className: cn(inputVariants({ error, hasLabel: !!label }), className, "custom-placeholder-value"), "data-icon": !!icon, ref: ref }, props, { style: Object.assign(Object.assign({ paddingLeft: iconUrl &&
|
|
53
|
+
}` }), _jsx("input", Object.assign({ placeholder: translatedPlaceholder || placeholder, value: value, onChange: (e) => onChange(e.target.value), id: id, type: type, className: cn(inputVariants({ error, hasLabel: !!label }), className, "custom-placeholder-value"), "data-icon": !!icon, ref: ref }, props, { style: Object.assign(Object.assign({ paddingLeft: iconUrl &&
|
|
48
54
|
iconPosition === "left" &&
|
|
49
55
|
placeholderTextAlign === "center"
|
|
50
56
|
? undefined
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface ApplePayButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
3
|
+
}
|
|
4
|
+
declare const ApplePayButton: React.ForwardRefExoticComponent<ApplePayButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
5
|
+
export { ApplePayButton };
|
|
6
|
+
//# sourceMappingURL=apple-pay-button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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,WAAW,mBACf,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC;CACtD;AAED,QAAA,MAAM,cAAc,+FAyJnB,CAAA;AAGD,OAAO,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -0,0 +1,144 @@
|
|
|
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
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
+
var t = {};
|
|
12
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
+
t[p] = s[p];
|
|
14
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
+
t[p[i]] = s[p[i]];
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
21
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
|
+
import * as React from "react";
|
|
23
|
+
import ApplePayButtonComponent from 'apple-pay-button';
|
|
24
|
+
const ApplePayButton = React.forwardRef((_a, ref) => {
|
|
25
|
+
var props = __rest(_a, []);
|
|
26
|
+
const onClick = () => {
|
|
27
|
+
// Define ApplePayPaymentRequest
|
|
28
|
+
const applePayRequest = {
|
|
29
|
+
countryCode: 'US',
|
|
30
|
+
currencyCode: 'USD',
|
|
31
|
+
merchantCapabilities: [
|
|
32
|
+
"supports3DS"
|
|
33
|
+
],
|
|
34
|
+
supportedNetworks: [
|
|
35
|
+
"visa",
|
|
36
|
+
"masterCard",
|
|
37
|
+
"amex",
|
|
38
|
+
"discover"
|
|
39
|
+
],
|
|
40
|
+
total: {
|
|
41
|
+
label: "Merchant Name",
|
|
42
|
+
type: "final",
|
|
43
|
+
amount: "10.00",
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
// Create ApplePaySession
|
|
47
|
+
const session = new ApplePaySession(3, applePayRequest);
|
|
48
|
+
handleEventsForApplePay(session);
|
|
49
|
+
session.begin();
|
|
50
|
+
};
|
|
51
|
+
const defaultFetcher = (url, body) => fetch(url, {
|
|
52
|
+
method: body ? "POST" : "GET",
|
|
53
|
+
headers: {
|
|
54
|
+
"Content-Type": "application/json",
|
|
55
|
+
},
|
|
56
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
57
|
+
}).then((res) => res.json());
|
|
58
|
+
// const fetcher = defaultFetcher
|
|
59
|
+
// const { data, error } = useSWR(url ? [url, body] : null, ([url, body]) =>
|
|
60
|
+
// fetcher(url, body)
|
|
61
|
+
// )
|
|
62
|
+
const validateMerchant = (validationURL, merchantIdentifier, domainName, displayName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
63
|
+
let url = "http://localhost:3000/3Mo5UakuRa/api/v1/applePay/merchantVerification";
|
|
64
|
+
let body = {
|
|
65
|
+
validationURL,
|
|
66
|
+
merchantIdentifier,
|
|
67
|
+
domainName,
|
|
68
|
+
displayName
|
|
69
|
+
};
|
|
70
|
+
return defaultFetcher(url, body);
|
|
71
|
+
});
|
|
72
|
+
const handleEventsForApplePay = (session) => {
|
|
73
|
+
session.onvalidatemerchant = (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
74
|
+
const merchantSession = yield validateMerchant(event.validationURL, "merchantId", "domainName", "displayName");
|
|
75
|
+
if (merchantSession) {
|
|
76
|
+
session.completeMerchantValidation(merchantSession);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
console.error("Error during validating merchant");
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
session.onpaymentmethodselected = (event) => {
|
|
83
|
+
// Define ApplePayPaymentMethodUpdate based on the selected payment method.
|
|
84
|
+
// No updates or errors are needed, pass an empty object.
|
|
85
|
+
const update = {
|
|
86
|
+
newTotal: {
|
|
87
|
+
label: "Merchant Name",
|
|
88
|
+
type: "final",
|
|
89
|
+
amount: "10.00",
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
session.completePaymentMethodSelection(update);
|
|
93
|
+
};
|
|
94
|
+
session.onshippingmethodselected = (event) => {
|
|
95
|
+
// Define ApplePayShippingMethodUpdate based on the selected shipping method.
|
|
96
|
+
// No updates or errors are needed, pass an empty object.
|
|
97
|
+
const update = {
|
|
98
|
+
newTotal: {
|
|
99
|
+
label: "Merchant Name",
|
|
100
|
+
type: "final",
|
|
101
|
+
amount: "10.00",
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
session.completeShippingMethodSelection(update);
|
|
105
|
+
};
|
|
106
|
+
session.onshippingcontactselected = (event) => {
|
|
107
|
+
// Define ApplePayShippingContactUpdate based on the selected shipping contact.
|
|
108
|
+
const update = {
|
|
109
|
+
newTotal: {
|
|
110
|
+
label: "Merchant Name",
|
|
111
|
+
type: "final",
|
|
112
|
+
amount: "10.00",
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
session.completeShippingContactSelection(update);
|
|
116
|
+
};
|
|
117
|
+
session.onpaymentauthorized = (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
118
|
+
// Define ApplePayPaymentAuthorizationResult
|
|
119
|
+
const paymentData = event.payment;
|
|
120
|
+
if (paymentData.token) {
|
|
121
|
+
// Forward token to your gateway for processing payment and return result to apple pay session
|
|
122
|
+
const result = {
|
|
123
|
+
status: ApplePaySession.STATUS_SUCCESS,
|
|
124
|
+
};
|
|
125
|
+
session.completePayment(result);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
const result = {
|
|
129
|
+
status: ApplePaySession.STATUS_FAILURE,
|
|
130
|
+
};
|
|
131
|
+
session.completePayment(result);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
session.oncancel = (event) => {
|
|
135
|
+
console.log("Session Cancelled.");
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
return (_jsx("div", { children: _jsx(ApplePayButtonComponent, { onClick: onClick, style: {
|
|
139
|
+
width: '100%',
|
|
140
|
+
borderRadius: '8px',
|
|
141
|
+
}, type: "continue" }) }));
|
|
142
|
+
});
|
|
143
|
+
ApplePayButton.displayName = "ApplePayButton";
|
|
144
|
+
export { ApplePayButton };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"money.d.ts","sourceRoot":"","sources":["../../../components/ui/money.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEjE,UAAU,SAAS;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;CACd;AAED,QAAA,MAAM,aAAa,gGAMjB,CAAA;AAEF,MAAM,WAAW,UACf,SAAQ,SAAS,EACf,YAAY,CAAC,OAAO,aAAa,CAAC;IAChC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,MAAM,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;CAC7B;AAEL,iBAAS,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAqB,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"money.d.ts","sourceRoot":"","sources":["../../../components/ui/money.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEjE,UAAU,SAAS;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;CACd;AAED,QAAA,MAAM,aAAa,gGAMjB,CAAA;AAEF,MAAM,WAAW,UACf,SAAQ,SAAS,EACf,YAAY,CAAC,OAAO,aAAa,CAAC;IAChC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,MAAM,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;CAC7B;AAEL,iBAAS,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAqB,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,EAAE,UAAU,2CAuB9F;AAED,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,CAAA"}
|
|
@@ -21,7 +21,13 @@ const moneyVariants = cva("", {
|
|
|
21
21
|
});
|
|
22
22
|
function Money(_a) {
|
|
23
23
|
var { price, locale, currency, hideZeroCents = false, styles } = _a, props = __rest(_a, ["price", "locale", "currency", "hideZeroCents", "styles"]);
|
|
24
|
-
|
|
24
|
+
let language = locale;
|
|
25
|
+
// Fix for when we want to format in USD in english
|
|
26
|
+
// but language only contains two letter region
|
|
27
|
+
if (currency === "USD" && !(locale === null || locale === void 0 ? void 0 : locale.includes("-"))) {
|
|
28
|
+
language = `en-${locale}`;
|
|
29
|
+
}
|
|
30
|
+
const formatter = React.useMemo(() => new Intl.NumberFormat(language, {
|
|
25
31
|
style: "currency",
|
|
26
32
|
currency: currency,
|
|
27
33
|
currencyDisplay: "narrowSymbol",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tapcart/mobile-components",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.19",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"style": "dist/styles.css",
|
|
@@ -11,6 +11,18 @@
|
|
|
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
|
+
},
|
|
14
26
|
"peerDependencies": {
|
|
15
27
|
"react": "^17.0.2 || ^18.0.0",
|
|
16
28
|
"react-dom": "^17.0.2 || ^18.0.0"
|
|
@@ -20,19 +32,19 @@
|
|
|
20
32
|
"@types/lodash": "4.17.5",
|
|
21
33
|
"@types/react": "^18.2.0",
|
|
22
34
|
"@types/react-dom": "^18.2.0",
|
|
35
|
+
"app-studio-types": "workspace:*",
|
|
23
36
|
"autoprefixer": "^10.4.14",
|
|
24
37
|
"chokidar-cli": "^3.0.0",
|
|
25
38
|
"concurrently": "^8.2.2",
|
|
26
39
|
"eslint": "^7.32.0",
|
|
40
|
+
"eslint-config-custom": "workspace:*",
|
|
27
41
|
"jest": "^29.7.0",
|
|
28
42
|
"postcss": "^8.4.24",
|
|
29
43
|
"tailwindcss": "^3.3.2",
|
|
30
44
|
"ts-jest": "^29.2.5",
|
|
31
45
|
"tsc-alias": "^1.8.10",
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"eslint-config-custom": "0.0.0",
|
|
35
|
-
"tsconfig": "0.0.0"
|
|
46
|
+
"tsconfig": "workspace:*",
|
|
47
|
+
"typescript": "^4.5.2"
|
|
36
48
|
},
|
|
37
49
|
"dependencies": {
|
|
38
50
|
"@radix-ui/react-accordion": "^1.1.2",
|
|
@@ -68,17 +80,5 @@
|
|
|
68
80
|
"tailwind-merge": "^1.13.2",
|
|
69
81
|
"tailwindcss-animate": "^1.0.6",
|
|
70
82
|
"vaul": "0.9.1"
|
|
71
|
-
},
|
|
72
|
-
"scripts": {
|
|
73
|
-
"lint": "eslint \"**/*.ts*\"",
|
|
74
|
-
"ui:add": "pnpm dlx shadcn-ui@latest add",
|
|
75
|
-
"build:styles": "postcss styles/globals.css -o dist/styles.css",
|
|
76
|
-
"build:ts": "tsc -p tsconfig.json && tsc-alias",
|
|
77
|
-
"build": "pnpm run build:ts && pnpm run build:styles",
|
|
78
|
-
"dev:ts": "tsc -w -p tsconfig.json",
|
|
79
|
-
"dev:styles": "npx tailwindcss -i styles/globals.css -o dist/styles.css --watch",
|
|
80
|
-
"dev": "concurrently \"pnpm run dev:ts\" \"pnpm run dev:styles\"",
|
|
81
|
-
"test": "jest",
|
|
82
|
-
"test:watch": "jest --watch"
|
|
83
83
|
}
|
|
84
|
-
}
|
|
84
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
;
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,16 +0,0 @@
|
|
|
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;
|