@progress/kendo-react-grid
Version:
React Data Grid (Table) provides 100+ ready-to-use data grid features. KendoReact Grid package
66 lines (65 loc) • 2.8 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2026 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
"use client";
import * as n from "react";
import { defaultSearchProps as _, defaultSemanticSearchProps as z, defaultAiAssistantProps as F, DEFAULT_STB_SETTINGS as G } from "../defaultConfigs.mjs";
import { normalizeHistorySettings as B } from "../utils.mjs";
function K({
searchConfigProp: T,
semanticSearchConfigProp: b,
aiAssistantConfigProp: x,
activeModeProp: f,
sharedHistory: l
}) {
var V;
const [S, r] = n.useState(f != null ? f : null), [I, E] = n.useState(null);
n.useEffect(() => {
f !== void 0 && r(f);
}, [f]), n.useEffect(() => {
(S === "search" || S === "semanticSearch") && E(S);
}, [S]);
const t = n.useMemo(() => T === !0 ? { ..._, enabled: !0 } : T === !1 || T === void 0 ? null : { ..._, ...T }, [T]), e = n.useMemo(() => b === !0 ? { ...z, enabled: !0 } : b === !1 || b === void 0 ? null : { ...z, ...b }, [b]), u = n.useMemo(() => x === !0 ? { ...F, enabled: !0 } : x === !1 || x === void 0 ? null : { ...F, ...x }, [x]), N = n.useMemo(
() => B(l != null ? l : t == null ? void 0 : t.history),
[t == null ? void 0 : t.history, l]
), R = n.useMemo(
() => B(l != null ? l : e == null ? void 0 : e.history),
[e == null ? void 0 : e.history, l]
), U = n.useMemo(
() => B(l != null ? l : u == null ? void 0 : u.history),
[u == null ? void 0 : u.history, l]
), w = n.useMemo(() => {
var D, L;
const m = {
search: t,
semanticSearch: e,
aiAssistant: u
};
return S && ((D = m[S]) != null && D.enabled) ? S : f && ((L = m[f]) != null && L.enabled) ? f : t != null && t.enabled ? "search" : e != null && e.enabled ? "semanticSearch" : u != null && u.enabled ? "aiAssistant" : null;
}, [f, S, t, e, u]), j = n.useMemo(() => {
const m = u == null ? void 0 : u.speechToTextButton;
return m === !0 ? G : m === !1 || !m ? null : { ...G, ...m };
}, [u == null ? void 0 : u.speechToTextButton]), k = (V = w === "search" ? t == null ? void 0 : t.delay : e == null ? void 0 : e.delay) != null ? V : 300;
return {
searchMode: t,
semanticSearchMode: e,
aiAssistantMode: u,
selectedView: w,
selectedViewState: S,
setSelectedViewState: r,
lastSearchMode: I,
setLastSearchMode: E,
searchHistorySettings: N,
semanticSearchHistorySettings: R,
aiAssistantHistorySettings: U,
speechToTextButtonSettings: j,
currentSearchDelay: k
};
}
export {
K as useSmartBoxModes
};