@dso-toolkit/core 45.0.1 → 45.1.0

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 (175) hide show
  1. package/dist/cjs/dso-accordion-section.cjs.entry.js +110 -0
  2. package/dist/cjs/dso-accordion.cjs.entry.js +297 -0
  3. package/dist/cjs/dso-alert.cjs.entry.js +3 -3
  4. package/dist/cjs/dso-attachments-counter.cjs.entry.js +3 -3
  5. package/dist/cjs/dso-autosuggest.cjs.entry.js +1 -1
  6. package/dist/cjs/dso-badge.cjs.entry.js +1 -1
  7. package/dist/cjs/dso-banner.cjs.entry.js +2 -2
  8. package/dist/cjs/dso-date-picker.cjs.entry.js +1 -1
  9. package/dist/cjs/dso-dropdown-menu.cjs.entry.js +3 -3
  10. package/dist/cjs/dso-header.cjs.entry.js +6 -6
  11. package/dist/cjs/dso-helpcenter-panel.cjs.entry.js +59 -3
  12. package/dist/cjs/dso-highlight-box.cjs.entry.js +2 -2
  13. package/dist/cjs/dso-icon.cjs.entry.js +2 -2
  14. package/dist/cjs/dso-image-overlay.cjs.entry.js +11 -5
  15. package/dist/cjs/dso-info-button.cjs.entry.js +4 -3
  16. package/dist/cjs/dso-info_2.cjs.entry.js +3 -3
  17. package/dist/cjs/dso-label.cjs.entry.js +1 -1
  18. package/dist/cjs/dso-map-base-layers.cjs.entry.js +1 -1
  19. package/dist/cjs/dso-map-controls.cjs.entry.js +2 -2
  20. package/dist/cjs/dso-map-overlays.cjs.entry.js +1 -1
  21. package/dist/cjs/dso-ozon-content.cjs.entry.js +44 -9
  22. package/dist/cjs/dso-pagination.cjs.entry.js +98 -6
  23. package/dist/cjs/dso-progress-bar.cjs.entry.js +1 -1
  24. package/dist/cjs/dso-progress-indicator.cjs.entry.js +1 -1
  25. package/dist/cjs/dso-responsive-element.cjs.entry.js +6 -1
  26. package/dist/cjs/dso-toggletip.cjs.entry.js +2 -2
  27. package/dist/cjs/dso-toolkit.cjs.js +2 -2
  28. package/dist/cjs/dso-tooltip.cjs.entry.js +1 -1
  29. package/dist/cjs/dso-tree-view.cjs.entry.js +1 -1
  30. package/dist/cjs/dso-viewer-grid.cjs.entry.js +11 -5
  31. package/dist/cjs/{focus-trap.esm-a85643b0.js → focus-trap.esm-e2addb10.js} +28 -11
  32. package/dist/cjs/{index-0a7c679a.js → index-4066351a.js} +7 -0
  33. package/dist/cjs/{index.esm-3520a2a6.js → index.esm-50325ea2.js} +110 -12
  34. package/dist/cjs/loader.cjs.js +2 -2
  35. package/dist/collection/collection-manifest.json +2 -0
  36. package/dist/collection/components/accordion/accordion.css +9 -0
  37. package/dist/collection/components/accordion/accordion.interfaces.js +1 -0
  38. package/dist/collection/components/accordion/accordion.js +260 -0
  39. package/dist/collection/components/accordion/accordion.template.js +26 -0
  40. package/dist/collection/components/accordion/components/accordion-section.css +221 -0
  41. package/dist/collection/components/accordion/components/accordion-section.js +292 -0
  42. package/dist/collection/components/alert/alert.css +4 -41
  43. package/dist/collection/components/alert/alert.js +1 -0
  44. package/dist/collection/components/attachments-counter/attachments-counter.css +0 -12
  45. package/dist/collection/components/attachments-counter/attachments-counter.js +2 -1
  46. package/dist/collection/components/banner/banner.css +0 -4
  47. package/dist/collection/components/dropdown-menu/dropdown-menu.css +0 -7
  48. package/dist/collection/components/header/header.css +20 -379
  49. package/dist/collection/components/header/header.js +22 -24
  50. package/dist/collection/components/helpcenter-panel/helpcenter-panel.css +3 -102
  51. package/dist/collection/components/helpcenter-panel/helpcenter-panel.js +71 -5
  52. package/dist/collection/components/highlight-box/highlight-box.css +0 -2
  53. package/dist/collection/components/image-overlay/image-overlay.css +37 -1134
  54. package/dist/collection/components/image-overlay/image-overlay.js +13 -3
  55. package/dist/collection/components/image-overlay/image-overlay.template.js +9 -1
  56. package/dist/collection/components/info/info.css +19 -1070
  57. package/dist/collection/components/info/info.js +1 -0
  58. package/dist/collection/components/info-button/info-button.css +8 -17
  59. package/dist/collection/components/info-button/info-button.js +9 -3
  60. package/dist/collection/components/map-controls/map-controls.css +20 -1172
  61. package/dist/collection/components/ozon-content/nodes/figuur.node.js +41 -6
  62. package/dist/collection/components/ozon-content/ozon-content.css +22 -41
  63. package/dist/collection/components/pagination/pagination.css +1 -0
  64. package/dist/collection/components/pagination/pagination.js +121 -13
  65. package/dist/collection/components/responsive-element/responsive-element.interfaces.js +1 -0
  66. package/dist/collection/components/responsive-element/responsive-element.js +48 -1
  67. package/dist/collection/components/responsive-element/responsive-element.template.js +4 -2
  68. package/dist/collection/components/toggletip/toggletip.css +4 -0
  69. package/dist/collection/components/viewer-grid/viewer-grid.css +34 -1220
  70. package/dist/collection/components/viewer-grid/viewer-grid.js +12 -1
  71. package/dist/custom-elements/index.d.ts +12 -0
  72. package/dist/custom-elements/index.js +1933 -1219
  73. package/dist/dso-toolkit/dso-toolkit.esm.js +1 -1
  74. package/dist/dso-toolkit/p-02b2e01c.entry.js +1 -0
  75. package/dist/dso-toolkit/{p-d780f9ff.entry.js → p-05a9e206.entry.js} +1 -1
  76. package/dist/dso-toolkit/p-22c35db5.js +5 -0
  77. package/dist/dso-toolkit/{p-361528b4.entry.js → p-2e74485e.entry.js} +1 -1
  78. package/dist/dso-toolkit/p-2f6b1092.entry.js +1 -0
  79. package/dist/dso-toolkit/{p-bf4d6f63.entry.js → p-3381c859.entry.js} +1 -1
  80. package/dist/dso-toolkit/{p-3799366e.entry.js → p-37a34037.entry.js} +1 -1
  81. package/dist/dso-toolkit/p-42450cfe.js +1 -0
  82. package/dist/dso-toolkit/p-4c44d27c.entry.js +1 -0
  83. package/dist/dso-toolkit/{p-91b6a181.entry.js → p-4fd140e9.entry.js} +1 -1
  84. package/dist/dso-toolkit/p-53c7bf4f.entry.js +1 -0
  85. package/dist/dso-toolkit/{p-d60876c2.entry.js → p-67b11174.entry.js} +1 -1
  86. package/dist/dso-toolkit/{p-e4bcafc4.entry.js → p-6cac0292.entry.js} +1 -1
  87. package/dist/dso-toolkit/p-7213783b.entry.js +1 -0
  88. package/dist/dso-toolkit/p-73bbb9a6.entry.js +1 -0
  89. package/dist/dso-toolkit/{p-16635f4b.entry.js → p-8515d157.entry.js} +1 -1
  90. package/dist/dso-toolkit/{p-375a2523.entry.js → p-93b53eb7.entry.js} +1 -1
  91. package/dist/dso-toolkit/p-ac0c0eee.entry.js +1 -0
  92. package/dist/dso-toolkit/p-b1a75b67.entry.js +1 -0
  93. package/dist/dso-toolkit/p-b6afe104.entry.js +1 -0
  94. package/dist/dso-toolkit/{p-590cbab6.entry.js → p-b9531adb.entry.js} +1 -1
  95. package/dist/dso-toolkit/p-c339891f.entry.js +1 -0
  96. package/dist/dso-toolkit/{p-6bc71e48.entry.js → p-d2255268.entry.js} +1 -1
  97. package/dist/dso-toolkit/p-d6192ab8.entry.js +1 -0
  98. package/dist/dso-toolkit/p-de50f5f1.entry.js +1 -0
  99. package/dist/dso-toolkit/p-e16b5d71.entry.js +1 -0
  100. package/dist/dso-toolkit/p-e2e2106e.entry.js +1 -0
  101. package/dist/dso-toolkit/p-ea1d4c81.entry.js +1 -0
  102. package/dist/dso-toolkit/{p-25f8dbc6.entry.js → p-ec3b8800.entry.js} +1 -1
  103. package/dist/dso-toolkit/p-efd815dc.entry.js +1 -0
  104. package/dist/dso-toolkit/p-f42d8240.entry.js +1 -0
  105. package/dist/dso-toolkit/p-f8b023c4.js +5 -0
  106. package/dist/esm/dso-accordion-section.entry.js +106 -0
  107. package/dist/esm/dso-accordion.entry.js +293 -0
  108. package/dist/esm/dso-alert.entry.js +3 -3
  109. package/dist/esm/dso-attachments-counter.entry.js +3 -3
  110. package/dist/esm/dso-autosuggest.entry.js +1 -1
  111. package/dist/esm/dso-badge.entry.js +1 -1
  112. package/dist/esm/dso-banner.entry.js +2 -2
  113. package/dist/esm/dso-date-picker.entry.js +1 -1
  114. package/dist/esm/dso-dropdown-menu.entry.js +3 -3
  115. package/dist/esm/dso-header.entry.js +6 -6
  116. package/dist/esm/dso-helpcenter-panel.entry.js +59 -3
  117. package/dist/esm/dso-highlight-box.entry.js +2 -2
  118. package/dist/esm/dso-icon.entry.js +2 -2
  119. package/dist/esm/dso-image-overlay.entry.js +11 -5
  120. package/dist/esm/dso-info-button.entry.js +4 -3
  121. package/dist/esm/dso-info_2.entry.js +3 -3
  122. package/dist/esm/dso-label.entry.js +1 -1
  123. package/dist/esm/dso-map-base-layers.entry.js +1 -1
  124. package/dist/esm/dso-map-controls.entry.js +2 -2
  125. package/dist/esm/dso-map-overlays.entry.js +1 -1
  126. package/dist/esm/dso-ozon-content.entry.js +44 -9
  127. package/dist/esm/dso-pagination.entry.js +98 -6
  128. package/dist/esm/dso-progress-bar.entry.js +1 -1
  129. package/dist/esm/dso-progress-indicator.entry.js +1 -1
  130. package/dist/esm/dso-responsive-element.entry.js +6 -1
  131. package/dist/esm/dso-toggletip.entry.js +2 -2
  132. package/dist/esm/dso-toolkit.js +2 -2
  133. package/dist/esm/dso-tooltip.entry.js +1 -1
  134. package/dist/esm/dso-tree-view.entry.js +1 -1
  135. package/dist/esm/dso-viewer-grid.entry.js +11 -5
  136. package/dist/esm/{focus-trap.esm-a01ad6c9.js → focus-trap.esm-e3b5bde3.js} +28 -11
  137. package/dist/esm/{index-1602fde1.js → index-771c1291.js} +7 -1
  138. package/dist/esm/{index.esm-45465af7.js → index.esm-4510c39e.js} +110 -12
  139. package/dist/esm/loader.js +2 -2
  140. package/dist/types/components/accordion/accordion.d.ts +32 -0
  141. package/dist/types/components/accordion/accordion.interfaces.d.ts +20 -0
  142. package/dist/types/components/accordion/accordion.template.d.ts +2 -0
  143. package/dist/types/components/accordion/components/accordion-section.d.ts +25 -0
  144. package/dist/types/components/helpcenter-panel/helpcenter-panel.d.ts +11 -0
  145. package/dist/types/components/image-overlay/image-overlay.d.ts +3 -0
  146. package/dist/types/components/info-button/info-button.d.ts +1 -0
  147. package/dist/types/components/ozon-content/nodes/figuur.node.d.ts +4 -1
  148. package/dist/types/components/pagination/pagination.d.ts +15 -0
  149. package/dist/types/components/responsive-element/responsive-element.d.ts +5 -2
  150. package/dist/types/components/responsive-element/responsive-element.interfaces.d.ts +5 -0
  151. package/dist/types/components/responsive-element/responsive-element.template.d.ts +1 -1
  152. package/dist/types/components.d.ts +99 -0
  153. package/package.json +4 -3
  154. package/readme.md +0 -7
  155. package/dist/collection/icon/dso-icon-sass-function.js +0 -42
  156. package/dist/dso-toolkit/dso-toolkit.css +0 -1
  157. package/dist/dso-toolkit/p-02272301.entry.js +0 -1
  158. package/dist/dso-toolkit/p-10a6db1a.entry.js +0 -1
  159. package/dist/dso-toolkit/p-131d54e3.js +0 -5
  160. package/dist/dso-toolkit/p-1450f113.entry.js +0 -1
  161. package/dist/dso-toolkit/p-15d0f2eb.entry.js +0 -1
  162. package/dist/dso-toolkit/p-3b5f957e.entry.js +0 -1
  163. package/dist/dso-toolkit/p-49938275.entry.js +0 -1
  164. package/dist/dso-toolkit/p-5a56d726.entry.js +0 -1
  165. package/dist/dso-toolkit/p-5e5fbd41.js +0 -5
  166. package/dist/dso-toolkit/p-68d49733.entry.js +0 -1
  167. package/dist/dso-toolkit/p-7b716383.entry.js +0 -1
  168. package/dist/dso-toolkit/p-b95bc2c7.entry.js +0 -1
  169. package/dist/dso-toolkit/p-c1070a58.entry.js +0 -1
  170. package/dist/dso-toolkit/p-c62606a3.js +0 -1
  171. package/dist/dso-toolkit/p-e7888d49.entry.js +0 -1
  172. package/dist/dso-toolkit/p-eb17d45e.entry.js +0 -1
  173. package/dist/dso-toolkit/p-f726111e.entry.js +0 -1
  174. package/dist/dso-toolkit/p-fd8a8509.entry.js +0 -1
  175. package/dist/types/icon/dso-icon-sass-function.d.ts +0 -4
