@tapcart/mobile-components 0.7.12 → 0.7.14

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.
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ type TranslationMap = Record<string, string>;
3
+ export declare const TranslationProvider: ({ translations, children, }: {
4
+ translations: TranslationMap;
5
+ children: React.ReactNode;
6
+ }) => import("react/jsx-runtime").JSX.Element;
7
+ export declare const useTranslation: () => TranslationMap;
8
+ export declare const getTextTranslation: ({ text, translations, }: {
9
+ text: string;
10
+ translations: Record<string, string>;
11
+ }) => string | undefined;
12
+ export {};
13
+ //# sourceMappingURL=translation-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translation-context.d.ts","sourceRoot":"","sources":["../../../components/contexts/translation-context.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAoC,MAAM,OAAO,CAAA;AAExD,KAAK,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAI5C,eAAO,MAAM,mBAAmB;kBAIhB,cAAc;cAClB,MAAM,SAAS;6CAK1B,CAAA;AAED,eAAO,MAAM,cAAc,sBAAuC,CAAA;AAElE,eAAO,MAAM,kBAAkB;UAIvB,MAAM;kBACE,OAAO,MAAM,EAAE,MAAM,CAAC;wBAMrC,CAAA"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { createContext, useContext } from "react";
4
+ const TranslationContext = createContext({});
5
+ export const TranslationProvider = ({ translations, children, }) => (_jsx(TranslationContext.Provider, Object.assign({ value: translations }, { children: children })));
6
+ export const useTranslation = () => useContext(TranslationContext);
7
+ export const getTextTranslation = ({ text, translations, }) => {
8
+ const key = text.trim().toLowerCase();
9
+ if (!(key in translations))
10
+ return undefined;
11
+ return translations[key];
12
+ };
@@ -1,9 +1,4 @@
1
- interface Collection {
2
- id: string;
3
- title: string;
4
- handle: string;
5
- products: Product[];
6
- }
1
+ import { Collection } from "app-studio-types";
7
2
  interface UseCollectionProps {
8
3
  apiUrl: string;
9
4
  appId: string;
@@ -13,12 +8,10 @@ interface UseCollectionProps {
13
8
  language: string;
14
9
  getCollections?: boolean;
15
10
  limit?: number;
11
+ metafields?: string;
16
12
  }
17
- interface Product {
18
- handle: string;
19
- }
20
- export declare const useCollection: ({ apiUrl, appId, collectionId, collectionHandle, collectionIdList, language, limit, getCollections, }: UseCollectionProps) => {
21
- collections: Collection[] | null;
13
+ export declare const useCollection: ({ apiUrl, appId, collectionId, collectionHandle, collectionIdList, language, limit, getCollections, metafields, }: UseCollectionProps) => {
14
+ collections: Collection[];
22
15
  specificCollection: Collection | null;
23
16
  loading: boolean;
24
17
  error: string | null;
@@ -1 +1 @@
1
- {"version":3,"file":"use-collection.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-collection.ts"],"names":[],"mappings":"AAGA,UAAU,UAAU;IAClB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,OAAO,EAAE,CAAA;CACpB;AAED,UAAU,kBAAkB;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,UAAU,OAAO;IACf,MAAM,EAAE,MAAM,CAAA;CAEf;AA6ED,eAAO,MAAM,aAAa,0GASvB,kBAAkB;;;;;CA0DpB,CAAA"}
1
+ {"version":3,"file":"use-collection.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-collection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAG7C,UAAU,kBAAkB;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAqFD,eAAO,MAAM,aAAa,sHAUvB,kBAAkB;;;;;CA6DpB,CAAA"}
@@ -27,14 +27,15 @@ const fetchWrapper = (url, errorCallback) => __awaiter(void 0, void 0, void 0, f
27
27
  errorCallback(error instanceof Error ? error.message : "An unknown error occurred.");
28
28
  }
29
29
  });
