@aquera/ngx-smart-table 0.0.17-alpha → 0.0.19-alpha

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 (170) hide show
  1. package/{fesm2020 → fesm2022}/aquera-ngx-smart-table.mjs +1579 -2101
  2. package/fesm2022/aquera-ngx-smart-table.mjs.map +1 -0
  3. package/package.json +8 -16
  4. package/types/aquera-ngx-smart-table.d.ts +5909 -0
  5. package/aquera-ngx-smart-table.d.ts +0 -5
  6. package/esm2020/aquera-ngx-smart-table.mjs +0 -5
  7. package/esm2020/lib/builder/components/builder-preview/builder-preview.component.mjs +0 -63
  8. package/esm2020/lib/builder/components/builder-toolbar/builder-toolbar.component.mjs +0 -115
  9. package/esm2020/lib/builder/components/column-editor/column-editor.component.mjs +0 -206
  10. package/esm2020/lib/builder/components/column-list/column-list.component.mjs +0 -125
  11. package/esm2020/lib/builder/components/definition-builder/definition-builder.component.mjs +0 -105
  12. package/esm2020/lib/builder/components/table-config-editor/table-config-editor.component.mjs +0 -132
  13. package/esm2020/lib/builder/definition-builder.module.mjs +0 -70
  14. package/esm2020/lib/builder/models/builder-state.interface.mjs +0 -5
  15. package/esm2020/lib/builder/services/definition-builder.service.mjs +0 -251
  16. package/esm2020/lib/builder/services/definition-export.service.mjs +0 -167
  17. package/esm2020/lib/builder/services/definition-import.service.mjs +0 -193
  18. package/esm2020/lib/builder/services/sample-data-generator.service.mjs +0 -126
  19. package/esm2020/lib/builder/utils/config-validator.util.mjs +0 -165
  20. package/esm2020/lib/builder/utils/typescript-generator.util.mjs +0 -206
  21. package/esm2020/lib/editors/index.mjs +0 -9
  22. package/esm2020/lib/editors/nile-autocomplete-editor.mjs +0 -228
  23. package/esm2020/lib/editors/nile-calendar-editor.mjs +0 -211
  24. package/esm2020/lib/editors/nile-date-picker-editor.mjs +0 -188
  25. package/esm2020/lib/editors/nile-input-editor.mjs +0 -235
  26. package/esm2020/lib/editors/nile-select-editor.mjs +0 -498
  27. package/esm2020/lib/factories/column-config.factory.mjs +0 -231
  28. package/esm2020/lib/models/autosave-config.interface.mjs +0 -8
  29. package/esm2020/lib/models/base-column-config.class.mjs +0 -253
  30. package/esm2020/lib/models/cell-strategies.interface.mjs +0 -6
  31. package/esm2020/lib/models/cell-types.mjs +0 -147
  32. package/esm2020/lib/models/column-action.interface.mjs +0 -6
  33. package/esm2020/lib/models/column-config.interface.mjs +0 -43
  34. package/esm2020/lib/models/column-config.utils.mjs +0 -101
  35. package/esm2020/lib/models/row-action.interface.mjs +0 -5
  36. package/esm2020/lib/models/row-validator.interface.mjs +0 -2
  37. package/esm2020/lib/models/schema-validation.interface.mjs +0 -2
  38. package/esm2020/lib/models/sheet-action.interface.mjs +0 -5
  39. package/esm2020/lib/models/sheet-config.interface.mjs +0 -5
  40. package/esm2020/lib/models/table-config.interface.mjs +0 -107
  41. package/esm2020/lib/models/table-validator.interface.mjs +0 -2
  42. package/esm2020/lib/models/workbook-action.interface.mjs +0 -5
  43. package/esm2020/lib/models/workbook-config.interface.mjs +0 -5
  44. package/esm2020/lib/renderer/components/st-add-column-button/st-add-column-button.component.mjs +0 -24
  45. package/esm2020/lib/renderer/components/st-cell/st-cell.component.mjs +0 -397
  46. package/esm2020/lib/renderer/components/st-column-editor-modal/st-column-editor-modal.component.mjs +0 -103
  47. package/esm2020/lib/renderer/components/st-column-filter/st-column-filter.component.mjs +0 -383
  48. package/esm2020/lib/renderer/components/st-column-menu/st-column-menu.component.mjs +0 -232
  49. package/esm2020/lib/renderer/components/st-column-visibility/st-column-visibility.component.mjs +0 -97
  50. package/esm2020/lib/renderer/components/st-header/st-header.component.mjs +0 -157
  51. package/esm2020/lib/renderer/components/st-pagination/st-pagination.component.mjs +0 -87
  52. package/esm2020/lib/renderer/components/st-row-actions-dropdown/st-row-actions-dropdown.component.mjs +0 -167
  53. package/esm2020/lib/renderer/components/st-sheet/st-sheet.component.mjs +0 -165
  54. package/esm2020/lib/renderer/components/st-sheet-actions/st-sheet-actions.component.mjs +0 -112
  55. package/esm2020/lib/renderer/components/st-table/st-table.component.mjs +0 -1453
  56. package/esm2020/lib/renderer/components/st-table-actions/st-table-actions.component.mjs +0 -169
  57. package/esm2020/lib/renderer/components/st-workbook/st-workbook.component.mjs +0 -581
  58. package/esm2020/lib/renderer/directives/click-outside.directive.mjs +0 -28
  59. package/esm2020/lib/renderer/directives/st-column-resize.directive.mjs +0 -108
  60. package/esm2020/lib/renderer/directives/st-keyboard-navigation.directive.mjs +0 -83
  61. package/esm2020/lib/renderer/models/cell-state.interface.mjs +0 -66
  62. package/esm2020/lib/renderer/models/cell.class.mjs +0 -389
  63. package/esm2020/lib/renderer/models/row-validation-state.interface.mjs +0 -7
  64. package/esm2020/lib/renderer/models/sheet-state.class.mjs +0 -90
  65. package/esm2020/lib/renderer/models/sheet-state.interface.mjs +0 -5
  66. package/esm2020/lib/renderer/models/table-state.class.mjs +0 -871
  67. package/esm2020/lib/renderer/models/table-state.interface.mjs +0 -5
  68. package/esm2020/lib/renderer/models/table-types.mjs +0 -29
  69. package/esm2020/lib/renderer/models/table-validation-state.interface.mjs +0 -7
  70. package/esm2020/lib/renderer/models/workbook-state.class.mjs +0 -174
  71. package/esm2020/lib/renderer/models/workbook-state.interface.mjs +0 -5
  72. package/esm2020/lib/renderer/models/z-index.enum.mjs +0 -55
  73. package/esm2020/lib/schemas/table-config.schema.mjs +0 -472
  74. package/esm2020/lib/services/autosave.service.mjs +0 -92
  75. package/esm2020/lib/services/custom-validation-rules.util.mjs +0 -124
  76. package/esm2020/lib/services/json-schema-validator.service.mjs +0 -216
  77. package/esm2020/lib/services/row-validation.service.mjs +0 -42
  78. package/esm2020/lib/services/validation-logger.service.mjs +0 -177
  79. package/esm2020/lib/services/virtual-scroll.service.mjs +0 -52
  80. package/esm2020/lib/shared/shared-table-components.module.mjs +0 -35
  81. package/esm2020/lib/smart-table.module.mjs +0 -124
  82. package/esm2020/lib/strategies/default-editors.mjs +0 -433
  83. package/esm2020/lib/strategies/default-formatters.mjs +0 -238
  84. package/esm2020/lib/strategies/default-validators.mjs +0 -327
  85. package/esm2020/public-api.mjs +0 -146
  86. package/fesm2015/aquera-ngx-smart-table.mjs +0 -12347
  87. package/fesm2015/aquera-ngx-smart-table.mjs.map +0 -1
  88. package/fesm2020/aquera-ngx-smart-table.mjs.map +0 -1
  89. package/lib/builder/components/builder-preview/builder-preview.component.d.ts +0 -31
  90. package/lib/builder/components/builder-toolbar/builder-toolbar.component.d.ts +0 -53
  91. package/lib/builder/components/column-editor/column-editor.component.d.ts +0 -69
  92. package/lib/builder/components/column-list/column-list.component.d.ts +0 -65
  93. package/lib/builder/components/definition-builder/definition-builder.component.d.ts +0 -58
  94. package/lib/builder/components/table-config-editor/table-config-editor.component.d.ts +0 -32
  95. package/lib/builder/definition-builder.module.d.ts +0 -15
  96. package/lib/builder/models/builder-state.interface.d.ts +0 -93
  97. package/lib/builder/services/definition-builder.service.d.ts +0 -80
  98. package/lib/builder/services/definition-export.service.d.ts +0 -59
  99. package/lib/builder/services/definition-import.service.d.ts +0 -31
  100. package/lib/builder/services/sample-data-generator.service.d.ts +0 -41
  101. package/lib/builder/utils/config-validator.util.d.ts +0 -32
  102. package/lib/builder/utils/typescript-generator.util.d.ts +0 -29
  103. package/lib/editors/index.d.ts +0 -8
  104. package/lib/editors/nile-autocomplete-editor.d.ts +0 -102
  105. package/lib/editors/nile-calendar-editor.d.ts +0 -88
  106. package/lib/editors/nile-date-picker-editor.d.ts +0 -97
  107. package/lib/editors/nile-input-editor.d.ts +0 -67
  108. package/lib/editors/nile-select-editor.d.ts +0 -113
  109. package/lib/factories/column-config.factory.d.ts +0 -73
  110. package/lib/models/autosave-config.interface.d.ts +0 -23
  111. package/lib/models/base-column-config.class.d.ts +0 -115
  112. package/lib/models/cell-strategies.interface.d.ts +0 -188
  113. package/lib/models/cell-types.d.ts +0 -337
  114. package/lib/models/column-action.interface.d.ts +0 -86
  115. package/lib/models/column-config.interface.d.ts +0 -272
  116. package/lib/models/column-config.utils.d.ts +0 -37
  117. package/lib/models/row-action.interface.d.ts +0 -86
  118. package/lib/models/row-validator.interface.d.ts +0 -37
  119. package/lib/models/schema-validation.interface.d.ts +0 -42
  120. package/lib/models/sheet-action.interface.d.ts +0 -59
  121. package/lib/models/sheet-config.interface.d.ts +0 -41
  122. package/lib/models/table-config.interface.d.ts +0 -251
  123. package/lib/models/table-validator.interface.d.ts +0 -40
  124. package/lib/models/workbook-action.interface.d.ts +0 -95
  125. package/lib/models/workbook-config.interface.d.ts +0 -107
  126. package/lib/renderer/components/st-add-column-button/st-add-column-button.component.d.ts +0 -9
  127. package/lib/renderer/components/st-cell/st-cell.component.d.ts +0 -69
  128. package/lib/renderer/components/st-column-editor-modal/st-column-editor-modal.component.d.ts +0 -39
  129. package/lib/renderer/components/st-column-filter/st-column-filter.component.d.ts +0 -139
  130. package/lib/renderer/components/st-column-menu/st-column-menu.component.d.ts +0 -81
  131. package/lib/renderer/components/st-column-visibility/st-column-visibility.component.d.ts +0 -44
  132. package/lib/renderer/components/st-header/st-header.component.d.ts +0 -93
  133. package/lib/renderer/components/st-pagination/st-pagination.component.d.ts +0 -42
  134. package/lib/renderer/components/st-row-actions-dropdown/st-row-actions-dropdown.component.d.ts +0 -67
  135. package/lib/renderer/components/st-sheet/st-sheet.component.d.ts +0 -98
  136. package/lib/renderer/components/st-sheet-actions/st-sheet-actions.component.d.ts +0 -58
  137. package/lib/renderer/components/st-table/st-table.component.d.ts +0 -380
  138. package/lib/renderer/components/st-table-actions/st-table-actions.component.d.ts +0 -77
  139. package/lib/renderer/components/st-workbook/st-workbook.component.d.ts +0 -275
  140. package/lib/renderer/directives/click-outside.directive.d.ts +0 -10
  141. package/lib/renderer/directives/st-column-resize.directive.d.ts +0 -44
  142. package/lib/renderer/directives/st-keyboard-navigation.directive.d.ts +0 -19
  143. package/lib/renderer/models/cell-state.interface.d.ts +0 -118
  144. package/lib/renderer/models/cell.class.d.ts +0 -174
  145. package/lib/renderer/models/row-validation-state.interface.d.ts +0 -27
  146. package/lib/renderer/models/sheet-state.class.d.ts +0 -67
  147. package/lib/renderer/models/sheet-state.interface.d.ts +0 -55
  148. package/lib/renderer/models/table-state.class.d.ts +0 -320
  149. package/lib/renderer/models/table-state.interface.d.ts +0 -18
  150. package/lib/renderer/models/table-types.d.ts +0 -228
  151. package/lib/renderer/models/table-validation-state.interface.d.ts +0 -34
  152. package/lib/renderer/models/workbook-state.class.d.ts +0 -117
  153. package/lib/renderer/models/workbook-state.interface.d.ts +0 -71
  154. package/lib/renderer/models/z-index.enum.d.ts +0 -44
  155. package/lib/schemas/table-config.schema.d.ts +0 -455
  156. package/lib/services/autosave.service.d.ts +0 -73
  157. package/lib/services/custom-validation-rules.util.d.ts +0 -12
  158. package/lib/services/json-schema-validator.service.d.ts +0 -49
  159. package/lib/services/row-validation.service.d.ts +0 -17
  160. package/lib/services/validation-logger.service.d.ts +0 -87
  161. package/lib/services/virtual-scroll.service.d.ts +0 -44
  162. package/lib/shared/shared-table-components.module.d.ts +0 -9
  163. package/lib/smart-table.module.d.ts +0 -26
  164. package/lib/strategies/default-editors.d.ts +0 -109
  165. package/lib/strategies/default-formatters.d.ts +0 -116
  166. package/lib/strategies/default-validators.d.ts +0 -113
  167. package/public-api.d.ts +0 -70
  168. package/src/lib/builder/README.md +0 -30
  169. package/src/lib/editors/README.md +0 -303
  170. package/src/lib/renderer/components/st-column-filter/README.md +0 -286
