@ozguraltan/strapi-content-input 1.0.27 → 1.0.29

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.
@@ -3,8 +3,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const React = require("react");
5
5
  const ReactDOM = require("react-dom");
6
- const SurveyWidgetEditor = require("./SurveyWidgetEditor-k7kA6LQT.js");
7
- const index = require("./index-BvofXe07.js");
6
+ const SurveyWidgetEditor = require("./SurveyWidgetEditor-DGNf6Mui.js");
7
+ const index = require("./index-BiQZO5zW.js");
8
8
  const react = require("swiper/react");
9
9
  const modules = require("swiper/modules");
10
10
  const admin = require("@strapi/strapi/admin");
@@ -1802,7 +1802,7 @@ const RichHtmlEditor = ({
1802
1802
  justifyContent: "center",
1803
1803
  padding: 20
1804
1804
  },
1805
- onClick: () => setLinkModalOpen(false),
1805
+ onClick: (e) => e.stopPropagation(),
1806
1806
  children: /* @__PURE__ */ jsxRuntime.jsxs(
1807
1807
  "div",
1808
1808
  {
@@ -3513,7 +3513,7 @@ const TabAccordionEditor = ({ widget, onChange }) => {
3513
3513
  justifyContent: "center",
3514
3514
  padding: 20
3515
3515
  },
3516
- onClick: () => setDesignModalNodeIdx(null),
3516
+ onClick: (e) => e.stopPropagation(),
3517
3517
  children: /* @__PURE__ */ jsxRuntime.jsxs(
3518
3518
  "div",
3519
3519
  {
@@ -9520,7 +9520,7 @@ const HeroSliderStudioModal = ({
9520
9520
  "div",
9521
9521
  {
9522
9522
  "data-ci-studio-modal": "true",
9523
- onClick: onClose,
9523
+ onClick: (e) => e.stopPropagation(),
9524
9524
  style: {
9525
9525
  position: "fixed",
9526
9526
  inset: 0,
@@ -12888,7 +12888,7 @@ const DataTableStudioModal = ({
12888
12888
  {
12889
12889
  className: "ci-root",
12890
12890
  "data-ci-studio-modal": "true",
12891
- onClick: onClose,
12891
+ onClick: (e) => e.stopPropagation(),
12892
12892
  style: {
12893
12893
  position: "fixed",
12894
12894
  inset: 0,
@@ -14894,7 +14894,7 @@ const CustomCardStudioModal = ({
14894
14894
  {
14895
14895
  className: "ci-root",
14896
14896
  "data-ci-studio-modal": "true",
14897
- onClick: onClose,
14897
+ onClick: (e) => e.stopPropagation(),
14898
14898
  style: {
14899
14899
  position: "fixed",
14900
14900
  inset: 0,
@@ -16789,12 +16789,14 @@ const DynamicFormPreviewCard = ({ data, locale, activeDevice }) => {
16789
16789
  }
16790
16790
  );
16791
16791
  };
16792
- const SurveyPreviewCard = ({ data, locale }) => {
16792
+ const SurveyPreviewCard = ({ data, options, locale }) => {
16793
16793
  const tr = locale === "tr";
16794
16794
  const surveyRef = data?.survey?.slug || data?.survey?.id || data?.surveySlug || data?.surveyId || "showcase_dx_survey";
16795
16795
  const [remoteSurvey, setRemoteSurvey] = React.useState(null);
16796
+ const [loadingSurvey, setLoadingSurvey] = React.useState(true);
16796
16797
  React.useEffect(() => {
16797
16798
  let cancelled = false;
16799
+ setLoadingSurvey(true);
16798
16800
  const fetchSurvey = async () => {
16799
16801
  try {
16800
16802
  const res = await fetch(
@@ -16802,9 +16804,32 @@ const SurveyPreviewCard = ({ data, locale }) => {
16802
16804
  );
16803
16805
  if (res.ok) {
16804
16806
  const json = await res.json();
16805
- if (!cancelled && json) setRemoteSurvey(json);
16807
+ if (!cancelled && json) {
16808
+ setRemoteSurvey(json);
16809
+ setLoadingSurvey(false);
16810
+ return;
16811
+ }
16812
+ }
16813
+ } catch {
16814
+ }
16815
+ try {
16816
+ let rawToken = typeof window !== "undefined" && (window.sessionStorage?.getItem("jwtToken") || window.localStorage?.getItem("jwtToken")) || "";
16817
+ if (rawToken.startsWith('"') && rawToken.endsWith('"')) {
16818
+ rawToken = JSON.parse(rawToken);
16819
+ }
16820
+ const adminRes = await fetch(
16821
+ `/content-input/surveys/${encodeURIComponent(String(surveyRef))}`,
16822
+ rawToken ? { headers: { Authorization: `Bearer ${rawToken}` } } : void 0
16823
+ );
16824
+ if (adminRes.ok) {
16825
+ const adminJson = await adminRes.json();
16826
+ if (!cancelled && adminJson) {
16827
+ setRemoteSurvey(adminJson);
16828
+ }
16806
16829
  }
16807
16830
  } catch {
16831
+ } finally {
16832
+ if (!cancelled) setLoadingSurvey(false);
16808
16833
  }
16809
16834
  };
16810
16835
  fetchSurvey();
@@ -16812,6 +16837,7 @@ const SurveyPreviewCard = ({ data, locale }) => {
16812
16837
  const detail = ev?.detail;
16813
16838
  if (detail && (detail.slug === surveyRef || detail._id === surveyRef)) {
16814
16839
  setRemoteSurvey(detail);
16840
+ setLoadingSurvey(false);
16815
16841
  }
16816
16842
  };
16817
16843
  if (typeof window !== "undefined") {
@@ -16824,19 +16850,22 @@ const SurveyPreviewCard = ({ data, locale }) => {
16824
16850
  }
16825
16851
  };
16826
16852
  }, [surveyRef]);
16827
- const title = pickLocalized(
16828
- remoteSurvey?.titleI18n,
16829
- locale,
16830
- remoteSurvey?.title || data?.title || (tr ? "Kurumsal Anket" : "Enterprise Survey")
16831
- );
16832
- const desc = pickLocalized(remoteSurvey?.description, locale, "");
16833
- const mode = remoteSurvey?.displayMode || data?.survey?.displayMode || "single_page";
16834
- const questions = Array.isArray(remoteSurvey?.questions) ? remoteSurvey.questions.filter((q) => q.type !== "statement").slice(0, 2) : [];
16835
- const submitLbl = pickLocalized(
16836
- remoteSurvey?.settings?.submitLabel,
16837
- locale,
16838
- tr ? "Anketi Gönder" : "Submit Survey"
16839
- );
16853
+ if (remoteSurvey && Array.isArray(remoteSurvey.questions)) {
16854
+ const modeOverride = data?.displayModeOverride;
16855
+ const effectiveDraft = modeOverride === "quick_poll" || modeOverride === "single_page" || modeOverride === "multi_step" ? { ...remoteSurvey, displayMode: modeOverride } : remoteSurvey;
16856
+ return /* @__PURE__ */ jsxRuntime.jsx(
16857
+ SurveyWidgetEditor.SurveyLivePreviewPane,
16858
+ {
16859
+ draft: effectiveDraft,
16860
+ uiLocale: locale,
16861
+ embeddedCanvas: true,
16862
+ hideTitle: Boolean(data?.hideTitle),
16863
+ hideDescription: Boolean(data?.hideDescription),
16864
+ compact: Boolean(data?.compact),
16865
+ cardStyleOptions: options
16866
+ }
16867
+ );
16868
+ }
16840
16869
  return /* @__PURE__ */ jsxRuntime.jsxs(
16841
16870
  "div",
16842
16871
  {
@@ -16845,158 +16874,18 @@ const SurveyPreviewCard = ({ data, locale }) => {
16845
16874
  borderRadius: 12,
16846
16875
  padding: 18,
16847
16876
  background: "#ffffff",
16848
- boxShadow: "0 4px 16px rgba(15, 23, 42, 0.05)"
16877
+ boxShadow: "0 4px 16px rgba(15, 23, 42, 0.05)",
16878
+ display: "flex",
16879
+ alignItems: "center",
16880
+ justifyContent: "space-between",
16881
+ gap: 10
16849
16882
  },
16850
16883
  children: [
16851
- !data?.hideTitle && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: 14 }, children: [
16852
- /* @__PURE__ */ jsxRuntime.jsxs(
16853
- "div",
16854
- {
16855
- style: {
16856
- display: "flex",
16857
- alignItems: "center",
16858
- justifyContent: "space-between",
16859
- gap: 8,
16860
- marginBottom: 4
16861
- },
16862
- children: [
16863
- /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
16864
- /* @__PURE__ */ jsxRuntime.jsx(index.MaterialIcon, { name: "poll", size: 20, color: "#2563eb" }),
16865
- /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 15, fontWeight: 700, color: "#0f172a" }, children: title })
16866
- ] }),
16867
- /* @__PURE__ */ jsxRuntime.jsxs(
16868
- "span",
16869
- {
16870
- style: {
16871
- fontSize: 10,
16872
- fontWeight: 700,
16873
- padding: "2px 8px",
16874
- borderRadius: 12,
16875
- background: "#eff6ff",
16876
- color: "#1d4ed8"
16877
- },
16878
- children: [
16879
- mode,
16880
- " • ",
16881
- remoteSurvey?.responseCount ?? 0,
16882
- " ",
16883
- tr ? "katılım" : "votes"
16884
- ]
16885
- }
16886
- )
16887
- ]
16888
- }
16889
- ),
16890
- desc && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 12, color: "#475569" }, children: desc })
16884
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
16885
+ /* @__PURE__ */ jsxRuntime.jsx(index.MaterialIcon, { name: "poll", size: 20, color: "#2563eb" }),
16886
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 13.5, fontWeight: 700, color: "#0f172a" }, children: data?.survey?.name || data?.title || (loadingSurvey ? tr ? "Anket yükleniyor..." : "Loading survey..." : `${tr ? "Anket" : "Survey"}: ${surveyRef}`) })
16891
16887
  ] }),
16892
- mode === "multi_step" && Array.isArray(remoteSurvey?.steps) && /* @__PURE__ */ jsxRuntime.jsx(
16893
- "div",
16894
- {
16895
- style: {
16896
- display: "flex",
16897
- gap: 6,
16898
- marginBottom: 12,
16899
- paddingBottom: 10,
16900
- borderBottom: "1px solid #f1f5f9"
16901
- },
16902
- children: remoteSurvey.steps.map((st, i) => /* @__PURE__ */ jsxRuntime.jsx(
16903
- "span",
16904
- {
16905
- style: {
16906
- padding: "3px 9px",
16907
- borderRadius: 12,
16908
- background: i === 0 ? "#2563eb" : "#f1f5f9",
16909
- color: i === 0 ? "#ffffff" : "#64748b",
16910
- fontSize: 10.5,
16911
- fontWeight: 700
16912
- },
16913
- children: pickLocalized(st.title, locale, `${i + 1}`)
16914
- },
16915
- st.id || i
16916
- ))
16917
- }
16918
- ),
16919
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", flexDirection: "column", gap: 12 }, children: questions.length > 0 ? questions.map((q, idx) => /* @__PURE__ */ jsxRuntime.jsxs(
16920
- "div",
16921
- {
16922
- style: {
16923
- padding: 12,
16924
- borderRadius: 8,
16925
- background: "#f8fafc",
16926
- border: "1px solid #e2e8f0"
16927
- },
16928
- children: [
16929
- /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { fontSize: 12, fontWeight: 700, color: "#0f172a", marginBottom: 8 }, children: [
16930
- pickLocalized(q.title, locale, q.key),
16931
- q.required && /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: "#dc2626" }, children: " *" })
16932
- ] }),
16933
- q.type === "nps" ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", gap: 4, flexWrap: "wrap" }, children: Array.from({ length: 11 }, (_, n) => /* @__PURE__ */ jsxRuntime.jsx(
16934
- "span",
16935
- {
16936
- style: {
16937
- width: 24,
16938
- height: 24,
16939
- borderRadius: 5,
16940
- border: "1px solid #cbd5e1",
16941
- background: n === 9 ? "#10b981" : "#ffffff",
16942
- color: n === 9 ? "#ffffff" : "#334155",
16943
- fontSize: 10.5,
16944
- fontWeight: 700,
16945
- display: "inline-flex",
16946
- alignItems: "center",
16947
- justifyContent: "center"
16948
- },
16949
- children: n
16950
- },
16951
- n
16952
- )) }) : Array.isArray(q.options) ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", flexDirection: "column", gap: 5 }, children: q.options.slice(0, 3).map((opt) => /* @__PURE__ */ jsxRuntime.jsxs(
16953
- "div",
16954
- {
16955
- style: {
16956
- display: "flex",
16957
- alignItems: "center",
16958
- gap: 7,
16959
- fontSize: 11.5,
16960
- color: "#334155"
16961
- },
16962
- children: [
16963
- /* @__PURE__ */ jsxRuntime.jsx(
16964
- "span",
16965
- {
16966
- style: {
16967
- width: 13,
16968
- height: 13,
16969
- borderRadius: q.type === "multiple_choice" ? 3 : "50%",
16970
- border: "1.5px solid #94a3b8"
16971
- }
16972
- }
16973
- ),
16974
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: pickLocalized(opt.labels, locale, opt.id) })
16975
- ]
16976
- },
16977
- opt.id
16978
- )) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 11, color: "#64748b" }, children: q.type })
16979
- ]
16980
- },
16981
- q.key || idx
16982
- )) : /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { fontSize: 12, color: "#64748b" }, children: [
16983
- "Survey: ",
16984
- /* @__PURE__ */ jsxRuntime.jsx("code", { children: surveyRef })
16985
- ] }) }),
16986
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: { marginTop: 12, display: "flex", justifyContent: "flex-end" }, children: /* @__PURE__ */ jsxRuntime.jsx(
16987
- "span",
16988
- {
16989
- style: {
16990
- padding: "7px 16px",
16991
- borderRadius: 6,
16992
- background: "#2563eb",
16993
- color: "#ffffff",
16994
- fontSize: 11.5,
16995
- fontWeight: 700
16996
- },
16997
- children: submitLbl
16998
- }
16999
- ) })
16888
+ /* @__PURE__ */ jsxRuntime.jsx("code", { style: { fontSize: 11, color: "#64748b" }, children: surveyRef })
17000
16889
  ]
