@conduction/nextcloud-vue 2.181.1 → 2.183.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 (29) hide show
  1. package/dist/esm/components/CnMapWidget/CnMapWidget.vue.js +1 -1
  2. package/dist/esm/components/CnMapWidget/CnMapWidget2.vue.js +43 -11
  3. package/dist/esm/components/CnMapWidget/CnMapWidget2.vue.js.map +1 -1
  4. package/dist/esm/components/CnMapWidget/CnMapWidget3.vue.js.map +1 -1
  5. package/dist/esm/components/CnMapWidget/basemapPresets.js +81 -0
  6. package/dist/esm/components/CnMapWidget/basemapPresets.js.map +1 -0
  7. package/dist/esm/components/CnMapWidget/spatialFilter.js +136 -0
  8. package/dist/esm/components/CnMapWidget/spatialFilter.js.map +1 -0
  9. package/dist/esm/components/CnMapWidgetForm/CnMapWidgetForm.vue.js +1 -1
  10. package/dist/esm/components/CnMapWidgetForm/CnMapWidgetForm2.vue.js +37 -12
  11. package/dist/esm/components/CnMapWidgetForm/CnMapWidgetForm2.vue.js.map +1 -1
  12. package/dist/esm/components/CnMapWidgetForm/CnMapWidgetForm3.vue.js +27 -9
  13. package/dist/esm/components/CnMapWidgetForm/CnMapWidgetForm3.vue.js.map +1 -1
  14. package/dist/esm/l10n/nl.json.js +5 -1
  15. package/dist/esm/l10n/nl.json.js.map +1 -1
  16. package/dist/esm/library-style.js +1 -1
  17. package/dist/esm/nextcloud-vue.css +23 -23
  18. package/dist/esm/utils/geo.js +49 -10
  19. package/dist/esm/utils/geo.js.map +1 -1
  20. package/dist/nextcloud-vue.cjs.js +369 -43
  21. package/dist/nextcloud-vue.cjs.js.map +2 -2
  22. package/dist/nextcloud-vue.css +23 -23
  23. package/l10n/nl.json +5 -1
  24. package/package.json +1 -1
  25. package/src/components/CnMapWidget/CnMapWidget.vue +48 -11
  26. package/src/components/CnMapWidget/basemapPresets.js +78 -0
  27. package/src/components/CnMapWidget/spatialFilter.js +132 -0
  28. package/src/components/CnMapWidgetForm/CnMapWidgetForm.vue +53 -13
  29. package/src/utils/geo.js +48 -9
@@ -7535,7 +7535,11 @@ var translations$c = {
7535
7535
  "An EAN-13 code takes twelve or thirteen digits with a valid check digit.": "Een EAN-13-code neemt twaalf of dertien cijfers met een geldig controlecijfer.",
7536
7536
  "A Code 128 code takes letters, digits and plain punctuation only.": "Een Code 128-code neemt alleen letters, cijfers en gewone leestekens.",
7537
7537
  "Started. It finishes in the background.": "Gestart. Het wordt op de achtergrond afgerond.",
7538
- "At most {max} rows.": "Hoogstens {max} rijen."
7538
+ "At most {max} rows.": "Hoogstens {max} rijen.",
7539
+ "Location field": "Locatieveld",
7540
+ "Objects are plotted from the location field: a point, line or area. Without one, from their location (@self.geo). Objects without a location are skipped.": "Objecten worden getekend vanuit het locatieveld: een punt, lijn of vlak. Zonder locatieveld vanuit hun locatie (@self.geo). Objecten zonder locatie worden overgeslagen.",
7541
+ "Custom base map": "Eigen achtergrondkaart",
7542
+ "Base map": "Achtergrondkaart"
7539
7543
  };
