@teipublisher/pb-components 2.26.1-next.3 → 3.0.0-next-4.1

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 (262) hide show
  1. package/.github/workflows/docker-cypress.yml +54 -0
  2. package/.github/workflows/main.yml +6 -4
  3. package/.github/workflows/node.js.yml +56 -21
  4. package/.github/workflows/release.js.yml +19 -17
  5. package/.releaserc.json +1 -1
  6. package/CHANGELOG.md +346 -11
  7. package/Dockerfile +78 -70
  8. package/README.md +112 -4
  9. package/css/components.css +5 -5
  10. package/css/gridjs/mermaid.min.css +1 -1
  11. package/css/leaflet/Control.Geocoder.css +1 -126
  12. package/css/leaflet/images/layers.png +0 -0
  13. package/css/tify/tify.css +6 -5
  14. package/css/tom-select/tom-select.bootstrap4.min.css +1 -1
  15. package/css/tom-select/tom-select.bootstrap5.min.css +1 -1
  16. package/css/tom-select/tom-select.default.min.css +1 -1
  17. package/css/tom-select/tom-select.default.min.css.map +1 -0
  18. package/css/tom-select/tom-select.min.css +1 -1
  19. package/cypress.config.js +84 -0
  20. package/dist/api.html +1 -1
  21. package/dist/css/design-system.css +607 -0
  22. package/dist/demo/bundle-test.html +4 -3
  23. package/dist/demo/components.css +46 -1
  24. package/dist/demo/design-system.html +710 -0
  25. package/dist/demo/dts-client.html +2 -2
  26. package/dist/demo/pb-autocomplete.html +23 -11
  27. package/dist/demo/pb-autocomplete2.html +66 -55
  28. package/dist/demo/pb-autocomplete3.html +17 -8
  29. package/dist/demo/pb-blacklab-highlight.html +28 -11
  30. package/dist/demo/pb-blacklab-results.html +3 -2
  31. package/dist/demo/pb-browse-docs.html +24 -24
  32. package/dist/demo/pb-browse-docs2.html +3 -3
  33. package/dist/demo/pb-clipboard.html +32 -28
  34. package/dist/demo/pb-code-editor.html +6 -6
  35. package/dist/demo/pb-code-highlight.html +63 -63
  36. package/dist/demo/pb-codepen.html +1 -1
  37. package/dist/demo/pb-collapse.html +1 -1
  38. package/dist/demo/pb-collapse2.html +2 -2
  39. package/dist/demo/pb-combo-box.html +135 -130
  40. package/dist/demo/pb-custom-form.html +64 -55
  41. package/dist/demo/pb-dialog.html +12 -6
  42. package/dist/demo/pb-document.html +1 -1
  43. package/dist/demo/pb-download.html +68 -59
  44. package/dist/demo/pb-drawer.html +67 -46
  45. package/dist/demo/pb-drawer2.html +65 -58
  46. package/dist/demo/pb-edit-app.html +2 -2
  47. package/dist/demo/pb-edit-xml.html +1 -1
  48. package/dist/demo/pb-facsimile-2.html +26 -11
  49. package/dist/demo/pb-facsimile-3.html +25 -10
  50. package/dist/demo/pb-facsimile-dedup-test-2.html +48 -0
  51. package/dist/demo/pb-facsimile-dedup-test.html +48 -0
  52. package/dist/demo/pb-facsimile.html +4 -4
  53. package/dist/demo/pb-formula.html +1 -1
  54. package/dist/demo/pb-grid.html +22 -8
  55. package/dist/demo/pb-highlight.html +2 -2
  56. package/dist/demo/pb-i18n-simple.html +1 -0
  57. package/dist/demo/pb-i18n.html +15 -5
  58. package/dist/demo/pb-image-strip-standalone.html +2 -2
  59. package/dist/demo/pb-image-strip-view.html +2 -2
  60. package/dist/demo/pb-leaflet-map.html +3 -3
  61. package/dist/demo/pb-leaflet-map2.html +2 -2
  62. package/dist/demo/pb-leaflet-map3.html +3 -3
  63. package/dist/demo/pb-link.html +1 -1
  64. package/dist/demo/pb-load.html +2 -6
  65. package/dist/demo/pb-login.html +1 -3
  66. package/dist/demo/pb-manage-odds.html +9 -4
  67. package/dist/demo/pb-markdown.html +1 -1
  68. package/dist/demo/pb-media-query.html +2 -2
  69. package/dist/demo/pb-mei.html +2 -2
  70. package/dist/demo/pb-mei2.html +2 -2
  71. package/dist/demo/pb-message.html +2 -3
  72. package/dist/demo/pb-odd-editor.html +54 -52
  73. package/dist/demo/pb-page-header.html +27 -0
  74. package/dist/demo/pb-popover.html +1 -1
  75. package/dist/demo/pb-print-preview.html +2 -2
  76. package/dist/demo/pb-progress.html +4 -4
  77. package/dist/demo/pb-repeat.html +32 -36
  78. package/dist/demo/pb-search.html +16 -5
  79. package/dist/demo/pb-search2.html +4 -4
  80. package/dist/demo/pb-search3.html +3 -3
  81. package/dist/demo/pb-search4.html +3 -3
  82. package/dist/demo/pb-select-feature.html +4 -4
  83. package/dist/demo/pb-select-feature2.html +4 -4
  84. package/dist/demo/pb-select-feature3.html +2 -2
  85. package/dist/demo/pb-select-i18n.html +58 -53
  86. package/dist/demo/pb-select-odd.html +1 -1
  87. package/dist/demo/pb-select.html +190 -75
  88. package/dist/demo/pb-select2.html +91 -37
  89. package/dist/demo/pb-select3.html +109 -41
  90. package/dist/demo/pb-svg.html +1 -1
  91. package/dist/demo/pb-table-grid.html +26 -15
  92. package/dist/demo/pb-tabs.html +15 -7
  93. package/dist/demo/pb-tify.html +7 -7
  94. package/dist/demo/pb-timeline.html +1 -1
  95. package/dist/demo/pb-timeline2.html +1 -1
  96. package/dist/demo/pb-toggle-feature.html +26 -23
  97. package/dist/demo/pb-toggle-feature2.html +4 -4
  98. package/dist/demo/pb-toggle-feature3.html +2 -2
  99. package/dist/demo/pb-toggle-feature4.html +56 -54
  100. package/dist/demo/pb-version.html +2 -2
  101. package/dist/demo/pb-view.html +78 -40
  102. package/dist/demo/pb-view2.html +69 -46
  103. package/dist/demo/pb-view3.html +53 -48
  104. package/dist/demo/pb-view4.html +70 -49
  105. package/dist/demo/pb-zoom.html +2 -2
  106. package/dist/{es-global-bridge-d8ce175d.js → es-global-bridge-D8ZcUcx_.js} +0 -4
  107. package/dist/focus-mixin-VCsFap6b.js +768 -0
  108. package/dist/images/icons.svg +217 -0
  109. package/dist/jinn-codemirror-DETLdm08.js +1 -0
  110. package/dist/lib/openseadragon.min.js +80 -0
  111. package/dist/lib/openseadragon.min.js.map +1 -0
  112. package/dist/pb-code-editor.js +25 -20
  113. package/dist/pb-component-docs.js +414 -3225
  114. package/dist/pb-components-bundle.js +3046 -4402
  115. package/dist/pb-dialog-tklYGWfc.js +121 -0
  116. package/dist/pb-edit-app.js +208 -107
  117. package/dist/pb-elements.json +716 -249
  118. package/dist/pb-facsimile.js +46 -0
  119. package/dist/pb-i18n-C0NDma4h.js +1 -0
  120. package/dist/pb-leaflet-map.js +23 -23
  121. package/dist/pb-mei.js +152 -134
  122. package/dist/pb-mixin-DHoWQheB.js +1 -0
  123. package/dist/pb-odd-editor.js +1671 -1231
  124. package/dist/pb-tify.js +1 -27
  125. package/dist/unsafe-html-D5VGo9Oq.js +1 -0
  126. package/dist/urls-BEONu_g4.js +1 -0
  127. package/eslint.config.mjs +92 -0
  128. package/gh-pages.js +5 -3
  129. package/i18n/common/en.json +6 -0
  130. package/i18n/common/pl.json +2 -2
  131. package/images/icons.svg +217 -0
  132. package/index.html +0 -5
  133. package/lib/leaflet-src.js.map +1 -0
  134. package/lib/leaflet.markercluster-src.js.map +1 -0
  135. package/lib/openseadragon.min.js +6 -6
  136. package/package.json +56 -81
  137. package/pb-elements.json +716 -249
  138. package/rollup.config.mjs +312 -0
  139. package/src/assets/components.css +5 -5
  140. package/src/assets/design-system.css +607 -0
  141. package/src/authority/airtable.js +20 -21
  142. package/src/authority/anton.js +129 -129
  143. package/src/authority/custom.js +70 -27
  144. package/src/authority/geonames.js +38 -32
  145. package/src/authority/gnd.js +50 -42
  146. package/src/authority/kbga.js +136 -134
  147. package/src/authority/metagrid.js +44 -46
  148. package/src/authority/reconciliation.js +66 -68
  149. package/src/authority/registry.js +4 -4
  150. package/src/docs/demo-utils.js +91 -0
  151. package/src/docs/pb-component-docs.js +287 -147
  152. package/src/docs/pb-component-view.js +380 -273
  153. package/src/docs/pb-components-list.js +115 -51
  154. package/src/docs/pb-demo-snippet.js +199 -174
  155. package/src/dts-client.js +306 -303
  156. package/src/dts-select-endpoint.js +125 -85
  157. package/src/parse-date-service.js +184 -135
  158. package/src/pb-ajax.js +175 -173
  159. package/src/pb-authority-lookup.js +198 -158
  160. package/src/pb-autocomplete.js +731 -313
  161. package/src/pb-blacklab-highlight.js +266 -260
  162. package/src/pb-blacklab-results.js +230 -225
  163. package/src/pb-browse-docs.js +601 -484
  164. package/src/pb-browse.js +68 -65
  165. package/src/pb-clipboard.js +97 -76
  166. package/src/pb-code-editor.js +111 -103
  167. package/src/pb-code-highlight.js +234 -204
  168. package/src/pb-codepen.js +81 -73
  169. package/src/pb-collapse.js +265 -152
  170. package/src/pb-combo-box.js +191 -191
  171. package/src/pb-components-bundle.js +1 -7
  172. package/src/pb-components.js +2 -6
  173. package/src/pb-custom-form.js +230 -141
  174. package/src/pb-dialog.js +99 -63
  175. package/src/pb-document.js +118 -91
  176. package/src/pb-download.js +214 -198
  177. package/src/pb-drawer.js +146 -149
  178. package/src/pb-edit-app.js +471 -240
  179. package/src/pb-edit-xml.js +101 -98
  180. package/src/pb-events.js +126 -107
  181. package/src/pb-facs-link.js +130 -101
  182. package/src/pb-facsimile.js +494 -410
  183. package/src/pb-fetch.js +389 -0
  184. package/src/pb-formula.js +152 -154
  185. package/src/pb-geolocation.js +130 -132
  186. package/src/pb-grid-action.js +59 -56
  187. package/src/pb-grid.js +388 -228
  188. package/src/pb-highlight.js +142 -142
  189. package/src/pb-hotkeys.js +40 -42
  190. package/src/pb-i18n.js +115 -127
  191. package/src/pb-icon-button.js +108 -0
  192. package/src/pb-icon.js +283 -0
  193. package/src/pb-image-strip.js +85 -79
  194. package/src/pb-lang.js +142 -57
  195. package/src/pb-leaflet-map.js +551 -483
  196. package/src/pb-link.js +132 -126
  197. package/src/pb-load.js +495 -428
  198. package/src/pb-login.js +303 -248
  199. package/src/pb-manage-odds.js +384 -338
  200. package/src/pb-map-icon.js +90 -90
  201. package/src/pb-map-layer.js +86 -86
  202. package/src/pb-markdown.js +107 -110
  203. package/src/pb-media-query.js +75 -73
  204. package/src/pb-mei.js +523 -303
  205. package/src/pb-message.js +144 -98
  206. package/src/pb-mixin.js +268 -265
  207. package/src/pb-navigation.js +83 -96
  208. package/src/pb-observable.js +39 -39
  209. package/src/pb-odd-editor.js +1209 -948
  210. package/src/pb-odd-elementspec-editor.js +375 -310
  211. package/src/pb-odd-model-editor.js +1189 -941
  212. package/src/pb-odd-parameter-editor.js +269 -170
  213. package/src/pb-odd-rendition-editor.js +184 -131
  214. package/src/pb-page.js +451 -422
  215. package/src/pb-paginate.js +260 -178
  216. package/src/pb-panel.js +217 -183
  217. package/src/pb-popover-themes.js +16 -9
  218. package/src/pb-popover.js +297 -288
  219. package/src/pb-print-preview.js +128 -128
  220. package/src/pb-progress.js +52 -52
  221. package/src/pb-repeat.js +141 -108
  222. package/src/pb-restricted.js +85 -78
  223. package/src/pb-search.js +258 -230
  224. package/src/pb-select-feature.js +210 -126
  225. package/src/pb-select-odd.js +184 -118
  226. package/src/pb-select-template.js +113 -78
  227. package/src/pb-select.js +330 -229
  228. package/src/pb-split-list.js +181 -176
  229. package/src/pb-svg.js +81 -80
  230. package/src/pb-table-column.js +55 -55
  231. package/src/pb-table-grid.js +334 -205
  232. package/src/pb-tabs.js +238 -61
  233. package/src/pb-tify.js +3331 -126
  234. package/src/pb-timeline.js +394 -255
  235. package/src/pb-toggle-feature.js +196 -188
  236. package/src/pb-upload.js +201 -176
  237. package/src/pb-version.js +22 -34
  238. package/src/pb-view-annotate.js +138 -102
  239. package/src/pb-view.js +1722 -1272
  240. package/src/pb-zoom.js +144 -46
  241. package/src/search-result-service.js +256 -223
  242. package/src/seed-element.js +14 -22
  243. package/src/settings.js +4 -4
  244. package/src/theming.js +98 -91
  245. package/src/urls.js +403 -289
  246. package/src/utils.js +53 -51
  247. package/vite.config.js +86 -0
  248. package/css/pb-styles.css +0 -51
  249. package/dist/iron-form-3b8dcaa7.js +0 -210
  250. package/dist/jinn-codemirror-da0e2d1f.js +0 -1
  251. package/dist/paper-checkbox-515a5284.js +0 -1597
  252. package/dist/paper-icon-button-b1d31571.js +0 -398
  253. package/dist/paper-listbox-a3b7175c.js +0 -1265
  254. package/dist/pb-i18n-0611135a.js +0 -1
  255. package/dist/pb-mixin-b1caa22e.js +0 -158
  256. package/dist/polymer-hack.js +0 -1
  257. package/dist/vaadin-element-mixin-fe4a4883.js +0 -527
  258. package/lib/Control.Geocoder.min.js +0 -2
  259. package/lib/Control.Geocoder.min.js.map +0 -1
  260. package/src/assets/pb-styles.css +0 -51
  261. package/src/pb-light-dom.js +0 -41
  262. package/src/polymer-hack.js +0 -6
