@one-paragon/angular-utilities 2.8.4 → 2.8.5

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 (203) hide show
  1. package/fesm2022/one-paragon-angular-utilities.mjs +7350 -0
  2. package/fesm2022/one-paragon-angular-utilities.mjs.map +1 -0
  3. package/package.json +27 -15
  4. package/types/one-paragon-angular-utilities.d.ts +2211 -0
  5. package/karma.conf.js +0 -43
  6. package/ng-package.json +0 -7
  7. package/src/action-state/action-state-spinner/action-state-spinner.component.css +0 -16
  8. package/src/action-state/action-state-spinner/action-state-spinner.component.html +0 -7
  9. package/src/action-state/action-state-spinner/action-state-spinner.component.spec.ts +0 -25
  10. package/src/action-state/action-state-spinner/action-state-spinner.component.ts +0 -26
  11. package/src/action-state/action-state-ui/action-state-ui.module.ts +0 -13
  12. package/src/action-state/index.ts +0 -8
  13. package/src/action-state/ngrx-ext/ngrx-ext.module.ts +0 -14
  14. package/src/action-state/ngrx.ts +0 -69
  15. package/src/http-request-state/RequestStateFactory.ts +0 -56
  16. package/src/http-request-state/RequestStateStore.ts +0 -360
  17. package/src/http-request-state/deprecated.ts +0 -20
  18. package/src/http-request-state/directives/HttpStateDirectiveBase.ts +0 -29
  19. package/src/http-request-state/directives/http-error-state-directive.ts +0 -21
  20. package/src/http-request-state/directives/http-inProgress-state-directive.ts +0 -19
  21. package/src/http-request-state/directives/http-notStarted-state-directive.ts +0 -19
  22. package/src/http-request-state/directives/http-success-state-directive.ts +0 -29
  23. package/src/http-request-state/directives/index.ts +0 -5
  24. package/src/http-request-state/directives/request-state-directive.spec.ts +0 -73
  25. package/src/http-request-state/directives/request-state-directive.ts +0 -78
  26. package/src/http-request-state/documentation/CREATE-REQUESTOR.md +0 -667
  27. package/src/http-request-state/documentation/README.md +0 -191
  28. package/src/http-request-state/documentation/REQUEST-STATE-STORE-CONFIG.md +0 -648
  29. package/src/http-request-state/documentation/REQUESTOR.md +0 -616
  30. package/src/http-request-state/helpers.ts +0 -30
  31. package/src/http-request-state/http-state-module.ts +0 -23
  32. package/src/http-request-state/index.ts +0 -7
  33. package/src/http-request-state/models/view-context.ts +0 -18
  34. package/src/http-request-state/observable.spec.ts +0 -43
  35. package/src/http-request-state/request-state.ts +0 -66
  36. package/src/http-request-state/rxjs/getRequestorBody.ts +0 -10
  37. package/src/http-request-state/rxjs/getRequestorState.ts +0 -8
  38. package/src/http-request-state/rxjs/index.ts +0 -4
  39. package/src/http-request-state/rxjs/tapError.ts +0 -16
  40. package/src/http-request-state/rxjs/tapSuccess.ts +0 -16
  41. package/src/http-request-state/strategies.spec.ts +0 -42
  42. package/src/http-request-state/types.ts +0 -54
  43. package/src/ngrx/actionable-selector.ts +0 -189
  44. package/src/ngrx/index.ts +0 -1
  45. package/src/public-api.ts +0 -40
  46. package/src/rxjs/defaultShareReplay.ts +0 -8
  47. package/src/rxjs/index.ts +0 -5
  48. package/src/rxjs/mapError.ts +0 -8
  49. package/src/rxjs/rxjs-operators.ts +0 -130
  50. package/src/rxjs/subjectifier.ts +0 -17
  51. package/src/rxjs/subscriber.directive.ts +0 -57
  52. package/src/specs/clickSubject.spec.ts +0 -99
  53. package/src/specs/dialog.spec.ts +0 -101
  54. package/src/specs/toggleGroupDirective.spec.ts +0 -229
  55. package/src/table-builder/classes/DefaultSettings.ts +0 -11
  56. package/src/table-builder/classes/MatTableObservableDataSource.ts +0 -23
  57. package/src/table-builder/classes/TableBuilderConfig.ts +0 -49
  58. package/src/table-builder/classes/TableBuilderDataSource.ts +0 -64
  59. package/src/table-builder/classes/TableState.ts +0 -96
  60. package/src/table-builder/classes/data-store.ts +0 -10
  61. package/src/table-builder/classes/display-col.ts +0 -5
  62. package/src/table-builder/classes/filter-info.ts +0 -129
  63. package/src/table-builder/classes/table-builder-general-settings.ts +0 -233
  64. package/src/table-builder/classes/table-builder.ts +0 -105
  65. package/src/table-builder/classes/table-store.helpers.ts +0 -109
  66. package/src/table-builder/classes/table-store.ts +0 -540
  67. package/src/table-builder/components/array-column.component.ts +0 -34
  68. package/src/table-builder/components/column-builder/column-builder.component.html +0 -109
  69. package/src/table-builder/components/column-builder/column-builder.component.scss +0 -43
  70. package/src/table-builder/components/column-builder/column-builder.component.spec.ts +0 -49
  71. package/src/table-builder/components/column-builder/column-builder.component.ts +0 -130
  72. package/src/table-builder/components/column-builder/column-helpers.ts +0 -54
  73. package/src/table-builder/components/column-header-menu/column-header-menu.component.html +0 -128
  74. package/src/table-builder/components/column-header-menu/column-header-menu.component.scss +0 -97
  75. package/src/table-builder/components/column-header-menu/column-header-menu.component.ts +0 -113
  76. package/src/table-builder/components/date-filter/date-filter.component.html +0 -39
  77. package/src/table-builder/components/date-filter/date-filter.component.ts +0 -33
  78. package/src/table-builder/components/date-time-filter/date-time-filter.component.html +0 -25
  79. package/src/table-builder/components/date-time-filter/date-time-filter.component.ts +0 -33
  80. package/src/table-builder/components/filter/filter.component.html +0 -120
  81. package/src/table-builder/components/filter/filter.component.scss +0 -60
  82. package/src/table-builder/components/filter/filter.component.spec.ts +0 -86
  83. package/src/table-builder/components/filter/filter.component.ts +0 -73
  84. package/src/table-builder/components/filter/in-list/in-list-filter.component.ts +0 -171
  85. package/src/table-builder/components/gen-col-displayer/gen-col-displayer.component.html +0 -60
  86. package/src/table-builder/components/gen-col-displayer/gen-col-displayer.component.scss +0 -57
  87. package/src/table-builder/components/gen-col-displayer/gen-col-displayer.component.ts +0 -44
  88. package/src/table-builder/components/generic-table/generic-table.component.html +0 -140
  89. package/src/table-builder/components/generic-table/generic-table.component.scss +0 -45
  90. package/src/table-builder/components/generic-table/generic-table.component.ts +0 -531
  91. package/src/table-builder/components/generic-table/paginator.component.ts +0 -125
  92. package/src/table-builder/components/group-by-list/group-by-list.component.css +0 -24
  93. package/src/table-builder/components/group-by-list/group-by-list.component.html +0 -21
  94. package/src/table-builder/components/group-by-list/group-by-list.component.spec.ts +0 -23
  95. package/src/table-builder/components/group-by-list/group-by-list.component.ts +0 -26
  96. package/src/table-builder/components/in-filter/in-filter.component.css +0 -22
  97. package/src/table-builder/components/in-filter/in-filter.component.html +0 -38
  98. package/src/table-builder/components/in-filter/in-filter.component.ts +0 -66
  99. package/src/table-builder/components/index.ts +0 -9
  100. package/src/table-builder/components/initialization-component/initialization.component.html +0 -78
  101. package/src/table-builder/components/initialization-component/initialization.component.ts +0 -28
  102. package/src/table-builder/components/link-column.component.ts +0 -42
  103. package/src/table-builder/components/number-filter/number-filter.component.css +0 -10
  104. package/src/table-builder/components/number-filter/number-filter.component.html +0 -32
  105. package/src/table-builder/components/number-filter/number-filter.component.spec.ts +0 -30
  106. package/src/table-builder/components/number-filter/number-filter.component.ts +0 -34
  107. package/src/table-builder/components/profiles-menu/profiles-menu.component.html +0 -77
  108. package/src/table-builder/components/profiles-menu/profiles-menu.component.scss +0 -126
  109. package/src/table-builder/components/profiles-menu/profiles-menu.component.spec.ts +0 -23
  110. package/src/table-builder/components/profiles-menu/profiles-menu.component.ts +0 -64
  111. package/src/table-builder/components/reset-menu/reset-menu.component.css +0 -3
  112. package/src/table-builder/components/reset-menu/reset-menu.component.html +0 -10
  113. package/src/table-builder/components/reset-menu/reset-menu.component.ts +0 -87
  114. package/src/table-builder/components/scroll-strategy.ts +0 -139
  115. package/src/table-builder/components/sort-menu/sort-menu.component-store.ts +0 -57
  116. package/src/table-builder/components/sort-menu/sort-menu.component.html +0 -115
  117. package/src/table-builder/components/sort-menu/sort-menu.component.scss +0 -119
  118. package/src/table-builder/components/sort-menu/sort-menu.component.ts +0 -88
  119. package/src/table-builder/components/table-container/table-container.component.html +0 -94
  120. package/src/table-builder/components/table-container/table-container.component.scss +0 -60
  121. package/src/table-builder/components/table-container/table-container.component.ts +0 -467
  122. package/src/table-builder/components/table-container/table-container.helpers/data-state.helpers.ts +0 -113
  123. package/src/table-builder/components/table-container/table-container.helpers/filter-state.helpers.ts +0 -125
  124. package/src/table-builder/components/table-container/table-container.helpers/groupBy.helpers.ts +0 -172
  125. package/src/table-builder/components/table-container/table-container.helpers/meta-data.helpers.ts +0 -19
  126. package/src/table-builder/components/table-container/table-container.helpers/sort-state.helpers.ts +0 -47
  127. package/src/table-builder/components/table-container/tableProps.ts +0 -21
  128. package/src/table-builder/components/table-container/virtual-scroll-container.ts +0 -216
  129. package/src/table-builder/components/table-container-filter/filter-list/filter-list.component.html +0 -42
  130. package/src/table-builder/components/table-container-filter/filter-list/filter-list.component.ts +0 -47
  131. package/src/table-builder/components/table-container-filter/gen-filter-displayer/gen-filter-displayer.component.css +0 -40
  132. package/src/table-builder/components/table-container-filter/gen-filter-displayer/gen-filter-displayer.component.html +0 -11
  133. package/src/table-builder/components/table-container-filter/gen-filter-displayer/gen-filter-displayer.component.spec.ts +0 -85
  134. package/src/table-builder/components/table-container-filter/gen-filter-displayer/gen-filter-displayer.component.ts +0 -35
  135. package/src/table-builder/components/table-container-filter/table-wrapper-filter-store.ts +0 -13
  136. package/src/table-builder/components/table-header-menu/table-header-menu.component.css +0 -21
  137. package/src/table-builder/components/table-header-menu/table-header-menu.component.html +0 -48
  138. package/src/table-builder/components/table-header-menu/table-header-menu.component.ts +0 -36
  139. package/src/table-builder/directives/custom-cell-directive.ts +0 -63
  140. package/src/table-builder/directives/custom-header-directive.ts +0 -16
  141. package/src/table-builder/directives/group-row-directive.ts +0 -91
  142. package/src/table-builder/directives/index.ts +0 -8
  143. package/src/table-builder/directives/multi-sort.directive.spec.ts +0 -124
  144. package/src/table-builder/directives/multi-sort.directive.ts +0 -58
  145. package/src/table-builder/directives/resize-column.directive.ts +0 -107
  146. package/src/table-builder/directives/table-wrapper.directive.ts +0 -13
  147. package/src/table-builder/directives/tb-filter.directive.ts +0 -376
  148. package/src/table-builder/documentation/table-builder/CUSTOM-CELL.md +0 -568
  149. package/src/table-builder/documentation/table-builder/CUSTOM-GROUP-ROW.md +0 -356
  150. package/src/table-builder/documentation/table-builder/METADATA-DOCUMENTATION.md +0 -517
  151. package/src/table-builder/documentation/table-builder/STYLER-STYLE.md +0 -228
  152. package/src/table-builder/documentation/table-builder/TABLE-BUILDER-CONFIG.md +0 -325
  153. package/src/table-builder/documentation/table-builder/TABLE-BUILDER-SETTINGS.md +0 -515
  154. package/src/table-builder/documentation/table-builder/TABLE-BUILDER.md +0 -430
  155. package/src/table-builder/documentation/table-builder/TABLE-CONTAINER.md +0 -628
  156. package/src/table-builder/enums/filterTypes.ts +0 -39
  157. package/src/table-builder/functions/boolean-filter-function.ts +0 -12
  158. package/src/table-builder/functions/date-filter-function.ts +0 -85
  159. package/src/table-builder/functions/download-data.ts +0 -11
  160. package/src/table-builder/functions/null-filter-function.ts +0 -9
  161. package/src/table-builder/functions/number-filter-function.ts +0 -47
  162. package/src/table-builder/functions/sort-data-function.ts +0 -80
  163. package/src/table-builder/functions/string-filter-function.ts +0 -59
  164. package/src/table-builder/interfaces/ColumnInfo.ts +0 -9
  165. package/src/table-builder/interfaces/dictionary.ts +0 -3
  166. package/src/table-builder/interfaces/meta-data.ts +0 -279
  167. package/src/table-builder/ngrx/tableBuilderStateStore.ts +0 -203
  168. package/src/table-builder/pipes/column-total.pipe.ts +0 -16
  169. package/src/table-builder/pipes/format-filter-type.pipe.ts +0 -12
  170. package/src/table-builder/pipes/format-filter-value.pipe.ts +0 -71
  171. package/src/table-builder/pipes/key-display.ts +0 -13
  172. package/src/table-builder/services/all-values-filter-creator.service.ts +0 -92
  173. package/src/table-builder/services/export-to-csv.service.ts +0 -117
  174. package/src/table-builder/services/link-creator.service.ts +0 -98
  175. package/src/table-builder/services/table-template-service.ts +0 -47
  176. package/src/table-builder/services/transform-creator.ts +0 -90
  177. package/src/table-builder/specs/table-custom-filters.spec.ts +0 -262
  178. package/src/table-builder/styles/collapser.styles.scss +0 -16
  179. package/src/table-builder/table-builder.module.ts +0 -42
  180. package/src/table-builder/types/group-types.ts +0 -42
  181. package/src/table-builder/types/index.ts +0 -1
  182. package/src/test.ts +0 -17
  183. package/src/utilities/array-helpers.ts +0 -13
  184. package/src/utilities/directives/auto-focus.directive.ts +0 -20
  185. package/src/utilities/directives/clickEmitterDirective.ts +0 -15
  186. package/src/utilities/directives/clickSubject.ts +0 -19
  187. package/src/utilities/directives/conditional-classes.directive.ts +0 -36
  188. package/src/utilities/directives/dialog-service.ts +0 -19
  189. package/src/utilities/directives/dialog.ts +0 -174
  190. package/src/utilities/directives/mat-toggle-group-directive.ts +0 -60
  191. package/src/utilities/directives/prevent-enter.directive.ts +0 -12
  192. package/src/utilities/directives/stop-propagation.directive.ts +0 -19
  193. package/src/utilities/directives/styler.ts +0 -45
  194. package/src/utilities/directives/trim-whitespace.directive.ts +0 -20
  195. package/src/utilities/index.ts +0 -22
  196. package/src/utilities/module.ts +0 -53
  197. package/src/utilities/pipes/function.pipe.ts +0 -21
  198. package/src/utilities/pipes/phone.pipe.ts +0 -20
  199. package/src/utilities/pipes/space-case.pipes.spec.ts +0 -47
  200. package/src/utilities/pipes/space-case.pipes.ts +0 -29
  201. package/tsconfig.lib.json +0 -20
  202. package/tsconfig.lib.prod.json +0 -10
  203. package/tsconfig.spec.json +0 -17
