@sisense/sdk-ui 2.1.1 → 2.2.0

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 (31) hide show
  1. package/dist/ai.cjs +9 -9
  2. package/dist/ai.js +525 -636
  3. package/dist/analytics-composer.cjs +1 -1
  4. package/dist/analytics-composer.js +4 -4
  5. package/dist/{derive-chart-family-CQ1Myy0A.cjs → derive-chart-family-BsbFdcgd.cjs} +1 -1
  6. package/dist/{derive-chart-family-C8duLtwv.js → derive-chart-family-C9IDI6UV.js} +18 -0
  7. package/dist/{dimensions-DOWF8q44.js → dimensions-HgrcPa-Q.js} +1 -1
  8. package/dist/{dimensions-BBfnA6e8.cjs → dimensions-mYUylB-h.cjs} +1 -1
  9. package/dist/index.cjs +14 -14
  10. package/dist/index.js +5622 -5335
  11. package/dist/packages/sdk-ui/src/api/rest-api.d.ts +1 -0
  12. package/dist/packages/sdk-ui/src/api/types/dashboard-dto.d.ts +7 -0
  13. package/dist/packages/sdk-ui/src/common/hooks/use-state-with-history.d.ts +64 -0
  14. package/dist/packages/sdk-ui/src/dashboard/components/dashboard-header.d.ts +1 -1
  15. package/dist/packages/sdk-ui/src/dashboard/dashboard.d.ts +7 -1
  16. package/dist/packages/sdk-ui/src/dashboard/hooks/use-dashboard-header-toolbar.d.ts +17 -0
  17. package/dist/packages/sdk-ui/src/dashboard/hooks/use-edit-mode-toolbar.d.ts +52 -0
  18. package/dist/packages/sdk-ui/src/dashboard/types.d.ts +3 -1
  19. package/dist/packages/sdk-ui/src/error-boundary/error-boundary.d.ts +6 -2
  20. package/dist/packages/sdk-ui/src/models/dashboard/dashboard-model.d.ts +7 -0
  21. package/dist/packages/sdk-ui/src/models/dashboard/translate-dashboard-dto-utils.d.ts +3 -1
  22. package/dist/packages/sdk-ui/src/models/dashboard/types.d.ts +1 -1
  23. package/dist/packages/sdk-ui/src/models/dashboard/use-dashboard-model/use-dashboard-model-reducer.d.ts +14 -5
  24. package/dist/packages/sdk-ui/src/props.d.ts +4 -1
  25. package/dist/packages/sdk-ui/src/translation/resources/en.d.ts +9 -0
  26. package/dist/packages/sdk-ui/src/translation/resources/index.d.ts +18 -0
  27. package/dist/{use-common-filters-NTIrYvRs.cjs → use-common-filters-BKYG6WGA.cjs} +47 -47
  28. package/dist/{use-common-filters--6cyMg9O.js → use-common-filters-DkwU7HJ3.js} +1696 -1565
  29. package/dist/{widget-composer-BZwsi1mW.js → widget-composer-CACtfvw6.js} +98 -95
  30. package/dist/{widget-composer-Bv_aqjLX.cjs → widget-composer-JVl8mNCt.cjs} +1 -1
  31. package/package.json +7 -7
@@ -33,6 +33,7 @@ export declare class RestApi {
33
33
  }[] | undefined;
34
34
  layout?: import("./types/dashboard-dto").LayoutDto | undefined;
35
35
  style?: import("./types/dashboard-dto").DashboardStyleDto | undefined;
36
+ settings?: import("./types/dashboard-dto").DashboardSettings | undefined;
36
37
  } & import("../utils/utility-types").AnyObject)[]>;
37
38
  /**
38
39
  * Get a specific dashboard
@@ -41,6 +41,12 @@ export type DashboardStyleDto = {
41
41
  paletteId?: string;
42
42
  };
43
43
  export declare const isCascadingFilterDto: (filter: FilterDto | CascadingFilterDto) => filter is CascadingFilterDto;
44
+ export type DashboardSettings = {
45
+ autoUpdateOnFiltersChange?: boolean;
46
+ useAcceleration?: boolean;
47
+ aiAssistantEnabled?: boolean;
48
+ managedByTool?: string;
49
+ };
44
50
  /**
45
51
  * @internal
46
52
  */
@@ -56,5 +62,6 @@ export type DashboardDto = {
56
62
  }[];
