@tapcart/mobile-components 0.7.25 → 0.7.27

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.
Files changed (57) hide show
  1. package/dist/components/contexts/translationContext.d.ts +9 -0
  2. package/dist/components/contexts/translationContext.d.ts.map +1 -0
  3. package/dist/components/contexts/translationContext.js +5 -0
  4. package/dist/components/hooks/use-destination.d.ts +23 -0
  5. package/dist/components/hooks/use-destination.d.ts.map +1 -0
  6. package/dist/components/hooks/use-destination.js +13 -0
  7. package/dist/components/hooks/use-infinite-scroll.d.ts +3 -0
  8. package/dist/components/hooks/use-infinite-scroll.d.ts.map +1 -1
  9. package/dist/components/hooks/use-products.d.ts +2 -0
  10. package/dist/components/hooks/use-products.d.ts.map +1 -1
  11. package/dist/components/hooks/use-products.js +40 -5
  12. package/dist/components/hooks/use-sort-filter.d.ts +3 -0
  13. package/dist/components/hooks/use-sort-filter.d.ts.map +1 -1
  14. package/dist/components/hooks/use-tap.d.ts +8 -0
  15. package/dist/components/hooks/use-tap.d.ts.map +1 -0
  16. package/dist/components/hooks/use-tap.js +100 -0
  17. package/dist/components/libs/sort-filter/custom-search.d.ts +7 -0
  18. package/dist/components/libs/sort-filter/custom-search.d.ts.map +1 -0
  19. package/dist/components/libs/sort-filter/custom-search.js +30 -0
  20. package/dist/components/libs/sort-filter/search-integration.d.ts +1 -0
  21. package/dist/components/libs/sort-filter/search-integration.d.ts.map +1 -1
  22. package/dist/components/libs/sort-filter/search-integration.js +3 -0
  23. package/dist/components/ui/use-tap.d.ts +8 -0
  24. package/dist/components/ui/use-tap.d.ts.map +1 -0
  25. package/dist/components/ui/use-tap.js +100 -0
  26. package/dist/components/ui/video copy.d.ts +18 -0
  27. package/dist/components/ui/video copy.d.ts.map +1 -0
  28. package/dist/components/ui/video copy.js +70 -0
  29. package/dist/components/ui/video.v2.d.ts +18 -0
  30. package/dist/components/ui/video.v2.d.ts.map +1 -0
  31. package/dist/components/ui/video.v2.js +70 -0
  32. package/dist/index copy.d.ts +59 -0
  33. package/dist/index copy.d.ts.map +1 -0
  34. package/dist/index copy.js +59 -0
  35. package/dist/lib/utils/destination.d.ts +17 -0
  36. package/dist/lib/utils/destination.d.ts.map +1 -0
  37. package/dist/lib/utils/destination.js +15 -0
  38. package/dist/lib/utils/id.d.ts +5 -0
  39. package/dist/lib/utils/id.d.ts.map +1 -0
  40. package/dist/lib/utils/id.js +29 -0
  41. package/dist/lib/utils/index.d.ts +18 -0
  42. package/dist/lib/utils/index.d.ts.map +1 -0
  43. package/dist/lib/utils/index.js +55 -0
  44. package/dist/lib/utils/misc.d.ts +1 -0
  45. package/dist/lib/utils/misc.d.ts.map +1 -0
  46. package/dist/lib/utils/misc.js +1 -0
  47. package/dist/lib/utils/style.d.ts +154 -0
  48. package/dist/lib/utils/style.d.ts.map +1 -0
  49. package/dist/lib/utils/style.js +148 -0
  50. package/dist/lib/utils.deprecated.d.ts +181 -0
  51. package/dist/lib/utils.deprecated.d.ts.map +1 -0
  52. package/dist/lib/utils.deprecated.js +222 -0
  53. package/dist/styles.css +3 -8
  54. package/dist/v2.d.ts +59 -0
  55. package/dist/v2.d.ts.map +1 -0
  56. package/dist/v2.js +59 -0
  57. package/package.json +1 -1
