@prismicio/next 2.2.1-pr.131.6624bed → 2.2.1-pr.131.6c77550

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.
@@ -16,7 +16,7 @@ const simulatorManager = new _prismicio_simulator_kit.SimulatorManager();
16
16
  * development in Slice Machine and live previews in the Page Builder.
17
17
  */
18
18
  const SliceSimulator = ({ children, background, zIndex, className }) => {
19
- const [message, setMessage] = (0, react.useState)((0, _prismicio_simulator_kit.getDefaultMessage)());
19
+ const [message, setMessage] = (0, react.useState)(() => (0, _prismicio_simulator_kit.getDefaultMessage)());
20
20
  const router = (0, next_navigation.useRouter)();
21
21
  const routerRef = (0, react.useRef)(router);
22
22
  routerRef.current = router;
@@ -1 +1 @@
1
- {"version":3,"file":"SliceSimulator.cjs","names":["SimulatorManager","StateEventType","SliceSimulatorWrapper"],"sources":["../src/SliceSimulator.tsx"],"sourcesContent":["\"use client\";\n\nimport { SliceSimulatorWrapper } from \"./SliceSimulatorWrapper\";\nimport {\n\tSimulatorManager,\n\tStateEventType,\n\tgetDefaultMessage,\n} 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, useRef, useState } from \"react\";\nimport type { FC, ReactNode } from \"react\";\n\nconst STATE_PARAMS_KEY = \"state\";\n\nconst simulatorManager = new SimulatorManager();\n\n/**\n * Parameters provided to the Slice Simulator page.\n */\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\n * development in Slice Machine 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\tconst routerRef = useRef(router);\n\trouterRef.current = router;\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(() => routerRef.current.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}, []);\n\n\treturn (\n\t\t<SliceSimulatorWrapper\n\t\t\tmessage={message}\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":";;;;;;;;;;;AAcA,MAAM,mBAAmB;AAEzB,MAAM,mBAAmB,IAAIA,2CAAkB;;;;;AAoB/C,MAAa,kBAA2C,EACvD,UACA,YACA,QACA,gBACK;CACL,MAAM,CAAC,SAAS,mFAA0C,CAAC;CAC3D,MAAM,yCAAoB;CAC1B,MAAM,8BAAmB,OAAO;AAChC,WAAU,UAAU;AAEpB,4BAAgB;AACf,mBAAiB,MAAM,GACtBC,wCAAe,SACd,cAAc;GACd,MAAM,MAAM,IAAI,IAAI,OAAO,SAAS,KAAK;AACzC,OAAI,aAAa,IAChB,+DAC8B,KAAK,UAAU,UAAU,CAAC,CACxD;AAED,UAAO,QAAQ,aAAa,MAAM,IAAI,IAAI;AAE1C,oBAAiB,UAAU,QAAQ,SAAS,EAAE,EAAE;KAEjD,mBACA;AACD,mBAAiB,MAAM,GACtBA,wCAAe,UACd,eAAe,WAAW,WAAW,EACtC,oBACA;AAED,mBAAiB,MAAM;AAEvB,eAAa;AACZ,oBAAiB,MAAM,IAAIA,wCAAe,QAAQ,mBAAmB;AAErE,oBAAiB,MAAM,IAAIA,wCAAe,SAAS,oBAAoB;;IAEtE,EAAE,CAAC;AAEN,QACC,2CAACC;EACS;EACG;EACJ;EACG;EAEV;GACsB"}
1
+ {"version":3,"file":"SliceSimulator.cjs","names":["SimulatorManager","StateEventType","SliceSimulatorWrapper"],"sources":["../src/SliceSimulator.tsx"],"sourcesContent":["\"use client\";\n\nimport { SliceSimulatorWrapper } from \"./SliceSimulatorWrapper\";\nimport {\n\tSimulatorManager,\n\tStateEventType,\n\tgetDefaultMessage,\n} 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, useRef, useState } from \"react\";\nimport type { FC, ReactNode } from \"react\";\n\nconst STATE_PARAMS_KEY = \"state\";\n\nconst simulatorManager = new SimulatorManager();\n\n/**\n * Parameters provided to the Slice Simulator page.\n */\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\n * development in Slice Machine 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\tconst routerRef = useRef(router);\n\trouterRef.current = router;\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(() => routerRef.current.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}, []);\n\n\treturn (\n\t\t<SliceSimulatorWrapper\n\t\t\tmessage={message}\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":";;;;;;;;;;;AAcA,MAAM,mBAAmB;AAEzB,MAAM,mBAAmB,IAAIA,2CAAkB;;;;;AAoB/C,MAAa,kBAA2C,EACvD,UACA,YACA,QACA,gBACK;CACL,MAAM,CAAC,SAAS,yFAAgD,CAAC;CACjE,MAAM,yCAAoB;CAC1B,MAAM,8BAAmB,OAAO;AAChC,WAAU,UAAU;AAEpB,4BAAgB;AACf,mBAAiB,MAAM,GACtBC,wCAAe,SACd,cAAc;GACd,MAAM,MAAM,IAAI,IAAI,OAAO,SAAS,KAAK;AACzC,OAAI,aAAa,IAChB,+DAC8B,KAAK,UAAU,UAAU,CAAC,CACxD;AAED,UAAO,QAAQ,aAAa,MAAM,IAAI,IAAI;AAE1C,oBAAiB,UAAU,QAAQ,SAAS,EAAE,EAAE;KAEjD,mBACA;AACD,mBAAiB,MAAM,GACtBA,wCAAe,UACd,eAAe,WAAW,WAAW,EACtC,oBACA;AAED,mBAAiB,MAAM;AAEvB,eAAa;AACZ,oBAAiB,MAAM,IAAIA,wCAAe,QAAQ,mBAAmB;AAErE,oBAAiB,MAAM,IAAIA,wCAAe,SAAS,oBAAoB;;IAEtE,EAAE,CAAC;AAEN,QACC,2CAACC;EACS;EACG;EACJ;EACG;EAEV;GACsB"}
@@ -15,7 +15,7 @@ const simulatorManager = new SimulatorManager();
15
15
  * development in Slice Machine and live previews in the Page Builder.
16
16
  */
17
17
  const SliceSimulator = ({ children, background, zIndex, className }) => {
18
- const [message, setMessage] = useState(getDefaultMessage());
18
+ const [message, setMessage] = useState(() => getDefaultMessage());
19
19
  const router = useRouter();
20
20
  const routerRef = useRef(router);
21
21
  routerRef.current = router;
@@ -1 +1 @@
1
- {"version":3,"file":"SliceSimulator.js","names":[],"sources":["../src/SliceSimulator.tsx"],"sourcesContent":["\"use client\";\n\nimport { SliceSimulatorWrapper } from \"./SliceSimulatorWrapper\";\nimport {\n\tSimulatorManager,\n\tStateEventType,\n\tgetDefaultMessage,\n} 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, useRef, useState } from \"react\";\nimport type { FC, ReactNode } from \"react\";\n\nconst STATE_PARAMS_KEY = \"state\";\n\nconst simulatorManager = new SimulatorManager();\n\n/**\n * Parameters provided to the Slice Simulator page.\n */\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\n * development in Slice Machine 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\tconst routerRef = useRef(router);\n\trouterRef.current = router;\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(() => routerRef.current.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}, []);\n\n\treturn (\n\t\t<SliceSimulatorWrapper\n\t\t\tmessage={message}\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":";;;;;;;;;;AAcA,MAAM,mBAAmB;AAEzB,MAAM,mBAAmB,IAAI,kBAAkB;;;;;AAoB/C,MAAa,kBAA2C,EACvD,UACA,YACA,QACA,gBACK;CACL,MAAM,CAAC,SAAS,cAAc,SAAS,mBAAmB,CAAC;CAC3D,MAAM,SAAS,WAAW;CAC1B,MAAM,YAAY,OAAO,OAAO;AAChC,WAAU,UAAU;AAEpB,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,UAAU,QAAQ,SAAS,EAAE,EAAE;KAEjD,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,EAAE,CAAC;AAEN,QACC,oBAAC;EACS;EACG;EACJ;EACG;EAEV;GACsB"}
1
+ {"version":3,"file":"SliceSimulator.js","names":[],"sources":["../src/SliceSimulator.tsx"],"sourcesContent":["\"use client\";\n\nimport { SliceSimulatorWrapper } from \"./SliceSimulatorWrapper\";\nimport {\n\tSimulatorManager,\n\tStateEventType,\n\tgetDefaultMessage,\n} 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, useRef, useState } from \"react\";\nimport type { FC, ReactNode } from \"react\";\n\nconst STATE_PARAMS_KEY = \"state\";\n\nconst simulatorManager = new SimulatorManager();\n\n/**\n * Parameters provided to the Slice Simulator page.\n */\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\n * development in Slice Machine 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\tconst routerRef = useRef(router);\n\trouterRef.current = router;\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(() => routerRef.current.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}, []);\n\n\treturn (\n\t\t<SliceSimulatorWrapper\n\t\t\tmessage={message}\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":";;;;;;;;;;AAcA,MAAM,mBAAmB;AAEzB,MAAM,mBAAmB,IAAI,kBAAkB;;;;;AAoB/C,MAAa,kBAA2C,EACvD,UACA,YACA,QACA,gBACK;CACL,MAAM,CAAC,SAAS,cAAc,eAAe,mBAAmB,CAAC;CACjE,MAAM,SAAS,WAAW;CAC1B,MAAM,YAAY,OAAO,OAAO;AAChC,WAAU,UAAU;AAEpB,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,UAAU,QAAQ,SAAS,EAAE,EAAE;KAEjD,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,EAAE,CAAC;AAEN,QACC,oBAAC;EACS;EACG;EACJ;EACG;EAEV;GACsB"}
@@ -9,7 +9,7 @@ let _prismicio_simulator_kit = require("@prismicio/simulator/kit");
9
9
  */
10
10
  const SliceSimulatorWrapper = ({ className, children, zIndex, background, message }) => {
11
11
  const defaultProps = (0, _prismicio_simulator_kit.getDefaultProps)();
12
- const outerProps = {
12
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
13
13
  className: [_prismicio_simulator_kit.simulatorClass, className].filter(Boolean).join(" "),
14
14
  style: {
15
15
  zIndex: typeof zIndex === "undefined" ? defaultProps.zIndex : zIndex ?? void 0,
@@ -20,15 +20,8 @@ const SliceSimulatorWrapper = ({ className, children, zIndex, background, messag
20
20
  height: "100vh",
21
21
  overflow: "auto",
22
22
  background: typeof background === "undefined" ? defaultProps.background : background ?? void 0
23
- }
24
- };
25
- if (message) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
26
- ...outerProps,
27
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("article", { dangerouslySetInnerHTML: { __html: message } })
28
- });
29
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
30
- ...outerProps,
31
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
23
+ },
24
+ children: message ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("article", { dangerouslySetInnerHTML: { __html: message } }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
32
25
  id: "root",
33
26
  className: _prismicio_simulator_kit.simulatorRootClass,
34
27
  onClickCapture: _prismicio_simulator_kit.onClickHandler,
@@ -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\";\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};\n\n/**\n * A wrapper for the slice simulator that isolates the given children from the\n * page's layout.\n */\nexport const SliceSimulatorWrapper: FC<SliceSimulatorWrapperProps> = ({\n\tclassName,\n\tchildren,\n\tzIndex,\n\tbackground,\n\tmessage,\n}) => {\n\tconst defaultProps = getDefaultProps();\n\n\tconst outerProps = {\n\t\tclassName: [simulatorClass, className].filter(Boolean).join(\" \"),\n\t\tstyle: {\n\t\t\tzIndex:\n\t\t\t\ttypeof zIndex === \"undefined\"\n\t\t\t\t\t? defaultProps.zIndex\n\t\t\t\t\t: (zIndex ?? undefined),\n\t\t\tposition: \"fixed\" as const,\n\t\t\ttop: 0,\n\t\t\tleft: 0,\n\t\t\twidth: \"100%\",\n\t\t\theight: \"100vh\",\n\t\t\toverflow: \"auto\",\n\t\t\tbackground:\n\t\t\t\ttypeof background === \"undefined\"\n\t\t\t\t\t? defaultProps.background\n\t\t\t\t\t: (background ?? undefined),\n\t\t},\n\t};\n\n\tif (message) {\n\t\treturn (\n\t\t\t<div {...outerProps}>\n\t\t\t\t<article dangerouslySetInnerHTML={{ __html: message }} />\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div {...outerProps}>\n\t\t\t<div\n\t\t\t\tid=\"root\"\n\t\t\t\tclassName={simulatorRootClass}\n\t\t\t\tonClickCapture={onClickHandler as unknown as React.MouseEventHandler}\n\t\t\t\tonSubmitCapture={\n\t\t\t\t\tdisableEventHandler as unknown as React.FormEventHandler\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t</div>\n\t);\n};\n"],"mappings":";;;;;;;;;AAoBA,MAAa,yBAAyD,EACrE,WACA,UACA,QACA,YACA,cACK;CACL,MAAM,8DAAgC;CAEtC,MAAM,aAAa;EAClB,WAAW,CAACA,yCAAgB,UAAU,CAAC,OAAO,QAAQ,CAAC,KAAK,IAAI;EAChE,OAAO;GACN,QACC,OAAO,WAAW,cACf,aAAa,SACZ,UAAU;GACf,UAAU;GACV,KAAK;GACL,MAAM;GACN,OAAO;GACP,QAAQ;GACR,UAAU;GACV,YACC,OAAO,eAAe,cACnB,aAAa,aACZ,cAAc;GACnB;EACD;AAED,KAAI,QACH,QACC,2CAAC;EAAI,GAAI;YACR,2CAAC,aAAQ,yBAAyB,EAAE,QAAQ,SAAS,GAAI;GACpD;AAIR,QACC,2CAAC;EAAI,GAAI;YACR,2CAAC;GACA,IAAG;GACH,WAAWC;GACX,gBAAgBC;GAChB,iBACCC;GAGA;IACI;GACD"}
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};\n\n/**\n * A wrapper for the slice simulator that isolates the given children from the\n * page's layout.\n */\nexport const SliceSimulatorWrapper: FC<SliceSimulatorWrapperProps> = ({\n\tclassName,\n\tchildren,\n\tzIndex,\n\tbackground,\n\tmessage,\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:\n\t\t\t\t\ttypeof zIndex === \"undefined\"\n\t\t\t\t\t\t? defaultProps.zIndex\n\t\t\t\t\t\t: (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\"\n\t\t\t\t\t\t? defaultProps.background\n\t\t\t\t\t\t: (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) : (\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={\n\t\t\t\t\t\tdisableEventHandler as unknown as React.FormEventHandler\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{children}\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</div>\n\t);\n};\n"],"mappings":";;;;;;;;;AAoBA,MAAa,yBAAyD,EACrE,WACA,UACA,QACA,YACA,cACK;CACL,MAAM,8DAAgC;AAEtC,QACC,2CAAC;EACA,WAAW,CAACA,yCAAgB,UAAU,CAAC,OAAO,QAAQ,CAAC,KAAK,IAAI;EAChE,OAAO;GACN,QACC,OAAO,WAAW,cACf,aAAa,SACZ,UAAU;GACf,UAAU;GACV,KAAK;GACL,MAAM;GACN,OAAO;GACP,QAAQ;GACR,UAAU;GACV,YACC,OAAO,eAAe,cACnB,aAAa,aACZ,cAAc;GACnB;YAEA,UACA,2CAAC,aAAQ,yBAAyB,EAAE,QAAQ,SAAS,GAAI,GAEzD,2CAAC;GACA,IAAG;GACH,WAAWC;GACX,gBAAgBC;GAChB,iBACCC;GAGA;IACI;GAEF"}
@@ -8,7 +8,7 @@ import { disableEventHandler, getDefaultProps, onClickHandler, simulatorClass, s
8
8
  */
9
9
  const SliceSimulatorWrapper = ({ className, children, zIndex, background, message }) => {
10
10
  const defaultProps = getDefaultProps();
11
- const outerProps = {
11
+ return /* @__PURE__ */ jsx("div", {
12
12
  className: [simulatorClass, className].filter(Boolean).join(" "),
13
13
  style: {
14
14
  zIndex: typeof zIndex === "undefined" ? defaultProps.zIndex : zIndex ?? void 0,
@@ -19,15 +19,8 @@ const SliceSimulatorWrapper = ({ className, children, zIndex, background, messag
19
19
  height: "100vh",
20
20
  overflow: "auto",
21
21
  background: typeof background === "undefined" ? defaultProps.background : background ?? void 0
22
- }
23
- };
24
- if (message) return /* @__PURE__ */ jsx("div", {
25
- ...outerProps,
26
- children: /* @__PURE__ */ jsx("article", { dangerouslySetInnerHTML: { __html: message } })
27
- });
28
- return /* @__PURE__ */ jsx("div", {
29
- ...outerProps,
30
- children: /* @__PURE__ */ jsx("div", {
22
+ },
23
+ children: message ? /* @__PURE__ */ jsx("article", { dangerouslySetInnerHTML: { __html: message } }) : /* @__PURE__ */ jsx("div", {
31
24
  id: "root",
32
25
  className: simulatorRootClass,
33
26
  onClickCapture: onClickHandler,
@@ -1 +1 @@
1
- {"version":3,"file":"SliceSimulatorWrapper.js","names":[],"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};\n\n/**\n * A wrapper for the slice simulator that isolates the given children from the\n * page's layout.\n */\nexport const SliceSimulatorWrapper: FC<SliceSimulatorWrapperProps> = ({\n\tclassName,\n\tchildren,\n\tzIndex,\n\tbackground,\n\tmessage,\n}) => {\n\tconst defaultProps = getDefaultProps();\n\n\tconst outerProps = {\n\t\tclassName: [simulatorClass, className].filter(Boolean).join(\" \"),\n\t\tstyle: {\n\t\t\tzIndex:\n\t\t\t\ttypeof zIndex === \"undefined\"\n\t\t\t\t\t? defaultProps.zIndex\n\t\t\t\t\t: (zIndex ?? undefined),\n\t\t\tposition: \"fixed\" as const,\n\t\t\ttop: 0,\n\t\t\tleft: 0,\n\t\t\twidth: \"100%\",\n\t\t\theight: \"100vh\",\n\t\t\toverflow: \"auto\",\n\t\t\tbackground:\n\t\t\t\ttypeof background === \"undefined\"\n\t\t\t\t\t? defaultProps.background\n\t\t\t\t\t: (background ?? undefined),\n\t\t},\n\t};\n\n\tif (message) {\n\t\treturn (\n\t\t\t<div {...outerProps}>\n\t\t\t\t<article dangerouslySetInnerHTML={{ __html: message }} />\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div {...outerProps}>\n\t\t\t<div\n\t\t\t\tid=\"root\"\n\t\t\t\tclassName={simulatorRootClass}\n\t\t\t\tonClickCapture={onClickHandler as unknown as React.MouseEventHandler}\n\t\t\t\tonSubmitCapture={\n\t\t\t\t\tdisableEventHandler as unknown as React.FormEventHandler\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t</div>\n\t);\n};\n"],"mappings":";;;;;;;;AAoBA,MAAa,yBAAyD,EACrE,WACA,UACA,QACA,YACA,cACK;CACL,MAAM,eAAe,iBAAiB;CAEtC,MAAM,aAAa;EAClB,WAAW,CAAC,gBAAgB,UAAU,CAAC,OAAO,QAAQ,CAAC,KAAK,IAAI;EAChE,OAAO;GACN,QACC,OAAO,WAAW,cACf,aAAa,SACZ,UAAU;GACf,UAAU;GACV,KAAK;GACL,MAAM;GACN,OAAO;GACP,QAAQ;GACR,UAAU;GACV,YACC,OAAO,eAAe,cACnB,aAAa,aACZ,cAAc;GACnB;EACD;AAED,KAAI,QACH,QACC,oBAAC;EAAI,GAAI;YACR,oBAAC,aAAQ,yBAAyB,EAAE,QAAQ,SAAS,GAAI;GACpD;AAIR,QACC,oBAAC;EAAI,GAAI;YACR,oBAAC;GACA,IAAG;GACH,WAAW;GACX,gBAAgB;GAChB,iBACC;GAGA;IACI;GACD"}
1
+ {"version":3,"file":"SliceSimulatorWrapper.js","names":[],"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};\n\n/**\n * A wrapper for the slice simulator that isolates the given children from the\n * page's layout.\n */\nexport const SliceSimulatorWrapper: FC<SliceSimulatorWrapperProps> = ({\n\tclassName,\n\tchildren,\n\tzIndex,\n\tbackground,\n\tmessage,\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:\n\t\t\t\t\ttypeof zIndex === \"undefined\"\n\t\t\t\t\t\t? defaultProps.zIndex\n\t\t\t\t\t\t: (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\"\n\t\t\t\t\t\t? defaultProps.background\n\t\t\t\t\t\t: (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) : (\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={\n\t\t\t\t\t\tdisableEventHandler as unknown as React.FormEventHandler\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{children}\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</div>\n\t);\n};\n"],"mappings":";;;;;;;;AAoBA,MAAa,yBAAyD,EACrE,WACA,UACA,QACA,YACA,cACK;CACL,MAAM,eAAe,iBAAiB;AAEtC,QACC,oBAAC;EACA,WAAW,CAAC,gBAAgB,UAAU,CAAC,OAAO,QAAQ,CAAC,KAAK,IAAI;EAChE,OAAO;GACN,QACC,OAAO,WAAW,cACf,aAAa,SACZ,UAAU;GACf,UAAU;GACV,KAAK;GACL,MAAM;GACN,OAAO;GACP,QAAQ;GACR,UAAU;GACV,YACC,OAAO,eAAe,cACnB,aAAa,aACZ,cAAc;GACnB;YAEA,UACA,oBAAC,aAAQ,yBAAyB,EAAE,QAAQ,SAAS,GAAI,GAEzD,oBAAC;GACA,IAAG;GACH,WAAW;GACX,gBAAgB;GAChB,iBACC;GAGA;IACI;GAEF"}
package/dist/package.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  //#region package.json
3
- var version = "2.2.1-pr.131.6624bed";
3
+ var version = "2.2.1-pr.131.6c77550";
4
4
 
5
5
  //#endregion
6
6
  Object.defineProperty(exports, 'version', {
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "2.2.1-pr.131.6624bed";
2
+ var version = "2.2.1-pr.131.6c77550";
3
3
 
4
4
  //#endregion
5
5
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/next",
3
- "version": "2.2.1-pr.131.6624bed",
3
+ "version": "2.2.1-pr.131.6c77550",
4
4
  "description": "Helpers to integrate Prismic into Next.js apps",
5
5
  "keywords": [
6
6
  "typescript",
@@ -40,7 +40,7 @@ export const SliceSimulator: FC<SliceSimulatorProps> = ({
40
40
  zIndex,
41
41
  className,
42
42
  }) => {
43
- const [message, setMessage] = useState(getDefaultMessage());
43
+ const [message, setMessage] = useState(() => getDefaultMessage());
44
44
  const router = useRouter();
45
45
  const routerRef = useRef(router);
46
46
  routerRef.current = router;
@@ -27,46 +27,40 @@ export const SliceSimulatorWrapper: FC<SliceSimulatorWrapperProps> = ({
27
27
  }) => {
28
28
  const defaultProps = getDefaultProps();
29
29
 
30
- const outerProps = {
31
- className: [simulatorClass, className].filter(Boolean).join(" "),
32
- style: {
33
- zIndex:
34
- typeof zIndex === "undefined"
35
- ? defaultProps.zIndex
36
- : (zIndex ?? undefined),
37
- position: "fixed" as const,
38
- top: 0,
39
- left: 0,
40
- width: "100%",
41
- height: "100vh",
42
- overflow: "auto",
43
- background:
44
- typeof background === "undefined"
45
- ? defaultProps.background
46
- : (background ?? undefined),
47
- },
48
- };
49
-
50
- if (message) {
51
- return (
52
- <div {...outerProps}>
53
- <article dangerouslySetInnerHTML={{ __html: message }} />
54
- </div>
55
- );
56
- }
57
-
58
30
  return (
59
- <div {...outerProps}>
60
- <div
61
- id="root"
62
- className={simulatorRootClass}
63
- onClickCapture={onClickHandler as unknown as React.MouseEventHandler}
64
- onSubmitCapture={
65
- disableEventHandler as unknown as React.FormEventHandler
66
- }
67
- >
68
- {children}
69
- </div>
31
+ <div
32
+ className={[simulatorClass, className].filter(Boolean).join(" ")}
33
+ style={{
34
+ zIndex:
35
+ typeof zIndex === "undefined"
36
+ ? defaultProps.zIndex
37
+ : (zIndex ?? undefined),
38
+ position: "fixed",
39
+ top: 0,
40
+ left: 0,
41
+ width: "100%",
42
+ height: "100vh",
43
+ overflow: "auto",
44
+ background:
45
+ typeof background === "undefined"
46
+ ? defaultProps.background
47
+ : (background ?? undefined),
48
+ }}
49
+ >
50
+ {message ? (
51
+ <article dangerouslySetInnerHTML={{ __html: message }} />
52
+ ) : (
53
+ <div
54
+ id="root"
55
+ className={simulatorRootClass}
56
+ onClickCapture={onClickHandler as unknown as React.MouseEventHandler}
57
+ onSubmitCapture={
58
+ disableEventHandler as unknown as React.FormEventHandler
59
+ }
60
+ >
61
+ {children}
62
+ </div>
63
+ )}
70
64
  </div>
71
65
  );
72
66
  };