@shiva004/surveys 0.1.8 → 0.3.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.
- package/README.md +29 -1
- package/dist/App.d.ts +1 -1
- package/dist/docs/UserJourneyDocs.d.ts +12 -0
- package/dist/docs/pages.d.ts +22 -0
- package/dist/docs/statics.d.ts +10 -0
- package/dist/index.d.ts +9 -3
- package/dist/index.js +928 -302
- package/dist/journey/JourneyApp.d.ts +1 -1
- package/dist/journey/analytics.d.ts +1 -1
- package/dist/style.css +1 -1
- package/dist/survey/SurveyApp.d.ts +1 -1
- package/dist/survey/data.d.ts +1 -1
- package/dist/survey/nps.d.ts +1 -1
- package/dist/ui.d.ts +1 -1
- package/package.json +12 -14
- package/dist/index.cjs +0 -1
- package/dist/main.d.ts +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
export declare const JourneyApp: React.FC;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JourneyMap } from '../types';
|
|
1
|
+
import type { JourneyMap } from '../types';
|
|
2
2
|
export declare const PAGES: string[];
|
|
3
3
|
/** Simulated sessions: each session is the ordered list of pages one visitor saw. */
|
|
4
4
|
export declare function simulate(count: number, rand: () => number): string[][];
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
:root{--bg:#0f1117;--card:#171a23;--line:#262b3a;--text:#e6e8ef;--muted:#8b93a7;--accent:#7c3aed;--good:#4edea3;--warn:#ffcc6b;--bad:#ffb4ab;color-scheme:dark}@media (prefers-color-scheme: light){:root{--bg:#f6f7fb;--card:#ffffff;--line:#dfe2ec;--text:#1f2433;--muted:#667085;color-scheme:light}}*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--text);font:14px/1.45 system-ui,-apple-system,Segoe UI,sans-serif}h2{margin:0;font-size:22px}h3{margin:18px 0 8px}.shell{max-width:1100px;margin:0 auto;padding:16px 20px 48px}.topbar{display:flex;align-items:center;gap:16px;padding-bottom:12px;border-bottom:1px solid var(--line);margin-bottom:18px}.page-head{display:flex;justify-content:space-between;align-items:flex-start;gap:12px;margin-bottom:16px}.actions{display:flex;gap:8px}.muted{color:var(--muted)}.small{font-size:12px}.mono{font-family:ui-monospace,Menlo,Consolas,monospace}.right{text-align:right;white-space:nowrap}.stats{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:12px;margin-bottom:16px}.stat{background:var(--card);border:1px solid var(--line);border-top:3px solid var(--accent);border-radius:10px;padding:12px 14px}.stat-label{color:var(--muted);font-size:12px}.stat-value{font-size:24px;font-weight:700;margin-top:2px;overflow-wrap:anywhere}.tabs{display:inline-flex;gap:4px;background:var(--card);border:1px solid var(--line);border-radius:10px;padding:3px;margin-bottom:14px}.tab{border:0;background:none;color:var(--muted);padding:6px 12px;border-radius:7px;cursor:pointer;font:inherit}.tab.active{background:var(--accent);color:#fff}.table{width:100%;border-collapse:collapse;background:var(--card);border:1px solid var(--line);border-radius:10px;overflow:hidden}.table th,.table td{padding:10px 12px;text-align:left;border-bottom:1px solid var(--line);vertical-align:middle}.table th{font-size:12px;color:var(--muted);font-weight:600}.card{background:var(--card);border:1px solid var(--line);border-radius:10px;padding:14px;display:flex;flex-direction:column;gap:8px}.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(270px,1fr));gap:12px}.stack{display:flex;flex-direction:column;gap:10px}.row{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.grow{flex:1}.form{margin-bottom:10px}.form label{display:flex;flex-direction:column;gap:4px;font-size:12px;color:var(--muted)}.form label.inline{flex-direction:row;align-items:center}.input{width:100%;background:var(--bg);color:var(--text);border:1px solid var(--line);border-radius:8px;padding:8px 10px;font:inherit}.input:focus{outline:none;border-color:var(--accent)}.input.slim{width:auto;padding:5px 8px}.input.narrow{width:130px}.btn{background:var(--card);color:var(--text);border:1px solid var(--line);border-radius:8px;padding:6px 12px;cursor:pointer;font:inherit}.btn:hover:not(:disabled){border-color:var(--accent)}.btn:disabled{opacity:.45;cursor:not-allowed}.btn.primary{background:var(--accent);border-color:var(--accent);color:#fff}.btn.danger:hover:not(:disabled){border-color:var(--bad);color:var(--bad)}.bar{height:6px;border-radius:99px;background:#7f7f7f2e;overflow:hidden}.bar-fill{height:100%;border-radius:99px;transition:width .3s}.scale{display:flex;flex-wrap:wrap;gap:6px}.chip{border:1px solid var(--line);background:var(--bg);color:var(--text);border-radius:8px;padding:5px 10px;cursor:pointer;font:inherit;font-size:12.5px}.chip.active{background:var(--accent);border-color:var(--accent);color:#fff}.chip.static{cursor:default;font-family:ui-monospace,Menlo,monospace}.steps{display:flex;flex-wrap:wrap;align-items:center;gap:6px}.pill{display:inline-block;border-radius:99px;padding:2px 9px;font-size:11px;background:#7f7f7f2e}.pill.promoter{background:#4edea32e;color:var(--good)}.pill.passive{background:#ffcc6b2e;color:var(--warn)}.pill.detractor{background:#ffb4ab2e;color:var(--bad)}.stages{display:flex;gap:12px;overflow-x:auto;padding-bottom:6px}.stage{min-width:190px;width:190px}.badge{width:24px;height:24px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;font-size:11px;font-weight:700}.error{color:var(--bad);font-size:12.5px}
|
|
1
|
+
:root{--bg:#0f1117;--card:#171a23;--line:#262b3a;--text:#e6e8ef;--muted:#8b93a7;--accent:#7c3aed;--good:#4edea3;--warn:#ffcc6b;--bad:#ffb4ab;color-scheme:dark}@media (prefers-color-scheme: light){:root{--bg:#f6f7fb;--card:#ffffff;--line:#dfe2ec;--text:#1f2433;--muted:#667085;color-scheme:light}}*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--text);font:14px/1.45 system-ui,-apple-system,Segoe UI,sans-serif}h2{margin:0;font-size:22px}h3{margin:18px 0 8px}.shell{max-width:1100px;margin:0 auto;padding:16px 20px 48px}.topbar{display:flex;align-items:center;gap:16px;padding-bottom:12px;border-bottom:1px solid var(--line);margin-bottom:18px}.page-head{display:flex;justify-content:space-between;align-items:flex-start;gap:12px;margin-bottom:16px}.actions{display:flex;gap:8px}.muted{color:var(--muted)}.small{font-size:12px}.mono{font-family:ui-monospace,Menlo,Consolas,monospace}.right{text-align:right;white-space:nowrap}.stats{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:12px;margin-bottom:16px}.stat{background:var(--card);border:1px solid var(--line);border-top:3px solid var(--accent);border-radius:10px;padding:12px 14px}.stat-label{color:var(--muted);font-size:12px}.stat-value{font-size:24px;font-weight:700;margin-top:2px;overflow-wrap:anywhere}.tabs{display:inline-flex;gap:4px;background:var(--card);border:1px solid var(--line);border-radius:10px;padding:3px;margin-bottom:14px}.tab{border:0;background:none;color:var(--muted);padding:6px 12px;border-radius:7px;cursor:pointer;font:inherit}.tab.active{background:var(--accent);color:#fff}.table{width:100%;border-collapse:collapse;background:var(--card);border:1px solid var(--line);border-radius:10px;overflow:hidden}.table th,.table td{padding:10px 12px;text-align:left;border-bottom:1px solid var(--line);vertical-align:middle}.table th{font-size:12px;color:var(--muted);font-weight:600}.card{background:var(--card);border:1px solid var(--line);border-radius:10px;padding:14px;display:flex;flex-direction:column;gap:8px}.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(270px,1fr));gap:12px}.stack{display:flex;flex-direction:column;gap:10px}.row{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.grow{flex:1}.form{margin-bottom:10px}.form label{display:flex;flex-direction:column;gap:4px;font-size:12px;color:var(--muted)}.form label.inline{flex-direction:row;align-items:center}.input{width:100%;background:var(--bg);color:var(--text);border:1px solid var(--line);border-radius:8px;padding:8px 10px;font:inherit}.input:focus{outline:none;border-color:var(--accent)}.input.slim{width:auto;padding:5px 8px}.input.narrow{width:130px}.btn{background:var(--card);color:var(--text);border:1px solid var(--line);border-radius:8px;padding:6px 12px;cursor:pointer;font:inherit}.btn:hover:not(:disabled){border-color:var(--accent)}.btn:disabled{opacity:.45;cursor:not-allowed}.btn.primary{background:var(--accent);border-color:var(--accent);color:#fff}.btn.danger:hover:not(:disabled){border-color:var(--bad);color:var(--bad)}.bar{height:6px;border-radius:99px;background:#7f7f7f2e;overflow:hidden}.bar-fill{height:100%;border-radius:99px;transition:width .3s}.scale{display:flex;flex-wrap:wrap;gap:6px}.chip{border:1px solid var(--line);background:var(--bg);color:var(--text);border-radius:8px;padding:5px 10px;cursor:pointer;font:inherit;font-size:12.5px}.chip.active{background:var(--accent);border-color:var(--accent);color:#fff}.chip.static{cursor:default;font-family:ui-monospace,Menlo,monospace}.steps{display:flex;flex-wrap:wrap;align-items:center;gap:6px}.pill{display:inline-block;border-radius:99px;padding:2px 9px;font-size:11px;background:#7f7f7f2e}.pill.promoter{background:#4edea32e;color:var(--good)}.pill.passive{background:#ffcc6b2e;color:var(--warn)}.pill.detractor{background:#ffb4ab2e;color:var(--bad)}.stages{display:flex;gap:12px;overflow-x:auto;padding-bottom:6px}.stage{min-width:190px;width:190px}.badge{width:24px;height:24px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;font-size:11px;font-weight:700}.error{color:var(--bad);font-size:12.5px}.ujd{--acc:#7c3aed;--bg:#fff;--bg2:#f4f5f9;--fg:#111827;--muted:#6b7280;--bd:#e4e6ee;--link:#0d6efd;background:var(--bg);color:var(--fg);font:15px/1.6 Inter,system-ui,-apple-system,Segoe UI,sans-serif;min-height:100vh}.ujd[data-theme=dark]{--bg:#0f1117;--bg2:#1a1d27;--fg:#e8eaf1;--muted:#8a91a5;--bd:rgba(255,255,255,.12);--link:#6ea8fe}.ujd *,.ujd *:before,.ujd *:after{box-sizing:border-box}.ujd a{color:var(--link);cursor:pointer}.ujd code{font:.875em ui-monospace,SFMono-Regular,Menlo,monospace;color:#d63384}.ujd[data-theme=dark] code{color:#e685b5}.ujd-nav{position:sticky;top:0;z-index:20;height:3.5rem;display:flex;align-items:center;justify-content:space-between;padding:0 1rem;background:var(--bg);border-bottom:1px solid var(--bd)}.ujd-brand{font-weight:600;color:var(--fg)!important;text-decoration:none}.ujd-brand span{color:var(--muted);font-weight:400}.ujd-nav-actions{display:flex;gap:.5rem;align-items:center}.ujd-btn{background:none;border:1px solid var(--bd);color:var(--muted)!important;border-radius:.375rem;padding:.25rem .65rem;font-size:.85rem;cursor:pointer;text-decoration:none}.ujd-btn:hover{color:var(--fg)!important;background:var(--bg2)}.ujd-layout{display:grid;grid-template-columns:17rem minmax(0,1fr) 15rem;gap:1.5rem;max-width:92rem;margin:0 auto;padding:0 1rem}.ujd-side,.ujd-toc{position:sticky;top:3.5rem;height:calc(100vh - 3.5rem);overflow-y:auto;padding:1rem 0;align-self:start}.ujd-group{display:flex;align-items:center;gap:.4rem;width:100%;padding:.35rem .5rem;font:600 1.05rem inherit;background:none;border:0;color:var(--fg);text-align:left;cursor:pointer}.ujd-chev{display:inline-block;transition:transform .2s;font-size:1rem}.ujd-group[aria-expanded=true] .ujd-chev{transform:rotate(90deg)}.ujd-side ul{list-style:none;margin:0;padding:0 0 .5rem 1.5rem}.ujd-side ul a{display:block;padding:.2rem .5rem;color:var(--muted);text-decoration:none;border-radius:.375rem;font-size:.93rem}.ujd-side ul a:hover{color:var(--fg);background:var(--bg2)}.ujd-side ul a.active{color:var(--fg);font-weight:600}.ujd-toc h6{font-weight:600;margin:0 0 .5rem;padding-bottom:.5rem;border-bottom:1px solid var(--bd);font-size:1rem}.ujd-toc nav a{display:block;padding:.18rem .5rem;text-decoration:none;color:var(--muted);font-size:.9rem}.ujd-toc nav .sub{padding-left:1rem}.ujd-toc nav a:hover span,.ujd-toc nav .active{color:var(--acc)}.ujd-toc nav .active{font-weight:600}.ujd main{padding:1.5rem 0;min-width:0}.ujd main [id]{scroll-margin-top:4.5rem}.ujd h1{font-size:3rem;font-weight:500;margin:0;line-height:1.2}.ujd-titlebar{display:flex;justify-content:space-between;align-items:flex-start;gap:1rem}.ujd-lead{font-size:1.4rem;font-weight:300}.ujd h2{font-size:2rem;font-weight:500;margin:3.5rem 0 .75rem}.ujd h3{font-size:1.35rem;margin:2rem 0 .5rem}.ujd-callout{padding:1rem 1.25rem;border:1px solid var(--bd);border-left:.3rem solid var(--acc);border-radius:.5rem;background:var(--bg2);margin:1.25rem 0}.ujd-callout.ujd-warn{border-left-color:#f59e0b}.ujd pre{background:var(--bg2);border:1px solid var(--bd);border-radius:.5rem;padding:1rem;overflow-x:auto;font-size:.85rem}.ujd pre code{color:inherit}.ujd-table-wrap{overflow-x:auto}.ujd-table{width:100%;border-collapse:collapse;font-size:.92rem;margin:.5rem 0 1rem}.ujd-table th,.ujd-table td{text-align:left;padding:.4rem .6rem;border-bottom:1px solid var(--bd);vertical-align:middle}.ujd-table th{font-weight:600}.ujd-verb{font-weight:600;font-size:.75rem}.ujd-get{color:#198754}.ujd-post{color:#0d6efd}.ujd-del{color:#dc3545}.ujd-small{font-size:.85rem;color:var(--muted)}.ujd-row{display:flex;gap:.5rem;margin-bottom:1rem}.ujd-cards{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:1rem;margin-bottom:1rem}.ujd-card{display:block;border:1px solid var(--bd);border-radius:.5rem;padding:1rem;text-decoration:none;color:var(--fg)!important;transition:transform .2s,border-color .2s}.ujd-card:hover{transform:translateY(-2px);border-color:var(--acc)}.ujd-card h5{margin:0 0 .4rem;font-size:1.1rem}.ujd-card p{margin:0;color:var(--muted);font-size:.85rem}.ujd-accent{color:var(--acc)}.ujd-sw{display:inline-block;width:1rem;height:1rem;border-radius:.25rem;border:1px solid var(--bd);vertical-align:-.15rem;margin-right:.4rem}.ujd-demo{display:grid;grid-template-columns:1fr 1fr;gap:1rem}.ujd-mini{border-radius:.75rem;padding:1rem;border:1px solid var(--m-border);background:var(--m-bg);color:var(--m-text)}.ujd-mini .ujd-card-in{background:var(--m-surface);border:1px solid var(--m-border);border-radius:.6rem;padding:.75rem;margin-top:.6rem}.ujd-mini small{color:var(--m-muted)}.ujd-big{font-size:1.25rem;font-weight:600}.ujd-pill{display:inline-block;font-size:.7rem;padding:.1rem .5rem;border-radius:999px;background:#7c3aed26;color:var(--m-accent);border:1px solid rgba(124,58,237,.3)}.ujd-mini.l{--m-bg:#f4f5f9;--m-surface:#fff;--m-border:#e4e6ee;--m-text:#000;--m-muted:#6b7280;--m-accent:#6d28d9}.ujd-mini.d{--m-bg:#0f1117;--m-surface:#161922;--m-border:rgba(255,255,255,.1);--m-text:#e8eaf1;--m-muted:#8a91a5;--m-accent:#d2bbff}@media (max-width:1199.98px){.ujd-layout{grid-template-columns:17rem minmax(0,1fr)}.ujd-toc{display:none}}@media (max-width:991.98px){.ujd-layout{grid-template-columns:minmax(0,1fr)}.ujd-side{display:none}}@media (max-width:767.98px){.ujd-demo,.ujd-cards{grid-template-columns:1fr}.ujd-hide-sm{display:none}.ujd h1{font-size:2.2rem}}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
export declare const SurveyApp: React.FC;
|
package/dist/survey/data.d.ts
CHANGED
package/dist/survey/nps.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Survey, SurveyResponse } from '../types';
|
|
1
|
+
import type { Survey, SurveyResponse } from '../types';
|
|
2
2
|
export type NpsCategory = 'promoter' | 'passive' | 'detractor';
|
|
3
3
|
export declare const npsCategory: (s: number) => NpsCategory;
|
|
4
4
|
/** NPS = % promoters (9-10) minus % detractors (0-6). Passives (7-8) only count in the total. */
|
package/dist/ui.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,37 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shiva004/surveys",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Survey and User Journey POC components for React",
|
|
4
5
|
"type": "module",
|
|
5
|
-
"main": "./dist/index.
|
|
6
|
+
"main": "./dist/index.js",
|
|
6
7
|
"module": "./dist/index.js",
|
|
7
8
|
"types": "./dist/index.d.ts",
|
|
8
9
|
"exports": {
|
|
9
10
|
".": {
|
|
10
11
|
"types": "./dist/index.d.ts",
|
|
11
|
-
"import": "./dist/index.js"
|
|
12
|
-
"require": "./dist/index.cjs"
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
13
|
},
|
|
14
14
|
"./style.css": "./dist/style.css"
|
|
15
15
|
},
|
|
16
|
-
"files": [
|
|
17
|
-
|
|
18
|
-
],
|
|
16
|
+
"files": ["dist"],
|
|
17
|
+
"sideEffects": ["**/*.css"],
|
|
19
18
|
"scripts": {
|
|
20
19
|
"dev": "vite",
|
|
21
|
-
"build": "
|
|
22
|
-
"
|
|
20
|
+
"build": "vite build && tsc -p tsconfig.build.json",
|
|
21
|
+
"prepublishOnly": "npm run build"
|
|
23
22
|
},
|
|
24
23
|
"peerDependencies": {
|
|
25
|
-
"react": "
|
|
26
|
-
"react-dom": "^18.0.0"
|
|
24
|
+
"react": ">=18"
|
|
27
25
|
},
|
|
28
26
|
"devDependencies": {
|
|
29
|
-
"@types/node": "^26.6.6",
|
|
30
27
|
"@types/react": "^18.3.3",
|
|
31
28
|
"@types/react-dom": "^18.3.0",
|
|
32
29
|
"@vitejs/plugin-react": "^4.3.1",
|
|
30
|
+
"react": "^18.3.1",
|
|
31
|
+
"react-dom": "^18.3.1",
|
|
33
32
|
"typescript": "^5.5.4",
|
|
34
|
-
"vite": "^5.4.2"
|
|
35
|
-
"vite-plugin-dts": "^5.1.2"
|
|
33
|
+
"vite": "^5.4.2"
|
|
36
34
|
}
|
|
37
35
|
}
|
package/dist/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),j=require("react"),b=({label:s,value:n,color:a="#7c3aed"})=>e.jsxs("div",{className:"stat",style:{borderTopColor:a},children:[e.jsx("div",{className:"stat-label",children:s}),e.jsx("div",{className:"stat-value",children:n})]}),O=({items:s,value:n,onChange:a})=>e.jsx("div",{className:"tabs",children:s.map(t=>e.jsx("button",{type:"button",className:t.id===n?"tab active":"tab",onClick:()=>a(t.id),children:t.label},t.id))}),N=({pct:s,color:n="#7c3aed"})=>e.jsx("div",{className:"bar",children:e.jsx("div",{className:"bar-fill",style:{width:`${Math.max(0,Math.min(100,s))}%`,background:n}})}),w=({title:s,subtitle:n,actions:a,children:t})=>e.jsxs("section",{children:[e.jsxs("div",{className:"page-head",children:[e.jsxs("div",{children:[e.jsx("h2",{children:s}),n&&e.jsx("p",{className:"muted",children:n})]}),e.jsx("div",{className:"actions",children:a})]}),t]}),E=s=>()=>{s|=0,s=s+1831565813|0;let n=Math.imul(s^s>>>15,1|s);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296},y=s=>`${s}_${Math.random().toString(36).slice(2,8)}`,D=["/home","/pricing","/features","/docs","/signup","/dashboard","/checkout"],F=[["/home",.55],["/pricing",.15],["/features",.15],["/docs",.15]],B={"/home":[["/pricing",.3],["/features",.3],["/docs",.1],["/signup",.1],["EXIT",.2]],"/pricing":[["/signup",.3],["/features",.15],["/home",.1],["EXIT",.45]],"/features":[["/pricing",.3],["/signup",.15],["/docs",.15],["EXIT",.4]],"/docs":[["/features",.2],["/signup",.15],["/home",.1],["EXIT",.55]],"/signup":[["/dashboard",.6],["EXIT",.4]],"/dashboard":[["/checkout",.25],["/docs",.15],["/features",.1],["EXIT",.5]],"/checkout":[["EXIT",1]]},M=(s,n)=>{let a=0;for(const[t,l]of s)if(a+=l,n<a)return t;return s[s.length-1][0]};function P(s,n){return Array.from({length:s},()=>{let a=M(F,n());const t=[a];for(;t.length<8;){const l=M(B[a],n());if(l==="EXIT")break;t.push(l),a=l}return t})}const X=()=>P(400,E(42));function Q(s){const n=new Map,a=t=>(n.has(t)||n.set(t,{views:0,entries:0,bounces:0,exits:0}),n.get(t));for(const t of s)t.forEach(l=>{a(l).views+=1}),a(t[0]).entries+=1,t.length===1&&(a(t[0]).bounces+=1),a(t[t.length-1]).exits+=1;return[...n.entries()].map(([t,l])=>({page:t,views:l.views,bounceRate:l.entries?l.bounces/l.entries*100:0,exitRate:l.views?l.exits/l.views*100:0})).sort((t,l)=>l.views-t.views)}function L(s,n=8){const a=new Map;for(const t of s){const l=t.slice(0,4),h=l.join(">"),p=a.get(h)??{steps:l,users:0,conv:0};p.users+=1,t.includes("/signup")&&(p.conv+=1),a.set(h,p)}return[...a.values()].map(t=>({steps:t.steps,users:t.users,convRate:t.conv/t.users*100})).sort((t,l)=>l.users-t.users).slice(0,n)}function H(s){const n=new Map;for(const a of s)for(let t=0;t<a.length-1;t++){const l=n.get(a[t])??new Map;l.set(a[t+1],(l.get(a[t+1])??0)+1),n.set(a[t],l)}return[...n.entries()].map(([a,t])=>{const l=[...t.values()].reduce((h,p)=>h+p,0);return{from:a,total:l,destinations:[...t.entries()].map(([h,p])=>({to:h,pct:p/l*100})).sort((h,p)=>p.pct-h.pct)}}).sort((a,t)=>t.total-a.total)}const J=(s,n)=>s.length?s.filter(a=>a.some(t=>n.includes(t))).length/s.length*100:0,W={id:"jm1",name:"New customer journey",stages:[{id:"st1",name:"Awareness",emotion:"curious",pages:["/home"]},{id:"st2",name:"Consideration",emotion:"analytical",pages:["/pricing","/features"]},{id:"st3",name:"Sign up",emotion:"confident",pages:["/signup"]},{id:"st4",name:"Activation",emotion:"engaged",pages:["/dashboard"]},{id:"st5",name:"Purchase",emotion:"satisfied",pages:["/checkout"]}]},U=[{id:"nav",label:"Navigation Analysis"},{id:"paths",label:"Paths"},{id:"flows",label:"Userflows"},{id:"maps",label:"Journey Maps"}],A={curious:"#adc6ff",analytical:"#7c3aed",confident:"#4edea3",engaged:"#d2bbff",satisfied:"#ffcc6b",cautious:"#ffb4ab"},V=s=>s.split("/").filter(Boolean).pop()??s,G=s=>s>25?"#ffb4ab":s>15?"#ffcc6b":"#4edea3",Y=()=>{var o;const[s,n]=j.useState("nav"),[a,t]=j.useState(X),[l,h]=j.useState(W),p=j.useMemo(()=>Q(a),[a]),m=j.useMemo(()=>L(a),[a]),g=j.useMemo(()=>H(a),[a]),d=p.reduce((c,r)=>c+r.views,0),u=a.length,i=a.filter(c=>c.length===1).length;return e.jsxs(w,{title:"User Journey",subtitle:"One stream of page views feeds every view below.",actions:e.jsx("button",{className:"btn primary",onClick:()=>t(c=>[...c,...P(50,Math.random)]),children:"+ Simulate 50 sessions"}),children:[e.jsxs("div",{className:"stats",children:[e.jsx(b,{label:"Sessions",value:u.toLocaleString(),color:"#6366f1"}),e.jsx(b,{label:"Page views",value:d.toLocaleString(),color:"#0ea5e9"}),e.jsx(b,{label:"Bounce rate",value:`${u?(i/u*100).toFixed(1):0}%`,color:"#f59e0b"}),e.jsx(b,{label:"Top page",value:((o=p[0])==null?void 0:o.page)??"—",color:"#10b981"})]}),e.jsx(O,{items:U,value:s,onChange:n}),s==="nav"&&e.jsxs("table",{className:"table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Page"}),e.jsx("th",{children:"Views"}),e.jsx("th",{children:"Share"}),e.jsx("th",{children:"Bounce rate"}),e.jsx("th",{children:"Exit rate"})]})}),e.jsx("tbody",{children:p.map(c=>e.jsxs("tr",{children:[e.jsx("td",{className:"mono",children:c.page}),e.jsx("td",{className:"mono",children:c.views}),e.jsx("td",{style:{minWidth:120},children:e.jsx(N,{pct:c.views/d*100})}),e.jsxs("td",{className:"mono",style:{color:G(c.bounceRate)},children:[c.bounceRate.toFixed(1),"%"]}),e.jsxs("td",{className:"mono",children:[c.exitRate.toFixed(1),"%"]})]},c.page))})]}),s==="paths"&&e.jsx("div",{className:"grid",children:m.map((c,r)=>e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"row",children:[e.jsxs("span",{className:"pill passive",children:["#",r+1]}),e.jsx("span",{className:"grow"}),e.jsxs("span",{className:"mono small",children:[c.convRate.toFixed(1),"% reach signup"]})]}),e.jsx("div",{className:"steps",title:c.steps.join(" → "),children:c.steps.map((v,x)=>e.jsxs(j.Fragment,{children:[x>0&&e.jsx("span",{className:"muted",children:"→"}),e.jsx("span",{className:"chip static",children:V(v)})]},x))}),e.jsxs("div",{className:"small muted",children:[c.users," users"]}),e.jsx(N,{pct:c.convRate,color:"#10b981"})]},c.steps.join(">")))}),s==="flows"&&e.jsx("div",{className:"grid",children:g.map(c=>e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"row",children:[e.jsx("strong",{className:"mono",children:c.from}),e.jsx("span",{className:"grow"}),e.jsxs("span",{className:"small muted",children:[c.total," transitions"]})]}),c.destinations.slice(0,4).map(r=>e.jsxs("div",{children:[e.jsxs("div",{className:"row small",children:[e.jsxs("span",{className:"mono",children:["→ ",r.to]}),e.jsx("span",{className:"grow"}),e.jsxs("span",{className:"mono",children:[r.pct.toFixed(0),"%"]})]}),e.jsx(N,{pct:r.pct})]},r.to))]},c.from))}),s==="maps"&&e.jsx(z,{map:l,setMap:h,sessions:a})]})},z=({map:s,setMap:n,sessions:a})=>{const[t,l]=j.useState(""),[h,p]=j.useState("curious"),[m,g]=j.useState([]),[d,u]=j.useState(""),i=()=>{if(!t.trim())return u("Stage name is required.");if(m.length===0)return u("Pick at least one touchpoint page.");const o={id:y("st"),name:t.trim(),emotion:h,pages:m};n({...s,stages:[...s.stages,o]}),l(""),g([]),u("")};return e.jsxs("div",{className:"stack",children:[e.jsx("input",{className:"input",value:s.name,onChange:o=>n({...s,name:o.target.value}),"aria-label":"Journey name"}),e.jsxs("div",{className:"stages",children:[s.stages.map((o,c)=>{const r=J(a,o.pages),v=A[o.emotion]??"#7c3aed";return e.jsxs("div",{className:"card stage",children:[e.jsxs("div",{className:"row",children:[e.jsx("span",{className:"badge",style:{background:`${v}30`,color:v},children:c+1}),e.jsx("strong",{children:o.name}),e.jsx("span",{className:"grow"}),e.jsx("button",{className:"btn danger","aria-label":`Remove ${o.name}`,onClick:()=>n({...s,stages:s.stages.filter(x=>x.id!==o.id)}),children:"✕"})]}),o.pages.map(x=>e.jsxs("div",{className:"small mono muted",children:["✓ ",x]},x)),e.jsxs("div",{className:"small",style:{color:v},children:["Emotion: ",o.emotion]}),e.jsx(N,{pct:r}),e.jsxs("div",{className:"small mono muted",children:[r.toFixed(0),"% reach"]})]},o.id)}),s.stages.length===0&&e.jsx("div",{className:"muted",children:"No stages yet. Add one below."})]}),e.jsxs("div",{className:"card form",children:[e.jsx("strong",{children:"Add stage"}),e.jsxs("div",{className:"row",children:[e.jsx("input",{className:"input",placeholder:"Stage name",value:t,onChange:o=>l(o.target.value)}),e.jsx("select",{className:"input slim",value:h,onChange:o=>p(o.target.value),children:Object.keys(A).map(o=>e.jsx("option",{children:o},o))})]}),e.jsx("div",{className:"scale",children:D.map(o=>e.jsx("button",{type:"button",className:m.includes(o)?"chip active":"chip",onClick:()=>g(c=>c.includes(o)?c.filter(r=>r!==o):[...c,o]),children:o},o))}),e.jsxs("div",{className:"row",children:[e.jsx("span",{className:"grow"}),d&&e.jsx("span",{className:"error",children:d}),e.jsx("button",{className:"btn primary",onClick:i,children:"+ Add stage"})]})]})]})},C=s=>new Date(Date.UTC(2026,10,6)-s*864e5).toISOString(),K=[{id:"s1",name:"Q4 Product Satisfaction",description:"How do users feel about the product right now?",status:"active",target:100,createdAt:C(30),questions:[{id:"s1q1",type:"nps",text:"How likely are you to recommend us to a colleague?",required:!0},{id:"s1q2",type:"rating",text:"How satisfied are you with the product?",required:!0},{id:"s1q3",type:"multiple_choice",text:"Which feature do you use most?",required:!1,options:["Feature Flags","Experiments","Segments","Audit Log"]},{id:"s1q4",type:"open_text",text:"What is one thing we should improve?",required:!1}]},{id:"s2",name:"Onboarding Experience",description:"First-week feedback from new accounts.",status:"draft",target:50,createdAt:C(5),questions:[{id:"s2q1",type:"nps",text:"How likely are you to recommend our onboarding?",required:!0},{id:"s2q2",type:"open_text",text:"What was confusing?",required:!1}]}],T=["Love the rollout controls","Dashboards load slowly","Needs better docs","Great support","Too many clicks to create a flag"];function Z(){const s=E(7);return Array.from({length:36},(n,a)=>{const t=Math.min(10,Math.floor(s()*s()*4+s()*8+3));return{id:`r${a}`,surveyId:"s1",userId:`user_${100+a}`,createdAt:C(Math.floor(s()*28)),answers:[{questionId:"s1q1",value:t},{questionId:"s1q2",value:Math.max(1,Math.min(5,Math.round(t/2)))},{questionId:"s1q3",value:["Feature Flags","Experiments","Segments","Audit Log"][Math.floor(s()*4)]},{questionId:"s1q4",value:T[Math.floor(s()*T.length)]}]}})}const I=s=>s>=9?"promoter":s>=7?"passive":"detractor";function S(s){if(s.length===0)return null;const n=s.filter(t=>t>=9).length,a=s.filter(t=>t<=6).length;return{score:Math.round((n-a)/s.length*100),promoters:n,passives:s.length-n-a,detractors:a,total:s.length}}function k(s,n){const a=s.questions.find(t=>t.type==="nps");return a?n.filter(t=>t.surveyId===s.id).map(t=>{var l;return(l=t.answers.find(h=>h.questionId===a.id))==null?void 0:l.value}).filter(t=>typeof t=="number"):[]}const ee=["nps","rating","multiple_choice","open_text"],R=s=>new Date(s).toLocaleDateString(void 0,{day:"2-digit",month:"short",year:"numeric"}),se=()=>{const[s,n]=j.useState(K),[a,t]=j.useState(Z),[l,h]=j.useState({name:"list"}),p=i=>s.find(o=>o.id===i),m=()=>h({name:"list"});if(l.name==="create")return e.jsx(te,{onCancel:m,onSave:i=>{n(o=>[i,...o]),m()}});if(l.name==="take"){const i=p(l.id);return i?e.jsx(ae,{survey:i,onCancel:m,onSubmit:o=>{t(c=>[{id:y("r"),surveyId:i.id,userId:`user_${900+c.length}`,createdAt:new Date().toISOString(),answers:o},...c]),h({name:"results",id:i.id})}}):null}if(l.name==="results"){const i=p(l.id);return i?e.jsx(ne,{survey:i,responses:a.filter(o=>o.surveyId===i.id),onBack:m,onTake:()=>h({name:"take",id:i.id})}):null}const g=a.length,d=s.filter(i=>i.status==="active").length,u=S(s.flatMap(i=>k(i,a)));return e.jsxs(w,{title:"Surveys",subtitle:"Create, run and measure user surveys.",actions:e.jsx("button",{className:"btn primary",onClick:()=>h({name:"create"}),children:"+ Create Survey"}),children:[e.jsxs("div",{className:"stats",children:[e.jsx(b,{label:"Total surveys",value:s.length,color:"#6366f1"}),e.jsx(b,{label:"Active",value:d,color:"#10b981"}),e.jsx(b,{label:"Total responses",value:g}),e.jsx(b,{label:"Overall NPS",value:u?u.score:"—",color:"#f59e0b"})]}),e.jsxs("table",{className:"table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Survey"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Progress"}),e.jsx("th",{children:"NPS"}),e.jsx("th",{children:"Created"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:s.map(i=>{const o=a.filter(r=>r.surveyId===i.id).length,c=S(k(i,a));return e.jsxs("tr",{children:[e.jsxs("td",{children:[e.jsx("strong",{children:i.name}),e.jsxs("div",{className:"muted small",children:[i.questions.length," questions"]})]}),e.jsx("td",{children:e.jsx("select",{className:"input slim",value:i.status,onChange:r=>n(v=>v.map(x=>x.id===i.id?{...x,status:r.target.value}:x)),children:["draft","active","paused","closed"].map(r=>e.jsx("option",{children:r},r))})}),e.jsxs("td",{style:{minWidth:140},children:[e.jsxs("div",{className:"small mono",children:[o," / ",i.target]}),e.jsx(N,{pct:o/i.target*100})]}),e.jsx("td",{className:"mono",children:c?c.score:"—"}),e.jsx("td",{className:"muted small",children:R(i.createdAt)}),e.jsxs("td",{className:"right",children:[e.jsx("button",{className:"btn",onClick:()=>h({name:"results",id:i.id}),children:"Results"})," ",e.jsx("button",{className:"btn",disabled:i.status!=="active",title:i.status!=="active"?"Set status to active to collect answers":"",onClick:()=>h({name:"take",id:i.id}),children:"Take"})," ",e.jsx("button",{className:"btn danger",onClick:()=>{window.confirm(`Delete "${i.name}" and its responses?`)&&(n(r=>r.filter(v=>v.id!==i.id)),t(r=>r.filter(v=>v.surveyId!==i.id)))},children:"Delete"})]})]},i.id)})})]})]})},te=({onSave:s,onCancel:n})=>{const[a,t]=j.useState(""),[l,h]=j.useState(""),[p,m]=j.useState(100),[g,d]=j.useState([{id:y("q"),type:"nps",text:"How likely are you to recommend us?",required:!0}]),[u,i]=j.useState(""),o=(r,v)=>d(x=>x.map(f=>f.id===r?{...f,...v}:f)),c=()=>{if(!a.trim())return i("Survey name is required.");if(g.length===0)return i("Add at least one question.");if(g.some(r=>!r.text.trim()))return i("Every question needs text.");if(g.some(r=>r.type==="multiple_choice"&&(r.options??[]).filter(v=>v.trim()).length<2))return i("Multiple choice needs at least two options.");s({id:y("s"),name:a.trim(),description:l.trim(),status:"active",target:p,createdAt:new Date().toISOString(),questions:g.map(r=>({...r,text:r.text.trim(),options:r.type==="multiple_choice"?(r.options??[]).filter(v=>v.trim()):void 0}))})};return e.jsxs(w,{title:"Create Survey",subtitle:"Build a new survey.",actions:e.jsx("button",{className:"btn",onClick:n,children:"Back"}),children:[e.jsxs("div",{className:"card form",children:[e.jsxs("label",{children:["Name",e.jsx("input",{className:"input",value:a,onChange:r=>t(r.target.value),placeholder:"e.g. Q1 Product Satisfaction"})]}),e.jsxs("label",{children:["Description",e.jsx("input",{className:"input",value:l,onChange:r=>h(r.target.value)})]}),e.jsxs("label",{children:["Target responses",e.jsx("input",{className:"input narrow",type:"number",min:1,value:p,onChange:r=>m(Math.max(1,parseInt(r.target.value,10)||1))})]})]}),e.jsxs("h3",{children:["Questions (",g.length,")"]}),g.map((r,v)=>e.jsxs("div",{className:"card form",children:[e.jsxs("div",{className:"row",children:[e.jsxs("strong",{children:["Q",v+1]}),e.jsx("select",{className:"input slim",value:r.type,onChange:x=>o(r.id,{type:x.target.value,options:x.target.value==="multiple_choice"?["Option 1","Option 2"]:void 0}),children:ee.map(x=>e.jsx("option",{value:x,children:x.replace("_"," ")},x))}),e.jsxs("label",{className:"inline",children:[e.jsx("input",{type:"checkbox",checked:r.required,onChange:x=>o(r.id,{required:x.target.checked})})," required"]}),e.jsx("span",{className:"grow"}),e.jsx("button",{className:"btn danger",onClick:()=>d(x=>x.filter(f=>f.id!==r.id)),children:"Remove"})]}),e.jsx("input",{className:"input",value:r.text,onChange:x=>o(r.id,{text:x.target.value}),placeholder:"Enter your question…"}),r.type==="multiple_choice"&&e.jsxs("div",{className:"stack",children:[(r.options??[]).map((x,f)=>e.jsx("input",{className:"input slim",value:x,onChange:_=>o(r.id,{options:(r.options??[]).map(($,q)=>q===f?_.target.value:$)})},f)),e.jsx("button",{className:"btn",onClick:()=>o(r.id,{options:[...r.options??[],`Option ${(r.options??[]).length+1}`]}),children:"+ Add option"})]})]},r.id)),e.jsxs("div",{className:"row",children:[e.jsx("button",{className:"btn",onClick:()=>d(r=>[...r,{id:y("q"),type:"rating",text:"",required:!1}]),children:"+ Add question"}),e.jsx("span",{className:"grow"}),u&&e.jsx("span",{className:"error",children:u}),e.jsx("button",{className:"btn primary",onClick:c,children:"Create Survey"})]})]})},ae=({survey:s,onSubmit:n,onCancel:a})=>{const[t,l]=j.useState({}),[h,p]=j.useState(""),m=(d,u)=>l(i=>({...i,[d]:u})),g=()=>{const d=s.questions.find(u=>u.required&&(t[u.id]===void 0||t[u.id]===""));if(d)return p(`"${d.text}" is required.`);p(""),n(s.questions.filter(u=>t[u.id]!==void 0&&t[u.id]!=="").map(u=>({questionId:u.id,value:t[u.id]})))};return e.jsxs(w,{title:s.name,subtitle:s.description||"Answer the questions below.",actions:e.jsx("button",{className:"btn",onClick:a,children:"Cancel"}),children:[s.questions.map((d,u)=>e.jsxs("div",{className:"card form",children:[e.jsxs("strong",{children:[u+1,". ",d.text,d.required&&e.jsx("span",{className:"error",children:" *"})]}),d.type==="nps"&&e.jsx("div",{className:"scale",children:Array.from({length:11},(i,o)=>e.jsx("button",{className:t[d.id]===o?"chip active":"chip",onClick:()=>m(d.id,o),children:o},o))}),d.type==="rating"&&e.jsx("div",{className:"scale",children:[1,2,3,4,5].map(i=>e.jsxs("button",{className:t[d.id]===i?"chip active":"chip",onClick:()=>m(d.id,i),children:[i," ★"]},i))}),d.type==="multiple_choice"&&e.jsx("div",{className:"scale",children:(d.options??[]).map(i=>e.jsx("button",{className:t[d.id]===i?"chip active":"chip",onClick:()=>m(d.id,i),children:i},i))}),d.type==="open_text"&&e.jsx("textarea",{className:"input",rows:2,value:String(t[d.id]??""),onChange:i=>m(d.id,i.target.value)})]},d.id)),e.jsxs("div",{className:"row",children:[e.jsx("span",{className:"grow"}),h&&e.jsx("span",{className:"error",children:h}),e.jsx("button",{className:"btn primary",onClick:g,children:"Submit response"})]})]})},ne=({survey:s,responses:n,onBack:a,onTake:t})=>{const l=j.useMemo(()=>S(k(s,n)),[s,n]),h=s.questions.find(m=>m.type==="nps"),p=m=>l?Math.round(m/l.total*100):0;return e.jsxs(w,{title:s.name,subtitle:`${n.length} responses`,actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:a,children:"Back"}),e.jsx("button",{className:"btn primary",disabled:s.status!=="active",onClick:t,children:"Take survey"})]}),children:[e.jsxs("div",{className:"stats",children:[e.jsx(b,{label:"NPS",value:l?l.score:"—",color:"#f59e0b"}),e.jsx(b,{label:"Promoters",value:l?`${p(l.promoters)}%`:"—",color:"#4edea3"}),e.jsx(b,{label:"Passives",value:l?`${p(l.passives)}%`:"—",color:"#ffcc6b"}),e.jsx(b,{label:"Detractors",value:l?`${p(l.detractors)}%`:"—",color:"#ffb4ab"})]}),e.jsxs("table",{className:"table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"User"}),e.jsx("th",{children:"NPS"}),s.questions.filter(m=>m.type!=="nps").map(m=>e.jsx("th",{children:m.text},m.id)),e.jsx("th",{children:"Date"})]})}),e.jsxs("tbody",{children:[n.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:9,className:"muted",children:"No responses yet."})}),n.map(m=>{var d;const g=h?(d=m.answers.find(u=>u.questionId===h.id))==null?void 0:d.value:void 0;return e.jsxs("tr",{children:[e.jsx("td",{className:"mono",children:m.userId}),e.jsx("td",{children:typeof g=="number"?e.jsxs("span",{className:`pill ${I(g)}`,children:[g," · ",I(g)]}):"—"}),s.questions.filter(u=>u.type!=="nps").map(u=>{var i;return e.jsx("td",{children:String(((i=m.answers.find(o=>o.questionId===u.id))==null?void 0:i.value)??"—")},u.id)}),e.jsx("td",{className:"muted small",children:R(m.createdAt)})]},m.id)})]})]})]})};exports.JourneyApp=Y;exports.SurveyApp=se;exports.npsCategory=I;exports.npsOf=S;exports.npsScores=k;
|
package/dist/main.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|