@tapcart/mobile-components 0.7.69 → 0.7.70

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.
@@ -41,7 +41,7 @@ const constructURL = (apiURL) => {
41
41
  const url = new URL(apiURL);
42
42
  return url.toString();
43
43
  };
44
- const useInfiniteScroll = ({ initialData, queryVariables: queryVariableProps, direction = "vertical", productLimit = Infinity, threshold = 0.8, interval = 300, }) => {
44
+ const useInfiniteScroll = ({ initialData, queryVariables: queryVariableProps, direction = "vertical", productLimit = Infinity, threshold = 0.01, interval = 300, }) => {
45
45
  var _a, _b, _c, _d, _e;
46
46
  const searchParams = useSearchParams();
47
47
  const productCount = useRef(0);
@@ -1 +1 @@
1
- {"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../components/ui/image.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,KAAK,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAmC1D,KAAK,aAAa,GAAG;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,gBAAgB,EAAE,MAAM,CAAA;CACzB,CAAA;AAUD,MAAM,MAAM,YAAY,GAAG;IACzB,GAAG,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,CAAA;IACtB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB,CAAA;AAED,MAAM,MAAM,MAAM,GAAG,CAAC,MAAM,EAAE,YAAY,KAAK,MAAM,CAAA;AAKrD,KAAK,IAAI,GAAG,QAAQ,GAAG,KAAK,GAAG,QAAQ,GAAG,MAA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G;AACH,wBAAgB,mBAAmB,CACjC,KAAK,6BAA0B,EAC/B,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,GACpB,MAAM,EAAE,CAUV;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAIzE;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,WAAW,CAAC,EAAE,MAAM,EAAE,EACtB,WAAW,CAAC,EAAE,MAAM,EACpB,IAAI,GAAE,IAAe,GAEnB;IACE,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,IAAI,EAAE,IAAI,CAAA;CACX,EAAE,GACH,SAAS,CAUZ"}
@@ -14,7 +14,6 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
14
14
  /* eslint-disable @next/next/no-img-element */
15
15
  import * as React from "react";
16
16
  import ReactDOM from "react-dom";
17
- import { cn } from "../../lib/utils";
18
17
  function ImagePreload({ imgAttributes }) {
19
18
  const opts = {
20
19
  as: "image",
@@ -176,16 +175,14 @@ export const Image = React.forwardRef((_a, ref) => {
176
175
  sizes,
177
176
  fetchPriority: normalizedProps.fetchPriority,
178
177
  src: normalizedProps.src || "",
179
- } })), _jsx("div", Object.assign({ className: cn("relative border-transparent", {
180
- "bg-stateColors-skeleton": hasError || !isLoaded,
181
- }), style: Object.assign({ borderRadius: `${imageRadius}px` }, wrapperStyle) }, { children: !hasError && normalizedProps.src ? (_jsx("img", Object.assign({}, passthroughProps, { fetchPriority: normalizedProps.fetchPriority, alt: normalizedProps.alt, decoding: decoding, height: normalizedProps.height, loading: loading, srcSet: srcSet, width: normalizedProps.width, className: imgClassName, onLoad: handleImageLoad, onError: handleImageError, sizes: sizes,
178
+ } })), _jsx("div", Object.assign({ className: "relative border-transparent bg-stateColors-skeleton", style: Object.assign({ borderRadius: `${imageRadius}px` }, wrapperStyle) }, { children: !hasError && normalizedProps.src ? (_jsx("img", Object.assign({}, passthroughProps, { fetchPriority: normalizedProps.fetchPriority, alt: normalizedProps.alt, decoding: decoding, height: normalizedProps.height, loading: loading, srcSet: srcSet, width: normalizedProps.width, className: imgClassName, onLoad: handleImageLoad, onError: handleImageError, sizes: sizes,
182
179
  // `src` needs to come after `sizes` and `srcSet` because React updates
183
180
  // attributes in order. If we keep `src` the first one, Safari will
184
181
  // immediately start to fetch `src`, before `sizes` and `srcSet` are even
185
182
  // updated by React. That causes multiple unnecessary requests if `srcSet`
186
183
  // and `sizes` are defined.
187
184
  // This bug cannot be reproduced in Chrome or Firefox.
188
- src: normalizedProps.src, ref: setRefs, style: Object.assign({ objectFit: normalizedProps.objectFit, maxHeight: "100%", height: "100%", width: "100%", borderRadius: `${imageRadius}px` }, passthroughProps.style) }))) : (_jsx("div", { className: "w-full h-full bg-stateColors-skeleton", style: Object.assign({ aspectRatio: aspectRatio && aspectRatio !== "auto"
185
+ src: normalizedProps.src, ref: setRefs, style: Object.assign({ objectFit: normalizedProps.objectFit, maxHeight: "100%", height: "100%", width: "100%", borderRadius: `${imageRadius}px` }, passthroughProps.style) }))) : (_jsx("div", { className: "w-full h-full", style: Object.assign({ aspectRatio: aspectRatio && aspectRatio !== "auto"
189
186
  ? (_c = normalizedProps === null || normalizedProps === void 0 ? void 0 : normalizedProps.aspectRatio) === null || _c === void 0 ? void 0 : _c.replace(":", "/")
190
187
  : "2/3" }, imageWrapperStyles) })) }))] }));
191
188
  });