@@ -1,30 +1,30 @@
1
- import { get as i18n } from "./pb-i18n.js";
1
+ import { get as i18n } from './pb-i18n.js';
2
2
 
3
3
  export class SearchResultService {
4
4
  /*
5
- * SEARCH RESULT OBJECT
6
- * Service that loads initial data from a datasource,
7
- * can be a database or an API, and converts it in
8
- * a format that can be used by the pb-timeline component.
9
- *
10
- * public methods:
11
- * getMinDateStr()
12
- * getMaxDateStr()
13
- * getMinDate()
14
- * getMaxDate()
15
- * export()
16
- * getIntervalSizes()
17
- */
5
+ * SEARCH RESULT OBJECT
6
+ * Service that loads initial data from a datasource,
7
+ * can be a database or an API, and converts it in
8
+ * a format that can be used by the pb-timeline component.
9
+ *
10
+ * public methods:
11
+ * getMinDateStr()
12
+ * getMaxDateStr()
13
+ * getMinDate()
14
+ * getMaxDate()
15
+ * export()
16
+ * getIntervalSizes()
17
+ */
18
18
 
19
19
  /*
20
- * CONSRTUCTOR INPUTS EXPLAINED
21
- * jsonData: data to load, object with
22
- * keys => valid datestrings formatted YYYY-MM-DD
23
- * values => number of results for this day
24
- * maxInterval: max amount of bins allowed
25
- * scopes: array of all 6 possible values for scope
26
- */
27
- constructor(jsonData = {}, maxInterval = 60, scopes = ["D", "W", "M", "Y", "5Y", "10Y"]) {
20
+ * CONSRTUCTOR INPUTS EXPLAINED
21
+ * jsonData: data to load, object with
22
+ * keys => valid datestrings formatted YYYY-MM-DD
23
+ * values => number of results for this day
24
+ * maxInterval: max amount of bins allowed
25
+ * scopes: array of all 6 possible values for scope
26
+ */
27
+ constructor(jsonData = {}, maxInterval = 60, scopes = ['D', 'W', 'M', 'Y', '5Y', '10Y']) {
28
28
  this.data = { invalid: {}, valid: {} };
29
29
  this.maxInterval = maxInterval;
30
30
  this.scopes = scopes;
@@ -32,20 +32,23 @@ export class SearchResultService {
32
32
  }
33
33
 
34
34
  /*
35
- * based on the loaded jsonData, compute
36
- * - min date as dateStr or utc-date-object
37
- * - max date as dateStr or utc-date-object
38
- */
35
+ * based on the loaded jsonData, compute
36
+ * - min date as dateStr or utc-date-object
37
+ * - max date as dateStr or utc-date-object
38
+ */
39
39
  getMinDateStr() {
40
40
  return Object.keys(this.data.valid).sort()[0];
41
41
  }
42
+
42
43
  getMaxDateStr() {
43
- let days = Object.keys(this.data.valid);
44
+ const days = Object.keys(this.data.valid);
44
45
  return days.sort()[days.length - 1];
45
46
  }
47
+
46
48
  getMinDate() {
47
49
  return this._dateStrToUTCDate(this.getMinDateStr());
48
50
  }
51
+
49
52
  getMaxDate() {
50
53
  return this._dateStrToUTCDate(this.getMaxDateStr());
51
54
  }
@@ -53,25 +56,27 @@ export class SearchResultService {
53
56
  getEndOfRangeDate(scope, date) {
54
57
  return this._UTCDateToDateStr(this._increaseDateBy(scope, date));
55
58
  }
56
-
59
+
57
60
  /*
58
- * exports data for each scope
59
- * when no argument is provided, the optimal scope based
60
- * on the maxInterval (default 60) will be assigned
61
- */
61
+ * exports data for each scope
62
+ * when no argument is provided, the optimal scope based
63
+ * on the maxInterval (default 60) will be assigned
64
+ */
62
65
  export(scope) {
63
66
  // auto assign scope when no argument provided
64
67
  scope = scope || this._autoAssignScope();
65
68
  // validate scope
66
69
  if (!this.scopes.includes(scope)) {
67
- throw new Error(`invalid scope provided, expected: ["10Y", "5Y", "Y", "M", "W", "D"]. Got: "${scope}"`);
70
+ throw new Error(
71
+ `invalid scope provided, expected: ["10Y", "5Y", "Y", "M", "W", "D"]. Got: "${scope}"`,
72
+ );
68
73
  }
69
74
  // initialize object to export
70
75
  const exportData = {
71
76
  data: [],
72
- scope: scope,
73
- binTitleRotated: this._binTitleRotatedLookup(scope)
74
- }
77
+ scope,
78
+ binTitleRotated: this._binTitleRotatedLookup(scope),
79
+ };
75
80
  if (Object.keys(this.data.valid).length === 0) {
76
81
  return exportData;
77
82
  }
@@ -88,29 +93,31 @@ export class SearchResultService {
88
93
  currentDate = this._increaseDateBy(scope, currentDate);
89
94
  }
90
95
  // count all values
91
- Object.keys(this.data.valid).sort().forEach(dateStr => {
92
- const currentCategory = this._classify(dateStr, scope);
93
- const targetBinObject = exportData.data.find(it => it.category === currentCategory);
94
- try {
95
- const value = this.data.valid[dateStr];
96
- if (typeof value === 'object') {
97
- targetBinObject.value += value.count || 0;
98
- if (value.info) {
99
- targetBinObject.info = targetBinObject.info.concat(value.info);
96
+ Object.keys(this.data.valid)
97
+ .sort()
98
+ .forEach(dateStr => {
99
+ const currentCategory = this._classify(dateStr, scope);
100
+ const targetBinObject = exportData.data.find(it => it.category === currentCategory);
101
+ try {
102
+ const value = this.data.valid[dateStr];
103
+ if (typeof value === 'object') {
104
+ targetBinObject.value += value.count || 0;
105
+ if (value.info) {
106
+ targetBinObject.info = targetBinObject.info.concat(value.info);
107
+ }
108
+ } else {
109
+ targetBinObject.value += this.data.valid[dateStr] || 0;
100
110
  }
101
- } else {
102
- targetBinObject.value += this.data.valid[dateStr] || 0;
111
+ } catch (e) {
112
+ console.log(e);
113
+ console.log('currentCategory');
114
+ console.log(currentCategory);
103
115
  }
104
- } catch(e) {
105
- console.log(e);
106
- console.log("currentCategory");
107
- console.log(currentCategory);
108
- }
109
- });
116
+ });
110
117
  if (this.data.invalid) {
111
118
  let invalid = 0;
112
119
  let info = [];
113
- Object.values(this.data.invalid).forEach((value) => {
120
+ Object.values(this.data.invalid).forEach(value => {
114
121
  if (typeof value === 'object') {
115
122
  invalid += value.count || 0;
116
123
  info = info.concat(value.info);
@@ -126,7 +133,7 @@ export class SearchResultService {
126
133
  category: '?',
127
134
  separator: true,
128
135
  value: invalid,
129
- info
136
+ info,
130
137
  });
131
138
  }
132
139
  }
@@ -134,67 +141,73 @@ export class SearchResultService {
134
141
  }
135
142
 
136
143
  /*
137
- * returns optimal scope based on the maxInterval
138
- * by computing the scope that meets the criteria
139
- * nbr of bins <= maxInterval
140
- */
144
+ * returns optimal scope based on the maxInterval
145
+ * by computing the scope that meets the criteria
146
+ * nbr of bins <= maxInterval
147
+ */
141
148
  _autoAssignScope() {
142
149
  for (let i = 0; i < this.scopes.length; i++) {
143
150
  if (this._computeIntervalSize(this.scopes[i]) <= this.maxInterval) {
144
151
  return this.scopes[i];
145
152
  }
146
153
  }
147
- throw new Error(`Interval too big! Computed: ${this._computeIntervalSize(this.scopes[i])}. Allowed: ${this.maxInterval}. Try to increase maxInterval.`);
154
+ throw new Error(
155
+ `Interval too big! Computed: ${this._computeIntervalSize(this.scopes[i])}. Allowed: ${
156
+ this.maxInterval
157
+ }. Try to increase maxInterval.`,
158
+ );
148
159
  }
149
160
 
150
161
  /*
151
- * splits input data in 2 sections
152
- * => valid data
153
- * => invalid (if not a vaid date, for example 2012-00-00 is invalid)
154
- */
162
+ * splits input data in 2 sections
163
+ * => valid data
164
+ * => invalid (if not a vaid date, for example 2012-00-00 is invalid)
165
+ */
155
166
  _validateJsonData(jsonData) {
156
- Object.keys(jsonData).sort().forEach(key => {
157
- if (this._isValidDateStr(key)) {
158
- this.data.valid[key] = jsonData[key];
159
- } else {
160
- this.data.invalid[key] = jsonData[key];
161
- }
162
- });
167
+ Object.keys(jsonData)
168
+ .sort()
169
+ .forEach(key => {
170
+ if (this._isValidDateStr(key)) {
171
+ this.data.valid[key] = jsonData[key];
172
+ } else {
173
+ this.data.invalid[key] = jsonData[key];
174
+ }
175
+ });
163
176
  }
164
177
 
165
178
  /*
166
- * lookup table which bin titles should be rotated
167
- */
179
+ * lookup table which bin titles should be rotated
180
+ */
168
181
  _binTitleRotatedLookup(scope) {
169
182
  const lookup = {
170
- "10Y": true,
171
- "5Y": true,
172
- "Y": true,
173
- "M": false, // only exception not to rotate in monthly scope
174
- "W": true,
175
- "D": true,
176
- }
183
+ '10Y': true,
184
+ '5Y': true,
185
+ Y: true,
186
+ M: false, // only exception not to rotate in monthly scope
187
+ W: true,
188
+ D: true,
189
+ };
177
190
  return lookup[scope];
178
191
  }
179
192
 
180
193
  /*
181
- * Helper method that builds a binObject that
182
- * can be read by the pb-timeline component
183
- */
194
+ * Helper method that builds a binObject that
195
+ * can be read by the pb-timeline component
196
+ */
184
197
  _buildBinObject(dateStr, category, scope) {
185
- const split = dateStr.split("-");
198
+ const split = dateStr.split('-');
186
199
  const yearStr = split[0];
187
200
  const monthStr = split[1];
188
201
  const dayStr = split[2];
189
202
  // for all scopes this remains the same
190
203
  const binObject = {
191
- dateStr: dateStr,
192
- category: category,
204
+ dateStr,
205
+ category,
193
206
  value: 0,
194
- info: []
195
- }
207
+ info: [],
208
+ };
196
209
  // scope specific bin data
197
- if (scope === "10Y") {
210
+ if (scope === '10Y') {
198
211
  binObject.tooltip = `${category} - ${Number(category) + 9}`; // 1900 - 1999
199
212
  binObject.selectionStart = `${category}`;
200
213
  binObject.selectionEnd = `${Number(category) + 9}`;
@@ -203,8 +216,8 @@ export class SearchResultService {
203
216
  binObject.title = `${category} - ${Number(category) + 99}`;
204
217
  binObject.binTitle = category;
205
218
  binObject.seperator = true;
206
- };
207
- } else if (scope === "5Y") {
219
+ }
220
+ } else if (scope === '5Y') {
208
221
  binObject.tooltip = `${category} - ${Number(category) + 4}`; // 1995 - 1999
209
222
  binObject.selectionStart = `${category}`;
210
223
  binObject.selectionEnd = `${Number(category) + 4}`;
@@ -214,7 +227,7 @@ export class SearchResultService {
214
227
  binObject.binTitle = category;
215
228
  binObject.seperator = true;
216
229
  }
217
- } else if (scope === "Y") {
230
+ } else if (scope === 'Y') {
218
231
  binObject.tooltip = category;
219
232
  binObject.selectionStart = category;
220
233
  binObject.selectionEnd = category;
@@ -224,7 +237,7 @@ export class SearchResultService {
224
237
  binObject.binTitle = `${category}`;
225
238
  binObject.seperator = true;
226
239
  }
227
- } else if (scope === "M") {
240
+ } else if (scope === 'M') {
228
241
  const monthNum = Number(monthStr);
229
242
  const month = this._monthLookup(monthNum); // Jan,Feb,Mar,...,Nov,Dez
230
243
  binObject.binTitle = month[0]; // J,F,M,A,M,J,J,..N,D
@@ -236,122 +249,134 @@ export class SearchResultService {
236
249
  binObject.title = yearStr; // YYYY
237
250
  binObject.seperator = true;
238
251
  }
239
- } else if (scope === "W") {
240
- const week = category.split("-")[1];; // => W52
252
+ } else if (scope === 'W') {
253
+ const week = category.split('-')[1]; // => W52
241
254
  binObject.tooltip = `${yearStr} ${week}`; // 1996 W52
242
255
  binObject.selectionStart = `${yearStr} ${week}`; // 1996 W52
243
256
  binObject.selectionEnd = `${yearStr} ${week}`; // 1996 W52
244
- let currentDate = this._dateStrToUTCDate(dateStr);
245
- let lastWeek = this._addDays(currentDate, -7);
257
+ const currentDate = this._dateStrToUTCDate(dateStr);
258
+ const lastWeek = this._addDays(currentDate, -7);
246
259
  // title and binTitle every first monday of the month
247
260
  if (currentDate.getUTCMonth() !== lastWeek.getUTCMonth()) {
248
261
  binObject.binTitle = week;
249
262
  binObject.title = this._monthLookup(currentDate.getUTCMonth() + 1);
250
263
  }
251
264
  // seperator every start of the year
252
- binObject.seperator = week === "W1";
253
- } else if (scope === "D") {
265
+ binObject.seperator = week === 'W1';
266
+ } else if (scope === 'D') {
254
267
  binObject.tooltip = dateStr;
255
268
  binObject.selectionStart = dateStr;
256
269
  binObject.selectionEnd = dateStr;
257
270
  // every monday
258
271
  if (this._dateStrToUTCDate(dateStr).getUTCDay() === 1) {
259
272
  binObject.binTitle = `${Number(dayStr)}.${Number(monthStr)}`;
260
- binObject.title = `${this._classify(dateStr, "W").replace("-", " ")}`;
273
+ binObject.title = `${this._classify(dateStr, 'W').replace('-', ' ')}`;
261
274
  binObject.seperator = true;
262
275
  }
263
276
  } else {
264
- throw new Error(`invalid scope provided, expected: ["10Y", "5Y", "Y", "M", "W", "D"]. Got: "${scope}"`);
277
+ throw new Error(
278
+ `invalid scope provided, expected: ["10Y", "5Y", "Y", "M", "W", "D"]. Got: "${scope}"`,
279
+ );
265
280
  }
266
281
  return binObject;
267
282
  }
268
283
 
269
284
  /*
270
- * ...classifies dateStr into category (based on scope)
271
- * EXAMPLES:
272
- * _classify("2016-01-12", "10Y") // => "2010"
273
- * _classify("2016-01-12", "5Y") // => "2015"
274
- * _classify("2016-01-12", "Y") // => "2016"
275
- * _classify("2016-01-12", "M") // => "2010-01"
276
- * _classify("2016-01-12", "W") // => "2016-W2"
277
- * _classify("2016-01-12", "D") // => "2016-01-12"
278
- */
279
- _classify(dateStr, scope) { // returns category (as string)
280
- if (!dateStr.match(/^\d{4}-\d{2}-\d{2}$/)) { // quick validate dateStr
285
+ * ...classifies dateStr into category (based on scope)
286
+ * EXAMPLES:
287
+ * _classify("2016-01-12", "10Y") // => "2010"
288
+ * _classify("2016-01-12", "5Y") // => "2015"
289
+ * _classify("2016-01-12", "Y") // => "2016"
290
+ * _classify("2016-01-12", "M") // => "2010-01"
291
+ * _classify("2016-01-12", "W") // => "2016-W2"
292
+ * _classify("2016-01-12", "D") // => "2016-01-12"
293
+ */
294
+ _classify(dateStr, scope) {
295
+ // returns category (as string)
296
+ if (!dateStr.match(/^\d{4}-\d{2}-\d{2}$/)) {
297
+ // quick validate dateStr
281
298
  throw new Error(`invalid dateStr format, expected "YYYY-MM-DD", got: "${dateStr}".`);
282
299
  }
283
- if (!dateStr || !scope) { // both inputs provided
300
+ if (!dateStr || !scope) {
301
+ // both inputs provided
284
302
  throw new Error(`both inputs must be provided. Got dateStr=${dateStr}, scope=${scope}`);
285
303
  }
286
304
  switch (scope) {
287
- case "10Y": case "5Y":
288
- const intervalSize = Number(scope.replace("Y", ""));
289
- const startYear = Math.floor(Number(dateStr.split("-")[0]) / intervalSize) * intervalSize;
305
+ case '10Y':
306
+ case '5Y':
307
+ const intervalSize = Number(scope.replace('Y', ''));
308
+ const startYear = Math.floor(Number(dateStr.split('-')[0]) / intervalSize) * intervalSize;
290
309
  return startYear.toString();
291
- case "Y":
310
+ case 'Y':
292
311
  return dateStr.substr(0, 4);
293
- case "M":
312
+ case 'M':
294
313
  return dateStr.substr(0, 7);
295
- case "W":
314
+ case 'W':
296
315
  const UTCDate = this._dateStrToUTCDate(dateStr);
297
316
  return this._UTCDateToWeekFormat(UTCDate);
298
- case "D":
317
+ case 'D':
299
318
  return dateStr;
300
319
  }
301
320
  }
302
321
 
303
322
  /*
304
- * ...gets first day as UTC Date, based on the category
305
- * EXAMPLES:
306
- * _getFirstDay("2010") // => 2010-01-01
307
- * _getFirstDay("2010-12") // => 2010-12-01
308
- * _getFirstDay("2010-W10") // => 2010-03-08
309
- */
323
+ * ...gets first day as UTC Date, based on the category
324
+ * EXAMPLES:
325
+ * _getFirstDay("2010") // => 2010-01-01
326
+ * _getFirstDay("2010-12") // => 2010-12-01
327
+ * _getFirstDay("2010-W10") // => 2010-03-08
328
+ */
310
329
  _getFirstDay(categoryStr) {
311
- if (categoryStr.match(/^\d{4}-\d{2}-\d{2}$/)) { // YYYY-MM-DD => return same value
330
+ if (categoryStr.match(/^\d{4}-\d{2}-\d{2}$/)) {
331
+ // YYYY-MM-DD => return same value
312
332
  return categoryStr;
313
333
  }
314
- if (categoryStr.match(/^\d{4}-\d{2}$/)) { // YYYY-MM
315
- return `${categoryStr}-01`; // add -01
334
+ if (categoryStr.match(/^\d{4}-\d{2}$/)) {
335
+ // YYYY-MM
336
+ return `${categoryStr}-01`; // add -01
316
337
  }
317
- if (categoryStr.match(/^\d{4}$/)) { // YYYY
318
- return `${categoryStr}-01-01`; // add -01-01
338
+ if (categoryStr.match(/^\d{4}$/)) {
339
+ // YYYY
340
+ return `${categoryStr}-01-01`; // add -01-01
319
341
  }
320
- if (categoryStr.match(/^\d{4}-W([1-9]|[1-4][0-9]|5[0-3])$/)) { // YYYY-W? // ? => [1-53]
342
+ if (categoryStr.match(/^\d{4}-W([1-9]|[1-4][0-9]|5[0-3])$/)) {
343
+ // YYYY-W? // ? => [1-53]
321
344
  // |YYYY-W |1-9 | 10-49 | 50-53 |
322
- const split = categoryStr.split("-");
345
+ const split = categoryStr.split('-');
323
346
  const year = Number(split[0]);
324
- const weekNumber = Number(split[1].replace("W", ""));
347
+ const weekNumber = Number(split[1].replace('W', ''));
325
348
  return this._getDateStrOfISOWeek(year, weekNumber);
326
349
  }
327
- throw new Error("invalid categoryStr");
350
+ throw new Error('invalid categoryStr');
328
351
  }
329
352
 
330
353
  /*
331
- * converts dateStr (YYYY-MM-DD) to a date object in UTC time
332
- */
354
+ * converts dateStr (YYYY-MM-DD) to a date object in UTC time
355
+ */
333
356
  _dateStrToUTCDate(dateStr) {
334
357
  if (!this._isValidDateStr(dateStr)) {
335
- throw new Error(`invalid dateStr, expected "YYYY-MM-DD" with month[1-12] and day[1-31], got: "${dateStr}".`);
358
+ throw new Error(
359
+ `invalid dateStr, expected "YYYY-MM-DD" with month[1-12] and day[1-31], got: "${dateStr}".`,
360
+ );
336
361
  }
337
- const split = dateStr.split("-");
338
- const year = Number(split[0]);
362
+ const split = dateStr.split('-');
363
+ const year = Number(split[0]);
339
364
  const month = Number(split[1]);
340
- const day = Number(split[2]);
365
+ const day = Number(split[2]);
341
366
  return new Date(Date.UTC(year, month - 1, day));
342
367
  }
343
368
 
344
369
  /*
345
- * converts a UTC date object to a dateStr (YYYY-MM-DD)
346
- */
370
+ * converts a UTC date object to a dateStr (YYYY-MM-DD)
371
+ */
347
372
  _UTCDateToDateStr(UTCDate) {
348
- return UTCDate.toISOString().split("T")[0];
373
+ return UTCDate.toISOString().split('T')[0];
349
374
  }
350
375
 
351
376
  /*
352
- * example:
353
- * 1 Jan 2020 => 2020-W1
354
- */
377
+ * example:
378
+ * 1 Jan 2020 => 2020-W1
379
+ */
355
380
  _UTCDateToWeekFormat(UTCDate) {
356
381
  const year = this._getISOWeekYear(UTCDate);
357
382
  const weekNbr = this._getISOWeek(UTCDate);
@@ -362,56 +387,63 @@ export class SearchResultService {
362
387
  * returns the ISO week (_getISOWeek) or year (_getISOWeekYear)
363
388
  * as number based on a UTC date.
364
389
  */
365
- _getISOWeek(UTCDate) { // https://weeknumber.net/how-to/javascript
366
- let date = new Date(UTCDate.getTime());
390
+ _getISOWeek(UTCDate) {
391
+ // https://weeknumber.net/how-to/javascript
392
+ const date = new Date(UTCDate.getTime());
367
393
  date.setHours(0, 0, 0, 0);
368
394
  // Thursday in current week decides the year.
369
- date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
395
+ date.setDate(date.getDate() + 3 - ((date.getDay() + 6) % 7));
370
396
  // January 4 is always in week 1.
371
- let week1 = new Date(date.getFullYear(), 0, 4);
397
+ const week1 = new Date(date.getFullYear(), 0, 4);
372
398
  // Adjust to Thursday in week 1 and count number of weeks from date to week1.
373
- return 1 + Math.round(((date.getTime() - week1.getTime()) / 86400000
374
- - 3 + (week1.getDay() + 6) % 7) / 7);
399
+ return (
400
+ 1 +
401
+ Math.round(
402
+ ((date.getTime() - week1.getTime()) / 86400000 - 3 + ((week1.getDay() + 6) % 7)) / 7,
403
+ )
404
+ );
375
405
  }
406
+
376
407
  /*
377
- * returns the ISO week year as number based on a UTC date
378
- * this is only needed for rollovers, for example:
379
- * => 1.jan 2011 is in W52 of year 2010.
380
- */
381
- _getISOWeekYear(UTCDate) { // https://weeknumber.net/how-to/javascript
382
- var date = new Date(UTCDate.getTime());
383
- date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
408
+ * returns the ISO week year as number based on a UTC date
409
+ * this is only needed for rollovers, for example:
410
+ * => 1.jan 2011 is in W52 of year 2010.
411
+ */
412
+ _getISOWeekYear(UTCDate) {
413
+ // https://weeknumber.net/how-to/javascript
414
+ const date = new Date(UTCDate.getTime());
415
+ date.setDate(date.getDate() + 3 - ((date.getDay() + 6) % 7));
384
416
  return date.getFullYear();
385
417
  }
386
418
 
387
419
  /*
388
- * given the year and weeknumber -> return dateStr (YYYY-MM-DD)
389
- */
390
- _getDateStrOfISOWeek(year, weekNumber) { // https://stackoverflow.com/a/16591175/6272061
391
- let simple = new Date(Date.UTC(year, 0, 1 + (weekNumber - 1) * 7));
392
- let dow = simple.getUTCDay();
393
- let ISOweekStart = simple;
394
- if (dow <= 4)
395
- ISOweekStart.setDate(simple.getDate() - simple.getUTCDay() + 1);
396
- else
397
- ISOweekStart.setDate(simple.getDate() + 8 - simple.getUTCDay());
398
- return ISOweekStart.toISOString().split("T")[0];
420
+ * given the year and weeknumber -> return dateStr (YYYY-MM-DD)
421
+ */
422
+ _getDateStrOfISOWeek(year, weekNumber) {
423
+ // https://stackoverflow.com/a/16591175/6272061
424
+ const simple = new Date(Date.UTC(year, 0, 1 + (weekNumber - 1) * 7));
425
+ const dow = simple.getUTCDay();
426
+ const ISOweekStart = simple;
427
+ if (dow <= 4) ISOweekStart.setDate(simple.getDate() - simple.getUTCDay() + 1);
428
+ else ISOweekStart.setDate(simple.getDate() + 8 - simple.getUTCDay());
429
+ return ISOweekStart.toISOString().split('T')[0];
399
430
  }
400
431
 
401
432
  /*
402
- * compute the interval sizes based on the scope
403
- * prediction only, not the actuall export of the data
404
- */
433
+ * compute the interval sizes based on the scope
434
+ * prediction only, not the actuall export of the data
435
+ */
405
436
  getIntervalSizes() {
406
437
  return {
407
- "D": this._computeIntervalSize("D"),
408
- "W": this._computeIntervalSize("W"),
409
- "M": this._computeIntervalSize("M"),
410
- "Y": this._computeIntervalSize("Y"),
411
- "5Y": this._computeIntervalSize("5Y"),
412
- "10Y": this._computeIntervalSize("10Y"),
413
- }
438
+ D: this._computeIntervalSize('D'),
439
+ W: this._computeIntervalSize('W'),
440
+ M: this._computeIntervalSize('M'),
441
+ Y: this._computeIntervalSize('Y'),
442
+ '5Y': this._computeIntervalSize('5Y'),
443
+ '10Y': this._computeIntervalSize('10Y'),
444
+ };
414
445
  }
446
+
415
447
  _computeIntervalSize(scope) {
416
448
  const maxDate = this.getMaxDateStr();
417
449
  if (!maxDate) {
@@ -427,65 +459,68 @@ export class SearchResultService {
427
459
  }
428
460
  return count;
429
461
  }
462
+
430
463
  _increaseDateBy(scope, date) {
431
464
  switch (scope) {
432
- case "D":
465
+ case 'D':
433
466
  return this._addDays(date, 1);
434
- case "W":
467
+ case 'W':
435
468
  return this._addDays(date, 7);
436
- case "M":
469
+ case 'M':
437
470
  return this._addMonths(date, 1);
438
- case "Y":
471
+ case 'Y':
439
472
  return this._addYears(date, 1);
440
- case "5Y":
473
+ case '5Y':
441
474
  return this._addYears(date, 5);
442
- case "10Y":
475
+ case '10Y':
443
476
  return this._addYears(date, 10);
444
477
  }
445
478
  }
446
479
 
447
480
  /*
448
- * functions that add n days (_addDays), months (_addMonths)
449
- * or years (_addYears) to a UTC date object
450
- * returns the computed new UTC date
451
- */
481
+ * functions that add n days (_addDays), months (_addMonths)
482
+ * or years (_addYears) to a UTC date object
483
+ * returns the computed new UTC date
484
+ */
452
485
  _addDays(UTCDate, days) {
453
- let newUTCDate = new Date(UTCDate.valueOf());
486
+ const newUTCDate = new Date(UTCDate.valueOf());
454
487
  newUTCDate.setUTCDate(newUTCDate.getUTCDate() + days);
455
488
  return newUTCDate;
456
489
  }
490
+
457
491
  _addMonths(UTCdate, months) {
458
- let newUTCDate = new Date(UTCdate.valueOf());
459
- let d = newUTCDate.getUTCDate();
492
+ const newUTCDate = new Date(UTCdate.valueOf());
493
+ const d = newUTCDate.getUTCDate();
460
494
  newUTCDate.setUTCMonth(newUTCDate.getUTCMonth() + +months);
461
495
  if (newUTCDate.getUTCDate() != d) {
462
496
  newUTCDate.setUTCDate(0);
463
497
  }
464
498
  return newUTCDate;
465
499
  }
500
+
466
501
  _addYears(UTCdate, years) {
467
- let newUTCDate = new Date(UTCdate.valueOf());
502
+ const newUTCDate = new Date(UTCdate.valueOf());
468
503
  newUTCDate.setUTCFullYear(newUTCDate.getUTCFullYear() + years);
469
504
  return newUTCDate;
470
505
  }
471
506
 
472
507
  /*
473
- * Validates dateStr. rules:
474
- * => year: 4 digit number
475
- * => month: [1-12]
476
- * => day: [1-31]
477
- */
508
+ * Validates dateStr. rules:
509
+ * => year: 4 digit number
510
+ * => month: [1-12]
511
+ * => day: [1-31]
512
+ */
478
513
  _isValidDateStr(str) {
479
514
  if (!str) {
480
515
  return false;
481
516
  }
482
517
 
483
- let split = str.split("-");
518
+ const split = str.split('-');
484
519
  if (split.length !== 3) return false;
485
- let year = split[0];
486
- let month = split[1];
487
- let day = split[2];
488
- if (year === "0000" || day === "00" || month === "00") return false;
520
+ const year = split[0];
521
+ const month = split[1];
522
+ const day = split[2];
523
+ if (year === '0000' || day === '00' || month === '00') return false;
489
524
  if (Number(day) < 1 || Number(day) > 31) return false;
490
525
  if (Number(month) < 1 || Number(month) > 12) return false;
491
526
  // if all checks are passed => valid datestring!
@@ -493,29 +528,27 @@ export class SearchResultService {
493
528
  }
494
529
 
495
530
  /*
496
- * Converts month number (str or number) to a 3 char
497
- * abbreviation of the month (in english)
498
- */
531
+ * Converts month number (str or number) to a 3 char
532
+ * abbreviation of the month (in english)
533
+ */
499
534
  _monthLookup(num) {
500
535
  if (num > 12 || num < 1) {
501
536
  throw new Error(`invalid 'num' provided, expected 1-12. Got: ${num}`);
502
537
  }
503
538
  const lookup = {
504
- "1": "Jan",
505
- "2": "Feb",
506
- "3": "Mar",
507
- "4": "Apr",
508
- "5": "May",
509
- "6": "Jun",
510
- "7": "Jul",
511
- "8": "Aug",
512
- "9": "Sep",
513
- "10": "Oct",
514
- "11": "Nov",
515
- "12": "Dec",
516
- }
539
+ 1: 'Jan',
540
+ 2: 'Feb',
541
+ 3: 'Mar',
542
+ 4: 'Apr',
543
+ 5: 'May',
544
+ 6: 'Jun',
545
+ 7: 'Jul',
546
+ 8: 'Aug',
547
+ 9: 'Sep',
548
+ 10: 'Oct',
549
+ 11: 'Nov',
550
+ 12: 'Dec',
551
+ };
517
552
  return lookup[num.toString()];
518
553
  }
519
554
  }
520
-
521
-