@@ -0,0 +1,148 @@
1
+ import { clsx } from "clsx";
2
+ import { twMerge } from "tailwind-merge";
3
+ // #endregion =-=-=-= Types =-=-=-=
4
+ // #region =-=-=-= Class Utils =-=-=-=
5
+ export { cva } from "class-variance-authority";
6
+ export function cn(...inputs) {
7
+ return twMerge(clsx(inputs));
8
+ }
9
+ const alignmentClasses = {
10
+ left: "justify-start",
11
+ middle: "justify-center",
12
+ right: "justify-end",
13
+ };
14
+ export const mapFlexToAlignment = (flexClass) => {
15
+ if (flexClass in alignmentClasses)
16
+ return alignmentClasses[flexClass];
17
+ return "";
18
+ };
19
+ // #endregion =-=-=-= Class Utils =-=-=-=
20
+ // #region =-=-=-= Icon Utils =-=-=-=
21
+ export const iconColorLevels = [
22
+ "coreColors-primaryIcon",
23
+ "coreColors-secondaryIcon",
24
+ "coreColors-headerIcon",
25
+ "coreColors-brandColorPrimary",
26
+ "stateColors-subscriptions",
27
+ "stateColors-favorites",
28
+ "stateColors-reviews",
29
+ "stateColors-success",
30
+ "stateColors-error",
31
+ "stateColors-warning",
32
+ "stateColors-disabled",
33
+ "buttonColors-primaryText",
34
+ "buttonColors-secondaryText",
35
+ ];
36
+ export const iconColorVariantClasses = {};
37
+ for (let iconColorLevel of iconColorLevels) {
38
+ iconColorVariantClasses[iconColorLevel] = `text-${iconColorLevel}`;
39
+ }
40
+ // #endregion =-=-=-= Icon Utils =-=-=-=
41
+ // #region =-=-=-= Color Utils =-=-=-=
42
+ export const getColor = (colorOption) => {
43
+ if ((colorOption === null || colorOption === void 0 ? void 0 : colorOption.value) === null) {
44
+ return undefined;
45
+ }
46
+ return colorOption
47
+ ? (colorOption === null || colorOption === void 0 ? void 0 : colorOption.type) === "brand-kit"
48
+ ? `var(--${colorOption.value})`
49
+ : colorOption.value
50
+ : undefined;
51
+ };
52
+ // #endregion =-=-=-= Color Utils =-=-=-=
53
+ // #region =-=-=-= Inline Style Utils =-=-=-=
54
+ export const getBorderSidesStyle = (borderSides) => {
55
+ const style = (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("all"))
56
+ ? { borderWidth: "1px" }
57
+ : {
58
+ borderTopWidth: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("top")) ? "1px" : 0,
59
+ borderBottomWidth: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("bottom")) ? "1px" : 0,
60
+ borderLeftWidth: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("left")) ? "1px" : 0,
61
+ borderRightWidth: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("right")) ? "1px" : 0,
62
+ };
63
+ return style;
64
+ };
65
+ export const getVerticalAlignmentStyle = (alignmentAndSpacing) => {
66
+ const { alignment, spacing } = alignmentAndSpacing;
67
+ switch (alignment) {
68
+ case "bottom":
69
+ return { bottom: `${spacing.bottom}px`, top: "auto" };
70
+ case "middle":
71
+ return { top: "50%", transform: "translateY(-50%)" };
72
+ case "top":
73
+ return { top: `${spacing.top}px`, bottom: "auto" };
74
+ default:
75
+ return {};
76
+ }
77
+ };
78
+ export const getPaddingStyle = (padding) => {
79
+ if (!padding)
80
+ return {};
81
+ return {
82
+ paddingTop: (padding === null || padding === void 0 ? void 0 : padding.top) !== undefined ? `${padding.top}px` : undefined,
83
+ paddingBottom: (padding === null || padding === void 0 ? void 0 : padding.bottom) !== undefined ? `${padding.bottom}px` : undefined,
84
+ paddingLeft: (padding === null || padding === void 0 ? void 0 : padding.left) !== undefined ? `${padding.left}px` : undefined,
85
+ paddingRight: (padding === null || padding === void 0 ? void 0 : padding.right) !== undefined ? `${padding.right}px` : undefined,
86
+ };
87
+ };
88
+ export const getBackgroundAndPaddingStyle = (backgroundAndPadding) => {
89
+ const { backgroundColor, borderSides, borderColor, cornerRadius, padding, borderRadius, } = backgroundAndPadding;
90
+ const radius = cornerRadius || borderRadius;
91
+ const defaultBorderWidth = borderSides ? "0px" : undefined;
92
+ return Object.assign(Object.assign({}, getPaddingStyle(padding)), { backgroundColor: getColor(backgroundColor), borderColor: getColor(borderColor), borderTopWidth: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("top")) || (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("all"))
93
+ ? "1px"
94
+ : defaultBorderWidth, borderBottomWidth: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("bottom")) || (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("all"))
95
+ ? "1px"
96
+ : defaultBorderWidth, borderLeftWidth: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("left")) || (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("all"))
97
+ ? "1px"
98
+ : defaultBorderWidth, borderRightWidth: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("right")) || (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("all"))
99
+ ? "1px"
100
+ : defaultBorderWidth, borderStyle: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.length) ? "solid" : undefined, borderRadius: radius !== undefined ? `${radius}px` : undefined });
101
+ };
102
+ export const getBackgroundAndSpacingStyle = (backgroundAndSpacing) => {
103
+ const { spacing, borderColor, backgroundColor, backgroundCorners } = backgroundAndSpacing;
104
+ return {
105
+ padding: `${spacing.top}px ${spacing.right}px ${spacing.bottom}px ${spacing.left}px`,
106
+ borderColor: borderColor ? borderColor.value : "transparent",
107
+ backgroundColor: getColor(backgroundColor) || "transparent",
108
+ borderRadius: `${backgroundCorners !== null && backgroundCorners !== void 0 ? backgroundCorners : 0}px`,
109
+ };
110
+ };
111
+ export const getTextStyle = (textStyle) => {
112
+ const { font, size, color, uppercase, textAlignment, wrapText } = textStyle;
113
+ return {
114
+ fontFamily: font.family === "initial" ? undefined : font.family,
115
+ fontWeight: font.weight === "initial" ? undefined : font.weight,
116
+ fontSize: size,
117
+ color: getColor(color),
118
+ textTransform: uppercase ? "uppercase" : "none",
119
+ textAlign: textAlignment,
120
+ textWrap: wrapText ? "wrap" : "nowrap",
121
+ };
122
+ };
123
+ export const getVerticalAlignment = (alignment, padding = { top: 0, bottom: 0 }) => {
124
+ if (alignment === "bottom") {
125
+ return { bottom: `${padding.bottom}px`, top: "auto" };
126
+ }
127
+ else if (alignment === "middle") {
128
+ return { top: "50%", transform: `translateY(-50%)` };
129
+ }
130
+ else if (alignment === "top") {
131
+ return { top: `${padding.top}px`, bottom: "auto" };
132
+ }
133
+ else {
134
+ return {};
135
+ }
136
+ };
137
+ export const getOverlayStyle = (opacity) => {
138
+ const opacityDecimal = opacity / 100;
139
+ return {
140
+ position: "absolute",
141
+ top: 0,
142
+ left: 0,
143
+ right: 0,
144
+ bottom: 0,
145
+ backgroundColor: `rgba(0, 0, 0, ${opacityDecimal})`,
146
+ };
147
+ };
148
+ // #endregion =-=-=-= Inline Style Utils =-=-=-=
@@ -0,0 +1,181 @@
1
+ import { ClassValue } from "clsx";
2
+ export type Color = {
3
+ type: "custom" | "brand-kit";
4
+ value: string;
5
+ };
6
+ export declare function cn(...inputs: ClassValue[]): string;
7
+ export declare const iconColorLevels: string[];
8
+ export declare const iconColorVariantClasses: Record<string, string>;
9
+ export { cva } from "class-variance-authority";
10
+ export declare const getColor: (colorOption: Color | undefined) => string | undefined;
11
+ type BorderSide = "all" | "top" | "bottom" | "left" | "right";
12
+ type BorderSides = BorderSide[];
13
+ export declare const getBorderSidesStyle: (borderSides: BorderSides) => {
14
+ borderWidth: string;
15
+ borderTopWidth?: undefined;
16
+ borderBottomWidth?: undefined;
17
+ borderLeftWidth?: undefined;
18
+ borderRightWidth?: undefined;
19
+ } | {
20
+ borderTopWidth: string | number;
21
+ borderBottomWidth: string | number;
22
+ borderLeftWidth: string | number;
23
+ borderRightWidth: string | number;
24
+ borderWidth?: undefined;
25
+ };
26
+ type VerticalAlignment = "top" | "middle" | "bottom";
27
+ export type Spacing = {
28
+ top: number;
29
+ bottom: number;
30
+ left: number;
31
+ right: number;
32
+ };
33
+ interface AlignmentAndSpacing {
34
+ alignment: VerticalAlignment;
35
+ spacing: Spacing;
36
+ }
37
+ export declare const getVerticalAlignmentStyle: (alignmentAndSpacing: AlignmentAndSpacing) => {
38
+ bottom: string;
39
+ top: string;
40
+ transform?: undefined;
41
+ } | {
42
+ top: string;
43
+ transform: string;
44
+ bottom?: undefined;
45
+ } | {
46
+ bottom?: undefined;
47
+ top?: undefined;
48
+ transform?: undefined;
49
+ };
50
+ export declare const getPaddingStyle: (padding: Partial<Spacing> | undefined) => {
51
+ paddingTop?: undefined;
52
+ paddingBottom?: undefined;
53
+ paddingLeft?: undefined;
54
+ paddingRight?: undefined;
55
+ } | {
56
+ paddingTop: string | undefined;
57
+ paddingBottom: string | undefined;
58
+ paddingLeft: string | undefined;
59
+ paddingRight: string | undefined;
60
+ };
61
+ export type BackgroundAndPadding = {
62
+ backgroundColor?: Color;
63
+ borderSides?: BorderSides;
64
+ borderColor?: Color;
65
+ cornerRadius?: number;
66
+ padding?: Partial<Spacing>;
67
+ borderRadius?: number;
68
+ };
69
+ export declare const getBackgroundAndPaddingStyle: (backgroundAndPadding: BackgroundAndPadding) => {
70
+ backgroundColor: string | undefined;
71
+ borderColor: string | undefined;
72
+ borderTopWidth: string | undefined;
73
+ borderBottomWidth: string | undefined;
74
+ borderLeftWidth: string | undefined;
75
+ borderRightWidth: string | undefined;
76
+ borderStyle: string | undefined;
77
+ borderRadius: string | undefined;
78
+ paddingTop?: undefined;
79
+ paddingBottom?: undefined;
80
+ paddingLeft?: undefined;
81
+ paddingRight?: undefined;
82
+ } | {
83
+ backgroundColor: string | undefined;
84
+ borderColor: string | undefined;
85
+ borderTopWidth: string | undefined;
86
+ borderBottomWidth: string | undefined;
87
+ borderLeftWidth: string | undefined;
88
+ borderRightWidth: string | undefined;
89
+ borderStyle: string | undefined;
90
+ borderRadius: string | undefined;
91
+ paddingTop: string | undefined;
92
+ paddingBottom: string | undefined;
93
+ paddingLeft: string | undefined;
94
+ paddingRight: string | undefined;
95
+ };
96
+ type BackgroundAndSpacing = AlignmentAndSpacing & {
97
+ backgroundColor?: Color;
98
+ borderColor?: Color;
99
+ backgroundCorners?: number;
100
+ };
101
+ export declare const getBackgroundAndSpacingStyle: (backgroundAndSpacing: BackgroundAndSpacing) => {
102
+ padding: string;
103
+ borderColor: string;
104
+ backgroundColor: string;
105
+ borderRadius: string;
106
+ };
107
+ export type TextStyle = {
108
+ font: {
109
+ family: string;
110
+ weight: number | string;
111
+ };
112
+ size: number | string;
113
+ color: Color;
114
+ uppercase: boolean;
115
+ textAlignment: "left" | "center" | "right" | "justify";
116
+ wrapText: boolean;
117
+ };
118
+ type Headline = TextStyle;
119
+ type Subtext = TextStyle;
120
+ export declare const getTextStyle: (textStyle: Headline | Subtext) => {
121
+ fontFamily: string | undefined;
122
+ fontWeight: string | number | undefined;
123
+ fontSize: string | number;
124
+ color: string | undefined;
125
+ textTransform: string;
126
+ textAlign: "center" | "left" | "right" | "justify";
127
+ textWrap: string;
128
+ };
129
+ export declare const getVerticalAlignment: (alignment: string, padding?: {
130
+ top: number;
131
+ bottom: number;
132
+ }) => {
133
+ bottom: string;
134
+ top: string;
135
+ transform?: undefined;
136
+ } | {
137
+ top: string;
138
+ transform: string;
139
+ bottom?: undefined;
140
+ } | {
141
+ bottom?: undefined;
142
+ top?: undefined;
143
+ transform?: undefined;
144
+ };
145
+ export declare const mapFlexToAlignment: (flexClass: string) => string;
146
+ export declare function getIdFromGid(gid: string | undefined): string;
147
+ export declare function productGidFromId(id: string | null | undefined): string | null;
148
+ export declare function variantGidFromId(id: string | null | undefined): string | null;
149
+ export declare function throttleFunction(fn: Function, wait: number): ((...args: any[]) => void)[];
150
+ export declare function formatRelativeTime(inputDate: Date | string): string;
151
+ export declare const stringRatioToInt: (string: string) => number;
152
+ export declare const getOverlayStyle: (opacity: number) => {
153
+ position: string;
154
+ top: number;
155
+ left: number;
156
+ right: number;
157
+ bottom: number;
158
+ backgroundColor: string;
159
+ };
160
+ type DestinationActions = {
161
+ openScreen: (arg: {
162
+ destination: {
163
+ type: "internal" | "web";
164
+ url: string;
165
+ };
166
+ }) => void;
167
+ openProduct: (arg: {
168
+ productId: string;
169
+ }) => void;
170
+ openCollection: (arg: {
171
+ collectionId: string;
172
+ }) => void;
173
+ };
174
+ export declare const getDestinationHandler: (type: "app-screen" | "url" | "product" | "collection" | "none") => ((location: string, actions: DestinationActions) => void) | ((location: string, actions: DestinationActions) => void) | ((location: string, actions: DestinationActions) => void) | ((location: string, actions: DestinationActions) => void) | (() => void);
175
+ export declare function getProductGidsFromIds(ids: string[]): string[];
176
+ export declare const createCollectionImageMap: (collections: {
177
+ id: string;
178
+ customImage: boolean;
179
+ image?: string;
180
+ }[]) => Record<string, string>;
181
+ //# sourceMappingURL=utils.deprecated.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.deprecated.d.ts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QpE,CAAA"}
@@ -0,0 +1,222 @@
1
+ import { clsx } from "clsx";
2
+ import { twMerge } from "tailwind-merge";
3
+ import dayjs from "dayjs";
4
+ import relativeTime from "dayjs/plugin/relativeTime";
5
+ export function cn(...inputs) {
6
+ return twMerge(clsx(inputs));
7
+ }
8
+ export const iconColorLevels = [
9
+ "coreColors-primaryIcon",
10
+ "coreColors-secondaryIcon",
11
+ "coreColors-headerIcon",
12
+ "coreColors-brandColorPrimary",
13
+ "stateColors-subscriptions",
14
+ "stateColors-favorites",
15
+ "stateColors-reviews",
16
+ "stateColors-success",
17
+ "stateColors-error",
18
+ "stateColors-warning",
19
+ "stateColors-disabled",
20
+ "buttonColors-primaryText",
21
+ "buttonColors-secondaryText",
22
+ ];
23
+ export const iconColorVariantClasses = {};
24
+ for (let iconColorLevel of iconColorLevels) {
25
+ iconColorVariantClasses[iconColorLevel] = `text-${iconColorLevel}`;
26
+ }
27
+ export { cva } from "class-variance-authority";
28
+ export const getColor = (colorOption) => {
29
+ if ((colorOption === null || colorOption === void 0 ? void 0 : colorOption.value) === null) {
30
+ return undefined;
31
+ }
32
+ return colorOption
33
+ ? (colorOption === null || colorOption === void 0 ? void 0 : colorOption.type) === "brand-kit"
34
+ ? `var(--${colorOption.value})`
35
+ : colorOption.value
36
+ : undefined;
37
+ };
38
+ export const getBorderSidesStyle = (borderSides) => {
39
+ const style = (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("all"))
40
+ ? { borderWidth: "1px" }
41
+ : {
42
+ borderTopWidth: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("top")) ? "1px" : 0,
43
+ borderBottomWidth: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("bottom")) ? "1px" : 0,
44
+ borderLeftWidth: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("left")) ? "1px" : 0,
45
+ borderRightWidth: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("right")) ? "1px" : 0,
46
+ };
47
+ return style;
48
+ };
49
+ export const getVerticalAlignmentStyle = (alignmentAndSpacing) => {
50
+ const { alignment, spacing } = alignmentAndSpacing;
51
+ switch (alignment) {
52
+ case "bottom":
53
+ return { bottom: `${spacing.bottom}px`, top: "auto" };
54
+ case "middle":
55
+ return { top: "50%", transform: "translateY(-50%)" };
56
+ case "top":
57
+ return { top: `${spacing.top}px`, bottom: "auto" };
58
+ default:
59
+ return {};
60
+ }
61
+ };
62
+ export const getPaddingStyle = (padding) => {
63
+ if (!padding)
64
+ return {};
65
+ return {
66
+ paddingTop: (padding === null || padding === void 0 ? void 0 : padding.top) !== undefined ? `${padding.top}px` : undefined,
67
+ paddingBottom: (padding === null || padding === void 0 ? void 0 : padding.bottom) !== undefined ? `${padding.bottom}px` : undefined,
68
+ paddingLeft: (padding === null || padding === void 0 ? void 0 : padding.left) !== undefined ? `${padding.left}px` : undefined,
69
+ paddingRight: (padding === null || padding === void 0 ? void 0 : padding.right) !== undefined ? `${padding.right}px` : undefined,
70
+ };
71
+ };
72
+ export const getBackgroundAndPaddingStyle = (backgroundAndPadding) => {
73
+ const { backgroundColor, borderSides, borderColor, cornerRadius, padding, borderRadius, } = backgroundAndPadding;
74
+ const radius = cornerRadius || borderRadius;
75
+ const defaultBorderWidth = borderSides ? "0px" : undefined;
76
+ return Object.assign(Object.assign({}, getPaddingStyle(padding)), { backgroundColor: getColor(backgroundColor), borderColor: getColor(borderColor), borderTopWidth: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("top")) || (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("all"))
77
+ ? "1px"
78
+ : defaultBorderWidth, borderBottomWidth: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("bottom")) || (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("all"))
79
+ ? "1px"
80
+ : defaultBorderWidth, borderLeftWidth: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("left")) || (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("all"))
81
+ ? "1px"
82
+ : defaultBorderWidth, borderRightWidth: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("right")) || (borderSides === null || borderSides === void 0 ? void 0 : borderSides.includes("all"))
83
+ ? "1px"
84
+ : defaultBorderWidth, borderStyle: (borderSides === null || borderSides === void 0 ? void 0 : borderSides.length) ? "solid" : undefined, borderRadius: radius !== undefined ? `${radius}px` : undefined });
85
+ };
86
+ export const getBackgroundAndSpacingStyle = (backgroundAndSpacing) => {
87
+ const { spacing, borderColor, backgroundColor, backgroundCorners } = backgroundAndSpacing;
88
+ return {
89
+ padding: `${spacing.top}px ${spacing.right}px ${spacing.bottom}px ${spacing.left}px`,
90
+ borderColor: borderColor ? borderColor.value : "transparent",
91
+ backgroundColor: getColor(backgroundColor) || "transparent",
92
+ borderRadius: `${backgroundCorners !== null && backgroundCorners !== void 0 ? backgroundCorners : 0}px`,
93
+ };
94
+ };
95
+ export const getTextStyle = (textStyle) => {
96
+ const { font, size, color, uppercase, textAlignment, wrapText } = textStyle;
97
+ return {
98
+ fontFamily: font.family === "initial" ? undefined : font.family,
99
+ fontWeight: font.weight === "initial" ? undefined : font.weight,
100
+ fontSize: size,
101
+ color: getColor(color),
102
+ textTransform: uppercase ? "uppercase" : "none",
103
+ textAlign: textAlignment,
104
+ textWrap: wrapText ? "wrap" : "nowrap",
105
+ };
106
+ };
107
+ export const getVerticalAlignment = (alignment, padding = { top: 0, bottom: 0 }) => {
108
+ if (alignment === "bottom") {
109
+ return { bottom: `${padding.bottom}px`, top: "auto" };
110
+ }
111
+ else if (alignment === "middle") {
112
+ return { top: "50%", transform: `translateY(-50%)` };
113
+ }
114
+ else if (alignment === "top") {
115
+ return { top: `${padding.top}px`, bottom: "auto" };
116
+ }
117
+ else {
118
+ return {};
119
+ }
120
+ };
121
+ const alignmentClasses = {
122
+ left: "justify-start",
123
+ middle: "justify-center",
124
+ right: "justify-end",
125
+ };
126
+ export const mapFlexToAlignment = (flexClass) => {
127
+ if (flexClass in alignmentClasses)
128
+ return alignmentClasses[flexClass];
129
+ return "";
130
+ };
131
+ export function getIdFromGid(gid) {
132
+ if (!gid)
133
+ return "";
134
+ const arr = gid.split("/");
135
+ return arr[arr.length - 1] || "";
136
+ }
137
+ export function productGidFromId(id) {
138
+ if (!id)
139
+ return null;
140
+ if (id.startsWith("gid://shopify/Product/"))
141
+ return id;
142
+ return `gid://shopify/Product/${id}`;
143
+ }
144
+ export function variantGidFromId(id) {
145
+ if (!id)
146
+ return null;
147
+ if (id.startsWith("gid://shopify/ProductVariant/"))
148
+ return id;
149
+ return `gid://shopify/ProductVariant/${id}`;
150
+ }
151
+ // Use to prevent multiple clicks in quick succession
152
+ export function throttleFunction(fn, wait) {
153
+ let throttle = false;
154
+ return [
155
+ function () {
156
+ return throttle;
157
+ },
158
+ function (...args) {
159
+ if (!throttle) {
160
+ fn(...args);
161
+ throttle = true;
162
+ setInterval(() => {
163
+ throttle = false;
164
+ }, wait);
165
+ }
166
+ },
167
+ ];
168
+ }
169
+ export function formatRelativeTime(inputDate) {
170
+ dayjs.extend(relativeTime);
171
+ return dayjs(inputDate).fromNow();
172
+ }
173
+ export const stringRatioToInt = (string) => {
174
+ const [numerator, denominator] = string
175
+ .replace(":", "/")
176
+ .split("/")
177
+ .map((part) => part.trim())
178
+ .map(Number);
179
+ return numerator / denominator;
180
+ };
181
+ export const getOverlayStyle = (opacity) => {
182
+ const opacityDecimal = opacity / 100;
183
+ return {
184
+ position: "absolute",
185
+ top: 0,
186
+ left: 0,
187
+ right: 0,
188
+ bottom: 0,
189
+ backgroundColor: `rgba(0, 0, 0, ${opacityDecimal})`,
190
+ };
191
+ };
192
+ const DESTINATION_HANDLERS = {
193
+ "app-screen": (location, actions) => actions.openScreen({ destination: { type: "internal", url: location } }),
194
+ url: (location, actions) => actions.openScreen({
195
+ destination: {
196
+ type: "web",
197
+ url: location.includes("https://") ? location : `https://${location}`,
198
+ },
199
+ }),
200
+ product: (location, actions) => actions.openProduct({ productId: location }),
201
+ collection: (location, actions) => actions.openCollection({ collectionId: location }),
202
+ none: () => { },
203
+ };
204
+ export const getDestinationHandler = (type) => {
205
+ return DESTINATION_HANDLERS[type];
206
+ };
207
+ export function getProductGidsFromIds(ids) {
208
+ return ids.map((id) => {
209
+ if (id.startsWith("gid://shopify/Product/")) {
210
+ return id;
211
+ }
212
+ return `gid://shopify/Product/${id}`;
213
+ });
214
+ }
215
+ export const createCollectionImageMap = (collections) => {
216
+ return collections.reduce((imageMap, collection) => {
217
+ if (collection.customImage && collection.image) {
218
+ imageMap[collection.id] = collection.image;
219
+ }
220
+ return imageMap;
221
+ }, {});
222
+ };
package/dist/styles.css CHANGED
@@ -812,10 +812,6 @@ video {
812
812
  margin-top: 0.75rem;
813
813
  margin-bottom: 0.75rem;
814
814
  }
