@restio/ui 0.2.0 → 0.2.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 (37) hide show
  1. package/dist/assets/svg/open-dialog.svg +29 -0
  2. package/dist/components/button/button-types.d.ts +2 -1
  3. package/dist/components/input/date/date-utils.d.ts +10 -26
  4. package/dist/components/input/date/use-digit-input.d.ts +18 -0
  5. package/dist/components/progress-bar/progress-bar-types.d.ts +9 -3
  6. package/dist/components/progress-bar/stories/progress-bar.stories.d.ts +1 -0
  7. package/dist/custom-components/layout/layout-renderers.d.ts +8 -8
  8. package/dist/custom-components/layout/layout-types.d.ts +21 -11
  9. package/dist/custom-components/layout/layout-utils.d.ts +3 -0
  10. package/dist/custom-components/layout/layout-utils.test.d.ts +1 -0
  11. package/dist/custom-components/layout/layout.d.ts +2 -7
  12. package/dist/custom-components/layout/layout.test.d.ts +1 -0
  13. package/dist/data-components/assets/finance-asset.d.ts +15 -0
  14. package/dist/data-components/card-list/card-list.d.ts +0 -3
  15. package/dist/data-components/cell/cell-registry.d.ts +2 -2
  16. package/dist/data-components/chart/chart-tooltip/chart-tooltip.d.ts +1 -2
  17. package/dist/data-components/data-component-utils.d.ts +24 -0
  18. package/dist/data-components/data-structure/data-structure.d.ts +7 -0
  19. package/dist/data-components/form/form-types.d.ts +1 -4
  20. package/dist/data-components/kpi/kpi-types.d.ts +17 -0
  21. package/dist/data-components/kpi/kpi.d.ts +5 -0
  22. package/dist/data-components/layout/card-layout-presets.d.ts +12 -0
  23. package/dist/data-components/layout/finance/finance-layouts.d.ts +18 -0
  24. package/dist/data-components/layout/finance/kpi-layout-presets.d.ts +35 -0
  25. package/dist/data-components/layout/finance/stories/finance-card-list.stories.d.ts +16 -0
  26. package/dist/data-components/switcher/prop-schema/prop-schema-types.d.ts +6 -0
  27. package/dist/data-components/switcher/prop-schema/prop-schema.d.ts +6 -0
  28. package/dist/data-components/switcher/switcher-types.d.ts +3 -1
  29. package/dist/data-components/table-grid/row/table-grid-row-utils.d.ts +2 -5
  30. package/dist/experimental-components/dashboard-builder/dashboard-builder-types.d.ts +1 -1
  31. package/dist/index.d.ts +9 -1
  32. package/dist/restio-ui.cjs.js +89 -61
  33. package/dist/restio-ui.es.js +10302 -9751
  34. package/dist/types/global-types.d.ts +5 -0
  35. package/dist/ui.css +1 -1
  36. package/package.json +1 -1
  37. package/dist/data-components/data-structure/data-structure-utils.d.ts +0 -15
@@ -0,0 +1,29 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
2
+ <rect width="256" height="256" fill="none"/>
3
+
4
+ <!-- Dialog principale -->
5
+ <rect
6
+ x="40"
7
+ y="72"
8
+ width="128"
9
+ height="128"
10
+ rx="8"
11
+ fill="none"
12
+ stroke="currentColor"
13
+ stroke-linecap="round"
14
+ stroke-linejoin="round"
15
+ stroke-width="16"/>
16
+
17
+ <!-- Dialog aperto -->
18
+ <rect
19
+ x="120"
20
+ y="40"
21
+ width="96"
22
+ height="96"
23
+ rx="8"
24
+ fill="none"
25
+ stroke="currentColor"
26
+ stroke-linecap="round"
27
+ stroke-linejoin="round"
28
+ stroke-width="16"/>
29
+ </svg>
@@ -1,11 +1,12 @@
1
1
  import { Size } from '../../types/global-types';
2
+ export type ButtonVariant = "base" | "primary" | "danger" | "invisible" | "link";
2
3
  export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
3
4
  alignContent?: 'start' | 'center';
4
5
  leadingVisual?: string;
5
6
  trailingVisual?: string;
6
7
  loading?: boolean;
7
8
  size?: Size;
8
- variant?: "base" | "primary" | "danger" | "invisible" | "link";
9
+ variant?: ButtonVariant;
9
10
  disabled?: boolean;
