@datagouv/components-next 1.0.2-dev.217 → 1.0.2-dev.219
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.
- package/dist/{Datafair.client-BvMcdrbK.js → Datafair.client-BQzHk6je.js} +1 -1
- package/dist/{ImagePreview.client-Cio--Qu5.js → ImagePreview.client-Cld46eGd.js} +1 -1
- package/dist/{JsonPreview.client-BlV_YzS0.js → JsonPreview.client-BXURFXgZ.js} +2 -2
- package/dist/{MapContainer.client-D75Y6Cgo.js → MapContainer.client-Dc4DB5l3.js} +2 -2
- package/dist/{PdfPreview.client-Bb8GFhVj.js → PdfPreview.client-llrHD630.js} +2 -2
- package/dist/{Pmtiles.client-Dh0kfu2W.js → Pmtiles.client-DFP8oK6A.js} +1 -1
- package/dist/{PreviewWrapper.vue_vue_type_script_setup_true_lang-DtHTULUf.js → PreviewWrapper.vue_vue_type_script_setup_true_lang-5yjTI07B.js} +1 -1
- package/dist/{XmlPreview.client-DVI6hHVe.js → XmlPreview.client-C3OEOuUI.js} +3 -3
- package/dist/components-next.js +113 -112
- package/dist/{index-CaaH94Ot.js → index-5j8dwm1I.js} +1 -1
- package/dist/{leaflet-src-CCCMNTu8.js → leaflet-src-CtezwTk4.js} +1 -1
- package/dist/{main-hDFmYneb.js → main-HU94LBny.js} +1344 -1327
- package/dist/{vue3-xml-viewer.common-BdDsD8kK.js → vue3-xml-viewer.common-C1QomD0e.js} +1 -1
- package/package.json +1 -1
- package/src/components/TabularExplorer/TabularCellPopover.vue +4 -30
- package/src/functions/tabular.ts +33 -0
package/package.json
CHANGED
|
@@ -80,7 +80,7 @@ import {
|
|
|
80
80
|
} from '@remixicon/vue'
|
|
81
81
|
import { toast } from 'vue-sonner'
|
|
82
82
|
import { useTranslation } from '../../composables/useTranslation'
|
|
83
|
-
import {
|
|
83
|
+
import { buildCellValueFilter, buildTypeConfig } from '../../functions/tabular'
|
|
84
84
|
import ClientOnly from '../ClientOnly.vue'
|
|
85
85
|
import type { ColumnType, ColumnFilters } from './types'
|
|
86
86
|
|
|
@@ -128,36 +128,10 @@ function close() {
|
|
|
128
128
|
|
|
129
129
|
function filterByValue() {
|
|
130
130
|
if (!cell.value) return
|
|
131
|
-
const val = String(cell.value.value ?? '')
|
|
132
131
|
const col = cell.value.column
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
if (cell.value.columnType === 'date') {
|
|
137
|
-
const day = toIsoDay(cell.value.value)
|
|
138
|
-
if (day) {
|
|
139
|
-
filters.value = { ...filters.value, [col]: { ...existing, date: { operator: 'is', start: day } } }
|
|
140
|
-
}
|
|
141
|
-
// An empty cell has no day to select: filtering on the missing values is
|
|
142
|
-
// what "this value" means there, and the panel shows it as such.
|
|
143
|
-
else if (cell.value.value == null || cell.value.value === '') {
|
|
144
|
-
filters.value = { ...filters.value, [col]: { ...existing, null: 'only' } }
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
else if (cell.value.columnType === 'categorical' || cell.value.columnType === 'text' || cell.value.columnType === 'year') {
|
|
148
|
-
const current = existing.in ?? []
|
|
149
|
-
if (!current.includes(val)) {
|
|
150
|
-
filters.value = { ...filters.value, [col]: { ...existing, in: [...current, val] } }
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
else if (cell.value.columnType === 'number') {
|
|
154
|
-
const num = Number(cell.value.value)
|
|
155
|
-
if (Number.isFinite(num)) {
|
|
156
|
-
filters.value = { ...filters.value, [col]: { ...existing, min: num, max: num } }
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
else if (cell.value.columnType === 'boolean') {
|
|
160
|
-
filters.value = { ...filters.value, [col]: { ...existing, exact: val } }
|
|
132
|
+
filters.value = {
|
|
133
|
+
...filters.value,
|
|
134
|
+
[col]: buildCellValueFilter(cell.value.columnType, cell.value.value, filters.value[col] ?? {}),
|
|
161
135
|
}
|
|
162
136
|
close()
|
|
163
137
|
}
|
package/src/functions/tabular.ts
CHANGED
|
@@ -93,6 +93,39 @@ export function buildDateFilterParams(column: string, filter: DateFilter): Recor
|
|
|
93
93
|
return params
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
/**
|
|
97
|
+
* The filter "filter by this value" sets on a column for the cell that was
|
|
98
|
+
* clicked, merged into the filters already set on that column.
|
|
99
|
+
*
|
|
100
|
+
* An empty cell holds no value to match on: whatever the column type, filtering
|
|
101
|
+
* on the missing values is what "this value" means there — and it is the filter
|
|
102
|
+
* the column panel offers for them.
|
|
103
|
+
*/
|
|
104
|
+
export function buildCellValueFilter(columnType: ColumnType, value: unknown, existing: ColumnFilters): ColumnFilters {
|
|
105
|
+
if (value == null || value === '') return { ...existing, null: 'only' }
|
|
106
|
+
switch (columnType) {
|
|
107
|
+
// A date goes through the same `date` filter the column panel writes, so the
|
|
108
|
+
// calendar opens on the day that was clicked instead of on an empty month.
|
|
109
|
+
case 'date': {
|
|
110
|
+
const day = toIsoDay(value)
|
|
111
|
+
return day ? { ...existing, date: { operator: 'is', start: day } } : existing
|
|
112
|
+
}
|
|
113
|
+
case 'number': {
|
|
114
|
+
const num = Number(value)
|
|
115
|
+
return Number.isFinite(num) ? { ...existing, min: num, max: num } : existing
|
|
116
|
+
}
|
|
117
|
+
case 'boolean':
|
|
118
|
+
return { ...existing, exact: String(value) }
|
|
119
|
+
case 'categorical':
|
|
120
|
+
case 'text':
|
|
121
|
+
case 'year': {
|
|
122
|
+
const val = String(value)
|
|
123
|
+
const selected = existing.in ?? []
|
|
124
|
+
return selected.includes(val) ? existing : { ...existing, in: [...selected, val] }
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
96
129
|
export type TypeDisplay = {
|
|
97
130
|
icon: Component
|
|
98
131
|
label: string
|