815
- .my-4 {
816
- margin-top: 1rem;
817
- margin-bottom: 1rem;
818
- }
819
815
  .my-auto {
820
816
  margin-top: auto;
821
817
  margin-bottom: auto;
@@ -1006,6 +1002,9 @@ video {
1006
1002
  .min-h-\[24px\] {
1007
1003
  min-height: 24px;
1008
1004
  }
1005
+ .min-h-\[315px\] {
1006
+ min-height: 315px;
1007
+ }
1009
1008
  .w-0 {
1010
1009
  width: 0px;
1011
1010
  }
@@ -1466,10 +1465,6 @@ video {
1466
1465
  .\!border-stateColors-error {
1467
1466
  border-color: var(--stateColors-error) !important;
1468
1467
  }
1469
- .border-\[\#E3E3E3\] {
1470
- --tw-border-opacity: 1;
1471
- border-color: rgb(227 227 227 / var(--tw-border-opacity));
1472
- }
1473
1468
  .border-black {
1474
1469
  --tw-border-opacity: 1;
1475
1470
  border-color: rgb(0 0 0 / var(--tw-border-opacity));
package/dist/v2.d.ts ADDED
@@ -0,0 +1,59 @@
1
+ export { cn, cva, getColor, getBackgroundAndPaddingStyle, getBorderSidesStyle, getTextStyle, getVerticalAlignmentStyle, getBackgroundAndSpacingStyle, getIdFromGid, productGidFromId, variantGidFromId, getPaddingStyle, getVerticalAlignment, mapFlexToAlignment, formatRelativeTime, stringRatioToInt, getOverlayStyle, getDestinationHandler, createCollectionImageMap, } from "./lib/utils";
2
+ export * from "./components/hooks/use-collection";
3
+ export * from "./components/hooks/use-infinite-scroll";
4
+ export * from "./components/hooks/use-recommendations";
5
+ export * from "./components/hooks/use-products";
6
+ export * from "./components/hooks/use-scroll-direction";
7
+ export * from "./components/hooks/use-sort-filter";
8
+ export * from "./components/hooks/use-product-options";
9
+ export * from "./components/hooks/use-shop";
10
+ export * from "./components/hooks/use-tap";
11
+ export * from "./components/ui/accordion";
12
+ export * from "./components/ui/aspect-ratio";
13
+ export * from "./components/ui/badge";
14
+ export * from "./components/ui/button";
15
+ export * from "./components/ui/carousel";
16
+ export * from "./components/ui/checkbox";
17
+ export * from "./components/ui/chip";
18
+ export * from "./components/ui/color-swatch";
19
+ export * from "./components/ui/container";
20
+ export * from "./components/ui/drawer";
21
+ export * from "./components/ui/dropdown";
22
+ export * from "./components/ui/empty-message";
23
+ export * from "./components/ui/favorite";
24
+ export * from "./components/ui/grid";
25
+ export * from "./components/ui/icon";
26
+ export * from "./components/ui/image";
27
+ export * from "./components/ui/Input/input";
28
+ export * from "./components/ui/label";
29
+ export * from "./components/ui/line-item-text-icons";
30
+ export * from "./components/ui/money";
31
+ export * from "./components/ui/price";
32
+ export * from "./components/ui/product-card";
33
+ export * from "./components/ui/quantity-picker";
34
+ export * from "./components/ui/radio-group";
35
+ export * from "./components/ui/scroll-area";
36
+ export * from "./components/ui/selectors";
37
+ export * from "./components/ui/separator";
38
+ export * from "./components/ui/skeleton";
39
+ export * from "./components/ui/slider";
40
+ export * from "./components/ui/subscription";
41
+ export * from "./components/ui/switch";
42
+ export * from "./components/ui/tabs";
43
+ export * from "./components/ui/text";
44
+ export * from "./components/ui/textarea";
45
+ export * from "./components/ui/toast";
46
+ export * from "./components/ui/toaster";
47
+ export * from "./components/ui/toggle-group";
48
+ export * from "./components/ui/toggle";
49
+ export * from "./components/ui/use-toast";
50
+ export * from "./components/ui/video";
51
+ export * from "./components/ui/video.v2";
52
+ export * from "./components/ui/wishlist";
53
+ export * from "./components/ui/wishlist-select";
54
+ export * from "./components/hooks/use-shop";
55
+ export * from "./components/libs/sort-filter/search-integration";
56
+ export * from "./components/hooks/use-reviews";
57
+ export * from "./components/ui/subcollection-tabs";
58
+ export * from "./components/libs/sort-filter/search-integration";
59
+ //# sourceMappingURL=v2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v2.d.ts","sourceRoot":"","sources":["../v2.ts"],"names":[],"mappings":"AACA,OAAO,EACL,EAAE,EACF,GAAG,EACH,QAAQ,EACR,4BAA4B,EAC5B,mBAAmB,EACnB,YAAY,EACZ,yBAAyB,EACzB,4BAA4B,EAC5B,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,wBAAwB,GACzB,MAAM,aAAa,CAAA;AACpB,cAAc,mCAAmC,CAAA;AACjD,cAAc,wCAAwC,CAAA;AACtD,cAAc,wCAAwC,CAAA;AACtD,cAAc,iCAAiC,CAAA;AAC/C,cAAc,yCAAyC,CAAA;AACvD,cAAc,oCAAoC,CAAA;AAClD,cAAc,wCAAwC,CAAA;AACtD,cAAc,6BAA6B,CAAA;AAC3C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,2BAA2B,CAAA;AACzC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA;AACtC,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA;AACxC,cAAc,sBAAsB,CAAA;AACpC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,2BAA2B,CAAA;AACzC,cAAc,wBAAwB,CAAA;AACtC,cAAc,0BAA0B,CAAA;AACxC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,0BAA0B,CAAA;AACxC,cAAc,sBAAsB,CAAA;AACpC,cAAc,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