@toolbox-web/grid-angular 0.1.3 → 0.3.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.
@@ -0,0 +1,140 @@
1
+ import { Type } from '@angular/core';
2
+ import { ColumnConfig, GridConfig } from '../../../../dist/libs/grid/index.d.ts';
3
+ /**
4
+ * Interface for Angular renderer components.
5
+ *
6
+ * Renderer components receive the cell value, row data, and column config as inputs.
7
+ * Use Angular signal inputs for reactive updates.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { Component, input } from '@angular/core';
12
+ * import type { AngularCellRenderer } from '@toolbox-web/grid-angular';
13
+ *
14
+ * @Component({
15
+ * selector: 'app-status-badge',
16
+ * template: `<span [class]="'badge-' + value()">{{ value() }}</span>`
17
+ * })
18
+ * export class StatusBadgeComponent implements AngularCellRenderer<Employee, string> {
19
+ * value = input.required<string>();
20
+ * row = input.required<Employee>();
21
+ * column = input<unknown>();
22
+ * }
23
+ * ```
24
+ */
25
+ export interface AngularCellRenderer<TRow = unknown, TValue = unknown> {
26
+ /** The cell value - use `input<TValue>()` or `input.required<TValue>()` */
27
+ value: {
28
+ (): TValue | undefined;
29
+ };
30
+ /** The full row data - use `input<TRow>()` or `input.required<TRow>()` */
31
+ row: {
32
+ (): TRow | undefined;
33
+ };
34
+ /** The column configuration (optional) - use `input<unknown>()` */
35
+ column?: {
36
+ (): unknown;
37
+ };
38
+ }
39
+ /**
40
+ * Interface for Angular editor components.
41
+ *
42
+ * Editor components receive the cell value, row data, and column config as inputs,
43
+ * plus must emit `commit` and `cancel` outputs.
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * import { Component, input, output } from '@angular/core';
48
+ * import type { AngularCellEditor } from '@toolbox-web/grid-angular';
49
+ *
50
+ * @Component({
51
+ * selector: 'app-status-editor',
52
+ * template: `
53
+ * <select [value]="value()" (change)="commit.emit($any($event.target).value)">
54
+ * <option value="active">Active</option>
55
+ * <option value="inactive">Inactive</option>
56
+ * </select>
57
+ * `
58
+ * })
59
+ * export class StatusEditorComponent implements AngularCellEditor<Employee, string> {
60
+ * value = input.required<string>();
61
+ * row = input.required<Employee>();
62
+ * column = input<unknown>();
63
+ * commit = output<string>();
64
+ * cancel = output<void>();
65
+ * }
66
+ * ```
67
+ */
68
+ export interface AngularCellEditor<TRow = unknown, TValue = unknown> extends AngularCellRenderer<TRow, TValue> {
69
+ /** Emit to commit the new value - use `output<TValue>()` */
70
+ commit: {
71
+ emit(value: TValue): void;
72
+ subscribe?(fn: (value: TValue) => void): {
73
+ unsubscribe(): void;
74
+ };
75
+ };
76
+ /** Emit to cancel editing - use `output<void>()` */
77
+ cancel: {
78
+ emit(): void;
79
+ subscribe?(fn: () => void): {
80
+ unsubscribe(): void;
81
+ };
82
+ };
83
+ }
84
+ /**
85
+ * Angular-specific column configuration.
86
+ *
87
+ * Extends the base ColumnConfig to allow Angular component classes
88
+ * to be used directly as renderers and editors.
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * import type { AngularColumnConfig } from '@toolbox-web/grid-angular';
93
+ * import { StatusBadgeComponent, StatusEditorComponent } from './components';
94
+ *
95
+ * const columns: AngularColumnConfig<Employee>[] = [
96
+ * { field: 'name', header: 'Name' },
97
+ * {
98
+ * field: 'status',
99
+ * header: 'Status',
100
+ * editable: true,
101
+ * renderer: StatusBadgeComponent,
102
+ * editor: StatusEditorComponent,
103
+ * },
104
+ * ];
105
+ * ```
106
+ */
107
+ export interface AngularColumnConfig<TRow = unknown> extends Omit<ColumnConfig<TRow>, 'renderer' | 'editor'> {
108
+ /**
109
+ * Cell renderer - can be:
110
+ * - A function `(ctx) => HTMLElement | string`
111
+ * - An Angular component class implementing AngularCellRenderer
112
+ */
113
+ renderer?: ColumnConfig<TRow>['renderer'] | Type<AngularCellRenderer<TRow, unknown>>;
114
+ /**
115
+ * Cell editor - can be:
116
+ * - A function `(ctx) => HTMLElement`
117
+ * - An Angular component class implementing AngularCellEditor
118
+ */
119
+ editor?: ColumnConfig<TRow>['editor'] | Type<AngularCellEditor<TRow, unknown>>;
120
+ }
121
+ /**
122
+ * Angular-specific grid configuration.
123
+ *
124
+ * Extends the base GridConfig to use AngularColumnConfig.
125
+ */
126
+ export interface AngularGridConfig<TRow = unknown> extends Omit<GridConfig<TRow>, 'columns'> {
127
+ columns?: AngularColumnConfig<TRow>[];
128
+ }
129
+ /**
130
+ * Type guard to check if a value is an Angular component class.
131
+ *
132
+ * Detects Angular components by checking for internal Angular markers:
133
+ * - ɵcmp (component definition)
134
+ * - ɵfac (factory function)
135
+ *
136
+ * Also checks if it's an ES6 class (vs function) by inspecting the
137
+ * string representation.
138
+ */
139
+ export declare function isComponentClass(value: unknown): value is Type<unknown>;
140
+ //# sourceMappingURL=angular-column-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"angular-column-config.d.ts","sourceRoot":"","sources":["../../../../libs/grid-angular/src/lib/angular-column-config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,mBAAmB,CAAC,IAAI,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO;IACnE,2EAA2E;IAC3E,KAAK,EAAE;QAAE,IAAI,MAAM,GAAG,SAAS,CAAA;KAAE,CAAC;IAClC,0EAA0E;IAC1E,GAAG,EAAE;QAAE,IAAI,IAAI,GAAG,SAAS,CAAA;KAAE,CAAC;IAC9B,mEAAmE;IACnE,MAAM,CAAC,EAAE;QAAE,IAAI,OAAO,CAAA;KAAE,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,WAAW,iBAAiB,CAAC,IAAI,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO,CAAE,SAAQ,mBAAmB,CAAC,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@@
1
1
  import { ApplicationRef, EnvironmentInjector, ViewContainerRef } from '@angular/core';