@@ -4,7 +4,8 @@ interface GridType {
4
4
  className: any;
5
5
  children: React.ReactNode;
6
6
  isLoadingMore: boolean;
7
- loaderItem: React.ReactNode;
7
+ isReachingEnd: boolean;
8
+ LoaderItem: React.FunctionComponent;
8
9
  overscan?: number;
9
10
  estimatedHeight?: number;
10
11
  }
@@ -13,6 +14,6 @@ declare const virtualGridVariants: (props?: ({
13
14
  } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
14
15
  export interface VirtualGridProps extends GridType, VariantProps<typeof virtualGridVariants> {
15
16
  }
16
- declare function VirtualGrid({ className, columns, children, overscan, estimatedHeight, isLoadingMore, loaderItem, }: VirtualGridProps): import("react/jsx-runtime").JSX.Element;
17
+ declare function VirtualGrid({ className, columns, children, overscan, estimatedHeight, isLoadingMore, isReachingEnd, LoaderItem, }: VirtualGridProps): import("react/jsx-runtime").JSX.Element;
17
18
  export { VirtualGrid, virtualGridVariants };
18
19
  //# sourceMappingURL=virtual-grid.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"virtual-grid.d.ts","sourceRoot":"","sources":["../../../components/ui/virtual-grid.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAKjE,UAAU,QAAQ;IAChB,SAAS,EAAE,GAAG,CAAA;IACd,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,aAAa,EAAE,OAAO,CAAA;IACtB,UAAU,EAAE,KAAK,CAAC,SAAS,CAAA;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AAED,QAAA,MAAM,mBAAmB;;mFAYvB,CAAA;AAEF,MAAM,WAAW,gBACf,SAAQ,QAAQ,EACd,YAAY,CAAC,OAAO,mBAAmB,CAAC;CAAG;AAE/C,iBAAS,WAAW,CAAC,EACnB,SAAS,EACT,OAAO,EACP,QAAQ,EACR,QAAY,EACZ,eAAqB,EACrB,aAAa,EACb,UAAU,GACX,EAAE,gBAAgB,2CA4ElB;AAED,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,CAAA"}
1
+ {"version":3,"file":"virtual-grid.d.ts","sourceRoot":"","sources":["../../../components/ui/virtual-grid.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAKjE,UAAU,QAAQ;IAChB,SAAS,EAAE,GAAG,CAAA;IACd,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,aAAa,EAAE,OAAO,CAAA;IACtB,aAAa,EAAE,OAAO,CAAA;IACtB,UAAU,EAAE,KAAK,CAAC,iBAAiB,CAAA;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AAED,QAAA,MAAM,mBAAmB;;mFAYvB,CAAA;AAEF,MAAM,WAAW,gBACf,SAAQ,QAAQ,EACd,YAAY,CAAC,OAAO,mBAAmB,CAAC;CAAG;AAE/C,iBAAS,WAAW,CAAC,EACnB,SAAS,EACT,OAAO,EACP,QAAQ,EACR,QAAY,EACZ,eAAqB,EACrB,aAAa,EACb,aAAa,EACb,UAAU,GACX,EAAE,gBAAgB,2CA+DlB;AAED,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,CAAA"}
@@ -16,13 +16,13 @@ const virtualGridVariants = cva("grid", {
16
16
  columns: 2,
17
17
  },
18
18
  });
19
- function VirtualGrid({ className, columns, children, overscan = 4, estimatedHeight = 375, isLoadingMore, loaderItem, }) {
19
+ function VirtualGrid({ className, columns, children, overscan = 4, estimatedHeight = 375, isLoadingMore, isReachingEnd, LoaderItem, }) {
20
20
  const NUM_LOADER_ITEMS = columns || 2;
21
21
  const col = columns || 2;
22
22
  const parentRef = React.useRef(document.getElementById("tc-vgsl"));
23
23
  const childrenArray = React.Children.toArray(children);
24
24
  const rowCount = Math.ceil(childrenArray.length / col);
25
- const totalItems = rowCount + (isLoadingMore ? 1 : 0);
25
+ const totalItems = rowCount;
26
26
  const rowVirtualizer = useVirtual({
27
27
  size: totalItems,
28
28
  parentRef,
@@ -36,15 +36,6 @@ function VirtualGrid({ className, columns, children, overscan = 4, estimatedHeig
36
36
  willChange: "transform",
37
37
  }, className: cn(virtualGridVariants({ columns }), className) }, { children: rowVirtualizer.virtualItems.map((virtualRow) => {
38
38
  const rowStartIndex = virtualRow.index * col;
39
- if (isLoadingMore && virtualRow.index === rowCount) {
40
- return (_jsx("div", Object.assign({ style: {
41
- position: "absolute",
42
- top: 0,
43
- left: 0,
44
- width: "100%",
45
- transform: `translateY(${virtualRow.start}px)`,
46
- }, className: cn(virtualGridVariants({ columns })), ref: virtualRow.measureRef }, { children: Array.from({ length: NUM_LOADER_ITEMS }).map((_, index) => (_jsx("div", { children: loaderItem }, index))) }), `loader-row-${virtualRow.index}`));
47
- }
48
39
  return (_jsx("div", Object.assign({ className: cn(virtualGridVariants({ columns })), style: {
49
40
  position: "absolute",
50
41
  top: 0,
@@ -53,8 +44,9 @@ function VirtualGrid({ className, columns, children, overscan = 4, estimatedHeig
53
44
  transform: `translateY(${virtualRow.start}px)`,
54
45
  }, ref: virtualRow.measureRef }, { children: Array.from({ length: col }).map((_, colIndex) => {
55
46
  const index = rowStartIndex + colIndex;
56
- if (index >= childrenArray.length)
57
- return null;
47
+ if ((index >= childrenArray.length && !isReachingEnd) ||
48
+ !childrenArray[index])
49
+ return (_jsx("div", { children: _jsx(LoaderItem, {}) }, index));
58
50
  return _jsx("div", { children: childrenArray[index] }, index);
59
51
  }) }), `row-${virtualRow.index}`));
60
52
  }) })));
package/dist/styles.css CHANGED
@@ -1443,10 +1443,18 @@ video {
1443
1443
  .rounded-sm {
1444
1444
  border-radius: calc(var(--radius) - 4px);
1445
1445
  }
1446
+ .rounded-b {
1447
+ border-bottom-right-radius: 0.25rem;
1448
+ border-bottom-left-radius: 0.25rem;
1449
+ }
1446
1450
  .rounded-b-lg {
1447
1451
  border-bottom-right-radius: var(--radius);
1448
1452
  border-bottom-left-radius: var(--radius);
1449
1453
  }
1454
+ .rounded-t {
1455
+ border-top-left-radius: 0.25rem;
1456
+ border-top-right-radius: 0.25rem;
1457
+ }
1450
1458
  .rounded-t-2xl {
1451
1459
  border-top-left-radius: 1rem;
1452
1460
  border-top-right-radius: 1rem;
@@ -2027,6 +2035,9 @@ video {
2027
2035
  .opacity-50 {
2028
2036
  opacity: 0.5;
2029
2037
  }
2038
+ .opacity-70 {
2039
+ opacity: 0.7;
2040
+ }
2030
2041
  .shadow {
2031
2042
  --tw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
2032
2043
  --tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapcart/mobile-components",
3
- "version": "0.7.69",
3
+ "version": "0.7.70",
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
48
  "postcss": "^8.4.24",
33
49
  "tailwindcss": "^3.3.2",
34
50
  "ts-jest": "^29.2.5",
35
51
  "tsc-alias": "^1.8.10",
36
- "typescript": "^4.5.2",
37
- "app-studio-types": "0.0.9",
38
- "eslint-config-custom": "0.0.0",
39
- "tsconfig": "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,6 +0,0 @@
1
- import React from "react"
2
- export declare function useClickOutside(
3
- ref: React.RefObject<HTMLElement>,
4
- callback: () => void
5
- ): void
6
- //# sourceMappingURL=use-click-outside.d.ts.map
@@ -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,7 +0,0 @@
1
- import React from "react"
2
- declare const useClickOutside: (
3
- ref: React.RefObject<HTMLElement>,
4
- callback: () => void
5
- ) => void
6
- export default useClickOutside
7
- //# sourceMappingURL=use-outside-click.d.ts.map
@@ -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,8 +0,0 @@
1
- import React from "react"
2
- declare const useTap: (tapThreshold?: number) => {
3
- onTap: (handler: (event: any) => void) => (event: any) => void
4
- isPressed: boolean
5
- ref: React.MutableRefObject<null>
6
- }
7
- export { useTap }
8
- //# sourceMappingURL=use-tap.d.ts.map
@@ -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 }