@aurora-studio/starter-core 0.1.11 → 0.1.13

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.
@@ -1 +1 @@
1
- import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export function ProductCardSkeleton(){return _jsxs("div",{className:"group p-4 rounded-xl bg-aurora-surface border border-aurora-border overflow-hidden w-full min-w-[160px] min-h-[280px] flex flex-col",children:[_jsxs("div",{className:"block",children:[_jsx("div",{className:"aspect-square rounded-lg bg-aurora-surface-hover mb-3 overflow-hidden skeleton-shimmer"}),_jsx("div",{className:"h-4 rounded skeleton-shimmer w-3/4 mb-1"}),_jsx("div",{className:"h-4 rounded skeleton-shimmer w-1/4"})]}),_jsx("div",{className:"mt-auto pt-3",children:_jsx("div",{className:"h-12 rounded-xl skeleton-shimmer w-full"})})]})}
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export function ProductCardSkeleton(){return _jsxs("div",{className:"group p-4 rounded-xl bg-aurora-surface border border-aurora-border overflow-hidden w-full min-w-[160px] min-h-[280px] flex flex-col",children:[_jsxs("div",{className:"block",children:[_jsx("div",{className:"aspect-square rounded-lg mb-3 overflow-hidden skeleton-shimmer"}),_jsx("div",{className:"h-4 rounded skeleton-shimmer w-3/4 mb-1"}),_jsx("div",{className:"h-4 rounded skeleton-shimmer w-1/4"})]}),_jsx("div",{className:"mt-auto pt-3",children:_jsx("div",{className:"h-12 rounded-xl skeleton-shimmer w-full"})})]})}
@@ -1 +1 @@
1
- "use client";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{useState,useEffect,useRef,useCallback}from"react";import Link from"next/link";import{Search}from"lucide-react";import{formatPrice,toCents}from"../lib/format-price";import{search}from"../lib/aurora";import{holmesSearch}from"../lib/holmes-events";import{useCart}from"./CartProvider";import{ProductImage}from"./ProductImage";const RECENT_KEY="aurora-search-recent";const RECENT_MAX=5;function loadRecent(){if(typeof window==="undefined")return[];try{const stored=localStorage.getItem(RECENT_KEY);return stored?JSON.parse(stored):[]}catch{return[]}}function saveRecent(terms){if(typeof window==="undefined")return;localStorage.setItem(RECENT_KEY,JSON.stringify(terms.slice(0,RECENT_MAX)))}export function SearchDropdown({vendorId:vendorId,placeholder:placeholder="Search milk, bananas, pasta…",fullWidth:fullWidth,variant:variant="default",excludeDietary:excludeDietary=[],getRecipeSuggestion:getRecipeSuggestion}){const[query,setQuery]=useState("");const[hits,setHits]=useState([]);const[loading,setLoading]=useState(false);const[open,setOpen]=useState(false);const[recentSearches,setRecentSearches]=useState([]);const debounceRef=useRef(null);const containerRef=useRef(null);const{addItem:addItem}=useCart();useEffect(()=>{setRecentSearches(loadRecent())},[]);const addToRecent=useCallback(term=>{const t=term.trim().toLowerCase();if(!t)return;setRecentSearches(prev=>{const next=[t,...prev.filter(x=>x!==t)].slice(0,RECENT_MAX);saveRecent(next);return next})},[]);const doSearch=useCallback(async q=>{if(!q.trim()){setHits([]);return}holmesSearch(q.trim());setLoading(true);try{const res=await search({q:q.trim(),limit:12,vendorId:vendorId,excludeDietary:excludeDietary.length?excludeDietary:undefined});setHits(res.hits??[])}catch{setHits([])}finally{setLoading(false)}},[vendorId,excludeDietary]);useEffect(()=>{if(debounceRef.current)clearTimeout(debounceRef.current);if(!query.trim()){setHits([]);return}setOpen(true);debounceRef.current=setTimeout(()=>doSearch(query),180);return()=>{if(debounceRef.current)clearTimeout(debounceRef.current)}},[query,doSearch]);useEffect(()=>{function handleClickOutside(e){if(containerRef.current&&!containerRef.current.contains(e.target)){setOpen(false)}}document.addEventListener("mousedown",handleClickOutside);return()=>document.removeEventListener("mousedown",handleClickOutside)},[]);const categories=[...new Set(hits.map(h=>h.category_name??h.category).filter(Boolean))].slice(0,3);const brands=[...new Set(hits.map(h=>h.brand??h.brand_name).filter(Boolean))].slice(0,3);const handleProductSelect=(hit,quickAdd)=>{addToRecent(query);if(quickAdd&&hit.price!=null&&Number(hit.price)>0&&hit.tableSlug){addItem({recordId:hit.recordId,tableSlug:hit.tableSlug,name:hit.name??hit.title??hit.snippet??hit.recordId??"",unitAmount:toCents(hit.price)??0,imageUrl:hit.image_url})}};const showRecent=open&&query.trim()&&!loading&&hits.length===0&&recentSearches.length>0;const recipeSuggestion=getRecipeSuggestion?.(query)??null;const showRecipeSuggestion=open&&query.trim().length>=2&&recipeSuggestion&&!loading;const fieldShell=variant==="default"?"flex w-full items-center rounded-lg border border-aurora-border/90 bg-aurora-surface shadow-sm transition-colors focus-within:border-aurora-primary/70 focus-within:ring-1 focus-within:ring-aurora-primary/40":"flex w-full items-center rounded-lg bg-transparent";const inputClass="flex-1 min-w-0 h-10 py-0 pr-3 text-sm leading-normal text-aurora-text placeholder:text-aurora-muted "+"border-0 bg-transparent shadow-none outline-none ring-0 focus:outline-none focus:ring-0 "+"[&::-webkit-search-cancel-button]:appearance-none [&::-webkit-search-decoration]:appearance-none";return _jsxs("div",{ref:containerRef,className:`relative w-full ${fullWidth?"":"max-w-[280px]"}`,children:[_jsxs("div",{className:fieldShell,children:[_jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center text-aurora-muted pointer-events-none","aria-hidden":true,children:_jsx(Search,{className:"h-4 w-4 shrink-0"})}),_jsx("input",{type:"search",value:query,onChange:e=>setQuery(e.target.value),onFocus:()=>(query.trim()||recentSearches.length)&&setOpen(true),placeholder:placeholder,className:inputClass,"aria-label":"Search products"})]}),open&&(query.trim()||showRecent)&&_jsx("div",{className:"absolute top-full left-0 right-0 mt-1 rounded-component bg-aurora-surface border border-aurora-border shadow-xl z-[9999] max-h-96 overflow-y-auto",children:loading?_jsx("div",{className:"p-4 text-aurora-muted text-sm",children:"Searching…"}):hits.length===0&&!showRecent&&!showRecipeSuggestion?_jsx("div",{className:"p-4 text-aurora-muted text-sm",children:"No results"}):_jsxs("div",{className:"py-2",children:[showRecipeSuggestion&&_jsx("div",{className:"px-3 py-1.5 text-xs font-semibold uppercase tracking-wider text-aurora-muted border-b border-aurora-border",children:"Suggestions"}),showRecipeSuggestion&&_jsxs(Link,{href:`/catalogue?q=${encodeURIComponent(recipeSuggestion.replace("?","").split(" ")[0].toLowerCase())}`,onClick:()=>{addToRecent(recipeSuggestion);setOpen(false)},className:"flex items-center gap-3 px-4 py-2 hover:bg-aurora-surface-hover transition-colors border-b border-aurora-border",children:[_jsx(Search,{className:"w-4 h-4 text-aurora-muted shrink-0"}),_jsx("span",{className:"font-medium truncate",children:recipeSuggestion})]}),hits.length>0&&_jsxs(_Fragment,{children:[_jsx("div",{className:"px-3 py-1.5 text-xs font-semibold uppercase tracking-wider text-aurora-muted border-b border-aurora-border",children:"Products"}),_jsx("ul",{children:hits.slice(0,6).map(hit=>_jsx("li",{className:"group/item",children:_jsxs("div",{className:"flex items-center gap-3 px-4 py-2 hover:bg-aurora-surface-hover transition-colors",children:[_jsxs(Link,{href:`/catalogue/${hit.recordId}`,onClick:()=>{handleProductSelect(hit);setOpen(false)},className:"flex items-center gap-3 flex-1 min-w-0",children:[_jsx("div",{className:"w-10 h-10 rounded-component bg-aurora-surface-hover shrink-0 overflow-hidden",children:_jsx(ProductImage,{src:hit.image_url,className:"w-full h-full",thumbnail:true,fallback:_jsx("div",{className:"w-full h-full flex items-center justify-center text-aurora-muted text-xs",children:"-"})})}),_jsxs("div",{className:"flex-1 min-w-0",children:[_jsx("p",{className:"font-medium truncate",children:hit.name??hit.title??hit.snippet??hit.recordId}),hit.price!=null&&Number(hit.price)>0&&_jsx("p",{className:"text-sm text-aurora-primary font-semibold",children:formatPrice(toCents(hit.price)??0)})]})]}),hit.price!=null&&Number(hit.price)>0&&_jsx("button",{type:"button",onClick:e=>{e.preventDefault();handleProductSelect(hit,true);setOpen(false)},className:"shrink-0 px-3 py-1.5 rounded-lg bg-aurora-primary text-white text-xs font-medium hover:bg-aurora-primary-dark transition-colors opacity-0 group-hover/item:opacity-100",children:"Quick add"})]})},`${hit.tableSlug}-${hit.recordId}`))}),categories.length>0&&_jsxs(_Fragment,{children:[_jsx("div",{className:"px-3 py-1.5 text-xs font-semibold uppercase tracking-wider text-aurora-muted border-t border-b border-aurora-border mt-1",children:"Categories"}),_jsx("ul",{children:categories.map(cat=>_jsx("li",{children:_jsx(Link,{href:`/catalogue?category=${encodeURIComponent(String(cat).toLowerCase().replace(/\s+/g,"-"))}`,onClick:()=>{addToRecent(query);setOpen(false)},className:"flex items-center gap-3 px-4 py-2 hover:bg-aurora-surface-hover transition-colors",children:_jsx("span",{className:"font-medium truncate",children:cat})})},cat))})]}),brands.length>0&&_jsxs(_Fragment,{children:[_jsx("div",{className:"px-3 py-1.5 text-xs font-semibold uppercase tracking-wider text-aurora-muted border-t border-b border-aurora-border mt-1",children:"Brands"}),_jsx("ul",{children:brands.map(brand=>_jsx("li",{children:_jsx(Link,{href:`/catalogue?q=${encodeURIComponent(brand)}`,onClick:()=>{addToRecent(query);setOpen(false)},className:"flex items-center gap-3 px-4 py-2 hover:bg-aurora-surface-hover transition-colors",children:_jsx("span",{className:"font-medium truncate",children:brand})})},brand))})]})]}),showRecent&&_jsxs(_Fragment,{children:[_jsx("div",{className:"px-3 py-1.5 text-xs font-semibold uppercase tracking-wider text-aurora-muted border-b border-aurora-border",children:"Recent searches"}),_jsx("ul",{children:recentSearches.map(term=>_jsx("li",{children:_jsxs("button",{type:"button",onClick:()=>{setQuery(term);doSearch(term)},className:"w-full text-left flex items-center gap-3 px-4 py-2 hover:bg-aurora-surface-hover transition-colors",children:[_jsx(Search,{className:"w-4 h-4 text-aurora-muted shrink-0"}),_jsx("span",{className:"font-medium truncate",children:term})]})},term))})]})]})})]})}
1
+ "use client";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{useState,useEffect,useRef,useCallback}from"react";import Link from"next/link";import{Search}from"lucide-react";import{formatPrice,toCents}from"../lib/format-price";import{search}from"../lib/aurora";import{holmesSearch}from"../lib/holmes-events";import{useCart}from"./CartProvider";import{ProductImage}from"./ProductImage";const RECENT_KEY="aurora-search-recent";const RECENT_MAX=5;function loadRecent(){if(typeof window==="undefined")return[];try{const stored=localStorage.getItem(RECENT_KEY);return stored?JSON.parse(stored):[]}catch{return[]}}function saveRecent(terms){if(typeof window==="undefined")return;localStorage.setItem(RECENT_KEY,JSON.stringify(terms.slice(0,RECENT_MAX)))}function catalogueQueryFromRecipeSuggestion(suggestion){return suggestion.replace(/\?$/,"").trim()}export function SearchDropdown({vendorId:vendorId,placeholder:placeholder="Search milk, bananas, pasta…",fullWidth:fullWidth,variant:variant="default",excludeDietary:excludeDietary=[],getRecipeSuggestion:getRecipeSuggestion}){const[query,setQuery]=useState("");const[hits,setHits]=useState([]);const[loading,setLoading]=useState(false);const[open,setOpen]=useState(false);const[recentSearches,setRecentSearches]=useState([]);const debounceRef=useRef(null);const containerRef=useRef(null);const{addItem:addItem}=useCart();useEffect(()=>{setRecentSearches(loadRecent())},[]);const addToRecent=useCallback(term=>{const t=term.trim().toLowerCase();if(!t)return;setRecentSearches(prev=>{const next=[t,...prev.filter(x=>x!==t)].slice(0,RECENT_MAX);saveRecent(next);return next})},[]);const doSearch=useCallback(async q=>{if(!q.trim()){setHits([]);return}holmesSearch(q.trim());setLoading(true);try{const res=await search({q:q.trim(),limit:12,vendorId:vendorId,excludeDietary:excludeDietary.length?excludeDietary:undefined});setHits(res.hits??[])}catch{setHits([])}finally{setLoading(false)}},[vendorId,excludeDietary]);useEffect(()=>{if(debounceRef.current)clearTimeout(debounceRef.current);if(!query.trim()){setHits([]);return}setOpen(true);debounceRef.current=setTimeout(()=>doSearch(query),180);return()=>{if(debounceRef.current)clearTimeout(debounceRef.current)}},[query,doSearch]);useEffect(()=>{function handleClickOutside(e){if(containerRef.current&&!containerRef.current.contains(e.target)){setOpen(false)}}document.addEventListener("mousedown",handleClickOutside);return()=>document.removeEventListener("mousedown",handleClickOutside)},[]);const categories=[...new Set(hits.map(h=>h.category_name??h.category).filter(Boolean))].slice(0,3);const brands=[...new Set(hits.map(h=>h.brand??h.brand_name).filter(Boolean))].slice(0,3);const handleProductSelect=(hit,quickAdd)=>{addToRecent(query);if(quickAdd&&hit.price!=null&&Number(hit.price)>0&&hit.tableSlug){addItem({recordId:hit.recordId,tableSlug:hit.tableSlug,name:hit.name??hit.title??hit.snippet??hit.recordId??"",unitAmount:toCents(hit.price)??0,imageUrl:hit.image_url})}};const showRecent=open&&query.trim()&&!loading&&hits.length===0&&recentSearches.length>0;const recipeSuggestion=getRecipeSuggestion?.(query)??null;const showRecipeSuggestion=open&&query.trim().length>=2&&recipeSuggestion&&!loading;const resolvedCatalogueQ=recipeSuggestion?catalogueQueryFromRecipeSuggestion(recipeSuggestion):query.trim();const goToCatalogueSearch=qRaw=>{const t=qRaw.trim();if(!t)return;const sug=getRecipeSuggestion?.(t)??null;if(sug)setQuery(sug);else setQuery(t);const qFinal=sug?catalogueQueryFromRecipeSuggestion(sug):t;window.location.assign(`/catalogue?q=${encodeURIComponent(qFinal)}`)};const fieldShell=variant==="default"?"flex w-full items-center rounded-lg border border-aurora-border/90 bg-aurora-surface shadow-sm transition-colors focus-within:border-aurora-primary/70 focus-within:ring-1 focus-within:ring-aurora-primary/40":"flex w-full items-center rounded-lg bg-transparent";const inputClass="flex-1 min-w-0 h-10 py-0 pr-3 text-sm leading-normal text-aurora-text placeholder:text-aurora-muted "+"border-0 bg-transparent shadow-none outline-none ring-0 focus:outline-none focus:ring-0 "+"[&::-webkit-search-cancel-button]:appearance-none [&::-webkit-search-decoration]:appearance-none";return _jsxs("div",{ref:containerRef,className:`relative w-full ${fullWidth?"":"max-w-[280px]"}`,children:[_jsxs("div",{className:fieldShell,children:[_jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center text-aurora-muted pointer-events-none","aria-hidden":true,children:_jsx(Search,{className:"h-4 w-4 shrink-0"})}),_jsx("input",{type:"search",value:query,onChange:e=>setQuery(e.target.value),onFocus:()=>(query.trim()||recentSearches.length)&&setOpen(true),onKeyDown:e=>{if(e.key!=="Enter")return;e.preventDefault();goToCatalogueSearch(query);setOpen(false)},placeholder:placeholder,className:inputClass,"aria-label":"Search products"})]}),open&&(query.trim()||showRecent)&&_jsx("div",{className:"absolute top-full left-0 right-0 mt-1 rounded-component bg-aurora-surface border border-aurora-border shadow-xl z-[9999] max-h-96 overflow-y-auto",children:loading?_jsx("div",{className:"p-4 text-aurora-muted text-sm",children:"Searching…"}):hits.length===0&&!showRecent&&!showRecipeSuggestion?_jsx("div",{className:"p-4 text-aurora-muted text-sm",children:"No results"}):_jsxs("div",{className:"py-2",children:[showRecipeSuggestion&&_jsx("div",{className:"px-3 py-1.5 text-xs font-semibold uppercase tracking-wider text-aurora-muted border-b border-aurora-border",children:"Suggestions"}),showRecipeSuggestion&&_jsxs(Link,{href:`/catalogue?q=${encodeURIComponent(resolvedCatalogueQ)}`,onClick:()=>{setQuery(recipeSuggestion);addToRecent(resolvedCatalogueQ);setOpen(false)},className:"flex items-center gap-3 px-4 py-2 hover:bg-aurora-surface-hover transition-colors border-b border-aurora-border",children:[_jsx(Search,{className:"w-4 h-4 text-aurora-muted shrink-0"}),_jsx("span",{className:"font-medium truncate",children:recipeSuggestion})]}),hits.length>0&&_jsxs(_Fragment,{children:[_jsx("div",{className:"px-3 py-1.5 text-xs font-semibold uppercase tracking-wider text-aurora-muted border-b border-aurora-border",children:"Products"}),_jsx("ul",{children:hits.slice(0,6).map(hit=>_jsx("li",{className:"group/item",children:_jsxs("div",{className:"flex items-center gap-3 px-4 py-2 hover:bg-aurora-surface-hover transition-colors",children:[_jsxs(Link,{href:`/catalogue/${hit.recordId}`,onClick:()=>{const label=String(hit.name??hit.title??hit.snippet??hit.recordId??"");if(label)setQuery(label);handleProductSelect(hit);setOpen(false)},className:"flex items-center gap-3 flex-1 min-w-0",children:[_jsx("div",{className:"w-10 h-10 rounded-component bg-aurora-surface-hover shrink-0 overflow-hidden",children:_jsx(ProductImage,{src:hit.image_url,className:"w-full h-full",thumbnail:true,fallback:_jsx("div",{className:"w-full h-full flex items-center justify-center text-aurora-muted text-xs",children:"-"})})}),_jsxs("div",{className:"flex-1 min-w-0",children:[_jsx("p",{className:"font-medium truncate",children:hit.name??hit.title??hit.snippet??hit.recordId}),hit.price!=null&&Number(hit.price)>0&&_jsx("p",{className:"text-sm text-aurora-primary font-semibold",children:formatPrice(toCents(hit.price)??0)})]})]}),hit.price!=null&&Number(hit.price)>0&&_jsx("button",{type:"button",onClick:e=>{e.preventDefault();const label=String(hit.name??hit.title??hit.snippet??hit.recordId??"");if(label)setQuery(label);handleProductSelect(hit,true);setOpen(false)},className:"shrink-0 px-3 py-1.5 rounded-lg bg-aurora-primary text-white text-xs font-medium hover:bg-aurora-primary-dark transition-colors opacity-0 group-hover/item:opacity-100",children:"Quick add"})]})},`${hit.tableSlug}-${hit.recordId}`))}),categories.length>0&&_jsxs(_Fragment,{children:[_jsx("div",{className:"px-3 py-1.5 text-xs font-semibold uppercase tracking-wider text-aurora-muted border-t border-b border-aurora-border mt-1",children:"Categories"}),_jsx("ul",{children:categories.map(cat=>_jsx("li",{children:_jsx(Link,{href:`/catalogue?category=${encodeURIComponent(String(cat).toLowerCase().replace(/\s+/g,"-"))}`,onClick:()=>{setQuery(String(cat));addToRecent(String(cat));setOpen(false)},className:"flex items-center gap-3 px-4 py-2 hover:bg-aurora-surface-hover transition-colors",children:_jsx("span",{className:"font-medium truncate",children:cat})})},cat))})]}),brands.length>0&&_jsxs(_Fragment,{children:[_jsx("div",{className:"px-3 py-1.5 text-xs font-semibold uppercase tracking-wider text-aurora-muted border-t border-b border-aurora-border mt-1",children:"Brands"}),_jsx("ul",{children:brands.map(brand=>_jsx("li",{children:_jsx(Link,{href:`/catalogue?q=${encodeURIComponent(brand)}`,onClick:()=>{setQuery(String(brand));addToRecent(String(brand));setOpen(false)},className:"flex items-center gap-3 px-4 py-2 hover:bg-aurora-surface-hover transition-colors",children:_jsx("span",{className:"font-medium truncate",children:brand})})},brand))})]})]}),showRecent&&_jsxs(_Fragment,{children:[_jsx("div",{className:"px-3 py-1.5 text-xs font-semibold uppercase tracking-wider text-aurora-muted border-b border-aurora-border",children:"Recent searches"}),_jsx("ul",{children:recentSearches.map(term=>_jsx("li",{children:_jsxs("button",{type:"button",onClick:()=>{setQuery(term);doSearch(term)},className:"w-full text-left flex items-center gap-3 px-4 py-2 hover:bg-aurora-surface-hover transition-colors",children:[_jsx(Search,{className:"w-4 h-4 text-aurora-muted shrink-0"}),_jsx("span",{className:"font-medium truncate",children:term})]})},term))})]})]})})]})}
@@ -1 +1 @@
1
- "use client";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import Link from"next/link";import{useCart}from"./CartProvider";import{formatPrice}from"../lib/format-price";import{ShoppingBag}from"lucide-react";const SHIPPING_CENTS=250;const FREE_DELIVERY_THRESHOLD_CENTS=2500;export function SmartCartPanel(){const{items:items,total:total}=useCart();const count=items.reduce((s,i)=>s+i.quantity,0);const shipping=count>0?SHIPPING_CENTS:0;const grandTotal=total+shipping;const toFreeDelivery=Math.max(0,FREE_DELIVERY_THRESHOLD_CENTS-total);if(count===0)return null;return _jsx("div",{className:"sticky bottom-0 z-40 mt-10 px-6 py-4 rounded-2xl bg-aurora-surface border border-aurora-border shadow-xl shadow-aurora-primary/5",children:_jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between sm:gap-6 gap-3 max-w-4xl mx-auto",children:[_jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[_jsx("span",{className:"flex items-center justify-center w-11 h-11 shrink-0 rounded-xl bg-aurora-primary/15 text-aurora-primary",children:_jsx(ShoppingBag,{className:"w-5 h-5"})}),_jsxs("div",{className:"min-w-0",children:[_jsxs("p",{className:"font-semibold text-aurora-text text-base",children:[count," ",count===1?"item":"items"," · ",formatPrice(grandTotal)]}),toFreeDelivery>0&&_jsxs("p",{className:"text-sm text-aurora-primary font-medium mt-0.5",children:["Add ",formatPrice(toFreeDelivery)," more for free delivery"]}),toFreeDelivery<=0&&total>0&&_jsx("p",{className:"text-sm text-aurora-primary font-medium mt-0.5",children:"You've unlocked free delivery"})]})]}),_jsx(Link,{href:"/cart",className:"inline-flex items-center justify-center px-6 py-2.5 rounded-xl bg-aurora-primary text-white font-semibold text-sm hover:bg-aurora-primary-dark transition-colors shrink-0 shadow-lg shadow-aurora-primary/25",children:"View cart · Checkout"})]})})}
1
+ "use client";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import Link from"next/link";import{useCart}from"./CartProvider";import{formatPrice}from"../lib/format-price";import{ShoppingBag}from"lucide-react";const SHIPPING_CENTS=250;const FREE_DELIVERY_THRESHOLD_CENTS=2500;export function SmartCartPanel(){const{items:items,total:total}=useCart();const count=items.reduce((s,i)=>s+i.quantity,0);const shipping=count>0?SHIPPING_CENTS:0;const grandTotal=total+shipping;const toFreeDelivery=Math.max(0,FREE_DELIVERY_THRESHOLD_CENTS-total);if(count===0)return null;return _jsx("div",{className:"fixed inset-x-0 bottom-0 z-50 flex justify-center px-4 pt-2 pb-[max(0.75rem,env(safe-area-inset-bottom))] pointer-events-none","data-smart-cart-panel":true,children:_jsxs("div",{className:"pointer-events-auto w-full max-w-6xl flex flex-col sm:flex-row sm:items-center sm:justify-between sm:gap-6 gap-3 rounded-2xl border border-aurora-border/80 bg-aurora-surface px-4 py-3.5 sm:px-6 sm:py-4 shadow-xl shadow-black/10 dark:shadow-black/40 dark:border-aurora-border/60",children:[_jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[_jsx("span",{className:"flex items-center justify-center w-11 h-11 shrink-0 rounded-xl bg-aurora-primary/15 text-aurora-primary",children:_jsx(ShoppingBag,{className:"w-5 h-5"})}),_jsxs("div",{className:"min-w-0",children:[_jsxs("p",{className:"font-semibold text-aurora-text text-base",children:[count," ",count===1?"item":"items"," · ",formatPrice(grandTotal)]}),toFreeDelivery>0&&_jsxs("p",{className:"text-sm text-aurora-primary font-medium mt-0.5",children:["Add ",formatPrice(toFreeDelivery)," more for free delivery"]}),toFreeDelivery<=0&&total>0&&_jsx("p",{className:"text-sm text-aurora-primary font-medium mt-0.5",children:"You've unlocked free delivery"})]})]}),_jsx(Link,{href:"/cart",className:"inline-flex items-center justify-center px-6 py-2.5 rounded-xl bg-aurora-primary text-white font-semibold text-sm hover:bg-aurora-primary-dark transition-colors shrink-0 shadow-lg shadow-aurora-primary/25",children:"View cart · Checkout"})]})})}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aurora-studio/starter-core",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "scripts": {
5
5
  "build": "tsc -p tsconfig.build.json && node scripts/minify-dist.mjs",
6
6
  "prepare": "tsc -p tsconfig.build.json && node scripts/minify-dist.mjs",
@@ -31,14 +31,14 @@
31
31
  "access": "public"
32
32
  },
33
33
  "peerDependencies": {
34
- "@aurora-studio/sdk": "^0.2.31",
34
+ "@aurora-studio/sdk": "^0.2.32",
35
35
  "lucide-react": ">=0.400",
36
36
  "next": ">=14",
37
37
  "react": "^18 || ^19",
38
38
  "react-dom": "^18 || ^19"
39
39
  },
40
40
  "devDependencies": {
41
- "@aurora-studio/sdk": "^0.2.31",
41
+ "@aurora-studio/sdk": "^0.2.32",
42
42
  "@eslint/js": "^10.0.1",
43
43
  "@types/node": "^22.0.0",
44
44
  "@types/react": "^19.0.0",