10
11
  count?: number;
11
12
  }
@@ -1,4 +1,4 @@
1
- import { DatePickerMode, DateRange } from './date-types';
1
+ import { DatePickerMode } from './date-types';
2
2
  /** Build a 6-week (42-day) grid starting from the Monday before the 1st of the month */
3
3
  export declare function buildDayGrid(year: number, month: number): Date[];
4
4
  export declare const WEEK_DAYS: string[];
@@ -10,33 +10,18 @@ export declare function getQuarter(date: Date): number;
10
10
  export declare function startOfQuarter(year: number, quarter: number): Date;
11
11
  /** Returns the last day of a quarter */
12
12
  export declare function endOfQuarter(year: number, quarter: number): Date;
13
- /** Format a Date to "DD/MM/YYYY" */
14
- export declare function formatDateInput(date: Date | undefined): string;
15
- /** Return the 8-digit string (DDMMYYYY) from a Date, used to seed masked inputs */
13
+ /** Format a Date for display according to the picker mode. */
14
+ export declare function formatByMode(date: Date | undefined, mode: DatePickerMode): string;
15
+ /** Return the 8-digit string (DDMMYYYY) from a Date, used to seed masked inputs. */
16
16
  export declare function extractDateDigits(date: Date | undefined): string;
17
- /** Format a raw digit string (DDMMYYYY) into the DD/MM/YYYY display form */
17
+ /** Format a raw digit string (DDMMYYYY) into the DD/MM/YYYY display form. */
18
18
  export declare function formatDigitsToDisplay(digits: string): string;
19
- /** Parse a raw digit string (DDMMYYYY, 8 chars) into a Date */
19
+ /** Parse a raw digit string (DDMMYYYY, 8 chars) into a Date. */
20
20
  export declare function parseDigitsToDate(digits: string): Date | undefined;
21
- /** Format a Date for month mode: "MMM YYYY" */
22
- export declare function formatMonthInput(date: Date | undefined): string;
23
- /** Format a Date for quarter mode: "Qn YYYY" */
24
- export declare function formatQuarterInput(date: Date | undefined): string;
25
- /** Format a Date for year mode */
26
- export declare function formatYearInput(date: Date | undefined): string;
27
- export declare function formatByMode(date: Date | undefined, mode: DatePickerMode): string;
28
- /** Parse "DD/MM/YYYY" text to Date or undefined */
29
- export declare function parseDateInput(text: string): Date | undefined;
30
- /** Returns true if two dates represent the same calendar day */
31
- export declare function isSameDay(a: Date | undefined, b: Date | undefined): boolean;
32
- export declare function isSameMonth(a: Date | undefined, b: Date | undefined): boolean;
33
- export declare function isSameQuarter(a: Date | undefined, b: Date | undefined): boolean;
34
- export declare function isSameYear(a: Date | undefined, b: Date | undefined): boolean;
35
- /** Returns true if date is between start and end (exclusive) */
36
- export declare function isBetween(date: Date, start: Date | undefined, end: Date | undefined): boolean;
37
- export declare function isMonthBetween(date: Date, start: Date | undefined, end: Date | undefined): boolean;
38
- export declare function isQuarterBetween(year: number, q: number, start: Date | undefined, end: Date | undefined): boolean;
39
- export declare function isYearBetween(year: number, start: Date | undefined, end: Date | undefined): boolean;
21
+ /** Returns true if two dates match at the given granularity. */
22
+ export declare function isSame(a: Date | undefined, b: Date | undefined, mode: DatePickerMode): boolean;
23
+ /** Returns true if date is strictly between start and end at the given granularity. */
24
+ export declare function isBetweenByMode(date: Date, start: Date | undefined, end: Date | undefined, mode: DatePickerMode): boolean;
40
25
  export declare function startOfDay(d: Date): Date;
41
26
  export declare function startOfWeek(d: Date): Date;
42
27
  export declare function endOfWeek(d: Date): Date;
@@ -47,4 +32,3 @@ export declare function endOfYear(d: Date): Date;
47
32
  export declare function addDays(d: Date, n: number): Date;
48
33
  export declare function addMonths(d: Date, n: number): Date;
49
34
  export declare function addYears(d: Date, n: number): Date;
