@shopify/shop-minis-react 0.0.29 → 0.0.31

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 (34) hide show
  1. package/dist/components/atoms/list.js +37 -31
  2. package/dist/components/atoms/list.js.map +1 -1
  3. package/dist/components/commerce/search.js.map +1 -1
  4. package/dist/hooks/navigation/useNavigateWithTransition.js.map +1 -1
  5. package/dist/hooks/navigation/useShopNavigation.js.map +1 -1
  6. package/dist/hooks/user/useCurrentUser.js.map +1 -1
  7. package/dist/hooks/user/useFollowedShopsActions.js.map +1 -1
  8. package/dist/hooks/user/useGenerateUserToken.js +12 -0
  9. package/dist/hooks/user/useGenerateUserToken.js.map +1 -0
  10. package/dist/hooks/util/useImagePicker.js.map +1 -1
  11. package/dist/index.js +111 -106
  12. package/dist/index.js.map +1 -1
  13. package/dist/mocks.js +24 -16
  14. package/dist/mocks.js.map +1 -1
  15. package/dist/shop-minis-platform/src/types/user.js +6 -0
  16. package/dist/shop-minis-platform/src/types/user.js.map +1 -0
  17. package/package.json +2 -2
  18. package/src/components/atoms/list.tsx +24 -4
  19. package/src/components/commerce/search.tsx +1 -1
  20. package/src/hooks/index.ts +1 -0
  21. package/src/hooks/navigation/useNavigateWithTransition.ts +6 -1
  22. package/src/hooks/navigation/useShopNavigation.ts +3 -1
  23. package/src/hooks/user/useCurrentUser.ts +3 -0
  24. package/src/hooks/user/useFollowedShopsActions.ts +2 -2
  25. package/src/hooks/user/useGenerateUserToken.ts +25 -0
  26. package/src/hooks/util/{useImagePicker.tsx → useImagePicker.ts} +8 -2
  27. package/src/mocks.ts +11 -4
  28. package/src/stories/ImageContentWrapper.stories.tsx +68 -0
  29. package/src/stories/MerchantCard.stories.tsx +21 -0
  30. package/src/stories/ProductCard.stories.tsx +10 -3
  31. package/src/stories/ProductLink.stories.tsx +3 -3
  32. package/src/stories/QuantitySelector.stories.tsx +78 -0
  33. package/src/stories/VideoPlayer.stories.tsx +129 -0
  34. package/src/hooks/util/useImagePicker.doc.tsx +0 -41
@@ -1,48 +1,54 @@
1
- import { jsxs as u, jsx as o } from "react/jsx-runtime";
2
- import { useCallback as f } from "react";
3
- import { VariableSizeList as V } from "../../shop-minis-react/node_modules/.pnpm/react-window@1.8.11_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/react-window/dist/index.esm.js";
1
+ import { jsxs as m, jsx as n } from "react/jsx-runtime";
2
+ import { useRef as V, useCallback as f } from "react";
3
+ import { VariableSizeList as _ } from "../../shop-minis-react/node_modules/.pnpm/react-window@1.8.11_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/react-window/dist/index.esm.js";
4
4
  import { cn as j } from "../../lib/utils.js";
5
5
  /* empty css */
6
6
  import { Pagination as C } from "./pagination.js";
