@conduction/nextcloud-vue 2.182.0 → 2.184.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 (27) hide show
  1. package/dist/esm/components/CnChartWidget/CnChartWidget.vue.js +1 -1
  2. package/dist/esm/components/CnChartWidget/CnChartWidget2.vue.js +21 -0
  3. package/dist/esm/components/CnChartWidget/CnChartWidget2.vue.js.map +1 -1
  4. package/dist/esm/components/CnChartWidget/CnChartWidget3.vue.js.map +1 -1
  5. package/dist/esm/components/CnMapWidget/CnMapWidget.vue.js +1 -1
  6. package/dist/esm/components/CnMapWidget/CnMapWidget2.vue.js +36 -7
  7. package/dist/esm/components/CnMapWidget/CnMapWidget2.vue.js.map +1 -1
  8. package/dist/esm/components/CnMapWidget/CnMapWidget3.vue.js.map +1 -1
  9. package/dist/esm/components/CnMapWidget/spatialFilter.js +136 -0
  10. package/dist/esm/components/CnMapWidget/spatialFilter.js.map +1 -0
  11. package/dist/esm/components/CnStatsBlockWidget/CnStatsBlockWidget.vue.js +1 -1
  12. package/dist/esm/components/CnStatsBlockWidget/CnStatsBlockWidget2.vue.js +20 -0
  13. package/dist/esm/components/CnStatsBlockWidget/CnStatsBlockWidget2.vue.js.map +1 -1
  14. package/dist/esm/components/CnStatsBlockWidget/CnStatsBlockWidget3.vue.js.map +1 -1
  15. package/dist/esm/library-style.js +1 -1
  16. package/dist/esm/mixins/widgetData.js +69 -0
  17. package/dist/esm/mixins/widgetData.js.map +1 -0
  18. package/dist/esm/nextcloud-vue.css +112 -112
  19. package/dist/nextcloud-vue.cjs.js +275 -10
  20. package/dist/nextcloud-vue.cjs.js.map +2 -2
  21. package/dist/nextcloud-vue.css +112 -112
  22. package/package.json +1 -1
  23. package/src/components/CnChartWidget/CnChartWidget.vue +21 -0
  24. package/src/components/CnMapWidget/CnMapWidget.vue +41 -7
  25. package/src/components/CnMapWidget/spatialFilter.js +132 -0
  26. package/src/components/CnStatsBlockWidget/CnStatsBlockWidget.vue +20 -0
  27. package/src/mixins/widgetData.js +66 -0
@@ -19700,6 +19700,73 @@ function useEndpointSource(source, options) {
19700
19700
  return { data, body, loading, error, refused, refusal, truncated, blocked, awaitingRequest, request, refetch }
19701
19701
  }
19702
19702
 
