@webitel/ui-datalist 1.0.0 → 1.0.2

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 (155) hide show
  1. package/Readme.md +19 -0
  2. package/package.json +3 -1
  3. package/src/filter-presets/api/PresetQuery.api.ts +122 -0
  4. package/src/filter-presets/components/_shared/input-fields/preset-description-field.vue +32 -0
  5. package/src/filter-presets/components/_shared/input-fields/preset-name-field.vue +28 -0
  6. package/src/filter-presets/components/_shared/preset-filters-preview.vue +45 -0
  7. package/src/filter-presets/components/apply-preset/apply-preset-action.vue +234 -0
  8. package/src/filter-presets/components/apply-preset/preset-preview.vue +210 -0
  9. package/src/filter-presets/components/save-preset/overwrite-preset-popup.vue +64 -0
  10. package/src/filter-presets/components/save-preset/save-preset-action.vue +139 -0
  11. package/src/filter-presets/components/save-preset/save-preset-popup.vue +136 -0
  12. package/src/filter-presets/index.ts +5 -0
  13. package/src/filter-presets/stores/createFilterPresetsStore.ts +17 -0
  14. package/src/filter-presets/stores/headers/headers.ts +24 -0
  15. package/src/filters/classes/Filter.ts +30 -0
  16. package/src/filters/classes/FilterStorage.ts +34 -0
  17. package/src/filters/classes/FilterStorageOptions.d.ts +6 -0
  18. package/src/filters/classes/FiltersManager.ts +190 -0
  19. package/src/filters/components/config/dynamic-filter-config-form-label.vue +49 -0
  20. package/src/filters/components/config/dynamic-filter-config-form.vue +139 -0
  21. package/src/filters/components/config/dynamic-filter-config-view.vue +40 -0
  22. package/src/filters/components/dynamic-filter-add-action.vue +54 -0
  23. package/src/filters/components/dynamic-filter-panel-wrapper.vue +57 -0
  24. package/src/filters/components/dynamic-filter-search.vue +60 -0
  25. package/src/filters/components/filter-options/_shared/composables/booleanFilterToolkit.ts +39 -0
  26. package/src/filters/components/filter-options/_shared/composables/useFromToSecToPreviewTime.ts +41 -0
  27. package/src/filters/components/filter-options/_shared/date-time-filter/date-time-filter-value-field.vue +56 -0
  28. package/src/filters/components/filter-options/_shared/durations/duration-filter-value-field.vue +84 -0
  29. package/src/filters/components/filter-options/_shared/has-options/has-option-filter-value-field.vue +38 -0
  30. package/src/filters/components/filter-options/_shared/types/BooleanFilter.ts +1 -0
  31. package/src/filters/components/filter-options/actual-reaction-time/actual-reaction-time-filter-value-field.vue +18 -0
  32. package/src/filters/components/filter-options/actual-reaction-time/actual-reaction-time-filter-value-preview.vue +44 -0
  33. package/src/filters/components/filter-options/actual-resolution-time/actual-resolution-time-filter-value-field.vue +18 -0
  34. package/src/filters/components/filter-options/actual-resolution-time/actual-resolution-time-filter-value-preview.vue +44 -0
  35. package/src/filters/components/filter-options/agent/agent-filter-value-field.vue +58 -0
  36. package/src/filters/components/filter-options/agent/agent-filter-value-preview.vue +31 -0
  37. package/src/filters/components/filter-options/agent/config.js +4 -0
  38. package/src/filters/components/filter-options/amd-result/amd-result-filter-value-field.vue +52 -0
  39. package/src/filters/components/filter-options/amd-result/amd-result-filter-value-preview.vue +18 -0
  40. package/src/filters/components/filter-options/assignee/assignee-filter-value-field.vue +73 -0
  41. package/src/filters/components/filter-options/assignee/assignee-filter-value-preview.vue +36 -0
  42. package/src/filters/components/filter-options/assignee/config.js +4 -0
  43. package/src/filters/components/filter-options/author/author-filter-value-field.vue +56 -0
  44. package/src/filters/components/filter-options/author/author-filter-value-preview.vue +31 -0
  45. package/src/filters/components/filter-options/author/config.js +4 -0
  46. package/src/filters/components/filter-options/cause/cause-filter-value-field.vue +52 -0
  47. package/src/filters/components/filter-options/cause/cause-filter-value-preview.vue +18 -0
  48. package/src/filters/components/filter-options/close-reason-groups-case/close-reason-groups-case-filter-value-field.vue +102 -0
  49. package/src/filters/components/filter-options/close-reason-groups-case/close-reason-groups-case-filter-value-preview.vue +34 -0
  50. package/src/filters/components/filter-options/close-reason-groups-case/config.js +7 -0
  51. package/src/filters/components/filter-options/contact/config.js +4 -0
  52. package/src/filters/components/filter-options/contact/contact-filter-value-field.vue +56 -0
  53. package/src/filters/components/filter-options/contact/contact-filter-value-preview.vue +31 -0
  54. package/src/filters/components/filter-options/contact-group/config.js +4 -0
  55. package/src/filters/components/filter-options/contact-group/contact-group-filter-value-field.vue +74 -0
  56. package/src/filters/components/filter-options/contact-group/contact-group-filter-value-preview.vue +38 -0
  57. package/src/filters/components/filter-options/created-at-from/created-at-from-filter-value-field.vue +24 -0
  58. package/src/filters/components/filter-options/created-at-from/created-at-from-filter-value-preview.vue +15 -0
  59. package/src/filters/components/filter-options/created-at-to/created-at-to-filter-value-field.vue +24 -0
  60. package/src/filters/components/filter-options/created-at-to/created-at-to-filter-value-preview.vue +15 -0
  61. package/src/filters/components/filter-options/direction/direction-filter-value-field.vue +51 -0
  62. package/src/filters/components/filter-options/direction/direction-filter-value-preview.vue +17 -0
  63. package/src/filters/components/filter-options/gateway/config.js +4 -0
  64. package/src/filters/components/filter-options/gateway/gateway-filter-value-field.vue +56 -0
  65. package/src/filters/components/filter-options/gateway/gateway-filter-value-preview.vue +31 -0
  66. package/src/filters/components/filter-options/grantee/config.js +4 -0
  67. package/src/filters/components/filter-options/grantee/grantee-filter-value-field.vue +56 -0
  68. package/src/filters/components/filter-options/grantee/grantee-filter-value-preview.vue +31 -0
  69. package/src/filters/components/filter-options/has-attachment/has-attachment-filter-value-field.vue +43 -0
  70. package/src/filters/components/filter-options/has-attachment/has-attachment-filter-value-preview.vue +24 -0
  71. package/src/filters/components/filter-options/has-file/has-file-filter-value-field.vue +33 -0
  72. package/src/filters/components/filter-options/has-file/has-file-filter-value-preview.vue +15 -0
  73. package/src/filters/components/filter-options/has-rating/has-rating-filter-value-field.vue +33 -0
  74. package/src/filters/components/filter-options/has-rating/has-rating-filter-value-preview.vue +15 -0
  75. package/src/filters/components/filter-options/has-transcription/has-transcription-filter-value-field.vue +33 -0
  76. package/src/filters/components/filter-options/has-transcription/has-transcription-filter-value-preview.vue +15 -0
  77. package/src/filters/components/filter-options/impacted/config.js +4 -0
  78. package/src/filters/components/filter-options/impacted/impacted-filter-value-field.vue +56 -0
  79. package/src/filters/components/filter-options/impacted/impacted-filter-value-preview.vue +31 -0
  80. package/src/filters/components/filter-options/index.ts +250 -0
  81. package/src/filters/components/filter-options/priority-case/config.js +4 -0
  82. package/src/filters/components/filter-options/priority-case/priority-case-filter-value-field.vue +57 -0
  83. package/src/filters/components/filter-options/priority-case/priority-case-filter-value-preview.vue +31 -0
  84. package/src/filters/components/filter-options/queue/config.js +4 -0
  85. package/src/filters/components/filter-options/queue/queue-filter-value-field.vue +56 -0
  86. package/src/filters/components/filter-options/queue/queue-filter-value-preview.vue +31 -0
  87. package/src/filters/components/filter-options/rated-by/config.js +4 -0
  88. package/src/filters/components/filter-options/rated-by/rated-by-filter-value-field.vue +56 -0
  89. package/src/filters/components/filter-options/rated-by/rated-by-filter-value-preview.vue +31 -0
  90. package/src/filters/components/filter-options/rating/rating-from-to-filter-value-field.vue +100 -0
  91. package/src/filters/components/filter-options/rating/rating-from-to-filter-value-preview.vue +39 -0
  92. package/src/filters/components/filter-options/reaction-time/reaction-time-filter-value-field.vue +18 -0
  93. package/src/filters/components/filter-options/reaction-time/reaction-time-filter-value-preview.vue +44 -0
  94. package/src/filters/components/filter-options/reporter/config.js +4 -0
  95. package/src/filters/components/filter-options/reporter/reporter-filter-value-field.vue +56 -0
  96. package/src/filters/components/filter-options/reporter/reporter-filter-value-preview.vue +31 -0
  97. package/src/filters/components/filter-options/resolution-time/resolution-time-filter-value-field.vue +18 -0
  98. package/src/filters/components/filter-options/resolution-time/resolution-time-filter-value-preview.vue +44 -0
  99. package/src/filters/components/filter-options/score/score-from-to-filter-value-field.vue +100 -0
  100. package/src/filters/components/filter-options/score/score-from-to-filter-value-preview.vue +39 -0
  101. package/src/filters/components/filter-options/service-case/config.js +6 -0
  102. package/src/filters/components/filter-options/service-case/service-case-filter-value-field.vue +82 -0
  103. package/src/filters/components/filter-options/service-case/service-case-filter-value-preview.vue +34 -0
  104. package/src/filters/components/filter-options/sla/config.js +4 -0
  105. package/src/filters/components/filter-options/sla/sla-filter-value-field.vue +57 -0
  106. package/src/filters/components/filter-options/sla/sla-filter-value-preview.vue +31 -0
  107. package/src/filters/components/filter-options/sla-condition/config.js +6 -0
  108. package/src/filters/components/filter-options/sla-condition/sla-condition-filter-value-field.vue +98 -0
  109. package/src/filters/components/filter-options/sla-condition/sla-condition-filter-value-preview.vue +37 -0
  110. package/src/filters/components/filter-options/source-case/config.js +4 -0
  111. package/src/filters/components/filter-options/source-case/source-case-filter-value-field.vue +57 -0
  112. package/src/filters/components/filter-options/source-case/source-case-filter-value-preview.vue +31 -0
  113. package/src/filters/components/filter-options/status-case/config.js +7 -0
  114. package/src/filters/components/filter-options/status-case/status-case-filter-value-field.vue +102 -0
  115. package/src/filters/components/filter-options/status-case/status-case-filter-value-preview.vue +37 -0
  116. package/src/filters/components/filter-options/tag/tag-filter-value-field.vue +52 -0
  117. package/src/filters/components/filter-options/tag/tag-filter-value-preview.vue +38 -0
  118. package/src/filters/components/filter-options/talk-duration/TalkDurationFilter.d.ts +4 -0
  119. package/src/filters/components/filter-options/talk-duration/talk-duration-filter-value-field.vue +19 -0
  120. package/src/filters/components/filter-options/talk-duration/talk-duration-filter-value-preview.vue +44 -0
  121. package/src/filters/components/filter-options/team/config.js +4 -0
  122. package/src/filters/components/filter-options/team/team-filter-value-field.vue +56 -0
  123. package/src/filters/components/filter-options/team/team-filter-value-preview.vue +31 -0
  124. package/src/filters/components/filter-options/total-duration/TotalDurationFilter.d.ts +4 -0
  125. package/src/filters/components/filter-options/total-duration/total-duration-filter-value-field.vue +19 -0
  126. package/src/filters/components/filter-options/total-duration/total-duration-filter-value-preview.vue +44 -0
  127. package/src/filters/components/filter-options/user/config.js +4 -0
  128. package/src/filters/components/filter-options/user/user-filter-value-field.vue +56 -0
  129. package/src/filters/components/filter-options/user/user-filter-value-preview.vue +31 -0
  130. package/src/filters/components/filter-options/variable/variable-filter-value-field.vue +49 -0
  131. package/src/filters/components/filter-options/variable/variable-filter-value-preview.vue +39 -0
  132. package/src/filters/components/preview/dynamic-filter-preview-info.vue +35 -0
  133. package/src/filters/components/preview/dynamic-filter-preview.vue +76 -0
  134. package/src/filters/components/table-filters-panel.vue +83 -0
  135. package/src/filters/createTableFiltersStore.ts +81 -0
  136. package/src/filters/enums/FilterOption.ts +43 -0
  137. package/src/filters/enums/amd-result-options.ts +38 -0
  138. package/src/filters/enums/boolean-options.ts +16 -0
  139. package/src/filters/enums/direction-options.ts +20 -0
  140. package/src/filters/enums/hangup-cause-options.ts +265 -0
  141. package/src/filters/enums/tag-options.ts +8 -0
  142. package/src/filters/index.ts +27 -0
  143. package/src/filters/scripts/utils.ts +31 -0
  144. package/src/filters/types/Filter.d.ts +46 -0
  145. package/src/filters/types/FiltersManager.d.ts +76 -0
  146. package/src/headers/createTableHeadersStore.ts +140 -0
  147. package/src/index.d.ts +0 -0
  148. package/src/index.ts +3 -0
  149. package/src/pagination/createTablePaginationStore.ts +64 -0
  150. package/src/persist/PersistedStorage.types.ts +51 -0
  151. package/src/persist/useLocalStoragePersistedStorage.ts +37 -0
  152. package/src/persist/usePersistedStorage.ts +151 -0
  153. package/src/persist/useRoutePersistedStorage.ts +41 -0
  154. package/src/table/createTableStore.store.ts +206 -0
  155. package/src/types/tableStore.types.ts +61 -0