17001
16890
  }
17002
16891
  );
@@ -18291,6 +18180,7 @@ const WidgetPreview = ({
18291
18180
  "div",
18292
18181
  {
18293
18182
  className: "ci-root",
18183
+ "data-ci-studio-modal": "true",
18294
18184
  style: {
18295
18185
  position: "fixed",
18296
18186
  inset: 0,
@@ -18301,10 +18191,7 @@ const WidgetPreview = ({
18301
18191
  justifyContent: "center",
18302
18192
  padding: 24
18303
18193
  },
18304
- onClick: (e) => {
18305
- e.stopPropagation();
18306
- setGalleryPopupIndex(null);
18307
- },
18194
+ onClick: (e) => e.stopPropagation(),
18308
18195
  children: /* @__PURE__ */ jsxRuntime.jsxs(
18309
18196
  "div",
18310
18197
  {
@@ -18949,6 +18836,7 @@ const WidgetPreview = ({
18949
18836
  "div",
18950
18837
  {
18951
18838
  className: "ci-root",
18839
+ "data-ci-studio-modal": "true",
18952
18840
  style: {
18953
18841
  position: "fixed",
18954
18842
  inset: 0,
@@ -18959,10 +18847,7 @@ const WidgetPreview = ({
18959
18847
  justifyContent: "center",
18960
18848
  padding: 24
18961
18849
  },
18962
- onClick: (e) => {
18963
- e.stopPropagation();
18964
- setYtPopupOpen(false);
18965
- },
18850
+ onClick: (e) => e.stopPropagation(),
18966
18851
  children: /* @__PURE__ */ jsxRuntime.jsxs(
18967
18852
  "div",
18968
18853
  {
@@ -19357,7 +19242,7 @@ const WidgetPreview = ({
19357
19242
  );
19358
19243
  }
19359
19244
  if (id === "survey") {
19360
- return /* @__PURE__ */ jsxRuntime.jsx(SurveyPreviewCard, { data, locale });
19245
+ return /* @__PURE__ */ jsxRuntime.jsx(SurveyPreviewCard, { data, options, locale });
19361
19246
  }
19362
19247
  if (id === "entityCard") {
19363
19248
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -23249,7 +23134,7 @@ const ContentFormWidgetEditor = ({
23249
23134
  justifyContent: "center",
23250
23135
  padding: 20
23251
23136
  },
23252
- onClick: () => setStudioOpen(false),
23137
+ onClick: (e) => e.stopPropagation(),
23253
23138
  children: /* @__PURE__ */ jsxRuntime.jsxs(
23254
23139
  "div",
23255
23140
  {
@@ -29983,8 +29868,6 @@ const VisualEditorModal = ({ open, onClose }) => {
29983
29868
  if (e.key === "Escape") {
29984
29869
  if (editor.selected) {
29985
29870
  editor.clearSelection();
29986
- } else {
29987
- onClose();
29988
29871
  }
29989
29872
  return;
29990
29873
  }
@@ -32001,7 +31884,7 @@ const InnerContentBuilder = ({
32001
31884
  justifyContent: "center",
32002
31885
  padding: 20
32003
31886
  },
32004
- onClick: () => setAddWidgetTarget(null),
31887
+ onClick: (e) => e.stopPropagation(),
32005
31888
  children: /* @__PURE__ */ jsxRuntime.jsxs(
32006
31889
  "div",
32007
31890
  {
@@ -32126,7 +32009,7 @@ const InnerContentBuilder = ({
32126
32009
  justifyContent: "center",
32127
32010
  padding: 20
32128
32011
  },
32129
- onClick: () => setEditingWidgetPos(null),
32012
+ onClick: (e) => e.stopPropagation(),
32130
32013
  children: /* @__PURE__ */ jsxRuntime.jsxs(
32131
32014
  "div",
32132
32015
  {