@citizenplane/pimp 18.10.3 → 18.11.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.
Files changed (92) hide show
  1. package/dist/components/CpSeatMap.vue.d.ts +29 -0
  2. package/dist/components/CpSeatMap.vue.d.ts.map +1 -0
  3. package/dist/components/CpSeatMapEmergencyExitDialog.vue.d.ts +21 -0
  4. package/dist/components/CpSeatMapEmergencyExitDialog.vue.d.ts.map +1 -0
  5. package/dist/components/CpSeatMapGrid.vue.d.ts +17 -0
  6. package/dist/components/CpSeatMapGrid.vue.d.ts.map +1 -0
  7. package/dist/components/CpSeatMapPlane.vue.d.ts +24 -0
  8. package/dist/components/CpSeatMapPlane.vue.d.ts.map +1 -0
  9. package/dist/components/CpSeatMapRow.vue.d.ts +22 -0
  10. package/dist/components/CpSeatMapRow.vue.d.ts.map +1 -0
  11. package/dist/components/CpSeatMapRowFacility.vue.d.ts +16 -0
  12. package/dist/components/CpSeatMapRowFacility.vue.d.ts.map +1 -0
  13. package/dist/components/CpSeatMapSeat.vue.d.ts +21 -0
  14. package/dist/components/CpSeatMapSeat.vue.d.ts.map +1 -0
  15. package/dist/components/CpSeatMapSeatWrapper.vue.d.ts +23 -0
  16. package/dist/components/CpSeatMapSeatWrapper.vue.d.ts.map +1 -0
  17. package/dist/components/CpSeatMapZone.vue.d.ts +16 -0
  18. package/dist/components/CpSeatMapZone.vue.d.ts.map +1 -0
  19. package/dist/components/icons/IconPlaneNose.vue.d.ts +3 -0
  20. package/dist/components/icons/IconPlaneNose.vue.d.ts.map +1 -0
  21. package/dist/components/icons/IconPlaneWing.vue.d.ts +3 -0
  22. package/dist/components/icons/IconPlaneWing.vue.d.ts.map +1 -0
  23. package/dist/components/icons/IconSparkle.vue.d.ts +3 -0
  24. package/dist/components/icons/IconSparkle.vue.d.ts.map +1 -0
  25. package/dist/components/index.d.ts +14 -1
  26. package/dist/components/index.d.ts.map +1 -1
  27. package/dist/constants/seatMap/CpSeatMapConfig.d.ts +22 -0
  28. package/dist/constants/seatMap/CpSeatMapConfig.d.ts.map +1 -0
  29. package/dist/constants/seatMap/CpSeatMapSeatSelection.d.ts +12 -0
  30. package/dist/constants/seatMap/CpSeatMapSeatSelection.d.ts.map +1 -0
  31. package/dist/constants/seatMap/CpSeatMapTransitionDirections.d.ts +5 -0
  32. package/dist/constants/seatMap/CpSeatMapTransitionDirections.d.ts.map +1 -0
  33. package/dist/constants/seatMap/IataTravelerTypes.d.ts +7 -0
  34. package/dist/constants/seatMap/IataTravelerTypes.d.ts.map +1 -0
  35. package/dist/constants/seatMap/Seat.d.ts +18 -0
  36. package/dist/constants/seatMap/Seat.d.ts.map +1 -0
  37. package/dist/constants/seatMap/SeatAncillary.d.ts +9 -0
  38. package/dist/constants/seatMap/SeatAncillary.d.ts.map +1 -0
  39. package/dist/constants/seatMap/SeatCharacteristic.d.ts +7 -0
  40. package/dist/constants/seatMap/SeatCharacteristic.d.ts.map +1 -0
  41. package/dist/constants/seatMap/SeatCharacteristicCodes.d.ts +10 -0
  42. package/dist/constants/seatMap/SeatCharacteristicCodes.d.ts.map +1 -0
  43. package/dist/constants/seatMap/SeatMap.d.ts +10 -0
  44. package/dist/constants/seatMap/SeatMap.d.ts.map +1 -0
  45. package/dist/constants/seatMap/SeatMapZone.d.ts +6 -0
  46. package/dist/constants/seatMap/SeatMapZone.d.ts.map +1 -0
  47. package/dist/constants/seatMap/SeatRow.d.ts +15 -0
  48. package/dist/constants/seatMap/SeatRow.d.ts.map +1 -0
  49. package/dist/constants/seatMap/SeatRowFacilities.d.ts +10 -0
  50. package/dist/constants/seatMap/SeatRowFacilities.d.ts.map +1 -0
  51. package/dist/constants/seatMap/SeatRowFacilityFlags.d.ts +8 -0
  52. package/dist/constants/seatMap/SeatRowFacilityFlags.d.ts.map +1 -0
  53. package/dist/constants/seatMap/SeatStatuses.d.ts +8 -0
  54. package/dist/constants/seatMap/SeatStatuses.d.ts.map +1 -0
  55. package/dist/constants/seatMap/index.d.ts +16 -0
  56. package/dist/constants/seatMap/index.d.ts.map +1 -0
  57. package/dist/helpers/seatMap.d.ts +28 -0
  58. package/dist/helpers/seatMap.d.ts.map +1 -0
  59. package/dist/pimp.es.js +4263 -3756
  60. package/dist/pimp.umd.js +40 -40
  61. package/dist/style.css +1 -1
  62. package/package.json +1 -1
  63. package/src/components/CpSeatMap.vue +226 -0
  64. package/src/components/CpSeatMapEmergencyExitDialog.vue +87 -0
  65. package/src/components/CpSeatMapGrid.vue +41 -0
  66. package/src/components/CpSeatMapPlane.vue +221 -0
  67. package/src/components/CpSeatMapRow.vue +183 -0
  68. package/src/components/CpSeatMapRowFacility.vue +88 -0
  69. package/src/components/CpSeatMapSeat.vue +138 -0
  70. package/src/components/CpSeatMapSeatWrapper.vue +189 -0
  71. package/src/components/CpSeatMapZone.vue +60 -0
  72. package/src/components/icons/IconPlaneNose.vue +39 -0
  73. package/src/components/icons/IconPlaneWing.vue +11 -0
  74. package/src/components/icons/IconSparkle.vue +8 -0
  75. package/src/components/index.ts +51 -0
  76. package/src/constants/seatMap/CpSeatMapConfig.ts +47 -0
  77. package/src/constants/seatMap/CpSeatMapSeatSelection.ts +12 -0
  78. package/src/constants/seatMap/CpSeatMapTransitionDirections.ts +4 -0
  79. package/src/constants/seatMap/IataTravelerTypes.ts +6 -0
  80. package/src/constants/seatMap/Seat.ts +18 -0
  81. package/src/constants/seatMap/SeatAncillary.ts +8 -0
  82. package/src/constants/seatMap/SeatCharacteristic.ts +7 -0
  83. package/src/constants/seatMap/SeatCharacteristicCodes.ts +9 -0
  84. package/src/constants/seatMap/SeatMap.ts +10 -0
  85. package/src/constants/seatMap/SeatMapZone.ts +5 -0
  86. package/src/constants/seatMap/SeatRow.ts +15 -0
  87. package/src/constants/seatMap/SeatRowFacilities.ts +10 -0
  88. package/src/constants/seatMap/SeatRowFacilityFlags.ts +7 -0
  89. package/src/constants/seatMap/SeatStatuses.ts +7 -0
  90. package/src/constants/seatMap/index.ts +16 -0
  91. package/src/helpers/seatMap.ts +76 -0
  92. package/src/stories/CpSeatMap.stories.ts +357 -0
