@one-paragon/angular-utilities 2.8.3 → 2.8.4
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.
- package/karma.conf.js +43 -0
- package/ng-package.json +7 -0
- package/package.json +15 -27
- package/src/action-state/action-state-spinner/action-state-spinner.component.css +16 -0
- package/src/action-state/action-state-spinner/action-state-spinner.component.html +7 -0
- package/src/action-state/action-state-spinner/action-state-spinner.component.spec.ts +25 -0
- package/src/action-state/action-state-spinner/action-state-spinner.component.ts +26 -0
- package/src/action-state/action-state-ui/action-state-ui.module.ts +13 -0
- package/src/action-state/index.ts +8 -0
- package/src/action-state/ngrx-ext/ngrx-ext.module.ts +14 -0
- package/src/action-state/ngrx.ts +69 -0
- package/src/http-request-state/RequestStateFactory.ts +56 -0
- package/src/http-request-state/RequestStateStore.ts +360 -0
- package/src/http-request-state/deprecated.ts +20 -0
- package/src/http-request-state/directives/HttpStateDirectiveBase.ts +29 -0
- package/src/http-request-state/directives/http-error-state-directive.ts +21 -0
- package/src/http-request-state/directives/http-inProgress-state-directive.ts +19 -0
- package/src/http-request-state/directives/http-notStarted-state-directive.ts +19 -0
- package/src/http-request-state/directives/http-success-state-directive.ts +29 -0
- package/src/http-request-state/directives/index.ts +5 -0
- package/src/http-request-state/directives/request-state-directive.spec.ts +73 -0
- package/src/http-request-state/directives/request-state-directive.ts +78 -0
- package/src/http-request-state/documentation/CREATE-REQUESTOR.md +667 -0
- package/src/http-request-state/documentation/README.md +191 -0
- package/src/http-request-state/documentation/REQUEST-STATE-STORE-CONFIG.md +648 -0
- package/src/http-request-state/documentation/REQUESTOR.md +616 -0
- package/src/http-request-state/helpers.ts +30 -0
- package/src/http-request-state/http-state-module.ts +23 -0
- package/src/http-request-state/index.ts +7 -0
- package/src/http-request-state/models/view-context.ts +18 -0
- package/src/http-request-state/observable.spec.ts +43 -0
- package/src/http-request-state/request-state.ts +66 -0
- package/src/http-request-state/rxjs/getRequestorBody.ts +10 -0
- package/src/http-request-state/rxjs/getRequestorState.ts +8 -0
- package/src/http-request-state/rxjs/index.ts +4 -0
- package/src/http-request-state/rxjs/tapError.ts +16 -0
- package/src/http-request-state/rxjs/tapSuccess.ts +16 -0
- package/src/http-request-state/strategies.spec.ts +42 -0
- package/src/http-request-state/types.ts +54 -0
- package/src/ngrx/actionable-selector.ts +189 -0
- package/src/ngrx/index.ts +1 -0
- package/src/public-api.ts +40 -0
- package/src/rxjs/defaultShareReplay.ts +8 -0
- package/src/rxjs/index.ts +5 -0
- package/src/rxjs/mapError.ts +8 -0
- package/src/rxjs/rxjs-operators.ts +130 -0
- package/src/rxjs/subjectifier.ts +17 -0
- package/src/rxjs/subscriber.directive.ts +57 -0
- package/src/specs/clickSubject.spec.ts +99 -0
- package/src/specs/dialog.spec.ts +101 -0
- package/src/specs/toggleGroupDirective.spec.ts +229 -0
- package/src/table-builder/classes/DefaultSettings.ts +11 -0
- package/src/table-builder/classes/MatTableObservableDataSource.ts +23 -0
- package/src/table-builder/classes/TableBuilderConfig.ts +49 -0
- package/src/table-builder/classes/TableBuilderDataSource.ts +64 -0
- package/src/table-builder/classes/TableState.ts +96 -0
- package/src/table-builder/classes/data-store.ts +10 -0
- package/src/table-builder/classes/display-col.ts +5 -0
- package/src/table-builder/classes/filter-info.ts +129 -0
- package/src/table-builder/classes/table-builder-general-settings.ts +233 -0
- package/src/table-builder/classes/table-builder.ts +105 -0
- package/src/table-builder/classes/table-store.helpers.ts +109 -0
- package/src/table-builder/classes/table-store.ts +540 -0
- package/src/table-builder/components/array-column.component.ts +34 -0
- package/src/table-builder/components/column-builder/column-builder.component.html +109 -0
- package/src/table-builder/components/column-builder/column-builder.component.scss +43 -0
- package/src/table-builder/components/column-builder/column-builder.component.spec.ts +49 -0
- package/src/table-builder/components/column-builder/column-builder.component.ts +130 -0
- package/src/table-builder/components/column-builder/column-helpers.ts +54 -0
- package/src/table-builder/components/column-header-menu/column-header-menu.component.html +128 -0
- package/src/table-builder/components/column-header-menu/column-header-menu.component.scss +97 -0
- package/src/table-builder/components/column-header-menu/column-header-menu.component.ts +113 -0
- package/src/table-builder/components/date-filter/date-filter.component.html +39 -0
- package/src/table-builder/components/date-filter/date-filter.component.ts +33 -0
- package/src/table-builder/components/date-time-filter/date-time-filter.component.html +25 -0
- package/src/table-builder/components/date-time-filter/date-time-filter.component.ts +33 -0
- package/src/table-builder/components/filter/filter.component.html +120 -0
- package/src/table-builder/components/filter/filter.component.scss +60 -0
- package/src/table-builder/components/filter/filter.component.spec.ts +86 -0
- package/src/table-builder/components/filter/filter.component.ts +73 -0
- package/src/table-builder/components/filter/in-list/in-list-filter.component.ts +171 -0
- package/src/table-builder/components/gen-col-displayer/gen-col-displayer.component.html +60 -0
- package/src/table-builder/components/gen-col-displayer/gen-col-displayer.component.scss +57 -0
- package/src/table-builder/components/gen-col-displayer/gen-col-displayer.component.ts +44 -0
- package/src/table-builder/components/generic-table/generic-table.component.html +140 -0
- package/src/table-builder/components/generic-table/generic-table.component.scss +45 -0
- package/src/table-builder/components/generic-table/generic-table.component.ts +531 -0
- package/src/table-builder/components/generic-table/paginator.component.ts +125 -0
- package/src/table-builder/components/group-by-list/group-by-list.component.css +24 -0
- package/src/table-builder/components/group-by-list/group-by-list.component.html +21 -0
- package/src/table-builder/components/group-by-list/group-by-list.component.spec.ts +23 -0
- package/src/table-builder/components/group-by-list/group-by-list.component.ts +26 -0
- package/src/table-builder/components/in-filter/in-filter.component.css +22 -0
- package/src/table-builder/components/in-filter/in-filter.component.html +38 -0
- package/src/table-builder/components/in-filter/in-filter.component.ts +66 -0
- package/src/table-builder/components/index.ts +9 -0
- package/src/table-builder/components/initialization-component/initialization.component.html +78 -0
- package/src/table-builder/components/initialization-component/initialization.component.ts +28 -0
- package/src/table-builder/components/link-column.component.ts +42 -0
- package/src/table-builder/components/number-filter/number-filter.component.css +10 -0
- package/src/table-builder/components/number-filter/number-filter.component.html +32 -0
- package/src/table-builder/components/number-filter/number-filter.component.spec.ts +30 -0
- package/src/table-builder/components/number-filter/number-filter.component.ts +34 -0
- package/src/table-builder/components/profiles-menu/profiles-menu.component.html +77 -0
- package/src/table-builder/components/profiles-menu/profiles-menu.component.scss +126 -0
- package/src/table-builder/components/profiles-menu/profiles-menu.component.spec.ts +23 -0
- package/src/table-builder/components/profiles-menu/profiles-menu.component.ts +64 -0
- package/src/table-builder/components/reset-menu/reset-menu.component.css +3 -0
- package/src/table-builder/components/reset-menu/reset-menu.component.html +10 -0
- package/src/table-builder/components/reset-menu/reset-menu.component.ts +87 -0
- package/src/table-builder/components/scroll-strategy.ts +139 -0
- package/src/table-builder/components/sort-menu/sort-menu.component-store.ts +57 -0
- package/src/table-builder/components/sort-menu/sort-menu.component.html +115 -0
- package/src/table-builder/components/sort-menu/sort-menu.component.scss +119 -0
- package/src/table-builder/components/sort-menu/sort-menu.component.ts +88 -0
- package/src/table-builder/components/table-container/table-container.component.html +94 -0
- package/src/table-builder/components/table-container/table-container.component.scss +60 -0
- package/src/table-builder/components/table-container/table-container.component.ts +467 -0
- package/src/table-builder/components/table-container/table-container.helpers/data-state.helpers.ts +113 -0
- package/src/table-builder/components/table-container/table-container.helpers/filter-state.helpers.ts +125 -0
- package/src/table-builder/components/table-container/table-container.helpers/groupBy.helpers.ts +172 -0
- package/src/table-builder/components/table-container/table-container.helpers/meta-data.helpers.ts +19 -0
- package/src/table-builder/components/table-container/table-container.helpers/sort-state.helpers.ts +47 -0
- package/src/table-builder/components/table-container/tableProps.ts +21 -0
- package/src/table-builder/components/table-container/virtual-scroll-container.ts +216 -0
- package/src/table-builder/components/table-container-filter/filter-list/filter-list.component.html +42 -0
- package/src/table-builder/components/table-container-filter/filter-list/filter-list.component.ts +47 -0
- package/src/table-builder/components/table-container-filter/gen-filter-displayer/gen-filter-displayer.component.css +40 -0
- package/src/table-builder/components/table-container-filter/gen-filter-displayer/gen-filter-displayer.component.html +11 -0
- package/src/table-builder/components/table-container-filter/gen-filter-displayer/gen-filter-displayer.component.spec.ts +85 -0
- package/src/table-builder/components/table-container-filter/gen-filter-displayer/gen-filter-displayer.component.ts +35 -0
- package/src/table-builder/components/table-container-filter/table-wrapper-filter-store.ts +13 -0
- package/src/table-builder/components/table-header-menu/table-header-menu.component.css +21 -0
- package/src/table-builder/components/table-header-menu/table-header-menu.component.html +48 -0
- package/src/table-builder/components/table-header-menu/table-header-menu.component.ts +36 -0
- package/src/table-builder/directives/custom-cell-directive.ts +63 -0
- package/src/table-builder/directives/custom-header-directive.ts +16 -0
- package/src/table-builder/directives/group-row-directive.ts +91 -0
- package/src/table-builder/directives/index.ts +8 -0
- package/src/table-builder/directives/multi-sort.directive.spec.ts +124 -0
- package/src/table-builder/directives/multi-sort.directive.ts +58 -0
- package/src/table-builder/directives/resize-column.directive.ts +107 -0
- package/src/table-builder/directives/table-wrapper.directive.ts +13 -0
- package/src/table-builder/directives/tb-filter.directive.ts +376 -0
- package/src/table-builder/documentation/table-builder/CUSTOM-CELL.md +568 -0
- package/src/table-builder/documentation/table-builder/CUSTOM-GROUP-ROW.md +356 -0
- package/src/table-builder/documentation/table-builder/METADATA-DOCUMENTATION.md +517 -0
- package/src/table-builder/documentation/table-builder/STYLER-STYLE.md +228 -0
- package/src/table-builder/documentation/table-builder/TABLE-BUILDER-CONFIG.md +325 -0
- package/src/table-builder/documentation/table-builder/TABLE-BUILDER-SETTINGS.md +515 -0
- package/src/table-builder/documentation/table-builder/TABLE-BUILDER.md +430 -0
- package/src/table-builder/documentation/table-builder/TABLE-CONTAINER.md +628 -0
- package/src/table-builder/enums/filterTypes.ts +39 -0
- package/src/table-builder/functions/boolean-filter-function.ts +12 -0
- package/src/table-builder/functions/date-filter-function.ts +85 -0
- package/src/table-builder/functions/download-data.ts +11 -0
- package/src/table-builder/functions/null-filter-function.ts +9 -0
- package/src/table-builder/functions/number-filter-function.ts +47 -0
- package/src/table-builder/functions/sort-data-function.ts +80 -0
- package/src/table-builder/functions/string-filter-function.ts +59 -0
- package/src/table-builder/interfaces/ColumnInfo.ts +9 -0
- package/src/table-builder/interfaces/dictionary.ts +3 -0
- package/src/table-builder/interfaces/meta-data.ts +279 -0
- package/src/table-builder/ngrx/tableBuilderStateStore.ts +203 -0
- package/src/table-builder/pipes/column-total.pipe.ts +16 -0
- package/src/table-builder/pipes/format-filter-type.pipe.ts +12 -0
- package/src/table-builder/pipes/format-filter-value.pipe.ts +71 -0
- package/src/table-builder/pipes/key-display.ts +13 -0
- package/src/table-builder/services/all-values-filter-creator.service.ts +92 -0
- package/src/table-builder/services/export-to-csv.service.ts +117 -0
- package/src/table-builder/services/link-creator.service.ts +98 -0
- package/src/table-builder/services/table-template-service.ts +47 -0
- package/src/table-builder/services/transform-creator.ts +90 -0
- package/src/table-builder/specs/table-custom-filters.spec.ts +262 -0
- package/src/table-builder/styles/collapser.styles.scss +16 -0
- package/src/table-builder/table-builder.module.ts +42 -0
- package/src/table-builder/types/group-types.ts +42 -0
- package/src/table-builder/types/index.ts +1 -0
- package/src/test.ts +17 -0
- package/src/utilities/array-helpers.ts +13 -0
- package/src/utilities/directives/auto-focus.directive.ts +20 -0
- package/src/utilities/directives/clickEmitterDirective.ts +15 -0
- package/src/utilities/directives/clickSubject.ts +19 -0
- package/src/utilities/directives/conditional-classes.directive.ts +36 -0
- package/src/utilities/directives/dialog-service.ts +19 -0
- package/src/utilities/directives/dialog.ts +174 -0
- package/src/utilities/directives/mat-toggle-group-directive.ts +60 -0
- package/src/utilities/directives/prevent-enter.directive.ts +12 -0
- package/src/utilities/directives/stop-propagation.directive.ts +19 -0
- package/src/utilities/directives/styler.ts +45 -0
- package/src/utilities/directives/trim-whitespace.directive.ts +20 -0
- package/src/utilities/index.ts +22 -0
- package/src/utilities/module.ts +53 -0
- package/src/utilities/pipes/function.pipe.ts +21 -0
- package/src/utilities/pipes/phone.pipe.ts +20 -0
- package/src/utilities/pipes/space-case.pipes.spec.ts +47 -0
- package/src/utilities/pipes/space-case.pipes.ts +29 -0
- package/tsconfig.lib.json +20 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +17 -0
- package/fesm2022/one-paragon-angular-utilities.mjs +0 -7328
- package/fesm2022/one-paragon-angular-utilities.mjs.map +0 -1
- package/types/one-paragon-angular-utilities.d.ts +0 -2197
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
# StylerStyle Documentation
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
`StylerStyle<T>` is a flexible type for applying dynamic inline CSS styles based on row data. It allows you to conditionally apply styles to table cells, rows, or column parts.
|
|
6
|
+
|
|
7
|
+
## Type Definition
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
type StylerStyle<T = any> = Dictionary<
|
|
11
|
+
string | {
|
|
12
|
+
condition?: ((t: T) => boolean) | true,
|
|
13
|
+
value: ((t: T) => string) | string
|
|
14
|
+
}
|
|
15
|
+
>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Where `Dictionary<T>` is equivalent to `{ [key: string]: T }`.
|
|
19
|
+
|
|
20
|
+
## Usage Patterns
|
|
21
|
+
|
|
22
|
+
### Simple Static Styles
|
|
23
|
+
|
|
24
|
+
Apply a static CSS value directly:
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
const styles: StylerStyle = {
|
|
28
|
+
'color': 'red',
|
|
29
|
+
'font-weight': 'bold',
|
|
30
|
+
'background-color': '#f0f0f0'
|
|
31
|
+
};
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Dynamic Styles Based on Data
|
|
35
|
+
|
|
36
|
+
Compute style values from the row data:
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
const styles: StylerStyle<User> = {
|
|
40
|
+
'color': (user) => user.isActive ? 'green' : 'gray',
|
|
41
|
+
'font-size': (user) => user.isPriority ? '16px' : '14px',
|
|
42
|
+
'opacity': (user) => user.status === 'archived' ? '0.5' : '1'
|
|
43
|
+
};
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Conditional Styles with Static Values
|
|
47
|
+
|
|
48
|
+
Apply a static style only when a condition is met:
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
const styles: StylerStyle<User> = {
|
|
52
|
+
'background-color': {
|
|
53
|
+
condition: (user) => user.isWarning,
|
|
54
|
+
value: '#fff3cd'
|
|
55
|
+
},
|
|
56
|
+
'border-left': {
|
|
57
|
+
condition: (user) => user.isPriority,
|
|
58
|
+
value: '4px solid #dc3545'
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Conditional Styles with Dynamic Values
|
|
64
|
+
|
|
65
|
+
Apply a computed style only when a condition is met:
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
const styles: StylerStyle<User> = {
|
|
69
|
+
'background-color': {
|
|
70
|
+
condition: (user) => user.score !== null,
|
|
71
|
+
value: (user) => user.score > 80 ? '#d4edda' : '#f8d7da'
|
|
72
|
+
},
|
|
73
|
+
'font-weight': {
|
|
74
|
+
condition: (user) => user.role === 'admin',
|
|
75
|
+
value: (user) => user.isActive ? 'bold' : 'normal'
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Always-Applied Conditional Styles
|
|
81
|
+
|
|
82
|
+
Use `condition: true` to always evaluate the value function:
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
const styles: StylerStyle<User> = {
|
|
86
|
+
'color': {
|
|
87
|
+
condition: true,
|
|
88
|
+
value: (user) => {
|
|
89
|
+
if (user.status === 'error') return '#dc3545';
|
|
90
|
+
if (user.status === 'warning') return '#ffc107';
|
|
91
|
+
if (user.status === 'success') return '#28a745';
|
|
92
|
+
return 'inherit';
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Common Use Cases
|
|
99
|
+
|
|
100
|
+
### Row-Level Styling
|
|
101
|
+
|
|
102
|
+
Apply styles to entire table rows based on row data:
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
tableSettings: {
|
|
106
|
+
rowStyles: {
|
|
107
|
+
'background-color': (row) => row.isSelected ? '#e3f2fd' : 'transparent',
|
|
108
|
+
'opacity': (row) => row.isDeleted ? '0.5' : '1',
|
|
109
|
+
'cursor': 'pointer'
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Cell-Level Styling
|
|
115
|
+
|
|
116
|
+
Apply styles to individual cells in a column:
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
{
|
|
120
|
+
key: 'amount',
|
|
121
|
+
fieldType: FieldType.Currency,
|
|
122
|
+
additional: {
|
|
123
|
+
styles: {
|
|
124
|
+
'color': (row) => row.amount < 0 ? 'red' : 'green',
|
|
125
|
+
'font-weight': (row) => Math.abs(row.amount) > 1000 ? 'bold' : 'normal'
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Column Part Styling
|
|
132
|
+
|
|
133
|
+
Apply styles to specific parts of a column:
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
{
|
|
137
|
+
key: 'status',
|
|
138
|
+
fieldType: FieldType.String,
|
|
139
|
+
additional: {
|
|
140
|
+
columnPartStyles: {
|
|
141
|
+
header: {
|
|
142
|
+
'background-color': '#f5f5f5',
|
|
143
|
+
'font-weight': 'bold'
|
|
144
|
+
},
|
|
145
|
+
body: (row) => ({
|
|
146
|
+
'color': row.status === 'active' ? 'green' : 'red',
|
|
147
|
+
'text-transform': 'uppercase'
|
|
148
|
+
}),
|
|
149
|
+
footer: {
|
|
150
|
+
'background-color': '#e0e0e0',
|
|
151
|
+
'font-style': 'italic'
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Complex Conditional Logic
|
|
159
|
+
|
|
160
|
+
Combine multiple conditions for sophisticated styling:
|
|
161
|
+
|
|
162
|
+
```typescript
|
|
163
|
+
const styles: StylerStyle<Order> = {
|
|
164
|
+
'background-color': {
|
|
165
|
+
condition: (order) => order.isPriority || order.isUrgent,
|
|
166
|
+
value: (order) => {
|
|
167
|
+
if (order.isUrgent) return '#ffebee';
|
|
168
|
+
if (order.isPriority) return '#fff9c4';
|
|
169
|
+
return 'transparent';
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
'border-left': {
|
|
173
|
+
condition: (order) => order.daysOverdue > 0,
|
|
174
|
+
value: (order) => {
|
|
175
|
+
const width = Math.min(order.daysOverdue, 5);
|
|
176
|
+
return `${width}px solid #f44336`;
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
'font-weight': {
|
|
180
|
+
condition: (order) => order.value > 10000,
|
|
181
|
+
value: 'bold'
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Style Properties
|
|
187
|
+
|
|
188
|
+
Any valid CSS property can be used as a key. Common properties include:
|
|
189
|
+
|
|
190
|
+
- **Colors**: `color`, `background-color`, `border-color`
|
|
191
|
+
- **Typography**: `font-size`, `font-weight`, `font-style`, `text-align`, `text-transform`
|
|
192
|
+
- **Spacing**: `padding`, `margin`, `padding-left`, `margin-top`
|
|
193
|
+
- **Borders**: `border`, `border-left`, `border-width`, `border-style`
|
|
194
|
+
- **Layout**: `display`, `width`, `height`, `min-width`, `max-width`
|
|
195
|
+
- **Visual Effects**: `opacity`, `box-shadow`, `transform`
|
|
196
|
+
- **Interaction**: `cursor`, `pointer-events`
|
|
197
|
+
|
|
198
|
+
**Note**: Use camelCase for multi-word CSS properties (e.g., `backgroundColor`) or string literals (e.g., `'background-color'`).
|
|
199
|
+
|
|
200
|
+
## Performance Considerations
|
|
201
|
+
|
|
202
|
+
- **Memoization**: Style functions are evaluated on every change detection cycle. Keep them simple and avoid expensive computations.
|
|
203
|
+
- **Condition First**: When using the object form, the `condition` is evaluated before the `value`, allowing you to skip expensive value calculations when not needed.
|
|
204
|
+
- **Static Styles**: Prefer static string values when styles don't depend on data.
|
|
205
|
+
|
|
206
|
+
## Type Safety
|
|
207
|
+
|
|
208
|
+
When using TypeScript, the generic type `T` provides type safety for your row data:
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
interface Product {
|
|
212
|
+
id: number;
|
|
213
|
+
name: string;
|
|
214
|
+
stock: number;
|
|
215
|
+
price: number;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const productStyles: StylerStyle<Product> = {
|
|
219
|
+
'color': (product) => product.stock < 10 ? 'red' : 'black',
|
|
220
|
+
// TypeScript will provide autocomplete for 'product' properties
|
|
221
|
+
'font-weight': (product) => product.price > 100 ? 'bold' : 'normal'
|
|
222
|
+
};
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## Related Documentation
|
|
226
|
+
|
|
227
|
+
- [MetaData Configuration](./METADATA-DOCUMENTATION.md#styling-configuration) - How to use `StylerStyle` with column metadata
|
|
228
|
+
- [Table Builder Settings](./TABLE-BUILDER-SETTINGS.md#table-settings) - How to use `StylerStyle` for row-level styling
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
# TableBuilderConfig Documentation
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
`TableBuilderConfig` allows you to set global default settings for all Table Builder instances in your application. These defaults can be overridden at the component level when needed.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
### Global Configuration (Application-Wide)
|
|
10
|
+
|
|
11
|
+
Use `provideTableBuilder` in your application configuration to set defaults for all tables:
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
// In app.config.ts or main.ts
|
|
15
|
+
import { ApplicationConfig } from '@angular/core';
|
|
16
|
+
import { provideTableBuilder } from 'angular-utilities';
|
|
17
|
+
|
|
18
|
+
export const appConfig: ApplicationConfig = {
|
|
19
|
+
providers: [
|
|
20
|
+
provideTableBuilder({
|
|
21
|
+
defaultTableSettings: {
|
|
22
|
+
pageSize: 25,
|
|
23
|
+
headerSettings: {
|
|
24
|
+
showTitleWhenCollapsed: true
|
|
25
|
+
},
|
|
26
|
+
tableSettings: {
|
|
27
|
+
usePaginator: true,
|
|
28
|
+
exportSettings: {
|
|
29
|
+
dateFormat: 'MM/dd/yyyy',
|
|
30
|
+
mapEnumToString: true
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
dateFormats: {
|
|
35
|
+
dateFormat: 'MM/dd/yyyy',
|
|
36
|
+
dateTimeFormat: 'MM/dd/yyyy HH:mm:ss'
|
|
37
|
+
},
|
|
38
|
+
arrayDefaults: {
|
|
39
|
+
limit: 5,
|
|
40
|
+
arrayStyle: ArrayStyle.CommaDelimited
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
]
|
|
44
|
+
};
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Component-Level Configuration
|
|
48
|
+
|
|
49
|
+
You can also provide `TableBuilderConfig` at the component level to set defaults for tables within that component and its children:
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import { Component } from '@angular/core';
|
|
53
|
+
import { provideTableBuilder } from 'angular-utilities';
|
|
54
|
+
|
|
55
|
+
@Component({
|
|
56
|
+
selector: 'app-users-table',
|
|
57
|
+
template: `...`,
|
|
58
|
+
providers: [
|
|
59
|
+
provideTableBuilder({
|
|
60
|
+
defaultTableSettings: {
|
|
61
|
+
pageSize: 50,
|
|
62
|
+
tableSettings: {
|
|
63
|
+
includeSelectionColumn: true
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
]
|
|
68
|
+
})
|
|
69
|
+
export class UsersTableComponent { }
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## TableBuilderConfig Properties
|
|
75
|
+
|
|
76
|
+
### `defaultTableSettings`
|
|
77
|
+
|
|
78
|
+
- **Type**: `Partial<TableBuilderSettings> & { pageSize?: number }`
|
|
79
|
+
- **Description**: Default settings that will be applied to all tables. These can be overridden at the individual table level.
|
|
80
|
+
- **See**: [TableBuilderSettings Documentation](./TABLE-BUILDER-SETTINGS.md) for detailed information about all available settings.
|
|
81
|
+
|
|
82
|
+
**Example**:
|
|
83
|
+
```typescript
|
|
84
|
+
defaultTableSettings: {
|
|
85
|
+
pageSize: 25,
|
|
86
|
+
headerSettings: {
|
|
87
|
+
hideExport: false,
|
|
88
|
+
showTitleWhenCollapsed: true
|
|
89
|
+
},
|
|
90
|
+
columnHeaderSettings: {
|
|
91
|
+
stickyHeaderRow: true
|
|
92
|
+
},
|
|
93
|
+
tableSettings: {
|
|
94
|
+
usePaginator: true,
|
|
95
|
+
useVirtualScroll: false,
|
|
96
|
+
trackBy: 'id'
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### `export` ⚠️ **Deprecated**
|
|
102
|
+
|
|
103
|
+
- **Type**: `TableBuilderExport | undefined`
|
|
104
|
+
- **Deprecated**: Use `defaultTableSettings.tableSettings.exportSettings` instead.
|
|
105
|
+
- **Description**: Legacy global export settings.
|
|
106
|
+
- **See**: [MetaData Documentation - Export Configuration](./METADATA-DOCUMENTATION.md#export-configuration) for details on export options.
|
|
107
|
+
|
|
108
|
+
### `dateFormats`
|
|
109
|
+
|
|
110
|
+
- **Type**: `DefaultSettings | undefined`
|
|
111
|
+
- **Description**: Default date and datetime formats applied to all Date and DateTime columns unless overridden at the column level.
|
|
112
|
+
|
|
113
|
+
**Interface**:
|
|
114
|
+
```typescript
|
|
115
|
+
interface DefaultSettings {
|
|
116
|
+
dateFormat?: string;
|
|
117
|
+
dateTimeFormat?: string;
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**Properties**:
|
|
122
|
+
- **`dateFormat`**: Default format for `FieldType.Date` columns (e.g., `'MM/dd/yyyy'`)
|
|
123
|
+
- **`dateTimeFormat`**: Default format for `FieldType.DateTime` columns (e.g., `'MM/dd/yyyy HH:mm:ss'`)
|
|
124
|
+
|
|
125
|
+
**Example**:
|
|
126
|
+
```typescript
|
|
127
|
+
dateFormats: {
|
|
128
|
+
dateFormat: 'dd/MM/yyyy',
|
|
129
|
+
dateTimeFormat: 'dd/MM/yyyy HH:mm:ss'
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### `arrayDefaults`
|
|
134
|
+
|
|
135
|
+
- **Type**: `ArrayAdditional | undefined`
|
|
136
|
+
- **Description**: Default settings for how array-type columns are displayed.
|
|
137
|
+
- **See**: [MetaData Documentation - Array Types](./METADATA-DOCUMENTATION.md#array-types) for more details on array configuration.
|
|
138
|
+
|
|
139
|
+
**Properties**:
|
|
140
|
+
- **`limit`**: Maximum number of array items to display (default: `3`)
|
|
141
|
+
- **`arrayStyle`**: How to display array items
|
|
142
|
+
- `ArrayStyle.CommaDelimited` (default): Items separated by commas
|
|
143
|
+
- `ArrayStyle.NewLine`: Each item on a new line
|
|
144
|
+
|
|
145
|
+
**Example**:
|
|
146
|
+
```typescript
|
|
147
|
+
arrayDefaults: {
|
|
148
|
+
limit: 5,
|
|
149
|
+
arrayStyle: ArrayStyle.NewLine
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### `transformers`
|
|
154
|
+
|
|
155
|
+
- **Type**: `Partial<{ [key in keyof typeof FieldType]: (val: any) => any }> | undefined`
|
|
156
|
+
- **Description**: Global transformation functions for specific field types. These are applied to values before display, allowing you to customize how data is rendered for each field type across all tables.
|
|
157
|
+
|
|
158
|
+
**Example**:
|
|
159
|
+
```typescript
|
|
160
|
+
transformers: {
|
|
161
|
+
[FieldType.Currency]: (val: number) => {
|
|
162
|
+
// Add custom currency symbol
|
|
163
|
+
return val != null ? `$${val.toFixed(2)}` : '';
|
|
164
|
+
},
|
|
165
|
+
[FieldType.PhoneNumber]: (val: string) => {
|
|
166
|
+
// Format phone numbers
|
|
167
|
+
if (!val) return '';
|
|
168
|
+
const cleaned = val.replace(/\D/g, '');
|
|
169
|
+
return `(${cleaned.slice(0, 3)}) ${cleaned.slice(3, 6)}-${cleaned.slice(6)}`;
|
|
170
|
+
},
|
|
171
|
+
[FieldType.Boolean]: (val: boolean) => {
|
|
172
|
+
return val ? 'Yes' : 'No';
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
**Available FieldTypes**:
|
|
178
|
+
- `FieldType.String`
|
|
179
|
+
- `FieldType.Number`
|
|
180
|
+
- `FieldType.Boolean`
|
|
181
|
+
- `FieldType.Date`
|
|
182
|
+
- `FieldType.DateTime`
|
|
183
|
+
- `FieldType.Currency`
|
|
184
|
+
- `FieldType.PhoneNumber`
|
|
185
|
+
- `FieldType.Enum`
|
|
186
|
+
- `FieldType.Array`
|
|
187
|
+
- `FieldType.ImageUrl`
|
|
188
|
+
- And more...
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## Configuration Precedence
|
|
193
|
+
|
|
194
|
+
Settings are applied in the following order (later sources override earlier ones):
|
|
195
|
+
|
|
196
|
+
1. **Global Config** (via `provideTableBuilder` at app level)
|
|
197
|
+
2. **Component Config** (via `provideTableBuilder` in component providers)
|
|
198
|
+
3. **Table-Specific Settings** (passed directly to the table component)
|
|
199
|
+
4. **Column-Specific Settings** (defined in MetaData for individual columns)
|
|
200
|
+
|
|
201
|
+
**Example**:
|
|
202
|
+
```typescript
|
|
203
|
+
// 1. Global default (applies to all tables)
|
|
204
|
+
provideTableBuilder({
|
|
205
|
+
defaultTableSettings: { pageSize: 10 }
|
|
206
|
+
})
|
|
207
|
+
|
|
208
|
+
// 2. Component-level default (applies to tables in this component)
|
|
209
|
+
@Component({
|
|
210
|
+
providers: [
|
|
211
|
+
provideTableBuilder({
|
|
212
|
+
defaultTableSettings: { pageSize: 25 } // Overrides global
|
|
213
|
+
})
|
|
214
|
+
]
|
|
215
|
+
})
|
|
216
|
+
|
|
217
|
+
// 3. Table-specific setting
|
|
218
|
+
const tableSettings: TableBuilderSettings = {
|
|
219
|
+
tableSettings: {
|
|
220
|
+
paginatorSettings: { pageSize: 50 } // Overrides component-level
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## Default Configuration
|
|
228
|
+
|
|
229
|
+
If no configuration is provided, Table Builder uses these defaults:
|
|
230
|
+
|
|
231
|
+
```typescript
|
|
232
|
+
const defaultConfig: TableBuilderConfig = {
|
|
233
|
+
defaultTableSettings: {
|
|
234
|
+
pageSize: 10
|
|
235
|
+
},
|
|
236
|
+
arrayDefaults: {
|
|
237
|
+
limit: 3,
|
|
238
|
+
arrayStyle: ArrayStyle.CommaDelimited
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## Complete Example
|
|
246
|
+
|
|
247
|
+
```typescript
|
|
248
|
+
import { ApplicationConfig } from '@angular/core';
|
|
249
|
+
import { provideTableBuilder, ArrayStyle, FieldType } from 'angular-utilities';
|
|
250
|
+
|
|
251
|
+
export const appConfig: ApplicationConfig = {
|
|
252
|
+
providers: [
|
|
253
|
+
provideTableBuilder({
|
|
254
|
+
// Default table settings applied to all tables
|
|
255
|
+
defaultTableSettings: {
|
|
256
|
+
pageSize: 25,
|
|
257
|
+
|
|
258
|
+
headerSettings: {
|
|
259
|
+
showTitleWhenCollapsed: true,
|
|
260
|
+
hideExport: false
|
|
261
|
+
},
|
|
262
|
+
|
|
263
|
+
columnHeaderSettings: {
|
|
264
|
+
stickyHeaderRow: true,
|
|
265
|
+
noFilters: false
|
|
266
|
+
},
|
|
267
|
+
|
|
268
|
+
tableSettings: {
|
|
269
|
+
usePaginator: true,
|
|
270
|
+
useVirtualScroll: false,
|
|
271
|
+
trackBy: 'id',
|
|
272
|
+
|
|
273
|
+
exportSettings: {
|
|
274
|
+
dateFormat: 'MM/dd/yyyy',
|
|
275
|
+
dateTimeFormat: 'MM/dd/yyyy HH:mm:ss',
|
|
276
|
+
mapEnumToString: true,
|
|
277
|
+
mapLink: 'as view'
|
|
278
|
+
},
|
|
279
|
+
|
|
280
|
+
rowClasses: {
|
|
281
|
+
'hover-highlight': true
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
|
|
286
|
+
// Global date formats
|
|
287
|
+
dateFormats: {
|
|
288
|
+
dateFormat: 'MM/dd/yyyy',
|
|
289
|
+
dateTimeFormat: 'MM/dd/yyyy HH:mm:ss'
|
|
290
|
+
},
|
|
291
|
+
|
|
292
|
+
// Array display defaults
|
|
293
|
+
arrayDefaults: {
|
|
294
|
+
limit: 5,
|
|
295
|
+
arrayStyle: ArrayStyle.CommaDelimited
|
|
296
|
+
},
|
|
297
|
+
|
|
298
|
+
// Global transformers for field types
|
|
299
|
+
transformers: {
|
|
300
|
+
[FieldType.Currency]: (val: number) =>
|
|
301
|
+
val != null ? `$${val.toLocaleString('en-US', { minimumFractionDigits: 2 })}` : '',
|
|
302
|
+
|
|
303
|
+
[FieldType.PhoneNumber]: (val: string) => {
|
|
304
|
+
if (!val) return '';
|
|
305
|
+
const cleaned = val.replace(/\D/g, '');
|
|
306
|
+
if (cleaned.length === 10) {
|
|
307
|
+
return `(${cleaned.slice(0, 3)}) ${cleaned.slice(3, 6)}-${cleaned.slice(6)}`;
|
|
308
|
+
}
|
|
309
|
+
return val;
|
|
310
|
+
},
|
|
311
|
+
|
|
312
|
+
[FieldType.Boolean]: (val: boolean) => val ? '✓' : '✗'
|
|
313
|
+
}
|
|
314
|
+
})
|
|
315
|
+
]
|
|
316
|
+
};
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
---
|
|
320
|
+
|
|
321
|
+
## Related Documentation
|
|
322
|
+
|
|
323
|
+
- [TableBuilderSettings Documentation](./TABLE-BUILDER-SETTINGS.md) - Detailed documentation for all table settings
|
|
324
|
+
- [MetaData Documentation](./METADATA-DOCUMENTATION.md) - Column configuration options
|
|
325
|
+
- [StylerStyle Documentation](./STYLER-STYLE.md) - Dynamic styling patterns
|