@contentstack/live-preview-utils 4.0.1 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/README.md +3 -3
  2. package/dist/legacy/light-sdk.cjs +1 -1
  3. package/dist/legacy/light-sdk.js +1 -1
  4. package/dist/legacy/livePreview/eventManager/postMessageEvent.hooks.cjs +24 -8
  5. package/dist/legacy/livePreview/eventManager/postMessageEvent.hooks.cjs.map +1 -1
  6. package/dist/legacy/livePreview/eventManager/postMessageEvent.hooks.js +24 -8
  7. package/dist/legacy/livePreview/eventManager/postMessageEvent.hooks.js.map +1 -1
  8. package/dist/legacy/preview/contentstack-live-preview-HOC.cjs +1 -1
  9. package/dist/legacy/preview/contentstack-live-preview-HOC.js +1 -1
  10. package/dist/legacy/visualBuilder/components/VariantIndicator.cjs +36 -0
  11. package/dist/legacy/visualBuilder/components/VariantIndicator.cjs.map +1 -0
  12. package/dist/legacy/visualBuilder/components/VariantIndicator.d.cts +3 -0
  13. package/dist/legacy/visualBuilder/components/VariantIndicator.d.ts +3 -0
  14. package/dist/legacy/visualBuilder/components/VariantIndicator.js +13 -0
  15. package/dist/legacy/visualBuilder/components/VariantIndicator.js.map +1 -0
  16. package/dist/legacy/visualBuilder/components/fieldLabelWrapper.cjs +124 -114
  17. package/dist/legacy/visualBuilder/components/fieldLabelWrapper.cjs.map +1 -1
  18. package/dist/legacy/visualBuilder/components/fieldLabelWrapper.js +124 -114
  19. package/dist/legacy/visualBuilder/components/fieldLabelWrapper.js.map +1 -1
  20. package/dist/legacy/visualBuilder/components/icons/variant.cjs +5 -1
  21. package/dist/legacy/visualBuilder/components/icons/variant.cjs.map +1 -1
  22. package/dist/legacy/visualBuilder/components/icons/variant.d.cts +3 -1
  23. package/dist/legacy/visualBuilder/components/icons/variant.d.ts +3 -1
  24. package/dist/legacy/visualBuilder/components/icons/variant.js +5 -1
  25. package/dist/legacy/visualBuilder/components/icons/variant.js.map +1 -1
  26. package/dist/legacy/visualBuilder/generators/generateHoverOutline.cjs +10 -1
  27. package/dist/legacy/visualBuilder/generators/generateHoverOutline.cjs.map +1 -1
  28. package/dist/legacy/visualBuilder/generators/generateHoverOutline.d.cts +1 -1
  29. package/dist/legacy/visualBuilder/generators/generateHoverOutline.d.ts +1 -1
  30. package/dist/legacy/visualBuilder/generators/generateHoverOutline.js +10 -1
  31. package/dist/legacy/visualBuilder/generators/generateHoverOutline.js.map +1 -1
  32. package/dist/legacy/visualBuilder/listeners/mouseHover.cjs +13 -10
  33. package/dist/legacy/visualBuilder/listeners/mouseHover.cjs.map +1 -1
  34. package/dist/legacy/visualBuilder/listeners/mouseHover.js +13 -10
  35. package/dist/legacy/visualBuilder/listeners/mouseHover.js.map +1 -1
  36. package/dist/legacy/visualBuilder/utils/enableInlineEditing.cjs +3 -1
  37. package/dist/legacy/visualBuilder/utils/enableInlineEditing.cjs.map +1 -1
  38. package/dist/legacy/visualBuilder/utils/enableInlineEditing.js +3 -1
  39. package/dist/legacy/visualBuilder/utils/enableInlineEditing.js.map +1 -1
  40. package/dist/legacy/visualBuilder/utils/handleFieldMouseDown.cjs +5 -0
  41. package/dist/legacy/visualBuilder/utils/handleFieldMouseDown.cjs.map +1 -1
  42. package/dist/legacy/visualBuilder/utils/handleFieldMouseDown.js +5 -0
  43. package/dist/legacy/visualBuilder/utils/handleFieldMouseDown.js.map +1 -1
  44. package/dist/legacy/visualBuilder/utils/isFieldDisabled.cjs +1 -1
  45. package/dist/legacy/visualBuilder/utils/isFieldDisabled.cjs.map +1 -1
  46. package/dist/legacy/visualBuilder/utils/isFieldDisabled.js +1 -1
  47. package/dist/legacy/visualBuilder/utils/isFieldDisabled.js.map +1 -1
  48. package/dist/legacy/visualBuilder/visualBuilder.style.cjs +26 -1
  49. package/dist/legacy/visualBuilder/visualBuilder.style.cjs.map +1 -1
  50. package/dist/legacy/visualBuilder/visualBuilder.style.d.cts +3 -0
  51. package/dist/legacy/visualBuilder/visualBuilder.style.d.ts +3 -0
  52. package/dist/legacy/visualBuilder/visualBuilder.style.js +26 -1
  53. package/dist/legacy/visualBuilder/visualBuilder.style.js.map +1 -1
  54. package/dist/modern/light-sdk.cjs +1 -1
  55. package/dist/modern/light-sdk.js +1 -1
  56. package/dist/modern/livePreview/eventManager/postMessageEvent.hooks.cjs +23 -7
  57. package/dist/modern/livePreview/eventManager/postMessageEvent.hooks.cjs.map +1 -1
  58. package/dist/modern/livePreview/eventManager/postMessageEvent.hooks.js +23 -7
  59. package/dist/modern/livePreview/eventManager/postMessageEvent.hooks.js.map +1 -1
  60. package/dist/modern/preview/contentstack-live-preview-HOC.cjs +1 -1
  61. package/dist/modern/preview/contentstack-live-preview-HOC.js +1 -1
  62. package/dist/modern/visualBuilder/components/VariantIndicator.cjs +36 -0
  63. package/dist/modern/visualBuilder/components/VariantIndicator.cjs.map +1 -0
  64. package/dist/modern/visualBuilder/components/VariantIndicator.d.cts +3 -0
  65. package/dist/modern/visualBuilder/components/VariantIndicator.d.ts +3 -0
  66. package/dist/modern/visualBuilder/components/VariantIndicator.js +13 -0
  67. package/dist/modern/visualBuilder/components/VariantIndicator.js.map +1 -0
  68. package/dist/modern/visualBuilder/components/fieldLabelWrapper.cjs +124 -114
  69. package/dist/modern/visualBuilder/components/fieldLabelWrapper.cjs.map +1 -1
  70. package/dist/modern/visualBuilder/components/fieldLabelWrapper.js +124 -114
  71. package/dist/modern/visualBuilder/components/fieldLabelWrapper.js.map +1 -1
  72. package/dist/modern/visualBuilder/components/icons/variant.cjs +5 -1
  73. package/dist/modern/visualBuilder/components/icons/variant.cjs.map +1 -1
  74. package/dist/modern/visualBuilder/components/icons/variant.d.cts +3 -1
  75. package/dist/modern/visualBuilder/components/icons/variant.d.ts +3 -1
  76. package/dist/modern/visualBuilder/components/icons/variant.js +5 -1
  77. package/dist/modern/visualBuilder/components/icons/variant.js.map +1 -1
  78. package/dist/modern/visualBuilder/generators/generateHoverOutline.cjs +10 -1
  79. package/dist/modern/visualBuilder/generators/generateHoverOutline.cjs.map +1 -1
  80. package/dist/modern/visualBuilder/generators/generateHoverOutline.d.cts +1 -1
  81. package/dist/modern/visualBuilder/generators/generateHoverOutline.d.ts +1 -1
  82. package/dist/modern/visualBuilder/generators/generateHoverOutline.js +10 -1
  83. package/dist/modern/visualBuilder/generators/generateHoverOutline.js.map +1 -1
  84. package/dist/modern/visualBuilder/listeners/mouseHover.cjs +13 -10
  85. package/dist/modern/visualBuilder/listeners/mouseHover.cjs.map +1 -1
  86. package/dist/modern/visualBuilder/listeners/mouseHover.js +13 -10
  87. package/dist/modern/visualBuilder/listeners/mouseHover.js.map +1 -1
  88. package/dist/modern/visualBuilder/utils/enableInlineEditing.cjs +3 -1
  89. package/dist/modern/visualBuilder/utils/enableInlineEditing.cjs.map +1 -1
  90. package/dist/modern/visualBuilder/utils/enableInlineEditing.js +3 -1
  91. package/dist/modern/visualBuilder/utils/enableInlineEditing.js.map +1 -1
  92. package/dist/modern/visualBuilder/utils/handleFieldMouseDown.cjs +5 -0
  93. package/dist/modern/visualBuilder/utils/handleFieldMouseDown.cjs.map +1 -1
  94. package/dist/modern/visualBuilder/utils/handleFieldMouseDown.js +5 -0
  95. package/dist/modern/visualBuilder/utils/handleFieldMouseDown.js.map +1 -1
  96. package/dist/modern/visualBuilder/utils/isFieldDisabled.cjs +1 -1
  97. package/dist/modern/visualBuilder/utils/isFieldDisabled.cjs.map +1 -1
  98. package/dist/modern/visualBuilder/utils/isFieldDisabled.js +1 -1
  99. package/dist/modern/visualBuilder/utils/isFieldDisabled.js.map +1 -1
  100. package/dist/modern/visualBuilder/visualBuilder.style.cjs +26 -1
  101. package/dist/modern/visualBuilder/visualBuilder.style.cjs.map +1 -1
  102. package/dist/modern/visualBuilder/visualBuilder.style.d.cts +3 -0
  103. package/dist/modern/visualBuilder/visualBuilder.style.d.ts +3 -0
  104. package/dist/modern/visualBuilder/visualBuilder.style.js +26 -1
  105. package/dist/modern/visualBuilder/visualBuilder.style.js.map +1 -1
  106. package/package.json +1 -3
