@toolbox-web/grid-react 0.0.2

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.
@@ -0,0 +1,155 @@
1
+ import { ColumnConfig, DataGridElement, GridConfig } from '../../../../dist/libs/grid/index.d.ts';
2
+ import { ReactNode } from 'react';
3
+ import { ReactGridConfig } from './react-column-config';
4
+ /**
5
+ * Props for the DataGrid component.
6
+ */
7
+ export interface DataGridProps<TRow = unknown> {
8
+ /** Row data to display */
9
+ rows: TRow[];
10
+ /**
11
+ * Grid configuration. Supports React renderers/editors via `reactRenderer` and `reactEditor` properties.
12
+ * @example
13
+ * ```tsx
14
+ * gridConfig={{
15
+ * columns: [
16
+ * {
17
+ * field: 'status',
18
+ * reactRenderer: (ctx) => <StatusBadge value={ctx.value} />,
19
+ * reactEditor: (ctx) => <StatusEditor value={ctx.value} onCommit={ctx.commit} />,
20
+ * },
21
+ * ],
22
+ * }}
23
+ * ```
24
+ */
25
+ gridConfig?: ReactGridConfig<TRow>;
26
+ /** Column definitions (alternative to gridConfig.columns) */
27
+ columns?: ColumnConfig<TRow>[];
28
+ /** Fit mode for column sizing */
29
+ fitMode?: 'stretch' | 'fit-columns' | 'auto-fit';
30
+ /** Edit trigger mode */
31
+ editOn?: 'click' | 'dblclick' | 'none';
32
+ /** Custom CSS styles to inject into grid shadow DOM */
33
+ customStyles?: string;
34
+ /** Class name for the grid element */
35
+ className?: string;
36
+ /** Inline styles for the grid element */
37
+ style?: React.CSSProperties;
38
+ /** Children (GridColumn components for custom renderers/editors) */
39
+ children?: ReactNode;
40
+ /** Fired when rows change (sorting, editing, etc.) */
41
+ onRowsChange?: (rows: TRow[]) => void;
42
+ /** Fired when a cell value is edited */
43
+ onCellEdit?: (event: CustomEvent<{
44
+ row: TRow;
45
+ field: string;
46
+ oldValue: unknown;
47
+ newValue: unknown;
48
+ }>) => void;
49
+ /** Fired when a row is clicked */
50
+ onRowClick?: (event: CustomEvent<{
51
+ row: TRow;
52
+ rowIndex: number;
53
+ }>) => void;
54
+ /** Fired when column state changes (resize, reorder, visibility) */
55
+ onColumnStateChange?: (event: CustomEvent<{
56
+ columns: ColumnConfig<TRow>[];
57
+ }>) => void;
58
+ /** Fired when sort changes */
59
+ onSortChange?: (event: CustomEvent<{
60
+ field: string;
61
+ direction: 'asc' | 'desc';
62
+ } | null>) => void;
63
+ }
64
+ /**
65
+ * Ref handle for the DataGrid component.
66
+ */
67
+ export interface DataGridRef<TRow = unknown> {
68
+ /** The underlying grid DOM element */
69
+ element: DataGridElement | null;
70
+ /** Get the effective configuration */
71
+ getConfig: () => Promise<Readonly<GridConfig<TRow>>>;
72
+ /** Wait for the grid to be ready */
73
+ ready: () => Promise<void>;
74
+ /** Force a layout recalculation */
75
+ forceLayout: () => Promise<void>;
76
+ /** Toggle a group row */
77
+ toggleGroup: (key: string) => Promise<void>;
78
+ /** Register custom styles */
79
+ registerStyles: (id: string, css: string) => void;
80
+ /** Unregister custom styles */
81
+ unregisterStyles: (id: string) => void;
82
+ }
83
+ /**
84
+ * React wrapper component for the tbw-grid web component.
85
+ *
86
+ * ## Basic Usage
87
+ *
88
+ * ```tsx
89
+ * import { DataGrid } from '@toolbox-web/grid-react';
90
+ *
91
+ * function MyComponent() {
92
+ * const [rows, setRows] = useState([...]);
93
+ *
94
+ * return (
95
+ * <DataGrid
96
+ * rows={rows}
97
+ * columns={[
98
+ * { field: 'name', header: 'Name' },
99
+ * { field: 'age', header: 'Age', type: 'number' },
100
+ * ]}
101
+ * onRowsChange={setRows}
102
+ * />
103
+ * );
104
+ * }
105
+ * ```
106
+ *
107
+ * ## With Custom Renderers
108
+ *
109
+ * ```tsx
110
+ * import { DataGrid, GridColumn } from '@toolbox-web/grid-react';
111
+ *
112
+ * function MyComponent() {
113
+ * return (
114
+ * <DataGrid rows={rows}>
115
+ * <GridColumn field="status">
116
+ * {(ctx) => <StatusBadge status={ctx.value} />}
117
+ * </GridColumn>
118
+ * <GridColumn
119
+ * field="name"
120
+ * editable
121
+ * editor={(ctx) => (
122
+ * <input
123
+ * defaultValue={ctx.value}
124
+ * onBlur={(e) => ctx.commit(e.target.value)}
125
+ * onKeyDown={(e) => e.key === 'Escape' && ctx.cancel()}
126
+ * />
127
+ * )}
128
+ * />
129
+ * </DataGrid>
130
+ * );
131
+ * }
132
+ * ```
133
+ *
134
+ * ## With Ref
135
+ *
136
+ * ```tsx
137
+ * import { DataGrid, DataGridRef } from '@toolbox-web/grid-react';
138
+ * import { useRef } from 'react';
139
+ *
140
+ * function MyComponent() {
141
+ * const gridRef = useRef<DataGridRef>(null);
142
+ *
143
+ * const handleClick = async () => {
144
+ * const config = await gridRef.current?.getConfig();
145
+ * console.log('Current columns:', config?.columns);
146
+ * };
147
+ *
148
+ * return <DataGrid ref={gridRef} rows={rows} />;
149
+ * }
150
+ * ```
151
+ */
152
+ export declare const DataGrid: <TRow = unknown>(props: DataGridProps<TRow> & {
153
+ ref?: React.Ref<DataGridRef<TRow>>;
154
+ }) => React.ReactElement;
155
+ //# sourceMappingURL=data-grid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-grid.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/lib/data-grid.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEnF,OAAO,EAA+D,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACpG,OAAO,aAAa,CAAC;AAErB,OAAO,EAA0B,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAwFrF;;GAEG;AACH,MAAM,WAAW,aAAa,CAAC,IAAI,GAAG,OAAO;IAC3C,0BAA0B;IAC1B,IAAI,EAAE,IAAI,EAAE,CAAC;IACb;;;;;;;;;;;;;;OAcG;IACH,UAAU,CAAC,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;IACnC,6DAA6D;IAC7D,OAAO,CAAC,EAAE,YAAY,CAA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,WAAW,WAAW,CAAC,IAAI,GAAG,OAAO;IACzC,sCAAsC;IACtC,OAAO,EAAE,eAAe,GAAG,IAAI,CAAC;IAChC,sCAAsC;IACtC,SAAS,EAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACrD,oCAAoC;IACpC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,mCAAmC;IACnC,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,yBAAyB;IACzB,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,6BAA6B;IAC7B,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,+BAA+B;IAC/B,gBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,eAAO,MAAM,QAAQ,EA4Of,CAAC,IAAI,GAAG,OAAO,EAAE,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAA;CAAE,KAAK,KAAK,CAAC,YAAY,CAAC"}
@@ -0,0 +1,117 @@
1
+ import { CellRenderContext, ColumnEditorContext } from '../../../../dist/libs/grid/index.d.ts';
2
+ import { ReactNode } from 'react';
3
+ /**
4
+ * Props for the GridColumn component.
5
+ */
6
+ export interface GridColumnProps<TRow = unknown, TValue = unknown> {
7
+ /** Field key in the row object */
8
+ field: keyof TRow & string;
9
+ /** Column header text (defaults to capitalized field) */
10
+ header?: string;
11
+ /** Column data type */
12
+ type?: 'string' | 'number' | 'date' | 'boolean' | 'select' | 'typeahead';
13
+ /** Whether the column is editable */
14
+ editable?: boolean;
15
+ /** Whether the column is sortable */
16
+ sortable?: boolean;
17
+ /** Whether the column is resizable */
18
+ resizable?: boolean;
19
+ /** Column width (e.g., "100px", "10%") */
20
+ width?: string | number;
21
+ /** Minimum width for stretch mode */
22
+ minWidth?: number;
23
+ /** Whether the column is hidden */
24
+ hidden?: boolean;
25
+ /** Prevent column from being hidden */
26
+ lockVisible?: boolean;
27
+ /**
28
+ * Custom cell renderer (render prop pattern).
29
+ * Receives cell context and returns React node.
30
+ *
31
+ * @example
32
+ * ```tsx
33
+ * <GridColumn field="status">
34
+ * {(ctx) => <StatusBadge status={ctx.value} />}
35
+ * </GridColumn>
36
+ * ```
37
+ */
38
+ children?: (ctx: CellRenderContext<TRow, TValue>) => ReactNode;
39
+ /**
40
+ * Custom cell editor.
41
+ * Receives editor context with commit/cancel functions.
42
+ *
43
+ * @example
44
+ * ```tsx
45
+ * <GridColumn
46
+ * field="name"
47
+ * editable
48
+ * editor={(ctx) => (
49
+ * <input
50
+ * defaultValue={ctx.value}
51
+ * onBlur={(e) => ctx.commit(e.target.value)}
52
+ * onKeyDown={(e) => e.key === 'Escape' && ctx.cancel()}
53
+ * />
54
+ * )}
55
+ * />
56
+ * ```
57
+ */
58
+ editor?: (ctx: ColumnEditorContext<TRow, TValue>) => ReactNode;
59
+ /** Select/typeahead options */
60
+ options?: Array<{
61
+ label: string;
62
+ value: unknown;
63
+ }>;
64
+ /** Allow multiple selection (for select/typeahead) */
65
+ multi?: boolean;
66
+ /** Custom formatter function */
67
+ format?: (value: TValue, row: TRow) => string;
68
+ }
69
+ /**
70
+ * Column configuration component for use with DataGrid.
71
+ *
72
+ * Renders a `<tbw-grid-column>` custom element in the light DOM
73
+ * and registers React renderers/editors with the adapter.
74
+ *
75
+ * ## Basic Usage
76
+ *
77
+ * ```tsx
78
+ * <DataGrid rows={rows}>
79
+ * <GridColumn field="name" header="Full Name" />
80
+ * <GridColumn field="age" type="number" sortable />
81
+ * </DataGrid>
82
+ * ```
83
+ *
84
+ * ## Custom Renderer
85
+ *
86
+ * ```tsx
87
+ * <GridColumn field="status">
88
+ * {(ctx) => (
89
+ * <span className={`status-${ctx.value}`}>
90
+ * {ctx.value}
91
+ * </span>
92
+ * )}
93
+ * </GridColumn>
94
+ * ```
95
+ *
96
+ * ## Custom Editor
97
+ *
98
+ * ```tsx
99
+ * <GridColumn
100
+ * field="price"
101
+ * editable
102
+ * editor={(ctx) => (
103
+ * <input
104
+ * type="number"
105
+ * defaultValue={ctx.value}
106
+ * onBlur={(e) => ctx.commit(Number(e.target.value))}
107
+ * onKeyDown={(e) => {
108
+ * if (e.key === 'Enter') ctx.commit(Number(e.currentTarget.value));
109
+ * if (e.key === 'Escape') ctx.cancel();
110
+ * }}
111
+ * />
112
+ * )}
113
+ * />
114
+ * ```
115
+ */
116
+ export declare function GridColumn<TRow = unknown, TValue = unknown>(props: GridColumnProps<TRow, TValue>): React.ReactElement;
117
+ //# sourceMappingURL=grid-column.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grid-column.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/lib/grid-column.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAuB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5D,OAAO,aAAa,CAAC;AAGrB;;GAEG;AACH,MAAM,WAAW,eAAe,CAAC,IAAI,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO;IAC/D,kCAAkC;IAClC,KAAK,EAAE,MAAM,IAAI,GAAG,MAAM,CAAC;IAC3B,yDAAyD;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uBAAuB;IACvB,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,WAAW,CAAC;IACzE,qCAAqC;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qCAAqC;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sCAAsC;IACtC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,0CAA0C;IAC1C,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,qCAAqC;IACrC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mCAAmC;IACnC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,uCAAuC;IACvC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,SAAS,CAAC;IAC/D;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,SAAS,CAAC;IAC/D,+BAA+B;IAC/B,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACnD,sDAAsD;IACtD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,gCAAgC;IAChC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,KAAK,MAAM,CAAC;CAC/C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,wBAAgB,UAAU,CAAC,IAAI,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO,EAAE,KAAK,EAAE,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,KAAK,CAAC,YAAY,CAyErH"}
@@ -0,0 +1,88 @@
1
+ import { ReactNode, ReactElement } from 'react';
2
+ /**
3
+ * Context object passed to the detail panel render function.
4
+ */
5
+ export interface DetailPanelContext<TRow = unknown> {
6
+ /** The row data for this detail panel */
7
+ row: TRow;
8
+ /** The row index */
9
+ rowIndex: number;
10
+ }
11
+ /**
12
+ * Get the detail renderer for a grid element.
13
+ * @internal
14
+ */
15
+ export declare function getDetailRenderer(gridElement: HTMLElement): ((ctx: DetailPanelContext<unknown>) => ReactNode) | undefined;
16
+ /**
17
+ * Props for the GridDetailPanel component.
18
+ */
19
+ export interface GridDetailPanelProps<TRow = unknown> {
20
+ /**
21
+ * Render function for the detail panel content.
22
+ * Receives the row data and row index.
23
+ *
24
+ * @example
25
+ * ```tsx
26
+ * <GridDetailPanel>
27
+ * {({ row }) => <EmployeeDetails employee={row} />}
28
+ * </GridDetailPanel>
29
+ * ```
30
+ */
31
+ children: (ctx: DetailPanelContext<TRow>) => ReactNode;
32
+ /**
33
+ * Whether to show the expand/collapse column.
34
+ * @default true
35
+ */
36
+ showExpandColumn?: boolean;
37
+ /**
38
+ * Animation style for expand/collapse.
39
+ * - 'slide': Smooth height animation (default)
40
+ * - 'fade': Opacity transition
41
+ * - false: No animation
42
+ * @default 'slide'
43
+ */
44
+ animation?: 'slide' | 'fade' | false;
45
+ }
46
+ /**
47
+ * Component for defining a master-detail panel within a DataGrid.
48
+ *
49
+ * Renders a `<tbw-grid-detail>` custom element in the light DOM that the
50
+ * MasterDetailPlugin picks up to render expandable row details.
51
+ *
52
+ * ## Usage
53
+ *
54
+ * ```tsx
55
+ * import { DataGrid, GridDetailPanel } from '@toolbox-web/grid-react';
56
+ * import { MasterDetailPlugin } from '@toolbox-web/grid/all';
57
+ *
58
+ * function EmployeeGrid() {
59
+ * const config = {
60
+ * plugins: [new MasterDetailPlugin()],
61
+ * // ... other config
62
+ * };
63
+ *
64
+ * return (
65
+ * <DataGrid rows={employees} gridConfig={config}>
66
+ * <GridDetailPanel showExpandColumn animation="slide">
67
+ * {({ row }) => (
68
+ * <div className="detail-panel">
69
+ * <h3>{row.firstName} {row.lastName}</h3>
70
+ * <p>Department: {row.department}</p>
71
+ * <p>Email: {row.email}</p>
72
+ * </div>
73
+ * )}
74
+ * </GridDetailPanel>
75
+ * </DataGrid>
76
+ * );
77
+ * }
78
+ * ```
79
+ *
80
+ * ## How it works
81
+ *
82
+ * 1. This component renders a `<tbw-grid-detail>` element in the grid's light DOM
83
+ * 2. The ReactGridAdapter detects this element and creates a detail renderer
84
+ * 3. When a row is expanded, the adapter calls your render function
85
+ * 4. The React component is rendered into the detail row container
86
+ */
87
+ export declare function GridDetailPanel<TRow = unknown>(props: GridDetailPanelProps<TRow>): ReactElement;
88
+ //# sourceMappingURL=grid-detail-panel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grid-detail-panel.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/lib/grid-detail-panel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,aAAa,CAAC;AAErB;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,IAAI,GAAG,OAAO;IAChD,yCAAyC;IACzC,GAAG,EAAE,IAAI,CAAC;IACV,oBAAoB;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAUD;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,WAAW,GACvB,CAAC,CAAC,GAAG,EAAE,kBAAkB,CAAC,OAAO,CAAC,KAAK,SAAS,CAAC,GAAG,SAAS,CAe/D;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB,CAAC,IAAI,GAAG,OAAO;IAClD;;;;;;;;;;OAUG;IACH,QAAQ,EAAE,CAAC,GAAG,EAAE,kBAAkB,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC;IAEvD;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;CACtC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAgB,eAAe,CAAC,IAAI,GAAG,OAAO,EAAE,KAAK,EAAE,oBAAoB,CAAC,IAAI,CAAC,GAAG,YAAY,CAqC/F"}
@@ -0,0 +1,31 @@
1
+ import { ReactElement, ReactNode } from 'react';
2
+ /**
3
+ * Props for the GridToolButtons container component.
4
+ */
5
+ export interface GridToolButtonsProps {
6
+ /** Child buttons to render inside the container */
7
+ children: ReactNode;
8
+ }
9
+ /**
10
+ * Container component for toolbar buttons in DataGrid shell header.
11
+ *
12
+ * This component renders a `<tbw-grid-tool-buttons>` element that gets
13
+ * slotted into the shell toolbar. Place your buttons inside.
14
+ *
15
+ * ## Usage
16
+ *
17
+ * ```tsx
18
+ * <DataGrid rows={rows} gridConfig={config}>
19
+ * <GridToolButtons>
20
+ * <button className="tbw-toolbar-btn" title="Export CSV" onClick={handleExport}>
21
+ * 📄
22
+ * </button>
23
+ * <button className="tbw-toolbar-btn" title="Print" onClick={window.print}>
24
+ * 🖨️
25
+ * </button>
26
+ * </GridToolButtons>
27
+ * </DataGrid>
28
+ * ```
29
+ */
30
+ export declare function GridToolButtons({ children }: GridToolButtonsProps): ReactElement;
31
+ //# sourceMappingURL=grid-tool-button.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grid-tool-button.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/lib/grid-tool-button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,mDAAmD;IACnD,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,EAAE,oBAAoB,GAAG,YAAY,CAEhF"}
@@ -0,0 +1,98 @@
1
+ import { ReactNode, ReactElement } from 'react';
2
+ /**
3
+ * Context object passed to the tool panel render function.
4
+ */
5
+ export interface ToolPanelContext {
6
+ /** Reference to the grid element */
7
+ grid: HTMLElement;
8
+ }
9
+ /**
10
+ * Get the tool panel renderer for a panel element.
11
+ * @internal
12
+ */
13
+ export declare function getToolPanelRenderer(panelElement: HTMLElement): ((ctx: ToolPanelContext) => ReactNode) | undefined;
14
+ /**
15
+ * Get all registered tool panel elements within a grid.
16
+ * @internal
17
+ */
18
+ export declare function getToolPanelElements(gridElement: HTMLElement): HTMLElement[];
19
+ /**
20
+ * Props for the GridToolPanel component.
21
+ */
22
+ export interface GridToolPanelProps {
23
+ /**
24
+ * Unique identifier for this panel.
25
+ * Required for the shell plugin to track the panel.
26
+ */
27
+ id: string;
28
+ /**
29
+ * Panel title shown in the accordion header.
30
+ */
31
+ title: string;
32
+ /**
33
+ * Icon for the accordion section header.
34
+ * Can be an emoji or text.
35
+ */
36
+ icon?: string;
37
+ /**
38
+ * Tooltip text for the accordion header.
39
+ */
40
+ tooltip?: string;
41
+ /**
42
+ * Panel order priority. Lower values appear first.
43
+ * @default 100
44
+ */
45
+ order?: number;
46
+ /**
47
+ * Render function for the panel content.
48
+ * Receives a context with the grid element reference.
49
+ *
50
+ * @example
51
+ * ```tsx
52
+ * <GridToolPanel id="filters" title="Quick Filters" icon="🔍">
53
+ * {({ grid }) => <QuickFilters gridRef={grid} />}
54
+ * </GridToolPanel>
55
+ * ```
56
+ */
57
+ children: (ctx: ToolPanelContext) => ReactNode;
58
+ }
59
+ /**
60
+ * Component for defining a custom tool panel within a DataGrid.
61
+ *
62
+ * Renders a `<tbw-grid-tool-panel>` custom element in the light DOM that the
63
+ * ShellPlugin picks up and displays in the side panel accordion.
64
+ *
65
+ * ## Usage
66
+ *
67
+ * ```tsx
68
+ * import { DataGrid, GridToolPanel } from '@toolbox-web/grid-react';
69
+ *
70
+ * function EmployeeGrid() {
71
+ * return (
72
+ * <DataGrid rows={employees} gridConfig={config}>
73
+ * <GridToolPanel id="quick-filters" title="Quick Filters" icon="🔍" order={10}>
74
+ * {({ grid }) => (
75
+ * <div className="filters">
76
+ * <button onClick={() => applyFilter(grid, 'active')}>Active</button>
77
+ * <button onClick={() => applyFilter(grid, 'inactive')}>Inactive</button>
78
+ * </div>
79
+ * )}
80
+ * </GridToolPanel>
81
+ *
82
+ * <GridToolPanel id="stats" title="Statistics" icon="📊" order={20}>
83
+ * {() => <StatsPanel data={employees} />}
84
+ * </GridToolPanel>
85
+ * </DataGrid>
86
+ * );
87
+ * }
88
+ * ```
89
+ *
90
+ * ## How it works
91
+ *
92
+ * 1. This component renders a `<tbw-grid-tool-panel>` element in the grid's light DOM
93
+ * 2. The ReactGridAdapter detects this element and creates a panel renderer
94
+ * 3. When the shell plugin initializes, it finds these panels and renders them
95
+ * 4. The React component is rendered into the accordion panel container
96
+ */
97
+ export declare function GridToolPanel(props: GridToolPanelProps): ReactElement;
98
+ //# sourceMappingURL=grid-tool-panel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grid-tool-panel.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/lib/grid-tool-panel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,aAAa,CAAC;AAErB;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,oCAAoC;IACpC,IAAI,EAAE,WAAW,CAAC;CACnB;AAUD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,WAAW,GAAG,CAAC,CAAC,GAAG,EAAE,gBAAgB,KAAK,SAAS,CAAC,GAAG,SAAS,CAYlH;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,WAAW,GAAG,WAAW,EAAE,CAO5E;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;;;;;;;OAUG;IACH,QAAQ,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,SAAS,CAAC;CAChD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,YAAY,CAiCrE"}
@@ -0,0 +1,71 @@
1
+ import { CellRenderContext, ColumnConfig, ColumnEditorContext, GridConfig } from '../../../../dist/libs/grid/index.d.ts';
2
+ import { ReactNode } from 'react';
3
+ /**
4
+ * Extended column config that supports React components for renderers/editors.
5
+ *
6
+ * Use `renderer` and `editor` properties to define React-based cell renderers
7
+ * and editors directly in your gridConfig. These accept React render functions
8
+ * that return ReactNode (JSX).
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * const gridConfig: ReactGridConfig<Employee> = {
13
+ * columns: [
14
+ * {
15
+ * field: 'status',
16
+ * header: 'Status',
17
+ * // React renderer - same property name as vanilla, but returns JSX
18
+ * renderer: (ctx) => <StatusBadge value={ctx.value} />,
19
+ * // React editor - same property name as vanilla, but returns JSX
20
+ * editor: (ctx) => (
21
+ * <StatusSelect
22
+ * value={ctx.value}
23
+ * onCommit={ctx.commit}
24
+ * onCancel={ctx.cancel}
25
+ * />
26
+ * ),
27
+ * },
28
+ * ],
29
+ * };
30
+ * ```
31
+ */
32
+ export interface ReactColumnConfig<TRow = unknown> extends Omit<ColumnConfig<TRow>, 'renderer' | 'viewRenderer' | 'editor'> {
33
+ /**
34
+ * React component renderer for cell display.
35
+ * Receives cell context and returns a React node (JSX).
36
+ *
37
+ * Same property name as vanilla JS, but accepts React components.
38
+ */
39
+ renderer?: (ctx: CellRenderContext<TRow>) => ReactNode;
40
+ /**
41
+ * React component editor for cell editing.
42
+ * Receives editor context with commit/cancel functions and returns a React node (JSX).
43
+ *
44
+ * Same property name as vanilla JS, but accepts React components.
45
+ */
46
+ editor?: (ctx: ColumnEditorContext<TRow>) => ReactNode;
47
+ }
48
+ /**
49
+ * Grid config with React-enhanced column definitions.
50
+ */
51
+ export type ReactGridConfig<TRow = unknown> = Omit<GridConfig<TRow>, 'columns'> & {
52
+ columns?: ReactColumnConfig<TRow>[];
53
+ };
54
+ /**
55
+ * Wraps a React renderer function into a DOM-returning viewRenderer.
56
+ * Used internally by DataGrid to process reactRenderer properties.
57
+ */
58
+ export declare function wrapReactRenderer<TRow>(renderFn: (ctx: CellRenderContext<TRow>) => ReactNode): (ctx: CellRenderContext<TRow>) => HTMLElement;
59
+ /**
60
+ * Wraps a React editor function into a DOM-returning editor spec.
61
+ * Used internally by DataGrid to process reactEditor properties.
62
+ */
63
+ export declare function wrapReactEditor<TRow>(editorFn: (ctx: ColumnEditorContext<TRow>) => ReactNode): (ctx: ColumnEditorContext<TRow>) => HTMLElement;
64
+ /**
65
+ * Processes a ReactGridConfig, converting React renderer/editor functions
66
+ * to DOM-returning functions that the grid core understands.
67
+ *
68
+ * @internal Used by DataGrid component
69
+ */
70
+ export declare function processReactGridConfig<TRow>(config: ReactGridConfig<TRow> | undefined): GridConfig<TRow> | undefined;
71
+ //# sourceMappingURL=react-column-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-column-config.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/lib/react-column-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC1G,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,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