@tapcart/mobile-components 0.8.21 → 0.8.25

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.
@@ -2,6 +2,8 @@ import { PhoenixBlock } from "app-studio-types";
2
2
  export declare const useBlockConditionalRendering: (_props: {
3
3
  appId: string;
4
4
  apiUrl: string;
5
+ deviceVariables: any;
6
+ customerVariables: any;
5
7
  }, _block: PhoenixBlock) => {
6
8
  shouldShow: boolean;
7
9
  isLoading: boolean;
@@ -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;AAgBzB,eAAO,MAAM,4BAA4B,WAC/B;IACN,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf,UACO,YAAY;;;CA8KrB,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;AAczB,eAAO,MAAM,4BAA4B,WAC/B;IACN,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,eAAe,EAAE,GAAG,CAAA;IACpB,iBAAiB,EAAE,GAAG,CAAA;CACvB,UACO,YAAY;;;CA+KrB,CAAA"}
@@ -14,19 +14,17 @@ import { useMemo } from "react";
14
14
  import { useProducts } from "./use-products";
15
15
  import { useCollection } from "./use-collection";
16
16
  import { useSearchParams } from "next/navigation";
17
- //@ts-expect-error
18
- import { useVariables } from "@tapcart/webbridge-react";
19
17
  import { gidFromId, countNumberOfTagsInState, getEnvState, shouldShowBlock, evaluateConditions, } from "../../lib/utils";
20
18
  export const useBlockConditionalRendering = (_props, _block) => {
21
19
  var _a, _b, _c, _d, _e;
22
20
  const _f = ((_a = _block === null || _block === void 0 ? void 0 : _block.visibilityConditions) === null || _a === void 0 ? void 0 : _a.conditions) || {}, { enabled: conditionalsV1IsEnabled = false, exclude: isInverse = false } = _f, restOfProps = __rest(_f, ["enabled", "exclude"]);
23
21
  const { _version = 1, conditions, enabled: conditionalsV2IsEnabled = false, } = (_block === null || _block === void 0 ? void 0 : _block.visibilityConditions) || {};
22
+ if (!conditionalsV1IsEnabled && !conditionalsV2IsEnabled) {
23
+ return { shouldShow: true, isLoading: false };
24
+ }
24
25
  const blockState = restOfProps;
25
- const { appId = "", apiUrl = "" } = _props;
26
+ const { appId = "", apiUrl = "", deviceVariables, customerVariables } = _props;
26
27
  const searchParams = useSearchParams();
27
- const variables = useVariables();
28
- const deviceVariables = variables === null || variables === void 0 ? void 0 : variables.device;
29
- const customerVariables = variables === null || variables === void 0 ? void 0 : variables.customer;
30
28
  // locale is provided in this form en_US
31
29
  const [language, country] = ((_b = deviceVariables === null || deviceVariables === void 0 ? void 0 : deviceVariables.locale) === null || _b === void 0 ? void 0 : _b.split("_")) || [];
32
30
  const productId = (_c = searchParams === null || searchParams === void 0 ? void 0 : searchParams.get("productId")) !== null && _c !== void 0 ? _c : undefined;
@@ -8,11 +8,13 @@ interface UseCollectionProps {
8
8
  language: string;
9
9
  getCollections?: boolean;
10
10
  limit?: number;
11
+ fetchMaxProduct?: boolean;
11
12
  metafields?: string;
12
13
  }
13
- export declare const useCollection: ({ apiUrl, appId, collectionId, collectionHandle, collectionIdList, language, limit, getCollections, metafields, }: UseCollectionProps) => {
14
+ export declare const useCollection: ({ apiUrl, appId, collectionId, collectionHandle, collectionIdList, language, limit, getCollections, metafields, fetchMaxProduct, }: UseCollectionProps) => {
14
15
  collections: Collection[];
15
16
  specificCollection: Collection | null;
17
+ maxProductCollection: Collection | null;
16
18
  loading: boolean;
17
19
  error: string | null;
18
20
  };
@@ -1 +1 @@
1
- {"version":3,"file":"use-collection.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-collection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAG7C,UAAU,kBAAkB;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAqFD,eAAO,MAAM,aAAa,sHAUvB,kBAAkB;;;;;CA6DpB,CAAA"}
1
+ {"version":3,"file":"use-collection.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-collection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAG7C,UAAU,kBAAkB;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AA2GD,eAAO,MAAM,aAAa,uIAWvB,kBAAkB;;;;;;CA8EpB,CAAA"}
@@ -43,14 +43,26 @@ const fetchAllCollections = (apiUrl, setError, limit = 100) => __awaiter(void 0,
43
43
  }).toString();
44
44
  return yield fetchWrapper(`${apiUrl}/collections/by-app-id?${limitParam}`, setError);
45
45
  });
