UNPKG

synapse-react-client

Version:

[![npm version](https://badge.fury.io/js/synapse-react-client.svg)](https://badge.fury.io/js/synapse-react-client) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettie

160 lines (159 loc) 4.16 kB
import { jsx as O } from "react/jsx-runtime"; import { getDisplayValue as Z } from "../../utils/functions/getDataFromFromStorage.js"; import { unCamelCase as ee } from "../../utils/functions/unCamelCase.js"; import oe from "../../utils/hooks/useMutuallyExclusiveState.js"; import { useQuery as te } from "@tanstack/react-query"; import { useMemo as u, useState as t, useEffect as se, useCallback as c } from "react"; import { useDeepCompareMemoize as le } from "use-deep-compare-effect"; import { useQueryContext as ne } from "../QueryContext/QueryContext.js"; import { useGetQueryMetadata as V } from "../QueryWrapper/useGetQueryMetadata.js"; import { NoContentPlaceholderType as ae } from "../SynapseTable/NoContentPlaceholderType.js"; import re from "./NoContentPlaceholder.js"; import { QueryVisualizationContextProvider as ie } from "./QueryVisualizationContext.js"; const ue = []; function ge(o) { const { noContentPlaceholderType: m = ae.INTERACTIVE, defaultShowSearchBar: v = !1, defaultShowPlots: N = !0, hideCopyToClipboard: j = !1, hideSearchBarControl: d = !1, unitDescription: f = "result", helpConfiguration: a, hasCustomPlots: h = !1, visibleColumnCount: C = 1 / 0, enabledExternalAnalysisPlatforms: p = ue } = o, r = u( () => o.columnAliases ?? {}, [o.columnAliases] ), { getCurrentQueryRequest: y, hasFacetedSelectColumn: i, hasResettableFilters: S, rowDataQueryOptions: z } = ne(), { data: w } = V(), { data: U } = te({ ...z, select: (e) => e.responseBody?.queryResult?.queryResults.headers, placeholderData: (e) => e }), { data: _ } = V({ select: (e) => e.responseBody?.selectColumns, placeholderData: (e) => e }), b = le( U ?? _ ?? [] ), [T, k] = t(!1), [g, G] = t(N), [x, H] = t( !j ), [P, W] = t(!0), [ A, D, E, F ] = oe( v && !d, !1 ), [ M, Y ] = t(!1), [I, q] = t([]), $ = u( () => y(), [y] ); se(() => { q( b.slice(0, C).map((e) => e.name) ); }, [b, $.query.sql, C]); const Q = c( (e, s) => { const L = localStorage.getItem("force-display-original-column-names") === "true"; if (!e || L && !s) return e; if (r[e]) return r[e]; if (s) { const l = w?.columnModels?.find( (n) => n.name === e ); if (l?.jsonSubColumns) { const n = l.jsonSubColumns.find( (X) => X.jsonPath === s ); if (n) return n.name; } } return ee(e); }, [r, w?.columnModels] ), R = c( (e, s) => { if (Array.isArray(a)) return a.find( (l) => l.columnName === e && l.jsonPath === s )?.helpText; }, [a] ), B = c( () => /* @__PURE__ */ O( re, { type: m, hasResettableFilters: S } ), [m, S] ), J = u( () => ({ columnsToShowInTable: I, setColumnsToShowInTable: q, rgbIndex: o.rgbIndex, unitDescription: f, showLastUpdatedOn: o.showLastUpdatedOn, getColumnDisplayName: Q, getDisplayValue: Z, getHelpText: R, NoContentPlaceholder: B, isShowingExportToAnalysisPlatformModal: M, setIsShowingExportToAnalysisPlatformModal: Y, showFacetFilter: i ? P : !1, setShowFacetFilter: W, hideSearchBarControl: d, showSearchBar: A, setShowSearchBar: D, showDownloadConfirmation: E, setShowDownloadConfirmation: F, showSqlEditor: T, setShowSqlEditor: k, showPlots: h || i ? g : !1, setShowPlots: G, showCopyToClipboard: x, setShowCopyToClipboard: H, enabledExternalAnalysisPlatforms: p }), [ B, Q, R, i, M, o.rgbIndex, o.showLastUpdatedOn, F, D, x, E, P, g, A, T, f, I, h, p ] ), { children: K } = o; return /* @__PURE__ */ O(ie, { queryVisualizationContext: J, children: K }); } export { ge as QueryVisualizationWrapper }; //# sourceMappingURL=QueryVisualizationWrapper.js.map