@colabcommerce/elements 0.9.1 → 0.9.3
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/dist/QuoteForm.js +24 -0
- package/dist/Store.js +37 -0
- package/dist/StoreLocator.js +34 -0
- package/dist/StoreLocatorProvider.js +1 -0
- package/dist/elements.css +1 -0
- package/dist/index-DvX0QvFh.js +31 -0
- package/dist/navigation-DpGLbcKb.js +1 -0
- package/dist/store-locator-Bto20jHS.js +1 -0
- package/dist/styles.js +1 -0
- package/dist/translations-6mspyPRw.js +1 -0
- package/dist/useStoreLocator.js +1 -0
- package/dist/useStoreLocatorConfig-r4Y_2t-M.js +1 -0
- package/package.json +5 -1
- package/.pnp.cjs +0 -16484
- package/.pnp.loader.mjs +0 -2126
- package/.yarn/install-state.gz +0 -0
- package/.yarn/releases/yarn-4.12.0.cjs +0 -942
- package/.yarnrc.yml +0 -1
- package/cypress/fixtures/example.json +0 -5
- package/cypress/support/commands.js +0 -25
- package/cypress/support/component-index.html +0 -15
- package/cypress/support/component.js +0 -26
- package/eslint.config.js +0 -32
- package/index.html +0 -13
- package/playground/index.html +0 -14
- package/playground/main.jsx +0 -36
- package/src/App.css +0 -0
- package/src/App.jsx +0 -65
- package/src/components/CollapsibleStoreHours/index.jsx +0 -269
- package/src/components/HoursList/index.jsx +0 -225
- package/src/components/LeadForm/index.jsx +0 -241
- package/src/components/MessageDialog/index.jsx +0 -169
- package/src/components/QuoteForm/index.jsx +0 -82
- package/src/components/QuoteFormSearch/index.jsx +0 -276
- package/src/components/QuoteFormStoreList/index.jsx +0 -65
- package/src/components/QuoteFormStoreListItem/index.jsx +0 -134
- package/src/components/QuoteLeadForm/index.jsx +0 -16
- package/src/components/QuoteMap/index.jsx +0 -96
- package/src/components/QuoteMapMarker/index.jsx +0 -56
- package/src/components/StaticMap/index.jsx +0 -24
- package/src/components/Store/index.jsx +0 -44
- package/src/components/StoreContact/index.jsx +0 -96
- package/src/components/StoreInfo/index.jsx +0 -50
- package/src/components/StoreList/index.jsx +0 -59
- package/src/components/StoreListItem/index.jsx +0 -99
- package/src/components/StoreListItem/indexStoreListItem.cy.jsx +0 -30
- package/src/components/StoreListNoneFound/index.jsx +0 -16
- package/src/components/StoreLocator/index.jsx +0 -43
- package/src/components/StoreLocatorMap/index.jsx +0 -93
- package/src/components/StoreLocatorMapMarker/index.jsx +0 -55
- package/src/components/StoreLocatorMessageDialog/index.jsx +0 -20
- package/src/components/StoreLocatorSearch/index.jsx +0 -316
- package/src/components/StoreMap/index.jsx +0 -30
- package/src/components/StoreMeta/index.jsx +0 -7
- package/src/components/StoreProducts/index.jsx +0 -112
- package/src/components/ui/Badge/index.jsx +0 -46
- package/src/components/ui/Button/index.jsx +0 -56
- package/src/components/ui/Button/indexButton.cy.jsx +0 -9
- package/src/components/ui/Card/index.jsx +0 -90
- package/src/components/ui/Input/index.jsx +0 -19
- package/src/components/ui/Input/indexInput.cy.jsx +0 -9
- package/src/components/ui/LoadingPuff/index.jsx +0 -10
- package/src/components/ui/Panel/index.jsx +0 -23
- package/src/components/ui/PhoneNumberInput/index.jsx +0 -17
- package/src/contexts/quote-form.jsx +0 -94
- package/src/contexts/store-locator.jsx +0 -83
- package/src/contexts/store.jsx +0 -59
- package/src/contexts/translations.jsx +0 -11
- package/src/dist.css +0 -229
- package/src/entries/QuoteForm.js +0 -2
- package/src/entries/Store.js +0 -2
- package/src/entries/StoreLocator.js +0 -2
- package/src/entries/StoreLocatorProvider.js +0 -2
- package/src/entries/styles.js +0 -2
- package/src/entries/useStoreLocator.js +0 -2
- package/src/i18n/defaultResources.js +0 -19
- package/src/i18n/index.js +0 -44
- package/src/i18n/mergeResources.js +0 -22
- package/src/index.css +0 -214
- package/src/lib/addressComponentsToAddress.js +0 -43
- package/src/lib/productSchema.js +0 -6
- package/src/lib/useGeolocation.js +0 -266
- package/src/lib/useHours.js +0 -205
- package/src/lib/usePlacesAutocomplete.js +0 -288
- package/src/lib/useProductAvailability.js +0 -38
- package/src/lib/useRudderAnalytics.js +0 -50
- package/src/lib/useSearchResults.js +0 -102
- package/src/lib/useStoreLocatorConfig.js +0 -50
- package/src/lib/utils/cn.js +0 -6
- package/src/lib/utils/measure.js +0 -31
- package/src/locales/en/default.json +0 -58
- package/src/locales/es/default.json +0 -58
- package/src/locales/fr/default.json +0 -58
- package/src/locales/it/default.json +0 -58
- package/src/main.jsx +0 -10
- package/vite.config.js +0 -67
- /package/{public → dist}/vite.svg +0 -0
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025 Colab Commerce <https://colabcommerce.com>
|
|
3
|
-
* All rights reserved.
|
|
4
|
-
*
|
|
5
|
-
* This hook provides a store locator configuration based on the organization ID
|
|
6
|
-
* provided.
|
|
7
|
-
* Usage:
|
|
8
|
-
* const { config, isLoading, error } = useStoreLocatorConfig(id)
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { useEffect, useState } from 'react'
|
|
12
|
-
|
|
13
|
-
export default function useStoreLocatorConfig(organizationId) {
|
|
14
|
-
|
|
15
|
-
const [config, setConfig] = useState(null)
|
|
16
|
-
const [isLoading, setIsLoading] = useState(false)
|
|
17
|
-
const [error, setError] = useState(null)
|
|
18
|
-
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
async function fetchConfig() {
|
|
21
|
-
if (!organizationId) {
|
|
22
|
-
setConfig(null)
|
|
23
|
-
setIsLoading(false)
|
|
24
|
-
setError(null)
|
|
25
|
-
return
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
setIsLoading(true)
|
|
29
|
-
setError(null)
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
const response = await fetch(`https://api.colabcommerce.com/widget_api/store_locator/${organizationId}`)
|
|
33
|
-
if (!response.ok) {
|
|
34
|
-
throw new Error(`Error fetching store locator config: ${response.statusText}`)
|
|
35
|
-
}
|
|
36
|
-
const data = await response.json()
|
|
37
|
-
setConfig(data)
|
|
38
|
-
} catch (err) {
|
|
39
|
-
setError(err)
|
|
40
|
-
setConfig(null)
|
|
41
|
-
} finally {
|
|
42
|
-
setIsLoading(false)
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
fetchConfig()
|
|
47
|
-
}, [organizationId])
|
|
48
|
-
|
|
49
|
-
return { config, isLoading, error }
|
|
50
|
-
}
|
package/src/lib/utils/cn.js
DELETED
package/src/lib/utils/measure.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// Calculate the distance between two points (latitude/longitude) using the Haversine formula
|
|
2
|
-
// and return the distance in meters.
|
|
3
|
-
|
|
4
|
-
export function distanceBetweenPoints(lat1, lon1, lat2, lon2) {
|
|
5
|
-
const toRadians = (degrees) => (degrees * Math.PI) / 180;
|
|
6
|
-
|
|
7
|
-
const R = 6371e3; // Earth's radius in meters
|
|
8
|
-
const φ1 = toRadians(lat1);
|
|
9
|
-
const φ2 = toRadians(lat2);
|
|
10
|
-
const Δφ = toRadians(lat2 - lat1);
|
|
11
|
-
const Δλ = toRadians(lon2 - lon1);
|
|
12
|
-
|
|
13
|
-
const a =
|
|
14
|
-
Math.sin(Δφ / 2) * Math.sin(Δφ / 2) +
|
|
15
|
-
Math.cos(φ1) * Math.cos(φ2) *
|
|
16
|
-
Math.sin(Δλ / 2) * Math.sin(Δλ / 2);
|
|
17
|
-
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
|
18
|
-
|
|
19
|
-
const distance = R * c; // in meters
|
|
20
|
-
return distance;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function metersToMiles(meters) {
|
|
24
|
-
const miles = meters / 1609.344;
|
|
25
|
-
return miles;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function milesToMeters(miles) {
|
|
29
|
-
const meters = miles * 1609.344;
|
|
30
|
-
return meters;
|
|
31
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"closed": "Closed",
|
|
3
|
-
"closes_at": "Closes at {{time}}",
|
|
4
|
-
"closing_soon": "Closing Soon",
|
|
5
|
-
"consent": {
|
|
6
|
-
"label": "I agree to have {{storeName}} contact me via either email or phone call."
|
|
7
|
-
},
|
|
8
|
-
"contact_online": "Contact Our Authorized Online Retailer",
|
|
9
|
-
"distance_away": "{{distance}} {{distanceUnit}} away",
|
|
10
|
-
"email": {
|
|
11
|
-
"placeholder": "Email",
|
|
12
|
-
"required": "Email is required"
|
|
13
|
-
},
|
|
14
|
-
"friday": "Friday",
|
|
15
|
-
"get_directions": "Directions",
|
|
16
|
-
"loading": "Loading",
|
|
17
|
-
"location_search_placeholder": "Search stores by city, state, or zip",
|
|
18
|
-
"location_search_placeholder_w_location": "Stores near {{location}}",
|
|
19
|
-
"message": "Message",
|
|
20
|
-
"monday": "Monday",
|
|
21
|
-
"name": {
|
|
22
|
-
"label": "Name",
|
|
23
|
-
"placeholder": "Name",
|
|
24
|
-
"required": "Name is required"
|
|
25
|
-
},
|
|
26
|
-
"no_results": "No Results",
|
|
27
|
-
"no_stores_found": "No stores found matching your criteria.",
|
|
28
|
-
"number_stores_found": "{{count}} stores found",
|
|
29
|
-
"open": "Open",
|
|
30
|
-
"opening_soon": "Opening Soon",
|
|
31
|
-
"opens_at": "Opens at {{time}}",
|
|
32
|
-
"phone_number": {
|
|
33
|
-
"placeholder": "555 555 5555",
|
|
34
|
-
"required": "Phone number is required"
|
|
35
|
-
},
|
|
36
|
-
"quote_message": {
|
|
37
|
-
"placeholder": "Any additional notes"
|
|
38
|
-
},
|
|
39
|
-
"quote_submit": "Request Quote",
|
|
40
|
-
"saturday": "Saturday",
|
|
41
|
-
"search_adjust_prompt": "You can try adjusting your search filters or expanding the search radius.",
|
|
42
|
-
"select_store": "Select",
|
|
43
|
-
"sending": "Sending",
|
|
44
|
-
"send_message_to": "Send a message to {{name}}",
|
|
45
|
-
"storeName": "the store",
|
|
46
|
-
"store_romance": "{{name}} is your destination for contemporary and classic furniture pieces. With over 20\n years of experience in the industry, we pride ourselves on offering exceptional quality, personalized\n service, and an extensive selection of home furnishings that transform spaces into beautiful, functional\n living environments.",
|
|
47
|
-
"store": {
|
|
48
|
-
"types": {
|
|
49
|
-
"retailer": "Retailer"
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
"sunday": "Sunday",
|
|
53
|
-
"thursday": "Thursday",
|
|
54
|
-
"tuesday": "Tuesday",
|
|
55
|
-
"use_my_location": "Use my current location",
|
|
56
|
-
"view_details": "View Details",
|
|
57
|
-
"wednesday": "Wednesday"
|
|
58
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"closed": "Cerrado",
|
|
3
|
-
"closes_at": "Cierra a {{time}}",
|
|
4
|
-
"closing_soon": "Cerrando pronto",
|
|
5
|
-
"consent": {
|
|
6
|
-
"label": "Acepto que {{storeName}} se comunique conmigo por correo electrónico o por teléfono."
|
|
7
|
-
},
|
|
8
|
-
"contact_online": "Contacta a nuestro minorista autorizado en línea",
|
|
9
|
-
"distance_away": "{{distance}} {{distanceUnit}} de distancia",
|
|
10
|
-
"email": {
|
|
11
|
-
"placeholder": "Correo electrónico",
|
|
12
|
-
"required": "Se requiere correo electrónico"
|
|
13
|
-
},
|
|
14
|
-
"friday": "Viernes",
|
|
15
|
-
"get_directions": "Direcciones",
|
|
16
|
-
"loading": "Cargando",
|
|
17
|
-
"location_search_placeholder": "Buscar tiendas por ciudad, estado o código postal",
|
|
18
|
-
"location_search_placeholder_w_location": "Tiendas cerca de {{location}}",
|
|
19
|
-
"message": "Mensaje",
|
|
20
|
-
"monday": "Lunes",
|
|
21
|
-
"name": {
|
|
22
|
-
"label": "Nombre",
|
|
23
|
-
"placeholder": "Nombre",
|
|
24
|
-
"required": "Se requiere un nombre"
|
|
25
|
-
},
|
|
26
|
-
"no_results": "Sin resultados",
|
|
27
|
-
"no_stores_found": "No se encontraron tiendas que coincidan con sus criterios.",
|
|
28
|
-
"number_stores_found": "{{count}} tiendas encontradas",
|
|
29
|
-
"open": "Abrir",
|
|
30
|
-
"opening_soon": "Próximamente",
|
|
31
|
-
"opens_at": "Abre a {{time}}",
|
|
32
|
-
"phone_number": {
|
|
33
|
-
"placeholder": "555 555 5555",
|
|
34
|
-
"required": "Se requiere un número de teléfono"
|
|
35
|
-
},
|
|
36
|
-
"quote_message": {
|
|
37
|
-
"placeholder": "Cualquier nota adicional"
|
|
38
|
-
},
|
|
39
|
-
"quote_submit": "Solicitar cotización",
|
|
40
|
-
"saturday": "Sábado",
|
|
41
|
-
"search_adjust_prompt": "Puedes intentar ajustar tus filtros de búsqueda o ampliar el radio de búsqueda.",
|
|
42
|
-
"select_store": "Seleccionar",
|
|
43
|
-
"sending": "Enviando",
|
|
44
|
-
"send_message_to": "Enviar un mensaje a {{name}}",
|
|
45
|
-
"storeName": "la tienda",
|
|
46
|
-
"store_romance": "{{name}} es tu destino para piezas de muebles contemporáneos y clásicos. Con más de 20 años de experiencia en la industria, nos enorgullecemos de ofrecer una calidad excepcional, un servicio personalizado y una amplia selección de muebles para el hogar que transforman los espacios en entornos de vida hermosos y funcionales.",
|
|
47
|
-
"store": {
|
|
48
|
-
"types": {
|
|
49
|
-
"retailer": "Minorista"
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
"sunday": "Domingo",
|
|
53
|
-
"thursday": "Jueves",
|
|
54
|
-
"tuesday": "Martes",
|
|
55
|
-
"use_my_location": "Usar mi ubicación actual",
|
|
56
|
-
"view_details": "Ver detalles",
|
|
57
|
-
"wednesday": "Miércoles"
|
|
58
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"closed": "Fermé",
|
|
3
|
-
"closes_at": "Ferme à {{time}}",
|
|
4
|
-
"closing_soon": "Fermeture imminente",
|
|
5
|
-
"consent": {
|
|
6
|
-
"label": "J'accepte que {{storeName}} me contacte par e-mail ou par téléphone."
|
|
7
|
-
},
|
|
8
|
-
"contact_online": "Contactez notre détaillant en ligne autorisé",
|
|
9
|
-
"distance_away": "{{distance}} {{distanceUnit}} de distance",
|
|
10
|
-
"email": {
|
|
11
|
-
"placeholder": "Email",
|
|
12
|
-
"required": "L'email est requis"
|
|
13
|
-
},
|
|
14
|
-
"friday": "Vendredi",
|
|
15
|
-
"get_directions": "Directions",
|
|
16
|
-
"loading": "Chargement",
|
|
17
|
-
"location_search_placeholder": "Rechercher des magasins par ville, état ou code postal",
|
|
18
|
-
"location_search_placeholder_w_location": "Magasins près de {{location}}",
|
|
19
|
-
"message": "Message",
|
|
20
|
-
"monday": "Lundi",
|
|
21
|
-
"name": {
|
|
22
|
-
"label": "Nom",
|
|
23
|
-
"placeholder": "Nom",
|
|
24
|
-
"required": "Le nom est requis"
|
|
25
|
-
},
|
|
26
|
-
"no_results": "Aucun résultat",
|
|
27
|
-
"no_stores_found": "Aucun magasin trouvé correspondant à vos critères.",
|
|
28
|
-
"number_stores_found": "{{count}} magasins trouvés",
|
|
29
|
-
"open": "Ouvrir",
|
|
30
|
-
"opening_soon": "Ouverture prochaine",
|
|
31
|
-
"opens_at": "Ouvre à {{time}}",
|
|
32
|
-
"phone_number": {
|
|
33
|
-
"placeholder": "555 555 5555",
|
|
34
|
-
"required": "Le numéro de téléphone est requis"
|
|
35
|
-
},
|
|
36
|
-
"quote_message": {
|
|
37
|
-
"placeholder": "Toute note supplémentaire"
|
|
38
|
-
},
|
|
39
|
-
"quote_submit": "Demander un devis",
|
|
40
|
-
"saturday": "Samedi",
|
|
41
|
-
"search_adjust_prompt": "Vous pouvez essayer d'ajuster vos filtres de recherche ou d'élargir le rayon de recherche.",
|
|
42
|
-
"select_store": "Sélectionner",
|
|
43
|
-
"sending": "Envoi",
|
|
44
|
-
"send_message_to": "Envoyer un message à {{name}}",
|
|
45
|
-
"storeName": "le magasin",
|
|
46
|
-
"store_romance": "{{name}} est votre destination pour des pièces de mobilier contemporaines et classiques. Avec plus de 20 ans d'expérience dans l'industrie, nous sommes fiers d'offrir une qualité exceptionnelle, un service personnalisé et une vaste sélection de meubles qui transforment les espaces en environnements de vie beaux et fonctionnels.",
|
|
47
|
-
"store": {
|
|
48
|
-
"types": {
|
|
49
|
-
"retailer": "Détaillant"
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
"sunday": "Dimanche",
|
|
53
|
-
"thursday": "Jeudi",
|
|
54
|
-
"tuesday": "Mardi",
|
|
55
|
-
"use_my_location": "Utiliser ma position actuelle",
|
|
56
|
-
"view_details": "Voir les détails",
|
|
57
|
-
"wednesday": "Mercredi"
|
|
58
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"closed": "Chiuso",
|
|
3
|
-
"closes_at": "Chiude alle {{time}}",
|
|
4
|
-
"closing_soon": "In chiusura presto",
|
|
5
|
-
"consent": {
|
|
6
|
-
"label": "Accetto di essere contattato da {{storeName}} tramite email o telefonata."
|
|
7
|
-
},
|
|
8
|
-
"contact_online": "Contatta il nostro rivenditore autorizzato online",
|
|
9
|
-
"distance_away": "{{distance}} {{distanceUnit}} di distanza",
|
|
10
|
-
"email": {
|
|
11
|
-
"placeholder": "Email",
|
|
12
|
-
"required": "L'email è obbligatoria"
|
|
13
|
-
},
|
|
14
|
-
"friday": "Venerdì",
|
|
15
|
-
"get_directions": "Indicazioni",
|
|
16
|
-
"loading": "Caricamento",
|
|
17
|
-
"location_search_placeholder": "Cerca negozi per città, stato o codice postale",
|
|
18
|
-
"location_search_placeholder_w_location": "Negozi vicino a {{location}}",
|
|
19
|
-
"message": "Messaggio",
|
|
20
|
-
"monday": "Lunedì",
|
|
21
|
-
"name": {
|
|
22
|
-
"label": "Nome",
|
|
23
|
-
"placeholder": "Nome",
|
|
24
|
-
"required": "Il nome è obbligatorio"
|
|
25
|
-
},
|
|
26
|
-
"no_results": "Nessun risultato",
|
|
27
|
-
"no_stores_found": "Nessun negozio trovato che corrisponda ai tuoi criteri.",
|
|
28
|
-
"number_stores_found": "Trovati {{count}} negozi",
|
|
29
|
-
"open": "Apri",
|
|
30
|
-
"opening_soon": "Apertura Imminente",
|
|
31
|
-
"opens_at": "Apre alle {{time}}",
|
|
32
|
-
"phone_number": {
|
|
33
|
-
"placeholder": "555 555 5555",
|
|
34
|
-
"required": "Il numero di telefono è obbligatorio"
|
|
35
|
-
},
|
|
36
|
-
"quote_message": {
|
|
37
|
-
"placeholder": "Eventuali note aggiuntive"
|
|
38
|
-
},
|
|
39
|
-
"quote_submit": "Richiesta di preventivo",
|
|
40
|
-
"saturday": "Sabato",
|
|
41
|
-
"search_adjust_prompt": "Puoi provare ad aggiustare i tuoi filtri di ricerca o ad ampliare il raggio di ricerca.",
|
|
42
|
-
"select_store": "Seleziona",
|
|
43
|
-
"sending": "Invio",
|
|
44
|
-
"send_message_to": "Invia un messaggio a {{name}}",
|
|
45
|
-
"storeName": "il negozio",
|
|
46
|
-
"store_romance": "{{name}} è la tua destinazione per pezzi di arredamento contemporanei e classici. Con oltre 20 anni di esperienza nel settore, ci vantiamo di offrire qualità eccezionale, servizio personalizzato e un'ampia selezione di mobili per la casa che trasformano gli spazi in ambienti abitativi belli e funzionali.",
|
|
47
|
-
"store": {
|
|
48
|
-
"types": {
|
|
49
|
-
"retailer": "Rivenditore"
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
"sunday": "Domenica",
|
|
53
|
-
"thursday": "Giovedì",
|
|
54
|
-
"tuesday": "Martedì",
|
|
55
|
-
"use_my_location": "Usa la mia posizione attuale",
|
|
56
|
-
"view_details": "Visualizza dettagli",
|
|
57
|
-
"wednesday": "Mercoledì"
|
|
58
|
-
}
|
package/src/main.jsx
DELETED
package/vite.config.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'vite'
|
|
2
|
-
import react from '@vitejs/plugin-react'
|
|
3
|
-
import tailwindcss from '@tailwindcss/vite'
|
|
4
|
-
import path from 'path'
|
|
5
|
-
import fs from 'fs'
|
|
6
|
-
|
|
7
|
-
const entriesDir = path.resolve(__dirname, 'src/entries')
|
|
8
|
-
|
|
9
|
-
const entryPoints = Object.fromEntries(
|
|
10
|
-
fs
|
|
11
|
-
.readdirSync(entriesDir)
|
|
12
|
-
.filter((file) => /\.(js|jsx|ts|tsx)$/.test(file))
|
|
13
|
-
.map((file) => [path.parse(file).name, path.join(entriesDir, file)])
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
// mark packages as external by exact name or prefix
|
|
17
|
-
const makeExternal = (externals) => {
|
|
18
|
-
const exact = new Set(externals)
|
|
19
|
-
return (id) => {
|
|
20
|
-
if (exact.has(id)) return true
|
|
21
|
-
// handle subpath imports like react/jsx-runtime
|
|
22
|
-
for (const pkg of exact) {
|
|
23
|
-
if (id.startsWith(`${pkg}/`)) return true
|
|
24
|
-
}
|
|
25
|
-
// radix wildcard
|
|
26
|
-
if (id.startsWith('@radix-ui/')) return true
|
|
27
|
-
return false
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export default defineConfig({
|
|
32
|
-
plugins: [
|
|
33
|
-
react({
|
|
34
|
-
babel: { plugins: [['babel-plugin-react-compiler']] },
|
|
35
|
-
}),
|
|
36
|
-
tailwindcss(),
|
|
37
|
-
],
|
|
38
|
-
resolve: {
|
|
39
|
-
alias: { '@': path.resolve(__dirname, 'src') },
|
|
40
|
-
},
|
|
41
|
-
build: {
|
|
42
|
-
lib: {
|
|
43
|
-
entry: entryPoints,
|
|
44
|
-
formats: ['es'],
|
|
45
|
-
fileName: (_format, entryName) => `${entryName}.js`,
|
|
46
|
-
},
|
|
47
|
-
minify: 'terser',
|
|
48
|
-
cssMinify: 'esbuild',
|
|
49
|
-
terserOptions: {
|
|
50
|
-
compress: { passes: 2, drop_console: true, drop_debugger: true },
|
|
51
|
-
format: { comments: false },
|
|
52
|
-
},
|
|
53
|
-
rollupOptions: {
|
|
54
|
-
external: makeExternal([
|
|
55
|
-
'react',
|
|
56
|
-
'react-dom',
|
|
57
|
-
'react/jsx-runtime',
|
|
58
|
-
'i18next',
|
|
59
|
-
'react-i18next',
|
|
60
|
-
|
|
61
|
-
// OPTIONAL: if you want these to be owned by the host app too
|
|
62
|
-
// '@vis.gl/react-google-maps',
|
|
63
|
-
// '@rudderstack/analytics-js',
|
|
64
|
-
]),
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
})
|
|
File without changes
|