@@ -0,0 +1,11 @@
1
+ <template>
2
+ <svg fill="none" preserveAspectRatio="xMaxYMid meet" viewBox="0 0 180 509" xmlns="http://www.w3.org/2000/svg">
3
+ <path d="M0 87.8 L180 0 L180 490.1 L0 508.7 Z" fill="url(#paint0_linear_23056_30266)" />
4
+ <defs>
5
+ <linearGradient id="paint0_linear_23056_30266" x1="1" x2="0" y1="0.5" y2="0.5">
6
+ <stop offset="0.5" stop-color="white" />
7
+ <stop offset="1" stop-color="white" stop-opacity="0" />
8
+ </linearGradient>
9
+ </defs>
10
+ </svg>
11
+ </template>
@@ -0,0 +1,8 @@
1
+ <template>
2
+ <svg fill="none" height="13" viewBox="0 0 13 13" width="13" xmlns="http://www.w3.org/2000/svg">
3
+ <path
4
+ d="M5.64966 0.826416C5.81077 0.391202 6.42605 0.3912 6.58716 0.826416L7.65063 3.70044C7.80258 4.11068 8.12614 4.43424 8.53638 4.58618L11.4104 5.64966C11.8456 5.81077 11.8456 6.42605 11.4104 6.58716L8.53638 7.65063C8.12614 7.80258 7.80258 8.12614 7.65063 8.53638L6.58716 11.4104C6.42605 11.8456 5.81077 11.8456 5.64966 11.4104L4.58618 8.53638C4.43424 8.12614 4.11068 7.80258 3.70044 7.65063L0.826416 6.58716C0.391202 6.42605 0.3912 5.81077 0.826416 5.64966L3.70044 4.58618C4.05951 4.45319 4.35244 4.18883 4.52173 3.84985L4.58618 3.70044L5.64966 0.826416Z"
5
+ stroke="#D1D3E6"
6
+ />
7
+ </svg>
8
+ </template>
@@ -43,6 +43,15 @@ import CpMultiselect from './CpMultiselect.vue'
43
43
  import CpRadio from './CpRadio.vue'
