rasp-feedback 1.0.7 → 1.0.8

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 (34) hide show
  1. package/dist/nextjs/components/PostItem.d.ts.map +1 -1
  2. package/dist/nextjs/components/PostItem.js +38 -40
  3. package/dist/nextjs/components/RaspForm.d.ts +2 -2
  4. package/dist/nextjs/components/RaspForm.d.ts.map +1 -1
  5. package/dist/nextjs/components/RaspForm.js +33 -56
  6. package/dist/nextjs/components/RaspProvider.d.ts.map +1 -1
  7. package/dist/nextjs/components/RaspProvider.js +230 -323
  8. package/dist/nextjs/components/StaticFormComponent.d.ts +4 -1
  9. package/dist/nextjs/components/StaticFormComponent.d.ts.map +1 -1
  10. package/dist/nextjs/components/StaticFormComponent.js +212 -84
  11. package/dist/nextjs/constants/baserasplauncher.d.ts +2 -0
  12. package/dist/nextjs/constants/baserasplauncher.d.ts.map +1 -0
  13. package/dist/nextjs/constants/baserasplauncher.js +1 -0
  14. package/dist/nextjs/constants/iconexp.js +3 -3
  15. package/dist/nextjs/functions/functionsexp.d.ts +72 -0
  16. package/dist/nextjs/functions/functionsexp.d.ts.map +1 -1
  17. package/dist/nextjs/functions/functionsexp.js +238 -32
  18. package/dist/vue/components/PostItem.vue.d.ts +17 -10
  19. package/dist/vue/components/PostItem.vue.d.ts.map +1 -1
  20. package/dist/vue/components/RaspForm.vue.d.ts.map +1 -1
  21. package/dist/vue/components/RaspProvider.vue.d.ts.map +1 -1
  22. package/dist/vue/components/Skeleton.vue.d.ts.map +1 -1
  23. package/dist/vue/components/StaticFormComponent.vue.d.ts +3 -3
  24. package/dist/vue/components/StaticFormComponent.vue.d.ts.map +1 -1
  25. package/dist/vue/index.js +636 -793
  26. package/dist/vue/index.umd.cjs +1 -1
  27. package/package.json +4 -27
  28. package/dist/nextjs/components/MainViewHandler.d.ts +0 -10
  29. package/dist/nextjs/components/MainViewHandler.d.ts.map +0 -1
  30. package/dist/nextjs/components/MainViewHandler.js +0 -17
  31. package/dist/nextjs/components/Posttem.d.ts +0 -7
  32. package/dist/nextjs/components/Posttem.d.ts.map +0 -1
  33. package/dist/nextjs/components/Posttem.js +0 -14
  34. package/dist/vue/index.css +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"PostItem.d.ts","sourceRoot":"","sources":["../../../src/nextjs/components/PostItem.tsx"],"names":[],"mappings":"AAIA,iBAAS,QAAQ,CAAC,EAAC,IAAI,EAAE,aAAa,EAAE,cAAc,EAAC,EAAC;IACpD,IAAI,EAAC,GAAG,CAAC;IACT,aAAa,EAAC,GAAG,CAAC;IAClB,cAAc,EAAC,GAAG,CAAC;CAEtB,2CAoEA;AAED,eAAe,QAAQ,CAAA"}
1
+ {"version":3,"file":"PostItem.d.ts","sourceRoot":"","sources":["../../../src/nextjs/components/PostItem.tsx"],"names":[],"mappings":"AAKA,iBAAS,QAAQ,CAAC,EAAC,IAAI,EAAE,aAAa,EAAE,cAAc,EAAC,EAAC;IACpD,IAAI,EAAC,GAAG,CAAC;IACT,aAAa,EAAC,GAAG,CAAC;IAClB,cAAc,EAAC,GAAG,CAAC;CAEtB,2CA6DA;AAED,eAAe,QAAQ,CAAA"}
@@ -1,56 +1,54 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useEffect, useState } from 'react';
2
+ import { useState, useEffect } from 'react';
3
3
  import { fontMap } from '../constants/fontexp';