57
63
  layout?: LayoutDto;
58
64
  style?: DashboardStyleDto;
65
+ settings?: DashboardSettings;
59
66
  } & AnyObject;
60
67
  export {};
@@ -0,0 +1,64 @@
1
+ interface UseStateWithHistoryOptions<T> {
2
+ /**
3
+ * Maximum number of history entries to store
4
+ * @default 10
5
+ */
6
+ capacity?: number;
7
+ /**
8
+ * Initial history entries
9
+ * @default []
10
+ */
11
+ initialHistory?: T[];
12
+ }
13
+ interface StateWithHistoryResult<T> {
14
+ /** Current state value */
15
+ state: T;
16
+ /** All history entries */
17
+ history: T[];
18
+ /** Index of the current state in history */
19
+ currentIndex: number;
20
+ /** Set state and add to history */
21
+ setState: (value: T | ((prev: T) => T)) => void;
22
+ /** Go back to the previous state in history */
23
+ undo: () => void;
24
+ /** Go forward to the next state in history */
25
+ redo: () => void;
26
+ /** Whether there's a previous state to go back to */
27
+ canUndo: boolean;
28
+ /** Whether there's a next state to go forward to */
29
+ canRedo: boolean;
30
+ /** Go to a specific point in history by index */
31
+ goTo: (index: number) => void;
32
+ /** Clear all history except current state */
33
+ clearHistory: () => void;
34
+ }
35
+ /**
36
+ * A hook that provides state management with history tracking for undo/redo functionality.
37
+ *
38
+ * @param initialState - The initial state value
39
+ * @param options - Configuration options for history management
40
+ * @returns An object containing the current state, history, and methods to navigate through history
41
+ *
42
+ * @example
43
+ * ```tsx
44
+ * const {
45
+ * state,
46
+ * setState,
47
+ * undo,
48
+ * redo,
49
+ * canUndo,
50
+ * canRedo
51
+ * } = useStateWithHistory({ count: 0 });
52
+ *
53
+ * // Update state
54
+ * setState({ count: state.count + 1 });
55
+ *
56
+ * // Undo last action if possible
57
+ * if (canUndo) undo();
58
+ *
59
+ * // Redo last undone action if possible
60
+ * if (canRedo) redo();
61
+ * ```
62
+ */
63
+ export declare function useStateWithHistory<T>(initialState: T, options?: UseStateWithHistoryOptions<T>): StateWithHistoryResult<T>;
64
+ export {};
@@ -1,3 +1,3 @@
1
1
  import { DashboardHeaderProps } from '../../dashboard/types';
2
2
  export declare const DASHBOARD_HEADER_HEIGHT = 48;
