@ozguraltan/strapi-content-input 1.0.21 → 1.0.23

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 (29) hide show
  1. package/README.md +42 -13
  2. package/dist/admin/{AnalyticsHubPage-DsrcGI_Y.mjs → AnalyticsHubPage-Dvpx3KsP.mjs} +168 -55
  3. package/dist/admin/{AnalyticsHubPage-0p0Mx4AU.js → AnalyticsHubPage-K_trli5i.js} +186 -55
  4. package/dist/admin/{ContentInputField-CHXrzvE-.mjs → ContentInputField-C2kmtUwD.mjs} +328 -366
  5. package/dist/admin/{ContentInputField-7rWLSx_7.js → ContentInputField-CjxYYEps.js} +343 -381
  6. package/dist/admin/{SurveyWidgetEditor-BVN6X_3G.mjs → SurveyWidgetEditor-DMWOkHUt.mjs} +3271 -227
  7. package/dist/admin/{SurveyWidgetEditor-BmgYQaQS.js → SurveyWidgetEditor-DOYxWop9.js} +3247 -203
  8. package/dist/admin/{index-hFIuYqu5.mjs → index-AePRA0IB.mjs} +2 -2
  9. package/dist/admin/{index-CZAwXCFH.js → index-B9C8Qrfd.js} +2 -2
  10. package/dist/admin/index.js +1 -1
  11. package/dist/admin/index.mjs +1 -1
  12. package/dist/admin/src/components/common/CIImageSettingsControl.d.ts +17 -0
  13. package/dist/admin/src/components/widgets/CustomCardWidgetEditor.d.ts +1 -0
  14. package/dist/admin/src/components/widgets/HeroSliderStage.d.ts +3 -0
  15. package/dist/admin/src/components/widgets/SurveyLivePreviewPane.d.ts +9 -0
  16. package/dist/admin/src/components/widgets/SurveyWidgetEditor.d.ts +3 -1
  17. package/dist/admin/src/core/canvasClasses.d.ts +1 -0
  18. package/dist/admin/src/core/types.d.ts +12 -0
  19. package/dist/server/index.js +1359 -196
  20. package/dist/server/index.mjs +1341 -196
  21. package/dist/server/src/config/index.d.ts +4 -0
  22. package/dist/server/src/controllers/ci-image.d.ts +11 -2
  23. package/dist/server/src/controllers/index.d.ts +1 -0
  24. package/dist/server/src/index.d.ts +15 -1
  25. package/dist/server/src/services/ci-survey.d.ts +10 -1
  26. package/dist/server/src/services/index.d.ts +10 -1
  27. package/dist/server/src/utils/image-variants.d.ts +74 -0
  28. package/dist/server/src/utils/surveyEngine.d.ts +5 -0
  29. package/package.json +1 -1
package/README.md CHANGED
@@ -40,9 +40,16 @@ npm install git+ssh://git@gitlab.com:ozguraltan/strapi-content-input.git
40
40
  ### Step 2: Enable in `config/plugins.ts` & `config/features.ts`
41
41
  ```ts
42
42
  // config/plugins.ts
43
- export default () => ({
43
+ export default ({ env }) => ({
44
44
  'content-input': {
45
45
  enabled: true,
46
+ config: {
47
+ // Optional — defaults work out of the box even without .env variables:
48
+ imageVariantFolder: env('CI_IMAGE_VARIANT_FOLDER', 'ci-optimized'), // CDN subfolder for sharp WebP variants
49
+ imageVariantFormat: env('CI_IMAGE_VARIANT_FORMAT', 'webp'), // 'webp' (preserves PNG alpha transparency)
50
+ imageVariantQuality: env.int('CI_IMAGE_VARIANT_QUALITY', 85),
51
+ redirectProxyToCdn: env.bool('CI_IMAGE_REDIRECT_CDN', true), // 302 redirect /api/content-input/image -> CDN
52
+ },
46
53
  },
47
54
  });
48
55
  ```
