@prismicio/react 2.6.0-alpha.1 → 2.6.0-alpha.3
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/PrismicImage.cjs +6 -5
- package/dist/PrismicImage.cjs.map +1 -1
- package/dist/PrismicImage.js +6 -4
- package/dist/PrismicImage.js.map +1 -1
- package/dist/PrismicText.cjs +4 -4
- package/dist/PrismicText.cjs.map +1 -1
- package/dist/PrismicText.js +4 -3
- package/dist/PrismicText.js.map +1 -1
- package/dist/PrismicToolbar.cjs +3 -2
- package/dist/PrismicToolbar.cjs.map +1 -1
- package/dist/PrismicToolbar.js +2 -1
- package/dist/PrismicToolbar.js.map +1 -1
- package/dist/_node_modules/@prismicio/client/dist/errors/PrismicError.cjs +19 -0
- package/dist/_node_modules/@prismicio/client/dist/errors/PrismicError.cjs.map +1 -0
- package/dist/_node_modules/@prismicio/client/dist/errors/PrismicError.js +19 -0
- package/dist/_node_modules/@prismicio/client/dist/errors/PrismicError.js.map +1 -0
- package/dist/_node_modules/@prismicio/client/dist/getToolbarSrc.cjs +13 -0
- package/dist/_node_modules/@prismicio/client/dist/getToolbarSrc.cjs.map +1 -0
- package/dist/_node_modules/@prismicio/client/dist/getToolbarSrc.js +13 -0
- package/dist/_node_modules/@prismicio/client/dist/getToolbarSrc.js.map +1 -0
- package/dist/_node_modules/@prismicio/client/dist/helpers/asImagePixelDensitySrcSet.cjs +21 -0
- package/dist/_node_modules/@prismicio/client/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -0
- package/dist/_node_modules/@prismicio/client/dist/helpers/asImagePixelDensitySrcSet.js +21 -0
- package/dist/_node_modules/@prismicio/client/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -0
- package/dist/_node_modules/@prismicio/client/dist/helpers/asImageWidthSrcSet.cjs +45 -0
- package/dist/_node_modules/@prismicio/client/dist/helpers/asImageWidthSrcSet.cjs.map +1 -0
- package/dist/_node_modules/@prismicio/client/dist/helpers/asImageWidthSrcSet.js +45 -0
- package/dist/_node_modules/@prismicio/client/dist/helpers/asImageWidthSrcSet.js.map +1 -0
- package/dist/_node_modules/@prismicio/client/dist/helpers/asLink.cjs +38 -0
- package/dist/_node_modules/@prismicio/client/dist/helpers/asLink.cjs.map +1 -0
- package/dist/_node_modules/@prismicio/client/dist/helpers/asLink.js +38 -0
- package/dist/_node_modules/@prismicio/client/dist/helpers/asLink.js.map +1 -0
- package/dist/_node_modules/@prismicio/client/dist/helpers/asLinkAttrs.cjs +28 -0
- package/dist/_node_modules/@prismicio/client/dist/helpers/asLinkAttrs.cjs.map +1 -0
- package/dist/_node_modules/@prismicio/client/dist/helpers/asLinkAttrs.js +28 -0
- package/dist/_node_modules/@prismicio/client/dist/helpers/asLinkAttrs.js.map +1 -0
- package/dist/_node_modules/@prismicio/client/dist/helpers/asText.cjs +12 -0
- package/dist/_node_modules/@prismicio/client/dist/helpers/asText.cjs.map +1 -0
- package/dist/_node_modules/@prismicio/client/dist/helpers/asText.js +12 -0
- package/dist/_node_modules/@prismicio/client/dist/helpers/asText.js.map +1 -0
- package/dist/_node_modules/@prismicio/client/dist/helpers/documentToLinkField.cjs +26 -0
- package/dist/_node_modules/@prismicio/client/dist/helpers/documentToLinkField.cjs.map +1 -0
- package/dist/_node_modules/@prismicio/client/dist/helpers/documentToLinkField.js +26 -0
- package/dist/_node_modules/@prismicio/client/dist/helpers/documentToLinkField.js.map +1 -0
- package/dist/_node_modules/@prismicio/client/dist/helpers/isFilled.cjs +24 -0
- package/dist/_node_modules/@prismicio/client/dist/helpers/isFilled.cjs.map +1 -0
- package/dist/_node_modules/@prismicio/client/dist/helpers/isFilled.js +24 -0
- package/dist/_node_modules/@prismicio/client/dist/helpers/isFilled.js.map +1 -0
- package/dist/_node_modules/@prismicio/client/dist/isRepositoryName.cjs +7 -0
- package/dist/_node_modules/@prismicio/client/dist/isRepositoryName.cjs.map +1 -0
- package/dist/_node_modules/@prismicio/client/dist/isRepositoryName.js +7 -0
- package/dist/_node_modules/@prismicio/client/dist/isRepositoryName.js.map +1 -0
- package/dist/_node_modules/@prismicio/client/dist/lib/isInternalURL.cjs +9 -0
- package/dist/_node_modules/@prismicio/client/dist/lib/isInternalURL.cjs.map +1 -0
- package/dist/_node_modules/@prismicio/client/dist/lib/isInternalURL.js +9 -0
- package/dist/_node_modules/@prismicio/client/dist/lib/isInternalURL.js.map +1 -0
- package/dist/_node_modules/@prismicio/client/dist/types/value/link.cjs +10 -0
- package/dist/_node_modules/@prismicio/client/dist/types/value/link.cjs.map +1 -0
- package/dist/_node_modules/@prismicio/client/dist/types/value/link.js +10 -0
- package/dist/_node_modules/@prismicio/client/dist/types/value/link.js.map +1 -0
- package/dist/_node_modules/imgix-url-builder/dist/index.cjs +41 -0
- package/dist/_node_modules/imgix-url-builder/dist/index.cjs.map +1 -0
- package/dist/_node_modules/imgix-url-builder/dist/index.js +41 -0
- package/dist/_node_modules/imgix-url-builder/dist/index.js.map +1 -0
- package/dist/clientHooks.d.ts +90 -0
- package/dist/package.json.cjs +1 -1
- package/dist/package.json.js +1 -1
- package/dist/react-server/PrismicLink.cjs +3 -2
- package/dist/react-server/PrismicLink.cjs.map +1 -1
- package/dist/react-server/PrismicLink.js +2 -1
- package/dist/react-server/PrismicLink.js.map +1 -1
- package/dist/react-server/PrismicRichText.cjs +2 -3
- package/dist/react-server/PrismicRichText.cjs.map +1 -1
- package/dist/react-server/PrismicRichText.js +2 -2
- package/dist/react-server/PrismicRichText.js.map +1 -1
- package/dist/react-server/unsupported.cjs +26 -26
- package/dist/react-server/unsupported.cjs.map +1 -1
- package/dist/react-server/unsupported.js +26 -26
- package/dist/react-server/unsupported.js.map +1 -1
- package/package.json +2 -2
- package/src/react-server/unsupported.ts +112 -26
package/dist/PrismicImage.cjs
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
4
|
const React = require("react");
|
|
5
|
-
const prismic = require("@prismicio/client");
|
|
6
5
|
const __PRODUCTION__ = require("./lib/__PRODUCTION__.cjs");
|
|
7
6
|
const devMsg = require("./lib/devMsg.cjs");
|
|
7
|
+
const isFilled = require('./_node_modules/@prismicio/client/dist/helpers/isFilled.cjs');
|
|
8
|
+
const asImageWidthSrcSet = require('./_node_modules/@prismicio/client/dist/helpers/asImageWidthSrcSet.cjs');
|
|
9
|
+
const asImagePixelDensitySrcSet = require('./_node_modules/@prismicio/client/dist/helpers/asImagePixelDensitySrcSet.cjs');
|
|
8
10
|
function _interopNamespaceDefault(e) {
|
|
9
11
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
10
12
|
if (e) {
|
|
@@ -22,7 +24,6 @@ function _interopNamespaceDefault(e) {
|
|
|
22
24
|
return Object.freeze(n);
|
|
23
25
|
}
|
|
24
26
|
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
25
|
-
const prismic__namespace = /* @__PURE__ */ _interopNamespaceDefault(prismic);
|
|
26
27
|
const PrismicImage = React__namespace.forwardRef(function PrismicImage2(props, ref) {
|
|
27
28
|
const { field, alt, fallbackAlt, imgixParams, widths, pixelDensities, ...restProps } = props;
|
|
28
29
|
if (!__PRODUCTION__.__PRODUCTION__) {
|
|
@@ -36,18 +37,18 @@ const PrismicImage = React__namespace.forwardRef(function PrismicImage2(props, r
|
|
|
36
37
|
console.warn(`[PrismicImage] Only one of "widths" or "pixelDensities" props can be provided. You can resolve this warning by removing either the "widths" or "pixelDensities" prop. "widths" will be used in this case.`);
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
|
-
if (
|
|
40
|
+
if (isFilled.imageThumbnail(field)) {
|
|
40
41
|
let src;
|
|
41
42
|
let srcSet;
|
|
42
43
|
if (widths || !pixelDensities) {
|
|
43
|
-
const res =
|
|
44
|
+
const res = asImageWidthSrcSet.asImageWidthSrcSet(field, {
|
|
44
45
|
...imgixParams,
|
|
45
46
|
widths: widths === "defaults" ? void 0 : widths
|
|
46
47
|
});
|
|
47
48
|
src = res.src;
|
|
48
49
|
srcSet = res.srcset;
|
|
49
50
|
} else if (pixelDensities) {
|
|
50
|
-
const res =
|
|
51
|
+
const res = asImagePixelDensitySrcSet.asImagePixelDensitySrcSet(field, {
|
|
51
52
|
...imgixParams,
|
|
52
53
|
pixelDensities: pixelDensities === "defaults" ? void 0 : pixelDensities
|
|
53
54
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicImage.cjs","sources":["../../src/PrismicImage.tsx"],"sourcesContent":["import * as React from \"react\";\nimport * as prismic from \"@prismicio/client\";\n\nimport { __PRODUCTION__ } from \"./lib/__PRODUCTION__\";\nimport { devMsg } from \"./lib/devMsg\";\n\n/**\n * Props for `<PrismicImage>`.\n */\nexport type PrismicImageProps = Omit<\n\tReact.DetailedHTMLProps<\n\t\tReact.ImgHTMLAttributes<HTMLImageElement>,\n\t\tHTMLImageElement\n\t>,\n\t\"src\" | \"srcset\" | \"alt\"\n> & {\n\t/**\n\t * The Prismic Image field or thumbnail to render.\n\t */\n\tfield: prismic.ImageFieldImage | null | undefined;\n\n\t/**\n\t * An object of Imgix URL API parameters to transform the image.\n\t *\n\t * See: https://docs.imgix.com/apis/rendering\n\t */\n\timgixParams?: Parameters<typeof prismic.asImageSrc>[1];\n\n\t/**\n\t * Declare an image as decorative by providing `alt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\talt?: \"\";\n\n\t/**\n\t * Declare an image as decorative only if the Image field does not have\n\t * alternative text by providing `fallbackAlt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\";\n} & (\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * Widths used to build a `srcset` value for the Image field.\n\t\t\t\t *\n\t\t\t\t * If a `widths` prop is not given or `\"defaults\"` is passed, the\n\t\t\t\t * following widths will be used: 640, 750, 828, 1080, 1200, 1920, 2048,\n\t\t\t\t * 3840.\n\t\t\t\t *\n\t\t\t\t * If the Image field contains responsive views, each responsive view\n\t\t\t\t * can be used as a width in the resulting `srcset` by passing\n\t\t\t\t * `\"thumbnails\"` as the `widths` prop.\n\t\t\t\t */\n\t\t\t\twidths?:\n\t\t\t\t\t| NonNullable<\n\t\t\t\t\t\t\tParameters<typeof prismic.asImageWidthSrcSet>[1]\n\t\t\t\t\t >[\"widths\"]\n\t\t\t\t\t| \"defaults\";\n\t\t\t\t/**\n\t\t\t\t * Not used when the `widths` prop is used.\n\t\t\t\t */\n\t\t\t\tpixelDensities?: never;\n\t\t }\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * Not used when the `widths` prop is used.\n\t\t\t\t */\n\t\t\t\twidths?: never;\n\t\t\t\t/**\n\t\t\t\t * Pixel densities used to build a `srcset` value for the Image field.\n\t\t\t\t *\n\t\t\t\t * If a `pixelDensities` prop is passed `\"defaults\"`, the following\n\t\t\t\t * pixel densities will be used: 1, 2, 3.\n\t\t\t\t */\n\t\t\t\tpixelDensities:\n\t\t\t\t\t| NonNullable<\n\t\t\t\t\t\t\tParameters<typeof prismic.asImagePixelDensitySrcSet>[1]\n\t\t\t\t\t >[\"pixelDensities\"]\n\t\t\t\t\t| \"defaults\";\n\t\t }\n\t);\n\n/**\n * React component that renders an image from a Prismic Image field or one of\n * its thumbnails. It will automatically set the `alt` attribute using the Image\n * field's `alt` property.\n *\n * By default, a widths-based srcset will be used to support responsive images.\n * This ensures only the smallest image needed for a browser is downloaded.\n *\n * To use a pixel-density-based srcset, use the `pixelDensities` prop. Default\n * pixel densities can be used by using `pixelDensities=\"defaults\"`.\n *\n * **Note**: If you are using a framework that has a native image component,\n * such as Next.js and Gatsby, prefer using those image components instead. They\n * can provide deeper framework integration than `<PrismicImage>`.\n *\n * @param props - Props for the component.\n *\n * @returns A responsive image component for the given Image field.\n */\nexport const PrismicImage = React.forwardRef(function PrismicImage(\n\tprops: PrismicImageProps,\n\tref: React.ForwardedRef<HTMLImageElement>,\n): JSX.Element | null {\n\tconst {\n\t\tfield,\n\t\talt,\n\t\tfallbackAlt,\n\t\timgixParams,\n\t\twidths,\n\t\tpixelDensities,\n\t\t...restProps\n\t} = props;\n\n\tif (!__PRODUCTION__) {\n\t\tif (typeof alt === \"string\" && props.alt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] The \"alt\" prop can only be used to declare an image as decorative by passing an empty string (alt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"alt\" prop or changing it to alt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\n\t\tif (typeof fallbackAlt === \"string\" && fallbackAlt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] The \"fallbackAlt\" prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"fallbackAlt\" prop or changing it to fallbackAlt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\n\t\tif (widths && pixelDensities) {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] Only one of \"widths\" or \"pixelDensities\" props can be provided. You can resolve this warning by removing either the \"widths\" or \"pixelDensities\" prop. \"widths\" will be used in this case.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tif (prismic.isFilled.imageThumbnail(field)) {\n\t\tlet src: string | undefined;\n\t\tlet srcSet: string | undefined;\n\n\t\tif (widths || !pixelDensities) {\n\t\t\tconst res = prismic.asImageWidthSrcSet(field, {\n\t\t\t\t...imgixParams,\n\t\t\t\twidths: widths === \"defaults\" ? undefined : widths,\n\t\t\t});\n\n\t\t\tsrc = res.src;\n\t\t\tsrcSet = res.srcset;\n\t\t} else if (pixelDensities) {\n\t\t\tconst res = prismic.asImagePixelDensitySrcSet(field, {\n\t\t\t\t...imgixParams,\n\t\t\t\tpixelDensities:\n\t\t\t\t\tpixelDensities === \"defaults\" ? undefined : pixelDensities,\n\t\t\t});\n\n\t\t\tsrc = res.src;\n\t\t\tsrcSet = res.srcset;\n\t\t}\n\n\t\treturn (\n\t\t\t<img\n\t\t\t\tref={ref}\n\t\t\t\tsrc={src}\n\t\t\t\tsrcSet={srcSet}\n\t\t\t\talt={alt ?? (field.alt || fallbackAlt)}\n\t\t\t\t{...restProps}\n\t\t\t/>\n\t\t);\n\t} else {\n\t\treturn null;\n\t}\n});\n"],"names":["React","PrismicImage","__PRODUCTION__","devMsg","prismic","jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"PrismicImage.cjs","sources":["../../src/PrismicImage.tsx"],"sourcesContent":["import * as React from \"react\";\nimport * as prismic from \"@prismicio/client\";\n\nimport { __PRODUCTION__ } from \"./lib/__PRODUCTION__\";\nimport { devMsg } from \"./lib/devMsg\";\n\n/**\n * Props for `<PrismicImage>`.\n */\nexport type PrismicImageProps = Omit<\n\tReact.DetailedHTMLProps<\n\t\tReact.ImgHTMLAttributes<HTMLImageElement>,\n\t\tHTMLImageElement\n\t>,\n\t\"src\" | \"srcset\" | \"alt\"\n> & {\n\t/**\n\t * The Prismic Image field or thumbnail to render.\n\t */\n\tfield: prismic.ImageFieldImage | null | undefined;\n\n\t/**\n\t * An object of Imgix URL API parameters to transform the image.\n\t *\n\t * See: https://docs.imgix.com/apis/rendering\n\t */\n\timgixParams?: Parameters<typeof prismic.asImageSrc>[1];\n\n\t/**\n\t * Declare an image as decorative by providing `alt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\talt?: \"\";\n\n\t/**\n\t * Declare an image as decorative only if the Image field does not have\n\t * alternative text by providing `fallbackAlt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\";\n} & (\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * Widths used to build a `srcset` value for the Image field.\n\t\t\t\t *\n\t\t\t\t * If a `widths` prop is not given or `\"defaults\"` is passed, the\n\t\t\t\t * following widths will be used: 640, 750, 828, 1080, 1200, 1920, 2048,\n\t\t\t\t * 3840.\n\t\t\t\t *\n\t\t\t\t * If the Image field contains responsive views, each responsive view\n\t\t\t\t * can be used as a width in the resulting `srcset` by passing\n\t\t\t\t * `\"thumbnails\"` as the `widths` prop.\n\t\t\t\t */\n\t\t\t\twidths?:\n\t\t\t\t\t| NonNullable<\n\t\t\t\t\t\t\tParameters<typeof prismic.asImageWidthSrcSet>[1]\n\t\t\t\t\t >[\"widths\"]\n\t\t\t\t\t| \"defaults\";\n\t\t\t\t/**\n\t\t\t\t * Not used when the `widths` prop is used.\n\t\t\t\t */\n\t\t\t\tpixelDensities?: never;\n\t\t }\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * Not used when the `widths` prop is used.\n\t\t\t\t */\n\t\t\t\twidths?: never;\n\t\t\t\t/**\n\t\t\t\t * Pixel densities used to build a `srcset` value for the Image field.\n\t\t\t\t *\n\t\t\t\t * If a `pixelDensities` prop is passed `\"defaults\"`, the following\n\t\t\t\t * pixel densities will be used: 1, 2, 3.\n\t\t\t\t */\n\t\t\t\tpixelDensities:\n\t\t\t\t\t| NonNullable<\n\t\t\t\t\t\t\tParameters<typeof prismic.asImagePixelDensitySrcSet>[1]\n\t\t\t\t\t >[\"pixelDensities\"]\n\t\t\t\t\t| \"defaults\";\n\t\t }\n\t);\n\n/**\n * React component that renders an image from a Prismic Image field or one of\n * its thumbnails. It will automatically set the `alt` attribute using the Image\n * field's `alt` property.\n *\n * By default, a widths-based srcset will be used to support responsive images.\n * This ensures only the smallest image needed for a browser is downloaded.\n *\n * To use a pixel-density-based srcset, use the `pixelDensities` prop. Default\n * pixel densities can be used by using `pixelDensities=\"defaults\"`.\n *\n * **Note**: If you are using a framework that has a native image component,\n * such as Next.js and Gatsby, prefer using those image components instead. They\n * can provide deeper framework integration than `<PrismicImage>`.\n *\n * @param props - Props for the component.\n *\n * @returns A responsive image component for the given Image field.\n */\nexport const PrismicImage = React.forwardRef(function PrismicImage(\n\tprops: PrismicImageProps,\n\tref: React.ForwardedRef<HTMLImageElement>,\n): JSX.Element | null {\n\tconst {\n\t\tfield,\n\t\talt,\n\t\tfallbackAlt,\n\t\timgixParams,\n\t\twidths,\n\t\tpixelDensities,\n\t\t...restProps\n\t} = props;\n\n\tif (!__PRODUCTION__) {\n\t\tif (typeof alt === \"string\" && props.alt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] The \"alt\" prop can only be used to declare an image as decorative by passing an empty string (alt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"alt\" prop or changing it to alt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\n\t\tif (typeof fallbackAlt === \"string\" && fallbackAlt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] The \"fallbackAlt\" prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"fallbackAlt\" prop or changing it to fallbackAlt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\n\t\tif (widths && pixelDensities) {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] Only one of \"widths\" or \"pixelDensities\" props can be provided. You can resolve this warning by removing either the \"widths\" or \"pixelDensities\" prop. \"widths\" will be used in this case.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tif (prismic.isFilled.imageThumbnail(field)) {\n\t\tlet src: string | undefined;\n\t\tlet srcSet: string | undefined;\n\n\t\tif (widths || !pixelDensities) {\n\t\t\tconst res = prismic.asImageWidthSrcSet(field, {\n\t\t\t\t...imgixParams,\n\t\t\t\twidths: widths === \"defaults\" ? undefined : widths,\n\t\t\t});\n\n\t\t\tsrc = res.src;\n\t\t\tsrcSet = res.srcset;\n\t\t} else if (pixelDensities) {\n\t\t\tconst res = prismic.asImagePixelDensitySrcSet(field, {\n\t\t\t\t...imgixParams,\n\t\t\t\tpixelDensities:\n\t\t\t\t\tpixelDensities === \"defaults\" ? undefined : pixelDensities,\n\t\t\t});\n\n\t\t\tsrc = res.src;\n\t\t\tsrcSet = res.srcset;\n\t\t}\n\n\t\treturn (\n\t\t\t<img\n\t\t\t\tref={ref}\n\t\t\t\tsrc={src}\n\t\t\t\tsrcSet={srcSet}\n\t\t\t\talt={alt ?? (field.alt || fallbackAlt)}\n\t\t\t\t{...restProps}\n\t\t\t/>\n\t\t);\n\t} else {\n\t\treturn null;\n\t}\n});\n"],"names":["React","PrismicImage","__PRODUCTION__","devMsg","prismic.isFilled.imageThumbnail","prismic.asImageWidthSrcSet","prismic.asImagePixelDensitySrcSet","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAyGO,MAAM,eAAeA,iBAAM,WAAW,SAASC,cACrD,OACA,KAAyC;AAEnC,QAAA,EACL,OACA,KACA,aACA,aACA,QACA,gBACA,GAAG,UACA,IAAA;AAEJ,MAAI,CAACC,eAAAA,gBAAgB;AACpB,QAAI,OAAO,QAAQ,YAAY,MAAM,QAAQ,IAAI;AAChD,cAAQ,KACP,qQAAqQC,OACpQ,OAAA,6BAA6B,GAC3B;AAAA,IAEJ;AAED,QAAI,OAAO,gBAAgB,YAAY,gBAAgB,IAAI;AAC1D,cAAQ,KACP,qSAAqSA,OACpS,OAAA,6BAA6B,GAC3B;AAAA,IAEJ;AAED,QAAI,UAAU,gBAAgB;AAC7B,cAAQ,KACP,2MAA2M;AAAA,IAE5M;AAAA,EACD;AAED,MAAIC,SAAAA,eAAgC,KAAK,GAAG;AACvC,QAAA;AACA,QAAA;AAEA,QAAA,UAAU,CAAC,gBAAgB;AACxB,YAAA,MAAMC,mBAAQ,mBAAmB,OAAO;AAAA,QAC7C,GAAG;AAAA,QACH,QAAQ,WAAW,aAAa,SAAY;AAAA,MAAA,CAC5C;AAED,YAAM,IAAI;AACV,eAAS,IAAI;AAAA,eACH,gBAAgB;AACpB,YAAA,MAAMC,0BAAQ,0BAA0B,OAAO;AAAA,QACpD,GAAG;AAAA,QACH,gBACC,mBAAmB,aAAa,SAAY;AAAA,MAAA,CAC7C;AAED,YAAM,IAAI;AACV,eAAS,IAAI;AAAA,IACb;AAGA,WAAAC,2BAAA,IAAC,OACA,EAAA,KACA,KACA,QACA,KAAK,QAAQ,MAAM,OAAO,cAC1B,GAAI,UAAU,CAAA;AAAA,EAAA,OAGV;AACC,WAAA;AAAA,EACP;AACF,CAAC;;"}
|
package/dist/PrismicImage.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import * as prismic from "@prismicio/client";
|
|
4
3
|
import { __PRODUCTION__ } from "./lib/__PRODUCTION__.js";
|
|
5
4
|
import { devMsg } from "./lib/devMsg.js";
|
|
5
|
+
import { imageThumbnail } from './_node_modules/@prismicio/client/dist/helpers/isFilled.js';
|
|
6
|
+
import { asImageWidthSrcSet } from './_node_modules/@prismicio/client/dist/helpers/asImageWidthSrcSet.js';
|
|
7
|
+
import { asImagePixelDensitySrcSet } from './_node_modules/@prismicio/client/dist/helpers/asImagePixelDensitySrcSet.js';
|
|
6
8
|
const PrismicImage = React.forwardRef(function PrismicImage2(props, ref) {
|
|
7
9
|
const { field, alt, fallbackAlt, imgixParams, widths, pixelDensities, ...restProps } = props;
|
|
8
10
|
if (!__PRODUCTION__) {
|
|
@@ -16,18 +18,18 @@ const PrismicImage = React.forwardRef(function PrismicImage2(props, ref) {
|
|
|
16
18
|
console.warn(`[PrismicImage] Only one of "widths" or "pixelDensities" props can be provided. You can resolve this warning by removing either the "widths" or "pixelDensities" prop. "widths" will be used in this case.`);
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
|
-
if (
|
|
21
|
+
if (imageThumbnail(field)) {
|
|
20
22
|
let src;
|
|
21
23
|
let srcSet;
|
|
22
24
|
if (widths || !pixelDensities) {
|
|
23
|
-
const res =
|
|
25
|
+
const res = asImageWidthSrcSet(field, {
|
|
24
26
|
...imgixParams,
|
|
25
27
|
widths: widths === "defaults" ? void 0 : widths
|
|
26
28
|
});
|
|
27
29
|
src = res.src;
|
|
28
30
|
srcSet = res.srcset;
|
|
29
31
|
} else if (pixelDensities) {
|
|
30
|
-
const res =
|
|
32
|
+
const res = asImagePixelDensitySrcSet(field, {
|
|
31
33
|
...imgixParams,
|
|
32
34
|
pixelDensities: pixelDensities === "defaults" ? void 0 : pixelDensities
|
|
33
35
|
});
|
package/dist/PrismicImage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicImage.js","sources":["../../src/PrismicImage.tsx"],"sourcesContent":["import * as React from \"react\";\nimport * as prismic from \"@prismicio/client\";\n\nimport { __PRODUCTION__ } from \"./lib/__PRODUCTION__\";\nimport { devMsg } from \"./lib/devMsg\";\n\n/**\n * Props for `<PrismicImage>`.\n */\nexport type PrismicImageProps = Omit<\n\tReact.DetailedHTMLProps<\n\t\tReact.ImgHTMLAttributes<HTMLImageElement>,\n\t\tHTMLImageElement\n\t>,\n\t\"src\" | \"srcset\" | \"alt\"\n> & {\n\t/**\n\t * The Prismic Image field or thumbnail to render.\n\t */\n\tfield: prismic.ImageFieldImage | null | undefined;\n\n\t/**\n\t * An object of Imgix URL API parameters to transform the image.\n\t *\n\t * See: https://docs.imgix.com/apis/rendering\n\t */\n\timgixParams?: Parameters<typeof prismic.asImageSrc>[1];\n\n\t/**\n\t * Declare an image as decorative by providing `alt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\talt?: \"\";\n\n\t/**\n\t * Declare an image as decorative only if the Image field does not have\n\t * alternative text by providing `fallbackAlt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\";\n} & (\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * Widths used to build a `srcset` value for the Image field.\n\t\t\t\t *\n\t\t\t\t * If a `widths` prop is not given or `\"defaults\"` is passed, the\n\t\t\t\t * following widths will be used: 640, 750, 828, 1080, 1200, 1920, 2048,\n\t\t\t\t * 3840.\n\t\t\t\t *\n\t\t\t\t * If the Image field contains responsive views, each responsive view\n\t\t\t\t * can be used as a width in the resulting `srcset` by passing\n\t\t\t\t * `\"thumbnails\"` as the `widths` prop.\n\t\t\t\t */\n\t\t\t\twidths?:\n\t\t\t\t\t| NonNullable<\n\t\t\t\t\t\t\tParameters<typeof prismic.asImageWidthSrcSet>[1]\n\t\t\t\t\t >[\"widths\"]\n\t\t\t\t\t| \"defaults\";\n\t\t\t\t/**\n\t\t\t\t * Not used when the `widths` prop is used.\n\t\t\t\t */\n\t\t\t\tpixelDensities?: never;\n\t\t }\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * Not used when the `widths` prop is used.\n\t\t\t\t */\n\t\t\t\twidths?: never;\n\t\t\t\t/**\n\t\t\t\t * Pixel densities used to build a `srcset` value for the Image field.\n\t\t\t\t *\n\t\t\t\t * If a `pixelDensities` prop is passed `\"defaults\"`, the following\n\t\t\t\t * pixel densities will be used: 1, 2, 3.\n\t\t\t\t */\n\t\t\t\tpixelDensities:\n\t\t\t\t\t| NonNullable<\n\t\t\t\t\t\t\tParameters<typeof prismic.asImagePixelDensitySrcSet>[1]\n\t\t\t\t\t >[\"pixelDensities\"]\n\t\t\t\t\t| \"defaults\";\n\t\t }\n\t);\n\n/**\n * React component that renders an image from a Prismic Image field or one of\n * its thumbnails. It will automatically set the `alt` attribute using the Image\n * field's `alt` property.\n *\n * By default, a widths-based srcset will be used to support responsive images.\n * This ensures only the smallest image needed for a browser is downloaded.\n *\n * To use a pixel-density-based srcset, use the `pixelDensities` prop. Default\n * pixel densities can be used by using `pixelDensities=\"defaults\"`.\n *\n * **Note**: If you are using a framework that has a native image component,\n * such as Next.js and Gatsby, prefer using those image components instead. They\n * can provide deeper framework integration than `<PrismicImage>`.\n *\n * @param props - Props for the component.\n *\n * @returns A responsive image component for the given Image field.\n */\nexport const PrismicImage = React.forwardRef(function PrismicImage(\n\tprops: PrismicImageProps,\n\tref: React.ForwardedRef<HTMLImageElement>,\n): JSX.Element | null {\n\tconst {\n\t\tfield,\n\t\talt,\n\t\tfallbackAlt,\n\t\timgixParams,\n\t\twidths,\n\t\tpixelDensities,\n\t\t...restProps\n\t} = props;\n\n\tif (!__PRODUCTION__) {\n\t\tif (typeof alt === \"string\" && props.alt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] The \"alt\" prop can only be used to declare an image as decorative by passing an empty string (alt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"alt\" prop or changing it to alt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\n\t\tif (typeof fallbackAlt === \"string\" && fallbackAlt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] The \"fallbackAlt\" prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"fallbackAlt\" prop or changing it to fallbackAlt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\n\t\tif (widths && pixelDensities) {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] Only one of \"widths\" or \"pixelDensities\" props can be provided. You can resolve this warning by removing either the \"widths\" or \"pixelDensities\" prop. \"widths\" will be used in this case.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tif (prismic.isFilled.imageThumbnail(field)) {\n\t\tlet src: string | undefined;\n\t\tlet srcSet: string | undefined;\n\n\t\tif (widths || !pixelDensities) {\n\t\t\tconst res = prismic.asImageWidthSrcSet(field, {\n\t\t\t\t...imgixParams,\n\t\t\t\twidths: widths === \"defaults\" ? undefined : widths,\n\t\t\t});\n\n\t\t\tsrc = res.src;\n\t\t\tsrcSet = res.srcset;\n\t\t} else if (pixelDensities) {\n\t\t\tconst res = prismic.asImagePixelDensitySrcSet(field, {\n\t\t\t\t...imgixParams,\n\t\t\t\tpixelDensities:\n\t\t\t\t\tpixelDensities === \"defaults\" ? undefined : pixelDensities,\n\t\t\t});\n\n\t\t\tsrc = res.src;\n\t\t\tsrcSet = res.srcset;\n\t\t}\n\n\t\treturn (\n\t\t\t<img\n\t\t\t\tref={ref}\n\t\t\t\tsrc={src}\n\t\t\t\tsrcSet={srcSet}\n\t\t\t\talt={alt ?? (field.alt || fallbackAlt)}\n\t\t\t\t{...restProps}\n\t\t\t/>\n\t\t);\n\t} else {\n\t\treturn null;\n\t}\n});\n"],"names":["PrismicImage"],"mappings":"
|
|
1
|
+
{"version":3,"file":"PrismicImage.js","sources":["../../src/PrismicImage.tsx"],"sourcesContent":["import * as React from \"react\";\nimport * as prismic from \"@prismicio/client\";\n\nimport { __PRODUCTION__ } from \"./lib/__PRODUCTION__\";\nimport { devMsg } from \"./lib/devMsg\";\n\n/**\n * Props for `<PrismicImage>`.\n */\nexport type PrismicImageProps = Omit<\n\tReact.DetailedHTMLProps<\n\t\tReact.ImgHTMLAttributes<HTMLImageElement>,\n\t\tHTMLImageElement\n\t>,\n\t\"src\" | \"srcset\" | \"alt\"\n> & {\n\t/**\n\t * The Prismic Image field or thumbnail to render.\n\t */\n\tfield: prismic.ImageFieldImage | null | undefined;\n\n\t/**\n\t * An object of Imgix URL API parameters to transform the image.\n\t *\n\t * See: https://docs.imgix.com/apis/rendering\n\t */\n\timgixParams?: Parameters<typeof prismic.asImageSrc>[1];\n\n\t/**\n\t * Declare an image as decorative by providing `alt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\talt?: \"\";\n\n\t/**\n\t * Declare an image as decorative only if the Image field does not have\n\t * alternative text by providing `fallbackAlt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\";\n} & (\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * Widths used to build a `srcset` value for the Image field.\n\t\t\t\t *\n\t\t\t\t * If a `widths` prop is not given or `\"defaults\"` is passed, the\n\t\t\t\t * following widths will be used: 640, 750, 828, 1080, 1200, 1920, 2048,\n\t\t\t\t * 3840.\n\t\t\t\t *\n\t\t\t\t * If the Image field contains responsive views, each responsive view\n\t\t\t\t * can be used as a width in the resulting `srcset` by passing\n\t\t\t\t * `\"thumbnails\"` as the `widths` prop.\n\t\t\t\t */\n\t\t\t\twidths?:\n\t\t\t\t\t| NonNullable<\n\t\t\t\t\t\t\tParameters<typeof prismic.asImageWidthSrcSet>[1]\n\t\t\t\t\t >[\"widths\"]\n\t\t\t\t\t| \"defaults\";\n\t\t\t\t/**\n\t\t\t\t * Not used when the `widths` prop is used.\n\t\t\t\t */\n\t\t\t\tpixelDensities?: never;\n\t\t }\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * Not used when the `widths` prop is used.\n\t\t\t\t */\n\t\t\t\twidths?: never;\n\t\t\t\t/**\n\t\t\t\t * Pixel densities used to build a `srcset` value for the Image field.\n\t\t\t\t *\n\t\t\t\t * If a `pixelDensities` prop is passed `\"defaults\"`, the following\n\t\t\t\t * pixel densities will be used: 1, 2, 3.\n\t\t\t\t */\n\t\t\t\tpixelDensities:\n\t\t\t\t\t| NonNullable<\n\t\t\t\t\t\t\tParameters<typeof prismic.asImagePixelDensitySrcSet>[1]\n\t\t\t\t\t >[\"pixelDensities\"]\n\t\t\t\t\t| \"defaults\";\n\t\t }\n\t);\n\n/**\n * React component that renders an image from a Prismic Image field or one of\n * its thumbnails. It will automatically set the `alt` attribute using the Image\n * field's `alt` property.\n *\n * By default, a widths-based srcset will be used to support responsive images.\n * This ensures only the smallest image needed for a browser is downloaded.\n *\n * To use a pixel-density-based srcset, use the `pixelDensities` prop. Default\n * pixel densities can be used by using `pixelDensities=\"defaults\"`.\n *\n * **Note**: If you are using a framework that has a native image component,\n * such as Next.js and Gatsby, prefer using those image components instead. They\n * can provide deeper framework integration than `<PrismicImage>`.\n *\n * @param props - Props for the component.\n *\n * @returns A responsive image component for the given Image field.\n */\nexport const PrismicImage = React.forwardRef(function PrismicImage(\n\tprops: PrismicImageProps,\n\tref: React.ForwardedRef<HTMLImageElement>,\n): JSX.Element | null {\n\tconst {\n\t\tfield,\n\t\talt,\n\t\tfallbackAlt,\n\t\timgixParams,\n\t\twidths,\n\t\tpixelDensities,\n\t\t...restProps\n\t} = props;\n\n\tif (!__PRODUCTION__) {\n\t\tif (typeof alt === \"string\" && props.alt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] The \"alt\" prop can only be used to declare an image as decorative by passing an empty string (alt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"alt\" prop or changing it to alt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\n\t\tif (typeof fallbackAlt === \"string\" && fallbackAlt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] The \"fallbackAlt\" prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"fallbackAlt\" prop or changing it to fallbackAlt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\n\t\tif (widths && pixelDensities) {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] Only one of \"widths\" or \"pixelDensities\" props can be provided. You can resolve this warning by removing either the \"widths\" or \"pixelDensities\" prop. \"widths\" will be used in this case.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tif (prismic.isFilled.imageThumbnail(field)) {\n\t\tlet src: string | undefined;\n\t\tlet srcSet: string | undefined;\n\n\t\tif (widths || !pixelDensities) {\n\t\t\tconst res = prismic.asImageWidthSrcSet(field, {\n\t\t\t\t...imgixParams,\n\t\t\t\twidths: widths === \"defaults\" ? undefined : widths,\n\t\t\t});\n\n\t\t\tsrc = res.src;\n\t\t\tsrcSet = res.srcset;\n\t\t} else if (pixelDensities) {\n\t\t\tconst res = prismic.asImagePixelDensitySrcSet(field, {\n\t\t\t\t...imgixParams,\n\t\t\t\tpixelDensities:\n\t\t\t\t\tpixelDensities === \"defaults\" ? undefined : pixelDensities,\n\t\t\t});\n\n\t\t\tsrc = res.src;\n\t\t\tsrcSet = res.srcset;\n\t\t}\n\n\t\treturn (\n\t\t\t<img\n\t\t\t\tref={ref}\n\t\t\t\tsrc={src}\n\t\t\t\tsrcSet={srcSet}\n\t\t\t\talt={alt ?? (field.alt || fallbackAlt)}\n\t\t\t\t{...restProps}\n\t\t\t/>\n\t\t);\n\t} else {\n\t\treturn null;\n\t}\n});\n"],"names":["PrismicImage","prismic.isFilled.imageThumbnail","prismic.asImageWidthSrcSet","prismic.asImagePixelDensitySrcSet"],"mappings":";;;;;;;AAyGO,MAAM,eAAe,MAAM,WAAW,SAASA,cACrD,OACA,KAAyC;AAEnC,QAAA,EACL,OACA,KACA,aACA,aACA,QACA,gBACA,GAAG,UACA,IAAA;AAEJ,MAAI,CAAC,gBAAgB;AACpB,QAAI,OAAO,QAAQ,YAAY,MAAM,QAAQ,IAAI;AAChD,cAAQ,KACP,qQAAqQ,OACpQ,6BAA6B,GAC3B;AAAA,IAEJ;AAED,QAAI,OAAO,gBAAgB,YAAY,gBAAgB,IAAI;AAC1D,cAAQ,KACP,qSAAqS,OACpS,6BAA6B,GAC3B;AAAA,IAEJ;AAED,QAAI,UAAU,gBAAgB;AAC7B,cAAQ,KACP,2MAA2M;AAAA,IAE5M;AAAA,EACD;AAED,MAAIC,eAAgC,KAAK,GAAG;AACvC,QAAA;AACA,QAAA;AAEA,QAAA,UAAU,CAAC,gBAAgB;AACxB,YAAA,MAAMC,mBAA2B,OAAO;AAAA,QAC7C,GAAG;AAAA,QACH,QAAQ,WAAW,aAAa,SAAY;AAAA,MAAA,CAC5C;AAED,YAAM,IAAI;AACV,eAAS,IAAI;AAAA,eACH,gBAAgB;AACpB,YAAA,MAAMC,0BAAkC,OAAO;AAAA,QACpD,GAAG;AAAA,QACH,gBACC,mBAAmB,aAAa,SAAY;AAAA,MAAA,CAC7C;AAED,YAAM,IAAI;AACV,eAAS,IAAI;AAAA,IACb;AAGA,WAAA,oBAAC,OACA,EAAA,KACA,KACA,QACA,KAAK,QAAQ,MAAM,OAAO,cAC1B,GAAI,UAAU,CAAA;AAAA,EAAA,OAGV;AACC,WAAA;AAAA,EACP;AACF,CAAC;"}
|
package/dist/PrismicText.cjs
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
4
|
const React = require("react");
|
|
5
|
-
const prismic = require("@prismicio/client");
|
|
6
5
|
const __PRODUCTION__ = require("./lib/__PRODUCTION__.cjs");
|
|
7
6
|
const devMsg = require("./lib/devMsg.cjs");
|
|
7
|
+
const isFilled = require('./_node_modules/@prismicio/client/dist/helpers/isFilled.cjs');
|
|
8
|
+
const asText = require('./_node_modules/@prismicio/client/dist/helpers/asText.cjs');
|
|
8
9
|
function _interopNamespaceDefault(e) {
|
|
9
10
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
10
11
|
if (e) {
|
|
@@ -22,7 +23,6 @@ function _interopNamespaceDefault(e) {
|
|
|
22
23
|
return Object.freeze(n);
|
|
23
24
|
}
|
|
24
25
|
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
25
|
-
const prismic__namespace = /* @__PURE__ */ _interopNamespaceDefault(prismic);
|
|
26
26
|
const PrismicText = (props) => {
|
|
27
27
|
if (!__PRODUCTION__.__PRODUCTION__) {
|
|
28
28
|
if (typeof props.field === "string") {
|
|
@@ -30,8 +30,8 @@ const PrismicText = (props) => {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
return React__namespace.useMemo(() => {
|
|
33
|
-
if (
|
|
34
|
-
const text =
|
|
33
|
+
if (isFilled.richText(props.field)) {
|
|
34
|
+
const text = asText.asText(props.field, props.separator);
|
|
35
35
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: text });
|
|
36
36
|
} else {
|
|
37
37
|
return props.fallback != null ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: props.fallback }) : null;
|
package/dist/PrismicText.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicText.cjs","sources":["../../src/PrismicText.tsx"],"sourcesContent":["import * as React from \"react\";\nimport * as prismic from \"@prismicio/client\";\n\nimport { __PRODUCTION__ } from \"./lib/__PRODUCTION__\";\nimport { devMsg } from \"./lib/devMsg\";\n\n/**\n * Props for `<PrismicText>`.\n */\nexport type PrismicTextProps = {\n\t/**\n\t * The Prismic Rich Text field to render.\n\t */\n\tfield: prismic.RichTextField | null | undefined;\n\n\t/**\n\t * The string rendered when the field is empty. If a fallback is not given,\n\t * `null` will be rendered.\n\t */\n\tfallback?: string;\n\n\t/**\n\t * The separator used between blocks. Defaults to `\\n`.\n\t */\n\tseparator?: string;\n};\n\n/**\n * React component that renders content from a Prismic Rich Text field as plain\n * text.\n *\n * @remarks\n * This component returns a React fragment with no wrapping element around the\n * content. If you need a wrapper, add a component around `<PrismicText>`.\n * @example Rendering a Rich Text field as plain text.\n *\n * ```jsx\n * <PrismicText field={document.data.content} />;\n * ```\n *\n * @param props - Props for the component.\n *\n * @returns The Rich Text field's content as plain text.\n *\n * @see Learn about Rich Text fields {@link https://prismic.io/docs/core-concepts/rich-text-title}\n */\nexport const PrismicText = (props: PrismicTextProps): JSX.Element | null => {\n\tif (!__PRODUCTION__) {\n\t\tif (typeof props.field === \"string\") {\n\t\t\tthrow new Error(\n\t\t\t\t`[PrismicText] The \"field\" prop only accepts a Rich Text or Title field's value but was provided a different type of field instead (e.g. a Key Text or Select field). You can resolve this error by rendering the field value inline without <PrismicText>. For more details, see ${devMsg(\n\t\t\t\t\t\"prismictext-works-only-with-rich-text-and-title-fields\",\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\t}\n\n\treturn React.useMemo(() => {\n\t\tif (prismic.isFilled.richText(props.field)) {\n\t\t\tconst text = prismic.asText(props.field, props.separator);\n\n\t\t\treturn <>{text}</>;\n\t\t} else {\n\t\t\treturn props.fallback != null ? <>{props.fallback}</> : null;\n\t\t}\n\t}, [props.field, props.fallback, props.separator]);\n};\n"],"names":["__PRODUCTION__","devMsg","React","prismic","jsx","Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA8Ca,MAAA,cAAc,CAAC,UAA+C;AAC1E,MAAI,CAACA,eAAAA,gBAAgB;AAChB,QAAA,OAAO,MAAM,UAAU,UAAU;AACpC,YAAM,IAAI,MACT,oRAAoRC,OAAA,OACnR,wDAAwD,GACtD;AAAA,IAEJ;AAAA,EACD;AAEM,SAAAC,iBAAM,QAAQ,MAAK;AACzB,QAAIC,
|
|
1
|
+
{"version":3,"file":"PrismicText.cjs","sources":["../../src/PrismicText.tsx"],"sourcesContent":["import * as React from \"react\";\nimport * as prismic from \"@prismicio/client\";\n\nimport { __PRODUCTION__ } from \"./lib/__PRODUCTION__\";\nimport { devMsg } from \"./lib/devMsg\";\n\n/**\n * Props for `<PrismicText>`.\n */\nexport type PrismicTextProps = {\n\t/**\n\t * The Prismic Rich Text field to render.\n\t */\n\tfield: prismic.RichTextField | null | undefined;\n\n\t/**\n\t * The string rendered when the field is empty. If a fallback is not given,\n\t * `null` will be rendered.\n\t */\n\tfallback?: string;\n\n\t/**\n\t * The separator used between blocks. Defaults to `\\n`.\n\t */\n\tseparator?: string;\n};\n\n/**\n * React component that renders content from a Prismic Rich Text field as plain\n * text.\n *\n * @remarks\n * This component returns a React fragment with no wrapping element around the\n * content. If you need a wrapper, add a component around `<PrismicText>`.\n * @example Rendering a Rich Text field as plain text.\n *\n * ```jsx\n * <PrismicText field={document.data.content} />;\n * ```\n *\n * @param props - Props for the component.\n *\n * @returns The Rich Text field's content as plain text.\n *\n * @see Learn about Rich Text fields {@link https://prismic.io/docs/core-concepts/rich-text-title}\n */\nexport const PrismicText = (props: PrismicTextProps): JSX.Element | null => {\n\tif (!__PRODUCTION__) {\n\t\tif (typeof props.field === \"string\") {\n\t\t\tthrow new Error(\n\t\t\t\t`[PrismicText] The \"field\" prop only accepts a Rich Text or Title field's value but was provided a different type of field instead (e.g. a Key Text or Select field). You can resolve this error by rendering the field value inline without <PrismicText>. For more details, see ${devMsg(\n\t\t\t\t\t\"prismictext-works-only-with-rich-text-and-title-fields\",\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\t}\n\n\treturn React.useMemo(() => {\n\t\tif (prismic.isFilled.richText(props.field)) {\n\t\t\tconst text = prismic.asText(props.field, props.separator);\n\n\t\t\treturn <>{text}</>;\n\t\t} else {\n\t\t\treturn props.fallback != null ? <>{props.fallback}</> : null;\n\t\t}\n\t}, [props.field, props.fallback, props.separator]);\n};\n"],"names":["__PRODUCTION__","devMsg","React","prismic.isFilled.richText","prismic.asText","jsx","Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA8Ca,MAAA,cAAc,CAAC,UAA+C;AAC1E,MAAI,CAACA,eAAAA,gBAAgB;AAChB,QAAA,OAAO,MAAM,UAAU,UAAU;AACpC,YAAM,IAAI,MACT,oRAAoRC,OAAA,OACnR,wDAAwD,GACtD;AAAA,IAEJ;AAAA,EACD;AAEM,SAAAC,iBAAM,QAAQ,MAAK;AACzB,QAAIC,SAA0B,SAAA,MAAM,KAAK,GAAG;AAC3C,YAAM,OAAOC,OAAAA,OAAe,MAAM,OAAO,MAAM,SAAS;AAExD,mEAAU,UAAK,KAAA,CAAA;AAAA,IAAA,OACT;AACN,aAAO,MAAM,YAAY,OAAUC,+BAAAC,WAAAA,UAAA,EAAA,UAAA,MAAM,SAAS,CAAA,IAAM;AAAA,IACxD;AAAA,EAAA,GACC,CAAC,MAAM,OAAO,MAAM,UAAU,MAAM,SAAS,CAAC;AAClD;;"}
|
package/dist/PrismicText.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import * as prismic from "@prismicio/client";
|
|
4
3
|
import { __PRODUCTION__ } from "./lib/__PRODUCTION__.js";
|
|
5
4
|
import { devMsg } from "./lib/devMsg.js";
|
|
5
|
+
import { richText } from './_node_modules/@prismicio/client/dist/helpers/isFilled.js';
|
|
6
|
+
import { asText } from './_node_modules/@prismicio/client/dist/helpers/asText.js';
|
|
6
7
|
const PrismicText = (props) => {
|
|
7
8
|
if (!__PRODUCTION__) {
|
|
8
9
|
if (typeof props.field === "string") {
|
|
@@ -10,8 +11,8 @@ const PrismicText = (props) => {
|
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
13
|
return React.useMemo(() => {
|
|
13
|
-
if (
|
|
14
|
-
const text =
|
|
14
|
+
if (richText(props.field)) {
|
|
15
|
+
const text = asText(props.field, props.separator);
|
|
15
16
|
return /* @__PURE__ */ jsx(Fragment, { children: text });
|
|
16
17
|
} else {
|
|
17
18
|
return props.fallback != null ? /* @__PURE__ */ jsx(Fragment, { children: props.fallback }) : null;
|
package/dist/PrismicText.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicText.js","sources":["../../src/PrismicText.tsx"],"sourcesContent":["import * as React from \"react\";\nimport * as prismic from \"@prismicio/client\";\n\nimport { __PRODUCTION__ } from \"./lib/__PRODUCTION__\";\nimport { devMsg } from \"./lib/devMsg\";\n\n/**\n * Props for `<PrismicText>`.\n */\nexport type PrismicTextProps = {\n\t/**\n\t * The Prismic Rich Text field to render.\n\t */\n\tfield: prismic.RichTextField | null | undefined;\n\n\t/**\n\t * The string rendered when the field is empty. If a fallback is not given,\n\t * `null` will be rendered.\n\t */\n\tfallback?: string;\n\n\t/**\n\t * The separator used between blocks. Defaults to `\\n`.\n\t */\n\tseparator?: string;\n};\n\n/**\n * React component that renders content from a Prismic Rich Text field as plain\n * text.\n *\n * @remarks\n * This component returns a React fragment with no wrapping element around the\n * content. If you need a wrapper, add a component around `<PrismicText>`.\n * @example Rendering a Rich Text field as plain text.\n *\n * ```jsx\n * <PrismicText field={document.data.content} />;\n * ```\n *\n * @param props - Props for the component.\n *\n * @returns The Rich Text field's content as plain text.\n *\n * @see Learn about Rich Text fields {@link https://prismic.io/docs/core-concepts/rich-text-title}\n */\nexport const PrismicText = (props: PrismicTextProps): JSX.Element | null => {\n\tif (!__PRODUCTION__) {\n\t\tif (typeof props.field === \"string\") {\n\t\t\tthrow new Error(\n\t\t\t\t`[PrismicText] The \"field\" prop only accepts a Rich Text or Title field's value but was provided a different type of field instead (e.g. a Key Text or Select field). You can resolve this error by rendering the field value inline without <PrismicText>. For more details, see ${devMsg(\n\t\t\t\t\t\"prismictext-works-only-with-rich-text-and-title-fields\",\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\t}\n\n\treturn React.useMemo(() => {\n\t\tif (prismic.isFilled.richText(props.field)) {\n\t\t\tconst text = prismic.asText(props.field, props.separator);\n\n\t\t\treturn <>{text}</>;\n\t\t} else {\n\t\t\treturn props.fallback != null ? <>{props.fallback}</> : null;\n\t\t}\n\t}, [props.field, props.fallback, props.separator]);\n};\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PrismicText.js","sources":["../../src/PrismicText.tsx"],"sourcesContent":["import * as React from \"react\";\nimport * as prismic from \"@prismicio/client\";\n\nimport { __PRODUCTION__ } from \"./lib/__PRODUCTION__\";\nimport { devMsg } from \"./lib/devMsg\";\n\n/**\n * Props for `<PrismicText>`.\n */\nexport type PrismicTextProps = {\n\t/**\n\t * The Prismic Rich Text field to render.\n\t */\n\tfield: prismic.RichTextField | null | undefined;\n\n\t/**\n\t * The string rendered when the field is empty. If a fallback is not given,\n\t * `null` will be rendered.\n\t */\n\tfallback?: string;\n\n\t/**\n\t * The separator used between blocks. Defaults to `\\n`.\n\t */\n\tseparator?: string;\n};\n\n/**\n * React component that renders content from a Prismic Rich Text field as plain\n * text.\n *\n * @remarks\n * This component returns a React fragment with no wrapping element around the\n * content. If you need a wrapper, add a component around `<PrismicText>`.\n * @example Rendering a Rich Text field as plain text.\n *\n * ```jsx\n * <PrismicText field={document.data.content} />;\n * ```\n *\n * @param props - Props for the component.\n *\n * @returns The Rich Text field's content as plain text.\n *\n * @see Learn about Rich Text fields {@link https://prismic.io/docs/core-concepts/rich-text-title}\n */\nexport const PrismicText = (props: PrismicTextProps): JSX.Element | null => {\n\tif (!__PRODUCTION__) {\n\t\tif (typeof props.field === \"string\") {\n\t\t\tthrow new Error(\n\t\t\t\t`[PrismicText] The \"field\" prop only accepts a Rich Text or Title field's value but was provided a different type of field instead (e.g. a Key Text or Select field). You can resolve this error by rendering the field value inline without <PrismicText>. For more details, see ${devMsg(\n\t\t\t\t\t\"prismictext-works-only-with-rich-text-and-title-fields\",\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\t}\n\n\treturn React.useMemo(() => {\n\t\tif (prismic.isFilled.richText(props.field)) {\n\t\t\tconst text = prismic.asText(props.field, props.separator);\n\n\t\t\treturn <>{text}</>;\n\t\t} else {\n\t\t\treturn props.fallback != null ? <>{props.fallback}</> : null;\n\t\t}\n\t}, [props.field, props.fallback, props.separator]);\n};\n"],"names":["prismic.isFilled.richText","prismic.asText"],"mappings":";;;;;;AA8Ca,MAAA,cAAc,CAAC,UAA+C;AAC1E,MAAI,CAAC,gBAAgB;AAChB,QAAA,OAAO,MAAM,UAAU,UAAU;AACpC,YAAM,IAAI,MACT,oRAAoR,OACnR,wDAAwD,GACtD;AAAA,IAEJ;AAAA,EACD;AAEM,SAAA,MAAM,QAAQ,MAAK;AACzB,QAAIA,SAA0B,MAAM,KAAK,GAAG;AAC3C,YAAM,OAAOC,OAAe,MAAM,OAAO,MAAM,SAAS;AAExD,6CAAU,UAAK,KAAA,CAAA;AAAA,IAAA,OACT;AACN,aAAO,MAAM,YAAY,OAAU,oBAAA,UAAA,EAAA,UAAA,MAAM,SAAS,CAAA,IAAM;AAAA,IACxD;AAAA,EAAA,GACC,CAAC,MAAM,OAAO,MAAM,UAAU,MAAM,SAAS,CAAC;AAClD;"}
|
package/dist/PrismicToolbar.cjs
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
"use strict";
|
|
4
4
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
5
5
|
const React = require("react");
|
|
6
|
-
const
|
|
6
|
+
const getToolbarSrc = require('./_node_modules/@prismicio/client/dist/getToolbarSrc.cjs');
|
|
7
|
+
require("@prismicio/richtext");
|
|
7
8
|
function _interopNamespaceDefault(e) {
|
|
8
9
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
9
10
|
if (e) {
|
|
@@ -22,7 +23,7 @@ function _interopNamespaceDefault(e) {
|
|
|
22
23
|
}
|
|
23
24
|
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
24
25
|
const PrismicToolbar = ({ repositoryName }) => {
|
|
25
|
-
const src =
|
|
26
|
+
const src = getToolbarSrc.getToolbarSrc(repositoryName);
|
|
26
27
|
React__namespace.useEffect(() => {
|
|
27
28
|
const existingScript = document.querySelector(`script[src="${src}"]`);
|
|
28
29
|
if (!existingScript) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicToolbar.cjs","sources":["../../src/PrismicToolbar.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { getToolbarSrc } from \"@prismicio/client\";\n\n/**\n * Props for `<PrismicToolbar>`.\n */\nexport type PrismicToolbarProps = {\n\t/**\n\t * The name of the Prismic repository. For example, `\"my-repo\"` if the\n\t * repository URL is `my-repo.prismic.io`.\n\t */\n\trepositoryName: string;\n\n\t/**\n\t * The type of toolbar needed for the repository. Defaults to `\"new\"`.\n\t *\n\t * @deprecated All repositories use the \"new\"-type toolbar. This option can be\n\t * removed.\n\t * @see To check which version you need, view the Prismic Toolbar documentation {@link https://prismic.io/docs/technologies/previews-and-the-prismic-toolbar-reactjs}\n\t */\n\ttype?: \"new\" | \"legacy\";\n};\n\n/**\n * React component that injects the Prismic Toolbar into the app. This component\n * can be placed anywhere in the React tree.\n */\nexport const PrismicToolbar = ({\n\trepositoryName,\n}: PrismicToolbarProps): null => {\n\tconst src = getToolbarSrc(repositoryName);\n\n\tReact.useEffect(() => {\n\t\tconst existingScript = document.querySelector(`script[src=\"${src}\"]`);\n\n\t\tif (!existingScript) {\n\t\t\tconst script = document.createElement(\"script\");\n\t\t\tscript.src = src;\n\t\t\tscript.defer = true;\n\n\t\t\t// Used to distinguish the toolbar element from other elements.\n\t\t\tscript.dataset.prismicToolbar = \"\";\n\t\t\tscript.dataset.repositoryName = repositoryName;\n\n\t\t\t// Disable Happy DOM `<script>` evaluation during\n\t\t\t// tests.\n\t\t\t//\n\t\t\t// This is a patch ONLY INCLUDED DURING TESTS. It will\n\t\t\t// be pruned during code minification in non-test\n\t\t\t// environments.\n\t\t\t//\n\t\t\t// @see https://github.com/capricorn86/happy-dom/blob/02ae081e36f990c06171eda44f9d885fd9413d73/packages/happy-dom/src/nodes/html-script-element/HTMLScriptElement.ts#L191-L209\n\t\t\tif (process.env.NODE_ENV === \"test\") {\n\t\t\t\t// @ts-expect-error - `_evaluateScript` is a Happy DOM-specific property.\n\t\t\t\tscript._evaluateScript = false;\n\t\t\t}\n\n\t\t\tdocument.body.appendChild(script);\n\t\t}\n\t}, [repositoryName, src]);\n\n\treturn null;\n};\n"],"names":["React"],"mappings":"
|
|
1
|
+
{"version":3,"file":"PrismicToolbar.cjs","sources":["../../src/PrismicToolbar.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { getToolbarSrc } from \"@prismicio/client\";\n\n/**\n * Props for `<PrismicToolbar>`.\n */\nexport type PrismicToolbarProps = {\n\t/**\n\t * The name of the Prismic repository. For example, `\"my-repo\"` if the\n\t * repository URL is `my-repo.prismic.io`.\n\t */\n\trepositoryName: string;\n\n\t/**\n\t * The type of toolbar needed for the repository. Defaults to `\"new\"`.\n\t *\n\t * @deprecated All repositories use the \"new\"-type toolbar. This option can be\n\t * removed.\n\t * @see To check which version you need, view the Prismic Toolbar documentation {@link https://prismic.io/docs/technologies/previews-and-the-prismic-toolbar-reactjs}\n\t */\n\ttype?: \"new\" | \"legacy\";\n};\n\n/**\n * React component that injects the Prismic Toolbar into the app. This component\n * can be placed anywhere in the React tree.\n */\nexport const PrismicToolbar = ({\n\trepositoryName,\n}: PrismicToolbarProps): null => {\n\tconst src = getToolbarSrc(repositoryName);\n\n\tReact.useEffect(() => {\n\t\tconst existingScript = document.querySelector(`script[src=\"${src}\"]`);\n\n\t\tif (!existingScript) {\n\t\t\tconst script = document.createElement(\"script\");\n\t\t\tscript.src = src;\n\t\t\tscript.defer = true;\n\n\t\t\t// Used to distinguish the toolbar element from other elements.\n\t\t\tscript.dataset.prismicToolbar = \"\";\n\t\t\tscript.dataset.repositoryName = repositoryName;\n\n\t\t\t// Disable Happy DOM `<script>` evaluation during\n\t\t\t// tests.\n\t\t\t//\n\t\t\t// This is a patch ONLY INCLUDED DURING TESTS. It will\n\t\t\t// be pruned during code minification in non-test\n\t\t\t// environments.\n\t\t\t//\n\t\t\t// @see https://github.com/capricorn86/happy-dom/blob/02ae081e36f990c06171eda44f9d885fd9413d73/packages/happy-dom/src/nodes/html-script-element/HTMLScriptElement.ts#L191-L209\n\t\t\tif (process.env.NODE_ENV === \"test\") {\n\t\t\t\t// @ts-expect-error - `_evaluateScript` is a Happy DOM-specific property.\n\t\t\t\tscript._evaluateScript = false;\n\t\t\t}\n\n\t\t\tdocument.body.appendChild(script);\n\t\t}\n\t}, [repositoryName, src]);\n\n\treturn null;\n};\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA6BO;AAGA;AAENA;AACC;AAEA;AACO;AACN;AACA;AAGA;AACA;AAUI;AAEH;AAAyB;AAGjB;AAAuB;AAChC;AAGK;AACR;;"}
|
package/dist/PrismicToolbar.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
'use client';
|
|
3
3
|
import * as React from "react";
|
|
4
|
-
import { getToolbarSrc } from
|
|
4
|
+
import { getToolbarSrc } from './_node_modules/@prismicio/client/dist/getToolbarSrc.js';
|
|
5
|
+
import "@prismicio/richtext";
|
|
5
6
|
const PrismicToolbar = ({ repositoryName }) => {
|
|
6
7
|
const src = getToolbarSrc(repositoryName);
|
|
7
8
|
React.useEffect(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicToolbar.js","sources":["../../src/PrismicToolbar.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { getToolbarSrc } from \"@prismicio/client\";\n\n/**\n * Props for `<PrismicToolbar>`.\n */\nexport type PrismicToolbarProps = {\n\t/**\n\t * The name of the Prismic repository. For example, `\"my-repo\"` if the\n\t * repository URL is `my-repo.prismic.io`.\n\t */\n\trepositoryName: string;\n\n\t/**\n\t * The type of toolbar needed for the repository. Defaults to `\"new\"`.\n\t *\n\t * @deprecated All repositories use the \"new\"-type toolbar. This option can be\n\t * removed.\n\t * @see To check which version you need, view the Prismic Toolbar documentation {@link https://prismic.io/docs/technologies/previews-and-the-prismic-toolbar-reactjs}\n\t */\n\ttype?: \"new\" | \"legacy\";\n};\n\n/**\n * React component that injects the Prismic Toolbar into the app. This component\n * can be placed anywhere in the React tree.\n */\nexport const PrismicToolbar = ({\n\trepositoryName,\n}: PrismicToolbarProps): null => {\n\tconst src = getToolbarSrc(repositoryName);\n\n\tReact.useEffect(() => {\n\t\tconst existingScript = document.querySelector(`script[src=\"${src}\"]`);\n\n\t\tif (!existingScript) {\n\t\t\tconst script = document.createElement(\"script\");\n\t\t\tscript.src = src;\n\t\t\tscript.defer = true;\n\n\t\t\t// Used to distinguish the toolbar element from other elements.\n\t\t\tscript.dataset.prismicToolbar = \"\";\n\t\t\tscript.dataset.repositoryName = repositoryName;\n\n\t\t\t// Disable Happy DOM `<script>` evaluation during\n\t\t\t// tests.\n\t\t\t//\n\t\t\t// This is a patch ONLY INCLUDED DURING TESTS. It will\n\t\t\t// be pruned during code minification in non-test\n\t\t\t// environments.\n\t\t\t//\n\t\t\t// @see https://github.com/capricorn86/happy-dom/blob/02ae081e36f990c06171eda44f9d885fd9413d73/packages/happy-dom/src/nodes/html-script-element/HTMLScriptElement.ts#L191-L209\n\t\t\tif (process.env.NODE_ENV === \"test\") {\n\t\t\t\t// @ts-expect-error - `_evaluateScript` is a Happy DOM-specific property.\n\t\t\t\tscript._evaluateScript = false;\n\t\t\t}\n\n\t\t\tdocument.body.appendChild(script);\n\t\t}\n\t}, [repositoryName, src]);\n\n\treturn null;\n};\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PrismicToolbar.js","sources":["../../src/PrismicToolbar.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { getToolbarSrc } from \"@prismicio/client\";\n\n/**\n * Props for `<PrismicToolbar>`.\n */\nexport type PrismicToolbarProps = {\n\t/**\n\t * The name of the Prismic repository. For example, `\"my-repo\"` if the\n\t * repository URL is `my-repo.prismic.io`.\n\t */\n\trepositoryName: string;\n\n\t/**\n\t * The type of toolbar needed for the repository. Defaults to `\"new\"`.\n\t *\n\t * @deprecated All repositories use the \"new\"-type toolbar. This option can be\n\t * removed.\n\t * @see To check which version you need, view the Prismic Toolbar documentation {@link https://prismic.io/docs/technologies/previews-and-the-prismic-toolbar-reactjs}\n\t */\n\ttype?: \"new\" | \"legacy\";\n};\n\n/**\n * React component that injects the Prismic Toolbar into the app. This component\n * can be placed anywhere in the React tree.\n */\nexport const PrismicToolbar = ({\n\trepositoryName,\n}: PrismicToolbarProps): null => {\n\tconst src = getToolbarSrc(repositoryName);\n\n\tReact.useEffect(() => {\n\t\tconst existingScript = document.querySelector(`script[src=\"${src}\"]`);\n\n\t\tif (!existingScript) {\n\t\t\tconst script = document.createElement(\"script\");\n\t\t\tscript.src = src;\n\t\t\tscript.defer = true;\n\n\t\t\t// Used to distinguish the toolbar element from other elements.\n\t\t\tscript.dataset.prismicToolbar = \"\";\n\t\t\tscript.dataset.repositoryName = repositoryName;\n\n\t\t\t// Disable Happy DOM `<script>` evaluation during\n\t\t\t// tests.\n\t\t\t//\n\t\t\t// This is a patch ONLY INCLUDED DURING TESTS. It will\n\t\t\t// be pruned during code minification in non-test\n\t\t\t// environments.\n\t\t\t//\n\t\t\t// @see https://github.com/capricorn86/happy-dom/blob/02ae081e36f990c06171eda44f9d885fd9413d73/packages/happy-dom/src/nodes/html-script-element/HTMLScriptElement.ts#L191-L209\n\t\t\tif (process.env.NODE_ENV === \"test\") {\n\t\t\t\t// @ts-expect-error - `_evaluateScript` is a Happy DOM-specific property.\n\t\t\t\tscript._evaluateScript = false;\n\t\t\t}\n\n\t\t\tdocument.body.appendChild(script);\n\t\t}\n\t}, [repositoryName, src]);\n\n\treturn null;\n};\n"],"names":[],"mappings":";;;;;AA6BO;AAGA;AAEN;AACC;AAEA;AACO;AACN;AACA;AAGA;AACA;AAUI;AAEH;AAAyB;AAGjB;AAAuB;AAChC;AAGK;AACR;;;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
|
+
var __publicField = (obj, key, value) => {
|
|
6
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
|
+
return value;
|
|
8
|
+
};
|
|
9
|
+
class PrismicError extends Error {
|
|
10
|
+
constructor(message = "An invalid API response was returned", url, response) {
|
|
11
|
+
super(message);
|
|
12
|
+
__publicField(this, "url");
|
|
13
|
+
__publicField(this, "response");
|
|
14
|
+
this.url = url;
|
|
15
|
+
this.response = response;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.PrismicError = PrismicError;
|
|
19
|
+
//# sourceMappingURL=PrismicError.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicError.cjs","sources":["../../../../../../node_modules/@prismicio/client/dist/errors/PrismicError.js"],"sourcesContent":["var __defProp = Object.defineProperty;\nvar __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __publicField = (obj, key, value) => {\n __defNormalProp(obj, typeof key !== \"symbol\" ? key + \"\" : key, value);\n return value;\n};\nclass PrismicError extends Error {\n constructor(message = \"An invalid API response was returned\", url, response) {\n super(message);\n __publicField(this, \"url\");\n __publicField(this, \"response\");\n this.url = url;\n this.response = response;\n }\n}\nexport {\n PrismicError\n};\n//# sourceMappingURL=PrismicError.js.map\n"],"names":[],"mappings":";;AAAA,IAAI,YAAY,OAAO;AACvB,IAAI,kBAAkB,CAAC,KAAK,KAAK,UAAU,OAAO,MAAM,UAAU,KAAK,KAAK,EAAE,YAAY,MAAM,cAAc,MAAM,UAAU,MAAM,MAAO,CAAA,IAAI,IAAI,GAAG,IAAI;AAC1J,IAAI,gBAAgB,CAAC,KAAK,KAAK,UAAU;AACvC,kBAAgB,KAAK,OAAO,QAAQ,WAAW,MAAM,KAAK,KAAK,KAAK;AACpE,SAAO;AACT;AACA,MAAM,qBAAqB,MAAM;AAAA,EAC/B,YAAY,UAAU,wCAAwC,KAAK,UAAU;AAC3E,UAAM,OAAO;AACb,kBAAc,MAAM,KAAK;AACzB,kBAAc,MAAM,UAAU;AAC9B,SAAK,MAAM;AACX,SAAK,WAAW;AAAA,EACjB;AACH;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
class PrismicError extends Error {
|
|
8
|
+
constructor(message = "An invalid API response was returned", url, response) {
|
|
9
|
+
super(message);
|
|
10
|
+
__publicField(this, "url");
|
|
11
|
+
__publicField(this, "response");
|
|
12
|
+
this.url = url;
|
|
13
|
+
this.response = response;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
PrismicError
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=PrismicError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicError.js","sources":["../../../../../../node_modules/@prismicio/client/dist/errors/PrismicError.js"],"sourcesContent":["var __defProp = Object.defineProperty;\nvar __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __publicField = (obj, key, value) => {\n __defNormalProp(obj, typeof key !== \"symbol\" ? key + \"\" : key, value);\n return value;\n};\nclass PrismicError extends Error {\n constructor(message = \"An invalid API response was returned\", url, response) {\n super(message);\n __publicField(this, \"url\");\n __publicField(this, \"response\");\n this.url = url;\n this.response = response;\n }\n}\nexport {\n PrismicError\n};\n//# sourceMappingURL=PrismicError.js.map\n"],"names":[],"mappings":"AAAA,IAAI,YAAY,OAAO;AACvB,IAAI,kBAAkB,CAAC,KAAK,KAAK,UAAU,OAAO,MAAM,UAAU,KAAK,KAAK,EAAE,YAAY,MAAM,cAAc,MAAM,UAAU,MAAM,MAAO,CAAA,IAAI,IAAI,GAAG,IAAI;AAC1J,IAAI,gBAAgB,CAAC,KAAK,KAAK,UAAU;AACvC,kBAAgB,KAAK,OAAO,QAAQ,WAAW,MAAM,KAAK,KAAK,KAAK;AACpE,SAAO;AACT;AACA,MAAM,qBAAqB,MAAM;AAAA,EAC/B,YAAY,UAAU,wCAAwC,KAAK,UAAU;AAC3E,UAAM,OAAO;AACb,kBAAc,MAAM,KAAK;AACzB,kBAAc,MAAM,UAAU;AAC9B,SAAK,MAAM;AACX,SAAK,WAAW;AAAA,EACjB;AACH;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const PrismicError = require("./errors/PrismicError.cjs");
|
|
4
|
+
const isRepositoryName = require("./isRepositoryName.cjs");
|
|
5
|
+
const getToolbarSrc = (repositoryName) => {
|
|
6
|
+
if (isRepositoryName.isRepositoryName(repositoryName)) {
|
|
7
|
+
return `https://static.cdn.prismic.io/prismic.js?new=true&repo=${repositoryName}`;
|
|
8
|
+
} else {
|
|
9
|
+
throw new PrismicError.PrismicError(`An invalid Prismic repository name was given: ${repositoryName}`, void 0, void 0);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
exports.getToolbarSrc = getToolbarSrc;
|
|
13
|
+
//# sourceMappingURL=getToolbarSrc.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getToolbarSrc.cjs","sources":["../../../../../node_modules/@prismicio/client/dist/getToolbarSrc.js"],"sourcesContent":["import { PrismicError } from \"./errors/PrismicError.js\";\nimport { isRepositoryName } from \"./isRepositoryName.js\";\nconst getToolbarSrc = (repositoryName) => {\n if (isRepositoryName(repositoryName)) {\n return `https://static.cdn.prismic.io/prismic.js?new=true&repo=${repositoryName}`;\n } else {\n throw new PrismicError(`An invalid Prismic repository name was given: ${repositoryName}`, void 0, void 0);\n }\n};\nexport {\n getToolbarSrc\n};\n//# sourceMappingURL=getToolbarSrc.js.map\n"],"names":["isRepositoryName","PrismicError"],"mappings":";;;;AAEK,MAAC,gBAAgB,CAAC,mBAAmB;AACxC,MAAIA,iBAAAA,iBAAiB,cAAc,GAAG;AACpC,WAAO,0DAA0D;AAAA,EACrE,OAAS;AACL,UAAM,IAAIC,aAAAA,aAAa,iDAAiD,kBAAkB,QAAQ,MAAM;AAAA,EACzG;AACH;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PrismicError } from "./errors/PrismicError.js";
|
|
2
|
+
import { isRepositoryName } from "./isRepositoryName.js";
|
|
3
|
+
const getToolbarSrc = (repositoryName) => {
|
|
4
|
+
if (isRepositoryName(repositoryName)) {
|
|
5
|
+
return `https://static.cdn.prismic.io/prismic.js?new=true&repo=${repositoryName}`;
|
|
6
|
+
} else {
|
|
7
|
+
throw new PrismicError(`An invalid Prismic repository name was given: ${repositoryName}`, void 0, void 0);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
getToolbarSrc
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=getToolbarSrc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getToolbarSrc.js","sources":["../../../../../node_modules/@prismicio/client/dist/getToolbarSrc.js"],"sourcesContent":["import { PrismicError } from \"./errors/PrismicError.js\";\nimport { isRepositoryName } from \"./isRepositoryName.js\";\nconst getToolbarSrc = (repositoryName) => {\n if (isRepositoryName(repositoryName)) {\n return `https://static.cdn.prismic.io/prismic.js?new=true&repo=${repositoryName}`;\n } else {\n throw new PrismicError(`An invalid Prismic repository name was given: ${repositoryName}`, void 0, void 0);\n }\n};\nexport {\n getToolbarSrc\n};\n//# sourceMappingURL=getToolbarSrc.js.map\n"],"names":[],"mappings":";;AAEK,MAAC,gBAAgB,CAAC,mBAAmB;AACxC,MAAI,iBAAiB,cAAc,GAAG;AACpC,WAAO,0DAA0D;AAAA,EACrE,OAAS;AACL,UAAM,IAAI,aAAa,iDAAiD,kBAAkB,QAAQ,MAAM;AAAA,EACzG;AACH;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const index = require("../../../../imgix-url-builder/dist/index.cjs");
|
|
4
|
+
const isFilled = require("./isFilled.cjs");
|
|
5
|
+
const DEFAULT_PIXEL_DENSITIES = [1, 2, 3];
|
|
6
|
+
const asImagePixelDensitySrcSet = (field, params = {}) => {
|
|
7
|
+
if (field && isFilled.imageThumbnail(field)) {
|
|
8
|
+
const { pixelDensities = DEFAULT_PIXEL_DENSITIES, ...imgixParams } = params;
|
|
9
|
+
return {
|
|
10
|
+
src: index.buildURL(field.url, imgixParams),
|
|
11
|
+
srcset: index.buildPixelDensitySrcSet(field.url, {
|
|
12
|
+
...imgixParams,
|
|
13
|
+
pixelDensities
|
|
14
|
+
})
|
|
15
|
+
};
|
|
16
|
+
} else {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
exports.asImagePixelDensitySrcSet = asImagePixelDensitySrcSet;
|
|
21
|
+
//# sourceMappingURL=asImagePixelDensitySrcSet.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asImagePixelDensitySrcSet.cjs","sources":["../../../../../../node_modules/@prismicio/client/dist/helpers/asImagePixelDensitySrcSet.js"],"sourcesContent":["import { buildURL, buildPixelDensitySrcSet } from \"imgix-url-builder\";\nimport { imageThumbnail } from \"./isFilled.js\";\nconst DEFAULT_PIXEL_DENSITIES = [1, 2, 3];\nconst asImagePixelDensitySrcSet = (field, params = {}) => {\n if (field && imageThumbnail(field)) {\n const { pixelDensities = DEFAULT_PIXEL_DENSITIES, ...imgixParams } = params;\n return {\n src: buildURL(field.url, imgixParams),\n srcset: buildPixelDensitySrcSet(field.url, {\n ...imgixParams,\n pixelDensities\n })\n };\n } else {\n return null;\n }\n};\nexport {\n asImagePixelDensitySrcSet\n};\n//# sourceMappingURL=asImagePixelDensitySrcSet.js.map\n"],"names":["imageThumbnail","buildURL","buildPixelDensitySrcSet"],"mappings":";;;;AAEA,MAAM,0BAA0B,CAAC,GAAG,GAAG,CAAC;AACnC,MAAC,4BAA4B,CAAC,OAAO,SAAS,OAAO;AACxD,MAAI,SAASA,wBAAe,KAAK,GAAG;AAClC,UAAM,EAAE,iBAAiB,yBAAyB,GAAG,YAAW,IAAK;AACrE,WAAO;AAAA,MACL,KAAKC,MAAQ,SAAC,MAAM,KAAK,WAAW;AAAA,MACpC,QAAQC,MAAAA,wBAAwB,MAAM,KAAK;AAAA,QACzC,GAAG;AAAA,QACH;AAAA,MACR,CAAO;AAAA,IACP;AAAA,EACA,OAAS;AACL,WAAO;AAAA,EACR;AACH;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { buildURL, buildPixelDensitySrcSet } from "../../../../imgix-url-builder/dist/index.js";
|
|
2
|
+
import { imageThumbnail } from "./isFilled.js";
|
|
3
|
+
const DEFAULT_PIXEL_DENSITIES = [1, 2, 3];
|
|
4
|
+
const asImagePixelDensitySrcSet = (field, params = {}) => {
|
|
5
|
+
if (field && imageThumbnail(field)) {
|
|
6
|
+
const { pixelDensities = DEFAULT_PIXEL_DENSITIES, ...imgixParams } = params;
|
|
7
|
+
return {
|
|
8
|
+
src: buildURL(field.url, imgixParams),
|
|
9
|
+
srcset: buildPixelDensitySrcSet(field.url, {
|
|
10
|
+
...imgixParams,
|
|
11
|
+
pixelDensities
|
|
12
|
+
})
|
|
13
|
+
};
|
|
14
|
+
} else {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
asImagePixelDensitySrcSet
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=asImagePixelDensitySrcSet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asImagePixelDensitySrcSet.js","sources":["../../../../../../node_modules/@prismicio/client/dist/helpers/asImagePixelDensitySrcSet.js"],"sourcesContent":["import { buildURL, buildPixelDensitySrcSet } from \"imgix-url-builder\";\nimport { imageThumbnail } from \"./isFilled.js\";\nconst DEFAULT_PIXEL_DENSITIES = [1, 2, 3];\nconst asImagePixelDensitySrcSet = (field, params = {}) => {\n if (field && imageThumbnail(field)) {\n const { pixelDensities = DEFAULT_PIXEL_DENSITIES, ...imgixParams } = params;\n return {\n src: buildURL(field.url, imgixParams),\n srcset: buildPixelDensitySrcSet(field.url, {\n ...imgixParams,\n pixelDensities\n })\n };\n } else {\n return null;\n }\n};\nexport {\n asImagePixelDensitySrcSet\n};\n//# sourceMappingURL=asImagePixelDensitySrcSet.js.map\n"],"names":[],"mappings":";;AAEA,MAAM,0BAA0B,CAAC,GAAG,GAAG,CAAC;AACnC,MAAC,4BAA4B,CAAC,OAAO,SAAS,OAAO;AACxD,MAAI,SAAS,eAAe,KAAK,GAAG;AAClC,UAAM,EAAE,iBAAiB,yBAAyB,GAAG,YAAW,IAAK;AACrE,WAAO;AAAA,MACL,KAAK,SAAS,MAAM,KAAK,WAAW;AAAA,MACpC,QAAQ,wBAAwB,MAAM,KAAK;AAAA,QACzC,GAAG;AAAA,QACH;AAAA,MACR,CAAO;AAAA,IACP;AAAA,EACA,OAAS;AACL,WAAO;AAAA,EACR;AACH;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const index = require("../../../../imgix-url-builder/dist/index.cjs");
|
|
4
|
+
const isFilled = require("./isFilled.cjs");
|
|
5
|
+
const DEFAULT_WIDTHS = [640, 828, 1200, 2048, 3840];
|
|
6
|
+
const asImageWidthSrcSet = (field, params = {}) => {
|
|
7
|
+
if (field && isFilled.imageThumbnail(field)) {
|
|
8
|
+
let {
|
|
9
|
+
widths = DEFAULT_WIDTHS,
|
|
10
|
+
// eslint-disable-next-line prefer-const
|
|
11
|
+
...imgixParams
|
|
12
|
+
} = params;
|
|
13
|
+
const { url, dimensions, alt: _alt, copyright: _copyright, ...responsiveViews } = field;
|
|
14
|
+
const responsiveViewObjects = Object.values(responsiveViews);
|
|
15
|
+
if (widths === "thumbnails" && responsiveViewObjects.length < 1) {
|
|
16
|
+
widths = DEFAULT_WIDTHS;
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
src: index.buildURL(url, imgixParams),
|
|
20
|
+
srcset: (
|
|
21
|
+
// By this point, we know `widths` can only be
|
|
22
|
+
// `"thubmanils"` if the field has thumbnails.
|
|
23
|
+
widths === "thumbnails" ? [
|
|
24
|
+
index.buildWidthSrcSet(url, {
|
|
25
|
+
...imgixParams,
|
|
26
|
+
widths: [dimensions.width]
|
|
27
|
+
}),
|
|
28
|
+
...responsiveViewObjects.map((thumbnail) => {
|
|
29
|
+
return index.buildWidthSrcSet(thumbnail.url, {
|
|
30
|
+
...imgixParams,
|
|
31
|
+
widths: [thumbnail.dimensions.width]
|
|
32
|
+
});
|
|
33
|
+
})
|
|
34
|
+
].join(", ") : index.buildWidthSrcSet(field.url, {
|
|
35
|
+
...imgixParams,
|
|
36
|
+
widths
|
|
37
|
+
})
|
|
38
|
+
)
|
|
39
|
+
};
|
|
40
|
+
} else {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
exports.asImageWidthSrcSet = asImageWidthSrcSet;
|
|
45
|
+
//# sourceMappingURL=asImageWidthSrcSet.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asImageWidthSrcSet.cjs","sources":["../../../../../../node_modules/@prismicio/client/dist/helpers/asImageWidthSrcSet.js"],"sourcesContent":["import { buildURL, buildWidthSrcSet } from \"imgix-url-builder\";\nimport { imageThumbnail } from \"./isFilled.js\";\nconst DEFAULT_WIDTHS = [640, 828, 1200, 2048, 3840];\nconst asImageWidthSrcSet = (field, params = {}) => {\n if (field && imageThumbnail(field)) {\n let {\n widths = DEFAULT_WIDTHS,\n // eslint-disable-next-line prefer-const\n ...imgixParams\n } = params;\n const { url, dimensions, alt: _alt, copyright: _copyright, ...responsiveViews } = field;\n const responsiveViewObjects = Object.values(responsiveViews);\n if (widths === \"thumbnails\" && responsiveViewObjects.length < 1) {\n widths = DEFAULT_WIDTHS;\n }\n return {\n src: buildURL(url, imgixParams),\n srcset: (\n // By this point, we know `widths` can only be\n // `\"thubmanils\"` if the field has thumbnails.\n widths === \"thumbnails\" ? [\n buildWidthSrcSet(url, {\n ...imgixParams,\n widths: [dimensions.width]\n }),\n ...responsiveViewObjects.map((thumbnail) => {\n return buildWidthSrcSet(thumbnail.url, {\n ...imgixParams,\n widths: [thumbnail.dimensions.width]\n });\n })\n ].join(\", \") : buildWidthSrcSet(field.url, {\n ...imgixParams,\n widths\n })\n )\n };\n } else {\n return null;\n }\n};\nexport {\n asImageWidthSrcSet\n};\n//# sourceMappingURL=asImageWidthSrcSet.js.map\n"],"names":["imageThumbnail","buildURL","buildWidthSrcSet"],"mappings":";;;;AAEA,MAAM,iBAAiB,CAAC,KAAK,KAAK,MAAM,MAAM,IAAI;AAC7C,MAAC,qBAAqB,CAAC,OAAO,SAAS,OAAO;AACjD,MAAI,SAASA,wBAAe,KAAK,GAAG;AAClC,QAAI;AAAA,MACF,SAAS;AAAA;AAAA,MAET,GAAG;AAAA,IACJ,IAAG;AACJ,UAAM,EAAE,KAAK,YAAY,KAAK,MAAM,WAAW,YAAY,GAAG,gBAAiB,IAAG;AAClF,UAAM,wBAAwB,OAAO,OAAO,eAAe;AAC3D,QAAI,WAAW,gBAAgB,sBAAsB,SAAS,GAAG;AAC/D,eAAS;AAAA,IACV;AACD,WAAO;AAAA,MACL,KAAKC,MAAAA,SAAS,KAAK,WAAW;AAAA,MAC9B;AAAA;AAAA;AAAA,QAGE,WAAW,eAAe;AAAA,UACxBC,MAAAA,iBAAiB,KAAK;AAAA,YACpB,GAAG;AAAA,YACH,QAAQ,CAAC,WAAW,KAAK;AAAA,UACrC,CAAW;AAAA,UACD,GAAG,sBAAsB,IAAI,CAAC,cAAc;AAC1C,mBAAOA,MAAgB,iBAAC,UAAU,KAAK;AAAA,cACrC,GAAG;AAAA,cACH,QAAQ,CAAC,UAAU,WAAW,KAAK;AAAA,YACjD,CAAa;AAAA,UACb,CAAW;AAAA,QACF,EAAC,KAAK,IAAI,IAAIA,MAAAA,iBAAiB,MAAM,KAAK;AAAA,UACzC,GAAG;AAAA,UACH;AAAA,QACV,CAAS;AAAA;AAAA,IAET;AAAA,EACA,OAAS;AACL,WAAO;AAAA,EACR;AACH;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { buildURL, buildWidthSrcSet } from "../../../../imgix-url-builder/dist/index.js";
|
|
2
|
+
import { imageThumbnail } from "./isFilled.js";
|
|
3
|
+
const DEFAULT_WIDTHS = [640, 828, 1200, 2048, 3840];
|
|
4
|
+
const asImageWidthSrcSet = (field, params = {}) => {
|
|
5
|
+
if (field && imageThumbnail(field)) {
|
|
6
|
+
let {
|
|
7
|
+
widths = DEFAULT_WIDTHS,
|
|
8
|
+
// eslint-disable-next-line prefer-const
|
|
9
|
+
...imgixParams
|
|
10
|
+
} = params;
|
|
11
|
+
const { url, dimensions, alt: _alt, copyright: _copyright, ...responsiveViews } = field;
|
|
12
|
+
const responsiveViewObjects = Object.values(responsiveViews);
|
|
13
|
+
if (widths === "thumbnails" && responsiveViewObjects.length < 1) {
|
|
14
|
+
widths = DEFAULT_WIDTHS;
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
src: buildURL(url, imgixParams),
|
|
18
|
+
srcset: (
|
|
19
|
+
// By this point, we know `widths` can only be
|
|
20
|
+
// `"thubmanils"` if the field has thumbnails.
|
|
21
|
+
widths === "thumbnails" ? [
|
|
22
|
+
buildWidthSrcSet(url, {
|
|
23
|
+
...imgixParams,
|
|
24
|
+
widths: [dimensions.width]
|
|
25
|
+
}),
|
|
26
|
+
...responsiveViewObjects.map((thumbnail) => {
|
|
27
|
+
return buildWidthSrcSet(thumbnail.url, {
|
|
28
|
+
...imgixParams,
|
|
29
|
+
widths: [thumbnail.dimensions.width]
|
|
30
|
+
});
|
|
31
|
+
})
|
|
32
|
+
].join(", ") : buildWidthSrcSet(field.url, {
|
|
33
|
+
...imgixParams,
|
|
34
|
+
widths
|
|
35
|
+
})
|
|
36
|
+
)
|
|
37
|
+
};
|
|
38
|
+
} else {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
export {
|
|
43
|
+
asImageWidthSrcSet
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=asImageWidthSrcSet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asImageWidthSrcSet.js","sources":["../../../../../../node_modules/@prismicio/client/dist/helpers/asImageWidthSrcSet.js"],"sourcesContent":["import { buildURL, buildWidthSrcSet } from \"imgix-url-builder\";\nimport { imageThumbnail } from \"./isFilled.js\";\nconst DEFAULT_WIDTHS = [640, 828, 1200, 2048, 3840];\nconst asImageWidthSrcSet = (field, params = {}) => {\n if (field && imageThumbnail(field)) {\n let {\n widths = DEFAULT_WIDTHS,\n // eslint-disable-next-line prefer-const\n ...imgixParams\n } = params;\n const { url, dimensions, alt: _alt, copyright: _copyright, ...responsiveViews } = field;\n const responsiveViewObjects = Object.values(responsiveViews);\n if (widths === \"thumbnails\" && responsiveViewObjects.length < 1) {\n widths = DEFAULT_WIDTHS;\n }\n return {\n src: buildURL(url, imgixParams),\n srcset: (\n // By this point, we know `widths` can only be\n // `\"thubmanils\"` if the field has thumbnails.\n widths === \"thumbnails\" ? [\n buildWidthSrcSet(url, {\n ...imgixParams,\n widths: [dimensions.width]\n }),\n ...responsiveViewObjects.map((thumbnail) => {\n return buildWidthSrcSet(thumbnail.url, {\n ...imgixParams,\n widths: [thumbnail.dimensions.width]\n });\n })\n ].join(\", \") : buildWidthSrcSet(field.url, {\n ...imgixParams,\n widths\n })\n )\n };\n } else {\n return null;\n }\n};\nexport {\n asImageWidthSrcSet\n};\n//# sourceMappingURL=asImageWidthSrcSet.js.map\n"],"names":[],"mappings":";;AAEA,MAAM,iBAAiB,CAAC,KAAK,KAAK,MAAM,MAAM,IAAI;AAC7C,MAAC,qBAAqB,CAAC,OAAO,SAAS,OAAO;AACjD,MAAI,SAAS,eAAe,KAAK,GAAG;AAClC,QAAI;AAAA,MACF,SAAS;AAAA;AAAA,MAET,GAAG;AAAA,IACJ,IAAG;AACJ,UAAM,EAAE,KAAK,YAAY,KAAK,MAAM,WAAW,YAAY,GAAG,gBAAiB,IAAG;AAClF,UAAM,wBAAwB,OAAO,OAAO,eAAe;AAC3D,QAAI,WAAW,gBAAgB,sBAAsB,SAAS,GAAG;AAC/D,eAAS;AAAA,IACV;AACD,WAAO;AAAA,MACL,KAAK,SAAS,KAAK,WAAW;AAAA,MAC9B;AAAA;AAAA;AAAA,QAGE,WAAW,eAAe;AAAA,UACxB,iBAAiB,KAAK;AAAA,YACpB,GAAG;AAAA,YACH,QAAQ,CAAC,WAAW,KAAK;AAAA,UACrC,CAAW;AAAA,UACD,GAAG,sBAAsB,IAAI,CAAC,cAAc;AAC1C,mBAAO,iBAAiB,UAAU,KAAK;AAAA,cACrC,GAAG;AAAA,cACH,QAAQ,CAAC,UAAU,WAAW,KAAK;AAAA,YACjD,CAAa;AAAA,UACb,CAAW;AAAA,QACF,EAAC,KAAK,IAAI,IAAI,iBAAiB,MAAM,KAAK;AAAA,UACzC,GAAG;AAAA,UACH;AAAA,QACV,CAAS;AAAA;AAAA,IAET;AAAA,EACA,OAAS;AACL,WAAO;AAAA,EACR;AACH;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const link = require("../types/value/link.cjs");
|
|
4
|
+
const documentToLinkField = require("./documentToLinkField.cjs");
|
|
5
|
+
const asLink = (linkFieldOrDocument, linkResolver) => {
|
|
6
|
+
if (!linkFieldOrDocument) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
const linkField = (
|
|
10
|
+
// prettier-ignore
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
12
|
+
// @ts-ignore - Bug in TypeScript 4.9: https://github.com/microsoft/TypeScript/issues/51501
|
|
13
|
+
// TODO: Remove the `prettier-ignore` comment when this bug is fixed.
|
|
14
|
+
"link_type" in linkFieldOrDocument ? linkFieldOrDocument : documentToLinkField.documentToLinkField(linkFieldOrDocument)
|
|
15
|
+
);
|
|
16
|
+
switch (linkField.link_type) {
|
|
17
|
+
case link.LinkType.Media:
|
|
18
|
+
case link.LinkType.Web:
|
|
19
|
+
return "url" in linkField ? linkField.url : null;
|
|
20
|
+
case link.LinkType.Document: {
|
|
21
|
+
if ("id" in linkField && linkResolver) {
|
|
22
|
+
const resolvedURL = linkResolver(linkField);
|
|
23
|
+
if (resolvedURL != null) {
|
|
24
|
+
return resolvedURL;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if ("url" in linkField && linkField.url) {
|
|
28
|
+
return linkField.url;
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
case link.LinkType.Any:
|
|
33
|
+
default:
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
exports.asLink = asLink;
|
|
38
|
+
//# sourceMappingURL=asLink.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asLink.cjs","sources":["../../../../../../node_modules/@prismicio/client/dist/helpers/asLink.js"],"sourcesContent":["import { LinkType } from \"../types/value/link.js\";\nimport { documentToLinkField } from \"./documentToLinkField.js\";\nconst asLink = (linkFieldOrDocument, linkResolver) => {\n if (!linkFieldOrDocument) {\n return null;\n }\n const linkField = (\n // prettier-ignore\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Bug in TypeScript 4.9: https://github.com/microsoft/TypeScript/issues/51501\n // TODO: Remove the `prettier-ignore` comment when this bug is fixed.\n \"link_type\" in linkFieldOrDocument ? linkFieldOrDocument : documentToLinkField(linkFieldOrDocument)\n );\n switch (linkField.link_type) {\n case LinkType.Media:\n case LinkType.Web:\n return \"url\" in linkField ? linkField.url : null;\n case LinkType.Document: {\n if (\"id\" in linkField && linkResolver) {\n const resolvedURL = linkResolver(linkField);\n if (resolvedURL != null) {\n return resolvedURL;\n }\n }\n if (\"url\" in linkField && linkField.url) {\n return linkField.url;\n }\n return null;\n }\n case LinkType.Any:\n default:\n return null;\n }\n};\nexport {\n asLink\n};\n//# sourceMappingURL=asLink.js.map\n"],"names":["documentToLinkField","LinkType"],"mappings":";;;;AAEK,MAAC,SAAS,CAAC,qBAAqB,iBAAiB;AACpD,MAAI,CAAC,qBAAqB;AACxB,WAAO;AAAA,EACR;AACD,QAAM;AAAA;AAAA;AAAA;AAAA;AAAA,IAKJ,eAAe,sBAAsB,sBAAsBA,oBAAAA,oBAAoB,mBAAmB;AAAA;AAEpG,UAAQ,UAAU,WAAS;AAAA,IACzB,KAAKC,KAAAA,SAAS;AAAA,IACd,KAAKA,KAAQ,SAAC;AACZ,aAAO,SAAS,YAAY,UAAU,MAAM;AAAA,IAC9C,KAAKA,KAAAA,SAAS,UAAU;AACtB,UAAI,QAAQ,aAAa,cAAc;AACrC,cAAM,cAAc,aAAa,SAAS;AAC1C,YAAI,eAAe,MAAM;AACvB,iBAAO;AAAA,QACR;AAAA,MACF;AACD,UAAI,SAAS,aAAa,UAAU,KAAK;AACvC,eAAO,UAAU;AAAA,MAClB;AACD,aAAO;AAAA,IACR;AAAA,IACD,KAAKA,KAAAA,SAAS;AAAA,IACd;AACE,aAAO;AAAA,EACV;AACH;;","x_google_ignoreList":[0]}
|