@@ -1,22 +1,57 @@
1
1
  import { h } from '@stencil/core';
2
2
  import { getNodeName } from '../get-node-name.function';
3
+ const Bijschrift = ({ bijschrift, bron, mapNodeToJsx }) => {
4
+ return (h("span", { class: "figuur-bijschrift" },
5
+ bijschrift && bijschrift.inhoud && mapNodeToJsx(bijschrift.inhoud),
6
+ bron && (`${bijschrift ? ' ' : ''}(bron: ${mapNodeToJsx(bron)})`)));
7
+ };
3
8
  export class OzonContentFiguurNode {
4
9
  constructor() {
5
10
  this.name = [
6
11
  'Figuur',
7
12
  ];
8
13
  }
9
- render(node) {
10
- var _a, _b, _c, _d, _e;
14
+ setImageDimensions(imageElement, schaal) {
15
+ const { naturalHeight, naturalWidth } = imageElement;
16
+ imageElement.height = naturalHeight * (schaal / 100);
17
+ imageElement.width = naturalWidth * (schaal / 100);
18
+ }
19
+ onImageLoad(event, schaal) {
20
+ if (event.target instanceof HTMLImageElement && schaal) {
21
+ this.setImageDimensions(event.target, schaal);
22
+ }
23
+ }
24
+ render(node, { mapNodeToJsx }) {
25
+ var _a, _b, _c, _d, _e, _f, _g;
11
26
  const childNodes = Array.from(node.childNodes);
12
27
  const titel = (_a = childNodes.find(n => getNodeName(n) === 'Titel')) === null || _a === void 0 ? void 0 : _a.textContent;
13
- const bijschrift = (_b = childNodes.find(n => getNodeName(n) === 'Bijschrift')) === null || _b === void 0 ? void 0 : _b.textContent;
28
+ const bron = (_b = childNodes.find(n => getNodeName(n) === 'Bron')) === null || _b === void 0 ? void 0 : _b.childNodes;
14
29
  const illustratieNode = childNodes.find(n => getNodeName(n) === 'Illustratie');
30
+ const bijschriftNode = childNodes.find(n => getNodeName(n) === 'Bijschrift');
15
31
  if (illustratieNode instanceof Element) {
16
- return (h("div", { class: "dso-ozon-figuur" },
32
+ const illustratie = {
33
+ naam: illustratieNode.getAttribute('naam'),
34
+ breedte: illustratieNode.getAttribute('breedte'),
35
+ hoogte: illustratieNode.getAttribute('hoogte'),
36
+ uitlijning: illustratieNode.getAttribute('uitlijning'),
37
+ alt: illustratieNode.getAttribute('alt'),
38
+ schaal: illustratieNode.getAttribute('schaal'),
39
+ };
40
+ const bijschrift = bijschriftNode instanceof Element ? {
41
+ inhoud: bijschriftNode.childNodes,
42
+ locatie: (_c = bijschriftNode.getAttribute('locatie')) !== null && _c !== void 0 ? _c : 'onder',
43
+ }
44
+ : undefined;
45
+ return (h("div", { class: `dso-ozon-figuur ${bijschrift ? `bijschrift-${bijschrift.locatie}` : 'onder'}` },
46
+ titel && (h("span", { class: "figuur-titel" }, titel)),
47
+ (bijschrift === null || bijschrift === void 0 ? void 0 : bijschrift.locatie) === 'boven' && h(Bijschrift, { bijschrift: bijschrift, bron: bron, mapNodeToJsx: mapNodeToJsx }),
17
48
  h("dso-image-overlay", null,
18
- h("img", { src: (_c = illustratieNode.getAttribute('naam')) !== null && _c !== void 0 ? _c : undefined, alt: (_e = (_d = titel !== null && titel !== void 0 ? titel : illustratieNode.getAttribute('alt')) !== null && _d !== void 0 ? _d : illustratieNode.getAttribute('naam')) !== null && _e !== void 0 ? _e : undefined })),
19
- bijschrift && (h("span", { class: "figuur-bijschrift" }, bijschrift))));
49
+ h("div", { slot: "titel" },
50
+ h("span", null, titel)),
51
+ h("img", { src: (_d = illustratie.naam) !== null && _d !== void 0 ? _d : undefined, alt: (_g = (_f = (_e = illustratie.alt) !== null && _e !== void 0 ? _e : titel) !== null && _f !== void 0 ? _f : illustratie.naam) !== null && _g !== void 0 ? _g : undefined, onLoad: (event) => this.onImageLoad(event, Number(illustratie.schaal)) }),
52
+ h("div", { slot: "bijschrift" },
53
+ h(Bijschrift, { bijschrift: bijschrift, bron: bron, mapNodeToJsx: mapNodeToJsx }))),
54
+ ((bijschrift === null || bijschrift === void 0 ? void 0 : bijschrift.locatie) === 'onder' || (!bijschrift && bron)) && h(Bijschrift, { bijschrift: bijschrift, bron: bron, mapNodeToJsx: mapNodeToJsx })));
20
55
  }
21
56
  }
22
57
  }
