picocrank 1.31.1 → 1.33.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.
- package/docs/table.md +99 -0
- package/package.json +1 -1
- package/router.js +11 -0
- package/styles/picocrank-extensions.css +65 -0
- package/vue/components/Calendar.vue +41 -63
- package/vue/components/LoadingArea.spec.js +72 -0
- package/vue/components/LoadingArea.vue +176 -0
- package/vue/components/Table.spec.js +715 -0
- package/vue/components/Table.vue +974 -16
- package/vue/components/TableColumnFilterPopover.vue +56 -8
- package/vue/components/TableRowContextMenu.vue +267 -0
- package/vue/composables/tableFilters.js +6 -1
- package/vue/data/navSectionHubs.js +5 -0
- package/vue/examples/LoadingAreaExample.vue +175 -0
- package/vue/examples/TableExample.vue +156 -4
|
@@ -2,9 +2,53 @@
|
|
|
2
2
|
<Section
|
|
3
3
|
:title="tableSectionTitle"
|
|
4
4
|
:icon="TableIcon"
|
|
5
|
-
subtitle="Sortable columns, pagination, and column filters. Right-click or long-press a column header to filter."
|
|
5
|
+
subtitle="Sortable columns, pagination, and column filters. Right-click or long-press a column header to filter. Enable “Row context menu” to right-click rows."
|
|
6
6
|
:padding="false"
|
|
7
7
|
>
|
|
8
|
+
<template v-if="multiSelectEnabled" #toolbar>
|
|
9
|
+
<span v-if="selectedKeys.length" class="subtle selection-count">
|
|
10
|
+
{{ selectedKeys.length }} selected
|
|
11
|
+
</span>
|
|
12
|
+
<button
|
|
13
|
+
type="button"
|
|
14
|
+
class="inline-icon neutral"
|
|
15
|
+
:disabled="!selectedKeys.length"
|
|
16
|
+
@click="bulkExportSelected"
|
|
17
|
+
>
|
|
18
|
+
<HugeiconsIcon
|
|
19
|
+
:icon="Download01Icon"
|
|
20
|
+
width="1em"
|
|
21
|
+
height="1em"
|
|
22
|
+
:strokeWidth="iconStrokeWidth"
|
|
23
|
+
aria-hidden="true"
|
|
24
|
+
/>
|
|
25
|
+
<span>Export</span>
|
|
26
|
+
</button>
|
|
27
|
+
<button
|
|
28
|
+
type="button"
|
|
29
|
+
class="inline-icon bad"
|
|
30
|
+
:disabled="!selectedKeys.length"
|
|
31
|
+
@click="bulkDeleteSelected"
|
|
32
|
+
>
|
|
33
|
+
<HugeiconsIcon
|
|
34
|
+
:icon="Delete02Icon"
|
|
35
|
+
width="1em"
|
|
36
|
+
height="1em"
|
|
37
|
+
:strokeWidth="iconStrokeWidth"
|
|
38
|
+
aria-hidden="true"
|
|
39
|
+
/>
|
|
40
|
+
<span>Delete</span>
|
|
41
|
+
</button>
|
|
42
|
+
<button
|
|
43
|
+
type="button"
|
|
44
|
+
class="neutral"
|
|
45
|
+
:disabled="!selectedKeys.length"
|
|
46
|
+
@click="clearSelection"
|
|
47
|
+
>
|
|
48
|
+
Clear selection
|
|
49
|
+
</button>
|
|
50
|
+
</template>
|
|
51
|
+
|
|
8
52
|
<Table
|
|
9
53
|
table-id="table-example"
|
|
10
54
|
row-key="name"
|
|
@@ -14,6 +58,9 @@
|
|
|
14
58
|
:filterable="enabledFeatures.includes('filters')"
|
|
15
59
|
:column-options="enabledFeatures.includes('columnOptions')"
|
|
16
60
|
:loading="enabledFeatures.includes('loading')"
|
|
61
|
+
:selectable="multiSelectEnabled"
|
|
62
|
+
v-model:selected-keys="selectedKeys"
|
|
63
|
+
:row-context-menu="rowContextMenuEnabled ? rowContextMenuItems : null"
|
|
17
64
|
:horizontal-scroll="layout === 'scroll'"
|
|
18
65
|
:responsive-columns="layout === 'priorities'"
|
|
19
66
|
:sticky-cols="stickyCols"
|
|
@@ -127,6 +174,25 @@
|
|
|
127
174
|
<p v-else-if="enabledFeatures.includes('columnOptions')" class="event-line subtle">
|
|
128
175
|
Layout: using developer defaults (change columns, order, or filters to see a preset or “Custom” label).
|
|
129
176
|
</p>
|
|
177
|
+
|
|
178
|
+
<p v-if="multiSelectEnabled && selectedKeys.length" class="event-line">
|
|
179
|
+
<strong>Selection:</strong>
|
|
180
|
+
{{ selectedKeys.join(', ') }}
|
|
181
|
+
</p>
|
|
182
|
+
<p v-else-if="multiSelectEnabled" class="event-line subtle">
|
|
183
|
+
Selection: enable “Multi-select”, then click rows or checkboxes. Use the toolbar Export / Delete actions on the selected set.
|
|
184
|
+
</p>
|
|
185
|
+
|
|
186
|
+
<p v-if="lastContextMenuAction" class="event-line">
|
|
187
|
+
<strong>Context menu:</strong>
|
|
188
|
+
{{ lastContextMenuAction }}
|
|
189
|
+
</p>
|
|
190
|
+
<p v-else-if="rowContextMenuEnabled" class="event-line subtle">
|
|
191
|
+
Context menu: right-click a row. With multi-select, right-click inside the selection to act on all selected rows.
|
|
192
|
+
</p>
|
|
193
|
+
<p v-else-if="lastBulkAction" class="event-line subtle">
|
|
194
|
+
{{ lastBulkAction }}
|
|
195
|
+
</p>
|
|
130
196
|
</div>
|
|
131
197
|
</Section>
|
|
132
198
|
|
|
@@ -165,11 +231,13 @@
|
|
|
165
231
|
|
|
166
232
|
<script setup>
|
|
167
233
|
import { ref, computed, onMounted } from 'vue'
|
|
168
|
-
import {
|
|
234
|
+
import { HugeiconsIcon } from '@hugeicons/vue'
|
|
235
|
+
import { TableIcon, Settings01Icon, Download01Icon, Delete02Icon, ViewIcon } from '@hugeicons/core-free-icons'
|
|
169
236
|
import { getExampleTableRows } from '../data/examplePeople.js'
|
|
170
237
|
import { countActiveFilters } from '../composables/tableFilters.js'
|
|
171
238
|
|
|
172
|
-
const
|
|
239
|
+
const iconStrokeWidth = 2.5
|
|
240
|
+
const defaultFeatures = ['pagination', 'filters', 'columnOptions', 'rowClick', 'rowContextMenu']
|
|
173
241
|
|
|
174
242
|
const defaultColumnVisibility = {
|
|
175
243
|
birthYear: false,
|
|
@@ -184,9 +252,15 @@ const dataConnected = ref(true)
|
|
|
184
252
|
const data = ref([])
|
|
185
253
|
const lastRowClick = ref(null)
|
|
186
254
|
const lastQuery = ref(null)
|
|
255
|
+
const lastBulkAction = ref(null)
|
|
256
|
+
const lastContextMenuAction = ref(null)
|
|
257
|
+
const selectedKeys = ref([])
|
|
187
258
|
const tableLayoutLabel = ref('')
|
|
188
259
|
const rowDialogRef = ref(null)
|
|
189
260
|
|
|
261
|
+
const multiSelectEnabled = computed(() => enabledFeatures.value.includes('multiSelect'))
|
|
262
|
+
const rowContextMenuEnabled = computed(() => enabledFeatures.value.includes('rowContextMenu'))
|
|
263
|
+
|
|
190
264
|
const tableSectionTitle = computed(() => {
|
|
191
265
|
if (tableLayoutLabel.value) {
|
|
192
266
|
return `Table Example (${tableLayoutLabel.value})`
|
|
@@ -204,6 +278,8 @@ const featureOptions = [
|
|
|
204
278
|
{ value: 'filters', label: 'Column filters' },
|
|
205
279
|
{ value: 'columnOptions', label: 'Column options' },
|
|
206
280
|
{ value: 'rowClick', label: 'Row click' },
|
|
281
|
+
{ value: 'multiSelect', label: 'Multi-select' },
|
|
282
|
+
{ value: 'rowContextMenu', label: 'Row context menu' },
|
|
207
283
|
{ value: 'loading', label: 'Loading state' },
|
|
208
284
|
]
|
|
209
285
|
|
|
@@ -285,12 +361,56 @@ const tableListeners = computed(() => {
|
|
|
285
361
|
const listeners = {
|
|
286
362
|
onQueryChange: handleQueryChange,
|
|
287
363
|
}
|
|
288
|
-
|
|
364
|
+
// Row click opens the detail dialog; multi-select uses row clicks for selection instead.
|
|
365
|
+
if (enabledFeatures.value.includes('rowClick') && !multiSelectEnabled.value) {
|
|
289
366
|
listeners.onRowClick = handleRowClick
|
|
290
367
|
}
|
|
291
368
|
return listeners
|
|
292
369
|
})
|
|
293
370
|
|
|
371
|
+
const rowContextMenuItems = computed(() => [
|
|
372
|
+
{
|
|
373
|
+
id: 'view',
|
|
374
|
+
label: 'View details',
|
|
375
|
+
icon: ViewIcon,
|
|
376
|
+
action: ({ row, rows }) => {
|
|
377
|
+
const target = rows[0] ?? row
|
|
378
|
+
if (!target) {
|
|
379
|
+
return
|
|
380
|
+
}
|
|
381
|
+
lastContextMenuAction.value = `View “${target.name}”`
|
|
382
|
+
lastRowClick.value = {
|
|
383
|
+
row: target,
|
|
384
|
+
index: tableData.value.findIndex((item) => item.name === target.name),
|
|
385
|
+
}
|
|
386
|
+
rowDialogRef.value?.showModal()
|
|
387
|
+
},
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
id: 'export',
|
|
391
|
+
label: 'Export',
|
|
392
|
+
icon: Download01Icon,
|
|
393
|
+
action: ({ keys }) => {
|
|
394
|
+
lastContextMenuAction.value = `Exported ${keys.length} row(s): ${keys.join(', ')}`
|
|
395
|
+
lastBulkAction.value = lastContextMenuAction.value
|
|
396
|
+
},
|
|
397
|
+
},
|
|
398
|
+
{ divider: true },
|
|
399
|
+
{
|
|
400
|
+
id: 'delete',
|
|
401
|
+
label: 'Delete',
|
|
402
|
+
icon: Delete02Icon,
|
|
403
|
+
danger: true,
|
|
404
|
+
action: ({ keys }) => {
|
|
405
|
+
const removeSet = new Set(keys)
|
|
406
|
+
data.value = data.value.filter((row) => !removeSet.has(row.name))
|
|
407
|
+
selectedKeys.value = selectedKeys.value.filter((key) => !removeSet.has(key))
|
|
408
|
+
lastContextMenuAction.value = `Deleted ${keys.length} row(s): ${keys.join(', ')}`
|
|
409
|
+
lastBulkAction.value = lastContextMenuAction.value
|
|
410
|
+
},
|
|
411
|
+
},
|
|
412
|
+
])
|
|
413
|
+
|
|
294
414
|
function handleRowClick(payload) {
|
|
295
415
|
lastRowClick.value = payload
|
|
296
416
|
rowDialogRef.value?.showModal()
|
|
@@ -306,6 +426,29 @@ function handleQueryChange(query) {
|
|
|
306
426
|
lastQuery.value = query
|
|
307
427
|
}
|
|
308
428
|
|
|
429
|
+
function clearSelection() {
|
|
430
|
+
selectedKeys.value = []
|
|
431
|
+
lastBulkAction.value = 'Selection cleared.'
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
function bulkExportSelected() {
|
|
435
|
+
if (!selectedKeys.value.length) {
|
|
436
|
+
return
|
|
437
|
+
}
|
|
438
|
+
lastBulkAction.value = `Exported ${selectedKeys.value.length} row(s): ${selectedKeys.value.join(', ')}`
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
function bulkDeleteSelected() {
|
|
442
|
+
if (!selectedKeys.value.length) {
|
|
443
|
+
return
|
|
444
|
+
}
|
|
445
|
+
const removed = [...selectedKeys.value]
|
|
446
|
+
const removeSet = new Set(removed)
|
|
447
|
+
data.value = data.value.filter((row) => !removeSet.has(row.name))
|
|
448
|
+
selectedKeys.value = []
|
|
449
|
+
lastBulkAction.value = `Deleted ${removed.length} row(s): ${removed.join(', ')}`
|
|
450
|
+
}
|
|
451
|
+
|
|
309
452
|
function statusTagClass(value) {
|
|
310
453
|
if (value === 'Active') {
|
|
311
454
|
return 'good'
|
|
@@ -323,7 +466,11 @@ function resetControls() {
|
|
|
323
466
|
stickyColsOption.value = '2'
|
|
324
467
|
wideTable.value = true
|
|
325
468
|
dataConnected.value = true
|
|
469
|
+
data.value = getExampleTableRows()
|
|
326
470
|
lastRowClick.value = null
|
|
471
|
+
lastBulkAction.value = null
|
|
472
|
+
lastContextMenuAction.value = null
|
|
473
|
+
selectedKeys.value = []
|
|
327
474
|
if (rowDialogRef.value?.open) {
|
|
328
475
|
rowDialogRef.value.close()
|
|
329
476
|
}
|
|
@@ -347,6 +494,11 @@ onMounted(() => {
|
|
|
347
494
|
margin: 0.35rem 0;
|
|
348
495
|
}
|
|
349
496
|
|
|
497
|
+
.selection-count {
|
|
498
|
+
align-self: center;
|
|
499
|
+
margin-right: 0.5rem;
|
|
500
|
+
}
|
|
501
|
+
|
|
350
502
|
.row-detail-dialog .dialog-panel h3 {
|
|
351
503
|
margin: 0 0 0.5rem;
|
|
352
504
|
}
|