@tapcart/mobile-components 0.7.64 → 0.7.66
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-mock-cart.d.ts +12 -5
- package/dist/components/hooks/use-mock-cart.d.ts.map +1 -1
- package/dist/components/hooks/use-mock-cart.js +10 -11
- package/dist/components/ui/quantity-picker.d.ts +2 -0
- package/dist/components/ui/quantity-picker.d.ts.map +1 -1
- package/dist/components/ui/quantity-picker.js +4 -4
- package/dist/components/ui/wishlist.js +1 -1
- package/dist/lib/cart.util.d.ts.map +1 -1
- package/dist/lib/cart.util.js +8 -3
- package/dist/lib/cart.util.test.js +1 -0
- package/dist/styles.css +0 -6
- package/package.json +21 -21
- package/dist/components/hooks/use-click-outside.d.ts +0 -6
- package/dist/components/hooks/use-click-outside.d.ts.map +0 -1
- package/dist/components/hooks/use-click-outside.js +0 -15
- package/dist/components/hooks/use-outside-click.d.ts +0 -7
- package/dist/components/hooks/use-outside-click.d.ts.map +0 -1
- package/dist/components/hooks/use-outside-click.js +0 -16
- package/dist/components/hooks/use-tap.d.ts +0 -8
- package/dist/components/hooks/use-tap.d.ts.map +0 -1
- package/dist/components/hooks/use-tap.js +0 -100
|
@@ -47,7 +47,7 @@ export declare const useMockCart: ({ apiUrl, appId, enabled, limit, }: UseMockCa
|
|
|
47
47
|
createdAt: string;
|
|
48
48
|
displayName: string;
|
|
49
49
|
inventoryPolicy: "continue" | "deny";
|
|
50
|
-
|
|
50
|
+
quantityAvailable: number;
|
|
51
51
|
legacyResourceId: string;
|
|
52
52
|
metafield?: import("app-studio-types").Metafield | undefined;
|
|
53
53
|
position: number;
|
|
@@ -60,10 +60,16 @@ export declare const useMockCart: ({ apiUrl, appId, enabled, limit, }: UseMockCa
|
|
|
60
60
|
};
|
|
61
61
|
};
|
|
62
62
|
sellingPlanAllocation: {
|
|
63
|
-
priceAdjustments:
|
|
64
|
-
perDeliveryPrice:
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
priceAdjustments: {
|
|
64
|
+
perDeliveryPrice: {
|
|
65
|
+
amount: string;
|
|
66
|
+
currencyCode: string;
|
|
67
|
+
};
|
|
68
|
+
price: {
|
|
69
|
+
amount: string;
|
|
70
|
+
currencyCode: string;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
67
73
|
sellingPlan: {
|
|
68
74
|
id: string;
|
|
69
75
|
name: string;
|
|
@@ -154,6 +160,7 @@ export declare const useMockCart: ({ apiUrl, appId, enabled, limit, }: UseMockCa
|
|
|
154
160
|
currencyCode: string;
|
|
155
161
|
};
|
|
156
162
|
}[];
|
|
163
|
+
checkoutUrl: string;
|
|
157
164
|
};
|
|
158
165
|
};
|
|
159
166
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-mock-cart.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-mock-cart.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"use-mock-cart.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-mock-cart.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAA;AAgLhF,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCnB,CAAA"}
|
|
@@ -27,6 +27,7 @@ const cartMock = {
|
|
|
27
27
|
presentmentAmountUsed: { amount: "10.00", currencyCode: "USD" },
|
|
28
28
|
},
|
|
29
29
|
],
|
|
30
|
+
checkoutUrl: "",
|
|
30
31
|
};
|
|
31
32
|
const transformCart = ({ products, cartOrigin = cartMock, }) => {
|
|
32
33
|
let subtotal = cartOrigin.subtotal;
|
|
@@ -59,18 +60,16 @@ const transformCart = ({ products, cartOrigin = cartMock, }) => {
|
|
|
59
60
|
}
|
|
60
61
|
const sellingPlanAllocation = i === 0
|
|
61
62
|
? {
|
|
62
|
-
priceAdjustments:
|
|
63
|
-
{
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
currencyCode: "USD",
|
|
67
|
-
},
|
|
68
|
-
price: {
|
|
69
|
-
amount: price,
|
|
70
|
-
currencyCode: "USD",
|
|
71
|
-
},
|
|
63
|
+
priceAdjustments: {
|
|
64
|
+
perDeliveryPrice: {
|
|
65
|
+
amount: price.toString(),
|
|
66
|
+
currencyCode: "USD",
|
|
72
67
|
},
|
|
73
|
-
|
|
68
|
+
price: {
|
|
69
|
+
amount: price.toString(),
|
|
70
|
+
currencyCode: "USD",
|
|
71
|
+
},
|
|
72
|
+
},
|
|
74
73
|
sellingPlan: {
|
|
75
74
|
id: "gid://shopify/SellingPlan/123",
|
|
76
75
|
name: "Delivery every 30 Days",
|
|
@@ -7,6 +7,8 @@ export interface QuantityPickerProps extends React.HTMLAttributes<HTMLDivElement
|
|
|
7
7
|
iconColor: string;
|
|
8
8
|
onDecreaseClick: React.ReactEventHandler;
|
|
9
9
|
onIncreaseClick: React.ReactEventHandler;
|
|
10
|
+
isDecreaseDisabled?: boolean;
|
|
11
|
+
isIncreaseDisabled?: boolean;
|
|
10
12
|
value: number;
|
|
11
13
|
setValue: (_: number) => void;
|
|
12
14
|
className?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quantity-picker.d.ts","sourceRoot":"","sources":["../../../components/ui/quantity-picker.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAK9B,MAAM,WAAW,mBACf,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IAC5C,eAAe,EAAE,MAAM,CAAA;IACvB,eAAe,EAAE,MAAM,CAAA;IACvB,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,OAAO,CAAA;IACrB,SAAS,EAAE,MAAM,CAAA;IACjB,eAAe,EAAE,KAAK,CAAC,iBAAiB,CAAA;IACxC,eAAe,EAAE,KAAK,CAAC,iBAAiB,CAAA;IACxC,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;IAChC,WAAW,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;IACjC,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B;
|
|
1
|
+
{"version":3,"file":"quantity-picker.d.ts","sourceRoot":"","sources":["../../../components/ui/quantity-picker.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAK9B,MAAM,WAAW,mBACf,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IAC5C,eAAe,EAAE,MAAM,CAAA;IACvB,eAAe,EAAE,MAAM,CAAA;IACvB,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,OAAO,CAAA;IACrB,SAAS,EAAE,MAAM,CAAA;IACjB,eAAe,EAAE,KAAK,CAAC,iBAAiB,CAAA;IACxC,eAAe,EAAE,KAAK,CAAC,iBAAiB,CAAA;IACxC,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;IAChC,WAAW,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;IACjC,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B;AAmCD,QAAA,MAAM,cAAc,4FAuFnB,CAAA;AAID,OAAO,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -15,14 +15,14 @@ import * as React from "react";
|
|
|
15
15
|
import { cn } from "../../lib/utils";
|
|
16
16
|
import { Icon } from "./icon";
|
|
17
17
|
import { useTap } from "./tap";
|
|
18
|
-
const IconButton = ({ iconUrl, iconColor, handler, className, style }) => {
|
|
18
|
+
const IconButton = ({ iconUrl, iconColor, handler, className, style, disabled }) => {
|
|
19
19
|
const { onTap, isPressed, ref: tapRef } = useTap();
|
|
20
|
-
return (_jsx("button", Object.assign({ onClick: onTap(handler), ref: tapRef, className: cn("flex items-center justify-center h-7 w-7 bg-stateColors-skeleton border border-coreColors-dividingLines", className), style: style }, { children: _jsx(Icon, { url: iconUrl, size: "sm", strokeColor: iconColor, strokeWidth: 4, style: {
|
|
20
|
+
return (_jsx("button", Object.assign({ onClick: onTap(handler), ref: tapRef, className: cn("flex items-center justify-center h-7 w-7 bg-stateColors-skeleton border border-coreColors-dividingLines", className), style: style, disabled: disabled }, { children: _jsx(Icon, { url: iconUrl, size: "sm", strokeColor: iconColor, strokeWidth: 4, style: {
|
|
21
21
|
opacity: isPressed ? 0.7 : 1,
|
|
22
22
|
} }) })));
|
|
23
23
|
};
|
|
24
24
|
const QuantityPicker = React.forwardRef((_a, ref) => {
|
|
25
|
-
var { className, decreaseIconUrl, increaseIconUrl, deleteIconUrl, isDeleteOnly = false, iconColor, onDecreaseClick, onIncreaseClick, value, setValue, inputStyle, buttonStyle, buttonCornerRadius = 4 } = _a, props = __rest(_a, ["className", "decreaseIconUrl", "increaseIconUrl", "deleteIconUrl", "isDeleteOnly", "iconColor", "onDecreaseClick", "onIncreaseClick", "value", "setValue", "inputStyle", "buttonStyle", "buttonCornerRadius"]);
|
|
25
|
+
var { className, decreaseIconUrl, increaseIconUrl, deleteIconUrl, isDeleteOnly = false, iconColor, onDecreaseClick, onIncreaseClick, isDecreaseDisabled, isIncreaseDisabled, value, setValue, inputStyle, buttonStyle, buttonCornerRadius = 4 } = _a, props = __rest(_a, ["className", "decreaseIconUrl", "increaseIconUrl", "deleteIconUrl", "isDeleteOnly", "iconColor", "onDecreaseClick", "onIncreaseClick", "isDecreaseDisabled", "isIncreaseDisabled", "value", "setValue", "inputStyle", "buttonStyle", "buttonCornerRadius"]);
|
|
26
26
|
const leftButtonStyle = Object.assign(Object.assign({}, buttonStyle), { borderTopLeftRadius: buttonCornerRadius
|
|
27
27
|
? `${buttonCornerRadius}px`
|
|
28
28
|
: undefined, borderBottomLeftRadius: buttonCornerRadius
|
|
@@ -34,7 +34,7 @@ const QuantityPicker = React.forwardRef((_a, ref) => {
|
|
|
34
34
|
? `${buttonCornerRadius}px`
|
|
35
35
|
: undefined });
|
|
36
36
|
const singleButtonStyle = Object.assign(Object.assign({}, buttonStyle), { borderRadius: buttonCornerRadius ? `${buttonCornerRadius}px` : undefined });
|
|
37
|
-
return (_jsx("div", Object.assign({ className: cn("flex", className), ref: ref }, props, { children: isDeleteOnly ? (_jsx(IconButton, { handler: onDecreaseClick, iconUrl: deleteIconUrl, iconColor: iconColor, style: singleButtonStyle })) : (_jsxs(_Fragment, { children: [_jsx(IconButton, { handler: onDecreaseClick, iconUrl: value === 1 ? deleteIconUrl : decreaseIconUrl, iconColor: iconColor, style: leftButtonStyle }), _jsx("input", { type: "text", pattern: "[0-9]*", value: value, onBlur: (e) => (e.target.value = value.toString()), onFocus: (e) => (e.target.value = ""), onChange: (e) => setValue(parseInt(e.target.value) || 0), className: "w-8 h-7 focus-visible:outline-none text-center bg-coreColors-inputBackground text-textColors-primaryColor border-t border-b border-coreColors-dividingLines", style: inputStyle }), _jsx(IconButton, { handler: onIncreaseClick, iconUrl: increaseIconUrl, iconColor: iconColor, style: rightButtonStyle })] })) })));
|
|
37
|
+
return (_jsx("div", Object.assign({ className: cn("flex", className), ref: ref }, props, { children: isDeleteOnly ? (_jsx(IconButton, { handler: onDecreaseClick, iconUrl: deleteIconUrl, iconColor: iconColor, style: singleButtonStyle })) : (_jsxs(_Fragment, { children: [_jsx(IconButton, { handler: onDecreaseClick, iconUrl: value === 1 ? deleteIconUrl : decreaseIconUrl, iconColor: iconColor, style: leftButtonStyle, disabled: isDecreaseDisabled }), _jsx("input", { type: "text", pattern: "[0-9]*", value: value, onBlur: (e) => (e.target.value = value.toString()), onFocus: (e) => (e.target.value = ""), onChange: (e) => setValue(parseInt(e.target.value) || 0), className: "w-8 h-7 focus-visible:outline-none text-center bg-coreColors-inputBackground text-textColors-primaryColor border-t border-b border-coreColors-dividingLines", style: inputStyle }), _jsx(IconButton, { handler: onIncreaseClick, iconUrl: increaseIconUrl, iconColor: iconColor, style: rightButtonStyle, disabled: isIncreaseDisabled })] })) })));
|
|
38
38
|
});
|
|
39
39
|
QuantityPicker.displayName = "QuantityPicker";
|
|
40
40
|
export { QuantityPicker };
|
|
@@ -22,7 +22,7 @@ const Wishlist = React.forwardRef((_a, ref) => {
|
|
|
22
22
|
var { selected = false, onClick, className, name, amount, imgUrl, aspectRatio, objectFit, isTrigger, translations, nameStyle, amountStyle } = _a, props = __rest(_a, ["selected", "onClick", "className", "name", "amount", "imgUrl", "aspectRatio", "objectFit", "isTrigger", "translations", "nameStyle", "amountStyle"]);
|
|
23
23
|
return (_jsxs("button", Object.assign({ className: cn("flex flex-row items-center px-4 py-2 w-full ", selected ? "bg-stateColors-skeleton" : "", className), ref: ref, onClick: onClick }, props, { children: [imgUrl ? (_jsx("div", Object.assign({ className: "h-10 w-10 border border-coreColors-dividingLines rounded-sm overflow-hidden", style: {
|
|
24
24
|
flex: "0 1 auto",
|
|
25
|
-
} }, { children: _jsx("img", { alt: "wishlist-image", src: `${imgUrl}?width=40`, width: 40, height: 40, className: cn("rounded-sm w-full h-full", objectFit === "contain" ? "object-contain" : "object-cover") }) }))) : (_jsx(PlaceholderIcon, {})), _jsxs("div", Object.assign({ className: "flex flex-col flex-1 items-start mx-2
|
|
25
|
+
} }, { children: _jsx("img", { alt: "wishlist-image", src: `${imgUrl}?width=40`, width: 40, height: 40, className: cn("rounded-sm w-full h-full", objectFit === "contain" ? "object-contain" : "object-cover") }) }))) : (_jsx(PlaceholderIcon, {})), _jsxs("div", Object.assign({ className: "flex flex-col flex-1 items-start mx-2 overflow-hidden" }, { children: [isTrigger && _jsx(Text, Object.assign({ type: "body-secondary" }, { children: "Wishlists" })), _jsx(Text, Object.assign({ type: "body-primary", className: "w-full overflow-hidden text-ellipsis whitespace-nowrap text-left", style: nameStyle }, { children: name })), !isTrigger && (_jsx(Text, Object.assign({ type: "body-secondary", className: "w-full overflow-hidden text-ellipsis whitespace-nowrap text-left", style: amountStyle }, { children: `${amount} ${amount !== 1
|
|
26
26
|
? translations["checkout-summary-items"]
|
|
27
27
|
: translations["checkout-summary-item"]}` })))] }))] })));
|
|
28
28
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cart.util.d.ts","sourceRoot":"","sources":["../../lib/cart.util.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,sBAAsB,EACtB,6BAA6B,EAC9B,MAAM,kBAAkB,CAAA;AAuCzB,eAAO,MAAM,oBAAoB,SAAU,MAAM,QAAQ,YAAY,YAGpE,CAAA;AAED,eAAO,MAAM,kBAAkB,SAAU,MAAM,QAAQ,YAAY,YAGlE,CAAA;
|
|
1
|
+
{"version":3,"file":"cart.util.d.ts","sourceRoot":"","sources":["../../lib/cart.util.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,sBAAsB,EACtB,6BAA6B,EAC9B,MAAM,kBAAkB,CAAA;AAuCzB,eAAO,MAAM,oBAAoB,SAAU,MAAM,QAAQ,YAAY,YAGpE,CAAA;AAED,eAAO,MAAM,kBAAkB,SAAU,MAAM,QAAQ,YAAY,YAGlE,CAAA;AAqGD,MAAM,MAAM,cAAc,GAAG;IAC3B,yBAAyB,EAAE,sBAAsB,EAAE,CAAA;IACnD,gBAAgB,EAAE,6BAA6B,EAAE,CAAA;IACjD,cAAc,EAAE,OAAO,CAAA;IACvB,oBAAoB,EAAE,MAAM,CAAA;IAC5B,oBAAoB,EAAE,MAAM,CAAA;IAC5B,WAAW,EAAE,MAAM,CAAA;IACnB,mBAAmB,EAAE,MAAM,CAAA;IAC3B,oBAAoB,EAAE,MAAM,CAAA;CAC7B,CAAA;AAED,eAAO,MAAM,uBAAuB,EAAE,cASrC,CAAA;AAED,eAAO,MAAM,qBAAqB,SAAU,YAAY,KAAG,cA4B1D,CAAA"}
|
package/dist/lib/cart.util.js
CHANGED
|
@@ -68,7 +68,11 @@ const getLineItemDiscounts = (cart) => {
|
|
|
68
68
|
if (!code)
|
|
69
69
|
return;
|
|
70
70
|
if (!acc[code]) {
|
|
71
|
-
acc[code] = {
|
|
71
|
+
acc[code] = {
|
|
72
|
+
amount: 0,
|
|
73
|
+
type: discount.type,
|
|
74
|
+
readOnly: discount.readOnly,
|
|
75
|
+
};
|
|
72
76
|
}
|
|
73
77
|
acc[code].amount += discount.amount;
|
|
74
78
|
});
|
|
@@ -76,12 +80,13 @@ const getLineItemDiscounts = (cart) => {
|
|
|
76
80
|
}, {});
|
|
77
81
|
if (!discountMap)
|
|
78
82
|
return [];
|
|
79
|
-
return (_b = Object.entries(discountMap)) === null || _b === void 0 ? void 0 : _b.map(([code, { amount, type }]) => ({
|
|
83
|
+
return (_b = Object.entries(discountMap)) === null || _b === void 0 ? void 0 : _b.map(([code, { amount, type, readOnly }]) => ({
|
|
80
84
|
id: code,
|
|
81
85
|
name: `Discount - ${code}`,
|
|
82
86
|
amount,
|
|
83
87
|
type,
|
|
84
|
-
|
|
88
|
+
readOnly,
|
|
89
|
+
}));
|
|
85
90
|
};
|
|
86
91
|
const getDiscountsTotalAmount = (orderAndLineItemDiscounts) => {
|
|
87
92
|
return orderAndLineItemDiscounts === null || orderAndLineItemDiscounts === void 0 ? void 0 : orderAndLineItemDiscounts.reduce((acc, discount) => acc + +discount.amount, 0);
|
package/dist/styles.css
CHANGED
|
@@ -998,9 +998,6 @@ video {
|
|
|
998
998
|
.h-\[22px\] {
|
|
999
999
|
height: 22px;
|
|
1000
1000
|
}
|
|
1001
|
-
.h-\[36\] {
|
|
1002
|
-
height: 36;
|
|
1003
|
-
}
|
|
1004
1001
|
.h-\[38px\] {
|
|
1005
1002
|
height: 38px;
|
|
1006
1003
|
}
|
|
@@ -1097,9 +1094,6 @@ video {
|
|
|
1097
1094
|
.w-\[138px\] {
|
|
1098
1095
|
width: 138px;
|
|
1099
1096
|
}
|
|
1100
|
-
.w-\[154px\] {
|
|
1101
|
-
width: 154px;
|
|
1102
|
-
}
|
|
1103
1097
|
.w-\[1px\] {
|
|
1104
1098
|
width: 1px;
|
|
1105
1099
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tapcart/mobile-components",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.66",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"style": "dist/styles.css",
|
|
@@ -11,6 +11,20 @@
|
|
|
11
11
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
12
12
|
"author": "Tapcart Inc.",
|
|
13
13
|
"homepage": "https://tapcart.com",
|
|
14
|
+
"scripts": {
|
|
15
|
+
"clean": "rm -rf dist node_modules",
|
|
16
|
+
"lint": "eslint \"**/*.ts*\"",
|
|
17
|
+
"ui:add": "pnpm dlx shadcn-ui@latest add",
|
|
18
|
+
"build:styles": "postcss styles/globals.css -o dist/styles.css",
|
|
19
|
+
"build:ts": "tsc -p tsconfig.json && tsc-alias",
|
|
20
|
+
"build": "pnpm run build:ts && pnpm run build:styles",
|
|
21
|
+
"dev:ts": "tsc -w -p tsconfig.json",
|
|
22
|
+
"dev:styles": "npx tailwindcss -i styles/globals.css -o dist/styles.css --watch",
|
|
23
|
+
"dev": "concurrently \"pnpm run dev:ts\" \"pnpm run dev:styles\"",
|
|
24
|
+
"test": "jest",
|
|
25
|
+
"test:silent": "jest --silent",
|
|
26
|
+
"test:watch": "jest --watch"
|
|
27
|
+
},
|
|
14
28
|
"peerDependencies": {
|
|
15
29
|
"react": "^17.0.2 || ^18.0.0",
|
|
16
30
|
"react-dom": "^17.0.2 || ^18.0.0"
|
|
@@ -23,20 +37,20 @@
|
|
|
23
37
|
"@types/pluralize": "^0.0.33",
|
|
24
38
|
"@types/react": "^18.2.0",
|
|
25
39
|
"@types/react-dom": "^18.2.0",
|
|
40
|
+
"app-studio-types": "workspace:*",
|
|
26
41
|
"autoprefixer": "^10.4.14",
|
|
27
42
|
"chokidar-cli": "^3.0.0",
|
|
28
43
|
"concurrently": "^8.2.2",
|
|
29
44
|
"eslint": "^7.32.0",
|
|
45
|
+
"eslint-config-custom": "workspace:*",
|
|
30
46
|
"jest": "^29.7.0",
|
|
31
47
|
"jest-environment-jsdom": "^29.7.0",
|
|
32
|
-
"postcss": "^8.
|
|
48
|
+
"postcss": "^8.5.2",
|
|
33
49
|
"tailwindcss": "^3.3.2",
|
|
34
50
|
"ts-jest": "^29.2.5",
|
|
35
51
|
"tsc-alias": "^1.8.10",
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"tsconfig": "0.0.0",
|
|
39
|
-
"eslint-config-custom": "0.0.0"
|
|
52
|
+
"tsconfig": "workspace:*",
|
|
53
|
+
"typescript": "^4.5.2"
|
|
40
54
|
},
|
|
41
55
|
"dependencies": {
|
|
42
56
|
"@radix-ui/react-accordion": "^1.1.2",
|
|
@@ -76,19 +90,5 @@
|
|
|
76
90
|
"tailwind-merge": "^1.13.2",
|
|
77
91
|
"tailwindcss-animate": "^1.0.6",
|
|
78
92
|
"vaul": "0.9.1"
|
|
79
|
-
},
|
|
80
|
-
"scripts": {
|
|
81
|
-
"clean": "rm -rf dist node_modules",
|
|
82
|
-
"lint": "eslint \"**/*.ts*\"",
|
|
83
|
-
"ui:add": "pnpm dlx shadcn-ui@latest add",
|
|
84
|
-
"build:styles": "postcss styles/globals.css -o dist/styles.css",
|
|
85
|
-
"build:ts": "tsc -p tsconfig.json && tsc-alias",
|
|
86
|
-
"build": "pnpm run build:ts && pnpm run build:styles",
|
|
87
|
-
"dev:ts": "tsc -w -p tsconfig.json",
|
|
88
|
-
"dev:styles": "npx tailwindcss -i styles/globals.css -o dist/styles.css --watch",
|
|
89
|
-
"dev": "concurrently \"pnpm run dev:ts\" \"pnpm run dev:styles\"",
|
|
90
|
-
"test": "jest",
|
|
91
|
-
"test:silent": "jest --silent",
|
|
92
|
-
"test:watch": "jest --watch"
|
|
93
93
|
}
|
|
94
|
-
}
|
|
94
|
+
}
|
|
@@ -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,15 +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
|
-
}
|
|
@@ -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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-tap.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-tap.ts"],"names":[],"mappings":"AACA,OAAO,KAAmD,MAAM,OAAO,CAAA;AAuFvE,QAAA,MAAM,MAAM;6BAuBkC,GAAG,KAAK,IAAI,aACvC,GAAG;;;CAerB,CAAA;AAED,OAAO,EAAE,MAAM,EAAE,CAAA"}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
import { useState, useEffect, useCallback, useRef } from "react"
|
|
3
|
-
// Shared manager for all instances of the hook
|
|
4
|
-
const tapManager = (() => {
|
|
5
|
-
const elements = new Map()
|
|
6
|
-
let isListening = false
|
|
7
|
-
const startListening = () => {
|
|
8
|
-
if (isListening) return
|
|
9
|
-
const handleTouchStart = (e) => {
|
|
10
|
-
const touch = e.touches[0]
|
|
11
|
-
elements.forEach((data, el) => {
|
|
12
|
-
if (el.contains(touch.target)) {
|
|
13
|
-
data.touchStarted = true
|
|
14
|
-
data.touchMoved = false
|
|
15
|
-
data.startPosition = { x: touch.clientX, y: touch.clientY }
|
|
16
|
-
// Don't set isPressed here, wait to determine if it's a tap or drag
|
|
17
|
-
}
|
|
18
|
-
})
|
|
19
|
-
}
|
|
20
|
-
const handleTouchMove = (e) => {
|
|
21
|
-
const touch = e.touches[0]
|
|
22
|
-
elements.forEach((data, el) => {
|
|
23
|
-
if (data.touchStarted) {
|
|
24
|
-
const deltaX = Math.abs(touch.clientX - data.startPosition.x)
|
|
25
|
-
const deltaY = Math.abs(touch.clientY - data.startPosition.y)
|
|
26
|
-
if (deltaX > data.tapThreshold || deltaY > data.tapThreshold) {
|
|
27
|
-
data.touchMoved = true
|
|
28
|
-
data.setIsPressed(false)
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
})
|
|
32
|
-
}
|
|
33
|
-
const handleTouchEnd = () => {
|
|
34
|
-
elements.forEach((data) => {
|
|
35
|
-
if (data.touchStarted) {
|
|
36
|
-
data.touchStarted = false
|
|
37
|
-
if (!data.touchMoved) {
|
|
38
|
-
// It's a tap, set isPressed briefly
|
|
39
|
-
data.setIsPressed(true)
|
|
40
|
-
setTimeout(() => data.setIsPressed(false), 100)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
})
|
|
44
|
-
}
|
|
45
|
-
document.addEventListener("touchstart", (e) => handleTouchStart(e), {
|
|
46
|
-
passive: true,
|
|
47
|
-
})
|
|
48
|
-
document.addEventListener("touchmove", (e) => handleTouchMove(e), {
|
|
49
|
-
passive: true,
|
|
50
|
-
})
|
|
51
|
-
document.addEventListener("touchend", () => handleTouchEnd(), {
|
|
52
|
-
passive: true,
|
|
53
|
-
})
|
|
54
|
-
isListening = true
|
|
55
|
-
}
|
|
56
|
-
return {
|
|
57
|
-
register: (el, data) => {
|
|
58
|
-
elements.set(el, data)
|
|
59
|
-
startListening()
|
|
60
|
-
},
|
|
61
|
-
unregister: (el) => {
|
|
62
|
-
elements.delete(el)
|
|
63
|
-
},
|
|
64
|
-
elements,
|
|
65
|
-
}
|
|
66
|
-
})()
|
|
67
|
-
const useTap = (tapThreshold = 10) => {
|
|
68
|
-
const [isPressed, setIsPressed] = useState(false)
|
|
69
|
-
const elementRef = useRef(null)
|
|
70
|
-
useEffect(() => {
|
|
71
|
-
const element = elementRef.current
|
|
72
|
-
if (!element) return
|
|
73
|
-
const data = {
|
|
74
|
-
touchStarted: false,
|
|
75
|
-
touchMoved: false,
|
|
76
|
-
startPosition: { x: 0, y: 0 },
|
|
77
|
-
setIsPressed,
|
|
78
|
-
tapThreshold,
|
|
79
|
-
}
|
|
80
|
-
tapManager.register(element, data)
|
|
81
|
-
return () => {
|
|
82
|
-
tapManager.unregister(element)
|
|
83
|
-
}
|
|
84
|
-
}, [tapThreshold])
|
|
85
|
-
const onTap = useCallback((handler) => {
|
|
86
|
-
return (event) => {
|
|
87
|
-
const data = tapManager.elements.get(elementRef.current)
|
|
88
|
-
if (!data) return
|
|
89
|
-
if (event.type === "touchend" && !data.touchMoved) {
|
|
90
|
-
handler(event)
|
|
91
|
-
} else if (event.type === "click" && !data.touchStarted) {
|
|
92
|
-
handler(event)
|
|
93
|
-
setIsPressed(true)
|
|
94
|
-
setTimeout(() => setIsPressed(false), 100)
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}, [])
|
|
98
|
-
return { onTap, isPressed, ref: elementRef }
|
|
99
|
-
}
|
|
100
|
-
export { useTap }
|