4
- import { CircleArrowDown, CircleArrowUp } from 'lucide-react';
4
+ import { CircleArrowUp } from 'lucide-react';
5
+ import { motion } from 'framer-motion';
5
6
  function PostItem({ post, setShowVoteUI, setCurrentPost }) {
6
- const [isMobile, setIsMobile] = useState(false);
7
+ const [hasUpvoted, setHasUpvoted] = useState(false);
7
8
  useEffect(() => {
8
- if (typeof window === 'undefined')
9
- return;
10
- const checkMobile = () => {
11
- setIsMobile(window.innerWidth <= 768);
12
- };
13
- checkMobile();
14
- window.addEventListener('resize', checkMobile);
15
- return () => window.removeEventListener('resize', checkMobile);
16
- }, []);
17
- return (_jsxs("div", { onClick: () => {
9
+ // Check if user has upvoted this post
10
+ const voteKey = `voted_${post._id}`;
11
+ const voteStatus = localStorage.getItem(voteKey);
12
+ setHasUpvoted(voteStatus === 'up');
13
+ }, [post._id]);
14
+ const purpleColor = '#9e54df';
15
+ const backgroundColor = hasUpvoted ? purpleColor : 'white';
16
+ const borderColor = hasUpvoted ? purpleColor : 'black';
17
+ const badgeBackgroundColor = hasUpvoted ? purpleColor : 'black';
18
+ return (_jsxs(motion.div, { onClick: () => {
18
19
  setCurrentPost(post);
19
20
  setShowVoteUI(true);
21
+ }, whileHover: {
22
+ borderColor: purpleColor,
23
+ boxShadow: `0 4px 8px 0 rgba(158, 84, 223, 0.2), 0 6px 20px 0 rgba(158, 84, 223, 0.19)`,
24
+ transition: { duration: 0.1 },
20
25
  }, style: {
21
- padding: isMobile ? "8px" : "5px",
26
+ padding: "10px",
22
27
  width: "100%",
23
28
  display: "flex",
24
29
  flexDirection: "row",
25
- gap: isMobile ? "10px" : "20px",
26
- justifyContent: "start",
30
+ gap: "20px",
27
31
  alignItems: "center",
28
- borderBottom: "2px solid black",
29
- cursor: "pointer"
30
- }, children: [_jsxs("div", { style: {
32
+ border: `2px solid ${borderColor}`,
33
+ borderRadius: '10px',
34
+ cursor: "pointer",
35
+ justifyContent: "space-between",
36
+ backgroundColor: backgroundColor,
37
+ transition: 'all 0.3s ease',
38
+ }, children: [_jsx("h1", { className: fontMap.poppins.className, style: {
39
+ fontSize: "12px",
40
+ color: hasUpvoted ? 'white' : 'black'
41
+ }, children: post.title }), _jsxs("div", { style: {
31
42
  display: "flex",
32
43
  flexDirection: "row",
33
- gap: "5px",
44
+ gap: "4px",
34
45
  alignItems: "center",
35
- minWidth: isMobile ? "60px" : "auto"
36
- }, children: [_jsx(CircleArrowUp, { size: isMobile ? 16 : 20 }), _jsx("p", { className: fontMap.wixmadefor.className, style: {
37
- fontSize: isMobile ? "12px" : "14px"
38
- }, children: post.upvote_count }), _jsx(CircleArrowDown, { size: isMobile ? 16 : 20 }), _jsx("p", { className: fontMap.wixmadefor.className, style: {
39
- fontSize: isMobile ? "12px" : "14px"
40
- }, children: post.downvote_count })] }), _jsxs("div", { style: {
41
- flex: 1,
42
- overflow: "hidden"
43
- }, children: [_jsx("h1", { className: fontMap.poppins.className, style: {
44
- fontSize: isMobile ? "11px" : "12px",
45
- whiteSpace: isMobile ? "nowrap" : "normal",
46
- overflow: isMobile ? "hidden" : "visible",
47
- textOverflow: isMobile ? "ellipsis" : "clip"
48
- }, children: post.title }), _jsx("h2", { className: fontMap.wixmadefor.className, style: {
49
- fontSize: isMobile ? "9px" : "10px",
50
- color: "gray",
51
- whiteSpace: isMobile ? "nowrap" : "normal",
52
- overflow: isMobile ? "hidden" : "visible",
53
- textOverflow: isMobile ? "ellipsis" : "clip"
54
- }, children: isMobile ? post.subtitle.slice(0, 45) + "..." : post.subtitle.slice(0, 65) + "..." })] })] }));
46
+ backgroundColor: badgeBackgroundColor,
47
+ padding: "8px",
48
+ borderRadius: "10px",
49
+ }, children: [_jsx(CircleArrowUp, { size: 20, color: "white" }), _jsx("p", { className: fontMap.wixmadefor.className, style: {
50
+ fontSize: "14px",
51
+ color: "white"
52
+ }, children: post.upvote_count })] })] }));
55
53
  }
56
54
  export default PostItem;
@@ -1,7 +1,7 @@
1
1
  import type { CSSProperties } from 'react';
2
2
  interface Props {
3
- otherStyles?: CSSProperties;
3
+ style?: CSSProperties;
4
4
  }
5
- export declare function RaspForm({ otherStyles }: Props): import("react/jsx-runtime").JSX.Element;
5
+ export declare function RaspForm({ style }: Props): import("react/jsx-runtime").JSX.Element;
6
6
  export {};
7
7
  //# sourceMappingURL=RaspForm.d.ts.map
