rasp-feedback 1.0.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/LICENSE +21 -0
- package/README.md +85 -0
- package/dist/nextjs/components/RaspForm.d.ts +7 -0
- package/dist/nextjs/components/RaspForm.d.ts.map +1 -0
- package/dist/nextjs/components/RaspForm.js +105 -0
- package/dist/nextjs/components/RaspProvider.d.ts +11 -0
- package/dist/nextjs/components/RaspProvider.d.ts.map +1 -0
- package/dist/nextjs/components/RaspProvider.js +150 -0
- package/dist/nextjs/components/Skeleton.d.ts +7 -0
- package/dist/nextjs/components/Skeleton.d.ts.map +1 -0
- package/dist/nextjs/components/Skeleton.js +14 -0
- package/dist/nextjs/components/StaticFormComponent.d.ts +7 -0
- package/dist/nextjs/components/StaticFormComponent.d.ts.map +1 -0
- package/dist/nextjs/components/StaticFormComponent.js +89 -0
- package/dist/nextjs/constants/baserasplogo.d.ts +2 -0
- package/dist/nextjs/constants/baserasplogo.d.ts.map +1 -0
- package/dist/nextjs/constants/baserasplogo.js +1 -0
- package/dist/nextjs/constants/fontexp.d.ts +2 -0
- package/dist/nextjs/constants/fontexp.d.ts.map +1 -0
- package/dist/nextjs/constants/fontexp.js +51 -0
- package/dist/nextjs/constants/iconexp.d.ts +8 -0
- package/dist/nextjs/constants/iconexp.d.ts.map +1 -0
- package/dist/nextjs/constants/iconexp.js +19 -0
- package/dist/nextjs/functions/functionsexp.d.ts +5 -0
- package/dist/nextjs/functions/functionsexp.d.ts.map +1 -0
- package/dist/nextjs/functions/functionsexp.js +96 -0
- package/dist/nextjs/images/rasp_logo.png +0 -0
- package/dist/nextjs/index.css +49 -0
- package/dist/nextjs/index.d.ts +5 -0
- package/dist/nextjs/index.d.ts.map +1 -0
- package/dist/nextjs/index.js +3 -0
- package/dist/vue/components/RaspForm.vue.d.ts +11 -0
- package/dist/vue/components/RaspForm.vue.d.ts.map +1 -0
- package/dist/vue/components/RaspProvider.vue.d.ts +27 -0
- package/dist/vue/components/RaspProvider.vue.d.ts.map +1 -0
- package/dist/vue/components/Skeleton.vue.d.ts +10 -0
- package/dist/vue/components/Skeleton.vue.d.ts.map +1 -0
- package/dist/vue/components/StaticFormComponent.vue.d.ts +9 -0
- package/dist/vue/components/StaticFormComponent.vue.d.ts.map +1 -0
- package/dist/vue/constants/fontexp.d.ts +2 -0
- package/dist/vue/constants/fontexp.d.ts.map +1 -0
- package/dist/vue/constants/iconexp.d.ts +24 -0
- package/dist/vue/constants/iconexp.d.ts.map +1 -0
- package/dist/vue/functions/functionsexp.d.ts +5 -0
- package/dist/vue/functions/functionsexp.d.ts.map +1 -0
- package/dist/vue/images/rasp_logo.png +0 -0
- package/dist/vue/index.css +1 -0
- package/dist/vue/index.d.ts +5 -0
- package/dist/vue/index.d.ts.map +1 -0
- package/dist/vue/index.js +667 -0
- package/dist/vue/index.umd.cjs +1 -0
- package/package.json +73 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 MasterKlm
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Rasp
|
|
2
|
+
|
|
3
|
+
Official Rasp SDK to implement user feedback collection forms easily into your website.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
```bash
|
|
7
|
+
npm install rasp-feedback
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Next.js / React
|
|
14
|
+
```tsx
|
|
15
|
+
import { RaspProvider } from 'rasp-feedback/nextjs';
|
|
16
|
+
|
|
17
|
+
export default function App() {
|
|
18
|
+
return (
|
|
19
|
+
<RaspProvider launcherPosition={{ top: '90%', left: '95%' }}>
|
|
20
|
+
<YourApp />
|
|
21
|
+
</RaspProvider>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Vue 3
|
|
27
|
+
```vue
|
|
28
|
+
<script setup>
|
|
29
|
+
import { RaspProvider } from 'rasp-feedback/vue';
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<template>
|
|
33
|
+
<RaspProvider>
|
|
34
|
+
<YourApp />
|
|
35
|
+
</RaspProvider>
|
|
36
|
+
</template>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Environment Setup
|
|
40
|
+
|
|
41
|
+
Create a `.env` file:
|
|
42
|
+
```
|
|
43
|
+
# Next.js
|
|
44
|
+
NEXT_PUBLIC_RASP_COMPANY_ID=your_company_id
|
|
45
|
+
|
|
46
|
+
# Vue (Vite)
|
|
47
|
+
VITE_RASP_COMPANY_ID=your_company_id
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Documentation
|
|
51
|
+
|
|
52
|
+
Full documentation available at [https://tryrasp.online/docs](https://tryrasp.online/docs)
|
|
53
|
+
|
|
54
|
+
## License
|
|
55
|
+
|
|
56
|
+
MIT © Rabuuk (Pty) Ltd.
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Create `LICENSE`:
|
|
60
|
+
```
|
|
61
|
+
MIT License
|
|
62
|
+
|
|
63
|
+
Copyright (c) 2025 Rabuuk (Pty) Ltd.
|
|
64
|
+
|
|
65
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
66
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
67
|
+
in the Software without restriction, including without limitation the rights
|
|
68
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
69
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
70
|
+
furnished to do so, subject to the following conditions:
|
|
71
|
+
|
|
72
|
+
The above copyright notice and this permission notice shall be included in all
|
|
73
|
+
copies or substantial portions of the Software.
|
|
74
|
+
|
|
75
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
76
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
77
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
78
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
79
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
80
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
81
|
+
SOFTWARE.
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Create `.npmignore`:
|
|
85
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RaspForm.d.ts","sourceRoot":"","sources":["../../../src/nextjs/components/RaspForm.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAS3C,UAAU,KAAK;IACb,WAAW,CAAC,EAAE,aAAa,CAAC;CAC7B;AAED,wBAAgB,QAAQ,CAAC,EAAE,WAAW,EAAE,EAAE,KAAK,2CAwJ9C"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
'use client'; // Important for Next.js App Router
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
{ /*@ts-ignore*/ }
|
|
5
|
+
import { getFormByDomainOrCompany, getBrandTheme, getFormTheme } from '../functions/functionsexp';
|
|
6
|
+
import StaticFormComponent from './StaticFormComponent';
|
|
7
|
+
import Skeleton from './Skeleton';
|
|
8
|
+
import { fontMap } from '../constants/fontexp';
|
|
9
|
+
import { RASP_LOGO_BASE64 } from '../constants/baserasplogo';
|
|
10
|
+
export function RaspForm({ otherStyles }) {
|
|
11
|
+
const [companyId, setCompanyId] = useState(null);
|
|
12
|
+
const [currentUrl, setCurrentUrl] = useState('');
|
|
13
|
+
const [form, setForm] = useState(null);
|
|
14
|
+
const [fields, setFields] = useState(null);
|
|
15
|
+
const [mainTheme, setMainTheme] = useState(null);
|
|
16
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
17
|
+
const getForm = async () => {
|
|
18
|
+
const f = await getFormByDomainOrCompany(companyId, currentUrl);
|
|
19
|
+
if (!f) {
|
|
20
|
+
setForm(f);
|
|
21
|
+
setIsLoading(false);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
setForm(f[0]);
|
|
25
|
+
};
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (typeof window !== 'undefined') {
|
|
28
|
+
setCompanyId(process.env.NEXT_PUBLIC_RASP_COMPANY_ID);
|
|
29
|
+
setCurrentUrl(window.location.href);
|
|
30
|
+
}
|
|
31
|
+
}, []);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (companyId) {
|
|
34
|
+
if (form) {
|
|
35
|
+
setFields(form.fields);
|
|
36
|
+
if (form.usebrandtheme === true) {
|
|
37
|
+
getBrandTheme(companyId).then((brandTheme) => {
|
|
38
|
+
setMainTheme(brandTheme);
|
|
39
|
+
setIsLoading(false);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
if (form.usebrandtheme === false) {
|
|
43
|
+
getFormTheme(form.formId).then((formTheme) => {
|
|
44
|
+
setMainTheme(formTheme);
|
|
45
|
+
setIsLoading(false);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}, [form]);
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (currentUrl.trim()) {
|
|
53
|
+
if (companyId) {
|
|
54
|
+
getForm();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return (_jsxs("div", { children: [form && _jsx(_Fragment, { children: form.active && mainTheme && fields && _jsx("div", { id: "rasp-form-div", style: {
|
|
59
|
+
padding: 0,
|
|
60
|
+
margin: 0,
|
|
61
|
+
border: 0,
|
|
62
|
+
background: "transparent",
|
|
63
|
+
width: "auto",
|
|
64
|
+
height: "auto",
|
|
65
|
+
display: "inline-block",
|
|
66
|
+
transform: "translate(-50%, -25%)",
|
|
67
|
+
overflow: "visible",
|
|
68
|
+
...otherStyles
|
|
69
|
+
}, children: _jsx(StaticFormComponent, { form: form, mainTheme: mainTheme, fields: fields }) }) }), !isLoading && !form && _jsxs("div", { style: {
|
|
70
|
+
display: 'flex',
|
|
71
|
+
flexDirection: 'column',
|
|
72
|
+
alignItems: 'center',
|
|
73
|
+
borderRadius: '0.75rem',
|
|
74
|
+
backgroundColor: 'white',
|
|
75
|
+
margin: '1.25rem',
|
|
76
|
+
width: '470px',
|
|
77
|
+
minHeight: '400px',
|
|
78
|
+
border: '1px solid black',
|
|
79
|
+
padding: '1rem',
|
|
80
|
+
boxShadow: '0 1px 3px 0 rgba(0, 0, 0, 1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)'
|
|
81
|
+
}, children: [_jsx("br", {}), _jsx("br", {}), _jsx("img", { src: RASP_LOGO_BASE64, width: "150px", height: "150px", alt: "rasp logo" }), _jsx("h1", { className: `${fontMap.poppins.className}`, children: "404" }), _jsx("h2", { className: `${fontMap.wixmadefor.className}`, style: { textAlign: 'center' }, children: !companyId ? "CompanyId is not provided. Please provide companyId in your env file." : "No forms found for this URL." }), !companyId && _jsxs("p", { className: `${fontMap.wixmadefor.className}`, style: { textAlign: 'center' }, children: [" Refer to Rasp docs for help: ", _jsx("a", { href: 'https://tryrasp.online/docs', style: { textDecoration: "underline" }, children: "https://tryrasp.online/docs" })] }), companyId && _jsxs("p", { className: `${fontMap.wixmadefor.className}`, style: { textAlign: 'center' }, children: [" Set this as your form domain url: ", currentUrl] })] }), isLoading &&
|
|
82
|
+
_jsx("div", { id: "rasp-form-div", style: {
|
|
83
|
+
padding: 0,
|
|
84
|
+
margin: 0,
|
|
85
|
+
border: 0,
|
|
86
|
+
background: "transparent",
|
|
87
|
+
width: "auto",
|
|
88
|
+
height: "auto",
|
|
89
|
+
display: "inline-block",
|
|
90
|
+
transform: "translate(-50%, -25%)",
|
|
91
|
+
overflow: "visible",
|
|
92
|
+
}, children: _jsx("div", { style: {
|
|
93
|
+
display: 'flex',
|
|
94
|
+
flexDirection: "column",
|
|
95
|
+
justifyContent: 'center',
|
|
96
|
+
borderRadius: '0.75rem',
|
|
97
|
+
backgroundColor: "white",
|
|
98
|
+
margin: '1.25rem',
|
|
99
|
+
width: '470px',
|
|
100
|
+
minHeight: '400px',
|
|
101
|
+
border: '1px solid whitesmoke',
|
|
102
|
+
padding: '2rem',
|
|
103
|
+
paddingTop: "0px"
|
|
104
|
+
}, children: _jsxs("div", { style: { marginTop: "-30px" }, children: [_jsx(Skeleton, { width: 400, height: 40 }), _jsx(Skeleton, { width: 400, height: 30 }), _jsx("br", {}), _jsx(Skeleton, { width: 400, height: 70 }), _jsx(Skeleton, { width: 400, height: 100 })] }) }) })] }));
|
|
105
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import "../index.css";
|
|
3
|
+
export interface RaspProviderProps {
|
|
4
|
+
launcherPosition?: {
|
|
5
|
+
top?: string;
|
|
6
|
+
left?: string;
|
|
7
|
+
};
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
export declare const RaspProvider: React.FC<RaspProviderProps>;
|
|
11
|
+
//# sourceMappingURL=RaspProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RaspProvider.d.ts","sourceRoot":"","sources":["../../../src/nextjs/components/RaspProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAKlD,OAAO,cAAc,CAAA;AAMrB,MAAM,WAAW,iBAAiB;IAChC,gBAAgB,CAAC,EAAC;QAChB,GAAG,CAAC,EAAC,MAAM,CAAC;QACZ,IAAI,CAAC,EAAC,MAAM,CAAA;KACb,CAAA;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAGD,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA2MpD,CAAA"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
'use client'; // Important for Next.js App Router
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
{ /*@ts-ignore*/ }
|
|
5
|
+
import { getFormByDomainOrCompany, getBrandTheme, getFormTheme } from '../functions/functionsexp';
|
|
6
|
+
import { MessageSquare } from 'lucide-react';
|
|
7
|
+
import "../index.css";
|
|
8
|
+
import StaticFormComponent from './StaticFormComponent';
|
|
9
|
+
import Skeleton from './Skeleton';
|
|
10
|
+
import { fontMap } from '../constants/fontexp';
|
|
11
|
+
import { RASP_LOGO_BASE64 } from '../constants/baserasplogo';
|
|
12
|
+
export const RaspProvider = ({ children, launcherPosition }) => {
|
|
13
|
+
const [companyId, setCompanyId] = useState(null);
|
|
14
|
+
const [currentUrl, setCurrentUrl] = useState('');
|
|
15
|
+
const [form, setForm] = useState(null);
|
|
16
|
+
const [fields, setFields] = useState(null);
|
|
17
|
+
const [mainTheme, setMainTheme] = useState(null);
|
|
18
|
+
const [showForm, setShowForm] = useState(false);
|
|
19
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
20
|
+
const [showFormSkeleton, setShowFormSkeleton] = useState(false);
|
|
21
|
+
const getForm = async () => {
|
|
22
|
+
setIsLoading(true);
|
|
23
|
+
const f = await getFormByDomainOrCompany(companyId, currentUrl);
|
|
24
|
+
if (!f) {
|
|
25
|
+
setForm(f);
|
|
26
|
+
setIsLoading(false);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
setForm(f[0]);
|
|
30
|
+
};
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (typeof window !== 'undefined') {
|
|
33
|
+
setCompanyId(process.env.NEXT_PUBLIC_RASP_COMPANY_ID);
|
|
34
|
+
setCurrentUrl(window.location.href);
|
|
35
|
+
}
|
|
36
|
+
}, []);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (companyId) {
|
|
39
|
+
if (form) {
|
|
40
|
+
setFields(form.fields);
|
|
41
|
+
if (form.usebrandtheme === true) {
|
|
42
|
+
getBrandTheme(companyId).then((brandTheme) => {
|
|
43
|
+
setMainTheme(brandTheme);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
if (form.usebrandtheme === false) {
|
|
47
|
+
getFormTheme(form.formId).then((formTheme) => {
|
|
48
|
+
setMainTheme(formTheme);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}, [form]);
|
|
54
|
+
return (_jsxs("div", { children: [children, form && _jsx(_Fragment, { children: showForm && form.active && mainTheme && fields && _jsx("div", { id: "rasp-form-div", style: {
|
|
55
|
+
position: "fixed",
|
|
56
|
+
top: "15%",
|
|
57
|
+
left: "60%",
|
|
58
|
+
zIndex: 1000000000000000,
|
|
59
|
+
padding: 0,
|
|
60
|
+
margin: 0,
|
|
61
|
+
border: 0,
|
|
62
|
+
background: "transparent",
|
|
63
|
+
width: "auto",
|
|
64
|
+
height: "auto",
|
|
65
|
+
display: "inline-block",
|
|
66
|
+
transform: "translate(-50%, -25%)",
|
|
67
|
+
overflow: "visible"
|
|
68
|
+
}, children: _jsx(StaticFormComponent, { form: form, mainTheme: mainTheme, fields: fields }) }) }), !isLoading && !form && _jsxs("div", { style: {
|
|
69
|
+
position: "fixed",
|
|
70
|
+
top: "19%",
|
|
71
|
+
left: "60%",
|
|
72
|
+
zIndex: 1000000000000000,
|
|
73
|
+
display: 'flex',
|
|
74
|
+
flexDirection: 'column',
|
|
75
|
+
alignItems: 'center',
|
|
76
|
+
borderRadius: '0.75rem',
|
|
77
|
+
backgroundColor: 'white',
|
|
78
|
+
margin: '1.25rem',
|
|
79
|
+
width: '470px',
|
|
80
|
+
minHeight: '400px',
|
|
81
|
+
border: '1px solid black',
|
|
82
|
+
padding: '1rem',
|
|
83
|
+
boxShadow: '0 1px 3px 0 rgba(0, 0, 0, 1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)'
|
|
84
|
+
}, children: [_jsx("br", {}), _jsx("br", {}), _jsx("img", { src: RASP_LOGO_BASE64, width: "150px", height: "150px", alt: "rasp logo" }), _jsx("h1", { className: `${fontMap.poppins.className}`, children: "404" }), _jsx("h2", { className: `${fontMap.wixmadefor.className}`, style: { textAlign: 'center' }, children: !companyId ? "CompanyId is not provided. Please provide companyId in your env file." : "No forms found for this URL." }), !companyId && _jsxs("p", { className: `${fontMap.wixmadefor.className}`, style: { textAlign: 'center' }, children: [" Refer to Rasp docs for help: ", _jsx("a", { href: 'https://tryrasp.online/docs', style: { textDecoration: "underline" }, children: "https://tryrasp.online/docs" })] }), companyId && _jsxs("p", { className: `${fontMap.wixmadefor.className}`, style: { textAlign: 'center' }, children: [" Set this as your form domain url: ", currentUrl] })] }), isLoading && showFormSkeleton && !form && !mainTheme &&
|
|
85
|
+
_jsx("div", { id: "rasp-form-div", style: {
|
|
86
|
+
position: "fixed",
|
|
87
|
+
top: "18%",
|
|
88
|
+
left: "60%",
|
|
89
|
+
zIndex: 1000000000000000,
|
|
90
|
+
padding: 0,
|
|
91
|
+
margin: 0,
|
|
92
|
+
border: 0,
|
|
93
|
+
background: "transparent",
|
|
94
|
+
width: "auto",
|
|
95
|
+
height: "auto",
|
|
96
|
+
display: "inline-block",
|
|
97
|
+
transform: "translate(-50%, -25%)",
|
|
98
|
+
overflow: "visible"
|
|
99
|
+
}, children: _jsx("div", { style: {
|
|
100
|
+
display: 'flex',
|
|
101
|
+
flexDirection: "column",
|
|
102
|
+
justifyContent: 'center',
|
|
103
|
+
borderRadius: '0.75rem',
|
|
104
|
+
backgroundColor: "white",
|
|
105
|
+
margin: '1.25rem',
|
|
106
|
+
width: '470px',
|
|
107
|
+
minHeight: '400px',
|
|
108
|
+
border: '1px solid whitesmoke',
|
|
109
|
+
padding: '2rem',
|
|
110
|
+
paddingTop: "0px"
|
|
111
|
+
}, children: _jsxs("div", { style: { marginTop: "-30px" }, children: [_jsx(Skeleton, { width: 400, height: 40 }), _jsx(Skeleton, { width: 400, height: 30 }), _jsx("br", {}), _jsx(Skeleton, { width: 400, height: 70 }), _jsx(Skeleton, { width: 400, height: 100 })] }) }) }), _jsx("div", { id: "rasp-launcher", onClick: () => {
|
|
112
|
+
if (!currentUrl.trim() || !companyId)
|
|
113
|
+
return;
|
|
114
|
+
// If the form is visible, play exit animation then hide
|
|
115
|
+
if (showForm) {
|
|
116
|
+
const el = document.getElementById('rasp-form-div');
|
|
117
|
+
if (el) {
|
|
118
|
+
el.classList.add('rasp-exit');
|
|
119
|
+
// match animation duration (250ms) + small buffer
|
|
120
|
+
setTimeout(() => {
|
|
121
|
+
setShowForm(false);
|
|
122
|
+
el.classList.remove('rasp-exit');
|
|
123
|
+
}, 300);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
// fallback: just hide
|
|
127
|
+
setShowForm(false);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
setIsLoading(true);
|
|
131
|
+
setShowFormSkeleton(true);
|
|
132
|
+
// If the form is not visible, fetch then show it
|
|
133
|
+
getForm().then(() => {
|
|
134
|
+
setShowForm(true);
|
|
135
|
+
setIsLoading(false);
|
|
136
|
+
setShowFormSkeleton(false);
|
|
137
|
+
});
|
|
138
|
+
}, style: {
|
|
139
|
+
backgroundColor: "white",
|
|
140
|
+
padding: 15,
|
|
141
|
+
borderWidth: 1,
|
|
142
|
+
borderColor: "black",
|
|
143
|
+
borderRadius: "100%",
|
|
144
|
+
position: "fixed",
|
|
145
|
+
zIndex: 1000000000000000,
|
|
146
|
+
cursor: "pointer",
|
|
147
|
+
top: launcherPosition ? launcherPosition.top : "90%",
|
|
148
|
+
left: launcherPosition ? launcherPosition.left : "95%"
|
|
149
|
+
}, children: _jsx(MessageSquare, { color: 'black', size: 20 }) })] }));
|
|
150
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Skeleton.d.ts","sourceRoot":"","sources":["../../../src/nextjs/components/Skeleton.tsx"],"names":[],"mappings":"AACA,OAAO,cAAc,CAAA;AAErB,iBAAS,QAAQ,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,2CAcrE;AAED,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import "../index.css";
|
|
3
|
+
function Skeleton({ width, height }) {
|
|
4
|
+
return (_jsx("div", { style: {
|
|
5
|
+
width: width + 'px',
|
|
6
|
+
height: height + 'px',
|
|
7
|
+
borderRadius: '10px',
|
|
8
|
+
marginTop: '5px',
|
|
9
|
+
background: 'linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 37%, #f0f0f0 63%)',
|
|
10
|
+
backgroundSize: '400% 100%',
|
|
11
|
+
animation: 'skeleton-loading 1.4s ease infinite',
|
|
12
|
+
} }));
|
|
13
|
+
}
|
|
14
|
+
export default Skeleton;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StaticFormComponent.d.ts","sourceRoot":"","sources":["../../../src/nextjs/components/StaticFormComponent.tsx"],"names":[],"mappings":"AAMA,iBAAS,mBAAmB,CAAC,EAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAC,EAAC;IAAG,IAAI,EAAE,GAAG,CAAC;IAClE,SAAS,EAAE,GAAG,CAAC;IACf,MAAM,EAAE,GAAG,EAAE,CAAC;CAAC,2CA0LhB;AAED,eAAe,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { iconMap } from '../constants/iconexp';
|
|
4
|
+
import { fontMap } from '../constants/fontexp';
|
|
5
|
+
import { addFeedback } from '../functions/functionsexp';
|
|
6
|
+
function StaticFormComponent({ form, mainTheme, fields }) {
|
|
7
|
+
const [responses, setResponses] = useState(() => form.fieldsResponseObj.map((field) => ({
|
|
8
|
+
...field,
|
|
9
|
+
response: ""
|
|
10
|
+
})));
|
|
11
|
+
const [submitted, setSubmitted] = useState(false);
|
|
12
|
+
const formContainerId = 'form-container-' + Math.random().toString(36).substr(2, 9);
|
|
13
|
+
const successContainerId = 'success-container-' + Math.random().toString(36).substr(2, 9);
|
|
14
|
+
const updateResponse = (index, value) => {
|
|
15
|
+
setResponses((prev) => {
|
|
16
|
+
const updated = [...prev];
|
|
17
|
+
updated[index] = { ...updated[index], response: value };
|
|
18
|
+
return updated;
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
const handleSubmit = async (e) => {
|
|
22
|
+
e.preventDefault();
|
|
23
|
+
try {
|
|
24
|
+
await addFeedback(form.companyId, form.formId, responses);
|
|
25
|
+
// Clear fields
|
|
26
|
+
setResponses(form.fieldsResponseObj.map((field) => ({
|
|
27
|
+
...field,
|
|
28
|
+
response: ""
|
|
29
|
+
})));
|
|
30
|
+
// Show success UI
|
|
31
|
+
setSubmitted(true);
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
console.error('Error submitting feedback:', error);
|
|
35
|
+
alert('Failed to submit feedback. Please try again.');
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
return (_jsx(_Fragment, { children: mainTheme && mainTheme.data && _jsx("div", { style: {
|
|
39
|
+
display: 'flex',
|
|
40
|
+
justifyContent: 'center',
|
|
41
|
+
borderRadius: '0.75rem',
|
|
42
|
+
backgroundColor: mainTheme.data.background,
|
|
43
|
+
margin: '1.25rem',
|
|
44
|
+
width: '470px',
|
|
45
|
+
minHeight: '400px',
|
|
46
|
+
border: '1px solid black',
|
|
47
|
+
padding: '1rem',
|
|
48
|
+
boxShadow: '0 1px 3px 0 rgba(0, 0, 0, 1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)'
|
|
49
|
+
}, children: form && _jsxs(_Fragment, { children: [!submitted && _jsxs("form", { onSubmit: handleSubmit, id: formContainerId, style: { display: 'flex', flexDirection: 'column', alignItems: 'center', width: '100%' }, children: [_jsx("h2", { className: fontMap[form.design.title.fontId].className, style: { marginTop: '1rem', fontSize: form.design.title.size + "px", textAlign: 'center', color: mainTheme.data.text.title }, children: form.title }), _jsx("p", { className: fontMap[form.design.subtitle.fontId].className, style: { marginTop: '1rem', fontSize: form.design.subtitle.size + "px", textAlign: 'center', color: mainTheme.data.text.subtitle }, children: form.subtitle }), _jsx("br", {}), fields.map((field, index) => {
|
|
50
|
+
if (field._type === 'input') {
|
|
51
|
+
return (_jsx("input", { required: true, value: responses[index]?.response || "", placeholder: field.placeholder, className: fontMap.wixmadefor.className, onChange: (e) => updateResponse(index, e.target.value), style: {
|
|
52
|
+
width: "100%",
|
|
53
|
+
padding: 10,
|
|
54
|
+
borderColor: mainTheme.data.text.title,
|
|
55
|
+
borderWidth: 1,
|
|
56
|
+
marginTop: '5px',
|
|
57
|
+
borderRadius: 10,
|
|
58
|
+
color: mainTheme.data.text.title
|
|
59
|
+
} }, index));
|
|
60
|
+
}
|
|
61
|
+
if (field._type === "rating") {
|
|
62
|
+
const currentRating = parseInt(responses[index]?.response || 0);
|
|
63
|
+
return (_jsx("div", { style: { display: "flex", gap: "10px", marginTop: "10px" }, children: [1, 2, 3, 4, 5].map((num) => (_jsx("div", { style: { cursor: "pointer" }, onClick: () => updateResponse(index, String(num)), children: currentRating >= num ? iconMap.starActive : iconMap.starUnactive }, num))) }, index));
|
|
64
|
+
}
|
|
65
|
+
if (field._type === 'textarea') {
|
|
66
|
+
return (_jsx("textarea", { required: true, className: fontMap.wixmadefor.className, value: responses[index]?.response || "", placeholder: field.placeholder, onChange: (e) => updateResponse(index, e.target.value), style: {
|
|
67
|
+
height: '7.5rem',
|
|
68
|
+
marginTop: '5px',
|
|
69
|
+
borderWidth: 1,
|
|
70
|
+
borderColor: mainTheme.data.text.title,
|
|
71
|
+
padding: 10,
|
|
72
|
+
borderRadius: 10,
|
|
73
|
+
width: "100%",
|
|
74
|
+
color: mainTheme.data.text.title
|
|
75
|
+
} }, index));
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}), _jsx("br", {}), _jsx("button", { type: "submit", className: fontMap.poppins.className, style: {
|
|
79
|
+
padding: "15px",
|
|
80
|
+
borderRadius: "15px",
|
|
81
|
+
backgroundColor: mainTheme.data.highlight,
|
|
82
|
+
color: "white",
|
|
83
|
+
width: "40%",
|
|
84
|
+
fontSize: "13px",
|
|
85
|
+
cursor: "pointer",
|
|
86
|
+
border: "none"
|
|
87
|
+
}, children: "Send Feedback" })] }), submitted && _jsxs("div", { id: successContainerId, style: { display: "flex", flexDirection: 'column', alignItems: 'center', width: '100%' }, children: [_jsx("br", {}), _jsx("br", {}), _jsx("br", {}), form.success_icon && iconMap[form.success_icon] ? iconMap[form.success_icon] : iconMap.circleCheckBig, _jsx("h2", { className: fontMap[form.success_heading_font].className, style: { marginTop: '1rem', fontSize: form.design.title.size + "px", color: mainTheme.data.text.title }, children: form.success_heading }), _jsx("p", { className: fontMap[form.success_message_font].className, style: { marginTop: '1rem', fontSize: '0.875rem', textAlign: 'center', color: mainTheme.data.text.subtitle }, children: form.success_message })] })] }) }) }));
|
|
88
|
+
}
|
|
89
|
+
export default StaticFormComponent;
|