@@ -65,14 +65,6 @@ button.toggle-note:focus, button.toggle-note:focus-visible {
65
65
  button.toggle-note:active {
66
66
  outline: 0;
67
67
  }
68
- button.toggle-note.extern::after, button.toggle-note.download::after {
69
- content: "";
70
- display: inline-block;
71
- height: 1.5em;
72
- margin-left: 8px;
73
- vertical-align: top;
74
- width: 1.5em;
75
- }
76
68
  button.toggle-note[disabled] {
77
69
  color: #afcf9d;
78
70
  }
@@ -92,38 +84,6 @@ button.toggle-note.btn-align {
92
84
  padding: 11px 0;
93
85
  position: relative;
94
86
  }
95
- button.toggle-note.extern::after, button.toggle-note.download::after {
96
- position: relative;
97
- top: -2px;
98
- }
99
- button.toggle-note.download::after {
100
- background: var(--dso-icon, var(--di-download)) no-repeat;
101
- background-position: center;
102
- background-size: cover;
103
- height: 24px;
104
- vertical-align: top;
105
- width: 24px;
106
- }
107
- button.toggle-note.download[disabled]::after {
108
- --dso-icon: var(--di-download-grasgroen-40);
109
- }
110
- button.toggle-note.download:not([disabled]):hover::after, button.toggle-note.download:not([disabled]):active::after {
111
- --dso-icon: var(--di-download-scampi);
112
- }
113
- button.toggle-note.extern::after {
114
- background: var(--dso-icon, var(--di-external-link)) no-repeat;
115
- background-position: center;
116
- background-size: cover;
117
- height: 24px;
118
- vertical-align: top;
119
- width: 24px;
120
- }
121
- button.toggle-note.extern[disabled]::after {
122
- --dso-icon: var(--di-external-link-grasgroen-40);
123
- }
124
- button.toggle-note.extern:not([disabled]):hover::after, button.toggle-note.extern:not([disabled]):active::after {
125
- --dso-icon: var(--di-external-link-scampi);
126
- }
127
87
  button.toggle-note.dso-spinner-left::before {
128
88
  background-image: url("data:image/svg+xml,%3Csvg class='spinner' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg' %3E%3Cstyle%3E .spinner %7B animation: rotator 8s linear infinite; transform-origin: center; %7D @keyframes rotator %7B 0%25 %7B transform: rotate(0deg); %7D 100%25 %7B transform: rotate(360deg); %7D %7D .path %7B stroke-dasharray: 265; stroke-dashoffset: 0; transform-origin: center; stroke: %2339870c; animation: dash 2s ease-in-out infinite; %7D @keyframes dash %7B 0%25 %7B stroke-dashoffset: 265; %7D 50%25 %7B stroke-dashoffset: 65; transform:rotate(90deg); %7D 100%25 %7B stroke-dashoffset: 265; transform:rotate(360deg); %7D %3C/style%3E%3Ccircle class='path' fill='none' stroke-width='10' stroke-linecap='butt' cx='50' cy='50' r='45'%3E%3C/circle%3E%3C/svg%3E");
129
89
  background-repeat: no-repeat;
@@ -150,6 +110,12 @@ button.toggle-note span:not(.sr-only) + dso-icon,
150
110
  button.toggle-note span:not(.sr-only) + svg.di {
151
111
  margin-left: 8px;
152
112
  }
113
+ button.toggle-note svg.di.di-chevron-down + span:not(.sr-only),
114
+ button.toggle-note svg.di.di-chevron-up + span:not(.sr-only),
115
+ button.toggle-note span:not(.sr-only) + svg.di.di-chevron-down,
116
+ button.toggle-note span:not(.sr-only) + svg.di.di-chevron-up {
117
+ margin-left: 4px;
118
+ }
153
119
  button.toggle-note dso-icon[icon=chevron-left] + span:not(.sr-only),
154
120
  button.toggle-note dso-icon[icon=chevron-right] + span:not(.sr-only),
155
121
  button.toggle-note svg.di.di-angle-down + span:not(.sr-only),
@@ -210,10 +176,25 @@ span[role=paragraph] {
210
176
  text-align: right;
211
177
  }
212
178
 
179
+ .dso-ozon-figuur {
180
+ margin-bottom: 16px;
181
+ }
213
182
  .dso-ozon-figuur .figuur-bijschrift {
214
183
  display: block;
215
184
  font-size: 0.75rem;
216
- padding-bottom: 2.5rem;
185
+ font-style: italic;
186
+ }
187
+ .dso-ozon-figuur.bijschrift-boven .figuur-bijschrift {
188
+ padding-bottom: 0.25rem;
189
+ }
190
+ .dso-ozon-figuur.bijschrift-onder .figuur-bijschrift {
191
+ padding-top: 0.25rem;
192
+ }
193
+ .dso-ozon-figuur .figuur-titel {
194
+ color: #8b4a6a;
195
+ display: block;
196
+ font-weight: 500;
197
+ padding-bottom: 0.5rem;
217
198
  }
218
199
 
219
200
  .od-Tabel thead {
@@ -9,6 +9,7 @@
9
9
  }
10
10
 
11
11
  .pagination {
12
+ padding-inline-start: initial;
12
13
  text-align: center;
13
14
  }
14
15
  .pagination > li {
@@ -1,11 +1,22 @@
1
- import { h, Component, Event, Prop } from '@stencil/core';
1
+ import { h, Component, Element, Event, Fragment, Listen, Prop, State } from '@stencil/core';
2
2
  export class Pagination {
3
3
  constructor() {
4
+ this.sizePositionsMap = {
5
+ small: 7,
6
+ medium: 9,
7
+ large: 11,
8
+ };
4
9
  /**
5
10
  * This function is called to format the href
6
11
  */
7
12
  this.formatHref = (page) => '#' + page;
8
13
  }
14
+ /**
15
+ * Listens to the dsoSizeChange event on Responsive Element
16
+ */
17
+ sizeChangeHandler(event) {
18
+ this.availablePositions = this.getAvailablePositions(this.sizePositionsMap[event.detail]);
19
+ }
9
20
  clickHandler(e, page) {
10
21
  this.dsoSelectPage.emit({
11
22
  originalEvent: e,
@@ -14,24 +25,110 @@ export class Pagination {
14
25
  });
15
26
  }
16
27
  ;
28
+ componentDidLoad() {
29
+ var _a;
30
+ (_a = this.responsiveElement) === null || _a === void 0 ? void 0 : _a.getSize().then((size) => this.availablePositions = this.getAvailablePositions(this.sizePositionsMap[size]));
31
+ }
17
32
  render() {
18
33
  var _a;
19
34
  if (!this.totalPages) {
20
35
  return null;
21
36
  }
37
+ if (this.availablePositions === undefined) {
38
+ return (h("dso-responsive-element", { ref: element => this.responsiveElement = element }));
39
+ }
40
+ const availablePositions = this.availablePositions;
22
41
  const currentPage = (_a = this.currentPage) !== null && _a !== void 0 ? _a : 0;
23
- const pages = Array.from({ length: this.totalPages }, (_value, i) => i + 1);
24
- const currentPageOutOfBounds = currentPage < pages[0] || currentPage > pages[pages.length - 1];
25
- return (h("ul", { class: "pagination" },
26
- h("li", { class: (currentPage <= pages[0] || currentPageOutOfBounds) ? 'dso-page-hidden' : undefined },
27
- h("a", { href: this.formatHref(pages[0]), "aria-label": "Vorige", onClick: e => currentPage && this.clickHandler(e, pages[currentPage - 2]) },
28
- h("dso-icon", { icon: "chevron-left" }))),
29
- pages.map(page => (h("li", { key: page, class: currentPage === page ? 'active' : undefined }, currentPage === page
30
- ? (h("span", { "aria-current": "page" }, page))
31
- : (h("a", { href: this.formatHref(page), onClick: e => this.clickHandler(e, page) }, page))))),
32
- h("li", { class: (currentPage >= pages[pages.length - 1] || currentPageOutOfBounds) ? 'dso-page-hidden' : undefined },
33
- h("a", { href: this.formatHref(pages[pages.length - 1]), "aria-label": "Volgende", onClick: e => currentPage && this.clickHandler(e, pages[currentPage]) },
34
- h("dso-icon", { icon: "chevron-right" })))));
42
+ const pages = this.getPages(currentPage, this.availablePositions, this.totalPages);
43
+ return (h("dso-responsive-element", { ref: element => this.responsiveElement = element },
44
+ h("ul", { class: "pagination" },
45
+ h("li", { class: (currentPage <= 1 || currentPage > this.totalPages) ? 'dso-page-hidden' : undefined },
46
+ h("a", { href: this.formatHref(pages[0]), "aria-label": "Vorige", onClick: e => currentPage && this.clickHandler(e, pages[currentPage - 2]) },
47
+ h("dso-icon", { icon: "chevron-left" }))),
48
+ (pages).map(page => (h(Fragment, null,
49
+ this.showEllipsisBeforeLast(pages, page, availablePositions, pages[pages.length - 1]) &&
50
+ h("li", null,
51
+ h("span", null, "...")),
52
+ h("li", { key: page, class: currentPage === page ? 'active' : undefined }, currentPage === page
53
+ ? (h("span", { "aria-current": "page" }, page))
54
+ : (h("a", { href: this.formatHref(page), onClick: e => this.clickHandler(e, page) }, page))),
55
+ this.showEllipsisAfterFirst(pages, page, availablePositions) &&
56
+ h("li", null,
57
+ h("span", null, "..."))))),
58
+ h("li", { class: (currentPage < 1 || currentPage >= this.totalPages) ? 'dso-page-hidden' : undefined },
59
+ h("a", { href: this.formatHref(pages[pages.length - 1]), "aria-label": "Volgende", onClick: e => currentPage && this.clickHandler(e, pages[currentPage]) },
60
+ h("dso-icon", { icon: "chevron-right" }))))));
61
+ }
62
+ getAvailablePositions(sizePositions) {
63
+ if (sizePositions % 2 === 0) { // Even aantal posities zorgt voor een scheve pagination
64
+ return sizePositions - 1;
65
+ }
66
+ if (sizePositions <= 3) { // Voor het kunnen tonen van de vorige knop, volgende knop en 1 pagina zijn minimaal 3 posities nodig.
67
+ return 3;
68
+ }
69
+ return sizePositions;
70
+ }
71
+ getPages(currentPage, availablePositions, totalPages) {
72
+ if (totalPages + 2 <= availablePositions) { // + 2 voor de vorige en volgende knop
73
+ return Array.from({ length: totalPages }, (_value, i) => i + 1);
74
+ }
75
+ if (availablePositions === 3) {
76
+ return [currentPage];
77
+ }
78
+ if (availablePositions === 5) {
79
+ return [1, currentPage, totalPages];
80
+ }
81
+ return [
82
+ 1,
83
+ ...this.getPageRange(currentPage, availablePositions, totalPages),
84
+ totalPages
85
+ ];
86
+ }
87
+ getPageRange(currentPage, availablePositions, totalPages) {
88
+ const range = [];
89
+ const positionRange = Math.floor(availablePositions / 2);
90
+ if (currentPage <= positionRange) {
91
+ for (let i = 2; i <= availablePositions - 4; i++) {
92
+ range.push(i);
93
+ }
94
+ }
95
+ if (currentPage >= positionRange && currentPage <= totalPages - positionRange) {
96
+ if (positionRange === 1) {
97
+ if (currentPage > totalPages - 2) {
98
+ range.push(totalPages - 2);
99
+ }
100
+ range.push(currentPage);
101
+ if (currentPage < 3) {
102
+ range.push(3);
103
+ }
104
+ }
105
+ if (positionRange > 1) {
106
+ const pagesBeforeOrAfter = positionRange - 3;
107
+ for (let i = Math.min(currentPage - pagesBeforeOrAfter, totalPages - positionRange); i <= Math.max(currentPage + pagesBeforeOrAfter, positionRange); i++) {
108
+ if (i > 2 && i < totalPages - 1) {
109
+ range.push(i);
110
+ }
111
+ }
112
+ }
113
+ }
114
+ if (currentPage > totalPages - positionRange) {
115
+ for (let i = totalPages - (availablePositions - 5); i <= totalPages - 1; i++) {
116
+ range.push(i);
117
+ }
118
+ }
119
+ return range.filter((v, i, a) => a.indexOf(v) === i);
120
+ }
121
+ showEllipsisAfterFirst(pages, page, availablePositions) {
122
+ return pages.indexOf(page) === 0 &&
123
+ pages[pages.length - 1] > availablePositions - 2 &&
124
+ !pages.some(p => p === 2) &&
125
+ availablePositions >= 7;
126
+ }
127
+ showEllipsisBeforeLast(pages, page, availablePositions, totalPages) {
128
+ return pages.indexOf(page) === pages.length - 1 &&
129
+ pages[pages.length - 1] > availablePositions - 2 &&
130
+ !pages.some(p => p === totalPages - 1) &&
131
+ availablePositions >= 7;
35
132
  }
36
133
  static get is() { return "dso-pagination"; }
37
134
  static get encapsulation() { return "shadow"; }
@@ -93,6 +190,9 @@ export class Pagination {
93
190
  "defaultValue": "(page) => '#' + page"
94
191
  }
95
192
  }; }
193
+ static get states() { return {
194
+ "availablePositions": {}
195
+ }; }
96
196
  static get events() { return [{
97
197
  "method": "dsoSelectPage",
98
198
  "name": "dsoSelectPage",
@@ -114,4 +214,12 @@ export class Pagination {
114
214
  }
115
215
  }
116
216
  }]; }
217
+ static get elementRef() { return "host"; }
218
+ static get listeners() { return [{
219
+ "name": "dsoSizeChange",
220
+ "method": "sizeChangeHandler",
221
+ "target": undefined,
222
+ "capture": false,
223
+ "passive": false
224
+ }]; }
117
225
  }
@@ -1,4 +1,4 @@
1
- import { Component, Element, Host, State, h } from '@stencil/core';
1
+ import { Component, Element, Event, h, Host, Method, State } from '@stencil/core';
2
2
  const elementSizes = [
3
3
  {
4
4
  width: 624, alias: 'large'
@@ -18,8 +18,12 @@ export class ResponsiveElement {
18
18
  var _a, _b;
19
19
  const size = (_b = (_a = elementSizes.find(s => entry.contentRect.width >= s.width)) === null || _a === void 0 ? void 0 : _a.alias) !== null && _b !== void 0 ? _b : elementSizes[0].alias;
20
20
  this.sizeAlias = size;
21
+ this.dsoSizeChange.emit(size);
21
22
  });
22
23
  }
24
+ async getSize() {
25
+ return this.sizeAlias;
26
+ }
23
27
  componentWillLoad() {
24
28
  this.observer.observe(this.host);
25
29
  }
@@ -42,5 +46,48 @@ export class ResponsiveElement {
42
46
  "sizeAlias": {},
43
47
  "sizeWidth": {}
44
48
  }; }
