@vcmap/ui 5.0.0-rc.24 → 5.0.0-rc.25

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 (215) hide show
  1. package/build/build.js +132 -14
  2. package/build/buildHelpers.js +196 -92
  3. package/build/bundle.js +56 -0
  4. package/build/commonViteConfig.js +2 -2
  5. package/config/base.config.json +29 -2
  6. package/config/dev.config.json +29 -1
  7. package/config/www.config.json +81 -39
  8. package/dist/assets/@mdi/font/LICENSE +20 -0
  9. package/dist/assets/@mdi/font/css/materialdesignicons.css.map +16 -0
  10. package/dist/assets/@mdi/font/css/materialdesignicons.min.e3f476.css +3 -0
  11. package/dist/assets/@mdi/font/fonts/materialdesignicons-webfont.woff2 +0 -0
  12. package/dist/assets/cesium/Workers/{AxisAlignedBoundingBox-85d9e53a.js → AxisAlignedBoundingBox-4140c51f.js} +1 -1
  13. package/dist/assets/cesium/Workers/{BoundingRectangle-1ee7eb47.js → BoundingRectangle-c714b156.js} +1 -1
  14. package/dist/assets/cesium/Workers/{BoxGeometry-3b2be784.js → BoxGeometry-6f3da43d.js} +1 -1
  15. package/dist/assets/cesium/Workers/{Color-f107c84d.js → Color-8a565ff2.js} +5 -5
  16. package/dist/assets/cesium/Workers/{CoplanarPolygonGeometryLibrary-78d71993.js → CoplanarPolygonGeometryLibrary-4b4d4096.js} +1 -1
  17. package/dist/assets/cesium/Workers/{CorridorGeometryLibrary-50d99b33.js → CorridorGeometryLibrary-7b94502b.js} +1 -1
  18. package/dist/assets/cesium/Workers/{CylinderGeometry-51b0d9bf.js → CylinderGeometry-ca070b87.js} +1 -1
  19. package/dist/assets/cesium/Workers/{EllipseGeometry-bcfb5d87.js → EllipseGeometry-122e51fa.js} +1 -1
  20. package/dist/assets/cesium/Workers/{EllipseGeometryLibrary-e94f8472.js → EllipseGeometryLibrary-4d326efc.js} +1 -1
  21. package/dist/assets/cesium/Workers/{EllipseOutlineGeometry-28e3a1bb.js → EllipseOutlineGeometry-16cc2bd7.js} +1 -1
  22. package/dist/assets/cesium/Workers/{EllipsoidGeometry-b222fa63.js → EllipsoidGeometry-cb148ca2.js} +1 -1
  23. package/dist/assets/cesium/Workers/{EllipsoidOutlineGeometry-38a3fb5b.js → EllipsoidOutlineGeometry-0fa10c79.js} +1 -1
  24. package/dist/assets/cesium/Workers/{EllipsoidTangentPlane-8c89f28c.js → EllipsoidTangentPlane-6dd1b7af.js} +1 -1
  25. package/dist/assets/cesium/Workers/{FrustumGeometry-bdd3a04d.js → FrustumGeometry-ee73037c.js} +1 -1
  26. package/dist/assets/cesium/Workers/{GeometryAttribute-153115c5.js → GeometryAttribute-ff5b4fb1.js} +1 -1
  27. package/dist/assets/cesium/Workers/{GeometryPipeline-acb2399c.js → GeometryPipeline-1f8fbf05.js} +1 -1
  28. package/dist/assets/cesium/Workers/{IntersectionTests-271e513e.js → IntersectionTests-70d39ba9.js} +1 -1
  29. package/dist/assets/cesium/Workers/{OrientedBoundingBox-5e04e31f.js → OrientedBoundingBox-159cf1d6.js} +1 -1
  30. package/dist/assets/cesium/Workers/{PolygonGeometryLibrary-6762b65b.js → PolygonGeometryLibrary-076a5d25.js} +1 -1
  31. package/dist/assets/cesium/Workers/{PolygonPipeline-7dc7a431.js → PolygonPipeline-b9f2810a.js} +1 -1
  32. package/dist/assets/cesium/Workers/{PolylinePipeline-15fde655.js → PolylinePipeline-639192e0.js} +1 -1
  33. package/dist/assets/cesium/Workers/{PolylineVolumeGeometryLibrary-ba7dfed5.js → PolylineVolumeGeometryLibrary-b73549fb.js} +1 -1
  34. package/dist/assets/cesium/Workers/{PrimitivePipeline-68f0b9a2.js → PrimitivePipeline-10ede1b6.js} +1 -1
  35. package/dist/assets/cesium/Workers/{RectangleGeometryLibrary-8eaf23da.js → RectangleGeometryLibrary-c35a7356.js} +1 -1
  36. package/dist/assets/cesium/Workers/{TerrainEncoding-eb8a645a.js → TerrainEncoding-668d242f.js} +1 -1
  37. package/dist/assets/cesium/Workers/{Transforms-f6451f99.js → Transforms-a2a85221.js} +14 -0
  38. package/dist/assets/cesium/Workers/{WallGeometryLibrary-feef3109.js → WallGeometryLibrary-1938bf0d.js} +1 -1
  39. package/dist/assets/cesium/Workers/cesiumWorkerBootstrapper.js +1 -1
  40. package/dist/assets/cesium/Workers/combineGeometry.js +1 -1
  41. package/dist/assets/cesium/Workers/createBoxGeometry.js +1 -1
  42. package/dist/assets/cesium/Workers/createBoxOutlineGeometry.js +1 -1
  43. package/dist/assets/cesium/Workers/createCircleGeometry.js +1 -1
  44. package/dist/assets/cesium/Workers/createCircleOutlineGeometry.js +1 -1
  45. package/dist/assets/cesium/Workers/createCoplanarPolygonGeometry.js +1 -1
  46. package/dist/assets/cesium/Workers/createCoplanarPolygonOutlineGeometry.js +1 -1
  47. package/dist/assets/cesium/Workers/createCorridorGeometry.js +1 -1
  48. package/dist/assets/cesium/Workers/createCorridorOutlineGeometry.js +1 -1
  49. package/dist/assets/cesium/Workers/createCylinderGeometry.js +1 -1
  50. package/dist/assets/cesium/Workers/createCylinderOutlineGeometry.js +1 -1
  51. package/dist/assets/cesium/Workers/createEllipseGeometry.js +1 -1
  52. package/dist/assets/cesium/Workers/createEllipseOutlineGeometry.js +1 -1
  53. package/dist/assets/cesium/Workers/createEllipsoidGeometry.js +1 -1
  54. package/dist/assets/cesium/Workers/createEllipsoidOutlineGeometry.js +1 -1
  55. package/dist/assets/cesium/Workers/createFrustumGeometry.js +1 -1
  56. package/dist/assets/cesium/Workers/createFrustumOutlineGeometry.js +1 -1
  57. package/dist/assets/cesium/Workers/createGeometry.js +1 -1
  58. package/dist/assets/cesium/Workers/createGroundPolylineGeometry.js +1 -1
  59. package/dist/assets/cesium/Workers/createPlaneGeometry.js +1 -1
  60. package/dist/assets/cesium/Workers/createPlaneOutlineGeometry.js +1 -1
  61. package/dist/assets/cesium/Workers/createPolygonGeometry.js +1 -1
  62. package/dist/assets/cesium/Workers/createPolygonOutlineGeometry.js +1 -1
  63. package/dist/assets/cesium/Workers/createPolylineGeometry.js +1 -1
  64. package/dist/assets/cesium/Workers/createPolylineVolumeGeometry.js +1 -1
  65. package/dist/assets/cesium/Workers/createPolylineVolumeOutlineGeometry.js +1 -1
  66. package/dist/assets/cesium/Workers/createRectangleGeometry.js +1 -1
  67. package/dist/assets/cesium/Workers/createRectangleOutlineGeometry.js +1 -1
  68. package/dist/assets/cesium/Workers/createSimplePolylineGeometry.js +1 -1
  69. package/dist/assets/cesium/Workers/createSphereGeometry.js +1 -1
  70. package/dist/assets/cesium/Workers/createSphereOutlineGeometry.js +1 -1
  71. package/dist/assets/cesium/Workers/createVectorTileGeometries.js +1 -1
  72. package/dist/assets/cesium/Workers/createVectorTilePolygons.js +1 -1
  73. package/dist/assets/cesium/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +1 -1
  74. package/dist/assets/cesium/Workers/createVerticesFromHeightmap.js +1 -1
  75. package/dist/assets/cesium/Workers/createVerticesFromQuantizedTerrainMesh.js +1 -1
  76. package/dist/assets/cesium/Workers/createWallGeometry.js +1 -1
  77. package/dist/assets/cesium/Workers/createWallOutlineGeometry.js +1 -1
  78. package/dist/assets/cesium/Workers/package.js +1 -1
  79. package/dist/assets/cesium/Workers/transferTypedArrayTest.js +1 -1
  80. package/dist/assets/cesium/Workers/upsampleQuantizedTerrainMesh.js +1 -1
  81. package/dist/assets/{cesium.253914.js → cesium.1457fa.js} +58656 -33170
  82. package/dist/assets/cesium.js +1 -1
  83. package/dist/assets/core.47836f.js +19060 -0
  84. package/dist/assets/core.js +1 -1
  85. package/dist/assets/index-bb372634.js +1 -0
  86. package/dist/assets/{ol.1c946a.js → ol.9e4d23.js} +27344 -12118
  87. package/dist/assets/ol.js +1 -1
  88. package/dist/assets/ui.6ed89d.css +5 -0
  89. package/dist/assets/ui.6ed89d.js +13461 -0
  90. package/dist/assets/ui.js +1 -1
  91. package/dist/assets/{vue.c1ece7.js → vue.7327e4.js} +834 -598
  92. package/dist/assets/vue.js +2 -2
  93. package/dist/assets/{vuetify.6efa21.css → vuetify.d2131d.css} +1 -1
  94. package/dist/assets/{vuetify.6efa21.js → vuetify.d2131d.js} +343 -103
  95. package/dist/assets/vuetify.js +2 -2
  96. package/dist/index.html +7 -6
  97. package/index.html +14 -6
  98. package/index.js +17 -2
  99. package/lib/olLib.js +19 -16
  100. package/package.json +15 -14
  101. package/plugins/@vcmap/create-link/fallbackCreateLink.vue +0 -2
  102. package/plugins/@vcmap/simple-graph/index.js +1 -1
  103. package/plugins/@vcmap-show-case/README.md +2 -1
  104. package/plugins/@vcmap-show-case/buttons-example/ButtonsExample.vue +55 -79
  105. package/plugins/@vcmap-show-case/category-tester/CategoriesExample.vue +135 -0
  106. package/plugins/@vcmap-show-case/category-tester/CollectionComponentOptions.vue +209 -0
  107. package/plugins/@vcmap-show-case/category-tester/index.js +19 -1
  108. package/plugins/@vcmap-show-case/collection-manager-example/CollectionManagerExample.vue +182 -0
  109. package/plugins/@vcmap-show-case/collection-manager-example/README.md +3 -0
  110. package/plugins/@vcmap-show-case/collection-manager-example/index.js +74 -0
  111. package/plugins/@vcmap-show-case/collection-manager-example/package.json +5 -0
  112. package/plugins/@vcmap-show-case/form-inputs-example/FormInputsExample.vue +20 -3
  113. package/plugins/@vcmap-show-case/switch-map-callback-example/README.md +21 -0
  114. package/plugins/@vcmap-show-case/switch-map-callback-example/SwitchMapCallback.js +47 -0
  115. package/plugins/@vcmap-show-case/switch-map-callback-example/config.json +3 -0
  116. package/plugins/@vcmap-show-case/switch-map-callback-example/index.js +34 -0
  117. package/plugins/@vcmap-show-case/switch-map-callback-example/package.json +5 -0
  118. package/plugins/@vcmap-show-case/table-example/DataTableExample.vue +0 -1
  119. package/plugins/package.json +3 -1
  120. package/public/assets/@mdi/font/LICENSE +20 -0
  121. package/public/assets/@mdi/font/css/materialdesignicons.css.map +16 -0
  122. package/public/assets/@mdi/font/css/materialdesignicons.min.css +3 -0
  123. package/public/assets/@mdi/font/fonts/materialdesignicons-webfont.woff2 +0 -0
  124. package/public/assets/favicon-128.png +0 -0
  125. package/public/assets/favicon-180.png +0 -0
  126. package/public/assets/favicon-192.png +0 -0
  127. package/public/assets/favicon-32.png +0 -0
  128. package/public/assets/logo-mobile.svg +9 -0
  129. package/public/assets/logo.svg +26 -0
  130. package/src/application/VcsApp.vue +34 -5
  131. package/src/application/VcsAttributions.vue +20 -5
  132. package/src/application/VcsAttributionsFooter.vue +0 -1
  133. package/src/application/VcsNavbar.vue +18 -13
  134. package/src/callback/activateLayersCallback.js +54 -0
  135. package/src/callback/applyLayerStyleCallback.js +63 -0
  136. package/src/callback/deactivateLayersCallback.js +54 -0
  137. package/src/callback/goToViewpointCallback.js +54 -0
  138. package/src/callback/vcsCallback.js +66 -0
  139. package/src/components/buttons/VcsActionButtonList.vue +28 -10
  140. package/src/components/buttons/VcsButton.vue +38 -100
  141. package/src/components/buttons/VcsFormButton.vue +6 -4
  142. package/src/components/buttons/VcsToolButton.vue +161 -0
  143. package/src/components/form-inputs-controls/VcsDatePicker.vue +19 -5
  144. package/src/components/form-inputs-controls/VcsFormSection.vue +0 -1
  145. package/src/components/form-inputs-controls/VcsSelect.vue +16 -2
  146. package/src/components/form-inputs-controls/VcsSlider.vue +72 -0
  147. package/src/components/form-inputs-controls/VcsTextField.vue +24 -13
  148. package/src/components/form-inputs-controls/VcsWizard.vue +13 -14
  149. package/src/components/form-inputs-controls/VcsWizardStep.vue +0 -1
  150. package/src/components/lists/VcsList.vue +3 -2
  151. package/src/components/lists/VcsTreeviewLeaf.vue +0 -1
  152. package/src/components/tables/VcsDataTable.vue +2 -4
  153. package/src/contentTree/LayerTree.vue +15 -9
  154. package/src/contentTree/contentTreeCollection.js +1 -1
  155. package/src/contentTree/contentTreeItem.js +22 -3
  156. package/src/contentTree/groupContentTreeItem.js +1 -0
  157. package/src/contentTree/layerContentTreeItem.js +4 -14
  158. package/src/contentTree/layerGroupContentTreeItem.js +4 -14
  159. package/src/contentTree/obliqueCollectionContentTreeItem.js +4 -0
  160. package/src/contentTree/viewpointContentTreeItem.js +1 -0
  161. package/src/featureInfo/BalloonComponent.vue +0 -1
  162. package/src/featureInfo/abstractFeatureInfoView.js +16 -1
  163. package/src/featureInfo/featureInfo.js +45 -56
  164. package/src/i18n/de.js +5 -2
  165. package/src/i18n/en.js +5 -2
  166. package/src/i18n/i18nCollection.js +1 -2
  167. package/src/init.js +1 -4
  168. package/src/legend/vcsLegend.vue +1 -1
  169. package/src/manager/buttonManager.js +15 -0
  170. package/src/manager/{categoryManager/CategoryComponent.vue → collectionManager/CollectionComponent.vue} +57 -66
  171. package/src/manager/collectionManager/CollectionComponentList.vue +62 -0
  172. package/src/manager/collectionManager/CollectionComponentProvider.vue +38 -0
  173. package/src/manager/collectionManager/CollectionManager.vue +43 -0
  174. package/src/manager/collectionManager/categoryManager.js +83 -0
  175. package/src/manager/collectionManager/collectionComponent.js +453 -0
  176. package/src/manager/collectionManager/collectionManager.js +432 -0
  177. package/src/manager/navbarManager.js +5 -4
  178. package/src/manager/toolbox/GroupToolboxComponent.vue +5 -7
  179. package/src/manager/toolbox/SelectToolboxComponent.vue +6 -9
  180. package/src/manager/toolbox/ToolboxManager.vue +4 -5
  181. package/src/manager/window/WindowComponentHeader.vue +0 -4
  182. package/src/navigation/mapNavigation.vue +34 -8
  183. package/src/navigation/overviewMap.js +7 -1
  184. package/src/notifier/notifierComponent.vue +0 -1
  185. package/src/pluginHelper.js +5 -0
  186. package/src/search/resultItem.vue +0 -1
  187. package/src/search/searchComponent.vue +7 -9
  188. package/src/styles/_theming.scss +2 -2
  189. package/src/styles/_typography.scss +2 -2
  190. package/src/styles/main.scss +8 -0
  191. package/src/styles/vcsFont.scss +1 -22
  192. package/src/vcsUiApp.js +76 -12
  193. package/src/vuePlugins/i18n.js +18 -19
  194. package/src/vuePlugins/vuetify.js +0 -1
  195. package/dist/assets/core.3a8205.js +0 -18426
  196. package/dist/assets/index.91ae2d55.js +0 -1
  197. package/dist/assets/ui.0025be.css +0 -5
  198. package/dist/assets/ui.0025be.js +0 -18534
  199. package/plugins/@vcmap-show-case/category-tester/Categories.vue +0 -291
  200. package/plugins/@vcmap-show-case/category-tester/Category.vue +0 -164
  201. package/src/manager/categoryManager/CategoryComponentList.vue +0 -82
  202. package/src/manager/categoryManager/CategoryManager.vue +0 -47
  203. package/src/manager/categoryManager/categoryManager.js +0 -633
  204. package/start.js +0 -9
  205. /package/{src/assets/favicon-128.png → dist/assets/favicon-128.4c4ce5.png} +0 -0
  206. /package/{src/assets/favicon-180.png → dist/assets/favicon-180.5b99c0.png} +0 -0
  207. /package/{src/assets/favicon-192.png → dist/assets/favicon-192.0e205e.png} +0 -0
  208. /package/{src/assets/favicon-32.png → dist/assets/favicon-32.6b9add.png} +0 -0
  209. /package/dist/assets/{favicon.decf54cc.svg → favicon.d5ec97.svg} +0 -0
  210. /package/dist/assets/font/{TitilliumWeb-Regular.woff2 → TitilliumWeb-Regular.9ca076.woff2} +0 -0
  211. /package/{src/assets/logo-mobile.svg → dist/assets/logo-mobile.2d10a6.svg} +0 -0
  212. /package/{src/assets/logo.svg → dist/assets/logo.27089a.svg} +0 -0
  213. /package/{src → public}/assets/favicon.svg +0 -0
  214. /package/{src → public}/assets/font/OFL.txt +0 -0
  215. /package/{src → public}/assets/font/TitilliumWeb-Regular.woff2 +0 -0