2
- import { ColumnEditorSpec, ColumnViewRenderer, FrameworkAdapter } from '../../../../dist/libs/grid/index.d.ts';
2
+ import { ColumnConfig, ColumnEditorSpec, ColumnViewRenderer, FrameworkAdapter, GridConfig, TypeDefault } from '../../../../dist/libs/grid/index.d.ts';
3
+ import { AngularColumnConfig, AngularGridConfig } from './angular-column-config';
3
4
  /**
4
5
  * Framework adapter that enables zero-boilerplate integration of Angular components
5
6
  * with the grid's light DOM configuration API.
@@ -65,7 +66,44 @@ export declare class AngularGridAdapter implements FrameworkAdapter {
65
66
  private appRef;
66
67
  private viewContainerRef;
67
68
  private viewRefs;
69
+ private componentRefs;
70
+ private typeRegistry;
68
71
  constructor(injector: EnvironmentInjector, appRef: ApplicationRef, viewContainerRef: ViewContainerRef);
72
+ /**
73
+ * Processes an Angular grid configuration, converting component class references
74
+ * to actual renderer/editor functions.
75
+ *
76
+ * Call this method on your gridConfig before passing it to the grid.
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * import { AngularGridAdapter, type AngularGridConfig } from '@toolbox-web/grid-angular';
81
+ *
82
+ * const config: AngularGridConfig<Employee> = {
83
+ * columns: [
84
+ * { field: 'status', renderer: StatusBadgeComponent, editor: StatusEditorComponent },
85
+ * ],
86
+ * };
87
+ *
88
+ * // In component
89
+ * constructor() {
90
+ * const adapter = inject(AngularGridAdapter); // or create new instance
91
+ * this.processedConfig = adapter.processGridConfig(config);
92
+ * }
93
+ * ```
94
+ *
95
+ * @param config - Angular grid configuration with possible component class references
96
+ * @returns Processed GridConfig with actual renderer/editor functions
97
+ */
98
+ processGridConfig<TRow = unknown>(config: AngularGridConfig<TRow>): GridConfig<TRow>;
99
+ /**
100
+ * Processes a single column configuration, converting component class references
101
+ * to actual renderer/editor functions.
102
+ *
103
+ * @param column - Angular column configuration
104
+ * @returns Processed ColumnConfig
105
+ */
106
+ processColumn<TRow = unknown>(column: AngularColumnConfig<TRow>): ColumnConfig<TRow>;
69
107
  /**
70
108
  * Determines if this adapter can handle the given element.
71
109
  * Checks if a template is registered for this element (structural or nested).
@@ -117,7 +155,56 @@ export declare class AngularGridAdapter implements FrameworkAdapter {
117
155
  */