19703
+ /*
19704
+ * SPDX-FileCopyrightText: 2026 Conduction B.V.
19705
+ * SPDX-License-Identifier: EUPL-1.2
19706
+ */
19707
+
19708
+ /**
19709
+ * widgetData — a self-fetching widget tells its host what it shows.
19710
+ *
19711
+ * A widget that fetches its own data (CnChartWidget, CnStatsBlockWidget)
19712
+ * keeps that data to itself, so a host that derives values from it (a
19713
+ * dashboard's calculated fields, an export) has nothing to read. A widget
19714
+ * using this mixin defines a `widgetData` computed returning a plain,
19715
+ * serialisable summary of what it shows, or null while there is nothing yet;
19716
+ * the mixin emits `data` with that summary whenever it changes, including the
19717
+ * first time it is known.
19718
+ *
19719
+ * @spec openspec/changes/widget-data-event/specs/widget-data-event/spec.md#requirement-a-self-fetching-widget-tells-its-host-what-it-shows
19720
+ */
19721
+ var widgetData = {
19722
+ emits: ['data'],
19723
+
19724
+ watch: {
19725
+ widgetData: {
19726
+ immediate: true,
19727
+ /**
19728
+ * Emit the summary once it is known, and on every change.
19729
+ *
19730
+ * @param {object|null} summary The widget's data summary.
19731
+ * @return {void}
19732
+ */
19733
+ handler(summary) {
19734
+ if (summary !== null && summary !== undefined) {
19735
+ /**
19736
+ * What the widget shows, as a plain summary.
19737
+ *
19738
+ * @event data
19739
+ * @type {object}
19740
+ */
19741
+ this.$emit('data', summary);
19742
+ }
19743
+ },
19744
+ },
19745
+ },
19746
+ };
19747
+
19748
+ /**
19749
+ * The sum of the numbers in a chart series: a list of numbers (a pie or
19750
+ * donut) or the `data` of its first named series. Non-numbers count as 0.
19751
+ *
19752
+ * @param {Array<number|object>|undefined} series The series.
19753
+ * @return {number|null} The total, or null for no series.
19754
+ * @spec openspec/changes/widget-data-event/specs/widget-data-event/spec.md#requirement-a-self-fetching-widget-tells-its-host-what-it-shows
19755
+ */
19756
+ function seriesTotal(series) {
19757
+ if (!Array.isArray(series) || series.length === 0) {
19758
+ return null
19759
+ }
19760
+ const values = typeof series[0] === 'object' && series[0] !== null ? series[0].data : series;
19761
+ if (!Array.isArray(values)) {
19762
+ return null
19763
+ }
19764
+ return values.reduce((sum, value) => {
19765
+ const number = typeof value === 'object' && value !== null ? Number(value.y) : Number(value);
19766
+ return Number.isFinite(number) ? sum + number : sum
19767
+ }, 0)
19768
+ }
19769
+
19703
19770
  /**
19704
19771
  * SPDX-FileCopyrightText: 2026 Conduction B.V.
19705
19772
  * SPDX-License-Identifier: EUPL-1.2
@@ -26675,6 +26742,8 @@ var script$9b = {
26675
26742
 
26676
26743
  components: { CnEndpointNotice: __sfc_main$96, NcNoteCard: vue.NcNoteCard },
26677
26744
 
26745
+ mixins: [widgetData],
26746
+
26678
26747
  inject: {
26679
26748
  /**
26680
26749
  * Reactive date-range provided by an ancestor `CnDashboardPage`.
@@ -27424,6 +27493,24 @@ var script$9b = {
27424
27493
  return fromDs !== undefined ? fromDs : this.series
27425
27494
  },
27426
27495
 
27496
+ /**
27497
+ * What the chart shows, for the `data` event: its series, categories,
27498
+ * labels and the total of its first series; null until it has a series.
27499
+ *
27500
+ * @return {{series: Array, categories: Array, labels: Array, total: number|null}|null}
27501
+ * @spec openspec/changes/widget-data-event/specs/widget-data-event/spec.md#requirement-a-self-fetching-widget-tells-its-host-what-it-shows
27502
+ */
27503
+ widgetData() {
27504
+ const series = this.resolvedSeries;
27505
+ if (!Array.isArray(series) || series.length === 0) {
27506
+ return null
27507
+ }
27508
+ const categories = Array.isArray(this.resolvedCategories) ? this.resolvedCategories : [];
27509
+ const rest = this.aggregateData || this.bucketData || this.groupByData;
27510
+ const labels = Array.isArray(rest?.labels) ? rest.labels : (Array.isArray(this.labels) ? this.labels : categories);
27511
+ return { series, categories, labels, total: seriesTotal(series) }
27512
+ },
27513
+
27427
27514
  resolvedCategories() {
27428
27515
  if (this.cellData) {
27429
27516
  return this.cellData.categories
@@ -29488,7 +29575,7 @@ function render$99(_ctx, _cache, $props, $setup, $data, $options) {
29488
29575
  }
29489
29576
 
29490
29577
  script$9b.render = render$99;
29491
- script$9b.__scopeId = "data-v-1fd46864";
29578
+ script$9b.__scopeId = "data-v-03a0a5bc";
29492
29579
  const __sfc_main$95 = script$9b;
29493
29580
 
29494
29581
  /**
@@ -42816,6 +42903,137 @@ function hasImagePosition(row, xField, yField) {
42816
42903
  return !!row && Number.isFinite(row[xField]) && Number.isFinite(row[yField])
42817
42904
  }
42818
42905
 
42906
+ /**
42907
+ * SPDX-FileCopyrightText: 2026 Conduction B.V. <info@conduction.nl>
42908
+ * SPDX-License-Identifier: EUPL-1.2
42909
+ *
42910
+ * Spatial filters and detail links for a map that plots OpenRegister objects.
42911
+ *
42912
+ * `markers.dataSource.spatialFilter` narrows the objects to an area, through
42913
+ * OpenRegister's geo filters:
42914
+ * - `{ bbox: [west, south, east, north] }` → `GET ?geo.bbox=w,s,e,n`
42915
+ * - `{ near: [lon, lat], radius: meters }` → `GET ?geo.near=lon,lat&geo.radius=m`
42916
+ * - `{ within: <GeoJSON Polygon|MultiPolygon> }` → `POST …/geo-search`
42917
+ * The map's `markers.geoProperty`, when set, is sent as `geo.property` so the
42918
+ * filter reads the same property the map draws.
42919
+ *
42920
+ * `markers.detailLink` is the address a clicked feature opens in a new tab: a
42921
+ * template whose `{id}`, `{register}`, `{schema}` and `{<property>}` tokens are
42922
+ * filled from the object. Without a template, a `url` the object carries (the
42923
+ * address OpenRegister's deep-link registry stamps) is opened instead. An
42924
+ * app-absolute path gets the instance's webroot.
42925
+ */
42926
+
42927
+
42928
+ const POLYGON_TYPES = ['Polygon', 'MultiPolygon'];
42929
+
42930
+ /**
42931
+ * Whether every entry is a finite number and there are `length` of them.
42932
+ *
42933
+ * @param {unknown} list The value.
42934
+ * @param {number} length The expected length.
42935
+ * @return {boolean}
42936
+ */
42937
+ function isNumberTuple(list, length) {
42938
+ return Array.isArray(list) && list.length === length && list.every((n) => Number.isFinite(Number(n)) && n !== '' && n !== null)
42939
+ }
42940
+
42941
+ /**
42942
+ * The OpenRegister request a spatial filter makes, or null when there is no
42943
+ * usable filter. A malformed filter is ignored rather than sent, so a typo in
42944
+ * a widget's config never empties the map with a 422.
42945
+ *
42946
+ * @param {object|null|undefined} spatialFilter The `dataSource.spatialFilter` block.
42947
+ * @param {string} [geoProperty] The property the map draws, sent as `geo.property`.
42948
+ * @return {{params: object}|{body: object}|null} Query params for the listing, or a geo-search body.
42949
+ * @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
42950
+ */
42951
+ function spatialFilterRequest(spatialFilter, geoProperty) {
42952
+ if (!spatialFilter || typeof spatialFilter !== 'object') {
42953
+ return null
42954
+ }
42955
+ const property = typeof geoProperty === 'string' && geoProperty !== '' ? { 'geo.property': geoProperty } : {};
42956
+
42957
+ const within = spatialFilter.within;
42958
+ if (within && typeof within === 'object' && POLYGON_TYPES.includes(within.type) && Array.isArray(within.coordinates)) {
42959
+ const body = { geometry: { within } };
42960
+ if (property['geo.property']) {
42961
+ body.property = property['geo.property'];
42962
+ }
42963
+ return { body }
42964
+ }
42965
+ if (isNumberTuple(spatialFilter.bbox, 4)) {
42966
+ return { params: { 'geo.bbox': spatialFilter.bbox.map(Number).join(','), ...property } }
42967
+ }
42968
+ if (isNumberTuple(spatialFilter.near, 2) && Number(spatialFilter.radius) > 0) {
42969
+ return {
42970
+ params: {
42971
+ 'geo.near': spatialFilter.near.map(Number).join(','),
42972
+ 'geo.radius': String(Number(spatialFilter.radius)),
42973
+ ...property,
42974
+ },
42975
+ }
42976
+ }
42977
+ return null
42978
+ }
42979
+
42980
+ /**
42981
+ * The value a detail-link token reads from an object.
42982
+ *
42983
+ * @param {object} object The feature's properties (the OpenRegister object).
42984
+ * @param {string} token The token name.
42985
+ * @return {unknown}
42986
+ */
42987
+ function tokenValue(object, token) {
42988
+ const self = object['@self'] && typeof object['@self'] === 'object' ? object['@self'] : {};
42989
+ if (token === 'id') {
42990
+ return self.id ?? object.id ?? object.uuid
42991
+ }
42992
+ if (token === 'register' || token === 'schema') {
42993
+ return self[token] ?? object[token]
42994
+ }
42995
+ return object[token]
42996
+ }
42997
+
42998
+ /**
42999
+ * The address a clicked feature opens, or null when it has none. A template
43000
+ * with a token the object cannot fill gives null, so a click never opens a
43001
+ * half-built address.
43002
+ *
43003
+ * @param {object|null} feature The clicked GeoJSON feature.
43004
+ * @param {string} [template] The `markers.detailLink` template.
43005
+ * @return {string|null} A safe href, or null.
43006
+ * @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
43007
+ */
43008
+ function featureDetailUrl(feature, template) {
43009
+ const object = feature && feature.properties && typeof feature.properties === 'object' ? feature.properties : null;
43010
+ if (object === null) {
43011
+ return null
43012
+ }
43013
+ let href = null;
43014
+ if (typeof template === 'string' && template !== '') {
43015
+ let missing = false;
43016
+ href = template.replace(/\{([\w@.-]+)\}/g, (_match, token) => {
43017
+ const value = tokenValue(object, token);
43018
+ if (value === undefined || value === null || value === '' || typeof value === 'object') {
43019
+ missing = true;
43020
+ return ''
43021
+ }
43022
+ return encodeURIComponent(String(value))
43023
+ });
43024
+ if (missing) {
43025
+ return null
43026
+ }
43027
+ } else if (typeof object.url === 'string' && object.url !== '') {
43028
+ href = object.url;
43029
+ }
43030
+ if (href === null) {
43031
+ return null
43032
+ }
43033
+ const safe = safeHref(href);
43034
+ return safe === '#' ? null : prefixUrl(safe)
43035
+ }
43036
+
42819
43037
  const ALLOWED_LAYER_TYPES = ['tile', 'wms', 'wfs', 'geojson', 'image'];
42820
43038
 
42821
43039
  // Raw input on the map container, which is what tells a user's pan or zoom from
@@ -43004,14 +43222,16 @@ var script$8S = {
43004
43222
 
43005
43223
  /**
43006
43224
  * Marker config. `{ features?, dataSource?, geoProperty?, latField?, lngField?, xField?, yField?,
43007
- * popupField?, clustering?, iconColor?, iconUrl?, centerMarker? }`. On an image map
43225
+ * popupField?, clustering?, iconColor?, iconUrl?, centerMarker?, detailLink? }`. On an image map
43008
43226
  * (a layer of type `image`) markers read `xField` / `yField` (default `x` / `y`,
43009
43227
  * pixels from the picture's top left) instead of `latField` / `lngField`. `features[]` is inline;
43010
43228
  * `dataSource.url` is HTTP-fetched on mount; `dataSource.{register, schema}`
43011
43229
  * plots the objects of an OpenRegister register/schema via `geoProperty` (a property
43012
43230
  * holding a GeoJSON geometry of any type, or a point) when set, else `@self.geo`.
43013
43231
  * `centerMarker: true` adds an extra pin at the map's `center`, alongside any
43014
- * source markers.
43232
+ * source markers. `dataSource.spatialFilter` (`{ bbox }`, `{ near, radius }` or
43233
+ * `{ within }`) narrows a register source to an area; `detailLink` is the address
43234
+ * a clicked object opens in a new tab (see spatialFilter.js).
43015
43235
  *
43016
43236
  * @type {object|null}
43017
43237
  */
@@ -43419,14 +43639,18 @@ var script$8S = {
43419
43639
  },
43420
43640
 
43421
43641
  /**
43422
- * The data-source filter with its tokens resolved, serialised so a new
43423
- * record re-reads the markers.
43642
+ * The data-source filter with its tokens resolved, and the spatial
43643
+ * filter, serialised so a new record or a new area re-reads the markers.
43424
43644
  *
43425
43645
  * @return {string}
43646
+ * @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
43426
43647
  */
43427
43648
  filterKey() {
43428
43649
  const ds = this.cfg.markers && this.cfg.markers.dataSource;
43429
- return ds && ds.filter ? JSON.stringify(this.sourceFilter(ds)) : ''
43650
+ if (!ds || (!ds.filter && !ds.spatialFilter)) {
43651
+ return ''
43652
+ }
43653
+ return JSON.stringify([ds.filter ? this.sourceFilter(ds) : null, ds.spatialFilter || null])
43430
43654
  },
43431
43655
 
43432
43656
  unplottedLabel() {
@@ -43969,6 +44193,7 @@ var script$8S = {
43969
44193
  * @type {{feature: object, latlng: object}}
43970
44194
  */
43971
44195
  this.$emit('marker-click', { feature, latlng: e.latlng });
44196
+ this.openFeatureDetail(feature);
43972
44197
  });
43973
44198
  },
43974
44199
  });