7540
7544
  var plurals = {
7541
7545
  "{count} member": [
@@ -42479,16 +42483,44 @@ function parseGeoPoint(geo) {
42479
42483
  )
42480
42484
  }
42481
42485
 
42486
+ const GEOMETRY_TYPES = ['Point', 'MultiPoint', 'LineString', 'MultiLineString', 'Polygon', 'MultiPolygon'];
42487
+
42488
+ /**
42489
+ * The GeoJSON geometry a property value holds: a geometry, or a Feature's
42490
+ * geometry. Returns null for anything else, so a point-shaped value falls
42491
+ * through to parseGeoPoint().
42492
+ *
42493
+ * @param {unknown} value The property value.
42494
+ * @return {?object} The geometry, or null.
42495
+ */
42496
+ function parseGeoGeometry(value) {
42497
+ if (!value || typeof value !== 'object') {
42498
+ return null
42499
+ }
42500
+ const geometry = value.type === 'Feature' ? value.geometry : value;
42501
+ if (!geometry || !GEOMETRY_TYPES.includes(geometry.type) || !Array.isArray(geometry.coordinates)) {
42502
+ return null
42503
+ }
42504
+ if (geometry.type === 'Point') {
42505
+ const point = parseGeoPoint(geometry);
42506
+ return point ? { type: 'Point', coordinates: [point.lng, point.lat] } : null
42507
+ }
42508
+ return geometry.coordinates.length > 0 ? geometry : null
42509
+ }
42510
+
42482
42511
  /**
42483
- * Turn an OpenRegister object into a GeoJSON Point Feature, or null when it has no
42512
+ * Turn an OpenRegister object into a GeoJSON Feature, or null when it has no
42484
42513
  * usable location.
42485
42514
  *
42486
- * Looks at `@self.geo` first (where the geo widget writes it). Falls back to plain
42487
- * lat/lng fields on the object itself, so a schema that models coordinates as its own
42488
- * properties still plots without having to migrate to `@self.geo`.
42515
+ * With `geoProperty` set, that property is read first: a GeoJSON geometry of any
42516
+ * type (point, line, polygon or a multi-geometry), a Feature, or a lat/lng value.
42517
+ * Otherwise, or when it is empty, `@self.geo` is read (where the geo widget writes
42518
+ * it), and then plain lat/lng fields on the object itself, so a schema that models
42519
+ * coordinates as its own properties still plots.
42489
42520
  *
42490
42521
  * @param {object} obj The OpenRegister object.
42491
42522
  * @param {object} [options] Options.
42523
+ * @param {string} [options.geoProperty] Property holding the object's geometry.
42492
42524
  * @param {string} [options.latField] Property holding latitude, for the fallback.
42493
42525
  * @param {string} [options.lngField] Property holding longitude, for the fallback.
42494
42526
  * @return {?object} A GeoJSON Feature whose `properties` is the object, or null.
@@ -42498,14 +42530,25 @@ function objectToGeoFeature(obj, options = {}) {
42498
42530
  return null
42499
42531
  }
42500
42532
 
42533
+ const { geoProperty, latField, lngField } = options;
42534
+ if (geoProperty) {
42535
+ const value = obj[geoProperty];
42536
+ const geometry = parseGeoGeometry(value);
42537
+ const point = geometry ? null : parseGeoPoint(value);
42538
+ if (geometry || point) {
42539
+ return {
42540
+ type: 'Feature',
42541
+ geometry: geometry || { type: 'Point', coordinates: [point.lng, point.lat] },
42542
+ properties: { ...obj },
42543
+ }
42544
+ }
42545
+ }
42546
+
42501
42547
  const self = obj['@self'] || {};
42502
42548
  let point = parseGeoPoint(self.geo);
42503
42549
 
42504
- if (!point) {
42505
- const { latField, lngField } = options;
42506
- if (latField && lngField) {
42507
- point = finitePoint(obj[latField], obj[lngField]);
42508
- }
42550
+ if (!point && latField && lngField) {
42551
+ point = finitePoint(obj[latField], obj[lngField]);
42509
42552
  }
42510
42553
  if (!point) {
42511
42554
  return null
@@ -42773,6 +42816,137 @@ function hasImagePosition(row, xField, yField) {
42773
42816
  return !!row && Number.isFinite(row[xField]) && Number.isFinite(row[yField])
42774
42817
  }
42775
42818
 
42819
+ /**
42820
+ * SPDX-FileCopyrightText: 2026 Conduction B.V. <info@conduction.nl>
42821
+ * SPDX-License-Identifier: EUPL-1.2
42822
+ *
42823
+ * Spatial filters and detail links for a map that plots OpenRegister objects.
42824
+ *
42825
+ * `markers.dataSource.spatialFilter` narrows the objects to an area, through
42826
+ * OpenRegister's geo filters:
42827
+ * - `{ bbox: [west, south, east, north] }` → `GET ?geo.bbox=w,s,e,n`
42828
+ * - `{ near: [lon, lat], radius: meters }` → `GET ?geo.near=lon,lat&geo.radius=m`
42829
+ * - `{ within: <GeoJSON Polygon|MultiPolygon> }` → `POST …/geo-search`
42830
+ * The map's `markers.geoProperty`, when set, is sent as `geo.property` so the
42831
+ * filter reads the same property the map draws.
42832
+ *
42833
+ * `markers.detailLink` is the address a clicked feature opens in a new tab: a
42834
+ * template whose `{id}`, `{register}`, `{schema}` and `{<property>}` tokens are
42835
+ * filled from the object. Without a template, a `url` the object carries (the
42836
+ * address OpenRegister's deep-link registry stamps) is opened instead. An
42837
+ * app-absolute path gets the instance's webroot.
42838
+ */
42839
+
42840
+
42841
+ const POLYGON_TYPES = ['Polygon', 'MultiPolygon'];
42842
+
42843
+ /**
42844
+ * Whether every entry is a finite number and there are `length` of them.
42845
+ *
42846
+ * @param {unknown} list The value.
42847
+ * @param {number} length The expected length.
42848
+ * @return {boolean}
42849
+ */
42850
+ function isNumberTuple(list, length) {
42851
+ return Array.isArray(list) && list.length === length && list.every((n) => Number.isFinite(Number(n)) && n !== '' && n !== null)
42852
+ }
42853
+
42854
+ /**
42855
+ * The OpenRegister request a spatial filter makes, or null when there is no
42856
+ * usable filter. A malformed filter is ignored rather than sent, so a typo in
42857
+ * a widget's config never empties the map with a 422.
42858
+ *
42859
+ * @param {object|null|undefined} spatialFilter The `dataSource.spatialFilter` block.
42860
+ * @param {string} [geoProperty] The property the map draws, sent as `geo.property`.
42861
+ * @return {{params: object}|{body: object}|null} Query params for the listing, or a geo-search body.
42862
+ * @spec openspec/changes/map-spatial-filter-and-detail-link/specs/map-spatial-filter-and-detail-link/spec.md#requirement-a-map-can-narrow-its-objects-to-an-area
42863
+ */
42864
+ function spatialFilterRequest(spatialFilter, geoProperty) {
42865
+ if (!spatialFilter || typeof spatialFilter !== 'object') {
42866
+ return null
42867
+ }
42868
+ const property = typeof geoProperty === 'string' && geoProperty !== '' ? { 'geo.property': geoProperty } : {};
42869
+
42870
+ const within = spatialFilter.within;
42871
+ if (within && typeof within === 'object' && POLYGON_TYPES.includes(within.type) && Array.isArray(within.coordinates)) {
42872
+ const body = { geometry: { within } };
42873
+ if (property['geo.property']) {
42874
+ body.property = property['geo.property'];
42875
+ }
42876
+ return { body }
42877
+ }
42878
+ if (isNumberTuple(spatialFilter.bbox, 4)) {
42879
+ return { params: { 'geo.bbox': spatialFilter.bbox.map(Number).join(','), ...property } }
42880
+ }
42881
+ if (isNumberTuple(spatialFilter.near, 2) && Number(spatialFilter.radius) > 0) {
42882
+ return {
42883
+ params: {
42884
+ 'geo.near': spatialFilter.near.map(Number).join(','),
42885
+ 'geo.radius': String(Number(spatialFilter.radius)),
42886
+ ...property,
42887
+ },
42888
+ }
42889
+ }
42890
+ return null
42891
+ }
42892
+
42893
+ /**
42894
+ * The value a detail-link token reads from an object.
42895
+ *
42896
+ * @param {object} object The feature's properties (the OpenRegister object).
42897
+ * @param {string} token The token name.
42898
+ * @return {unknown}
42899
+ */
42900
+ function tokenValue(object, token) {
42901
+ const self = object['@self'] && typeof object['@self'] === 'object' ? object['@self'] : {};
42902
+ if (token === 'id') {
42903
+ return self.id ?? object.id ?? object.uuid
42904
+ }
42905
+ if (token === 'register' || token === 'schema') {
42906
+ return self[token] ?? object[token]
42907
+ }
42908
+ return object[token]
42909
+ }
42910
+
42911
+ /**
42912
+ * The address a clicked feature opens, or null when it has none. A template
42913
+ * with a token the object cannot fill gives null, so a click never opens a
42914
+ * half-built address.
42915
+ *
42916
+ * @param {object|null} feature The clicked GeoJSON feature.
42917
+ * @param {string} [template] The `markers.detailLink` template.
42918
+ * @return {string|null} A safe href, or null.
42919
+ * @spec openspec/changes/map-spatial-filter-and-detail-link/specs/map-spatial-filter-and-detail-link/spec.md#requirement-a-clicked-object-opens-its-detail-page
42920
+ */
42921
+ function featureDetailUrl(feature, template) {
42922
+ const object = feature && feature.properties && typeof feature.properties === 'object' ? feature.properties : null;
42923
+ if (object === null) {
42924
+ return null
42925
+ }
42926
+ let href = null;
42927
+ if (typeof template === 'string' && template !== '') {
42928
+ let missing = false;
42929
+ href = template.replace(/\{([\w@.-]+)\}/g, (_match, token) => {
42930
+ const value = tokenValue(object, token);
42931
+ if (value === undefined || value === null || value === '' || typeof value === 'object') {
42932
+ missing = true;
42933
+ return ''
42934
+ }
42935
+ return encodeURIComponent(String(value))
42936
+ });
42937
+ if (missing) {
42938
+ return null
42939
+ }
42940
+ } else if (typeof object.url === 'string' && object.url !== '') {
42941
+ href = object.url;
42942
+ }
42943
+ if (href === null) {
42944
+ return null
42945
+ }
42946
+ const safe = safeHref(href);
42947
+ return safe === '#' ? null : prefixUrl(safe)
42948
+ }
42949
+
42776
42950
  const ALLOWED_LAYER_TYPES = ['tile', 'wms', 'wfs', 'geojson', 'image'];
42777
42951
 
42778
42952
  // Raw input on the map container, which is what tells a user's pan or zoom from
@@ -42960,14 +43134,17 @@ var script$8S = {
42960
43134
  },
42961
43135
 
42962
43136
  /**
42963
- * Marker config. `{ features?, dataSource?, latField?, lngField?, xField?, yField?,
42964
- * popupField?, clustering?, iconColor?, iconUrl?, centerMarker? }`. On an image map
43137
+ * Marker config. `{ features?, dataSource?, geoProperty?, latField?, lngField?, xField?, yField?,
43138
+ * popupField?, clustering?, iconColor?, iconUrl?, centerMarker?, detailLink? }`. On an image map
42965
43139
  * (a layer of type `image`) markers read `xField` / `yField` (default `x` / `y`,
42966
43140
  * pixels from the picture's top left) instead of `latField` / `lngField`. `features[]` is inline;
42967
43141
  * `dataSource.url` is HTTP-fetched on mount; `dataSource.{register, schema}`
42968
- * plots the objects of an OpenRegister register/schema via their `@self.geo`.
43142
+ * plots the objects of an OpenRegister register/schema via `geoProperty` (a property
43143
+ * holding a GeoJSON geometry of any type, or a point) when set, else `@self.geo`.
42969
43144
  * `centerMarker: true` adds an extra pin at the map's `center`, alongside any
42970
- * source markers.
43145
+ * source markers. `dataSource.spatialFilter` (`{ bbox }`, `{ near, radius }` or
43146
+ * `{ within }`) narrows a register source to an area; `detailLink` is the address
43147
+ * a clicked object opens in a new tab (see spatialFilter.js).
42971
43148
  *
42972
43149
  * @type {object|null}
42973
43150
  */
@@ -43375,14 +43552,18 @@ var script$8S = {
43375
43552
  },
43376
43553
 
43377
43554
  /**
43378
- * The data-source filter with its tokens resolved, serialised so a new
43379
- * record re-reads the markers.
43555
+ * The data-source filter with its tokens resolved, and the spatial
43556
+ * filter, serialised so a new record or a new area re-reads the markers.
43380
43557
  *
43381
43558
  * @return {string}
43559
+ * @spec openspec/changes/map-spatial-filter-and-detail-link/specs/map-spatial-filter-and-detail-link/spec.md#requirement-a-map-can-narrow-its-objects-to-an-area
43382
43560
  */
43383
43561
  filterKey() {
43384
43562
  const ds = this.cfg.markers && this.cfg.markers.dataSource;
43385
- return ds && ds.filter ? JSON.stringify(this.sourceFilter(ds)) : ''
43563
+ if (!ds || (!ds.filter && !ds.spatialFilter)) {
43564
+ return ''
43565
+ }
43566
+ return JSON.stringify([ds.filter ? this.sourceFilter(ds) : null, ds.spatialFilter || null])
43386
43567
  },
43387
43568
 
43388
43569
  unplottedLabel() {
@@ -43925,6 +44106,7 @@ var script$8S = {
43925
44106
  * @type {{feature: object, latlng: object}}
43926
44107
  */
43927
44108
  this.$emit('marker-click', { feature, latlng: e.latlng });
44109
+ this.openFeatureDetail(feature);
43928
44110
  });
43929
44111
  },