44
44
  import CpRadioGroup from './CpRadioGroup.vue'
45
45
  import CpRadioNew from './CpRadioNew.vue'
46
+ import CpSeatMap from './CpSeatMap.vue'
47
+ import CpSeatMapEmergencyExitDialog from './CpSeatMapEmergencyExitDialog.vue'
48
+ import CpSeatMapGrid from './CpSeatMapGrid.vue'
49
+ import CpSeatMapPlane from './CpSeatMapPlane.vue'
50
+ import CpSeatMapRow from './CpSeatMapRow.vue'
51
+ import CpSeatMapRowFacility from './CpSeatMapRowFacility.vue'
52
+ import CpSeatMapSeat from './CpSeatMapSeat.vue'
53
+ import CpSeatMapSeatWrapper from './CpSeatMapSeatWrapper.vue'
54
+ import CpSeatMapZone from './CpSeatMapZone.vue'
46
55
  import CpSelect from './CpSelect.vue'
47
56
  import CpSelectableButton from './CpSelectableButton.vue'
48
57
  import CpSelectMenu from './CpSelectMenu.vue'
@@ -132,6 +141,15 @@ const Components = {
132
141
  CpTransitionSlide,
133
142
  CpTransitionTabContent,
134
143
  CpTrip,
144
+ CpSeatMap,
145
+ CpSeatMapEmergencyExitDialog,
146
+ CpSeatMapGrid,
147
+ CpSeatMapPlane,
148
+ CpSeatMapRow,
149
+ CpSeatMapRowFacility,
150
+ CpSeatMapSeat,
151
+ CpSeatMapSeatWrapper,
152
+ CpSeatMapZone,
135
153
  }
136
154
 
137
155
  const Pimp: Plugin = {
@@ -152,6 +170,30 @@ const Pimp: Plugin = {
152
170
  },
153
171
  }
154
172
 
