@toolbox-web/grid-react 0.8.1 → 0.9.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.
@@ -125,6 +125,31 @@ export interface DataGridProps<TRow = unknown> extends AllFeatureProps<TRow>, Ev
125
125
  * ```
126
126
  */
127
127
  selectable?: boolean;
128
+ /**
129
+ * Show a loading overlay on the grid.
130
+ * Use this during initial data fetch or refresh operations.
131
+ *
132
+ * For row/cell loading states, use the ref to access methods:
133
+ * - `ref.element.setRowLoading(rowId, true/false)`
134
+ * - `ref.element.setCellLoading(rowId, field, true/false)`
135
+ *
136
+ * @default false
137
+ *
138
+ * @example
139
+ * ```tsx
140
+ * const [loading, setLoading] = useState(true);
141
+ *
142
+ * useEffect(() => {
143
+ * fetchData().then(data => {
144
+ * setRows(data);
145
+ * setLoading(false);
146
+ * });
147
+ * }, []);
148
+ *
149
+ * <DataGrid loading={loading} rows={rows} />
150
+ * ```
151
+ */
152
+ loading?: boolean;
128
153
  /** Edit trigger mode - DEPRECATED: use `editing` prop instead */
129
154
  editOn?: 'click' | 'dblclick' | 'none';
130
155
  /** Custom CSS styles to inject into grid shadow DOM */
@@ -171,6 +196,16 @@ export interface DataGridRef<TRow = unknown> {
171
196
  registerStyles: (id: string, css: string) => void;
172
197
  /** Unregister custom styles */
173
198
  unregisterStyles: (id: string) => void;
199
+ /** Set loading state for a specific row */
200
+ setRowLoading: (rowId: string, loading: boolean) => void;
201
+ /** Set loading state for a specific cell */
202
+ setCellLoading: (rowId: string, field: string, loading: boolean) => void;
203
+ /** Check if a row is in loading state */
204
+ isRowLoading: (rowId: string) => boolean;
205
+ /** Check if a cell is in loading state */
206
+ isCellLoading: (rowId: string, field: string) => boolean;
207
+ /** Clear all loading states (grid, rows, and cells) */
208
+ clearAllLoading: () => void;
174
209
  }
175
210
  /**
176
211
  * React wrapper component for the tbw-grid web component.
@@ -1 +1 @@
1
- {"version":3,"file":"data-grid.d.ts","sourceRoot":"","s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I,CAAC;IAClD,+BAA+B;IAC/B,gBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,2CAA2C;IAC3C,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACzD,4CAA4C;IAC5C,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACzE,yCAAyC;IACzC,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IACzC,0CAA0C;IAC1C,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IACzD,uDAAuD;IACvD,eAAe,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,eAAO,MAAM,QAAQ,EAmcf,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,95 @@
1
+ import { GridIcons } from '@toolbox-web/grid';
2
+ import { FC, ReactNode } from 'react';
3
+ /**
4
+ * Context for providing icon overrides to grids.
5
+ * @internal
6
+ */
7
+ export declare const GridIconContext: import('react').Context<Partial<GridIcons> | null>;
8
+ /**
9
+ * Props for the GridIconProvider component.
10
+ */
11
+ export interface GridIconProviderProps {
12
+ /**
13
+ * Icon overrides to provide to all descendant grids.
14
+ * Only specify icons you want to override - defaults are used for the rest.
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * const icons = {
19
+ * expand: '➕',
20
+ * collapse: '➖',
21
+ * sortAsc: '↑',
22
+ * sortDesc: '↓',
23
+ * };
24
+ *
25
+ * <GridIconProvider icons={icons}>
26
+ * <App />
27
+ * </GridIconProvider>
28
+ * ```
29
+ */
30
+ icons: Partial<GridIcons>;
31
+ children: ReactNode;
32
+ }
33
+ /**
34
+ * Provides application-wide icon overrides for all descendant grids.
35
+ *
36
+ * Wrap your application (or part of it) with this provider to customize
37
+ * grid icons across all DataGrid components.
38
+ *
39
+ * @example
40
+ * ```tsx
41
+ * // App.tsx or main.tsx
42
+ * import { GridIconProvider } from '@toolbox-web/grid-react';
43
+ *
44
+ * const customIcons = {
45
+ * expand: '➕',
46
+ * collapse: '➖',
47
+ * sortAsc: '↑',
48
+ * sortDesc: '↓',
49
+ * filter: '<svg>...</svg>',
50
+ * };
51
+ *
52
+ * function App() {
53
+ * return (
54
+ * <GridIconProvider icons={customIcons}>
55
+ * <Dashboard />
56
+ * </GridIconProvider>
57
+ * );
58
+ * }
59
+ * ```
60
+ *
61
+ * Available icons to override:
62
+ * - `expand` - Expand icon for collapsed items (trees, groups, details)
63
+ * - `collapse` - Collapse icon for expanded items
64
+ * - `sortAsc` - Sort ascending indicator
65
+ * - `sortDesc` - Sort descending indicator
66
+ * - `sortNone` - Sort neutral/unsorted indicator
67
+ * - `submenuArrow` - Submenu arrow for context menus
68
+ * - `dragHandle` - Drag handle icon for reordering
69
+ * - `toolPanel` - Tool panel toggle icon in toolbar
70
+ * - `filter` - Filter icon in column headers
71
+ * - `filterActive` - Filter icon when filter is active
72
+ * - `print` - Print icon for print button
73
+ */
74
+ export declare const GridIconProvider: FC<GridIconProviderProps>;
75
+ /**
76
+ * Hook to access icon overrides from context.
77
+ *
78
+ * @returns The icon overrides from the nearest GridIconProvider, or null if none.
79
+ *
80
+ * @example
81
+ * ```tsx
82
+ * function MyComponent() {
83
+ * const icons = useGridIcons();
84
+ * console.log('Current expand icon:', icons?.expand);
85
+ * return <div />;
86
+ * }
87
+ * ```
88
+ */
89
+ export declare function useGridIcons(): Partial<GridIcons> | null;
90
+ /**
91
+ * Internal context export for use by DataGrid.
92
+ * @internal
93
+ */
94
+ export declare const GridIconContextInternal: import('react').Context<Partial<GridIcons> | null>;
95
+ //# sourceMappingURL=grid-icon-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grid-icon-registry.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/lib/grid-icon-registry.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAA6B,KAAK,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE3E;;;GAGG;AACH,eAAO,MAAM,eAAe,oDAAiD,CAAC;AAE9E;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;;;;;;;;;;;;;;OAiBG;IACH,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAC1B,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAEtD,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAAC,SAAS,CAAC,GAAG,IAAI,CAExD;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,oDAAkB,CAAC"}
@@ -0,0 +1,90 @@
1
+ import { GridIcons } from '@toolbox-web/grid';
2
+ import { FC, ReactNode } from 'react';
3
+ import { TypeDefaultsMap } from './grid-type-registry';
4
+ /**
5
+ * Props for the GridProvider component.
6
+ */
7
+ export interface GridProviderProps {
8
+ /**
9
+ * Icon overrides to provide to all descendant grids.
10
+ * Optional - only specify if you want to customize icons.
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * icons={{
15
+ * expand: '➕',
16
+ * collapse: '➖',
17
+ * sortAsc: '↑',
18
+ * sortDesc: '↓',
19
+ * }}
20
+ * ```
21
+ */
22
+ icons?: Partial<GridIcons>;
23
+ /**
24
+ * Type-level default renderers and editors.
25
+ * Optional - only specify if you want custom type defaults.
26
+ *
27
+ * @example
28
+ * ```tsx
29
+ * defaults={{
30
+ * country: {
31
+ * renderer: (ctx) => <CountryBadge value={ctx.value} />,
32
+ * editor: (ctx) => <CountrySelect value={ctx.value} onCommit={ctx.commit} />
33
+ * },
34
+ * date: {
35
+ * renderer: (ctx) => formatDate(ctx.value),
36
+ * }
37
+ * }}
38
+ * ```
39
+ */
40
+ defaults?: TypeDefaultsMap;
41
+ children: ReactNode;
42
+ }
43
+ /**
44
+ * Combined provider for application-wide grid configuration.
45
+ *
46
+ * This component wraps both `GridTypeProvider` and `GridIconProvider` to reduce
47
+ * nesting in your component tree. All props are optional - only provide what you need.
48
+ *
49
+ * @example
50
+ * ```tsx
51
+ * // App.tsx or main.tsx
52
+ * import { GridProvider } from '@toolbox-web/grid-react';
53
+ *
54
+ * const typeDefaults = {
55
+ * country: { renderer: (ctx) => <CountryBadge value={ctx.value} /> },
56
+ * status: { renderer: (ctx) => <StatusBadge value={ctx.value} /> },
57
+ * };
58
+ *
59
+ * const icons = {
60
+ * expand: '➕',
61
+ * collapse: '➖',
62
+ * };
63
+ *
64
+ * function App() {
65
+ * return (
66
+ * <GridProvider defaults={typeDefaults} icons={icons}>
67
+ * <Dashboard />
68
+ * </GridProvider>
69
+ * );
70
+ * }
71
+ * ```
72
+ *
73
+ * @example
74
+ * ```tsx
75
+ * // Icons only
76
+ * <GridProvider icons={{ expand: '+', collapse: '-' }}>
77
+ * <App />
78
+ * </GridProvider>
79
+ * ```
80
+ *
81
+ * @example
82
+ * ```tsx
83
+ * // Type defaults only
84
+ * <GridProvider defaults={{ date: { renderer: (ctx) => formatDate(ctx.value) } }}>
85
+ * <App />
86
+ * </GridProvider>
87
+ * ```
88
+ */
89
+ export declare const GridProvider: FC<GridProviderProps>;
90
+ //# sourceMappingURL=grid-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grid-provider.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/lib/grid-provider.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEhD,OAAO,EAAoB,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE9E;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAE3B;;;;;;;;;;;;;;;;OAgBG;IACH,QAAQ,CAAC,EAAE,eAAe,CAAC;IAE3B,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CAgB9C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toolbox-web/grid-react",
3
- "version": "0.8.1",
3
+ "version": "0.9.0",
4
4
  "description": "React adapter for @toolbox-web/grid data grid component",
5
5
  "type": "module",
6
6
  "main": "./index.js",