@@ -1,303 +0,0 @@
1
- # Custom Editors
2
-
3
- This folder contains custom cell editors for the ngx-smart-table demo.
4
-
5
- ## Creating Custom Editors
6
-
7
- Custom editors can be created by implementing the `CellEditor<T>` interface from `ngx-smart-table`.
8
-
9
- ### Example: NileInputEditor
10
-
11
- The `NileInputEditor` demonstrates how to use custom web components (from `@aquera/nile-elements`) as cell editors.
12
-
13
- **Important:** NileInput uses custom events that replace their native counterparts:
14
- - `nile-blur` replaces `blur`
15
- - `nile-focus` replaces `focus`
16
- - `nile-input` replaces `input`
17
- - `nile-change` replaces `change`
18
- - Standard keyboard events (`keydown`, `keyup`, etc.) still work normally
19
-
20
- #### Features
21
-
22
- - ✅ **Generic type support** - Type-safe with `<T>` parameter (defaults to `string`)
23
- - ✅ **Full NileInput API support** - All NileInput properties configurable via options
24
- - ✅ **Built-in validation** - Validates before saving with `checkValidity()` and `reportValidity()`
25
- - ✅ **Type-aware values** - Returns proper types for number, date, and text inputs
26
- - ✅ **Clear button support** - Optional clearable input with `nile-clear` event handling
27
- - ✅ **Proper cleanup** - All event listeners tracked and removed on destroy
28
- - ✅ **Mobile-friendly** - Uses `enterkeyhint: 'done'` by default for better mobile UX
29
- - ✅ **Real-time updates** - Triggers `onChange` during typing via `nile-input` event
30
- - ✅ **Visual states** - Support for error, warning, success states
31
- - ✅ **Style variants** - Filled and pill styles available
32
-
33
- ```typescript
34
- import { CellEditor, CellEditorContext } from 'ngx-smart-table';
35
- import { NileInput } from '@aquera/nile-elements';
36
- import { NileInputEditorOptions } from './nile-input-editor';
37
-
38
- export class NileInputEditor<T = string> implements CellEditor<T> {
39
- private input?: NileInput;
40
-
41
- constructor(options?: NileInputEditorOptions) {}
42
-
43
- edit(context: CellEditorContext<T>): void {
44
- // 1. Create your custom element
45
- this.input = new NileInput();
46
- this.input.value = String(context.value ?? '');
47
-
48
- // 2. Apply all options
49
- this.applyOptions();
50
-
51
- // 3. Set up event handlers
52
- // ✅ Use keydown (still works - not replaced)
53
- this.input.addEventListener('keydown', (e: KeyboardEvent) => {
54
- if (e.key === 'Enter') this.saveValue(context, true);
55
- if (e.key === 'Escape') context.onCancel();
56
- });
57
-
58
- // ✅ Use custom nile-blur event (replaces blur)
59
- this.input.addEventListener('nile-blur', (e: Event) => {
60
- const customEvent = e as CustomEvent;
61
- if (this.input?.checkValidity()) {
62
- context.onSave(customEvent.detail.value);
63
- }
64
- });
65
-
66
- // Optional: Real-time updates
67
- this.input.addEventListener('nile-input', (e: Event) => {
68
- const customEvent = e as CustomEvent;
69
- context.onChange(customEvent.detail.value);
70
- });
71
-
72
- // 4. Render in the container
73
- context.container.appendChild(this.input);
74
- this.input.focus();
75
- }
76
-
77
- destroy(): void {
78
- // Cleanup all event listeners
79
- this.input?.remove();
80
- }
81
- }
82
- ```
83
-
84
- ### Using Custom Editors in Column Config
85
-
86
- ```typescript
87
- import { Columns } from 'ngx-smart-table';
88
- import { NileInputEditor } from '../editors';
89
-
90
- export const columns = [
91
- // Basic text input (generic type defaults to string)
92
- Columns.text('name', {
93
- header: 'Name',
94
- editable: true,
95
- editor: new NileInputEditor({
96
- placeholder: 'Enter name',
97
- maxLength: 100,
98
- required: true,
99
- validateOnSave: true
100
- })
101
- }),
102
-
103
- // Email input with validation
104
- Columns.text('email', {
105
- header: 'Email',
106
- editable: true,
107
- editor: new NileInputEditor({
108
- type: 'email',
109
- placeholder: 'user@example.com',
110
- required: true,
111
- pattern: '^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$',
112
- errorMessage: 'Please enter a valid email address'
113
- })
114
- }),
115
-
116
- // Number input with range (explicitly typed as number)
117
- Columns.number('age', {
118
- header: 'Age',
119
- editable: true,
120
- editor: new NileInputEditor<number>({
121
- type: 'number',
122
- min: 18,
123
- max: 120,
124
- step: 1,
125
- required: true
126
- })
127
- }),
128
-
129
- // Input with clear button and filled style
130
- Columns.text('notes', {
131
- header: 'Notes',
132
- editable: true,
133
- editor: new NileInputEditor({
134
- placeholder: 'Add notes...',
135
- clearable: true,
136
- filled: true,
137
- maxLength: 500
138
- })
139
- }),
140
-
141
- // Phone number with custom input mode
142
- Columns.text('phone', {
143
- header: 'Phone',
144
- editable: true,
145
- editor: new NileInputEditor({
146
- type: 'tel',
147
- placeholder: '+1 (555) 000-0000',
148
- inputmode: 'tel',
149
- pattern: '^\\+?[1-9]\\d{1,14}$'
150
- })
151
- })
152
- ];
153
- ```
154
-
155
- ## CellEditor Interface
156
-
157
- ```typescript
158
- interface CellEditor<T = any> {
159
- /**
160
- * Initialize and render the editor
161
- * @param context Editor context with value, callbacks, and container
162
- */
163
- edit(context: CellEditorContext<T>): void;
164
-
165
- /**
166
- * Optional cleanup when editor is destroyed
167
- */
168
- destroy?(): void;
169
-
170
- /**
171
- * Optional method to focus the editor
172
- */
173
- focus?(): void;
174
-
175
- /**
176
- * Optional method to get current editor value without saving
177
- */
178
- getCurrentValue?(): T;
179
- }
180
- ```
181
-
182
- ## NileInputEditorOptions
183
-
184
- Complete configuration interface for NileInputEditor:
185
-
186
- ```typescript
187
- interface NileInputEditorOptions {
188
- // Basic properties
189
- placeholder?: string; // Placeholder text
190
- maxLength?: number; // Maximum character length
191
- minLength?: number; // Minimum character length
192
- autoFocus?: boolean; // Auto-focus on edit (default: true)
193
- selectOnFocus?: boolean; // Select text on focus (default: true)
194
- type?: 'text' | 'email' | 'tel' | 'url' | 'search' | 'number' | 'password' | 'date' | 'time' | 'datetime-local';
195
- size?: 'small' | 'medium' | 'large'; // Input size (default: 'medium')
196
-
197
- // Style options
198
- filled?: boolean; // Filled background style
199
- pill?: boolean; // Rounded pill style
200
-
201
- // Behavior options
202
- clearable?: boolean; // Show clear button
203
- disabled?: boolean; // Disable input
204
- readonly?: boolean; // Make readonly
205
- required?: boolean; // Required field
206
-
207
- // Validation
208
- pattern?: string; // Regex pattern for validation
209
- min?: number | string; // Minimum value (number/date types)
210
- max?: number | string; // Maximum value (number/date types)
211
- step?: number | 'any'; // Step increment (number type)
212
-
213
- // Visual states
214
- warning?: boolean; // Warning state styling
215
- error?: boolean; // Error state styling
216
- success?: boolean; // Success state styling
217
- errorMessage?: string; // Error message text
218
- helpText?: string; // Help text below input
219
-
220
- // Advanced options
221
- enterkeyhint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';
222
- spellcheck?: boolean; // Enable spell checking
223
- autocomplete?: string; // Autocomplete attribute
224
- inputmode?: 'none' | 'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url';
225
-
226
- // Validation behavior
227
- validateOnSave?: boolean; // Validate before saving (default: true)
228
- }
229
- ```
230
-
231
- ## CellEditorContext
232
-
233
- The context object passed to `edit()` contains:
234
-
235
- - `value: T` - Current cell value
236
- - `rowData: any` - Full row data
237
- - `columnKey: string` - Column identifier
238
- - `rowIndex: number` - Row index
239
- - `container: HTMLElement` - DOM element to render the editor in
240
- - `onChange: (newValue: T) => void` - Real-time change callback
241
- - `onSave: (newValue: T) => void` - Save and exit edit mode
242
- - `onCancel: () => void` - Cancel editing and restore original value
243
-
244
- ## Best Practices
245
-
246
- 1. **Always check for container**: Ensure `context.container` exists before rendering
247
- 2. **Handle keyboard events**: Support Enter (save) and Escape (cancel)
248
- 3. **Clean up in destroy()**: Remove event listeners and DOM elements
249
- 4. **Auto-focus**: Focus the editor element after rendering
250
- 5. **Style appropriately**: Set width/height to fit the cell
251
- 6. **Use correct events**: If using custom elements with custom events, use those instead of native events
252
-
253
- ## NileInput Custom Events
254
-
255
- NileInput from `@aquera/nile-elements` uses custom events that replace native DOM events:
256
-
257
- | Custom Event | Replaces | Detail | Usage |
258
- |--------------|----------|--------|-------|
259
- | `nile-blur` | `blur` | `{ value }` | Input lost focus - use for saving |
260
- | `nile-focus` | `focus` | `{ value }` | Input gained focus |
261
- | `nile-input` | `input` | `{ value }` | Value updated on each keystroke |
262
- | `nile-change` | `change` | `{ value }` | Committed change (includes clear) |
263
- | `nile-clear` | N/A | `{ value: '' }` | Clear button clicked |
264
- | `nile-init` | N/A | N/A | Component connected/initialized |
265
- | `nile-after-init` | N/A | N/A | After initial render/setup |
266
- | `nile-destroy` | N/A | N/A | Component disconnected/cleanup |
267
- | `nile-value-marked` | N/A | marked value + flags | Non-printable chars marked |
268
-
269
- **Note:** Standard keyboard events (`keydown`, `keyup`, `keypress`) are NOT replaced and work normally.
270
-
271
- ### Example with Multiple Events
272
-
273
- ```typescript
274
- edit(context: CellEditorContext<string>): void {
275
- this.input = new NileInput();
276
- this.input.value = context.value ?? '';
277
-
278
- // Keyboard events still work
279
- this.input.addEventListener('keydown', (e: KeyboardEvent) => {
280
- if (e.key === 'Enter') context.onSave(this.input!.value);
281
- if (e.key === 'Escape') context.onCancel();
282
- });
283
-
284
- // Use custom events
285
- this.input.addEventListener('nile-blur', (e: Event) => {
286
- const customEvent = e as CustomEvent;
287
- context.onSave(customEvent.detail.value);
288
- });
289
-
290
- this.input.addEventListener('nile-input', (e: Event) => {
291
- const customEvent = e as CustomEvent;
292
- context.onChange(customEvent.detail.value); // Real-time updates
293
- });
294
-
295
- this.input.addEventListener('nile-clear', (e: Event) => {
296
- const customEvent = e as CustomEvent;
297
- context.onSave(''); // Handle clear button
298
- });
299
-
300
- context.container.appendChild(this.input);
301
- this.input.focus();
302
- }
303
- ```
@@ -1,286 +0,0 @@
1
- # StColumnFilterComponent - Nile Elements Integration
2
-
3
- ## Overview
4
-
5
- The `StColumnFilterComponent` has been refactored to use Nile Elements components for a consistent, modern UI. It's now designed as a shared component that can accept context-based inputs.
6
-
7
- ## Key Changes
8
-
9
- ### 1. **Nile Components Integration**
10
- - Replaced native HTML inputs with `nile-input`
11
- - Replaced native selects with `nile-select` and `nile-option`
12
- - Replaced native checkboxes with `nile-checkbox`
13
- - Replaced native buttons with `nile-button`
14
- - Wrapped everything in `nile-popover` for better positioning and control
15
-
16
- ### 2. **Context-Based Architecture**
17
- Added `FilterContext` interface for flexible component usage:
18
-
19
- ```typescript
20
- export interface FilterContext {
21
- column: ColumnConfig<any>;
22
- tableState?: TableState;
23
- columnIndex: number;
24
- isFirstColumn: boolean;
25
- isLastColumn: boolean;
26
- }
27
- ```
28
-
29
- ### 3. **New Event Emitters**
30
- - `@Output() filterApplied` - Emits when filter is applied with operator and value
31
- - `@Output() filterCleared` - Emits when filter is cleared
32
- - `@Output() closed` - Existing event, emits when popover closes
33
-
34
- ## Usage
35
-
36
- ### Traditional Usage (Individual Inputs)
37
- ```typescript
38
- <st-column-filter
39
- [column]="columnConfig"
40
- [tableState]="tableState"
41
- [columnIndex]="0"
42
- [isFirstColumn]="true"
43
- [isLastColumn]="false"
44
- (filterApplied)="onFilterApplied($event)"
45
- (filterCleared)="onFilterCleared()"
46
- (closed)="onFilterClosed()">
47
- </st-column-filter>
48
- ```
49
-
50
- ### Context-Based Usage (Shared Component Pattern)
51
- ```typescript
52
- // Define context
53
- const filterContext: FilterContext = {
54
- column: columnConfig,
55
- tableState: this.tableState,
56
- columnIndex: 0,
57
- isFirstColumn: true,
58
- isLastColumn: false
59
- };
60
-
61
- // Use in template
62
- <st-column-filter
63
- [filterContext]="filterContext"
64
- (filterApplied)="onFilterApplied($event)"
65
- (filterCleared)="onFilterCleared()">
66
- </st-column-filter>
67
- ```
68
-
69
- ## Nile Component Event Handlers
70
-
71
- The component now uses Nile Elements custom events:
72
-
73
- | Nile Component | Event | Handler Method |
74
- |----------------|-------|----------------|
75
- | `nile-popover` | `nile-hide` | `onPopoverHide()` |
76
- | `nile-select` | `nile-change` | `onOperatorChange($event)` / `onSelectChange($event)` |
77
- | `nile-input` | `nile-input` | `onValueInput($event)` |
78
- | `nile-checkbox` | `nile-change` | `onCheckboxChange($event)` / `onMultiselectCheckboxChange($event, value)` |
79
- | `nile-button` | `click` | `onApply()` / `onClear()` |
80
-
81
- ## Event Details Structure
82
-
83
- ### nile-change (select/checkbox)
84
- ```typescript
85
- {
86
- detail: {
87
- value: any, // For select
88
- checked: boolean // For checkbox
89
- }
90
- }
91
- ```
92
-
93
- ### nile-input
94
- ```typescript
95
- {
96
- detail: {
97
- value: string
98
- }
99
- }
100
- ```
101
-
102
- ### filterApplied Output
103
- ```typescript
104
- {
105
- operator: FilterOperator,
106
- value: any
107
- }
108
- ```
109
-
110
- ## Filter Input Types
111
-
112
- The component automatically renders appropriate Nile components based on data type:
113
-
114
- | Data Type | Nile Component | Description |
115
- |-----------|----------------|-------------|
116
- | `text` | `nile-input[type="text"]` | Text input with operators |
117
- | `number` | `nile-input[type="number"]` | Number input with comparison operators |
118
- | `date` | `nile-input[type="date"]` | Date picker with before/after operators |
119
- | `checkbox` | `nile-checkbox` | Boolean toggle |
120
- | `select` | `nile-select` | Single selection dropdown |
121
- | `multiselect` | Multiple `nile-checkbox` | Multiple selection with checkboxes |
122
-
123
- ## Styling
124
-
125
- ### CSS Parts (Shadow DOM)
126
- The component uses Nile Elements' CSS parts for customization:
127
-
128
- ```scss
129
- // Customize popover
130
- st-column-filter::part(popover) {
131
- min-width: 320px;
132
- }
133
-
134
- // Customize inputs
135
- st-column-filter nile-input::part(base) {
136
- width: 100%;
137
- }
138
-
139
- // Customize buttons
140
- st-column-filter nile-button::part(base) {
141
- min-width: 80px;
142
- }
143
- ```
144
-
145
- ### Component SCSS Classes
146
- Internal classes for layout:
147
-
148
- - `.st-column-filter-popover` - Wrapper class
149
- - `.filter-content` - Main content container
150
- - `.filter-value-section` - Value input area
151
- - `.filter-multiselect` - Multiselect container
152
- - `.filter-actions` - Button area
153
-
154
- ## Programmatic Control
155
-
156
- ### Opening the Filter
157
- ```typescript
158
- @ViewChild(StColumnFilterComponent) filterComponent!: StColumnFilterComponent;
159
-
160
- openFilter() {
161
- this.filterComponent.open();
162
- }
163
- ```
164
-
165
- ### Closing the Filter
166
- ```typescript
167
- closeFilter() {
168
- this.filterComponent.close();
169
- }
170
- ```
171
-
172
- ### Getting Filter Context
173
- ```typescript
174
- const context = this.filterComponent.context;
175
- console.log('Current column:', context.column.key);
176
- ```
177
-
178
- ## Migration Guide
179
-
180
- If you're migrating from the old HTML-based filter:
181
-
182
- ### Before (Native HTML)
183
- ```html
184
- <input type="text" [(ngModel)]="filterValue">
185
- <button (click)="onApply()">Apply</button>
186
- ```
187
-
188
- ### After (Nile Components)
189
- ```html
190
- <nile-input
191
- [value]="filterValue"
192
- (nile-input)="onValueInput($event)">
193
- </nile-input>
194
- <nile-button (click)="onApply()">Apply</nile-button>
195
- ```
196
-
197
- ### Event Handler Updates
198
- ```typescript
199
- // Old: Direct ngModel binding
200
- // filterValue is automatically updated
201
-
202
- // New: Event handler
203
- onValueInput(event: Event): void {
204
- const customEvent = event as CustomEvent;
205
- this.filterValue = customEvent.detail.value;
206
- }
207
- ```
208
-
209
- ## Best Practices
210
-
211
- 1. **Use Context Pattern** for shared/reusable filters
212
- 2. **Listen to Events** - Use `filterApplied` and `filterCleared` for logging/analytics
213
- 3. **Customize via CSS Parts** - Use Nile's shadow DOM parts for theming
214
- 4. **Programmatic Control** - Use `open()`/`close()` methods for complex UX flows
215
-
216
- ## Examples
217
-
218
- ### Complete Example with All Features
219
- ```typescript
220
- @Component({
221
- template: `
222
- <st-column-filter
223
- [filterContext]="getFilterContext(column)"
224
- (filterApplied)="logFilterApplied($event)"
225
- (filterCleared)="logFilterCleared()"
226
- (closed)="onFilterUIClosed()">
227
- </st-column-filter>
228
- `
229
- })
230
- export class MyComponent {
231
- getFilterContext(column: ColumnConfig): FilterContext {
232
- return {
233
- column,
234
- tableState: this.tableState,
235
- columnIndex: this.getColumnIndex(column),
236
- isFirstColumn: this.isFirst(column),
237
- isLastColumn: this.isLast(column)
238
- };
239
- }
240
-
241
- logFilterApplied(event: { operator: FilterOperator; value: any }) {
242
- console.log(`Filter applied: ${event.operator} = ${event.value}`);
243
- // Send to analytics, etc.
244
- }
245
-
246
- logFilterCleared() {
247
- console.log('Filter cleared');
248
- }
249
-
250
- onFilterUIClosed() {
251
- console.log('Filter UI closed');
252
- }
253
- }
254
- ```
255
-
256
- ## Troubleshooting
257
-
258
- ### Popover Not Showing
259
- - Ensure `isOpen` is set to `true`
260
- - Check that the anchor element is in the DOM
261
- - Verify Nile Elements are properly imported: `import '@aquera/nile-elements'`
262
-
263
- ### Events Not Firing
264
- - Make sure you're using custom event handlers (e.g., `nile-change`, not `change`)
265
- - Cast events to `CustomEvent` to access `detail` property
266
- - Check browser console for any Nile Elements errors
267
-
268
- ### Styling Issues
269
- - Use `::part()` pseudo-element for shadow DOM styling
270
- - Check that CSS imports are correct
271
- - Verify SCSS variables are available
272
-
273
- ## Dependencies
274
-
275
- - `@aquera/nile-elements` - Required for all Nile components
276
- - Angular forms (FormsModule) - For ngModel directives
277
- - RxJS - For observable subscriptions (TableState)
278
-
279
- ## Browser Compatibility
280
-
281
- Works with all browsers that support:
282
- - Web Components (Custom Elements)
283
- - Shadow DOM
284
- - ES6+
285
-
286
- See Nile Elements documentation for specific browser support matrix.