@kivacore/data-source-query-builder
v0.0.1
Published
Visual query builder React component for Kiva data sources.
Readme
@kivacore/data-source-query-builder
A visual query builder React component for Kiva data sources. Supports filters, column selection, ordering, calculations, formulas, pivots, and child queries.
Installation
npm install @kivacore/data-source-query-builderPrerequisites
Your app needs Tailwind CSS configured. Add this package to your Tailwind content paths:
// tailwind.config.js
content: [
// ...
'./node_modules/@kivacore/data-source-query-builder/dist/**/*.js'
]Usage
import { DataSourceQueryBuilder } from '@kivacore/data-source-query-builder';
import type { ISelectQueryParams } from '@kivacore/data-source-query-builder';
function App() {
const [query, setQuery] = useState<Partial<ISelectQueryParams>>({});
return (
<DataSourceQueryBuilder
value={query}
onChange={setQuery}
/>
);
}Props
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| value | Partial<ISelectQueryParams> | required | Current query state |
| onChange | (value) => void | required | Called when the query changes |
| fields | IField[] | [] | Available fields for the selected data source |
| dataSources | IDataSourceReference[] | [] | Pre-loaded data sources |
| locale | UiI18nLocale | 'en' | UI locale |
| variant | 'default' \| 'bordered' \| 'compact' | — | Visual variant |
| size | 'sm' \| 'default' \| 'lg' | 'default' | Component size |
| className | string | — | Additional CSS class |
| defaultSection | DSQBSection | 'dataSource' | Initially active section |
| enableFormulas | boolean | true | Show formula editor |
| enablePivot | boolean | true | Show pivot editor |
| enableChildQueries | boolean | true | Show child queries editor |
| enableCalculations | boolean | true | Show calculations editor |
Kiva Auth Integration
When wrapped in a KivaAuthContext provider from @kivacore/signin, the component automatically discovers data sources and runs query previews against the Kiva API.
import { KivaAuthProvider } from '@kivacore/signin';
<KivaAuthProvider config={authConfig}>
<DataSourceQueryBuilder value={query} onChange={setQuery} />
</KivaAuthProvider>Without auth, you can still use the component by passing fields and dataSources props directly.
Peer Dependencies
react>=19react-dom>=19@kivacore/signin>=0.3.0 (optional)
License
MIT