@@ -1 +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,2CA6L9C"}
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,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAED,wBAAgB,QAAQ,CAAC,EAAE,KAAK,EAAE,EAAE,KAAK,2CAsKxC"}
@@ -2,44 +2,46 @@
2
2
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useEffect, useState } from 'react';
4
4
  { /*@ts-ignore*/ }
5
- import { getFormByDomainOrCompany, getBrandTheme, getFormTheme } from '../functions/functionsexp';
5
+ import { getFormByRoute, getBrandTheme, getFormTheme } from '../functions/functionsexp';
6
6
  import StaticFormComponent from './StaticFormComponent';
7
7
  import Skeleton from './Skeleton';
8
8
  import { fontMap } from '../constants/fontexp';
9
9
  import { RASP_LOGO_BASE64 } from '../constants/baserasplogo';
10
- export function RaspForm({ otherStyles }) {
10
+ export function RaspForm({ style }) {
11
11
  const [companyId, setCompanyId] = useState(null);
12
- const [currentUrl, setCurrentUrl] = useState('');
12
+ const [currentPath, setCurrentPath] = useState('');
13
13
  const [form, setForm] = useState(null);
14
14
  const [fields, setFields] = useState(null);
15
15
  const [mainTheme, setMainTheme] = useState(null);
16
16
  const [isLoading, setIsLoading] = useState(true);
17
- const [isMobile, setIsMobile] = useState(false);
17
+ const [windowWidth, setWindowWidth] = useState(0);
18
18
  const getForm = async () => {
19
- const f = await getFormByDomainOrCompany(companyId, currentUrl);
20
- if (!f) {
21
- setForm(f);
19
+ setIsLoading(true);
20
+ const result = await getFormByRoute(currentPath, undefined, companyId);
21
+ if (!result) {
22
+ setForm(null);
22
23
  setIsLoading(false);
23
24
  return;
24
25
  }
25
- setForm(f[0]);
26
+ setForm(result.form);
27
+ setIsLoading(false);
26
28
  };
27
29
  useEffect(() => {
28
30
  if (typeof window !== 'undefined') {
29
31
  setCompanyId(process.env.NEXT_PUBLIC_RASP_COMPANY_ID);
30
- setCurrentUrl(window.location.href);
31
- // Check if mobile
32
- const checkMobile = () => {
33
- setIsMobile(window.innerWidth <= 768);
34
- };
35
- checkMobile();
36
- window.addEventListener('resize', checkMobile);
37
- return () => window.removeEventListener('resize', checkMobile);
32
+ setCurrentPath(window.location.pathname);
38
33
  }
39
34
  }, []);
40
35
  useEffect(() => {
41
36
  if (typeof window === 'undefined')
42
37
  return;
38
+ // Set initial window width
39
+ setWindowWidth(window.innerWidth);
40
+ // Add resize listener
41
+ const handleResize = () => {
42
+ setWindowWidth(window.innerWidth);
43
+ };
44
+ window.addEventListener('resize', handleResize);
43
45
  if (!document.getElementById('rasp-google-fonts')) {
44
46
  const link = document.createElement('link');
45
47
  link.id = 'rasp-google-fonts';
@@ -68,12 +70,10 @@ export function RaspForm({ otherStyles }) {
68
70
  }
69
71
  }, [form]);
70
72
  useEffect(() => {
71
- if (currentUrl.trim()) {
72
- if (companyId) {
73
- getForm();
74
- }
73
+ if (companyId && currentPath) {
74
+ getForm();
75
75
  }
76
- });
76
+ }, [companyId, currentPath]);
77
77
  return (_jsxs("div", { children: [form && _jsx(_Fragment, { children: form.active && mainTheme && fields && _jsx("div", { id: "rasp-form-div", style: {
78
78
  padding: 0,
79
79
  margin: 0,
@@ -82,36 +82,17 @@ export function RaspForm({ otherStyles }) {
82
82
  width: "auto",
83
83
  height: "auto",
84
84
  display: "inline-block",
85
- transform: isMobile ? "none" : "translate(-50%, -25%)",
85
+ transform: "translate(-50%, -25%)",
86
86
  overflow: "visible",
87
- ...otherStyles
88
- }, children: _jsx(StaticFormComponent, { form: form, mainTheme: mainTheme, fields: fields }) }) }), !isLoading && !form && _jsxs("div", { style: {
87
+ ...style
88
+ }, children: _jsx(StaticFormComponent, { form: form, mainTheme: mainTheme, fields: fields, submitable: true, isFormComponent: true }) }) }), !isLoading && !form && _jsxs("div", { style: {
89
89
  display: 'flex',
90
90
  flexDirection: 'column',
91
91
  alignItems: 'center',
92
- borderRadius: '0.75rem',
93
92
  backgroundColor: 'white',
94
- margin: isMobile ? '0.75rem' : '1.25rem',
95
- width: isMobile ? '90vw' : '470px',
96
- maxWidth: '470px',
97
- minHeight: isMobile ? '350px' : '400px',
98
- border: '1px solid black',
99
- padding: isMobile ? '0.75rem' : '1rem',
100
- boxShadow: '0 1px 3px 0 rgba(0, 0, 0, 1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)'
101
- }, children: [_jsx("br", {}), _jsx("br", {}), _jsx("img", { src: RASP_LOGO_BASE64, width: isMobile ? "120px" : "150px", height: isMobile ? "120px" : "150px", alt: "rasp logo" }), _jsx("h1", { className: `${fontMap.poppins.className}`, style: { fontSize: isMobile ? '2rem' : '2.5rem' }, children: "404" }), _jsx("h2", { className: `${fontMap.wixmadefor.className}`, style: {
102
- textAlign: 'center',
103
- fontSize: isMobile ? '0.9rem' : '1rem',
104
- padding: isMobile ? '0 0.5rem' : '0'
105
- }, 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: {
106
- textAlign: 'center',
107
- fontSize: isMobile ? '0.85rem' : '1rem',
108
- padding: isMobile ? '0 0.5rem' : '0'
109
- }, 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: {
110
- textAlign: 'center',
111
- fontSize: isMobile ? '0.85rem' : '1rem',
112
- padding: isMobile ? '0 0.5rem' : '0',
113
- wordBreak: 'break-all'
114
- }, children: [" Set this as your form domain url: ", currentUrl] })] }), isLoading &&
93
+ width: '470px',
94
+ minHeight: '400px',
95
+ }, 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://www.tryrasp.online/docs', style: { textDecoration: "underline" }, children: "https://www.tryrasp.online/docs" })] }), companyId && typeof window !== 'undefined' && _jsxs("p", { className: `${fontMap.wixmadefor.className}`, style: { textAlign: 'center' }, children: [" Set this as your form domain url: ", window.location.href] })] }), isLoading &&
115
96
  _jsx("div", { id: "rasp-form-div", style: {
116
97
  padding: 0,
117
98
  margin: 0,
@@ -120,20 +101,16 @@ export function RaspForm({ otherStyles }) {
120
101
  width: "auto",
121
102
  height: "auto",
122
103
  display: "inline-block",
123
- transform: isMobile ? "none" : "translate(-50%, -25%)",
104
+ transform: "translate(-50%, -25%)",
124
105
  overflow: "visible",
125
106
  }, children: _jsx("div", { style: {
126
107
  display: 'flex',
127
108
  flexDirection: "column",
128
109
  justifyContent: 'center',
129
- borderRadius: '0.75rem',
130
- backgroundColor: "white",
131
- margin: isMobile ? '0.75rem' : '1.25rem',
132
- width: isMobile ? '90vw' : '470px',
133
- maxWidth: '470px',
134
- minHeight: isMobile ? '350px' : '400px',
135
- border: '1px solid whitesmoke',
136
- padding: isMobile ? '1.5rem' : '2rem',
110
+ backgroundColor: "transparent",
111
+ width: '470px',
112
+ minHeight: '400px',
113
+ padding: '2rem',
137
114
  paddingTop: "0px"
138
- }, children: _jsxs("div", { style: { marginTop: "-30px" }, children: [_jsx(Skeleton, { width: isMobile ? Math.min(window.innerWidth * 0.8, 400) : 400, height: 40 }), _jsx(Skeleton, { width: isMobile ? Math.min(window.innerWidth * 0.8, 400) : 400, height: 30 }), _jsx("br", {}), _jsx(Skeleton, { width: isMobile ? Math.min(window.innerWidth * 0.8, 400) : 400, height: 70 }), _jsx(Skeleton, { width: isMobile ? Math.min(window.innerWidth * 0.8, 400) : 400, height: 100 })] }) }) })] }));
115
+ }, children: _jsxs("div", { style: { marginTop: "-30px" }, children: [_jsx(Skeleton, { width: windowWidth > 400 ? 400 : 350, height: 40 }), _jsx(Skeleton, { width: windowWidth > 400 ? 400 : 350, height: 30 }), _jsx("br", {}), _jsx(Skeleton, { width: windowWidth > 400 ? 400 : 350, height: 70 }), _jsx(Skeleton, { width: windowWidth > 400 ? 400 : 350, height: 100 })] }) }) })] }));
139
116
  }
@@ -1 +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;AAQrB,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,CAwiBpD,CAAA"}
1
+ {"version":3,"file":"RaspProvider.d.ts","sourceRoot":"","sources":["../../../src/nextjs/components/RaspProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAIlD,OAAO,cAAc,CAAA;AAUrB,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;AAKD,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA+epD,CAAA"}