popsite-ui 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/App.jsx +95 -0
- package/README.md +92 -0
- package/components/layout/PortalHeader.jsx +18 -0
- package/components/layout/SystemSidebar.jsx +33 -0
- package/components/modules/AnalyticsDashboardModule.jsx +17 -0
- package/components/modules/ChatMessagingModule.jsx +17 -0
- package/components/modules/EcommerceStoreModule.jsx +17 -0
- package/components/modules/EventTicketBookingModule.jsx +17 -0
- package/components/modules/FlightBookingModule.jsx +17 -0
- package/components/modules/FoodOrderingModule.jsx +17 -0
- package/components/modules/HospitalAppointmentModule.jsx +17 -0
- package/components/modules/HotelBookingModule.jsx +17 -0
- package/components/modules/InvoiceBillingModule.jsx +17 -0
- package/components/modules/LibraryManagementModule.jsx +17 -0
- package/components/modules/ModuleContentDeck.jsx +44 -0
- package/components/modules/MovieBookingModule.jsx +17 -0
- package/components/modules/QuizExamModule.jsx +17 -0
- package/components/modules/StudentRegistrationModule.jsx +17 -0
- package/components/modules/SystemModuleRenderer.jsx +19 -0
- package/components/modules/SystemModuleTemplate.jsx +62 -0
- package/components/modules/SystemVisualWidget.jsx +123 -0
- package/components/modules/moduleContentMap.js +238 -0
- package/components/modules/moduleEnhancementsMap.js +439 -0
- package/components/modules/systemModuleMap.js +31 -0
- package/components/system/DynamicSystemForm.jsx +154 -0
- package/components/system/SystemHero.jsx +21 -0
- package/components/system/SystemSummaryCard.jsx +53 -0
- package/data/systems/analyticsDashboard.js +48 -0
- package/data/systems/chatMessaging.js +43 -0
- package/data/systems/ecommerceStore.js +50 -0
- package/data/systems/eventTicketBooking.js +50 -0
- package/data/systems/flightBooking.js +38 -0
- package/data/systems/foodOrdering.js +48 -0
- package/data/systems/hospitalAppointment.js +50 -0
- package/data/systems/hotelBooking.js +38 -0
- package/data/systems/index.js +31 -0
- package/data/systems/invoiceBilling.js +50 -0
- package/data/systems/libraryManagement.js +43 -0
- package/data/systems/movieBooking.js +48 -0
- package/data/systems/quizExam.js +38 -0
- package/data/systems/studentRegistration.js +43 -0
- package/dist/popsite-ui.es.js +4368 -0
- package/dist/popsite-ui.umd.js +60 -0
- package/dist/style.css +1 -0
- package/index.html +13 -0
- package/library/index.js +20 -0
- package/main.jsx +15 -0
- package/package.json +40 -0
- package/src/App.jsx +12 -0
- package/src/components/modules/AnalyticsDashboardModule.jsx +224 -0
- package/src/components/modules/ChatMessagingModule.jsx +294 -0
- package/src/components/modules/EcommerceStoreModule.jsx +405 -0
- package/src/components/modules/EventTicketBookingModule.jsx +253 -0
- package/src/components/modules/FlightBookingModule.jsx +399 -0
- package/src/components/modules/FoodOrderingModule.jsx +316 -0
- package/src/components/modules/HospitalAppointmentModule.jsx +267 -0
- package/src/components/modules/HotelBookingModule.jsx +317 -0
- package/src/components/modules/InvoiceBillingModule.jsx +302 -0
- package/src/components/modules/LandingPageModule.jsx +185 -0
- package/src/components/modules/LibraryManagementModule.jsx +189 -0
- package/src/components/modules/MovieBookingModule.jsx +337 -0
- package/src/components/modules/QuizExamModule.jsx +255 -0
- package/src/components/modules/StudentRegistrationModule.jsx +292 -0
- package/src/components/system/SystemHero.jsx +44 -0
- package/src/components/system/SystemSummaryCard.jsx +29 -0
- package/src/components/system/Toast.jsx +69 -0
- package/src/data/systems/analyticsDashboard.js +32 -0
- package/src/data/systems/chatMessaging.js +59 -0
- package/src/data/systems/ecommerceStore.js +84 -0
- package/src/data/systems/eventBooking.js +33 -0
- package/src/data/systems/flightBooking.js +59 -0
- package/src/data/systems/foodOrdering.js +48 -0
- package/src/data/systems/hospitalAppointment.js +48 -0
- package/src/data/systems/hotelBooking.js +59 -0
- package/src/data/systems/invoiceBilling.js +19 -0
- package/src/data/systems/landingPage.js +29 -0
- package/src/data/systems/libraryManagement.js +17 -0
- package/src/data/systems/movieBooking.js +49 -0
- package/src/data/systems/quizExam.js +31 -0
- package/src/data/systems/studentRegistration.js +9 -0
- package/src/index.js +22 -0
- package/src/main.jsx +10 -0
- package/src/styles.css +296 -0
- package/styles.css +820 -0
- package/utils/systemEngine.js +128 -0
- package/vite.config.js +8 -0
- package/vite.lib.config.js +27 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
const DEFAULT_CURRENCY = 'USD';
|
|
2
|
+
|
|
3
|
+
const hasOwnProperty = (object, key) => Object.prototype.hasOwnProperty.call(object, key);
|
|
4
|
+
|
|
5
|
+
const normalizeOption = (option) => {
|
|
6
|
+
if (typeof option === 'string') {
|
|
7
|
+
return { label: option, value: option };
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return {
|
|
11
|
+
label: option.label,
|
|
12
|
+
value: option.value
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const buildInitialFormData = (fields) => {
|
|
17
|
+
return fields.reduce((initialData, field) => {
|
|
18
|
+
if (hasOwnProperty(field, 'defaultValue')) {
|
|
19
|
+
initialData[field.name] = field.defaultValue;
|
|
20
|
+
return initialData;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (field.type === 'number') {
|
|
24
|
+
initialData[field.name] = field.min ?? 1;
|
|
25
|
+
return initialData;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
initialData[field.name] = '';
|
|
29
|
+
return initialData;
|
|
30
|
+
}, {});
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const getLabelForValue = (options, value) => {
|
|
34
|
+
if (!Array.isArray(options)) {
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const matchingOption = options
|
|
39
|
+
.map((option) => normalizeOption(option))
|
|
40
|
+
.find((option) => option.value === value);
|
|
41
|
+
|
|
42
|
+
return matchingOption ? matchingOption.label : value;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const formatFieldValue = (field, value) => {
|
|
46
|
+
if (value === undefined || value === null || value === '') {
|
|
47
|
+
return 'Not provided';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (field.type === 'date') {
|
|
51
|
+
const parsedDate = new Date(value);
|
|
52
|
+
if (Number.isNaN(parsedDate.valueOf())) {
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return parsedDate.toLocaleDateString();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (field.type === 'select' || field.type === 'radio') {
|
|
60
|
+
return getLabelForValue(field.options, value);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (field.type === 'number') {
|
|
64
|
+
const numericValue = Number(value);
|
|
65
|
+
return Number.isNaN(numericValue) ? value : numericValue;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return value;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const buildSummaryRows = (fields, formData) => {
|
|
72
|
+
return fields.map((field) => {
|
|
73
|
+
return {
|
|
74
|
+
label: field.label,
|
|
75
|
+
value: formatFieldValue(field, formData[field.name])
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export const calculatePricing = (system, formData) => {
|
|
81
|
+
const pricing = system.pricing ?? {};
|
|
82
|
+
const quantityField = pricing.quantityField;
|
|
83
|
+
const rawQuantity = quantityField ? Number(formData[quantityField]) : 1;
|
|
84
|
+
const quantity = Number.isFinite(rawQuantity) && rawQuantity > 0 ? rawQuantity : 1;
|
|
85
|
+
|
|
86
|
+
let unitPrice = pricing.basePrice ?? 0;
|
|
87
|
+
|
|
88
|
+
if (pricing.tierField && pricing.tiers) {
|
|
89
|
+
const selectedTier = formData[pricing.tierField];
|
|
90
|
+
unitPrice = pricing.tiers[selectedTier] ?? unitPrice;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const subtotal = quantity * unitPrice;
|
|
94
|
+
const fee = pricing.fee ?? 0;
|
|
95
|
+
const total = subtotal + fee;
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
quantity,
|
|
99
|
+
unitPrice,
|
|
100
|
+
subtotal,
|
|
101
|
+
fee,
|
|
102
|
+
total,
|
|
103
|
+
currency: pricing.currency ?? DEFAULT_CURRENCY,
|
|
104
|
+
quantityLabel: pricing.quantityLabel ?? 'Units',
|
|
105
|
+
chargeLabel: pricing.chargeLabel ?? 'Total Amount'
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export const buildSubmissionRecord = (system, formData) => {
|
|
110
|
+
return {
|
|
111
|
+
formData,
|
|
112
|
+
summaryRows: buildSummaryRows(system.fields, formData),
|
|
113
|
+
pricing: calculatePricing(system, formData),
|
|
114
|
+
submittedAt: new Date().toISOString()
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export const formatCurrency = (amount, currency = DEFAULT_CURRENCY) => {
|
|
119
|
+
try {
|
|
120
|
+
return new Intl.NumberFormat('en-US', {
|
|
121
|
+
style: 'currency',
|
|
122
|
+
currency
|
|
123
|
+
}).format(Number(amount) || 0);
|
|
124
|
+
} catch (error) {
|
|
125
|
+
const safeAmount = Number(amount) || 0;
|
|
126
|
+
return `$${safeAmount.toFixed(2)}`;
|
|
127
|
+
}
|
|
128
|
+
};
|
package/vite.config.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import react from '@vitejs/plugin-react';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
plugins: [react()],
|
|
7
|
+
build: {
|
|
8
|
+
lib: {
|
|
9
|
+
entry: path.resolve(__dirname, 'src/index.js'),
|
|
10
|
+
name: 'PopSiteUI',
|
|
11
|
+
fileName: (format) => `popsite-ui.${format}.js`,
|
|
12
|
+
},
|
|
13
|
+
rollupOptions: {
|
|
14
|
+
external: ['react', 'react-dom'],
|
|
15
|
+
output: {
|
|
16
|
+
globals: {
|
|
17
|
+
react: 'React',
|
|
18
|
+
'react-dom': 'ReactDOM',
|
|
19
|
+
},
|
|
20
|
+
assetFileNames: (assetInfo) => {
|
|
21
|
+
if (assetInfo.name === 'style.css') return 'style.css';
|
|
22
|
+
return assetInfo.name;
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
});
|