@citizenplane/pimp 9.3.0 → 9.4.1
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 +565 -562
- package/dist/pimp.umd.js +8 -8
- package/package.json +1 -1
- package/src/components/CpMultiselect.vue +13 -2
- package/src/stories/CpMultiselect.stories.ts +41 -43
package/package.json
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
@keydown.enter="toggleDropdown"
|
|
26
26
|
@show="handleOverlayShown"
|
|
27
27
|
@hide="handleOverlayHidden"
|
|
28
|
+
@value-change="handleValueChange"
|
|
28
29
|
@click="handleClick"
|
|
29
30
|
>
|
|
30
31
|
<template #empty>
|
|
@@ -33,10 +34,10 @@
|
|
|
33
34
|
</slot>
|
|
34
35
|
</template>
|
|
35
36
|
<template #chip="{ value, removeCallback }">
|
|
36
|
-
<slot name="
|
|
37
|
+
<slot name="tag" :option="value" :remove="removeCallback">
|
|
37
38
|
<cp-badge class="cpMultiselect__tag" is-clearable size="sm" @on-clear="removeCallback">
|
|
38
39
|
<template #leading-icon>
|
|
39
|
-
<slot name="
|
|
40
|
+
<slot name="tag-leading-icon" :option="value" />
|
|
40
41
|
</template>
|
|
41
42
|
{{ value.name }}
|
|
42
43
|
</cp-badge>
|
|
@@ -89,6 +90,7 @@ interface Emits {
|
|
|
89
90
|
(e: 'update:modelValue', value: Record<string, unknown> | Record<string, unknown>[] | null): void
|
|
90
91
|
(e: 'overlayShown'): void
|
|
91
92
|
(e: 'overlayHidden'): void
|
|
93
|
+
(e: 'searchChange', value: string | object): void
|
|
92
94
|
}
|
|
93
95
|
|
|
94
96
|
interface Props {
|
|
@@ -151,6 +153,8 @@ const passThroughConfig = computed(() => ({
|
|
|
151
153
|
|
|
152
154
|
const multiselect = ref<InstanceType<typeof AutoComplete> | null>(null)
|
|
153
155
|
|
|
156
|
+
const searchQuery = ref('')
|
|
157
|
+
|
|
154
158
|
// @ts-expect-error 'overlayVisible' does not exist on type instance of AutoComplete
|
|
155
159
|
const isDropdownOpen = computed(() => multiselect.value?.overlayVisible)
|
|
156
160
|
|
|
@@ -173,6 +177,13 @@ const handleClear = () => (selectModel.value = null)
|
|
|
173
177
|
const handleOverlayShown = () => emit('overlayShown')
|
|
174
178
|
const handleOverlayHidden = () => emit('overlayHidden')
|
|
175
179
|
|
|
180
|
+
const handleValueChange = (newValue: string | object) => {
|
|
181
|
+
if (typeof newValue !== 'string') return
|
|
182
|
+
|
|
183
|
+
searchQuery.value = newValue
|
|
184
|
+
emit('searchChange', newValue)
|
|
185
|
+
}
|
|
186
|
+
|
|
176
187
|
const getInputElement = () => {
|
|
177
188
|
if (!multiselect.value) return null
|
|
178
189
|
// @ts-expect-error '$el' does not exist on type instance of AutoComplete
|
|
@@ -4,6 +4,44 @@ import type { Meta, StoryObj } from '@storybook/vue3'
|
|
|
4
4
|
|
|
5
5
|
import CpMultiselect from '@/components/CpMultiselect.vue'
|
|
6
6
|
|
|
7
|
+
const supplierOptions = [
|
|
8
|
+
{ id: 1, name: 'MGA AIRLINES' },
|
|
9
|
+
{ id: 2, name: 'ZENITH - EUROATLANTIC AIRWAYS' },
|
|
10
|
+
{ id: 3, name: 'ZENITH - SOUTHERN AIRWAYS EXPRESS MOKULELE AIRLINES AND SURF AIR MOBILITY' },
|
|
11
|
+
{ id: 4, name: 'EDO TUNISAIR ITALY' },
|
|
12
|
+
{ id: 5, name: 'LMX SUISSE SA' },
|
|
13
|
+
{ id: 6, name: 'LMX VOYAGES SAS' },
|
|
14
|
+
{ id: 7, name: 'FLY KHIVA TRAVEL' },
|
|
15
|
+
{ id: 8, name: 'ZENITH - AIR CHATHAMS' },
|
|
16
|
+
{ id: 9, name: 'CP EMPLOYEES' },
|
|
17
|
+
{ id: 10, name: 'MONDIAL TOURISME' },
|
|
18
|
+
{ id: 11, name: 'UNITRAVEL UTAZÁSI IRODA' },
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
const airlineOptions = [
|
|
22
|
+
{ id: 1, name: 'United Airlines', iata_code: 'UA' },
|
|
23
|
+
{ id: 2, name: 'Delta Airlines', iata_code: 'DL' },
|
|
24
|
+
{ id: 3, name: 'American Airlines', iata_code: 'AA' },
|
|
25
|
+
{ id: 4, name: 'Southwest Airlines', iata_code: 'WN' },
|
|
26
|
+
{ id: 5, name: 'Alaska Airlines', iata_code: 'AS' },
|
|
27
|
+
{ id: 6, name: 'JetBlue Airways', iata_code: 'B6' },
|
|
28
|
+
{ id: 7, name: 'Spirit Airlines', iata_code: 'NK' },
|
|
29
|
+
{ id: 8, name: 'Frontier Airlines', iata_code: 'F9' },
|
|
30
|
+
{ id: 9, name: 'Hawaiian Airlines', iata_code: 'HA' },
|
|
31
|
+
{ id: 10, name: 'SkyWest Airlines', iata_code: 'OO' },
|
|
32
|
+
{ id: 11, name: 'Allegiant Air', iata_code: 'G4' },
|
|
33
|
+
{ id: 12, name: 'Atlantic Southeast Airlines', iata_code: 'EV' },
|
|
34
|
+
{ id: 13, name: 'American Eagle Airlines', iata_code: 'MQ' },
|
|
35
|
+
{ id: 14, name: 'Alaska Airlines', iata_code: 'AS' },
|
|
36
|
+
{ id: 15, name: 'Air France', iata_code: 'AF', disabled: true },
|
|
37
|
+
{ id: 16, name: 'Air Canada', iata_code: 'AC' },
|
|
38
|
+
{ id: 17, name: 'Air New Zealand', iata_code: 'NZ' },
|
|
39
|
+
{ id: 18, name: 'Air China', iata_code: 'CA' },
|
|
40
|
+
{ id: 19, name: 'Air India', iata_code: 'AI' },
|
|
41
|
+
{ id: 20, name: 'Air Berlin', iata_code: 'AB' },
|
|
42
|
+
{ id: 21, name: 'AirAsia', iata_code: 'AK' },
|
|
43
|
+
]
|
|
44
|
+
|
|
7
45
|
const meta = {
|
|
8
46
|
title: 'CpMultiSelect',
|
|
9
47
|
component: CpMultiselect,
|
|
@@ -66,19 +104,7 @@ export const Single: Story = {
|
|
|
66
104
|
args: {
|
|
67
105
|
placeholder: 'Select a supplier',
|
|
68
106
|
multiple: false,
|
|
69
|
-
options:
|
|
70
|
-
{ id: 1, name: 'MGA AIRLINES' },
|
|
71
|
-
{ id: 2, name: 'ZENITH - EUROATLANTIC AIRWAYS' },
|
|
72
|
-
{ id: 3, name: 'ZENITH - SOUTHERN AIRWAYS EXPRESS MOKULELE AIRLINES AND SURF AIR MOBILITY' },
|
|
73
|
-
{ id: 4, name: 'EDO TUNISAIR ITALY' },
|
|
74
|
-
{ id: 5, name: 'LMX SUISSE SA' },
|
|
75
|
-
{ id: 6, name: 'LMX VOYAGES SAS' },
|
|
76
|
-
{ id: 7, name: 'FLY KHIVA TRAVEL' },
|
|
77
|
-
{ id: 8, name: 'ZENITH - AIR CHATHAMS' },
|
|
78
|
-
{ id: 9, name: 'CP EMPLOYEES' },
|
|
79
|
-
{ id: 10, name: 'MONDIAL TOURISME' },
|
|
80
|
-
{ id: 11, name: 'UNITRAVEL UTAZÁSI IRODA' },
|
|
81
|
-
],
|
|
107
|
+
options: supplierOptions,
|
|
82
108
|
},
|
|
83
109
|
render: (args) => ({
|
|
84
110
|
components: { CpMultiselect },
|
|
@@ -114,12 +140,6 @@ export const Single: Story = {
|
|
|
114
140
|
<template #prefix>
|
|
115
141
|
<cp-partner-badge type="supplier" size="sm" />
|
|
116
142
|
</template>
|
|
117
|
-
<template #option="{ option }">
|
|
118
|
-
<div style="display: flex; align-items: center; gap: 8px;">
|
|
119
|
-
<cp-partner-badge type="supplier" size="xs" />
|
|
120
|
-
{{ option.name }}
|
|
121
|
-
</div>
|
|
122
|
-
</template>
|
|
123
143
|
</CpMultiselect>
|
|
124
144
|
</div>
|
|
125
145
|
`,
|
|
@@ -135,29 +155,7 @@ export const Multiple: Story = {
|
|
|
135
155
|
disabled: false,
|
|
136
156
|
multiple: true,
|
|
137
157
|
emptyMessage: 'No airlines found',
|
|
138
|
-
options:
|
|
139
|
-
{ id: 1, name: 'United Airlines', iata_code: 'UA' },
|
|
140
|
-
{ id: 2, name: 'Delta Airlines', iata_code: 'DL' },
|
|
141
|
-
{ id: 3, name: 'American Airlines', iata_code: 'AA' },
|
|
142
|
-
{ id: 4, name: 'Southwest Airlines', iata_code: 'WN' },
|
|
143
|
-
{ id: 5, name: 'Alaska Airlines', iata_code: 'AS' },
|
|
144
|
-
{ id: 6, name: 'JetBlue Airways', iata_code: 'B6' },
|
|
145
|
-
{ id: 7, name: 'Spirit Airlines', iata_code: 'NK' },
|
|
146
|
-
{ id: 8, name: 'Frontier Airlines', iata_code: 'F9' },
|
|
147
|
-
{ id: 9, name: 'Hawaiian Airlines', iata_code: 'HA' },
|
|
148
|
-
{ id: 10, name: 'SkyWest Airlines', iata_code: 'OO' },
|
|
149
|
-
{ id: 11, name: 'Allegiant Air', iata_code: 'G4' },
|
|
150
|
-
{ id: 12, name: 'Atlantic Southeast Airlines', iata_code: 'EV' },
|
|
151
|
-
{ id: 13, name: 'American Eagle Airlines', iata_code: 'MQ' },
|
|
152
|
-
{ id: 14, name: 'Alaska Airlines', iata_code: 'AS' },
|
|
153
|
-
{ id: 15, name: 'Air France', iata_code: 'AF', disabled: true },
|
|
154
|
-
{ id: 16, name: 'Air Canada', iata_code: 'AC' },
|
|
155
|
-
{ id: 17, name: 'Air New Zealand', iata_code: 'NZ' },
|
|
156
|
-
{ id: 18, name: 'Air China', iata_code: 'CA' },
|
|
157
|
-
{ id: 19, name: 'Air India', iata_code: 'AI' },
|
|
158
|
-
{ id: 20, name: 'Air Berlin', iata_code: 'AB' },
|
|
159
|
-
{ id: 21, name: 'AirAsia', iata_code: 'AK' },
|
|
160
|
-
],
|
|
158
|
+
options: airlineOptions,
|
|
161
159
|
},
|
|
162
160
|
render: (args) => ({
|
|
163
161
|
components: { CpMultiselect },
|
|
@@ -193,7 +191,7 @@ export const Multiple: Story = {
|
|
|
193
191
|
<template #prefix>
|
|
194
192
|
<cp-partner-badge type="airline" size="sm" />
|
|
195
193
|
</template>
|
|
196
|
-
<template #
|
|
194
|
+
<template #tag-leading-icon="{ option }">
|
|
197
195
|
<cp-airline-logo :iata-code="option.iata_code" size="14" />
|
|
198
196
|
</template>
|
|
199
197
|
<template #option="{ option }">
|