@shiva004/surveys 0.1.7 → 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 +2 -0
- 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 +11 -0
- package/dist/index.js +1178 -0
- package/dist/journey/JourneyApp.d.ts +2 -0
- package/dist/journey/analytics.d.ts +29 -0
- package/dist/style.css +1 -0
- package/dist/survey/SurveyApp.d.ts +2 -0
- package/dist/survey/data.d.ts +3 -0
- package/dist/survey/nps.d.ts +12 -0
- package/dist/types.d.ts +40 -0
- package/dist/ui.d.ts +26 -0
- package/package.json +20 -9
- package/dist/assets/index-BPe2owrS.js +0 -40
- package/dist/assets/index-Chkvn1aI.css +0 -1
- package/dist/index.html +0 -13
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { JourneyMap } from '../types';
|
|
2
|
+
export declare const PAGES: string[];
|
|
3
|
+
/** Simulated sessions: each session is the ordered list of pages one visitor saw. */
|
|
4
|
+
export declare function simulate(count: number, rand: () => number): string[][];
|
|
5
|
+
export declare const initialSessions: () => string[][];
|
|
6
|
+
export interface NavRow {
|
|
7
|
+
page: string;
|
|
8
|
+
views: number;
|
|
9
|
+
bounceRate: number;
|
|
10
|
+
exitRate: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function navigationStats(sessions: string[][]): NavRow[];
|
|
13
|
+
export interface PathRow {
|
|
14
|
+
steps: string[];
|
|
15
|
+
users: number;
|
|
16
|
+
convRate: number;
|
|
17
|
+
}
|
|
18
|
+
export declare function pathStats(sessions: string[][], top?: number): PathRow[];
|
|
19
|
+
export interface FlowRow {
|
|
20
|
+
from: string;
|
|
21
|
+
total: number;
|
|
22
|
+
destinations: {
|
|
23
|
+
to: string;
|
|
24
|
+
pct: number;
|
|
25
|
+
}[];
|
|
26
|
+
}
|
|
27
|
+
export declare function flowStats(sessions: string[][]): FlowRow[];
|
|
28
|
+
export declare const stageReach: (sessions: string[][], pages: string[]) => number;
|
|
29
|
+
export declare const defaultMap: JourneyMap;
|
package/dist/style.css
ADDED
|
@@ -0,0 +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}.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}}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Survey, SurveyResponse } from '../types';
|
|
2
|
+
export type NpsCategory = 'promoter' | 'passive' | 'detractor';
|
|
3
|
+
export declare const npsCategory: (s: number) => NpsCategory;
|
|
4
|
+
/** NPS = % promoters (9-10) minus % detractors (0-6). Passives (7-8) only count in the total. */
|
|
5
|
+
export declare function npsOf(scores: number[]): {
|
|
6
|
+
score: number;
|
|
7
|
+
promoters: number;
|
|
8
|
+
passives: number;
|
|
9
|
+
detractors: number;
|
|
10
|
+
total: number;
|
|
11
|
+
} | null;
|
|
12
|
+
export declare function npsScores(survey: Survey, responses: SurveyResponse[]): number[];
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export type QType = 'nps' | 'rating' | 'multiple_choice' | 'open_text';
|
|
2
|
+
export type SurveyStatus = 'draft' | 'active' | 'paused' | 'closed';
|
|
3
|
+
export interface Question {
|
|
4
|
+
id: string;
|
|
5
|
+
type: QType;
|
|
6
|
+
text: string;
|
|
7
|
+
required: boolean;
|
|
8
|
+
options?: string[];
|
|
9
|
+
}
|
|
10
|
+
export interface Survey {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
status: SurveyStatus;
|
|
15
|
+
target: number;
|
|
16
|
+
createdAt: string;
|
|
17
|
+
questions: Question[];
|
|
18
|
+
}
|
|
19
|
+
export interface Answer {
|
|
20
|
+
questionId: string;
|
|
21
|
+
value: string | number;
|
|
22
|
+
}
|
|
23
|
+
export interface SurveyResponse {
|
|
24
|
+
id: string;
|
|
25
|
+
surveyId: string;
|
|
26
|
+
userId: string;
|
|
27
|
+
createdAt: string;
|
|
28
|
+
answers: Answer[];
|
|
29
|
+
}
|
|
30
|
+
export interface Stage {
|
|
31
|
+
id: string;
|
|
32
|
+
name: string;
|
|
33
|
+
emotion: string;
|
|
34
|
+
pages: string[];
|
|
35
|
+
}
|
|
36
|
+
export interface JourneyMap {
|
|
37
|
+
id: string;
|
|
38
|
+
name: string;
|
|
39
|
+
stages: Stage[];
|
|
40
|
+
}
|
package/dist/ui.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const Stat: React.FC<{
|
|
3
|
+
label: string;
|
|
4
|
+
value: string | number;
|
|
5
|
+
color?: string;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const Tabs: React.FC<{
|
|
8
|
+
items: {
|
|
9
|
+
id: string;
|
|
10
|
+
label: string;
|
|
11
|
+
}[];
|
|
12
|
+
value: string;
|
|
13
|
+
onChange: (id: string) => void;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const Bar: React.FC<{
|
|
16
|
+
pct: number;
|
|
17
|
+
color?: string;
|
|
18
|
+
}>;
|
|
19
|
+
export declare const Page: React.FC<{
|
|
20
|
+
title: string;
|
|
21
|
+
subtitle?: string;
|
|
22
|
+
actions?: React.ReactNode;
|
|
23
|
+
children: React.ReactNode;
|
|
24
|
+
}>;
|
|
25
|
+
export declare const rng: (seed: number) => () => number;
|
|
26
|
+
export declare const uid: (p: string) => string;
|
package/package.json
CHANGED
|
@@ -1,23 +1,34 @@
|
|
|
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
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./style.css": "./dist/style.css"
|
|
15
|
+
},
|
|
16
|
+
"files": ["dist"],
|
|
17
|
+
"sideEffects": ["**/*.css"],
|
|
8
18
|
"scripts": {
|
|
9
19
|
"dev": "vite",
|
|
10
|
-
"build": "
|
|
11
|
-
"
|
|
20
|
+
"build": "vite build && tsc -p tsconfig.build.json",
|
|
21
|
+
"prepublishOnly": "npm run build"
|
|
12
22
|
},
|
|
13
|
-
"
|
|
14
|
-
"react": "
|
|
15
|
-
"react-dom": "^18.3.1"
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"react": ">=18"
|
|
16
25
|
},
|
|
17
26
|
"devDependencies": {
|
|
18
27
|
"@types/react": "^18.3.3",
|
|
19
28
|
"@types/react-dom": "^18.3.0",
|
|
20
29
|
"@vitejs/plugin-react": "^4.3.1",
|
|
30
|
+
"react": "^18.3.1",
|
|
31
|
+
"react-dom": "^18.3.1",
|
|
21
32
|
"typescript": "^5.5.4",
|
|
22
33
|
"vite": "^5.4.2"
|
|
23
34
|
}
|