49
+ static get events() { return [{
50
+ "method": "dsoSizeChange",
51
+ "name": "dsoSizeChange",
52
+ "bubbles": true,
53
+ "cancelable": true,
54
+ "composed": true,
55
+ "docs": {
56
+ "tags": [],
57
+ "text": ""
58
+ },
59
+ "complexType": {
60
+ "original": "ResponsiveElementSize",
61
+ "resolved": "\"large\" | \"medium\" | \"small\"",
62
+ "references": {
63
+ "ResponsiveElementSize": {
64
+ "location": "import",
65
+ "path": "./responsive-element.interfaces"
66
+ }
67
+ }
68
+ }
69
+ }]; }
70
+ static get methods() { return {
71
+ "getSize": {
72
+ "complexType": {
73
+ "signature": "() => Promise<ResponsiveElementSize>",
74
+ "parameters": [],
75
+ "references": {
76
+ "Promise": {
77
+ "location": "global"
78
+ },
79
+ "ResponsiveElementSize": {
80
+ "location": "import",
81
+ "path": "./responsive-element.interfaces"
82
+ }
83
+ },
84
+ "return": "Promise<ResponsiveElementSize>"
85
+ },
86
+ "docs": {
87
+ "text": "",
88
+ "tags": []
89
+ }
90
+ }
91
+ }; }
45
92
  static get elementRef() { return "host"; }
46
93
  }
@@ -1,7 +1,9 @@
1
1
  import { html } from 'lit-html';
2
- export function responsiveElementTemplate({ children }) {
2
+ export function responsiveElementTemplate({ dsoSizeChange }, children) {
3
3
  return html `
4
- <dso-responsive-element>
4
+ <dso-responsive-element
5
+ @dsoSizeChange=${dsoSizeChange}
6
+ >
5
7
  ${children}
6
8
  </dso-responsive-element>
7
9
  `;
@@ -4,6 +4,10 @@
4
4
  box-sizing: border-box;
5
5
  }
6
6
 
7
+ :host {
8
+ display: inline-block;
9
+ }
10
+
7
11
  :host(:focus) {
8
12
  outline: none;
9
13
  }