@citizenplane/pimp 9.2.0 → 9.4.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.
@@ -1,9 +1,47 @@
1
- import { ref, toValue } from 'vue'
1
+ import { ref, toValue, computed } from 'vue'
2
2
 
3
3
  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 },
@@ -238,3 +236,38 @@ export const Invalid: Story = {
238
236
  `,
239
237
  }),
240
238
  }
239
+
240
+ export const Highlighted: Story = {
241
+ args: {
242
+ placeholder: 'Select a supplier',
243
+ disabled: false,
244
+ options: supplierOptions,
245
+ },
246
+ render: (args) => ({
247
+ components: { CpMultiselect },
248
+ setup() {
249
+ const selectedSupplier = ref(null)
250
+ const searchQuery = ref('')
251
+ const handleSearch = (query: string) => {
252
+ searchQuery.value = query
253
+ }
254
+
255
+ const suggestions = computed(() => {
256
+ return args.options?.filter((option) => {
257
+ return option.name.toLowerCase().includes(searchQuery.value.toLowerCase())
258
+ })
259
+ })
260
+
261
+ return { args, selectedSupplier, suggestions, handleSearch }
262
+ },
263
+ template: `
264
+ <div style="padding: 20px;">
265
+ <CpMultiselect v-model="selectedSupplier" v-bind="args" :options="suggestions" @search-change="handleSearch">
266
+ <template #prefix>
267
+ <cp-partner-badge type="supplier" size="sm" />
268
+ </template>
269
+ </CpMultiselect>
270
+ </div>
271
+ `,
272
+ }),
273
+ }