@@ -44466,8 +44691,11 @@ var script$8S = {
44466
44691
  * skipped rather than dropped at (0, 0) — an invisible wrong marker is worse
44467
44692
  * than an absent one.
44468
44693
  *
44469
- * @param {{register: string, schema: string, limit?: number}} ds The data source.
44694
+ * A `spatialFilter` narrows the objects to an area (see spatialFilter.js).
44695
+ *
44696
+ * @param {{register: string, schema: string, limit?: number, spatialFilter?: object}} ds The data source.
44470
44697
  * @return {Promise<Array<object>>} GeoJSON Feature array.
44698
+ * @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
44471
44699
  */
44472
44700
  async fetchRegisterFeatures(ds) {
44473
44701
  try {
@@ -44479,7 +44707,11 @@ var script$8S = {
44479
44707
  '/apps/openregister/api/objects/{register}/{schema}',
44480
44708
  { register: ds.register, schema: ds.schema },
44481
44709
  );
44482
- const res = await axios.get(url, { params: { ...this.sourceFilter(ds), _limit: ds.limit || 500 } });
44710
+ const params = { ...this.sourceFilter(ds), _limit: ds.limit || 500 };
44711
+ const spatial = spatialFilterRequest(ds.spatialFilter, this.cfg.markers && this.cfg.markers.geoProperty);
44712
+ const res = spatial && spatial.body
44713
+ ? await axios.post(url + '/geo-search', spatial.body, { params })
44714
+ : await axios.get(url, { params: { ...params, ...(spatial ? spatial.params : {}) } });
44483
44715
  const rows = (res && res.data && res.data.results) || [];
44484
44716
 
44485
44717
  const latField = this.cfg.markers && this.cfg.markers.latField;
@@ -44499,6 +44731,20 @@ var script$8S = {
44499
44731
  }
44500
44732
  },
44501
44733
 
44734
+ /**
44735
+ * Open a clicked object's detail address in a new tab, when it has one.
44736
+ *
44737
+ * @param {object} feature The clicked GeoJSON feature.
44738
+ * @return {void}
44739
+ * @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
44740
+ */
44741
+ openFeatureDetail(feature) {
44742
+ const href = featureDetailUrl(feature, this.cfg.markers && this.cfg.markers.detailLink);
44743
+ if (href !== null) {
44744
+ window.open(href, '_blank', 'noopener,noreferrer');
44745
+ }
44746
+ },
44747
+
44502
44748
  /**
44503
44749
  * Normalise a fetched payload into a GeoJSON Feature array.
44504
44750
  * Accepts FeatureCollection, raw Feature[], or flat rows that
@@ -44625,7 +44871,7 @@ function render$8Q(_ctx, _cache, $props, $setup, $data, $options) {
44625
44871
  }
44626
44872
 
44627
44873
  script$8S.render = render$8Q;
44628
- script$8S.__scopeId = "data-v-356bff56";
44874
+ script$8S.__scopeId = "data-v-1fc9cf51";
44629
44875
  const __sfc_main$8M = script$8S;
44630
44876
 
44631
44877
  /**
@@ -189750,6 +189996,8 @@ var script$6o = {
189750
189996
 
189751
189997
  components: { CnStatsBlock: __sfc_main$6k, CnStatWidget: __sfc_main$6j },
189752
189998
 
189999
+ mixins: [widgetData],
190000
+
189753
190001
  inject: {
189754
190002
  /**
189755
190003
  * Detail-page object context provided by CnDetailPage — enables
@@ -190215,6 +190463,23 @@ var script$6o = {
190215
190463
  })))
190216
190464
  },
190217
190465
 
190466
+ /**
190467
+ * What the widget shows, for the `data` event: the count of a single
190468
+ * source, or every entry's count; null until a count is known.
190469
+ *
190470
+ * @return {{count: number}|{counts: Array<number|null>}|null}
190471
+ * @spec openspec/changes/widget-data-event/specs/widget-data-event/spec.md#requirement-a-self-fetching-widget-tells-its-host-what-it-shows
190472
+ */
190473
+ widgetData() {
190474
+ if (this.hasEntries) {
190475
+ return this.entryFetching.some(Boolean) || this.entryCounts.length === 0 ? null : { counts: [...this.entryCounts] }
190476
+ }
190477
+ if (typeof this.restCount === 'number' || this.dsData?.count !== undefined) {
190478
+ return { count: this.resolvedCount }
190479
+ }
190480
+ return null
190481
+ },
190482
+
190218
190483
  resolvedCount() {
190219
190484
  if (typeof this.restCount === 'number') {
190220
190485
  return this.restCount
@@ -190585,7 +190850,7 @@ function render$6m(_ctx, _cache, $props, $setup, $data, $options) {
190585
190850
  }
190586
190851
 
190587
190852
  script$6o.render = render$6m;
190588
- script$6o.__scopeId = "data-v-4341e971";
190853
+ script$6o.__scopeId = "data-v-23816a8e";
190589
190854
  const __sfc_main$6i = script$6o;
190590
190855
 
190591
190856
  const DEFAULT_CONTENT$p = Object.freeze({
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/dist/nextcloud-vue.cjs.js.map
3
- size: 53743152 bytes
4
- sha256: 1d542dc533f09e1585e988401d043577fcd319f05237fa857a6ca90c1a2fb424
3
+ size: 53764950 bytes
4
+ sha256: 9d79106eadd9b97d063d110f8fc759b7f4cd4087d863cd49b781631cf890a89d