@seekora-ai/ui-sdk-react 0.2.12 → 0.2.14
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/components/CurrentRefinements.d.ts +22 -2
- package/dist/components/CurrentRefinements.d.ts.map +1 -1
- package/dist/components/CurrentRefinements.js +199 -47
- package/dist/components/Facets.d.ts +30 -1
- package/dist/components/Facets.d.ts.map +1 -1
- package/dist/components/Facets.js +418 -46
- package/dist/components/HierarchicalMenu.d.ts.map +1 -1
- package/dist/components/HierarchicalMenu.js +112 -4
- package/dist/components/InfiniteHits.d.ts +2 -0
- package/dist/components/InfiniteHits.d.ts.map +1 -1
- package/dist/components/InfiniteHits.js +6 -3
- package/dist/components/Pagination.d.ts +47 -1
- package/dist/components/Pagination.d.ts.map +1 -1
- package/dist/components/Pagination.js +166 -28
- package/dist/components/QuerySuggestions.d.ts +2 -0
- package/dist/components/QuerySuggestions.d.ts.map +1 -1
- package/dist/components/QuerySuggestions.js +4 -3
- package/dist/components/QuerySuggestionsDropdown.d.ts +1 -1
- package/dist/components/QuerySuggestionsDropdown.d.ts.map +1 -1
- package/dist/components/QuerySuggestionsDropdown.js +4 -4
- package/dist/components/RangeSlider.d.ts.map +1 -1
- package/dist/components/RangeSlider.js +49 -2
- package/dist/components/Recommendations.d.ts +6 -0
- package/dist/components/Recommendations.d.ts.map +1 -1
- package/dist/components/Recommendations.js +12 -6
- package/dist/components/RichQuerySuggestions.d.ts +11 -0
- package/dist/components/RichQuerySuggestions.d.ts.map +1 -1
- package/dist/components/RichQuerySuggestions.js +2 -3
- package/dist/components/SearchBar.d.ts +18 -0
- package/dist/components/SearchBar.d.ts.map +1 -1
- package/dist/components/SearchBar.js +134 -24
- package/dist/components/SearchProvider.d.ts +8 -1
- package/dist/components/SearchProvider.d.ts.map +1 -1
- package/dist/components/SearchProvider.js +16 -4
- package/dist/components/SearchResults.d.ts +12 -0
- package/dist/components/SearchResults.d.ts.map +1 -1
- package/dist/components/SearchResults.js +11 -5
- package/dist/components/SortBy.d.ts +44 -4
- package/dist/components/SortBy.d.ts.map +1 -1
- package/dist/components/SortBy.js +154 -29
- package/dist/components/Stats.d.ts +14 -0
- package/dist/components/Stats.d.ts.map +1 -1
- package/dist/components/Stats.js +172 -23
- package/dist/components/section-primitives/SectionItemGrid.d.ts +3 -1
- package/dist/components/section-primitives/SectionItemGrid.d.ts.map +1 -1
- package/dist/components/section-primitives/SectionItemGrid.js +3 -2
- package/dist/components/suggestions/AmazonDropdown.d.ts.map +1 -1
- package/dist/components/suggestions/AmazonDropdown.js +4 -6
- package/dist/components/suggestions/GoogleDropdown.d.ts.map +1 -1
- package/dist/components/suggestions/GoogleDropdown.js +4 -8
- package/dist/components/suggestions/MinimalDropdown.d.ts.map +1 -1
- package/dist/components/suggestions/MinimalDropdown.js +4 -6
- package/dist/components/suggestions/MobileSheetDropdown.d.ts.map +1 -1
- package/dist/components/suggestions/MobileSheetDropdown.js +4 -6
- package/dist/components/suggestions/PinterestDropdown.d.ts.map +1 -1
- package/dist/components/suggestions/PinterestDropdown.js +4 -8
- package/dist/components/suggestions/ShopifyDropdown.d.ts.map +1 -1
- package/dist/components/suggestions/ShopifyDropdown.js +4 -6
- package/dist/components/suggestions/SpotlightDropdown.d.ts.map +1 -1
- package/dist/components/suggestions/SpotlightDropdown.js +4 -6
- package/dist/components/suggestions/SuggestionSearchBar.d.ts.map +1 -1
- package/dist/components/suggestions/SuggestionSearchBar.js +1 -0
- package/dist/components/suggestions/types.d.ts +2 -0
- package/dist/components/suggestions/types.d.ts.map +1 -1
- package/dist/components/suggestions/utils.d.ts +10 -1
- package/dist/components/suggestions/utils.d.ts.map +1 -1
- package/dist/components/suggestions/utils.js +36 -0
- package/dist/components/suggestions-primitives/SuggestionList.d.ts +8 -1
- package/dist/components/suggestions-primitives/SuggestionList.d.ts.map +1 -1
- package/dist/components/suggestions-primitives/SuggestionList.js +7 -4
- package/dist/components/suggestions-primitives/SuggestionsDropdownComposition.d.ts.map +1 -1
- package/dist/components/suggestions-primitives/SuggestionsDropdownComposition.js +0 -2
- package/dist/components/suggestions-primitives/highlightMarkup.d.ts +16 -4
- package/dist/components/suggestions-primitives/highlightMarkup.d.ts.map +1 -1
- package/dist/components/suggestions-primitives/highlightMarkup.js +42 -4
- package/dist/docsearch/components/Results.d.ts +3 -1
- package/dist/docsearch/components/Results.d.ts.map +1 -1
- package/dist/docsearch/components/Results.js +6 -2
- package/dist/hooks/useClickTracking.d.ts +36 -0
- package/dist/hooks/useClickTracking.d.ts.map +1 -0
- package/dist/hooks/useClickTracking.js +96 -0
- package/dist/hooks/useExperiment.d.ts +25 -0
- package/dist/hooks/useExperiment.d.ts.map +1 -0
- package/dist/hooks/useExperiment.js +146 -0
- package/dist/hooks/useKeyboardNavigation.d.ts +51 -0
- package/dist/hooks/useKeyboardNavigation.d.ts.map +1 -0
- package/dist/hooks/useKeyboardNavigation.js +113 -0
- package/dist/hooks/useQuerySuggestions.d.ts.map +1 -1
- package/dist/hooks/useQuerySuggestions.js +19 -3
- package/dist/hooks/useQuerySuggestionsEnhanced.d.ts.map +1 -1
- package/dist/hooks/useQuerySuggestionsEnhanced.js +25 -7
- package/dist/hooks/useSuggestionsAnalytics.d.ts.map +1 -1
- package/dist/hooks/useSuggestionsAnalytics.js +6 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/src/index.d.ts +249 -19
- package/dist/src/index.esm.js +1659 -305
- package/dist/src/index.esm.js.map +1 -1
- package/dist/src/index.js +1658 -304
- package/dist/src/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -29,7 +29,7 @@ const formatPrice = (value, currency = '₹') => {
|
|
|
29
29
|
}
|
|
30
30
|
return String(value);
|
|
31
31
|
};
|
|
32
|
-
export const SearchResults = ({ results: resultsProp, loading: loadingProp, error: errorProp, onResultClick, renderResult, renderEmpty, renderLoading, renderError, className, style, theme: customTheme, itemsPerPage = 20, showPagination = false, viewMode = 'list', fieldMapping, extractResults, enableKeyboardNavigation = true, autoFocus = false, }) => {
|
|
32
|
+
export const SearchResults = ({ results: resultsProp, loading: loadingProp, error: errorProp, onResultClick, renderResult, renderEmpty, showLoadingState = false, renderLoading, renderError, className, style, theme: customTheme, itemsPerPage = 20, showPagination = false, viewMode = 'list', fieldMapping, extractResults, enableKeyboardNavigation = true, autoFocus = false, minHeight = '400px', minWidth = '100%', loadingOpacity = 0.7, }) => {
|
|
33
33
|
const { theme, client, enableAnalytics } = useSearchContext();
|
|
34
34
|
const { results: stateResults, loading: stateLoading, error: stateError, currentPage, itemsPerPage: stateItemsPerPage } = useSearchState();
|
|
35
35
|
const searchResultsTheme = customTheme || {};
|
|
@@ -373,6 +373,10 @@ export const SearchResults = ({ results: resultsProp, loading: loadingProp, erro
|
|
|
373
373
|
});
|
|
374
374
|
// Determine container style based on view mode
|
|
375
375
|
const containerStyle = {
|
|
376
|
+
minHeight: `var(--seekora-results-min-height, ${minHeight})`,
|
|
377
|
+
minWidth: `var(--seekora-results-min-width, ${minWidth})`,
|
|
378
|
+
transition: 'opacity 200ms ease-in-out',
|
|
379
|
+
opacity: loading && resultItems.length > 0 ? loadingOpacity : 1,
|
|
376
380
|
...style,
|
|
377
381
|
};
|
|
378
382
|
// Determine results list style based on view mode
|
|
@@ -396,20 +400,22 @@ export const SearchResults = ({ results: resultsProp, loading: loadingProp, erro
|
|
|
396
400
|
hasError: !!error,
|
|
397
401
|
isLoading: loading,
|
|
398
402
|
});
|
|
399
|
-
if (loading)
|
|
403
|
+
// When loading with no previous results, show loading only if showLoadingState (default: show previous results, no loading screen)
|
|
404
|
+
if (loading && resultItems.length === 0 && showLoadingState) {
|
|
400
405
|
log.verbose('SearchResults: Rendering loading state');
|
|
401
|
-
return (React.createElement("div", { className: clsx(searchResultsTheme.container, className), style:
|
|
406
|
+
return (React.createElement("div", { className: clsx(searchResultsTheme.container, className), style: containerStyle }, renderLoading ? renderLoading() : defaultRenderLoading()));
|
|
402
407
|
}
|
|
408
|
+
// When loading with previous results, fall through and render them (with opacity transition)
|
|
403
409
|
if (error) {
|
|
404
410
|
log.error('SearchResults: Rendering error state', {
|
|
405
411
|
error: error.message,
|
|
406
412
|
stack: error.stack,
|
|
407
413
|
});
|
|
408
|
-
return (React.createElement("div", { className: clsx(searchResultsTheme.container, className), style:
|
|
414
|
+
return (React.createElement("div", { className: clsx(searchResultsTheme.container, className), style: containerStyle }, renderError ? renderError(error) : defaultRenderError(error)));
|
|
409
415
|
}
|
|
410
416
|
if (!results || resultItems.length === 0) {
|
|
411
417
|
log.verbose('SearchResults: No results to display');
|
|
412
|
-
return (React.createElement("div", { className: clsx(searchResultsTheme.container, className), style:
|
|
418
|
+
return (React.createElement("div", { className: clsx(searchResultsTheme.container, className), style: containerStyle }, renderEmpty ? renderEmpty() : defaultRenderEmpty()));
|
|
413
419
|
}
|
|
414
420
|
const renderFn = renderResult || defaultRenderResult;
|
|
415
421
|
return (React.createElement("div", { ref: containerRef, className: clsx(searchResultsTheme.container, className), style: containerStyle, tabIndex: enableKeyboardNavigation ? 0 : undefined, onKeyDown: handleKeyDown, role: "listbox", "aria-label": "Search results", "aria-activedescendant": activeIndex >= 0 ? `result-${activeIndex}` : undefined },
|
|
@@ -1,18 +1,50 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* SortBy Component
|
|
3
3
|
*
|
|
4
|
-
* Displays sort options for search results
|
|
5
|
-
*
|
|
4
|
+
* Displays sort options for search results in multiple display variants:
|
|
5
|
+
* - dropdown (default) — native select element
|
|
6
|
+
* - button-group — horizontal row of toggle buttons
|
|
7
|
+
* - radio-group — vertical list of radio inputs
|
|
8
|
+
*
|
|
9
|
+
* Integrates with SearchStateManager for automatic state sync.
|
|
10
|
+
*
|
|
11
|
+
* CSS Variables (apply on a parent element to customize):
|
|
12
|
+
* --seekora-sort-bg — background color
|
|
13
|
+
* --seekora-sort-color — text color
|
|
14
|
+
* --seekora-sort-border — border color
|
|
15
|
+
* --seekora-sort-active-bg — active item background
|
|
16
|
+
* --seekora-sort-active-color — active item text color
|
|
6
17
|
*/
|
|
7
18
|
import React from 'react';
|
|
8
19
|
export interface SortOption {
|
|
9
20
|
value: string;
|
|
10
21
|
label: string;
|
|
11
22
|
}
|
|
23
|
+
export type SortByVariant = 'dropdown' | 'button-group' | 'radio-group';
|
|
24
|
+
export type SortBySize = 'small' | 'medium' | 'large';
|
|
12
25
|
export interface SortByTheme {
|
|
26
|
+
/** Root container */
|
|
13
27
|
container?: string;
|
|
28
|
+
/** Dropdown select element */
|
|
14
29
|
select?: string;
|
|
30
|
+
/** Dropdown option element */
|
|
15
31
|
option?: string;
|
|
32
|
+
/** Optional label above the control */
|
|
33
|
+
label?: string;
|
|
34
|
+
/** Button group wrapper */
|
|
35
|
+
buttonGroup?: string;
|
|
36
|
+
/** Individual button in the group */
|
|
37
|
+
buttonGroupItem?: string;
|
|
38
|
+
/** Active button in the group */
|
|
39
|
+
buttonGroupItemActive?: string;
|
|
40
|
+
/** Radio group wrapper */
|
|
41
|
+
radioGroup?: string;
|
|
42
|
+
/** Individual radio row (input + label) */
|
|
43
|
+
radioItem?: string;
|
|
44
|
+
/** Active radio row */
|
|
45
|
+
radioItemActive?: string;
|
|
46
|
+
/** Radio label text */
|
|
47
|
+
radioLabel?: string;
|
|
16
48
|
}
|
|
17
49
|
export interface SortByProps {
|
|
18
50
|
/** Available sort options */
|
|
@@ -23,7 +55,7 @@ export interface SortByProps {
|
|
|
23
55
|
defaultValue?: string;
|
|
24
56
|
/** Callback when sort changes */
|
|
25
57
|
onSortChange?: (value: string) => void;
|
|
26
|
-
/** Custom render function for select */
|
|
58
|
+
/** Custom render function for select (only used in dropdown variant) */
|
|
27
59
|
renderSelect?: (props: {
|
|
28
60
|
value: string;
|
|
29
61
|
onChange: (e: React.ChangeEvent<HTMLSelectElement>) => void;
|
|
@@ -35,10 +67,18 @@ export interface SortByProps {
|
|
|
35
67
|
style?: React.CSSProperties;
|
|
36
68
|
/** Custom theme */
|
|
37
69
|
theme?: SortByTheme;
|
|
38
|
-
/** Placeholder text */
|
|
70
|
+
/** Placeholder text (dropdown variant) */
|
|
39
71
|
placeholder?: string;
|
|
40
72
|
/** Whether to sync with SearchStateManager (default: true) */
|
|
41
73
|
syncWithState?: boolean;
|
|
74
|
+
/** Display variant (default: 'dropdown') */
|
|
75
|
+
variant?: SortByVariant;
|
|
76
|
+
/** Optional label text displayed above the control */
|
|
77
|
+
label?: string;
|
|
78
|
+
/** Whether to show the label (default: true when label is provided) */
|
|
79
|
+
showLabel?: boolean;
|
|
80
|
+
/** Size variant affecting padding and font size (default: 'medium') */
|
|
81
|
+
size?: SortBySize;
|
|
42
82
|
}
|
|
43
83
|
export declare const SortBy: React.FC<SortByProps>;
|
|
44
84
|
//# sourceMappingURL=SortBy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SortBy.d.ts","sourceRoot":"","sources":["../../src/components/SortBy.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"SortBy.d.ts","sourceRoot":"","sources":["../../src/components/SortBy.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAwC,MAAM,OAAO,CAAC;AAS7D,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,cAAc,GAAG,aAAa,CAAC;AACxE,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEtD,MAAM,WAAW,WAAW;IAC1B,qBAAqB;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8BAA8B;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8BAA8B;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2BAA2B;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qCAAqC;IACrC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iCAAiC;IACjC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,0BAA0B;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uBAAuB;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,uBAAuB;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,6BAA6B;IAC7B,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yBAAyB;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iCAAiC;IACjC,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,wEAAwE;IACxE,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;QAC5D,OAAO,EAAE,UAAU,EAAE,CAAC;KACvB,KAAK,KAAK,CAAC,SAAS,CAAC;IACtB,uBAAuB;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oBAAoB;IACpB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,mBAAmB;IACnB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8DAA8D;IAC9D,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,4CAA4C;IAC5C,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,sDAAsD;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uEAAuE;IACvE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,uEAAuE;IACvE,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AA8BD,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAmSxC,CAAC"}
|
|
@@ -1,61 +1,186 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* SortBy Component
|
|
3
3
|
*
|
|
4
|
-
* Displays sort options for search results
|
|
5
|
-
*
|
|
4
|
+
* Displays sort options for search results in multiple display variants:
|
|
5
|
+
* - dropdown (default) — native select element
|
|
6
|
+
* - button-group — horizontal row of toggle buttons
|
|
7
|
+
* - radio-group — vertical list of radio inputs
|
|
8
|
+
*
|
|
9
|
+
* Integrates with SearchStateManager for automatic state sync.
|
|
10
|
+
*
|
|
11
|
+
* CSS Variables (apply on a parent element to customize):
|
|
12
|
+
* --seekora-sort-bg — background color
|
|
13
|
+
* --seekora-sort-color — text color
|
|
14
|
+
* --seekora-sort-border — border color
|
|
15
|
+
* --seekora-sort-active-bg — active item background
|
|
16
|
+
* --seekora-sort-active-color — active item text color
|
|
6
17
|
*/
|
|
7
|
-
import React, { useEffect } from 'react';
|
|
18
|
+
import React, { useCallback, useEffect, useId } from 'react';
|
|
8
19
|
import { useSearchContext } from './SearchProvider';
|
|
9
20
|
import { useSearchState } from '../hooks/useSearchState';
|
|
10
21
|
import { clsx } from 'clsx';
|
|
11
|
-
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
// Helpers
|
|
24
|
+
// ---------------------------------------------------------------------------
|
|
25
|
+
/** Map a size token to theme fontSize and spacing values. */
|
|
26
|
+
function sizeStyles(size, theme) {
|
|
27
|
+
switch (size) {
|
|
28
|
+
case 'small':
|
|
29
|
+
return { fontSize: theme.typography.fontSize.small, padding: theme.spacing.small };
|
|
30
|
+
case 'large':
|
|
31
|
+
return { fontSize: theme.typography.fontSize.large, padding: theme.spacing.medium };
|
|
32
|
+
case 'medium':
|
|
33
|
+
default:
|
|
34
|
+
return { fontSize: theme.typography.fontSize.medium, padding: theme.spacing.small };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function resolveBorderRadius(br) {
|
|
38
|
+
return typeof br === 'string' ? br : br.medium;
|
|
39
|
+
}
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
// Component
|
|
42
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
export const SortBy = ({ options, value: valueProp, defaultValue, onSortChange, renderSelect, className, style, theme: customTheme, placeholder = 'Sort by...', syncWithState = true, variant = 'dropdown', label, showLabel, size = 'medium', }) => {
|
|
12
44
|
const { theme } = useSearchContext();
|
|
13
45
|
const { sortBy: stateManagerSortBy, setSortBy } = useSearchState();
|
|
14
46
|
const sortByTheme = customTheme || {};
|
|
15
|
-
|
|
47
|
+
const instanceId = useId();
|
|
48
|
+
// Determine whether the label should render.
|
|
49
|
+
const shouldShowLabel = showLabel !== undefined ? showLabel : !!label;
|
|
50
|
+
// ------ State ----------------------------------------------------------
|
|
16
51
|
const [internalValue, setInternalValue] = React.useState(defaultValue || options[0]?.value || '');
|
|
17
52
|
// Sync with StateManager on mount if defaultValue is set
|
|
18
53
|
useEffect(() => {
|
|
19
54
|
if (syncWithState && defaultValue && !stateManagerSortBy) {
|
|
20
55
|
setSortBy(defaultValue, false); // Don't trigger search on initial sync
|
|
21
56
|
}
|
|
22
|
-
}, []);
|
|
57
|
+
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
23
58
|
// Determine the current value: controlled prop > StateManager > internal
|
|
24
59
|
const value = valueProp !== undefined
|
|
25
60
|
? valueProp
|
|
26
|
-
:
|
|
61
|
+
: syncWithState && stateManagerSortBy
|
|
27
62
|
? stateManagerSortBy
|
|
28
63
|
: internalValue;
|
|
64
|
+
// ------ Handlers -------------------------------------------------------
|
|
29
65
|
const handleChange = (e) => {
|
|
30
|
-
|
|
66
|
+
applyValue(e.target.value);
|
|
67
|
+
};
|
|
68
|
+
const applyValue = useCallback((newValue) => {
|
|
31
69
|
setInternalValue(newValue);
|
|
32
|
-
// Update StateManager (automatically triggers search)
|
|
33
70
|
if (syncWithState) {
|
|
34
71
|
setSortBy(newValue);
|
|
35
72
|
}
|
|
36
|
-
// Call callback for backwards compatibility
|
|
37
73
|
if (onSortChange) {
|
|
38
74
|
onSortChange(newValue);
|
|
39
75
|
}
|
|
76
|
+
}, [syncWithState, setSortBy, onSortChange]);
|
|
77
|
+
// ------ Derived styles -------------------------------------------------
|
|
78
|
+
const { fontSize, padding } = sizeStyles(size, theme);
|
|
79
|
+
const borderRadius = resolveBorderRadius(theme.borderRadius);
|
|
80
|
+
const cssVarStyle = {
|
|
81
|
+
'--seekora-sort-bg': theme.colors.background,
|
|
82
|
+
'--seekora-sort-color': theme.colors.text,
|
|
83
|
+
'--seekora-sort-border': theme.colors.border,
|
|
84
|
+
'--seekora-sort-active-bg': theme.colors.primary,
|
|
85
|
+
'--seekora-sort-active-color': theme.colors.background,
|
|
40
86
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
87
|
+
// ------ Label ----------------------------------------------------------
|
|
88
|
+
const labelElement = shouldShowLabel && label ? (React.createElement("span", { className: clsx(sortByTheme.label), style: {
|
|
89
|
+
display: 'block',
|
|
90
|
+
marginBottom: theme.spacing.small,
|
|
91
|
+
fontSize,
|
|
92
|
+
color: 'var(--seekora-sort-color)',
|
|
93
|
+
fontWeight: 500,
|
|
94
|
+
} }, label)) : null;
|
|
95
|
+
// ------ Dropdown variant (original) ------------------------------------
|
|
96
|
+
if (variant === 'dropdown') {
|
|
97
|
+
if (renderSelect) {
|
|
98
|
+
return (React.createElement("div", { className: clsx(sortByTheme.container, className), style: { ...cssVarStyle, ...style } },
|
|
99
|
+
labelElement,
|
|
100
|
+
renderSelect({
|
|
101
|
+
value,
|
|
102
|
+
onChange: handleChange,
|
|
103
|
+
options,
|
|
104
|
+
})));
|
|
105
|
+
}
|
|
106
|
+
return (React.createElement("div", { className: clsx(sortByTheme.container, className), style: { ...cssVarStyle, ...style } },
|
|
107
|
+
labelElement,
|
|
108
|
+
React.createElement("select", { value: value, onChange: handleChange, className: clsx(sortByTheme.select), style: {
|
|
109
|
+
padding,
|
|
110
|
+
paddingRight: theme.spacing.medium,
|
|
111
|
+
fontSize,
|
|
112
|
+
border: '1px solid var(--seekora-sort-border)',
|
|
113
|
+
borderRadius,
|
|
114
|
+
backgroundColor: 'var(--seekora-sort-bg)',
|
|
115
|
+
color: 'var(--seekora-sort-color)',
|
|
116
|
+
cursor: 'pointer',
|
|
117
|
+
outline: 'none',
|
|
118
|
+
width: '100%',
|
|
119
|
+
}, "aria-label": label || 'Sort results' }, options.map((option) => (React.createElement("option", { key: option.value, value: option.value, className: sortByTheme.option }, option.label))))));
|
|
120
|
+
}
|
|
121
|
+
// ------ Button group variant -------------------------------------------
|
|
122
|
+
if (variant === 'button-group') {
|
|
123
|
+
return (React.createElement("div", { className: clsx(sortByTheme.container, className), style: { ...cssVarStyle, ...style } },
|
|
124
|
+
labelElement,
|
|
125
|
+
React.createElement("div", { role: "group", "aria-label": label || 'Sort results', className: clsx(sortByTheme.buttonGroup), style: {
|
|
126
|
+
display: 'inline-flex',
|
|
127
|
+
borderRadius,
|
|
128
|
+
overflow: 'hidden',
|
|
129
|
+
border: '1px solid var(--seekora-sort-border)',
|
|
130
|
+
} }, options.map((option, index) => {
|
|
131
|
+
const isActive = option.value === value;
|
|
132
|
+
return (React.createElement("button", { key: option.value, type: "button", role: "button", "aria-pressed": isActive, onClick: () => applyValue(option.value), className: clsx(sortByTheme.buttonGroupItem, isActive && sortByTheme.buttonGroupItemActive), style: {
|
|
133
|
+
padding,
|
|
134
|
+
fontSize,
|
|
135
|
+
border: 'none',
|
|
136
|
+
borderRight: index < options.length - 1
|
|
137
|
+
? '1px solid var(--seekora-sort-border)'
|
|
138
|
+
: 'none',
|
|
139
|
+
backgroundColor: isActive
|
|
140
|
+
? 'var(--seekora-sort-active-bg)'
|
|
141
|
+
: 'var(--seekora-sort-bg)',
|
|
142
|
+
color: isActive
|
|
143
|
+
? 'var(--seekora-sort-active-color)'
|
|
144
|
+
: 'var(--seekora-sort-color)',
|
|
145
|
+
cursor: 'pointer',
|
|
146
|
+
fontWeight: isActive ? 600 : 400,
|
|
147
|
+
transition: 'background-color 0.15s ease, color 0.15s ease',
|
|
148
|
+
outline: 'none',
|
|
149
|
+
} }, option.label));
|
|
150
|
+
}))));
|
|
151
|
+
}
|
|
152
|
+
// ------ Radio group variant --------------------------------------------
|
|
153
|
+
if (variant === 'radio-group') {
|
|
154
|
+
const radioName = `seekora-sort-${instanceId}`;
|
|
155
|
+
return (React.createElement("div", { className: clsx(sortByTheme.container, className), style: { ...cssVarStyle, ...style } },
|
|
156
|
+
labelElement,
|
|
157
|
+
React.createElement("div", { role: "radiogroup", "aria-label": label || 'Sort results', className: clsx(sortByTheme.radioGroup), style: {
|
|
158
|
+
display: 'flex',
|
|
159
|
+
flexDirection: 'column',
|
|
160
|
+
gap: theme.spacing.small,
|
|
161
|
+
} }, options.map((option) => {
|
|
162
|
+
const isActive = option.value === value;
|
|
163
|
+
const radioId = `${radioName}-${option.value}`;
|
|
164
|
+
return (React.createElement("label", { key: option.value, htmlFor: radioId, className: clsx(sortByTheme.radioItem, isActive && sortByTheme.radioItemActive), style: {
|
|
165
|
+
display: 'flex',
|
|
166
|
+
alignItems: 'center',
|
|
167
|
+
gap: theme.spacing.small,
|
|
168
|
+
padding,
|
|
169
|
+
borderRadius,
|
|
170
|
+
cursor: 'pointer',
|
|
171
|
+
backgroundColor: isActive
|
|
172
|
+
? 'var(--seekora-sort-active-bg)'
|
|
173
|
+
: 'transparent',
|
|
174
|
+
color: isActive
|
|
175
|
+
? 'var(--seekora-sort-active-color)'
|
|
176
|
+
: 'var(--seekora-sort-color)',
|
|
177
|
+
fontWeight: isActive ? 600 : 400,
|
|
178
|
+
transition: 'background-color 0.15s ease, color 0.15s ease',
|
|
179
|
+
} },
|
|
180
|
+
React.createElement("input", { type: "radio", id: radioId, name: radioName, value: option.value, checked: isActive, onChange: () => applyValue(option.value), style: { margin: 0 } }),
|
|
181
|
+
React.createElement("span", { className: clsx(sortByTheme.radioLabel), style: { fontSize } }, option.label)));
|
|
182
|
+
}))));
|
|
59
183
|
}
|
|
60
|
-
|
|
184
|
+
// Fallback — should never reach here, but satisfies TS exhaustiveness
|
|
185
|
+
return null;
|
|
61
186
|
};
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Stats Component
|
|
3
3
|
*
|
|
4
4
|
* Displays search statistics (total results, processing time, etc.)
|
|
5
|
+
* Supports inline, badge, and detailed display variants.
|
|
5
6
|
*/
|
|
6
7
|
import React from 'react';
|
|
7
8
|
import type { SearchResponse } from '@seekora-ai/search-sdk';
|
|
@@ -10,6 +11,13 @@ export interface StatsTheme {
|
|
|
10
11
|
text?: string;
|
|
11
12
|
highlight?: string;
|
|
12
13
|
separator?: string;
|
|
14
|
+
badge?: string;
|
|
15
|
+
badgeLabel?: string;
|
|
16
|
+
badgeValue?: string;
|
|
17
|
+
detailed?: string;
|
|
18
|
+
detailedRow?: string;
|
|
19
|
+
detailedLabel?: string;
|
|
20
|
+
detailedValue?: string;
|
|
13
21
|
}
|
|
14
22
|
export interface StatsProps {
|
|
15
23
|
/** Search results response */
|
|
@@ -32,6 +40,12 @@ export interface StatsProps {
|
|
|
32
40
|
showQuery?: boolean;
|
|
33
41
|
/** Custom separator between stats */
|
|
34
42
|
separator?: string;
|
|
43
|
+
/** Display variant */
|
|
44
|
+
variant?: 'inline' | 'badge' | 'detailed';
|
|
45
|
+
/** Show result count (default: true) */
|
|
46
|
+
showResultCount?: boolean;
|
|
47
|
+
/** Custom number formatter (default: toLocaleString) */
|
|
48
|
+
formatNumber?: (n: number) => string;
|
|
35
49
|
}
|
|
36
50
|
export declare const Stats: React.FC<StatsProps>;
|
|
37
51
|
//# sourceMappingURL=Stats.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stats.d.ts","sourceRoot":"","sources":["../../src/components/Stats.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Stats.d.ts","sourceRoot":"","sources":["../../src/components/Stats.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAsC,MAAM,OAAO,CAAC;AAI3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,MAAM,WAAW,UAAU;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,UAAU;IACzB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IAChC,6BAA6B;IAC7B,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE;QACpB,YAAY,EAAE,MAAM,CAAC;QACrB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,KAAK,KAAK,CAAC,SAAS,CAAC;IACtB,uBAAuB;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oBAAoB;IACpB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,mBAAmB;IACnB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,2BAA2B;IAC3B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,iBAAiB;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,qCAAqC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sBAAsB;IACtB,OAAO,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,UAAU,CAAC;IAC1C,wCAAwC;IACxC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,wDAAwD;IACxD,YAAY,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;CACtC;AA8BD,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,UAAU,CAsTtC,CAAC"}
|
package/dist/components/Stats.js
CHANGED
|
@@ -2,13 +2,48 @@
|
|
|
2
2
|
* Stats Component
|
|
3
3
|
*
|
|
4
4
|
* Displays search statistics (total results, processing time, etc.)
|
|
5
|
+
* Supports inline, badge, and detailed display variants.
|
|
5
6
|
*/
|
|
6
|
-
import React from 'react';
|
|
7
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
7
8
|
import { useSearchContext } from './SearchProvider';
|
|
9
|
+
import { useSearchState } from '../hooks/useSearchState';
|
|
8
10
|
import { clsx } from 'clsx';
|
|
9
|
-
|
|
11
|
+
/** CSS class name used for the animated count fade transition */
|
|
12
|
+
const ANIMATE_CLASS = 'seekora-stats-animate';
|
|
13
|
+
/** Inline <style> for the count-change animation and CSS custom properties */
|
|
14
|
+
const statsStyleId = 'seekora-stats-styles';
|
|
15
|
+
function ensureStatsStyles() {
|
|
16
|
+
if (typeof document === 'undefined')
|
|
17
|
+
return;
|
|
18
|
+
if (document.getElementById(statsStyleId))
|
|
19
|
+
return;
|
|
20
|
+
const style = document.createElement('style');
|
|
21
|
+
style.id = statsStyleId;
|
|
22
|
+
style.textContent = `
|
|
23
|
+
.seekora-stats-root {
|
|
24
|
+
--seekora-stats-color: inherit;
|
|
25
|
+
--seekora-stats-bg: transparent;
|
|
26
|
+
--seekora-stats-font-size: inherit;
|
|
27
|
+
--seekora-stats-badge-bg: inherit;
|
|
28
|
+
--seekora-stats-badge-color: inherit;
|
|
29
|
+
}
|
|
30
|
+
.${ANIMATE_CLASS} {
|
|
31
|
+
opacity: 0;
|
|
32
|
+
transition: opacity 250ms ease-in-out;
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
35
|
+
document.head.appendChild(style);
|
|
36
|
+
}
|
|
37
|
+
export const Stats = ({ results: resultsProp, renderStats, className, style, theme: customTheme, showProcessingTime = false, showQuery = false, separator = ' \u2022 ', variant = 'inline', showResultCount = true, formatNumber, }) => {
|
|
10
38
|
const { theme } = useSearchContext();
|
|
39
|
+
const { results: stateResults } = useSearchState();
|
|
11
40
|
const statsTheme = customTheme || {};
|
|
41
|
+
// Use results from prop if provided, otherwise from state manager
|
|
42
|
+
const results = resultsProp || stateResults;
|
|
43
|
+
// Inject keyframe / transition styles once
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
ensureStatsStyles();
|
|
46
|
+
}, []);
|
|
12
47
|
// Extract stats from results
|
|
13
48
|
const res = results;
|
|
14
49
|
const totalResults = res?.totalResults
|
|
@@ -19,34 +54,148 @@ export const Stats = ({ results, renderStats, className, style, theme: customThe
|
|
|
19
54
|
|| res?.data?.processingTimeMS
|
|
20
55
|
|| res?.data?.data?.processingTimeMS;
|
|
21
56
|
const query = (res?.query ?? '');
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
57
|
+
// Number formatter
|
|
58
|
+
const fmt = formatNumber || ((n) => n.toLocaleString());
|
|
59
|
+
// Animated count change — toggle a CSS class briefly on totalResults change
|
|
60
|
+
const countRef = useRef(null);
|
|
61
|
+
const prevTotalRef = useRef(totalResults);
|
|
62
|
+
const [animating, setAnimating] = useState(false);
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
if (prevTotalRef.current !== totalResults) {
|
|
65
|
+
prevTotalRef.current = totalResults;
|
|
66
|
+
setAnimating(true);
|
|
67
|
+
// After a frame, remove the class so the transition plays (opacity 0 -> 1)
|
|
68
|
+
const raf = requestAnimationFrame(() => {
|
|
69
|
+
setAnimating(false);
|
|
70
|
+
});
|
|
71
|
+
return () => cancelAnimationFrame(raf);
|
|
26
72
|
}
|
|
27
|
-
|
|
28
|
-
|
|
73
|
+
}, [totalResults]);
|
|
74
|
+
// Helper: border radius value from theme
|
|
75
|
+
const borderRadiusSmall = typeof theme.borderRadius === 'string'
|
|
76
|
+
? theme.borderRadius
|
|
77
|
+
: theme.borderRadius.small;
|
|
78
|
+
// ─── Custom render ────────────────────────────────────────
|
|
79
|
+
if (renderStats) {
|
|
80
|
+
return (React.createElement("div", { className: clsx('seekora-stats-root', statsTheme.container, className), style: style }, renderStats({
|
|
81
|
+
totalResults,
|
|
82
|
+
processingTime,
|
|
83
|
+
query,
|
|
84
|
+
})));
|
|
85
|
+
}
|
|
86
|
+
// ─── Inline variant (original behaviour) ──────────────────
|
|
87
|
+
if (variant === 'inline') {
|
|
88
|
+
const parts = [];
|
|
89
|
+
if (showResultCount) {
|
|
90
|
+
if (totalResults > 0) {
|
|
91
|
+
parts.push(React.createElement("span", { key: "count", className: statsTheme.text },
|
|
92
|
+
React.createElement("span", { ref: countRef, className: clsx(animating && ANIMATE_CLASS), style: { transition: 'opacity 250ms ease-in-out' } }, fmt(totalResults)),
|
|
93
|
+
` result${totalResults !== 1 ? 's' : ''}`));
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
parts.push(React.createElement("span", { key: "count", className: statsTheme.text }, "No results"));
|
|
97
|
+
}
|
|
29
98
|
}
|
|
30
99
|
if (showProcessingTime && processingTime !== undefined) {
|
|
31
|
-
parts.push(
|
|
100
|
+
parts.push(React.createElement("span", { key: "time", className: statsTheme.text },
|
|
101
|
+
fmt(processingTime),
|
|
102
|
+
"ms"));
|
|
32
103
|
}
|
|
33
104
|
if (showQuery && query) {
|
|
34
|
-
parts.push(
|
|
105
|
+
parts.push(React.createElement("span", { key: "query", className: statsTheme.text },
|
|
106
|
+
"for \"",
|
|
107
|
+
query,
|
|
108
|
+
"\""));
|
|
35
109
|
}
|
|
36
|
-
return (React.createElement("div", { className: clsx(statsTheme.container, className), style: {
|
|
37
|
-
fontSize: theme.typography.fontSize.medium,
|
|
38
|
-
color: theme.colors.text,
|
|
110
|
+
return (React.createElement("div", { className: clsx('seekora-stats-root', statsTheme.container, className), style: {
|
|
111
|
+
fontSize: 'var(--seekora-stats-font-size,' + theme.typography.fontSize.medium + ')',
|
|
112
|
+
color: 'var(--seekora-stats-color,' + theme.colors.text + ')',
|
|
113
|
+
backgroundColor: 'var(--seekora-stats-bg, transparent)',
|
|
39
114
|
...style,
|
|
40
115
|
} }, parts.map((part, index) => (React.createElement("span", { key: index },
|
|
41
|
-
index > 0 && React.createElement("span", { className: statsTheme.separator, style: { margin: `0 ${theme.spacing.small}` } }, separator),
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
116
|
+
index > 0 && (React.createElement("span", { className: statsTheme.separator, style: { margin: `0 ${theme.spacing.small}` } }, separator)),
|
|
117
|
+
part)))));
|
|
118
|
+
}
|
|
119
|
+
// ─── Badge variant ────────────────────────────────────────
|
|
120
|
+
if (variant === 'badge') {
|
|
121
|
+
const badges = [];
|
|
122
|
+
const badgeStyle = {
|
|
123
|
+
display: 'inline-flex',
|
|
124
|
+
alignItems: 'center',
|
|
125
|
+
gap: theme.spacing.small,
|
|
126
|
+
padding: `${theme.spacing.small} ${theme.spacing.medium}`,
|
|
127
|
+
borderRadius: borderRadiusSmall,
|
|
128
|
+
backgroundColor: `var(--seekora-stats-badge-bg, ${theme.colors.primary}1A)`, // 10 % opacity hex
|
|
129
|
+
color: `var(--seekora-stats-badge-color, ${theme.colors.primary})`,
|
|
130
|
+
fontSize: theme.typography.fontSize.small,
|
|
131
|
+
fontWeight: 500,
|
|
132
|
+
};
|
|
133
|
+
if (showResultCount) {
|
|
134
|
+
badges.push(React.createElement("span", { key: "count", className: clsx(statsTheme.badge), style: badgeStyle },
|
|
135
|
+
React.createElement("span", { className: statsTheme.badgeLabel }, "Results"),
|
|
136
|
+
React.createElement("span", { className: clsx(statsTheme.badgeValue, animating && ANIMATE_CLASS), style: { fontWeight: 600, transition: 'opacity 250ms ease-in-out' } }, totalResults > 0 ? fmt(totalResults) : '0')));
|
|
137
|
+
}
|
|
138
|
+
if (showQuery && query) {
|
|
139
|
+
badges.push(React.createElement("span", { key: "query", className: clsx(statsTheme.badge), style: badgeStyle },
|
|
140
|
+
React.createElement("span", { className: statsTheme.badgeLabel }, "Query"),
|
|
141
|
+
React.createElement("span", { className: statsTheme.badgeValue, style: { fontWeight: 600 } }, query)));
|
|
142
|
+
}
|
|
143
|
+
if (showProcessingTime && processingTime !== undefined) {
|
|
144
|
+
badges.push(React.createElement("span", { key: "time", className: clsx(statsTheme.badge), style: badgeStyle },
|
|
145
|
+
React.createElement("span", { className: statsTheme.badgeLabel }, "Time"),
|
|
146
|
+
React.createElement("span", { className: statsTheme.badgeValue, style: { fontWeight: 600 } },
|
|
147
|
+
fmt(processingTime),
|
|
148
|
+
"ms")));
|
|
149
|
+
}
|
|
150
|
+
return (React.createElement("div", { className: clsx('seekora-stats-root', statsTheme.container, className), style: {
|
|
151
|
+
display: 'flex',
|
|
152
|
+
flexWrap: 'wrap',
|
|
153
|
+
gap: theme.spacing.small,
|
|
154
|
+
fontSize: 'var(--seekora-stats-font-size,' + theme.typography.fontSize.small + ')',
|
|
155
|
+
color: 'var(--seekora-stats-color,' + theme.colors.text + ')',
|
|
156
|
+
backgroundColor: 'var(--seekora-stats-bg, transparent)',
|
|
157
|
+
...style,
|
|
158
|
+
} }, badges));
|
|
159
|
+
}
|
|
160
|
+
// ─── Detailed variant ─────────────────────────────────────
|
|
161
|
+
if (variant === 'detailed') {
|
|
162
|
+
const rows = [];
|
|
163
|
+
if (showResultCount) {
|
|
164
|
+
rows.push({
|
|
165
|
+
label: 'Total Results',
|
|
166
|
+
value: (React.createElement("span", { className: clsx(animating && ANIMATE_CLASS), style: { transition: 'opacity 250ms ease-in-out' } }, fmt(totalResults))),
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
if (showQuery && query) {
|
|
170
|
+
rows.push({ label: 'Query', value: query });
|
|
171
|
+
}
|
|
172
|
+
if (showProcessingTime && processingTime !== undefined) {
|
|
173
|
+
rows.push({ label: 'Time', value: `${fmt(processingTime)}ms` });
|
|
174
|
+
}
|
|
175
|
+
return (React.createElement("div", { className: clsx('seekora-stats-root', statsTheme.detailed, statsTheme.container, className), style: {
|
|
176
|
+
display: 'flex',
|
|
177
|
+
flexDirection: 'column',
|
|
178
|
+
gap: theme.spacing.small,
|
|
179
|
+
fontSize: 'var(--seekora-stats-font-size,' + theme.typography.fontSize.medium + ')',
|
|
180
|
+
color: 'var(--seekora-stats-color,' + theme.colors.text + ')',
|
|
181
|
+
backgroundColor: 'var(--seekora-stats-bg, transparent)',
|
|
182
|
+
...style,
|
|
183
|
+
} }, rows.map((row, index) => (React.createElement("div", { key: index, className: statsTheme.detailedRow, style: {
|
|
184
|
+
display: 'flex',
|
|
185
|
+
alignItems: 'center',
|
|
186
|
+
gap: theme.spacing.small,
|
|
187
|
+
} },
|
|
188
|
+
React.createElement("span", { className: statsTheme.detailedLabel, style: {
|
|
189
|
+
color: theme.colors.textSecondary,
|
|
190
|
+
fontWeight: 500,
|
|
191
|
+
} },
|
|
192
|
+
row.label,
|
|
193
|
+
":"),
|
|
194
|
+
React.createElement("span", { className: statsTheme.detailedValue, style: {
|
|
195
|
+
color: theme.colors.text,
|
|
196
|
+
fontWeight: 600,
|
|
197
|
+
} }, row.value))))));
|
|
50
198
|
}
|
|
51
|
-
|
|
199
|
+
// Fallback (should not be reached)
|
|
200
|
+
return null;
|
|
52
201
|
};
|
|
@@ -7,6 +7,8 @@ export interface SectionItemGridProps {
|
|
|
7
7
|
maxItems?: number;
|
|
8
8
|
className?: string;
|
|
9
9
|
style?: React.CSSProperties;
|
|
10
|
+
/** Show loading state when fetching and no previous items (default false: show previous results until new render) */
|
|
11
|
+
showLoadingState?: boolean;
|
|
10
12
|
getItemId?: (item: unknown) => string;
|
|
11
13
|
getItemTitle?: (item: unknown) => string;
|
|
12
14
|
getItemImage?: (item: unknown) => string | undefined;
|
|
@@ -14,5 +16,5 @@ export interface SectionItemGridProps {
|
|
|
14
16
|
getItemUrl?: (item: unknown) => string | undefined;
|
|
15
17
|
renderItem?: (item: unknown, index: number) => React.ReactNode;
|
|
16
18
|
}
|
|
17
|
-
export declare function SectionItemGrid({ columns, maxItems, className, style, getItemId, getItemTitle, getItemImage, getItemDescription, getItemUrl, renderItem, }: SectionItemGridProps): React.JSX.Element;
|
|
19
|
+
export declare function SectionItemGrid({ columns, maxItems, className, style, showLoadingState, getItemId, getItemTitle, getItemImage, getItemDescription, getItemUrl, renderItem, }: SectionItemGridProps): React.JSX.Element;
|
|
18
20
|
//# sourceMappingURL=SectionItemGrid.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SectionItemGrid.d.ts","sourceRoot":"","sources":["../../../src/components/section-primitives/SectionItemGrid.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,MAAM,CAAC;IACtC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,MAAM,CAAC;IACzC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,MAAM,GAAG,SAAS,CAAC;IACrD,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,MAAM,GAAG,SAAS,CAAC;IAC3D,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,MAAM,GAAG,SAAS,CAAC;IACnD,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC;CAChE;AAED,wBAAgB,eAAe,CAAC,EAC9B,OAAW,EACX,QAAa,EACb,SAAS,EACT,KAAK,EACL,SAA8E,EAC9E,YAAyE,EACzE,YAAmE,EACnE,kBAAqF,EACrF,UAA6D,EAC7D,UAAU,GACX,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"SectionItemGrid.d.ts","sourceRoot":"","sources":["../../../src/components/section-primitives/SectionItemGrid.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,qHAAqH;IACrH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,MAAM,CAAC;IACtC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,MAAM,CAAC;IACzC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,MAAM,GAAG,SAAS,CAAC;IACrD,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,MAAM,GAAG,SAAS,CAAC;IAC3D,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,MAAM,GAAG,SAAS,CAAC;IACnD,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC;CAChE;AAED,wBAAgB,eAAe,CAAC,EAC9B,OAAW,EACX,QAAa,EACb,SAAS,EACT,KAAK,EACL,gBAAwB,EACxB,SAA8E,EAC9E,YAAyE,EACzE,YAAmE,EACnE,kBAAqF,EACrF,UAA6D,EAC7D,UAAU,GACX,EAAE,oBAAoB,qBAuBtB"}
|