@seekora-ai/ui-sdk-react 0.2.32 → 0.2.33
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/docsearch/components/DocSearch.d.ts +3 -3
- package/dist/docsearch/components/DocSearch.d.ts.map +1 -1
- package/dist/docsearch/components/DocSearch.js +20 -18
- package/dist/docsearch/components/DocSearchButton.d.ts +3 -3
- package/dist/docsearch/components/DocSearchButton.d.ts.map +1 -1
- package/dist/docsearch/components/DocSearchButton.js +5 -5
- package/dist/docsearch/components/Modal.d.ts +3 -2
- package/dist/docsearch/components/Modal.d.ts.map +1 -1
- package/dist/docsearch/components/Modal.js +16 -13
- package/dist/docsearch/types.d.ts +17 -13
- package/dist/docsearch/types.d.ts.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/src/index.d.ts +18 -14
- package/dist/src/index.esm.js +28 -23
- package/dist/src/index.esm.js.map +1 -1
- package/dist/src/index.js +28 -23
- package/dist/src/index.js.map +1 -1
- package/package.json +3 -3
package/dist/src/index.d.ts
CHANGED
|
@@ -3790,10 +3790,14 @@ interface DocSearchProps {
|
|
|
3790
3790
|
shortcutKey?: string;
|
|
3791
3791
|
/** Post-process results per source (e.g. filter by permission, resolve :storeId). */
|
|
3792
3792
|
processGroupedResults?: (sourceId: string, items: DocSearchSuggestion[]) => DocSearchSuggestion[];
|
|
3793
|
+
/** Additional CSS class applied to the modal overlay and container — use to scope CSS variable overrides. */
|
|
3794
|
+
className?: string;
|
|
3793
3795
|
}
|
|
3794
3796
|
interface DocSearchButtonProps {
|
|
3795
3797
|
onClick: () => void;
|
|
3796
3798
|
placeholder?: string;
|
|
3799
|
+
/** Additional CSS class for the button element. */
|
|
3800
|
+
className?: string;
|
|
3797
3801
|
}
|
|
3798
3802
|
interface DocSearchTranslations {
|
|
3799
3803
|
buttonText?: string;
|
|
@@ -3812,40 +3816,40 @@ interface DocSearchState {
|
|
|
3812
3816
|
isLoading: boolean;
|
|
3813
3817
|
error: string | null;
|
|
3814
3818
|
selectedIndex: number;
|
|
3815
|
-
mode:
|
|
3819
|
+
mode: "suggestions" | "results";
|
|
3816
3820
|
}
|
|
3817
3821
|
type DocSearchAction = {
|
|
3818
|
-
type:
|
|
3822
|
+
type: "SET_QUERY";
|
|
3819
3823
|
payload: string;
|
|
3820
3824
|
} | {
|
|
3821
|
-
type:
|
|
3825
|
+
type: "SET_RESULTS";
|
|
3822
3826
|
payload: DocSearchHit[];
|
|
3823
3827
|
} | {
|
|
3824
|
-
type:
|
|
3828
|
+
type: "SET_SUGGESTIONS";
|
|
3825
3829
|
payload: DocSearchSuggestion[];
|
|
3826
3830
|
} | {
|
|
3827
|
-
type:
|
|
3831
|
+
type: "SET_LOADING";
|
|
3828
3832
|
payload: boolean;
|
|
3829
3833
|
} | {
|
|
3830
|
-
type:
|
|
3834
|
+
type: "SET_ERROR";
|
|
3831
3835
|
payload: string | null;
|
|
3832
3836
|
} | {
|
|
3833
|
-
type:
|
|
3837
|
+
type: "SET_SELECTED_INDEX";
|
|
3834
3838
|
payload: number;
|
|
3835
3839
|
} | {
|
|
3836
|
-
type:
|
|
3840
|
+
type: "SELECT_NEXT";
|
|
3837
3841
|
} | {
|
|
3838
|
-
type:
|
|
3842
|
+
type: "SELECT_PREV";
|
|
3839
3843
|
} | {
|
|
3840
|
-
type:
|
|
3841
|
-
payload:
|
|
3844
|
+
type: "SET_MODE";
|
|
3845
|
+
payload: "suggestions" | "results";
|
|
3842
3846
|
} | {
|
|
3843
|
-
type:
|
|
3847
|
+
type: "RESET";
|
|
3844
3848
|
};
|
|
3845
3849
|
|
|
3846
|
-
declare function DocSearch({ storeId, storeSecret, seekoraApiEndpoint, apiEndpoint, apiKey, sources, placeholder, maxResults, debounceMs, onSelect, onClose, translations, renderButton, buttonComponent: ButtonComponent, initialOpen, disableShortcut, shortcutKey, processGroupedResults, }: DocSearchProps): React__default.JSX.Element;
|
|
3850
|
+
declare function DocSearch({ storeId, storeSecret, seekoraApiEndpoint, apiEndpoint, apiKey, sources, placeholder, maxResults, debounceMs, onSelect, onClose, translations, renderButton, buttonComponent: ButtonComponent, initialOpen, disableShortcut, shortcutKey, processGroupedResults, className, }: DocSearchProps): React__default.JSX.Element;
|
|
3847
3851
|
|
|
3848
|
-
declare function DocSearchButton({ onClick, placeholder }: DocSearchButtonProps): React__default.JSX.Element;
|
|
3852
|
+
declare function DocSearchButton({ onClick, placeholder, className, }: DocSearchButtonProps): React__default.JSX.Element;
|
|
3849
3853
|
|
|
3850
3854
|
interface UseDocSearchOptions {
|
|
3851
3855
|
apiEndpoint?: string;
|
package/dist/src/index.esm.js
CHANGED
|
@@ -16674,24 +16674,27 @@ const SuggestionDropdownVariants = {
|
|
|
16674
16674
|
minimal: MinimalDropdown,
|
|
16675
16675
|
};
|
|
16676
16676
|
|
|
16677
|
-
function Modal({ isOpen, onClose, children }) {
|
|
16677
|
+
function Modal({ isOpen, onClose, children, className }) {
|
|
16678
16678
|
const overlayRef = useRef(null);
|
|
16679
16679
|
const containerRef = useRef(null);
|
|
16680
16680
|
useEffect(() => {
|
|
16681
16681
|
const handleClickOutside = (event) => {
|
|
16682
|
-
if (containerRef.current &&
|
|
16682
|
+
if (containerRef.current &&
|
|
16683
|
+
!containerRef.current.contains(event.target)) {
|
|
16683
16684
|
onClose();
|
|
16684
16685
|
}
|
|
16685
16686
|
};
|
|
16686
16687
|
if (isOpen)
|
|
16687
|
-
document.addEventListener(
|
|
16688
|
-
return () => document.removeEventListener(
|
|
16688
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
16689
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
16689
16690
|
}, [isOpen, onClose]);
|
|
16690
16691
|
useEffect(() => {
|
|
16691
16692
|
if (isOpen) {
|
|
16692
16693
|
const originalOverflow = document.body.style.overflow;
|
|
16693
|
-
document.body.style.overflow =
|
|
16694
|
-
return () => {
|
|
16694
|
+
document.body.style.overflow = "hidden";
|
|
16695
|
+
return () => {
|
|
16696
|
+
document.body.style.overflow = originalOverflow;
|
|
16697
|
+
};
|
|
16695
16698
|
}
|
|
16696
16699
|
}, [isOpen]);
|
|
16697
16700
|
useEffect(() => {
|
|
@@ -16702,7 +16705,7 @@ function Modal({ isOpen, onClose, children }) {
|
|
|
16702
16705
|
const firstElement = focusableElements[0];
|
|
16703
16706
|
const lastElement = focusableElements[focusableElements.length - 1];
|
|
16704
16707
|
const handleTabKey = (e) => {
|
|
16705
|
-
if (e.key !==
|
|
16708
|
+
if (e.key !== "Tab")
|
|
16706
16709
|
return;
|
|
16707
16710
|
if (e.shiftKey) {
|
|
16708
16711
|
if (document.activeElement === firstElement) {
|
|
@@ -16717,12 +16720,12 @@ function Modal({ isOpen, onClose, children }) {
|
|
|
16717
16720
|
}
|
|
16718
16721
|
}
|
|
16719
16722
|
};
|
|
16720
|
-
container.addEventListener(
|
|
16721
|
-
return () => container.removeEventListener(
|
|
16723
|
+
container.addEventListener("keydown", handleTabKey);
|
|
16724
|
+
return () => container.removeEventListener("keydown", handleTabKey);
|
|
16722
16725
|
}, [isOpen]);
|
|
16723
|
-
if (!isOpen || typeof document ===
|
|
16726
|
+
if (!isOpen || typeof document === "undefined")
|
|
16724
16727
|
return null;
|
|
16725
|
-
const modalContent = (React.createElement("div", { ref: overlayRef, className:
|
|
16728
|
+
const modalContent = (React.createElement("div", { ref: overlayRef, className: `seekora-docsearch-overlay${className ? ` ${className}` : ""}`, role: "dialog", "aria-modal": "true", "aria-label": "Search documentation" },
|
|
16726
16729
|
React.createElement("div", { ref: containerRef, className: "seekora-docsearch-container" }, children)));
|
|
16727
16730
|
return createPortal(modalContent, document.body);
|
|
16728
16731
|
}
|
|
@@ -17136,9 +17139,9 @@ function getShortcutText(key = 'K') {
|
|
|
17136
17139
|
return isMac ? `⌘${key}` : `Ctrl+${key}`;
|
|
17137
17140
|
}
|
|
17138
17141
|
|
|
17139
|
-
function DocSearchButton({ onClick, placeholder =
|
|
17140
|
-
const shortcutText = getShortcutText(
|
|
17141
|
-
return (React.createElement("button", { type: "button", className:
|
|
17142
|
+
function DocSearchButton({ onClick, placeholder = "Search documentation...", className, }) {
|
|
17143
|
+
const shortcutText = getShortcutText("K");
|
|
17144
|
+
return (React.createElement("button", { type: "button", className: `seekora-docsearch-button${className ? ` ${className}` : ""}`, onClick: onClick, "aria-label": "Search documentation" },
|
|
17142
17145
|
React.createElement("span", { className: "seekora-docsearch-button-icon" },
|
|
17143
17146
|
React.createElement("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true" },
|
|
17144
17147
|
React.createElement("path", { d: "M9 3.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM2 9a7 7 0 1112.452 4.391l3.328 3.329a.75.75 0 11-1.06 1.06l-3.329-3.328A7 7 0 012 9z", fill: "currentColor" }))),
|
|
@@ -17583,17 +17586,17 @@ function useSeekoraSearch$1(options) {
|
|
|
17583
17586
|
};
|
|
17584
17587
|
}
|
|
17585
17588
|
|
|
17586
|
-
function DocSearch({ storeId, storeSecret, seekoraApiEndpoint, apiEndpoint, apiKey, sources, placeholder =
|
|
17589
|
+
function DocSearch({ storeId, storeSecret, seekoraApiEndpoint, apiEndpoint, apiKey, sources, placeholder = "Search documentation...", maxResults = 10, debounceMs = 200, onSelect, onClose, translations = {}, renderButton = true, buttonComponent: ButtonComponent = DocSearchButton, initialOpen = false, disableShortcut = false, shortcutKey = "k", processGroupedResults, className, }) {
|
|
17587
17590
|
const [isOpen, setIsOpen] = useState(initialOpen);
|
|
17588
17591
|
const scrollSelectionIntoViewRef = useRef(false);
|
|
17589
17592
|
const useSeekoraSDK = !!storeId;
|
|
17590
17593
|
const seekoraSearch = useSeekoraSearch$1({
|
|
17591
|
-
storeId: storeId ||
|
|
17594
|
+
storeId: storeId || "",
|
|
17592
17595
|
storeSecret,
|
|
17593
17596
|
apiEndpoint: seekoraApiEndpoint,
|
|
17594
17597
|
maxResults,
|
|
17595
17598
|
debounceMs,
|
|
17596
|
-
analyticsTags: [
|
|
17599
|
+
analyticsTags: ["docsearch"],
|
|
17597
17600
|
});
|
|
17598
17601
|
const legacySearch = useDocSearch({
|
|
17599
17602
|
apiEndpoint,
|
|
@@ -17604,11 +17607,13 @@ function DocSearch({ storeId, storeSecret, seekoraApiEndpoint, apiEndpoint, apiK
|
|
|
17604
17607
|
processGroupedResults,
|
|
17605
17608
|
});
|
|
17606
17609
|
const { query, suggestions, isLoading, error, selectedIndex, setQuery, selectNext, selectPrev, setSelectedIndex, reset, getSelectedItem, } = useSeekoraSDK ? seekoraSearch : legacySearch;
|
|
17607
|
-
const groupedSuggestions = useSeekoraSDK
|
|
17610
|
+
const groupedSuggestions = useSeekoraSDK
|
|
17611
|
+
? undefined
|
|
17612
|
+
: legacySearch.groupedSuggestions;
|
|
17608
17613
|
const results = useSeekoraSDK ? suggestions : legacySearch.results;
|
|
17609
|
-
const mode = useSeekoraSDK ?
|
|
17614
|
+
const mode = useSeekoraSDK ? "suggestions" : legacySearch.mode;
|
|
17610
17615
|
const searchSources = useSeekoraSDK
|
|
17611
|
-
? [{ id:
|
|
17616
|
+
? [{ id: "seekora", name: "Results", endpoint: "" }]
|
|
17612
17617
|
: legacySearch.sources;
|
|
17613
17618
|
const handleOpen = useCallback(() => setIsOpen(true), []);
|
|
17614
17619
|
const handleClose = useCallback(() => {
|
|
@@ -17652,10 +17657,10 @@ function DocSearch({ storeId, storeSecret, seekoraApiEndpoint, apiEndpoint, apiK
|
|
|
17652
17657
|
shortcutKey,
|
|
17653
17658
|
});
|
|
17654
17659
|
const handleKeyDown = useCallback((event) => handleModalKeyDown(event), [handleModalKeyDown]);
|
|
17655
|
-
const displayHits = mode ===
|
|
17660
|
+
const displayHits = mode === "results" ? results : suggestions;
|
|
17656
17661
|
return (React.createElement(React.Fragment, null,
|
|
17657
|
-
renderButton && (React.createElement(ButtonComponent, { onClick: handleOpen, placeholder: translations.buttonText || placeholder })),
|
|
17658
|
-
React.createElement(Modal, { isOpen: isOpen, onClose: handleClose },
|
|
17662
|
+
renderButton && (React.createElement(ButtonComponent, { onClick: handleOpen, placeholder: translations.buttonText || placeholder, className: className })),
|
|
17663
|
+
React.createElement(Modal, { isOpen: isOpen, onClose: handleClose, className: className },
|
|
17659
17664
|
React.createElement("div", { className: "seekora-docsearch-modal", onKeyDown: handleKeyDown },
|
|
17660
17665
|
React.createElement("header", { className: "seekora-docsearch-header" },
|
|
17661
17666
|
React.createElement(SearchBox, { value: query, onChange: setQuery, placeholder: placeholder, onClear: reset }),
|