@@ -0,0 +1,38 @@
1
+ import { FilterInitParams } from '../types/Filter';
2
+
3
+ /**
4
+ * AMD Result to filter
5
+ * @enum
6
+ * @readonly
7
+ */
8
+
9
+ export const AmdResultOptions: Array<FilterInitParams> = [
10
+ {
11
+ name: 'NOTSURE',
12
+ value: 'NOTSURE',
13
+ },
14
+ {
15
+ name: 'HUMAN',
16
+ value: 'HUMAN',
17
+ },
18
+ {
19
+ name: 'MACHINE',
20
+ value: 'MACHINE',
21
+ },
22
+ {
23
+ name: 'CANCEL',
24
+ value: 'CANCEL',
25
+ },
26
+ {
27
+ name: 'SILENCE',
28
+ value: 'SILENCE',
29
+ },
30
+ {
31
+ name: 'VOICEMAIL',
32
+ value: 'VOICEMAIL',
33
+ },
34
+ {
35
+ name: 'RINGING',
36
+ value: 'RINGING',
37
+ },
38
+ ] as const;
@@ -0,0 +1,16 @@
1
+ /*
2
+ values are strings instead of booleans because restoration from url query
3
+ returns string for any type of value [DEV-3924]
4
+ */
5
+ import { FilterEnumOption } from '../types/Filter';
6
+
7
+ export const BooleanOptions: Array<FilterEnumOption> = [
8
+ {
9
+ locale: 'vocabulary.yes',
10
+ value: 'true',
11
+ },
12
+ {
13
+ locale: 'vocabulary.no',
14
+ value: 'false',
15
+ },
16
+ ] as const;
@@ -0,0 +1,20 @@
1
+ import { CallDirection } from 'webitel-sdk';
2
+
3
+ export type CallDirectionType =
4
+ (typeof CallDirection)[keyof typeof CallDirection];
5
+
6
+ export type DirectionOption = {
7
+ locale: [string, number];
8
+ value: CallDirectionType;
9
+ };
10
+
11
+ export const DirectionOptions: readonly DirectionOption[] = [
12
+ {
13
+ locale: [`calls.direction.${CallDirection.Inbound}`, 2],
14
+ value: CallDirection.Inbound,
15
+ },
16
+ {
17
+ locale: [`calls.direction.${CallDirection.Outbound}`, 2],
18
+ value: CallDirection.Outbound,
19
+ },
20
+ ] as const;
@@ -0,0 +1,265 @@
1
+ import { FilterInitParams } from '../types/Filter';
2
+
3
+ /**
4
+ * Hangup causes to filter
5
+ * @enum
6
+ * @readonly
7
+ */
8
+ export const HangupCauseOptions: Array<FilterInitParams> = [
9
+ {
10
+ name: 'UNSPECIFIED',
11
+ value: 'UNSPECIFIED',
12
+ },
13
+ {
14
+ name: 'UNALLOCATED_NUMBER',
15
+ value: 'UNALLOCATED_NUMBER',
16
+ },
17
+ {
18
+ name: 'NO_ROUTE_TRANSIT_NET',
19
+ value: 'NO_ROUTE_TRANSIT_NET',
20
+ },
21
+ {
22
+ name: 'NO_ROUTE_DESTINATION',
23
+ value: 'NO_ROUTE_DESTINATION',
24
+ },
25
+ {
26
+ name: 'CHANNEL_UNACCEPTABLE',
27
+ value: 'CHANNEL_UNACCEPTABLE',
28
+ },
29
+ {
30
+ name: 'CALL_AWARDED_DELIVERED',
31
+ value: 'CALL_AWARDED_DELIVERED',
32
+ },
33
+ {
34
+ name: 'NORMAL_CLEARING',
35
+ value: 'NORMAL_CLEARING',
36
+ },
37
+ {
38
+ name: 'USER_BUSY',
39
+ value: 'USER_BUSY',
40
+ },
41
+ {
42
+ name: 'NO_USER_RESPONSE',
43
+ value: 'NO_USER_RESPONSE',
44
+ },
45
+ {
46
+ name: 'NO_ANSWER',
47
+ value: 'NO_ANSWER',
48
+ },
49
+ {
50
+ name: 'SUBSCRIBER_ABSENT',
51
+ value: 'SUBSCRIBER_ABSENT',
52
+ },
53
+ {
54
+ name: 'CALL_REJECTED',
55
+ value: 'CALL_REJECTED',
56
+ },
57
+ {
58
+ name: 'NUMBER_CHANGED',
59
+ value: 'NUMBER_CHANGED',
60
+ },
61
+ {
62
+ name: 'REDIRECTION_TO_NEW_DESTINATION',
63
+ value: 'REDIRECTION_TO_NEW_DESTINATION',
64
+ },
65
+ {
66
+ name: 'EXCHANGE_ROUTING_ERROR',
67
+ value: 'EXCHANGE_ROUTING_ERROR',
68
+ },
69
+ {
70
+ name: 'DESTINATION_OUT_OF_ORDER',
71
+ value: 'DESTINATION_OUT_OF_ORDER',
72
+ },
73
+ {
74
+ name: 'INVALID_NUMBER_FORMAT',
75
+ value: 'INVALID_NUMBER_FORMAT',
76
+ },
77
+ {
78
+ name: 'FACILITY_REJECTED',
79
+ value: 'FACILITY_REJECTED',
80
+ },
81
+ {
82
+ name: 'RESPONSE_TO_STATUS_ENQUIRY',
83
+ value: 'RESPONSE_TO_STATUS_ENQUIRY',
84
+ },
85
+ {
86
+ name: 'NORMAL_UNSPECIFIED',
87
+ value: 'NORMAL_UNSPECIFIED',
88
+ },
89
+ {
90
+ name: 'NORMAL_CIRCUIT_CONGESTION',
91
+ value: 'NORMAL_CIRCUIT_CONGESTION',
92
+ },
93
+ {
94
+ name: 'NETWORK_OUT_OF_ORDER',
95
+ value: 'NETWORK_OUT_OF_ORDER',
96
+ },
97
+ {
98
+ name: 'NORMAL_TEMPORARY_FAILURE',
99
+ value: 'NORMAL_TEMPORARY_FAILURE',
100
+ },
101
+ {
102
+ name: 'SWITCH_CONGESTION',
103
+ value: 'SWITCH_CONGESTION',
104
+ },
105
+ {
106
+ name: 'ACCESS_INFO_DISCARDED',
107
+ value: 'ACCESS_INFO_DISCARDED',
108
+ },
109
+ {
110
+ name: 'REQUESTED_CHAN_UNAVAIL',
111
+ value: 'REQUESTED_CHAN_UNAVAIL',
112
+ },
113
+ {
114
+ name: 'PRE_EMPTED',
115
+ value: 'PRE_EMPTED',
116
+ },
117
+ {
118
+ name: 'FACILITY_NOT_SUBSCRIBED',
119
+ value: 'FACILITY_NOT_SUBSCRIBED',
120
+ },
121
+ {
122
+ name: 'OUTGOING_CALL_BARRED',
123
+ value: 'OUTGOING_CALL_BARRED',
124
+ },
125
+ {
126
+ name: 'INCOMING_CALL_BARRED',
127
+ value: 'INCOMING_CALL_BARRED',
128
+ },
129
+ {
130
+ name: 'BEARERCAPABILITY_NOTAUTH',
131
+ value: 'BEARERCAPABILITY_NOTAUTH',
132
+ },
133
+ {
134
+ name: 'BEARERCAPABILITY_NOTAVAIL',
135
+ value: 'BEARERCAPABILITY_NOTAVAIL',
136
+ },
137
+ {
138
+ name: 'SERVICE_UNAVAILABLE',
139
+ value: 'SERVICE_UNAVAILABLE',
140
+ },
141
+ {
142
+ name: 'BEARERCAPABILITY_NOTIMPL',
143
+ value: 'BEARERCAPABILITY_NOTIMPL',
144
+ },
145
+ {
146
+ name: 'CHAN_NOT_IMPLEMENTED',
147
+ value: 'CHAN_NOT_IMPLEMENTED',
148
+ },
149
+ {
150
+ name: 'FACILITY_NOT_IMPLEMENTED',
151
+ value: 'FACILITY_NOT_IMPLEMENTED',
152
+ },
153
+ {
154
+ name: 'SERVICE_NOT_IMPLEMENTED',
155
+ value: 'SERVICE_NOT_IMPLEMENTED',
156
+ },
157
+ {
158
+ name: 'INVALID_CALL_REFERENCE',
159
+ value: 'INVALID_CALL_REFERENCE',
160
+ },
161
+ {
162
+ name: 'INCOMPATIBLE_DESTINATION',
163
+ value: 'INCOMPATIBLE_DESTINATION',
164
+ },
165
+ {
166
+ name: 'INVALID_MSG_UNSPECIFIED',
167
+ value: 'INVALID_MSG_UNSPECIFIED',
168
+ },
169
+ {
170
+ name: 'MANDATORY_IE_MISSING',
171
+ value: 'MANDATORY_IE_MISSING',
172
+ },
173
+ {
174
+ name: 'MESSAGE_TYPE_NONEXIST',
175
+ value: 'MESSAGE_TYPE_NONEXIST',
176
+ },
177
+ {
178
+ name: 'WRONG_MESSAGE',
179
+ value: 'WRONG_MESSAGE',
180
+ },
181
+ {
182
+ name: 'IE_NONEXIST',
183
+ value: 'IE_NONEXIST',
184
+ },
185
+ {
186
+ name: 'INVALID_IE_CONTENTS',
187
+ value: 'INVALID_IE_CONTENTS',
188
+ },
189
+ {
190
+ name: 'WRONG_CALL_STATE',
191
+ value: 'WRONG_CALL_STATE',
192
+ },
193
+ {
194
+ name: 'RECOVERY_ON_TIMER_EXPIRE',
195
+ value: 'RECOVERY_ON_TIMER_EXPIRE',
196
+ },
197
+ {
198
+ name: 'MANDATORY_IE_LENGTH_ERROR',
199
+ value: 'MANDATORY_IE_LENGTH_ERROR',
200
+ },
201
+ {
202
+ name: 'PROTOCOL_ERROR',
203
+ value: 'PROTOCOL_ERROR',
204
+ },
205
+ {
206
+ name: 'INTERWORKING',
207
+ value: 'INTERWORKING',
208
+ },
209
+ {
210
+ name: 'ORIGINATOR_CANCEL',
211
+ value: 'ORIGINATOR_CANCEL',
212
+ },
213
+ {
214
+ name: 'CRASH',
215
+ value: 'CRASH',
216
+ },
217
+ {
218
+ name: 'SYSTEM_SHUTDOWN',
219
+ value: 'SYSTEM_SHUTDOWN',
220
+ },
221
+ {
222
+ name: 'LOSE_RACE',
223
+ value: 'LOSE_RACE',
224
+ },
225
+ {
226
+ name: 'MANAGER_REQUEST',
227
+ value: 'MANAGER_REQUEST',
228
+ },
229
+ {
230
+ name: 'BLIND_TRANSFER',
231
+ value: 'BLIND_TRANSFER',
232
+ },
233
+ {
234
+ name: 'ATTENDED_TRANSFER',
235
+ value: 'ATTENDED_TRANSFER',
236
+ },
237
+ {
238
+ name: 'ALLOTTED_TIMEOUT',
239
+ value: 'ALLOTTED_TIMEOUT',
240
+ },
241
+ {
242
+ name: 'USER_CHALLENGE',
243
+ value: 'USER_CHALLENGE',
244
+ },
245
+ {
246
+ name: 'MEDIA_TIMEOUT',
247
+ value: 'MEDIA_TIMEOUT',
248
+ },
249
+ {
250
+ name: 'PICKED_OFF',
251
+ value: 'PICKED_OFF',
252
+ },
253
+ {
254
+ name: 'USER_NOT_REGISTERED',
255
+ value: 'USER_NOT_REGISTERED',
256
+ },
257
+ {
258
+ name: 'PROGRESS_TIMEOUT',
259
+ value: 'PROGRESS_TIMEOUT',
260
+ },
261
+ {
262
+ name: 'GATEWAY_DOWN',
263
+ value: 'GATEWAY_DOWN',
264
+ },
265
+ ] as const;
@@ -0,0 +1,8 @@
1
+ import { FilterEnumOption } from '../types/Filter';
2
+
3
+ export const TagOptions: Array<FilterEnumOption> = [
4
+ {
5
+ locale: 'filters.tag.options.vm',
6
+ value: 'vm',
7
+ },
8
+ ] as const;
@@ -0,0 +1,27 @@
1
+ import { Filter } from './classes/Filter.ts';
2
+ import { createFiltersManager } from './classes/FiltersManager';
3
+ import type {
4
+ FilterConfig,
5
+ FilterInitParams,
6
+ FilterLabel,
7
+ FilterName,
8
+ FilterValue,
9
+ IFilter,
10
+ } from './types/Filter.d.ts';
11
+ import type {
12
+ FiltersManagerConfig,
13
+ IFiltersManager,
14
+ } from './types/FiltersManager.d.ts';
15
+
16
+ export { createFiltersManager, Filter };
17
+
18
+ export type {
19
+ FilterConfig,
20
+ FilterInitParams,
21
+ FilterLabel,
22
+ FilterName,
23
+ FiltersManagerConfig,
24
+ FilterValue,
25
+ IFilter,
26
+ IFiltersManager,
27
+ };
@@ -0,0 +1,31 @@
1
+ import type { FilterName } from '../types/Filter';
2
+
3
+ export const filterLabelToSnapshotKey = (name: FilterName): string =>
4
+ `${name}_lbl`;
5
+
6
+ export const filterValueToSnapshotKey = (name: FilterName): string =>
7
+ `${name}_val`;
8
+
9
+ const filterLabelFromSnapshotKey = (snapshotKey: string): FilterName =>
10
+ snapshotKey.replace('_lbl', '');
11
+
12
+ const filterValueFromSnapshotKey = (snapshotKey: string): FilterName =>
13
+ snapshotKey.replace('_val', '');
14
+
15
+ const isLabelSnapshotKey = (snapshotKey: string): boolean =>
16
+ snapshotKey.includes('_lbl');
17
+
18
+ const isValueSnapshotKey = (snapshotKey: string): boolean =>
19
+ snapshotKey.includes('_val');
20
+
21
+ export const filterNameFromSnapshotKey = (snapshotKey: string): FilterName => {
22
+ if (isLabelSnapshotKey(snapshotKey))
23
+ return filterLabelFromSnapshotKey(snapshotKey);
24
+ if (isValueSnapshotKey(snapshotKey))
25
+ return filterValueFromSnapshotKey(snapshotKey);
26
+ };
27
+
28
+ export const filterValuePropFromSnapshotKey = (snapshotKey: string): string => {
29
+ if (isLabelSnapshotKey(snapshotKey)) return 'label';
30
+ if (isValueSnapshotKey(snapshotKey)) return 'value';
31
+ };
@@ -0,0 +1,46 @@
1
+ export type FilterName = string;
2
+ export type FilterLabel = string;
3
+ export type FilterValue =
4
+ | object
5
+ | []
6
+ | string
7
+ | number
8
+ | boolean
9
+ | undefined
10
+ | null;
11
+
12
+ /**
13
+ * represents user-input data, that should be (re)stored
14
+ */
15
+ export interface FilterData {
16
+ value: FilterValue;
17
+ label?: FilterLabel;
18
+ }
19
+
20
+ export interface FilterInitParams extends FilterData {
21
+ name: FilterName;
22
+ }
23
+
24
+ export interface FilterEnumOption {
25
+ locale: string;
26
+ value: FilterValue;
27
+ }
28
+
29
+ export interface FilterConfig {
30
+ /**
31
+ * Perform simple type conversion on store/restore,
32
+ * without need to provide custom store/restore functions
33
+ */
34
+ storableType?: string;
35
+ /**
36
+ * list of persistence storages that should be used for this filter
37
+ */
38
+ storage?: string[];
39
+ }
40
+
41
+ export interface IFilter {
42
+ name: FilterName;
43
+ value: FilterValue;
44
+ label?: FilterLabel;
45
+ set: (data: FilterData) => IFilter;
46
+ }
@@ -0,0 +1,76 @@
1
+ import type {
2
+ FilterConfig,
3
+ FilterInitParams,
4
+ FilterLabel,
5
+ FilterName,
6
+ FilterValue,
7
+ IFilter,
8
+ } from './Filter.types.ts';
9
+
10
+ export interface IFiltersManager {
11
+ filters: Map<FilterName, IFilter>;
12
+
13
+ hasFilter: (name: FilterName) => boolean;
14
+ getFilter: (name: FilterName) => IFilter;
15
+ addFilter: (
16
+ params: FilterInitParams,
17
+ payload?: object,
18
+ config?: FilterConfig,
19
+ ) => IFilter;
20
+ updateFilter: ({
21
+ name,
22
+ }: {
23
+ name: FilterName;
24
+ value?: FilterValue;
25
+ label?: FilterLabel;
26
+ }) => IFilter;
27
+ deleteFilter: (name: FilterName) => IFilter;
28
+
29
+ /**
30
+ * Converts filters data to String, that can be stored
31
+ */
32
+ toString: () => string;
33
+
34
+ /**
35
+ * Restores filters from string
36
+ */
37
+ fromString: (snapshotStr: string) => void;
38
+
39
+ /**
40
+ * deletes filters
41
+ * If include/exclude are not provided, all filters will be deleted
42
+ */
43
+ reset: ({
44
+ include,
45
+ exclude,
46
+ }?: {
47
+ include?: FilterName[];
48
+ exclude?: FilterName[];
49
+ }) => void;
50
+
51
+ /**
52
+ * @returns Array<FilterName>
53
+ */
54
+ getAllKeys: () => FilterName[];
55
+
56
+ /**
57
+ * @returns { FilterName: FilterValue }
58
+ */
59
+
60
+ getAllValues: () => { [name: FilterName]: FilterValue };
61
+ /**
62
+ * @returns Array<IFilter>
63
+ * @param include
64
+ * @param exclude
65
+ */
66
+
67
+ getFiltersList: ({
68
+ include,
69
+ exclude,
70
+ }?: {
71
+ include?: FilterName[];
72
+ exclude?: FilterName[];
73
+ }) => IFilter[];
74
+ }
75
+
76
+ export type FiltersManagerConfig = FilterConfig;
@@ -0,0 +1,140 @@
1
+ import { WtTableHeader } from '@webitel/ui-sdk/src/components/wt-table/types/WtTable';
2
+ import { sortToQueryAdapter } from '@webitel/ui-sdk/src/scripts';
3
+ import { SortSymbols } from '@webitel/ui-sdk/src/scripts/sortQueryAdapters';
4
+ import { defineStore } from 'pinia';
5
+ import { computed, ref } from 'vue';
6
+
7
+ import { PersistedStorageType } from '../persist/PersistedStorage.types';
8
+ import { usePersistedStorage } from '../persist/usePersistedStorage.ts';
9
+
10
+ export const createTableHeadersStore = (
11
+ namespace: string,
12
+ { headers: rawHeaders },
13
+ ) => {
14
+ const id = `${namespace}/headers`;
15
+
16
+ return defineStore(id, () => {
17
+ const headers = ref(rawHeaders);
18
+
19
+ const shownHeaders = computed(() => {
20
+ return headers.value.filter((header) => header.show);
21
+ });
22
+
23
+ const fields = computed(() => {
24
+ return shownHeaders.value.map((header) => header.field);
25
+ });
26
+
27
+ const sort = computed(() => {
28
+ const encodeSortQuery = ({ column, order }) =>
29
+ `${sortToQueryAdapter(order)}${column.field}`;
30
+
31
+ const sortedCol = headers.value.find((header) => header.sort);
32
+
33
+ return sortedCol
34
+ ? encodeSortQuery({ column: sortedCol, order: sortedCol.sort })
35
+ : null;
36
+ });
37
+
38
+ const $reset = () => {
39
+ headers.value = rawHeaders;
40
+ };
41
+
42
+ const updateShownHeaders = (value) => {
43
+ headers.value = value;
44
+ };
45
+
46
+ const updateFields = (fields: string[]) => {
47
+ const newHeaders = headers.value.map((header: WtTableHeader) => {
48
+ return {
49
+ ...header,
50
+ show: fields.includes(header.field),
51
+ };
52
+ });
53
+ updateShownHeaders(newHeaders);
54
+ };
55
+
56
+ const updateSort = (column) => {
57
+ const getNextSortOrder = (sort) => {
58
+ switch (sort) {
59
+ case SortSymbols.NONE:
60
+ return SortSymbols.ASC;
61
+ case SortSymbols.ASC:
62
+ return SortSymbols.DESC;
63
+ case SortSymbols.DESC:
64
+ return SortSymbols.NONE;
65
+ default:
66
+ return SortSymbols.ASC;
67
+ }
68
+ };
69
+
70
+ const changeHeadersSort = ({ headers, sortedHeader, order }) => {
71
+ return headers.map((header) => {
72
+ if (header.sort === undefined) return header;
73
+
74
+ // reset all headers by default
75
+ let newSort = null;
76
+
77
+ if (header.field === sortedHeader.field) {
78
+ newSort = order;
79
+ }
80
+
81
+ return {
82
+ ...header,
83
+ sort: newSort,
84
+ };
85
+ });
86
+ };
87
+
88
+ const order = getNextSortOrder(column.sort);
89
+
90
+ const newHeaders = changeHeadersSort({
91
+ headers: headers.value,
92
+ sortedHeader: column,
93
+ order,
94
+ });
95
+
96
+ headers.value = newHeaders;
97
+ };
98
+ const setupPersistence = async () => {
99
+ const { restore: restoreFields } = usePersistedStorage({
100
+ name: 'fields',
101
+ value: fields,
102
+ storages: [
103
+ PersistedStorageType.LocalStorage,
104
+ PersistedStorageType.Route,
105
+ ],
106
+ storagePath: id,
107
+ onStore: (save, { name }) => {
108
+ const value = fields.value.join(',');
109
+ return save({ name, value });
110
+ },
111
+ onRestore: async (restore, name) => {
112
+ const value = (await restore(name)) as string;
113
+ if (value) {
114
+ return updateFields(value.split(','));
115
+ }
116
+ },
117
+ });
118
+
119
+ const { restore: restoreSort } = usePersistedStorage({
120
+ name: 'sort',
121
+ value: sort,
122
+ });
123
+
124
+ return Promise.allSettled([restoreFields(), restoreSort()]);
125
+ };
126
+
127
+ return {
128
+ headers,
129
+ shownHeaders,
130
+ fields,
131
+ sort,
132
+
133
+ updateShownHeaders,
134
+ updateSort,
135
+
136
+ setupPersistence,
137
+ $reset,
138
+ };
139
+ });
140
+ };
package/src/index.d.ts ADDED
File without changes
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { createTableStore } from './table/createTableStore.store';
2
+
3
+ export { createTableStore };