@tapcart/mobile-components 0.4.3 → 0.4.6
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 +4 -3
- package/dist/components/hooks/use-infinite-scroll.d.ts.map +1 -1
- package/dist/components/hooks/use-infinite-scroll.js +30 -17
- package/dist/components/ui/Input/index.d.ts +2 -0
- package/dist/components/ui/Input/index.d.ts.map +1 -0
- package/dist/components/ui/Input/index.js +1 -0
- package/dist/components/ui/Input/input.d.ts +5 -0
- package/dist/components/ui/Input/input.d.ts.map +1 -0
- package/dist/components/ui/Input/input.js +46 -0
- package/dist/components/ui/Input/types.d.ts +34 -0
- package/dist/components/ui/Input/types.d.ts.map +1 -0
- package/dist/components/ui/Input/types.js +1 -0
- package/dist/components/ui/Input/useInput.d.ts +41 -0
- package/dist/components/ui/Input/useInput.d.ts.map +1 -0
- package/dist/components/ui/Input/useInput.js +69 -0
- package/dist/components/ui/button.d.ts +1 -0
- package/dist/components/ui/button.d.ts.map +1 -1
- package/dist/components/ui/button.js +3 -3
- package/dist/components/ui/icon.d.ts.map +1 -1
- package/dist/components/ui/icon.js +6 -1
- package/dist/components/ui/image.d.ts +3 -0
- package/dist/components/ui/image.d.ts.map +1 -1
- package/dist/components/ui/image.js +42 -12
- package/dist/components/ui/money.d.ts.map +1 -1
- package/dist/components/ui/money.js +1 -0
- package/dist/components/ui/product-card.d.ts +2 -1
- package/dist/components/ui/product-card.d.ts.map +1 -1
- package/dist/components/ui/product-card.js +6 -6
- package/dist/components/ui/selectors.d.ts +1 -0
- package/dist/components/ui/selectors.d.ts.map +1 -1
- package/dist/components/ui/selectors.js +4 -4
- package/dist/components/ui/skeleton.d.ts +1 -1
- package/dist/components/ui/slider.js +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/lib/utils.d.ts +5 -0
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +3 -0
- package/dist/styles.css +40 -20
- package/package.json +16 -16
|
@@ -5,10 +5,10 @@ interface PageData {
|
|
|
5
5
|
products: Product[];
|
|
6
6
|
cursorBlob?: string;
|
|
7
7
|
filtersData: any;
|
|
8
|
+
apiURL: string;
|
|
8
9
|
}
|
|
9
10
|
interface UseInfiniteScrollProps {
|
|
10
11
|
initialData: PageData;
|
|
11
|
-
loadMoreProducts: (params: any) => Promise<PageData>;
|
|
12
12
|
queryVariables: Record<string, any>;
|
|
13
13
|
}
|
|
14
14
|
interface UseInfiniteScrollReturn {
|
|
@@ -23,6 +23,7 @@ interface UseInfiniteScrollReturn {
|
|
|
23
23
|
isLoading: boolean;
|
|
24
24
|
isValidating: boolean;
|
|
25
25
|
}
|
|
26
|
-
declare const
|
|
27
|
-
|
|
26
|
+
declare const constructURL: (params: Record<string, any>, apiURL: string) => string;
|
|
27
|
+
declare const useInfiniteScroll: ({ initialData, queryVariables: queryVariableProps, }: UseInfiniteScrollProps) => UseInfiniteScrollReturn;
|
|
28
|
+
export { useInfiniteScroll, constructURL };
|
|
28
29
|
//# 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":"AAQA,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;
|
|
1
|
+
{"version":3,"file":"use-infinite-scroll.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-infinite-scroll.ts"],"names":[],"mappings":"AAQA,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;CACpC;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;AA2CD,QAAA,MAAM,YAAY,WAAY,OAAO,MAAM,EAAE,GAAG,CAAC,UAAU,MAAM,WAahE,CAAA;AAqBD,QAAA,MAAM,iBAAiB,yDAGpB,sBAAsB,KAAG,uBAoF3B,CAAA;AAED,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -35,7 +35,30 @@ const reconcileFilters = ({ selectedFilters = "[]", filtersData = [] }) => {
|
|
|
35
35
|
filtersData,
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
|
-
const
|
|
38
|
+
const constructURL = (params, apiURL) => {
|
|
39
|
+
const url = new URL(apiURL);
|
|
40
|
+
Object.keys(params).forEach((key) => {
|
|
41
|
+
const value = params[key];
|
|
42
|
+
if (value !== undefined && value !== null) {
|
|
43
|
+
if (typeof value === "string") {
|
|
44
|
+
url.searchParams.append(key, value);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
url.searchParams.append(key, JSON.stringify(value));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
return url.toString();
|
|
52
|
+
};
|
|
53
|
+
const getKey = (pageIndex, previousPageData, queryVariables, apiURL) => {
|
|
54
|
+
var _a;
|
|
55
|
+
if (pageIndex === 0)
|
|
56
|
+
return constructURL(queryVariables, apiURL);
|
|
57
|
+
if (!previousPageData || !((_a = previousPageData.pageData) === null || _a === void 0 ? void 0 : _a.cursorBlob))
|
|
58
|
+
return null;
|
|
59
|
+
return constructURL(Object.assign(Object.assign({}, queryVariables), { cursorBlob: previousPageData.pageData.cursorBlob }), apiURL);
|
|
60
|
+
};
|
|
61
|
+
const useInfiniteScroll = ({ initialData, queryVariables: queryVariableProps, }) => {
|
|
39
62
|
var _a, _b, _c, _d;
|
|
40
63
|
const searchParams = useSearchParams();
|
|
41
64
|
const sortStateFromParam = useCallback(() => {
|
|
@@ -57,15 +80,8 @@ const useInfiniteScroll = ({ initialData, loadMoreProducts, queryVariables: quer
|
|
|
57
80
|
sortStateFromParam,
|
|
58
81
|
]);
|
|
59
82
|
const { ref, inView } = useInView({ rootMargin: "600px" }); // controls how early the next page loads
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
if (pageIndex === 0)
|
|
63
|
-
return queryVariables;
|
|
64
|
-
if (!previousPageData || !((_a = previousPageData.pageData) === null || _a === void 0 ? void 0 : _a.cursorBlob))
|
|
65
|
-
return null;
|
|
66
|
-
return Object.assign(Object.assign({}, queryVariables), { cursorBlob: previousPageData.pageData.cursorBlob });
|
|
67
|
-
};
|
|
68
|
-
const { data, error, size, setSize, isLoading, isValidating, } = useSWRInfinite(getKey, loadMoreProducts, {
|
|
83
|
+
const fetcher = (url) => fetch(url).then((res) => res.json());
|
|
84
|
+
const { data, error, size, setSize, isLoading, isValidating, } = useSWRInfinite((pageIndex, previousPageData) => getKey(pageIndex, previousPageData, queryVariables, initialData.apiURL), fetcher, {
|
|
69
85
|
revalidateFirstPage: false,
|
|
70
86
|
initialSize: 1,
|
|
71
87
|
});
|
|
@@ -77,20 +93,17 @@ const useInfiniteScroll = ({ initialData, loadMoreProducts, queryVariables: quer
|
|
|
77
93
|
? !((_d = (_c = data[data.length - 1]) === null || _c === void 0 ? void 0 : _c.pageData) === null || _d === void 0 ? void 0 : _d.cursorBlob)
|
|
78
94
|
: true;
|
|
79
95
|
const isReachingEnd = isEmpty || isEndPointer;
|
|
96
|
+
const isRefreshing = isValidating && data && data.length === size;
|
|
80
97
|
const loadMore = useCallback(() => {
|
|
81
|
-
if (!isLoadingMore && !isReachingEnd) {
|
|
98
|
+
if (!isLoadingMore && !isReachingEnd && !isRefreshing) {
|
|
82
99
|
setSize(size + 1);
|
|
83
100
|
}
|
|
84
|
-
}, [isLoadingMore, isReachingEnd,
|
|
101
|
+
}, [isLoadingMore, isReachingEnd, isRefreshing, setSize, size]);
|
|
85
102
|
useEffect(() => {
|
|
86
103
|
if (inView) {
|
|
87
104
|
loadMore();
|
|
88
105
|
}
|
|
89
106
|
}, [inView, loadMore]);
|
|
90
|
-
// Trigger a new page load when the query variables change
|
|
91
|
-
useEffect(() => {
|
|
92
|
-
setSize(1);
|
|
93
|
-
}, [queryVariables, setSize]);
|
|
94
107
|
return {
|
|
95
108
|
data,
|
|
96
109
|
error,
|
|
@@ -104,4 +117,4 @@ const useInfiniteScroll = ({ initialData, loadMoreProducts, queryVariables: quer
|
|
|
104
117
|
isValidating,
|
|
105
118
|
};
|
|
106
119
|
};
|
|
107
|
-
export { useInfiniteScroll };
|
|
120
|
+
export { useInfiniteScroll, constructURL };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/ui/Input/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './input';
|
|
@@ -0,0 +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;AAGxD,QAAA,MAAM,KAAK,qFAiIV,CAAA;AAGD,OAAO,EAAE,KAAK,EAAE,CAAA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import * as React from "react";
|
|
14
|
+
import { inputVariants, useInput } from "./useInput";
|
|
15
|
+
import { cn } from "../../../lib/utils";
|
|
16
|
+
import { Icon } from "../icon";
|
|
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"]);
|
|
20
|
+
const { Comp, inputPaddingRight, inputPaddingLeft, borderStyle, borderRadiusStyle, iconLeftPadding, iconRightPadding, iconTopPadding, iconBottomPadding, placeholderTextColorStyle, iconColorStyle, inputBgColor, inputBorderColorStyle, } = useInput({
|
|
21
|
+
asChild,
|
|
22
|
+
icon,
|
|
23
|
+
iconPosition,
|
|
24
|
+
iconColor,
|
|
25
|
+
className,
|
|
26
|
+
backgroundColor,
|
|
27
|
+
borderRadius,
|
|
28
|
+
inputBorderColor,
|
|
29
|
+
borderSides,
|
|
30
|
+
inputSpacing,
|
|
31
|
+
inputPadding,
|
|
32
|
+
placeholderTextColor,
|
|
33
|
+
});
|
|
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" ? undefined : "coreColors-secondaryIcon", className: cn("flex items-center absolute aspect-square fill-current z-10 icon ", {
|
|
35
|
+
"w-5": true,
|
|
36
|
+
"text-stateColors-error": error,
|
|
37
|
+
}), style: {
|
|
38
|
+
left: iconLeftPadding,
|
|
39
|
+
right: iconRightPadding,
|
|
40
|
+
top: iconTopPadding,
|
|
41
|
+
bottom: iconBottomPadding,
|
|
42
|
+
color: iconColorStyle,
|
|
43
|
+
} })), _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), "data-icon": !!icon, ref: ref }, props, { style: Object.assign(Object.assign({ paddingLeft: 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 && iconPosition === "right" && (_jsx(Icon, { name: icon, "data-error": error, size: "sm", className: "absolute w-5 aspect-square fill-current text-textColors-secondaryColor top-[18px] z-10 origin-[0] end-4 peer-pr-8 icon data-[error=true]:text-stateColors-error" }))] })));
|
|
44
|
+
});
|
|
45
|
+
Input.displayName = "Input";
|
|
46
|
+
export { Input };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { VariantProps } from "class-variance-authority";
|
|
3
|
+
import { inputVariants } from "../../../components/ui/Input/useInput";
|
|
4
|
+
import { Color } from "../../../lib/utils";
|
|
5
|
+
export type BorderSides = ("all" | "bottom" | "left" | "right" | "top")[];
|
|
6
|
+
export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange">, VariantProps<typeof inputVariants> {
|
|
7
|
+
id: string;
|
|
8
|
+
label?: string;
|
|
9
|
+
asChild?: boolean;
|
|
10
|
+
value: string;
|
|
11
|
+
onChange: (value: string) => void;
|
|
12
|
+
icon?: string;
|
|
13
|
+
iconPosition?: "left" | "right";
|
|
14
|
+
iconColor?: Color;
|
|
15
|
+
placeholder: string;
|
|
16
|
+
placeholderFont?: string;
|
|
17
|
+
placeholderFontWeight?: string;
|
|
18
|
+
placeholderFontSize?: number;
|
|
19
|
+
placeholderTextAlign?: "left" | "center" | "right";
|
|
20
|
+
placeholderTextColor?: Color;
|
|
21
|
+
placeholderUpperCase?: boolean;
|
|
22
|
+
backgroundColor?: Color;
|
|
23
|
+
borderRadius?: number;
|
|
24
|
+
inputBorderColor?: Color;
|
|
25
|
+
borderSides?: BorderSides;
|
|
26
|
+
inputPadding?: {
|
|
27
|
+
top: number;
|
|
28
|
+
bottom: number;
|
|
29
|
+
left: number;
|
|
30
|
+
right: number;
|
|
31
|
+
};
|
|
32
|
+
inputSpacing?: number;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +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,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,MAAM,MAAM,WAAW,GAAG,CAAC,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC,EAAE,CAAC;AAE1E,MAAM,WAAW,UACf,SAAQ,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,UAAU,CAAC,EACnE,YAAY,CAAC,OAAO,aAAa,CAAC;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,oBAAoB,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;IACnD,oBAAoB,CAAC,EAAE,KAAK,CAAC;IAC7B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,eAAe,CAAC,EAAE,KAAK,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,KAAK,CAAC;IACzB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,YAAY,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;KAAE,CAAC;IAC7E,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { InputProps } from "../../../components/ui/Input/types";
|
|
3
|
+
export declare const DEFAULT_ICON_SIZE = 20;
|
|
4
|
+
export declare const DEFAULT_X_PADDING = 12;
|
|
5
|
+
export declare const DEFAULT_Y_PADDING = 8;
|
|
6
|
+
export declare const inputVariants: (props?: ({
|
|
7
|
+
hasLabel?: boolean | null | undefined;
|
|
8
|
+
error?: boolean | null | undefined;
|
|
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">) => {
|
|
11
|
+
Comp: string | import("react").ForwardRefExoticComponent<import("@radix-ui/react-slot").SlotProps & import("react").RefAttributes<HTMLElement>>;
|
|
12
|
+
inputPaddingRight: string | undefined;
|
|
13
|
+
inputPaddingLeft: string | undefined;
|
|
14
|
+
borderStyle: {
|
|
15
|
+
borderWidth: string;
|
|
16
|
+
borderTopWidth?: undefined;
|
|
17
|
+
borderBottomWidth?: undefined;
|
|
18
|
+
borderLeftWidth?: undefined;
|
|
19
|
+
borderRightWidth?: undefined;
|
|
20
|
+
} | {
|
|
21
|
+
borderTopWidth: string | number;
|
|
22
|
+
borderBottomWidth: string | number;
|
|
23
|
+
borderLeftWidth: string | number;
|
|
24
|
+
borderRightWidth: string | number;
|
|
25
|
+
borderWidth?: undefined;
|
|
26
|
+
};
|
|
27
|
+
borderRadiusStyle: {
|
|
28
|
+
borderRadius: string;
|
|
29
|
+
} | {
|
|
30
|
+
borderRadius?: undefined;
|
|
31
|
+
};
|
|
32
|
+
iconLeftPadding: string;
|
|
33
|
+
iconRightPadding: string;
|
|
34
|
+
iconTopPadding: string;
|
|
35
|
+
iconBottomPadding: string;
|
|
36
|
+
placeholderTextColorStyle: string | undefined;
|
|
37
|
+
iconColorStyle: string | undefined;
|
|
38
|
+
inputBgColor: string | undefined;
|
|
39
|
+
inputBorderColorStyle: string | undefined;
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=useInput.d.ts.map
|
|
@@ -0,0 +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,UAAW,KAAK,UAAU,EAAE,SAAS,GAAG,MAAM,GAAG,cAAc,GAAG,WAAW,GAAG,WAAW,GAAG,iBAAiB,GAAG,cAAc,GAAG,kBAAkB,GAAG,aAAa,GAAG,cAAc,GAAG,cAAc,GAAG,sBAAsB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkErP,CAAA"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { getColor } from "../../../lib/utils";
|
|
2
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
4
|
+
export const DEFAULT_ICON_SIZE = 20;
|
|
5
|
+
export const DEFAULT_X_PADDING = 12;
|
|
6
|
+
export const DEFAULT_Y_PADDING = 8;
|
|
7
|
+
export const inputVariants = cva("flex w-full border border-coreColors-dividingLines bg-coreColors-inputBackground text-textColors-primaryColor text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-textColors-secondaryColor focus-visible:outline-none focus-visible:ring-0 disabled:cursor-not-allowed disabled:opacity-50 focus:border-coreColors-brandColorPrimary peer data-[icon=true]:pr-10", {
|
|
8
|
+
variants: {
|
|
9
|
+
hasLabel: {
|
|
10
|
+
true: "h-14 px-4 rounded pt-5 pb-2 placeholder-shown:p-4",
|
|
11
|
+
false: "pl-10 pr-4 py-2",
|
|
12
|
+
},
|
|
13
|
+
error: {
|
|
14
|
+
true: "border-stateColors-error text-stateColors-error placeholder:text-stateColors-error focus:border-stateColors-error [&+label]:text-stateColors-error",
|
|
15
|
+
false: "",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
defaultVariants: {
|
|
19
|
+
error: false,
|
|
20
|
+
hasLabel: true,
|
|
21
|
+
},
|
|
22
|
+
});
|
|
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 = DEFAULT_X_PADDING, } = props;
|
|
26
|
+
const Comp = asChild ? Slot : "div";
|
|
27
|
+
const inputPaddingRight = icon && iconPosition === "right" ? (inputPadding === null || inputPadding === void 0 ? void 0 : inputPadding.right) ? `${inputPadding === null || inputPadding === void 0 ? void 0 : inputPadding.right}px` : "2.5rem" : undefined;
|
|
28
|
+
const inputPaddingLeft = icon && iconPosition === "left"
|
|
29
|
+
? (inputPadding === null || inputPadding === void 0 ? void 0 : inputPadding.left) !== undefined && inputSpacing
|
|
30
|
+
? `calc(${(inputPadding === null || inputPadding === void 0 ? void 0 : inputPadding.left) + inputSpacing + DEFAULT_ICON_SIZE}px)`
|
|
31
|
+
: (inputPadding === null || inputPadding === void 0 ? void 0 : inputPadding.left)
|
|
32
|
+
? `calc(${(inputPadding === null || inputPadding === void 0 ? void 0 : inputPadding.left) + DEFAULT_ICON_SIZE + DEFAULT_Y_PADDING}px)`
|
|
33
|
+
: inputSpacing
|
|
34
|
+
? `calc(${inputSpacing + DEFAULT_X_PADDING + DEFAULT_ICON_SIZE}px)`
|
|
35
|
+
: `calc(${DEFAULT_Y_PADDING + DEFAULT_X_PADDING + DEFAULT_ICON_SIZE}px)`
|
|
36
|
+
: undefined;
|
|
37
|
+
const borderStyle = borderSides.includes("all")
|
|
38
|
+
? { borderWidth: "1px" }
|
|
39
|
+
: {
|
|
40
|
+
borderTopWidth: borderSides.includes("top") ? "1px" : 0,
|
|
41
|
+
borderBottomWidth: borderSides.includes("bottom") ? "1px" : 0,
|
|
42
|
+
borderLeftWidth: borderSides.includes("left") ? "1px" : 0,
|
|
43
|
+
borderRightWidth: borderSides.includes("right") ? "1px" : 0,
|
|
44
|
+
};
|
|
45
|
+
const borderRadiusStyle = borderRadius ? { borderRadius: `${borderRadius}px` } : {};
|
|
46
|
+
const iconLeftPadding = (inputPadding === null || inputPadding === void 0 ? void 0 : inputPadding.left) !== undefined ? `${inputPadding.left}px` : `${DEFAULT_X_PADDING}px`;
|
|
47
|
+
const iconRightPadding = (inputPadding === null || inputPadding === void 0 ? void 0 : inputPadding.right) !== undefined ? `${inputPadding.right}px` : `${DEFAULT_X_PADDING}px`;
|
|
48
|
+
const iconTopPadding = (inputPadding === null || inputPadding === void 0 ? void 0 : inputPadding.top) !== undefined ? `${inputPadding.top}px` : `${DEFAULT_Y_PADDING}px`;
|
|
49
|
+
const iconBottomPadding = (inputPadding === null || inputPadding === void 0 ? void 0 : inputPadding.bottom) !== undefined ? `${inputPadding.bottom}px` : `${DEFAULT_Y_PADDING}px`;
|
|
50
|
+
const iconColorStyle = getColor(iconColor);
|
|
51
|
+
const inputBgColor = getColor(backgroundColor);
|
|
52
|
+
const inputBorderColorStyle = getColor(inputBorderColor);
|
|
53
|
+
const placeholderTextColorStyle = getColor(placeholderTextColor);
|
|
54
|
+
return {
|
|
55
|
+
Comp,
|
|
56
|
+
inputPaddingRight,
|
|
57
|
+
inputPaddingLeft,
|
|
58
|
+
borderStyle,
|
|
59
|
+
borderRadiusStyle,
|
|
60
|
+
iconLeftPadding,
|
|
61
|
+
iconRightPadding,
|
|
62
|
+
iconTopPadding,
|
|
63
|
+
iconBottomPadding,
|
|
64
|
+
placeholderTextColorStyle,
|
|
65
|
+
iconColorStyle,
|
|
66
|
+
inputBgColor,
|
|
67
|
+
inputBorderColorStyle,
|
|
68
|
+
};
|
|
69
|
+
};
|
|
@@ -10,6 +10,7 @@ export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElemen
|
|
|
10
10
|
icon?: string;
|
|
11
11
|
labelClassName?: string;
|
|
12
12
|
labelStyle?: React.CSSProperties | undefined;
|
|
13
|
+
iconColor?: string;
|
|
13
14
|
}
|
|
14
15
|
declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
15
16
|
export { Button, buttonVariants };
|
|
@@ -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;AAKjE,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,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,UAAU,CAAC,EAAE,KAAK,CAAC,aAAa,GAAG,SAAS,CAAA;
|
|
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;AAKjE,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,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,UAAU,CAAC,EAAE,KAAK,CAAC,aAAa,GAAG,SAAS,CAAA;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,QAAA,MAAM,MAAM,uFAuEX,CAAA;AAGD,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -79,13 +79,13 @@ const labelVariants = cva("truncate", {
|
|
|
79
79
|
},
|
|
80
80
|
});
|
|
81
81
|
const Button = React.forwardRef((_a, ref) => {
|
|
82
|
-
var { className, labelClassName, labelStyle, variant, size, asChild = false, loading, icon } = _a, props = __rest(_a, ["className", "labelClassName", "labelStyle", "variant", "size", "asChild", "loading", "icon"]);
|
|
82
|
+
var { className, labelClassName, labelStyle, variant, size, asChild = false, loading, icon, iconColor } = _a, props = __rest(_a, ["className", "labelClassName", "labelStyle", "variant", "size", "asChild", "loading", "icon", "iconColor"]);
|
|
83
83
|
const Comp = asChild ? Slot : "button";
|
|
84
84
|
const IconButton = () => (icon ? _jsx(Icon, { name: icon, size: "sm" }) : null);
|
|
85
|
-
const BasicButton = () => (_jsxs(_Fragment, { children: [icon ? (_jsx(Icon, { name: icon, size: variant === "quickadd" ? "xs" : "sm", className: cn(iconVariants({ variant }), "mr-2") })) : null, !loading ? (_jsx(Text, Object.assign({ type: "body-primary", className: cn(labelVariants({ variant }), labelClassName), style: labelStyle }, { children: props.children }))) : (_jsx(_Fragment, {}))] }));
|
|
85
|
+
const BasicButton = () => (_jsxs(_Fragment, { children: [icon ? (_jsx(Icon, { name: icon, size: variant === "quickadd" ? "xs" : "sm", className: cn(iconVariants({ variant }), "mr-2"), style: { color: iconColor } })) : null, !loading ? (_jsx(Text, Object.assign({ type: "body-primary", className: cn(labelVariants({ variant }), labelClassName), style: labelStyle }, { children: props.children }))) : (_jsx(_Fragment, {}))] }));
|
|
86
86
|
return (_jsx(Comp, Object.assign({ className: cn(buttonVariants({ variant, size }), className, {
|
|
87
87
|
"pointer-events-none": loading,
|
|
88
|
-
}), ref: ref }, props, { children: loading ? (_jsx("div", Object.assign({ className: cn("flex items-center justify-center", size === "icon" ? "h-5" : "h-6") }, { children: _jsx(Icon, { className: cn(iconVariants({ variant }), "h-5 w-5 animate-spin"), name: "loader" }) }))) : size === "icon" ? (_jsx(IconButton, {})) : (_jsx(BasicButton, {})) })));
|
|
88
|
+
}), ref: ref }, props, { children: loading ? (_jsx("div", Object.assign({ className: cn("flex items-center justify-center", size === "icon" ? "h-5" : "h-6") }, { children: _jsx(Icon, { className: cn(iconVariants({ variant }), "h-5 w-5 animate-spin"), name: "loader", style: { color: iconColor } }) }))) : size === "icon" ? (_jsx(IconButton, {})) : (_jsx(BasicButton, {})) })));
|
|
89
89
|
});
|
|
90
90
|
Button.displayName = "Button";
|
|
91
91
|
export { Button, buttonVariants };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../../components/ui/icon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAEL,eAAe,
|
|
1
|
+
{"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../../components/ui/icon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAEL,eAAe,EAkChB,MAAM,qBAAqB,CAAA;AAI5B,QAAA,MAAM,YAAY;;;mFAgBjB,CAAA;AAsDD,MAAM,WAAW,SACf,SAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC,EACzD,YAAY,CAAC,OAAO,YAAY,CAAC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,iBAAS,IAAI,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,IAAW,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,SAAS,2CAczE;AAED,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,eAAe,EAAE,CAAA"}
|
|
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { cva } from "class-variance-authority";
|
|
14
|
-
import { IconUpload, IconPencilMinus, IconPlus, IconMinus, IconAdjustmentsAlt, IconArrowsSort, IconAlertCircle, IconCircleX, IconInfoCircle, IconCheck, IconSquareOff, IconMapPin, IconRepeat, IconSquare, IconSquareCheck, IconChevronUp, IconChevronRight, IconEyeOff, IconSquareX, IconCircle, IconChevronDown, IconHeartFilled, IconCurrencyDollar, IconX, IconCircleOff, IconCircleDotFilled, IconMoodSad, IconSquareXFilled, IconTrash, IconLoader2, } from "@tabler/icons-react";
|
|
14
|
+
import { IconUpload, IconPencilMinus, IconPlus, IconMinus, IconAdjustmentsAlt, IconArrowsSort, IconAlertCircle, IconCircleX, IconInfoCircle, IconCheck, IconSquareOff, IconMapPin, IconRepeat, IconSquare, IconSquareCheck, IconChevronUp, IconChevronRight, IconEyeOff, IconSquareX, IconCircle, IconChevronDown, IconHeartFilled, IconCurrencyDollar, IconX, IconCircleOff, IconCircleDotFilled, IconMoodSad, IconSquareXFilled, IconTrash, IconLoader2, IconColumns1, IconColumns2, IconColumns3, IconSearch, IconShoppingCartOff } from "@tabler/icons-react";
|
|
15
15
|
import { cn, iconColorVariantClasses } from "../../lib/utils";
|
|
16
16
|
const iconVariants = cva("inline-flex items-center justify-center text-sm font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none ring-offset-background", {
|
|
17
17
|
variants: {
|
|
@@ -70,6 +70,11 @@ const icons = {
|
|
|
70
70
|
"square-x-filled": IconSquareXFilled,
|
|
71
71
|
trash: IconTrash,
|
|
72
72
|
loader: IconLoader2,
|
|
73
|
+
"columns-1": IconColumns1,
|
|
74
|
+
"columns-2": IconColumns2,
|
|
75
|
+
"columns-3": IconColumns3,
|
|
76
|
+
search: IconSearch,
|
|
77
|
+
"shopping-cart-off": IconShoppingCartOff,
|
|
73
78
|
};
|
|
74
79
|
function Icon(_a) {
|
|
75
80
|
var { className, name, size = "md", color } = _a, props = __rest(_a, ["className", "name", "size", "color"]);
|
|
@@ -54,6 +54,9 @@ type TapcartImageBaseProps = {
|
|
|
54
54
|
* "fill" maps to `object-fit: cover`
|
|
55
55
|
*/
|
|
56
56
|
objectFit?: "fit" | "fill" | "cover" | "contain" | "none" | "scale-down";
|
|
57
|
+
/** An optional prop to set styles for the image wrapper
|
|
58
|
+
*/
|
|
59
|
+
imageWrapperStyles?: any;
|
|
57
60
|
};
|
|
58
61
|
/**
|
|
59
62
|
* Tapcart’s Image component is a wrapper around the HTML image element.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../components/ui/image.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../components/ui/image.tsx"],"names":[],"mappings":"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"}
|
|
@@ -9,10 +9,27 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
/* eslint-disable react/display-name */
|
|
14
14
|
/* eslint-disable @next/next/no-img-element */
|
|
15
15
|
import * as React from "react";
|
|
16
|
+
import ReactDOM from "react-dom";
|
|
17
|
+
function ImagePreload({ imgAttributes }) {
|
|
18
|
+
const opts = {
|
|
19
|
+
as: "image",
|
|
20
|
+
imageSrcSet: imgAttributes.srcSet,
|
|
21
|
+
imageSizes: imgAttributes.sizes,
|
|
22
|
+
fetchPriority: imgAttributes.fetchPriority,
|
|
23
|
+
};
|
|
24
|
+
if (ReactDOM.preload) {
|
|
25
|
+
// See https://github.com/facebook/react/pull/26940
|
|
26
|
+
ReactDOM.preload(imgAttributes.src,
|
|
27
|
+
// @ts-expect-error TODO: upgrade to `@types/react-dom@18.3.x`
|
|
28
|
+
opts);
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
16
33
|
/**
|
|
17
34
|
* Tapcart’s Image component is a wrapper around the HTML image element.
|
|
18
35
|
* It supports the same props as the HTML `img` element, but automatically
|
|
@@ -49,12 +66,12 @@ import * as React from "react";
|
|
|
49
66
|
*/
|
|
50
67
|
export const Image = React.forwardRef((_a, ref) => {
|
|
51
68
|
var _b;
|
|
52
|
-
var { alt, aspectRatio, crop = "center", data, decoding = "async", height = "auto", loader = shopifyLoader, loading = "lazy", sizes, src, srcSetOptions = {
|
|
69
|
+
var { alt, aspectRatio, crop = "center", data, decoding = "async", height = "auto", loader = shopifyLoader, loading = "lazy", sizes, src, imageWrapperStyles, srcSetOptions = {
|
|
53
70
|
intervals: 15,
|
|
54
71
|
startingWidth: 100,
|
|
55
72
|
incrementSize: 100,
|
|
56
73
|
placeholderWidth: 100,
|
|
57
|
-
}, width = "100%", objectFit = "cover" } = _a, passthroughProps = __rest(_a, ["alt", "aspectRatio", "crop", "data", "decoding", "height", "loader", "loading", "sizes", "src", "srcSetOptions", "width", "objectFit"]);
|
|
74
|
+
}, width = "100%", objectFit = "cover" } = _a, passthroughProps = __rest(_a, ["alt", "aspectRatio", "crop", "data", "decoding", "height", "loader", "loading", "sizes", "src", "imageWrapperStyles", "srcSetOptions", "width", "objectFit"]);
|
|
58
75
|
/*
|
|
59
76
|
* Gets normalized values for width, height from data prop
|
|
60
77
|
*/
|
|
@@ -100,6 +117,7 @@ export const Image = React.forwardRef((_a, ref) => {
|
|
|
100
117
|
: objectFit === "fit"
|
|
101
118
|
? "contain"
|
|
102
119
|
: objectFit;
|
|
120
|
+
const nFetchPriority = loading === "eager" ? "high" : "auto";
|
|
103
121
|
return {
|
|
104
122
|
width: nWidth,
|
|
105
123
|
height: nHeight,
|
|
@@ -107,6 +125,7 @@ export const Image = React.forwardRef((_a, ref) => {
|
|
|
107
125
|
alt: nAlt,
|
|
108
126
|
aspectRatio: nAspectRatio,
|
|
109
127
|
objectFit: nObjectFit,
|
|
128
|
+
fetchPriority: nFetchPriority,
|
|
110
129
|
};
|
|
111
130
|
}, [
|
|
112
131
|
width,
|
|
@@ -135,15 +154,26 @@ export const Image = React.forwardRef((_a, ref) => {
|
|
|
135
154
|
setHasError(true);
|
|
136
155
|
};
|
|
137
156
|
const imgClassName = `opacity-0 transition-opacity duration-500 ease-in-out ${isLoaded ? "opacity-100" : ""}`;
|
|
138
|
-
const wrapperStyle = {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
157
|
+
const wrapperStyle = Object.assign({ aspectRatio: (_b = normalizedProps.aspectRatio) === null || _b === void 0 ? void 0 : _b.replace(":", "/") }, imageWrapperStyles);
|
|
158
|
+
const srcSet = generateSrcSet(normalizedProps.src, generateSizes(imageWidths, normalizedProps.aspectRatio, crop), loader, normalizedProps.objectFit === "contain");
|
|
159
|
+
return (_jsxs(_Fragment, { children: [loading === "eager" && (_jsx(ImagePreload, { imgAttributes: {
|
|
160
|
+
srcSet,
|
|
161
|
+
sizes,
|
|
162
|
+
fetchPriority: normalizedProps.fetchPriority,
|
|
163
|
+
src: normalizedProps.src || "",
|
|
164
|
+
} })), _jsx("div", Object.assign({ className: "relative bg-stateColors-skeleton border-transparent", style: 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,
|
|
165
|
+
// `src` needs to come after `sizes` and `srcSet` because React updates
|
|
166
|
+
// attributes in order. If we keep `src` the first one, Safari will
|
|
167
|
+
// immediately start to fetch `src`, before `sizes` and `srcSet` are even
|
|
168
|
+
// updated by React. That causes multiple unnecessary requests if `srcSet`
|
|
169
|
+
// and `sizes` are defined.
|
|
170
|
+
// This bug cannot be reproduced in Chrome or Firefox.
|
|
171
|
+
src: normalizedProps.src, ref: ref, style: {
|
|
172
|
+
objectFit: normalizedProps.objectFit,
|
|
173
|
+
maxHeight: "100%",
|
|
174
|
+
height: "100%",
|
|
175
|
+
width: "100%",
|
|
176
|
+
} }))) : (_jsx("div", { className: "absolute top-0 left-0 w-full h-full bg-stateColors-skeleton " })) }))] }));
|
|
147
177
|
});
|
|
148
178
|
/**
|
|
149
179
|
* The shopifyLoader function is a simple utility function that takes a src, width,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"money.d.ts","sourceRoot":"","sources":["../../../components/ui/money.tsx"],"names":[],"mappings":"AACA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEjE,UAAU,SAAS;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;CACd;AAED,QAAA,MAAM,aAAa,gGAMjB,CAAA;AAEF,MAAM,WAAW,UACf,SAAQ,SAAS,EACf,YAAY,CAAC,OAAO,aAAa,CAAC;CAAG;AAEzC,iBAAS,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"money.d.ts","sourceRoot":"","sources":["../../../components/ui/money.tsx"],"names":[],"mappings":"AACA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEjE,UAAU,SAAS;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;CACd;AAED,QAAA,MAAM,aAAa,gGAMjB,CAAA;AAEF,MAAM,WAAW,UACf,SAAQ,SAAS,EACf,YAAY,CAAC,OAAO,aAAa,CAAC;CAAG;AAEzC,iBAAS,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,UAAU,2CAS/D;AAED,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,CAAA"}
|
|
@@ -23,6 +23,7 @@ function Money(_a) {
|
|
|
23
23
|
const formatter = new Intl.NumberFormat(locale, {
|
|
24
24
|
style: "currency",
|
|
25
25
|
currency: currency,
|
|
26
|
+
currencyDisplay: "narrowSymbol",
|
|
26
27
|
});
|
|
27
28
|
let formattedPrice = formatter.format(Number(price));
|
|
28
29
|
return _jsx("span", Object.assign({}, props, { children: formattedPrice }));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Product } from "app-studio-types";
|
|
3
3
|
type Config = {
|
|
4
|
-
|
|
4
|
+
columns?: string;
|
|
5
5
|
productImage?: {
|
|
6
6
|
enabled: boolean;
|
|
7
7
|
cornerRadius: number;
|
|
@@ -80,6 +80,7 @@ export type ProductCardProps = {
|
|
|
80
80
|
productId: string;
|
|
81
81
|
variantId?: string;
|
|
82
82
|
}) => void;
|
|
83
|
+
className?: string;
|
|
83
84
|
};
|
|
84
85
|
declare const ProductCard: React.FC<ProductCardProps>;
|
|
85
86
|
export { ProductCard };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-card.d.ts","sourceRoot":"","sources":["../../../components/ui/product-card.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAO9B,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAG1C,KAAK,MAAM,GAAG;IACZ,
|
|
1
|
+
{"version":3,"file":"product-card.d.ts","sourceRoot":"","sources":["../../../components/ui/product-card.tsx"],"names":[],"mappings":"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"}
|
|
@@ -133,7 +133,7 @@ const productCardFavoriteVariants = cva("absolute ", {
|
|
|
133
133
|
iconPosition: "below-image-on-right",
|
|
134
134
|
},
|
|
135
135
|
});
|
|
136
|
-
const ProductCard = ({ config, tapcartData, product, isLoading, favorited, onFavoriteClick, onQuickAdd, openProduct, }) => {
|
|
136
|
+
const ProductCard = ({ config, tapcartData, product, isLoading, favorited, onFavoriteClick, onQuickAdd, openProduct, className, }) => {
|
|
137
137
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18;
|
|
138
138
|
const { variants, images, title, tags } = product;
|
|
139
139
|
// Select the variant that has the lowest price that is available or just the lowest price if none are available
|
|
@@ -172,12 +172,12 @@ const ProductCard = ({ config, tapcartData, product, isLoading, favorited, onFav
|
|
|
172
172
|
// Prepare Product Open
|
|
173
173
|
const _openProduct = () => openProduct === null || openProduct === void 0 ? void 0 : openProduct({ productId, variantId });
|
|
174
174
|
const getImageSizes = (config) => {
|
|
175
|
-
switch (config.
|
|
176
|
-
case "
|
|
175
|
+
switch (config.columns) {
|
|
176
|
+
case "1":
|
|
177
177
|
return "100vw";
|
|
178
|
-
case "
|
|
178
|
+
case "2":
|
|
179
179
|
return "50vw";
|
|
180
|
-
case "
|
|
180
|
+
case "3":
|
|
181
181
|
return "33vw";
|
|
182
182
|
default:
|
|
183
183
|
return "100vw";
|
|
@@ -185,7 +185,7 @@ const ProductCard = ({ config, tapcartData, product, isLoading, favorited, onFav
|
|
|
185
185
|
};
|
|
186
186
|
const sizes = getImageSizes(config);
|
|
187
187
|
const imageSwipeEnabled = (((_e = config.productImage) === null || _e === void 0 ? void 0 : _e.allowSwipeability) && product.images.length > 1);
|
|
188
|
-
return (_jsx("div", Object.assign({ className:
|
|
188
|
+
return (_jsx("div", Object.assign({ className: cn("w-1/2", className) }, { children: _jsxs("div", Object.assign({ className: "w-full active:opacity-70", onClick: () => {
|
|
189
189
|
_openProduct();
|
|
190
190
|
} }, { children: [((_f = config.productImage) === null || _f === void 0 ? void 0 : _f.enabled) && (_jsxs("div", Object.assign({ className: "relative w-full overflow-hidden", style: {
|
|
191
191
|
borderTopLeftRadius: `${config.productImage.cornerRadius}px`,
|
|
@@ -24,6 +24,7 @@ declare const Selectors: React.ForwardRefExoticComponent<Omit<React.DetailedHTML
|
|
|
24
24
|
type SelectorContainerProps = {
|
|
25
25
|
children: React.ReactElement<SelectorsProps>[];
|
|
26
26
|
containerRef: React.RefObject<HTMLDivElement>;
|
|
27
|
+
className: string;
|
|
27
28
|
};
|
|
28
29
|
declare const SelectorContainer: React.FC<SelectorContainerProps>;
|
|
29
30
|
export { SelectorContainer, Selectors, selectorsVariants };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../../components/ui/selectors.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAIjE,QAAA,MAAM,iBAAiB;;;mFAiBtB,CAAA;AACD,KAAK,cAAc,GAAG,KAAK,CAAC,wBAAwB,CAAC,QAAQ,CAAC,GAC5D,YAAY,CAAC,OAAO,iBAAiB,CAAC,GAAG;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,GAAG,SAAS,CAAA;CAClE,CAAA;AAEH,QAAA,MAAM,SAAS;;;;;;;;eAHA,MAAM,iBAAiB,CAAC,iBAAiB,CAAC,GAAG,SAAS;
|
|
1
|
+
{"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../../components/ui/selectors.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAIjE,QAAA,MAAM,iBAAiB;;;mFAiBtB,CAAA;AACD,KAAK,cAAc,GAAG,KAAK,CAAC,wBAAwB,CAAC,QAAQ,CAAC,GAC5D,YAAY,CAAC,OAAO,iBAAiB,CAAC,GAAG;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,GAAG,SAAS,CAAA;CAClE,CAAA;AAEH,QAAA,MAAM,SAAS;;;;;;;;eAHA,MAAM,iBAAiB,CAAC,iBAAiB,CAAC,GAAG,SAAS;2CAyCpE,CAAA;AACD,KAAK,sBAAsB,GAAG;IAC5B,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC,cAAc,CAAC,EAAE,CAAA;IAC9C,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAA;IAC7C,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AACD,QAAA,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CA6CvD,CAAA;AAID,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAA"}
|
|
@@ -31,14 +31,14 @@ const selectorsVariants = cva("flex py-2 px-4 whitespace-nowrap bg-coreColors-pa
|
|
|
31
31
|
},
|
|
32
32
|
});
|
|
33
33
|
const Selectors = React.forwardRef((_a, ref) => {
|
|
34
|
-
var { label, selected, disabled = false, className, onSelect } = _a, props = __rest(_a, ["label", "selected", "disabled", "className", "onSelect"]);
|
|
34
|
+
var { label, selected, disabled = false, className, onSelect, children } = _a, props = __rest(_a, ["label", "selected", "disabled", "className", "onSelect", "children"]);
|
|
35
35
|
return (_jsx("button", Object.assign({ disabled: disabled, onClick: onSelect, className: cn(selectorsVariants({
|
|
36
36
|
selected: selected,
|
|
37
37
|
className,
|
|
38
38
|
disabled,
|
|
39
|
-
}), "group"), ref: ref }, props, { children: _jsx(Text, Object.assign({ type: "body-primary", color: "text-textColors-primaryColor" }, { children: label })) })));
|
|
39
|
+
}), "group"), ref: ref }, props, { children: children ? (children) : (_jsx(Text, Object.assign({ type: "body-primary", color: "text-textColors-primaryColor" }, { children: label }))) })));
|
|
40
40
|
});
|
|
41
|
-
const SelectorContainer = ({ children, containerRef, }) => {
|
|
41
|
+
const SelectorContainer = ({ children, containerRef, className, }) => {
|
|
42
42
|
const [showFadeLeft, setShowFadeLeft] = React.useState(false);
|
|
43
43
|
const [showFadeRight, setShowFadeRight] = React.useState(false);
|
|
44
44
|
const checkOverflow = () => {
|
|
@@ -55,7 +55,7 @@ const SelectorContainer = ({ children, containerRef, }) => {
|
|
|
55
55
|
React.useEffect(() => {
|
|
56
56
|
checkOverflow();
|
|
57
57
|
}, [children]);
|
|
58
|
-
return (_jsx("div", Object.assign({ className: "relative" }, { children: _jsxs("div", Object.assign({ className: "flex gap-2 px-1 h-[42px] items-center overflow-x-auto overflow-y-hidden no-scrollbar", onScroll: checkOverflow, ref: containerRef }, { children: [children, showFadeLeft && (_jsx("div", { className: "absolute top-0 left-0 w-8 h-full pointer-events-none bg-fade-left" })), showFadeRight && (_jsx("div", { className: "absolute top-0 right-0 w-8 h-full pointer-events-none bg-fade-right" }))] })) })));
|
|
58
|
+
return (_jsx("div", Object.assign({ className: "relative" }, { children: _jsxs("div", Object.assign({ className: cn("flex gap-2 px-1 h-[42px] items-center overflow-x-auto overflow-y-hidden no-scrollbar", className), onScroll: checkOverflow, ref: containerRef }, { children: [children, showFadeLeft && (_jsx("div", { className: "absolute top-0 left-0 w-8 h-full pointer-events-none bg-fade-left" })), showFadeRight && (_jsx("div", { className: "absolute top-0 right-0 w-8 h-full pointer-events-none bg-fade-right" }))] })) })));
|
|
59
59
|
};
|
|
60
60
|
Selectors.displayName = "Selectors";
|
|
61
61
|
export { SelectorContainer, Selectors, selectorsVariants };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { type VariantProps } from "class-variance-authority";
|
|
3
3
|
declare const skeletonVariants: (props?: ({
|
|
4
|
-
variant?: "
|
|
4
|
+
variant?: "line" | "rectangular" | "circle" | null | undefined;
|
|
5
5
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
6
6
|
export interface SkeletonProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof skeletonVariants> {
|
|
7
7
|
height?: number;
|
|
@@ -14,7 +14,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
14
14
|
import * as React from "react";
|
|
15
15
|
import * as SliderPrimitive from "@radix-ui/react-slider";
|
|
16
16
|
import { cn } from "../../lib/utils";
|
|
17
|
-
import { Input } from "./
|
|
17
|
+
import { Input } from "./Input";
|
|
18
18
|
const Slider = React.forwardRef((_a, ref) => {
|
|
19
19
|
var { className, max, min = 0, step = 1, defaultValue, value, onChange } = _a,
|
|
20
20
|
// doubleValue = false,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from "./components/ui/button";
|
|
2
|
-
export * from "./components/ui/input";
|
|
2
|
+
export * from "./components/ui/Input/input";
|
|
3
3
|
export * from "./components/ui/aspect-ratio";
|
|
4
4
|
export * from "./components/ui/accordion";
|
|
5
5
|
export * from "./components/ui/icon";
|
|
@@ -32,14 +32,13 @@ export * from "./components/ui/favorite";
|
|
|
32
32
|
export * from "./components/ui/wishlist";
|
|
33
33
|
export * from "./components/ui/product-card";
|
|
34
34
|
export * from "./components/ui/dropdown";
|
|
35
|
-
export * from "./components/ui/product-grid";
|
|
36
35
|
export * from "./components/ui/quantity-picker";
|
|
37
36
|
export * from "./components/hooks/use-infinite-scroll";
|
|
38
37
|
export * from "./components/ui/subscription";
|
|
39
38
|
export * from "./components/ui/line-item-text-icons";
|
|
40
39
|
export * from "./components/ui/textarea";
|
|
41
40
|
export * from "./components/hooks/use-scroll-direction";
|
|
41
|
+
export { cn, cva, getColor } from "./lib/utils";
|
|
42
42
|
export * from "./components/ui/image";
|
|
43
43
|
export * from "./components/ui/empty-message";
|
|
44
|
-
export { cn, cva } from "./lib/utils";
|
|
45
44
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AACA,cAAc,wBAAwB,CAAA;AACtC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AACA,cAAc,wBAAwB,CAAA;AACtC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,8BAA8B,CAAA;AAC5C,cAAc,2BAA2B,CAAA;AACzC,cAAc,sBAAsB,CAAA;AACpC,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA;AACxC,cAAc,2BAA2B,CAAA;AACzC,cAAc,sBAAsB,CAAA;AACpC,cAAc,uBAAuB,CAAA;AACrC,cAAc,2BAA2B,CAAA;AACzC,cAAc,uBAAuB,CAAA;AACrC,cAAc,uBAAuB,CAAA;AACrC,cAAc,uBAAuB,CAAA;AACrC,cAAc,0BAA0B,CAAA;AACxC,cAAc,sBAAsB,CAAA;AACpC,cAAc,wBAAwB,CAAA;AACtC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,wBAAwB,CAAA;AACtC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,wBAAwB,CAAA;AACtC,cAAc,2BAA2B,CAAA;AACzC,cAAc,uBAAuB,CAAA;AACrC,cAAc,yBAAyB,CAAA;AACvC,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,wBAAwB,CAAA;AACtC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,sBAAsB,CAAA;AACpC,cAAc,uBAAuB,CAAA;AACrC,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA;AACxC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,0BAA0B,CAAA;AACxC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,wCAAwC,CAAA;AACtD,cAAc,8BAA8B,CAAA;AAC5C,cAAc,sCAAsC,CAAA;AACpD,cAAc,0BAA0B,CAAA;AACxC,cAAc,yCAAyC,CAAA;AACvD,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAC/C,cAAc,uBAAuB,CAAA;AACrC,cAAc,+BAA+B,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// component exports
|
|
2
2
|
export * from "./components/ui/button";
|
|
3
|
-
export * from "./components/ui/input";
|
|
3
|
+
export * from "./components/ui/Input/input";
|
|
4
4
|
export * from "./components/ui/aspect-ratio";
|
|
5
5
|
export * from "./components/ui/accordion";
|
|
6
6
|
export * from "./components/ui/icon";
|
|
@@ -33,13 +33,12 @@ export * from "./components/ui/favorite";
|
|
|
33
33
|
export * from "./components/ui/wishlist";
|
|
34
34
|
export * from "./components/ui/product-card";
|
|
35
35
|
export * from "./components/ui/dropdown";
|
|
36
|
-
export * from "./components/ui/product-grid";
|
|
37
36
|
export * from "./components/ui/quantity-picker";
|
|
38
37
|
export * from "./components/hooks/use-infinite-scroll";
|
|
39
38
|
export * from "./components/ui/subscription";
|
|
40
39
|
export * from "./components/ui/line-item-text-icons";
|
|
41
40
|
export * from "./components/ui/textarea";
|
|
42
41
|
export * from "./components/hooks/use-scroll-direction";
|
|
42
|
+
export { cn, cva, getColor } from "./lib/utils";
|
|
43
43
|
export * from "./components/ui/image";
|
|
44
44
|
export * from "./components/ui/empty-message";
|
|
45
|
-
export { cn, cva } from "./lib/utils";
|
package/dist/lib/utils.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { ClassValue } from "clsx";
|
|
2
|
+
export type Color = {
|
|
3
|
+
type: "custom" | "brand-kit";
|
|
4
|
+
value: string;
|
|
5
|
+
};
|
|
2
6
|
export declare function cn(...inputs: ClassValue[]): string;
|
|
3
7
|
export declare const iconColorLevels: string[];
|
|
4
8
|
export declare const iconColorVariantClasses: Record<string, string>;
|
|
5
9
|
export { cva } from "class-variance-authority";
|
|
10
|
+
export declare const getColor: (colorOption: Color | undefined) => string | undefined;
|
|
6
11
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/lib/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAQ,MAAM,MAAM,CAAA;AAGvC,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC;AAED,eAAO,MAAM,eAAe,UAc3B,CAAA;AAED,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,CAAA;AAMjE,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAA"}
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAQ,MAAM,MAAM,CAAA;AAGvC,MAAM,MAAM,KAAK,GAAG;IAAE,IAAI,EAAE,QAAQ,GAAG,WAAW,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpE,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC;AAED,eAAO,MAAM,eAAe,UAc3B,CAAA;AAED,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,CAAA;AAMjE,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAA;AAG9C,eAAO,MAAM,QAAQ,gBAAiB,KAAK,GAAG,SAAS,uBAEtD,CAAC"}
|
package/dist/lib/utils.js
CHANGED
|
@@ -23,3 +23,6 @@ for (let iconColorLevel of iconColorLevels) {
|
|
|
23
23
|
iconColorVariantClasses[iconColorLevel] = `text-${iconColorLevel}`;
|
|
24
24
|
}
|
|
25
25
|
export { cva } from "class-variance-authority";
|
|
26
|
+
export const getColor = (colorOption) => {
|
|
27
|
+
return colorOption ? (colorOption === null || colorOption === void 0 ? void 0 : colorOption.type) === 'brand-kit' ? `var(--${colorOption.value})` : colorOption.value : undefined;
|
|
28
|
+
};
|
package/dist/styles.css
CHANGED
|
@@ -814,6 +814,10 @@ body {
|
|
|
814
814
|
right: 0.5rem;
|
|
815
815
|
}
|
|
816
816
|
|
|
817
|
+
.start-10 {
|
|
818
|
+
inset-inline-start: 2.5rem;
|
|
819
|
+
}
|
|
820
|
+
|
|
817
821
|
.start-4 {
|
|
818
822
|
inset-inline-start: 1rem;
|
|
819
823
|
}
|
|
@@ -908,6 +912,10 @@ body {
|
|
|
908
912
|
margin-bottom: 0.5rem;
|
|
909
913
|
}
|
|
910
914
|
|
|
915
|
+
.mb-4 {
|
|
916
|
+
margin-bottom: 1rem;
|
|
917
|
+
}
|
|
918
|
+
|
|
911
919
|
.mb-6 {
|
|
912
920
|
margin-bottom: 1.5rem;
|
|
913
921
|
}
|
|
@@ -963,10 +971,6 @@ body {
|
|
|
963
971
|
display: grid;
|
|
964
972
|
}
|
|
965
973
|
|
|
966
|
-
.aspect-\[2\/3\] {
|
|
967
|
-
aspect-ratio: 2/3;
|
|
968
|
-
}
|
|
969
|
-
|
|
970
974
|
.aspect-productImages {
|
|
971
975
|
aspect-ratio: var(--productImage-aspectRatio);
|
|
972
976
|
}
|
|
@@ -1275,6 +1279,21 @@ body {
|
|
|
1275
1279
|
resize: both;
|
|
1276
1280
|
}
|
|
1277
1281
|
|
|
1282
|
+
.columns-1 {
|
|
1283
|
+
-moz-columns: 1;
|
|
1284
|
+
columns: 1;
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
.columns-2 {
|
|
1288
|
+
-moz-columns: 2;
|
|
1289
|
+
columns: 2;
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
.columns-3 {
|
|
1293
|
+
-moz-columns: 3;
|
|
1294
|
+
columns: 3;
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1278
1297
|
.grid-cols-1 {
|
|
1279
1298
|
grid-template-columns: repeat(1, minmax(0, 1fr));
|
|
1280
1299
|
}
|
|
@@ -1586,11 +1605,6 @@ body {
|
|
|
1586
1605
|
background-color: var(--coreColors-pageColor);
|
|
1587
1606
|
}
|
|
1588
1607
|
|
|
1589
|
-
.bg-neutral-100 {
|
|
1590
|
-
--tw-bg-opacity: 1;
|
|
1591
|
-
background-color: rgb(245 245 245 / var(--tw-bg-opacity));
|
|
1592
|
-
}
|
|
1593
|
-
|
|
1594
1608
|
.bg-productBadging-fill {
|
|
1595
1609
|
background-color: var(--productBadging-fill);
|
|
1596
1610
|
}
|
|
@@ -1672,6 +1686,11 @@ body {
|
|
|
1672
1686
|
padding: 1px;
|
|
1673
1687
|
}
|
|
1674
1688
|
|
|
1689
|
+
.px-0 {
|
|
1690
|
+
padding-left: 0px;
|
|
1691
|
+
padding-right: 0px;
|
|
1692
|
+
}
|
|
1693
|
+
|
|
1675
1694
|
.px-1 {
|
|
1676
1695
|
padding-left: 0.25rem;
|
|
1677
1696
|
padding-right: 0.25rem;
|
|
@@ -1748,6 +1767,10 @@ body {
|
|
|
1748
1767
|
padding-left: 0px;
|
|
1749
1768
|
}
|
|
1750
1769
|
|
|
1770
|
+
.pl-10 {
|
|
1771
|
+
padding-left: 2.5rem;
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1751
1774
|
.pl-2 {
|
|
1752
1775
|
padding-left: 0.5rem;
|
|
1753
1776
|
}
|
|
@@ -2274,6 +2297,14 @@ body {
|
|
|
2274
2297
|
text-decoration-line: unset !important;
|
|
2275
2298
|
}
|
|
2276
2299
|
|
|
2300
|
+
body::-webkit-scrollbar {
|
|
2301
|
+
display: none;
|
|
2302
|
+
-ms-overflow-style: none;
|
|
2303
|
+
/* IE and Edge */
|
|
2304
|
+
scrollbar-width: none;
|
|
2305
|
+
/* Firefox */
|
|
2306
|
+
}
|
|
2307
|
+
|
|
2277
2308
|
.file\:border-0::file-selector-button {
|
|
2278
2309
|
border-width: 0px;
|
|
2279
2310
|
}
|
|
@@ -2745,11 +2776,6 @@ body {
|
|
|
2745
2776
|
animation-duration: 500ms;
|
|
2746
2777
|
}
|
|
2747
2778
|
|
|
2748
|
-
:is(.dark .dark\:bg-neutral-900) {
|
|
2749
|
-
--tw-bg-opacity: 1;
|
|
2750
|
-
background-color: rgb(23 23 23 / var(--tw-bg-opacity));
|
|
2751
|
-
}
|
|
2752
|
-
|
|
2753
2779
|
@media (min-width: 640px) {
|
|
2754
2780
|
.sm\:mt-0 {
|
|
2755
2781
|
margin-top: 0px;
|
|
@@ -2778,12 +2804,6 @@ body {
|
|
|
2778
2804
|
}
|
|
2779
2805
|
}
|
|
2780
2806
|
|
|
2781
|
-
@media (min-width: 1024px) {
|
|
2782
|
-
.lg\:grid-cols-3 {
|
|
2783
|
-
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
2784
|
-
}
|
|
2785
|
-
}
|
|
2786
|
-
|
|
2787
2807
|
.\[\&\+label\]\:text-stateColors-error+label {
|
|
2788
2808
|
color: var(--stateColors-error);
|
|
2789
2809
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tapcart/mobile-components",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"style": "dist/styles.css",
|
|
@@ -11,16 +11,6 @@
|
|
|
11
11
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
12
12
|
"author": "Tapcart Inc.",
|
|
13
13
|
"homepage": "https://tapcart.com",
|
|
14
|
-
"scripts": {
|
|
15
|
-
"lint": "eslint \"**/*.ts*\"",
|
|
16
|
-
"ui:add": "pnpm dlx shadcn-ui@latest add",
|
|
17
|
-
"build:styles": "postcss styles/globals.css -o dist/styles.css",
|
|
18
|
-
"build:ts": "tsc -p tsconfig.json && tsc-alias",
|
|
19
|
-
"build": "pnpm run build:ts && pnpm run build:styles",
|
|
20
|
-
"dev:ts": "tsc -w -p tsconfig.json",
|
|
21
|
-
"dev:styles": "npx tailwindcss -i styles/globals.css -o dist/styles.css --watch",
|
|
22
|
-
"dev": "concurrently \"pnpm run dev:ts\" \"pnpm run dev:styles\""
|
|
23
|
-
},
|
|
24
14
|
"peerDependencies": {
|
|
25
15
|
"react": "^17.0.2 || ^18.0.0",
|
|
26
16
|
"react-dom": "^17.0.2 || ^18.0.0"
|
|
@@ -29,17 +19,17 @@
|
|
|
29
19
|
"@types/lodash": "4.17.5",
|
|
30
20
|
"@types/react": "^18.2.0",
|
|
31
21
|
"@types/react-dom": "^18.2.0",
|
|
32
|
-
"app-studio-types": "workspace:*",
|
|
33
22
|
"autoprefixer": "^10.4.14",
|
|
34
23
|
"chokidar-cli": "^3.0.0",
|
|
35
24
|
"concurrently": "^8.2.2",
|
|
36
25
|
"eslint": "^7.32.0",
|
|
37
|
-
"eslint-config-custom": "workspace:*",
|
|
38
26
|
"postcss": "^8.4.24",
|
|
39
27
|
"tailwindcss": "^3.3.2",
|
|
40
28
|
"tsc-alias": "^1.8.10",
|
|
41
|
-
"
|
|
42
|
-
"
|
|
29
|
+
"typescript": "^4.5.2",
|
|
30
|
+
"eslint-config-custom": "0.0.0",
|
|
31
|
+
"tsconfig": "0.0.0",
|
|
32
|
+
"app-studio-types": "0.0.0"
|
|
43
33
|
},
|
|
44
34
|
"dependencies": {
|
|
45
35
|
"@radix-ui/react-accordion": "^1.1.2",
|
|
@@ -71,5 +61,15 @@
|
|
|
71
61
|
"tailwind-merge": "^1.13.2",
|
|
72
62
|
"tailwindcss-animate": "^1.0.6",
|
|
73
63
|
"vaul": "^0.9.1"
|
|
64
|
+
},
|
|
65
|
+
"scripts": {
|
|
66
|
+
"lint": "eslint \"**/*.ts*\"",
|
|
67
|
+
"ui:add": "pnpm dlx shadcn-ui@latest add",
|
|
68
|
+
"build:styles": "postcss styles/globals.css -o dist/styles.css",
|
|
69
|
+
"build:ts": "tsc -p tsconfig.json && tsc-alias",
|
|
70
|
+
"build": "pnpm run build:ts && pnpm run build:styles",
|
|
71
|
+
"dev:ts": "tsc -w -p tsconfig.json",
|
|
72
|
+
"dev:styles": "npx tailwindcss -i styles/globals.css -o dist/styles.css --watch",
|
|
73
|
+
"dev": "concurrently \"pnpm run dev:ts\" \"pnpm run dev:styles\""
|
|
74
74
|
}
|
|
75
|
-
}
|
|
75
|
+
}
|