@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.
@@ -1,8 +1,8 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { useState, useCallback, useEffect } from "react";
3
3
  import { useFetchClient } from "@strapi/strapi/admin";
4
- import { M as MaterialIcon } from "./index-CStmbvTw.mjs";
5
- import { h as useStrapiLocales, K as getInitialLocale, L as createBlankSurveyDraft, M as ColorCodesManager, N as pickTextForLocale, O as SurveyAnalyticsView, P as SurveyStudioModal, Q as SurveyExportModal, T as SurveyImportModal, U as SurveyCleanupConfirmModal, V as persistLocale } from "./SurveyWidgetEditor-BZHyY2eb.mjs";
4
+ import { M as MaterialIcon } from "./index-BbqQm3-n.mjs";
5
+ import { h as useStrapiLocales, L as getInitialLocale, M as createBlankSurveyDraft, N as ColorCodesManager, O as pickTextForLocale, P as SurveyAnalyticsView, Q as SurveyStudioModal, T as SurveyExportModal, U as SurveyImportModal, V as SurveyCleanupConfirmModal, X as persistLocale } from "./SurveyWidgetEditor-BLv_25xY.mjs";
6
6
  const AnalyticsHubPage = () => {
7
7
  const { get, post } = useFetchClient();
8
8
  const { locales: strapiLocales } = useStrapiLocales();
@@ -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 admin = require("@strapi/strapi/admin");
6
- const index = require("./index-BvofXe07.js");
7
- const SurveyWidgetEditor = require("./SurveyWidgetEditor-k7kA6LQT.js");
6
+ const index = require("./index-BiQZO5zW.js");
7
+ const SurveyWidgetEditor = require("./SurveyWidgetEditor-DGNf6Mui.js");
8
8
  const AnalyticsHubPage = () => {
9
9
  const { get, post } = admin.useFetchClient();
10
10
  const { locales: strapiLocales } = SurveyWidgetEditor.useStrapiLocales();
@@ -1,8 +1,8 @@
1
1
  import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
2
  import React, { useState, useRef, useEffect, useMemo, useCallback } from "react";
3
3
  import { createPortal } from "react-dom";
4
- import { u as uid, a as useEditorTranslator, R as ROW_PRESETS, g as getRowPresetLabel, W as WIDGET_DEFINITIONS, b as getWidgetLabel, C as CIColorField, c as createWidget, d as createBlock, e as createRow, f as getWidgetDefinition, S as StrapiMediaPicker, D as DEVICES, r as resolveAdminMediaUrl, h as useStrapiLocales, i as useOptionalEditorContext, j as resolveCanvasMediaUrl, k as DEVICE_INDEX_MAP, l as useEditorContext, m as getDevice, n as rowCanvasClasses, o as nodeCanvasStyles, p as extractResponsiveProp, q as blockCanvasClasses, s as useColorCodes, t as getDeviceLabel, v as WIDTH_PRESETS, Z as ZOOM_OPTIONS, w as ColorCodesModal, x as getWidgetDescription, y as WIDGET_CATEGORIES, z as normalizeLocalizedRecord, A as normalizeOptionListByLocales, B as getDeviceTooltip, E as SurveyWidgetEditor, F as setResponsiveProp, G as getClipboard, H as copyToClipboard, I as EditorProvider, J as ensureIds } from "./SurveyWidgetEditor-BZHyY2eb.mjs";
5
- import { M as MaterialIcon } from "./index-CStmbvTw.mjs";
4
+ import { u as uid, a as useEditorTranslator, R as ROW_PRESETS, g as getRowPresetLabel, W as WIDGET_DEFINITIONS, b as getWidgetLabel, C as CIColorField, c as createWidget, d as createBlock, e as createRow, f as getWidgetDefinition, S as StrapiMediaPicker, D as DEVICES, r as resolveAdminMediaUrl, h as useStrapiLocales, i as useOptionalEditorContext, j as resolveCanvasMediaUrl, k as DEVICE_INDEX_MAP, l as SurveyLivePreviewPane, m as useEditorContext, n as getDevice, o as rowCanvasClasses, p as nodeCanvasStyles, q as extractResponsiveProp, s as blockCanvasClasses, t as useColorCodes, v as getDeviceLabel, w as WIDTH_PRESETS, Z as ZOOM_OPTIONS, x as ColorCodesModal, y as getWidgetDescription, z as WIDGET_CATEGORIES, A as normalizeLocalizedRecord, B as normalizeOptionListByLocales, E as getDeviceTooltip, F as SurveyWidgetEditor, G as setResponsiveProp, H as getClipboard, I as copyToClipboard, J as EditorProvider, K as ensureIds } from "./SurveyWidgetEditor-BLv_25xY.mjs";
5
+ import { M as MaterialIcon } from "./index-BbqQm3-n.mjs";
6
6
  import { Swiper, SwiperSlide } from "swiper/react";
7
7
  import { Navigation, Pagination, Autoplay, Parallax, EffectFade, EffectCreative, EffectCoverflow, EffectCube, EffectFlip, Mousewheel } from "swiper/modules";
8
8
  import { useFetchClient, useStrapiApp } from "@strapi/strapi/admin";
@@ -1798,7 +1798,7 @@ const RichHtmlEditor = ({
1798
1798
  justifyContent: "center",
1799
1799
  padding: 20
1800
1800
  },
1801
- onClick: () => setLinkModalOpen(false),
1801
+ onClick: (e) => e.stopPropagation(),
1802
1802
  children: /* @__PURE__ */ jsxs(
1803
1803
  "div",
1804
1804
  {
@@ -3509,7 +3509,7 @@ const TabAccordionEditor = ({ widget, onChange }) => {
3509
3509
  justifyContent: "center",
3510
3510
  padding: 20
3511
3511
  },
3512
- onClick: () => setDesignModalNodeIdx(null),
3512
+ onClick: (e) => e.stopPropagation(),
3513
3513
  children: /* @__PURE__ */ jsxs(
3514
3514
  "div",
3515
3515
  {
@@ -9516,7 +9516,7 @@ const HeroSliderStudioModal = ({
9516
9516
  "div",
9517
9517
  {
9518
9518
  "data-ci-studio-modal": "true",
9519
- onClick: onClose,
9519
+ onClick: (e) => e.stopPropagation(),
9520
9520
  style: {
9521
9521
  position: "fixed",
9522
9522
  inset: 0,
@@ -12884,7 +12884,7 @@ const DataTableStudioModal = ({
12884
12884
  {
12885
12885
  className: "ci-root",
12886
12886
  "data-ci-studio-modal": "true",
12887
- onClick: onClose,
12887
+ onClick: (e) => e.stopPropagation(),
12888
12888
  style: {
12889
12889
  position: "fixed",
12890
12890
  inset: 0,
@@ -14890,7 +14890,7 @@ const CustomCardStudioModal = ({
14890
14890
  {
14891
14891
  className: "ci-root",
14892
14892
  "data-ci-studio-modal": "true",
14893
- onClick: onClose,
14893
+ onClick: (e) => e.stopPropagation(),
14894
14894
  style: {
14895
14895
  position: "fixed",
14896
14896
  inset: 0,
@@ -16785,12 +16785,14 @@ const DynamicFormPreviewCard = ({ data, locale, activeDevice }) => {
16785
16785
  }
16786
16786
  );
16787
16787
  };
16788
- const SurveyPreviewCard = ({ data, locale }) => {
16788
+ const SurveyPreviewCard = ({ data, options, locale }) => {
16789
16789
  const tr = locale === "tr";
16790
16790
  const surveyRef = data?.survey?.slug || data?.survey?.id || data?.surveySlug || data?.surveyId || "showcase_dx_survey";
16791
16791
  const [remoteSurvey, setRemoteSurvey] = useState(null);
16792
+ const [loadingSurvey, setLoadingSurvey] = useState(true);
16792
16793
  useEffect(() => {
16793
16794
  let cancelled = false;
16795
+ setLoadingSurvey(true);
16794
16796
  const fetchSurvey = async () => {
16795
16797
  try {
16796
16798
  const res = await fetch(
@@ -16798,9 +16800,32 @@ const SurveyPreviewCard = ({ data, locale }) => {
16798
16800
  );
16799
16801
  if (res.ok) {
16800
16802
  const json = await res.json();
16801
- if (!cancelled && json) setRemoteSurvey(json);
16803
+ if (!cancelled && json) {
16804
+ setRemoteSurvey(json);
16805
+ setLoadingSurvey(false);
16806
+ return;
16807
+ }
16808
+ }
16809
+ } catch {
16810
+ }
16811
+ try {
16812
+ let rawToken = typeof window !== "undefined" && (window.sessionStorage?.getItem("jwtToken") || window.localStorage?.getItem("jwtToken")) || "";
16813
+ if (rawToken.startsWith('"') && rawToken.endsWith('"')) {
16814
+ rawToken = JSON.parse(rawToken);
16815
+ }
16816
+ const adminRes = await fetch(
16817
+ `/content-input/surveys/${encodeURIComponent(String(surveyRef))}`,
16818
+ rawToken ? { headers: { Authorization: `Bearer ${rawToken}` } } : void 0
16819
+ );
16820
+ if (adminRes.ok) {
16821
+ const adminJson = await adminRes.json();
16822
+ if (!cancelled && adminJson) {
16823
+ setRemoteSurvey(adminJson);
16824
+ }
16802
16825
  }
16803
16826
  } catch {
16827
+ } finally {
16828
+ if (!cancelled) setLoadingSurvey(false);
16804
16829
  }
16805
16830
  };
16806
16831
  fetchSurvey();
@@ -16808,6 +16833,7 @@ const SurveyPreviewCard = ({ data, locale }) => {
16808
16833
  const detail = ev?.detail;
16809
16834
  if (detail && (detail.slug === surveyRef || detail._id === surveyRef)) {
16810
16835
  setRemoteSurvey(detail);
16836
+ setLoadingSurvey(false);
16811
16837
  }
16812
16838
  };
16813
16839
  if (typeof window !== "undefined") {
@@ -16820,19 +16846,22 @@ const SurveyPreviewCard = ({ data, locale }) => {
16820
16846
  }
16821
16847
  };
16822
16848
  }, [surveyRef]);
16823
- const title = pickLocalized(
16824
- remoteSurvey?.titleI18n,
16825
- locale,
16826
- remoteSurvey?.title || data?.title || (tr ? "Kurumsal Anket" : "Enterprise Survey")
16827
- );
16828
- const desc = pickLocalized(remoteSurvey?.description, locale, "");
16829
- const mode = remoteSurvey?.displayMode || data?.survey?.displayMode || "single_page";
16830
- const questions = Array.isArray(remoteSurvey?.questions) ? remoteSurvey.questions.filter((q) => q.type !== "statement").slice(0, 2) : [];
16831
- const submitLbl = pickLocalized(
16832
- remoteSurvey?.settings?.submitLabel,
16833
- locale,
16834
- tr ? "Anketi Gönder" : "Submit Survey"
16835
- );
16849
+ if (remoteSurvey && Array.isArray(remoteSurvey.questions)) {
16850
+ const modeOverride = data?.displayModeOverride;
16851
+ const effectiveDraft = modeOverride === "quick_poll" || modeOverride === "single_page" || modeOverride === "multi_step" ? { ...remoteSurvey, displayMode: modeOverride } : remoteSurvey;
16852
+ return /* @__PURE__ */ jsx(
16853
+ SurveyLivePreviewPane,
16854
+ {
16855
+ draft: effectiveDraft,
16856
+ uiLocale: locale,
16857
+ embeddedCanvas: true,
16858
+ hideTitle: Boolean(data?.hideTitle),
16859
+ hideDescription: Boolean(data?.hideDescription),
16860
+ compact: Boolean(data?.compact),
16861
+ cardStyleOptions: options
16862
+ }
16863
+ );
16864
+ }
16836
16865
  return /* @__PURE__ */ jsxs(
16837
16866
  "div",
16838
16867
  {
@@ -16841,158 +16870,18 @@ const SurveyPreviewCard = ({ data, locale }) => {
16841
16870
  borderRadius: 12,
16842
16871
  padding: 18,
16843
16872
  background: "#ffffff",
16844
- boxShadow: "0 4px 16px rgba(15, 23, 42, 0.05)"
16873
+ boxShadow: "0 4px 16px rgba(15, 23, 42, 0.05)",
16874
+ display: "flex",
16875
+ alignItems: "center",
16876
+ justifyContent: "space-between",
16877
+ gap: 10
16845
16878
  },
16846
16879
  children: [
16847
- !data?.hideTitle && /* @__PURE__ */ jsxs("div", { style: { marginBottom: 14 }, children: [
16848
- /* @__PURE__ */ jsxs(
16849
- "div",
16850
- {
16851
- style: {
16852
- display: "flex",
16853
- alignItems: "center",
16854
- justifyContent: "space-between",
16855
- gap: 8,
16856
- marginBottom: 4
16857
- },
16858
- children: [
16859
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
16860
- /* @__PURE__ */ jsx(MaterialIcon, { name: "poll", size: 20, color: "#2563eb" }),
16861
- /* @__PURE__ */ jsx("span", { style: { fontSize: 15, fontWeight: 700, color: "#0f172a" }, children: title })
16862
- ] }),
16863
- /* @__PURE__ */ jsxs(
16864
- "span",
16865
- {
16866
- style: {
16867
- fontSize: 10,
16868
- fontWeight: 700,
16869
- padding: "2px 8px",
16870
- borderRadius: 12,
16871
- background: "#eff6ff",
16872
- color: "#1d4ed8"
16873
- },
16874
- children: [
16875
- mode,
16876
- " • ",
16877
- remoteSurvey?.responseCount ?? 0,
16878
- " ",
16879
- tr ? "katılım" : "votes"
16880
- ]
16881
- }
16882
- )
16883
- ]
16884
- }
16885
- ),
16886
- desc && /* @__PURE__ */ jsx("div", { style: { fontSize: 12, color: "#475569" }, children: desc })
16880
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
16881
+ /* @__PURE__ */ jsx(MaterialIcon, { name: "poll", size: 20, color: "#2563eb" }),
16882
+ /* @__PURE__ */ 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}`) })
16887
16883
  ] }),
16888
- mode === "multi_step" && Array.isArray(remoteSurvey?.steps) && /* @__PURE__ */ jsx(
16889
- "div",
16890
- {
16891
- style: {
16892
- display: "flex",
16893
- gap: 6,
16894
- marginBottom: 12,
16895
- paddingBottom: 10,
16896
- borderBottom: "1px solid #f1f5f9"
16897
- },
16898
- children: remoteSurvey.steps.map((st, i) => /* @__PURE__ */ jsx(
16899
- "span",
16900
- {
16901
- style: {
16902
- padding: "3px 9px",
16903
- borderRadius: 12,
16904
- background: i === 0 ? "#2563eb" : "#f1f5f9",
16905
- color: i === 0 ? "#ffffff" : "#64748b",
16906
- fontSize: 10.5,
16907
- fontWeight: 700
16908
- },
16909
- children: pickLocalized(st.title, locale, `${i + 1}`)
16910
- },
16911
- st.id || i
16912
- ))
16913
- }
16914
- ),
16915
- /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column", gap: 12 }, children: questions.length > 0 ? questions.map((q, idx) => /* @__PURE__ */ jsxs(
16916
- "div",
16917
- {
16918
- style: {
16919
- padding: 12,
16920
- borderRadius: 8,
16921
- background: "#f8fafc",
16922
- border: "1px solid #e2e8f0"
16923
- },
16924
- children: [
16925
- /* @__PURE__ */ jsxs("div", { style: { fontSize: 12, fontWeight: 700, color: "#0f172a", marginBottom: 8 }, children: [
16926
- pickLocalized(q.title, locale, q.key),
16927
- q.required && /* @__PURE__ */ jsx("span", { style: { color: "#dc2626" }, children: " *" })
16928
- ] }),
16929
- q.type === "nps" ? /* @__PURE__ */ jsx("div", { style: { display: "flex", gap: 4, flexWrap: "wrap" }, children: Array.from({ length: 11 }, (_, n) => /* @__PURE__ */ jsx(
16930
- "span",
16931
- {
16932
- style: {
16933
- width: 24,
16934
- height: 24,
16935
- borderRadius: 5,
16936
- border: "1px solid #cbd5e1",
16937
- background: n === 9 ? "#10b981" : "#ffffff",
16938
- color: n === 9 ? "#ffffff" : "#334155",
16939
- fontSize: 10.5,
16940
- fontWeight: 700,
16941
- display: "inline-flex",
16942
- alignItems: "center",
16943
- justifyContent: "center"
16944
- },
16945
- children: n
16946
- },
16947
- n
16948
- )) }) : Array.isArray(q.options) ? /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column", gap: 5 }, children: q.options.slice(0, 3).map((opt) => /* @__PURE__ */ jsxs(
16949
- "div",
16950
- {
16951
- style: {
16952
- display: "flex",
16953
- alignItems: "center",
16954
- gap: 7,
16955
- fontSize: 11.5,
16956
- color: "#334155"
16957
- },
16958
- children: [
16959
- /* @__PURE__ */ jsx(
16960
- "span",
16961
- {
16962
- style: {
16963
- width: 13,
16964
- height: 13,
16965
- borderRadius: q.type === "multiple_choice" ? 3 : "50%",
16966
- border: "1.5px solid #94a3b8"
16967
- }
16968
- }
16969
- ),
16970
- /* @__PURE__ */ jsx("span", { children: pickLocalized(opt.labels, locale, opt.id) })
16971
- ]
16972
- },
16973
- opt.id
16974
- )) }) : /* @__PURE__ */ jsx("div", { style: { fontSize: 11, color: "#64748b" }, children: q.type })
16975
- ]
16976
- },
16977
- q.key || idx
16978
- )) : /* @__PURE__ */ jsxs("div", { style: { fontSize: 12, color: "#64748b" }, children: [
16979
- "Survey: ",
16980
- /* @__PURE__ */ jsx("code", { children: surveyRef })
16981
- ] }) }),
16982
- /* @__PURE__ */ jsx("div", { style: { marginTop: 12, display: "flex", justifyContent: "flex-end" }, children: /* @__PURE__ */ jsx(
16983
- "span",
16984
- {
16985
- style: {
16986
- padding: "7px 16px",
16987
- borderRadius: 6,
16988
- background: "#2563eb",
16989
- color: "#ffffff",
16990
- fontSize: 11.5,
16991
- fontWeight: 700
16992
- },
16993
- children: submitLbl
16994
- }
16995
- ) })
16884
+ /* @__PURE__ */ jsx("code", { style: { fontSize: 11, color: "#64748b" }, children: surveyRef })
16996
16885
  ]
16997
16886
  }
16998
16887
  );
@@ -18287,6 +18176,7 @@ const WidgetPreview = ({
18287
18176
  "div",
18288
18177
  {
18289
18178
  className: "ci-root",
18179
+ "data-ci-studio-modal": "true",
18290
18180
  style: {
18291
18181
  position: "fixed",
18292
18182
  inset: 0,
@@ -18297,10 +18187,7 @@ const WidgetPreview = ({
18297
18187
  justifyContent: "center",
18298
18188
  padding: 24
18299
18189
  },
18300
- onClick: (e) => {
18301
- e.stopPropagation();
18302
- setGalleryPopupIndex(null);
18303
- },
18190
+ onClick: (e) => e.stopPropagation(),
18304
18191
  children: /* @__PURE__ */ jsxs(
18305
18192
  "div",
18306
18193
  {
@@ -18945,6 +18832,7 @@ const WidgetPreview = ({
18945
18832
  "div",
18946
18833
  {
18947
18834
  className: "ci-root",
18835
+ "data-ci-studio-modal": "true",
18948
18836
  style: {
18949
18837
  position: "fixed",
18950
18838
  inset: 0,
@@ -18955,10 +18843,7 @@ const WidgetPreview = ({
18955
18843
  justifyContent: "center",
18956
18844
  padding: 24
18957
18845
  },
18958
- onClick: (e) => {
18959
- e.stopPropagation();
18960
- setYtPopupOpen(false);
18961
- },
18846
+ onClick: (e) => e.stopPropagation(),
18962
18847
  children: /* @__PURE__ */ jsxs(
18963
18848
  "div",
18964
18849
  {
@@ -19353,7 +19238,7 @@ const WidgetPreview = ({
19353
19238
  );
19354
19239
  }
19355
19240
  if (id === "survey") {
19356
- return /* @__PURE__ */ jsx(SurveyPreviewCard, { data, locale });
19241
+ return /* @__PURE__ */ jsx(SurveyPreviewCard, { data, options, locale });
19357
19242
  }
19358
19243
  if (id === "entityCard") {
19359
19244
  return /* @__PURE__ */ jsx(
@@ -23245,7 +23130,7 @@ const ContentFormWidgetEditor = ({
23245
23130
  justifyContent: "center",
23246
23131
  padding: 20
23247
23132
  },
23248
- onClick: () => setStudioOpen(false),
23133
+ onClick: (e) => e.stopPropagation(),
23249
23134
  children: /* @__PURE__ */ jsxs(
23250
23135
  "div",
23251
23136
  {
@@ -29979,8 +29864,6 @@ const VisualEditorModal = ({ open, onClose }) => {
29979
29864
  if (e.key === "Escape") {
29980
29865
  if (editor.selected) {
29981
29866
  editor.clearSelection();
29982
- } else {
29983
- onClose();
29984
29867
  }
29985
29868
  return;
29986
29869
  }
@@ -31997,7 +31880,7 @@ const InnerContentBuilder = ({
31997
31880
  justifyContent: "center",
31998
31881
  padding: 20
31999
31882
  },
32000
- onClick: () => setAddWidgetTarget(null),
31883
+ onClick: (e) => e.stopPropagation(),
32001
31884
  children: /* @__PURE__ */ jsxs(
32002
31885
  "div",
32003
31886
  {
@@ -32122,7 +32005,7 @@ const InnerContentBuilder = ({
32122
32005
  justifyContent: "center",
32123
32006
  padding: 20
32124
32007
  },
32125
- onClick: () => setEditingWidgetPos(null),
32008
+ onClick: (e) => e.stopPropagation(),
32126
32009
  children: /* @__PURE__ */ jsxs(
32127
32010
  "div",
32128
32011
  {