@@ -119,11 +126,18 @@ export default [
119
126
  ![Canvas View](./docs/screenshots/02-canvas-view.png)
120
127
  ![Full-Screen Visual Editor](./docs/screenshots/03-visual-editor-tab-html.png)
121
128
 
122
- ### 2.2 Official Strapi Native Media Library Modal + `sharp` On-the-Fly + CDN Thumbnail Pipeline
123
- - **Official Strapi Media Library Modal (`components['media-library']` in `StrapiMediaPicker`):** Every media field across all 18 widgets and full-screen studios (`heroSlider` background image/video & floating layer, `customCard` media & author avatar, `entityCard`, `survey` image choice, `gallery`, `singleImage`, `youtubeVideo`, `banner`, `button`, `StyleControls`, and `RichHtmlEditor`) opens Strapi's **official native Media Library Dialog** (`z-index: 310` cleanly above all `200–270` ContentInput studios) with full-color thumbnails, pagination, folder navigation/creation, drag-and-drop upload, asset metadata editing, and Strapi's built-in **Cropper.js** cropper — plus an optional 1-click inline `sharp` **Crop & Rotate Studio** (`Free`, `1:1`, `16:9`, `4:3`, `3:2`, `4:5`, `-90°/+90°`, `Duplicate & Crop` or `Crop Original Asset`).
124
- - **On-the-Fly `sharp` Endpoint (`/api/content-input/image`) & Automatic CDN Upload:**
125
- - When a `gallery` widget uses `imageSettings` (`process: 'fit'` for `cWidth × cHeight` crop, or `process: 'widen'` for `cWidth` scaling), `sharp` generates the exact thumbnail on the backend, uploads the generated variant to Strapi's active Upload Provider / CDN (`strapi.plugin('upload').service('provider').upload`), persists the CDN URL in `file.formats['ci_fit_WxH']`, and caches it with immutable HTTP headers.
126
- - Clicking any gallery image opens the **Popup Lightbox** with the **full-resolution uncropped original image**.
129
+ ### 2.2 Universal `sharp` WebP + CDN Variant Engine (`ci-optimized/`) & Native Media Library Modal
130
+ - **Official Strapi Media Library Modal (`components['media-library']` in `StrapiMediaPicker`):** Every media field across all 18 widgets and full-screen studios (`heroSlider` background image/video & floating layer, `customCard` media & author avatar, `entityCard`, `survey` image choice, `dataTable` image cells, `gallery`, `singleImage`, `youtubeVideo`, `banner`, `button`, `StyleControls` Row/Block `bgImage`, and `RichHtmlEditor`) opens Strapi's **official native Media Library Dialog** (`z-index: 310` cleanly above all `200–270` ContentInput studios) with full-color thumbnails, pagination, folder navigation/creation, drag-and-drop upload, asset metadata editing, and Strapi's built-in **Cropper.js** cropper — plus an optional 1-click inline `sharp` **Crop & Rotate Studio** (`Free`, `1:1`, `16:9`, `4:3`, `3:2`, `4:5`, `-90°/+90°`, `Duplicate & Crop` or `Crop Original Asset`).
131
+ - **Default `ci-optimized/` CDN Subfolder & Transparent-Safe WebP Conversion:**
132
+ - All `sharp`-generated variants are uploaded to Strapi's active Upload Provider (Azure Blob Storage, AWS S3, Cloudflare R2, GCS, Cloudinary) inside the **`ci-optimized`** folder **by default** (`https://<your-cdn>/.../ci-optimized/ci_fit_500x500_<hash>.webp`) — even when `CI_IMAGE_VARIANT_FOLDER` is **not** set in `.env` (override via `CI_IMAGE_VARIANT_FOLDER` or set `'/'` to write at the bucket root).
133
+ - Raster images (`JPEG`, `PNG`, `WebP`, `AVIF`, `TIFF`, `BMP`) are converted to **`WebP`** using `sharp.webp({ quality: 85, alphaQuality: 100, effort: 4 })`, preserving **full 8-bit alpha transparency** for transparent PNG logos and floating layers.
134
+ - **`SVG`**, animated **`GIF`**, video (`mp4`, `webm`), audio, and documents (`PDF`, `DOCX`, `XLSX`, `ZIP`) automatically bypass `sharp` untouched.
135
+ - **JSONB `formats` Persistence on Selection + Save/Publish (Zero Storefront Proxy Calls):**
136
+ - Eagerly on Media Library selection (`POST /content-input/media/optimize`) **and** automatically during Strapi `beforeCreate` / `beforeUpdate` lifecycle hooks on **Save / Publish**, ContentInput generates missing `ci_fit_WxH`, `ci_widen_Wx0`, and `ci_auto_Wx0` variants across **all visual media slots** (`gallery`, `singleImage`, `banner`, `youtubeVideo`, Row/Block `bgImage`, `heroSlider`, `customCard`, `entityCard`, `survey`, `dataTable`, and `HtmlEditor` `<img>`), persists them in `plugin::upload.file.formats`, and embeds `optimized_url`, `original_url`, and `formats` directly inside the `ContentInput` JSONB snapshot.
137
+ - Storefront Nuxt renderers read `asset.formats['ci_fit_WxH'].url` / `asset.optimized_url` directly so `<img src>` and CSS `background-image` point straight to your **CDN URL** with **zero** calls to `/api/content-input/image`!
138
+ - Gallery Lightbox Popups use crisp `ci_auto_1920x0` WebP (while `process: 'none'` serves `original_url` untouched).
139
+ - **302 CDN Redirect on `GET /api/content-input/image`:**
140
+ - For legacy un-resaved entries or headless on-the-fly usage, `GET /api/content-input/image` generates/reuses the CDN variant and responds with an **HTTP `302` redirect** to the permanent `https://` CDN URL (or returns `{ url, formatKey }` JSON when `?json=1` or `Accept: application/json` is passed; falls back to immutable byte-stream in local `/uploads/...` setups).
127
141
  - **Official Swiper.js Engine + Native Framework Navigation Buttons (`CISwiperNavButtons`):**
128
142
  - Supports touch/mouse drag-to-swipe (`grabCursor`), mousewheel scrolling (`mousewheel`), transition effects (`slide`, `fade`, `cube`, `coverflow`, `flip`), `slidesPerView`, `spaceBetween`, `loop`, `autoplay`, and `pagination`.
129
143
  - Replaces Swiper's oversized raw `.swiper-button-prev`/`.swiper-button-next` chevrons across `heroSlider`, `gallery`, `entityCard`, and `customCard` with genuine Vuetify `<v-btn>` and Element Plus `<el-button>` components supporting selectable **`navButtonStyle`** (`'fab' | 'outlined' | 'tonal' | 'icon' | 'square'`), **`navButtonSize`** (`'sm' | 'md' | 'lg'`), and Color Codes / `#HEX` / `RGBA` **`navButtonColor`**.
@@ -286,7 +300,7 @@ The **`survey`** widget provides a full-featured survey, NPS, and quick-poll pla
286
300
  | `image_choice` | Visual cards backed by Strapi Media Library (`option.image`) | Visual option `%` distribution bars |
287
301
  | `nps` | `0–10` Net Promoter Score scale with localized endpoint labels | **NPS Score Gauge (`-100..+100`)** + Promoters (`9–10`), Passives (`7–8`), Detractors (`0–6`) + `0..10` histogram |
288
302
  | `star_rating` | `1–5` or `1–10` interactive star rating | Weighted average score (`★`) + per-score vertical histogram |
289
- | `likert_scale` | `1–5` or `1–7` agreement scale with `lowLabel` / `highLabel` | Weighted average + distribution histogram |
303
+ | `likert_scale` | `1–5` or `1–7` scale with `lowLabel`/`highLabel` **or** per-score Strapi `i18n` `scaleLabels` + 1-click presets | Weighted average + labeled distribution histogram |
290
304
  | `matrix_single` | Evaluation table (`rows[] × columns[]`, 1 choice per row) | **Color-coded Matrix Heatmap Table** (`%` & count per cell) |
291
305
  | `ranking` | Drag-and-drop + ↑/↓ priority ordering of items | **Borda Count Leaderboard** (Average Rank, `#1` votes, Borda score `%`) |
292
306
  | `short_text` | Single-line open-ended input with `vee-validate` rules (`email`, `min`, `max`, etc.) | Searchable Open-Ended Response Feed with locale & timestamp |
@@ -327,8 +341,10 @@ Reporting is available in **two places** inside Strapi Admin:
327
341
  - Global dashboard for all surveys, polls, and dynamic form submissions.
328
342
  - **4 KPI Cards:** Total Responses & Quota progress, Average & Median Completion Time (`durationMs`), Net Promoter Score (`-100..+100`) stacked bar, and Locale breakdown.
329
343
  - **30-Day Daily Participation Trend** bar chart + Date Range (`from`/`to`) & `Locale` filters.
330
- - **1-Click Export:** UTF-8 BOM `.csv` (opens directly in Microsoft Excel with Turkish/Unicode characters intact) and structured `.json` export (`GET /content-input/surveys/:id/export?format=csv|json`).
331
- 2. **Inline `Survey Studio Modal` -> `Tab 4: Analytics & Reports`:** View live charts for the selected survey directly inside the Content Manager page editor.
344
+ - **1-Click Export (`.xlsx`, `.csv`, `.json`):** Multi-sheet native Microsoft Excel **`.xlsx`** workbook (`Responses` + `Summary` sheets with auto-fitted columns), UTF-8 BOM `.csv`, and structured `.json` export (`GET /content-input/surveys/:id/export?format=xlsx|csv|json`), plus `.xlsx` & `.csv` export for Dynamic Form submissions.
345
+ 2. **Inline `Survey Studio Modal` -> `Tab 2: Live Flow Preview & Simulator` & `Tab 4: Analytics & Reports`:**
346
+ - **`Tab 2: Live Flow Preview & Simulator` (`SurveyLivePreviewPane`):** Interactive sandbox inside the Survey Studio modal (works directly against unsaved `draft` state without polluting live analytics DB) with **Desktop / Tablet / Mobile** viewport switcher, **Strapi `i18n` test locale** switcher, full multi-step wizard & validation testing across all 13 question types, **Reset Flow**, and a real-time **Skip Logic Visibility & JSON Payload Inspector**.
347
+ - **`Tab 4: Analytics & Reports`:** View live charts for the selected survey directly inside the Content Manager page editor.
332
348
  3. **Rich Seed Dataset Included in Playground (`525` Responses):** Boots automatically with 3 realistic showcase surveys (`showcase_dx_survey` with `185` correlated 30-day responses, `showcase_roadmap_poll` with `245` votes, and `showcase_visual_theme_poll` with `95` votes) plus `20` sample corporate form submissions.
333
349
 
334
350
  ---
@@ -433,13 +449,25 @@ npm install git+ssh://git@gitlab.com:ozguraltan/strapi-content-input.git
433
449
  ### Adım 2: `config/plugins.ts` ve `config/features.ts` İçinde Etkinleştirin
434
450
  ```ts
435
451
  // config/plugins.ts
436
- export default () => ({
452
+ export default ({ env }) => ({
437
453
  'content-input': {
438
454
  enabled: true,
455
+ config: {
456
+ // Opsiyonel — .env içinde tanımlanmasa bile varsayılan değerler otomatik çalışır:
457
+ imageVariantFolder: env('CI_IMAGE_VARIANT_FOLDER', 'ci-optimized'), // CDN alt klasörü (varsayılan: ci-optimized)
458
+ imageVariantFormat: env('CI_IMAGE_VARIANT_FORMAT', 'webp'), // Transparan PNG destekli WebP
459
+ imageVariantQuality: env.int('CI_IMAGE_VARIANT_QUALITY', 85),
460
+ redirectProxyToCdn: env.bool('CI_IMAGE_REDIRECT_CDN', true), // /api/content-input/image -> 302 CDN yönlendirmesi
461
+ },
439
462
  },
440
463
  });
441
464
  ```
442
465
 
466
+ > **Evrensel `sharp` WebP + `ci-optimized` CDN Varyant Mimarisi:**
467
+ > - `.env` dosyasında `CI_IMAGE_VARIANT_FOLDER` tanımlı **olmasa bile** `sharp` ile üretilen tüm görsel varyantları aktif Upload Provider / CDN üzerinde otomatik olarak **`ci-optimized/`** klasörü altına (`https://<cdn-adresiniz>/.../ci-optimized/ci_*_<hash>.webp`) yüklenir.
468
+ > - **`SVG`** ve animasyonlu **`GIF`** (ayrıca video ve PDF/ofis dokümanları) hariç tüm raster görseller (`JPEG`, `PNG`, `WebP`, `AVIF`, `TIFF`, `BMP`), transparan PNG alfa kanalını tam koruyan (`alphaQuality: 100`) **`WebP`** formatına dönüştürülür.
469
+ > - Yalnızca Galeri değil; **`singleImage`**, **`banner`**, **`youtubeVideo` kapak görseli**, **Satır/Sütun `bgImage`**, **`heroSlider` (`bgImage`, `mobileBgImage`, `floating_image`)**, **`customCard` (`image` & `authorAvatar`)**, **`entityCard`**, **`survey` (`image_choice`)**, **`dataTable` (`image` hücreleri)** ve **`HtmlEditor` (`<img>`)** dahil görsel seçilen tüm alanlar hem seçim anında hem de **Save / Publish** sırasında otomatik optimize edilerek `optimized_url` ve `formats` (`ci_fit_*`, `ci_widen_*`, `ci_auto_*`) bilgisini doğrudan `ContentInput` JSONB içine yazar. Böylece Nuxt vitrin (storefront) uygulamaları `localhost:1337/api/content-input/image` proxy adresine gitmeden **doğrudan CDN URL'lerini** render eder; eski içerikler için `/api/content-input/image` uç noktası da CDN adresine **HTTP `302` Redirect** uygular (`?json=1` ile JSON döner, lokal ortamda byte-stream fallback korunur).
470
+
443
471
  **Strapi v5.61+** sürümlerinde tüm ContentInput bileşenlerinde ve tam ekran stüdyolarda Strapi'nin kendi tam özellikli **Medya Kütüphanesi Modalının** (küçük resimler/thumbnails, sayfalama, klasör yönetimi, çoklu yükleme ve dahili kırpma/crop aracı ile) açılması için `config/features.ts` dosyasına `useLegacyMediaLibrary: true` ekleyin:
444
472
  ```ts
445
473
  // config/features.ts
@@ -548,7 +576,7 @@ export default () => ({
548
576
  - `multi_step`: Adım çubuklu, ilerleme yüzdeli, her adımda validasyon yapan **Çok Adımlı Sihirbaz (Wizard)** modu.
549
577
  2. **13 Soru ve Öğe Tipi:**
550
578
  - Seçimli tipler: `single_choice` (Tekli Seçim + `"Diğer"` açık uçlu seçenek + şık karıştırma), `multiple_choice` (Çoklu Seçim + `minSelections`/`maxSelections`), `dropdown` (Açılır Liste), `image_choice` (Strapi Medya Kütüphanesi görselli kart seçimi).
551
- - Ölçek, Matris ve Sıralama: `nps` (`0–10` Net Promoter Score), `star_rating` (`1–5` / `1–10` Yıldız), `likert_scale` (`1–5` / `1–7` Katılım Ölçeği), `matrix_single` (Satır × Sütun değerlendirme tablosu), `ranking` (Sürükle-bırak öncelik sıralama ve **Borda Puanlama**).
579
+ - Ölçek, Matris ve Sıralama: `nps` (`0–10` Net Promoter Score), `star_rating` (`1–5` / `1–10` Yıldız), `likert_scale` (`1–5` / `1–7` Katılım Ölçeği — sadece uç etiketler veya Strapi `i18n` dilleri kadar her puana özel `scaleLabels` + tek tık hazır şablonlar), `matrix_single` (Satır × Sütun değerlendirme tablosu), `ranking` (Sürükle-bırak öncelik sıralama ve **Borda Puanlama**).
552
580
  - Metin, Onay ve Bilgi: `short_text`, `long_text` (`vee-validate` kurallı), `consent` (KVKK/GDPR onayı) ve `statement` (bilgi/bölüm açıklaması).
553
581
  3. **Sabit Seçenek Kimliği (`option.id`) + Dinamik Strapi `i18n` Etiketleri:**
554
582
  - Seçenekler sabit bir `id` (`"opt_ai"`) ve Strapi `i18n` dillerine göre dinamik `labels` (`{ tr: "...", en: "...", de: "..." }`) sözlüğü ile saklanır. Böylece farklı dillerde verilen tüm oylar raporlama ekranında tek bir grafik çubuğunda birleşir.
@@ -558,8 +586,9 @@ export default () => ({
558
586
  - `status` (`draft` / `published` / `closed`), başlangıç/bitiş tarihi (`startsAt`/`endsAt`), maksimum yanıt kotası (`quotaLimit`).
559
587
  - `submissionPolicy`: `'one_per_voter'` (`localStorage` + sunucuda tuzlanmış **`HMAC-SHA256(IP + User-Agent + voterToken)`** kontrolü ile mükerrer oyda `HTTP 409`), `'one_per_token'` veya `'unlimited'`.
560
588
  - `anonymizeIp: true` ile ham IP kaydetmeden anonim parmak izi üretimi, `_hp` honeypot, isteğe bağlı Google reCAPTCHA v2 ve katılımcılara canlı sonuç gösterimi (`showPublicResults`: `'never' | 'after_vote' | 'always'`).
561
- 6. **Strapi Sol Menü "Surveys & Forms" Raporlama Merkezi (`/admin/plugins/content-input`):**
562
- - Hem Strapi sol menüsündeki bağımsız **Surveys & Forms** sayfasından hem de **Anket Stüdyosu -> Raporlama & Analiz** sekmesinden erişilebilir.
589
+ 6. **Canlı Önizleme & Akış Testi Sekmesi (`Tab 2`) + Strapi Sol Menü Raporlama Merkezi (`/admin/plugins/content-input`):**
590
+ - **Anket Stüdyosu -> `2. Önizleme & Canlı Akış Testi` Sekmesi:** Henüz veritabanına kaydetmeden taslak (`draft`) üzerinde tüm 13 soru tipini, çok adımlı sihirbaz (`multi_step`) geçişlerini, alan validasyonlarını, **Masaüstü / Tablet / Mobil** görünüm çerçevelerini, çok dilli (`i18n`) metinleri ve **Koşul & Yanıt Müfettişi** (hangi sorunun hangi koşulla gizlendiği + canlı JSON payload) panelini gerçek istatistikleri kirletmeden uçtan uca test etme imkanı sunar.
591
+ - Raporlama ekranına hem Strapi sol menüsündeki bağımsız **Surveys & Forms** sayfasından hem de **Anket Stüdyosu -> `4. Raporlama & Analiz`** sekmesinden erişilebilir.
563
592
  - Toplam yanıt & kota doluluk oranı, ortalama/medyan tamamlama süresi, **NPS Skoru (`-100..+100` — Destekçiler / Pasifler / Eleştirenler)**, **30 Günlük Katılım Trendi**, Matris **Isı Haritası (Heatmap)**, Borda Sıralama Liderlik Tablosu, aranabilir açık uçlu yanıt listesi, Tarih & Dil filtreleri ve tek tıkla **Excel uyumlu UTF-8 BOM `.csv` / `.json`** indirme özelliklerini içerir.
564
593
  - Playground ortamı **525 korelasyonlu örnek anket yanıtı** (`showcase_dx_survey`: `185`, `showcase_roadmap_poll`: `245`, `showcase_visual_theme_poll`: `95`) ve **20 örnek kurumsal form başvurusu** ile hazır gelir.
565
594
 
@@ -1,8 +1,10 @@
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-hFIuYqu5.mjs";
5
- import { h as useStrapiLocales, B as getInitialLocale, F as createBlankSurveyDraft, G as ColorCodesManager, H as pickTextForLocale, I as SurveyAnalyticsView, J as SurveyStudioModal, K as persistLocale } from "./SurveyWidgetEditor-BVN6X_3G.mjs";
4
+ import * as XLSXNs from "xlsx";
5
+ import { M as MaterialIcon } from "./index-AePRA0IB.mjs";
6
+ import { h as useStrapiLocales, K as getInitialLocale, L as createBlankSurveyDraft, M as ColorCodesManager, N as pickTextForLocale, O as SurveyAnalyticsView, P as SurveyStudioModal, Q as persistLocale } from "./SurveyWidgetEditor-DMWOkHUt.mjs";
7
+ const XLSX = XLSXNs?.utils ? XLSXNs : XLSXNs?.default || XLSXNs;
6
8
  const AnalyticsHubPage = () => {
7
9
  const { get, post } = useFetchClient();
8
10
  const { locales: strapiLocales } = useStrapiLocales();
@@ -22,6 +24,7 @@ const AnalyticsHubPage = () => {
22
24
  const [analyticsRefreshKey, setAnalyticsRefreshKey] = useState(0);
23
25
  const [reseeding, setReseeding] = useState(false);
24
26
  const [studioOpen, setStudioOpen] = useState(false);
27
+ const [studioInitialTab, setStudioInitialTab] = useState("builder");
25
28
  const [studioTarget, setStudioTarget] = useState(
26
29
  () => createBlankSurveyDraft(uiLocale)
27
30
  );
@@ -114,6 +117,57 @@ const AnalyticsHubPage = () => {
114
117
  document.body.removeChild(a);
115
118
  URL.revokeObjectURL(url);
116
119
  };
120
+ const exportFormSubmissionsXlsx = () => {
121
+ if (submissions.length === 0) return;
122
+ const dataKeys = Array.from(
123
+ new Set(
124
+ submissions.flatMap(
125
+ (s) => s.data && typeof s.data === "object" ? Object.keys(s.data) : []
126
+ )
127
+ )
128
+ );
129
+ const headers = ["ID", "Form", "Created At", "Mail Sent", ...dataKeys];
130
+ const formatCell = (v) => {
131
+ if (v === null || v === void 0) return "";
132
+ if (typeof v === "number") return v;
133
+ if (Array.isArray(v)) return v.join("; ");
134
+ if (typeof v === "object") return JSON.stringify(v);
135
+ return String(v);
136
+ };
137
+ const aoa = [headers];
138
+ for (const s of submissions) {
139
+ aoa.push([
140
+ String(s.id || s.documentId || ""),
141
+ String(s.formTitle || s.formSlug || ""),
142
+ String(s.createdAt || ""),
143
+ s.mailSent ? "Yes" : "No",
144
+ ...dataKeys.map((k) => formatCell(s.data?.[k]))
145
+ ]);
146
+ }
147
+ const ws = XLSX.utils.aoa_to_sheet(aoa);
148
+ ws["!cols"] = headers.map((h, cIdx) => {
149
+ let maxLen = Math.max(12, h.length);
150
+ for (let r = 1; r < Math.min(aoa.length, 250); r++) {
151
+ const len = String(aoa[r]?.[cIdx] ?? "").length;
152
+ if (len > maxLen) maxLen = len;
153
+ }
154
+ return { wch: Math.min(52, maxLen + 3) };
155
+ });
156
+ const wb = XLSX.utils.book_new();
157
+ XLSX.utils.book_append_sheet(wb, ws, tr ? "Form_Basvurulari" : "Submissions");
158
+ const out = XLSX.write(wb, { bookType: "xlsx", type: "array" });
159
+ const blob = new Blob([out], {
160
+ type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
161
+ });
162
+ const url = URL.createObjectURL(blob);
163
+ const a = document.createElement("a");
164
+ a.href = url;
165
+ a.download = `form-submissions-${selectedFormSlug}.xlsx`;
166
+ document.body.appendChild(a);
167
+ a.click();
168
+ document.body.removeChild(a);
169
+ URL.revokeObjectURL(url);
170
+ };
117
171
  const currentSurvey = surveys.find((s) => s.slug === selectedSurveySlug) || surveys[0] || null;
118
172
  const totalAllResponses = surveys.reduce((acc, s) => acc + (s.responseCount || 0), 0);
119
173
  return /* @__PURE__ */ jsxs(
@@ -169,6 +223,7 @@ const AnalyticsHubPage = () => {
169
223
  type: "button",
170
224
  onClick: () => {
171
225
  setStudioTarget(createBlankSurveyDraft(uiLocale));
226
+ setStudioInitialTab("builder");
172
227
  setStudioOpen(true);
173
228
  },
174
229
  style: {
@@ -480,35 +535,66 @@ const AnalyticsHubPage = () => {
480
535
  srv.slug
481
536
  );
482
537
  }),
483
- currentSurvey && /* @__PURE__ */ jsxs(
484
- "button",
485
- {
486
- type: "button",
487
- onClick: () => {
488
- setStudioTarget(currentSurvey);
489
- setStudioOpen(true);
490
- },
491
- style: {
492
- marginTop: 4,
493
- padding: "9px 12px",
494
- borderRadius: 8,
495
- border: "1px solid #2563eb",
496
- background: "#ffffff",
497
- color: "#1d4ed8",
498
- fontSize: 12,
499
- fontWeight: 700,
500
- cursor: "pointer",
501
- display: "inline-flex",
502
- alignItems: "center",
503
- justifyContent: "center",
504
- gap: 6
505
- },
506
- children: [
507
- /* @__PURE__ */ jsx(MaterialIcon, { name: "edit", size: 15, color: "#2563eb" }),
508
- /* @__PURE__ */ jsx("span", { children: tr ? "Seçili Anketi Düzenle (Studio)" : "Edit Selected Survey (Studio)" })
509
- ]
510
- }
511
- )
538
+ currentSurvey && /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 6, marginTop: 4 }, children: [
539
+ /* @__PURE__ */ jsxs(
540
+ "button",
541
+ {
542
+ type: "button",
543
+ onClick: () => {
544
+ setStudioTarget(currentSurvey);
545
+ setStudioInitialTab("builder");
546
+ setStudioOpen(true);
547
+ },
548
+ style: {
549
+ padding: "9px 12px",
550
+ borderRadius: 8,
551
+ border: "1px solid #2563eb",
552
+ background: "#ffffff",
553
+ color: "#1d4ed8",
554
+ fontSize: 12,
555
+ fontWeight: 700,
556
+ cursor: "pointer",
557
+ display: "inline-flex",
558
+ alignItems: "center",
559
+ justifyContent: "center",
560
+ gap: 6
561
+ },
562
+ children: [
563
+ /* @__PURE__ */ jsx(MaterialIcon, { name: "edit", size: 15, color: "#2563eb" }),
564
+ /* @__PURE__ */ jsx("span", { children: tr ? "Seçili Anketi Düzenle (Studio)" : "Edit Selected Survey (Studio)" })
565
+ ]
566
+ }
567
+ ),
568
+ /* @__PURE__ */ jsxs(
569
+ "button",
570
+ {
571
+ type: "button",
572
+ onClick: () => {
573
+ setStudioTarget(currentSurvey);
574
+ setStudioInitialTab("preview");
575
+ setStudioOpen(true);
576
+ },
577
+ style: {
578
+ padding: "9px 12px",
579
+ borderRadius: 8,
580
+ border: "1px solid #059669",
581
+ background: "#ecfdf5",
582
+ color: "#065f46",
583
+ fontSize: 12,
584
+ fontWeight: 700,
585
+ cursor: "pointer",
586
+ display: "inline-flex",
587
+ alignItems: "center",
588
+ justifyContent: "center",
589
+ gap: 6
590
+ },
591
+ children: [
592
+ /* @__PURE__ */ jsx(MaterialIcon, { name: "play_circle", size: 16, color: "#059669" }),
593
+ /* @__PURE__ */ jsx("span", { children: tr ? "Anket Akışını Önizle & Test Et" : "Preview & Test Survey Flow" })
594
+ ]
595
+ }
596
+ )
597
+ ] })
512
598
  ]
513
599
  }
514
600
  ),
@@ -581,30 +667,56 @@ const AnalyticsHubPage = () => {
581
667
  }
582
668
  )
583
669
  ] }),
584
- /* @__PURE__ */ jsxs(
585
- "button",
586
- {
587
- type: "button",
588
- onClick: exportFormSubmissionsCsv,
589
- style: {
590
- padding: "7px 14px",
591
- borderRadius: 6,
592
- border: "none",
593
- background: "#059669",
594
- color: "#ffffff",
595
- fontSize: 12,
596
- fontWeight: 700,
597
- cursor: "pointer",
598
- display: "inline-flex",
599
- alignItems: "center",
600
- gap: 6
601
- },
602
- children: [
603
- /* @__PURE__ */ jsx(MaterialIcon, { name: "download", size: 15, color: "#fff" }),
604
- /* @__PURE__ */ jsx("span", { children: tr ? "Başvuruları CSV İndir" : "Export Submissions CSV" })
605
- ]
606
- }
607
- )
670
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
671
+ /* @__PURE__ */ jsxs(
672
+ "button",
673
+ {
674
+ type: "button",
675
+ onClick: exportFormSubmissionsXlsx,
676
+ style: {
677
+ padding: "7px 14px",
678
+ borderRadius: 6,
679
+ border: "none",
680
+ background: "#059669",
681
+ color: "#ffffff",
682
+ fontSize: 12,
683
+ fontWeight: 700,
684
+ cursor: "pointer",
685
+ display: "inline-flex",
686
+ alignItems: "center",
687
+ gap: 6
688
+ },
689
+ children: [
690
+ /* @__PURE__ */ jsx(MaterialIcon, { name: "table_view", size: 15, color: "#fff" }),
691
+ /* @__PURE__ */ jsx("span", { children: tr ? "Excel İndir (.xlsx)" : "Export Excel (.xlsx)" })
692
+ ]
693
+ }
694
+ ),
695
+ /* @__PURE__ */ jsxs(
696
+ "button",
697
+ {
698
+ type: "button",
699
+ onClick: exportFormSubmissionsCsv,
700
+ style: {
701
+ padding: "7px 12px",
702
+ borderRadius: 6,
703
+ border: "1px solid #10b981",
704
+ background: "#ecfdf5",
705
+ color: "#065f46",
706
+ fontSize: 12,
707
+ fontWeight: 700,
708
+ cursor: "pointer",
709
+ display: "inline-flex",
710
+ alignItems: "center",
711
+ gap: 6
712
+ },
713
+ children: [
714
+ /* @__PURE__ */ jsx(MaterialIcon, { name: "download", size: 15, color: "#059669" }),
715
+ /* @__PURE__ */ jsx("span", { children: "CSV" })
716
+ ]
717
+ }
718
+ )
719
+ ] })
608
720
  ]
609
721
  }
610
722
  ),
@@ -670,6 +782,7 @@ const AnalyticsHubPage = () => {
670
782
  {
671
783
  open: studioOpen,
672
784
  initialSurvey: studioTarget,
785
+ initialTab: studioInitialTab,
673
786
  uiLocale,
674
787
  onClose: () => setStudioOpen(false),
675
788
  onSaved: (saved) => {