@citizenplane/pimp 9.13.5 → 9.13.7
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/pimp.es.js +2639 -2619
- package/dist/pimp.umd.js +25 -25
- package/package.json +1 -1
- package/src/components/CpTable.vue +27 -20
- package/src/components/icons/IconRoundTripNone.vue +10 -0
- package/src/constants/CpCustomIcons.ts +2 -0
- package/src/stories/CpTable.stories.ts +5 -50
package/package.json
CHANGED
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
</template>
|
|
125
125
|
|
|
126
126
|
<script setup lang="ts">
|
|
127
|
-
import { ref, computed, useId } from 'vue'
|
|
127
|
+
import { ref, computed, useId, watch } from 'vue'
|
|
128
128
|
|
|
129
129
|
import { CpTableColumnObject } from '@/constants/CpTableColumn'
|
|
130
130
|
|
|
@@ -136,9 +136,9 @@ import { camelize, decamelize } from '@/helpers/string'
|
|
|
136
136
|
import { PAGINATION_FORMATS, RESERVED_KEYS, VISIBLE_ROWS_MAX } from '@/constants'
|
|
137
137
|
|
|
138
138
|
interface Emits {
|
|
139
|
-
(
|
|
140
|
-
(
|
|
141
|
-
(
|
|
139
|
+
(evt: 'onRowClick', data: Record<string, unknown>): void
|
|
140
|
+
(evt: 'onNextClick' | 'onPreviousClick'): void
|
|
141
|
+
(evt: 'onColumnsChanged', columns: CpTableColumnObject[]): void
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
interface PaginationServer {
|
|
@@ -235,35 +235,42 @@ const containerDOMElement = computed(() => cpTableContainer.value)
|
|
|
235
235
|
const mainClasses = computed(() => ({ 'cpTable--isLoading': props.isLoading }))
|
|
236
236
|
const containerClasses = computed(() => ({ 'cpTable__container--hasPagination': hasPagination.value }))
|
|
237
237
|
|
|
238
|
+
const formatColumns = (column: CpTableColumnObject | string) => {
|
|
239
|
+
if (typeof column === 'string') {
|
|
240
|
+
return {
|
|
241
|
+
id: camelize(column),
|
|
242
|
+
name: decamelize(column),
|
|
243
|
+
isHidden: false,
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return {
|
|
248
|
+
...column,
|
|
249
|
+
id: column.id || camelize(column.name),
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
238
253
|
const normalizedColumns = computed<CpTableColumnObject[]>(() => {
|
|
239
254
|
if (!props.columns) return []
|
|
240
255
|
|
|
241
256
|
const columns = props.columns.length ? [...props.columns] : [...columnsFromRows.value]
|
|
242
257
|
|
|
243
|
-
return columns.map(
|
|
244
|
-
if (typeof column === 'string') {
|
|
245
|
-
return {
|
|
246
|
-
id: camelize(column),
|
|
247
|
-
name: decamelize(column),
|
|
248
|
-
isHidden: false,
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
return {
|
|
253
|
-
...column,
|
|
254
|
-
id: column.id || camelize(column.name),
|
|
255
|
-
}
|
|
256
|
-
})
|
|
258
|
+
return columns.map(formatColumns)
|
|
257
259
|
})
|
|
258
260
|
|
|
259
|
-
const visibleColumns = computed(() => normalizedColumns.value.filter(({ id }) => columnsModel.value.includes(id)))
|
|
260
|
-
|
|
261
261
|
const getVisibleColumnsIds = () => {
|
|
262
262
|
return normalizedColumns.value.filter(({ isHidden, isProtected }) => !isHidden || isProtected).map(({ id }) => id)
|
|
263
263
|
}
|
|
264
264
|
|
|
265
265
|
const columnsModel = ref<string[]>(getVisibleColumnsIds())
|
|
266
266
|
|
|
267
|
+
watch(columnsModel, (newColumnsModel) => {
|
|
268
|
+
const newColumns = normalizedColumns.value.map((col) => ({ ...col, isHidden: !newColumnsModel.includes(col.id) }))
|
|
269
|
+
emit('onColumnsChanged', newColumns)
|
|
270
|
+
})
|
|
271
|
+
|
|
272
|
+
const visibleColumns = computed(() => normalizedColumns.value.filter(({ id }) => columnsModel.value.includes(id)))
|
|
273
|
+
|
|
267
274
|
const numberOfColumns = computed(() => visibleColumns.value.length)
|
|
268
275
|
|
|
269
276
|
const hasGroupBy = computed(() => {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg fill="currentColor" height="24" opacity="0.4" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<path
|
|
4
|
+
d="M7.03016 12.6087C7.03016 12.487 6.96886 12.3043 6.84616 12.1826C6.62796 11.9662 6.31296 11.9421 6.07326 12.1105L5.98726 12.1826L3.18376 15.1044C2.96296 15.3235 2.94086 15.6412 3.11756 15.8357L3.18376 15.8957L5.98726 18.818C6.10996 18.9391 6.23266 19 6.41666 19C6.74796 19 6.97986 18.8028 7.02296 18.4971L7.03016 18.3913V16.399L15.0927 16.4C15.5551 16.4 15.9367 16.0567 15.9927 15.6129L15.9998 15.5C15.9998 15.0412 15.6537 14.6625 15.2065 14.607L15.0927 14.6L7.03016 14.599V12.6087Z"
|
|
5
|
+
/>
|
|
6
|
+
<path
|
|
7
|
+
d="M16.9698 5.60869C16.9698 5.48695 17.0311 5.30435 17.1538 5.18262C17.372 4.96619 17.687 4.94213 17.9267 5.11046L18.0127 5.18262L20.8162 8.10436C21.037 8.32349 21.0591 8.64122 20.8824 8.8357L20.8162 8.89566L18.0127 11.818C17.89 11.9391 17.7673 12 17.5833 12C17.252 12 17.0201 11.8028 16.977 11.4971L16.9698 11.3913V9.39901L8.90728 9.40001C8.44487 9.40001 8.06328 9.05667 8.00731 8.6129L8.00024 8.50001C8.00024 8.04119 8.34626 7.66255 8.7935 7.60702L8.90728 7.60001L16.9698 7.59901V5.60869Z"
|
|
8
|
+
/>
|
|
9
|
+
</svg>
|
|
10
|
+
</template>
|
|
@@ -94,6 +94,7 @@ import IconReceipt from '@/components/icons/IconReceipt.vue'
|
|
|
94
94
|
import IconRecurrence from '@/components/icons/IconRecurrence.vue'
|
|
95
95
|
import IconRefund from '@/components/icons/IconRefund.vue'
|
|
96
96
|
import IconRoundTrip from '@/components/icons/IconRoundTrip.vue'
|
|
97
|
+
import IconRoundTripNone from '@/components/icons/IconRoundTripNone.vue'
|
|
97
98
|
import IconRouteNoStop from '@/components/icons/IconRouteNoStop.vue'
|
|
98
99
|
import IconRouteOneStop from '@/components/icons/IconRouteOneStop.vue'
|
|
99
100
|
import IconScheduleChange from '@/components/icons/IconScheduleChange.vue'
|
|
@@ -211,6 +212,7 @@ export const CustomCpIcons = {
|
|
|
211
212
|
recurrence: IconRecurrence,
|
|
212
213
|
refund: IconRefund,
|
|
213
214
|
'round-trip': IconRoundTrip,
|
|
215
|
+
'round-trip-none': IconRoundTripNone,
|
|
214
216
|
'route-no-stop': IconRouteNoStop,
|
|
215
217
|
'route-one-stop': IconRouteOneStop,
|
|
216
218
|
'schedule-change': IconScheduleChange,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { action } from 'storybook/actions'
|
|
1
2
|
import { ref, computed } from 'vue'
|
|
2
3
|
|
|
3
4
|
import type { Meta, StoryObj } from '@storybook/vue3'
|
|
@@ -9,56 +10,6 @@ import { PAGINATION_FORMATS } from '@/constants'
|
|
|
9
10
|
const meta = {
|
|
10
11
|
title: 'CpTable',
|
|
11
12
|
component: CpTable,
|
|
12
|
-
argTypes: {
|
|
13
|
-
caption: {
|
|
14
|
-
control: 'text',
|
|
15
|
-
description: 'Table caption for accessibility',
|
|
16
|
-
},
|
|
17
|
-
columns: {
|
|
18
|
-
control: 'object',
|
|
19
|
-
description: 'Array of column definitions',
|
|
20
|
-
},
|
|
21
|
-
data: {
|
|
22
|
-
control: 'object',
|
|
23
|
-
description: 'Array of data objects to display',
|
|
24
|
-
},
|
|
25
|
-
pagination: {
|
|
26
|
-
control: 'object',
|
|
27
|
-
description: 'Pagination configuration (boolean or object)',
|
|
28
|
-
},
|
|
29
|
-
areRowsClickable: {
|
|
30
|
-
control: 'boolean',
|
|
31
|
-
description: 'Whether rows can be clicked',
|
|
32
|
-
},
|
|
33
|
-
emptyCellPlaceholder: {
|
|
34
|
-
control: 'text',
|
|
35
|
-
description: 'Placeholder text for empty cells',
|
|
36
|
-
},
|
|
37
|
-
noResultPlaceholder: {
|
|
38
|
-
control: 'text',
|
|
39
|
-
description: 'Placeholder text when no results found',
|
|
40
|
-
},
|
|
41
|
-
isLoading: {
|
|
42
|
-
control: 'boolean',
|
|
43
|
-
description: 'Whether the table is in loading state',
|
|
44
|
-
},
|
|
45
|
-
enableRowOptions: {
|
|
46
|
-
control: 'boolean',
|
|
47
|
-
description: 'Whether to show row options menu',
|
|
48
|
-
},
|
|
49
|
-
rowOptions: {
|
|
50
|
-
control: 'object',
|
|
51
|
-
description: 'Array of row options to display',
|
|
52
|
-
},
|
|
53
|
-
quickOptionsLimit: {
|
|
54
|
-
control: 'number',
|
|
55
|
-
description: 'Maximum number of quick options to display before showing the more button',
|
|
56
|
-
},
|
|
57
|
-
onRowClick: { action: 'row-clicked' },
|
|
58
|
-
onRowRightClick: { action: 'row-right-clicked' },
|
|
59
|
-
onNextClick: { action: 'next-clicked' },
|
|
60
|
-
onPreviousClick: { action: 'previous-clicked' },
|
|
61
|
-
},
|
|
62
13
|
parameters: {
|
|
63
14
|
backgrounds: {
|
|
64
15
|
default: 'dark',
|
|
@@ -96,6 +47,10 @@ export const Default: Story = {
|
|
|
96
47
|
pagination: {
|
|
97
48
|
enabled: true,
|
|
98
49
|
},
|
|
50
|
+
onOnRowClick: action('on-row-click'),
|
|
51
|
+
onOnPreviousClick: action('on-previous-click'),
|
|
52
|
+
onOnNextClick: action('on-next-click'),
|
|
53
|
+
onOnColumnsChanged: action('on-columns-changed'),
|
|
99
54
|
},
|
|
100
55
|
render: (args) => ({
|
|
101
56
|
components: { CpTable },
|