@shopify/shop-minis-react 0.0.26 → 0.0.28
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-skeleton.js +30 -0
- package/dist/components/commerce/product-link-skeleton.js.map +1 -0
- package/dist/components/commerce/product-link.js +68 -68
- package/dist/components/commerce/product-link.js.map +1 -1
- package/dist/components/commerce/search.js +144 -0
- package/dist/components/commerce/search.js.map +1 -0
- package/dist/components/content/image-content-wrapper.js +27 -0
- package/dist/components/content/image-content-wrapper.js.map +1 -0
- package/dist/components/ui/input.js +3 -3
- package/dist/components/ui/input.js.map +1 -1
- package/dist/hooks/product/useProductSearch.js +24 -23
- package/dist/hooks/product/useProductSearch.js.map +1 -1
- package/dist/index.js +232 -225
- package/dist/index.js.map +1 -1
- package/dist/shop-minis-react/node_modules/.pnpm/lucide-react@0.513.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/search.js +16 -0
- package/dist/shop-minis-react/node_modules/.pnpm/lucide-react@0.513.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/search.js.map +1 -0
- 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/shop-minis-react.css +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-skeleton.tsx +30 -0
- package/src/components/commerce/product-link.tsx +8 -5
- package/src/components/commerce/search.tsx +264 -0
- package/src/components/content/image-content-wrapper.tsx +42 -0
- package/src/components/index.ts +3 -1
- package/src/components/ui/input.tsx +1 -1
- package/src/hooks/product/useProductSearch.ts +10 -1
- package/src/styles/utilities.css +9 -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
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { jsx as e, jsxs as g } from "react/jsx-runtime";
|
|
2
|
+
import { useState as P, useCallback as y, createContext as k, useContext as L } from "react";
|
|
3
|
+
import { useProductSearch as T } from "../../hooks/product/useProductSearch.js";
|
|
4
|
+
import { cn as p } from "../../lib/utils.js";
|
|
5
|
+
import { IconButton as E } from "../atoms/icon-button.js";
|
|
6
|
+
import { List as _ } from "../atoms/list.js";
|
|
7
|
+
import { Input as j } from "../ui/input.js";
|
|
8
|
+
import { ProductLink as v } from "./product-link.js";
|
|
9
|
+
import { ProductLinkSkeleton as u } from "./product-link-skeleton.js";
|
|
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
|
+
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 = k(null);
|
|
13
|
+
function N() {
|
|
14
|
+
const t = L(S);
|
|
15
|
+
if (!t)
|
|
16
|
+
throw new Error("useSearchContext must be used within a SearchProvider");
|
|
17
|
+
return t;
|
|
18
|
+
}
|
|
19
|
+
function q({ initialQuery: t = "", children: i }) {
|
|
20
|
+
const [r, a] = P(t), { products: o, loading: s, error: n, fetchMore: c, hasNextPage: l, isTyping: d } = T({
|
|
21
|
+
query: r,
|
|
22
|
+
fetchPolicy: "network-only"
|
|
23
|
+
}), m = y((f) => {
|
|
24
|
+
a(f);
|
|
25
|
+
}, []), h = {
|
|
26
|
+
query: r,
|
|
27
|
+
setQuery: m,
|
|
28
|
+
products: o,
|
|
29
|
+
loading: s,
|
|
30
|
+
error: n,
|
|
31
|
+
fetchMore: c,
|
|
32
|
+
hasNextPage: l,
|
|
33
|
+
isTyping: d
|
|
34
|
+
};
|
|
35
|
+
return /* @__PURE__ */ e(S.Provider, { value: h, children: i });
|
|
36
|
+
}
|
|
37
|
+
function A({
|
|
38
|
+
placeholder: t = "Search products...",
|
|
39
|
+
className: i,
|
|
40
|
+
inputProps: r
|
|
41
|
+
}) {
|
|
42
|
+
const { query: a, setQuery: o } = N(), s = y(
|
|
43
|
+
(n) => {
|
|
44
|
+
o(n.target.value), r?.onChange?.(n);
|
|
45
|
+
},
|
|
46
|
+
[r, o]
|
|
47
|
+
);
|
|
48
|
+
return /* @__PURE__ */ g("div", { className: "relative flex flex-1 items-center rounded-full pl-4 pr-2 py-1 bg-gray-100", children: [
|
|
49
|
+
/* @__PURE__ */ e("div", { className: "relative flex items-center", children: /* @__PURE__ */ e(
|
|
50
|
+
z,
|
|
51
|
+
{
|
|
52
|
+
size: 18,
|
|
53
|
+
className: p("text-accent-foreground opacity-60")
|
|
54
|
+
}
|
|
55
|
+
) }),
|
|
56
|
+
/* @__PURE__ */ e("div", { className: "relative flex-1 flex items-center mx-2", children: /* @__PURE__ */ e(
|
|
57
|
+
j,
|
|
58
|
+
{
|
|
59
|
+
name: "search",
|
|
60
|
+
onChange: s,
|
|
61
|
+
placeholder: t,
|
|
62
|
+
type: "search",
|
|
63
|
+
role: "searchbox",
|
|
64
|
+
autoComplete: "off",
|
|
65
|
+
value: a,
|
|
66
|
+
"data-testid": "search-input",
|
|
67
|
+
...r,
|
|
68
|
+
className: p(
|
|
69
|
+
"w-full flex overflow-hidden rounded-radius-28 border-none py-4 px-0 text-text placeholder:text-text placeholder:opacity-60",
|
|
70
|
+
i
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
) }),
|
|
74
|
+
/* @__PURE__ */ e("div", { className: "relative flex items-center", children: a === "" ? null : /* @__PURE__ */ e(
|
|
75
|
+
E,
|
|
76
|
+
{
|
|
77
|
+
Icon: M,
|
|
78
|
+
size: "sm",
|
|
79
|
+
filled: !1,
|
|
80
|
+
iconStyles: "",
|
|
81
|
+
onClick: () => o(""),
|
|
82
|
+
buttonStyles: "flex items-center rounded-radius-max bg-[var(--grayscale-l20)]"
|
|
83
|
+
}
|
|
84
|
+
) })
|
|
85
|
+
] });
|
|
86
|
+
}
|
|
87
|
+
function F({
|
|
88
|
+
height: t = window.innerHeight,
|
|
89
|
+
renderItem: i,
|
|
90
|
+
itemHeight: r = Q,
|
|
91
|
+
initialStateComponent: a,
|
|
92
|
+
showScrollbar: o,
|
|
93
|
+
overscanCount: s = 5
|
|
94
|
+
}) {
|
|
95
|
+
const { query: n, products: c, loading: l, fetchMore: d, hasNextPage: m, 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) && (l || h), C = (!c || c.length === 0) && !l;
|
|
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(u, { className: "mb-4" }),
|
|
98
|
+
/* @__PURE__ */ e(u, { className: "mb-4" }),
|
|
99
|
+
/* @__PURE__ */ e(u, { className: "mb-4" }),
|
|
100
|
+
/* @__PURE__ */ e(u, { className: "mb-4" })
|
|
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
|
+
_,
|
|
103
|
+
{
|
|
104
|
+
items: c || [],
|
|
105
|
+
height: t,
|
|
106
|
+
renderItem: f,
|
|
107
|
+
itemSizeForRow: () => r,
|
|
108
|
+
fetchMore: m ? d : void 0,
|
|
109
|
+
showScrollbar: o,
|
|
110
|
+
overscanCount: s
|
|
111
|
+
}
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
function J({
|
|
115
|
+
initialQuery: t,
|
|
116
|
+
placeholder: i,
|
|
117
|
+
inputProps: r,
|
|
118
|
+
height: a,
|
|
119
|
+
className: o,
|
|
120
|
+
renderItem: s,
|
|
121
|
+
itemHeight: n
|
|
122
|
+
}) {
|
|
123
|
+
const c = (l, d) => s ? s(l, d) : /* @__PURE__ */ e("div", { className: "p-2", children: /* @__PURE__ */ e(v, { product: l, hideFavoriteAction: !0 }, l.id) });
|
|
124
|
+
return /* @__PURE__ */ e(q, { initialQuery: t, children: /* @__PURE__ */ g("div", { className: p("flex flex-col ", o), children: [
|
|
125
|
+
/* @__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
|
+
/* @__PURE__ */ e("div", { className: "h-14" }),
|
|
127
|
+
/* @__PURE__ */ e(
|
|
128
|
+
F,
|
|
129
|
+
{
|
|
130
|
+
height: a,
|
|
131
|
+
renderItem: c,
|
|
132
|
+
itemHeight: n,
|
|
133
|
+
showScrollbar: !0
|
|
134
|
+
}
|
|
135
|
+
)
|
|
136
|
+
] }) });
|
|
137
|
+
}
|
|
138
|
+
export {
|
|
139
|
+
J as Search,
|
|
140
|
+
A as SearchInput,
|
|
141
|
+
q as SearchProvider,
|
|
142
|
+
F as SearchResultsList
|
|
143
|
+
};
|
|
144
|
+
//# sourceMappingURL=search.js.map
|
|
@@ -0,0 +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,OAAI,EA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kB,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;"}
|
|
@@ -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;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import { cn as n } from "../../lib/utils.js";
|
|
3
|
-
function
|
|
3
|
+
function l({ className: e, type: i, ...r }) {
|
|
4
4
|
return /* @__PURE__ */ t(
|
|
5
5
|
"input",
|
|
6
6
|
{
|
|
@@ -8,7 +8,7 @@ function a({ className: e, type: i, ...r }) {
|
|
|
8
8
|
"data-slot": "input",
|
|
9
9
|
className: n(
|
|
10
10
|
"file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
|
11
|
-
"focus-
|
|
11
|
+
"focus:outline-none focus:ring-0 focus-visible:ring-0 focus-visible:outline-none",
|
|
12
12
|
"aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
|
13
13
|
e
|
|
14
14
|
),
|
|
@@ -17,6 +17,6 @@ function a({ className: e, type: i, ...r }) {
|
|
|
17
17
|
);
|
|
18
18
|
}
|
|
19
19
|
export {
|
|
20
|
-
|
|
20
|
+
l as Input
|
|
21
21
|
};
|
|
22
22
|
//# sourceMappingURL=input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.js","sources":["../../../src/components/ui/input.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport {cn} from '../../lib/utils'\n\nfunction Input({className, type, ...props}: React.ComponentProps<'input'>) {\n return (\n <input\n type={type}\n data-slot=\"input\"\n className={cn(\n 'file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm',\n 'focus-
|
|
1
|
+
{"version":3,"file":"input.js","sources":["../../../src/components/ui/input.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport {cn} from '../../lib/utils'\n\nfunction Input({className, type, ...props}: React.ComponentProps<'input'>) {\n return (\n <input\n type={type}\n data-slot=\"input\"\n className={cn(\n 'file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm',\n 'focus:outline-none focus:ring-0 focus-visible:ring-0 focus-visible:outline-none',\n 'aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive',\n className\n )}\n {...props}\n />\n )\n}\n\nexport {Input}\n"],"names":["Input","className","type","props","jsx","cn"],"mappings":";;AAIA,SAASA,EAAM,EAAC,WAAAC,GAAW,MAAAC,GAAM,GAAGC,KAAuC;AAEvE,SAAA,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAAF;AAAA,MACA,aAAU;AAAA,MACV,WAAWG;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,QACAJ;AAAA,MACF;AAAA,MACC,GAAGE;AAAA,IAAA;AAAA,EACN;AAEJ;"}
|
|
@@ -1,41 +1,42 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import
|
|
3
|
-
import { useShopActions as
|
|
1
|
+
import { useState as h, useCallback as S, useEffect as y, useMemo as b } from "react";
|
|
2
|
+
import g from "../../_virtual/debounce.js";
|
|
3
|
+
import { useShopActions as P } from "../../internal/useShopActions.js";
|
|
4
4
|
import { useShopActionsPaginatedDataFetching as k } from "../../internal/useShopActionsPaginatedDataFetching.js";
|
|
5
|
-
const v = (
|
|
6
|
-
const { getProductSearch:
|
|
5
|
+
const v = (s) => {
|
|
6
|
+
const { getProductSearch: u } = P(), {
|
|
7
7
|
query: e,
|
|
8
8
|
filters: c,
|
|
9
|
-
sortBy:
|
|
10
|
-
includeSensitive:
|
|
11
|
-
skip:
|
|
9
|
+
sortBy: n,
|
|
10
|
+
includeSensitive: a = !1,
|
|
11
|
+
skip: i = !1,
|
|
12
12
|
...d
|
|
13
|
-
} =
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
} = s ?? {}, [t, l] = h(e), r = S(
|
|
14
|
+
g((p) => {
|
|
15
|
+
l(p);
|
|
16
16
|
}, 300),
|
|
17
17
|
[]
|
|
18
18
|
);
|
|
19
|
-
y(() => (
|
|
20
|
-
|
|
21
|
-
}), [e,
|
|
22
|
-
const { data: o, ...
|
|
23
|
-
|
|
19
|
+
y(() => (r(e), () => {
|
|
20
|
+
r.cancel();
|
|
21
|
+
}), [e, r]);
|
|
22
|
+
const { data: o, ...m } = k(
|
|
23
|
+
u,
|
|
24
24
|
{
|
|
25
|
-
query:
|
|
25
|
+
query: t,
|
|
26
26
|
filters: c,
|
|
27
|
-
sortBy:
|
|
28
|
-
includeSensitive:
|
|
27
|
+
sortBy: n,
|
|
28
|
+
includeSensitive: a,
|
|
29
29
|
...d
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
|
-
skip:
|
|
32
|
+
skip: i,
|
|
33
33
|
hook: "useProductSearch"
|
|
34
34
|
}
|
|
35
|
-
),
|
|
35
|
+
), f = b(() => t.trim().length === 0 ? null : o ?? null, [o, t]);
|
|
36
36
|
return {
|
|
37
|
-
...
|
|
38
|
-
products:
|
|
37
|
+
...m,
|
|
38
|
+
products: f,
|
|
39
|
+
isTyping: t !== e
|
|
39
40
|
};
|
|
40
41
|
};
|
|
41
42
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useProductSearch.js","sources":["../../../src/hooks/product/useProductSearch.ts"],"sourcesContent":["import {useCallback, useEffect, useMemo, useState} from 'react'\n\nimport debounce from 'lodash/debounce'\n\nimport {useShopActions} from '../../internal/useShopActions'\nimport {useShopActionsPaginatedDataFetching} from '../../internal/useShopActionsPaginatedDataFetching'\nimport {\n PaginatedDataHookOptionsBase,\n PaginatedDataHookReturnsBase,\n Product,\n ProductFilters,\n ProductSearchSortBy,\n} from '../../types'\n\nexport interface UseProductSearchParams extends PaginatedDataHookOptionsBase {\n /**\n * The search query.\n */\n query: string\n /**\n * The filters to apply to the search.\n */\n filters?: ProductFilters\n /**\n * The sort order of the results.\n */\n sortBy?: ProductSearchSortBy\n /**\n * Whether to include sensitive products.\n */\n includeSensitive?: boolean\n}\n\ninterface UseProductSearchReturns extends PaginatedDataHookReturnsBase {\n /**\n * The products returned from the query.\n */\n products: Product[] | null\n}\n\nexport const useProductSearch = (\n params: UseProductSearchParams\n): UseProductSearchReturns => {\n const {getProductSearch} = useShopActions()\n const {\n query,\n filters,\n sortBy,\n includeSensitive = false,\n skip = false,\n ...restParams\n } = params ?? {}\n\n const [debouncedQuery, setDebouncedQuery] = useState<string>(query)\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const debouncedSetQuery = useCallback(\n debounce((newQuery: string) => {\n setDebouncedQuery(newQuery)\n }, 300),\n []\n )\n\n useEffect(() => {\n debouncedSetQuery(query)\n\n return () => {\n debouncedSetQuery.cancel()\n }\n }, [query, debouncedSetQuery])\n\n const {data, ...rest} = useShopActionsPaginatedDataFetching(\n getProductSearch,\n {\n query: debouncedQuery,\n filters,\n sortBy,\n includeSensitive,\n ...restParams,\n },\n {\n skip,\n hook: 'useProductSearch',\n }\n )\n\n const products = useMemo(() => {\n return data ?? null\n }, [data])\n\n return {\n ...rest,\n products,\n }\n}\n"],"names":["useProductSearch","params","getProductSearch","useShopActions","query","filters","sortBy","includeSensitive","skip","restParams","debouncedQuery","setDebouncedQuery","useState","debouncedSetQuery","useCallback","debounce","newQuery","useEffect","data","rest","useShopActionsPaginatedDataFetching","products","useMemo"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"useProductSearch.js","sources":["../../../src/hooks/product/useProductSearch.ts"],"sourcesContent":["import {useCallback, useEffect, useMemo, useState} from 'react'\n\nimport debounce from 'lodash/debounce'\n\nimport {useShopActions} from '../../internal/useShopActions'\nimport {useShopActionsPaginatedDataFetching} from '../../internal/useShopActionsPaginatedDataFetching'\nimport {\n PaginatedDataHookOptionsBase,\n PaginatedDataHookReturnsBase,\n Product,\n ProductFilters,\n ProductSearchSortBy,\n} from '../../types'\n\nexport interface UseProductSearchParams extends PaginatedDataHookOptionsBase {\n /**\n * The search query.\n */\n query: string\n /**\n * The filters to apply to the search.\n */\n filters?: ProductFilters\n /**\n * The sort order of the results.\n */\n sortBy?: ProductSearchSortBy\n /**\n * Whether to include sensitive products.\n */\n includeSensitive?: boolean\n}\n\ninterface UseProductSearchReturns extends PaginatedDataHookReturnsBase {\n /**\n * The products returned from the query.\n */\n products: Product[] | null\n /**\n * Whether the user is typing.\n */\n isTyping: boolean\n}\n\nexport const useProductSearch = (\n params: UseProductSearchParams\n): UseProductSearchReturns => {\n const {getProductSearch} = useShopActions()\n const {\n query,\n filters,\n sortBy,\n includeSensitive = false,\n skip = false,\n ...restParams\n } = params ?? {}\n\n const [debouncedQuery, setDebouncedQuery] = useState<string>(query)\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const debouncedSetQuery = useCallback(\n debounce((newQuery: string) => {\n setDebouncedQuery(newQuery)\n }, 300),\n []\n )\n\n useEffect(() => {\n debouncedSetQuery(query)\n\n return () => {\n debouncedSetQuery.cancel()\n }\n }, [query, debouncedSetQuery])\n\n const {data, ...rest} = useShopActionsPaginatedDataFetching(\n getProductSearch,\n {\n query: debouncedQuery,\n filters,\n sortBy,\n includeSensitive,\n ...restParams,\n },\n {\n skip,\n hook: 'useProductSearch',\n }\n )\n\n const products = useMemo(() => {\n if (debouncedQuery.trim().length === 0) {\n return null\n }\n\n return data ?? null\n }, [data, debouncedQuery])\n\n return {\n ...rest,\n products,\n isTyping: debouncedQuery !== query,\n }\n}\n"],"names":["useProductSearch","params","getProductSearch","useShopActions","query","filters","sortBy","includeSensitive","skip","restParams","debouncedQuery","setDebouncedQuery","useState","debouncedSetQuery","useCallback","debounce","newQuery","useEffect","data","rest","useShopActionsPaginatedDataFetching","products","useMemo"],"mappings":";;;;AA4Ca,MAAAA,IAAmB,CAC9BC,MAC4B;AACtB,QAAA,EAAC,kBAAAC,EAAgB,IAAIC,EAAe,GACpC;AAAA,IACJ,OAAAC;AAAA,IACA,SAAAC;AAAA,IACA,QAAAC;AAAA,IACA,kBAAAC,IAAmB;AAAA,IACnB,MAAAC,IAAO;AAAA,IACP,GAAGC;AAAA,EACL,IAAIR,KAAU,CAAC,GAET,CAACS,GAAgBC,CAAiB,IAAIC,EAAiBR,CAAK,GAG5DS,IAAoBC;AAAA,IACxBC,EAAS,CAACC,MAAqB;AAC7B,MAAAL,EAAkBK,CAAQ;AAAA,OACzB,GAAG;AAAA,IACN,CAAA;AAAA,EACF;AAEA,EAAAC,EAAU,OACRJ,EAAkBT,CAAK,GAEhB,MAAM;AACX,IAAAS,EAAkB,OAAO;AAAA,EAC3B,IACC,CAACT,GAAOS,CAAiB,CAAC;AAE7B,QAAM,EAAC,MAAAK,GAAM,GAAGC,EAAA,IAAQC;AAAA,IACtBlB;AAAA,IACA;AAAA,MACE,OAAOQ;AAAA,MACP,SAAAL;AAAA,MACA,QAAAC;AAAA,MACA,kBAAAC;AAAA,MACA,GAAGE;AAAA,IACL;AAAA,IACA;AAAA,MACE,MAAAD;AAAA,MACA,MAAM;AAAA,IAAA;AAAA,EAEV,GAEMa,IAAWC,EAAQ,MACnBZ,EAAe,OAAO,WAAW,IAC5B,OAGFQ,KAAQ,MACd,CAACA,GAAMR,CAAc,CAAC;AAElB,SAAA;AAAA,IACL,GAAGS;AAAA,IACH,UAAAE;AAAA,IACA,UAAUX,MAAmBN;AAAA,EAC/B;AACF;"}
|