@tapcart/mobile-components 0.7.21 → 0.7.23

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 (49) hide show
  1. package/dist/components/ui/drawer.d.ts.map +1 -1
  2. package/dist/components/ui/drawer.js +7 -1
  3. package/dist/components/ui/scroll-area.d.ts +1 -0
  4. package/dist/components/ui/scroll-area.d.ts.map +1 -1
  5. package/dist/components/ui/scroll-area.js +2 -2
  6. package/dist/styles.css +3 -0
  7. package/package.json +1 -1
  8. package/dist/components/contexts/translationContext.d.ts +0 -9
  9. package/dist/components/contexts/translationContext.d.ts.map +0 -1
  10. package/dist/components/contexts/translationContext.js +0 -5
  11. package/dist/components/hooks/use-destination.d.ts +0 -23
  12. package/dist/components/hooks/use-destination.d.ts.map +0 -1
  13. package/dist/components/hooks/use-destination.js +0 -13
  14. package/dist/components/hooks/use-tap.d.ts +0 -8
  15. package/dist/components/hooks/use-tap.d.ts.map +0 -1
  16. package/dist/components/hooks/use-tap.js +0 -100
  17. package/dist/components/ui/use-tap.d.ts +0 -8
  18. package/dist/components/ui/use-tap.d.ts.map +0 -1
  19. package/dist/components/ui/use-tap.js +0 -100
  20. package/dist/components/ui/video copy.d.ts +0 -18
  21. package/dist/components/ui/video copy.d.ts.map +0 -1
  22. package/dist/components/ui/video copy.js +0 -70
  23. package/dist/components/ui/video.v2.d.ts +0 -18
  24. package/dist/components/ui/video.v2.d.ts.map +0 -1
  25. package/dist/components/ui/video.v2.js +0 -70
  26. package/dist/index copy.d.ts +0 -59
  27. package/dist/index copy.d.ts.map +0 -1
  28. package/dist/index copy.js +0 -59
  29. package/dist/lib/utils/destination.d.ts +0 -17
  30. package/dist/lib/utils/destination.d.ts.map +0 -1
  31. package/dist/lib/utils/destination.js +0 -15
  32. package/dist/lib/utils/id.d.ts +0 -5
  33. package/dist/lib/utils/id.d.ts.map +0 -1
  34. package/dist/lib/utils/id.js +0 -29
  35. package/dist/lib/utils/index.d.ts +0 -18
  36. package/dist/lib/utils/index.d.ts.map +0 -1
  37. package/dist/lib/utils/index.js +0 -55
  38. package/dist/lib/utils/misc.d.ts +0 -1
  39. package/dist/lib/utils/misc.d.ts.map +0 -1
  40. package/dist/lib/utils/misc.js +0 -1
  41. package/dist/lib/utils/style.d.ts +0 -154
  42. package/dist/lib/utils/style.d.ts.map +0 -1
  43. package/dist/lib/utils/style.js +0 -148
  44. package/dist/lib/utils.deprecated.d.ts +0 -181
  45. package/dist/lib/utils.deprecated.d.ts.map +0 -1
  46. package/dist/lib/utils.deprecated.js +0 -222
  47. package/dist/v2.d.ts +0 -59
  48. package/dist/v2.d.ts.map +0 -1
  49. package/dist/v2.js +0 -59
