@shopify/shop-minis-react 0.1.1 → 0.1.2

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.
@@ -1,5 +1,5 @@
1
- var e = { exports: {} };
1
+ var r = {};
2
2
  export {
3
- e as __module
3
+ r as __exports
4
4
  };
5
5
  //# sourceMappingURL=index10.js.map
@@ -1,5 +1,6 @@
1
- var e = { exports: {} };
1
+ import { __require as r } from "../shop-minis-react/node_modules/.pnpm/use-sync-external-store@1.5.0_react@19.1.0/node_modules/use-sync-external-store/shim/index.js";
2
+ var i = r();
2
3
  export {
3
- e as __module
4
+ i as s
4
5
  };
5
6
  //# sourceMappingURL=index4.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index4.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"index4.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -1,6 +1,5 @@
1
- import { __require as r } from "../shop-minis-react/node_modules/.pnpm/@xmldom_xmldom@0.8.10/node_modules/@xmldom/xmldom/lib/index.js";
2
- var i = r();
1
+ var e = { exports: {} };
3
2
  export {
4
- i as l
3
+ e as __module
5
4
  };
6
5
  //# sourceMappingURL=index5.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index5.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
1
+ {"version":3,"file":"index5.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,6 +1,6 @@
1
- import { __require as r } from "../shop-minis-react/node_modules/.pnpm/use-sync-external-store@1.5.0_react@19.1.0/node_modules/use-sync-external-store/shim/index.js";
1
+ import { __require as r } from "../shop-minis-react/node_modules/.pnpm/@xmldom_xmldom@0.8.10/node_modules/@xmldom/xmldom/lib/index.js";
2
2
  var i = r();
3
3
  export {
4
- i as s
4
+ i as l
5
5
  };
6
6
  //# sourceMappingURL=index6.js.map
@@ -1,5 +1,5 @@
1
- var r = {};
1
+ var e = { exports: {} };
2
2
  export {
3
- r as __exports
3
+ e as __module
4
4
  };
5
5
  //# sourceMappingURL=index9.js.map
@@ -1,52 +1,64 @@
1
- import { jsx as s } from "react/jsx-runtime";
2
- import { memo as f, useState as L, useMemo as r, useCallback as v } from "react";
3
- import { cn as c } from "../../lib/utils.js";
4
- import { getThumbhashDataURL as I, getResizedImageUrl as k } from "../../utils/image.js";
5
- const U = f(function(m) {
1
+ import { jsx as n } from "react/jsx-runtime";
2
+ import { memo as v, useState as i, useEffect as k, useMemo as u, useCallback as I } from "react";
3
+ import { cn as m } from "../../lib/utils.js";
4
+ import { getThumbhashDataURL as j, getResizedImageUrl as y } from "../../utils/image.js";
5
+ const O = v(function(d) {
6
6
  const {
7
- src: e,
8
- thumbhash: o,
9
- onLoad: a,
10
- className: i,
11
- style: n,
12
- aspectRatio: l = "auto",
13
- ...d
14
- } = m, [u, g] = L(!1), t = r(
15
- () => I(o ?? void 0),
16
- [o]
17
- ), h = v(
18
- (p) => {
19
- g(!0), a?.(p);
20
- },
7
+ src: r,
8
+ file: t,
9
+ thumbhash: a,
10
+ onLoad: s,
11
+ className: b,
12
+ style: f,
13
+ aspectRatio: g = "auto",
14
+ ...h
15
+ } = d, [L, p] = i(!1), [o, c] = i(null);
16
+ k(() => {
17
+ if (!t) {
18
+ c(null);
19
+ return;
20
+ }
21
+ const e = URL.createObjectURL(t);
22
+ return c(e), () => {
23
+ URL.revokeObjectURL(e);
24
+ };
25
+ }, [t]);
26
+ const l = u(
27
+ () => j(a ?? void 0),
21
28
  [a]
22
- ), b = r(() => k(e), [e]);
23
- return /* @__PURE__ */ s(
29
+ ), U = I(
30
+ (e) => {
31
+ p(!0), s?.(e);
32
+ },
33
+ [s]
34
+ ), R = u(() => o || y(r), [o, r]);
35
+ return /* @__PURE__ */ n(
24
36
  "div",
25
37
  {
26
- className: c("relative w-full ", i),
38
+ className: m("relative w-full ", b),
27
39
  style: {
28
- ...n,
29
- aspectRatio: l,
30
- backgroundImage: t ? `url(${t})` : void 0,
40
+ ...f,
41
+ aspectRatio: g,
42
+ backgroundImage: l ? `url(${l})` : void 0,
31
43
  backgroundSize: "cover",
32
44
  backgroundPosition: "center"
33
45
  },
34
- children: /* @__PURE__ */ s(
46
+ children: /* @__PURE__ */ n(
35
47
  "img",
36
48
  {
37
- className: c(
49
+ className: m(
38
50
  "absolute inset-0 opacity-0 size-full object-cover",
39
- u && "opacity-100"
51
+ L && "opacity-100"
40
52
  ),
41
- src: b,
42
- onLoad: h,
43
- ...d
53
+ src: R,
54
+ onLoad: U,
55
+ ...h
44
56
  }
45
57
  )
46
58
  }
47
59
  );
48
60
  });
49
61
  export {
50
- U as Image
62
+ O as Image
51
63
  };
52
64
  //# sourceMappingURL=image.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"image.js","sources":["../../../src/components/atoms/image.tsx"],"sourcesContent":["/* eslint-disable jsx-a11y/alt-text */\n/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */\nimport {ImgHTMLAttributes, useCallback, useMemo, memo, useState} from 'react'\n\nimport {cn} from '../../lib/utils'\nimport {getThumbhashDataURL, getResizedImageUrl} from '../../utils'\n\ntype ImageProps = ImgHTMLAttributes<HTMLImageElement> & {\n src?: string\n thumbhash?: string | null\n aspectRatio?: number | string\n}\n\nexport const Image = memo(function Image(props: ImageProps) {\n const {\n src,\n thumbhash,\n onLoad,\n className,\n style,\n aspectRatio = 'auto',\n ...restProps\n } = props\n\n const [isLoaded, setIsLoaded] = useState(false)\n\n const thumbhashDataURL = useMemo(\n () => getThumbhashDataURL(thumbhash ?? undefined),\n [thumbhash]\n )\n\n const handleLoad = useCallback(\n (event: React.SyntheticEvent<HTMLImageElement, Event>) => {\n setIsLoaded(true)\n onLoad?.(event)\n },\n [onLoad]\n )\n\n const resizedImageSrc = useMemo(() => getResizedImageUrl(src), [src])\n\n return (\n <div\n className={cn('relative w-full ', className)}\n style={{\n ...style,\n aspectRatio,\n backgroundImage: thumbhashDataURL\n ? `url(${thumbhashDataURL})`\n : undefined,\n backgroundSize: 'cover',\n backgroundPosition: 'center',\n }}\n >\n <img\n className={cn(\n 'absolute inset-0 opacity-0 size-full object-cover',\n isLoaded && 'opacity-100'\n )}\n src={resizedImageSrc}\n onLoad={handleLoad}\n {...restProps}\n />\n </div>\n )\n})\n"],"names":["Image","memo","props","src","thumbhash","onLoad","className","style","aspectRatio","restProps","isLoaded","setIsLoaded","useState","thumbhashDataURL","useMemo","getThumbhashDataURL","handleLoad","useCallback","event","resizedImageSrc","getResizedImageUrl","jsx","cn"],"mappings":";;;;AAaO,MAAMA,IAAQC,EAAK,SAAeC,GAAmB;AACpD,QAAA;AAAA,IACJ,KAAAC;AAAA,IACA,WAAAC;AAAA,IACA,QAAAC;AAAA,IACA,WAAAC;AAAA,IACA,OAAAC;AAAA,IACA,aAAAC,IAAc;AAAA,IACd,GAAGC;AAAA,EAAA,IACDP,GAEE,CAACQ,GAAUC,CAAW,IAAIC,EAAS,EAAK,GAExCC,IAAmBC;AAAA,IACvB,MAAMC,EAAoBX,KAAa,MAAS;AAAA,IAChD,CAACA,CAAS;AAAA,EACZ,GAEMY,IAAaC;AAAA,IACjB,CAACC,MAAyD;AACxD,MAAAP,EAAY,EAAI,GAChBN,IAASa,CAAK;AAAA,IAChB;AAAA,IACA,CAACb,CAAM;AAAA,EACT,GAEMc,IAAkBL,EAAQ,MAAMM,EAAmBjB,CAAG,GAAG,CAACA,CAAG,CAAC;AAGlE,SAAA,gBAAAkB;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWC,EAAG,oBAAoBhB,CAAS;AAAA,MAC3C,OAAO;AAAA,QACL,GAAGC;AAAA,QACH,aAAAC;AAAA,QACA,iBAAiBK,IACb,OAAOA,CAAgB,MACvB;AAAA,QACJ,gBAAgB;AAAA,QAChB,oBAAoB;AAAA,MACtB;AAAA,MAEA,UAAA,gBAAAQ;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAWC;AAAA,YACT;AAAA,YACAZ,KAAY;AAAA,UACd;AAAA,UACA,KAAKS;AAAA,UACL,QAAQH;AAAA,UACP,GAAGP;AAAA,QAAA;AAAA,MAAA;AAAA,IACN;AAAA,EACF;AAEJ,CAAC;"}
1
+ {"version":3,"file":"image.js","sources":["../../../src/components/atoms/image.tsx"],"sourcesContent":["/* eslint-disable jsx-a11y/alt-text */\n/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */\nimport {\n ImgHTMLAttributes,\n useCallback,\n useMemo,\n memo,\n useState,\n useEffect,\n} from 'react'\n\nimport {cn} from '../../lib/utils'\nimport {getThumbhashDataURL, getResizedImageUrl} from '../../utils'\n\ntype ImageProps = ImgHTMLAttributes<HTMLImageElement> & {\n src?: string\n file?: File\n thumbhash?: string | null\n aspectRatio?: number | string\n}\n\nexport const Image = memo(function Image(props: ImageProps) {\n const {\n src,\n file,\n thumbhash,\n onLoad,\n className,\n style,\n aspectRatio = 'auto',\n ...restProps\n } = props\n\n const [isLoaded, setIsLoaded] = useState(false)\n const [blobUrl, setBlobUrl] = useState<string | null>(null)\n\n // Create and manage blob URL for File objects\n useEffect(() => {\n if (!file) {\n setBlobUrl(null)\n return\n }\n\n const url = URL.createObjectURL(file)\n setBlobUrl(url)\n\n // Cleanup on unmount or when file changes\n return () => {\n URL.revokeObjectURL(url)\n }\n }, [file])\n\n const thumbhashDataURL = useMemo(\n () => getThumbhashDataURL(thumbhash ?? undefined),\n [thumbhash]\n )\n\n const handleLoad = useCallback(\n (event: React.SyntheticEvent<HTMLImageElement, Event>) => {\n setIsLoaded(true)\n onLoad?.(event)\n },\n [onLoad]\n )\n\n // Use blob URL if file is provided, otherwise use src\n const imageSrc = useMemo(() => {\n if (blobUrl) return blobUrl\n return getResizedImageUrl(src)\n }, [blobUrl, src])\n\n return (\n <div\n className={cn('relative w-full ', className)}\n style={{\n ...style,\n aspectRatio,\n backgroundImage: thumbhashDataURL\n ? `url(${thumbhashDataURL})`\n : undefined,\n backgroundSize: 'cover',\n backgroundPosition: 'center',\n }}\n >\n <img\n className={cn(\n 'absolute inset-0 opacity-0 size-full object-cover',\n isLoaded && 'opacity-100'\n )}\n src={imageSrc}\n onLoad={handleLoad}\n {...restProps}\n />\n </div>\n )\n})\n"],"names":["Image","memo","props","src","file","thumbhash","onLoad","className","style","aspectRatio","restProps","isLoaded","setIsLoaded","useState","blobUrl","setBlobUrl","useEffect","url","thumbhashDataURL","useMemo","getThumbhashDataURL","handleLoad","useCallback","event","imageSrc","getResizedImageUrl","jsx","cn"],"mappings":";;;;AAqBO,MAAMA,IAAQC,EAAK,SAAeC,GAAmB;AACpD,QAAA;AAAA,IACJ,KAAAC;AAAA,IACA,MAAAC;AAAA,IACA,WAAAC;AAAA,IACA,QAAAC;AAAA,IACA,WAAAC;AAAA,IACA,OAAAC;AAAA,IACA,aAAAC,IAAc;AAAA,IACd,GAAGC;AAAA,EAAA,IACDR,GAEE,CAACS,GAAUC,CAAW,IAAIC,EAAS,EAAK,GACxC,CAACC,GAASC,CAAU,IAAIF,EAAwB,IAAI;AAG1D,EAAAG,EAAU,MAAM;AACd,QAAI,CAACZ,GAAM;AACT,MAAAW,EAAW,IAAI;AACf;AAAA,IAAA;AAGI,UAAAE,IAAM,IAAI,gBAAgBb,CAAI;AACpC,WAAAW,EAAWE,CAAG,GAGP,MAAM;AACX,UAAI,gBAAgBA,CAAG;AAAA,IACzB;AAAA,EAAA,GACC,CAACb,CAAI,CAAC;AAET,QAAMc,IAAmBC;AAAA,IACvB,MAAMC,EAAoBf,KAAa,MAAS;AAAA,IAChD,CAACA,CAAS;AAAA,EACZ,GAEMgB,IAAaC;AAAA,IACjB,CAACC,MAAyD;AACxD,MAAAX,EAAY,EAAI,GAChBN,IAASiB,CAAK;AAAA,IAChB;AAAA,IACA,CAACjB,CAAM;AAAA,EACT,GAGMkB,IAAWL,EAAQ,MACnBL,KACGW,EAAmBtB,CAAG,GAC5B,CAACW,GAASX,CAAG,CAAC;AAGf,SAAA,gBAAAuB;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWC,EAAG,oBAAoBpB,CAAS;AAAA,MAC3C,OAAO;AAAA,QACL,GAAGC;AAAA,QACH,aAAAC;AAAA,QACA,iBAAiBS,IACb,OAAOA,CAAgB,MACvB;AAAA,QACJ,gBAAgB;AAAA,QAChB,oBAAoB;AAAA,MACtB;AAAA,MAEA,UAAA,gBAAAQ;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAWC;AAAA,YACT;AAAA,YACAhB,KAAY;AAAA,UACd;AAAA,UACA,KAAKa;AAAA,UACL,QAAQH;AAAA,UACP,GAAGX;AAAA,QAAA;AAAA,MAAA;AAAA,IACN;AAAA,EACF;AAEJ,CAAC;"}
@@ -1,4 +1,4 @@
1
- import { s as r } from "../../../../../../../../_virtual/index6.js";
1
+ import { s as r } from "../../../../../../../../_virtual/index4.js";
2
2
  function s() {
3
3
  return r.useSyncExternalStore(
4
4
  e,
@@ -1,4 +1,4 @@
1
- import { __module as q } from "../../../../../../../../_virtual/index4.js";
1
+ import { __module as q } from "../../../../../../../../_virtual/index5.js";
2
2
  import { __require as F } from "../../../../../global@4.4.0/node_modules/global/window.js";
3
3
  import { __require as N } from "../../../../../@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/extends.js";
4
4
  import { __require as J } from "../../../../../is-function@1.0.2/node_modules/is-function/index.js";
@@ -1,4 +1,4 @@
1
- import { __exports as r } from "../../../../../../../../_virtual/index9.js";
1
+ import { __exports as r } from "../../../../../../../../_virtual/index10.js";
2
2
  import { __require as a } from "./dom.js";
3
3
  import { __require as o } from "./dom-parser.js";
4
4
  var i;
@@ -2,7 +2,7 @@ import L from "../../../../@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-ut
2
2
  import T from "../../../../../../../_virtual/window.js";
3
3
  import { forEachMediaGroup as Z } from "../../../../@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/media-groups.js";
4
4
  import J from "../../../../@videojs_vhs-utils@4.1.1/node_modules/@videojs/vhs-utils/es/decode-b64-to-uint8-array.js";
5
- import { l as Q } from "../../../../../../../_virtual/index5.js";
5
+ import { l as Q } from "../../../../../../../_virtual/index6.js";
6
6
  /*! @name mpd-parser @version 1.3.1 @license Apache-2.0 */
7
7
  const w = (e) => !!e && typeof e == "object", E = (...e) => e.reduce((n, t) => (typeof t != "object" || Object.keys(t).forEach((r) => {
8
8
  Array.isArray(n[r]) && Array.isArray(t[r]) ? n[r] = n[r].concat(t[r]) : w(n[r]) && w(t[r]) ? n[r] = E(n[r], t[r]) : n[r] = t[r];
@@ -1,4 +1,4 @@
1
- import { __module as r } from "../../../../../../../_virtual/index10.js";
1
+ import { __module as r } from "../../../../../../../_virtual/index9.js";
2
2
  import { __require as o } from "../cjs/use-sync-external-store-shim.production.js";
3
3
  import { __require as i } from "../cjs/use-sync-external-store-shim.development.js";
4
4
  var e;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shopify/shop-minis-react",
3
3
  "license": "SEE LICENSE IN LICENSE.txt",
4
- "version": "0.1.1",
4
+ "version": "0.1.2",
5
5
  "sideEffects": false,
6
6
  "type": "module",
7
7
  "engines": {
@@ -1,12 +1,20 @@
1
1
  /* eslint-disable jsx-a11y/alt-text */
2
2
  /* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
3
- import {ImgHTMLAttributes, useCallback, useMemo, memo, useState} from 'react'
3
+ import {
4
+ ImgHTMLAttributes,
5
+ useCallback,
6
+ useMemo,
7
+ memo,
8
+ useState,
9
+ useEffect,
10
+ } from 'react'
4
11
 
5
12
  import {cn} from '../../lib/utils'
6
13
  import {getThumbhashDataURL, getResizedImageUrl} from '../../utils'
7
14
 
8
15
  type ImageProps = ImgHTMLAttributes<HTMLImageElement> & {
9
16
  src?: string
17
+ file?: File
10
18
  thumbhash?: string | null
11
19
  aspectRatio?: number | string
12
20
  }
@@ -14,6 +22,7 @@ type ImageProps = ImgHTMLAttributes<HTMLImageElement> & {
14
22
  export const Image = memo(function Image(props: ImageProps) {
15
23
  const {
16
24
  src,
25
+ file,
17
26
  thumbhash,
18
27
  onLoad,
19
28
  className,
@@ -23,6 +32,23 @@ export const Image = memo(function Image(props: ImageProps) {
23
32
  } = props
24
33
 
25
34
  const [isLoaded, setIsLoaded] = useState(false)
35
+ const [blobUrl, setBlobUrl] = useState<string | null>(null)
36
+
37
+ // Create and manage blob URL for File objects
38
+ useEffect(() => {
39
+ if (!file) {
40
+ setBlobUrl(null)
41
+ return
42
+ }
43
+
44
+ const url = URL.createObjectURL(file)
45
+ setBlobUrl(url)
46
+
47
+ // Cleanup on unmount or when file changes
48
+ return () => {
49
+ URL.revokeObjectURL(url)
50
+ }
51
+ }, [file])
26
52
 
27
53
  const thumbhashDataURL = useMemo(
28
54
  () => getThumbhashDataURL(thumbhash ?? undefined),
@@ -37,7 +63,11 @@ export const Image = memo(function Image(props: ImageProps) {
37
63
  [onLoad]
38
64
  )
39
65
 
40
- const resizedImageSrc = useMemo(() => getResizedImageUrl(src), [src])
66
+ // Use blob URL if file is provided, otherwise use src
67
+ const imageSrc = useMemo(() => {
68
+ if (blobUrl) return blobUrl
69
+ return getResizedImageUrl(src)
70
+ }, [blobUrl, src])
41
71
 
42
72
  return (
43
73
  <div
@@ -57,7 +87,7 @@ export const Image = memo(function Image(props: ImageProps) {
57
87
  'absolute inset-0 opacity-0 size-full object-cover',
58
88
  isLoaded && 'opacity-100'
59
89
  )}
60
- src={resizedImageSrc}
90
+ src={imageSrc}
61
91
  onLoad={handleLoad}
62
92
  {...restProps}
63
93
  />