118
156
  createToolPanelRenderer(element: HTMLElement): ((container: HTMLElement) => void | (() => void)) | undefined;
119
157
  /**
120
- * Clean up all view references.
158
+ * Gets type-level defaults from the application's GridTypeRegistry.
159
+ *
160
+ * This enables application-wide type defaults configured via `provideGridTypeDefaults()`.
161
+ * The returned TypeDefault contains renderer/editor functions that instantiate
162
+ * Angular components dynamically.
163
+ *
164
+ * @example
165
+ * ```typescript
166
+ * // app.config.ts
167
+ * export const appConfig: ApplicationConfig = {
168
+ * providers: [
169
+ * provideGridTypeDefaults({
170
+ * country: {
171
+ * renderer: CountryCellComponent,
172
+ * editor: CountryEditorComponent
173
+ * }
174
+ * })
175
+ * ]
176
+ * };
177
+ *
178
+ * // Any grid with type: 'country' columns will use these components
179
+ * gridConfig = {
180
+ * columns: [{ field: 'country', type: 'country' }]
181
+ * };
182
+ * ```
183
+ */
184
+ getTypeDefault<TRow = unknown>(type: string): TypeDefault<TRow> | undefined;
185
+ /**
186
+ * Creates a renderer function from an Angular component class.
187
+ * @internal
188
+ */
189
+ private createComponentRenderer;
190
+ /**
191
+ * Creates an editor function from an Angular component class.
192
+ * @internal
193
+ */
194
+ private createComponentEditor;
195
+ /**
196
+ * Subscribes to an Angular output on a component instance.
197
+ * Works with both EventEmitter and OutputEmitterRef (signal outputs).
198
+ * @internal
199
+ */
200
+ private subscribeToOutput;
201
+ /**
202
+ * Sets component inputs using Angular's setInput API.
203
+ * @internal
204
+ */
205
+ private setComponentInputs;
206
+ /**
207
+ * Clean up all view references and component references.
121
208
  * Call this when your app/component is destroyed.
122
209
  */