@@ -1,181 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.deprecated.d.ts","sourceRoot":"","sources":["../../lib/utils.deprecated.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAQ,MAAM,MAAM,CAAA;AAKvC,MAAM,MAAM,KAAK,GAAG;IAAE,IAAI,EAAE,QAAQ,GAAG,WAAW,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAEnE,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;AAE9C,eAAO,MAAM,QAAQ,gBAAiB,KAAK,GAAG,SAAS,uBAUtD,CAAA;AAED,KAAK,UAAU,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAA;AAC7D,KAAK,WAAW,GAAG,UAAU,EAAE,CAAA;AAE/B,eAAO,MAAM,mBAAmB;;;;;;;;;;;;CAU/B,CAAA;AAED,KAAK,iBAAiB,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAEpD,MAAM,MAAM,OAAO,GAAG;IACpB,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,UAAU,mBAAmB;IAC3B,SAAS,EAAE,iBAAiB,CAAA;IAC5B,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,eAAO,MAAM,yBAAy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AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,YAOlD;AAED,eAAO,MAAM,wBAAwB,gBACtB;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,2BAQpE,CAAA"}
@@ -1,222 +0,0 @@
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/v2.d.ts DELETED
@@ -1,59 +0,0 @@
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
package/dist/v2.d.ts.map DELETED
@@ -1 +0,0 @@
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,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iCAAiC,CAAA;AAC/C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,kDAAkD,CAAA;AAChE,cAAc,gCAAgC,CAAA;AAC9C,cAAc,oCAAoC,CAAA;AAClD,cAAc,kDAAkD,CAAA"}
package/dist/v2.js DELETED
@@ -1,59 +0,0 @@
1
- // component exports
2
- export { cn, cva, getColor, getBackgroundAndPaddingStyle, getBorderSidesStyle, getTextStyle, getVerticalAlignmentStyle, getBackgroundAndSpacingStyle, getIdFromGid, productGidFromId, variantGidFromId, getPaddingStyle, getVerticalAlignment, mapFlexToAlignment, formatRelativeTime, stringRatioToInt, getOverlayStyle, getDestinationHandler, createCollectionImageMap, } from "./lib/utils";
3
- export * from "./components/hooks/use-collection";
4
- export * from "./components/hooks/use-infinite-scroll";
5
- export * from "./components/hooks/use-recommendations";
6
- export * from "./components/hooks/use-products";
7
- export * from "./components/hooks/use-scroll-direction";
8
- export * from "./components/hooks/use-sort-filter";
9
- export * from "./components/hooks/use-product-options";
10
- export * from "./components/hooks/use-shop";
11
- export * from "./components/hooks/use-tap";
12
- export * from "./components/ui/accordion";
13
- export * from "./components/ui/aspect-ratio";
14
- export * from "./components/ui/badge";
15
- export * from "./components/ui/button";
16
- export * from "./components/ui/carousel";
17
- export * from "./components/ui/checkbox";
18
- export * from "./components/ui/chip";
19
- export * from "./components/ui/color-swatch";
20
- export * from "./components/ui/container";
21
- export * from "./components/ui/drawer";
22
- export * from "./components/ui/dropdown";
23
- export * from "./components/ui/empty-message";
24
- export * from "./components/ui/favorite";
25
- export * from "./components/ui/grid";
26
- export * from "./components/ui/icon";
27
- export * from "./components/ui/image";
28
- export * from "./components/ui/Input/input";
29
- export * from "./components/ui/label";
30
- export * from "./components/ui/line-item-text-icons";
31
- export * from "./components/ui/money";
32
- export * from "./components/ui/price";
33
- export * from "./components/ui/product-card";
34
- export * from "./components/ui/quantity-picker";
35
- export * from "./components/ui/radio-group";
36
- export * from "./components/ui/scroll-area";
37
- export * from "./components/ui/selectors";
38
- export * from "./components/ui/separator";
39
- export * from "./components/ui/skeleton";
40
- export * from "./components/ui/slider";
41
- export * from "./components/ui/subscription";
42
- export * from "./components/ui/switch";
43
- export * from "./components/ui/tabs";
44
- export * from "./components/ui/text";
45
- export * from "./components/ui/textarea";
46
- export * from "./components/ui/toast";
47
- export * from "./components/ui/toaster";
48
- export * from "./components/ui/toggle-group";
49
- export * from "./components/ui/toggle";
50
- export * from "./components/ui/use-toast";
51
- export * from "./components/ui/video";
52
- export * from "./components/ui/video.v2";
53
- export * from "./components/ui/wishlist";
54
- export * from "./components/ui/wishlist-select";
55
- export * from "./components/hooks/use-shop";
56
- export * from "./components/libs/sort-filter/search-integration";
57
- export * from "./components/hooks/use-reviews";
58
- export * from "./components/ui/subcollection-tabs";
59
- export * from "./components/libs/sort-filter/search-integration";