@shopify/hydrogen-react 2022.7.0

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.
Files changed (172) hide show
  1. package/README.md +218 -0
  2. package/dist/dev/ExternalVideo.cjs +39 -0
  3. package/dist/dev/ExternalVideo.cjs.map +1 -0
  4. package/dist/dev/ExternalVideo.js +39 -0
  5. package/dist/dev/ExternalVideo.js.map +1 -0
  6. package/dist/dev/Image.cjs +104 -0
  7. package/dist/dev/Image.cjs.map +1 -0
  8. package/dist/dev/Image.js +104 -0
  9. package/dist/dev/Image.js.map +1 -0
  10. package/dist/dev/MediaFile.cjs +57 -0
  11. package/dist/dev/MediaFile.cjs.map +1 -0
  12. package/dist/dev/MediaFile.js +57 -0
  13. package/dist/dev/MediaFile.js.map +1 -0
  14. package/dist/dev/Metafield.cjs +295 -0
  15. package/dist/dev/Metafield.cjs.map +1 -0
  16. package/dist/dev/Metafield.js +295 -0
  17. package/dist/dev/Metafield.js.map +1 -0
  18. package/dist/dev/ModelViewer.cjs +145 -0
  19. package/dist/dev/ModelViewer.cjs.map +1 -0
  20. package/dist/dev/ModelViewer.js +145 -0
  21. package/dist/dev/ModelViewer.js.map +1 -0
  22. package/dist/dev/Money.cjs +40 -0
  23. package/dist/dev/Money.cjs.map +1 -0
  24. package/dist/dev/Money.js +40 -0
  25. package/dist/dev/Money.js.map +1 -0
  26. package/dist/dev/ProductPrice.cjs +61 -0
  27. package/dist/dev/ProductPrice.cjs.map +1 -0
  28. package/dist/dev/ProductPrice.js +61 -0
  29. package/dist/dev/ProductPrice.js.map +1 -0
  30. package/dist/dev/ProductProvider.cjs +161 -0
  31. package/dist/dev/ProductProvider.cjs.map +1 -0
  32. package/dist/dev/ProductProvider.js +161 -0
  33. package/dist/dev/ProductProvider.js.map +1 -0
  34. package/dist/dev/ShopPayButton.cjs +64 -0
  35. package/dist/dev/ShopPayButton.cjs.map +1 -0
  36. package/dist/dev/ShopPayButton.js +64 -0
  37. package/dist/dev/ShopPayButton.js.map +1 -0
  38. package/dist/dev/ShopifyProvider.cjs +46 -0
  39. package/dist/dev/ShopifyProvider.cjs.map +1 -0
  40. package/dist/dev/ShopifyProvider.js +46 -0
  41. package/dist/dev/ShopifyProvider.js.map +1 -0
  42. package/dist/dev/Video.cjs +44 -0
  43. package/dist/dev/Video.cjs.map +1 -0
  44. package/dist/dev/Video.js +44 -0
  45. package/dist/dev/Video.js.map +1 -0
  46. package/dist/dev/flatten-connection.cjs +23 -0
  47. package/dist/dev/flatten-connection.cjs.map +1 -0
  48. package/dist/dev/flatten-connection.js +23 -0
  49. package/dist/dev/flatten-connection.js.map +1 -0
  50. package/dist/dev/image-size.cjs +80 -0
  51. package/dist/dev/image-size.cjs.map +1 -0
  52. package/dist/dev/image-size.js +80 -0
  53. package/dist/dev/image-size.js.map +1 -0
  54. package/dist/dev/index.cjs +35 -0
  55. package/dist/dev/index.cjs.map +1 -0
  56. package/dist/dev/index.js +35 -0
  57. package/dist/dev/index.js.map +1 -0
  58. package/dist/dev/load-script.cjs +52 -0
  59. package/dist/dev/load-script.cjs.map +1 -0
  60. package/dist/dev/load-script.js +52 -0
  61. package/dist/dev/load-script.js.map +1 -0
  62. package/dist/dev/storefront-api-constants.cjs +5 -0
  63. package/dist/dev/storefront-api-constants.cjs.map +1 -0
  64. package/dist/dev/storefront-api-constants.js +5 -0
  65. package/dist/dev/storefront-api-constants.js.map +1 -0
  66. package/dist/dev/storefront-client.cjs +72 -0
  67. package/dist/dev/storefront-client.cjs.map +1 -0
  68. package/dist/dev/storefront-client.js +72 -0
  69. package/dist/dev/storefront-client.js.map +1 -0
  70. package/dist/dev/useMoney.cjs +72 -0
  71. package/dist/dev/useMoney.cjs.map +1 -0
  72. package/dist/dev/useMoney.js +72 -0
  73. package/dist/dev/useMoney.js.map +1 -0
  74. package/dist/prod/ExternalVideo.cjs +39 -0
  75. package/dist/prod/ExternalVideo.cjs.map +1 -0
  76. package/dist/prod/ExternalVideo.js +39 -0
  77. package/dist/prod/ExternalVideo.js.map +1 -0
  78. package/dist/prod/Image.cjs +99 -0
  79. package/dist/prod/Image.cjs.map +1 -0
  80. package/dist/prod/Image.js +99 -0
  81. package/dist/prod/Image.js.map +1 -0
  82. package/dist/prod/MediaFile.cjs +59 -0
  83. package/dist/prod/MediaFile.cjs.map +1 -0
  84. package/dist/prod/MediaFile.js +59 -0
  85. package/dist/prod/MediaFile.js.map +1 -0
  86. package/dist/prod/Metafield.cjs +288 -0
  87. package/dist/prod/Metafield.cjs.map +1 -0
  88. package/dist/prod/Metafield.js +288 -0
  89. package/dist/prod/Metafield.js.map +1 -0
  90. package/dist/prod/ModelViewer.cjs +143 -0
  91. package/dist/prod/ModelViewer.cjs.map +1 -0
  92. package/dist/prod/ModelViewer.js +143 -0
  93. package/dist/prod/ModelViewer.js.map +1 -0
  94. package/dist/prod/Money.cjs +40 -0
  95. package/dist/prod/Money.cjs.map +1 -0
  96. package/dist/prod/Money.js +40 -0
  97. package/dist/prod/Money.js.map +1 -0
  98. package/dist/prod/ProductPrice.cjs +61 -0
  99. package/dist/prod/ProductPrice.cjs.map +1 -0
  100. package/dist/prod/ProductPrice.js +61 -0
  101. package/dist/prod/ProductPrice.js.map +1 -0
  102. package/dist/prod/ProductProvider.cjs +161 -0
  103. package/dist/prod/ProductProvider.cjs.map +1 -0
  104. package/dist/prod/ProductProvider.js +161 -0
  105. package/dist/prod/ProductProvider.js.map +1 -0
  106. package/dist/prod/ShopPayButton.cjs +64 -0
  107. package/dist/prod/ShopPayButton.cjs.map +1 -0
  108. package/dist/prod/ShopPayButton.js +64 -0
  109. package/dist/prod/ShopPayButton.js.map +1 -0
  110. package/dist/prod/ShopifyProvider.cjs +46 -0
  111. package/dist/prod/ShopifyProvider.cjs.map +1 -0
  112. package/dist/prod/ShopifyProvider.js +46 -0
  113. package/dist/prod/ShopifyProvider.js.map +1 -0
  114. package/dist/prod/Video.cjs +44 -0
  115. package/dist/prod/Video.cjs.map +1 -0
  116. package/dist/prod/Video.js +44 -0
  117. package/dist/prod/Video.js.map +1 -0
  118. package/dist/prod/flatten-connection.cjs +18 -0
  119. package/dist/prod/flatten-connection.cjs.map +1 -0
  120. package/dist/prod/flatten-connection.js +18 -0
  121. package/dist/prod/flatten-connection.js.map +1 -0
  122. package/dist/prod/image-size.cjs +80 -0
  123. package/dist/prod/image-size.cjs.map +1 -0
  124. package/dist/prod/image-size.js +80 -0
  125. package/dist/prod/image-size.js.map +1 -0
  126. package/dist/prod/index.cjs +35 -0
  127. package/dist/prod/index.cjs.map +1 -0
  128. package/dist/prod/index.js +35 -0
  129. package/dist/prod/index.js.map +1 -0
  130. package/dist/prod/load-script.cjs +52 -0
  131. package/dist/prod/load-script.cjs.map +1 -0
  132. package/dist/prod/load-script.js +52 -0
  133. package/dist/prod/load-script.js.map +1 -0
  134. package/dist/prod/storefront-api-constants.cjs +5 -0
  135. package/dist/prod/storefront-api-constants.cjs.map +1 -0
  136. package/dist/prod/storefront-api-constants.js +5 -0
  137. package/dist/prod/storefront-api-constants.js.map +1 -0
  138. package/dist/prod/storefront-client.cjs +57 -0
  139. package/dist/prod/storefront-client.cjs.map +1 -0
  140. package/dist/prod/storefront-client.js +57 -0
  141. package/dist/prod/storefront-client.js.map +1 -0
  142. package/dist/prod/useMoney.cjs +72 -0
  143. package/dist/prod/useMoney.cjs.map +1 -0
  144. package/dist/prod/useMoney.js +72 -0
  145. package/dist/prod/useMoney.js.map +1 -0
  146. package/dist/types/ExternalVideo.d.ts +67 -0
  147. package/dist/types/Image.d.ts +54 -0
  148. package/dist/types/MediaFile.d.ts +31 -0
  149. package/dist/types/Metafield.d.ts +58 -0
  150. package/dist/types/ModelViewer.d.ts +57 -0
  151. package/dist/types/Money.d.ts +29 -0
  152. package/dist/types/ProductPrice.d.ts +22 -0
  153. package/dist/types/ProductProvider.d.ts +74 -0
  154. package/dist/types/ShopPayButton.d.ts +42 -0
  155. package/dist/types/ShopifyProvider.d.ts +42 -0
  156. package/dist/types/Video.d.ts +20 -0
  157. package/dist/types/flatten-connection.d.ts +17 -0
  158. package/dist/types/image-size.d.ts +36 -0
  159. package/dist/types/index.d.cts +15 -0
  160. package/dist/types/index.d.ts +15 -0
  161. package/dist/types/load-script.d.ts +11 -0
  162. package/dist/types/storefront-api-constants.d.ts +1 -0
  163. package/dist/types/storefront-api-response.types.d.ts +68 -0
  164. package/dist/types/storefront-api-types.d.ts +6537 -0
  165. package/dist/types/storefront-client.d.ts +63 -0
  166. package/dist/types/useMoney.d.ts +55 -0
  167. package/dist/umd/hydrogen-react.dev.js +1472 -0
  168. package/dist/umd/hydrogen-react.dev.js.map +1 -0
  169. package/dist/umd/hydrogen-react.prod.js +3 -0
  170. package/dist/umd/hydrogen-react.prod.js.map +1 -0
  171. package/package.json +106 -0
  172. package/storefront.schema.json +1 -0