123
210
  destroy(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"angular-grid-adapter.d.ts","sourceRoot":"","sources":["../../../../libs/grid-angular/src/lib/angular-grid-adapter.ts"],"names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OnInit } from '@angular/core';
2
+ import { AngularGridConfig } from '../angular-column-config';
2
3
  /**
3
4
  * Event detail for cell commit events.
4
5
  */
@@ -65,7 +66,7 @@ export interface RowCommitEvent<TRow = unknown> {
65
66
  * The directive automatically:
66
67
  * - Creates an AngularGridAdapter instance
67
68
  * - Registers it with the GridElement
68
- * - Injects custom styles into the grid's shadow DOM
69
+ * - Injects custom styles into the grid
69
70
  * - Handles cleanup on destruction
70
71
  */
71
72
  export declare class Grid implements OnInit, AfterContentInit, OnDestroy {
@@ -75,9 +76,10 @@ export declare class Grid implements OnInit, AfterContentInit, OnDestroy {
75
76
  private viewContainerRef;
76
77
  private adapter;
77
78
  private cellCommitListener;
79
+ constructor();
78
80
  private rowCommitListener;
79
81
  /**
80
- * Custom CSS styles to inject into the grid's shadow DOM.
82
+ * Custom CSS styles to inject into the grid.
81
83
  * Use this to style custom cell renderers, editors, or detail panels.
82
84
  *
83
85
  * @example
@@ -94,6 +96,42 @@ export declare class Grid implements OnInit, AfterContentInit, OnDestroy {
94
96
  * ```
95
97
  */
96
98
  customStyles: import('@angular/core').InputSignal<string | undefined>;
99
+ /**
100
+ * Angular-specific grid configuration that supports component classes for renderers/editors.
101
+ *
102
+ * Use this input when you want to specify Angular component classes directly in column configs.
103
+ * Components must implement the appropriate interfaces:
104
+ * - Renderers: `AngularCellRenderer<TRow, TValue>` - requires `value()` and `row()` signal inputs
105
+ * - Editors: `AngularCellEditor<TRow, TValue>` - adds `commit` and `cancel` outputs
106
+ *
107
+ * The directive automatically processes component classes and converts them to grid-compatible
108
+ * renderer/editor functions before applying to the grid.
109
+ *
110
+ * @example
111
+ * ```typescript
112
+ * // Component that implements AngularCellEditor
113
+ * @Component({...})
114
+ * export class BonusEditorComponent implements AngularCellEditor<Employee, number> {
115
+ * value = input.required<number>();
116
+ * row = input.required<Employee>();
117
+ * commit = output<number>();
118
+ * cancel = output<void>();
119
+ * }
120
+ *
121
+ * // In your grid config
122
+ * config: AngularGridConfig<Employee> = {
123
+ * columns: [
124
+ * { field: 'name', header: 'Name' },
125
+ * { field: 'bonus', header: 'Bonus', editable: true, editor: BonusEditorComponent }
126
+ * ]
127
+ * };
128
+ * ```
129
+ *
130
+ * ```html
131
+ * <tbw-grid [angularConfig]="config" [rows]="employees"></tbw-grid>
132
+ * ```
133
+ */
134
+ angularConfig: import('@angular/core').InputSignal<AngularGridConfig<any> | undefined>;
97
135
  /**
98
136
  * Emitted when a cell value is committed (inline editing).
99
137
  * Provides the row, field, new value, and change tracking information.
@@ -123,7 +161,7 @@ export declare class Grid implements OnInit, AfterContentInit, OnDestroy {
123
161
  ngOnInit(): void;
124
162
  ngAfterContentInit(): void;
125
163
  /**
126
- * Registers custom styles into the grid's shadow DOM.
164
+ * Registers custom styles into the grid.
127
165
  * Uses the grid's registerStyles() API for clean encapsulation.
128
166
  */
129
167
  private registerCustomStyles;
@@ -1 +1 @@
1
- {"version":3,"file":"grid.directive.d.ts","sourceRoot":"","sources":["../../../../../libs/grid-angular/src/lib/directives/grid.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAOhB,SAAS,EACT,MAAM,EAGP,MAAM,eAAe,CAAC;AAKvB;;GAEG;AACH,MAAM,WAAW,eAAe,CAAC,IAAI,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO;IAC/D,0BAA0B;IAC1B,GAAG,EAAE,IAAI,CAAC;IACV,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,+BAA+B;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,WAAW,EAAE,IAAI,EAAE,CAAC;IACpB,iDAAiD;IACjD,iBAAiB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/B,yDAAyD;IACzD,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,IAAI,GAAG,OAAO;IAC5C,0BAA0B;IAC1B,GAAG,EAAE,IAAI,CAAC;IACV,sCAAsC;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,WAAW,EAAE,IAAI,EAAE,CAAC;IACpB,iDAAiD;IACjD,iBAAiB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/B,yDAAyD;IACzD,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,qBACa,IAAK,YAAW,MAAM,EAAE,gBAAgB,EAAE,SAAS;IAC9D,OAAO,CAAC,UAAU,CAAmC;IACrD,OAAO,CAAC,QAAQ,CAA+B;IAC/C,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,gBAAgB,CAA4B;IAEpD,OAAO,CAAC,OAAO,CAAmC;IAClD,OAAO,CAAC,kBAAkB,CAAqC;IAC/D,OAAO,CAAC,iBAAiB,CAAqC;IAE9D;;;;;;;;;;;;;;;;OAgBG;IACH,YAAY,0DAAmB;IAE/B;;;;;;;;;;;;;;OAcG;IACH,UAAU,8EAA6B;IAEvC;;;;;;;;OAQG;IACH,SAAS,oEAA4B;IAErC,QAAQ,IAAI,IAAI;IAyBhB,kBAAkB,IAAI,IAAI;IAwB1B;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAU5B;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;IA4C7B,WAAW,IAAI,IAAI;CAyBpB"}
1
+ {"version":3,"file":"grid.directive.d.ts","sourceRoot":"","sources":["../../../../../libs/grid-angular/src/lib/directives/grid.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAQhB,SAAS,EACT,MAAM,EAGP,MAAM,eAAe,CAAC;AAGvB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAGlE;;GAEG;AACH,MAAM,WAAW,eAAe,CAAC,IAAI,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO;IAC/D,0BAA0B;I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;IAyBhB,kBAAkB,IAAI,IAAI;IAwB1B;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAU5B;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;IA4C7B,WAAW,IAAI,IAAI;CAyBpB"}
@@ -0,0 +1,110 @@
1
+ import { EnvironmentProviders, InjectionToken, Type } from '@angular/core';
2
+ import { TypeDefault } from '../../../../dist/libs/grid/index.d.ts';
3
+ /**
4
+ * Angular-specific type default configuration.
5
+ * Uses Angular component types instead of function-based renderers/editors.
6
+ */
7
+ export interface AngularTypeDefault<TRow = unknown> {
8
+ /** Angular component class for rendering cells of this type */
9
+ renderer?: Type<any>;
10
+ /** Angular component class for editing cells of this type */
11
+ editor?: Type<any>;
12
+ /** Default editorParams for this type */
13
+ editorParams?: Record<string, unknown>;
14
+ }
15
+ /**
16
+ * Injection token for providing type defaults at app level.
17
+ */
18
+ export declare const GRID_TYPE_DEFAULTS: InjectionToken<Record<string, AngularTypeDefault<unknown>>>;
19
+ /**
20
+ * Injectable service for managing type-level defaults.
21
+ *
22
+ * Use `provideGridTypeDefaults()` in your app config to set up defaults,
23
+ * or inject this service for dynamic registration.
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * // App-level setup (app.config.ts)
28
+ * export const appConfig: ApplicationConfig = {
29
+ * providers: [
30
+ * provideGridTypeDefaults({
31
+ * country: {
32
+ * renderer: CountryCellComponent,
33
+ * editor: CountryEditorComponent
34
+ * },
35
+ * status: {
36
+ * renderer: StatusBadgeComponent
37
+ * }
38
+ * })
39
+ * ]
40
+ * };
41
+ *
42
+ * // Dynamic registration
43
+ * @Component({ ... })
44
+ * export class AppComponent {
45
+ * private registry = inject(GridTypeRegistry);
46
+ *
47
+ * ngOnInit() {
48
+ * this.registry.register('currency', {
49
+ * renderer: CurrencyCellComponent
50
+ * });
51
+ * }
52
+ * }
53
+ * ```
54
+ */
55
+ export declare class GridTypeRegistry {
56
+ private readonly defaults;
57
+ constructor();
58
+ /**
59
+ * Register type-level defaults for a custom type.
60
+ *
61
+ * @param type - The type name (e.g., 'country', 'currency')
62
+ * @param defaults - Renderer/editor configuration
63
+ */
64
+ register<T = unknown>(type: string, defaults: AngularTypeDefault<T>): void;
65
+ /**
66
+ * Get type defaults for a given type.
67
+ */
68
+ get(type: string): AngularTypeDefault | undefined;
69
+ /**
70
+ * Remove type defaults for a type.
71
+ */
72
+ unregister(type: string): void;
73
+ /**
74
+ * Check if a type has registered defaults.
75
+ */
76
+ has(type: string): boolean;
77
+ /**
78
+ * Get all registered type names.
79
+ */
80
+ getRegisteredTypes(): string[];
81
+ /**
82
+ * Convert to TypeDefault for use with grid's typeDefaults.
83
+ * This is used internally by the adapter.
84
+ *
85
+ * @internal
86
+ */
87
+ getAsTypeDefault(type: string): TypeDefault | undefined;
88
+ }
89
+ /**
90
+ * Provides application-level type defaults for all grids.
91
+ *
92
+ * @example
93
+ * ```typescript
94
+ * // app.config.ts
95
+ * import { provideGridTypeDefaults } from '@toolbox-web/grid-angular';
96
+ * import { CountryCellComponent, StatusBadgeComponent } from './components';
97
+ *
98
+ * export const appConfig: ApplicationConfig = {
99
+ * providers: [
100
+ * provideGridTypeDefaults({
101
+ * country: { renderer: CountryCellComponent },
102
+ * status: { renderer: StatusBadgeComponent },
103
+ * date: { editor: DatePickerComponent }
104
+ * })
105
+ * ]
106
+ * };
107
+ * ```
108
+ */
109
+ export declare function provideGridTypeDefaults(defaults: Record<string, AngularTypeDefault>): EnvironmentProviders;
110
+ //# sourceMappingURL=grid-type-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grid-type-registry.d.ts","sourceRoot":"","sources":["../../../../libs/grid-angular/src/lib/grid-type-registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,oBAAoB,EAGpB,cAAc,EAEd,IAAI,EACL,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;GAGG;AACH,MAAM,WAAW,kBAAkB,CAAC,IAAI,GAAG,OAAO;IAChD,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IACrB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IACnB,yCAAyC;IACzC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACxC;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,6DAA+E,CAAC;AAE/G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,qBACa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyC;;IAYlE;;;;;OAKG;IACH,QAAQ,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,IAAI;IAI1E;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAIjD;;OAEG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAI9B;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B;;OAEG;IACH,kBAAkB,IAAI,MAAM,EAAE;IAI9B;;;;;OAKG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;CAYxD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,GAAG,oBAAoB,CAE1G"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toolbox-web/grid-angular",
3
- "version": "0.1.3",
3
+ "version": "0.3.0",
4
4
  "description": "Angular adapter for @toolbox-web/grid data grid component",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -27,7 +27,7 @@
27
27
  "url": "https://github.com/OysteinAmundsen/toolbox.git",
28
28
  "directory": "libs/grid-angular"
29
29
  },
30
- "homepage": "https://github.com/OysteinAmundsen/toolbox/tree/main/libs/grid-angular#readme",
30
+ "homepage": "https://toolboxjs.com",
31
31
  "bugs": {
32
32
  "url": "https://github.com/OysteinAmundsen/toolbox/issues"
33
33
  },