@@ -0,0 +1,453 @@
1
+ import { IndexedCollection, isOverrideCollection } from '@vcmap/core';
2
+ import { getLogger } from '@vcsuite/logger';
3
+ import { v4 as uuidv4 } from 'uuid';
4
+ import { computed, ref } from 'vue';
5
+ import { validateAction } from '../../components/lists/VcsActionList.vue';
6
+ import { sortByWeight } from '../buttonManager.js';
7
+
8
+ /**
9
+ * @typedef {Object} CollectionComponentUiOptions
10
+ * @property {string} [id]
11
+ * @property {string} [title]
12
+ * @property {boolean} [draggable] - only supported for IndexedCollections
13
+ * @property {boolean} [selectable]
14
+ * @property {boolean} [singleSelect]
15
+ */
16
+
17
+ /**
18
+ * @typedef {CollectionComponentUiOptions} CollectionComponentOptions
19
+ * @property {import("@vcmap/core").Collection<T>} collection
20
+ * @template {Object} T
21
+ */
22
+
23
+ /**
24
+ * Manages one collection and creates a mirrored items array with ListItems.
25
+ * Listens to all collection events and synchronizes changes to the items array.
26
+ * The Collection Items will be transformed and filtered with the given itemMappings and itemFilter functions
27
+ * @class
28
+ * @template {Object|VcsObject} T
29
+ */
30
+ class CollectionComponent {
31
+ /**
32
+ * @param {CollectionComponentOptions} options
33
+ * @param {string|vcsAppSymbol} owner
34
+ */
35
+ constructor(options, owner) {
36
+ if (!options?.collection?.uniqueKey) {
37
+ throw new Error(
38
+ 'CollectionComponentOptions requires a collection with mandatory key!',
39
+ );
40
+ }
41
+
42
+ /**
43
+ * @type {Collection<T>}
44
+ * @private
45
+ */
46
+ this._collection = options.collection;
47
+ /**
48
+ * @type {string}
49
+ * @private
50
+ */
51
+ this._id = options.id || uuidv4();
52
+ /**
53
+ * @type {import("vue").Ref<string>}
54
+ */
55
+ this.title = ref(options.title);
56
+ /**
57
+ * @type {import("vue").Ref<boolean>}
58
+ * @private
59
+ */
60
+ this._draggable = ref(
61
+ options.draggable && this._collection instanceof IndexedCollection,
62
+ );
63
+ /**
64
+ * @type {import("vue").Ref<boolean>}
65
+ */
66
+ this.selectable = ref(options.selectable);
67
+ /**
68
+ * @type {import("vue").Ref<boolean>}
69
+ */
70
+ this.singleSelect = ref(options.singleSelect);
71
+ /**
72
+ * @type {string|vcsAppSymbol}
73
+ * @private
74
+ */
75
+ this._owner = owner;
76
+
77
+ /**
78
+ * @type {import("vue").Ref<Array<OwnedAction>>}
79
+ */
80
+ this._actions = ref([]);
81
+ /**
82
+ * @type {Array<ItemMapping<*>>}
83
+ * @private
84
+ */
85
+ this._itemMappings = [];
86
+ /**
87
+ * @type {Array<ItemFilter<*>>}
88
+ * @private
89
+ */
90
+ this._itemFilters = [];
91
+ /**
92
+ * @type {import("vue").Ref<Array<import("@vcmap/ui").VcsListItem & { destroy: (function():void)|undefined }>>}
93
+ * @private
94
+ */
95
+ this._listItems = ref([]);
96
+ /**
97
+ * @type {import("vue").Ref<Array<import("@vcmap/ui").VcsListItem & { destroy: (function():void)|undefined }>>}
98
+ */
99
+ this.selection = ref([]);
100
+
101
+ this._listeners = [
102
+ this._collection.added.addEventListener(this._handleItemAdded.bind(this)),
103
+ this._collection.removed.addEventListener(
104
+ this._handleItemRemoved.bind(this),
105
+ ),
106
+ ];
107
+
108
+ if (this._collection[isOverrideCollection]) {
109
+ this._listeners.push(
110
+ this._collection.replaced.addEventListener((replacedEvent) => {
111
+ this._handleItemRemoved(replacedEvent.old);
112
+ }),
113
+ );
114
+ }
115
+
116
+ if (this._collection instanceof IndexedCollection) {
117
+ this._listeners.push(
118
+ this._collection.moved.addEventListener(
119
+ this._handleItemMoved.bind(this),
120
+ ),
121
+ );
122
+ }
123
+
124
+ this.reset();
125
+ }
126
+
127
+ /**
128
+ * @type {string}
129
+ * @readonly
130
+ */
131
+ get id() {
132
+ return this._id;
133
+ }
134
+
135
+ /**
136
+ * @type {Collection<*>}
137
+ * @readonly
138
+ */
139
+ get collection() {
140
+ return this._collection;
141
+ }
142
+
143
+ /**
144
+ * @type {import("vue").Ref<Array<import("@vcmap/ui").VcsListItem & { destroy: (function():void)|undefined }>>}
145
+ * @readonly
146
+ */
147
+ get items() {
148
+ return this._listItems;
149
+ }
150
+
151
+ /**
152
+ * @type {import("vue").Ref<boolean>}
153
+ * @readonly
154
+ */
155
+ get draggable() {
156
+ return this._draggable;
157
+ }
158
+
159
+ /**
160
+ * @param {boolean} value
161
+ */
162
+ set draggable(value) {
163
+ if (this._collection instanceof IndexedCollection) {
164
+ getLogger('CollectionComponent').warn(
165
+ 'draggable can only be set to IndexedCollections!',
166
+ );
167
+ return;
168
+ }
169
+ this._draggable.value = value;
170
+ }
171
+
172
+ /**
173
+ * @type {string|vcsAppSymbol}
174
+ * @readonly
175
+ */
176
+ get owner() {
177
+ return this._owner;
178
+ }
179
+
180
+ /**
181
+ * @returns {import("vue").ComputedRef<VcsAction[]>}
182
+ */
183
+ getActions() {
184
+ return computed(() => this._actions.value.map(({ action }) => action));
185
+ }
186
+
187
+ /**
188
+ * uses the itemMappings to transform the given Item to an VcsListItem usable in the VcsList
189
+ * @param {T} item
190
+ * @returns {import("@vcmap/ui").VcsListItem & { destroy: (function():void)|undefined }}
191
+ * @template T
192
+ * @private
193
+ */
194
+ _transformItem(item) {
195
+ const keyProperty = this._collection.uniqueKey;
196
+ const listItem = {
197
+ get name() {
198
+ return item[keyProperty];
199
+ },
200
+ title: item?.properties?.title || item[keyProperty],
201
+ visible: item?.properties?.visible,
202
+ disabled: item?.properties?.disabled,
203
+ tooltip: item?.properties?.tooltip,
204
+ icon: item?.properties?.icon,
205
+ hasUpdate: item?.properties?.hasUpdate,
206
+ actions: [],
207
+ };
208
+ this._itemMappings.forEach((itemMapping) => {
209
+ if (
210
+ itemMapping.predicate === undefined ||
211
+ itemMapping.predicate(item, this)
212
+ ) {
213
+ itemMapping.mappingFunction(item, this, listItem);
214
+ }
215
+ });
216
+ listItem.actions = listItem.actions.filter((action) => {
217
+ return validateAction(action);
218
+ });
219
+ return listItem;
220
+ }
221
+
222
+ /**
223
+ * Inserts the listItem into the list items array at the correct relative position in respect to the position of the listItem
224
+ * in the collection
225
+ * @param {import("@vcmap/ui").VcsListItem} listItem
226
+ * @private
227
+ */
228
+ _insertListItem(listItem) {
229
+ if (!this._listItems.value.includes(listItem)) {
230
+ if (this._collection instanceof IndexedCollection) {
231
+ const newItemIndex = this._collection.indexOfKey(listItem.name);
232
+ if (newItemIndex === this._collection.size - 1) {
233
+ this._listItems.value.push(listItem);
234
+ } else {
235
+ const positionInChildren = this._listItems.value.findIndex((elem) => {
236
+ const treeViewItemIndex = this._collection.indexOfKey(elem.name);
237
+ return newItemIndex < treeViewItemIndex;
238
+ });
239
+ if (positionInChildren >= 0) {
240
+ this._listItems.value.splice(positionInChildren, 0, listItem);
241
+ } else {
242
+ this._listItems.value.push(listItem);
243
+ }
244
+ }
245
+ } else {
246
+ this._listItems.value.push(listItem);
247
+ }
248
+ }
249
+ }
250
+
251
+ /**
252
+ * synchronizes the category items with the internal items list.
253
+ * @param {T} item
254
+ * @template T
255
+ * @private
256
+ */
257
+ _handleItemAdded(item) {
258
+ if (
259
+ this._itemFilters.every(({ filterFunction }) =>
260
+ filterFunction(item, this),
261
+ )
262
+ ) {
263
+ const listItem = this._transformItem(item);
264
+ this._insertListItem(listItem);
265
+ }
266
+ }
267
+
268
+ /**
269
+ * synchronizes the order of the list items with respect to the order of the items in the collection.
270
+ * removes and reinserts the moved item.
271
+ * @param {T} item
272
+ * @template T
273
+ * @private
274
+ */
275
+ _handleItemMoved(item) {
276
+ if (
277
+ this._itemFilters.every(({ filterFunction }) =>
278
+ filterFunction(item, this),
279
+ )
280
+ ) {
281
+ const index = this._listItems.value.findIndex((elem) => {
282
+ return elem.name === item[this._collection.uniqueKey];
283
+ });
284
+ if (index > -1) {
285
+ const listItem = this._listItems.value[index];
286
+ this._listItems.value.splice(index, 1);
287
+ this._insertListItem(listItem);
288
+ }
289
+ }
290
+ }
291
+
292
+ /**
293
+ * synchronizes the collection items with the internal list items.
294
+ * @param {T} item
295
+ * @template T
296
+ * @private
297
+ */
298
+ _handleItemRemoved(item) {
299
+ const index = this._listItems.value.findIndex((elem) => {
300
+ return elem.name === item[this._collection.uniqueKey];
301
+ });
302
+ if (index > -1) {
303
+ const listItem = this._listItems.value[index];
304
+ if (listItem.destroy) {
305
+ listItem.destroy();
306
+ }
307
+ this._listItems.value.splice(index, 1);
308
+ }
309
+ }
310
+
311
+ /**
312
+ * recreates the items array with the new Mapping Function
313
+ * @param {ItemMapping} itemMapping
314
+ */
315
+ addItemMapping(itemMapping) {
316
+ if (
317
+ !this._itemMappings.find(({ mappingFunction, owner }) => {
318
+ return (
319
+ itemMapping.mappingFunction === mappingFunction &&
320
+ itemMapping.owner === owner
321
+ );
322
+ })
323
+ ) {
324
+ this._itemMappings.push(itemMapping);
325
+ this.reset();
326
+ }
327
+ }
328
+
329
+ /**
330
+ * recreates the items array with the new Mapping Function
331
+ * @param {ItemMapping} itemMapping
332
+ */
333
+ removeItemMapping(itemMapping) {
334
+ const index = this._itemMappings.findIndex(({ mappingFunction, owner }) => {
335
+ return (
336
+ itemMapping.mappingFunction === mappingFunction &&
337
+ itemMapping.owner === owner
338
+ );
339
+ });
340
+ if (index > -1) {
341
+ this._itemMappings.splice(index, 1);
342
+ this.reset();
343
+ }
344
+ }
345
+
346
+ /**
347
+ * recreates the items array with the new Filter Function
348
+ * @param {ItemFilter} itemFilter
349
+ */
350
+ addItemFilter(itemFilter) {
351
+ if (
352
+ !this._itemFilters.find(({ filterFunction, owner }) => {
353
+ return (
354
+ itemFilter.filterFunction === filterFunction &&
355
+ itemFilter.owner === owner
356
+ );
357
+ })
358
+ ) {
359
+ this._itemFilters.push(itemFilter);
360
+ this.reset();
361
+ }
362
+ }
363
+
364
+ /**
365
+ * recreates the items array with the new Filter Function
366
+ * @param {ItemFilter} itemFilter
367
+ */
368
+ removeItemFilter(itemFilter) {
369
+ const index = this._itemFilters.findIndex(({ filterFunction, owner }) => {
370
+ return (
371
+ itemFilter.filterFunction === filterFunction &&
372
+ itemFilter.owner === owner
373
+ );
374
+ });
375
+ if (index > -1) {
376
+ this._itemFilters.splice(index, 1);
377
+ this.reset();
378
+ }
379
+ }
380
+
381
+ /**
382
+ * @param {Array<OwnedAction>} ownedActions
383
+ */
384
+ addActions(ownedActions) {
385
+ const actions = [...this._actions.value, ...ownedActions];
386
+ this._actions.value = actions
387
+ .filter((item, pos, self) => {
388
+ return self.indexOf(item) === pos;
389
+ })
390
+ .sort(sortByWeight);
391
+ }
392
+
393
+ /**
394
+ * @param {Array<OwnedAction>} ownedActions
395
+ */
396
+ removeActions(ownedActions) {
397
+ this._actions.value = this._actions.value.filter((ownedAction) => {
398
+ return !ownedActions.includes(ownedAction);
399
+ });
400
+ }
401
+
402
+ /**
403
+ * removes itemMapping, itemFilter and actions of provided owner and resets all list items
404
+ * @param {string | symbol} owner
405
+ */
406
+ removeOwner(owner) {
407
+ const itemMappings = this._itemMappings.filter((itemMapping) => {
408
+ return itemMapping.owner !== owner;
409
+ });
410
+ const itemFilters = this._itemFilters.filter((itemFilter) => {
411
+ return itemFilter.owner !== owner;
412
+ });
413
+ const actions = this._actions.value.filter(
414
+ (ownedAction) => ownedAction.owner !== owner,
415
+ );
416
+ if (
417
+ itemMappings.length < this._itemMappings.length ||
418
+ itemFilters.length < this._itemFilters.length
419
+ ) {
420
+ this.reset();
421
+ }
422
+ this._itemMappings = itemMappings;
423
+ this._itemFilters = itemFilters;
424
+ this._actions.value = actions;
425
+ }
426
+
427
+ /**
428
+ * resets this collection component by destroying all list items and
429
+ * re-adding them from the collection applying current filter and mapping functions
430
+ */
431
+ reset() {
432
+ this._listItems.value.forEach((i) => i.destroy?.());
433
+ this._listItems.value = [];
434
+ this.selection.value = [];
435
+ [...this._collection]
436
+ .filter((item) =>
437
+ this._itemFilters.every(({ filterFunction }) =>
438
+ filterFunction(item, this),
439
+ ),
440
+ )
441
+ .map((item) => this._transformItem(item))
442
+ .forEach((listItem) => this._listItems.value.push(listItem));
443
+ }
444
+
445
+ destroy() {
446
+ this._listeners.forEach((cb) => cb());
447
+ this._listItems.value.forEach((i) => i.destroy?.());
448
+ this._listItems.value = [];
449
+ this.selection.value = [];
450
+ }
451
+ }
452
+
453
+ export default CollectionComponent;