@@ -0,0 +1,57 @@
1
+ import { Image } from "./Image.js";
2
+ import { Video } from "./Video.js";
3
+ import { ExternalVideo } from "./ExternalVideo.js";
4
+ import { ModelViewer } from "./ModelViewer.js";
5
+ import { jsx } from "react/jsx-runtime";
6
+ function MediaFile({
7
+ data,
8
+ mediaOptions,
9
+ ...passthroughProps
10
+ }) {
11
+ switch (data.__typename) {
12
+ case "MediaImage": {
13
+ if (!data.image) {
14
+ const noDataImage = `<MediaFile/>: 'data.image' does not exist for __typename of 'MediaImage'; rendering 'null' by default.`;
15
+ {
16
+ throw new Error(noDataImage);
17
+ }
18
+ }
19
+ return /* @__PURE__ */ jsx(Image, {
20
+ ...passthroughProps,
21
+ ...mediaOptions == null ? void 0 : mediaOptions.image,
22
+ data: data.image
23
+ });
24
+ }
25
+ case "Video": {
26
+ return /* @__PURE__ */ jsx(Video, {
27
+ ...passthroughProps,
28
+ ...mediaOptions == null ? void 0 : mediaOptions.video,
29
+ data
30
+ });
31
+ }
32
+ case "ExternalVideo": {
33
+ return /* @__PURE__ */ jsx(ExternalVideo, {
34
+ ...passthroughProps,
35
+ ...mediaOptions == null ? void 0 : mediaOptions.externalVideo,
36
+ data
37
+ });
38
+ }
39
+ case "Model3d": {
40
+ return /* @__PURE__ */ jsx(ModelViewer, {
41
+ ...passthroughProps,
42
+ ...mediaOptions == null ? void 0 : mediaOptions.modelViewer,
43
+ data
44
+ });
45
+ }
46
+ default: {
47
+ const typenameMissingMessage = `<MediaFile /> requires the '__typename' property to exist on the 'data' prop in order to correctly render the correct component for this media. Rendering 'null' by default`;
48
+ {
49
+ throw new Error(typenameMissingMessage);
50
+ }
51
+ }
52
+ }
53
+ }
54
+ export {
55
+ MediaFile
56
+ };
57
+ //# sourceMappingURL=MediaFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MediaFile.js","sources":["../../src/MediaFile.tsx"],"sourcesContent":["import React from 'react';\nimport {Image, type ShopifyImageProps} from './Image.js';\nimport {Video} from './Video.js';\nimport {ExternalVideo} from './ExternalVideo.js';\nimport {ModelViewer} from './ModelViewer.js';\nimport type {MediaEdge as MediaEdgeType} from './storefront-api-types.js';\nimport type {PartialDeep} from 'type-fest';\n\ninterface MediaFileProps {\n /** An object with fields that correspond to the Storefront API's [Media object](https://shopify.dev/api/storefront/reference/products/media). */\n data: PartialDeep<MediaEdgeType['node'], {recurseIntoArrays: true}>;\n /** The options for the `Image`, `Video`, or `ExternalVideo` components. */\n mediaOptions?: {\n /** Props that will only apply when an `<Image />` is rendered */\n image: Omit<ShopifyImageProps, 'data'>;\n /** Props that will only apply when a `<Video />` is rendered */\n video: Omit<React.ComponentProps<typeof Video>, 'data'>;\n /** Props that will only apply when an `<ExternalVideo />` is rendered */\n externalVideo: Omit<\n React.ComponentProps<typeof ExternalVideo>['options'],\n 'data'\n >;\n /** Props that will only apply when a `<ModelViewer />` is rendered */\n modelViewer: Omit<typeof ModelViewer, 'data'>;\n };\n}\n\n/**\n * The `MediaFile` component renders the media for the Storefront API's\n * [Media object](https://shopify.dev/api/storefront/reference/products/media). It renders an `Image`, a\n * `Video`, an `ExternalVideo`, or a `ModelViewer` depending on the `__typename` of the `data` prop.\n */\nexport function MediaFile({\n data,\n mediaOptions,\n ...passthroughProps\n}: MediaFileProps) {\n switch (data.__typename) {\n case 'MediaImage': {\n if (!data.image) {\n const noDataImage = `<MediaFile/>: 'data.image' does not exist for __typename of 'MediaImage'; rendering 'null' by default.`;\n if (__HYDROGEN_DEV__) {\n throw new Error(noDataImage);\n } else {\n console.warn(noDataImage);\n return null;\n }\n }\n\n return (\n <Image\n {...passthroughProps}\n {...mediaOptions?.image}\n data={data.image}\n />\n );\n }\n case 'Video': {\n return (\n <Video {...passthroughProps} {...mediaOptions?.video} data={data} />\n );\n }\n case 'ExternalVideo': {\n return (\n <ExternalVideo\n {...passthroughProps}\n {...mediaOptions?.externalVideo}\n data={data}\n />\n );\n }\n case 'Model3d': {\n return (\n <ModelViewer\n {...passthroughProps}\n {...mediaOptions?.modelViewer}\n data={data}\n />\n );\n }\n default: {\n const typenameMissingMessage = `<MediaFile /> requires the '__typename' property to exist on the 'data' prop in order to correctly render the correct component for this media. Rendering 'null' by default`;\n if (__HYDROGEN_DEV__) {\n throw new Error(typenameMissingMessage);\n } else {\n console.error(typenameMissingMessage);\n return null;\n }\n }\n }\n}\n"],"names":["MediaFile","data","mediaOptions","passthroughProps","__typename","image","noDataImage","Error","video","externalVideo","modelViewer","typenameMissingMessage"],"mappings":";;;;;AAgCO,SAASA,UAAU;AAAA,EACxBC;AAAAA,EACAC;AAAAA,KACGC;AAHqB,GAIP;AACjB,UAAQF,KAAKG,YAAb;AAAA,IACE,KAAK,cAAc;AACb,UAAA,CAACH,KAAKI,OAAO;AACf,cAAMC,cAAe;AACC;AACd,gBAAA,IAAIC,MAAMD,WAAV;AAAA,QAIP;AAAA,MACF;AAED,iCACG,OAAD;AAAA,QAAA,GACMH;AAAAA,QADN,GAEMD,6CAAcG;AAAAA,QAClB,MAAMJ,KAAKI;AAAAA,MAAAA,CAJf;AAAA,IAOD;AAAA,IACD,KAAK,SAAS;AACZ,iCACG,OAAD;AAAA,QAAA,GAAWF;AAAAA,QAAX,GAAiCD,6CAAcM;AAAAA,QAAO;AAAA,MAAA,CADxD;AAAA,IAGD;AAAA,IACD,KAAK,iBAAiB;AACpB,iCACG,eAAD;AAAA,QAAA,GACML;AAAAA,QADN,GAEMD,6CAAcO;AAAAA,QAClB;AAAA,MAAA,CAJJ;AAAA,IAOD;AAAA,IACD,KAAK,WAAW;AACd,iCACG,aAAD;AAAA,QAAA,GACMN;AAAAA,QADN,GAEMD,6CAAcQ;AAAAA,QAClB;AAAA,MAAA,CAJJ;AAAA,IAOD;AAAA,IACD,SAAS;AACP,YAAMC,yBAA0B;AACV;AACd,cAAA,IAAIJ,MAAMI,sBAAV;AAAA,MAIP;AAAA,IACF;AAAA,EAnDH;AAqDD;"}
@@ -0,0 +1,295 @@
1
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ const react = require("react");
4
+ const ShopifyProvider = require("./ShopifyProvider.cjs");
5
+ const Image = require("./Image.cjs");
6
+ const Video = require("./Video.cjs");
7
+ const flattenConnection = require("./flatten-connection.cjs");
8
+ const jsxRuntime = require("react/jsx-runtime");
9
+ function Metafield(props) {
10
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
11
+ const {
12
+ data,
13
+ as,
14
+ ...passthroughProps
15
+ } = props;
16
+ const {
17
+ locale
18
+ } = ShopifyProvider.useShop();
19
+ const parsedMetafield = react.useMemo(() => parseMetafield(data), [data]);
20
+ if (!parsedMetafield) {
21
+ const noDataPropWarning = `<Metafield/>: nothing was passed to the data prop 'data'. Rendering 'null'`;
22
+ {
23
+ throw new Error(noDataPropWarning);
24
+ }
25
+ }
26
+ if (parsedMetafield.value === null || parsedMetafield.value === void 0) {
27
+ const noValueWarning = `<Metafield/>: No metafield value for metafield ${(_a = parsedMetafield.id) != null ? _a : parsedMetafield.key}. Rendering 'null'`;
28
+ {
29
+ throw new Error(noValueWarning);
30
+ }
31
+ }
32
+ switch (parsedMetafield.type) {
33
+ case "date": {
34
+ const Wrapper2 = as != null ? as : "time";
35
+ return /* @__PURE__ */ jsxRuntime.jsx(Wrapper2, {
36
+ ...passthroughProps,
37
+ children: parsedMetafield.value.toLocaleDateString(locale)
38
+ });
39
+ }
40
+ case "date_time": {
41
+ const Wrapper2 = as != null ? as : "time";
42
+ return /* @__PURE__ */ jsxRuntime.jsx(Wrapper2, {
43
+ ...passthroughProps,
44
+ children: parsedMetafield.value.toLocaleString(locale)
45
+ });
46
+ }
47
+ case "weight":
48
+ case "dimension":
49
+ case "volume": {
50
+ const Wrapper2 = as != null ? as : "span";
51
+ return /* @__PURE__ */ jsxRuntime.jsx(Wrapper2, {
52
+ ...passthroughProps,
53
+ children: getMeasurementAsString(parsedMetafield.value, locale)
54
+ });
55
+ }
56
+ case "rating": {
57
+ const Wrapper2 = as != null ? as : "span";
58
+ return /* @__PURE__ */ jsxRuntime.jsx(Wrapper2, {
59
+ ...passthroughProps,
60
+ children: parsedMetafield.value.value
61
+ });
62
+ }
63
+ case "single_line_text_field": {
64
+ const Wrapper2 = as != null ? as : "span";
65
+ return /* @__PURE__ */ jsxRuntime.jsx(Wrapper2, {
66
+ ...passthroughProps,
67
+ dangerouslySetInnerHTML: {
68
+ __html: parsedMetafield.value
69
+ }
70
+ });
71
+ }
72
+ case "multi_line_text_field": {
73
+ const Wrapper2 = as != null ? as : "div";
74
+ return /* @__PURE__ */ jsxRuntime.jsx(Wrapper2, {
75
+ ...passthroughProps,
76
+ dangerouslySetInnerHTML: {
77
+ __html: parsedMetafield.value.split("\n").join("<br/>")
78
+ }
79
+ });
80
+ }
81
+ case "url": {
82
+ const protocolLessUrl = new URL(parsedMetafield.value);
83
+ return /* @__PURE__ */ jsxRuntime.jsx("a", {
84
+ href: protocolLessUrl.href.replace(protocolLessUrl.protocol, ""),
85
+ ...passthroughProps,
86
+ children: parsedMetafield.value
87
+ });
88
+ }
89
+ case "json": {
90
+ const Wrapper2 = as != null ? as : "span";
91
+ return /* @__PURE__ */ jsxRuntime.jsx(Wrapper2, {
92
+ ...passthroughProps,
93
+ children: JSON.stringify(parsedMetafield.value)
94
+ });
95
+ }
96
+ case "product_reference":
97
+ case "variant_reference":
98
+ case "page_reference": {
99
+ const Wrapper2 = as != null ? as : "span";
100
+ const ref = parsedMetafield.reference;
101
+ return /* @__PURE__ */ jsxRuntime.jsx(Wrapper2, {
102
+ ...passthroughProps,
103
+ children: (_c = (_b = ref == null ? void 0 : ref.title) != null ? _b : ref == null ? void 0 : ref.id) != null ? _c : ""
104
+ });
105
+ }
106
+ case "list.single_line_text_field": {
107
+ const Wrapper2 = as != null ? as : "ul";
108
+ const refArray = parsedMetafield.references ? flattenConnection.flattenConnection(parsedMetafield.references) : [];
109
+ return /* @__PURE__ */ jsxRuntime.jsx(Wrapper2, {
110
+ ...passthroughProps,
111
+ children: refArray.map((ref, index) => /* @__PURE__ */ jsxRuntime.jsx("li", {
112
+ children: ref
113
+ }, `${ref != null ? ref : ""}-${index}`))
114
+ });
115
+ }
116
+ case "file_reference": {
117
+ if (((_d = parsedMetafield.reference) == null ? void 0 : _d.__typename) === "MediaImage") {
118
+ const ref = parsedMetafield.reference;
119
+ return ref.image ? /* @__PURE__ */ jsxRuntime.jsx(Image.Image, {
120
+ data: ref.image,
121
+ ...passthroughProps
122
+ }) : null;
123
+ } else if (((_e = parsedMetafield.reference) == null ? void 0 : _e.__typename) === "GenericFile") {
124
+ const ref = parsedMetafield.reference;
125
+ return ref.previewImage ? /* @__PURE__ */ jsxRuntime.jsx("a", {
126
+ href: (_g = (_f = parsedMetafield.reference) == null ? void 0 : _f.url) != null ? _g : "",
127
+ ...passthroughProps,
128
+ children: /* @__PURE__ */ jsxRuntime.jsx(Image.Image, {
129
+ data: ref.previewImage
130
+ })
131
+ }) : null;
132
+ } else if (((_h = parsedMetafield.reference) == null ? void 0 : _h.__typename) === "Video") {
133
+ const ref = parsedMetafield.reference;
134
+ return /* @__PURE__ */ jsxRuntime.jsx(Video.Video, {
135
+ ...passthroughProps,
136
+ data: ref
137
+ });
138
+ }
139
+ }
140
+ }
141
+ const Wrapper = as != null ? as : "span";
142
+ return /* @__PURE__ */ jsxRuntime.jsx(Wrapper, {
143
+ ...passthroughProps,
144
+ children: (_i = parsedMetafield.value) == null ? void 0 : _i.toString()
145
+ });
146
+ }
147
+ function parseMetafield(metafield) {
148
+ if (!metafield) {
149
+ {
150
+ console.warn(`'parseMetafield' was not passed any value for the 'metafield' argument`);
151
+ }
152
+ return null;
153
+ }
154
+ if (metafield.value === null || metafield.value === void 0) {
155
+ console.warn(`'parseMetafield()' was passed ${metafield.value} for 'metafield.value'`);
156
+ }
157
+ return {
158
+ ...metafield,
159
+ value: parseMetafieldValue(metafield)
160
+ };
161
+ }
162
+ function parseMetafieldValue(metafield) {
163
+ if (!metafield) {
164
+ return null;
165
+ }
166
+ if (metafield.value === null || metafield.value === void 0) {
167
+ {
168
+ console.warn(`'parseMetafieldValue()' was passed ${metafield.value} for 'metafield.value'`);
169
+ }
170
+ return metafield.value;
171
+ }
172
+ switch (metafield.type) {
173
+ case "boolean":
174
+ return metafield.value === "true";
175
+ case "number_integer":
176
+ return parseInt(metafield.value);
177
+ case "number_decimal":
178
+ return parseFloat(metafield.value);
179
+ case "date":
180
+ case "date_time":
181
+ return new Date(metafield.value);
182
+ case "json":
183
+ case "weight":
184
+ case "dimension":
185
+ case "volume":
186
+ case "rating":
187
+ return parseJSON(metafield.value);
188
+ case "color":
189
+ case "single_line_text_field":
190
+ case "multi_line_text_field":
191
+ case "product_reference":
192
+ case "page_reference":
193
+ case "variant_reference":
194
+ case "file_reference":
195
+ case "url":
196
+ default:
197
+ return metafield.value;
198
+ }
199
+ }
200
+ function parseJSON(json) {
201
+ if (String(json).includes("__proto__")) {
202
+ return JSON.parse(json, (k, v) => {
203
+ if (k !== "__proto__")
204
+ return v;
205
+ });
206
+ }
207
+ return JSON.parse(json);
208
+ }
209
+ const UNIT_MAPPING = {
210
+ mm: "millimeter",
211
+ cm: "centimeter",
212
+ m: "meter",
213
+ in: "inch",
214
+ ft: "foot",
215
+ yd: "yard",
216
+ ml: "milliliter",
217
+ l: "liter",
218
+ us_fl_oz: "fluid-ounce",
219
+ us_gal: "gallon",
220
+ kg: "kilogram",
221
+ g: "gram",
222
+ lb: "pound",
223
+ oz: "ounce"
224
+ };
225
+ function getMeasurementAsString(measurement, locale = "en-us", options = {}) {
226
+ let measure = {
227
+ value: measurement.value,
228
+ unit: UNIT_MAPPING[measurement.unit]
229
+ };
230
+ if (measure.unit == null) {
231
+ measure = convertToSupportedUnit(measurement.value, measurement.unit);
232
+ }
233
+ return new Intl.NumberFormat(locale, {
234
+ ...options,
235
+ unit: measure.unit,
236
+ style: "unit"
237
+ }).format(measure.value);
238
+ }
239
+ function convertToSupportedUnit(value, unit) {
240
+ switch (unit) {
241
+ case "cl":
242
+ return {
243
+ value: value / 1e3,
244
+ unit: "liter"
245
+ };
246
+ case "m3":
247
+ return {
248
+ value: value * 1e3,
249
+ unit: "liter"
250
+ };
251
+ case "us_pt":
252
+ return {
253
+ value: value * 0.125,
254
+ unit: "gallon"
255
+ };
256
+ case "us_qt":
257
+ return {
258
+ value: value * 0.5,
259
+ unit: "gallon"
260
+ };
261
+ case "us_oz":
262
+ return {
263
+ value: value / 128,
264
+ unit: "gallon"
265
+ };
266
+ case "imp_pt":
267
+ return {
268
+ value: value / 6.661,
269
+ unit: "gallon"
270
+ };
271
+ case "imp_qt":
272
+ return {
273
+ value: value / 3.331,
274
+ unit: "gallon"
275
+ };
276
+ case "imp_gal":
277
+ return {
278
+ value: value / 1.201,
279
+ unit: "gallon"
280
+ };
281
+ case "imp_fl_oz":
282
+ return {
283
+ value: value * 0.96076,
284
+ unit: "fluid-ounce"
285
+ };
286
+ default:
287
+ throw new Error(`Unit not supported: ${unit}`);
288
+ }
289
+ }
290
+ exports.Metafield = Metafield;
291
+ exports.getMeasurementAsString = getMeasurementAsString;
292
+ exports.parseJSON = parseJSON;
293
+ exports.parseMetafield = parseMetafield;
294
+ exports.parseMetafieldValue = parseMetafieldValue;
295
+ //# sourceMappingURL=Metafield.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Metafield.cjs","sources":["../../src/Metafield.tsx"],"sourcesContent":["import {type ElementType, useMemo, type ComponentPropsWithoutRef} from 'react';\nimport {useShop} from './ShopifyProvider.js';\nimport {Image} from './Image.js';\nimport type {\n MediaImage,\n Page,\n ProductVariant,\n Product,\n GenericFile,\n Video as VideoType,\n Metafield as MetafieldType,\n} from './storefront-api-types.js';\nimport {Video} from './Video.js';\nimport {flattenConnection} from './flatten-connection.js';\nimport type {PartialDeep, JsonValue} from 'type-fest';\n\ninterface BaseProps<ComponentGeneric extends ElementType> {\n /** An object with fields that correspond to the Storefront API's [Metafield object](https://shopify.dev/api/storefront/reference/common-objects/metafield). */\n data: PartialDeep<MetafieldType, {recurseIntoArrays: true}> | null;\n /** An HTML tag or React component to be rendered as the base element wrapper. The default value varies depending on [metafield.type](https://shopify.dev/apps/metafields/types). */\n as?: ComponentGeneric;\n}\n\nexport type MetafieldProps<ComponentGeneric extends ElementType> =\n ComponentPropsWithoutRef<ComponentGeneric> & BaseProps<ComponentGeneric>;\n\n/**\n * The `Metafield` component renders the value of a Storefront\n * API's [Metafield object](https://shopify.dev/api/storefront/reference/common-objects/metafield).\n * Relies on the `locale` property of the `useShop()` hook, so it must be a desendent of `<ShopifyProvider/>`\n *\n * Renders a smart default of the Metafield's `value`. For more information, refer to the [Default output](#default-output) section.\n */\nexport function Metafield<ComponentGeneric extends ElementType>(\n props: MetafieldProps<ComponentGeneric>\n) {\n const {data, as, ...passthroughProps} = props;\n const {locale} = useShop();\n\n const parsedMetafield = useMemo(() => parseMetafield(data), [data]);\n\n if (!parsedMetafield) {\n const noDataPropWarning = `<Metafield/>: nothing was passed to the data prop 'data'. Rendering 'null'`;\n if (__HYDROGEN_DEV__) {\n throw new Error(noDataPropWarning);\n } else {\n console.warn(noDataPropWarning);\n }\n return null;\n }\n\n if (parsedMetafield.value === null || parsedMetafield.value === undefined) {\n const noValueWarning = `<Metafield/>: No metafield value for metafield ${\n parsedMetafield.id ?? parsedMetafield.key\n }. Rendering 'null'`;\n if (__HYDROGEN_DEV__) {\n throw new Error(noValueWarning);\n } else {\n console.warn(noValueWarning);\n }\n return null;\n }\n\n switch (parsedMetafield.type) {\n case 'date': {\n const Wrapper = as ?? 'time';\n return (\n <Wrapper {...passthroughProps}>\n {(parsedMetafield.value as Date).toLocaleDateString(locale)}\n </Wrapper>\n );\n }\n case 'date_time': {\n const Wrapper = as ?? 'time';\n return (\n <Wrapper {...passthroughProps}>\n {(parsedMetafield.value as Date).toLocaleString(locale)}\n </Wrapper>\n );\n }\n case 'weight':\n case 'dimension':\n case 'volume': {\n const Wrapper = as ?? 'span';\n return (\n <Wrapper {...passthroughProps}>\n {getMeasurementAsString(parsedMetafield.value as Measurement, locale)}\n </Wrapper>\n );\n }\n case 'rating': {\n const Wrapper = as ?? 'span';\n return (\n <Wrapper {...passthroughProps}>\n {(parsedMetafield.value as Rating).value}\n </Wrapper>\n );\n }\n case 'single_line_text_field': {\n const Wrapper = as ?? 'span';\n return (\n <Wrapper\n {...passthroughProps}\n dangerouslySetInnerHTML={{__html: parsedMetafield.value as string}}\n />\n );\n }\n case 'multi_line_text_field': {\n const Wrapper = as ?? 'div';\n return (\n <Wrapper\n {...passthroughProps}\n dangerouslySetInnerHTML={{\n __html: (parsedMetafield.value as string).split('\\n').join('<br/>'),\n }}\n />\n );\n }\n case 'url': {\n const protocolLessUrl = new URL(parsedMetafield.value as string);\n return (\n <a\n href={protocolLessUrl.href.replace(protocolLessUrl.protocol, '')}\n {...passthroughProps}\n >\n {parsedMetafield.value as string}\n </a>\n );\n }\n case 'json': {\n const Wrapper = as ?? 'span';\n return (\n <Wrapper {...passthroughProps}>\n {JSON.stringify(parsedMetafield.value)}\n </Wrapper>\n );\n }\n case 'product_reference':\n case 'variant_reference':\n case 'page_reference': {\n const Wrapper = as ?? 'span';\n const ref = parsedMetafield.reference as Page | ProductVariant | Product;\n return (\n <Wrapper {...passthroughProps}>{ref?.title ?? ref?.id ?? ''}</Wrapper>\n );\n }\n case 'list.single_line_text_field': {\n const Wrapper = as ?? 'ul';\n // @ts-expect-error references currently only exists on 'unstable' SFAPI, but as soon as it does exist we can remove this ts-expect-error because I believe 'list.single_line_text_field' will also only be availabe in the same setting and we also handle if it doesn't exist\n const refArray = parsedMetafield.references\n ? // @ts-expect-error references currently only exists on 'unstable' SFAPI, but as soon as it does exist we can remove this ts-expect-error\n (flattenConnection(parsedMetafield.references) as string[])\n : [];\n return (\n <Wrapper {...passthroughProps}>\n {refArray.map((ref, index) => (\n // there's no unique way to identify these strings, so we do our best by combining the string with the index for the key\n // eslint-disable-next-line react/no-array-index-key\n <li key={`${ref ?? ''}-${index}`}>{ref}</li>\n ))}\n </Wrapper>\n );\n }\n case 'file_reference': {\n if (parsedMetafield.reference?.__typename === 'MediaImage') {\n const ref = parsedMetafield.reference as MediaImage;\n return ref.image ? (\n <Image data={ref.image} {...passthroughProps} />\n ) : null;\n } else if (parsedMetafield.reference?.__typename === 'GenericFile') {\n const ref = parsedMetafield.reference as GenericFile;\n return ref.previewImage ? (\n <a href={parsedMetafield.reference?.url ?? ''} {...passthroughProps}>\n <Image data={ref.previewImage} />\n </a>\n ) : null;\n } else if (parsedMetafield.reference?.__typename === 'Video') {\n const ref = parsedMetafield.reference as VideoType;\n return <Video {...passthroughProps} data={ref} />;\n }\n }\n }\n\n const Wrapper = as ?? 'span';\n return (\n <Wrapper {...passthroughProps}>{parsedMetafield.value?.toString()}</Wrapper>\n );\n}\n\n/**\n * The `parseMetafield` utility transforms a [Metafield](https://shopify.dev/api/storefront/reference/common-objects/Metafield)\n * into a new object whose `values` have been parsed according to the metafield `type`.\n * If the metafield is `null`, then it returns `null` back.\n */\nexport function parseMetafield(\n /** A [Metafield](https://shopify.dev/api/storefront/reference/common-objects/Metafield) or null */\n metafield: PartialDeep<MetafieldType, {recurseIntoArrays: true}> | null\n): PartialDeep<ParsedMetafield, {recurseIntoArrays: true}> | null {\n if (!metafield) {\n if (__HYDROGEN_DEV__) {\n console.warn(\n `'parseMetafield' was not passed any value for the 'metafield' argument`\n );\n }\n return null;\n }\n if (\n __HYDROGEN_DEV__ &&\n (metafield.value === null || metafield.value === undefined)\n ) {\n console.warn(\n `'parseMetafield()' was passed ${metafield.value} for 'metafield.value'`\n );\n }\n\n return {\n ...metafield,\n value: parseMetafieldValue(metafield),\n };\n}\n\n/**\n * The `parseMetafieldValue` function parses a [Metafield](https://shopify.dev/api/storefront/reference/common-objects/metafield)'s `value` from a string into a sensible type corresponding to the [Metafield](https://shopify.dev/api/storefront/reference/common-objects/metafield)'s `type`.\n */\nexport function parseMetafieldValue(\n metafield: PartialDeep<MetafieldType, {recurseIntoArrays: true}> | null\n): ParsedMetafield['value'] {\n if (!metafield) {\n return null;\n }\n\n if (metafield.value === null || metafield.value === undefined) {\n if (__HYDROGEN_DEV__) {\n console.warn(\n `'parseMetafieldValue()' was passed ${metafield.value} for 'metafield.value'`\n );\n }\n return metafield.value;\n }\n\n switch (metafield.type) {\n case 'boolean':\n return metafield.value === 'true';\n case 'number_integer':\n return parseInt(metafield.value);\n case 'number_decimal':\n return parseFloat(metafield.value);\n case 'date':\n case 'date_time':\n return new Date(metafield.value);\n case 'json':\n case 'weight':\n case 'dimension':\n case 'volume':\n case 'rating':\n return parseJSON(metafield.value);\n case 'color':\n case 'single_line_text_field':\n case 'multi_line_text_field':\n case 'product_reference':\n case 'page_reference':\n case 'variant_reference':\n case 'file_reference':\n case 'url':\n default:\n return metafield.value;\n }\n}\n\n/**\n * Parses a JSON string while preventing prototype injection attacks.\n */\nexport function parseJSON(json: string) {\n if (String(json).includes('__proto__')) {\n return JSON.parse(json, (k, v) => {\n if (k !== '__proto__') return v;\n });\n }\n\n return JSON.parse(json);\n}\n\nconst UNIT_MAPPING: Record<string, string> = {\n // Dimension\n mm: 'millimeter',\n cm: 'centimeter',\n m: 'meter',\n in: 'inch',\n ft: 'foot',\n yd: 'yard',\n // Volume\n ml: 'milliliter',\n l: 'liter',\n us_fl_oz: 'fluid-ounce',\n us_gal: 'gallon',\n // Weight\n kg: 'kilogram',\n g: 'gram',\n lb: 'pound',\n oz: 'ounce',\n};\n\nexport function getMeasurementAsString(\n measurement: Measurement,\n locale = 'en-us',\n options: Intl.NumberFormatOptions = {}\n) {\n let measure: {value: number; unit: string} = {\n value: measurement.value,\n unit: UNIT_MAPPING[measurement.unit],\n };\n\n if (measure.unit == null) {\n measure = convertToSupportedUnit(measurement.value, measurement.unit);\n }\n\n return new Intl.NumberFormat(locale, {\n ...options,\n unit: measure.unit,\n style: 'unit',\n }).format(measure.value);\n}\n\nfunction convertToSupportedUnit(value: number, unit: string) {\n switch (unit) {\n case 'cl':\n return {\n value: value / 1000,\n unit: 'liter',\n };\n case 'm3':\n return {\n value: value * 1000,\n unit: 'liter',\n };\n case 'us_pt':\n return {\n value: value * 0.125,\n unit: 'gallon',\n };\n case 'us_qt':\n return {\n value: value * 0.5,\n unit: 'gallon',\n };\n case 'us_oz':\n return {\n value: value / 128,\n unit: 'gallon',\n };\n case 'imp_pt':\n return {\n value: value / 6.661, // approximate conversion\n unit: 'gallon',\n };\n case 'imp_qt':\n return {\n value: value / 3.331, // approximate conversion\n unit: 'gallon',\n };\n case 'imp_gal':\n return {\n value: value / 1.201, // approximate conversion\n unit: 'gallon',\n };\n case 'imp_fl_oz':\n return {\n value: value * 0.96076, // approximate conversion\n unit: 'fluid-ounce',\n };\n default:\n throw new Error(`Unit not supported: ${unit}`);\n }\n}\n\ntype ParsedMetafield = Omit<\n PartialDeep<MetafieldType, {recurseIntoArrays: true}>,\n 'value'\n> & {\n value?: string | number | boolean | JsonValue | Date | Rating | Measurement;\n};\n\nexport interface Rating {\n value: number;\n scale_min: number;\n scale_max: number;\n}\n\ninterface Measurement {\n unit: string;\n value: number;\n}\n"],"names":["Metafield","props","data","as","passthroughProps","locale","useShop","parsedMetafield","useMemo","parseMetafield","noDataPropWarning","Error","value","undefined","noValueWarning","id","key","type","Wrapper","toLocaleDateString","toLocaleString","getMeasurementAsString","__html","split","join","protocolLessUrl","URL","href","replace","protocol","JSON","stringify","ref","reference","title","refArray","references","flattenConnection","map","index","__typename","image","_jsx","Image","previewImage","url","Video","toString","metafield","console","warn","parseMetafieldValue","parseInt","parseFloat","Date","parseJSON","json","String","includes","parse","k","v","UNIT_MAPPING","mm","cm","m","in","ft","yd","ml","l","us_fl_oz","us_gal","kg","g","lb","oz","measurement","options","measure","unit","convertToSupportedUnit","Intl","NumberFormat","style","format"],"mappings":";;;;;;;;AAiCO,SAASA,UACdC,OACA;;AACM,QAAA;AAAA,IAACC;AAAAA,IAAMC;AAAAA,OAAOC;AAAAA,EAAoBH,IAAAA;AAClC,QAAA;AAAA,IAACI;AAAAA,MAAUC,gBAAjB,QAAA;AAEMC,QAAAA,kBAAkBC,MAAAA,QAAQ,MAAMC,eAAeP,IAAD,GAAQ,CAACA,IAAD,CAA7B;AAE/B,MAAI,CAACK,iBAAiB;AACpB,UAAMG,oBAAqB;AACL;AACd,YAAA,IAAIC,MAAMD,iBAAV;AAAA,IAGP;AAAA,EAEF;AAED,MAAIH,gBAAgBK,UAAU,QAAQL,gBAAgBK,UAAUC,QAAW;AACzE,UAAMC,iBAAkB,mDACtBP,qBAAgBQ,OAAhBR,YAAsBA,gBAAgBS;AAElB;AACd,YAAA,IAAIL,MAAMG,cAAV;AAAA,IAGP;AAAA,EAEF;AAED,UAAQP,gBAAgBU,MAAxB;AAAA,IACE,KAAK,QAAQ;AACX,YAAMC,WAAUf,kBAAM;AACtB,4CACGe,UAAD;AAAA,QAAA,GAAad;AAAAA,QAAb,UACIG,gBAAgBK,MAAeO,mBAAmBd,MAAnD;AAAA,MAAA,CAFL;AAAA,IAKD;AAAA,IACD,KAAK,aAAa;AAChB,YAAMa,WAAUf,kBAAM;AACtB,4CACGe,UAAD;AAAA,QAAA,GAAad;AAAAA,QAAb,UACIG,gBAAgBK,MAAeQ,eAAef,MAA/C;AAAA,MA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