43930
44112
  });
@@ -44422,8 +44604,11 @@ var script$8S = {
44422
44604
  * skipped rather than dropped at (0, 0) — an invisible wrong marker is worse
44423
44605
  * than an absent one.
44424
44606
  *
44425
- * @param {{register: string, schema: string, limit?: number}} ds The data source.
44607
+ * A `spatialFilter` narrows the objects to an area (see spatialFilter.js).
44608
+ *
44609
+ * @param {{register: string, schema: string, limit?: number, spatialFilter?: object}} ds The data source.
44426
44610
  * @return {Promise<Array<object>>} GeoJSON Feature array.
44611
+ * @spec openspec/changes/map-spatial-filter-and-detail-link/specs/map-spatial-filter-and-detail-link/spec.md#requirement-a-map-can-narrow-its-objects-to-an-area
44427
44612
  */
44428
44613
  async fetchRegisterFeatures(ds) {
44429
44614
  try {
@@ -44435,16 +44620,22 @@ var script$8S = {
44435
44620
  '/apps/openregister/api/objects/{register}/{schema}',
44436
44621
  { register: ds.register, schema: ds.schema },
44437
44622
  );
44438
- const res = await axios.get(url, { params: { ...this.sourceFilter(ds), _limit: ds.limit || 500 } });
44623
+ const params = { ...this.sourceFilter(ds), _limit: ds.limit || 500 };
44624
+ const spatial = spatialFilterRequest(ds.spatialFilter, this.cfg.markers && this.cfg.markers.geoProperty);
44625
+ const res = spatial && spatial.body
44626
+ ? await axios.post(url + '/geo-search', spatial.body, { params })
44627
+ : await axios.get(url, { params: { ...params, ...(spatial ? spatial.params : {}) } });
44439
44628
  const rows = (res && res.data && res.data.results) || [];
44440
44629
 
44441
44630
  const latField = this.cfg.markers && this.cfg.markers.latField;
44442
44631
  const lngField = this.cfg.markers && this.cfg.markers.lngField;
44632
+ const geoProperty = this.cfg.markers && this.cfg.markers.geoProperty;
44443
44633
 
44444
44634
  // (0, 0) is where an unset pair of numbers lands, not a place.
44445
44635
  return rows
44446
- .map((row) => objectToGeoFeature(row, { latField, lngField }))
44447
- .filter((feature) => feature && !(feature.geometry.coordinates[0] === 0 && feature.geometry.coordinates[1] === 0))
44636
+ .map((row) => objectToGeoFeature(row, { geoProperty, latField, lngField }))
44637
+ .filter((feature) => feature && !(feature.geometry.type === 'Point'
44638
+ && feature.geometry.coordinates[0] === 0 && feature.geometry.coordinates[1] === 0))
44448
44639
  } catch (err) {
44449
44640
  this.markersFailed = true;
44450
44641
  // eslint-disable-next-line no-console
@@ -44453,6 +44644,20 @@ var script$8S = {
44453
44644
  }
44454
44645
  },
44455
44646
 
44647
+ /**
44648
+ * Open a clicked object's detail address in a new tab, when it has one.
44649
+ *
44650
+ * @param {object} feature The clicked GeoJSON feature.
44651
+ * @return {void}
44652
+ * @spec openspec/changes/map-spatial-filter-and-detail-link/specs/map-spatial-filter-and-detail-link/spec.md#requirement-a-clicked-object-opens-its-detail-page
44653
+ */
44654
+ openFeatureDetail(feature) {
44655
+ const href = featureDetailUrl(feature, this.cfg.markers && this.cfg.markers.detailLink);
44656
+ if (href !== null) {
44657
+ window.open(href, '_blank', 'noopener,noreferrer');
44658
+ }
44659
+ },
44660
+
44456
44661
  /**
44457
44662
  * Normalise a fetched payload into a GeoJSON Feature array.
44458
44663
  * Accepts FeatureCollection, raw Feature[], or flat rows that
@@ -44579,23 +44784,95 @@ function render$8Q(_ctx, _cache, $props, $setup, $data, $options) {
44579
44784
  }
44580
44785
 
44581
44786
  script$8S.render = render$8Q;
44582
- script$8S.__scopeId = "data-v-683678f9";
44787
+ script$8S.__scopeId = "data-v-1fc9cf51";
44583
44788
  const __sfc_main$8M = script$8S;
44584
44789
 
44790
+ /**
44791
+ * SPDX-FileCopyrightText: 2026 Conduction B.V. <info@conduction.nl>
44792
+ * SPDX-License-Identifier: EUPL-1.2
44793
+ *
44794
+ * The base maps the map widget form offers. Each entry has the same shape as a
44795
+ * `basemaps[]` item of CnMapWidget (`name`, `url`, `attribution`, `options`), so
44796
+ * a chosen preset is stored as an ordinary base map and renders on any version.
44797
+ *
44798
+ * The PDOK tiles are the Dutch government's open base maps, served in
44799
+ * EPSG:3857 so Leaflet's default projection draws them. A consuming app must
44800
+ * allow `service.pdok.nl` in its Content-Security-Policy `img-src`.
44801
+ */
44802
+
44803
+ const PDOK_ATTRIBUTION = 'Kaartgegevens © <a href="https://www.kadaster.nl">Kadaster</a>';
44804
+
44805
+ const BASEMAP_PRESETS = Object.freeze([
44806
+ Object.freeze({
44807
+ id: 'osm',
44808
+ name: 'OpenStreetMap',
44809
+ url: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
44810
+ attribution: '© OpenStreetMap contributors',
44811
+ options: Object.freeze({ maxZoom: 19 }),
44812
+ }),
44813
+ Object.freeze({
44814
+ id: 'pdok-brt',
44815
+ name: 'PDOK BRT achtergrondkaart',
44816
+ url: 'https://service.pdok.nl/brt/achtergrondkaart/wmts/v2_0/standaard/EPSG:3857/{z}/{x}/{y}.png',
44817
+ attribution: PDOK_ATTRIBUTION,
44818
+ options: Object.freeze({ maxZoom: 19 }),
44819
+ }),
44820
+ Object.freeze({
44821
+ id: 'pdok-brt-grijs',
44822
+ name: 'PDOK BRT achtergrondkaart grijs',
44823
+ url: 'https://service.pdok.nl/brt/achtergrondkaart/wmts/v2_0/grijs/EPSG:3857/{z}/{x}/{y}.png',
44824
+ attribution: PDOK_ATTRIBUTION,
44825
+ options: Object.freeze({ maxZoom: 19 }),
44826
+ }),
44827
+ Object.freeze({
44828
+ id: 'pdok-brt-pastel',
44829
+ name: 'PDOK BRT achtergrondkaart pastel',
44830
+ url: 'https://service.pdok.nl/brt/achtergrondkaart/wmts/v2_0/pastel/EPSG:3857/{z}/{x}/{y}.png',
44831
+ attribution: PDOK_ATTRIBUTION,
44832
+ options: Object.freeze({ maxZoom: 19 }),
44833
+ }),
44834
+ Object.freeze({
44835
+ id: 'pdok-luchtfoto',
44836
+ name: 'PDOK luchtfoto',
44837
+ url: 'https://service.pdok.nl/hwh/luchtfotorgb/wmts/v1_0/Actueel_orthoHR/EPSG:3857/{z}/{x}/{y}.jpeg',
44838
+ attribution: PDOK_ATTRIBUTION,
44839
+ options: Object.freeze({ maxZoom: 19 }),
44840
+ }),
44841
+ ]);
44842
+
44843
+ /**
44844
+ * The stored base map for a preset id, as a plain `basemaps[]` item.
44845
+ *
44846
+ * @param {string} id The preset id.
44847
+ * @return {{name: string, url: string, attribution: string, options: object}|null} The base map, or null.
44848
+ */
44849
+ function basemapFromPreset(id) {
44850
+ const preset = BASEMAP_PRESETS.find((entry) => entry.id === id);
44851
+ if (!preset) {
44852
+ return null
44853
+ }
44854
+ return { name: preset.name, url: preset.url, attribution: preset.attribution, options: { ...preset.options } }
44855
+ }
44856
+
44857
+ /**
44858
+ * The preset a stored base map came from, matched on its tile URL.
44859
+ *
44860
+ * @param {object|undefined} basemap A `basemaps[]` item.
44861
+ * @return {string|null} The preset id, or null for a custom base map.
44862
+ */
44863
+ function presetOf(basemap) {
44864
+ const url = basemap && basemap.url;
44865
+ const preset = BASEMAP_PRESETS.find((entry) => entry.url === url);
44866
+ return preset ? preset.id : null
44867
+ }
44868
+
44585
44869
  // The Netherlands, roughly — a sane default centre for a Dutch-government library.
44586
44870
  // autoFit is on by default, so this only shows before any object is plotted.
44587
44871
  const DEFAULT_CENTRE = [52.13, 5.29];
44588
44872
 
44589
44873
  // Without a basemap the widget renders a grey box: CnMapWidget's `basemaps` prop is
44590
44874
  // opt-in and empty by default. The Nextcloud CSP already allows *.tile.openstreetmap.org.
44591
- const DEFAULT_BASEMAPS = [
44592
- {
44593
- name: 'OpenStreetMap',
44594
- url: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
44595
- attribution: '© OpenStreetMap contributors',
44596
- options: { maxZoom: 19 },
44597
- },
44598
- ];
44875
+ const DEFAULT_BASEMAPS = [basemapFromPreset('osm')];
44599
44876
 
44600
44877
  const DEFAULT_CONTENT$t = {
44601
44878
  register: '',
@@ -44621,7 +44898,7 @@ const DEFAULT_CONTENT$t = {
44621
44898
  var script$8R = {
44622
44899
  name: 'CnMapWidgetForm',
44623
44900
 
44624
- components: { NcTextField: vue.NcTextField, NcCheckboxRadioSwitch: vue.NcCheckboxRadioSwitch, CnRegisterSchemaSelect: __sfc_main$92, CnFieldPicker: __sfc_main$94 },
44901
+ components: { NcTextField: vue.NcTextField, NcCheckboxRadioSwitch: vue.NcCheckboxRadioSwitch, NcSelect: vue.NcSelect, CnRegisterSchemaSelect: __sfc_main$92, CnFieldPicker: __sfc_main$94 },
44625
44902
 
44626
44903
  props: {
44627
44904
  /**
@@ -44671,11 +44948,12 @@ var script$8R = {
44671
44948
  zoom: Number.isFinite(initial.zoom) ? initial.zoom : 7,
44672
44949
  height: initial.height || '400px',
44673
44950
  popupField: initial.popupField ?? '',
44951
+ geoProperty: initial.markers?.geoProperty ?? '',
44674
44952
  clustering: initial.clustering === true,
44675
44953
  autoFit: initial.autoFit !== false,
44676
44954
  centerMarker: initial.markers?.centerMarker === true,
44677
- // Preserved verbatim: the form does not expose a basemap picker, and dropping
44678
- // it on save would turn the user's map into a grey box.
44955
+ // Preserved verbatim unless a preset is chosen: dropping it on save would
44956
+ // turn the user's map into a grey box, and a custom base map has no preset.
44679
44957
  basemaps: Array.isArray(initial.basemaps) && initial.basemaps.length
44680
44958
  ? initial.basemaps
44681
44959
  : DEFAULT_BASEMAPS,
@@ -44683,6 +44961,21 @@ var script$8R = {
44683
44961
  },
44684
44962
 
44685
44963
  computed: {
44964
+ /** The base map choices: the presets, plus the stored one when it is custom. */
44965
+ basemapOptions() {
44966
+ const presets = BASEMAP_PRESETS.map((preset) => ({ id: preset.id, label: preset.name }));
44967
+ if (presetOf(this.basemaps[0]) === null) {
44968
+ return [{ id: 'custom', label: this.basemaps[0]?.name || l10n.translate('nextcloud-vue', 'Custom base map') }, ...presets]
44969
+ }
44970
+ return presets
44971
+ },
44972
+
44973
+ /** The option of the first stored base map. */
44974
+ basemapOption() {
44975
+ const id = presetOf(this.basemaps[0]) ?? 'custom';
44976
+ return this.basemapOptions.find((option) => option.id === id) ?? null
44977
+ },
44978
+
44686
44979
  /** The assembled content blob from the current field values. */
44687
44980
  assembledContent() {
44688
44981
  return {
@@ -44700,6 +44993,7 @@ var script$8R = {
44700
44993
  markers: {
44701
44994
  dataSource: { register: this.source.register, schema: this.source.schema },
44702
44995
  popupField: this.popupField,
44996
+ ...(this.geoProperty ? { geoProperty: this.geoProperty } : {}),
44703
44997
  clustering: this.clustering,
44704
44998
  centerMarker: this.centerMarker,
44705
44999
  },
@@ -44733,6 +45027,20 @@ var script$8R = {
44733
45027
  if (key === 'register') {
44734
45028
  this.source.schema = '';
44735
45029
  this.popupField = '';
45030
+ this.geoProperty = '';
45031
+ }
45032
+ },
45033
+
45034
+ /**
45035
+ * Store the chosen preset as the base map. Choosing the custom entry keeps
45036
+ * the stored base maps as they are.
45037
+ *
45038
+ * @param {{id: string}|null} option The chosen option.
45039
+ */
45040
+ onBasemap(option) {
45041
+ const basemap = option && basemapFromPreset(option.id);
45042
+ if (basemap) {
45043
+ this.basemaps = [basemap];
44736
45044
  }
44737
45045
  },
44738
45046
 
@@ -44779,7 +45087,7 @@ var script$8R = {
44779
45087
 
44780
45088
  const _hoisted_1$8p = { class: "cn-map-widget-form" };
44781
45089
  const _hoisted_2$85 = {
44782
- key: 1,
45090
+ key: 2,
44783
45091
  class: "cn-map-widget-form__hint"
44784
45092
  };
44785
45093
  const _hoisted_3$7g = { class: "cn-map-widget-form__field" };
@@ -44790,6 +45098,7 @@ const _hoisted_6$5p = { class: "cn-map-widget-form__row" };
44790
45098
  function render$8P(_ctx, _cache, $props, $setup, $data, $options) {
44791
45099
  const _component_CnRegisterSchemaSelect = vue$1.resolveComponent("CnRegisterSchemaSelect");
44792
45100
  const _component_CnFieldPicker = vue$1.resolveComponent("CnFieldPicker");
45101
+ const _component_NcSelect = vue$1.resolveComponent("NcSelect");
44793
45102
  const _component_NcTextField = vue$1.resolveComponent("NcTextField");
44794
45103
  const _component_NcCheckboxRadioSwitch = vue$1.resolveComponent("NcCheckboxRadioSwitch");
44795
45104
 
@@ -44811,8 +45120,25 @@ function render$8P(_ctx, _cache, $props, $setup, $data, $options) {
44811
45120
  }, null, 8 /* PROPS */, ["value", "register", "schema", "label"]))
44812
45121
  : vue$1.createCommentVNode("v-if", true),
44813
45122
  ($data.source.register && $data.source.schema)
44814
- ? (vue$1.openBlock(), vue$1.createElementBlock("p", _hoisted_2$85, vue$1.toDisplayString($options.t('nextcloud-vue', 'Objects are plotted from their location (@self.geo). Objects without one are skipped.')), 1 /* TEXT */))
45123
+ ? (vue$1.openBlock(), vue$1.createBlock(_component_CnFieldPicker, {
45124
+ key: 1,
45125
+ value: $data.geoProperty,
45126
+ register: $data.source.register,
45127
+ schema: $data.source.schema,
45128
+ label: $options.t('nextcloud-vue', 'Location field'),
45129
+ onInput: _cache[3] || (_cache[3] = $event => ($data.geoProperty = $event))
45130
+ }, null, 8 /* PROPS */, ["value", "register", "schema", "label"]))
44815
45131
  : vue$1.createCommentVNode("v-if", true),
45132
+ ($data.source.register && $data.source.schema)
45133
+ ? (vue$1.openBlock(), vue$1.createElementBlock("p", _hoisted_2$85, vue$1.toDisplayString($options.t('nextcloud-vue', 'Objects are plotted from the location field: a point, line or area. Without one, from their location (@self.geo). Objects without a location are skipped.')), 1 /* TEXT */))
45134
+ : vue$1.createCommentVNode("v-if", true),
45135
+ vue$1.createVNode(_component_NcSelect, {
45136
+ modelValue: $options.basemapOption,
45137
+ options: $options.basemapOptions,
45138
+ inputLabel: $options.t('nextcloud-vue', 'Base map'),
45139
+ clearable: false,
45140
+ "onUpdate:modelValue": _cache[4] || (_cache[4] = $event => ($options.onBasemap($event)))
45141
+ }, null, 8 /* PROPS */, ["modelValue", "options", "inputLabel"]),
44816
45142
  vue$1.createElementVNode("label", _hoisted_3$7g, [
44817
45143
  vue$1.createElementVNode("span", _hoisted_4$6D, vue$1.toDisplayString($options.t('nextcloud-vue', 'Zoom')) + " (" + vue$1.toDisplayString($data.zoom) + ") ", 1 /* TEXT */),
44818
45144
  vue$1.createElementVNode("input", {
@@ -44822,7 +45148,7 @@ function render$8P(_ctx, _cache, $props, $setup, $data, $options) {
44822
45148
  step: "1",
44823
45149
  value: $data.zoom,
44824
45150
  class: "cn-map-widget-form__range",
44825
- onInput: _cache[3] || (_cache[3] = $event => ($options.onZoom($event.target.value)))
45151
+ onInput: _cache[5] || (_cache[5] = $event => ($options.onZoom($event.target.value)))
44826
45152
  }, null, 40 /* PROPS, NEED_HYDRATION */, _hoisted_5$5U)
44827
45153
  ]),
44828
45154
  vue$1.createVNode(_component_NcTextField, {
@@ -44830,7 +45156,7 @@ function render$8P(_ctx, _cache, $props, $setup, $data, $options) {
44830
45156
  label: $options.t('nextcloud-vue', 'Height'),
44831
45157
  labelVisible: true,
44832
45158
  placeholder: "400px",
44833
- "onUpdate:modelValue": _cache[4] || (_cache[4] = $event => ($data.height = $event))
45159
+ "onUpdate:modelValue": _cache[6] || (_cache[6] = $event => ($data.height = $event))
44834
45160
  }, null, 8 /* PROPS */, ["modelValue", "label"]),
44835
45161
  vue$1.createElementVNode("div", _hoisted_6$5p, [
44836
45162
  vue$1.createVNode(_component_NcTextField, {
@@ -44838,19 +45164,19 @@ function render$8P(_ctx, _cache, $props, $setup, $data, $options) {
44838
45164
  type: "number",
44839
45165
  label: $options.t('nextcloud-vue', 'Centre latitude'),
44840
45166
  labelVisible: true,
44841
- "onUpdate:modelValue": _cache[5] || (_cache[5] = $event => ($options.onCentre(0, $event)))
45167
+ "onUpdate:modelValue": _cache[7] || (_cache[7] = $event => ($options.onCentre(0, $event)))
44842
45168
  }, null, 8 /* PROPS */, ["modelValue", "label"]),
44843
45169
  vue$1.createVNode(_component_NcTextField, {
44844
45170
  modelValue: String($data.center[1]),
44845
45171
  type: "number",
44846
45172
  label: $options.t('nextcloud-vue', 'Centre longitude'),
44847
45173
  labelVisible: true,
44848
- "onUpdate:modelValue": _cache[6] || (_cache[6] = $event => ($options.onCentre(1, $event)))
45174
+ "onUpdate:modelValue": _cache[8] || (_cache[8] = $event => ($options.onCentre(1, $event)))
44849
45175
  }, null, 8 /* PROPS */, ["modelValue", "label"])
44850
45176
  ]),
44851
45177
  vue$1.createVNode(_component_NcCheckboxRadioSwitch, {
44852
45178
  modelValue: $data.centerMarker,
44853
- "onUpdate:modelValue": _cache[7] || (_cache[7] = $event => (($data.centerMarker) = $event)),
45179
+ "onUpdate:modelValue": _cache[9] || (_cache[9] = $event => (($data.centerMarker) = $event)),
44854
45180
  type: "switch"
44855
45181
  }, {
44856
45182
  default: vue$1.withCtx(() => [
@@ -44860,7 +45186,7 @@ function render$8P(_ctx, _cache, $props, $setup, $data, $options) {
44860
45186
  }, 8 /* PROPS */, ["modelValue"]),
44861
45187
  vue$1.createVNode(_component_NcCheckboxRadioSwitch, {
44862
45188
  modelValue: $data.autoFit,
44863
- "onUpdate:modelValue": _cache[8] || (_cache[8] = $event => (($data.autoFit) = $event)),
45189
+ "onUpdate:modelValue": _cache[10] || (_cache[10] = $event => (($data.autoFit) = $event)),
44864
45190
  type: "switch"
44865
45191
  }, {
44866
45192
  default: vue$1.withCtx(() => [
@@ -44870,7 +45196,7 @@ function render$8P(_ctx, _cache, $props, $setup, $data, $options) {
44870
45196
  }, 8 /* PROPS */, ["modelValue"]),
44871
45197
  vue$1.createVNode(_component_NcCheckboxRadioSwitch, {
44872
45198
  modelValue: $data.clustering,
44873
- "onUpdate:modelValue": _cache[9] || (_cache[9] = $event => (($data.clustering) = $event)),
45199
+ "onUpdate:modelValue": _cache[11] || (_cache[11] = $event => (($data.clustering) = $event)),
44874
45200
  type: "switch"
44875
45201
  }, {
44876
45202
  default: vue$1.withCtx(() => [
@@ -44882,7 +45208,7 @@ function render$8P(_ctx, _cache, $props, $setup, $data, $options) {
44882
45208
  }
44883
45209
 
44884
45210
  script$8R.render = render$8P;
44885
- script$8R.__scopeId = "data-v-ab71a77e";
45211
+ script$8R.__scopeId = "data-v-5ee2234a";
44886
45212
  const __sfc_main$8L = script$8R;
44887
45213
 
44888
45214
  /**
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/dist/nextcloud-vue.cjs.js.map
3
- size: 53730081 bytes
4
- sha256: fa68b264b61b2692fbe5547e27d6a290f7a8ed8506aefdfb8a98def4c44be83e
3
+ size: 53756679 bytes
4
+ sha256: 504642566e85d8556b1f782e1ff66647a0a2e0cb1b346e17a73f7a0402363aea