@sisense/sdk-ui 0.11.3 → 0.12.1

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.
Files changed (46) hide show
  1. package/dist/api/rest-api.d.ts +30 -0
  2. package/dist/api/types/dashboard-dto.d.ts +13 -0
  3. package/dist/app/client-application.d.ts +6 -0
  4. package/dist/app/settings/settings.d.ts +1 -0
  5. package/dist/chart-data-options/validate-data-options/index.d.ts +1 -0
  6. package/dist/chart-data-options/validate-data-options/validate-categorical-data-options.d.ts +3 -0
  7. package/dist/chart-data-options/{validate-data-options.d.ts → validate-data-options/validate-data-options.d.ts} +4 -4
  8. package/dist/chart-options-processor/chart-options-service.d.ts +1 -1
  9. package/dist/common/hooks/data-load-state-reducer.d.ts +65 -0
  10. package/dist/common/hooks/types.d.ts +8 -0
  11. package/dist/common/hooks/use-previous.d.ts +7 -0
  12. package/dist/dashboard-widget/types.d.ts +7 -6
  13. package/dist/dashboard-widget/utils.d.ts +0 -1
  14. package/dist/decorators/as-sisense-component.d.ts +2 -0
  15. package/dist/decorators/with-default-translations.d.ts +6 -0
  16. package/dist/decorators/with-sisense-context-validation.d.ts +1 -1
  17. package/dist/decorators/with-tracking/error-tracker.d.ts +2 -0
  18. package/dist/error-boundary/error-boundary-box.d.ts +4 -3
  19. package/dist/error-boundary/error-boundary.d.ts +3 -2
  20. package/dist/index.d.ts +1 -0
  21. package/dist/index.js +37090 -34175
  22. package/dist/models/dashboard/get-dashboard-model.d.ts +11 -0
  23. package/dist/models/dashboard/get-dashboard-models.d.ts +17 -0
  24. package/dist/models/dashboard/index.d.ts +6 -0
  25. package/dist/models/dashboard/translate-dashboard.d.ts +3 -0
  26. package/dist/models/dashboard/types.d.ts +8 -0
  27. package/dist/models/dashboard/use-get-dashboard-model.d.ts +99 -0
  28. package/dist/models/dashboard/use-get-dashboard-models.d.ts +84 -0
  29. package/dist/models/index.d.ts +2 -0
  30. package/dist/models/widget/index.d.ts +2 -0
  31. package/dist/models/widget/translate-widget.d.ts +3 -0
  32. package/dist/models/widget/types.d.ts +6 -0
  33. package/dist/props.d.ts +1 -1
  34. package/dist/query-execution/query-state-reducer.d.ts +2 -9
  35. package/dist/query-execution/use-execute-query-by-widget-id.d.ts +1 -1
  36. package/dist/query-execution/use-execute-query.d.ts +0 -7
  37. package/dist/translation/i18n-provider.d.ts +7 -0
  38. package/dist/translation/initialize-i18n.d.ts +2 -0
  39. package/dist/translation/resources/en.d.ts +28 -0
  40. package/dist/translation/resources/index.d.ts +59 -0
  41. package/dist/translation/resources/uk.d.ts +2 -0
  42. package/dist/translation/translatable-error.d.ts +5 -0
  43. package/dist/translation/use-initialized-i18n.d.ts +2 -0
  44. package/package.json +7 -5
  45. package/dist/dashboard-widget/fetch-widget.d.ts +0 -11
  46. package/dist/locales/en.d.ts +0 -17