@@ -1,203 +0,0 @@
1
- import { ComponentStore } from "@ngrx/component-store";
2
- import { Injectable, Signal } from "@angular/core";
3
- import { Dictionary } from "../interfaces/dictionary";
4
- import { PersistedTableState } from "../classes/TableState";
5
- import { isCustomFilter } from "../classes/filter-info";
6
-
7
- @Injectable({ providedIn: 'root' })
8
- export class TableBuilderStateStore extends ComponentStore<GlobalStorageState> {
9
- constructor(){
10
- super(loadGlobalStorageState() || defaultStorageState)
11
- }
12
-
13
- //selectors
14
- $selectLocalTableProfile = (profileKey:string): Signal<Profile | undefined> => this.selectSignal(state =>
15
- state.localProfiles[profileKey]);
16
-
17
- $selectLocalTableStateForView = (tableId: string) => this.selectSignal(
18
- this.$selectLocalTableProfile(tableId),
19
- (profile) => {
20
- if(profile?.current) {
21
- return profile.states[profile.current];
22
- }
23
- if(profile?.localSavedState) return profile.localSavedState;
24
- return null;
25
- }
26
- )
27
-
28
- $selectLocalProfileCurrentKey = (key:string) => this.selectSignal(
29
- this.$selectLocalTableProfile(key),
30
- (profile) => profile?.current);
31
-
32
- $selectLocalProfileDefaultKey = (key:string) => this.selectSignal(
33
- this.$selectLocalTableProfile(key),
34
- (profile) => profile?.default);
35
-
36
- $selectLocalProfileKeys = (tableId:string) => this.selectSignal(
37
- this.$selectLocalTableProfile(tableId),
38
- (profile) => Object.keys(profile?.states || {})
39
- );
40
-
41
-
42
- // reducers
43
-
44
-
45
- saveTableSettingsToLocalAndStorage = (tableId: string, stateName: string, tableState: PersistedTableState, asDefault?: boolean) => {
46
- this.saveTableStateToStorage(tableId, stateName, tableState, asDefault);
47
- this.saveTableStateToLocal({ tableId, tableState, stateName, asDefault });
48
- }
49
-
50
- saveTableStateToLocal = this.updater((state, props: { tableId: string, tableState: PersistedTableState, stateName?: string, asDefault?: boolean }) => {
51
- let profile = state.localProfiles[props.tableId];
52
- if(!profile?.states) {
53
- profile = { states: {} };
54
- }
55
- if(!props.stateName){
56
- profile = { ...profile, localSavedState: props.tableState };
57
- } else {
58
- profile = { ...profile, states: { ...profile.states, [props.stateName]: props.tableState } };
59
- }
60
- if(props.asDefault){
61
- profile.default = props.stateName;
62
- }
63
- return { ...state, localProfiles: { ...state.localProfiles, [props.tableId]: profile } }
64
- });
65
-
66
- saveTableStateToStorage = (tableId: string, stateName: string, tableState: PersistedTableState, asDefault = false) => {
67
- const globalSavedState: PersistedGlobalStorageSate = JSON.parse(localStorage.getItem('global-state-storage') ?? JSON.stringify(defaultStorageState) );
68
- globalSavedState.localProfiles[tableId] ??= { states: {} };
69
- const savableState = { ...tableState };
70
- savableState.filters = Object.values(savableState.filters || {}).filter(f => !isCustomFilter(f) || !f.notSavable).reduce((obj: any, filter) => {
71
- obj[filter.filterId!] = savableState.filters![filter.filterId!];
72
- return obj;
73
- }, {});
74
- globalSavedState.localProfiles[tableId].states[stateName] = savableState;
75
- if(asDefault){
76
- globalSavedState.localProfiles[tableId].default = stateName;
77
- }
78
- localStorage.setItem('global-state-storage', JSON.stringify( globalSavedState));
79
- }
80
-
81
- addNewStateToLocalAndStorage = (tableId: string, newStateName: string, tableState: PersistedTableState, asDefault?: boolean) => {
82
- this.saveTableSettingsToLocalAndStorage(tableId, newStateName, tableState, asDefault);
83
- this.setLocalCurrentState({ tableId: tableId, currentStateKey: newStateName });
84
- }
85
-
86
- setLocalCurrentState = this.updater((state, props: { tableId: string, currentStateKey: string }) => {
87
- const profile = state.localProfiles[props.tableId] || { states: {} };
88
- profile.current = props.currentStateKey;
89
- return { ...state, localProfiles: { ...state.localProfiles, [props.tableId]: { ...profile } } };
90
- });
91
-
92
- setDefaultInLocalAndStorage = (tableId: string, newDefault: string) => {
93
- this.setDefaultInLocal({ default: newDefault, key: tableId });
94
- this.setDefaultInStorage(tableId, newDefault);
95
- }
96
-
97
- setDefaultInLocal = this.updater((state, props: { key: string, default: string }) => {
98
- if(state.localProfiles[props.key]?.states[props.default]) {
99
- return ({ ...state, localProfiles: { ...state.localProfiles, [props.key]: { ...state.localProfiles[props.key], default: props.default } } });
100
- }
101
- return state;
102
- });
103
-
104
- unsetDefaultFromLocalAndStorage = (tableId: string) => {
105
- this.unsetDefaultFromLocal(tableId);
106
- this.unsetDefaultFromStorage(tableId);
107
- }
108
-
109
- unsetDefaultFromLocal = (tableId: string) => {
110
- this.patchState(tables => {
111
- const profile = { ...tables.localProfiles[tableId] };
112
- if(profile) {
113
- delete profile.default;
114
- }
115
- return { ...tables, localProfiles: { ...tables.localProfiles, [tableId]: profile } };
116
- });
117
- }
118
-
119
- unsetDefaultFromStorage = (tableId: string) => {
120
- const globalSavedState: GlobalStorageState = JSON.parse(localStorage.getItem('global-state-storage') ?? JSON.stringify(defaultStorageState) );
121
- if(globalSavedState.localProfiles[tableId]) {
122
- delete globalSavedState.localProfiles[tableId].default;
123
- localStorage.setItem('global-state-storage', JSON.stringify( globalSavedState));
124
- }
125
- }
126
-
127
- setDefaultInStorage = (tableId: string, stateName: string) => {
128
- const tableProfile = this.$selectLocalTableProfile(tableId)();
129
- const globalSavedState: GlobalStorageState = JSON.parse(localStorage.getItem('global-state-storage') ?? JSON.stringify(defaultStorageState) );
130
- let savedProfile = globalSavedState.localProfiles[stateName];
131
- if(!savedProfile?.states) {
132
- savedProfile = { default: stateName, states: tableProfile!.states };
133
- } else {
134
- savedProfile.default = stateName;
135
- }
136
- globalSavedState.localProfiles[tableId] = savedProfile;
137
- localStorage.setItem('global-state-storage', JSON.stringify( globalSavedState));
138
- }
139
-
140
- deleteLocalProfilesState = this.updater((state, props: { key: string, stateKey: string }) => {
141
- let profile = state.localProfiles[props.key];
142
- if(profile) {
143
- const current = profile.current === props.stateKey ? profile.default : profile.current;
144
- profile = { ...profile, current, states: { ...profile.states } };
145
- delete profile.states[props.stateKey];
146
- if(current === props.stateKey) {
147
- profile.current = undefined;
148
- }
149
- return { ...state, localProfiles: { ...state.localProfiles, [props.key]: profile } };
150
- } else {
151
- return state;
152
- }
153
- });
154
-
155
- deleteProfileFromLocalAndStorage = (key: string, stateKey: string) => {
156
- const globalSavedState: GlobalStorageState = JSON.parse(localStorage.getItem('global-state-storage') ?? JSON.stringify(defaultStorageState) );
157
- if(!globalSavedState.localProfiles[key]) {
158
- return;
159
- } else {
160
- delete (globalSavedState.localProfiles[key].states ?? {})[stateKey];
161
- }
162
- if(globalSavedState.localProfiles[key].default === stateKey) {
163
- globalSavedState.localProfiles[key].default = undefined;
164
- }
165
- localStorage.setItem('global-state-storage', JSON.stringify( globalSavedState));
166
- this.deleteLocalProfilesState({ key, stateKey })
167
- }
168
- }
169
-
170
- function loadGlobalStorageState() : GlobalStorageState | void {
171
- const storage = localStorage.getItem('global-state-storage');
172
-
173
- if(storage) {
174
- const s: GlobalStorageState = (JSON.parse(storage) as PersistedGlobalStorageSate);
175
- s.localProfiles ??= {};
176
- for(const key in s.localProfiles){
177
- const profile = s.localProfiles[key];
178
- s.localProfiles[key] = { ...profile, current: profile.default } as Profile
179
- }
180
- return { ...defaultStorageState, ...s };
181
- }
182
- }
183
-
184
- interface PersistedProfile {
185
- states: Dictionary<PersistedTableState>;
186
- default?: string;
187
- }
188
- export interface Profile extends PersistedProfile {
189
- current?: string;
190
- localSavedState?: PersistedTableState;
191
- }
192
-
193
- export interface GlobalStorageState {
194
- localProfiles: Dictionary<Profile>;
195
- }
196
-
197
- interface PersistedGlobalStorageSate {
198
- localProfiles: Dictionary<PersistedProfile>;
199
- }
200
-
201
- export const defaultStorageState: GlobalStorageState = {
202
- localProfiles: {}
203
- }
@@ -1,16 +0,0 @@
1
- import { Pipe, PipeTransform } from '@angular/core';
2
- import { MetaData } from '../interfaces/meta-data';
3
- import { sumBy } from 'lodash';
4
-
5
- @Pipe({
6
- name: 'columnTotal',
7
- })
8
- export class ColumnTotalPipe implements PipeTransform {
9
- transform(data: any[], metaData: MetaData) {
10
- const dataToCalculate = data.filter(d => !d.isGroupHeader)
11
- switch (metaData.additional!.footer!.type) {
12
- case 'sum':
13
- return sumBy(dataToCalculate, metaData.key);
14
- }
15
- }
16
- }
@@ -1,12 +0,0 @@
1
- import { Pipe, PipeTransform } from '@angular/core';
2
- import { FilterType } from '../enums/filterTypes';
3
-
4
- @Pipe({ name: 'formatFilterType' })
5
- export class FormatFilterTypePipe implements PipeTransform {
6
- transform(filterType: FilterType, value: any){
7
- if(filterType === FilterType.IsNull){
8
- return value ? filterType : 'Is Not Blank'
9
- }
10
- return filterType;
11
- }
12
- }
@@ -1,71 +0,0 @@
1
- import { Pipe, PipeTransform, computed, inject } from '@angular/core';
2
- import { TableStore } from '../classes/table-store';
3
- import { FieldType, MetaData } from '../interfaces/meta-data';
4
- import { FilterType } from '../enums/filterTypes';
5
- import { spaceCase } from '../../utilities/pipes/space-case.pipes';
6
- import { DateTimeFilterFuncs } from '../functions/date-filter-function';
7
- import { currencyFormatter, dateFormatter } from '../services/transform-creator';
8
- import { isBlankValueFilter } from '../services/all-values-filter-creator.service';
9
-
10
-
11
- @Pipe({ name: 'formatFilterValue' })
12
- export class FormatFilterValuePipe implements PipeTransform {
13
- tableState = inject(TableStore);
14
-
15
- transform(value: any, key: string, filterType: FilterType) {
16
- return computed(() => transform(value, this.tableState.$getMetaData(key)(), filterType));
17
- }
18
- }
19
-
20
- const transform = (value: any, meta: MetaData, filterType: FilterType): string => {
21
- if(filterType === FilterType.IsNull) {
22
- return '';
23
- }
24
- if(value && (filterType === FilterType.In )){
25
- if(meta.fieldType === FieldType.Enum) {
26
- return value.map((v: any) => mapSpecial(v) || spaceCase(meta.additional!.enumMap![v])).join(', ') ?? value;
27
- }
28
- if(meta.fieldType === FieldType.Date || meta.fieldType === FieldType.DateTime) {
29
- return value.map( (v: any) => mapSpecial(v) || mapDate(v, meta, filterType)).join(', ') ?? value;
30
- }
31
- if(meta.fieldType === FieldType.Number || meta.fieldType === FieldType.Currency) {
32
- return value.map( (v: any) => mapSpecial(v) || mapNumber(v, meta)).join(', ') ?? value;
33
- }
34
- return value.map(v => mapSpecial(v) || v).join(', ') ?? value;
35
- }
36
- if(filterType === FilterType.NumberBetween && (meta.fieldType === FieldType.Number || meta.fieldType === FieldType.Currency)){
37
- return mapNumber(value.Start, meta) + ' - ' + mapNumber(value.End, meta);
38
- }
39
- if(filterType === FilterType.DateBetween){
40
- return mapDate(value.Start, meta, filterType) + ' - ' + mapDate(value.End, meta, filterType);
41
- }
42
- if(meta.fieldType === FieldType.Date || meta.fieldType === FieldType.DateTime){
43
- return mapDate(value, meta, filterType);
44
- }
45
- if(meta.fieldType === FieldType.Currency){
46
- return mapNumber(value, meta);
47
- }
48
- return value
49
- }
50
-
51
- function mapDate(value: any, meta: MetaData, filterType: FilterType){
52
- if(meta.fieldType === FieldType.Date){
53
- return dateFormatter(value, 'shortDate');
54
- }
55
- if(meta.fieldType === FieldType.DateTime){
56
- return (!!DateTimeFilterFuncs[filterType] ? dateFormatter(value, 'shortDate') : dateFormatter(value, 'short')) || '';
57
- }
58
- return value
59
- }
60
-
61
- function mapNumber(value: any, meta: MetaData){
62
- if(meta.fieldType === FieldType.Currency){
63
- return currencyFormatter(value);
64
- }
65
- return value;
66
- }
67
-
68
- function mapSpecial(value: any){
69
- if(isBlankValueFilter(value)) return 'BLANK';
70
- return undefined
71
- }
@@ -1,13 +0,0 @@
1
- import { Pipe, PipeTransform, computed, inject } from '@angular/core';
2
- import { TableStore } from '../classes/table-store';
3
- import { spaceCase } from '../../utilities/pipes/space-case.pipes';
4
- import { Observable } from 'rxjs';
5
- import { map } from 'rxjs/operators';
6
-
7
- @Pipe({ name: 'keyDisplay' })
8
- export class KeyDisplayPipe implements PipeTransform {
9
- tableState = inject(TableStore);
10
-
11
- transform = (key: string) =>
12
- computed(() => this.tableState.$getMetaData(key)()?.displayName || spaceCase(key))
13
- }
@@ -1,92 +0,0 @@
1
- import { Dictionary } from "@ngrx/entity";
2
- import { AllValueOptions, FieldType, MetaData } from "../interfaces/meta-data";
3
- import { TableBuilderConfig } from "../classes/TableBuilderConfig";
4
- import { createTransformer } from "./transform-creator";
5
-
6
- export function buildInAllValuesFilter(
7
- config: TableBuilderConfig,
8
- previousMeta: MetaData[],
9
- currentMeta: MetaData[],
10
- data: any[],
11
- metaTimestamp: number,
12
- dataTimestamp: number,
13
- currentAllFilters: Dictionary<any[]>){
14
-
15
- const currentAll = currentMeta.filter(m => {
16
- const filterable = m.additional?.filterOptions?.filterableValues;
17
- return filterable === 'all values' || (filterable as AllValueOptions)?.allValues === true;
18
- });
19
-
20
- if(dataTimestamp > metaTimestamp){
21
- return currentAll.reduce((dict, md) => {
22
- dict[md.key] = buildFilter(data, md, config);
23
- return dict;
24
- }, {})
25
- }
26
- const previousAll = previousMeta.filter(m => {
27
- const filterable = m.additional?.filterOptions?.filterableValues;
28
- return filterable === 'all values' || (filterable as AllValueOptions)?.allValues === true;
29
- });
30
- const newCurrent = currentAll.filter(c => previousAll.every(p => c.key !== p.key));
31
- if(newCurrent.length){
32
- const c = { ...currentAllFilters }
33
- newCurrent.forEach(md => c[md.key] = buildFilter(data, md, config));
34
- return c;
35
- }
36
-
37
- return currentAllFilters;
38
- }
39
- export const blankValueFilter = '__tb_sp_blank';
40
- export const blankValueAndEmptyStringFilter = '__tb_sp_BLANK';
41
- function buildFilter(data: any[], metaData: MetaData, config: TableBuilderConfig){
42
- const map = metaData.fieldType == FieldType.Currency ? (v => v == null ? v : v[metaData.key])
43
- : typeof metaData.filterLogic?.filterBy === 'function' && !(metaData.additional?.filterOptions?.filterableValues as AllValueOptions)?.doNotIncludeBlanks ? metaData.filterLogic?.filterBy
44
- : createTransformer(metaData, config, true, false);
45
- const mapped: [any, any][] = data.map(v => {
46
- const mappedV = map(v);
47
- return [mappedV?.toString(), mappedV]
48
- });
49
-
50
- const blankAsOption = (metaData?.additional?.filterOptions?.filterableValues as AllValueOptions)?.doNotIncludeBlanks !== true;
51
- const stringsAsBlanks = (metaData?.additional?.filterOptions?.filterableValues as AllValueOptions)?.doNotTreatEmptyStringsAsBlanks !== true;
52
-
53
- const blankAsOptionAndHasBlanks = blankAsOption && mapped.some(([, v]) => v == undefined || (stringsAsBlanks && v === ''));
54
- if(blankAsOptionAndHasBlanks) {
55
- if(stringsAsBlanks) {
56
- mapped.push(['BLANK', blankValueAndEmptyStringFilter]);
57
- } else {
58
- mapped.push(['BLANK', blankValueFilter]);
59
- }
60
- }
61
- return [...new Map(mapped).values()].filter(v => v != undefined && (!blankAsOption || !stringsAsBlanks || v !== '')).sort((a, b) => {
62
- const isSymbolA = typeof a === 'symbol';
63
- const isSymbolB = typeof b === 'symbol';
64
-
65
- if(isSymbolA || isSymbolB) return 0; // keep symbols in place
66
-
67
- return String(a).localeCompare(String(b)); // normal string sort
68
- });
69
- }
70
-
71
- export const splitOutBlankFilter = <T>(arr: T[]) => {
72
- const result = Object.groupBy(arr, v => isBlankValueFilter(v) ? 'blank' : 'values');
73
- const blank = result.blank?.at(0);
74
- const blankFilter = blank === blankValueFilter ?
75
- (val) => val == undefined
76
- : blank === blankValueAndEmptyStringFilter ? (val) => {
77
- return (val === '' || val == null)}
78
- : undefined;
79
-
80
- return ({
81
- blankFilter,
82
- values: result.values || [],
83
- })
84
- }
85
-
86
- export function isBlankValueFilter(val: any) {
87
- return val === blankValueFilter || val === blankValueAndEmptyStringFilter;
88
- }
89
-
90
- export function isNotBlankValueFilter(val: any) {
91
- return !isBlankValueFilter(val);
92
- }
@@ -1,117 +0,0 @@
1
- import { DatePipe } from '@angular/common';
2
- import { Injectable, computed, inject } from '@angular/core';
3
- import { TableStore } from '../classes/table-store';
4
- import { TableBuilderConfigToken, TableBuilderExport } from '../classes/TableBuilderConfig';
5
- import { downloadData } from '../functions/download-data';
6
- import { ArrayAdditional, ArrayStyle, FieldType, MetaData } from '../interfaces/meta-data';
7
- import { isPipe } from './transform-creator';
8
- import { getFactory } from '../functions/sort-data-function';
9
- import { spaceCase } from '../../utilities';
10
- import { cloneDeep, merge } from 'lodash';
11
-
12
- @Injectable()
13
- export class ExportToCsvService<T> {
14
- private state = inject(TableStore);
15
- private config = inject(TableBuilderConfigToken);
16
- private datePipe = inject(DatePipe);
17
-
18
- private $exportSettings = computed<TableBuilderExport>(() => {
19
- const globalSettings = this.config?.defaultTableSettings?.tableSettings?.exportSettings
20
- || {};
21
- const tableSettings = (this.state.$notPersistedTableSettings()?.exportSettings || {}) ;
22
- return merge({}, globalSettings, tableSettings);
23
- });
24
-
25
- exportToCsv = (data: T[]) => {
26
- const hiddenKeys = this.state.selectSignal(s => s.hiddenKeys)();
27
- const meta = this.state.$metaDataArray().filter(md => !md.noExport && !hiddenKeys.includes(md.key));
28
- const extraLinkCols = this.getExtraLinkCols(meta);
29
- const csv = this.csvData(data, [...meta, ...extraLinkCols]);
30
- downloadData(csv, 'export.csv', 'text/csv') ;
31
- }
32
-
33
- private getExtraLinkCols = (meta: MetaData<T>[]) => {
34
- return meta.filter(md => {
35
- if(!md.additional?.link) return;
36
- const exportForCol = merge({}, this.$exportSettings(), md.additional?.export);
37
- return exportForCol.mapLink === 'add link' || exportForCol.mapLink === 'add excel';
38
- }).map(md => {
39
- const exportForCol = merge({}, this.$exportSettings(), md.additional?.export);
40
- const newCol = cloneDeep(md);
41
- newCol.additional!.export ??= {} as TableBuilderExport;
42
- newCol.additional!.export!.mapLink = exportForCol.mapLink === 'add link' ? 'as link' : 'as excel',
43
- newCol.displayName = newCol.additional!.export!.linkColumnName || ((newCol.displayName || newCol.key) + ' - (Link)')
44
- return newCol;
45
- })
46
- }
47
-
48
- private csvData = (data:Array<T>, metaData: MetaData<T>[]) => {
49
- const res = data.map(row => metaData.map(meta => this.metaToField(meta, row)).join(','));
50
- res.unshift(metaData.map(meta => meta.displayName || meta.key).join(','));
51
- return res.join('\n');
52
- }
53
-
54
- metaToField = (meta: MetaData<T>, row: T) => {
55
- const metaExport = meta.additional?.export;
56
- if(metaExport?.mapForExport) return metaExport.mapForExport(row);
57
-
58
- const exportForCol = merge({}, this.$exportSettings(), metaExport);
59
- let val: any = getFactory(meta.key)(row);
60
- if(val == null) return val
61
- if(meta.additional?.link && exportForCol.mapLink === 'as link' || exportForCol.mapLink === 'as excel'){
62
- let mapper = this.state.$getLinkInfo(meta)()?.link;
63
- if(mapper){
64
- let mapped = mapper(row);
65
- if(exportForCol!.linkDomainPrefix){
66
- const bet = mapped.startsWith('/') ? '' : '/';
67
- mapped = `${exportForCol!.linkDomainPrefix}${bet}${mapped}`;
68
- }
69
- if(exportForCol.mapLink === 'as excel'){
70
- mapped = this.cleanValForCsv(`=HYPERLINK("${mapped}", "${mapped}")`);
71
- }
72
- return mapped;
73
- }
74
- }
75
- val = this.cleanValForCsv(this.stringByType(meta, row, val, exportForCol));
76
- return val;
77
- }
78
-
79
- private stringByType(meta: MetaData<T>, row: T, val: any, exportForCol: TableBuilderExport ){
80
- if(meta.map){
81
- return meta.map(row);
82
- }
83
- switch (meta.fieldType) {
84
- case FieldType.Date:
85
- const dateFormat = meta.additional?.export?.dateFormat || exportForCol?.dateFormat || meta.additional?.dateFormat;
86
- return this.transformDate(val, dateFormat);
87
- case FieldType.DateTime:
88
- const dateTimeFormat = meta.additional?.export?.dateTimeFormat || exportForCol?.dateTimeFormat || meta.additional?.dateTimeOptions?.format;
89
- return this.transformDate(val, dateTimeFormat);
90
- case FieldType.String:
91
- const prepend: string = meta.additional?.export?.prepend || exportForCol?.prepend || '';
92
- return prepend + val;
93
- case FieldType.Array:
94
- const style = meta.additional?.arrayStyle ?? this.config.arrayDefaults?.arrayStyle;
95
- const limit = meta.additional?.limit ?? this.config.arrayDefaults?.limit;
96
- return (val as Array<string>).slice(0, limit).join(style === ArrayStyle.NewLine ? '\n' : ', ');
97
- case FieldType.Enum:
98
- return exportForCol?.mapEnumToString ? spaceCase(meta.additional!.enumMap![val]) : val;
99
- }
100
- return val;
101
- }
102
-
103
- cleanValForCsv(val: any) {
104
- if(typeof val === 'string' && (val.includes(',') || val.includes('"') || val.includes('\n'))) {
105
- val = val.replaceAll('"', '""');
106
- val = '"' + val + '"';
107
- }
108
- return val;
109
- }
110
-
111
- private transformDate(val: any, dateFormat: any) {
112
- if(this.config.transformers && this.config.transformers[FieldType.Date]) {
113
- return this.config.transformers[FieldType.Date]!(val);
114
- }
115
- return this.datePipe.transform(val, dateFormat);
116
- }
117
- }
@@ -1,98 +0,0 @@
1
- import { MetaData } from "../interfaces/meta-data";
2
- import { Dictionary } from "@ngrx/entity";
3
- import { QueryParamsHandling } from "@angular/router";
4
- import { getFactory } from "../functions/sort-data-function";
5
-
6
- export function createLinkCreatorDict<T>(metaDatas: MetaData<T>[]){
7
- return metaDatas.reduce((acc, md) => {
8
- if(md.additional?.link){ acc[md.key] = createLinkCreator(md)}
9
- return acc;
10
- }, {} as Dictionary<LinkInfo>)
11
- }
12
-
13
- function createLinkCreator<T>(metaData: MetaData<T>): LinkInfo{
14
- const target = metaData.additional?.link?.target || '_blank';
15
- const useRouterLink = metaData.additional?.link?.useRouterLink || false;
16
- const hasRoute = !!metaData.additional?.link?.interpolatedRoute;
17
-
18
- const qp = useRouterLink ?
19
- metaData.additional!.link!.routerLinkOptions?.queryParams?.reduce((map, [key, value]) => {
20
- map[key] = typeof value === 'function' ? value : parseInterpolated(value);
21
- return map;
22
- }, {})
23
- : undefined;
24
-
25
- const routerLinkOptions = useRouterLink ? {
26
- queryParams: (element: T) => metaData.additional!.link!.routerLinkOptions?.queryParams?.reduce((map, [key, value]) => {
27
- map[key] = qp![key](element);
28
- return map;
29
- }, {}) ?? null,
30
- fragment: metaData.additional!.link?.routerLinkOptions?.fragment,
31
- preserveFragment: metaData.additional!.link!.routerLinkOptions?.preserveFragment ?? false,
32
- queryParamsHandling: metaData.additional!.link!.routerLinkOptions?.queryParamsHandling ?? '',
33
- }
34
- : undefined;
35
-
36
- if(hasRoute) {
37
- const value = metaData.additional!.link!.interpolatedRoute!;
38
- return ({
39
- link: typeof value === 'function' ? (element: T) => value(element) : parseInterpolated(value),
40
- target,
41
- useRouterLink,
42
- routerLinkOptions,
43
- });
44
- } else {
45
- const slashIfNeeded = !metaData.additional?.link?.base?.endsWith('/') ? '/' : '';
46
- const base = metaData.additional!.link?.base;
47
- const getKey = key(metaData);
48
- return ({
49
- link: (element: T) => `${base}${slashIfNeeded}${getKey(element)}`,
50
- target,
51
- useRouterLink,
52
- routerLinkOptions,
53
- });
54
- }
55
- }
56
-
57
- const key = (metaData : MetaData) => metaData.additional!.link?.urlKey ?
58
- getFactory(metaData.additional!.link!.urlKey as string)
59
- :
60
- getFactory(metaData.key);
61
-
62
- export interface LinkInfo {
63
- link: (element: any) => string;
64
- target: string;
65
- useRouterLink: boolean;
66
- routerLinkOptions?: {
67
- queryParams: (element: any) => any;
68
- fragment?: string;
69
- preserveFragment?: boolean;
70
- queryParamsHandling?: QueryParamsHandling;
71
- }
72
- }
73
-
74
- function parseInterpolated(input: string) {
75
- // Match either content inside curly braces or content between curly braces
76
- const parts = input.split(/({[\w.]+})/);
77
-
78
- const result = parts
79
- .filter(part => part !== '') // Remove empty strings
80
- .map(part => {
81
- if(part.startsWith('{') && part.endsWith('}')) {
82
- // For interpolated values, remove the curly braces
83
- return {
84
- type: 'interpolated',
85
- val: getFactory(part.slice(1, -1))
86
- };
87
- } else {
88
- return {
89
- type: 'string',
90
- val: part
91
- };
92
- }
93
- }) as ({type: 'string', val:string} | {type:'interpolated', val: (t:any) => string})[];
94
-
95
- return function(val: any){
96
- return result.map(part => part.type === 'string' ? part.val : part.val(val)).join('');
97
- }
98
- }
@@ -1,47 +0,0 @@
1
- import { EnvironmentInjector, createComponent, inject } from "@angular/core";
2
- import { Injectable, TemplateRef } from "@angular/core";
3
- import { ArrayAdditional, ArrayStyle, FieldType, MetaData } from "../interfaces/meta-data";
4
- import { InitializationComponent } from "../components/initialization-component/initialization.component";
5
- import { TableBuilderConfigToken } from "../classes/TableBuilderConfig";
6
-
7
- @Injectable({ providedIn: 'root' })
8
- export class TableTemplateService {
9
- environmentInjector = inject(EnvironmentInjector);
10
- tableConfig = inject(TableBuilderConfigToken);
11
- initConfig = createComponent(InitializationComponent, {
12
- environmentInjector: this.environmentInjector,
13
- });
14
- initializationComponentInstance = this.initConfig.instance;
15
- getTemplate(metaData: MetaData) : TemplateRef<any> {
16
-
17
- if(metaData.fieldType === FieldType.Array){
18
- const arrayStyle = metaData.additional?.arrayStyle ?? this.tableConfig?.arrayDefaults?.arrayStyle;
19
- return arrayStyle === ArrayStyle.NewLine
20
- ? this.initializationComponentInstance.$arrayNewLineTemplate()
21
- : this.initializationComponentInstance.$arrayCommaTemplate();
22
- }
23
-
24
- if(metaData.fieldType === FieldType.ImageUrl) {
25
- return this.initializationComponentInstance.$imageUrlTemplate();
26
- }
27
-
28
- const useIcon = metaData.useIcon || (metaData.fieldType === FieldType.Boolean && metaData.useIcon !== false);
29
- if(metaData.additional?.link){
30
- const router = metaData.additional?.link?.useRouterLink;
31
- if(router) {
32
- return useIcon
33
- ? this.initializationComponentInstance.$routerLinkWithIconTemplate()
34
- : this.initializationComponentInstance.$routerLinkTemplate();
35
- }
36
- return useIcon
37
- ? this.initializationComponentInstance.$linkWithIconTemplate()!
38
- : this.initializationComponentInstance.$linkTemplate();
39
- }
40
-
41
- if(useIcon){
42
- return this.initializationComponentInstance.$defaultWithIcon();
43
- }
44
-
45
- return this.initializationComponentInstance.$defaultTemplate();
46
- }
47
- }