7
- const N = V;
7
+ const N = _;
8
8
  function q({
9
- items: r,
9
+ items: t,
10
10
  height: p,
11
- renderItem: l,
12
- className: m,
13
- showScrollbar: v = !1,
14
- header: t,
15
- headerHeight: n,
16
- itemSizeForRow: s,
17
- fetchMore: a,
18
- overscanCount: b,
19
- ...L
11
+ renderItem: o,
12
+ className: v,
13
+ showScrollbar: b = !1,
14
+ header: i,
15
+ headerHeight: c,
16
+ itemSizeForRow: a,
17
+ fetchMore: l,
18
+ overscanCount: g,
19
+ ...h
20
20
  }) {
21
- const g = f(
22
- ({ index: i, style: c }) => t && i === 0 ? /* @__PURE__ */ u("div", { style: c, children: [
23
- t,
24
- /* @__PURE__ */ o("div", { style: { top: n }, children: l(r[0], 0) })
25
- ] }) : a && i === r.length - 1 ? /* @__PURE__ */ u("div", { style: c, children: [
26
- l(r[i], i),
27
- /* @__PURE__ */ o("div", { style: { bottom: 0 }, children: /* @__PURE__ */ o(C, { fetchMore: a }) })
28
- ] }) : /* @__PURE__ */ o("div", { style: c, children: l(r[i], i) }),
29
- [r, l, t, a, n]
21
+ const s = V(null), e = f(() => {
22
+ if (s.current) return;
23
+ const r = Promise.resolve(l?.()).finally(() => {
24
+ s.current === r && (s.current = null);
25
+ });
26
+ s.current = r;
27
+ }, [l]), L = f(
28
+ ({ index: r, style: u }) => i && r === 0 ? /* @__PURE__ */ m("div", { style: u, children: [
29
+ i,
30
+ /* @__PURE__ */ n("div", { style: { top: c }, children: o(t[0], 0) })
31
+ ] }) : l && r === t.length - 1 ? /* @__PURE__ */ m("div", { style: u, children: [
32
+ o(t[r], r),
33
+ /* @__PURE__ */ n("div", { style: { bottom: 0 }, children: /* @__PURE__ */ n(C, { fetchMore: e }) })
34
+ ] }) : /* @__PURE__ */ n("div", { style: u, children: o(t[r], r) }),
35
+ [t, o, i, c, e, l]
30
36
  ), z = f(
31
- (i) => t && i === 0 ? (n || 0) + s(i) : s(i),
32
- [s, t, n]
33
- ), S = j(v ? void 0 : "no-scrollbars", m);
34
- return /* @__PURE__ */ o(
37
+ (r) => i && r === 0 ? (c || 0) + a(r) : a(r),
38
+ [a, i, c]
39
+ ), S = j(b ? void 0 : "no-scrollbars", v);
40
+ return /* @__PURE__ */ n(
35
41
  N,
36
42
  {
37
43
  className: S,
38
44
  height: p,
39
45
  direction: "vertical",
40
46
  width: "100%",
41
- itemCount: r.length,
42
- overscanCount: b,
47
+ itemCount: t.length,
48
+ overscanCount: g,
43
49
  itemSize: z,
44
- ...L,
45
- children: g
50
+ ...h,
51
+ children: L
46
52
  }
47
53
  );
48
54
  }
@@ -1 +1 @@
1
- {"version":3,"file":"list.js","sources":["../../../src/components/atoms/list.tsx"],"sourcesContent":["import {ComponentType, useCallback} from 'react'\n\nimport {\n VariableSizeList as _VariableSizeList,\n VariableSizeListProps,\n} from 'react-window'\n\nimport {cn} from '../../lib/utils'\nimport '../../styles/utilities.css'\n\nimport {Pagination} from './pagination'\n\nconst VariableSizeList =\n _VariableSizeList as unknown as ComponentType<VariableSizeListProps>\n\ninterface Props<T = any>\n extends Omit<\n VariableSizeListProps<T>,\n 'children' | 'itemCount' | 'width' | 'itemSize' | 'direction'\n > {\n items: T[]\n renderItem: (item: T, index: number) => React.ReactNode\n itemSizeForRow: (index: number) => number\n showScrollbar?: boolean\n header?: React.ReactNode\n headerHeight?: number\n fetchMore?: () => void\n}\n\nexport function List<T = any>({\n items,\n height,\n renderItem,\n className,\n showScrollbar = false,\n header,\n headerHeight,\n itemSizeForRow,\n fetchMore,\n overscanCount,\n ...listProps\n}: Props<T>) {\n const rowRenderer = useCallback(\n ({index, style}: {index: number; style: React.CSSProperties}) => {\n // prepend the header to the first row if it exists\n if (header && index === 0) {\n return (\n <div style={style}>\n {header}\n <div style={{top: headerHeight}}>{renderItem(items[0], 0)}</div>\n </div>\n )\n }\n\n // append the pagination spinner to the last row if fetchMore exists\n if (fetchMore && index === items.length - 1) {\n return (\n <div style={style}>\n {renderItem(items[index], index)}\n <div style={{bottom: 0}}>\n <Pagination fetchMore={fetchMore} />\n </div>\n </div>\n )\n }\n\n return <div style={style}>{renderItem(items[index], index)}</div>\n },\n [items, renderItem, header, fetchMore, headerHeight]\n )\n\n const getItemSize = useCallback(\n (index: number) => {\n // include the header height in the first row height\n if (header && index === 0) {\n const _headerHeight = headerHeight || 0\n return _headerHeight + itemSizeForRow(index)\n }\n\n return itemSizeForRow(index)\n },\n [itemSizeForRow, header, headerHeight]\n )\n\n const classNames = cn(showScrollbar ? undefined : 'no-scrollbars', className)\n\n return (\n <VariableSizeList\n className={classNames}\n height={height}\n direction=\"vertical\"\n width=\"100%\"\n itemCount={items.length}\n overscanCount={overscanCount}\n itemSize={getItemSize}\n {...listProps}\n >\n {rowRenderer}\n </VariableSizeList>\n )\n}\n"],"names":["VariableSizeList","_VariableSizeList","List","items","height","renderItem","className","showScrollbar","header","headerHeight","itemSizeForRow","fetchMore","overscanCount","listProps","rowRenderer","useCallback","index","style","jsxs","jsx","Pagination","getItemSize","classNames","cn"],"mappings":";;;;;;AAYA,MAAMA,IACJC;AAgBK,SAASC,EAAc;AAAA,EAC5B,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,YAAAC;AAAA,EACA,WAAAC;AAAA,EACA,eAA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A,UAAUS;AAAA,MACT,GAAGR;AAAA,MAEH,UAAAC;AAAA,IAAA;AAAA,EACH;AAEJ;"}
1
+ {"version":3,"file":"list.js","sources":["../../../src/components/atoms/list.tsx"],"sourcesContent":["import {ComponentType, useCallback, useRef} from 'react'\n\nimport {\n VariableSizeList as _VariableSizeList,\n VariableSizeListProps,\n} from 'react-window'\n\nimport {cn} from '../../lib/utils'\nimport '../../styles/utilities.css'\n\nimport {Pagination} from './pagination'\n\nconst VariableSizeList =\n _VariableSizeList as unknown as ComponentType<VariableSizeListProps>\n\ninterface Props<T = any>\n extends Omit<\n VariableSizeListProps<T>,\n 'children' | 'itemCount' | 'width' | 'itemSize' | 'direction'\n > {\n items: T[]\n renderItem: (item: T, index: number) => React.ReactNode\n itemSizeForRow: (index: number) => number\n showScrollbar?: boolean\n header?: React.ReactNode\n headerHeight?: number\n fetchMore?: () => Promise<void>\n}\n\nexport function List<T = any>({\n items,\n height,\n renderItem,\n className,\n showScrollbar = false,\n header,\n headerHeight,\n itemSizeForRow,\n fetchMore,\n overscanCount,\n ...listProps\n}: Props<T>) {\n const inFlightFetchMoreRef = useRef<Promise<void> | null>(null)\n\n // This is workaround to prevent multiple calls to fetchMore\n // react-window re-renders the rows while scrolling,\n // and the TrackingPixel could be triggered multiple times\n\n const _fetchMore = useCallback(() => {\n // Dedupe concurrent calls by returning the same in-flight promise\n if (inFlightFetchMoreRef.current) return\n\n const current = Promise.resolve(fetchMore?.()).finally(() => {\n // Only clear if this is still the most recent promise\n if (inFlightFetchMoreRef.current === current) {\n inFlightFetchMoreRef.current = null\n }\n })\n\n inFlightFetchMoreRef.current = current\n }, [fetchMore])\n\n const rowRenderer = useCallback(\n ({index, style}: {index: number; style: React.CSSProperties}) => {\n // prepend the header to the first row if it exists\n if (header && index === 0) {\n return (\n <div style={style}>\n {header}\n <div style={{top: headerHeight}}>{renderItem(items[0], 0)}</div>\n </div>\n )\n }\n\n // append the pagination spinner to the last row if fetchMore exists\n if (fetchMore && index === items.length - 1) {\n return (\n <div style={style}>\n {renderItem(items[index], index)}\n <div style={{bottom: 0}}>\n <Pagination fetchMore={_fetchMore} />\n </div>\n </div>\n )\n }\n\n return <div style={style}>{renderItem(items[index], index)}</div>\n },\n [items, renderItem, header, headerHeight, _fetchMore, fetchMore]\n )\n\n const getItemSize = useCallback(\n (index: number) => {\n // include the header height in the first row height\n if (header && index === 0) {\n const _headerHeight = headerHeight || 0\n return _headerHeight + itemSizeForRow(index)\n }\n\n return itemSizeForRow(index)\n },\n [itemSizeForRow, header, headerHeight]\n )\n\n const classNames = cn(showScrollbar ? undefined : 'no-scrollbars', className)\n\n return (\n <VariableSizeList\n className={classNames}\n height={height}\n direction=\"vertical\"\n width=\"100%\"\n itemCount={items.length}\n overscanCount={overscanCount}\n itemSize={getItemSize}\n {...listProps}\n >\n {rowRenderer}\n </VariableSizeList>\n )\n}\n"],"names":["VariableSizeList","_VariableSizeList","List","items","height","renderItem","className","showScrollbar","header","headerHeight","itemSizeForRow","fetchMore","overscanCount","listProps","inFlightFetchMoreRef","useRef","_fetchMore","useCallback","current","rowRenderer","index","style","jsxs","jsx","Pagination","getItemSize","classNames","cn"],"mappings":";;;;;;AAYA,MAAMA,IACJC;AAgBK,SAASC,EAAc;AAAA,EAC5B,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,YAAAC;AAAA,EACA,WAAAC;AAAA,EACA,eAAAC,IAAgB;AAAA,EAChB,QAAAC;AAAA,EACA,cAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,WAAAC;AAAA,EACA,eAAAC;AAAA,EACA,GAAGC;AACL,GAAa;AACL,QAAAC,IAAuBC,EAA6B,IAAI,GAMxDC,IAAaC,EAAY,MAAM;AAEnC,QAAIH,EAAqB,QAAS;AAElC,UAAMI,IAAU,QAAQ,QAAQP,IAAa,CAAA,EAAE,QAAQ,MAAM;AAEvD,MAAAG,EAAqB,YAAYI,MACnCJ,EAAqB,UAAU;AAAA,IACjC,CACD;AAED,IAAAA,EAAqB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AEJ;"}
@@ -1 +1 @@
1
- {"version":3,"file":"search.js","sources":["../../../src/components/commerce/search.tsx"],"sourcesContent":["import * as React from 'react'\nimport {createContext, useContext, useState, useCallback} from 'react'\n\nimport {SearchIcon, X} from 'lucide-react'\n\nimport {useProductSearch} from '../../hooks/product/useProductSearch'\nimport {cn} from '../../lib/utils'\nimport {type Product} from '../../types'\nimport {IconButton} from '../atoms/icon-button'\nimport {List} from '../atoms/list'\nimport {Input} from '../ui/input'\n\nimport {ProductLink} from './product-link'\nimport {ProductLinkSkeleton} from './product-link-skeleton'\n\nconst ESTIMATED_PRODUCT_LINK_HEIGHT = 100\n\ninterface SearchContextValue {\n query: string\n setQuery: (query: string) => void\n products: Product[] | null\n loading: boolean\n error: Error | null\n fetchMore?: () => void\n hasNextPage: boolean\n isTyping: boolean\n}\n\nconst SearchContext = createContext<SearchContextValue | null>(null)\n\nfunction useSearchContext() {\n const context = useContext(SearchContext)\n if (!context) {\n throw new Error('useSearchContext must be used within a SearchProvider')\n }\n return context\n}\n\nexport interface SearchProviderProps {\n initialQuery?: string\n children: React.ReactNode\n}\n\nfunction SearchProvider({initialQuery = '', children}: SearchProviderProps) {\n const [query, setQueryState] = useState(initialQuery)\n\n const {products, loading, error, fetchMore, hasNextPage, isTyping} =\n useProductSearch({\n query,\n fetchPolicy: 'network-only',\n })\n\n const setQuery = useCallback((newQuery: string) => {\n setQueryState(newQuery)\n }, [])\n\n const contextValue: SearchContextValue = {\n query,\n setQuery,\n products,\n loading,\n error,\n fetchMore,\n hasNextPage,\n isTyping,\n }\n\n return (\n <SearchContext.Provider value={contextValue}>\n {children}\n </SearchContext.Provider>\n )\n}\n\nexport interface SearchInputProps {\n placeholder?: string\n className?: string\n inputProps?: React.ComponentProps<'input'>\n}\n\nfunction SearchInput({\n placeholder = 'Search products...',\n className,\n inputProps,\n}: SearchInputProps) {\n const {query, setQuery} = useSearchContext()\n\n const handleQueryChange = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n setQuery(event.target.value)\n inputProps?.onChange?.(event)\n },\n [inputProps, setQuery]\n )\n\n return (\n <div className=\"relative flex flex-1 items-center rounded-full pl-4 pr-2 py-1 bg-gray-100\">\n <div className=\"relative flex items-center\">\n <SearchIcon\n size={18}\n className={cn('text-accent-foreground opacity-60')}\n />\n </div>\n <div className=\"relative flex-1 flex items-center mx-2\">\n <Input\n name=\"search\"\n onChange={handleQueryChange}\n placeholder={placeholder}\n type=\"search\"\n role=\"searchbox\"\n autoComplete=\"off\"\n value={query}\n data-testid=\"search-input\"\n {...inputProps}\n className={cn(\n `w-full flex overflow-hidden rounded-radius-28 border-none py-4 px-0 text-text placeholder:text-text placeholder:opacity-60`,\n className\n )}\n />\n </div>\n <div className=\"relative flex items-center\">\n {query === '' ? null : (\n <IconButton\n Icon={X}\n size=\"sm\"\n filled={false}\n iconStyles=\"\"\n onClick={() => setQuery('')}\n buttonStyles=\"flex items-center rounded-radius-max bg-[var(--grayscale-l20)]\"\n />\n )}\n </div>\n </div>\n )\n}\n\nexport interface SearchResultsListProps {\n renderItem?: (product: Product, index: number) => React.ReactNode\n height?: number\n itemHeight?: number\n initialStateComponent?: React.JSX.Element\n showScrollbar?: boolean\n overscanCount?: number\n}\n\nfunction SearchResultsList({\n height = window.innerHeight,\n renderItem,\n itemHeight = ESTIMATED_PRODUCT_LINK_HEIGHT,\n initialStateComponent,\n showScrollbar,\n overscanCount = 5,\n}: SearchResultsListProps) {\n const {query, products, loading, fetchMore, hasNextPage, isTyping} =\n useSearchContext()\n\n const _renderItem = (product: Product, index: number) => {\n if (renderItem) {\n return renderItem(product, index)\n }\n\n return (\n <div className=\"p-2\">\n <ProductLink key={product.id} product={product} hideFavoriteAction />\n </div>\n )\n }\n\n const shouldShowStartingState = query.trim().length === 0\n const shouldShowLoading =\n (!products || products.length === 0) && (loading || isTyping)\n const shouldShowEmptyState = (!products || products.length === 0) && !loading\n\n if (shouldShowStartingState) {\n return (\n initialStateComponent || (\n <div className=\"flex items-center justify-center h-32 text-gray-500\">\n Start typing to search for products\n </div>\n )\n )\n }\n\n if (shouldShowLoading) {\n return (\n <div className=\"flex flex-col px-4 py-4\">\n <ProductLinkSkeleton className=\"mb-4\" />\n <ProductLinkSkeleton className=\"mb-4\" />\n <ProductLinkSkeleton className=\"mb-4\" />\n <ProductLinkSkeleton className=\"mb-4\" />\n </div>\n )\n }\n\n if (shouldShowEmptyState) {\n return (\n <div className=\"flex items-center justify-center h-32 text-gray-500\">\n {`No products found for \"${query}\"`}\n </div>\n )\n }\n\n return (\n <List\n items={products || []}\n height={height}\n renderItem={_renderItem}\n itemSizeForRow={() => itemHeight}\n fetchMore={hasNextPage ? fetchMore : undefined}\n showScrollbar={showScrollbar}\n overscanCount={overscanCount}\n />\n )\n}\n\ninterface SearchProviderPropsWithoutChildren\n extends Omit<SearchProviderProps, 'children'> {}\nexport interface SearchResultsProps\n extends SearchProviderPropsWithoutChildren,\n SearchInputProps,\n SearchResultsListProps {\n showSearchInput?: boolean\n onProductClick?: (product: Product) => void\n}\n\nfunction Search({\n initialQuery,\n placeholder,\n inputProps,\n height,\n className,\n renderItem,\n itemHeight,\n onProductClick,\n}: SearchResultsProps) {\n const _renderItem = (product: Product, index: number) => {\n if (renderItem) {\n return renderItem(product, index)\n }\n\n return (\n <div className=\"p-2\">\n <ProductLink\n key={product.id}\n product={product}\n hideFavoriteAction\n onClick={onProductClick}\n />\n </div>\n )\n }\n\n return (\n <SearchProvider initialQuery={initialQuery}>\n <div className={cn('flex flex-col ', className)}>\n <div className=\"fixed top-0 left-0 right-0 p-4 w-full z-20 bg-background\">\n <SearchInput placeholder={placeholder} inputProps={inputProps} />\n </div>\n <div className=\"h-14\" />\n <SearchResultsList\n height={height}\n renderItem={_renderItem}\n itemHeight={itemHeight}\n showScrollbar\n />\n </div>\n </SearchProvider>\n )\n}\n\nexport {SearchProvider, SearchInput, SearchResultsList, Search}\n"],"names":["ESTIMATED_PRODUCT_LINK_HEIGHT","SearchContext","createContext","useSearchContext","context","useContext","SearchProvider","initialQuery","children","query","setQueryState","useState","products","loading","error","fetchMore","hasNextPage","isTyping","useProductSearch","setQuery","useCallback","newQuery","contextValue","SearchInput","placeholder","className","inputProps","handleQueryChange","event","jsxs","jsx","SearchIcon","cn","Input","IconButton","X","SearchResultsList","height","renderItem","itemHeight","initialStateComponent","showScrollbar","overscanCount","_renderItem","product","index","ProductLink","shouldShowStartingState","shouldShowLoading","shouldShowEmptyState","ProductLinkSkeleton","List","Search","onProductClick"],"mappings":";;;;;;;;;;;AAeA,MAAMA,IAAgC,KAahCC,IAAgBC,EAAyC,IAAI;AAEnE,SAASC,IAAmB;AACpB,QAAAC,IAAUC,EAAWJ,CAAa;AACxC,MAAI,CAACG;AACG,UAAA,IAAI,MAAM,uDAAuD;AAElE,SAAAA;AACT;AAOA,SAASE,EAAe,EAAC,cAAAC,IAAe,IAAI,UAAAC,KAAgC;AAC1E,QAAM,CAACC,GAAOC,CAAa,IAAIC,EAASJ,CAAY,GAE9C,EAAC,UAAAK,GAAU,SAAAC,GAAS,OAAAC,GAAO,WAAAC,GAAW,aAAAC,GAAa,UAAAC,MACvDC,EAAiB;AAAA,IACf,OAAAT;AAAA,IACA,aAAa;AAAA,EAAA,CACd,GAEGU,IAAWC,EAAY,CAACC,MAAqB;AACjD,IAAAX,EAAcW,CAAQ;AAAA,EACxB,GAAG,EAAE,GAECC,IAAmC;AAAA,IACvC,OAAAb;AAAA,IACA,UAAAU;AAAA,IACA,UAAAP;AAAA,IACA,SAAAC;AAAA,IACA,OAAAC;AAAA,IACA,WAAAC;AAAA,IACA,aAAAC;AAAA,IACA,UAAAC;AAAA,EACF;AAEA,2BACGhB,EAAc,UAAd,EAAuB,OAAOqB,GAC5B,UAAAd,GACH;AAEJ;AAQA,SAASe,EAAY;AAAA,EACnB,aAAAC,IAAc;AAAA,EACd,WAAAC;AAAA,EACA,YAAAC;AACF,GAAqB;AACnB,QAAM,EAAC,OAAAjB,GAAO,UAAAU,EAAQ,IAAIhB,EAAi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A,YAAAa;AAAA,EACA,YAAAC;AAAA,EACA,gBAAAc;AACF,GAAuB;AACf,QAAAV,IAAc,CAACC,GAAkBC,MACjCP,IACKA,EAAWM,GAASC,CAAK,IAIhC,gBAAAf,EAAC,OAAI,EAAA,WAAU,OACb,UAAA,gBAAAA;AAAA,IAACgB;AAAA,IAAA;AAAA,MAEC,SAAAF;AAAA,MACA,oBAAkB;AAAA,MAClB,SAASS;AAAA,IAAA;AAAA,IAHJT,EAAQ;AAAA,EAAA,GAKjB;AAKF,SAAA,gBAAAd,EAACxB,KAAe,cAAAC,GACd,UAAA,gBAAAsB,EAAC,SAAI,WAAWG,EAAG,kBAAkBP,CAAS,GAC5C,UAAA;AAAA,IAAA,gBAAAK,EAAC,SAAI,WAAU,4DACb,4BAACP,GAAY,EAAA,aAAAC,GAA0B,YAAAE,GAAwB,EACjE,CAAA;AAAA,IACA,gBAAAI,EAAC,OAAI,EAAA,WAAU,OAAO,CAAA;AAAA,IACtB,gBAAAA;AAAA,MAACM;AAAA,MAAA;AAAA,QACC,QAAAC;AAAA,QACA,YAAYM;AAAA,QACZ,YAAAJ;AAAA,QACA,eAAa;AAAA,MAAA;AAAA,IAAA;AAAA,EACf,EAAA,CACF,EACF,CAAA;AAEJ;"}
1
+ {"version":3,"file":"search.js","sources":["../../../src/components/commerce/search.tsx"],"sourcesContent":["import * as React from 'react'\nimport {createContext, useContext, useState, useCallback} from 'react'\n\nimport {SearchIcon, X} from 'lucide-react'\n\nimport {useProductSearch} from '../../hooks/product/useProductSearch'\nimport {cn} from '../../lib/utils'\nimport {type Product} from '../../types'\nimport {IconButton} from '../atoms/icon-button'\nimport {List} from '../atoms/list'\nimport {Input} from '../ui/input'\n\nimport {ProductLink} from './product-link'\nimport {ProductLinkSkeleton} from './product-link-skeleton'\n\nconst ESTIMATED_PRODUCT_LINK_HEIGHT = 100\n\ninterface SearchContextValue {\n query: string\n setQuery: (query: string) => void\n products: Product[] | null\n loading: boolean\n error: Error | null\n fetchMore?: () => Promise<void>\n hasNextPage: boolean\n isTyping: boolean\n}\n\nconst SearchContext = createContext<SearchContextValue | null>(null)\n\nfunction useSearchContext() {\n const context = useContext(SearchContext)\n if (!context) {\n throw new Error('useSearchContext must be used within a SearchProvider')\n }\n return context\n}\n\nexport interface SearchProviderProps {\n initialQuery?: string\n children: React.ReactNode\n}\n\nfunction SearchProvider({initialQuery = '', children}: SearchProviderProps) {\n const [query, setQueryState] = useState(initialQuery)\n\n const {products, loading, error, fetchMore, hasNextPage, isTyping} =\n useProductSearch({\n query,\n fetchPolicy: 'network-only',\n })\n\n const setQuery = useCallback((newQuery: string) => {\n setQueryState(newQuery)\n }, [])\n\n const contextValue: SearchContextValue = {\n query,\n setQuery,\n products,\n loading,\n error,\n fetchMore,\n hasNextPage,\n isTyping,\n }\n\n return (\n <SearchContext.Provider value={contextValue}>\n {children}\n </SearchContext.Provider>\n )\n}\n\nexport interface SearchInputProps {\n placeholder?: string\n className?: string\n inputProps?: React.ComponentProps<'input'>\n}\n\nfunction SearchInput({\n placeholder = 'Search products...',\n className,\n inputProps,\n}: SearchInputProps) {\n const {query, setQuery} = useSearchContext()\n\n const handleQueryChange = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n setQuery(event.target.value)\n inputProps?.onChange?.(event)\n },\n [inputProps, setQuery]\n )\n\n return (\n <div className=\"relative flex flex-1 items-center rounded-full pl-4 pr-2 py-1 bg-gray-100\">\n <div className=\"relative flex items-center\">\n <SearchIcon\n size={18}\n className={cn('text-accent-foreground opacity-60')}\n />\n </div>\n <div className=\"relative flex-1 flex items-center mx-2\">\n <Input\n name=\"search\"\n onChange={handleQueryChange}\n placeholder={placeholder}\n type=\"search\"\n role=\"searchbox\"\n autoComplete=\"off\"\n value={query}\n data-testid=\"search-input\"\n {...inputProps}\n className={cn(\n `w-full flex overflow-hidden rounded-radius-28 border-none py-4 px-0 text-text placeholder:text-text placeholder:opacity-60`,\n className\n )}\n />\n </div>\n <div className=\"relative flex items-center\">\n {query === '' ? null : (\n <IconButton\n Icon={X}\n size=\"sm\"\n filled={false}\n iconStyles=\"\"\n onClick={() => setQuery('')}\n buttonStyles=\"flex items-center rounded-radius-max bg-[var(--grayscale-l20)]\"\n />\n )}\n </div>\n </div>\n )\n}\n\nexport interface SearchResultsListProps {\n renderItem?: (product: Product, index: number) => React.ReactNode\n height?: number\n itemHeight?: number\n initialStateComponent?: React.JSX.Element\n showScrollbar?: boolean\n overscanCount?: number\n}\n\nfunction SearchResultsList({\n height = window.innerHeight,\n renderItem,\n itemHeight = ESTIMATED_PRODUCT_LINK_HEIGHT,\n initialStateComponent,\n showScrollbar,\n overscanCount = 5,\n}: SearchResultsListProps) {\n const {query, products, loading, fetchMore, hasNextPage, isTyping} =\n useSearchContext()\n\n const _renderItem = (product: Product, index: number) => {\n if (renderItem) {\n return renderItem(product, index)\n }\n\n return (\n <div className=\"p-2\">\n <ProductLink key={product.id} product={product} hideFavoriteAction />\n </div>\n )\n }\n\n const shouldShowStartingState = query.trim().length === 0\n const shouldShowLoading =\n (!products || products.length === 0) && (loading || isTyping)\n const shouldShowEmptyState = (!products || products.length === 0) && !loading\n\n if (shouldShowStartingState) {\n return (\n initialStateComponent || (\n <div className=\"flex items-center justify-center h-32 text-gray-500\">\n Start typing to search for products\n </div>\n )\n )\n }\n\n if (shouldShowLoading) {\n return (\n <div className=\"flex flex-col px-4 py-4\">\n <ProductLinkSkeleton className=\"mb-4\" />\n <ProductLinkSkeleton className=\"mb-4\" />\n <ProductLinkSkeleton className=\"mb-4\" />\n <ProductLinkSkeleton className=\"mb-4\" />\n </div>\n )\n }\n\n if (shouldShowEmptyState) {\n return (\n <div className=\"flex items-center justify-center h-32 text-gray-500\">\n {`No products found for \"${query}\"`}\n </div>\n )\n }\n\n return (\n <List\n items={products || []}\n height={height}\n renderItem={_renderItem}\n itemSizeForRow={() => itemHeight}\n fetchMore={hasNextPage ? fetchMore : undefined}\n showScrollbar={showScrollbar}\n overscanCount={overscanCount}\n />\n )\n}\n\ninterface SearchProviderPropsWithoutChildren\n extends Omit<SearchProviderProps, 'children'> {}\nexport interface SearchResultsProps\n extends SearchProviderPropsWithoutChildren,\n SearchInputProps,\n SearchResultsListProps {\n showSearchInput?: boolean\n onProductClick?: (product: Product) => void\n}\n\nfunction Search({\n initialQuery,\n placeholder,\n inputProps,\n height,\n className,\n renderItem,\n itemHeight,\n onProductClick,\n}: SearchResultsProps) {\n const _renderItem = (product: Product, index: number) => {\n if (renderItem) {\n return renderItem(product, index)\n }\n\n return (\n <div className=\"p-2\">\n <ProductLink\n key={product.id}\n product={product}\n hideFavoriteAction\n onClick={onProductClick}\n />\n </div>\n )\n }\n\n return (\n <SearchProvider initialQuery={initialQuery}>\n <div className={cn('flex flex-col ', className)}>\n <div className=\"fixed top-0 left-0 right-0 p-4 w-full z-20 bg-background\">\n <SearchInput placeholder={placeholder} inputProps={inputProps} />\n </div>\n <div className=\"h-14\" />\n <SearchResultsList\n height={height}\n renderItem={_renderItem}\n itemHeight={itemHeight}\n showScrollbar\n />\n </div>\n </SearchProvider>\n )\n}\n\nexport {SearchProvider, SearchInput, SearchResultsList, Search}\n"],"names":["ESTIMATED_PRODUCT_LINK_HEIGHT","SearchContext","createContext","useSearchContext","context","useContext","SearchProvider","initialQuery","children","query","setQueryState","useState","products","loading","error","fetchMore","hasNextPage","isTyping","useProductSearch","setQuery","useCallback","newQuery","contextValue","SearchInput","placeholder","className","inputProps","handleQueryChange","event","jsxs","jsx","SearchIcon","cn","Input","IconButton","X","SearchResultsList","height","renderItem","itemHeight","initialStateComponent","showScrollbar","overscanCount","_renderItem","product","index","ProductLink","shouldShowStartingState","shouldShowLoading","shouldShowEmptyState","ProductLinkSkeleton","List","Search","onProductClick"],"mappings":";;;;;;;;;;;AAeA,MAAMA,IAAgC,KAahCC,IAAgBC,EAAyC,IAAI;AAEnE,SAASC,IAAmB;AACpB,QAAAC,IAAUC,EAAWJ,CAAa;AACxC,MAAI,CAACG;AACG,UAAA,IAAI,MAAM,uDAA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DACb,4BAACP,GAAY,EAAA,aAAAC,GAA0B,YAAAE,GAAwB,EACjE,CAAA;AAAA,IACA,gBAAAI,EAAC,OAAI,EAAA,WAAU,OAAO,CAAA;AAAA,IACtB,gBAAAA;AAAA,MAACM;AAAA,MAAA;AAAA,QACC,QAAAC;AAAA,QACA,YAAYM;AAAA,QACZ,YAAAJ;AAAA,QACA,eAAa;AAAA,MAAA;AAAA,IAAA;AAAA,EACf,EAAA,CACF,EACF,CAAA;AAEJ;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useNavigateWithTransition.js","sources":["../../../src/hooks/navigation/useNavigateWithTransition.ts"],"sourcesContent":["import {useLocation, useNavigate, NavigateOptions} from 'react-router'\n\nimport {DATA_NAVIGATION_TYPE_ATTRIBUTE} from '../../types'\n\nexport function useNavigateWithTransition() {\n const navigate = useNavigate()\n const location = useLocation()\n\n const transitionNavigate = (\n to: string | number,\n options?: NavigateOptions\n ) => {\n if (typeof to === 'number') {\n // Delta navigation - no options parameter\n if (document.startViewTransition) {\n const transition = document.startViewTransition(() => {\n navigate(to)\n })\n\n transition.finished\n .then(() => {\n document.documentElement.removeAttribute(\n DATA_NAVIGATION_TYPE_ATTRIBUTE\n )\n })\n .catch(error => {\n console.error('View transition error:', error)\n })\n } else {\n return navigate(to)\n }\n return\n }\n\n const isSameRoute = to === location.pathname\n\n // Path navigation - with options\n if (document.startViewTransition) {\n const transition = document.startViewTransition(() => {\n navigate(to, {\n preventScrollReset: true,\n replace: isSameRoute,\n ...options,\n })\n })\n\n transition.finished\n .then(() => {\n document.documentElement.removeAttribute(\n DATA_NAVIGATION_TYPE_ATTRIBUTE\n )\n })\n .catch(error => {\n console.error('View transition error:', error)\n })\n } else {\n return navigate(to, options)\n }\n }\n\n return transitionNavigate\n}\n"],"names":["useNavigateWithTransition","navigate","useNavigate","location","useLocation","to","options","DATA_NAVIGATION_TYPE_ATTRIBUTE","error","isSameRoute"],"mappings":";;AAIO,SAASA,IAA4B;AAC1C,QAAMC,IAAWC,EAAY,GACvBC,IAAWC,EAAY;AAsDtB,SApDoB,CACzBC,GACAC,MACG;AACC,QAAA,OAAOD,KAAO,UAAU;AAE1B,UAAI,SAAS;AAKA,QAJQ,SAAS,oBAAoB,MAAM;AACpD,UAAAJ,EAASI,CAAE;AAAA,QAAA,CACZ,EAEU,SACR,KAAK,MAAM;AACV,mBAAS,gBAAgB;AAAA,YACvBE;AAAA,UACF;AAAA,QAAA,CACD,EACA,MAAM,CAASC,MAAA;AACN,kBAAA,MAAM,0BAA0BA,CAAK;AAAA,QAAA,CAC9C;AAAA;AAEH,eAAOP,EAASI,CAAE;AAEpB;AAAA,IAAA;AAGI,UAAAI,IAAcJ,MAAOF,EAAS;AAGpC,QAAI,SAAS;AASA,MARQ,SAAS,oBAAoB,MAAM;AACpD,QAAAF,EAASI,GAAI;AAAA,UACX,oBAAoB;AAAA,UACpB,SAASI;AAAA,UACT,GAAGH;AAAA,QAAA,CACJ;AAAA,MAAA,CACF,EAEU,SACR,KAAK,MAAM;AACV,iBAAS,gBAAgB;AAAA,UACvBC;AAAA,QACF;AAAA,MAAA,CACD,EACA,MAAM,CAASC,MAAA;AACN,gBAAA,MAAM,0BAA0BA,CAAK;AAAA,MAAA,CAC9C;AAAA;AAEI,aAAAP,EAASI,GAAIC,CAAO;AAAA,EAE/B;AAGF;"}
1
+ {"version":3,"file":"useNavigateWithTransition.js","sources":["../../../src/hooks/navigation/useNavigateWithTransition.ts"],"sourcesContent":["import {useLocation, useNavigate, NavigateOptions} from 'react-router'\n\nimport {DATA_NAVIGATION_TYPE_ATTRIBUTE} from '../../types'\n\ntype UseNavigateWithTransitionReturns = (\n to: string | number,\n options?: NavigateOptions\n) => void | Promise<void>\n\nexport function useNavigateWithTransition(): UseNavigateWithTransitionReturns {\n const navigate = useNavigate()\n const location = useLocation()\n\n const transitionNavigate = (\n to: string | number,\n options?: NavigateOptions\n ) => {\n if (typeof to === 'number') {\n // Delta navigation - no options parameter\n if (document.startViewTransition) {\n const transition = document.startViewTransition(() => {\n navigate(to)\n })\n\n transition.finished\n .then(() => {\n document.documentElement.removeAttribute(\n DATA_NAVIGATION_TYPE_ATTRIBUTE\n )\n })\n .catch(error => {\n console.error('View transition error:', error)\n })\n } else {\n return navigate(to)\n }\n return\n }\n\n const isSameRoute = to === location.pathname\n\n // Path navigation - with options\n if (document.startViewTransition) {\n const transition = document.startViewTransition(() => {\n navigate(to, {\n preventScrollReset: true,\n replace: isSameRoute,\n ...options,\n })\n })\n\n transition.finished\n .then(() => {\n document.documentElement.removeAttribute(\n DATA_NAVIGATION_TYPE_ATTRIBUTE\n )\n })\n .catch(error => {\n console.error('View transition error:', error)\n })\n } else {\n return navigate(to, options)\n }\n }\n\n return transitionNavigate\n}\n"],"names":["useNavigateWithTransition","navigate","useNavigate","location","useLocation","to","options","DATA_NAVIGATION_TYPE_ATTRIBUTE","error","isSameRoute"],"mappings":";;AASO,SAASA,IAA8D;AAC5E,QAAMC,IAAWC,EAAY,GACvBC,IAAWC,EAAY;AAsDtB,SApDoB,CACzBC,GACAC,MACG;AACC,QAAA,OAAOD,KAAO,UAAU;AAE1B,UAAI,SAAS;AAKA,QAJQ,SAAS,oBAAoB,MAAM;AACpD,UAAAJ,EAASI,CAAE;AAAA,QAAA,CACZ,EAEU,SACR,KAAK,MAAM;AACV,mBAAS,gBAAgB;AAAA,YACvBE;AAAA,UACF;AAAA,QAAA,CACD,EACA,MAAM,CAASC,MAAA;AACN,kBAAA,MAAM,0BAA0BA,CAAK;AAAA,QAAA,CAC9C;AAAA;AAEH,eAAOP,EAASI,CAAE;AAEpB;AAAA,IAAA;AAGI,UAAAI,IAAcJ,MAAOF,EAAS;AAGpC,QAAI,SAAS;AASA,MARQ,SAAS,oBAAoB,MAAM;AACpD,QAAAF,EAASI,GAAI;AAAA,UACX,oBAAoB;AAAA,UACpB,SAASI;AAAA,UACT,GAAGH;AAAA,QAAA,CACJ;AAAA,MAAA,CACF,EAEU,SACR,KAAK,MAAM;AACV,iBAAS,gBAAgB;AAAA,UACvBC;AAAA,QACF;AAAA,MAAA,CACD,EACA,MAAM,CAASC,MAAA;AACN,gBAAA,MAAM,0BAA0BA,CAAK;AAAA,MAAA,CAC9C;AAAA;AAEI,aAAAP,EAASI,GAAIC,CAAO;AAAA,EAE/B;AAGF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useShopNavigation.js","sources":["../../../src/hooks/navigation/useShopNavigation.ts"],"sourcesContent":["import {\n NavigateToCheckoutParams,\n NavigateToOrderParams,\n NavigateToProductParams,\n NavigateToShopParams,\n} from '@shopify/shop-minis-platform/actions'\n\nimport {useHandleAction} from '../../internal/useHandleAction'\nimport {useShopActions} from '../../internal/useShopActions'\n\ninterface UseShopNavigationReturns {\n /**\n * Navigates to a product.\n */\n navigateToProduct: (params: NavigateToProductParams) => Promise<void>\n /**\n * Navigates to a shop.\n */\n navigateToShop: (params: NavigateToShopParams) => Promise<void>\n /**\n * Navigates to an order.\n */\n navigateToOrder: (params: NavigateToOrderParams) => Promise<void>\n\n navigateToCheckout: (params: NavigateToCheckoutParams) => Promise<void>\n}\n\nexport const useShopNavigation = (): UseShopNavigationReturns => {\n const {\n navigateToProduct,\n navigateToShop,\n navigateToOrder,\n navigateToCheckout,\n } = useShopActions()\n\n return {\n navigateToProduct: useHandleAction(navigateToProduct),\n navigateToShop: useHandleAction(navigateToShop),\n navigateToOrder: useHandleAction(navigateToOrder),\n navigateToCheckout: useHandleAction(navigateToCheckout),\n }\n}\n"],"names":["useShopNavigation","navigateToProduct","navigateToShop","navigateToOrder","navigateToCheckout","useShopActions","useHandleAction"],"mappings":";;AA2BO,MAAMA,IAAoB,MAAgC;AACzD,QAAA;AAAA,IACJ,mBAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,oBAAAC;AAAA,MACEC,EAAe;AAEZ,SAAA;AAAA,IACL,mBAAmBC,EAAgBL,CAAiB;AAAA,IACpD,gBAAgBK,EAAgBJ,CAAc;AAAA,IAC9C,iBAAiBI,EAAgBH,CAAe;AAAA,IAChD,oBAAoBG,EAAgBF,CAAkB;AAAA,EACxD;AACF;"}
1
+ {"version":3,"file":"useShopNavigation.js","sources":["../../../src/hooks/navigation/useShopNavigation.ts"],"sourcesContent":["import {\n NavigateToCheckoutParams,\n NavigateToOrderParams,\n NavigateToProductParams,\n NavigateToShopParams,\n} from '@shopify/shop-minis-platform/actions'\n\nimport {useHandleAction} from '../../internal/useHandleAction'\nimport {useShopActions} from '../../internal/useShopActions'\n\ninterface UseShopNavigationReturns {\n /**\n * Navigates to a product.\n */\n navigateToProduct: (params: NavigateToProductParams) => Promise<void>\n /**\n * Navigates to a shop.\n */\n navigateToShop: (params: NavigateToShopParams) => Promise<void>\n /**\n * Navigates to an order.\n */\n navigateToOrder: (params: NavigateToOrderParams) => Promise<void>\n /**\n * Navigates to a checkout.\n */\n navigateToCheckout: (params: NavigateToCheckoutParams) => Promise<void>\n}\n\nexport const useShopNavigation = (): UseShopNavigationReturns => {\n const {\n navigateToProduct,\n navigateToShop,\n navigateToOrder,\n navigateToCheckout,\n } = useShopActions()\n\n return {\n navigateToProduct: useHandleAction(navigateToProduct),\n navigateToShop: useHandleAction(navigateToShop),\n navigateToOrder: useHandleAction(navigateToOrder),\n navigateToCheckout: useHandleAction(navigateToCheckout),\n }\n}\n"],"names":["useShopNavigation","navigateToProduct","navigateToShop","navigateToOrder","navigateToCheckout","useShopActions","useHandleAction"],"mappings":";;AA6BO,MAAMA,IAAoB,MAAgC;AACzD,QAAA;AAAA,IACJ,mBAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,oBAAAC;AAAA,MACEC,EAAe;AAEZ,SAAA;AAAA,IACL,mBAAmBC,EAAgBL,CAAiB;AAAA,IACpD,gBAAgBK,EAAgBJ,CAAc;AAAA,IAC9C,iBAAiBI,EAAgBH,CAAe;AAAA,IAChD,oBAAoBG,EAAgBF,CAAkB;AAAA,EACxD;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useCurrentUser.js","sources":["../../../src/hooks/user/useCurrentUser.ts"],"sourcesContent":["import {useShopActions} from '../../internal/useShopActions'\nimport {useShopActionsDataFetching} from '../../internal/useShopActionsDataFetching'\nimport {\n DataHookOptionsBase,\n DataHookReturnsBase,\n UserProfile,\n} from '../../types'\n\nexport interface UseCurrentUserParams extends DataHookOptionsBase {}\n\nexport interface UseCurrentUserReturns extends DataHookReturnsBase {\n currentUser: UserProfile | null\n}\n\n/**\n * Hook to fetch the current user's profile.\n */\nexport const useCurrentUser = (\n params?: UseCurrentUserParams\n): UseCurrentUserReturns => {\n const {skip, ...shopActionParams} = params || {}\n const {getCurrentUser} = useShopActions()\n\n const {data, ...rest} = useShopActionsDataFetching(\n getCurrentUser,\n shopActionParams,\n {\n skip,\n hook: 'useCurrentUser',\n }\n )\n\n return {\n ...rest,\n currentUser: data,\n }\n}\n"],"names":["useCurrentUser","params","skip","shopActionParams","getCurrentUser","useShopActions","data","rest","useShopActionsDataFetching"],"mappings":";;AAiBa,MAAAA,IAAiB,CAC5BC,MAC0B;AAC1B,QAAM,EAAC,MAAAC,GAAM,GAAGC,EAAgB,IAAIF,KAAU,CAAC,GACzC,EAAC,gBAAAG,EAAc,IAAIC,EAAe,GAElC,EAAC,MAAAC,GAAM,GAAGC,EAAA,IAAQC;AAAA,IACtBJ;AAAA,IACAD;AAAA,IACA;AAAA,MACE,MAAAD;AAAA,MACA,MAAM;AAAA,IAAA;AAAA,EAEV;AAEO,SAAA;AAAA,IACL,GAAGK;AAAA,IACH,aAAaD;AAAA,EACf;AACF;"}
1
+ {"version":3,"file":"useCurrentUser.js","sources":["../../../src/hooks/user/useCurrentUser.ts"],"sourcesContent":["import {useShopActions} from '../../internal/useShopActions'\nimport {useShopActionsDataFetching} from '../../internal/useShopActionsDataFetching'\nimport {\n DataHookOptionsBase,\n DataHookReturnsBase,\n UserProfile,\n} from '../../types'\n\nexport interface UseCurrentUserParams extends DataHookOptionsBase {}\n\nexport interface UseCurrentUserReturns extends DataHookReturnsBase {\n /**\n * The current user logged into Shop.\n */\n currentUser: UserProfile | null\n}\n\n/**\n * Hook to fetch the current user's profile.\n */\nexport const useCurrentUser = (\n params?: UseCurrentUserParams\n): UseCurrentUserReturns => {\n const {skip, ...shopActionParams} = params || {}\n const {getCurrentUser} = useShopActions()\n\n const {data, ...rest} = useShopActionsDataFetching(\n getCurrentUser,\n shopActionParams,\n {\n skip,\n hook: 'useCurrentUser',\n }\n )\n\n return {\n ...rest,\n currentUser: data,\n }\n}\n"],"names":["useCurrentUser","params","skip","shopActionParams","getCurrentUser","useShopActions","data","rest","useShopActionsDataFetching"],"mappings":";;AAoBa,MAAAA,IAAiB,CAC5BC,MAC0B;AAC1B,QAAM,EAAC,MAAAC,GAAM,GAAGC,EAAgB,IAAIF,KAAU,CAAC,GACzC,EAAC,gBAAAG,EAAc,IAAIC,EAAe,GAElC,EAAC,MAAAC,GAAM,GAAGC,EAAA,IAAQC;AAAA,IACtBJ;AAAA,IACAD;AAAA,IACA;AAAA,MACE,MAAAD;AAAA,MACA,MAAM;AAAA,IAAA;AAAA,EAEV;AAEO,SAAA;AAAA,IACL,GAAGK;AAAA,IACH,aAAaD;AAAA,EACf;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useFollowedShopsActions.js","sources":["../../../src/hooks/user/useFollowedShopsActions.ts"],"sourcesContent":["import {\n FollowShopParams,\n UnfollowShopParams,\n} from '@shopify/shop-minis-platform/actions'\n\nimport {useHandleAction} from '../../internal/useHandleAction'\nimport {useShopActions} from '../../internal/useShopActions'\n\ninterface UseFollowedShopsActionsReturns {\n /**\n * Follow a shop.\n */\n followShop: (params: FollowShopParams) => Promise<boolean>\n /**\n * Unfollow a shop.\n */\n unfollowShop: (params: UnfollowShopParams) => Promise<boolean>\n}\n\nexport const useFollowedShopsActions = (): UseFollowedShopsActionsReturns => {\n const {followShop, unfollowShop} = useShopActions()\n\n return {\n followShop: useHandleAction(followShop),\n unfollowShop: useHandleAction(unfollowShop),\n }\n}\n"],"names":["useFollowedShopsActions","followShop","unfollowShop","useShopActions","useHandleAction"],"mappings":";;AAmBO,MAAMA,IAA0B,MAAsC;AAC3E,QAAM,EAAC,YAAAC,GAAY,cAAAC,EAAY,IAAIC,EAAe;AAE3C,SAAA;AAAA,IACL,YAAYC,EAAgBH,CAAU;AAAA,IACtC,cAAcG,EAAgBF,CAAY;AAAA,EAC5C;AACF;"}
1
+ {"version":3,"file":"useFollowedShopsActions.js","sources":["../../../src/hooks/user/useFollowedShopsActions.ts"],"sourcesContent":["import {\n FollowShopParams,\n UnfollowShopParams,\n} from '@shopify/shop-minis-platform/actions'\n\nimport {useHandleAction} from '../../internal/useHandleAction'\nimport {useShopActions} from '../../internal/useShopActions'\n\ninterface UseFollowedShopsActionsReturns {\n /**\n * Follows a shop.\n */\n followShop: (params: FollowShopParams) => Promise<boolean>\n /**\n * Unfollows a shop.\n */\n unfollowShop: (params: UnfollowShopParams) => Promise<boolean>\n}\n\nexport const useFollowedShopsActions = (): UseFollowedShopsActionsReturns => {\n const {followShop, unfollowShop} = useShopActions()\n\n return {\n followShop: useHandleAction(followShop),\n unfollowShop: useHandleAction(unfollowShop),\n }\n}\n"],"names":["useFollowedShopsActions","followShop","unfollowShop","useShopActions","useHandleAction"],"mappings":";;AAmBO,MAAMA,IAA0B,MAAsC;AAC3E,QAAM,EAAC,YAAAC,GAAY,cAAAC,EAAY,IAAIC,EAAe;AAE3C,SAAA;AAAA,IACL,YAAYC,EAAgBH,CAAU;AAAA,IACtC,cAAcG,EAAgBF,CAAY;AAAA,EAC5C;AACF;"}
@@ -0,0 +1,12 @@
1
+ import { useHandleAction as n } from "../../internal/useHandleAction.js";
2
+ import { useShopActions as o } from "../../internal/useShopActions.js";
3
+ function s() {
4
+ const { generateUserToken: e } = o();
5
+ return {
6
+ generateUserToken: n(e)
7
+ };
8
+ }
9
+ export {
10
+ s as useGenerateUserToken
11
+ };
12
+ //# sourceMappingURL=useGenerateUserToken.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useGenerateUserToken.js","sources":["../../../src/hooks/user/useGenerateUserToken.ts"],"sourcesContent":["import {\n GeneratedTokenData,\n UserTokenGenerateUserErrors,\n} from '@shopify/shop-minis-platform'\n\nimport {useHandleAction} from '../../internal/useHandleAction'\nimport {useShopActions} from '../../internal/useShopActions'\n\ninterface UseGenerateUserTokenReturns {\n /**\n * Generates a temporary token for the user.\n */\n generateUserToken: () => Promise<{\n data: GeneratedTokenData\n userErrors?: UserTokenGenerateUserErrors[]\n }>\n}\n\nexport function useGenerateUserToken(): UseGenerateUserTokenReturns {\n const {generateUserToken} = useShopActions()\n\n return {\n generateUserToken: useHandleAction(generateUserToken),\n }\n}\n"],"names":["useGenerateUserToken","generateUserToken","useShopActions","useHandleAction"],"mappings":";;AAkBO,SAASA,IAAoD;AAC5D,QAAA,EAAC,mBAAAC,EAAiB,IAAIC,EAAe;AAEpC,SAAA;AAAA,IACL,mBAAmBC,EAAgBF,CAAiB;AAAA,EACtD;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useImagePicker.js","sources":["../../../src/hooks/util/useImagePicker.tsx"],"sourcesContent":["import {\n CameraFacing,\n useImagePickerContext,\n} from '../../providers/ImagePickerProvider'\n\ninterface UseImagePickerReturn {\n openCamera: (cameraFacing?: CameraFacing) => Promise<File>\n openGallery: () => Promise<File>\n}\n\nexport function useImagePicker(): UseImagePickerReturn {\n const {openCamera, openGallery} = useImagePickerContext()\n\n return {\n openCamera,\n openGallery,\n }\n}\n"],"names":["useImagePicker","openCamera","openGallery","useImagePickerContext"],"mappings":";AAUO,SAASA,IAAuC;AACrD,QAAM,EAAC,YAAAC,GAAY,aAAAC,EAAW,IAAIC,EAAsB;AAEjD,SAAA;AAAA,IACL,YAAAF;AAAA,IACA,aAAAC;AAAA,EACF;AACF;"}
1
+ {"version":3,"file":"useImagePicker.js","sources":["../../../src/hooks/util/useImagePicker.ts"],"sourcesContent":["import {\n CameraFacing,\n useImagePickerContext,\n} from '../../providers/ImagePickerProvider'\n\ninterface UseImagePickerReturns {\n /**\n * Opens the camera to take a photo.\n */\n openCamera: (cameraFacing?: CameraFacing) => Promise<File>\n /**\n * Opens the gallery to select an image.\n */\n openGallery: () => Promise<File>\n}\n\nexport function useImagePicker(): UseImagePickerReturns {\n const {openCamera, openGallery} = useImagePickerContext()\n\n return {\n openCamera,\n openGallery,\n }\n}\n"],"names":["useImagePicker","openCamera","openGallery","useImagePickerContext"],"mappings":";AAgBO,SAASA,IAAwC;AACtD,QAAM,EAAC,YAAAC,GAAY,aAAAC,EAAW,IAAIC,EAAsB;AAEjD,SAAA;AAAA,IACL,YAAAF;AAAA,IACA,aAAAC;AAAA,EACF;AACF;"}
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { DATA_NAVIGATION_TYPE_ATTRIBUTE as o, NAVIGATION_TYPES as t } from "./types/index.js";
2
2
  import { MinisContainer as p } from "./components/MinisContainer.js";
3
- import { ProductCard as l } from "./components/commerce/product-card.js";
3
+ import { ProductCard as m } from "./components/commerce/product-card.js";
4
4
  import { ProductLink as s } from "./components/commerce/product-link.js";
5
5
  import { MerchantCard as f, MerchantCardPrimitive as x } from "./components/commerce/merchant-card.js";
6
6
  import { ProductCardSkeleton as c } from "./components/commerce/product-card-skeleton.js";
@@ -10,10 +10,10 @@ import { Search as A, SearchInput as P, SearchProvider as h, SearchResultsList a
10
10
  import { ImageContentWrapper as v } from "./components/content/image-content-wrapper.js";
11
11
  import { MinisRouter as R } from "./components/navigation/minis-router.js";
12
12
  import { TransitionLink as E } from "./components/navigation/transition-link.js";
13
- import { Button as k } from "./components/atoms/button.js";
14
- import { FavoriteButton as L } from "./components/atoms/favorite-button.js";
15
- import { IconButton as N } from "./components/atoms/icon-button.js";
16
- import { ThumbhashImage as U } from "./components/atoms/thumbhash-image.js";
13
+ import { Button as F } from "./components/atoms/button.js";
14
+ import { FavoriteButton as B } from "./components/atoms/favorite-button.js";
15
+ import { IconButton as M } from "./components/atoms/icon-button.js";
16
+ import { ThumbhashImage as y } from "./components/atoms/thumbhash-image.js";
17
17
  import { Touchable as H } from "./components/atoms/touchable.js";
18
18
  import { LongPressDetector as V } from "./components/atoms/long-press-detector.js";
19
19
  import { AlertDialogAtom as _ } from "./components/atoms/alert-dialog.js";
@@ -21,23 +21,23 @@ import { List as Y } from "./components/atoms/list.js";
21
21
  import { VideoPlayer as j } from "./components/atoms/video-player.js";
22
22
  import { Accordion as J, AccordionContent as K, AccordionItem as X, AccordionTrigger as Z } from "./components/ui/accordion.js";
23
23
  import { Alert as rr, AlertDescription as er, AlertTitle as or } from "./components/ui/alert.js";
24
- import { AlertDialog as ar, AlertDialogAction as pr, AlertDialogCancel as ir, AlertDialogContent as lr, AlertDialogDescription as mr, AlertDialogFooter as sr, AlertDialogHeader as nr, AlertDialogOverlay as fr, AlertDialogPortal as xr, AlertDialogTitle as ur, AlertDialogTrigger as cr } from "./components/ui/alert-dialog.js";
24
+ import { AlertDialog as ar, AlertDialogAction as pr, AlertDialogCancel as ir, AlertDialogContent as mr, AlertDialogDescription as lr, AlertDialogFooter as sr, AlertDialogHeader as nr, AlertDialogOverlay as fr, AlertDialogPortal as xr, AlertDialogTitle as ur, AlertDialogTrigger as cr } from "./components/ui/alert-dialog.js";
25
25
  import { Avatar as gr, AvatarFallback as Sr, AvatarImage as Cr } from "./components/ui/avatar.js";
26
26
  import { Badge as Ar, badgeVariants as Pr } from "./components/ui/badge.js";
27
- import { Card as Tr, CardAction as Ir, CardContent as vr, CardDescription as wr, CardFooter as Rr, CardHeader as br, CardTitle as Er } from "./components/ui/card.js";
28
- import { Carousel as kr, CarouselContent as Br, CarouselItem as Lr, CarouselNext as Mr, CarouselPrevious as Nr } from "./components/ui/carousel.js";
29
- import { Checkbox as Ur } from "./components/ui/checkbox.js";
27
+ import { Card as Tr, CardAction as Ir, CardContent as vr, CardDescription as wr, CardFooter as Rr, CardHeader as kr, CardTitle as Er } from "./components/ui/card.js";
28
+ import { Carousel as Fr, CarouselContent as Ur, CarouselItem as Br, CarouselNext as Lr, CarouselPrevious as Mr } from "./components/ui/carousel.js";
29
+ import { Checkbox as yr } from "./components/ui/checkbox.js";
30
30
  import { Dialog as Hr, DialogClose as Or, DialogContent as Vr, DialogDescription as zr, DialogFooter as _r, DialogHeader as Wr, DialogOverlay as Yr, DialogPortal as Qr, DialogTitle as jr, DialogTrigger as qr } from "./components/ui/dialog.js";
31
31
  import { Drawer as Kr, DrawerClose as Xr, DrawerContent as Zr, DrawerDescription as $r, DrawerFooter as re, DrawerHeader as ee, DrawerOverlay as oe, DrawerPortal as te, DrawerTitle as ae, DrawerTrigger as pe } from "./components/ui/drawer.js";
32
- import { Input as le } from "./components/ui/input.js";
32
+ import { Input as me } from "./components/ui/input.js";
33
33
  import { Label as se } from "./components/ui/label.js";
34
34
  import { Progress as fe } from "./components/ui/progress.js";
35
35
  import { RadioGroup as ue, RadioGroupItem as ce } from "./components/ui/radio-group.js";
36
36
  import { ResizableHandle as ge, ResizablePanel as Se, ResizablePanelGroup as Ce } from "./components/ui/resizable.js";
37
37
  import { ScrollArea as Ae, ScrollBar as Pe } from "./components/ui/scroll-area.js";
38
- import { Select as Te, SelectContent as Ie, SelectGroup as ve, SelectItem as we, SelectLabel as Re, SelectScrollDownButton as be, SelectScrollUpButton as Ee, SelectSeparator as Fe, SelectTrigger as ke, SelectValue as Be } from "./components/ui/select.js";
39
- import { Separator as Me } from "./components/ui/separator.js";
40
- import { Sheet as ye, SheetClose as Ue, SheetContent as Ge, SheetDescription as He, SheetFooter as Oe, SheetHeader as Ve, SheetTitle as ze, SheetTrigger as _e } from "./components/ui/sheet.js";
38
+ import { Select as Te, SelectContent as Ie, SelectGroup as ve, SelectItem as we, SelectLabel as Re, SelectScrollDownButton as ke, SelectScrollUpButton as Ee, SelectSeparator as be, SelectTrigger as Fe, SelectValue as Ue } from "./components/ui/select.js";
39
+ import { Separator as Le } from "./components/ui/separator.js";
40
+ import { Sheet as Ne, SheetClose as ye, SheetContent as Ge, SheetDescription as He, SheetFooter as Oe, SheetHeader as Ve, SheetTitle as ze, SheetTrigger as _e } from "./components/ui/sheet.js";
41
41
  import { Toaster as Ye } from "./components/ui/sonner.js";
42
42
  import { Skeleton as je } from "./components/ui/skeleton.js";
43
43
  import { useRecentProducts as Je } from "./hooks/user/useRecentProducts.js";
@@ -46,41 +46,43 @@ import { useSavedProducts as $e } from "./hooks/user/useSavedProducts.js";
46
46
  import { useSavedProductsActions as eo } from "./hooks/user/useSavedProductsActions.js";
47
47
  import { useFollowedShops as to } from "./hooks/user/useFollowedShops.js";
48
48
  import { useFollowedShopsActions as po } from "./hooks/user/useFollowedShopsActions.js";
49
- import { useCurrentUser as lo } from "./hooks/user/useCurrentUser.js";
49
+ import { useCurrentUser as mo } from "./hooks/user/useCurrentUser.js";
50
50
  import { useOrders as so } from "./hooks/user/useOrders.js";
51
51
  import { useBuyerAttributes as fo } from "./hooks/user/useBuyerAttributes.js";
52
- import { useProductListActions as uo } from "./hooks/product/useProductListActions.js";
53
- import { useProductLists as go } from "./hooks/product/useProductLists.js";
54
- import { useProductList as Co } from "./hooks/product/useProductList.js";
55
- import { useProduct as Ao } from "./hooks/product/useProduct.js";
56
- import { useProducts as ho } from "./hooks/product/useProducts.js";
57
- import { useProductVariants as Io } from "./hooks/product/useProductVariants.js";
58
- import { useProductMedia as wo } from "./hooks/product/useProductMedia.js";
52
+ import { useGenerateUserToken as uo } from "./hooks/user/useGenerateUserToken.js";
53
+ import { useProductListActions as go } from "./hooks/product/useProductListActions.js";
54
+ import { useProductLists as Co } from "./hooks/product/useProductLists.js";
55
+ import { useProductList as Ao } from "./hooks/product/useProductList.js";
56
+ import { useProduct as ho } from "./hooks/product/useProduct.js";
57
+ import { useProducts as Io } from "./hooks/product/useProducts.js";
58
+ import { useProductVariants as wo } from "./hooks/product/useProductVariants.js";
59
+ import { useProductMedia as ko } from "./hooks/product/useProductMedia.js";
59
60
  import { useProductSearch as bo } from "./hooks/product/useProductSearch.js";
60
- import { useRecommendedProducts as Fo } from "./hooks/product/useRecommendedProducts.js";
61
- import { usePopularProducts as Bo } from "./hooks/product/usePopularProducts.js";
62
- import { useCuratedProducts as Mo } from "./hooks/product/useCuratedProducts.js";
63
- import { useAsyncStorage as yo } from "./hooks/storage/useAsyncStorage.js";
64
- import { useSecureStorage as Go } from "./hooks/storage/useSecureStorage.js";
65
- import { useImageUpload as Oo } from "./hooks/storage/useImageUpload.js";
66
- import { useShopNavigation as zo } from "./hooks/navigation/useShopNavigation.js";
67
- import { useCloseMini as Wo } from "./hooks/navigation/useCloseMini.js";
68
- import { useDeeplink as Qo } from "./hooks/navigation/useDeeplink.js";
69
- import { useNavigateWithTransition as qo } from "./hooks/navigation/useNavigateWithTransition.js";
70
- import { useShop as Ko } from "./hooks/shop/useShop.js";
71
- import { useShopCartActions as Zo } from "./hooks/shop/useShopCartActions.js";
72
- import { useRecommendedShops as rt } from "./hooks/shop/useRecommendedShops.js";
73
- import { useCreateImageContent as ot } from "./hooks/content/useCreateImageContent.js";
74
- import { useErrorToast as at } from "./hooks/util/useErrorToast.js";
75
- import { useErrorScreen as it } from "./hooks/util/useErrorScreen.js";
76
- import { useShare as mt } from "./hooks/util/useShare.js";
77
- import { useImagePicker as nt } from "./hooks/util/useImagePicker.js";
78
- import { MiniEntityNotFoundError as xt, MiniError as ut, MiniNetworkError as ct, formatError as dt } from "./utils/errors.js";
79
- import { extractBrandTheme as St, formatReviewCount as Ct, getFeaturedImages as Dt, normalizeRating as At } from "./utils/merchant-card.js";
80
- import { parseUrl as ht } from "./utils/parseUrl.js";
81
- import { fileToDataUri as It } from "./utils/imageToDataUri.js";
82
- import { ContentCreateUserErrorCode as wt } from "./shop-minis-platform/src/types/content.js";
83
- import { Consent as bt, ConsentStatus as Et } from "./shop-minis-platform/src/types/permissions.js";
61
+ import { useRecommendedProducts as Uo } from "./hooks/product/useRecommendedProducts.js";
62
+ import { usePopularProducts as Lo } from "./hooks/product/usePopularProducts.js";
63
+ import { useCuratedProducts as No } from "./hooks/product/useCuratedProducts.js";
64
+ import { useAsyncStorage as Go } from "./hooks/storage/useAsyncStorage.js";
65
+ import { useSecureStorage as Oo } from "./hooks/storage/useSecureStorage.js";
66
+ import { useImageUpload as zo } from "./hooks/storage/useImageUpload.js";
67
+ import { useShopNavigation as Wo } from "./hooks/navigation/useShopNavigation.js";
68
+ import { useCloseMini as Qo } from "./hooks/navigation/useCloseMini.js";
69
+ import { useDeeplink as qo } from "./hooks/navigation/useDeeplink.js";
70
+ import { useNavigateWithTransition as Ko } from "./hooks/navigation/useNavigateWithTransition.js";
71
+ import { useShop as Zo } from "./hooks/shop/useShop.js";
72
+ import { useShopCartActions as rt } from "./hooks/shop/useShopCartActions.js";
73
+ import { useRecommendedShops as ot } from "./hooks/shop/useRecommendedShops.js";
74
+ import { useCreateImageContent as at } from "./hooks/content/useCreateImageContent.js";
75
+ import { useErrorToast as it } from "./hooks/util/useErrorToast.js";
76
+ import { useErrorScreen as lt } from "./hooks/util/useErrorScreen.js";
77
+ import { useShare as nt } from "./hooks/util/useShare.js";
78
+ import { useImagePicker as xt } from "./hooks/util/useImagePicker.js";
79
+ import { MiniEntityNotFoundError as ct, MiniError as dt, MiniNetworkError as gt, formatError as St } from "./utils/errors.js";
80
+ import { extractBrandTheme as Dt, formatReviewCount as At, getFeaturedImages as Pt, normalizeRating as ht } from "./utils/merchant-card.js";
81
+ import { parseUrl as It } from "./utils/parseUrl.js";
82
+ import { fileToDataUri as wt } from "./utils/imageToDataUri.js";
83
+ import { UserState as kt, UserTokenGenerateUserErrorCode as Et } from "./shop-minis-platform/src/types/user.js";
84
+ import { ContentCreateUserErrorCode as Ft } from "./shop-minis-platform/src/types/content.js";
85
+ import { Consent as Bt, ConsentStatus as Lt } from "./shop-minis-platform/src/types/permissions.js";
84
86
  export {
85
87
  J as Accordion,
86
88
  K as AccordionContent,
@@ -92,8 +94,8 @@ export {
92
94
  pr as AlertDialogAction,
93
95
  _ as AlertDialogAtom,
94
96
  ir as AlertDialogCancel,
95
- lr as AlertDialogContent,
96
- mr as AlertDialogDescription,
97
+ mr as AlertDialogContent,
98
+ lr as AlertDialogDescription,
97
99
  sr as AlertDialogFooter,
98
100
  nr as AlertDialogHeader,
99
101
  fr as AlertDialogOverlay,
@@ -105,23 +107,23 @@ export {
105
107
  Sr as AvatarFallback,
106
108
  Cr as AvatarImage,
107
109
  Ar as Badge,
108
- k as Button,
110
+ F as Button,
109
111
  Tr as Card,
110
112
  Ir as CardAction,
111
113
  vr as CardContent,
112
114
  wr as CardDescription,
113
115
  Rr as CardFooter,
114
- br as CardHeader,
116
+ kr as CardHeader,
115
117
  Er as CardTitle,
116
- kr as Carousel,
117
- Br as CarouselContent,
118
- Lr as CarouselItem,
119
- Mr as CarouselNext,
120
- Nr as CarouselPrevious,
121
- Ur as Checkbox,
122
- bt as Consent,
123
- Et as ConsentStatus,
124
- wt as ContentCreateUserErrorCode,
118
+ Fr as Carousel,
119
+ Ur as CarouselContent,
120
+ Br as CarouselItem,
121
+ Lr as CarouselNext,
122
+ Mr as CarouselPrevious,
123
+ yr as Checkbox,
124
+ Bt as Consent,
125
+ Lt as ConsentStatus,
126
+ Ft as ContentCreateUserErrorCode,
125
127
  o as DATA_NAVIGATION_TYPE_ATTRIBUTE,
126
128
  Hr as Dialog,
127
129
  Or as DialogClose,
@@ -143,23 +145,23 @@ export {
143
145
  te as DrawerPortal,
144
146
  ae as DrawerTitle,
145
147
  pe as DrawerTrigger,
146
- L as FavoriteButton,
147
- N as IconButton,
148
+ B as FavoriteButton,
149
+ M as IconButton,
148
150
  v as ImageContentWrapper,
149
- le as Input,
151
+ me as Input,
150
152
  se as Label,
151
153
  Y as List,
152
154
  V as LongPressDetector,
153
155
  f as MerchantCard,
154
156
  x as MerchantCardPrimitive,
155
157
  g as MerchantCardSkeleton,
156
- xt as MiniEntityNotFoundError,
157
- ut as MiniError,
158
- ct as MiniNetworkError,
158
+ ct as MiniEntityNotFoundError,
159
+ dt as MiniError,
160
+ gt as MiniNetworkError,
159
161
  p as MinisContainer,
160
162
  R as MinisRouter,
161
163
  t as NAVIGATION_TYPES,
162
- l as ProductCard,
164
+ m as ProductCard,
163
165
  c as ProductCardSkeleton,
164
166
  s as ProductLink,
165
167
  fe as Progress,
@@ -180,14 +182,14 @@ export {
180
182
  ve as SelectGroup,
181
183
  we as SelectItem,
182
184
  Re as SelectLabel,
183
- be as SelectScrollDownButton,
185
+ ke as SelectScrollDownButton,
184
186
  Ee as SelectScrollUpButton,
185
- Fe as SelectSeparator,
186
- ke as SelectTrigger,
187
- Be as SelectValue,
188
- Me as Separator,
189
- ye as Sheet,
190
- Ue as SheetClose,
187
+ be as SelectSeparator,
188
+ Fe as SelectTrigger,
189
+ Ue as SelectValue,
190
+ Le as Separator,
191
+ Ne as Sheet,
192
+ ye as SheetClose,
191
193
  Ge as SheetContent,
192
194
  He as SheetDescription,
193
195
  Oe as SheetFooter,
@@ -195,53 +197,56 @@ export {
195
197
  ze as SheetTitle,
196
198
  _e as SheetTrigger,
197
199
  je as Skeleton,
198
- U as ThumbhashImage,
200
+ y as ThumbhashImage,
199
201
  Ye as Toaster,
200
202
  H as Touchable,
201
203
  E as TransitionLink,
204
+ kt as UserState,
205
+ Et as UserTokenGenerateUserErrorCode,
202
206
  j as VideoPlayer,
203
207
  Pr as badgeVariants,
204
- St as extractBrandTheme,
205
- It as fileToDataUri,
206
- dt as formatError,
207
- Ct as formatReviewCount,
208
- Dt as getFeaturedImages,
209
- At as normalizeRating,
210
- ht as parseUrl,
211
- yo as useAsyncStorage,
208
+ Dt as extractBrandTheme,
209
+ wt as fileToDataUri,
210
+ St as formatError,
211
+ At as formatReviewCount,
212
+ Pt as getFeaturedImages,
213
+ ht as normalizeRating,
214
+ It as parseUrl,
215
+ Go as useAsyncStorage,
212
216
  fo as useBuyerAttributes,
213
- Wo as useCloseMini,
214
- ot as useCreateImageContent,
215
- Mo as useCuratedProducts,
216
- lo as useCurrentUser,
217
- Qo as useDeeplink,
218
- it as useErrorScreen,
219
- at as useErrorToast,
217
+ Qo as useCloseMini,
218
+ at as useCreateImageContent,
219
+ No as useCuratedProducts,
220
+ mo as useCurrentUser,
221
+ qo as useDeeplink,
222
+ lt as useErrorScreen,
223
+ it as useErrorToast,
220
224
  to as useFollowedShops,
221
225
  po as useFollowedShopsActions,
222
- nt as useImagePicker,
223
- Oo as useImageUpload,
224
- qo as useNavigateWithTransition,
226
+ uo as useGenerateUserToken,
227
+ xt as useImagePicker,
228
+ zo as useImageUpload,
229
+ Ko as useNavigateWithTransition,
225
230
  so as useOrders,
226
- Bo as usePopularProducts,
227
- Ao as useProduct,
228
- Co as useProductList,
229
- uo as useProductListActions,
230
- go as useProductLists,
231
- wo as useProductMedia,
231
+ Lo as usePopularProducts,
232
+ ho as useProduct,
233
+ Ao as useProductList,
234
+ go as useProductListActions,
235
+ Co as useProductLists,
236
+ ko as useProductMedia,
232
237
  bo as useProductSearch,
233
- Io as useProductVariants,
234
- ho as useProducts,
238
+ wo as useProductVariants,
239
+ Io as useProducts,
235
240
  Je as useRecentProducts,
236
241
  Xe as useRecentShops,
237
- Fo as useRecommendedProducts,
238
- rt as useRecommendedShops,
242
+ Uo as useRecommendedProducts,
243
+ ot as useRecommendedShops,
239
244
  $e as useSavedProducts,
240
245
  eo as useSavedProductsActions,
241
- Go as useSecureStorage,
242
- mt as useShare,
243
- Ko as useShop,
244
- Zo as useShopCartActions,
245
- zo as useShopNavigation
246
+ Oo as useSecureStorage,
247
+ nt as useShare,
248
+ Zo as useShop,
249
+ rt as useShopCartActions,
250
+ Wo as useShopNavigation
246
251
  };
247
252
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}