@tapcart/mobile-components 0.7.0 → 0.7.1
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-infinite-scroll.d.ts +3 -1
- package/dist/components/hooks/use-infinite-scroll.d.ts.map +1 -1
- package/dist/components/hooks/use-infinite-scroll.js +34 -11
- package/dist/components/hooks/use-products.d.ts +3 -1
- package/dist/components/hooks/use-products.d.ts.map +1 -1
- package/dist/components/hooks/use-products.js +19 -5
- package/dist/components/hooks/use-reviews.d.ts +27 -0
- package/dist/components/hooks/use-reviews.d.ts.map +1 -0
- package/dist/components/hooks/use-reviews.js +130 -0
- package/dist/components/ui/Input/input.d.ts +1 -1
- package/dist/components/ui/Input/input.d.ts.map +1 -1
- package/dist/components/ui/Input/input.js +23 -5
- package/dist/components/ui/Input/types.d.ts +3 -2
- package/dist/components/ui/Input/types.d.ts.map +1 -1
- package/dist/components/ui/Input/useInput.d.ts +2 -2
- package/dist/components/ui/Input/useInput.d.ts.map +1 -1
- package/dist/components/ui/Input/useInput.js +24 -10
- package/dist/components/ui/accordion.d.ts +3 -1
- package/dist/components/ui/accordion.d.ts.map +1 -1
- package/dist/components/ui/accordion.js +2 -2
- package/dist/components/ui/button.d.ts +2 -2
- package/dist/components/ui/button.d.ts.map +1 -1
- package/dist/components/ui/button.js +1 -1
- package/dist/components/ui/carousel.d.ts +1 -0
- package/dist/components/ui/carousel.d.ts.map +1 -1
- package/dist/components/ui/carousel.js +61 -2
- package/dist/components/ui/chip.d.ts +2 -2
- package/dist/components/ui/icon.d.ts +4 -1
- package/dist/components/ui/icon.d.ts.map +1 -1
- package/dist/components/ui/icon.js +35 -8
- package/dist/components/ui/image.d.ts.map +1 -1
- package/dist/components/ui/image.js +1 -1
- package/dist/components/ui/radio-group.d.ts +2 -2
- package/dist/components/ui/scroll-area.d.ts +1 -0
- package/dist/components/ui/scroll-area.d.ts.map +1 -1
- package/dist/components/ui/scroll-area.js +2 -2
- package/dist/components/ui/toast.d.ts +2 -2
- package/dist/components/ui/toggle-group.d.ts +2 -2
- package/dist/components/ui/toggle.d.ts +2 -2
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/dist/lib/utils.d.ts +16 -0
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +18 -0
- package/dist/styles.css +201 -727
- package/package.json +3 -2
- package/dist/components/templates/product-card.d.ts +0 -33
- package/dist/components/templates/product-card.d.ts.map +0 -1
- package/dist/components/templates/product-card.js +0 -42
- package/dist/components/templates/product-grid.d.ts +0 -14
- package/dist/components/templates/product-grid.d.ts.map +0 -1
- package/dist/components/templates/product-grid.js +0 -22
- package/dist/components/ui/input.d.ts +0 -17
- package/dist/components/ui/input.d.ts.map +0 -1
- package/dist/components/ui/input.js +0 -35
- package/dist/components/ui/product-grid.d.ts +0 -15
- package/dist/components/ui/product-grid.d.ts.map +0 -1
- package/dist/components/ui/product-grid.js +0 -22
- package/dist/components/ui/select.d.ts +0 -14
- package/dist/components/ui/select.d.ts.map +0 -1
- package/dist/components/ui/select.js +0 -59
|
@@ -11,6 +11,8 @@ interface PageData {
|
|
|
11
11
|
interface UseInfiniteScrollProps {
|
|
12
12
|
initialData: PageData;
|
|
13
13
|
queryVariables: Record<string, any>;
|
|
14
|
+
direction: "vertical" | "horizontal";
|
|
15
|
+
productLimit: number;
|
|
14
16
|
}
|
|
15
17
|
interface UseInfiniteScrollReturn {
|
|
16
18
|
data: PageData[] | undefined;
|
|
@@ -26,6 +28,6 @@ interface UseInfiniteScrollReturn {
|
|
|
26
28
|
}
|
|
27
29
|
export declare const formatSearchParamsAsNextQueryVariables: (searchParams: ReadonlyURLSearchParams) => {};
|
|
28
30
|
declare const constructURL: (apiURL: string) => string;
|
|
29
|
-
declare const useInfiniteScroll: ({ initialData, queryVariables: queryVariableProps, }: UseInfiniteScrollProps) => UseInfiniteScrollReturn;
|
|
31
|
+
declare const useInfiniteScroll: ({ initialData, queryVariables: queryVariableProps, direction, productLimit, }: UseInfiniteScrollProps) => UseInfiniteScrollReturn;
|
|
30
32
|
export { useInfiniteScroll, constructURL };
|
|
31
33
|
//# sourceMappingURL=use-infinite-scroll.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-infinite-scroll.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-infinite-scroll.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,uBAAuB,EAAmB,MAAM,iBAAiB,CAAA;AAE1E,UAAU,OAAO;IACf,MAAM,EAAE,MAAM,CAAA;CAEf;AAED,UAAU,QAAQ;IAChB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,GAAG,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;CACf;AAOD,UAAU,sBAAsB;IAC9B,WAAW,EAAE,QAAQ,CAAA;IACrB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"use-infinite-scroll.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-infinite-scroll.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,uBAAuB,EAAmB,MAAM,iBAAiB,CAAA;AAE1E,UAAU,OAAO;IACf,MAAM,EAAE,MAAM,CAAA;CAEf;AAED,UAAU,QAAQ;IAChB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,GAAG,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;CACf;AAOD,UAAU,sBAAsB;IAC9B,WAAW,EAAE,QAAQ,CAAA;IACrB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACnC,SAAS,EAAE,UAAU,GAAG,YAAY,CAAA;IACpC,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,UAAU,uBAAuB;IAC/B,IAAI,EAAE,QAAQ,EAAE,GAAG,SAAS,CAAA;IAC5B,KAAK,EAAE,GAAG,CAAA;IACV,oBAAoB,EAAE,OAAO,CAAA;IAC7B,aAAa,EAAE,OAAO,GAAG,SAAS,CAAA;IAClC,OAAO,EAAE,OAAO,CAAA;IAChB,aAAa,EAAE,OAAO,CAAA;IACtB,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,KAAK,IAAI,CAAA;IAChD,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,SAAS,EAAE,OAAO,CAAA;IAClB,YAAY,EAAE,OAAO,CAAA;CACtB;AAED,eAAO,MAAM,sCAAsC,iBACnC,uBAAuB,OAsBtC,CAAA;AAED,QAAA,MAAM,YAAY,WAAY,MAAM,WAGnC,CAAA;AAED,QAAA,MAAM,iBAAiB,kFAKpB,sBAAsB,KAAG,uBAuG3B,CAAA;AAED,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
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
|
+
};
|
|
11
|
+
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
3
12
|
import useSWRInfinite from "swr/infinite";
|
|
4
13
|
import { useInView } from "react-intersection-observer";
|
|
5
14
|
import { useSearchParams } from "next/navigation";
|
|
@@ -31,10 +40,14 @@ const constructURL = (apiURL) => {
|
|
|
31
40
|
const url = new URL(apiURL);
|
|
32
41
|
return url.toString();
|
|
33
42
|
};
|
|
34
|
-
const useInfiniteScroll = ({ initialData, queryVariables: queryVariableProps, }) => {
|
|
43
|
+
const useInfiniteScroll = ({ initialData, queryVariables: queryVariableProps, direction = "vertical", productLimit = Infinity, }) => {
|
|
35
44
|
var _a, _b, _c, _d, _e;
|
|
36
45
|
const searchParams = useSearchParams();
|
|
37
|
-
const
|
|
46
|
+
const productCount = useRef(0);
|
|
47
|
+
const { ref, inView } = useInView({
|
|
48
|
+
rootMargin: direction === "vertical" ? "600px" : "0px 420px 0px 0px",
|
|
49
|
+
threshold: 0,
|
|
50
|
+
});
|
|
38
51
|
const queryVariables = useMemo(() => {
|
|
39
52
|
const formattedParams = formatSearchParamsAsNextQueryVariables(searchParams);
|
|
40
53
|
return Object.assign(Object.assign({}, queryVariableProps), { searchParams: formattedParams });
|
|
@@ -48,10 +61,16 @@ const useInfiniteScroll = ({ initialData, queryVariables: queryVariableProps, })
|
|
|
48
61
|
return null;
|
|
49
62
|
return Object.assign(Object.assign({}, queryVariables), { cursorBlob: previousPageData.pageData.cursorBlob });
|
|
50
63
|
};
|
|
51
|
-
const fetcher = (body) =>
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
64
|
+
const fetcher = (body) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65
|
+
var _f, _g;
|
|
66
|
+
const res = yield fetch(constructURL(initialData.apiURL), {
|
|
67
|
+
method: "POST",
|
|
68
|
+
body: JSON.stringify(body),
|
|
69
|
+
});
|
|
70
|
+
const data = yield res.json();
|
|
71
|
+
productCount.current += (_g = (_f = data === null || data === void 0 ? void 0 : data.products) === null || _f === void 0 ? void 0 : _f.length) !== null && _g !== void 0 ? _g : 0;
|
|
72
|
+
return data;
|
|
73
|
+
});
|
|
55
74
|
const { data, error, size, setSize, isLoading, isValidating, } = useSWRInfinite((pageIndex, previousPageData) => getKey(pageIndex, previousPageData, queryVariables), fetcher, {
|
|
56
75
|
revalidateFirstPage: false,
|
|
57
76
|
initialSize: 1,
|
|
@@ -66,9 +85,11 @@ const useInfiniteScroll = ({ initialData, queryVariables: queryVariableProps, })
|
|
|
66
85
|
const isReachingEnd = isEmpty || isEndPointer;
|
|
67
86
|
const isRefreshing = isValidating && data && data.length === size;
|
|
68
87
|
const loadMore = useCallback(() => {
|
|
69
|
-
if (
|
|
70
|
-
|
|
71
|
-
|
|
88
|
+
if (isLoadingMore || isReachingEnd || isRefreshing)
|
|
89
|
+
return;
|
|
90
|
+
if (productCount.current >= productLimit)
|
|
91
|
+
return;
|
|
92
|
+
setSize(size + 1);
|
|
72
93
|
}, [isLoadingMore, isReachingEnd, isRefreshing, setSize, size]);
|
|
73
94
|
useEffect(() => {
|
|
74
95
|
if (inView) {
|
|
@@ -83,7 +104,9 @@ const useInfiniteScroll = ({ initialData, queryVariables: queryVariableProps, })
|
|
|
83
104
|
isEmpty,
|
|
84
105
|
isReachingEnd,
|
|
85
106
|
ref,
|
|
86
|
-
products: data
|
|
107
|
+
products: data
|
|
108
|
+
? data === null || data === void 0 ? void 0 : data.flatMap((page) => page === null || page === void 0 ? void 0 : page.products).slice(0, productLimit)
|
|
109
|
+
: [],
|
|
87
110
|
isLoading,
|
|
88
111
|
isValidating,
|
|
89
112
|
};
|
|
@@ -8,7 +8,9 @@ type UseProductsProps = {
|
|
|
8
8
|
productIds: string[];
|
|
9
9
|
productHandles: string[];
|
|
10
10
|
baseURL: URL;
|
|
11
|
-
|
|
11
|
+
collection?: string;
|
|
12
|
+
queryVariables?: Record<string, any>;
|
|
13
|
+
fetcher?: (url: string, body?: Record<string, any> | null) => Promise<any>;
|
|
12
14
|
metafields?: MetafieldInput[];
|
|
13
15
|
};
|
|
14
16
|
type UseProductsReturn = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-products.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-products.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAE1C,KAAK,GAAG,GAAG,MAAM,CAAA;AACjB,KAAK,cAAc,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAA;AACxD,KAAK,gBAAgB,GAAG;IACtB,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,cAAc,EAAE,MAAM,EAAE,CAAA;IACxB,OAAO,EAAE,GAAG,CAAA;IACZ,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"use-products.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-products.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAE1C,KAAK,GAAG,GAAG,MAAM,CAAA;AACjB,KAAK,cAAc,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAA;AACxD,KAAK,gBAAgB,GAAG;IACtB,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,cAAc,EAAE,MAAM,EAAE,CAAA;IACxB,OAAO,EAAE,GAAG,CAAA;IACZ,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACpC,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IAC1E,UAAU,CAAC,EAAE,cAAc,EAAE,CAAA;CAC9B,CAAA;AACD,KAAK,iBAAiB,GAAG;IACvB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,KAAK,EAAE,GAAG,CAAA;IACV,SAAS,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,GAAG,iBAAiB,CAyD7E"}
|
|
@@ -2,23 +2,37 @@
|
|
|
2
2
|
import useSWR from "swr";
|
|
3
3
|
export function useProducts(props) {
|
|
4
4
|
let url = null;
|
|
5
|
+
let body = null;
|
|
5
6
|
if (props) {
|
|
6
|
-
const { baseURL, productIds, productHandles, metafields } = props;
|
|
7
|
+
const { baseURL, productIds, productHandles, metafields, collection, queryVariables, } = props;
|
|
7
8
|
let queryParams = new URLSearchParams();
|
|
8
9
|
if ((productIds === null || productIds === void 0 ? void 0 : productIds.length) > 0) {
|
|
9
10
|
queryParams.set("ids", productIds.join(","));
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
+
if ((productHandles === null || productHandles === void 0 ? void 0 : productHandles.length) > 0) {
|
|
12
13
|
queryParams.set("handles", productHandles.join(","));
|
|
13
14
|
}
|
|
14
15
|
if (metafields && metafields.length > 0) {
|
|
15
16
|
const metafieldStrings = metafields.map((m) => `${m.namespace}.${m.key}`);
|
|
16
17
|
queryParams.set("metafields", metafieldStrings.join(","));
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
+
if (collection) {
|
|
20
|
+
url = `${baseURL}/products/by-page?${queryParams.toString()}`;
|
|
21
|
+
body = queryVariables || {};
|
|
22
|
+
}
|
|
23
|
+
if ((productIds === null || productIds === void 0 ? void 0 : productIds.length) || (productHandles === null || productHandles === void 0 ? void 0 : productHandles.length)) {
|
|
24
|
+
url = `${baseURL}/products/by-ids?${queryParams.toString()}`;
|
|
25
|
+
}
|
|
19
26
|
}
|
|
20
|
-
const
|
|
21
|
-
|
|
27
|
+
const defaultFetcher = (url, body) => fetch(url, {
|
|
28
|
+
method: body ? "POST" : "GET",
|
|
29
|
+
headers: {
|
|
30
|
+
"Content-Type": "application/json",
|
|
31
|
+
},
|
|
32
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
33
|
+
}).then((res) => res.json());
|
|
34
|
+
const fetcher = (props === null || props === void 0 ? void 0 : props.fetcher) || defaultFetcher;
|
|
35
|
+
const { data, error } = useSWR(url ? [url, body] : null, ([url, body]) => fetcher(url, body));
|
|
22
36
|
return {
|
|
23
37
|
products: data || [],
|
|
24
38
|
error,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ReviewSummaryData, ReviewMetaData, ReviewSearchData } from "app-studio-types";
|
|
2
|
+
type UseReviewsProps = {
|
|
3
|
+
baseURL: string;
|
|
4
|
+
productId: string;
|
|
5
|
+
provider: string;
|
|
6
|
+
fetcher?: (url: string) => Promise<any>;
|
|
7
|
+
dataType: "summary" | "metadata" | "search";
|
|
8
|
+
searchText: string;
|
|
9
|
+
ratings: [number];
|
|
10
|
+
topics: [string];
|
|
11
|
+
sortBy: "date" | "votes_up" | "votes_down" | "time" | "rating" | "reviewer_type";
|
|
12
|
+
ascending: boolean;
|
|
13
|
+
perPage: number;
|
|
14
|
+
page: number;
|
|
15
|
+
};
|
|
16
|
+
type UseReviewsReturn = {
|
|
17
|
+
data: ReviewSummaryData | ReviewMetaData | ReviewSearchData;
|
|
18
|
+
error: any;
|
|
19
|
+
isLoading: boolean;
|
|
20
|
+
};
|
|
21
|
+
export declare function useReviews(props: UseReviewsProps | null): UseReviewsReturn;
|
|
22
|
+
type UseReviewsInfiniteReturn = UseReviewsReturn & {
|
|
23
|
+
ref: (node?: Element | null) => void;
|
|
24
|
+
};
|
|
25
|
+
export declare function useReviewsInfinite(props: UseReviewsProps | null): UseReviewsInfiniteReturn;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=use-reviews.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-reviews.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-reviews.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAGtF,KAAK,eAAe,GAAG;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACxC,QAAQ,EAAE,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC;IAClB,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,eAAe,CAAC;IACjF,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd,CAAA;AAED,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,iBAAiB,GAAG,cAAc,GAAG,gBAAgB,CAAA;IAC3D,KAAK,EAAE,GAAG,CAAA;IACV,SAAS,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,GAAG,gBAAgB,CAwD1E;AAED,KAAK,wBAAwB,GAAG,gBAAgB,GAAG;IACjD,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC;CACtC,CAAA;AAGD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,GAAG,wBAAwB,CA8F1F"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCallback, useEffect } from "react";
|
|
3
|
+
import useSWR from "swr";
|
|
4
|
+
import useSWRInfinite from "swr/infinite";
|
|
5
|
+
import { useInView } from 'react-intersection-observer';
|
|
6
|
+
export function useReviews(props) {
|
|
7
|
+
let url = null;
|
|
8
|
+
if (props) {
|
|
9
|
+
const { baseURL, productId, provider, dataType, searchText, ratings, topics, sortBy, ascending, perPage, page } = props;
|
|
10
|
+
let queryParams = new URLSearchParams();
|
|
11
|
+
if (productId.length > 0) {
|
|
12
|
+
queryParams.set("id", productId);
|
|
13
|
+
}
|
|
14
|
+
if (provider.length > 0) {
|
|
15
|
+
queryParams.set("provider", provider);
|
|
16
|
+
}
|
|
17
|
+
queryParams.set("dataType", dataType);
|
|
18
|
+
if (searchText) {
|
|
19
|
+
queryParams.set("searchText", searchText);
|
|
20
|
+
}
|
|
21
|
+
if (ratings && ratings.length > 0) {
|
|
22
|
+
queryParams.set("ratings", ratings.join(","));
|
|
23
|
+
}
|
|
24
|
+
if (topics && topics.length > 0) {
|
|
25
|
+
queryParams.set("topics", topics.join(","));
|
|
26
|
+
}
|
|
27
|
+
if (sortBy) {
|
|
28
|
+
queryParams.set("sortBy", sortBy);
|
|
29
|
+
}
|
|
30
|
+
if (ascending !== undefined) {
|
|
31
|
+
queryParams.set("ascending", ascending.toString());
|
|
32
|
+
}
|
|
33
|
+
if (perPage) {
|
|
34
|
+
queryParams.set("perPage", String(perPage));
|
|
35
|
+
}
|
|
36
|
+
if (page) {
|
|
37
|
+
queryParams.set("page", String(page));
|
|
38
|
+
}
|
|
39
|
+
if (dataType === null || productId === null || productId.length === 0) {
|
|
40
|
+
url = null;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
url = `${baseURL}/reviews/by-id?${queryParams.toString()}`;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const fetcher = (props === null || props === void 0 ? void 0 : props.fetcher) || ((url) => fetch(url).then((res) => res.json()));
|
|
47
|
+
const { data, error } = useSWR(url, fetcher);
|
|
48
|
+
return {
|
|
49
|
+
data: data || {},
|
|
50
|
+
error,
|
|
51
|
+
isLoading: !data && !error,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export function useReviewsInfinite(props) {
|
|
55
|
+
var _a, _b;
|
|
56
|
+
let url = null;
|
|
57
|
+
const { ref, inView } = useInView({ rootMargin: "800px" });
|
|
58
|
+
let baseURL = "";
|
|
59
|
+
let queryParams = new URLSearchParams();
|
|
60
|
+
if (props) {
|
|
61
|
+
const { productId, provider, dataType, searchText, ratings, topics, sortBy, ascending, perPage } = props; // Destructure all relevant props
|
|
62
|
+
baseURL = props.baseURL;
|
|
63
|
+
if (productId.length > 0) {
|
|
64
|
+
queryParams.set("id", productId);
|
|
65
|
+
}
|
|
66
|
+
if (provider.length > 0) {
|
|
67
|
+
queryParams.set("provider", provider);
|
|
68
|
+
}
|
|
69
|
+
queryParams.set("dataType", dataType);
|
|
70
|
+
if (searchText) {
|
|
71
|
+
queryParams.set("searchText", searchText);
|
|
72
|
+
}
|
|
73
|
+
if (ratings && ratings.length > 0) {
|
|
74
|
+
queryParams.set("ratings", ratings.join(","));
|
|
75
|
+
}
|
|
76
|
+
if (topics && topics.length > 0) {
|
|
77
|
+
queryParams.set("topics", topics.join(","));
|
|
78
|
+
}
|
|
79
|
+
if (sortBy) {
|
|
80
|
+
queryParams.set("sortBy", sortBy);
|
|
81
|
+
}
|
|
82
|
+
if (ascending !== undefined) {
|
|
83
|
+
queryParams.set("ascending", ascending.toString());
|
|
84
|
+
}
|
|
85
|
+
if (perPage) {
|
|
86
|
+
queryParams.set("perPage", String(perPage));
|
|
87
|
+
}
|
|
88
|
+
if (dataType === null || productId === null || productId.length === 0) {
|
|
89
|
+
url = null;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
url = `${baseURL}/reviews/by-id?${queryParams.toString()}`;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const getKey = (pageIndex, previousPageData) => {
|
|
96
|
+
const dataType = queryParams.get("dataType") === "null" ? null : queryParams.get("dataType");
|
|
97
|
+
if (dataType == null) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
return `${baseURL}/reviews/by-id?${queryParams.toString()}&page=${pageIndex + 1}`;
|
|
101
|
+
};
|
|
102
|
+
const fetcher = (props === null || props === void 0 ? void 0 : props.fetcher) || ((url) => fetch(url).then((res) => res.json()));
|
|
103
|
+
const { data: dataInfinite, error: errorInfinite, size, setSize, isLoading, isValidating, } = useSWRInfinite(getKey, fetcher);
|
|
104
|
+
let mergedReviews = dataInfinite
|
|
105
|
+
? dataInfinite
|
|
106
|
+
.filter(page => page && page.reviews)
|
|
107
|
+
.flatMap(page => (page.reviews))
|
|
108
|
+
: [];
|
|
109
|
+
let searchResponse = {
|
|
110
|
+
pagination: (dataInfinite === null || dataInfinite === void 0 ? void 0 : dataInfinite.length) ? dataInfinite[0].pagination : null,
|
|
111
|
+
reviews: mergedReviews
|
|
112
|
+
};
|
|
113
|
+
const isAllReviewsLoaded = (mergedReviews === null || mergedReviews === void 0 ? void 0 : mergedReviews.length) === ((_b = (_a = dataInfinite === null || dataInfinite === void 0 ? void 0 : dataInfinite[0]) === null || _a === void 0 ? void 0 : _a.pagination) === null || _b === void 0 ? void 0 : _b.total);
|
|
114
|
+
const loadMore = useCallback(() => {
|
|
115
|
+
if (!isLoading && !isValidating && !isAllReviewsLoaded) {
|
|
116
|
+
setSize(size + 1);
|
|
117
|
+
}
|
|
118
|
+
}, [isLoading, isValidating, setSize, size, isAllReviewsLoaded]);
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
if (inView) {
|
|
121
|
+
loadMore();
|
|
122
|
+
}
|
|
123
|
+
}, [inView, loadMore]);
|
|
124
|
+
return {
|
|
125
|
+
data: searchResponse || {},
|
|
126
|
+
error: errorInfinite,
|
|
127
|
+
isLoading: isValidating,
|
|
128
|
+
ref
|
|
129
|
+
};
|
|
130
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { InputProps } from "
|
|
2
|
+
import { InputProps } from "../../../components/ui/Input/types";
|
|
3
3
|
declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
|
|
4
4
|
export { Input };
|
|
5
5
|
//# sourceMappingURL=input.d.ts.map
|
|
@@ -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;AAExD,QAAA,MAAM,KAAK,qFA+KV,CAAA;AAGD,OAAO,EAAE,KAAK,EAAE,CAAA"}
|
|
@@ -12,14 +12,15 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import * as React from "react";
|
|
14
14
|
import { inputVariants, useInput } from "./useInput";
|
|
15
|
-
import { cn } from "../../../lib/utils";
|
|
15
|
+
import { cn, getColor } from "../../../lib/utils";
|
|
16
16
|
import { Icon } from "../icon";
|
|
17
17
|
const Input = React.forwardRef((_a, ref) => {
|
|
18
|
-
var { className, error = false, id, type, label, asChild, value, onChange, icon, iconPosition = "right", // Default to "right" for backward compatibility
|
|
19
|
-
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", "iconPosition", "iconColor", "placeholder", "placeholderFont", "placeholderFontWeight", "placeholderFontSize", "placeholderTextAlign", "placeholderTextColor", "placeholderUpperCase", "inputPadding", "backgroundColor", "borderRadius", "inputBorderColor", "borderSides", "inputSpacing"]);
|
|
18
|
+
var { className, error = false, id, type, label, asChild, value, onChange, icon, iconUrl, iconPosition = "right", // Default to "right" for backward compatibility
|
|
19
|
+
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"]);
|
|
20
20
|
const { Comp, inputPaddingRight, inputPaddingLeft, borderStyle, borderRadiusStyle, iconLeftPadding, iconRightPadding, iconTopPadding, iconBottomPadding, placeholderTextColorStyle, iconColorStyle, inputBgColor, inputBorderColorStyle, } = useInput({
|
|
21
21
|
asChild,
|
|
22
22
|
icon,
|
|
23
|
+
iconUrl,
|
|
23
24
|
iconPosition,
|
|
24
25
|
iconColor,
|
|
25
26
|
className,
|
|
@@ -31,7 +32,9 @@ const Input = React.forwardRef((_a, ref) => {
|
|
|
31
32
|
inputPadding,
|
|
32
33
|
placeholderTextColor,
|
|
33
34
|
});
|
|
34
|
-
return (_jsxs(Comp, Object.assign({ className: "relative flex items-center group" }, { children: [icon && iconPosition === "left" && (_jsx(Icon, { name: icon, "data-error": error, size: "sm", color: iconColorStyle !== "inherit"
|
|
35
|
+
return (_jsxs(Comp, Object.assign({ className: "relative flex items-center group" }, { children: [(icon || iconUrl) && iconPosition === "left" && (_jsx(Icon, { name: icon, url: iconUrl, "data-error": error, size: "sm", strokeColor: getColor(iconColor), color: iconColorStyle !== "inherit"
|
|
36
|
+
? undefined
|
|
37
|
+
: "coreColors-secondaryIcon", className: cn("flex items-center absolute aspect-square fill-current z-10 icon ", {
|
|
35
38
|
"w-5": true,
|
|
36
39
|
"text-stateColors-error": error,
|
|
37
40
|
}), style: {
|
|
@@ -43,7 +46,22 @@ const Input = React.forwardRef((_a, ref) => {
|
|
|
43
46
|
} })), _jsx("style", { children: `
|
|
44
47
|
.custom-placeholder-value::placeholder {
|
|
45
48
|
color: ${placeholderTextColorStyle};
|
|
46
|
-
}` }), _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:
|
|
49
|
+
}` }), _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 &&
|
|
50
|
+
iconPosition === "left" &&
|
|
51
|
+
placeholderTextAlign === "center"
|
|
52
|
+
? undefined
|
|
53
|
+
: inputPaddingLeft, paddingRight: inputPaddingRight, fontFamily: placeholderFont, fontWeight: placeholderFontWeight, fontSize: `${placeholderFontSize}px`, textAlign: placeholderTextAlign, color: placeholderTextColorStyle, textTransform: placeholderUpperCase ? "uppercase" : undefined, borderColor: inputBorderColorStyle, paddingTop: inputPadding === null || inputPadding === void 0 ? void 0 : inputPadding.top, paddingBottom: inputPadding === null || inputPadding === void 0 ? void 0 : inputPadding.bottom, backgroundColor: inputBgColor }, borderStyle), (label ? { borderRadius: "8px" } : borderRadiusStyle)) })), label ? (_jsx("label", Object.assign({ htmlFor: id, className: cn("absolute text-[10px] text-textColors-secondaryColor group-active:text-coreColors-brandColorPrimary top-2 z-10 h-4 origin-[0] opacity-100 peer-placeholder-shown:opacity-0", iconPosition === "left" ? "start-10" : "start-4") }, { children: label }))) : null, (icon || iconUrl) && iconPosition === "right" && (_jsx(Icon, { name: icon, url: iconUrl, "data-error": error, size: "sm", strokeColor: getColor(iconColor), color: iconColorStyle !== "inherit"
|
|
54
|
+
? undefined
|
|
55
|
+
: "coreColors-secondaryIcon", className: cn("flex items-center absolute aspect-square fill-current z-10 icon ", {
|
|
56
|
+
"w-5": true,
|
|
57
|
+
"text-stateColors-error": error,
|
|
58
|
+
}), style: {
|
|
59
|
+
left: iconLeftPadding,
|
|
60
|
+
right: iconRightPadding,
|
|
61
|
+
top: iconTopPadding,
|
|
62
|
+
bottom: iconBottomPadding,
|
|
63
|
+
color: iconColorStyle,
|
|
64
|
+
} }))] })));
|
|
47
65
|
});
|
|
48
66
|
Input.displayName = "Input";
|
|
49
67
|
export { Input };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { VariantProps } from "class-variance-authority";
|
|
3
|
-
import { inputVariants } from "
|
|
4
|
-
import { Color } from "
|
|
3
|
+
import { inputVariants } from "../../../components/ui/Input/useInput";
|
|
4
|
+
import { Color } from "../../../lib/utils";
|
|
5
5
|
export type BorderSides = ("all" | "bottom" | "left" | "right" | "top")[];
|
|
6
6
|
export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange">, VariantProps<typeof inputVariants> {
|
|
7
7
|
id: string;
|
|
@@ -10,6 +10,7 @@ export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElem
|
|
|
10
10
|
value: string;
|
|
11
11
|
onChange: (value: string) => void;
|
|
12
12
|
icon?: string;
|
|
13
|
+
iconUrl?: string;
|
|
13
14
|
iconPosition?: "left" | "right";
|
|
14
15
|
iconColor?: Color;
|
|
15
16
|
placeholder: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../components/ui/Input/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAA;AAC9D,OAAO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AAA;IACvB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,gBAAgB,CAAC,EAAE,KAAK,CAAA;IACxB,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,YAAY,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IAC3E,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { InputProps } from "
|
|
2
|
+
import { InputProps } from "../../../components/ui/Input/types";
|
|
3
3
|
export declare const DEFAULT_ICON_SIZE = 20;
|
|
4
4
|
export declare const DEFAULT_X_PADDING = 12;
|
|
5
5
|
export declare const DEFAULT_Y_PADDING = 8;
|
|
@@ -7,7 +7,7 @@ export declare const inputVariants: (props?: ({
|
|
|
7
7
|
hasLabel?: boolean | null | undefined;
|
|
8
8
|
error?: boolean | null | undefined;
|
|
9
9
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
10
|
-
export declare const useInput: (props: Pick<InputProps, "asChild" | "icon" | "iconPosition" | "iconColor" | "className" | "backgroundColor" | "borderRadius" | "inputBorderColor" | "borderSides" | "inputSpacing" | "inputPadding" | "placeholderTextColor">) => {
|
|
10
|
+
export declare const useInput: (props: Pick<InputProps, "asChild" | "icon" | "iconUrl" | "iconPosition" | "iconColor" | "className" | "backgroundColor" | "borderRadius" | "inputBorderColor" | "borderSides" | "inputSpacing" | "inputPadding" | "placeholderTextColor">) => {
|
|
11
11
|
Comp: string | import("react").ForwardRefExoticComponent<import("@radix-ui/react-slot").SlotProps & import("react").RefAttributes<HTMLElement>>;
|
|
12
12
|
inputPaddingRight: string | undefined;
|
|
13
13
|
inputPaddingLeft: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInput.d.ts","sourceRoot":"","sources":["../../../../components/ui/Input/useInput.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAGxD,eAAO,MAAM,iBAAiB,KAAK,CAAA;AACnC,eAAO,MAAM,iBAAiB,KAAK,CAAA;AACnC,eAAO,MAAM,iBAAiB,IAAI,CAAA;AAElC,eAAO,MAAM,aAAa;;;mFAkBzB,CAAA;AAED,eAAO,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"useInput.d.ts","sourceRoot":"","sources":["../../../../components/ui/Input/useInput.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAGxD,eAAO,MAAM,iBAAiB,KAAK,CAAA;AACnC,eAAO,MAAM,iBAAiB,KAAK,CAAA;AACnC,eAAO,MAAM,iBAAiB,IAAI,CAAA;AAElC,eAAO,MAAM,aAAa;;;mFAkBzB,CAAA;AAED,eAAO,MAAM,QAAQ,UACZ,KACL,UAAU,EACR,SAAS,GACT,MAAM,GACN,SAAS,GACT,cAAc,GACd,WAAW,GACX,WAAW,GACX,iBAAiB,GACjB,cAAc,GACd,kBAAkB,GAClB,aAAa,GACb,cAAc,GACd,cAAc,GACd,sBAAsB,CACzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwFF,CAAA"}
|
|
@@ -8,7 +8,7 @@ export const inputVariants = cva("flex w-full border border-coreColors-dividingL
|
|
|
8
8
|
variants: {
|
|
9
9
|
hasLabel: {
|
|
10
10
|
true: "h-14 px-4 rounded pt-5 pb-2 placeholder-shown:p-4",
|
|
11
|
-
false: "
|
|
11
|
+
false: "px-4 py-2",
|
|
12
12
|
},
|
|
13
13
|
error: {
|
|
14
14
|
true: "border-stateColors-error text-stateColors-error placeholder:text-stateColors-error focus:border-stateColors-error [&+label]:text-stateColors-error",
|
|
@@ -21,11 +21,15 @@ export const inputVariants = cva("flex w-full border border-coreColors-dividingL
|
|
|
21
21
|
},
|
|
22
22
|
});
|
|
23
23
|
export const useInput = (props) => {
|
|
24
|
-
const { asChild, icon, iconPosition = "right", // Default to "right" for backward compatibility
|
|
25
|
-
iconColor, placeholderTextColor, backgroundColor, borderRadius, inputBorderColor, borderSides = ["all"], inputPadding, inputSpacing
|
|
24
|
+
const { asChild, icon, iconUrl, iconPosition = "right", // Default to "right" for backward compatibility
|
|
25
|
+
iconColor, placeholderTextColor, backgroundColor, borderRadius, inputBorderColor, borderSides = ["all"], inputPadding, inputSpacing, } = props;
|
|
26
26
|
const Comp = asChild ? Slot : "div";
|
|
27
|
-
const inputPaddingRight = icon
|
|
28
|
-
|
|
27
|
+
const inputPaddingRight = (icon || iconUrl) && iconPosition === "right"
|
|
28
|
+
? (inputPadding === null || inputPadding === void 0 ? void 0 : inputPadding.right)
|
|
29
|
+
? `${inputPadding === null || inputPadding === void 0 ? void 0 : inputPadding.right}px`
|
|
30
|
+
: "2.5rem"
|
|
31
|
+
: undefined;
|
|
32
|
+
const inputPaddingLeft = (icon || iconUrl) && iconPosition === "left"
|
|
29
33
|
? (inputPadding === null || inputPadding === void 0 ? void 0 : inputPadding.left) !== undefined && inputSpacing
|
|
30
34
|
? `calc(${(inputPadding === null || inputPadding === void 0 ? void 0 : inputPadding.left) + inputSpacing + DEFAULT_ICON_SIZE}px)`
|
|
31
35
|
: (inputPadding === null || inputPadding === void 0 ? void 0 : inputPadding.left)
|
|
@@ -42,11 +46,21 @@ export const useInput = (props) => {
|
|
|
42
46
|
borderLeftWidth: borderSides.includes("left") ? "1px" : 0,
|
|
43
47
|
borderRightWidth: borderSides.includes("right") ? "1px" : 0,
|
|
44
48
|
};
|
|
45
|
-
const borderRadiusStyle = borderRadius
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
49
|
+
const borderRadiusStyle = borderRadius
|
|
50
|
+
? { borderRadius: `${borderRadius}px` }
|
|
51
|
+
: {};
|
|
52
|
+
const iconLeftPadding = (inputPadding === null || inputPadding === void 0 ? void 0 : inputPadding.left) !== undefined
|
|
53
|
+
? `${inputPadding.left}px`
|
|
54
|
+
: `${DEFAULT_X_PADDING}px`;
|
|
55
|
+
const iconRightPadding = (inputPadding === null || inputPadding === void 0 ? void 0 : inputPadding.right) !== undefined
|
|
56
|
+
? `${inputPadding.right}px`
|
|
57
|
+
: `${DEFAULT_X_PADDING}px`;
|
|
58
|
+
const iconTopPadding = (inputPadding === null || inputPadding === void 0 ? void 0 : inputPadding.top) !== undefined
|
|
59
|
+
? `${inputPadding.top}px`
|
|
60
|
+
: `${DEFAULT_Y_PADDING}px`;
|
|
61
|
+
const iconBottomPadding = (inputPadding === null || inputPadding === void 0 ? void 0 : inputPadding.bottom) !== undefined
|
|
62
|
+
? `${inputPadding.bottom}px`
|
|
63
|
+
: `${DEFAULT_Y_PADDING}px`;
|
|
50
64
|
const iconColorStyle = getColor(iconColor);
|
|
51
65
|
const inputBgColor = getColor(backgroundColor);
|
|
52
66
|
const inputBorderColorStyle = getColor(inputBorderColor);
|
|
@@ -5,6 +5,8 @@ declare const AccordionItem: React.ForwardRefExoticComponent<Omit<AccordionPrimi
|
|
|
5
5
|
declare const AccordionTrigger: React.ForwardRefExoticComponent<Omit<AccordionPrimitive.AccordionTriggerProps & React.RefAttributes<HTMLButtonElement>, "ref"> & {
|
|
6
6
|
showDefaultIcon?: boolean | undefined;
|
|
7
7
|
} & React.RefAttributes<HTMLButtonElement>>;
|
|
8
|
-
declare const AccordionContent: React.ForwardRefExoticComponent<Omit<AccordionPrimitive.AccordionContentProps & React.RefAttributes<HTMLDivElement>, "ref"> &
|
|
8
|
+
declare const AccordionContent: React.ForwardRefExoticComponent<Omit<AccordionPrimitive.AccordionContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
9
|
+
contentClassName: string;
|
|
10
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
9
11
|
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent };
|
|
10
12
|
//# sourceMappingURL=accordion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accordion.d.ts","sourceRoot":"","sources":["../../../components/ui/accordion.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,kBAAkB,MAAM,2BAA2B,CAAA;AAK/D,QAAA,MAAM,SAAS,8JAA0B,CAAA;AAEzC,QAAA,MAAM,aAAa,iKASjB,CAAA;AAGF,QAAA,MAAM,gBAAgB;;2CA4BpB,CAAA;AAGF,QAAA,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"accordion.d.ts","sourceRoot":"","sources":["../../../components/ui/accordion.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,kBAAkB,MAAM,2BAA2B,CAAA;AAK/D,QAAA,MAAM,SAAS,8JAA0B,CAAA;AAEzC,QAAA,MAAM,aAAa,iKASjB,CAAA;AAGF,QAAA,MAAM,gBAAgB;;2CA4BpB,CAAA;AAGF,QAAA,MAAM,gBAAgB;sBAGA,MAAM;wCAU1B,CAAA;AAIF,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAA"}
|
|
@@ -27,8 +27,8 @@ const AccordionTrigger = React.forwardRef((_a, ref) => {
|
|
|
27
27
|
});
|
|
28
28
|
AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName;
|
|
29
29
|
const AccordionContent = React.forwardRef((_a, ref) => {
|
|
30
|
-
var { className, children } = _a, props = __rest(_a, ["className", "children"]);
|
|
31
|
-
return (_jsx(AccordionPrimitive.Content, Object.assign({ ref: ref, className: "px-4 overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down" }, props, { children: _jsx("div", Object.assign({ className: cn("pb-4 pt-0", className) }, { children: children })) })));
|
|
30
|
+
var { className, children, contentClassName } = _a, props = __rest(_a, ["className", "children", "contentClassName"]);
|
|
31
|
+
return (_jsx(AccordionPrimitive.Content, Object.assign({ ref: ref, className: cn("px-4 overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down", contentClassName) }, props, { children: _jsx("div", Object.assign({ className: cn("pb-4 pt-0", className) }, { children: children })) })));
|
|
32
32
|
});
|
|
33
33
|
AccordionContent.displayName = AccordionPrimitive.Content.displayName;
|
|
34
34
|
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent };
|
|
@@ -2,8 +2,8 @@ import * as React from "react";
|
|
|
2
2
|
import { type VariantProps } from "class-variance-authority";
|
|
3
3
|
import { Color, TextStyle, BackgroundAndPadding } from "../../lib/utils";
|
|
4
4
|
declare const buttonVariants: (props?: ({
|
|
5
|
-
size?: "
|
|
6
|
-
variant?: "
|
|
5
|
+
size?: "default" | "sm" | "lg" | "content" | "icon" | null | undefined;
|
|
6
|
+
variant?: "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | "quickadd" | "applePay" | "shopPay" | null | undefined;
|
|
7
7
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
8
8
|
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
|
|
9
9
|
asChild?: boolean;
|
|
@@ -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;AAwCD,MAAM,WAAW,WACf,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EACnD,YAAY,CAAC,OAAO,cAAc,CAAC;IACrC,OAAO,CAAC,EAAE,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;IACtB,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CAChC;AAED,QAAA,MAAM,MAAM,uFA4FX,CAAA;AAGD,QAAA,MAAM,cAAc,iBACJ,SAAS,GACrB,oBAAoB,GAAG;IACrB,SAAS,EAAE,KAAK,CAAA;IAChB,WAAW,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;IAC5B,gBAAgB,EAAE,OAAO,CAAA;CAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkBJ,CAAA;AAED,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -81,7 +81,7 @@ const labelVariants = cva("truncate", {
|
|
|
81
81
|
const Button = React.forwardRef((_a, ref) => {
|
|
82
82
|
var { className, labelClassName, labelStyle, variant, size, asChild = false, loading, icon, iconColor, iconStrokeColor, iconPosition, iconSize, iconUrl, iconClassName } = _a, props = __rest(_a, ["className", "labelClassName", "labelStyle", "variant", "size", "asChild", "loading", "icon", "iconColor", "iconStrokeColor", "iconPosition", "iconSize", "iconUrl", "iconClassName"]);
|
|
83
83
|
const Comp = asChild ? Slot : "button";
|
|
84
|
-
const IconButton = () => icon || iconUrl ? (_jsx(Icon, { name: icon, size: "sm", style: { color: iconColor } })) : null;
|
|
84
|
+
const IconButton = () => icon || iconUrl ? (_jsx(Icon, { name: icon, url: iconUrl, size: "sm", style: { color: iconColor, stroke: iconColor, fill: iconColor } })) : null;
|
|
85
85
|
const BasicButton = () => (_jsxs(_Fragment, { children: [icon || iconUrl ? (_jsx(Icon, { name: iconUrl ? undefined : icon, url: iconUrl, size: iconSize || variant === "quickadd" ? "xs" : "sm", className: cn(iconVariants({ variant }), {
|
|
86
86
|
"mr-2": iconPosition === "left",
|
|
87
87
|
"ml-2": iconPosition === "right",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"carousel.d.ts","sourceRoot":"","sources":["../../../components/ui/carousel.ts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