@@ -73,7 +73,7 @@ function useOnEntryUpdatePostMessageEvent() {
73
73
  import_livePreviewEventManager2.LIVE_PREVIEW_POST_MESSAGE_EVENTS.ON_CHANGE,
74
74
  (event) => {
75
75
  try {
76
- const { ssr, onChange } = import_configManager.default.get();
76
+ const { ssr, onChange, stackDetails } = import_configManager.default.get();
77
77
  const event_type = event.data._metadata?.event_type;
78
78
  (0, import_configManager.setConfigFromParams)({
79
79
  live_preview: event.data.hash
@@ -88,13 +88,29 @@ function useOnEntryUpdatePostMessageEvent() {
88
88
  }
89
89
  ;
90
90
  if (ssr && !event_type) {
91
- if (window.location.href.includes("live_preview")) {
91
+ const url = new URL(window.location.href);
92
+ let live_preview = url.searchParams.get("live_preview");
93
+ let content_type_uid = url.searchParams.get("content_type_uid");
94
+ let entry_uid = url.searchParams.get("entry_uid");
95
+ if (live_preview && content_type_uid && entry_uid) {
92
96
  window.location.reload();
93
97
  } else {
94
- const url = new URL(window.location.href);
95
- url.searchParams.set("live_preview", event.data.hash);
96
- url.searchParams.set("content_type_uid", import_configManager.default.get().stackDetails.contentTypeUid || "");
97
- url.searchParams.set("entry_uid", import_configManager.default.get().stackDetails.entryUid || "");
98
+ live_preview = event.data.hash;
99
+ content_type_uid = event.data.content_type_uid || stackDetails.$contentTypeUid?.toString() || "";
100
+ entry_uid = event.data.entry_uid || stackDetails.$entryUid?.toString() || "";
101
+ url.searchParams.set("live_preview", live_preview);
102
+ if (content_type_uid) {
103
+ url.searchParams.set(
104
+ "content_type_uid",
105
+ content_type_uid
106
+ );
107
+ }
108
+ if (entry_uid) {
109
+ url.searchParams.set(
110
+ "entry_uid",
111
+ entry_uid
112
+ );
113
+ }
98
114
  window.location.href = url.toString();
99
115
  }
100
116
  }
@@ -121,7 +137,7 @@ function sendInitializeLivePreviewPostMessageEvent() {
121
137
  config: {
122
138
  shouldReload: import_configManager.default.get().ssr,
123
139
  href: window.location.href,
124
- sdkVersion: "4.0.1",
140
+ sdkVersion: "4.1.0",
125
141
  mode: import_configManager.default.get().mode
126
142
  }
127
143
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/livePreview/eventManager/postMessageEvent.hooks.ts"],"sourcesContent":["import { isOpeningInNewTab } from \"../../common/inIframe\";\nimport Config, { setConfigFromParams } from \"../../configManager/configManager\";\nimport { PublicLogger } from \"../../logger/logger\";\nimport { ILivePreviewWindowType } from \"../../types/types\";\nimport { addParamsToUrl, isOpeningInTimeline } from \"../../utils\";\nimport livePreviewPostMessage from \"./livePreviewEventManager\";\nimport { LIVE_PREVIEW_POST_MESSAGE_EVENTS } from \"./livePreviewEventManager.constant\";\nimport {\n HistoryLivePreviewPostMessageEventData,\n LivePreviewInitEventResponse,\n OnChangeLivePreviewPostMessageEventData,\n OnChangeLivePreviewPostMessageEventTypes,\n} from \"./types/livePreviewPostMessageEvent.type\";\n\n/**\n * Registers a post message event listener for history-related events.\n * The listener handles events for forward, backward, and reload actions on the browser history.\n */\nexport function useHistoryPostMessageEvent(): void {\n livePreviewPostMessage?.on<HistoryLivePreviewPostMessageEventData>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.HISTORY,\n (event) => {\n switch (event.data.type) {\n case \"forward\": {\n window.history.forward();\n break;\n }\n case \"backward\": {\n window.history.back();\n break;\n }\n case \"reload\": {\n window.history.go();\n break;\n }\n default: {\n const exhaustiveCheck: never = event.data.type;\n throw new Error(`Unhandled event: ${exhaustiveCheck}`);\n }\n }\n }\n );\n}\n\n/**\n * Registers a post message event listener for updating the entry in the live preview.\n */\nexport function useOnEntryUpdatePostMessageEvent(): void {\n livePreviewPostMessage?.on<OnChangeLivePreviewPostMessageEventData>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.ON_CHANGE,\n (event) => {\n try {\n const { ssr, onChange } = Config.get();\n const event_type = event.data._metadata?.event_type;\n setConfigFromParams({\n live_preview: event.data.hash,\n });\n\n // This section will run when there is a change in the entry and the website is CSR\n if (!ssr && !event_type) {\n onChange();\n } \n\n if(isOpeningInNewTab()) {\n if(!window) {\n PublicLogger.error(\"window is not defined\");\n return;\n };\n \n // This section will run when there is a change in the entry and the website is SSR\n if(ssr && !event_type) {\n if(window.location.href.includes(\"live_preview\")) {\n window.location.reload();\n } else {\n const url = new URL(window.location.href);\n url.searchParams.set(\"live_preview\", event.data.hash);\n url.searchParams.set(\"content_type_uid\", Config.get().stackDetails.contentTypeUid || \"\");\n url.searchParams.set(\"entry_uid\", Config.get().stackDetails.entryUid || \"\");\n window.location.href = url.toString();\n }\n }\n \n // This section will run when the hash changes and the website is SSR or CSR\n if(event_type === OnChangeLivePreviewPostMessageEventTypes.HASH_CHANGE){\n const newUrl = new URL(window.location.href);\n newUrl.searchParams.set(\"live_preview\", event.data.hash);\n window.history.pushState({}, \"\", newUrl.toString());\n }\n \n // This section will run when the URL of the page changes\n if(event_type === OnChangeLivePreviewPostMessageEventTypes.URL_CHANGE && event.data.url){\n window.location.href = event.data.url;\n }\n }\n\n \n } catch (error) {\n PublicLogger.error(\"Error handling live preview update:\", error);\n return;\n }\n }\n );\n}\n\nexport function sendInitializeLivePreviewPostMessageEvent(): void {\n livePreviewPostMessage\n ?.send<LivePreviewInitEventResponse>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.INIT,\n {\n config: {\n shouldReload: Config.get().ssr,\n href: window.location.href,\n sdkVersion: process?.env?.PACKAGE_VERSION,\n mode: Config.get().mode,\n },\n }\n )\n .then((data) => {\n const {\n contentTypeUid,\n entryUid,\n windowType = ILivePreviewWindowType.PREVIEW,\n } = data || {};\n\n // TODO: This is a fix for the issue where we were calling sending init in the builder\n // Let's remove this condition when we fix it.\n if (Config?.get()?.windowType && Config.get().windowType === ILivePreviewWindowType.BUILDER) {\n return;\n }\n\n if (contentTypeUid && entryUid) {\n // TODO: we should not use this function. Instead we should have sideEffect run automatically when we set the config.\n setConfigFromParams({\n content_type_uid: contentTypeUid,\n entry_uid: entryUid,\n });\n } else {\n // TODO: add debug logs that runs conditionally\n // PublicLogger.debug(\n // \"init message did not contain contentTypeUid or entryUid.\"\n // );\n }\n if (Config.get().ssr || isOpeningInTimeline() || isOpeningInNewTab()) {\n addParamsToUrl();\n }\n Config.set(\"windowType\", windowType);\n\n // set timeout for client side (use to show warning: You are not editing this page)\n if (!Config.get().ssr) {\n setInterval(() => {\n sendCurrentPageUrlPostMessageEvent();\n }, 1500);\n }\n\n useHistoryPostMessageEvent();\n useOnEntryUpdatePostMessageEvent();\n })\n .catch((e) => {\n // TODO: add debug logs that runs conditionally\n // PublicLogger.debug(\"Error while sending init message\", e);\n });\n}\n\nfunction sendCurrentPageUrlPostMessageEvent(): void {\n livePreviewPostMessage\n ?.send(LIVE_PREVIEW_POST_MESSAGE_EVENTS.CHECK_ENTRY_PAGE, {\n href: window.location.href,\n })\n .catch(() => {\n // TODO: add debug logs that runs conditionally\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAkC;AAClC,2BAA4C;AAC5C,oBAA6B;AAC7B,mBAAuC;AACvC,mBAAoD;AACpD,qCAAmC;AACnC,IAAAA,kCAAiD;AACjD,yCAKO;AAMA,SAAS,6BAAmC;AAC/C,iCAAAC,SAAwB;AAAA,IACpB,iEAAiC;AAAA,IACjC,CAAC,UAAU;AACP,cAAQ,MAAM,KAAK,MAAM;AAAA,QACrB,KAAK,WAAW;AACZ,iBAAO,QAAQ,QAAQ;AACvB;AAAA,QACJ;AAAA,QACA,KAAK,YAAY;AACb,iBAAO,QAAQ,KAAK;AACpB;AAAA,QACJ;AAAA,QACA,KAAK,UAAU;AACX,iBAAO,QAAQ,GAAG;AAClB;AAAA,QACJ;AAAA,QACA,SAAS;AACL,gBAAM,kBAAyB,MAAM,KAAK;AAC1C,gBAAM,IAAI,MAAM,oBAAoB,eAAe,EAAE;AAAA,QACzD;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AACJ;AAKO,SAAS,mCAA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AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AACJ;AAEO,SAAS,4CAAkD;AAC9D,iCAAAD,SACM;AAAA,IACE,iEAAiC;AAAA,IACjC;AAAA,MACI,QAAQ;AAAA,QACJ,cAAc,qBAAAC,QAAO,IAAI,EAAE;AAAA,QAC3B,MAAM,OAAO,SAAS;AAAA,QACtB,YAAY;AAAA,QACZ,MAAM,qBAAAA,QAAO,IAAI,EAAE;AAAA,MACvB;AAAA,IACJ;AAAA,EACJ,EACC,KAAK,CAAC,SAAS;AACZ,UAAM;AAAA,MACF;AAAA,MACA;AAAA,MACA,aAAa,oCAAuB;AAAA,IACxC,IAAI,QAAQ,CAAC;AAIb,QAAI,qBAAAA,SAAQ,IAAI,GAAG,cAAc,qBAAAA,QAAO,IAAI,EAAE,eAAe,oCAAuB,SAAS;AACzF;AAAA,IACJ;AAEA,QAAI,kBAAkB,UAAU;AAE5B,oDAAoB;AAAA,QAChB,kBAAkB;AAAA,QAClB,WAAW;AAAA,MACf,CAAC;AAAA,IACL,OAAO;AAAA,IAKP;AACA,QAAI,qBAAAA,QAAO,IAAI,EAAE,WAAO,kCAAoB,SAAK,mCAAkB,GAAG;AAClE,uCAAe;AAAA,IACnB;AACA,yBAAAA,QAAO,IAAI,cAAc,UAAU;AAGnC,QAAI,CAAC,qBAAAA,QAAO,IAAI,EAAE,KAAK;AACnB,kBAAY,MAAM;AACd,2CAAmC;AAAA,MACvC,GAAG,IAAI;AAAA,IACX;AAEA,+BAA2B;AAC3B,qCAAiC;AAAA,EACrC,CAAC,EACA,MAAM,CAAC,MAAM;AAAA,EAGd,CAAC;AACT;AAEA,SAAS,qCAA2C;AAChD,iCAAAD,SACM,KAAK,iEAAiC,kBAAkB;AAAA,IACtD,MAAM,OAAO,SAAS;AAAA,EAC1B,CAAC,EACA,MAAM,MAAM;AAAA,EAEb,CAAC;AACT;","names":["import_livePreviewEventManager","livePreviewPostMessage","Config"]}
1
+ {"version":3,"sources":["../../../../src/livePreview/eventManager/postMessageEvent.hooks.ts"],"sourcesContent":["import { isOpeningInNewTab } from \"../../common/inIframe\";\nimport Config, { setConfigFromParams } from \"../../configManager/configManager\";\nimport { PublicLogger } from \"../../logger/logger\";\nimport { ILivePreviewWindowType } from \"../../types/types\";\nimport { addParamsToUrl, isOpeningInTimeline } from \"../../utils\";\nimport livePreviewPostMessage from \"./livePreviewEventManager\";\nimport { LIVE_PREVIEW_POST_MESSAGE_EVENTS } from \"./livePreviewEventManager.constant\";\nimport {\n HistoryLivePreviewPostMessageEventData,\n LivePreviewInitEventResponse,\n OnChangeLivePreviewPostMessageEventData,\n OnChangeLivePreviewPostMessageEventTypes,\n} from \"./types/livePreviewPostMessageEvent.type\";\n\n/**\n * Registers a post message event listener for history-related events.\n * The listener handles events for forward, backward, and reload actions on the browser history.\n */\nexport function useHistoryPostMessageEvent(): void {\n livePreviewPostMessage?.on<HistoryLivePreviewPostMessageEventData>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.HISTORY,\n (event) => {\n switch (event.data.type) {\n case \"forward\": {\n window.history.forward();\n break;\n }\n case \"backward\": {\n window.history.back();\n break;\n }\n case \"reload\": {\n window.history.go();\n break;\n }\n default: {\n const exhaustiveCheck: never = event.data.type;\n throw new Error(`Unhandled event: ${exhaustiveCheck}`);\n }\n }\n }\n );\n}\n\n/**\n * Registers a post message event listener for updating the entry in the live preview.\n */\nexport function useOnEntryUpdatePostMessageEvent(): void {\n livePreviewPostMessage?.on<OnChangeLivePreviewPostMessageEventData>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.ON_CHANGE,\n (event) => {\n try {\n const { ssr, onChange, stackDetails } = Config.get();\n const event_type = event.data._metadata?.event_type;\n setConfigFromParams({\n live_preview: event.data.hash,\n });\n\n // This section will run when there is a change in the entry and the website is CSR\n if (!ssr && !event_type) {\n onChange();\n }\n\n if (isOpeningInNewTab()) {\n if (!window) {\n PublicLogger.error(\"window is not defined\");\n return;\n };\n\n if (ssr && !event_type) {\n const url = new URL(window.location.href);\n let live_preview = url.searchParams.get(\"live_preview\");\n let content_type_uid = url.searchParams.get(\"content_type_uid\");\n let entry_uid = url.searchParams.get(\"entry_uid\");\n\n if (live_preview && content_type_uid && entry_uid) {\n // All required params are present, just reload\n window.location.reload();\n } else {\n live_preview = event.data.hash;\n content_type_uid = event.data.content_type_uid || stackDetails.$contentTypeUid?.toString() || \"\";\n entry_uid = event.data.entry_uid || stackDetails.$entryUid?.toString() || \"\";\n // Set missing params and redirect\n url.searchParams.set(\"live_preview\", live_preview);\n if (content_type_uid) {\n url.searchParams.set(\n \"content_type_uid\",\n content_type_uid\n );\n }\n if (entry_uid) {\n url.searchParams.set(\n \"entry_uid\",\n entry_uid\n );\n }\n window.location.href = url.toString();\n }\n }\n\n // This section will run when the hash changes and the website is SSR or CSR\n if (event_type === OnChangeLivePreviewPostMessageEventTypes.HASH_CHANGE) {\n const newUrl = new URL(window.location.href);\n newUrl.searchParams.set(\"live_preview\", event.data.hash);\n window.history.pushState({}, \"\", newUrl.toString());\n }\n\n // This section will run when the URL of the page changes\n if (event_type === OnChangeLivePreviewPostMessageEventTypes.URL_CHANGE && event.data.url) {\n window.location.href = event.data.url;\n }\n }\n } catch (error) {\n PublicLogger.error(\"Error handling live preview update:\", error);\n return;\n }\n }\n );\n}\n\nexport function sendInitializeLivePreviewPostMessageEvent(): void {\n livePreviewPostMessage\n ?.send<LivePreviewInitEventResponse>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.INIT,\n {\n config: {\n shouldReload: Config.get().ssr,\n href: window.location.href,\n sdkVersion: process?.env?.PACKAGE_VERSION,\n mode: Config.get().mode,\n },\n }\n )\n .then((data) => {\n const {\n contentTypeUid,\n entryUid,\n windowType = ILivePreviewWindowType.PREVIEW,\n } = data || {};\n\n // TODO: This is a fix for the issue where we were calling sending init in the builder\n // Let's remove this condition when we fix it.\n if (Config?.get()?.windowType && Config.get().windowType === ILivePreviewWindowType.BUILDER) {\n return;\n }\n\n if (contentTypeUid && entryUid) {\n // TODO: we should not use this function. Instead we should have sideEffect run automatically when we set the config.\n setConfigFromParams({\n content_type_uid: contentTypeUid,\n entry_uid: entryUid,\n });\n } else {\n // TODO: add debug logs that runs conditionally\n // PublicLogger.debug(\n // \"init message did not contain contentTypeUid or entryUid.\"\n // );\n }\n if (Config.get().ssr || isOpeningInTimeline() || isOpeningInNewTab()) {\n addParamsToUrl();\n }\n Config.set(\"windowType\", windowType);\n\n // set timeout for client side (use to show warning: You are not editing this page)\n if (!Config.get().ssr) {\n setInterval(() => {\n sendCurrentPageUrlPostMessageEvent();\n }, 1500);\n }\n\n useHistoryPostMessageEvent();\n useOnEntryUpdatePostMessageEvent();\n })\n .catch((e) => {\n // TODO: add debug logs that runs conditionally\n // PublicLogger.debug(\"Error while sending init message\", e);\n });\n}\n\nfunction sendCurrentPageUrlPostMessageEvent(): void {\n livePreviewPostMessage\n ?.send(LIVE_PREVIEW_POST_MESSAGE_EVENTS.CHECK_ENTRY_PAGE, {\n href: window.location.href,\n })\n .catch(() => {\n // TODO: add debug logs that runs conditionally\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAkC;AAClC,2BAA4C;AAC5C,oBAA6B;AAC7B,mBAAuC;AACvC,mBAAoD;AACpD,qCAAmC;AACnC,IAAAA,kCAAiD;AACjD,yCAKO;AAMA,SAAS,6BAAmC;AAC/C,iCAAAC,SAAwB;AAAA,IACpB,iEAAiC;AAAA,IACjC,CAAC,UAAU;AACP,cAAQ,MAAM,KAAK,MAAM;AAAA,QACrB,KAAK,WAAW;AACZ,iBAAO,QAAQ,QAAQ;AACvB;AAAA,QACJ;AAAA,QACA,KAAK,YAAY;AACb,iBAAO,QAAQ,KAAK;AACpB;AAAA,QACJ;AAAA,QACA,KAAK,UAAU;AACX,iBAAO,QAAQ,GAAG;AAClB;AAAA,QACJ;AAAA,QACA,SAAS;AACL,gBAAM,kBAAyB,MA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AAI,EAAE,KAAK;AACnB,kBAAY,MAAM;AACd,2CAAmC;AAAA,MACvC,GAAG,IAAI;AAAA,IACX;AAEA,+BAA2B;AAC3B,qCAAiC;AAAA,EACrC,CAAC,EACA,MAAM,CAAC,MAAM;AAAA,EAGd,CAAC;AACT;AAEA,SAAS,qCAA2C;AAChD,iCAAAD,SACM,KAAK,iEAAiC,kBAAkB;AAAA,IACtD,MAAM,OAAO,SAAS;AAAA,EAC1B,CAAC,EACA,MAAM,MAAM;AAAA,EAEb,CAAC;AACT;","names":["import_livePreviewEventManager","livePreviewPostMessage","Config"]}
@@ -41,7 +41,7 @@ function useOnEntryUpdatePostMessageEvent() {
41
41
  LIVE_PREVIEW_POST_MESSAGE_EVENTS.ON_CHANGE,
42
42
  (event) => {
43
43
  try {
44
- const { ssr, onChange } = Config.get();
44
+ const { ssr, onChange, stackDetails } = Config.get();
45
45
  const event_type = event.data._metadata?.event_type;
46
46
  setConfigFromParams({
47
47
  live_preview: event.data.hash
@@ -56,13 +56,29 @@ function useOnEntryUpdatePostMessageEvent() {
56
56
  }
57
57
  ;
58
58
  if (ssr && !event_type) {
59
- if (window.location.href.includes("live_preview")) {
59
+ const url = new URL(window.location.href);
60
+ let live_preview = url.searchParams.get("live_preview");
61
+ let content_type_uid = url.searchParams.get("content_type_uid");
62
+ let entry_uid = url.searchParams.get("entry_uid");
63
+ if (live_preview && content_type_uid && entry_uid) {
60
64
  window.location.reload();
61
65
  } else {
62
- const url = new URL(window.location.href);
63
- url.searchParams.set("live_preview", event.data.hash);
64
- url.searchParams.set("content_type_uid", Config.get().stackDetails.contentTypeUid || "");
65
- url.searchParams.set("entry_uid", Config.get().stackDetails.entryUid || "");
66
+ live_preview = event.data.hash;
67
+ content_type_uid = event.data.content_type_uid || stackDetails.$contentTypeUid?.toString() || "";
68
+ entry_uid = event.data.entry_uid || stackDetails.$entryUid?.toString() || "";
69
+ url.searchParams.set("live_preview", live_preview);
70
+ if (content_type_uid) {
71
+ url.searchParams.set(
72
+ "content_type_uid",
73
+ content_type_uid
74
+ );
75
+ }
76
+ if (entry_uid) {
77
+ url.searchParams.set(
78
+ "entry_uid",
79
+ entry_uid
80
+ );
81
+ }
66
82
  window.location.href = url.toString();
67
83
  }
68
84
  }
@@ -89,7 +105,7 @@ function sendInitializeLivePreviewPostMessageEvent() {
89
105
  config: {
90
106
  shouldReload: Config.get().ssr,
91
107
  href: window.location.href,
92
- sdkVersion: "4.0.1",
108
+ sdkVersion: "4.1.0",
93
109
  mode: Config.get().mode
94
110
  }
95
111
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/livePreview/eventManager/postMessageEvent.hooks.ts"],"sourcesContent":["import { isOpeningInNewTab } from \"../../common/inIframe\";\nimport Config, { setConfigFromParams } from \"../../configManager/configManager\";\nimport { PublicLogger } from \"../../logger/logger\";\nimport { ILivePreviewWindowType } from \"../../types/types\";\nimport { addParamsToUrl, isOpeningInTimeline } from \"../../utils\";\nimport livePreviewPostMessage from \"./livePreviewEventManager\";\nimport { LIVE_PREVIEW_POST_MESSAGE_EVENTS } from \"./livePreviewEventManager.constant\";\nimport {\n HistoryLivePreviewPostMessageEventData,\n LivePreviewInitEventResponse,\n OnChangeLivePreviewPostMessageEventData,\n OnChangeLivePreviewPostMessageEventTypes,\n} from \"./types/livePreviewPostMessageEvent.type\";\n\n/**\n * Registers a post message event listener for history-related events.\n * The listener handles events for forward, backward, and reload actions on the browser history.\n */\nexport function useHistoryPostMessageEvent(): void {\n livePreviewPostMessage?.on<HistoryLivePreviewPostMessageEventData>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.HISTORY,\n (event) => {\n switch (event.data.type) {\n case \"forward\": {\n window.history.forward();\n break;\n }\n case \"backward\": {\n window.history.back();\n break;\n }\n case \"reload\": {\n window.history.go();\n break;\n }\n default: {\n const exhaustiveCheck: never = event.data.type;\n throw new Error(`Unhandled event: ${exhaustiveCheck}`);\n }\n }\n }\n );\n}\n\n/**\n * Registers a post message event listener for updating the entry in the live preview.\n */\nexport function useOnEntryUpdatePostMessageEvent(): void {\n livePreviewPostMessage?.on<OnChangeLivePreviewPostMessageEventData>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.ON_CHANGE,\n (event) => {\n try {\n const { ssr, onChange } = Config.get();\n const event_type = event.data._metadata?.event_type;\n setConfigFromParams({\n live_preview: event.data.hash,\n });\n\n // This section will run when there is a change in the entry and the website is CSR\n if (!ssr && !event_type) {\n onChange();\n } \n\n if(isOpeningInNewTab()) {\n if(!window) {\n PublicLogger.error(\"window is not defined\");\n return;\n };\n \n // This section will run when there is a change in the entry and the website is SSR\n if(ssr && !event_type) {\n if(window.location.href.includes(\"live_preview\")) {\n window.location.reload();\n } else {\n const url = new URL(window.location.href);\n url.searchParams.set(\"live_preview\", event.data.hash);\n url.searchParams.set(\"content_type_uid\", Config.get().stackDetails.contentTypeUid || \"\");\n url.searchParams.set(\"entry_uid\", Config.get().stackDetails.entryUid || \"\");\n window.location.href = url.toString();\n }\n }\n \n // This section will run when the hash changes and the website is SSR or CSR\n if(event_type === OnChangeLivePreviewPostMessageEventTypes.HASH_CHANGE){\n const newUrl = new URL(window.location.href);\n newUrl.searchParams.set(\"live_preview\", event.data.hash);\n window.history.pushState({}, \"\", newUrl.toString());\n }\n \n // This section will run when the URL of the page changes\n if(event_type === OnChangeLivePreviewPostMessageEventTypes.URL_CHANGE && event.data.url){\n window.location.href = event.data.url;\n }\n }\n\n \n } catch (error) {\n PublicLogger.error(\"Error handling live preview update:\", error);\n return;\n }\n }\n );\n}\n\nexport function sendInitializeLivePreviewPostMessageEvent(): void {\n livePreviewPostMessage\n ?.send<LivePreviewInitEventResponse>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.INIT,\n {\n config: {\n shouldReload: Config.get().ssr,\n href: window.location.href,\n sdkVersion: process?.env?.PACKAGE_VERSION,\n mode: Config.get().mode,\n },\n }\n )\n .then((data) => {\n const {\n contentTypeUid,\n entryUid,\n windowType = ILivePreviewWindowType.PREVIEW,\n } = data || {};\n\n // TODO: This is a fix for the issue where we were calling sending init in the builder\n // Let's remove this condition when we fix it.\n if (Config?.get()?.windowType && Config.get().windowType === ILivePreviewWindowType.BUILDER) {\n return;\n }\n\n if (contentTypeUid && entryUid) {\n // TODO: we should not use this function. Instead we should have sideEffect run automatically when we set the config.\n setConfigFromParams({\n content_type_uid: contentTypeUid,\n entry_uid: entryUid,\n });\n } else {\n // TODO: add debug logs that runs conditionally\n // PublicLogger.debug(\n // \"init message did not contain contentTypeUid or entryUid.\"\n // );\n }\n if (Config.get().ssr || isOpeningInTimeline() || isOpeningInNewTab()) {\n addParamsToUrl();\n }\n Config.set(\"windowType\", windowType);\n\n // set timeout for client side (use to show warning: You are not editing this page)\n if (!Config.get().ssr) {\n setInterval(() => {\n sendCurrentPageUrlPostMessageEvent();\n }, 1500);\n }\n\n useHistoryPostMessageEvent();\n useOnEntryUpdatePostMessageEvent();\n })\n .catch((e) => {\n // TODO: add debug logs that runs conditionally\n // PublicLogger.debug(\"Error while sending init message\", e);\n });\n}\n\nfunction sendCurrentPageUrlPostMessageEvent(): void {\n livePreviewPostMessage\n ?.send(LIVE_PREVIEW_POST_MESSAGE_EVENTS.CHECK_ENTRY_PAGE, {\n href: window.location.href,\n })\n .catch(() => {\n // TODO: add debug logs that runs conditionally\n });\n}\n"],"mappings":";;;AAAA,SAAS,yBAAyB;AAClC,OAAO,UAAU,2BAA2B;AAC5C,SAAS,oBAAoB;AAC7B,SAAS,8BAA8B;AACvC,SAAS,gBAAgB,2BAA2B;AACpD,OAAO,4BAA4B;AACnC,SAAS,wCAAwC;AACjD;AAAA,EAII;AAAA,OACG;AAMA,SAAS,6BAAmC;AAC/C,0BAAwB;AAAA,IACpB,iCAAiC;AAAA,IACjC,CAAC,UAAU;AACP,cAAQ,MAAM,KAAK,MAAM;AAAA,QACrB,KAAK,WAAW;AACZ,iBAAO,QAAQ,QAAQ;AACvB;AAAA,QACJ;AAAA,QACA,KAAK,YAAY;AACb,iBAAO,Q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tD,MAAM,OAAO,SAAS;AAAA,EAC1B,CAAC,EACA,MAAM,MAAM;AAAA,EAEb,CAAC;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../../src/livePreview/eventManager/postMessageEvent.hooks.ts"],"sourcesContent":["import { isOpeningInNewTab } from \"../../common/inIframe\";\nimport Config, { setConfigFromParams } from \"../../configManager/configManager\";\nimport { PublicLogger } from \"../../logger/logger\";\nimport { ILivePreviewWindowType } from \"../../types/types\";\nimport { addParamsToUrl, isOpeningInTimeline } from \"../../utils\";\nimport livePreviewPostMessage from \"./livePreviewEventManager\";\nimport { LIVE_PREVIEW_POST_MESSAGE_EVENTS } from \"./livePreviewEventManager.constant\";\nimport {\n HistoryLivePreviewPostMessageEventData,\n LivePreviewInitEventResponse,\n OnChangeLivePreviewPostMessageEventData,\n OnChangeLivePreviewPostMessageEventTypes,\n} from \"./types/livePreviewPostMessageEvent.type\";\n\n/**\n * Registers a post message event listener for history-related events.\n * The listener handles events for forward, backward, and reload actions on the browser history.\n */\nexport function useHistoryPostMessageEvent(): void {\n livePreviewPostMessage?.on<HistoryLivePreviewPostMessageEventData>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.HISTORY,\n (event) => {\n switch (event.data.type) {\n case \"forward\": {\n window.history.forward();\n break;\n }\n case \"backward\": {\n window.history.back();\n break;\n }\n case \"reload\": {\n window.history.go();\n break;\n }\n default: {\n const exhaustiveCheck: never = event.data.type;\n throw new Error(`Unhandled event: ${exhaustiveCheck}`);\n }\n }\n }\n );\n}\n\n/**\n * Registers a post message event listener for updating the entry in the live preview.\n */\nexport function useOnEntryUpdatePostMessageEvent(): void {\n livePreviewPostMessage?.on<OnChangeLivePreviewPostMessageEventData>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.ON_CHANGE,\n (event) => {\n try {\n const { ssr, onChange, stackDetails } = Config.get();\n const event_type = event.data._metadata?.event_type;\n setConfigFromParams({\n live_preview: event.data.hash,\n });\n\n // This section will run when there is a change in the entry and the website is CSR\n if (!ssr && !event_type) {\n onChange();\n }\n\n if (isOpeningInNewTab()) {\n if (!window) {\n PublicLogger.error(\"window is not defined\");\n return;\n };\n\n if (ssr && !event_type) {\n const url = new URL(window.location.href);\n let live_preview = url.searchParams.get(\"live_preview\");\n let content_type_uid = url.searchParams.get(\"content_type_uid\");\n let entry_uid = url.searchParams.get(\"entry_uid\");\n\n if (live_preview && content_type_uid && entry_uid) {\n // All required params are present, just reload\n window.location.reload();\n } else {\n live_preview = event.data.hash;\n content_type_uid = event.data.content_type_uid || stackDetails.$contentTypeUid?.toString() || \"\";\n entry_uid = event.data.entry_uid || stackDetails.$entryUid?.toString() || \"\";\n // Set missing params and redirect\n url.searchParams.set(\"live_preview\", live_preview);\n if (content_type_uid) {\n url.searchParams.set(\n \"content_type_uid\",\n content_type_uid\n );\n }\n if (entry_uid) {\n url.searchParams.set(\n \"entry_uid\",\n entry_uid\n );\n }\n window.location.href = url.toString();\n }\n }\n\n // This section will run when the hash changes and the website is SSR or CSR\n if (event_type === OnChangeLivePreviewPostMessageEventTypes.HASH_CHANGE) {\n const newUrl = new URL(window.location.href);\n newUrl.searchParams.set(\"live_preview\", event.data.hash);\n window.history.pushState({}, \"\", newUrl.toString());\n }\n\n // This section will run when the URL of the page changes\n if (event_type === OnChangeLivePreviewPostMessageEventTypes.URL_CHANGE && event.data.url) {\n window.location.href = event.data.url;\n }\n }\n } catch (error) {\n PublicLogger.error(\"Error handling live preview update:\", error);\n return;\n }\n }\n );\n}\n\nexport function sendInitializeLivePreviewPostMessageEvent(): void {\n livePreviewPostMessage\n ?.send<LivePreviewInitEventResponse>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.INIT,\n {\n config: {\n shouldReload: Config.get().ssr,\n href: window.location.href,\n sdkVersion: process?.env?.PACKAGE_VERSION,\n mode: Config.get().mode,\n },\n }\n )\n .then((data) => {\n const {\n contentTypeUid,\n entryUid,\n windowType = ILivePreviewWindowType.PREVIEW,\n } = data || {};\n\n // TODO: This is a fix for the issue where we were calling sending init in the builder\n // Let's remove this condition when we fix it.\n if (Config?.get()?.windowType && Config.get().windowType === ILivePreviewWindowType.BUILDER) {\n return;\n }\n\n if (contentTypeUid && entryUid) {\n // TODO: we should not use this function. Instead we should have sideEffect run automatically when we set the config.\n setConfigFromParams({\n content_type_uid: contentTypeUid,\n entry_uid: entryUid,\n });\n } else {\n // TODO: add debug logs that runs conditionally\n // PublicLogger.debug(\n // \"init message did not contain contentTypeUid or entryUid.\"\n // );\n }\n if (Config.get().ssr || isOpeningInTimeline() || isOpeningInNewTab()) {\n addParamsToUrl();\n }\n Config.set(\"windowType\", windowType);\n\n // set timeout for client side (use to show warning: You are not editing this page)\n if (!Config.get().ssr) {\n setInterval(() => {\n sendCurrentPageUrlPostMessageEvent();\n }, 1500);\n }\n\n useHistoryPostMessageEvent();\n useOnEntryUpdatePostMessageEvent();\n })\n .catch((e) => {\n // TODO: add debug logs that runs conditionally\n // PublicLogger.debug(\"Error while sending init message\", e);\n });\n}\n\nfunction sendCurrentPageUrlPostMessageEvent(): void {\n livePreviewPostMessage\n ?.send(LIVE_PREVIEW_POST_MESSAGE_EVENTS.CHECK_ENTRY_PAGE, {\n href: window.location.href,\n })\n .catch(() => {\n // TODO: add debug logs that runs conditionally\n });\n}\n"],"mappings":";;;AAAA,SAAS,yBAAyB;AAClC,OAAO,UAAU,2BAA2B;AAC5C,SAAS,oBAAoB;AAC7B,SAAS,8BAA8B;AACvC,SAAS,gBAAgB,2BAA2B;AACpD,OAAO,4BAA4B;AACnC,SAAS,wCAAwC;AACjD;AAAA,EAII;AAAA,OACG;AAMA,SAAS,6BAAmC;AAC/C,0BAAwB;AAAA,IACpB,iCAAiC;AAAA,IACjC,CAAC,UAAU;AACP,cAAQ,MAAM,KAAK,MAAM;AAAA,QACrB,KAAK,WAAW;AACZ,iBAAO,QAAQ,QAAQ;AACvB;AAAA,QACJ;AAAA,QACA,KAAK,YAAY;AACb,iBAAO,QAAQ,KAAK;AACpB;AAAA,QACJ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GnC,QAAI,CAAC,OAAO,IAAI,EAAE,KAAK;AACnB,kBAAY,MAAM;AACd,2CAAmC;AAAA,MACvC,GAAG,IAAI;AAAA,IACX;AAEA,+BAA2B;AAC3B,qCAAiC;AAAA,EACrC,CAAC,EACA,MAAM,CAAC,MAAM;AAAA,EAGd,CAAC;AACT;AAEA,SAAS,qCAA2C;AAChD,0BACM,KAAK,iCAAiC,kBAAkB;AAAA,IACtD,MAAM,OAAO,SAAS;AAAA,EAC1B,CAAC,EACA,MAAM,MAAM;AAAA,EAEb,CAAC;AACT;","names":[]}
@@ -227,7 +227,7 @@ var _ContentstackLivePreview = class _ContentstackLivePreview {
227
227
  * @returns The version of the SDK as a string.
228
228
  */
229
229
  static getSdkVersion() {
230
- return "4.0.1";
230
+ return "4.1.0";
231
231
  }
232
232
  };
233
233
  _ContentstackLivePreview.previewConstructors = {};
@@ -195,7 +195,7 @@ var _ContentstackLivePreview = class _ContentstackLivePreview {
195
195
  * @returns The version of the SDK as a string.
196
196
  */
197
197
  static getSdkVersion() {
198
- return "4.0.1";
198
+ return "4.1.0";
199
199
  }
200
200
  };
201
201
  _ContentstackLivePreview.previewConstructors = {};
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/visualBuilder/components/VariantIndicator.tsx
21
+ var VariantIndicator_exports = {};
22
+ __export(VariantIndicator_exports, {
23
+ VariantIndicator: () => VariantIndicator
24
+ });
25
+ module.exports = __toCommonJS(VariantIndicator_exports);
26
+ var import_variant = require("./icons/variant.cjs");
27
+ var import_visualBuilder = require("../visualBuilder.style.cjs");
28
+ var import_jsx_runtime = require("preact/jsx-runtime");
29
+ function VariantIndicator() {
30
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__variant-indicator"], children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_variant.VariantIcon, { size: "18px" }) });
31
+ }
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ VariantIndicator
35
+ });
36
+ //# sourceMappingURL=VariantIndicator.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/visualBuilder/components/VariantIndicator.tsx"],"sourcesContent":["import React from \"preact/compat\";\nimport { VariantIcon } from \"./icons/variant\";\nimport { visualBuilderStyles } from \"../visualBuilder.style\";\n\nexport function VariantIndicator(): JSX.Element {\n return (\n <div className={visualBuilderStyles()[\"visual-builder__variant-indicator\"]}>\n <VariantIcon size=\"18px\" />\n </div>\n );\n\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,qBAA4B;AAC5B,2BAAoC;AAKxB;AAHL,SAAS,mBAAgC;AAC5C,SACI,4CAAC,SAAI,eAAW,0CAAoB,EAAE,mCAAmC,GACrE,sDAAC,8BAAY,MAAK,QAAO,GAC7B;AAGR;","names":[]}
@@ -0,0 +1,3 @@
1
+ declare function VariantIndicator(): JSX.Element;
2
+
3
+ export { VariantIndicator };
@@ -0,0 +1,3 @@
1
+ declare function VariantIndicator(): JSX.Element;
2
+
3
+ export { VariantIndicator };
@@ -0,0 +1,13 @@
1
+ import "../../chunk-5WRI5ZAA.js";
2
+
3
+ // src/visualBuilder/components/VariantIndicator.tsx
4
+ import { VariantIcon } from "./icons/variant.js";
5
+ import { visualBuilderStyles } from "../visualBuilder.style.js";
6
+ import { jsx } from "preact/jsx-runtime";
7
+ function VariantIndicator() {
8
+ return /* @__PURE__ */ jsx("div", { className: visualBuilderStyles()["visual-builder__variant-indicator"], children: /* @__PURE__ */ jsx(VariantIcon, { size: "18px" }) });
9
+ }
10
+ export {
11
+ VariantIndicator
12
+ };
13
+ //# sourceMappingURL=VariantIndicator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/visualBuilder/components/VariantIndicator.tsx"],"sourcesContent":["import React from \"preact/compat\";\nimport { VariantIcon } from \"./icons/variant\";\nimport { visualBuilderStyles } from \"../visualBuilder.style\";\n\nexport function VariantIndicator(): JSX.Element {\n return (\n <div className={visualBuilderStyles()[\"visual-builder__variant-indicator\"]}>\n <VariantIcon size=\"18px\" />\n </div>\n );\n\n}"],"mappings":";;;AACA,SAAS,mBAAmB;AAC5B,SAAS,2BAA2B;AAKxB;AAHL,SAAS,mBAAgC;AAC5C,SACI,oBAAC,SAAI,WAAW,oBAAoB,EAAE,mCAAmC,GACrE,8BAAC,eAAY,MAAK,QAAO,GAC7B;AAGR;","names":[]}
@@ -50,6 +50,7 @@ var import_postMessage = require("../utils/types/postMessage.types.cjs");
50
50
  var import_icons2 = require("./icons/index.cjs");
51
51
  var import_Tooltip = require("./Tooltip.cjs");
52
52
  var import_fetchEntryPermissionsAndStageDetails = require("../utils/fetchEntryPermissionsAndStageDetails.cjs");
53
+ var import_VariantIndicator = require("./VariantIndicator.cjs");
53
54
  var import_jsx_runtime = require("preact/jsx-runtime");
54
55
  async function getFieldDisplayNames(fieldMetadata) {
55
56
  const result = await import_visualBuilderPostMessage.default?.send(import_postMessage.VisualBuilderPostMessageEvents.GET_FIELD_DISPLAY_NAMES, fieldMetadata);
@@ -208,135 +209,144 @@ function FieldLabelWrapperComponent(props) {
208
209
  return currentField.icon;
209
210
  }
210
211
  }
211
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
212
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
212
213
  "div",
213
214
  {
214
215
  className: (0, import_classnames.default)(
215
216
  "visual-builder__focused-toolbar__field-label-container",
216
217
  (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__focused-toolbar__field-label-container"]
217
218
  ),
218
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Tooltip.ToolbarTooltip, { data: { contentTypeName: currentField.parentContentTypeName, referenceFieldName: currentField.referenceFieldName }, disabled: !currentField.isReference || isDropdownOpen, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
219
- "div",
220
- {
221
- className: (0, import_classnames.default)(
222
- "visual-builder__focused-toolbar__field-label-wrapper",
223
- (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__focused-toolbar__field-label-wrapper"],
224
- {
225
- "visual-builder__focused-toolbar--field-disabled": currentField.disabled
226
- },
227
- {
228
- [(0, import_visualBuilder.visualBuilderStyles)()["visual-builder__focused-toolbar--field-disabled"]]: currentField.disabled
229
- },
230
- {
231
- "field-label-dropdown-open": isDropdownOpen,
232
- [(0, import_visualBuilder.visualBuilderStyles)()["field-label-dropdown-open"]]: isDropdownOpen
233
- }
234
- ),
235
- onClick: () => setIsDropdownOpen((prev) => !prev),
236
- "data-testid": "visual-builder__focused-toolbar__field-label-wrapper",
237
- "data-hovered-cslp": props.fieldMetadata.cslpValue,
238
- children: [
239
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
240
- "button",
219
+ children: [
220
+ currentField.isVariant ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_VariantIndicator.VariantIndicator, {}) : null,
221
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Tooltip.ToolbarTooltip, { data: { contentTypeName: currentField.parentContentTypeName, referenceFieldName: currentField.referenceFieldName }, disabled: !currentField.isReference || isDropdownOpen, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
222
+ "div",
223
+ {
224
+ className: (0, import_classnames.default)(
225
+ "visual-builder__focused-toolbar__field-label-wrapper",
226
+ (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__focused-toolbar__field-label-wrapper"],
227
+ {
228
+ "visual-builder__focused-toolbar--field-disabled": currentField.disabled
229
+ },
230
+ {
231
+ [(0, import_visualBuilder.visualBuilderStyles)()["visual-builder__focused-toolbar--field-disabled"]]: currentField.disabled
232
+ },
241
233
  {
242
- className: (0, import_classnames.default)(
243
- "visual-builder__focused-toolbar__field-label-wrapper__current-field visual-builder__button visual-builder__button--primary visual-builder__button-loader",
244
- (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__focused-toolbar__field-label-wrapper__current-field"],
245
- (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__button"],
246
- (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__button--primary"],
247
- (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__button-loader"],
248
- error && (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__button-error"]
249
- ),
250
- disabled: dataLoading,
251
- children: [
252
- currentField.isReference && !dataLoading && !error ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
253
- "div",
254
- {
255
- className: (0, import_classnames.default)(
256
- "visual-builder__reference-icon-container",
257
- (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__reference-icon-container"]
258
- ),
259
- children: [
260
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
261
- "div",
262
- {
263
- className: (0, import_classnames.default)(
264
- "visual-builder__field-icon",
265
- (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__field-icon"]
266
- ),
267
- dangerouslySetInnerHTML: {
268
- __html: import_generateCustomCursor.FieldTypeIconsMap.reference
269
- },
270
- "data-testid": "visual-builder__field-icon-caret"
271
- }
234
+ "field-label-dropdown-open": isDropdownOpen,
235
+ [(0, import_visualBuilder.visualBuilderStyles)()["field-label-dropdown-open"]]: isDropdownOpen
236
+ },
237
+ {
238
+ "visual-builder__focused-toolbar--variant": currentField.isVariant
239
+ },
240
+ {
241
+ [(0, import_visualBuilder.visualBuilderStyles)()["visual-builder__focused-toolbar--variant"]]: currentField.isVariant
242
+ }
243
+ ),
244
+ onClick: () => setIsDropdownOpen((prev) => !prev),
245
+ "data-testid": "visual-builder__focused-toolbar__field-label-wrapper",
246
+ "data-hovered-cslp": props.fieldMetadata.cslpValue,
247
+ children: [
248
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
249
+ "button",
250
+ {
251
+ className: (0, import_classnames.default)(
252
+ "visual-builder__focused-toolbar__field-label-wrapper__current-field visual-builder__button visual-builder__button--primary visual-builder__button-loader",
253
+ (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__focused-toolbar__field-label-wrapper__current-field"],
254
+ (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__button"],
255
+ (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__button--primary"],
256
+ (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__button-loader"],
257
+ error && (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__button-error"]
258
+ ),
259
+ disabled: dataLoading,
260
+ children: [
261
+ currentField.isReference && !dataLoading && !error ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
262
+ "div",
263
+ {
264
+ className: (0, import_classnames.default)(
265
+ "visual-builder__reference-icon-container",
266
+ (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__reference-icon-container"]
267
+ ),
268
+ children: [
269
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
270
+ "div",
271
+ {
272
+ className: (0, import_classnames.default)(
273
+ "visual-builder__field-icon",
274
+ (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__field-icon"]
275
+ ),
276
+ dangerouslySetInnerHTML: {
277
+ __html: import_generateCustomCursor.FieldTypeIconsMap.reference
278
+ },
279
+ "data-testid": "visual-builder__field-icon-caret"
280
+ }
281
+ ),
282
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CaretRightIcon, {})
283
+ ]
284
+ }
285
+ ) : null,
286
+ currentField.contentTypeName && !dataLoading && !error ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
287
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons2.ContentTypeIcon, {}),
288
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
289
+ "div",
290
+ {
291
+ className: (0, import_classnames.default)(
292
+ "visual-builder__focused-toolbar__text",
293
+ (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__focused-toolbar__text"]
294
+ ),
295
+ "data-testid": "visual-builder__focused-toolbar__ct-name",
296
+ children: currentField.contentTypeName + " : "
297
+ }
298
+ )
299
+ ] }) : null,
300
+ currentField.prefixIcon ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
301
+ "div",
302
+ {
303
+ className: (0, import_classnames.default)(
304
+ "visual-builder__field-icon",
305
+ (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__field-icon"]
272
306
  ),
273
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CaretRightIcon, {})
274
- ]
275
- }
276
- ) : null,
277
- currentField.contentTypeName && !dataLoading && !error ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
278
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons2.ContentTypeIcon, {}),
279
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
307
+ dangerouslySetInnerHTML: {
308
+ __html: currentField.prefixIcon
309
+ },
310
+ "data-testid": "visual-builder__field-icon"
311
+ }
312
+ ) : null,
313
+ currentField.text ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
280
314
  "div",
281
315
  {
282
316
  className: (0, import_classnames.default)(
283
317
  "visual-builder__focused-toolbar__text",
284
318
  (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__focused-toolbar__text"]
285
319
  ),
286
- "data-testid": "visual-builder__focused-toolbar__ct-name",
287
- children: currentField.contentTypeName + " : "
320
+ "data-testid": "visual-builder__focused-toolbar__text",
321
+ children: currentField.text
288
322
  }
289
- )
290
- ] }) : null,
291
- currentField.prefixIcon ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
292
- "div",
293
- {
294
- className: (0, import_classnames.default)(
295
- "visual-builder__field-icon",
296
- (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__field-icon"]
297
- ),
298
- dangerouslySetInnerHTML: {
299
- __html: currentField.prefixIcon
300
- },
301
- "data-testid": "visual-builder__field-icon"
302
- }
303
- ) : null,
304
- currentField.text ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
305
- "div",
306
- {
307
- className: (0, import_classnames.default)(
308
- "visual-builder__focused-toolbar__text",
309
- (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__focused-toolbar__text"]
310
- ),
311
- "data-testid": "visual-builder__focused-toolbar__text",
312
- children: currentField.text
313
- }
314
- ) : null,
315
- getCurrentFieldIcon(),
316
- error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_CslpError.CslpError, {}) : null
317
- ]
318
- }
319
- ),
320
- props.parentPaths.map((path, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
321
- "button",
322
- {
323
- className: (0, import_classnames.default)(
324
- "visual-builder__focused-toolbar__field-label-wrapper__parent-field visual-builder__button visual-builder__button--secondary visual-builder__focused-toolbar__text",
325
- (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__focused-toolbar__field-label-wrapper__parent-field"],
326
- (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__button"],
327
- (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__button--secondary"],
328
- (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__focused-toolbar__text"]
329
- ),
330
- "data-target-cslp": path,
331
- style: { top: calculateTopOffset(index) },
332
- onClick: () => onParentPathClick(path),
333
- children: displayNames[path]
334
- },
335
- path
336
- ))
337
- ]
338
- }
339
- ) })
323
+ ) : null,
324
+ getCurrentFieldIcon(),
325
+ error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_CslpError.CslpError, {}) : null
326
+ ]
327
+ }
328
+ ),
329
+ props.parentPaths.map((path, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
330
+ "button",
331
+ {
332
+ className: (0, import_classnames.default)(
333
+ "visual-builder__focused-toolbar__field-label-wrapper__parent-field visual-builder__button visual-builder__button--secondary visual-builder__focused-toolbar__text",
334
+ (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__focused-toolbar__field-label-wrapper__parent-field"],
335
+ (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__button"],
336
+ (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__button--secondary"],
337
+ (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__focused-toolbar__text"]
338
+ ),
339
+ "data-target-cslp": path,
340
+ style: { top: calculateTopOffset(index) },
341
+ onClick: () => onParentPathClick(path),
342
+ children: displayNames[path]
343
+ },
344
+ path
345
+ ))
346
+ ]
347
+ }
348
+ ) })
349
+ ]
340
350
  }
341
351
  );
342
352
  }