/** * Ajax Search Configuration * Type definitions and default values for the Ajax Search feature */ // Ajax Search Settings Interface export interface AjaxSearchSettings { // General Settings enabled: boolean; minChars: number; maxResults: number; searchDelay: number; enableCache: boolean; cacheExpiry: number; // Search Settings searchIn: { title: boolean; content: boolean; excerpt: boolean; sku: boolean; categories: boolean; tags: boolean; attributes: boolean; }; includeOutOfStock: boolean; excludeCategories: number[]; excludeProducts: number[]; // Display Settings showCategories: boolean; showSku: boolean; showPrice: boolean; showImage: boolean; showDescription: boolean; descriptionLength: number; showStock: boolean; showRating: boolean; showSaleBadge: boolean; // Suggestions showRecentSearches: boolean; maxRecentSearches: number; showPopularSearches: boolean; maxPopularSearches: number; // Template template: 'modern' | 'classic' | 'modal'; // Style Settings layout: 'dropdown' | 'fullwidth' | 'modal'; showSearchButton: boolean; searchButtonText: string; resultColumns: 1 | 2; primaryColor: string; secondaryColor: string; textColor: string; backgroundColor: string; borderRadius: number; boxShadow: 'none' | 'light' | 'medium' | 'heavy'; // Width Control maxWidth: number; fullWidth: boolean; // Button & Input Style inputHeight: number; inputFontSize: number; inputBorderColor: string; inputBorderWidth: number; inputFocusBorderColor: string; // Typography (Pro) fontFamily: string; fontSize: number; titleFontSize: number; // Text Customization placeholderText: string; noResultsText: string; viewAllText: string; searchingText: string; // Analytics (Pro only) enableAnalytics: boolean; trackSearches: boolean; trackClicks: boolean; // Advanced (Pro only) enableSynonyms: boolean; synonyms: SynonymGroup[]; enableTypoTolerance: boolean; typoThreshold: number; boostExactMatch: boolean; boostTitleMatch: boolean; titleBoostWeight: number; // Field Weights (Pro only) fieldWeights: { title: number; content: number; excerpt: number; sku: number; }; } // Synonym Group Interface export interface SynonymGroup { id: string; words: string[]; } // Search Analytics Interface export interface SearchAnalytics { totalSearches: number; uniqueSearches: number; searchesWithResults: number; searchesWithoutResults: number; averageResultsPerSearch: number; clickThroughRate: number; topSearchTerms: SearchTerm[]; noResultSearches: SearchTerm[]; dailySearches: DailySearchData[]; popularProducts: PopularProduct[]; } export interface SearchTerm { term: string; count: number; clicks: number; ctr: number; } export interface DailySearchData { date: string; searches: number; clicks: number; } export interface PopularProduct { id: number; name: string; image: string; clickCount: number; } // Default Settings export const defaultAjaxSearchSettings: AjaxSearchSettings = { // General enabled: false, minChars: 2, maxResults: 8, searchDelay: 300, enableCache: true, cacheExpiry: 3600, // Search Settings searchIn: { title: true, content: true, excerpt: true, sku: true, categories: true, tags: false, attributes: false, }, includeOutOfStock: true, excludeCategories: [], excludeProducts: [], // Display Settings showCategories: true, showSku: false, showPrice: true, showImage: true, showDescription: true, descriptionLength: 60, showStock: true, showRating: true, showSaleBadge: true, // Suggestions showRecentSearches: true, maxRecentSearches: 5, showPopularSearches: true, maxPopularSearches: 5, // Template template: 'modern', // Style Settings layout: 'dropdown', showSearchButton: false, searchButtonText: 'Search', resultColumns: 1, primaryColor: '#00226b', secondaryColor: '#153372', textColor: '#333333', backgroundColor: '#ffffff', borderRadius: 8, boxShadow: 'medium', // Width Control maxWidth: 600, fullWidth: false, // Button & Input Style inputHeight: 48, inputFontSize: 15, inputBorderColor: '#dddddd', inputBorderWidth: 1, inputFocusBorderColor: '#2271b1', // Typography (Pro) fontFamily: 'inherit', fontSize: 14, titleFontSize: 14, // Text Customization placeholderText: 'Search products...', noResultsText: 'No products found', viewAllText: 'View all results', searchingText: 'Searching...', // Analytics (Pro) enableAnalytics: false, trackSearches: true, trackClicks: true, // Advanced (Pro) enableSynonyms: false, synonyms: [], enableTypoTolerance: false, typoThreshold: 2, boostExactMatch: true, boostTitleMatch: true, titleBoostWeight: 2, // Field Weights (Pro) fieldWeights: { title: 5, content: 2, excerpt: 3, sku: 4, }, }; // REST API Endpoints export const AJAX_SEARCH_API = { settings: '/swift-commerce/v1/ajax-search/settings', analytics: '/swift-commerce/v1/ajax-search/analytics', clearAnalytics: '/swift-commerce/v1/ajax-search/analytics/clear', exportAnalytics: '/swift-commerce/v1/ajax-search/analytics/export', trending: '/swift-commerce/v1/ajax-search/trending', }; // Category Option Interface export interface CategoryOption { id: number; name: string; slug: string; count: number; parent: number; } // Tab Definitions export type AjaxSearchTab = 'general' | 'search' | 'customization' | 'analytics'; export const AJAX_SEARCH_TABS: { id: AjaxSearchTab; label: string; description: string }[] = [ { id: 'general', label: 'General', description: 'Basic settings and behavior configuration', }, { id: 'search', label: 'Search', description: 'Configure search fields and filtering options', }, { id: 'customization', label: 'Appearance', description: 'Customize appearance and display settings', }, { id: 'analytics', label: 'Analytics', description: 'View search analytics and insights', }, ]; // Layout Options export const LAYOUT_OPTIONS = [ { value: 'dropdown', label: 'Dropdown', description: 'Results appear below the search input' }, { value: 'fullwidth', label: 'Full Width', description: 'Results span the full width of the page' }, { value: 'modal', label: 'Modal', description: 'Results appear in a centered modal overlay' }, ]; // Shadow Options export const SHADOW_OPTIONS = [ { value: 'none', label: 'None' }, { value: 'light', label: 'Light' }, { value: 'medium', label: 'Medium' }, { value: 'heavy', label: 'Heavy' }, ]; // Template Presets — apply design values on select export const TEMPLATE_PRESETS: Record> = { modern: { primaryColor: '#00226b', secondaryColor: '#153372', textColor: '#333333', backgroundColor: '#ffffff', borderRadius: 12, boxShadow: 'medium', inputHeight: 48, inputFontSize: 15, inputBorderColor: '#e5e7eb', inputBorderWidth: 1, inputFocusBorderColor: '#00226b', showSearchButton: false, searchButtonText: 'Search', layout: 'dropdown', }, classic: { primaryColor: '#00226b', secondaryColor: '#153372', textColor: '#1a1a1a', backgroundColor: '#ffffff', borderRadius: 0, boxShadow: 'none', inputHeight: 44, inputFontSize: 14, inputBorderColor: '#00226b', inputBorderWidth: 2, inputFocusBorderColor: '#1a1a1a', showSearchButton: true, searchButtonText: 'Search', layout: 'dropdown', }, modal: { primaryColor: '#00226b', secondaryColor: '#153372', textColor: '#333333', backgroundColor: '#ffffff', borderRadius: 16, boxShadow: 'heavy', inputHeight: 52, inputFontSize: 16, inputBorderColor: '#e5e7eb', inputBorderWidth: 1, inputFocusBorderColor: '#00226b', showSearchButton: false, searchButtonText: 'Search', layout: 'modal', }, };