@prismicio/next 2.2.2 → 2.2.3-pr.136.19d76d2
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/PrismicNextImage.cjs +16 -20
- package/dist/PrismicNextImage.cjs.map +1 -1
- package/dist/PrismicNextImage.d.cts +14 -23
- package/dist/PrismicNextImage.d.cts.map +1 -0
- package/dist/PrismicNextImage.d.ts +14 -23
- package/dist/PrismicNextImage.d.ts.map +1 -0
- package/dist/PrismicNextImage.js +11 -15
- package/dist/PrismicNextImage.js.map +1 -1
- package/dist/PrismicNextLink.cjs +7 -8
- package/dist/PrismicNextLink.cjs.map +1 -1
- package/dist/PrismicNextLink.d.cts +10 -10
- package/dist/PrismicNextLink.d.cts.map +1 -0
- package/dist/PrismicNextLink.d.ts +10 -10
- package/dist/PrismicNextLink.d.ts.map +1 -0
- package/dist/PrismicNextLink.js +3 -4
- package/dist/PrismicNextLink.js.map +1 -1
- package/dist/PrismicPreview.cjs +13 -15
- package/dist/PrismicPreview.cjs.map +1 -1
- package/dist/PrismicPreview.d.cts +12 -14
- package/dist/PrismicPreview.d.cts.map +1 -0
- package/dist/PrismicPreview.d.ts +12 -14
- package/dist/PrismicPreview.d.ts.map +1 -0
- package/dist/PrismicPreview.js +8 -10
- package/dist/PrismicPreview.js.map +1 -1
- package/dist/PrismicPreviewClient.cjs +5 -9
- package/dist/PrismicPreviewClient.cjs.map +1 -1
- package/dist/PrismicPreviewClient.js +6 -10
- package/dist/PrismicPreviewClient.js.map +1 -1
- package/dist/SliceSimulator.cjs +6 -8
- package/dist/SliceSimulator.cjs.map +1 -1
- package/dist/SliceSimulator.d.cts +3 -6
- package/dist/SliceSimulator.d.cts.map +1 -0
- package/dist/SliceSimulator.d.ts +3 -6
- package/dist/SliceSimulator.d.ts.map +1 -0
- package/dist/SliceSimulator.js +4 -6
- package/dist/SliceSimulator.js.map +1 -1
- package/dist/SliceSimulatorWrapper.cjs +3 -7
- package/dist/SliceSimulatorWrapper.cjs.map +1 -1
- package/dist/SliceSimulatorWrapper.js +2 -6
- package/dist/SliceSimulatorWrapper.js.map +1 -1
- package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +8 -14
- package/dist/createLocaleRedirect.cjs +2 -3
- package/dist/createLocaleRedirect.cjs.map +1 -1
- package/dist/createLocaleRedirect.d.cts.map +1 -0
- package/dist/createLocaleRedirect.d.ts.map +1 -0
- package/dist/createLocaleRedirect.js +1 -2
- package/dist/createLocaleRedirect.js.map +1 -1
- package/dist/enableAutoPreviews.cjs +4 -6
- package/dist/enableAutoPreviews.cjs.map +1 -1
- package/dist/enableAutoPreviews.d.cts +2 -4
- package/dist/enableAutoPreviews.d.cts.map +1 -0
- package/dist/enableAutoPreviews.d.ts +2 -4
- package/dist/enableAutoPreviews.d.ts.map +1 -0
- package/dist/enableAutoPreviews.js +3 -5
- package/dist/enableAutoPreviews.js.map +1 -1
- package/dist/exitPreview.cjs +11 -13
- package/dist/exitPreview.cjs.map +1 -1
- package/dist/exitPreview.d.cts +9 -10
- package/dist/exitPreview.d.cts.map +1 -0
- package/dist/exitPreview.d.ts +9 -10
- package/dist/exitPreview.d.ts.map +1 -0
- package/dist/exitPreview.js +11 -12
- package/dist/exitPreview.js.map +1 -1
- package/dist/getSlices.cjs +2 -3
- package/dist/getSlices.cjs.map +1 -1
- package/dist/getSlices.d.cts.map +1 -0
- package/dist/getSlices.d.ts.map +1 -0
- package/dist/getSlices.js +1 -2
- package/dist/getSlices.js.map +1 -1
- package/dist/imgixLoader.cjs +4 -5
- package/dist/imgixLoader.cjs.map +1 -1
- package/dist/imgixLoader.d.cts +3 -4
- package/dist/imgixLoader.d.cts.map +1 -0
- package/dist/imgixLoader.d.ts +3 -4
- package/dist/imgixLoader.d.ts.map +1 -0
- package/dist/imgixLoader.js +3 -4
- package/dist/imgixLoader.js.map +1 -1
- package/dist/index.cjs +12 -12
- package/dist/index.js +1 -2
- package/dist/lib/devMsg.cjs +8 -11
- package/dist/lib/devMsg.cjs.map +1 -1
- package/dist/lib/devMsg.js +7 -10
- package/dist/lib/devMsg.js.map +1 -1
- package/dist/lib/resolveDefaultExport.cjs +9 -14
- package/dist/lib/resolveDefaultExport.cjs.map +1 -1
- package/dist/lib/resolveDefaultExport.js +9 -13
- package/dist/lib/resolveDefaultExport.js.map +1 -1
- package/dist/package.cjs +7 -8
- package/dist/package.js +2 -2
- package/dist/pages/PrismicPreview.cjs +12 -14
- package/dist/pages/PrismicPreview.cjs.map +1 -1
- package/dist/pages/PrismicPreview.d.cts +12 -14
- package/dist/pages/PrismicPreview.d.cts.map +1 -0
- package/dist/pages/PrismicPreview.d.ts +12 -14
- package/dist/pages/PrismicPreview.d.ts.map +1 -0
- package/dist/pages/PrismicPreview.js +8 -10
- package/dist/pages/PrismicPreview.js.map +1 -1
- package/dist/pages/SliceSimulator.cjs +5 -6
- package/dist/pages/SliceSimulator.cjs.map +1 -1
- package/dist/pages/SliceSimulator.d.cts +10 -13
- package/dist/pages/SliceSimulator.d.cts.map +1 -0
- package/dist/pages/SliceSimulator.d.ts +10 -13
- package/dist/pages/SliceSimulator.d.ts.map +1 -0
- package/dist/pages/SliceSimulator.js +3 -4
- package/dist/pages/SliceSimulator.js.map +1 -1
- package/dist/pages/enableAutoPreviews.cjs +4 -5
- package/dist/pages/enableAutoPreviews.cjs.map +1 -1
- package/dist/pages/enableAutoPreviews.d.cts +6 -8
- package/dist/pages/enableAutoPreviews.d.cts.map +1 -0
- package/dist/pages/enableAutoPreviews.d.ts +6 -8
- package/dist/pages/enableAutoPreviews.d.ts.map +1 -0
- package/dist/pages/enableAutoPreviews.js +4 -4
- package/dist/pages/enableAutoPreviews.js.map +1 -1
- package/dist/pages/exitPreview.cjs +10 -12
- package/dist/pages/exitPreview.cjs.map +1 -1
- package/dist/pages/exitPreview.d.cts +9 -10
- package/dist/pages/exitPreview.d.cts.map +1 -0
- package/dist/pages/exitPreview.d.ts +9 -10
- package/dist/pages/exitPreview.d.ts.map +1 -0
- package/dist/pages/exitPreview.js +10 -11
- package/dist/pages/exitPreview.js.map +1 -1
- package/dist/pages/redirectToPreviewURL.cjs +1 -2
- package/dist/pages/redirectToPreviewURL.cjs.map +1 -1
- package/dist/pages/redirectToPreviewURL.d.cts +8 -11
- package/dist/pages/redirectToPreviewURL.d.cts.map +1 -0
- package/dist/pages/redirectToPreviewURL.d.ts +8 -11
- package/dist/pages/redirectToPreviewURL.d.ts.map +1 -0
- package/dist/pages/redirectToPreviewURL.js +1 -1
- package/dist/pages/redirectToPreviewURL.js.map +1 -1
- package/dist/pages/setPreviewData.cjs +2 -3
- package/dist/pages/setPreviewData.cjs.map +1 -1
- package/dist/pages/setPreviewData.d.cts.map +1 -0
- package/dist/pages/setPreviewData.d.ts.map +1 -0
- package/dist/pages/setPreviewData.js +1 -2
- package/dist/pages/setPreviewData.js.map +1 -1
- package/dist/pages/types.d.cts +3 -9
- package/dist/pages/types.d.cts.map +1 -0
- package/dist/pages/types.d.ts +3 -9
- package/dist/pages/types.d.ts.map +1 -0
- package/dist/pages.cjs +12 -12
- package/dist/pages.js +1 -2
- package/dist/redirectToPreviewURL.cjs +3 -4
- package/dist/redirectToPreviewURL.cjs.map +1 -1
- package/dist/redirectToPreviewURL.d.cts +4 -7
- package/dist/redirectToPreviewURL.d.cts.map +1 -0
- package/dist/redirectToPreviewURL.d.ts +4 -7
- package/dist/redirectToPreviewURL.d.ts.map +1 -0
- package/dist/redirectToPreviewURL.js +2 -3
- package/dist/redirectToPreviewURL.js.map +1 -1
- package/dist/types.d.cts +1 -2
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.ts +1 -2
- package/dist/types.d.ts.map +1 -0
- package/package.json +34 -36
- package/src/PrismicNextImage.tsx +113 -134
- package/src/PrismicNextLink.tsx +43 -45
- package/src/PrismicPreview.tsx +28 -29
- package/src/PrismicPreviewClient.tsx +42 -44
- package/src/SliceSimulator.tsx +38 -43
- package/src/SliceSimulatorWrapper.tsx +15 -25
- package/src/createLocaleRedirect.ts +3 -3
- package/src/enableAutoPreviews.ts +15 -16
- package/src/exitPreview.ts +12 -13
- package/src/getSlices.ts +6 -10
- package/src/imgixLoader.ts +10 -10
- package/src/index.ts +18 -21
- package/src/lib/devMsg.ts +9 -11
- package/src/lib/resolveDefaultExport.ts +9 -13
- package/src/pages/PrismicPreview.tsx +47 -51
- package/src/pages/SliceSimulator.tsx +35 -37
- package/src/pages/enableAutoPreviews.ts +17 -17
- package/src/pages/exitPreview.ts +17 -18
- package/src/pages/index.ts +20 -23
- package/src/pages/redirectToPreviewURL.ts +22 -33
- package/src/pages/setPreviewData.ts +7 -7
- package/src/pages/types.ts +16 -20
- package/src/redirectToPreviewURL.ts +21 -30
- package/src/types.ts +12 -13
package/dist/PrismicPreview.cjs
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
|
-
const
|
|
2
|
-
const require_resolveDefaultExport = require(
|
|
3
|
-
const require_PrismicPreviewClient = require(
|
|
4
|
-
let next_script = require("next/script");
|
|
5
|
-
next_script = require_rolldown_runtime.__toESM(next_script);
|
|
1
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_resolveDefaultExport = require("./lib/resolveDefaultExport.cjs");
|
|
3
|
+
const require_PrismicPreviewClient = require("./PrismicPreviewClient.cjs");
|
|
6
4
|
let _prismicio_client = require("@prismicio/client");
|
|
5
|
+
let next_script_js = require("next/script.js");
|
|
6
|
+
next_script_js = require_runtime.__toESM(next_script_js);
|
|
7
7
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
-
|
|
9
8
|
//#region src/PrismicPreview.tsx
|
|
10
9
|
/**
|
|
11
|
-
* React component that sets up Prismic Previews using the Prismic Toolbar. When
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* changes.
|
|
10
|
+
* React component that sets up Prismic Previews using the Prismic Toolbar. When the Prismic Toolbar
|
|
11
|
+
* send events to the browser, such as on preview updates and exiting, this component will
|
|
12
|
+
* automatically refresh the page with the changes.
|
|
15
13
|
*
|
|
16
|
-
* This component can be wrapped around your app or added anywhere in your app's
|
|
17
|
-
*
|
|
14
|
+
* This component can be wrapped around your app or added anywhere in your app's tree. It must be
|
|
15
|
+
* rendered on every page.
|
|
18
16
|
*/
|
|
19
17
|
const PrismicPreview = async (props) => {
|
|
20
18
|
const { repositoryName, children, ...otherProps } = props;
|
|
21
|
-
const { draftMode } = await import("next/headers");
|
|
19
|
+
const { draftMode } = await import("next/headers.js");
|
|
22
20
|
const toolbarSrc = (0, _prismicio_client.getToolbarSrc)(repositoryName);
|
|
23
21
|
const isDraftMode = (await draftMode()).isEnabled;
|
|
24
|
-
const ResolvedScript = require_resolveDefaultExport.resolveDefaultExport(
|
|
22
|
+
const ResolvedScript = require_resolveDefaultExport.resolveDefaultExport(next_script_js.default);
|
|
25
23
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
26
24
|
children,
|
|
27
25
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PrismicPreviewClient.PrismicPreviewClient, {
|
|
@@ -35,7 +33,7 @@ const PrismicPreview = async (props) => {
|
|
|
35
33
|
})
|
|
36
34
|
] });
|
|
37
35
|
};
|
|
38
|
-
|
|
39
36
|
//#endregion
|
|
40
37
|
exports.PrismicPreview = PrismicPreview;
|
|
38
|
+
|
|
41
39
|
//# sourceMappingURL=PrismicPreview.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicPreview.cjs","names":["resolveDefaultExport","Script","PrismicPreviewClient"],"sources":["../src/PrismicPreview.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"PrismicPreview.cjs","names":["resolveDefaultExport","Script","PrismicPreviewClient"],"sources":["../src/PrismicPreview.tsx"],"sourcesContent":["import { getToolbarSrc } from \"@prismicio/client\"\nimport Script from \"next/script\"\nimport type { FC, ReactNode } from \"react\"\n\nimport { resolveDefaultExport } from \"./lib/resolveDefaultExport\"\nimport { PrismicPreviewClient } from \"./PrismicPreviewClient\"\n\n/** Props for `<PrismicPreview>`. */\nexport type PrismicPreviewProps = {\n\t/**\n\t * The name of your Prismic repository. A Prismic Toolbar will be registered using this\n\t * repository.\n\t */\n\trepositoryName: string\n\n\t/**\n\t * The URL of your app's Prismic preview endpoint (default: `/api/preview`). This URL will be\n\t * fetched on preview update events.\n\t */\n\tupdatePreviewURL?: string\n\n\t/**\n\t * The URL of your app's exit preview endpoint (default: `/api/exit-preview`). This URL will be\n\t * fetched on preview exit events.\n\t */\n\texitPreviewURL?: string\n\n\t/** Children to render adjacent to the Prismic Toolbar. */\n\tchildren?: ReactNode\n}\n\n/**\n * React component that sets up Prismic Previews using the Prismic Toolbar. When the Prismic Toolbar\n * send events to the browser, such as on preview updates and exiting, this component will\n * automatically refresh the page with the changes.\n *\n * This component can be wrapped around your app or added anywhere in your app's tree. It must be\n * rendered on every page.\n */\nexport const PrismicPreview: FC<PrismicPreviewProps> = async (props) => {\n\tconst { repositoryName, children, ...otherProps } = props\n\n\t// Need this to avoid the following Next.js build-time error:\n\t// You're importing a component that needs next/headers. That only works\n\t// in a Server Component which is not supported in the pages/ directory.\n\tconst { draftMode } = await import(\"next/headers\")\n\n\tconst toolbarSrc = getToolbarSrc(repositoryName)\n\tconst isDraftMode = (await draftMode()).isEnabled\n\n\tconst ResolvedScript = resolveDefaultExport(Script)\n\n\treturn (\n\t\t<>\n\t\t\t{children}\n\t\t\t<PrismicPreviewClient\n\t\t\t\trepositoryName={repositoryName}\n\t\t\t\tisDraftMode={isDraftMode}\n\t\t\t\t{...otherProps}\n\t\t\t/>\n\t\t\t<ResolvedScript src={toolbarSrc} strategy=\"lazyOnload\" />\n\t\t</>\n\t)\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAuCA,MAAa,iBAA0C,OAAO,UAAU;CACvE,MAAM,EAAE,gBAAgB,UAAU,GAAG,eAAe;CAKpD,MAAM,EAAE,cAAc,MAAM,OAAO;CAEnC,MAAM,cAAA,GAAA,kBAAA,eAA2B,eAAe;CAChD,MAAM,eAAe,MAAM,WAAW,EAAE;CAExC,MAAM,iBAAiBA,6BAAAA,qBAAqBC,eAAAA,QAAO;AAEnD,QACC,iBAAA,GAAA,kBAAA,MAAA,kBAAA,UAAA,EAAA,UAAA;EACE;EACD,iBAAA,GAAA,kBAAA,KAACC,6BAAAA,sBAAD;GACiB;GACH;GACb,GAAI;GACH,CAAA;EACF,iBAAA,GAAA,kBAAA,KAAC,gBAAD;GAAgB,KAAK;GAAY,UAAS;GAAe,CAAA;EACvD,EAAA,CAAA"}
|
|
@@ -4,31 +4,29 @@ import { FC, ReactNode } from "react";
|
|
|
4
4
|
/** Props for `<PrismicPreview>`. */
|
|
5
5
|
type PrismicPreviewProps = {
|
|
6
6
|
/**
|
|
7
|
-
* The name of your Prismic repository. A Prismic Toolbar will be registered
|
|
8
|
-
*
|
|
7
|
+
* The name of your Prismic repository. A Prismic Toolbar will be registered using this
|
|
8
|
+
* repository.
|
|
9
9
|
*/
|
|
10
10
|
repositoryName: string;
|
|
11
11
|
/**
|
|
12
|
-
* The URL of your app's Prismic preview endpoint (default: `/api/preview`).
|
|
13
|
-
*
|
|
12
|
+
* The URL of your app's Prismic preview endpoint (default: `/api/preview`). This URL will be
|
|
13
|
+
* fetched on preview update events.
|
|
14
14
|
*/
|
|
15
15
|
updatePreviewURL?: string;
|
|
16
16
|
/**
|
|
17
|
-
* The URL of your app's exit preview endpoint (default: `/api/exit-preview`).
|
|
18
|
-
*
|
|
17
|
+
* The URL of your app's exit preview endpoint (default: `/api/exit-preview`). This URL will be
|
|
18
|
+
* fetched on preview exit events.
|
|
19
19
|
*/
|
|
20
|
-
exitPreviewURL?: string;
|
|
21
|
-
/** Children to render adjacent to the Prismic Toolbar. */
|
|
20
|
+
exitPreviewURL?: string; /** Children to render adjacent to the Prismic Toolbar. */
|
|
22
21
|
children?: ReactNode;
|
|
23
22
|
};
|
|
24
23
|
/**
|
|
25
|
-
* React component that sets up Prismic Previews using the Prismic Toolbar. When
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* changes.
|
|
24
|
+
* React component that sets up Prismic Previews using the Prismic Toolbar. When the Prismic Toolbar
|
|
25
|
+
* send events to the browser, such as on preview updates and exiting, this component will
|
|
26
|
+
* automatically refresh the page with the changes.
|
|
29
27
|
*
|
|
30
|
-
* This component can be wrapped around your app or added anywhere in your app's
|
|
31
|
-
*
|
|
28
|
+
* This component can be wrapped around your app or added anywhere in your app's tree. It must be
|
|
29
|
+
* rendered on every page.
|
|
32
30
|
*/
|
|
33
31
|
declare const PrismicPreview: FC<PrismicPreviewProps>;
|
|
34
32
|
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicPreview.d.cts","names":[],"sources":["../src/PrismicPreview.tsx"],"mappings":";;;;KAQY,mBAAA;EAAA;;;;EAKX,cAAA;EAMA;;;;EAAA,gBAAA;EASoB;AAWrB;;;EAdC,cAAA,WAckD;EAXlD,QAAA,GAAW,SAAA;AAAA;;;;;;;;;cAWC,cAAA,EAAgB,EAAA,CAAG,mBAAA"}
|
package/dist/PrismicPreview.d.ts
CHANGED
|
@@ -4,31 +4,29 @@ import { FC, ReactNode } from "react";
|
|
|
4
4
|
/** Props for `<PrismicPreview>`. */
|
|
5
5
|
type PrismicPreviewProps = {
|
|
6
6
|
/**
|
|
7
|
-
* The name of your Prismic repository. A Prismic Toolbar will be registered
|
|
8
|
-
*
|
|
7
|
+
* The name of your Prismic repository. A Prismic Toolbar will be registered using this
|
|
8
|
+
* repository.
|
|
9
9
|
*/
|
|
10
10
|
repositoryName: string;
|
|
11
11
|
/**
|
|
12
|
-
* The URL of your app's Prismic preview endpoint (default: `/api/preview`).
|
|
13
|
-
*
|
|
12
|
+
* The URL of your app's Prismic preview endpoint (default: `/api/preview`). This URL will be
|
|
13
|
+
* fetched on preview update events.
|
|
14
14
|
*/
|
|
15
15
|
updatePreviewURL?: string;
|
|
16
16
|
/**
|
|
17
|
-
* The URL of your app's exit preview endpoint (default: `/api/exit-preview`).
|
|
18
|
-
*
|
|
17
|
+
* The URL of your app's exit preview endpoint (default: `/api/exit-preview`). This URL will be
|
|
18
|
+
* fetched on preview exit events.
|
|
19
19
|
*/
|
|
20
|
-
exitPreviewURL?: string;
|
|
21
|
-
/** Children to render adjacent to the Prismic Toolbar. */
|
|
20
|
+
exitPreviewURL?: string; /** Children to render adjacent to the Prismic Toolbar. */
|
|
22
21
|
children?: ReactNode;
|
|
23
22
|
};
|
|
24
23
|
/**
|
|
25
|
-
* React component that sets up Prismic Previews using the Prismic Toolbar. When
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* changes.
|
|
24
|
+
* React component that sets up Prismic Previews using the Prismic Toolbar. When the Prismic Toolbar
|
|
25
|
+
* send events to the browser, such as on preview updates and exiting, this component will
|
|
26
|
+
* automatically refresh the page with the changes.
|
|
29
27
|
*
|
|
30
|
-
* This component can be wrapped around your app or added anywhere in your app's
|
|
31
|
-
*
|
|
28
|
+
* This component can be wrapped around your app or added anywhere in your app's tree. It must be
|
|
29
|
+
* rendered on every page.
|
|
32
30
|
*/
|
|
33
31
|
declare const PrismicPreview: FC<PrismicPreviewProps>;
|
|
34
32
|
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicPreview.d.ts","names":[],"sources":["../src/PrismicPreview.tsx"],"mappings":";;;;KAQY,mBAAA;EAAA;;;;EAKX,cAAA;EAMA;;;;EAAA,gBAAA;EASoB;AAWrB;;;EAdC,cAAA,WAckD;EAXlD,QAAA,GAAW,SAAA;AAAA;;;;;;;;;cAWC,cAAA,EAAgB,EAAA,CAAG,mBAAA"}
|
package/dist/PrismicPreview.js
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import { resolveDefaultExport } from "./lib/resolveDefaultExport.js";
|
|
2
2
|
import { PrismicPreviewClient } from "./PrismicPreviewClient.js";
|
|
3
|
-
import Script from "next/script";
|
|
4
3
|
import { getToolbarSrc } from "@prismicio/client";
|
|
4
|
+
import Script from "next/script.js";
|
|
5
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
|
|
7
6
|
//#region src/PrismicPreview.tsx
|
|
8
7
|
/**
|
|
9
|
-
* React component that sets up Prismic Previews using the Prismic Toolbar. When
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* changes.
|
|
8
|
+
* React component that sets up Prismic Previews using the Prismic Toolbar. When the Prismic Toolbar
|
|
9
|
+
* send events to the browser, such as on preview updates and exiting, this component will
|
|
10
|
+
* automatically refresh the page with the changes.
|
|
13
11
|
*
|
|
14
|
-
* This component can be wrapped around your app or added anywhere in your app's
|
|
15
|
-
*
|
|
12
|
+
* This component can be wrapped around your app or added anywhere in your app's tree. It must be
|
|
13
|
+
* rendered on every page.
|
|
16
14
|
*/
|
|
17
15
|
const PrismicPreview = async (props) => {
|
|
18
16
|
const { repositoryName, children, ...otherProps } = props;
|
|
19
|
-
const { draftMode } = await import("next/headers");
|
|
17
|
+
const { draftMode } = await import("next/headers.js");
|
|
20
18
|
const toolbarSrc = getToolbarSrc(repositoryName);
|
|
21
19
|
const isDraftMode = (await draftMode()).isEnabled;
|
|
22
20
|
const ResolvedScript = resolveDefaultExport(Script);
|
|
@@ -33,7 +31,7 @@ const PrismicPreview = async (props) => {
|
|
|
33
31
|
})
|
|
34
32
|
] });
|
|
35
33
|
};
|
|
36
|
-
|
|
37
34
|
//#endregion
|
|
38
35
|
export { PrismicPreview };
|
|
36
|
+
|
|
39
37
|
//# sourceMappingURL=PrismicPreview.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicPreview.js","names":[],"sources":["../src/PrismicPreview.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"PrismicPreview.js","names":[],"sources":["../src/PrismicPreview.tsx"],"sourcesContent":["import { getToolbarSrc } from \"@prismicio/client\"\nimport Script from \"next/script\"\nimport type { FC, ReactNode } from \"react\"\n\nimport { resolveDefaultExport } from \"./lib/resolveDefaultExport\"\nimport { PrismicPreviewClient } from \"./PrismicPreviewClient\"\n\n/** Props for `<PrismicPreview>`. */\nexport type PrismicPreviewProps = {\n\t/**\n\t * The name of your Prismic repository. A Prismic Toolbar will be registered using this\n\t * repository.\n\t */\n\trepositoryName: string\n\n\t/**\n\t * The URL of your app's Prismic preview endpoint (default: `/api/preview`). This URL will be\n\t * fetched on preview update events.\n\t */\n\tupdatePreviewURL?: string\n\n\t/**\n\t * The URL of your app's exit preview endpoint (default: `/api/exit-preview`). This URL will be\n\t * fetched on preview exit events.\n\t */\n\texitPreviewURL?: string\n\n\t/** Children to render adjacent to the Prismic Toolbar. */\n\tchildren?: ReactNode\n}\n\n/**\n * React component that sets up Prismic Previews using the Prismic Toolbar. When the Prismic Toolbar\n * send events to the browser, such as on preview updates and exiting, this component will\n * automatically refresh the page with the changes.\n *\n * This component can be wrapped around your app or added anywhere in your app's tree. It must be\n * rendered on every page.\n */\nexport const PrismicPreview: FC<PrismicPreviewProps> = async (props) => {\n\tconst { repositoryName, children, ...otherProps } = props\n\n\t// Need this to avoid the following Next.js build-time error:\n\t// You're importing a component that needs next/headers. That only works\n\t// in a Server Component which is not supported in the pages/ directory.\n\tconst { draftMode } = await import(\"next/headers\")\n\n\tconst toolbarSrc = getToolbarSrc(repositoryName)\n\tconst isDraftMode = (await draftMode()).isEnabled\n\n\tconst ResolvedScript = resolveDefaultExport(Script)\n\n\treturn (\n\t\t<>\n\t\t\t{children}\n\t\t\t<PrismicPreviewClient\n\t\t\t\trepositoryName={repositoryName}\n\t\t\t\tisDraftMode={isDraftMode}\n\t\t\t\t{...otherProps}\n\t\t\t/>\n\t\t\t<ResolvedScript src={toolbarSrc} strategy=\"lazyOnload\" />\n\t\t</>\n\t)\n}\n"],"mappings":";;;;;;;;;;;;;;AAuCA,MAAa,iBAA0C,OAAO,UAAU;CACvE,MAAM,EAAE,gBAAgB,UAAU,GAAG,eAAe;CAKpD,MAAM,EAAE,cAAc,MAAM,OAAO;CAEnC,MAAM,aAAa,cAAc,eAAe;CAChD,MAAM,eAAe,MAAM,WAAW,EAAE;CAExC,MAAM,iBAAiB,qBAAqB,OAAO;AAEnD,QACC,qBAAA,UAAA,EAAA,UAAA;EACE;EACD,oBAAC,sBAAD;GACiB;GACH;GACb,GAAI;GACH,CAAA;EACF,oBAAC,gBAAD;GAAgB,KAAK;GAAY,UAAS;GAAe,CAAA;EACvD,EAAA,CAAA"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
require("./_virtual/_rolldown/runtime.cjs");
|
|
4
3
|
let _prismicio_client = require("@prismicio/client");
|
|
5
4
|
let next_navigation = require("next/navigation");
|
|
6
5
|
let react = require("react");
|
|
7
|
-
|
|
8
6
|
//#region src/PrismicPreviewClient.tsx
|
|
9
7
|
const PrismicPreviewClient = (props) => {
|
|
10
8
|
const { repositoryName, isDraftMode, updatePreviewURL = "/api/preview", exitPreviewURL = "/api/exit-preview" } = props;
|
|
@@ -51,14 +49,12 @@ const PrismicPreviewClient = (props) => {
|
|
|
51
49
|
/**
|
|
52
50
|
* Returns the value of a cookie from a given cookie store.
|
|
53
51
|
*
|
|
54
|
-
* @param cookieJar - The stringified cookie store from which to read the
|
|
55
|
-
* cookie.
|
|
56
|
-
*
|
|
52
|
+
* @param cookieJar - The stringified cookie store from which to read the cookie.
|
|
57
53
|
* @returns The value of the cookie, if it exists.
|
|
58
54
|
*/
|
|
59
55
|
function getPrismicPreviewCookie(cookieJar) {
|
|
60
|
-
function readValue(value
|
|
61
|
-
return value
|
|
56
|
+
function readValue(value) {
|
|
57
|
+
return value.replace(/%3B/g, ";");
|
|
62
58
|
}
|
|
63
59
|
const cookies = cookieJar.split("; ");
|
|
64
60
|
let value;
|
|
@@ -71,7 +67,7 @@ function getPrismicPreviewCookie(cookieJar) {
|
|
|
71
67
|
}
|
|
72
68
|
return value;
|
|
73
69
|
}
|
|
74
|
-
|
|
75
70
|
//#endregion
|
|
76
71
|
exports.PrismicPreviewClient = PrismicPreviewClient;
|
|
72
|
+
|
|
77
73
|
//# sourceMappingURL=PrismicPreviewClient.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicPreviewClient.cjs","names":["
|
|
1
|
+
{"version":3,"file":"PrismicPreviewClient.cjs","names":["prismicCookie"],"sources":["../src/PrismicPreviewClient.tsx"],"sourcesContent":["\"use client\"\n\nimport { cookie as prismicCookie } from \"@prismicio/client\"\nimport { useRouter } from \"next/navigation\"\nimport type { FC } from \"react\"\nimport { useEffect } from \"react\"\n\ntype PrismicPreviewClientProps = {\n\trepositoryName: string\n\tisDraftMode: boolean\n\tupdatePreviewURL?: string\n\texitPreviewURL?: string\n}\n\nexport const PrismicPreviewClient: FC<PrismicPreviewClientProps> = (props) => {\n\tconst {\n\t\trepositoryName,\n\t\tisDraftMode,\n\t\tupdatePreviewURL = \"/api/preview\",\n\t\texitPreviewURL = \"/api/exit-preview\",\n\t} = props\n\n\tconst { refresh } = useRouter()\n\n\tuseEffect(() => {\n\t\tconst controller = new AbortController()\n\n\t\twindow.addEventListener(\"prismicPreviewUpdate\", onUpdate, {\n\t\t\tsignal: controller.signal,\n\t\t})\n\t\twindow.addEventListener(\"prismicPreviewEnd\", onEnd, {\n\t\t\tsignal: controller.signal,\n\t\t})\n\n\t\tconst cookie = getPrismicPreviewCookie(window.document.cookie)\n\t\tconst cookieRepositoryName = cookie\n\t\t\t? (decodeURIComponent(cookie).match(/\"([^\"]+)\\.prismic\\.io\"/) || [])[1]\n\t\t\t: undefined\n\t\tconst hasCookieForRepository = cookieRepositoryName === repositoryName\n\n\t\t// Start the preview for preview share links. Previews from\n\t\t// share links do not go to the `updatePreviewURL` like a normal\n\t\t// preview.\n\t\tif (hasCookieForRepository && !isDraftMode) {\n\t\t\t// We check `opaqueredirect` because we don't care if\n\t\t\t// the redirect was successful or not. As long as it\n\t\t\t// redirects, we know the endpoint exists and draft mode\n\t\t\t// is active.\n\t\t\tglobalThis\n\t\t\t\t.fetch(updatePreviewURL, {\n\t\t\t\t\tredirect: \"manual\",\n\t\t\t\t\tsignal: controller.signal,\n\t\t\t\t})\n\t\t\t\t.then((res) => {\n\t\t\t\t\tif (res.type !== \"opaqueredirect\") {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`[<PrismicPreview>] Failed to start the preview using \"${updatePreviewURL}\". Does it exist?`,\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\trefresh()\n\t\t\t\t})\n\t\t\t\t.catch(() => {\n\t\t\t\t\t// noop\n\t\t\t\t})\n\t\t}\n\n\t\tfunction onUpdate(event: Event) {\n\t\t\tevent.preventDefault()\n\t\t\trefresh()\n\t\t}\n\n\t\tfunction onEnd(event: Event) {\n\t\t\tevent.preventDefault()\n\t\t\tglobalThis\n\t\t\t\t.fetch(exitPreviewURL, { signal: controller.signal })\n\t\t\t\t.then((res) => {\n\t\t\t\t\tif (!res.ok) {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`[<PrismicPreview>] Failed to exit Preview Mode using the \"${exitPreviewURL}\" API endpoint. Does it exist?`,\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\trefresh()\n\t\t\t\t})\n\t\t\t\t.catch(() => {\n\t\t\t\t\t// noop\n\t\t\t\t})\n\t\t}\n\n\t\treturn () => controller.abort()\n\t}, [repositoryName, isDraftMode, updatePreviewURL, exitPreviewURL, refresh])\n\n\treturn null\n}\n\n/**\n * Returns the value of a cookie from a given cookie store.\n *\n * @param cookieJar - The stringified cookie store from which to read the cookie.\n * @returns The value of the cookie, if it exists.\n */\nfunction getPrismicPreviewCookie(cookieJar: string): string | undefined {\n\tfunction readValue(value: string): string {\n\t\treturn value.replace(/%3B/g, \";\")\n\t}\n\n\tconst cookies = cookieJar.split(\"; \")\n\n\tlet value: string | undefined\n\n\tfor (const cookie of cookies) {\n\t\tconst parts = cookie.split(\"=\")\n\t\tconst name = readValue(parts[0]).replace(/%3D/g, \"=\")\n\n\t\tif (name === prismicCookie.preview) {\n\t\t\tvalue = readValue(parts.slice(1).join(\"=\"))\n\t\t\tcontinue\n\t\t}\n\t}\n\n\treturn value\n}\n"],"mappings":";;;;;;AAcA,MAAa,wBAAuD,UAAU;CAC7E,MAAM,EACL,gBACA,aACA,mBAAmB,gBACnB,iBAAiB,wBACd;CAEJ,MAAM,EAAE,aAAA,GAAA,gBAAA,YAAuB;AAE/B,EAAA,GAAA,MAAA,iBAAgB;EACf,MAAM,aAAa,IAAI,iBAAiB;AAExC,SAAO,iBAAiB,wBAAwB,UAAU,EACzD,QAAQ,WAAW,QACnB,CAAC;AACF,SAAO,iBAAiB,qBAAqB,OAAO,EACnD,QAAQ,WAAW,QACnB,CAAC;EAEF,MAAM,SAAS,wBAAwB,OAAO,SAAS,OAAO;AAS9D,OAR6B,UACzB,mBAAmB,OAAO,CAAC,MAAM,yBAAyB,IAAI,EAAE,EAAE,KACnE,KAAA,OACqD,kBAK1B,CAAC,YAK9B,YACE,MAAM,kBAAkB;GACxB,UAAU;GACV,QAAQ,WAAW;GACnB,CAAC,CACD,MAAM,QAAQ;AACd,OAAI,IAAI,SAAS,kBAAkB;AAClC,YAAQ,MACP,yDAAyD,iBAAiB,mBAC1E;AAED;;AAGD,YAAS;IACR,CACD,YAAY,GAEX;EAGJ,SAAS,SAAS,OAAc;AAC/B,SAAM,gBAAgB;AACtB,YAAS;;EAGV,SAAS,MAAM,OAAc;AAC5B,SAAM,gBAAgB;AACtB,cACE,MAAM,gBAAgB,EAAE,QAAQ,WAAW,QAAQ,CAAC,CACpD,MAAM,QAAQ;AACd,QAAI,CAAC,IAAI,IAAI;AACZ,aAAQ,MACP,6DAA6D,eAAe,gCAC5E;AAED;;AAGD,aAAS;KACR,CACD,YAAY,GAEX;;AAGJ,eAAa,WAAW,OAAO;IAC7B;EAAC;EAAgB;EAAa;EAAkB;EAAgB;EAAQ,CAAC;AAE5E,QAAO;;;;;;;;AASR,SAAS,wBAAwB,WAAuC;CACvE,SAAS,UAAU,OAAuB;AACzC,SAAO,MAAM,QAAQ,QAAQ,IAAI;;CAGlC,MAAM,UAAU,UAAU,MAAM,KAAK;CAErC,IAAI;AAEJ,MAAK,MAAM,UAAU,SAAS;EAC7B,MAAM,QAAQ,OAAO,MAAM,IAAI;AAG/B,MAFa,UAAU,MAAM,GAAG,CAAC,QAAQ,QAAQ,IAAI,KAExCA,kBAAAA,OAAc,SAAS;AACnC,WAAQ,UAAU,MAAM,MAAM,EAAE,CAAC,KAAK,IAAI,CAAC;AAC3C;;;AAIF,QAAO"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
2
|
import { cookie } from "@prismicio/client";
|
|
4
3
|
import { useRouter } from "next/navigation";
|
|
5
4
|
import { useEffect } from "react";
|
|
6
|
-
|
|
7
5
|
//#region src/PrismicPreviewClient.tsx
|
|
8
6
|
const PrismicPreviewClient = (props) => {
|
|
9
7
|
const { repositoryName, isDraftMode, updatePreviewURL = "/api/preview", exitPreviewURL = "/api/exit-preview" } = props;
|
|
@@ -12,8 +10,8 @@ const PrismicPreviewClient = (props) => {
|
|
|
12
10
|
const controller = new AbortController();
|
|
13
11
|
window.addEventListener("prismicPreviewUpdate", onUpdate, { signal: controller.signal });
|
|
14
12
|
window.addEventListener("prismicPreviewEnd", onEnd, { signal: controller.signal });
|
|
15
|
-
const cookie
|
|
16
|
-
if ((cookie
|
|
13
|
+
const cookie = getPrismicPreviewCookie(window.document.cookie);
|
|
14
|
+
if ((cookie ? (decodeURIComponent(cookie).match(/"([^"]+)\.prismic\.io"/) || [])[1] : void 0) === repositoryName && !isDraftMode) globalThis.fetch(updatePreviewURL, {
|
|
17
15
|
redirect: "manual",
|
|
18
16
|
signal: controller.signal
|
|
19
17
|
}).then((res) => {
|
|
@@ -50,14 +48,12 @@ const PrismicPreviewClient = (props) => {
|
|
|
50
48
|
/**
|
|
51
49
|
* Returns the value of a cookie from a given cookie store.
|
|
52
50
|
*
|
|
53
|
-
* @param cookieJar - The stringified cookie store from which to read the
|
|
54
|
-
* cookie.
|
|
55
|
-
*
|
|
51
|
+
* @param cookieJar - The stringified cookie store from which to read the cookie.
|
|
56
52
|
* @returns The value of the cookie, if it exists.
|
|
57
53
|
*/
|
|
58
54
|
function getPrismicPreviewCookie(cookieJar) {
|
|
59
|
-
function readValue(value
|
|
60
|
-
return value
|
|
55
|
+
function readValue(value) {
|
|
56
|
+
return value.replace(/%3B/g, ";");
|
|
61
57
|
}
|
|
62
58
|
const cookies = cookieJar.split("; ");
|
|
63
59
|
let value;
|
|
@@ -70,7 +66,7 @@ function getPrismicPreviewCookie(cookieJar) {
|
|
|
70
66
|
}
|
|
71
67
|
return value;
|
|
72
68
|
}
|
|
73
|
-
|
|
74
69
|
//#endregion
|
|
75
70
|
export { PrismicPreviewClient };
|
|
71
|
+
|
|
76
72
|
//# sourceMappingURL=PrismicPreviewClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicPreviewClient.js","names":["cookie","
|
|
1
|
+
{"version":3,"file":"PrismicPreviewClient.js","names":["cookie","prismicCookie"],"sources":["../src/PrismicPreviewClient.tsx"],"sourcesContent":["\"use client\"\n\nimport { cookie as prismicCookie } from \"@prismicio/client\"\nimport { useRouter } from \"next/navigation\"\nimport type { FC } from \"react\"\nimport { useEffect } from \"react\"\n\ntype PrismicPreviewClientProps = {\n\trepositoryName: string\n\tisDraftMode: boolean\n\tupdatePreviewURL?: string\n\texitPreviewURL?: string\n}\n\nexport const PrismicPreviewClient: FC<PrismicPreviewClientProps> = (props) => {\n\tconst {\n\t\trepositoryName,\n\t\tisDraftMode,\n\t\tupdatePreviewURL = \"/api/preview\",\n\t\texitPreviewURL = \"/api/exit-preview\",\n\t} = props\n\n\tconst { refresh } = useRouter()\n\n\tuseEffect(() => {\n\t\tconst controller = new AbortController()\n\n\t\twindow.addEventListener(\"prismicPreviewUpdate\", onUpdate, {\n\t\t\tsignal: controller.signal,\n\t\t})\n\t\twindow.addEventListener(\"prismicPreviewEnd\", onEnd, {\n\t\t\tsignal: controller.signal,\n\t\t})\n\n\t\tconst cookie = getPrismicPreviewCookie(window.document.cookie)\n\t\tconst cookieRepositoryName = cookie\n\t\t\t? (decodeURIComponent(cookie).match(/\"([^\"]+)\\.prismic\\.io\"/) || [])[1]\n\t\t\t: undefined\n\t\tconst hasCookieForRepository = cookieRepositoryName === repositoryName\n\n\t\t// Start the preview for preview share links. Previews from\n\t\t// share links do not go to the `updatePreviewURL` like a normal\n\t\t// preview.\n\t\tif (hasCookieForRepository && !isDraftMode) {\n\t\t\t// We check `opaqueredirect` because we don't care if\n\t\t\t// the redirect was successful or not. As long as it\n\t\t\t// redirects, we know the endpoint exists and draft mode\n\t\t\t// is active.\n\t\t\tglobalThis\n\t\t\t\t.fetch(updatePreviewURL, {\n\t\t\t\t\tredirect: \"manual\",\n\t\t\t\t\tsignal: controller.signal,\n\t\t\t\t})\n\t\t\t\t.then((res) => {\n\t\t\t\t\tif (res.type !== \"opaqueredirect\") {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`[<PrismicPreview>] Failed to start the preview using \"${updatePreviewURL}\". Does it exist?`,\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\trefresh()\n\t\t\t\t})\n\t\t\t\t.catch(() => {\n\t\t\t\t\t// noop\n\t\t\t\t})\n\t\t}\n\n\t\tfunction onUpdate(event: Event) {\n\t\t\tevent.preventDefault()\n\t\t\trefresh()\n\t\t}\n\n\t\tfunction onEnd(event: Event) {\n\t\t\tevent.preventDefault()\n\t\t\tglobalThis\n\t\t\t\t.fetch(exitPreviewURL, { signal: controller.signal })\n\t\t\t\t.then((res) => {\n\t\t\t\t\tif (!res.ok) {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`[<PrismicPreview>] Failed to exit Preview Mode using the \"${exitPreviewURL}\" API endpoint. Does it exist?`,\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\trefresh()\n\t\t\t\t})\n\t\t\t\t.catch(() => {\n\t\t\t\t\t// noop\n\t\t\t\t})\n\t\t}\n\n\t\treturn () => controller.abort()\n\t}, [repositoryName, isDraftMode, updatePreviewURL, exitPreviewURL, refresh])\n\n\treturn null\n}\n\n/**\n * Returns the value of a cookie from a given cookie store.\n *\n * @param cookieJar - The stringified cookie store from which to read the cookie.\n * @returns The value of the cookie, if it exists.\n */\nfunction getPrismicPreviewCookie(cookieJar: string): string | undefined {\n\tfunction readValue(value: string): string {\n\t\treturn value.replace(/%3B/g, \";\")\n\t}\n\n\tconst cookies = cookieJar.split(\"; \")\n\n\tlet value: string | undefined\n\n\tfor (const cookie of cookies) {\n\t\tconst parts = cookie.split(\"=\")\n\t\tconst name = readValue(parts[0]).replace(/%3D/g, \"=\")\n\n\t\tif (name === prismicCookie.preview) {\n\t\t\tvalue = readValue(parts.slice(1).join(\"=\"))\n\t\t\tcontinue\n\t\t}\n\t}\n\n\treturn value\n}\n"],"mappings":";;;;;AAcA,MAAa,wBAAuD,UAAU;CAC7E,MAAM,EACL,gBACA,aACA,mBAAmB,gBACnB,iBAAiB,wBACd;CAEJ,MAAM,EAAE,YAAY,WAAW;AAE/B,iBAAgB;EACf,MAAM,aAAa,IAAI,iBAAiB;AAExC,SAAO,iBAAiB,wBAAwB,UAAU,EACzD,QAAQ,WAAW,QACnB,CAAC;AACF,SAAO,iBAAiB,qBAAqB,OAAO,EACnD,QAAQ,WAAW,QACnB,CAAC;EAEF,MAAM,SAAS,wBAAwB,OAAO,SAAS,OAAO;AAS9D,OAR6B,UACzB,mBAAmB,OAAO,CAAC,MAAM,yBAAyB,IAAI,EAAE,EAAE,KACnE,KAAA,OACqD,kBAK1B,CAAC,YAK9B,YACE,MAAM,kBAAkB;GACxB,UAAU;GACV,QAAQ,WAAW;GACnB,CAAC,CACD,MAAM,QAAQ;AACd,OAAI,IAAI,SAAS,kBAAkB;AAClC,YAAQ,MACP,yDAAyD,iBAAiB,mBAC1E;AAED;;AAGD,YAAS;IACR,CACD,YAAY,GAEX;EAGJ,SAAS,SAAS,OAAc;AAC/B,SAAM,gBAAgB;AACtB,YAAS;;EAGV,SAAS,MAAM,OAAc;AAC5B,SAAM,gBAAgB;AACtB,cACE,MAAM,gBAAgB,EAAE,QAAQ,WAAW,QAAQ,CAAC,CACpD,MAAM,QAAQ;AACd,QAAI,CAAC,IAAI,IAAI;AACZ,aAAQ,MACP,6DAA6D,eAAe,gCAC5E;AAED;;AAGD,aAAS;KACR,CACD,YAAY,GAEX;;AAGJ,eAAa,WAAW,OAAO;IAC7B;EAAC;EAAgB;EAAa;EAAkB;EAAgB;EAAQ,CAAC;AAE5E,QAAO;;;;;;;;AASR,SAAS,wBAAwB,WAAuC;CACvE,SAAS,UAAU,OAAuB;AACzC,SAAO,MAAM,QAAQ,QAAQ,IAAI;;CAGlC,MAAM,UAAU,UAAU,MAAM,KAAK;CAErC,IAAI;AAEJ,MAAK,MAAMA,YAAU,SAAS;EAC7B,MAAM,QAAQA,SAAO,MAAM,IAAI;AAG/B,MAFa,UAAU,MAAM,GAAG,CAAC,QAAQ,QAAQ,IAAI,KAExCC,OAAc,SAAS;AACnC,WAAQ,UAAU,MAAM,MAAM,EAAE,CAAC,KAAK,IAAI,CAAC;AAC3C;;;AAIF,QAAO"}
|
package/dist/SliceSimulator.cjs
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const require_SliceSimulatorWrapper = require(
|
|
5
|
-
const require_getSlices = require('./getSlices.cjs');
|
|
2
|
+
require("./_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
const require_getSlices = require("./getSlices.cjs");
|
|
4
|
+
const require_SliceSimulatorWrapper = require("./SliceSimulatorWrapper.cjs");
|
|
6
5
|
let next_navigation = require("next/navigation");
|
|
7
6
|
let react = require("react");
|
|
8
7
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
8
|
let _prismicio_simulator_kit = require("@prismicio/simulator/kit");
|
|
10
9
|
let lz_string = require("lz-string");
|
|
11
|
-
|
|
12
10
|
//#region src/SliceSimulator.tsx
|
|
13
11
|
const STATE_PARAMS_KEY = "state";
|
|
14
12
|
const simulatorManager = new _prismicio_simulator_kit.SimulatorManager();
|
|
15
13
|
/**
|
|
16
|
-
* Simulate slices in isolation. The slice simulator enables live slice
|
|
17
|
-
*
|
|
14
|
+
* Simulate slices in isolation. The slice simulator enables live slice development in Slice Machine
|
|
15
|
+
* and live previews in the Page Builder.
|
|
18
16
|
*/
|
|
19
17
|
const SliceSimulator = ({ children, background, zIndex, className }) => {
|
|
20
18
|
const [message, setMessage] = (0, react.useState)(() => (0, _prismicio_simulator_kit.getDefaultMessage)());
|
|
@@ -43,7 +41,7 @@ const SliceSimulator = ({ children, background, zIndex, className }) => {
|
|
|
43
41
|
children
|
|
44
42
|
});
|
|
45
43
|
};
|
|
46
|
-
|
|
47
44
|
//#endregion
|
|
48
45
|
exports.SliceSimulator = SliceSimulator;
|
|
46
|
+
|
|
49
47
|
//# sourceMappingURL=SliceSimulator.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliceSimulator.cjs","names":["SimulatorManager","getSlices","StateEventType","SliceSimulatorWrapper"],"sources":["../src/SliceSimulator.tsx"],"sourcesContent":["\"use client\"
|
|
1
|
+
{"version":3,"file":"SliceSimulator.cjs","names":["SimulatorManager","getSlices","StateEventType","SliceSimulatorWrapper"],"sources":["../src/SliceSimulator.tsx"],"sourcesContent":["\"use client\"\n\nimport { SimulatorManager, StateEventType, getDefaultMessage } from \"@prismicio/simulator/kit\"\nimport type { SliceSimulatorProps as BaseSliceSimulatorProps } from \"@prismicio/simulator/kit\"\nimport { compressToEncodedURIComponent } from \"lz-string\"\nimport { useRouter } from \"next/navigation\"\nimport { useEffect, useState } from \"react\"\nimport type { FC, ReactNode } from \"react\"\n\nimport { getSlices } from \"./getSlices\"\nimport { SliceSimulatorWrapper } from \"./SliceSimulatorWrapper\"\n\nconst STATE_PARAMS_KEY = \"state\"\n\nconst simulatorManager = new SimulatorManager()\n\n/** Parameters provided to the Slice Simulator page. */\nexport type SliceSimulatorParams = {\n\tsearchParams: Promise<{\n\t\tstate?: string\n\t}>\n}\n\nexport type SliceSimulatorProps = BaseSliceSimulatorProps & {\n\tchildren: ReactNode\n\tclassName?: string\n}\n\n/**\n * Simulate slices in isolation. The slice simulator enables live slice development in Slice Machine\n * and live previews in the Page Builder.\n */\nexport const SliceSimulator: FC<SliceSimulatorProps> = ({\n\tchildren,\n\tbackground,\n\tzIndex,\n\tclassName,\n}) => {\n\tconst [message, setMessage] = useState(() => getDefaultMessage())\n\tconst router = useRouter()\n\n\tconst state =\n\t\ttypeof window !== \"undefined\"\n\t\t\t? new URL(window.location.href).searchParams.get(STATE_PARAMS_KEY)\n\t\t\t: undefined\n\tconst hasSlices = getSlices(state).length > 0\n\n\tuseEffect(() => {\n\t\tsimulatorManager.state.on(\n\t\t\tStateEventType.Slices,\n\t\t\t(newSlices) => {\n\t\t\t\tconst url = new URL(window.location.href)\n\t\t\t\turl.searchParams.set(\n\t\t\t\t\tSTATE_PARAMS_KEY,\n\t\t\t\t\tcompressToEncodedURIComponent(JSON.stringify(newSlices)),\n\t\t\t\t)\n\n\t\t\t\twindow.history.replaceState(null, \"\", url)\n\t\t\t\t// Wait until the next tick to prevent URL state race conditions.\n\t\t\t\tsetTimeout(() => router.refresh(), 0)\n\t\t\t},\n\t\t\t\"simulator-slices\",\n\t\t)\n\t\tsimulatorManager.state.on(\n\t\t\tStateEventType.Message,\n\t\t\t(newMessage) => setMessage(newMessage),\n\t\t\t\"simulator-message\",\n\t\t)\n\n\t\tsimulatorManager.init()\n\n\t\treturn () => {\n\t\t\tsimulatorManager.state.off(StateEventType.Slices, \"simulator-slices\")\n\n\t\t\tsimulatorManager.state.off(StateEventType.Message, \"simulator-message\")\n\t\t}\n\t}, [router])\n\n\treturn (\n\t\t<SliceSimulatorWrapper\n\t\t\tmessage={message}\n\t\t\thasSlices={hasSlices}\n\t\t\tbackground={background}\n\t\t\tzIndex={zIndex}\n\t\t\tclassName={className}\n\t\t>\n\t\t\t{children}\n\t\t</SliceSimulatorWrapper>\n\t)\n}\n"],"mappings":";;;;;;;;;;AAYA,MAAM,mBAAmB;AAEzB,MAAM,mBAAmB,IAAIA,yBAAAA,kBAAkB;;;;;AAkB/C,MAAa,kBAA2C,EACvD,UACA,YACA,QACA,gBACK;CACL,MAAM,CAAC,SAAS,eAAA,GAAA,MAAA,iBAAA,GAAA,yBAAA,oBAAgD,CAAC;CACjE,MAAM,UAAA,GAAA,gBAAA,YAAoB;CAM1B,MAAM,YAAYC,kBAAAA,UAHjB,OAAO,WAAW,cACf,IAAI,IAAI,OAAO,SAAS,KAAK,CAAC,aAAa,IAAI,iBAAiB,GAChE,KAAA,EAC8B,CAAC,SAAS;AAE5C,EAAA,GAAA,MAAA,iBAAgB;AACf,mBAAiB,MAAM,GACtBC,yBAAAA,eAAe,SACd,cAAc;GACd,MAAM,MAAM,IAAI,IAAI,OAAO,SAAS,KAAK;AACzC,OAAI,aAAa,IAChB,mBAAA,GAAA,UAAA,+BAC8B,KAAK,UAAU,UAAU,CAAC,CACxD;AAED,UAAO,QAAQ,aAAa,MAAM,IAAI,IAAI;AAE1C,oBAAiB,OAAO,SAAS,EAAE,EAAE;KAEtC,mBACA;AACD,mBAAiB,MAAM,GACtBA,yBAAAA,eAAe,UACd,eAAe,WAAW,WAAW,EACtC,oBACA;AAED,mBAAiB,MAAM;AAEvB,eAAa;AACZ,oBAAiB,MAAM,IAAIA,yBAAAA,eAAe,QAAQ,mBAAmB;AAErE,oBAAiB,MAAM,IAAIA,yBAAAA,eAAe,SAAS,oBAAoB;;IAEtE,CAAC,OAAO,CAAC;AAEZ,QACC,iBAAA,GAAA,kBAAA,KAACC,8BAAAA,uBAAD;EACU;EACE;EACC;EACJ;EACG;EAEV;EACsB,CAAA"}
|
|
@@ -2,10 +2,7 @@ import { FC, ReactNode } from "react";
|
|
|
2
2
|
import { SliceSimulatorProps } from "@prismicio/simulator/kit";
|
|
3
3
|
|
|
4
4
|
//#region src/SliceSimulator.d.ts
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Parameters provided to the Slice Simulator page.
|
|
8
|
-
*/
|
|
5
|
+
/** Parameters provided to the Slice Simulator page. */
|
|
9
6
|
type SliceSimulatorParams = {
|
|
10
7
|
searchParams: Promise<{
|
|
11
8
|
state?: string;
|
|
@@ -16,8 +13,8 @@ type SliceSimulatorProps$1 = SliceSimulatorProps & {
|
|
|
16
13
|
className?: string;
|
|
17
14
|
};
|
|
18
15
|
/**
|
|
19
|
-
* Simulate slices in isolation. The slice simulator enables live slice
|
|
20
|
-
*
|
|
16
|
+
* Simulate slices in isolation. The slice simulator enables live slice development in Slice Machine
|
|
17
|
+
* and live previews in the Page Builder.
|
|
21
18
|
*/
|
|
22
19
|
declare const SliceSimulator: FC<SliceSimulatorProps$1>;
|
|
23
20
|
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SliceSimulator.d.cts","names":[],"sources":["../src/SliceSimulator.tsx"],"mappings":";;;;;KAiBY,oBAAA;EACX,YAAA,EAAc,OAAA;IACb,KAAA;EAAA;AAAA;AAAA,KAIU,qBAAA,GAAsB,mBAAA;EACjC,QAAA,EAAU,SAAA;EACV,SAAA;AAAA;;AAFD;;;cASa,cAAA,EAAgB,EAAA,CAAG,qBAAA"}
|
package/dist/SliceSimulator.d.ts
CHANGED
|
@@ -2,10 +2,7 @@ import { FC, ReactNode } from "react";
|
|
|
2
2
|
import { SliceSimulatorProps } from "@prismicio/simulator/kit";
|
|
3
3
|
|
|
4
4
|
//#region src/SliceSimulator.d.ts
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Parameters provided to the Slice Simulator page.
|
|
8
|
-
*/
|
|
5
|
+
/** Parameters provided to the Slice Simulator page. */
|
|
9
6
|
type SliceSimulatorParams = {
|
|
10
7
|
searchParams: Promise<{
|
|
11
8
|
state?: string;
|
|
@@ -16,8 +13,8 @@ type SliceSimulatorProps$1 = SliceSimulatorProps & {
|
|
|
16
13
|
className?: string;
|
|
17
14
|
};
|
|
18
15
|
/**
|
|
19
|
-
* Simulate slices in isolation. The slice simulator enables live slice
|
|
20
|
-
*
|
|
16
|
+
* Simulate slices in isolation. The slice simulator enables live slice development in Slice Machine
|
|
17
|
+
* and live previews in the Page Builder.
|
|
21
18
|
*/
|
|
22
19
|
declare const SliceSimulator: FC<SliceSimulatorProps$1>;
|
|
23
20
|
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SliceSimulator.d.ts","names":[],"sources":["../src/SliceSimulator.tsx"],"mappings":";;;;;KAiBY,oBAAA;EACX,YAAA,EAAc,OAAA;IACb,KAAA;EAAA;AAAA;AAAA,KAIU,qBAAA,GAAsB,mBAAA;EACjC,QAAA,EAAU,SAAA;EACV,SAAA;AAAA;;AAFD;;;cASa,cAAA,EAAgB,EAAA,CAAG,qBAAA"}
|
package/dist/SliceSimulator.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
import { SliceSimulatorWrapper } from "./SliceSimulatorWrapper.js";
|
|
4
2
|
import { getSlices } from "./getSlices.js";
|
|
3
|
+
import { SliceSimulatorWrapper } from "./SliceSimulatorWrapper.js";
|
|
5
4
|
import { useRouter } from "next/navigation";
|
|
6
5
|
import { useEffect, useState } from "react";
|
|
7
6
|
import { jsx } from "react/jsx-runtime";
|
|
8
7
|
import { SimulatorManager, StateEventType, getDefaultMessage } from "@prismicio/simulator/kit";
|
|
9
8
|
import { compressToEncodedURIComponent } from "lz-string";
|
|
10
|
-
|
|
11
9
|
//#region src/SliceSimulator.tsx
|
|
12
10
|
const STATE_PARAMS_KEY = "state";
|
|
13
11
|
const simulatorManager = new SimulatorManager();
|
|
14
12
|
/**
|
|
15
|
-
* Simulate slices in isolation. The slice simulator enables live slice
|
|
16
|
-
*
|
|
13
|
+
* Simulate slices in isolation. The slice simulator enables live slice development in Slice Machine
|
|
14
|
+
* and live previews in the Page Builder.
|
|
17
15
|
*/
|
|
18
16
|
const SliceSimulator = ({ children, background, zIndex, className }) => {
|
|
19
17
|
const [message, setMessage] = useState(() => getDefaultMessage());
|
|
@@ -42,7 +40,7 @@ const SliceSimulator = ({ children, background, zIndex, className }) => {
|
|
|
42
40
|
children
|
|
43
41
|
});
|
|
44
42
|
};
|
|
45
|
-
|
|
46
43
|
//#endregion
|
|
47
44
|
export { SliceSimulator };
|
|
45
|
+
|
|
48
46
|
//# sourceMappingURL=SliceSimulator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliceSimulator.js","names":[],"sources":["../src/SliceSimulator.tsx"],"sourcesContent":["\"use client\"
|
|
1
|
+
{"version":3,"file":"SliceSimulator.js","names":[],"sources":["../src/SliceSimulator.tsx"],"sourcesContent":["\"use client\"\n\nimport { SimulatorManager, StateEventType, getDefaultMessage } from \"@prismicio/simulator/kit\"\nimport type { SliceSimulatorProps as BaseSliceSimulatorProps } from \"@prismicio/simulator/kit\"\nimport { compressToEncodedURIComponent } from \"lz-string\"\nimport { useRouter } from \"next/navigation\"\nimport { useEffect, useState } from \"react\"\nimport type { FC, ReactNode } from \"react\"\n\nimport { getSlices } from \"./getSlices\"\nimport { SliceSimulatorWrapper } from \"./SliceSimulatorWrapper\"\n\nconst STATE_PARAMS_KEY = \"state\"\n\nconst simulatorManager = new SimulatorManager()\n\n/** Parameters provided to the Slice Simulator page. */\nexport type SliceSimulatorParams = {\n\tsearchParams: Promise<{\n\t\tstate?: string\n\t}>\n}\n\nexport type SliceSimulatorProps = BaseSliceSimulatorProps & {\n\tchildren: ReactNode\n\tclassName?: string\n}\n\n/**\n * Simulate slices in isolation. The slice simulator enables live slice development in Slice Machine\n * and live previews in the Page Builder.\n */\nexport const SliceSimulator: FC<SliceSimulatorProps> = ({\n\tchildren,\n\tbackground,\n\tzIndex,\n\tclassName,\n}) => {\n\tconst [message, setMessage] = useState(() => getDefaultMessage())\n\tconst router = useRouter()\n\n\tconst state =\n\t\ttypeof window !== \"undefined\"\n\t\t\t? new URL(window.location.href).searchParams.get(STATE_PARAMS_KEY)\n\t\t\t: undefined\n\tconst hasSlices = getSlices(state).length > 0\n\n\tuseEffect(() => {\n\t\tsimulatorManager.state.on(\n\t\t\tStateEventType.Slices,\n\t\t\t(newSlices) => {\n\t\t\t\tconst url = new URL(window.location.href)\n\t\t\t\turl.searchParams.set(\n\t\t\t\t\tSTATE_PARAMS_KEY,\n\t\t\t\t\tcompressToEncodedURIComponent(JSON.stringify(newSlices)),\n\t\t\t\t)\n\n\t\t\t\twindow.history.replaceState(null, \"\", url)\n\t\t\t\t// Wait until the next tick to prevent URL state race conditions.\n\t\t\t\tsetTimeout(() => router.refresh(), 0)\n\t\t\t},\n\t\t\t\"simulator-slices\",\n\t\t)\n\t\tsimulatorManager.state.on(\n\t\t\tStateEventType.Message,\n\t\t\t(newMessage) => setMessage(newMessage),\n\t\t\t\"simulator-message\",\n\t\t)\n\n\t\tsimulatorManager.init()\n\n\t\treturn () => {\n\t\t\tsimulatorManager.state.off(StateEventType.Slices, \"simulator-slices\")\n\n\t\t\tsimulatorManager.state.off(StateEventType.Message, \"simulator-message\")\n\t\t}\n\t}, [router])\n\n\treturn (\n\t\t<SliceSimulatorWrapper\n\t\t\tmessage={message}\n\t\t\thasSlices={hasSlices}\n\t\t\tbackground={background}\n\t\t\tzIndex={zIndex}\n\t\t\tclassName={className}\n\t\t>\n\t\t\t{children}\n\t\t</SliceSimulatorWrapper>\n\t)\n}\n"],"mappings":";;;;;;;;;AAYA,MAAM,mBAAmB;AAEzB,MAAM,mBAAmB,IAAI,kBAAkB;;;;;AAkB/C,MAAa,kBAA2C,EACvD,UACA,YACA,QACA,gBACK;CACL,MAAM,CAAC,SAAS,cAAc,eAAe,mBAAmB,CAAC;CACjE,MAAM,SAAS,WAAW;CAM1B,MAAM,YAAY,UAHjB,OAAO,WAAW,cACf,IAAI,IAAI,OAAO,SAAS,KAAK,CAAC,aAAa,IAAI,iBAAiB,GAChE,KAAA,EAC8B,CAAC,SAAS;AAE5C,iBAAgB;AACf,mBAAiB,MAAM,GACtB,eAAe,SACd,cAAc;GACd,MAAM,MAAM,IAAI,IAAI,OAAO,SAAS,KAAK;AACzC,OAAI,aAAa,IAChB,kBACA,8BAA8B,KAAK,UAAU,UAAU,CAAC,CACxD;AAED,UAAO,QAAQ,aAAa,MAAM,IAAI,IAAI;AAE1C,oBAAiB,OAAO,SAAS,EAAE,EAAE;KAEtC,mBACA;AACD,mBAAiB,MAAM,GACtB,eAAe,UACd,eAAe,WAAW,WAAW,EACtC,oBACA;AAED,mBAAiB,MAAM;AAEvB,eAAa;AACZ,oBAAiB,MAAM,IAAI,eAAe,QAAQ,mBAAmB;AAErE,oBAAiB,MAAM,IAAI,eAAe,SAAS,oBAAoB;;IAEtE,CAAC,OAAO,CAAC;AAEZ,QACC,oBAAC,uBAAD;EACU;EACE;EACC;EACJ;EACG;EAEV;EACsB,CAAA"}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
require("./_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
3
3
|
let _prismicio_simulator_kit = require("@prismicio/simulator/kit");
|
|
4
|
-
|
|
5
4
|
//#region src/SliceSimulatorWrapper.tsx
|
|
6
|
-
/**
|
|
7
|
-
* A wrapper for the slice simulator that isolates the given children from the
|
|
8
|
-
* page's layout.
|
|
9
|
-
*/
|
|
5
|
+
/** A wrapper for the slice simulator that isolates the given children from the page's layout. */
|
|
10
6
|
const SliceSimulatorWrapper = ({ className, children, zIndex, background, message, hasSlices }) => {
|
|
11
7
|
const defaultProps = (0, _prismicio_simulator_kit.getDefaultProps)();
|
|
12
8
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -30,7 +26,7 @@ const SliceSimulatorWrapper = ({ className, children, zIndex, background, messag
|
|
|
30
26
|
}) : null
|
|
31
27
|
});
|
|
32
28
|
};
|
|
33
|
-
|
|
34
29
|
//#endregion
|
|
35
30
|
exports.SliceSimulatorWrapper = SliceSimulatorWrapper;
|
|
31
|
+
|
|
36
32
|
//# sourceMappingURL=SliceSimulatorWrapper.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliceSimulatorWrapper.cjs","names":["simulatorClass","simulatorRootClass","onClickHandler","disableEventHandler"],"sources":["../src/SliceSimulatorWrapper.tsx"],"sourcesContent":["import {\n\tdisableEventHandler,\n\tgetDefaultProps,\n\tonClickHandler,\n\tsimulatorClass,\n\tsimulatorRootClass,\n} from \"@prismicio/simulator/kit\"
|
|
1
|
+
{"version":3,"file":"SliceSimulatorWrapper.cjs","names":["simulatorClass","simulatorRootClass","onClickHandler","disableEventHandler"],"sources":["../src/SliceSimulatorWrapper.tsx"],"sourcesContent":["import {\n\tdisableEventHandler,\n\tgetDefaultProps,\n\tonClickHandler,\n\tsimulatorClass,\n\tsimulatorRootClass,\n} from \"@prismicio/simulator/kit\"\nimport type { SliceSimulatorProps } from \"@prismicio/simulator/kit\"\nimport type { FC, ReactNode } from \"react\"\n\ntype SliceSimulatorWrapperProps = SliceSimulatorProps & {\n\tchildren: ReactNode\n\tclassName?: string\n\tmessage?: string\n\thasSlices: boolean\n}\n\n/** A wrapper for the slice simulator that isolates the given children from the page's layout. */\nexport const SliceSimulatorWrapper: FC<SliceSimulatorWrapperProps> = ({\n\tclassName,\n\tchildren,\n\tzIndex,\n\tbackground,\n\tmessage,\n\thasSlices,\n}) => {\n\tconst defaultProps = getDefaultProps()\n\n\treturn (\n\t\t<div\n\t\t\tclassName={[simulatorClass, className].filter(Boolean).join(\" \")}\n\t\t\tstyle={{\n\t\t\t\tzIndex: typeof zIndex === \"undefined\" ? defaultProps.zIndex : (zIndex ?? undefined),\n\t\t\t\tposition: \"fixed\",\n\t\t\t\ttop: 0,\n\t\t\t\tleft: 0,\n\t\t\t\twidth: \"100%\",\n\t\t\t\theight: \"100vh\",\n\t\t\t\toverflow: \"auto\",\n\t\t\t\tbackground:\n\t\t\t\t\ttypeof background === \"undefined\" ? defaultProps.background : (background ?? undefined),\n\t\t\t}}\n\t\t>\n\t\t\t{message ? (\n\t\t\t\t<article dangerouslySetInnerHTML={{ __html: message }} />\n\t\t\t) : hasSlices ? (\n\t\t\t\t<div\n\t\t\t\t\tid=\"root\"\n\t\t\t\t\tclassName={simulatorRootClass}\n\t\t\t\t\tonClickCapture={onClickHandler as unknown as React.MouseEventHandler}\n\t\t\t\t\tonSubmitCapture={disableEventHandler as unknown as React.FormEventHandler}\n\t\t\t\t>\n\t\t\t\t\t{children}\n\t\t\t\t</div>\n\t\t\t) : null}\n\t\t</div>\n\t)\n}\n"],"mappings":";;;;;AAkBA,MAAa,yBAAyD,EACrE,WACA,UACA,QACA,YACA,SACA,gBACK;CACL,MAAM,gBAAA,GAAA,yBAAA,kBAAgC;AAEtC,QACC,iBAAA,GAAA,kBAAA,KAAC,OAAD;EACC,WAAW,CAACA,yBAAAA,gBAAgB,UAAU,CAAC,OAAO,QAAQ,CAAC,KAAK,IAAI;EAChE,OAAO;GACN,QAAQ,OAAO,WAAW,cAAc,aAAa,SAAU,UAAU,KAAA;GACzE,UAAU;GACV,KAAK;GACL,MAAM;GACN,OAAO;GACP,QAAQ;GACR,UAAU;GACV,YACC,OAAO,eAAe,cAAc,aAAa,aAAc,cAAc,KAAA;GAC9E;YAEA,UACA,iBAAA,GAAA,kBAAA,KAAC,WAAD,EAAS,yBAAyB,EAAE,QAAQ,SAAS,EAAI,CAAA,GACtD,YACH,iBAAA,GAAA,kBAAA,KAAC,OAAD;GACC,IAAG;GACH,WAAWC,yBAAAA;GACX,gBAAgBC,yBAAAA;GAChB,iBAAiBC,yBAAAA;GAEhB;GACI,CAAA,GACH;EACC,CAAA"}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { disableEventHandler, getDefaultProps, onClickHandler, simulatorClass, simulatorRootClass } from "@prismicio/simulator/kit";
|
|
3
|
-
|
|
4
3
|
//#region src/SliceSimulatorWrapper.tsx
|
|
5
|
-
/**
|
|
6
|
-
* A wrapper for the slice simulator that isolates the given children from the
|
|
7
|
-
* page's layout.
|
|
8
|
-
*/
|
|
4
|
+
/** A wrapper for the slice simulator that isolates the given children from the page's layout. */
|
|
9
5
|
const SliceSimulatorWrapper = ({ className, children, zIndex, background, message, hasSlices }) => {
|
|
10
6
|
const defaultProps = getDefaultProps();
|
|
11
7
|
return /* @__PURE__ */ jsx("div", {
|
|
@@ -29,7 +25,7 @@ const SliceSimulatorWrapper = ({ className, children, zIndex, background, messag
|
|
|
29
25
|
}) : null
|
|
30
26
|
});
|
|
31
27
|
};
|
|
32
|
-
|
|
33
28
|
//#endregion
|
|
34
29
|
export { SliceSimulatorWrapper };
|
|
30
|
+
|
|
35
31
|
//# sourceMappingURL=SliceSimulatorWrapper.js.map
|