feat: useQlikApi

This commit is contained in:
caele
2024-09-20 10:12:37 +02:00
parent 4a9417ae77
commit 8519d07693
6 changed files with 29 additions and 1 deletions

View File

@@ -265,6 +265,7 @@ const loadType = async ({
app,
selections,
nebbie,
qlikApi,
focusHandler,
emitter,
onMount,
@@ -277,6 +278,7 @@ const loadType = async ({
app,
selections,
nebbie,
qlikApi,
focusHandler,
emitter,
navigation,
@@ -317,7 +319,7 @@ const Cell = forwardRef(
ref
) => {
const { app, types } = halo;
const { nebbie } = halo.public;
const { nebbie, qlikApi } = halo.public;
const {
theme: themeName,
translator,
@@ -423,6 +425,7 @@ const Cell = forwardRef(
app,
selections,
nebbie,
qlikApi,
focusHandler: focusHandler.current,
emitter,
onMount,

View File

@@ -77,9 +77,14 @@ const DEFAULT_SNAPSHOT_CONFIG = /** @lends SnapshotConfiguration */ {
* });
*/
/**
* @interface QlikApi
*/
/**
* @interface Configuration
* @property {Function(LoadType):Promise<Visualization>=} load Fallback load function for missing types
* @property {QlikApi=} qlikApi Instance of qlik api to pass into visualizations
* @property {Context=} context Settings for the rendering instance
* @property {Array<TypeInfo>=} types Visualization types to register
* @property {Array<ThemeInfo>=} themes Themes to register
@@ -112,6 +117,7 @@ const DEFAULT_SNAPSHOT_CONFIG = /** @lends SnapshotConfiguration */ {
*/
const DEFAULT_CONFIG = {
qlikApi: undefined,
context: {},
load: () => undefined,
types: [],
@@ -243,6 +249,7 @@ function nuked(configuration = {}) {
theme: appTheme.externalAPI,
translator: locale.translator,
nebbie: null, // actual value is set further down
qlikApi: configuration.qlikApi,
};
const halo = {

View File

@@ -37,6 +37,7 @@ export {
useInteractionState,
useOptions,
useEmbed,
useQlikApi,
useRenderState,
useEmitter,
onTakeSnapshot,

View File

@@ -69,6 +69,7 @@ function createWithHooks(generator, opts, galaxy) {
model: opts.model,
app: opts.app,
global: qGlobal,
qlikApi: opts.qlikApi,
selections: opts.selections,
nebbie: opts.nebbie,
element: undefined, // set on mount

View File

@@ -743,6 +743,21 @@ export function useEmbed() {
return useInternalContext('nebbie');
}
/**
* Gets the possible qlik api instance provided
* @entry
* @since 5.5.0
* @returns {QlikApi} The qlik api instance provided to Nebula
* @example
* import { useQlikApi } from '@nebula.js/stardust';
*
* const api = useQlikApi();
* api.render(...)
*/
export function useQlikApi() {
return useInternalContext('qlikApi');
}
/**
* Gets the translator.
* @entry

View File

@@ -29,6 +29,7 @@ export {
useKeyboard,
useOptions,
useEmbed,
useQlikApi,
useRenderState,
useEmitter,
onTakeSnapshot,