3
- export declare const DashboardHeader: ({ title }: DashboardHeaderProps) => import("react/jsx-runtime").JSX.Element;
3
+ export declare const DashboardHeader: ({ title, toolbar }: DashboardHeaderProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,11 +1,14 @@
1
1
  /// <reference types="react" />
2
2
  import { DashboardProps } from '../dashboard/types';
3
3
  import { Filter, FilterRelations } from '@sisense/sdk-data';
4
+ import { WidgetsPanelLayout } from '../models';
4
5
  export declare enum DashboardChangeType {
5
6
  /** Dashboard filters have been updated */
6
7
  FILTERS_UPDATE = "FILTERS.UPDATE",
7
8
  /** Filters panel collapsed state changed */
8
- UI_FILTERS_PANEL_COLLAPSE = "UI.FILTERS.PANEL.COLLAPSE"
9
+ UI_FILTERS_PANEL_COLLAPSE = "UI.FILTERS.PANEL.COLLAPSE",
10
+ /** Widgets panel layout updated */
11
+ WIDGETS_PANEL_LAYOUT_UPDATE = "WIDGETS_PANEL_LAYOUT.UPDATE"
9
12
  }
10
13
  export type DashboardChangeAction = {
11
14
  type: DashboardChangeType.FILTERS_UPDATE;
@@ -13,6 +16,9 @@ export type DashboardChangeAction = {
13
16
  } | {
14
17
  type: DashboardChangeType.UI_FILTERS_PANEL_COLLAPSE;
15
18
  payload: boolean;
19
+ } | {
20
+ type: DashboardChangeType.WIDGETS_PANEL_LAYOUT_UPDATE;
21
+ payload: WidgetsPanelLayout;
16
22
  };
17
23
  /**
18
24
  * React component that renders a dashboard whose elements are customizable. It includes internal logic of applying common filters to widgets.
@@ -0,0 +1,17 @@
1
+ /// <reference types="react" />
2
+ export interface DashboardHeaderToolbarMenuItem {
3
+ title: string;
4
+ icon?: JSX.Element;
5
+ ariaLabel?: string;
6
+ onClick: () => void;
7
+ }
8
+ export interface UseDashboardHeaderToolbarProps {
9
+ menuItems: DashboardHeaderToolbarMenuItem[];
10
+ }
11
+ /**
12
+ * Hook that returns a toolbar element for dashboard header
13
+ */
14
+ export declare const useDashboardHeaderToolbar: ({ menuItems }: UseDashboardHeaderToolbarProps) => {
15
+ toolbar: () => import("react/jsx-runtime").JSX.Element;
16
+ };
17
+ export default useDashboardHeaderToolbar;
@@ -0,0 +1,52 @@
1
+ /// <reference types="react" />
2
+ import { WidgetsPanelLayout } from '../../models';
3
+ /**
4
+ * Props for the useEditModeToolbar hook
5
+ */
6
+ export interface UseEditModeToolbarProps {
7
+ /**
8
+ * Initial layout to track history for
9
+ */
10
+ initialLayout: WidgetsPanelLayout;
11
+ /**
12
+ * Optional callback when layout is applied
13
+ */
14
+ onApply?: (layout: WidgetsPanelLayout) => void;
15
+ /**
16
+ * Optional callback when edit is canceled
17
+ */
18
+ onCancel?: () => void;
19
+ /**
20
+ * Maximum number of history entries to store
21
+ * @default 20
22
+ */
23
+ historyCapacity?: number;
24
+ }
25
+ /**
26
+ * Return type for the useEditModeToolbar hook
27
+ */
28
+ export interface UseEditModeToolbarResult {
29
+ /**
30
+ * Current layout state
31
+ */
32
+ layout: WidgetsPanelLayout;
33
+ /**
34
+ * Function to update layout state and track in history
35
+ */
36
+ setLayout: (layout: WidgetsPanelLayout | ((prev: WidgetsPanelLayout) => WidgetsPanelLayout)) => void;
37
+ /**
38
+ * Whether there are unsaved changes
39
+ */
40
+ hasChanges: boolean;
41
+ /**
42
+ * Toolbar component with undo, redo, cancel, apply buttons
43
+ */
44
+ toolbar: () => JSX.Element;
45
+ }
46
+ /**
47
+ * Hook that provides layout state management with history tracking and a toolbar with undo/redo/cancel/apply buttons
48
+ *
49
+ * @param props Configuration options for the toolbar
50
+ * @returns Layout state and toolbar component
51
+ */
52
+ export declare function useEditModeToolbar({ initialLayout, onApply, onCancel, historyCapacity, }: UseEditModeToolbarProps): UseEditModeToolbarResult;
@@ -3,6 +3,7 @@ import { WidgetProps } from '../props';
3
3
  import { DashboardChangeAction } from '../dashboard/dashboard';
4
4
  import { DataSource, Filter, FilterRelations } from '@sisense/sdk-data';
5
5
  import { FiltersPanelConfig } from '../filters/components/filters-panel/types';
6
+ import { ReactNode } from 'react';
6
7
  export type { DashboardStyleOptions, WidgetsPanelColumnLayout, WidgetsPanelLayout, WidgetsPanelCell, WidgetsPanelRow, WidgetsPanelColumn, } from '../models';
7
8
  /**
8
9
  * Props of the {@link DashboardById} component.
@@ -88,7 +89,7 @@ export interface DashboardConfig {
88
89
  */
89
90
  responsive?: boolean;
90
91
  /**
91
- * If true will render editable layout.
92
+ * If true will .
92
93
  *
93
94
  * @internal
94
95
  */
@@ -170,4 +171,5 @@ export interface DashboardProps {
170
171
  */
171
172
  export interface DashboardHeaderProps {
172
173
  title: string;
174
+ toolbar?: () => ReactNode;
173
175
  }
@@ -8,11 +8,14 @@ interface ErrorBoundaryProps {
8
8
  error?: AbstractTranslatableError | Error | string;
9
9
  children: ReactNode;
10
10
  resetKeys?: any[];
11
- onError?: (error: Error) => void;
11
+ onError?: (error: Error) => void | ReactNode;
12
12
  isContainerComponent?: boolean;
13
+ /** If set to true, children will be rendered when an error is provided via props, but not when caught during rendering */
14
+ shouldRenderChildrenWithProvidedError?: boolean;
13
15
  }
14
16
  type ErrorBoundaryState = {
15
17
  error: AbstractTranslatableError | Error | string | null;
18
+ customErrorUI: ReactNode | null;
16
19
  };
17
20
  /**
18
21
  * This component is used to catch errors thrown by the UI component and display an error message
@@ -24,11 +27,12 @@ type ErrorBoundaryState = {
24
27
  */
25
28
  export declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
26
29
  showErrorBox: boolean;
27
- onError?: (error: Error) => void;
30
+ onError?: (error: Error) => void | ReactNode;
28
31
  isContainerComponent: boolean;
29
32
  constructor(props: ErrorBoundaryProps);
30
33
  static getDerivedStateFromError(error: Error): {
31
34
  error: Error;
35
+ customErrorUI: null;
32
36
  };
33
37
  componentDidCatch(error: Error): void;
34
38
  componentDidUpdate(prevProps: ErrorBoundaryProps, prevState: ErrorBoundaryState): void;
@@ -2,6 +2,7 @@ import { DataSource, Filter, FilterRelations } from '@sisense/sdk-data';
2
2
  import { DashboardStyleOptions, TabbersOptions, WidgetModel } from '../../models';
3
3
  import { type WidgetsOptions } from './types';
4
4
  import { DashboardLayoutOptions } from '../../dashboard';
5
+ import { DashboardSettings } from '../../api/types/dashboard-dto';
5
6
  /**
6
7
  * Model of Sisense Fusion dashboard defined in the abstractions of Compose SDK.
7
8
  *
@@ -55,4 +56,10 @@ export interface DashboardModel {
55
56
  * @internal
56
57
  */
57
58
  tabbersOptions?: TabbersOptions;
59
+ /**
60
+ * Dashboard settings.
61
+ *
62
+ * @internal
63
+ */
64
+ settings?: DashboardSettings;
58
65
  }
@@ -1,5 +1,6 @@
1
1
  import { Filter } from '@sisense/sdk-data';
2
- import { CascadingFilterDto, FilterDto } from '../../api/types/dashboard-dto';
2
+ import { CascadingFilterDto, FilterDto, LayoutDto } from '../../api/types/dashboard-dto';
3
+ import { WidgetsPanelLayout } from '../../dashboard/types';
3
4
  /**
4
5
  * Translates a {@link Filter} to a {@link FilterDto}.
5
6
  *
@@ -8,3 +9,4 @@ import { CascadingFilterDto, FilterDto } from '../../api/types/dashboard-dto';
8
9
  * @internal
9
10
  */
10
11
  export declare function filterToFilterDto(filter: Filter): FilterDto | CascadingFilterDto;
12
+ export declare function layoutToLayoutDto(layout: WidgetsPanelLayout): LayoutDto;
@@ -51,7 +51,7 @@ export type WidgetsOptions = Record<WidgetId, {
51
51
  filtersOptions?: CommonFiltersOptions;
52
52
  }>;
53
53
  /**
54
- * Options for TabberWidetss in a dashboard
54
+ * Options for TabberWidets in a dashboard
55
55
  *
56
56
  * This property actually moves responsibility on the layout management from the tabber widgets to the dashboard,
57
57
  * storing all the tabbers configs in the single place
@@ -1,4 +1,4 @@
1
- import { DashboardModel, WidgetModel } from '../../../models';
1
+ import { DashboardModel, WidgetModel, WidgetsPanelLayout } from '../../../models';
2
2
  import { Filter, FilterRelations } from '@sisense/sdk-data';
3
3
  import { RestApi } from '../../../api/rest-api';
4
4
  export type UseDashboardModelState = DashboardModel | null;
@@ -8,8 +8,7 @@ export type UseDashboardModelState = DashboardModel | null;
8
8
  * @internal
9
9
  */
10
10
  export declare enum UseDashboardModelActionTypeInternal {
11
- DASHBOARD_INIT = "DASHBOARD.INIT",
12
- DASHBOARD_UPDATE_LAYOUT = "DASHBOARD.UPDATE_LAYOUT"
11
+ DASHBOARD_INIT = "DASHBOARD.INIT"
13
12
  }
14
13
  /**
15
14
  * Action types for the dashboard model state used in {@link useDashboardModel}.
@@ -18,7 +17,8 @@ export declare enum UseDashboardModelActionTypeInternal {
18
17
  */
19
18
  export declare enum UseDashboardModelActionType {
20
19
  FILTERS_UPDATE = "FILTERS.UPDATE",
21
- ADD_WIDGET = "WIDGETS.ADD"
20
+ ADD_WIDGET = "WIDGETS.ADD",
21
+ WIDGETS_PANEL_LAYOUT_UPDATE = "WIDGETS_PANEL_LAYOUT.UPDATE"
22
22
  }
23
23
  /**
24
24
  * Internal actions for the dashboard model state used in {@link useDashboardModel}.
@@ -34,7 +34,7 @@ export type UseDashboardModelInternalAction = UseDashboardModelAction | {
34
34
  *
35
35
  * @internal
36
36
  */
37
- export type UseDashboardModelAction = UseDashboardModelFilterUpdateAction | UseDashboardModelAddWidgetAction;
37
+ export type UseDashboardModelAction = UseDashboardModelFilterUpdateAction | UseDashboardModelAddWidgetAction | UseDashboardModelLayoutUpdateAction;
38
38
  /**
39
39
  * Filter update actions for the dashboard model state used in {@link useDashboardModel}.
40
40
  *
@@ -53,6 +53,15 @@ export type UseDashboardModelAddWidgetAction = {
53
53
  type: UseDashboardModelActionType.ADD_WIDGET;
54
54
  payload: WidgetModel;
55
55
  };
56
+ /**
57
+ * Layout update action for the dashboard model state used in {@link useDashboardModel}.
58
+ *
59
+ * @internal
60
+ */
61
+ export type UseDashboardModelLayoutUpdateAction = {
62
+ type: UseDashboardModelActionType.WIDGETS_PANEL_LAYOUT_UPDATE;
63
+ payload: WidgetsPanelLayout;
64
+ };
56
65
  /**
57
66
  * Reducer for the dashboard model state used in {@link useDashboardModel}.
58
67
  *
@@ -86,6 +86,9 @@ export interface SisenseContextProviderProps {
86
86
  /**
87
87
  * Callback function that is triggered when an error occurs within the Sisense context.
88
88
  *
89
+ * Return React node to render a custom error UI.
90
+ * Return `undefined` to use the default error UI.
91
+ *
89
92
  * This callback is useful for handling errors that happen during the initialization or runtime of the Sisense context,
90
93
  * such as incorrect configuration, invalid authentication, or network-related issues.
91
94
  *
@@ -100,7 +103,7 @@ export interface SisenseContextProviderProps {
100
103
  componentName: string;
101
104
  /** The props of the component that caused the error. */
102
105
  componentProps: unknown;
103
- }) => void;
106
+ }) => void | ReactNode;
104
107
  /**
105
108
  * Boolean flag to enable sending silent pre-authentication requests to the Sisense instance.
106
109
  * Used to check if user is already authenticated, check is performed in an ivisible iframe.
@@ -352,6 +352,15 @@ export declare const translation: {
352
352
  grandTotal: string;
353
353
  subTotal: string;
354
354
  };
355
+ dashboard: {
356
+ toolbar: {
357
+ undo: string;
358
+ redo: string;
359
+ cancel: string;
360
+ apply: string;
361
+ editLayout: string;
362
+ };
363
+ };
355
364
  };
356
365
  /**
357
366
  * A reference type containing all currently used translation keys.
@@ -362,6 +362,15 @@ export declare const resources: {
362
362
  grandTotal: string;
363
363
  subTotal: string;
364
364
  };
365
+ dashboard: {
366
+ toolbar: {
367
+ undo: string;
368
+ redo: string;
369
+ cancel: string;
370
+ apply: string;
371
+ editLayout: string;
372
+ };
373
+ };
365
374
  };
366
375
  uk: {
367
376
  errors: {
@@ -717,5 +726,14 @@ export declare const resources: {
717
726
  grandTotal: string;
718
727
  subTotal: string;
719
728
  };
729
+ dashboard: {
730
+ toolbar: {
731
+ undo: string;
732
+ redo: string;
733
+ cancel: string;
734
+ apply: string;
735
+ editLayout: string;
736
+ };
737
+ };
720
738
  };
721
739
  };