30
- const fetchCollection = (apiUrl, language, setError, collectionId = "", collectionHandle = "") => __awaiter(void 0, void 0, void 0, function* () {
30
+ const fetchCollection = (apiUrl, language, setError, collectionId = "", collectionHandle = "", metafields = "") => __awaiter(void 0, void 0, void 0, function* () {
31
31
  const collectionBy = collectionHandle ? "by-handle" : "by-id";
32
32
  const params = new URLSearchParams({
33
33
  collectionHandle: collectionHandle,
34
34
  collectionId: collectionId,
35
35
  language,
36
- }).toString();
37
- return yield fetchWrapper(`${apiUrl}/collections/${collectionBy}?${params}`, setError);
36
+ metafields,
37
+ });
38
+ return yield fetchWrapper(`${apiUrl}/collections/${collectionBy}?${params.toString()}`, setError);
38
39
  });
39
40
  const fetchAllCollections = (apiUrl, setError, limit = 100) => __awaiter(void 0, void 0, void 0, function* () {
40
41
  const limitParam = new URLSearchParams({
@@ -42,8 +43,8 @@ const fetchAllCollections = (apiUrl, setError, limit = 100) => __awaiter(void 0,
42
43
  }).toString();
43
44
  return yield fetchWrapper(`${apiUrl}/collections/by-app-id?${limitParam}`, setError);
44
45
  });
45
- export const useCollection = ({ apiUrl, appId, collectionId, collectionHandle, collectionIdList, language, limit = 100, getCollections = false, }) => {
46
- const [collections, setCollections] = useState(null);
46
+ export const useCollection = ({ apiUrl, appId, collectionId, collectionHandle, collectionIdList, language, limit = 100, getCollections = false, metafields, }) => {
47
+ const [collections, setCollections] = useState([]);
47
48
  const [specificCollection, setSpecificCollection] = useState(null);
48
49
  const [loading, setLoading] = useState(true);
49
50
  const [error, setError] = useState(null);
@@ -52,7 +53,7 @@ export const useCollection = ({ apiUrl, appId, collectionId, collectionHandle, c
52
53
  try {
53
54
  if (getCollections) {
54
55
  const collections = yield fetchAllCollections(apiUrl, setError, limit);
55
- return setCollections(collections);
56
+ return setCollections(collections !== null && collections !== void 0 ? collections : []);
56
57
  }
57
58
  if (collectionIdList === null || collectionIdList === void 0 ? void 0 : collectionIdList.length) {
58
59
  const collections = yield Promise.all(collectionIdList.map((id) => fetchCollection(apiUrl, language, setError, id)));
@@ -60,7 +61,7 @@ export const useCollection = ({ apiUrl, appId, collectionId, collectionHandle, c
60
61
  return setCollections(filteredCollections);
61
62
  }
62
63
  if (collectionId || collectionHandle) {
63
- const collection = yield fetchCollection(apiUrl, language, setError, collectionId, collectionHandle);
64
+ const collection = yield fetchCollection(apiUrl, language, setError, collectionId, collectionHandle, metafields);
64
65
  return setSpecificCollection(collection);
65
66
  }
66
67
  }
@@ -82,6 +83,7 @@ export const useCollection = ({ apiUrl, appId, collectionId, collectionHandle, c
82
83
  getCollections,
83
84
  limit,
84
85
  collectionIdList,
86
+ metafields,
85
87
  ]);
86
88
  return { collections, specificCollection, loading, error };
87
89
  };
@@ -0,0 +1,10 @@
1
+ type Customer = {
2
+ isAuthenticated: boolean;
3
+ };
4
+ type UseCustomerProps = {};
5
+ type UseCustomerReturn = {
6
+ customer: Customer;
7
+ };
8
+ export declare const useCustomer: (props: UseCustomerProps | null) => UseCustomerReturn;
9
+ export {};
10
+ //# sourceMappingURL=use-customer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-customer.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-customer.ts"],"names":[],"mappings":"AAWA,KAAK,QAAQ,GAAG;IACd,eAAe,EAAE,OAAO,CAAA;CACzB,CAAA;AAGD,KAAK,gBAAgB,GAAG,EAAE,CAAA;AAE1B,KAAK,iBAAiB,GAAG;IACvB,QAAQ,EAAE,QAAQ,CAAA;CACnB,CAAA;AAED,eAAO,MAAM,WAAW,UACf,gBAAgB,GAAG,IAAI,KAC7B,iBAuBF,CAAA"}
@@ -0,0 +1,24 @@
1
+ "use client";
2
+ import { useState, useEffect } from "react";
3
+ // @ts-ignore -- webbridge-react is not typed (yet)
4
+ import { useActions } from "@tapcart/webbridge-react";
5
+ export const useCustomer = (props) => {
6
+ const [isAuthenticated, setIsAuthenticated] = useState(false);
7
+ const [customer, setCustomer] = useState({});
8
+ const actions = useActions();
9
+ // verify customer
10
+ useEffect(() => {
11
+ try {
12
+ // webbridge method to get customerIdentity
13
+ actions.getCustomerIdentity(null, {
14
+ onSuccess: (user) => setIsAuthenticated(!!(user === null || user === void 0 ? void 0 : user.email)),
15
+ });
16
+ }
17
+ catch (e) {
18
+ console.log("unable to get customer identity ", e);
19
+ }
20
+ }, [actions]);
21
+ return {
22
+ customer: Object.assign({ isAuthenticated }, customer),
23
+ };
24
+ };
@@ -7,8 +7,9 @@ interface MoneyType {
7
7
  }
8
8
  declare const moneyVariants: (props?: ({} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
9
9
  export interface MoneyProps extends MoneyType, VariantProps<typeof moneyVariants> {
10
+ hideZeroCents?: boolean;
10
11
  styles?: React.CSSProperties;
11
12
  }
12
- declare function Money({ price, locale, currency, styles, ...props }: MoneyProps): import("react/jsx-runtime").JSX.Element;
13
+ declare function Money({ price, locale, currency, hideZeroCents, styles, ...props }: MoneyProps): import("react/jsx-runtime").JSX.Element;
13
14
  export { Money, moneyVariants };
14
15
  //# sourceMappingURL=money.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"money.d.ts","sourceRoot":"","sources":["../../../components/ui/money.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,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;IAChC,MAAM,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;CAC7B;AAEL,iBAAS,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,EAAE,UAAU,2CASvE;AAED,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,CAAA"}
1
+ {"version":3,"file":"money.d.ts","sourceRoot":"","sources":["../../../components/ui/money.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,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;IAChC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,MAAM,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;CAC7B;AAEL,iBAAS,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAqB,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,EAAE,UAAU,2CAc9F;AAED,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,CAAA"}
@@ -10,6 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
+ import * as React from "react";
13
14
  import { cva } from "class-variance-authority";
14
15
  const moneyVariants = cva("", {
15
16
  variants: {},
@@ -19,13 +20,16 @@ const moneyVariants = cva("", {
19
20
  },
20
21
  });
21
22
  function Money(_a) {
22
- var { price, locale, currency, styles } = _a, props = __rest(_a, ["price", "locale", "currency", "styles"]);
23
- const formatter = new Intl.NumberFormat(locale, {
23
+ var { price, locale, currency, hideZeroCents = false, styles } = _a, props = __rest(_a, ["price", "locale", "currency", "hideZeroCents", "styles"]);
24
+ const formatter = React.useMemo(() => new Intl.NumberFormat(locale, {
24
25
  style: "currency",
25
26
  currency: currency,
26
27
  currencyDisplay: "narrowSymbol",
27
- });
28
- let formattedPrice = formatter.format(Number(price));
28
+ }), [locale, currency]);
29
+ const formattedPrice = React.useMemo(() => {
30
+ const formatted = formatter.format(Number(price));
31
+ return hideZeroCents ? formatted.replace(/(\.|,)00$/, '') : formatted;
32
+ }, [formatter, price, hideZeroCents]);
29
33
  return _jsx("span", Object.assign({}, props, { style: styles }, { children: formattedPrice }));
30
34
  }
31
35
  export { Money, moneyVariants };
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  interface PriceProps {
3
+ hideZeroCents?: boolean;
3
4
  price: number;
4
5
  priceHigh?: number;
5
6
  priceRanges?: boolean;
@@ -14,6 +15,6 @@ interface PriceProps {
14
15
  saleStyles?: React.CSSProperties;
15
16
  strikeThroughStyles?: React.CSSProperties;
16
17
  }
17
- declare function Price({ price, priceHigh, priceRanges, isSale, compareAtPrice, compareAtPriceHigh, currency, locale, fontSize, textAlignment, standardStyles, saleStyles, strikeThroughStyles, }: PriceProps): import("react/jsx-runtime").JSX.Element;
18
+ declare function Price({ price, priceHigh, priceRanges, isSale, compareAtPrice, compareAtPriceHigh, currency, locale, fontSize, textAlignment, standardStyles, saleStyles, strikeThroughStyles, hideZeroCents }: PriceProps): import("react/jsx-runtime").JSX.Element;
18
19
  export { Price };
19
20
  //# sourceMappingURL=price.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"price.d.ts","sourceRoot":"","sources":["../../../components/ui/price.tsx"],"names":[],"mappings":";AAIA,UAAU,UAAU;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACnC,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,aAAa,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,EAAE,CAAC;IACjD,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACrC,UAAU,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACjC,mBAAmB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC3C;AAED,iBAAS,KAAK,CAAC,EACb,KAAK,EACL,SAAS,EACT,WAAmB,EACnB,MAAc,EACd,cAAc,EACd,kBAAkB,EAClB,QAAgB,EAChB,MAAgB,EAChB,QAAa,EACb,aAAkB,EAClB,cAAc,EACd,UAAU,EACV,mBAAmB,GACpB,EAAE,UAAU,2CAiEZ;AAED,OAAO,EAAE,KAAK,EAAE,CAAA"}
1
+ {"version":3,"file":"price.d.ts","sourceRoot":"","sources":["../../../components/ui/price.tsx"],"names":[],"mappings":";AAIA,UAAU,UAAU;IAClB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACnC,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,aAAa,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,EAAE,CAAC;IACjD,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACrC,UAAU,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACjC,mBAAmB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC3C;AAED,iBAAS,KAAK,CAAC,EACb,KAAK,EACL,SAAS,EACT,WAAmB,EACnB,MAAc,EACd,cAAc,EACd,kBAAkB,EAClB,QAAgB,EAChB,MAAgB,EAChB,QAAa,EACb,aAAkB,EAClB,cAAc,EACd,UAAU,EACV,mBAAmB,EACnB,aAAa,EACd,EAAE,UAAU,2CAoEZ;AAED,OAAO,EAAE,KAAK,EAAE,CAAA"}
@@ -2,17 +2,17 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Money } from "./money";
3
3
  import { Text } from "./text";
4
4
  import { cn } from "../../lib/utils";
5
- function Price({ price, priceHigh, priceRanges = false, isSale = false, compareAtPrice, compareAtPriceHigh, currency = "USD", locale = "en-US", fontSize = 15, textAlignment = '', standardStyles, saleStyles, strikeThroughStyles, }) {
5
+ function Price({ price, priceHigh, priceRanges = false, isSale = false, compareAtPrice, compareAtPriceHigh, currency = "USD", locale = "en-US", fontSize = 15, textAlignment = '', standardStyles, saleStyles, strikeThroughStyles, hideZeroCents }) {
6
6
  const Spacer = () => (_jsx("span", { children: " - " }));
7
7
  const ProductPrice = () => {
8
8
  const priceStyles = (!isSale || !compareAtPrice) ? standardStyles : saleStyles;
9
9
  const colorClass = isSale ? 'text-textColors-salePriceText' : 'text-textColors-priceText';
10
- return (_jsx(Text, Object.assign({ className: `${colorClass} flex-shrink-0`, style: { fontSize: `${fontSize}px` } }, { children: _jsxs("span", Object.assign({ className: "flex-grow min-w-[fit-content]" }, { children: [_jsx(Money, { price: price, currency: currency, locale: locale, styles: priceStyles }), priceRanges && priceHigh !== undefined && _jsx(Spacer, {}), priceRanges && priceHigh !== undefined && (_jsx(Money, { price: priceHigh, currency: currency, locale: locale, styles: priceStyles }))] })) })));
10
+ return (_jsx(Text, Object.assign({ className: `${colorClass} flex-shrink-0`, style: { fontSize: `${fontSize}px` } }, { children: _jsxs("span", Object.assign({ className: "flex-grow min-w-[fit-content]" }, { children: [_jsx(Money, { price: price, currency: currency, locale: locale, styles: priceStyles, hideZeroCents: hideZeroCents }), priceRanges && priceHigh !== undefined && _jsx(Spacer, {}), priceRanges && priceHigh !== undefined && (_jsx(Money, { price: priceHigh, currency: currency, locale: locale, styles: priceStyles, hideZeroCents: hideZeroCents }))] })) })));
11
11
  };
12
12
  const StrikeThroughPrice = () => {
13
13
  if (!isSale || !compareAtPrice)
14
14
  return null;
15
- return (_jsxs(Text, Object.assign({ className: "line-through text-textColors-strikethroughPriceText flex-shrink-0 flex items-center", style: { fontSize: `${fontSize}px` } }, { children: [_jsx(Money, { price: compareAtPrice, currency: currency, locale: locale, styles: strikeThroughStyles }), priceRanges && compareAtPriceHigh && _jsx(Spacer, {}), priceRanges && compareAtPriceHigh && (_jsx(Money, { price: compareAtPriceHigh, currency: currency, locale: locale, styles: strikeThroughStyles }))] })));
15
+ return (_jsxs(Text, Object.assign({ className: "line-through text-textColors-strikethroughPriceText flex-shrink-0 flex items-center", style: { fontSize: `${fontSize}px` } }, { children: [_jsx(Money, { price: compareAtPrice, currency: currency, locale: locale, styles: strikeThroughStyles, hideZeroCents: hideZeroCents }), priceRanges && compareAtPriceHigh && _jsx(Spacer, {}), priceRanges && compareAtPriceHigh && (_jsx(Money, { price: compareAtPriceHigh, currency: currency, locale: locale, styles: strikeThroughStyles, hideZeroCents: hideZeroCents }))] })));
16
16
  };
17
17
  return (_jsxs("div", Object.assign({ className: cn("flex flex-wrap gap-x-2", { "justify-start": textAlignment === "left" }, { "justify-end": textAlignment === "right" }, { "justify-center": textAlignment === "center" }) }, { children: [_jsx(ProductPrice, {}), _jsx(StrikeThroughPrice, {})] })));
18
18
  }
@@ -0,0 +1,12 @@
1
+ import * as React from "react";
2
+ export interface StarRatingProps extends React.HTMLAttributes<HTMLDivElement> {
3
+ score: number;
4
+ iconSize?: "xs" | "sm" | "md" | "lg";
5
+ iconUrl?: string;
6
+ filledColor?: string;
7
+ emptyColor?: string;
8
+ designOptions?: "condensed" | "expanded";
9
+ }
10
+ declare const StarRating: React.ForwardRefExoticComponent<StarRatingProps & React.RefAttributes<HTMLDivElement>>;
11
+ export { StarRating };
12
+ //# sourceMappingURL=star-rating.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"star-rating.d.ts","sourceRoot":"","sources":["../../../components/ui/star-rating.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAK9B,MAAM,WAAW,eACf,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IAC5C,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;IACpC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,aAAa,CAAC,EAAE,WAAW,GAAG,UAAU,CAAA;CACzC;AAED,QAAA,MAAM,UAAU,wFA2Df,CAAA;AAID,OAAO,EAAE,UAAU,EAAE,CAAA"}
@@ -0,0 +1,34 @@
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 } from "react/jsx-runtime";
13
+ import * as React from "react";
14
+ import { cn } from "../../lib/utils";
15
+ import { Icon } from "./icon";
16
+ const StarRating = React.forwardRef((_a, ref) => {
17
+ var { className, score, iconSize = "sm", iconUrl, filledColor, emptyColor, designOptions } = _a, props = __rest(_a, ["className", "score", "iconSize", "iconUrl", "filledColor", "emptyColor", "designOptions"]);
18
+ if (designOptions === "condensed") {
19
+ return (_jsx(Icon, { size: iconSize, url: iconUrl, color: filledColor }));
20
+ }
21
+ return (_jsx("div", Object.assign({ className: cn("flex flex-row gap-1", className), ref: ref }, props, { children: Array.from({ length: 5 }).map((_, index) => {
22
+ if (score % 1 !== 0 && Math.floor(score) === index) {
23
+ return (_jsx(Icon, { size: iconSize, url: iconUrl, fillColor: filledColor, secondaryFillColor: emptyColor, fillPercentage: score % 1 }, index));
24
+ }
25
+ else if (index + 1 > score) {
26
+ return (_jsx(Icon, { size: iconSize, url: iconUrl, color: emptyColor }, index));
27
+ }
28
+ else {
29
+ return (_jsx(Icon, { size: iconSize, url: iconUrl, color: filledColor }, index));
30
+ }
31
+ }) })));
32
+ });
33
+ StarRating.displayName = "StarRating";
34
+ export { StarRating };
@@ -5,7 +5,8 @@ declare const textVariants: (props?: ({
5
5
  } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
6
6
  export interface TextProps extends React.HTMLAttributes<HTMLParagraphElement>, VariantProps<typeof textVariants> {
7
7
  fontColor?: string | null;
8
+ children?: React.ReactNode;
8
9
  }
9
- declare function Text({ className, type, fontColor, ...props }: TextProps): import("react/jsx-runtime").JSX.Element;
10
+ declare function Text({ className, type, fontColor, children, ...props }: TextProps): import("react/jsx-runtime").JSX.Element;
10
11
  export { Text, textVariants };
11
12
  //# sourceMappingURL=text.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../components/ui/text.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAGjE,QAAA,MAAM,YAAY;;mFAgBhB,CAAA;AAEF,MAAM,WAAW,SACf,SAAQ,KAAK,CAAC,cAAc,CAAC,oBAAoB,CAAC,EAChD,YAAY,CAAC,OAAO,YAAY,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC1B;AAED,iBAAS,IAAI,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,SAAS,2CAUhE;AAED,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,CAAA"}
1
+ {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../components/ui/text.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAOjE,QAAA,MAAM,YAAY;;mFAgBhB,CAAA;AAEF,MAAM,WAAW,SACf,SAAQ,KAAK,CAAC,cAAc,CAAC,oBAAoB,CAAC,EAChD,YAAY,CAAC,OAAO,YAAY,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B;AAED,iBAAS,IAAI,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,SAAS,2CAiB1E;AAED,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,CAAA"}
@@ -10,8 +10,10 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
+ import * as React from "react";
13
14
  import { cva } from "class-variance-authority";
14
15
  import { cn } from "../../lib/utils";
16
+ import { useTranslation, getTextTranslation, } from "../contexts/translation-context";
15
17
  const textVariants = cva("", {
16
18
  variants: {
17
19
  type: {
@@ -27,8 +29,14 @@ const textVariants = cva("", {
27
29
  },
28
30
  });
29
31
  function Text(_a) {
30
- var { className, type, fontColor } = _a, props = __rest(_a, ["className", "type", "fontColor"]);
32
+ var { className, type, fontColor, children } = _a, props = __rest(_a, ["className", "type", "fontColor", "children"]);
31
33
  const fontColorOverride = fontColor ? { color: fontColor } : {};
32
- return (_jsx("p", Object.assign({ className: cn(textVariants({ type }), className), style: fontColorOverride }, props)));
34
+ const translations = useTranslation();
35
+ const stringContents = React.Children.toArray(children).join("");
36
+ const textContents = getTextTranslation({
37
+ text: stringContents,
38
+ translations,
39
+ });
40
+ return (_jsx("p", Object.assign({ className: cn(textVariants({ type }), className), style: fontColorOverride }, props, { children: textContents ? textContents : children })));
33
41
  }
34
42
  export { Text, textVariants };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- export { cn, cva, getColor, getBackgroundAndPaddingStyle, getBorderSidesStyle, getTextStyle, getVerticalAlignmentStyle, getBackgroundAndSpacingStyle, getIdFromGid, productGidFromId, variantGidFromId, getPaddingStyle, getMarginStyle, getVerticalAlignment, mapFlexToAlignment, formatRelativeTime, stringRatioToInt, getOverlayStyle, throttleFunction, getDestinationHandler, getProductGidsFromIds, createCollectionImageMap, isFavoriteIntegrationEnabled } from "./lib/utils";
1
+ export { cn, cva, getColor, getBackgroundAndPaddingStyle, getBorderSidesStyle, getTextStyle, getVerticalAlignmentStyle, getBackgroundAndSpacingStyle, getIdFromGid, productGidFromId, variantGidFromId, getPaddingStyle, getMarginStyle, getVerticalAlignment, mapFlexToAlignment, formatRelativeTime, stringRatioToInt, getOverlayStyle, throttleFunction, getDestinationHandler, getProductGidsFromIds, createCollectionImageMap, isFavoriteIntegrationEnabled, } from "./lib/utils";
2
+ export * from "./components/contexts/translation-context";
2
3
  export * from "./components/hooks/use-collection";
3
4
  export * from "./components/hooks/use-infinite-scroll";
4
5
  export * from "./components/hooks/use-recommendations";
@@ -36,6 +37,7 @@ export * from "./components/ui/selectors";
36
37
  export * from "./components/ui/separator";
37
38
  export * from "./components/ui/skeleton";
38
39
  export * from "./components/ui/slider";
40
+ export * from "./components/ui/star-rating";
39
41
  export * from "./components/ui/subscription";
40
42
  export * from "./components/ui/switch";
41
43
  export * from "./components/ui/tabs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.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,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,4BAA4B,EAC7B,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,2BAA2B,CAAA;AACzC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA;AACtC,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA;AACxC,cAAc,sBA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Ac,iCAAiC,CAAA;AAC/C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,2BAA2B,CAAA;AACzC,cAAc,2BAA2B,CAAA;AACzC,cAAc,0BAA0B,CAAA;AACxC,cAAc,wBAAwB,CAAA;AACtC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,8BAA8B,CAAA;AAC5C,cAAc,wBAAwB,CAAA;AACtC,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA;AACpC,cAAc,0BAA0B,CAAA;AACxC,cAAc,uBAAuB,CAAA;AACrC,cAAc,yBAAyB,CAAA;AACvC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,wBAAwB,CAAA;AACtC,cAAc,2BAA2B,CAAA;AACzC,cAAc,uBAAuB,CAAA;AACrC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,0BAA0B,CAAA;AACxC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,kDAAkD,CAAA;AAChE,cAAc,gCAAgC,CAAA;AAC9C,cAAc,oCAAoC,CAAA;AAClD,cAAc,mCAAmC,CAAA;AACjD,cAAc,aAAa,CAAA;AAC3B,cAAc,6CAA6C,CAAA;AAC3D,cAAc,kDAAkD,CAAA;AAChE,cAAc,qBAAqB,CAAA"}
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // component exports
2
- export { cn, cva, getColor, getBackgroundAndPaddingStyle, getBorderSidesStyle, getTextStyle, getVerticalAlignmentStyle, getBackgroundAndSpacingStyle, getIdFromGid, productGidFromId, variantGidFromId, getPaddingStyle, getMarginStyle, getVerticalAlignment, mapFlexToAlignment, formatRelativeTime, stringRatioToInt, getOverlayStyle, throttleFunction, getDestinationHandler, getProductGidsFromIds, createCollectionImageMap, isFavoriteIntegrationEnabled } from "./lib/utils";
2
+ export { cn, cva, getColor, getBackgroundAndPaddingStyle, getBorderSidesStyle, getTextStyle, getVerticalAlignmentStyle, getBackgroundAndSpacingStyle, getIdFromGid, productGidFromId, variantGidFromId, getPaddingStyle, getMarginStyle, getVerticalAlignment, mapFlexToAlignment, formatRelativeTime, stringRatioToInt, getOverlayStyle, throttleFunction, getDestinationHandler, getProductGidsFromIds, createCollectionImageMap, isFavoriteIntegrationEnabled, } from "./lib/utils";
3
+ export * from "./components/contexts/translation-context";
3
4
  export * from "./components/hooks/use-collection";
4
5
  export * from "./components/hooks/use-infinite-scroll";
5
6
  export * from "./components/hooks/use-recommendations";
@@ -37,6 +38,7 @@ export * from "./components/ui/selectors";
37
38
  export * from "./components/ui/separator";
38
39
  export * from "./components/ui/skeleton";
39
40
  export * from "./components/ui/slider";
41
+ export * from "./components/ui/star-rating";
40
42
  export * from "./components/ui/subscription";
41
43
  export * from "./components/ui/switch";
42
44
  export * from "./components/ui/tabs";
package/dist/styles.css CHANGED
@@ -1261,6 +1261,9 @@ video {
1261
1261
  .items-start {
1262
1262
  align-items: flex-start;
1263
1263
  }
1264
+ .items-end {
1265
+ align-items: flex-end;
1266
+ }
1264
1267
  .items-center {
1265
1268
  align-items: center;
1266
1269
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapcart/mobile-components",
3
- "version": "0.7.12",
3
+ "version": "0.7.14",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "style": "dist/styles.css",