@@ -0,0 +1,11 @@
1
+ import { HttpClient } from '@sisense/sdk-rest-client';
2
+ export interface GetDashboardModelOptions {
3
+ /**
4
+ * Boolean flag whether to include widgets in the dashboard model
5
+ *
6
+ * If not specified, the default value is `false`
7
+ */
8
+ includeWidgets?: boolean;
9
+ }
10
+ /** @internal */
11
+ export declare function getDashboardModel(http: HttpClient, dashboardOid: string, options?: GetDashboardModelOptions): Promise<import("./types").DashboardModel>;
@@ -0,0 +1,17 @@
1
+ import { HttpClient } from '@sisense/sdk-rest-client';
2
+ export interface GetDashboardModelsOptions {
3
+ /**
4
+ * Dashboard title to search by
5
+ *
6
+ * The dashboard title is not unique, therefore, the result may return multiple dashboards.
7
+ */
8
+ searchByTitle?: string;
9
+ /**
10
+ * Boolean flag whether to include widgets in the dashboard model
11
+ *
12
+ * If not specified, the default value is `false`
13
+ */
14
+ includeWidgets?: boolean;
15
+ }
16
+ /** @internal */
17
+ export declare function getDashboardModels(http: HttpClient, options?: GetDashboardModelsOptions): Promise<import("./types.js").DashboardModel[]>;
@@ -0,0 +1,6 @@
1
+ export * from './types';
2
+ export * from './get-dashboard-model';
3
+ export * from './get-dashboard-models';
4
+ export * from './translate-dashboard';
5
+ export * from './use-get-dashboard-model';
6
+ export * from './use-get-dashboard-models';
@@ -0,0 +1,3 @@
1
+ import { type DashboardDto } from '../../api/types/dashboard-dto';
2
+ import { type DashboardModel } from './types';
3
+ export declare function translateDashboard({ oid, title, datasource, widgets, }: DashboardDto): DashboardModel;
@@ -0,0 +1,8 @@
1
+ import { type DataSource } from '@sisense/sdk-data';
2
+ import { type WidgetModel } from '../widget/types';
3
+ export type DashboardModel = {
4
+ oid: string;
5
+ title: string;
6
+ dataSource: DataSource;
7
+ widgets?: WidgetModel[];
8
+ };
@@ -0,0 +1,99 @@
1
+ import { type DashboardModel } from './types';
2
+ import { GetDashboardModelOptions } from './get-dashboard-model';
3
+ import { HookEnableParam } from '../../common/hooks/types';
4
+ /**
5
+ * Parameters for {@link useGetDashboardModel} hook.
6
+ */
7
+ export interface GetDashboardModelParams extends GetDashboardModelOptions, HookEnableParam {
8
+ /**
9
+ * Identifier of the dashboard that contains the widget
10
+ */
11
+ dashboardOid: string;
12
+ }
13
+ /**
14
+ * States of a dashboard model load.
15
+ */
16
+ export type DashboardModelState = DashboardModelLoadingState | DashboardModelErrorState | DashboardModelSuccessState;
17
+ /**
18
+ * State of a dashboard model loading.
19
+ */
20
+ export type DashboardModelLoadingState = {
21
+ /** Whether the dashboard model is loading */
22
+ isLoading: true;
23
+ /** Whether the dashboard model load has failed */
24
+ isError: false;
25
+ /** Whether the dashboard model load has succeeded */
26
+ isSuccess: false;
27
+ /** The error if any occurred */
28
+ error: undefined;
29
+ /** The result dashboard model if the load has succeeded */
30
+ dashboard: DashboardModel | undefined;
31
+ /** The status of the dashboard model load */
32
+ status: 'loading';
33
+ };
34
+ /**
35
+ * State of a dashboard model load that has failed.
36
+ */
37
+ export type DashboardModelErrorState = {
38
+ /** Whether the dashboard model is loading */
39
+ isLoading: false;
40
+ /** Whether the dashboard model load has failed */
41
+ isError: true;
42
+ /** Whether the dashboard model load has succeeded */
43
+ isSuccess: false;
44
+ /** The error if any occurred */
45
+ error: Error;
46
+ /** The result dashboard model if the load has succeeded */
47
+ dashboard: undefined;
48
+ /** The status of the dashboard model load */
49
+ status: 'error';
50
+ };
51
+ /**
52
+ * State of a dashboard model load that has succeeded.
53
+ */
54
+ export type DashboardModelSuccessState = {
55
+ /** Whether the dashboard model is loading */
56
+ isLoading: false;
57
+ /** Whether the dashboard model load has failed */
58
+ isError: false;
59
+ /** Whether the dashboard model load has succeeded */
60
+ isSuccess: true;
61
+ /** The error if any occurred */
62
+ error: undefined;
63
+ /** The result dashboard model if the load has succeeded */
64
+ dashboard: DashboardModel;
65
+ /** The status of the dashboard model load */
66
+ status: 'success';
67
+ };
68
+ /**
69
+ * React hook that retrieves an existing dashboard model from the Sisense instance.
70
+ *
71
+ * @example
72
+ * An example of retrieving an existing dashboard model from the Sisense instance and render its widgets with component `DashboardWidget`:
73
+ ```tsx
74
+ const { dashboard, isLoading, isError } = useGetDashboardModel({
75
+ dashboardOid: '6448665edac1920034bce7a8',
76
+ includeWidgets: true,
77
+ });
78
+ if (isLoading) {
79
+ return <div>Loading...</div>;
80
+ }
81
+ if (isError) {
82
+ return <div>Error</div>;
83
+ }
84
+ if (dashboard) {
85
+ return (
86
+ <div>
87
+ {`Dashboard Title - ${dashboard.title}`}
88
+ {dashboard.widgets?.map((widget) => (
89
+ <DashboardWidget key={widget.oid} widgetOid={widget.oid} dashboardOid={dashboard.oid} />
90
+ ))}
91
+ </div>
92
+ );
93
+ }
94
+ return null;
95
+ ```
96
+ * @param params - Parameters of the dashboard to be retrieved
97
+ * @returns Dashboard load state that contains the status of the execution, the result dashboard model, or the error if any
98
+ */
99
+ export declare const useGetDashboardModel: (params: GetDashboardModelParams) => DashboardModelState;
@@ -0,0 +1,84 @@
1
+ import { type DashboardModel } from './types.js';
2
+ import { HookEnableParam } from '../../common/hooks/types.js';
3
+ import { GetDashboardModelsOptions } from './get-dashboard-models.js';
4
+ /**
5
+ * Parameters for {@link useGetDashboardModels} hook.
6
+ */
7
+ export interface GetDashboardModelsParams extends GetDashboardModelsOptions, HookEnableParam {
8
+ }
9
+ /**
10
+ * States of a dashboard models load.
11
+ */
12
+ export type DashboardModelsState = DashboardModelsLoadingState | DashboardModelsErrorState | DashboardModelsSuccessState;
13
+ /**
14
+ * State of a dashboard models loading.
15
+ */
16
+ export type DashboardModelsLoadingState = {
17
+ /** Whether the dashboard models is loading */
18
+ isLoading: true;
19
+ /** Whether the dashboard models load has failed */
20
+ isError: false;
21
+ /** Whether the dashboard models load has succeeded */
22
+ isSuccess: false;
23
+ /** The error if any occurred */
24
+ error: undefined;
25
+ /** The result dashboard models if the load has succeeded */
26
+ dashboards: DashboardModel[] | undefined;
27
+ /** The status of the dashboard models load */
28
+ status: 'loading';
29
+ };
30
+ /**
31
+ * State of a dashboard models load that has failed.
32
+ */
33
+ export type DashboardModelsErrorState = {
34
+ /** Whether the dashboard models is loading */
35
+ isLoading: false;
36
+ /** Whether the dashboard models load has failed */
37
+ isError: true;
38
+ /** Whether the dashboard models load has succeeded */
39
+ isSuccess: false;
40
+ /** The error if any occurred */
41
+ error: Error;
42
+ /** The result dashboard models if the load has succeeded */
43
+ dashboards: undefined;
44
+ /** The status of the dashboard models load */
45
+ status: 'error';
46
+ };
47
+ /**
48
+ * State of a dashboard models load that has succeeded.
49
+ */
50
+ export type DashboardModelsSuccessState = {
51
+ /** Whether the dashboard models is loading */
52
+ isLoading: false;
53
+ /** Whether the dashboard models load has failed */
54
+ isError: false;
55
+ /** Whether the dashboard models load has succeeded */
56
+ isSuccess: true;
57
+ /** The error if any occurred */
58
+ error: undefined;
59
+ /** The result dashboard models if the load has succeeded */
60
+ dashboards: DashboardModel[];
61
+ /** The status of the dashboard models load */
62
+ status: 'success';
63
+ };
64
+ /**
65
+ * React hook that retrieves existing dashboards that the user can access to from the Sisense instance.
66
+ *
67
+ * @example
68
+ ```tsx
69
+ const { dashboards, isLoading, isError } = useGetDashboardModels();
70
+ if (isLoading) {
71
+ return <div>Loading...</div>;
72
+ }
73
+ if (isError) {
74
+ return <div>Error</div>;
75
+ }
76
+ if (dashboards) {
77
+ return <div>{`Total Dashboards: ${dashboards.length}`}</div>;
78
+ }
79
+ return null;
80
+ ```
81
+ * @param params - Parameters of the dashboards to be retrieved
82
+ * @returns Load state that contains the status of the execution, the result dashboards, or the error if any
83
+ */
84
+ export declare const useGetDashboardModels: (params?: GetDashboardModelsParams) => DashboardModelsState;
@@ -0,0 +1,2 @@
1
+ export * from './dashboard';
2
+ export * from './widget';
@@ -0,0 +1,2 @@
1
+ export * from './types';
2
+ export * from './translate-widget';
@@ -0,0 +1,3 @@
1
+ import { WidgetDto } from '../../dashboard-widget/types';
2
+ import { WidgetModel } from './types';
3
+ export declare function translateWidget(widget: WidgetDto): WidgetModel;
@@ -0,0 +1,6 @@
1
+ import { DataSource } from '@sisense/sdk-data';
2
+ export type WidgetModel = {
3
+ oid: string;
4
+ title: string;
5
+ dataSource: DataSource;
6
+ };
package/dist/props.d.ts CHANGED
@@ -744,7 +744,7 @@ export interface ExecuteQueryByWidgetIdProps {
744
744
  * - `codeFirst` - prioritizes the provided filters over the widget filters in case of filter conflicts by certain attributes.
745
745
  * - `codeOnly` - applies only the provided filters and completely ignores the widget filters.
746
746
  *
747
- * If not specified, the default strategy is `widgetFirst`.
747
+ * If not specified, the default strategy is `codeFirst`.
748
748
  */
749
749
  filtersMergeStrategy?: FiltersMergeStrategy;
750
750
  /** Function as child component that is called to render the query results */
@@ -1,4 +1,5 @@
1
1
  import { QueryResultData } from '@sisense/sdk-data';
2
+ import { DataLoadAction } from '../common/hooks/data-load-state-reducer';
2
3
  /**
3
4
  * State of a query execution.
4
5
  */
@@ -54,13 +55,5 @@ export type QuerySuccessState = {
54
55
  /** The status of the query execution */
55
56
  status: 'success';
56
57
  };
57
- export type QueryAction = {
58
- type: 'loading';
59
- } | {
60
- type: 'success';
61
- data: QueryResultData;
62
- } | {
63
- type: 'error';
64
- error: Error;
65
- };
58
+ export type QueryAction = DataLoadAction<QueryResultData>;
66
59
  export declare function queryStateReducer(state: QueryState, action: QueryAction): QueryState;
@@ -36,7 +36,7 @@ export type QueryByWidgetIdState = QueryState & {
36
36
  * The example below executes a query over the existing dashboard widget with the specified widget and dashboard OIDs.
37
37
  ```tsx
38
38
  const { data, isLoading, isError } = useExecuteQueryByWidgetId({
39
- widgetOid: '64473e07dac1920034bce77f'
39
+ widgetOid: '64473e07dac1920034bce77f',
40
40
  dashboardOid: '6441e728dac1920034bce737'
41
41
  });
42
42
  if (isLoading) {
@@ -61,10 +61,3 @@ export type ExecuteQueryParams = {
61
61
  * @returns Query state that contains the status of the query execution, the result data, or the error if any occurred
62
62
  */
63
63
  export declare const useExecuteQuery: (params: ExecuteQueryParams) => QueryState;
64
- /**
65
- * Hook that returns the value from the previous render.
66
- *
67
- * @param value - Value to return from the previous render.
68
- * @returns Value from the previous render.
69
- */
70
- export declare function usePrevious<T>(value: T): T | undefined;
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ type I18nProviderProps = {
3
+ children: React.ReactNode;
4
+ userLanguage?: string;
5
+ };
6
+ export declare const I18nProvider: ({ children, userLanguage }: I18nProviderProps) => JSX.Element | null;
7
+ export {};
@@ -0,0 +1,2 @@
1
+ export declare function initializeI18n(): import("@sisense/sdk-common").I18NextInitResult;
2
+ export declare const i18nextInstance: import("i18next").i18n;
@@ -0,0 +1,28 @@
1
+ export declare const translation: {
2
+ errors: {
3
+ noSisenseContext: string;
4
+ componentRenderError: string;
5
+ sisenseContextNoAuthentication: string;
6
+ chartNoSisenseContext: string;
7
+ dashboardWidgetNoSisenseContext: string;
8
+ dashboardWidgetInvalidIdentifiers: string;
9
+ executeQueryNoSisenseContext: string;
10
+ executeQueryNoDataSource: string;
11
+ dataOptions: {
12
+ emptyValueArray: string;
13
+ noDimensionsAndMeasures: string;
14
+ attributeNotFound: string;
15
+ measureNotFound: string;
16
+ filterAttributeNotFound: string;
17
+ highlightAttributeNotFound: string;
18
+ };
19
+ themeNotFound: string;
20
+ paletteNotFound: string;
21
+ unsupportedWidgetType: string;
22
+ sisenseContextNotFound: string;
23
+ dashboardInvalidIdentifier: string;
24
+ };
25
+ errorBoxText: string;
26
+ chartNoData: string;
27
+ };
28
+ export type TranslationDictionary = typeof translation;
@@ -0,0 +1,59 @@
1
+ import { TranslationDictionary } from './en.js';
2
+ export type { TranslationDictionary };
3
+ export declare const PACKAGE_NAMESPACE: "sdkUi";
4
+ export declare const resources: {
5
+ en: {
6
+ errors: {
7
+ noSisenseContext: string;
8
+ componentRenderError: string;
9
+ sisenseContextNoAuthentication: string;
10
+ chartNoSisenseContext: string;
11
+ dashboardWidgetNoSisenseContext: string;
12
+ dashboardWidgetInvalidIdentifiers: string;
13
+ executeQueryNoSisenseContext: string;
14
+ executeQueryNoDataSource: string;
15
+ dataOptions: {
16
+ emptyValueArray: string;
17
+ noDimensionsAndMeasures: string;
18
+ attributeNotFound: string;
19
+ measureNotFound: string;
20
+ filterAttributeNotFound: string;
21
+ highlightAttributeNotFound: string;
22
+ };
23
+ themeNotFound: string;
24
+ paletteNotFound: string;
25
+ unsupportedWidgetType: string;
26
+ sisenseContextNotFound: string;
27
+ dashboardInvalidIdentifier: string;
28
+ };
29
+ errorBoxText: string;
30
+ chartNoData: string;
31
+ };
32
+ uk: {
33
+ errors: {
34
+ noSisenseContext: string;
35
+ componentRenderError: string;
36
+ sisenseContextNoAuthentication: string;
37
+ chartNoSisenseContext: string;
38
+ dashboardWidgetNoSisenseContext: string;
39
+ dashboardWidgetInvalidIdentifiers: string;
40
+ executeQueryNoSisenseContext: string;
41
+ executeQueryNoDataSource: string;
42
+ dataOptions: {
43
+ emptyValueArray: string;
44
+ noDimensionsAndMeasures: string;
45
+ attributeNotFound: string;
46
+ measureNotFound: string;
47
+ filterAttributeNotFound: string;
48
+ highlightAttributeNotFound: string;
49
+ };
50
+ themeNotFound: string;
51
+ paletteNotFound: string;
52
+ unsupportedWidgetType: string;
53
+ sisenseContextNotFound: string;
54
+ dashboardInvalidIdentifier: string;
55
+ };
56
+ errorBoxText: string;
57
+ chartNoData: string;
58
+ };
59
+ };
@@ -0,0 +1,2 @@
1
+ import { TranslationDictionary } from './index.js';
2
+ export declare const translation: TranslationDictionary;
@@ -0,0 +1,5 @@
1
+ import { AbstractTranslatableError } from '@sisense/sdk-common';
2
+ import { PACKAGE_NAMESPACE } from './resources';
3
+ export declare class TranslatableError extends AbstractTranslatableError<typeof PACKAGE_NAMESPACE> {
4
+ constructor(translationKey: string, interpolationOptions?: Record<string, string>);
5
+ }
@@ -0,0 +1,2 @@
1
+ import { I18NextInstance } from '@sisense/sdk-common';
2
+ export declare function useInitializedI18n(): I18NextInstance | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sisense/sdk-ui",
3
- "version": "0.11.3",
3
+ "version": "0.12.1",
4
4
  "type": "module",
5
5
  "exports": "./dist/index.js",
6
6
  "main": "./dist/index.js",
@@ -12,10 +12,10 @@
12
12
  "@emotion/react": "^11.10.5",
13
13
  "@emotion/styled": "^11.10.5",
14
14
  "@mui/material": "^5.11.6",
15
- "@sisense/sdk-common": "^0.11.3",
16
- "@sisense/sdk-data": "^0.11.3",
17
- "@sisense/sdk-query-client": "^0.11.3",
18
- "@sisense/sdk-rest-client": "^0.11.3",
15
+ "@sisense/sdk-common": "^0.12.1",
16
+ "@sisense/sdk-data": "^0.12.1",
17
+ "@sisense/sdk-query-client": "^0.12.1",
18
+ "@sisense/sdk-rest-client": "^0.12.1",
19
19
  "@sisense/sisense-charts": "5.1.0-alpha-04052758.0",
20
20
  "classnames": "^2.3.2",
21
21
  "colorjs.io": "^0.4.3",
@@ -29,6 +29,7 @@
29
29
  "lodash": "^4.17.21",
30
30
  "merge-deep": "^3.0.3",
31
31
  "react-datepicker": "^4.16.0",
32
+ "react-i18next": "^13.2.2",
32
33
  "react-number-format": "^5.1.0",
33
34
  "ts-deepmerge": "6.0.2",
34
35
  "ts-essentials": "^9.3.0",
@@ -81,6 +82,7 @@
81
82
  "@types/react-plotly.js": "^2.6.0",
82
83
  "@vitejs/plugin-react-swc": "^3.3.0",
83
84
  "autoprefixer": "^10.4.14",
85
+ "canvas": "^2.11.2",
84
86
  "eslint": "^8.40.0",
85
87
  "jsdom": "^22.1.0",
86
88
  "plotly.js": "^2.25.2",
@@ -1,11 +0,0 @@
1
- import { ClientApplication } from '../app/client-application';
2
- import { WidgetDto } from './types';
3
- /**
4
- * Fetch a dashboard widget from the default Sisense instance using POC
5
- * authentication code.
6
- *
7
- * @param widgetOid - Widget identifier in Sisense instance
8
- * @param dashboardOid - Dashboard identifier in Sisense instance
9
- * @param app - Client application
10
- */
11
- export declare function fetchWidget(widgetOid: string, dashboardOid: string, app: ClientApplication): Promise<WidgetDto>;
@@ -1,17 +0,0 @@
1
- export declare const translation: {
2
- errors: {
3
- componentRenderError: string;
4
- sisenseContextNoAuthentication: string;
5
- chartNoSisenseContext: string;
6
- dashboardWidgetNoSisenseContext: string;
7
- dashboardWidgetInvalidIdentifiers: string;
8
- executeQueryNoSisenseContext: string;
9
- executeQueryNoDataSource: string;
10
- dataOptions: {
11
- emptyValueArray: string;
12
- };
13
- };
14
- common: {
15
- chartNoData: string;
16
- };
17
- };