@pagamio/frontend-commons-lib 0.8.184 → 0.8.187

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.
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import type { FeedbackPageProps } from './types';
3
+ export declare const FeedbackPage: React.FC<FeedbackPageProps>;
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ExternalLink, MessageSquare } from 'lucide-react';
3
+ import Button from '../components/ui/Button';
4
+ import Card from '../components/ui/Card';
5
+ import { openFeedbackForm } from './utils';
6
+ export const FeedbackPage = ({ config, userData, onNavigateBack, title = 'Share Your Feedback', description = 'We value your feedback! Help us improve by sharing your thoughts and suggestions.', buttonText = 'Open Feedback Form', }) => {
7
+ const handleOpenFeedback = () => {
8
+ openFeedbackForm(config, userData, onNavigateBack);
9
+ };
10
+ return (_jsx("div", { className: "min-h-screen flex items-center justify-center p-4", children: _jsx(Card, { className: "w-full max-w-md", children: _jsxs("div", { className: "p-6 text-center", children: [_jsx("div", { className: "mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-blue-100 dark:bg-blue-900", children: _jsx(MessageSquare, { className: "h-6 w-6 text-blue-600 dark:text-blue-300" }) }), _jsx("h1", { className: "text-xl font-semibold mb-2", children: title }), _jsx("p", { className: "text-gray-600 dark:text-gray-400 mb-6", children: description }), _jsxs("div", { className: "space-y-4", children: [_jsxs(Button, { onClick: handleOpenFeedback, className: "w-full", size: "lg", children: [_jsx(ExternalLink, { className: "mr-2 h-4 w-4" }), buttonText] }), onNavigateBack && (_jsx(Button, { variant: "outline", onClick: onNavigateBack, className: "w-full", children: "Go Back" }))] })] }) }) }));
11
+ };
@@ -0,0 +1,3 @@
1
+ export type { FeedbackFormConfig, FeedbackUserData, FeedbackPageProps } from './types';
2
+ export { generateFeedbackFormUrl, openFeedbackForm } from './utils';
3
+ export { FeedbackPage } from './FeedbackPage';
@@ -0,0 +1,4 @@
1
+ // Utilities
2
+ export { generateFeedbackFormUrl, openFeedbackForm } from './utils';
3
+ // Components
4
+ export { FeedbackPage } from './FeedbackPage';
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Feedback Form Configuration Types
3
+ */
4
+ export interface FeedbackFormConfig {
5
+ /** Base URL of the Google Form */
6
+ baseUrl: string;
7
+ /** Mapping of field names to Google Form entry IDs */
8
+ fieldIds: {
9
+ email?: string;
10
+ userRole?: string;
11
+ userId?: string;
12
+ userName?: string;
13
+ [key: string]: string | undefined;
14
+ };
15
+ }
16
+ export interface FeedbackUserData {
17
+ email?: string;
18
+ userRole?: string;
19
+ userId?: string | number;
20
+ userName?: string;
21
+ [key: string]: string | number | undefined;
22
+ }
23
+ export interface FeedbackPageProps {
24
+ /** Configuration for the feedback form */
25
+ config: FeedbackFormConfig;
26
+ /** User data to pre-fill the form */
27
+ userData?: FeedbackUserData;
28
+ /** Optional callback for navigation back */
29
+ onNavigateBack?: () => void;
30
+ /** Optional custom page title */
31
+ title?: string;
32
+ /** Optional custom page description */
33
+ description?: string;
34
+ /** Optional custom button text */
35
+ buttonText?: string;
36
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Feedback Form Configuration Types
3
+ */
4
+ export {};
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Configurable Google Form Pre-fill Utility
3
+ *
4
+ * This utility provides a configurable way to generate pre-filled Google Form URLs
5
+ * and open feedback forms across different applications.
6
+ */
7
+ import type { FeedbackFormConfig, FeedbackUserData } from './types';
8
+ /**
9
+ * Generate a pre-filled Google Form URL with user data
10
+ * @param config - Form configuration with base URL and field mappings
11
+ * @param userData - User information to pre-fill in the form
12
+ * @returns Pre-filled Google Form URL
13
+ */
14
+ export declare function generateFeedbackFormUrl(config: FeedbackFormConfig, userData?: FeedbackUserData): string;
15
+ /**
16
+ * Open feedback form in a new tab with pre-filled user data
17
+ * @param config - Form configuration with base URL and field mappings
18
+ * @param userData - User information to pre-fill in the form
19
+ * @param onFormOpened - Optional callback after form is opened
20
+ */
21
+ export declare function openFeedbackForm(config: FeedbackFormConfig, userData?: FeedbackUserData, onFormOpened?: () => void): void;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Generate a pre-filled Google Form URL with user data
3
+ * @param config - Form configuration with base URL and field mappings
4
+ * @param userData - User information to pre-fill in the form
5
+ * @returns Pre-filled Google Form URL
6
+ */
7
+ export function generateFeedbackFormUrl(config, userData = {}) {
8
+ const params = new URLSearchParams();
9
+ // Required by Google Forms for pre-filled links
10
+ params.append('usp', 'pp_url');
11
+ // Add user data to URL parameters
12
+ for (const [key, value] of Object.entries(userData)) {
13
+ const fieldId = config.fieldIds[key];
14
+ if (value != null && fieldId) {
15
+ // Encode the value but preserve @ symbol in email addresses
16
+ let encodedValue = encodeURIComponent(String(value));
17
+ if (key === 'email') {
18
+ // Replace encoded @ symbol back to @ for email fields
19
+ encodedValue = encodedValue.replaceAll('%40', '@');
20
+ }
21
+ params.append(fieldId, encodedValue);
22
+ }
23
+ }
24
+ return `${config.baseUrl}?${params.toString()}`;
25
+ }
26
+ /**
27
+ * Open feedback form in a new tab with pre-filled user data
28
+ * @param config - Form configuration with base URL and field mappings
29
+ * @param userData - User information to pre-fill in the form
30
+ * @param onFormOpened - Optional callback after form is opened
31
+ */
32
+ export function openFeedbackForm(config, userData = {}, onFormOpened) {
33
+ const url = generateFeedbackFormUrl(config, userData);
34
+ window.open(url, '_blank', 'noopener,noreferrer');
35
+ onFormOpened?.();
36
+ }
package/lib/index.d.ts CHANGED
@@ -19,3 +19,4 @@ export * from './translations';
19
19
  export * from './rbac';
20
20
  export { useImageUpload } from './shared/hooks/useImageUpload';
21
21
  export type { UseImageUploadProps, UploadResponse } from './shared/hooks/useImageUpload';
22
+ export * from './feedback';
package/lib/index.js CHANGED
@@ -28,3 +28,5 @@ export * from './translations';
28
28
  export * from './rbac';
29
29
  // Hooks
30
30
  export { useImageUpload } from './shared/hooks/useImageUpload';
31
+ // Feedback System
32
+ export * from './feedback';
package/lib/styles.css CHANGED
@@ -3132,6 +3132,10 @@ input[type="range"]::-ms-fill-lower {
3132
3132
  --tw-text-opacity: 1;
3133
3133
  color: rgb(63 131 248 / var(--tw-text-opacity, 1));
3134
3134
  }
3135
+ .text-blue-600 {
3136
+ --tw-text-opacity: 1;
3137
+ color: rgb(28 100 242 / var(--tw-text-opacity, 1));
3138
+ }
3135
3139
  .text-blue-700 {
3136
3140
  --tw-text-opacity: 1;
3137
3141
  color: rgb(26 86 219 / var(--tw-text-opacity, 1));
@@ -4790,6 +4794,10 @@ input[type="range"]::-ms-fill-lower {
4790
4794
  --tw-bg-opacity: 1;
4791
4795
  background-color: rgb(28 100 242 / var(--tw-bg-opacity, 1));
4792
4796
  }
4797
+ .dark\:bg-blue-900:is(.dark *) {
4798
+ --tw-bg-opacity: 1;
4799
+ background-color: rgb(35 56 118 / var(--tw-bg-opacity, 1));
4800
+ }
4793
4801
  .dark\:bg-cyan-100:is(.dark *) {
4794
4802
  --tw-bg-opacity: 1;
4795
4803
  background-color: rgb(207 250 254 / var(--tw-bg-opacity, 1));
@@ -4967,6 +4975,10 @@ input[type="range"]::-ms-fill-lower {
4967
4975
  .dark\:fill-gray-300:is(.dark *) {
4968
4976
  fill: #D1D5DB;
4969
4977
  }
4978
+ .dark\:text-blue-300:is(.dark *) {
4979
+ --tw-text-opacity: 1;
4980
+ color: rgb(164 202 254 / var(--tw-text-opacity, 1));
4981
+ }
4970
4982
  .dark\:text-blue-500:is(.dark *) {
4971
4983
  --tw-text-opacity: 1;
4972
4984
  color: rgb(63 131 248 / var(--tw-text-opacity, 1));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pagamio/frontend-commons-lib",
3
3
  "description": "Pagamio library for Frontend reusable components like the form engine and table container",
4
- "version": "0.8.184",
4
+ "version": "0.8.187",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "provenance": false