50
- export declare function rangeEquals(a: DateRange, b: DateRange): boolean;
@@ -0,0 +1,18 @@
1
+ import { DatePickerMode } from './date-types';
2
+ /**
3
+ * Shared masked-digit input logic for date fields (DD/MM/YYYY).
4
+ * Manages digit state, cursor auto-advance after DD/MM, and onBlur reset.
5
+ */
6
+ export declare function useDigitInput(opts: {
7
+ mode: DatePickerMode;
8
+ value: Date | undefined;
9
+ onCommit: (date: Date | undefined) => void;
10
+ /** Called when 8 digits are entered and the date is valid. Use for auto-advance to next field. */
11
+ onComplete?: () => void;
12
+ }): {
13
+ ref: import('react').RefObject<HTMLInputElement | null>;
14
+ digits: string;
15
+ displayValue: string;
16
+ handleChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
17
+ handleBlur: (onExternalBlur?: () => void) => void;
18
+ };
@@ -1,15 +1,21 @@
1
1
  import { State } from '../../types/global-types';
2
2
  export interface ProgressBarProps {
3
- /** Current progress value (0-100) */
3
+ /** Current progress value */
4
4
  value: number;
5
+ /** Minimum value of the range. Defaults to 0. */
6
+ min?: number;
7
+ /** Maximum value of the range. Defaults to 100. */
8
+ max?: number;
5
9
  /** Visual variant for color theming */
6
10
  variant?: State;
7
11
  /** Whether the progress bar is in an indeterminate loading state */
8
12
  indeterminate?: boolean;
9
- /** Whether to show the percentage label */
13
+ /** Whether to show the header with percentage (left) and value (right) above the bar */
10
14
  showLabel?: boolean;
11
- /** Custom label text (overrides percentage) */
15
+ /** Custom label text (overrides the percentage on the left) */
12
16
  label?: string;
17
+ /** Custom formatter for the value shown on the right */
18
+ formatValue?: (value: number) => string;
13
19
  /** Height of the progress bar */
14
20
  height?: number;
15
21
  /** Whether the component is disabled */
@@ -5,5 +5,6 @@ export default meta;
5
5
  type Story = StoryObj<ProgressBarProps>;
6
6
  export declare const Default: Story;
7
7
  export declare const WithLabel: Story;
8
+ export declare const GenericValue: Story;
8
9
  export declare const Indeterminate: Story;
9
10
  export declare const Disabled: Story;
@@ -1,8 +1,8 @@
1
- import { ContainerRenderer, ContainerRendererRegistry } from './layout-types';
2
- export declare const containerRenderers: ContainerRendererRegistry;
3
- /**
4
- * Register a renderer for a container type.
5
- * Call this to add support for new containers (Tabs, Accordion, Stepper, etc.)
6
- * without modifying existing code.
7
- */
8
- export declare function registerContainerRenderer(type: string, renderer: ContainerRenderer): void;
1
+ import { ReactNode } from 'react';
2
+ import { GridContainer, FlexContainer, LayoutNode } from './layout-types';
3
+ /** Render a grid container node */
4
+ export declare function renderGrid(node: GridContainer, renderChild: (n: LayoutNode) => ReactNode): ReactNode;
5
+ /** Render a flex container node */
6
+ export declare function renderFlex(node: FlexContainer, renderChild: (n: LayoutNode) => ReactNode): ReactNode;
7
+ /** Render a LayoutNode tree recursively */
8
+ export declare function renderNode(node: LayoutNode, renderBlock: (fieldId: string) => ReactNode): ReactNode;
@@ -1,10 +1,15 @@
1
1
  import { ReactNode } from 'react';
2
+ /** Layout breakpoint */
2
3
  export type Breakpoint = 'mobile' | 'tablet' | 'desktop';
4
+ export type alignX = 'start' | 'center' | 'end' | 'space-between' | 'space-around';
5
+ export type alignY = 'start' | 'center' | 'end' | 'stretch';
6
+ /** Layout block node */
3
7
  export type BlockNode = {
4
8
  type: 'block';
5
9
  /** The field/column identifier that the consumer maps to a Cell */
6
10
  fieldId: string;
7
11
  };
12
+ /** Grid child node */
8
13
  export type GridChild = {
9
14
  node: LayoutNode;
10
15
  col: number;
@@ -12,10 +17,11 @@ export type GridChild = {
12
17
  w: number;
13
18
  h: number;
14
19
  /** Horizontal alignment of content within the grid cell */
15
- alignX?: 'start' | 'center' | 'end';
20
+ alignX?: alignX;
16
21
  /** Vertical alignment of content within the grid cell */
17
- alignY?: 'start' | 'center' | 'end';
22
+ alignY?: alignY;
18
23
  };
24
+ /** Grid container node */
19
25
  export type GridContainer = {
20
26
  type: 'grid';
21
27
  columns: number;
@@ -23,21 +29,25 @@ export type GridContainer = {
23
29
  gap?: number;
24
30
  children: GridChild[];
25
31
  };
26
- export type LayoutNode = BlockNode | GridContainer;
32
+ /** Flex container node */
33
+ export type FlexContainer = {
34
+ type: 'flex';
35
+ direction?: 'row' | 'column';
36
+ gap?: number;
37
+ alignX?: alignX;
38
+ alignY?: alignY;
39
+ children: LayoutNode[];
40
+ };
41
+ /** Union of all node types */
42
+ export type LayoutNode = BlockNode | GridContainer | FlexContainer;
43
+ /** Responsive layout mapping breakpoints to layout trees */
27
44
  export type ResponsiveLayout = {
28
45
  [K in Breakpoint]: LayoutNode;
29
46
  };
47
+ /** Layout component props */
30
48
  export type LayoutProps = {
31
49
  /** Responsive layout tree */
32
50
  layout: ResponsiveLayout;
33
51
  /** Callback that renders a Block node given its fieldId */
34
52
  renderBlock: (fieldId: string) => ReactNode;
35
- /** Optional CSS class for the layout container */
36
- className?: string;
37
53
  };
38
- /** Any node that is not a Block (i.e. a container) */
39
- export type ContainerNode = Exclude<LayoutNode, BlockNode>;
40
- /** A renderer function for a specific container type */
41
- export type ContainerRenderer = (node: ContainerNode, renderChild: (n: LayoutNode) => ReactNode) => ReactNode;
42
- /** Registry mapping container type strings to their renderers */
43
- export type ContainerRendererRegistry = Map<string, ContainerRenderer>;
@@ -0,0 +1,3 @@
1
+ import { Breakpoint } from './layout-types';
2
+ /** Detect current breakpoint from window width */
3
+ export declare function getBreakpoint(): Breakpoint;
@@ -1,12 +1,7 @@
1
1
  import { default as React } from 'react';
2
2
  import { LayoutProps } from './layout-types';
3
3
  /**
4
- * Responsive layout component that renders a tree of nodes.
5
- *
6
- * Detects the current breakpoint (mobile / tablet / desktop) and renders
7
- * the corresponding tree using a recursive `renderNode` function.
8
- *
9
- * The consumer provides a `renderBlock` callback that maps a `fieldId`
10
- * to a React node (typically a Cell component).
4
+ * Responsive layout component.
5
+ * Detects the current breakpoint and renders the corresponding layout tree.
11
6
  */
12
7
  export declare const Layout: React.FC<LayoutProps>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ import { DataStructureColumn } from '../data-structure/data-structure';
2
+ /**
3
+ * Dataset shape for a single finance KPI card.
4
+ * Fields mirror the `fieldId`s used by the shared finance layouts.
5
+ */
6
+ export interface FinanceKpi {
7
+ id: number;
8
+ label: string;
9
+ value: string;
10
+ delta: string;
11
+ trend: number[];
12
+ icon?: string;
13
+ }
14
+ export declare const mockFinanceKpis: FinanceKpi[];
15
+ export declare const financeKpiColumns: DataStructureColumn<FinanceKpi>[];
@@ -2,9 +2,6 @@ import { CardListProps } from './card-list-types';
2
2
  /**
3
3
  * Renders an array of data as a list of cards.
4
4
  * Each card is configured with the same columns and layout.
5
- *
6
- * Supports single selection (`selected`) and multi-selection (`multiSelection`).
7
- * When either is provided, matching cards get the `selected` visual state.
8
5
  */
9
6
  export declare function CardList<TData>({ data, columns, layout, containerClassName, uiConfig, onCardClick, selected, multiSelection, isSelected, }: CardListProps<TData>): import("react").JSX.Element;
10
7
  export declare namespace CardList {
@@ -1,7 +1,7 @@
1
+ import { default as React, ReactNode } from 'react';
1
2
  import { CellType } from '../../types/global-types';
2
3
  import { DataStructureColumn } from '../data-structure/data-structure';
3
4
  import { ResolvedCellUI } from '../ui-layer/ui-layer-types';
4
- import { ReactNode } from 'react';
5
5
  export interface CellEditorProps<TData, TValue> {
6
6
  value: TValue;
7
7
  column: DataStructureColumn<TData, TValue>;
@@ -16,7 +16,7 @@ export interface CellEditorProps<TData, TValue> {
16
16
  }
17
17
  export interface CellHandler<TData, TValue> {
18
18
  /** Renders the display (read-only) view */
19
- display: (value: TValue, column?: DataStructureColumn<TData, TValue>, ui?: ResolvedCellUI) => ReactNode;
19
+ display: (value: TValue, column?: DataStructureColumn<TData, TValue>, ui?: ResolvedCellUI, rowData?: TData) => ReactNode;
20
20
  /** Renders the editor (editable) view. Undefined = display-only type. */
21
21
  edit?: (props: CellEditorProps<TData, TValue>) => ReactNode;
22
22
  /** When true, always renders the editor even when non-editable (e.g. TABLE_GRID) */
@@ -1,7 +1,6 @@
1
- import { default as React } from 'react';
2
1
  import { ChartTooltipProps } from './chart-tooltip-types';
3
2
  /**
4
3
  * Custom Recharts tooltip content that uses Restio design tokens.
5
4
  * Renders a label and a list of series values with their respective colors.
6
5
  */
7
- export declare const ChartTooltip: ({ active, payload, label }: ChartTooltipProps) => React.JSX.Element | null;
6
+ export declare const ChartTooltip: ({ active, payload, label }: ChartTooltipProps) => import("react").JSX.Element | null;
@@ -1,3 +1,27 @@
1
1
  import { DataStructureColumn } from './data-structure/data-structure';
2
+ /**
3
+ * Generate column definitions using a schema builder.
4
+ * Type-safe way to generate columns without Object.keys().
5
+ */
6
+ export declare function generateColumnsFromSchema<TData>(schema: (keyof TData)[], options?: {
7
+ headerFormatter?: (key: string) => string;
8
+ }): DataStructureColumn<TData>[];
9
+ /**
10
+ * Merge auto-generated columns with user-provided columns.
11
+ * User-provided columns take precedence.
12
+ */
13
+ export declare function mergeColumns<TData>(schema: (keyof TData)[], userColumns?: DataStructureColumn<TData>[], options?: {
14
+ headerFormatter?: (key: string) => string;
15
+ }): DataStructureColumn<TData>[];
2
16
  /** Resolve the stable ID for a schema column (same logic as getColId in table-utils) */
3
17
  export declare function resolveColumnId<TData>(col: DataStructureColumn<TData>, index: number): string;
18
+ /**
19
+ * Resolve columns to use for a dataset: honour explicit columns when provided,
20
+ * otherwise derive from the keys of the first row of `data`.
21
+ * Shared fallback used by Card, CardList, Form, Calendar, Chart, Gantt, TableGrid.
22
+ */
23
+ export declare function resolveColumnsFromData<TData>(data: TData[] | TData | undefined, columns?: DataStructureColumn<TData>[]): DataStructureColumn<TData>[];
24
+ /** Read a cell value via accessorFn / accessorKey (formula-unaware base for DataStructureColumn). */
25
+ export declare function getColumnValue<TData>(column: DataStructureColumn<TData>, rowData: TData): unknown;
26
+ /** Find the first column matching `colId` by `id` or `accessorKey` (string-coerced). */
27
+ export declare function findColumnById<TData>(columns: DataStructureColumn<TData>[], colId: string): DataStructureColumn<TData> | undefined;
@@ -40,4 +40,11 @@ export interface DataStructureColumn<TData, TValue = TData[keyof TData]> {
40
40
  * `data` and `columns` are excluded — they come from the cell value and schema.
41
41
  */
42
42
  columnConfig?: Record<string, unknown>;
43
+ /**
44
+ * Called when an interactive cell (e.g. BUTTON, IMAGE click) fires an action.
45
+ * The cell handler decides when to invoke it; the first argument is the
46
+ * action id (for BUTTON = `option.value`). Works in any data-component
47
+ * that renders Cell in display mode (CardList, TableGrid, …).
48
+ */
49
+ onCellClick?: (actionId: string, rowData: TData, column: DataStructureColumn<TData, TValue>) => void;
43
50
  }
@@ -38,10 +38,7 @@ export interface FormSpecificProps<TData> {
38
38
  onSubmit?: (data: TData) => void;
39
39
  /** Callback when cancel is clicked */
40
40
  onCancel?: () => void;
41
- /**
42
- * Custom action buttons rendered in the form footer.
43
- * When provided, replaces the default Save/Cancel buttons.
44
- */
41
+ /** Custom action buttons rendered in the form footer.*/
45
42
  actions?: ButtonProps[];
46
43
  /**
47
44
  * Server-driven callback invoked on every field change.
@@ -0,0 +1,17 @@
1
+ import { ResponsiveLayout } from '../../custom-components/layout/layout-types';
2
+ import { DataStructureComponent } from '../data-structure/data-structure';
3
+ /**
4
+ * Props for the KPI component.
5
+ * A KPI is a single-metric Card;
6
+ */
7
+ export interface KPISpecificProps<TData> {
8
+ /** Single row of data to display in the KPI */
9
+ data: TData;
10
+ /** Layout for the KPI fields. Reuse a shared layout example or supply a custom one. */
11
+ layout?: ResponsiveLayout;
12
+ /** Additional CSS class for the KPI container */
13
+ className?: string;
14
+ /** Called when the KPI is clicked */
15
+ onClick?: () => void;
16
+ }
17
+ export type KPIProps<TData> = Omit<DataStructureComponent<TData>, "data"> & KPISpecificProps<TData>;
@@ -0,0 +1,5 @@
1
+ import { KPIProps } from './kpi-types';
2
+ /**
3
+ * KPI component — a single-metric Card.
4
+ */
5
+ export declare function KPI<TData>({ data, columns, layout, className, uiConfig, onClick }: KPIProps<TData>): import("react").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import { ResponsiveLayout } from '../../custom-components/layout/layout-types';
2
+ /**
3
+ * Card layout: icon on the left, name + type next to it, actions right-aligned.
4
+ *
5
+ * Field IDs: `icon`, `name`, `type`, `actions`.
6
+ *
7
+ * ┌──────────────────────────────────────┐
8
+ * │ icon name actions │
9
+ * │ type │
10
+ * └──────────────────────────────────────┘
11
+ */
12
+ export declare const cardLayoutWithIcon: ResponsiveLayout;
@@ -0,0 +1,18 @@
1
+ import { ResponsiveLayout } from '../../../custom-components/layout/layout-types';
2
+ /**
3
+ * Shared finance layouts, usable by any component that accepts a
4
+ * `ResponsiveLayout` (Card, KPI, CardList).
5
+ *
6
+ * Field IDs are intentionally generic so they work with any dataset that
7
+ * follows the KPI shape: `label`, `value`, `delta`, `trend`, `icon`.
8
+ */
9
+ /**
10
+ * Compact KPI layout: label on top, big value in the middle, delta/trend
11
+ * at the bottom. On small breakpoints it collapses to a single column.
12
+ */
13
+ export declare const financeKpiLayout: ResponsiveLayout;
14
+ /**
15
+ * Finance layout with leading icon on the right side (icon spans the whole
16
+ * height). Useful when the dataset includes a representative icon/illustration.
17
+ */
18
+ export declare const financeKpiLayoutWithIcon: ResponsiveLayout;
@@ -0,0 +1,35 @@
1
+ import { ResponsiveLayout } from '../../../custom-components/layout/layout-types';
2
+ /**
3
+ * A registered KPI layout preset.
4
+ *
5
+ * `id` is the value stored in the widget config (and resolved back to a
6
+ * `ResponsiveLayout` at render time by the Switcher). `label` / `description`
7
+ * drive the selector UI; `layout` is the actual tree rendered in the preview
8
+ * and passed to the `KPI` component.
9
+ */
10
+ export interface KpiLayoutPreset {
11
+ id: string;
12
+ label: string;
13
+ description: string;
14
+ /** Bundled SVG icon name shown in the selector. */
15
+ leadingVisual?: string;
16
+ layout: ResponsiveLayout;
17
+ }
18
+ /**
19
+ * Registry of available KPI layout presets.
20
+ *
21
+ * This is the single source of truth for the KPI layout selector in the
22
+ * Switcher / Dashboard Builder. Add new presets here (built-in examples or
23
+ * user-created custom layouts) and they automatically appear in the
24
+ * `preview-dialog` selector.
25
+ */
26
+ export declare const kpiLayoutPresets: KpiLayoutPreset[];
27
+ /** Maps a preset id to its `ResponsiveLayout`. Falls back to `undefined`. */
28
+ export declare function resolveKpiLayoutPreset(id?: string): ResponsiveLayout | undefined;
29
+ /** Option shape consumed by the `preview-dialog` selector. */
30
+ export declare const kpiLayoutPresetOptions: {
31
+ value: string;
32
+ label: string;
33
+ description: string;
34
+ leadingVisual: string | undefined;
35
+ }[];
@@ -0,0 +1,16 @@
1
+ import { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { CardList } from '../../../card-list/card-list';
3
+ declare const meta: Meta<typeof CardList>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof CardList>;
6
+ /**
7
+ * CardList rendered with the shared finance layout (no KPI wrapper needed).
8
+ * Demonstrates that the same finance layout works at the card level for a
9
+ * list of KPI-like metrics.
10
+ */
11
+ export declare const FinanceLayout: Story;
12
+ /**
13
+ * CardList with the icon-aware finance layout variant.
14
+ * Each KPI row carries an emoji icon to fill the icon slot.
15
+ */
16
+ export declare const FinanceLayoutWithIcon: Story;
@@ -27,7 +27,13 @@ export interface PropFieldDescriptor {
27
27
  options?: {
28
28
  label: string;
29
29
  value: string;
30
+ description?: string;
31
+ leadingVisual?: string;
30
32
  }[];
33
+ /**
34
+ * Generic column-level configuration forwarded as-is to the generated
35
+ */
36
+ columnConfig?: Record<string, unknown>;
31
37
  /**
32
38
  * Optional condition: if provided, the field is only visible when this
33
39
  * function returns true given the current form values.
@@ -7,6 +7,8 @@ import { PropSchemaRegistry } from './prop-schema-types';
7
7
  * from the `columns` prop passed to the configurator.
8
8
  */
9
9
  export declare const propSchemaRegistry: PropSchemaRegistry;
10
+ /** Maps the KPI "layout" prop value to a shared ResponsiveLayout. */
11
+ export { resolveKpiLayoutPreset as kpiLayoutResolver } from '../../layout/finance/kpi-layout-presets';
10
12
  /**
11
13
  * Human-readable metadata for the component selector.
12
14
  */
@@ -34,4 +36,8 @@ export declare const dataComponentMetaList: ({
34
36
  id: "card-list";
35
37
  label: string;
36
38
  icon: string;
39
+ } | {
40
+ id: "kpi";
41
+ label: string;
42
+ icon: string;
37
43
  })[];
@@ -5,10 +5,11 @@ import { CalendarSpecificProps } from '../calendar/calendar-types';
5
5
  import { GanttSpecificProps } from '../gantt/gantt-types';
6
6
  import { FormSpecificProps } from '../form/form-types';
7
7
  import { CardListSpecificProps } from '../card-list/card-list-types';
8
+ import { KPISpecificProps } from '../kpi/kpi-types';
8
9
  /**
9
10
  * Identifiers for all data-components that the switcher can render.
10
11
  */
11
- export type DataComponentId = "table-grid" | "chart" | "calendar" | "gantt" | "form" | "card-list";
12
+ export type DataComponentId = "table-grid" | "chart" | "calendar" | "gantt" | "form" | "card-list" | "kpi";
12
13
  /**
13
14
  * Maps each component id to its specific props interface (without DataStructureComponent).
14
15
  * Used by the switcher to type the dynamic `componentProps` state.
@@ -20,6 +21,7 @@ export type ComponentSpecificPropsMap<TData> = {
20
21
  "gantt": GanttSpecificProps<TData>;
21
22
  "form": FormSpecificProps<TData>;
22
23
  "card-list": CardListSpecificProps<TData>;
24
+ "kpi": KPISpecificProps<TData>;
23
25
  };
24
26
  /**
25
27
  * Human-readable metadata for each data-component shown in the selector.
@@ -2,12 +2,9 @@ import { ColumnDef } from '../table-grid-types';
2
2
  /**
3
3
  * Get the cell value based on column definition and row data.
4
4
  * If the column has a formula, it evaluates the formula using the row data.
5
- * Otherwise, it retrieves the value using accessorFn or accessorKey.
6
- * @param column
7
- * @param rowData
8
- * @returns
5
+ * Otherwise, it retrieves the value via the shared accessorFn/accessorKey resolver.
9
6
  */
10
- export declare function getCellValue<TData>(column: ColumnDef<TData>, rowData: TData): import('../formula').FormulaValue | TData[keyof TData];
7
+ export declare function getCellValue<TData>(column: ColumnDef<TData>, rowData: TData): unknown;
11
8
  /**
12
9
  * Compute the subtotal value for a group row.
13
10
  * For numeric columns (including formula columns), returns the sum of all values in the group.
@@ -9,7 +9,7 @@ export declare const DASHBOARD_CONFIG_VERSION = 1;
9
9
  /**
10
10
  * A widget type that can be placed on the dashboard canvas.
11
11
  */
12
- export type WidgetComponentType = "table-grid" | "chart" | "calendar" | "form" | "card-list" | "gantt";
12
+ export type WidgetComponentType = "table-grid" | "chart" | "calendar" | "form" | "card-list" | "gantt" | "kpi";
13
13
  /**
14
14
  * Metadata for a widget type shown in the palette.
15
15
  */
package/dist/index.d.ts CHANGED
@@ -4,6 +4,8 @@ export { Banner } from './components/banner/banner';
4
4
  export type { BannerProps } from './components/banner/banner-types';
5
5
  export { Button } from './components/button/button';
6
6
  export type { ButtonProps } from './components/button/button-types';
7
+ export { ButtonGroup } from './components/button-group/button-group';
8
+ export type { ButtonGroupProps } from './components/button-group/button-group-types';
7
9
  export { ButtonDropdown } from './components/button-dropdown/button-dropdown';
8
10
  export type { ButtonDropdownProps } from './components/button-dropdown/button-dropdown-types';
9
11
  export { Checkbox } from './components/checkbox/checkbox';
@@ -43,7 +45,7 @@ export type { LabelProps } from './utility-components/label/label-types';
43
45
  export { Timeline } from './custom-components/timeline/timeline';
44
46
  export type { TimelineProps } from './custom-components/timeline/timeline-types';
45
47
  export { Layout } from './custom-components/layout/layout';
46
- export type { LayoutProps, ResponsiveLayout, BlockNode, GridContainer, GridChild, Breakpoint } from './custom-components/layout/layout-types';
48
+ export type { LayoutProps, ResponsiveLayout, BlockNode, GridContainer, GridChild, FlexContainer, Breakpoint } from './custom-components/layout/layout-types';
47
49
  export { useTour } from './hooks/useTour/useTour';
48
50
  export { TourProvider, useTourManager } from './hooks/useTour/useTour-context';
49
51
  export type { TourStep, TourPlacement, TourStepTrigger, TourProgress, TourOptions, TourInstance, TourPersistenceAdapter, TourAnalyticsAdapter, TourStepEvent, TourEvent, TourDropEvent, ManagedTourInfo, TourManagerInstance, } from './hooks/useTour/useTour-types';
@@ -108,6 +110,12 @@ export { SelectionGrid } from './components/selection-grid/selection-grid';
108
110
  export type { SelectionGridProps } from './components/selection-grid/selection-grid-types';
109
111
  export { CardList } from './data-components/card-list/card-list';
110
112
  export type { CardListProps } from './data-components/card-list/card-list-types';
113
+ export { KPI } from './data-components/kpi/kpi';
114
+ export type { KPIProps, KPISpecificProps } from './data-components/kpi/kpi-types';
115
+ export { financeKpiLayout, financeKpiLayoutWithIcon } from './data-components/layout/finance/finance-layouts';
116
+ export { cardLayoutWithIcon } from './data-components/layout/card-layout-presets';
117
+ export { kpiLayoutPresets, kpiLayoutPresetOptions, resolveKpiLayoutPreset } from './data-components/layout/finance/kpi-layout-presets';
118
+ export type { KpiLayoutPreset } from './data-components/layout/finance/kpi-layout-presets';
111
119
  export { Switcher } from './data-components/switcher/switcher';
112
120
  export type { SwitcherProps, DataComponentId, ComponentSpecificPropsMap } from './data-components/switcher/switcher-types';
113
121
  export { DataComponentConfigurator } from './data-components/data-component-configurator/data-component-configurator';