173
+ export type {
174
+ CpSeatMapConfig,
175
+ CpSeatMapSeatSelection,
176
+ Seat,
177
+ SeatAncillary,
178
+ SeatCharacteristic,
179
+ SeatMap,
180
+ SeatMapZone,
181
+ SeatRow,
182
+ SeatRowFacilityFlags,
183
+ } from '@/constants/seatMap'
184
+ export type { CpSeatMapSeatSelection as CpSeatMapSelection } from '@/constants/seatMap/CpSeatMapSeatSelection'
185
+
186
+ export {
187
+ CpSeatMapTransitionDirections,
188
+ DEFAULT_CP_SEAT_MAP_CONFIG,
189
+ IataTravelerTypes,
190
+ SeatCharacteristicCodes,
191
+ SeatRowFacilities,
192
+ SeatRowFacilityPosition,
193
+ SeatStatuses,
194
+ } from '@/constants/seatMap'
195
+ // Consumers key `selections` with this, so it has to be the very same helper.
196
+ export { displaySeat } from '@/helpers/seatMap'
155
197
  export {
156
198
  CpAccordion,
157
199
  CpAccordionGroup,
@@ -182,6 +224,15 @@ export {
182
224
  CpRadio,
183
225
  CpRadioGroup,
184
226
  CpRadioNew,
227
+ CpSeatMap,
228
+ CpSeatMapEmergencyExitDialog,
229
+ CpSeatMapGrid,
230
+ CpSeatMapPlane,
231
+ CpSeatMapRow,
232
+ CpSeatMapRowFacility,
233
+ CpSeatMapSeat,
234
+ CpSeatMapSeatWrapper,
235
+ CpSeatMapZone,
185
236
  CpSelect,
186
237
  CpSelectableButton,
187
238
  CpSelectMenu,
@@ -0,0 +1,47 @@
1
+ import { SeatStatuses } from './SeatStatuses'
2
+
3
+ export interface CpSeatMapConfig {
4
+ emergencyExit: {
5
+ close: string
6
+ confirm: string
7
+ disclaimerContent: string
8
+ disclaimerTitle: string
9
+ subtitle: string
10
+ title: string
11
+ }
12
+ facility: {
13
+ galley: string
14
+ lavatory: string
15
+ }
16
+ seatStatuses: Record<SeatStatuses, string> & {
17
+ selected: string
18
+ selectedForLinkedTraveler: string
19
+ selectTravelerFirst: string
20
+ }
21
+ }
22
+
23
+ export const DEFAULT_CP_SEAT_MAP_CONFIG: CpSeatMapConfig = {
24
+ seatStatuses: {
25
+ [SeatStatuses.FREE]: 'Available',
26
+ [SeatStatuses.OCCUPIED]: 'Occupied',
27
+ [SeatStatuses.OCCUPIED_BY_CURRENT_PAX]: 'Selected',
28
+ [SeatStatuses.BLOCKED]: 'Unavailable',
29
+ [SeatStatuses.PAYABLE]: 'Extra fee',
30
+ selected: 'Selected',
31
+ selectedForLinkedTraveler: 'Selected for this traveler and their linked traveler',
32
+ selectTravelerFirst: 'Select a traveler first',
33
+ },
34
+ facility: {
35
+ galley: 'Galley',
36
+ lavatory: 'Lavatory',
37
+ },
38
+ emergencyExit: {
39
+ close: 'Close',
40
+ confirm: 'Confirm',
41
+ disclaimerContent:
42
+ 'You must be able to assist the crew in an evacuation. Passengers who cannot are not allowed in these rows.',
43
+ disclaimerTitle: 'Emergency exit row requirements',
44
+ subtitle: 'This seat is located in an emergency exit row.',
45
+ title: 'Emergency exit row',
46
+ },
47
+ }
@@ -0,0 +1,12 @@
1
+ import type { IataTravelerTypes } from './IataTravelerTypes'
2
+
3
+ /**
4
+ * What the consumer knows about a seat it has assigned. Pimp holds no selection
5
+ * state of its own — it only renders what it is handed.
6
+ */
7
+ export interface CpSeatMapSeatSelection {
8
+ hasLinkedTraveler?: boolean
9
+ initials: string
10
+ /** Drives the linked-traveler badge icon; without it the badge falls back to infant. */
11
+ linkedTravelerType?: IataTravelerTypes
12
+ }
@@ -0,0 +1,4 @@
1
+ export enum CpSeatMapTransitionDirections {
2
+ BACKWARD = 'backward',
3
+ FORWARD = 'forward',
4
+ }
@@ -0,0 +1,6 @@
1
+ export enum IataTravelerTypes {
2
+ ADULT = 'ad',
3
+ CHILD = 'ch',
4
+ INFANT = 'inf',
5
+ UNACCOMPANIED_MINOR = 'um',
6
+ }
@@ -0,0 +1,18 @@
1
+ import type { SeatAncillary } from './SeatAncillary'
2
+ import type { SeatCharacteristic } from './SeatCharacteristic'
3
+ import type { SeatStatuses } from './SeatStatuses'
4
+
5
+ export interface Seat {
6
+ blocking_code?: string
7
+ characteristics: SeatCharacteristic[]
8
+ column: string
9
+ eligible_ancillaries: SeatAncillary[]
10
+ has_specific_message: boolean
11
+ id: number
12
+ is_exit_row: boolean
13
+ occupied_traveler_id: number
14
+ selected_ancillary?: SeatAncillary
15
+ status: SeatStatuses
16
+ traveler_eligibility?: Record<string, boolean>
17
+ type: string
18
+ }
@@ -0,0 +1,8 @@
1
+ export interface SeatAncillary {
2
+ amount: number
3
+ color: string
4
+ data_id: number
5
+ eligible_traveler_ids: number[]
6
+ formatted_amount: string
7
+ label: string
8
+ }
@@ -0,0 +1,7 @@
1
+ import type { SeatCharacteristicCodes } from './SeatCharacteristicCodes'
2
+
3
+ export interface SeatCharacteristic {
4
+ code: SeatCharacteristicCodes
5
+ data_id: number
6
+ label: string
7
+ }
@@ -0,0 +1,9 @@
1
+ export enum SeatCharacteristicCodes {
2
+ WINDOW = 'W',
3
+ AISLE = 'A',
4
+ BULKHEAD = 'K',
5
+ EMERGENCY_EXIT = 'E',
6
+ NO_SMOKING = 'N',
7
+ CENTER = '9',
8
+ CHARGEABLE = 'CH',
9
+ }
@@ -0,0 +1,10 @@
1
+ import type { SeatMapZone } from './SeatMapZone'
2
+ import type { SeatRow } from './SeatRow'
3
+
4
+ export interface SeatMap {
5
+ aircraft: string
6
+ exit_row_warning_child_max_age?: number
7
+ ref_id_segment: string
8
+ rows: SeatRow[]
9
+ zones: Record<string, SeatMapZone>
10
+ }
@@ -0,0 +1,5 @@
1
+ export interface SeatMapZone {
2
+ layout: (string | null)[]
3
+ prbds: string[]
4
+ title: string
5
+ }
@@ -0,0 +1,15 @@
1
+ import type { Seat } from './Seat'
2
+ import type { SeatRowFacilityFlags } from './SeatRowFacilityFlags'
3
+
4
+ export interface SeatRow {
5
+ bottom?: SeatRowFacilityFlags
6
+ has_exit_back: boolean
7
+ has_exit_front: boolean
8
+ has_exit_left: boolean
9
+ has_exit_right: boolean
10
+ is_exit: boolean
11
+ number: number
12
+ seats: Record<string, Seat>
13
+ top?: SeatRowFacilityFlags
14
+ zone: string
15
+ }
@@ -0,0 +1,10 @@
1
+ export enum SeatRowFacilities {
2
+ LAVATORY = 'lavatory',
3
+ GALLEY = 'galley',
4
+ CURTAIN = 'curtain',
5
+ }
6
+
7
+ export enum SeatRowFacilityPosition {
8
+ LEFT = 'left',
9
+ RIGHT = 'right',
10
+ }
@@ -0,0 +1,7 @@
1
+ export interface SeatRowFacilityFlags {
2
+ curtain?: boolean
3
+ galley_left?: boolean
4
+ galley_right?: boolean
5
+ lavatory_left?: boolean
6
+ lavatory_right?: boolean
7
+ }
@@ -0,0 +1,7 @@
1
+ export enum SeatStatuses {
2
+ FREE = 'free',
3
+ OCCUPIED = 'occupied',
4
+ OCCUPIED_BY_CURRENT_PAX = 'occupiedByCurrentPax',
5
+ BLOCKED = 'blocked',
6
+ PAYABLE = 'payable',
7
+ }
@@ -0,0 +1,16 @@
1
+ export type { CpSeatMapConfig } from './CpSeatMapConfig'
2
+ export type { CpSeatMapSeatSelection } from './CpSeatMapSeatSelection'
3
+ export type { Seat } from './Seat'
4
+ export type { SeatAncillary } from './SeatAncillary'
5
+ export type { SeatCharacteristic } from './SeatCharacteristic'
6
+ export type { SeatMap } from './SeatMap'
7
+ export type { SeatMapZone } from './SeatMapZone'
8
+ export type { SeatRow } from './SeatRow'
9
+ export type { SeatRowFacilityFlags } from './SeatRowFacilityFlags'
10
+
11
+ export { DEFAULT_CP_SEAT_MAP_CONFIG } from './CpSeatMapConfig'
12
+ export { CpSeatMapTransitionDirections } from './CpSeatMapTransitionDirections'
13
+ export { IataTravelerTypes } from './IataTravelerTypes'
14
+ export { SeatCharacteristicCodes } from './SeatCharacteristicCodes'
15
+ export { SeatRowFacilities, SeatRowFacilityPosition } from './SeatRowFacilities'
16
+ export { SeatStatuses } from './SeatStatuses'
@@ -0,0 +1,76 @@
1
+ import type { SeatMap } from '@/constants/seatMap/SeatMap'
2
+ import type { SeatRow } from '@/constants/seatMap/SeatRow'
3
+
4
+ import { IataTravelerTypes } from '@/constants/seatMap/IataTravelerTypes'
5
+
6
+ export type SeatMapLayout = (string | null)[]
7
+
8
+ export interface FormattedSeatMapZone {
9
+ id: string
10
+ layout: SeatMapLayout
11
+ title: string
12
+ }
13
+
14
+ /** A zone wider than this many columns switches the map to its compact treatment. */
15
+ const LARGE_PLANE_COLUMNS = 6
16
+
17
+ export const displaySeat = (seat: { column: string; row: number }) => `${seat.row}${seat.column}`
18
+
19
+ export const getSeatMapZones = (seatMap: SeatMap): FormattedSeatMapZone[] => {
20
+ return Object.keys(seatMap.zones).map((zoneId) => {
21
+ const zone = seatMap.zones[zoneId]
22
+
23
+ return {
24
+ id: zoneId,
25
+ title: zone?.title || '',
26
+ layout: zone?.layout || [],
27
+ }
28
+ })
29
+ }
30
+
31
+ export const getZoneRows = (seatMap: SeatMap, zoneId: string): SeatRow[] => {
32
+ return seatMap.rows.filter((row) => row.zone === zoneId).sort((a, b) => a.number - b.number)
33
+ }
34
+
35
+ export const isLargeSeatMap = (zones: FormattedSeatMapZone[]) => {
36
+ return zones.some((zone) => zone.layout.length > LARGE_PLANE_COLUMNS)
37
+ }
38
+
39
+ /** A `null` column is an aisle; it gets a named grid area so row numbers can sit in it. */
40
+ export const getGridTemplateAreas = (layout: SeatMapLayout) => {
41
+ let hallwayIndex = 0
42
+
43
+ return layout
44
+ .map((column) => {
45
+ if (column === null) {
46
+ hallwayIndex++
47
+ return `HALLWAY-${hallwayIndex}`
48
+ }
49
+
50
+ return column
51
+ })
52
+ .join(' ')
53
+ }
54
+
55
+ export const getGridTemplateColumns = (layout: SeatMapLayout) => {
56
+ return layout.map((column) => (column === null ? 'var(--hallway-width)' : 'var(--seat-width)')).join(' ')
57
+ }
58
+
59
+ /** Number of columns before the first aisle, used to span row facilities. */
60
+ export const getSeatBlockSize = (layout: SeatMapLayout) => {
61
+ const firstNullIndex = layout.indexOf(null)
62
+ return firstNullIndex > 0 ? firstNullIndex + 1 : layout.length
63
+ }
64
+
65
+ export const hasHallway = (layout: SeatMapLayout) => layout.includes(null)
66
+
67
+ export const getHallways = (layout: SeatMapLayout) => {
68
+ return layout.filter((column) => column === null).map((column, index) => ({ column, index: index + 1 }))
69
+ }
70
+
71
+ export const getTravelerIcon = (passengerType?: IataTravelerTypes) => {
72
+ if (!passengerType || passengerType === IataTravelerTypes.ADULT) return ''
73
+ if ([IataTravelerTypes.CHILD, IataTravelerTypes.UNACCOMPANIED_MINOR].includes(passengerType)) return 'child'
74
+
75
+ return 'infant'
76
+ }