@shopify/shop-minis-react 0.0.27 → 0.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/index2.js +4 -4
- package/dist/_virtual/index3.js +4 -4
- package/dist/components/atoms/content-monitor.js +22 -0
- package/dist/components/atoms/content-monitor.js.map +1 -0
- package/dist/components/atoms/content-wrapper.js +18 -0
- package/dist/components/atoms/content-wrapper.js.map +1 -0
- package/dist/components/atoms/long-press-detector.js +33 -0
- package/dist/components/atoms/long-press-detector.js.map +1 -0
- package/dist/components/commerce/product-link.js +117 -113
- package/dist/components/commerce/product-link.js.map +1 -1
- package/dist/components/commerce/search.js +26 -17
- package/dist/components/commerce/search.js.map +1 -1
- package/dist/components/content/image-content-wrapper.js +27 -0
- package/dist/components/content/image-content-wrapper.js.map +1 -0
- package/dist/components/navigation/minis-router.js +14 -0
- package/dist/components/navigation/minis-router.js.map +1 -0
- package/dist/index.js +214 -212
- package/dist/index.js.map +1 -1
- package/dist/shop-minis-react/node_modules/.pnpm/react-router@7.7.0_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/react-router/dist/development/chunk-EF7DTUVF.js +764 -567
- package/dist/shop-minis-react/node_modules/.pnpm/react-router@7.7.0_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/react-router/dist/development/chunk-EF7DTUVF.js.map +1 -1
- package/dist/shop-minis-react/node_modules/.pnpm/video.js@8.23.3/node_modules/video.js/dist/video.es.js +1 -1
- package/dist/utils/colors.js +1 -1
- package/package.json +1 -1
- package/src/components/atoms/content-monitor.tsx +25 -0
- package/src/components/{content → atoms}/content-wrapper.tsx +1 -0
- package/src/components/atoms/long-press-detector.tsx +52 -0
- package/src/components/commerce/product-link.tsx +10 -4
- package/src/components/commerce/search.tsx +8 -1
- package/src/components/content/image-content-wrapper.tsx +42 -0
- package/src/components/index.ts +3 -2
- package/src/components/navigation/minis-router.tsx +23 -0
- package/src/index.css +1 -0
- package/src/stories/Search.stories.tsx +37 -0
- package/src/styles/fonts.css +26 -0
- package/src/styles/theme.css +26 -0
- package/dist/components/content/content-monitor.js +0 -17
- package/dist/components/content/content-monitor.js.map +0 -1
- package/dist/components/content/content-wrapper.js +0 -17
- package/dist/components/content/content-wrapper.js.map +0 -1
- package/src/components/content/content-monitor.tsx +0 -23
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { jsx as e, jsxs as g } from "react/jsx-runtime";
|
|
2
|
-
import { useState as
|
|
2
|
+
import { useState as k, useCallback as y, createContext as P, useContext as L } from "react";
|
|
3
3
|
import { useProductSearch as T } from "../../hooks/product/useProductSearch.js";
|
|
4
4
|
import { cn as p } from "../../lib/utils.js";
|
|
5
5
|
import { IconButton as E } from "../atoms/icon-button.js";
|
|
6
6
|
import { List as _ } from "../atoms/list.js";
|
|
7
7
|
import { Input as j } from "../ui/input.js";
|
|
8
8
|
import { ProductLink as v } from "./product-link.js";
|
|
9
|
-
import { ProductLinkSkeleton as
|
|
9
|
+
import { ProductLinkSkeleton as m } from "./product-link-skeleton.js";
|
|
10
10
|
import z from "../../shop-minis-react/node_modules/.pnpm/lucide-react@0.513.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/search.js";
|
|
11
11
|
import M from "../../shop-minis-react/node_modules/.pnpm/lucide-react@0.513.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/x.js";
|
|
12
|
-
const Q = 100, S =
|
|
12
|
+
const Q = 100, S = P(null);
|
|
13
13
|
function N() {
|
|
14
14
|
const t = L(S);
|
|
15
15
|
if (!t)
|
|
@@ -17,20 +17,20 @@ function N() {
|
|
|
17
17
|
return t;
|
|
18
18
|
}
|
|
19
19
|
function q({ initialQuery: t = "", children: i }) {
|
|
20
|
-
const [r, a] =
|
|
20
|
+
const [r, a] = k(t), { products: o, loading: s, error: n, fetchMore: c, hasNextPage: d, isTyping: l } = T({
|
|
21
21
|
query: r,
|
|
22
22
|
fetchPolicy: "network-only"
|
|
23
|
-
}),
|
|
23
|
+
}), u = y((f) => {
|
|
24
24
|
a(f);
|
|
25
25
|
}, []), h = {
|
|
26
26
|
query: r,
|
|
27
|
-
setQuery:
|
|
27
|
+
setQuery: u,
|
|
28
28
|
products: o,
|
|
29
29
|
loading: s,
|
|
30
30
|
error: n,
|
|
31
31
|
fetchMore: c,
|
|
32
|
-
hasNextPage:
|
|
33
|
-
isTyping:
|
|
32
|
+
hasNextPage: d,
|
|
33
|
+
isTyping: l
|
|
34
34
|
};
|
|
35
35
|
return /* @__PURE__ */ e(S.Provider, { value: h, children: i });
|
|
36
36
|
}
|
|
@@ -92,12 +92,12 @@ function F({
|
|
|
92
92
|
showScrollbar: o,
|
|
93
93
|
overscanCount: s = 5
|
|
94
94
|
}) {
|
|
95
|
-
const { query: n, products: c, loading:
|
|
95
|
+
const { query: n, products: c, loading: d, fetchMore: l, hasNextPage: u, isTyping: h } = N(), f = (x, I) => i ? i(x, I) : /* @__PURE__ */ e("div", { className: "p-2", children: /* @__PURE__ */ e(v, { product: x, hideFavoriteAction: !0 }, x.id) }), b = n.trim().length === 0, w = (!c || c.length === 0) && (d || h), C = (!c || c.length === 0) && !d;
|
|
96
96
|
return b ? a || /* @__PURE__ */ e("div", { className: "flex items-center justify-center h-32 text-gray-500", children: "Start typing to search for products" }) : w ? /* @__PURE__ */ g("div", { className: "flex flex-col px-4 py-4", children: [
|
|
97
|
-
/* @__PURE__ */ e(
|
|
98
|
-
/* @__PURE__ */ e(
|
|
99
|
-
/* @__PURE__ */ e(
|
|
100
|
-
/* @__PURE__ */ e(
|
|
97
|
+
/* @__PURE__ */ e(m, { className: "mb-4" }),
|
|
98
|
+
/* @__PURE__ */ e(m, { className: "mb-4" }),
|
|
99
|
+
/* @__PURE__ */ e(m, { className: "mb-4" }),
|
|
100
|
+
/* @__PURE__ */ e(m, { className: "mb-4" })
|
|
101
101
|
] }) : C ? /* @__PURE__ */ e("div", { className: "flex items-center justify-center h-32 text-gray-500", children: `No products found for "${n}"` }) : /* @__PURE__ */ e(
|
|
102
102
|
_,
|
|
103
103
|
{
|
|
@@ -105,7 +105,7 @@ function F({
|
|
|
105
105
|
height: t,
|
|
106
106
|
renderItem: f,
|
|
107
107
|
itemSizeForRow: () => r,
|
|
108
|
-
fetchMore:
|
|
108
|
+
fetchMore: u ? l : void 0,
|
|
109
109
|
showScrollbar: o,
|
|
110
110
|
overscanCount: s
|
|
111
111
|
}
|
|
@@ -118,9 +118,18 @@ function J({
|
|
|
118
118
|
height: a,
|
|
119
119
|
className: o,
|
|
120
120
|
renderItem: s,
|
|
121
|
-
itemHeight: n
|
|
121
|
+
itemHeight: n,
|
|
122
|
+
onProductClick: c
|
|
122
123
|
}) {
|
|
123
|
-
const
|
|
124
|
+
const d = (l, u) => s ? s(l, u) : /* @__PURE__ */ e("div", { className: "p-2", children: /* @__PURE__ */ e(
|
|
125
|
+
v,
|
|
126
|
+
{
|
|
127
|
+
product: l,
|
|
128
|
+
hideFavoriteAction: !0,
|
|
129
|
+
onClick: c
|
|
130
|
+
},
|
|
131
|
+
l.id
|
|
132
|
+
) });
|
|
124
133
|
return /* @__PURE__ */ e(q, { initialQuery: t, children: /* @__PURE__ */ g("div", { className: p("flex flex-col ", o), children: [
|
|
125
134
|
/* @__PURE__ */ e("div", { className: "fixed top-0 left-0 right-0 p-4 w-full z-20 bg-background", children: /* @__PURE__ */ e(A, { placeholder: i, inputProps: r }) }),
|
|
126
135
|
/* @__PURE__ */ e("div", { className: "h-14" }),
|
|
@@ -128,7 +137,7 @@ function J({
|
|
|
128
137
|
F,
|
|
129
138
|
{
|
|
130
139
|
height: a,
|
|
131
|
-
renderItem:
|
|
140
|
+
renderItem: d,
|
|
132
141
|
itemHeight: n,
|
|
133
142
|
showScrollbar: !0
|
|
134
143
|
}
|
|
@@ -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}\n\nfunction Search({\n initialQuery,\n placeholder,\n inputProps,\n height,\n className,\n renderItem,\n itemHeight,\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 key={product.id} product={product} hideFavoriteAction />\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"],"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,EAAiB,GAErCwB,IAAoBP;AAAA,IACxB,CAACQ,MAA+C;AACrC,MAAAT,EAAAS,EAAM,OAAO,KAAK,GAC3BF,GAAY,WAAWE,CAAK;AAAA,IAC9B;AAAA,IACA,CAACF,GAAYP,CAAQ;AAAA,EACvB;AAGE,SAAA,gBAAAU,EAAC,OAA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oBAAkB,GAAA,GAAhDA,EAAQ,EAAyC,GACrE;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?: () => 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;AAA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,EAAA,CACF,EACF,CAAA;AAEJ;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as r, Fragment as a } from "react/jsx-runtime";
|
|
2
|
+
import { ContentWrapper as f } from "../atoms/content-wrapper.js";
|
|
3
|
+
function h({
|
|
4
|
+
onLoad: i,
|
|
5
|
+
width: m,
|
|
6
|
+
height: p,
|
|
7
|
+
className: l,
|
|
8
|
+
publicId: o,
|
|
9
|
+
externalId: t,
|
|
10
|
+
Loader: e
|
|
11
|
+
}) {
|
|
12
|
+
return /* @__PURE__ */ r(f, { ...t ? { externalId: t } : { publicId: o }, children: ({ content: n, loading: u }) => u ? e ? /* @__PURE__ */ r(a, { children: e }) : null : /* @__PURE__ */ r(
|
|
13
|
+
"img",
|
|
14
|
+
{
|
|
15
|
+
src: n?.image?.url,
|
|
16
|
+
width: m,
|
|
17
|
+
height: p,
|
|
18
|
+
alt: n?.title,
|
|
19
|
+
onLoad: i,
|
|
20
|
+
className: l
|
|
21
|
+
}
|
|
22
|
+
) });
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
h as ImageContentWrapper
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=image-content-wrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-content-wrapper.js","sources":["../../../src/components/content/image-content-wrapper.tsx"],"sourcesContent":["/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */\nimport {ContentWrapper} from '../atoms/content-wrapper'\n\ntype ImageContentWrapperProps = (\n | {publicId: string; externalId?: never}\n | {externalId: string; publicId?: never}\n) & {\n onLoad?: () => void\n width?: number\n height?: number\n className?: string\n Loader?: React.ReactNode | string\n}\n\nexport function ImageContentWrapper({\n onLoad,\n width,\n height,\n className,\n publicId,\n externalId,\n Loader,\n}: ImageContentWrapperProps) {\n return (\n <ContentWrapper {...(externalId ? {externalId} : {publicId: publicId!})}>\n {({content, loading}) => {\n if (loading) return Loader ? <>{Loader}</> : null\n\n return (\n <img\n src={content?.image?.url}\n width={width}\n height={height}\n alt={content?.title}\n onLoad={onLoad}\n className={className}\n />\n )\n }}\n </ContentWrapper>\n )\n}\n"],"names":["ImageContentWrapper","onLoad","width","height","className","publicId","externalId","Loader","jsx","ContentWrapper","content","loading","Fragment"],"mappings":";;AAcO,SAASA,EAAoB;AAAA,EAClC,QAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,YAAAC;AAAA,EACA,QAAAC;AACF,GAA6B;AAC3B,SACG,gBAAAC,EAAAC,GAAA,EAAgB,GAAIH,IAAa,EAAC,YAAAA,EAAU,IAAI,EAAC,UAAAD,EAC/C,GAAA,UAAA,CAAC,EAAC,SAAAK,GAAS,SAAAC,QACNA,IAAgBJ,IAAS,gBAAAC,EAAAI,GAAA,EAAG,YAAO,CAAA,IAAM,OAG3C,gBAAAJ;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAKE,GAAS,OAAO;AAAA,MACrB,OAAAR;AAAA,MACA,QAAAC;AAAA,MACA,KAAKO,GAAS;AAAA,MACd,QAAAT;AAAA,MACA,WAAAG;AAAA,IAAA;AAAA,EACF,GAGN;AAEJ;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { BrowserRouter as i } from "../../shop-minis-react/node_modules/.pnpm/react-router@7.7.0_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/react-router/dist/development/chunk-EF7DTUVF.js";
|
|
3
|
+
import { TransitionContainer as e } from "./transition-container.js";
|
|
4
|
+
function s({
|
|
5
|
+
children: o,
|
|
6
|
+
viewTransitions: n = !1,
|
|
7
|
+
...t
|
|
8
|
+
}) {
|
|
9
|
+
return n ? /* @__PURE__ */ r(i, { ...t, children: /* @__PURE__ */ r(e, { children: o }) }) : /* @__PURE__ */ r(i, { ...t, children: o });
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
s as MinisRouter
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=minis-router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"minis-router.js","sources":["../../../src/components/navigation/minis-router.tsx"],"sourcesContent":["import {BrowserRouter, BrowserRouterProps} from 'react-router'\n\nimport {TransitionContainer} from './transition-container'\n\ntype ShopMinisRouterProps = BrowserRouterProps & {\n viewTransitions?: boolean\n}\n\nexport function MinisRouter({\n children,\n viewTransitions = false,\n ...props\n}: ShopMinisRouterProps) {\n if (viewTransitions) {\n return (\n <BrowserRouter {...props}>\n <TransitionContainer>{children}</TransitionContainer>\n </BrowserRouter>\n )\n }\n\n return <BrowserRouter {...props}>{children}</BrowserRouter>\n}\n"],"names":["MinisRouter","children","viewTransitions","props","BrowserRouter","jsx","TransitionContainer"],"mappings":";;;AAQO,SAASA,EAAY;AAAA,EAC1B,UAAAC;AAAA,EACA,iBAAAC,IAAkB;AAAA,EAClB,GAAGC;AACL,GAAyB;AACvB,SAAID,sBAECE,GAAe,EAAA,GAAGD,GACjB,UAAC,gBAAAE,EAAAC,GAAA,EAAqB,UAAAL,EAAS,CAAA,GACjC,IAII,gBAAAI,EAAAD,GAAA,EAAe,GAAGD,GAAQ,UAAAF,EAAS,CAAA;AAC7C;"}
|