46
- export const useCollection = ({ apiUrl, appId, collectionId, collectionHandle, collectionIdList, language, limit = 100, getCollections = false, metafields, }) => {
46
+ const fetchCollectionWithMaxProduct = (apiUrl, setError, limit = 100) => __awaiter(void 0, void 0, void 0, function* () {
47
+ const params = new URLSearchParams({
48
+ limit: `${limit}`,
49
+ fetchMaxProduct: "true",
50
+ }).toString();
51
+ return yield fetchWrapper(`${apiUrl}/collections/by-app-id?${params}`, setError);
52
+ });
53
+ export const useCollection = ({ apiUrl, appId, collectionId, collectionHandle, collectionIdList, language, limit = 100, getCollections = false, metafields, fetchMaxProduct = false, }) => {
47
54
  const [collections, setCollections] = useState([]);
48
55
  const [specificCollection, setSpecificCollection] = useState(null);
56
+ const [maxProductCollection, setMaxProductCollection] = useState(null);
49
57
  const [loading, setLoading] = useState(true);
50
58
  const [error, setError] = useState(null);
51
59
  useEffect(() => {
52
60
  const fetchAllOrSumCollections = () => __awaiter(void 0, void 0, void 0, function* () {
53
61
  try {
62
+ if (fetchMaxProduct) {
63
+ const collection = yield fetchCollectionWithMaxProduct(apiUrl, setError, limit);
64
+ return setMaxProductCollection(collection);
65
+ }
54
66
  if (getCollections) {
55
67
  const collections = yield fetchAllCollections(apiUrl, setError, limit);
56
68
  return setCollections(collections !== null && collections !== void 0 ? collections : []);
@@ -85,5 +97,11 @@ export const useCollection = ({ apiUrl, appId, collectionId, collectionHandle, c
85
97
  collectionIdList,
86
98
  metafields,
87
99
  ]);
88
- return { collections, specificCollection, loading, error };
100
+ return {
101
+ collections,
102
+ specificCollection,
103
+ maxProductCollection,
104
+ loading,
105
+ error,
106
+ };
89
107
  };
@@ -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,gCAGrB,sBAAsB,KAAG,uBAmC3B,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;AAOtD,UAAU,sBAAsB;IAC9B,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACnC,MAAM,EAAE,MAAM,CAAA;CACf;AASD,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;AAiBD,QAAA,MAAM,kBAAkB,gCAGrB,sBAAsB,KAAG,uBA6D3B,CAAA;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAA"}
@@ -1,18 +1,43 @@
1
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
+ };
2
11
  import { useSearchParams } from "next/navigation";
12
+ import RecommendationsLocalStorage from "../libs/cache/RecommendationsLocalStorage";
13
+ import React from "react";
3
14
  import useSWR from "swr";
4
15
  const constructURL = (apiURL) => {
5
16
  const url = new URL(apiURL);
6
17
  return url.toString();
7
18
  };
19
+ const getCollections = (collections) => {
20
+ return collections
21
+ ? collections === null || collections === void 0 ? void 0 : collections.filter((obj) => obj.handle !== "empty-collection")
22
+ : [];
23
+ };
24
+ const recommendationsLocalStorage = new RecommendationsLocalStorage();
8
25
  const useRecommendations = ({ queryVariables, apiURL, }) => {
9
- var _a;
10
26
  const searchParams = useSearchParams();
11
27
  const recommendation = (searchParams === null || searchParams === void 0 ? void 0 : searchParams.get("recommendation")) || "";
28
+ const [cachedRecommendation, setCachedRecommendations] = React.useState(recommendationsLocalStorage.getCacheItem({
29
+ id: `${recommendation}-${queryVariables === null || queryVariables === void 0 ? void 0 : queryVariables.language}`,
30
+ }));
12
31
  const fetcher = (body) => fetch(constructURL(apiURL), {
13
32
  method: "POST",
14
33
  body: JSON.stringify(body),
15
- }).then((res) => res.json());
34
+ }).then((res) => __awaiter(void 0, void 0, void 0, function* () {
35
+ const data = yield res.json();
36
+ if (recommendation === "") {
37
+ recommendationsLocalStorage.setCacheItem(Object.assign({ id: `${queryVariables === null || queryVariables === void 0 ? void 0 : queryVariables.language}` }, data));
38
+ }
39
+ return data;
40
+ }));
16
41
  const { data, error, isLoading } = useSWR({
17
42
  appId: queryVariables.appId,
18
43
  query: recommendation,
@@ -21,12 +46,22 @@ const useRecommendations = ({ queryVariables, apiURL, }) => {
21
46
  revalidateOnFocus: false,
22
47
  revalidateOnReconnect: false,
23
48
  });
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");
49
+ React.useEffect(() => {
50
+ if (!data) {
51
+ return;
52
+ }
53
+ setCachedRecommendations({
54
+ id: `${recommendation}-${queryVariables === null || queryVariables === void 0 ? void 0 : queryVariables.language}`,
55
+ products: data === null || data === void 0 ? void 0 : data.products,
56
+ collections: getCollections(data === null || data === void 0 ? void 0 : data.collections),
57
+ searches: data === null || data === void 0 ? void 0 : data.searches,
58
+ });
59
+ }, [data]);
25
60
  return {
26
- products: data === null || data === void 0 ? void 0 : data.products,
27
- collections: recommendation === "*" ? [] : collections,
28
- searches: data === null || data === void 0 ? void 0 : data.searches,
29
- isLoading: isLoading,
61
+ products: cachedRecommendation === null || cachedRecommendation === void 0 ? void 0 : cachedRecommendation.products,
62
+ collections: cachedRecommendation === null || cachedRecommendation === void 0 ? void 0 : cachedRecommendation.collections,
63
+ searches: cachedRecommendation === null || cachedRecommendation === void 0 ? void 0 : cachedRecommendation.searches,
64
+ isLoading: !cachedRecommendation && isLoading,
30
65
  error: error,
31
66
  };
32
67
  };
@@ -0,0 +1,30 @@
1
+ import AppStudioCache from "./AppStudioCache";
2
+ type CachedRecommendation = {
3
+ id: string;
4
+ ct: number;
5
+ [key: string]: any;
6
+ };
7
+ export default class RecommendationsLocalStorage extends AppStudioCache {
8
+ adapter: string;
9
+ cachePrefix: string;
10
+ getQueryCacheKey(id: string): string;
11
+ constructor();
12
+ getCache(): CachedRecommendation[];
13
+ getCacheItem({ id }: {
14
+ id: string;
15
+ }): object | null;
16
+ setCacheItem(recommendation: {
17
+ id: string;
18
+ }, cache?: CachedRecommendation[], shouldExpire?: boolean): {
19
+ id: string;
20
+ } | undefined;
21
+ setCacheItems(items: {
22
+ id: string;
23
+ }[]): ({
24
+ id: string;
25
+ } | undefined)[];
26
+ expireCacheData(numNewItems?: number): void;
27
+ clearCache(): void;
28
+ }
29
+ export {};
30
+ //# sourceMappingURL=RecommendationsLocalStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RecommendationsLocalStorage.d.ts","sourceRoot":"","sources":["../../../../components/libs/cache/RecommendationsLocalStorage.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAE7C,KAAK,oBAAoB,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,EAAE,EAAE,MAAM,CAAA;IACV,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACnB,CAAA;AAED,MAAM,CAAC,OAAO,OAAO,2BAA4B,SAAQ,cAAc;IACrE,OAAO,EAAE,MAAM,CAAiC;IAChD,WAAW,EAAE,MAAM,CAAsB;IAEzC,gBAAgB,CAAC,EAAE,EAAE,MAAM;;IAQ3B,QAAQ,IAAI,oBAAoB,EAAE;IAiBlC,YAAY,CAAC,EAAE,EAAE,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,GAAG,IAAI;IAOnD,YAAY,CACV,cAAc,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,EAC9B,KAAK,CAAC,EAAE,oBAAoB,EAAE,EAC9B,YAAY,GAAE,OAAc;YAFN,MAAM;;IAiB9B,aAAa,CAAC,KAAK,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,EAAE;;;IASrC,eAAe,CAAC,WAAW,GAAE,MAAU;IAUvC,UAAU;CAMX"}
@@ -0,0 +1,67 @@
1
+ import AppStudioCache from "./AppStudioCache";
2
+ export default class RecommendationsLocalStorage extends AppStudioCache {
3
+ getQueryCacheKey(id) {
4
+ return `${this.cachePrefix}-data-${id}`;
5
+ }
6
+ constructor() {
7
+ super();
8
+ this.adapter = "local-storage-recommendation";
9
+ this.cachePrefix = "as-recommendation";
10
+ }
11
+ getCache() {
12
+ const items = [];
13
+ for (let i = 0; i < localStorage.length; i++) {
14
+ const key = localStorage.key(i);
15
+ if (key === null || key === void 0 ? void 0 : key.startsWith(this.getQueryCacheKey(""))) {
16
+ const value = localStorage.getItem(key);
17
+ if (value) {
18
+ const parsedValue = JSON.parse(value);
19
+ if (parsedValue === null || parsedValue === void 0 ? void 0 : parsedValue.id) {
20
+ items.push(JSON.parse(value));
21
+ }
22
+ }
23
+ }
24
+ }
25
+ return items;
26
+ }
27
+ getCacheItem({ id }) {
28
+ if (!(id === null || id === void 0 ? void 0 : id.length))
29
+ return null;
30
+ const item = localStorage.getItem(this.getQueryCacheKey(id));
31
+ if (!item)
32
+ return null;
33
+ return JSON.parse(item);
34
+ }
35
+ setCacheItem(recommendation, cache, shouldExpire = true) {
36
+ var _a;
37
+ if (!((_a = recommendation.id) === null || _a === void 0 ? void 0 : _a.length))
38
+ return;
39
+ if (shouldExpire) {
40
+ this.expireCacheData();
41
+ }
42
+ localStorage.setItem(this.getQueryCacheKey(recommendation.id), JSON.stringify(Object.assign(Object.assign({}, recommendation), { ct: Date.now() })));
43
+ return recommendation;
44
+ }
45
+ setCacheItems(items) {
46
+ this.expireCacheData(items.length);
47
+ const cache = this.getCache();
48
+ const cachedItems = items.map((item) => this.setCacheItem(item, cache, false));
49
+ return cachedItems;
50
+ }
51
+ expireCacheData(numNewItems = 0) {
52
+ const cacheItems = this.getCache();
53
+ if (cacheItems.length + numNewItems < 20)
54
+ return;
55
+ const numItemsToDelete = Math.max(10, numNewItems);
56
+ cacheItems.sort((a, b) => a.ct - b.ct);
57
+ cacheItems.slice(0, numItemsToDelete).forEach((item) => {
58
+ localStorage.removeItem(this.getQueryCacheKey(item.id));
59
+ });
60
+ }
61
+ clearCache() {
62
+ const cacheItems = this.getCache();
63
+ cacheItems.forEach((item) => {
64
+ localStorage.removeItem(this.getQueryCacheKey(item.id));
65
+ });
66
+ }
67
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../components/ui/button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAGL,KAAK,EAEL,SAAS,EAET,oBAAoB,EACrB,MAAM,iBAAiB,CAAA;AAIxB,QAAA,MAAM,cAAc;;;mFAgCnB,CAAA;AA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../../lib/utils";
17
17
  import { Icon } from "./icon";
18
18
  import { Text } from "./text";
19
+ import { useTap } from "./tap";
20
+ import { useMergeRefs } from "../hooks/use-merge-refs";
19
21
  const buttonVariants = cva("w-full flex rounded items-center justify-center transition-colors disabled:bg-stateColors-disabled disabled:border-stateColors-disabled disabled:pointer-events-none ring-offset-background overflow-elipse whitespace-nowrap truncate disabled:opacity-70 cursor-pointer", {
20
22
  variants: {
21
23
  size: {
@@ -80,6 +82,8 @@ const labelVariants = cva("truncate", {
80
82
  });
81
83
  const Button = React.forwardRef((_a, ref) => {
82
84
  var { className, labelClassName, labelStyle, variant, size, asChild = false, loading, icon, iconColor, iconStrokeColor, iconPosition, iconSize, iconUrl, iconClassName, onClick } = _a, props = __rest(_a, ["className", "labelClassName", "labelStyle", "variant", "size", "asChild", "loading", "icon", "iconColor", "iconStrokeColor", "iconPosition", "iconSize", "iconUrl", "iconClassName", "onClick"]);
85
+ const { onTap, isPressed, ref: tapRef } = useTap();
86
+ const mergedRef = useMergeRefs(ref, tapRef);
83
87
  const Comp = asChild ? Slot : "button";
84
88
  const IconButton = () => icon || iconUrl ? (_jsx(Icon, { name: icon, url: iconUrl, size: "sm", style: { color: iconColor } })) : null;
85
89
  // TODO: need to refactor icon sizing. This isnt extensible.
@@ -91,7 +95,7 @@ const Button = React.forwardRef((_a, ref) => {
91
95
  return (_jsx(Comp, Object.assign({ className: cn(buttonVariants({ variant, size }), className, {
92
96
  "pointer-events-none": loading,
93
97
  "flex-row-reverse": (icon || iconUrl) && iconPosition === "right",
94
- }), ref: ref, onClick: onClick }, props, { children: loading ? (_jsx(LoadingButton, {})) : typeof props.children === "object" &&
98
+ }), ref: mergedRef, onClick: onTap(onClick) }, props, { children: loading ? (_jsx(LoadingButton, {})) : typeof props.children === "object" &&
95
99
  React.isValidElement(props.children) ? ( // if children are passed as a valid React element
96
100
  props.children // render it
97
101
  ) : // otherwise use props
@@ -4,6 +4,7 @@ export interface LoadingDotsProps {
4
4
  spacing?: 0 | 1 | 2 | 4;
5
5
  opacity?: number;
6
6
  show?: boolean;
7
+ showBackground?: boolean;
7
8
  }
8
- export declare const LoadingDots: ({ iconColor, size, spacing, opacity, show, }: LoadingDotsProps) => import("react/jsx-runtime").JSX.Element | null;
9
+ export declare const LoadingDots: ({ iconColor, size, spacing, opacity, show, showBackground, }: LoadingDotsProps) => import("react/jsx-runtime").JSX.Element | null;
9
10
  //# sourceMappingURL=loading-dots.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"loading-dots.d.ts","sourceRoot":"","sources":["../../../components/ui/loading-dots.tsx"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACvB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AAED,eAAO,MAAM,WAAW,iDAMrB,gBAAgB,mDAyClB,CAAA"}
1
+ {"version":3,"file":"loading-dots.d.ts","sourceRoot":"","sources":["../../../components/ui/loading-dots.tsx"],"names":[],"mappings":"AAGA,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACvB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB;AAED,eAAO,MAAM,WAAW,iEAOrB,gBAAgB,mDA6ClB,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cn } from "../../lib/utils";
2
3
  import React from "react";
3
- export const LoadingDots = ({ iconColor, size = 4, spacing = 1, opacity = 0.8, show = false, }) => {
4
+ export const LoadingDots = ({ iconColor, size = 4, spacing = 1, opacity = 0.8, show = false, showBackground = true, }) => {
4
5
  const [showLoadingDots, setShowLoadingDots] = React.useState(show);
5
6
  const [isAnimatingOut, setIsAnimatingOut] = React.useState(false);
6
7
  React.useEffect(() => {
@@ -18,5 +19,7 @@ export const LoadingDots = ({ iconColor, size = 4, spacing = 1, opacity = 0.8, s
18
19
  }, [show]);
19
20
  if (!showLoadingDots)
20
21
  return null;
21
- return (_jsx("div", Object.assign({ className: `absolute inset-0 flex items-center justify-center bg-white bg-opacity-70 ${isAnimatingOut ? "animate-fadeOut" : "animate-fadeIn"}` }, { children: _jsxs("div", Object.assign({ className: `flex space-x-${spacing}` }, { children: [_jsx("div", { style: { backgroundColor: iconColor, opacity: opacity }, className: `h-${size} w-${size} bg-black rounded-full animate-bounce [animation-delay:-0.3s]` }), _jsx("div", { style: { backgroundColor: iconColor, opacity: opacity }, className: `h-${size} w-${size} bg-black rounded-full animate-bounce [animation-delay:-0.15s]` }), _jsx("div", { style: { backgroundColor: iconColor, opacity: opacity }, className: `h-${size} w-${size} bg-black rounded-full animate-bounce` })] })) })));
22
+ return (_jsx("div", Object.assign({ className: cn("absolute inset-0 flex items-center justify-center", isAnimatingOut ? "animate-fadeOut" : "animate-fadeIn", {
23
+ "bg-white bg-opacity-70": showBackground,
24
+ }) }, { children: _jsxs("div", Object.assign({ className: `flex space-x-${spacing}` }, { children: [_jsx("div", { style: { backgroundColor: iconColor, opacity: opacity }, className: `h-${size} w-${size} bg-black rounded-full animate-bounce [animation-delay:-0.3s]` }), _jsx("div", { style: { backgroundColor: iconColor, opacity: opacity }, className: `h-${size} w-${size} bg-black rounded-full animate-bounce [animation-delay:-0.15s]` }), _jsx("div", { style: { backgroundColor: iconColor, opacity: opacity }, className: `h-${size} w-${size} bg-black rounded-full animate-bounce` })] })) })));
22
25
  };
@@ -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;AAMjE,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;IACxB,OAAO,CAAC,EAAE;QACR,aAAa,EAAE,MAAM,CAAA;QACrB,WAAW,EAAE,MAAM,CAAA;KACpB,CAAA;IACD,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;CAC5B;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,EACV,OAGC,EACD,KAAK,GACN,EAAE,gBAAgB,2CAwElB;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;AAMjE,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;IACxB,OAAO,CAAC,EAAE;QACR,aAAa,EAAE,MAAM,CAAA;QACrB,WAAW,EAAE,MAAM,CAAA;KACpB,CAAA;IACD,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;CAC5B;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,EACV,OAGC,EACD,KAAK,GACN,EAAE,gBAAgB,2CAqElB;AAED,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,CAAA"}
@@ -36,8 +36,7 @@ function VirtualGrid({ className, columns, children, overscan = 4, estimatedHeig
36
36
  });
37
37
  return (_jsx(Container, Object.assign({ style: style }, { children: _jsx("div", Object.assign({ style: {
38
38
  width: "100%",
39
- height: (Math.ceil(childrenArray.length / col) - 1) * spacing.verticalGap +
40
- rowVirtualizer.totalSize,
39
+ height: rowVirtualizer.totalSize,
41
40
  position: "relative",
42
41
  } }, { children: rowVirtualizer.virtualItems.map((virtualRow) => {
43
42
  const rowStartIndex = virtualRow.index * col;
@@ -46,8 +45,9 @@ function VirtualGrid({ className, columns, children, overscan = 4, estimatedHeig
46
45
  top: 0,
47
46
  left: 0,
48
47
  width: "100%",
49
- transform: `translateY(${virtualRow.start + virtualRow.index * spacing.verticalGap}px)`,
48
+ transform: `translateY(${virtualRow.start}px)`,
50
49
  columnGap: `${spacing === null || spacing === void 0 ? void 0 : spacing.horizontalGap}px`,
50
+ paddingBottom: `${spacing === null || spacing === void 0 ? void 0 : spacing.verticalGap}px`,
51
51
  }, ref: virtualRow.measureRef }, { children: Array.from({ length: col }).map((_, colIndex) => {
52
52
  const index = rowStartIndex + colIndex;
53
53
  if (index >= childrenArray.length && !isReachingEnd)
package/dist/styles.css CHANGED
@@ -2115,6 +2115,9 @@ video {
2115
2115
  .text-textColors-strikethroughPriceText {
2116
2116
  color: var(--textColors-strikethroughPriceText);
2117
2117
  }
2118
+ .underline {
2119
+ text-decoration-line: underline;
2120
+ }
2118
2121
  .line-through {
2119
2122
  text-decoration-line: line-through;
2120
2123
  }
@@ -2279,9 +2282,6 @@ video {
2279
2282
  transform: translate3d(var(--tw-exit-translate-x, 0), var(--tw-exit-translate-y, 0), 0) scale3d(var(--tw-exit-scale, 1), var(--tw-exit-scale, 1), var(--tw-exit-scale, 1)) rotate(var(--tw-exit-rotate, 0));
2280
2283
  }
2281
2284
  }
2282
- .fade-in {
2283
- --tw-enter-opacity: 0;
2284
- }
2285
2285
  .duration-150 {
2286
2286
  animation-duration: 150ms;
2287
2287
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapcart/mobile-components",
3
- "version": "0.8.21",
3
+ "version": "0.8.25",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "style": "dist/styles.css",