@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,42 @@
|
|
|
1
|
+
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
|
|
2
|
+
import {ContentWrapper} from '../atoms/content-wrapper'
|
|
3
|
+
|
|
4
|
+
type ImageContentWrapperProps = (
|
|
5
|
+
| {publicId: string; externalId?: never}
|
|
6
|
+
| {externalId: string; publicId?: never}
|
|
7
|
+
) & {
|
|
8
|
+
onLoad?: () => void
|
|
9
|
+
width?: number
|
|
10
|
+
height?: number
|
|
11
|
+
className?: string
|
|
12
|
+
Loader?: React.ReactNode | string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function ImageContentWrapper({
|
|
16
|
+
onLoad,
|
|
17
|
+
width,
|
|
18
|
+
height,
|
|
19
|
+
className,
|
|
20
|
+
publicId,
|
|
21
|
+
externalId,
|
|
22
|
+
Loader,
|
|
23
|
+
}: ImageContentWrapperProps) {
|
|
24
|
+
return (
|
|
25
|
+
<ContentWrapper {...(externalId ? {externalId} : {publicId: publicId!})}>
|
|
26
|
+
{({content, loading}) => {
|
|
27
|
+
if (loading) return Loader ? <>{Loader}</> : null
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<img
|
|
31
|
+
src={content?.image?.url}
|
|
32
|
+
width={width}
|
|
33
|
+
height={height}
|
|
34
|
+
alt={content?.title}
|
|
35
|
+
onLoad={onLoad}
|
|
36
|
+
className={className}
|
|
37
|
+
/>
|
|
38
|
+
)
|
|
39
|
+
}}
|
|
40
|
+
</ContentWrapper>
|
|
41
|
+
)
|
|
42
|
+
}
|
package/src/components/index.ts
CHANGED
|
@@ -6,8 +6,9 @@ export * from './commerce/merchant-card'
|
|
|
6
6
|
export * from './commerce/product-card-skeleton'
|
|
7
7
|
export * from './commerce/merchant-card-skeleton'
|
|
8
8
|
export * from './commerce/quantity-selector'
|
|
9
|
+
export * from './commerce/search'
|
|
9
10
|
|
|
10
|
-
export * from './content/content-wrapper'
|
|
11
|
+
export * from './content/image-content-wrapper'
|
|
11
12
|
|
|
12
13
|
export * from './navigation/transition-container'
|
|
13
14
|
export * from './navigation/transition-link'
|
|
@@ -17,6 +18,7 @@ export * from './atoms/favorite-button'
|
|
|
17
18
|
export * from './atoms/icon-button'
|
|
18
19
|
export * from './atoms/thumbhash-image'
|
|
19
20
|
export * from './atoms/touchable'
|
|
21
|
+
export * from './atoms/long-press-detector'
|
|
20
22
|
export * from './atoms/alert-dialog'
|
|
21
23
|
export * from './atoms/list'
|
|
22
24
|
export * from './atoms/video-player'
|
|
@@ -9,7 +9,7 @@ function Input({className, type, ...props}: React.ComponentProps<'input'>) {
|
|
|
9
9
|
data-slot="input"
|
|
10
10
|
className={cn(
|
|
11
11
|
'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',
|
|
12
|
-
'focus-
|
|
12
|
+
'focus:outline-none focus:ring-0 focus-visible:ring-0 focus-visible:outline-none',
|
|
13
13
|
'aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive',
|
|
14
14
|
className
|
|
15
15
|
)}
|
|
@@ -36,6 +36,10 @@ interface UseProductSearchReturns extends PaginatedDataHookReturnsBase {
|
|
|
36
36
|
* The products returned from the query.
|
|
37
37
|
*/
|
|
38
38
|
products: Product[] | null
|
|
39
|
+
/**
|
|
40
|
+
* Whether the user is typing.
|
|
41
|
+
*/
|
|
42
|
+
isTyping: boolean
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
export const useProductSearch = (
|
|
@@ -85,11 +89,16 @@ export const useProductSearch = (
|
|
|
85
89
|
)
|
|
86
90
|
|
|
87
91
|
const products = useMemo(() => {
|
|
92
|
+
if (debouncedQuery.trim().length === 0) {
|
|
93
|
+
return null
|
|
94
|
+
}
|
|
95
|
+
|
|
88
96
|
return data ?? null
|
|
89
|
-
}, [data])
|
|
97
|
+
}, [data, debouncedQuery])
|
|
90
98
|
|
|
91
99
|
return {
|
|
92
100
|
...rest,
|
|
93
101
|
products,
|
|
102
|
+
isTyping: debouncedQuery !== query,
|
|
94
103
|
}
|
|
95
104
|
}
|
package/src/styles/utilities.css
CHANGED
|
@@ -20,3 +20,12 @@
|
|
|
20
20
|
.no-scrollbars::-webkit-scrollbar {
|
|
21
21
|
display: none; /* Safari and Chrome */
|
|
22
22
|
}
|
|
23
|
+
|
|
24
|
+
/* Search Bar utilities */
|
|
25
|
+
|
|
26
|
+
input[type='search']::-webkit-search-decoration,
|
|
27
|
+
input[type='search']::-webkit-search-cancel-button,
|
|
28
|
+
input[type='search']::-webkit-search-results-button,
|
|
29
|
+
input[type='search']::-webkit-search-results-decoration {
|
|
30
|
+
display: none;
|
|
31
|
+
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import { Touchable as t } from "../atoms/touchable.js";
|
|
3
|
-
function i({
|
|
4
|
-
// publicId,
|
|
5
|
-
children: o
|
|
6
|
-
}) {
|
|
7
|
-
return /* @__PURE__ */ r(
|
|
8
|
-
t,
|
|
9
|
-
{
|
|
10
|
-
children: o
|
|
11
|
-
}
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
export {
|
|
15
|
-
i as ContentMonitor
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=content-monitor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"content-monitor.js","sources":["../../../src/components/content/content-monitor.tsx"],"sourcesContent":["// import {useShopActions} from '../../internal/useShopActions'\nimport {Touchable} from '../atoms/touchable'\n\nexport function ContentMonitor({\n // publicId,\n children,\n}: {\n publicId: string\n children: React.ReactNode\n}) {\n // const {showFeedbackSheet} = useShopActions()\n\n return (\n <Touchable\n // TODO: Add long press support to Touchable\n // onLongPress={() => {\n // showFeedbackSheet({publicId})\n // }}\n >\n {children}\n </Touchable>\n )\n}\n"],"names":["ContentMonitor","children","jsx","Touchable"],"mappings":";;AAGO,SAASA,EAAe;AAAA;AAAA,EAE7B,UAAAC;AACF,GAGG;AAIC,SAAA,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MAME,UAAAF;AAAA,IAAA;AAAA,EACH;AAEJ;"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { jsx as c } from "react/jsx-runtime";
|
|
2
|
-
import { useContent as p } from "../../hooks/content/useContent.js";
|
|
3
|
-
import { ContentMonitor as m } from "./content-monitor.js";
|
|
4
|
-
function d({
|
|
5
|
-
publicId: r,
|
|
6
|
-
externalId: e,
|
|
7
|
-
children: o
|
|
8
|
-
}) {
|
|
9
|
-
const { content: i, loading: t } = p({
|
|
10
|
-
identifiers: [{ publicId: r, externalId: e }]
|
|
11
|
-
}), n = i?.[0];
|
|
12
|
-
return t || !n ? o({ loading: t }) : /* @__PURE__ */ c(m, { publicId: n.publicId, children: o({ content: n, loading: t }) });
|
|
13
|
-
}
|
|
14
|
-
export {
|
|
15
|
-
d as ContentWrapper
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=content-wrapper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"content-wrapper.js","sources":["../../../src/components/content/content-wrapper.tsx"],"sourcesContent":["import {useContent} from '../../hooks/content/useContent'\nimport {Content} from '../../types'\n\nimport {ContentMonitor} from './content-monitor'\n\ninterface BaseContentWrapperProps {\n children: ({\n content,\n loading,\n }: {\n content?: Content\n loading: boolean\n }) => JSX.Element | null\n}\n\ninterface PublicIdContentWrapperProps extends BaseContentWrapperProps {\n publicId: string\n externalId?: never\n}\n\ninterface ExternalIdContentWrapperProps extends BaseContentWrapperProps {\n externalId: string\n publicId?: never\n}\n\ntype ContentWrapperProps =\n | PublicIdContentWrapperProps\n | ExternalIdContentWrapperProps\n\n// It's too messy in the docs to show the complete types here so we show a simplified version\nexport interface ContentWrapperPropsForDocs extends BaseContentWrapperProps {\n publicId?: string\n externalId?: string\n}\n\nexport function ContentWrapper({\n publicId,\n externalId,\n children,\n}: ContentWrapperProps) {\n const {content, loading} = useContent({\n identifiers: [{publicId, externalId}],\n })\n\n const contentItem = content?.[0]\n\n if (loading || !contentItem) {\n return children({loading})\n }\n\n return (\n <ContentMonitor publicId={contentItem.publicId}>\n {children({content: contentItem, loading})}\n </ContentMonitor>\n )\n}\n"],"names":["ContentWrapper","publicId","externalId","children","content","loading","useContent","contentItem","jsx","ContentMonitor"],"mappings":";;;AAmCO,SAASA,EAAe;AAAA,EAC7B,UAAAC;AAAA,EACA,YAAAC;AAAA,EACA,UAAAC;AACF,GAAwB;AACtB,QAAM,EAAC,SAAAC,GAAS,SAAAC,EAAO,IAAIC,EAAW;AAAA,IACpC,aAAa,CAAC,EAAC,UAAAL,GAAU,YAAAC,EAAW,CAAA;AAAA,EAAA,CACrC,GAEKK,IAAcH,IAAU,CAAC;AAE3B,SAAAC,KAAW,CAACE,IACPJ,EAAS,EAAC,SAAAE,GAAQ,IAIzB,gBAAAG,EAACC,GAAe,EAAA,UAAUF,EAAY,UACnC,UAASJ,EAAA,EAAC,SAASI,GAAa,SAAAF,EAAO,CAAC,EAC3C,CAAA;AAEJ;"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// import {useShopActions} from '../../internal/useShopActions'
|
|
2
|
-
import {Touchable} from '../atoms/touchable'
|
|
3
|
-
|
|
4
|
-
export function ContentMonitor({
|
|
5
|
-
// publicId,
|
|
6
|
-
children,
|
|
7
|
-
}: {
|
|
8
|
-
publicId: string
|
|
9
|
-
children: React.ReactNode
|
|
10
|
-
}) {
|
|
11
|
-
// const {showFeedbackSheet} = useShopActions()
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<Touchable
|
|
15
|
-
// TODO: Add long press support to Touchable
|
|
16
|
-
// onLongPress={() => {
|
|
17
|
-
// showFeedbackSheet({publicId})
|
|
18
|
-
// }}
|
|
19
|
-
>
|
|
20
|
-
{children}
|
|
21
|
-
</Touchable>
|
|
22
|
-
)
|
|
23
|
-
}
|