@shopify/shop-minis-react 0.4.16 → 0.4.18
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/components/atoms/alert-dialog.js.map +1 -1
- package/dist/components/atoms/button.js.map +1 -1
- package/dist/components/atoms/icon-button.js.map +1 -1
- package/dist/components/atoms/image.js +65 -51
- package/dist/components/atoms/image.js.map +1 -1
- package/dist/components/atoms/list.js.map +1 -1
- package/dist/components/atoms/text-input.js.map +1 -1
- package/dist/components/atoms/touchable.js.map +1 -1
- package/dist/components/atoms/video-player.js +1 -1
- package/dist/components/atoms/video-player.js.map +1 -1
- package/dist/components/commerce/add-to-cart.js.map +1 -1
- package/dist/components/commerce/buy-now.js.map +1 -1
- package/dist/components/commerce/favorite-button.js +1 -4
- package/dist/components/commerce/favorite-button.js.map +1 -1
- package/dist/components/commerce/merchant-card.js.map +1 -1
- package/dist/components/commerce/product-link.js.map +1 -1
- package/dist/components/commerce/quantity-selector.js.map +1 -1
- package/dist/components/content/image-content-wrapper.js.map +1 -1
- package/dist/components/navigation/minis-router.js.map +1 -1
- package/dist/components/navigation/transition-link.js.map +1 -1
- package/dist/components/ui/alert.js.map +1 -1
- package/dist/components/ui/badge.js.map +1 -1
- package/dist/components/ui/input.js.map +1 -1
- package/dist/index.js +75 -73
- package/dist/utils/image.js +44 -24
- package/dist/utils/image.js.map +1 -1
- package/eslint/config.cjs +1 -0
- package/eslint/index.cjs +2 -0
- package/eslint/rules/no-javascript-files.cjs +44 -0
- package/package.json +1 -1
- package/src/components/atoms/alert-dialog.tsx +3 -3
- package/src/components/atoms/button.tsx +22 -0
- package/src/components/atoms/icon-button.tsx +16 -8
- package/src/components/atoms/image.test.tsx +27 -13
- package/src/components/atoms/image.tsx +41 -8
- package/src/components/atoms/list.tsx +25 -2
- package/src/components/atoms/text-input.tsx +3 -1
- package/src/components/atoms/touchable.tsx +15 -4
- package/src/components/atoms/video-player.tsx +16 -6
- package/src/components/commerce/add-to-cart.tsx +7 -11
- package/src/components/commerce/buy-now.tsx +7 -10
- package/src/components/commerce/favorite-button.tsx +6 -5
- package/src/components/commerce/merchant-card.tsx +4 -0
- package/src/components/commerce/product-link.tsx +15 -0
- package/src/components/commerce/quantity-selector.tsx +6 -1
- package/src/components/content/image-content-wrapper.tsx +16 -1
- package/src/components/navigation/minis-router.tsx +2 -2
- package/src/components/navigation/transition-link.tsx +11 -1
- package/src/components/ui/alert.tsx +7 -0
- package/src/components/ui/badge.tsx +9 -0
- package/src/components/ui/input.tsx +15 -0
- package/src/utils/image.ts +38 -0
|
@@ -4,7 +4,17 @@ import {useHref} from 'react-router'
|
|
|
4
4
|
|
|
5
5
|
import {useNavigateWithTransition} from '../../hooks/navigation/useNavigateWithTransition'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
export interface TransitionLinkDocProps {
|
|
8
|
+
/** The target path to navigate to */
|
|
9
|
+
to: string
|
|
10
|
+
/** Click handler called before navigation */
|
|
11
|
+
onClick?: React.MouseEventHandler<HTMLAnchorElement>
|
|
12
|
+
/** Content to render inside the link */
|
|
13
|
+
children?: React.ReactNode
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface TransitionLinkProps
|
|
17
|
+
extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
8
18
|
to: string
|
|
9
19
|
}
|
|
10
20
|
|
|
@@ -4,6 +4,13 @@ import {cva, type VariantProps} from 'class-variance-authority'
|
|
|
4
4
|
|
|
5
5
|
import {cn} from '../../lib/utils'
|
|
6
6
|
|
|
7
|
+
export interface AlertDocProps {
|
|
8
|
+
/** Visual style variant */
|
|
9
|
+
variant?: 'default' | 'destructive'
|
|
10
|
+
/** Content to render inside */
|
|
11
|
+
children?: React.ReactNode
|
|
12
|
+
}
|
|
13
|
+
|
|
7
14
|
const alertVariants = cva(
|
|
8
15
|
'relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current',
|
|
9
16
|
{
|
|
@@ -5,6 +5,15 @@ import {Slot as SlotPrimitive} from 'radix-ui'
|
|
|
5
5
|
|
|
6
6
|
import {cn} from '../../lib/utils'
|
|
7
7
|
|
|
8
|
+
export interface BadgeDocProps {
|
|
9
|
+
/** Visual style variant */
|
|
10
|
+
variant?: 'primary' | 'secondary' | 'destructive' | 'outline' | 'none'
|
|
11
|
+
/** Render as child element instead of span */
|
|
12
|
+
asChild?: boolean
|
|
13
|
+
/** Content to render inside */
|
|
14
|
+
children?: React.ReactNode
|
|
15
|
+
}
|
|
16
|
+
|
|
8
17
|
const badgeVariants = cva(
|
|
9
18
|
'inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none transition-[color,box-shadow] overflow-hidden',
|
|
10
19
|
{
|
|
@@ -2,6 +2,21 @@ import * as React from 'react'
|
|
|
2
2
|
|
|
3
3
|
import {cn} from '../../lib/utils'
|
|
4
4
|
|
|
5
|
+
export interface InputDocProps {
|
|
6
|
+
/** Ref to the input element (use instead of ref) */
|
|
7
|
+
innerRef?: React.Ref<HTMLInputElement>
|
|
8
|
+
/** Input type (text, email, password, etc.) */
|
|
9
|
+
type?: string
|
|
10
|
+
/** Placeholder text */
|
|
11
|
+
placeholder?: string
|
|
12
|
+
/** Current value */
|
|
13
|
+
value?: string
|
|
14
|
+
/** Change handler */
|
|
15
|
+
onChange?: React.ChangeEventHandler<HTMLInputElement>
|
|
16
|
+
/** Whether the input is disabled */
|
|
17
|
+
disabled?: boolean
|
|
18
|
+
}
|
|
19
|
+
|
|
5
20
|
// using the default ref doesn't seem to set the parent's ref object when mounted
|
|
6
21
|
// Since this is a shadCN component, we need to make sure to add back the innerRef prop,
|
|
7
22
|
// whenever the component is updated.
|
package/src/utils/image.ts
CHANGED
|
@@ -18,6 +18,44 @@ export function getThumbhashDataURL(thumbhash?: string): string | undefined {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Converts a data URL to a Blob
|
|
23
|
+
* @param dataURL The data URL to convert
|
|
24
|
+
* @returns A Blob object
|
|
25
|
+
*/
|
|
26
|
+
export function dataURLToBlob(dataURL: string): Blob {
|
|
27
|
+
const [header, base64Data] = dataURL.split(',')
|
|
28
|
+
const mimeMatch = header.match(/:(.*?);/)
|
|
29
|
+
const mime = mimeMatch ? mimeMatch[1] : 'image/png'
|
|
30
|
+
const binary = atob(base64Data)
|
|
31
|
+
const array = new Uint8Array(binary.length)
|
|
32
|
+
for (let i = 0; i < binary.length; i++) {
|
|
33
|
+
array[i] = binary.charCodeAt(i)
|
|
34
|
+
}
|
|
35
|
+
return new Blob([array], {type: mime})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Converts a thumbhash string to a blob URL for use as an image placeholder
|
|
40
|
+
* This is useful when CSP restrictions prevent data URLs
|
|
41
|
+
* @param thumbhash Base64 encoded thumbhash string
|
|
42
|
+
* @returns Blob URL that can be used as image source or undefined if conversion fails
|
|
43
|
+
*/
|
|
44
|
+
export function getThumbhashBlobURL(thumbhash?: string): string | undefined {
|
|
45
|
+
if (!thumbhash) return
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
const dataURL = getThumbhashDataURL(thumbhash)
|
|
49
|
+
if (!dataURL) return
|
|
50
|
+
|
|
51
|
+
const blob = dataURLToBlob(dataURL)
|
|
52
|
+
return URL.createObjectURL(blob)
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.warn('Failed to create thumbhash blob URL', error)
|
|
55
|
+
return undefined
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
21
59
|
/** Converts a file to a data URI
|
|
22
60
|
* @param file The file to convert
|
|
23
61
|
* @returns A promise that resolves to the data URI string
|