@citizenplane/pimp 8.26.1 → 8.28.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.
Files changed (187) hide show
  1. package/dist/{IconAccompaniedMinorEach-CUq3oXbX.js → IconAccompaniedMinorEach-MkIJAypb.js} +1 -1
  2. package/dist/{IconAccompaniedMinorNone-nZ4eSfTj.js → IconAccompaniedMinorNone-DMb-bSCG.js} +1 -1
  3. package/dist/{IconAccompaniedMinorOne-CDMqq14b.js → IconAccompaniedMinorOne-C9ORHm66.js} +1 -1
  4. package/dist/{IconAddReceipt-DRpGiWBU.js → IconAddReceipt-CeJlKuX2.js} +1 -1
  5. package/dist/{IconAirportTerminal-8k-3lKjb.js → IconAirportTerminal-D3p4CRpN.js} +1 -1
  6. package/dist/{IconArrival-m6HnOVje.js → IconArrival-C3oPAqgQ.js} +1 -1
  7. package/dist/IconBaggageCabinNone-valcCKfd.js +22 -0
  8. package/dist/IconBaggageCheckedNone-oq4yx5cO.js +22 -0
  9. package/dist/IconBaggagePersonalNone-BovIoK0M.js +20 -0
  10. package/dist/{IconBroadcast-B13UworG.js → IconBroadcast-CqdgVQaO.js} +1 -1
  11. package/dist/{IconCabinBag-CNnzHz2B.js → IconCabinBag-CMrtn-s6.js} +1 -1
  12. package/dist/IconCalendar-DmUZ-Du1.js +30 -0
  13. package/dist/IconCalendarDelay-DHaiharm.js +22 -0
  14. package/dist/{IconCheckedBaggage-CkxUDHe9.js → IconCheckedBaggage-OeOjHxe7.js} +1 -1
  15. package/dist/{IconCheckedBaggage20-DEtphLSa.js → IconCheckedBaggage20-CXeWuJgc.js} +1 -1
  16. package/dist/{IconCheckedBaggage30-CmAddx5h.js → IconCheckedBaggage30-Cartaaei.js} +1 -1
  17. package/dist/{IconChild-OReHyUco.js → IconChild-ChjkS7Gd.js} +1 -1
  18. package/dist/{IconContact-D2N23RZ5.js → IconContact-CtOxYQIs.js} +1 -1
  19. package/dist/{IconDeparture-D10LaXRX.js → IconDeparture-DJxClL94.js} +1 -1
  20. package/dist/{IconDistribution-SpPiru9I.js → IconDistribution-BmCLzb9p.js} +1 -1
  21. package/dist/{IconDistributionClosed-Bzqe7nju.js → IconDistributionClosed-BMjqoyt9.js} +1 -1
  22. package/dist/{IconDistributionExclusivePair-CjPM-_R1.js → IconDistributionExclusivePair-D71kgwyk.js} +1 -1
  23. package/dist/{IconDistributionSided-DehjCN0D.js → IconDistributionSided-Du56cPXR.js} +1 -1
  24. package/dist/{IconDistributionSupplySided-DWCyXqd1.js → IconDistributionSupplySided-BY9ACIGQ.js} +1 -1
  25. package/dist/{IconDynamicContent-BvzbgXvW.js → IconDynamicContent-DoYbB86x.js} +1 -1
  26. package/dist/IconEndDate-CVABdl-P.js +22 -0
  27. package/dist/{IconFares-zARDpPNl.js → IconFares-BXnx8WJa.js} +1 -1
  28. package/dist/{IconFaresOutlined-DLFV8nwg.js → IconFaresOutlined-CjJhZUKX.js} +1 -1
  29. package/dist/{IconFemale-Ba4uoI-S.js → IconFemale-D4lMoNKt.js} +1 -1
  30. package/dist/{IconFindConversation-d0pP3wG9.js → IconFindConversation-CYdB5hW8.js} +1 -1
  31. package/dist/{IconFire-CXzWKoMB.js → IconFire-Bh3vQ1A3.js} +1 -1
  32. package/dist/{IconFlight-Cof8M5dO.js → IconFlight-RyDIRwoI.js} +1 -1
  33. package/dist/{IconFlightReturn-CA9iGMcW.js → IconFlightReturn-DN7K5zxX.js} +1 -1
  34. package/dist/IconFlightSchedule-DAX_cnvF.js +28 -0
  35. package/dist/{IconHandHeart-CCLKnMOm.js → IconHandHeart-C5jxr29k.js} +1 -1
  36. package/dist/{IconHistory-DI6WD_3J.js → IconHistory-CuJwcjfY.js} +1 -1
  37. package/dist/{IconHourGlass-BorNLEca.js → IconHourGlass-DyrZPbXz.js} +1 -1
  38. package/dist/{IconIdCard-DhbhBkul.js → IconIdCard-lBDLYRPq.js} +1 -1
  39. package/dist/{IconInfant-D4EztT9g.js → IconInfant-E19ozPuk.js} +1 -1
  40. package/dist/{IconItinerary-Bhj_lgG2.js → IconItinerary-5AEG0f9f.js} +1 -1
  41. package/dist/{IconLeave-BvpY7gdD.js → IconLeave-XuFJRd-0.js} +1 -1
  42. package/dist/{IconMale-RMd_9ZSg.js → IconMale-R2ZgQj0s.js} +1 -1
  43. package/dist/{IconMultiSegments-DROUj0t5.js → IconMultiSegments-DfiqdUEm.js} +1 -1
  44. package/dist/IconNoPassport-h-6DjTcc.js +22 -0
  45. package/dist/{IconNoRefund-yNAZr7uX.js → IconNoRefund-C5R_Zxke.js} +1 -1
  46. package/dist/IconNoSeat-C-XnWQk8.js +23 -0
  47. package/dist/{IconNotion-CpZhGILz.js → IconNotion-pdx45QBU.js} +1 -1
  48. package/dist/{IconOffline-Bf1mw_1N.js → IconOffline-EG6mJ-Fs.js} +1 -1
  49. package/dist/{IconOneWay-6oGoLo57.js → IconOneWay-CX6CckSB.js} +2 -2
  50. package/dist/{IconPaid-B3dvioAR.js → IconPaid-BJhBGPy9.js} +1 -1
  51. package/dist/IconPassport-C6THdLYf.js +37 -0
  52. package/dist/{IconPayout-b3TcXwjA.js → IconPayout-MS-qRRR0.js} +1 -1
  53. package/dist/IconPlug-yYpQdJgj.js +22 -0
  54. package/dist/IconPlugOff-DSGcBog-.js +23 -0
  55. package/dist/{IconReceipt-Dh454941.js → IconReceipt-ChU6nBry.js} +1 -1
  56. package/dist/IconRecurrence-DtwCmoXo.js +22 -0
  57. package/dist/{IconRefund-D-FNjukU.js → IconRefund-D1wQXsZj.js} +1 -1
  58. package/dist/{IconRoundTrip-BqVPrNwg.js → IconRoundTrip-DhPU15r6.js} +1 -1
  59. package/dist/{IconRouteNoStop-CZ_QeOIY.js → IconRouteNoStop-C5b0NI9V.js} +1 -1
  60. package/dist/{IconRouteOneStop-DGpLAQmQ.js → IconRouteOneStop-CDL4AJoN.js} +1 -1
  61. package/dist/IconScheduleChange-CasvbB9p.js +22 -0
  62. package/dist/{IconSeatEmpty-BwyVwYQZ.js → IconSeatEmpty-CUDMQzqk.js} +1 -1
  63. package/dist/{IconSeatSold-B_SNoTs-.js → IconSeatSold-mwtkmlhT.js} +1 -1
  64. package/dist/{IconSeatTotal-DUEF7k6I.js → IconSeatTotal-BPegCOjA.js} +1 -1
  65. package/dist/IconStartDate-DoPJpEly.js +22 -0
  66. package/dist/{IconTemplate-D1ACYaHI.js → IconTemplate-CQH8r3U7.js} +1 -1
  67. package/dist/{IconTicket-5Z4b83BP.js → IconTicket-mONYGHBg.js} +1 -1
  68. package/dist/{IconTimer-DbcddAPo.js → IconTimer-BxR1ymxu.js} +1 -1
  69. package/dist/{IconTrafficControl-CEzhRpZt.js → IconTrafficControl-AcQHu-Dm.js} +1 -1
  70. package/dist/{index-DbgX3-2I.js → index-CjeXy6n3.js} +17600 -18506
  71. package/dist/pimp.es.js +1 -1
  72. package/dist/pimp.umd.js +23 -23
  73. package/dist/style.css +1 -1
  74. package/package.json +2 -1
  75. package/src/components/{core/BaseInputLabel.vue → BaseInputLabel.vue} +9 -15
  76. package/src/components/{core/BaseSelectClearButton.vue → BaseSelectClearButton.vue} +2 -2
  77. package/src/components/{atomic-elements/CpAirlineLogo.vue → CpAirlineLogo.vue} +9 -10
  78. package/src/components/{feedback-indicators/CpAlert.vue → CpAlert.vue} +16 -27
  79. package/src/components/{atomic-elements/CpBadge.vue → CpBadge.vue} +27 -44
  80. package/src/components/{buttons/CpButton.vue → CpButton.vue} +63 -104
  81. package/src/components/{date-pickers/CpCalendar.vue → CpCalendar.vue} +157 -156
  82. package/src/components/{toggles/CpCheckbox.vue → CpCheckbox.vue} +45 -54
  83. package/src/components/{date-pickers/CpDate.vue → CpDate.vue} +202 -212
  84. package/src/components/CpDatepicker.vue +203 -0
  85. package/src/components/{atomic-elements/CpDialog.vue → CpDialog.vue} +14 -9
  86. package/src/components/{typography/CpHeading.vue → CpHeading.vue} +11 -31
  87. package/src/components/{visual/CpIcon.vue → CpIcon.vue} +2 -1
  88. package/src/components/{inputs/CpInput.vue → CpInput.vue} +41 -58
  89. package/src/components/{feedback-indicators/CpLoader.vue → CpLoader.vue} +7 -8
  90. package/src/components/{selects/CpMultiselect.vue → CpMultiselect.vue} +60 -91
  91. package/src/components/{atomic-elements/CpPartnerBadge.vue → CpPartnerBadge.vue} +12 -20
  92. package/src/components/{toggles/CpRadio.vue → CpRadio.vue} +47 -58
  93. package/src/components/{selects/CpSelect.vue → CpSelect.vue} +74 -94
  94. package/src/components/{selects/CpSelectMenu.vue → CpSelectMenu.vue} +94 -96
  95. package/src/components/{toggles/CpSwitch.vue → CpSwitch.vue} +51 -67
  96. package/src/components/{lists-and-table/CpTable.vue → CpTable.vue} +159 -113
  97. package/src/components/{lists-and-table/CpTableEmptyState.vue → CpTableEmptyState.vue} +5 -8
  98. package/src/components/{inputs/CpTextarea.vue → CpTextarea.vue} +32 -52
  99. package/src/components/CpToaster.vue +377 -0
  100. package/src/components/{atomic-elements/CpTooltip.vue → CpTooltip.vue} +12 -11
  101. package/src/components/TransitionExpand.vue +70 -0
  102. package/src/components/icons/IconBaggageCabinNone.vue +24 -0
  103. package/src/components/icons/IconBaggageCheckedNone.vue +25 -0
  104. package/src/components/icons/IconBaggagePersonalNone.vue +33 -0
  105. package/src/components/icons/IconCalendar.vue +17 -0
  106. package/src/components/icons/IconCalendarDelay.vue +21 -0
  107. package/src/components/icons/IconEndDate.vue +19 -0
  108. package/src/components/icons/IconFlightSchedule.vue +23 -0
  109. package/src/components/icons/IconNoPassport.vue +23 -24
  110. package/src/components/icons/IconNoSeat.vue +18 -0
  111. package/src/components/icons/IconOneWay.vue +1 -1
  112. package/src/components/icons/IconPassport.vue +15 -22
  113. package/src/components/icons/IconPlug.vue +17 -0
  114. package/src/components/icons/IconPlugOff.vue +18 -0
  115. package/src/components/icons/IconRecurrence.vue +17 -8
  116. package/src/components/icons/IconScheduleChange.vue +17 -26
  117. package/src/components/icons/IconStartDate.vue +19 -0
  118. package/src/components/index.ts +43 -55
  119. package/src/constants/{src/CpCustomIcons.ts → CpCustomIcons.ts} +13 -2
  120. package/src/constants/CpTableConfig.ts +12 -0
  121. package/src/constants/Heading.ts +8 -0
  122. package/src/{utils/constants/src/Intent.js → constants/Intent.ts} +1 -1
  123. package/src/constants/PartnerTypes.ts +6 -0
  124. package/src/constants/Position.ts +10 -0
  125. package/src/constants/Sizes.ts +5 -0
  126. package/src/constants/colors/Colors.ts +10 -0
  127. package/src/constants/colors/ToggleColors.ts +6 -0
  128. package/src/constants/index.ts +10 -5
  129. package/src/directives/ClickOutside.ts +17 -0
  130. package/src/directives/{ResizeSelect.js → ResizeSelect.ts} +3 -3
  131. package/src/helpers/{dom.js → dom.ts} +13 -9
  132. package/src/helpers/{index.js → index.ts} +13 -3
  133. package/src/helpers/object.ts +9 -0
  134. package/src/helpers/string/src/camelize.ts +6 -0
  135. package/src/helpers/string/src/{decamelize.js → decamelize.ts} +1 -1
  136. package/src/libs/CoreDatepicker.vue +4 -4
  137. package/src/plugins/toaster.ts +71 -0
  138. package/src/stories/BaseInputLabel.stories.ts +2 -1
  139. package/src/stories/CpAirlineLogo.stories.ts +1 -1
  140. package/src/stories/CpAlert.stories.ts +2 -1
  141. package/src/stories/CpBadge.stories.ts +1 -1
  142. package/src/stories/CpButton.stories.ts +1 -1
  143. package/src/stories/CpCheckbox.stories.ts +4 -2
  144. package/src/stories/CpDate.stories.ts +4 -2
  145. package/src/stories/CpDatepicker.stories.ts +4 -2
  146. package/src/stories/CpDialog.stories.ts +3 -2
  147. package/src/stories/CpHeading.stories.ts +2 -1
  148. package/src/stories/CpIcon.stories.ts +3 -1
  149. package/src/stories/CpInput.stories.ts +4 -2
  150. package/src/stories/CpLoader.stories.ts +2 -1
  151. package/src/stories/CpMultiselect.stories.ts +3 -2
  152. package/src/stories/CpPartnerBadge.stories.ts +2 -2
  153. package/src/stories/CpRadio.stories.ts +4 -2
  154. package/src/stories/CpSelect.stories.ts +4 -2
  155. package/src/stories/CpSelectMenu.stories.ts +4 -2
  156. package/src/stories/CpSwitch.stories.ts +4 -2
  157. package/src/stories/CpTable.stories.ts +9 -2
  158. package/src/stories/CpTableEmptyState.stories.ts +2 -1
  159. package/src/stories/CpTextarea.stories.ts +4 -2
  160. package/src/stories/CpToaster.stories.ts +2 -1
  161. package/src/stories/CpTooltip.stories.ts +2 -1
  162. package/src/stories/TransitionExpand.stories.ts +4 -2
  163. package/src/types/luxon.d.ts +1 -0
  164. package/src/vendors/ff-polyfill.ts +38 -0
  165. package/vitest.workspace.js +1 -3
  166. package/dist/IconNoPassport-DBmaQH_g.js +0 -18
  167. package/dist/IconPassport-5SwUf6_R.js +0 -20
  168. package/dist/IconRecurrence-CXVkBJ3i.js +0 -24
  169. package/dist/IconScheduleChange-CEIGEhU4.js +0 -19
  170. package/src/components/date-pickers/CpDatepicker.vue +0 -229
  171. package/src/components/feedback-indicators/CpToaster.vue +0 -372
  172. package/src/components/helpers-utilities/TransitionExpand.vue +0 -72
  173. package/src/constants/src/CpTableConfig.ts +0 -14
  174. package/src/constants/src/Position.ts +0 -10
  175. package/src/constants/src/colors/Colors.ts +0 -10
  176. package/src/constants/src/colors/ToggleColors.ts +0 -6
  177. package/src/directives/ClickOutside.js +0 -13
  178. package/src/helpers/object.js +0 -9
  179. package/src/helpers/string/src/camelize.js +0 -6
  180. package/src/plugins/toaster.js +0 -61
  181. package/src/utils/constants/index.js +0 -3
  182. package/src/utils/constants/src/PartnerTypes.js +0 -6
  183. package/src/utils/constants/src/Sizes.js +0 -5
  184. package/src/vendors/ff-polyfill.js +0 -36
  185. /package/src/components/{atomic-elements/CpDialogWrapper.vue → CpDialogWrapper.vue} +0 -0
  186. /package/src/components/{logo/Pimp.vue → Pimp.vue} +0 -0
  187. /package/src/helpers/string/{index.js → index.ts} +0 -0
@@ -111,98 +111,109 @@
111
111
  </div>
112
112
  </template>
113
113
 
114
- <script setup>
114
+ <script setup lang="ts">
115
115
  import { ref, computed } from 'vue'
116
116
 
117
+ import CpTableEmptyState from '@/components/CpTableEmptyState.vue'
118
+
117
119
  import { camelize, decamelize } from '@/helpers/string'
120
+
121
+ import { PAGINATION_FORMATS, RESERVED_KEYS, VISIBLE_ROWS_MAX } from '@/constants'
118
122
  import { randomString } from '@/helpers'
119
123
 
120
- import CpTableEmptyState from '@/components/lists-and-table/CpTableEmptyState.vue'
124
+ const LoaderColor = '#5341F9'
125
+
126
+ interface ColumnDefinition {
127
+ id: string
128
+ name: string
129
+ textAlign?: 'left' | 'center' | 'right'
130
+ width?: number
131
+ }
121
132
 
122
- import { CpTableConfig } from '@/constants'
133
+ interface PaginationServer {
134
+ activePage: number
135
+ total: number
136
+ }
123
137
 
124
- const LoaderColor = '#5341F9'
138
+ interface Pagination {
139
+ enabled?: boolean
140
+ format?: (typeof PAGINATION_FORMATS)[keyof typeof PAGINATION_FORMATS]
141
+ limit?: number
142
+ server?: PaginationServer
143
+ }
125
144
 
126
- const props = defineProps({
127
- caption: {
128
- type: String,
129
- default: '',
130
- required: false,
131
- },
132
- columns: {
133
- type: Array,
134
- default: () => [],
135
- required: false,
136
- },
137
- data: {
138
- type: Array,
139
- required: true,
140
- },
141
- pagination: {
142
- type: [Boolean, Object],
143
- default: false,
144
- required: false,
145
- validator: (value) => {
146
- const isLimitValid = value.limit ? value.limit <= CpTableConfig.VISIBLE_ROWS_MAX : true
147
- const isFooterDetailsFormatValid = value.format
148
- ? Object.values(CpTableConfig.PAGINATION_FORMATS).includes(value.format)
149
- : true
150
-
151
- return isLimitValid && isFooterDetailsFormatValid
152
- },
153
- },
154
- areRowsClickable: {
155
- type: Boolean,
156
- default: false,
157
- required: false,
158
- },
159
- emptyCellPlaceholder: {
160
- type: String,
161
- default: 'n/a',
162
- required: false,
163
- },
164
- noResultPlaceholder: {
165
- type: String,
166
- default: 'No results found',
167
- required: false,
168
- },
169
- isLoading: {
170
- type: Boolean,
171
- default: false,
172
- required: false,
173
- },
174
- enableRowOptions: {
175
- type: Boolean,
176
- default: false,
177
- required: false,
178
- },
179
- quickOptionsLimit: {
180
- type: Number,
181
- default: 3,
182
- required: false,
183
- },
184
- rowOptions: {
185
- type: Array,
186
- default: () => [],
187
- required: false,
188
- },
145
+ interface RowOptions {
146
+ action: (payload: { rowData: Record<string, unknown>; rowIndex: number }, event: Event) => void
147
+ disabled?: boolean
148
+ icon: string
149
+ id: string
150
+ isCritical?: boolean
151
+ label: string
152
+ }
153
+
154
+ interface GroupByData {
155
+ groupBy: string
156
+ rows: Record<string, unknown>[]
157
+ }
158
+
159
+ interface Props {
160
+ areRowsClickable?: boolean
161
+ caption?: string
162
+ columns?: string[] | ColumnDefinition[]
163
+ data: (Record<string, unknown> | GroupByData)[]
164
+ emptyCellPlaceholder?: string
165
+ enableRowOptions?: boolean
166
+ isLoading?: boolean
167
+ noResultPlaceholder?: string
168
+ pagination?: Pagination
169
+ quickOptionsLimit?: number
170
+ rowOptions?: RowOptions[]
171
+ }
172
+
173
+ const props = withDefaults(defineProps<Props>(), {
174
+ caption: '',
175
+ columns: () => [],
176
+ pagination: undefined,
177
+ areRowsClickable: false,
178
+ emptyCellPlaceholder: 'n/a',
179
+ noResultPlaceholder: 'No results found',
180
+ isLoading: false,
181
+ enableRowOptions: false,
182
+ quickOptionsLimit: 3,
183
+ rowOptions: () => [],
189
184
  })
190
185
 
191
- const emit = defineEmits(['onRowClick', 'onRowRightClick', 'onNextClick', 'onPreviousClick'])
186
+ interface Emits {
187
+ (e: 'onRowClick', data: Record<string, unknown>): void
188
+ (e: 'onRowRightClick', payload: { data: Record<string, unknown>; event: Event }): void
189
+ (e: 'onNextClick'): void
190
+ (e: 'onPreviousClick'): void
191
+ }
192
+
193
+ const emit = defineEmits<Emits>()
192
194
 
193
195
  const uniqueId = ref(randomString())
194
196
  const pageNumber = ref(0)
195
- const cpTableContainer = ref(null)
197
+ const cpTableContainer = ref<HTMLElement | null>(null)
196
198
 
197
199
  const hasQuickOptions = computed(() => !!quickOptions.value.length)
198
200
  const hasMoreQuickActionsThanLimit = computed(() => props.rowOptions.length >= props.quickOptionsLimit)
199
201
 
200
- const defaultRowOptions = computed(() => {
201
- if (!props.enableRowOptions || !props.rowOptions.length) return {}
202
+ const defaultRowOptions = computed<RowOptions>(() => {
203
+ if (!props.enableRowOptions || !props.rowOptions.length) {
204
+ return {
205
+ id: 'default',
206
+ label: 'More',
207
+ icon: 'more-vertical',
208
+ action: () => {},
209
+ }
210
+ }
202
211
  return {
212
+ id: 'more',
203
213
  label: 'More',
204
214
  icon: 'more-vertical',
205
- action: ({ rowData, rowIndex }, $event) => handleRowRightClick({ rowData, rowIndex }, $event),
215
+ action: ({ rowData, rowIndex }: { rowData: Record<string, unknown>; rowIndex: number }, $event: Event) =>
216
+ handleRowRightClick({ rowData, rowIndex }, $event),
206
217
  }
207
218
  })
208
219
 
@@ -222,7 +233,7 @@ const containerDOMElement = computed(() => cpTableContainer.value)
222
233
  const mainClasses = computed(() => ({ 'cpTable--isLoading': props.isLoading }))
223
234
  const containerClasses = computed(() => ({ 'cpTable__container--hasPagination': hasPagination.value }))
224
235
 
225
- const normalizedColumns = computed(() => {
236
+ const normalizedColumns = computed<ColumnDefinition[]>(() => {
226
237
  if (!props.columns) return []
227
238
  const columns = props.columns.length ? [...props.columns] : [...columnsFromRows.value]
228
239
 
@@ -235,8 +246,8 @@ const normalizedColumns = computed(() => {
235
246
  }
236
247
 
237
248
  return {
238
- id: column.id || camelize(column.name),
239
249
  ...column,
250
+ id: column.id || camelize(column.name),
240
251
  }
241
252
  })
242
253
  })
@@ -245,30 +256,39 @@ const numberOfColumns = computed(() => normalizedColumns.value.length)
245
256
 
246
257
  const hasGroupBy = computed(() => {
247
258
  if (!props.data.length) return false
248
- return props.data.some((item) => CpTableConfig.RESERVED_KEYS.GROUP_BY in item)
259
+ return props.data.some((item) => RESERVED_KEYS.GROUP_BY in item)
249
260
  })
250
261
 
251
262
  const columnsFromRows = computed(() => {
252
263
  if (!props.data.length) return []
253
- const firstRow = hasGroupBy.value ? props.data[0].rows[0] : props.data[0]
254
- return Object.keys(firstRow)
264
+ const firstItem = props.data[0]
265
+ const firstRow = hasGroupBy.value && 'rows' in firstItem ? (firstItem as GroupByData).rows[0] : firstItem
266
+ return Object.keys(firstRow as Record<string, unknown>)
255
267
  })
256
268
 
257
269
  const numberOfResults = computed(() => {
258
- return isServerSidePagination.value ? props.pagination.server.total : flattenedRows.value.length
270
+ return isServerSidePagination.value ? props.pagination?.server?.total || 0 : flattenedRows.value.length
259
271
  })
260
272
 
261
273
  const hasNoResult = computed(() => numberOfResults.value === 0)
262
- const rowsPerPageLimit = computed(() => props.pagination.limit || CpTableConfig.VISIBLE_ROWS_MAX)
274
+ const rowsPerPageLimit = computed(() => {
275
+ if (typeof props.pagination === 'object' && props.pagination.limit) {
276
+ return props.pagination.limit
277
+ }
278
+ return VISIBLE_ROWS_MAX
279
+ })
263
280
 
264
281
  const flattenedRows = computed(() => {
265
282
  if (!props.data) return []
266
- if (!hasGroupBy.value) return props.data
283
+ if (!hasGroupBy.value) return props.data as Record<string, unknown>[]
267
284
 
268
- // Transform groupBy key into a row and add it in between others
269
- return props.data.reduce((flattenedRows, groupByItem) => {
270
- const fullWidthRow = { [CpTableConfig.RESERVED_KEYS.GROUP_BY]: groupByItem.groupBy }
271
- return [...flattenedRows, fullWidthRow, ...groupByItem.rows]
285
+ return props.data.reduce((flattenedRows: Record<string, unknown>[], item) => {
286
+ if ('groupBy' in item) {
287
+ const groupByItem = item as GroupByData
288
+ const fullWidthRow = { [RESERVED_KEYS.GROUP_BY]: groupByItem.groupBy }
289
+ return [...flattenedRows, fullWidthRow, ...groupByItem.rows]
290
+ }
291
+ return [...flattenedRows, item as Record<string, unknown>]
272
292
  }, [])
273
293
  })
274
294
 
@@ -286,11 +306,16 @@ const visibleRows = computed(() =>
286
306
  )
287
307
 
288
308
  const paginationState = computed(() => {
289
- return typeof props.pagination === 'boolean' ? props.pagination : props.pagination.enabled
309
+ return typeof props.pagination === 'boolean' ? props.pagination : props.pagination?.enabled
290
310
  })
291
311
 
292
- const hasPagination = computed(() => paginationState.value || numberOfResults.value > CpTableConfig.VISIBLE_ROWS_MAX)
293
- const paginationFormat = computed(() => props.pagination?.format || CpTableConfig.PAGINATION_FORMATS.PAGES)
312
+ const hasPagination = computed(() => paginationState.value || numberOfResults.value > VISIBLE_ROWS_MAX)
313
+ const paginationFormat = computed(() => {
314
+ if (typeof props.pagination === 'object' && props.pagination.format) {
315
+ return props.pagination.format
316
+ }
317
+ return PAGINATION_FORMATS.PAGES
318
+ })
294
319
  const hasRemainingPages = computed(() => numberOfPages.value > activePage.value)
295
320
  const isNextEnabled = computed(() => hasRemainingPages.value && !props.isLoading)
296
321
 
@@ -307,11 +332,11 @@ const activePage = computed(() => {
307
332
  })
308
333
 
309
334
  const isServerSidePagination = computed(() => {
310
- if (typeof props.pagination === 'boolean') return false
335
+ if (!props.pagination) return false
311
336
  return 'server' in props.pagination
312
337
  })
313
338
 
314
- const serverActivePage = computed(() => props.pagination.server.activePage)
339
+ const serverActivePage = computed(() => props.pagination?.server?.activePage || 0)
315
340
  const serverPagesStartIndex = computed(() => serverActivePage.value * rowsPerPageLimit.value + 1)
316
341
  const serverPagesEndIndex = computed(() => rowsPerPageLimit.value * (1 + serverActivePage.value))
317
342
 
@@ -325,7 +350,7 @@ const pageLastResultIndex = computed(() => {
325
350
  })
326
351
 
327
352
  const paginationLabel = computed(() => {
328
- if (paginationFormat.value === CpTableConfig.PAGINATION_FORMATS.PAGES) {
353
+ if (paginationFormat.value === PAGINATION_FORMATS.PAGES) {
329
354
  const pluralizedCount = numberOfPages.value > 1 ? 'pages' : 'page'
330
355
  return `${activePage.value}/${numberOfPages.value} ${pluralizedCount}`
331
356
  }
@@ -338,22 +363,25 @@ const paginationResultsDetails = computed(() => {
338
363
  return `${formattedNumberOfResults} ${pluralizedCount}`
339
364
  })
340
365
 
341
- const getQuickOptionTooltip = (option) => (!option.disabled ? option.label : '')
366
+ const getQuickOptionTooltip = (option: RowOptions) => (!option.disabled ? option.label : '')
342
367
 
343
- const getQuickOptionClasses = (option) => {
368
+ const getQuickOptionClasses = (option: RowOptions) => {
344
369
  return { 'cpTable__action--isCritical': option.isCritical }
345
370
  }
346
371
 
347
- const getRowPayload = (rowIndex) => rawVisibleRows.value[rowIndex]
372
+ const getRowPayload = (rowIndex: number) => rawVisibleRows.value[rowIndex]
348
373
 
349
- const handleRowClick = (rowData, rowIndex) => {
374
+ const handleRowClick = (rowData: Record<string, unknown>, rowIndex: number) => {
350
375
  if (isFullWidthRow(rowData)) return
351
376
 
352
377
  const data = getRowPayload(rowIndex)
353
378
  emit('onRowClick', data)
354
379
  }
355
380
 
356
- const handleRowRightClick = ({ rowData, rowIndex }, event) => {
381
+ const handleRowRightClick = (
382
+ { rowData, rowIndex }: { rowData: Record<string, unknown>; rowIndex: number },
383
+ event: Event,
384
+ ) => {
357
385
  if (isFullWidthRow(rowData)) return
358
386
 
359
387
  const data = getRowPayload(rowIndex)
@@ -375,7 +403,13 @@ const handleNavigationClick = (isNext = true) => {
375
403
  emit('onPreviousClick')
376
404
  }
377
405
 
378
- const normalizeRowData = ({ columns = normalizedColumns.value, rowPayload }) => {
406
+ const normalizeRowData = ({
407
+ columns = normalizedColumns.value,
408
+ rowPayload,
409
+ }: {
410
+ columns?: ColumnDefinition[]
411
+ rowPayload: Record<string, unknown>
412
+ }) => {
379
413
  if (!Array.isArray(rowPayload)) {
380
414
  return { ...rowPayload }
381
415
  }
@@ -390,12 +424,18 @@ const normalizeRowData = ({ columns = normalizedColumns.value, rowPayload }) =>
390
424
  }, {})
391
425
  }
392
426
 
393
- const mapCellToColumn = ({ columns = normalizedColumns.value, rowPayload }) => {
427
+ const mapCellToColumn = ({
428
+ columns = normalizedColumns.value,
429
+ rowPayload,
430
+ }: {
431
+ columns?: ColumnDefinition[]
432
+ rowPayload: Record<string, unknown>
433
+ }) => {
394
434
  if (isFullWidthRow(rowPayload)) return rowPayload
395
435
  // Bind column id with each row key
396
436
  // and replace row missing keys with the emptyCellPlaceholder value
397
437
  return columns.reduce((finalRow, currentColumn) => {
398
- const correspondingColumn = currentColumn?.id || currentColumn
438
+ const correspondingColumn = currentColumn.id
399
439
  const correspondingValue = rowPayload[correspondingColumn] || props.emptyCellPlaceholder
400
440
  const cellValue = { [correspondingColumn]: correspondingValue }
401
441
 
@@ -411,9 +451,13 @@ const decreaseOffset = () => {
411
451
  if (isPreviousEnabled.value) pageNumber.value--
412
452
  }
413
453
 
414
- const resetScrollPosition = () => (containerDOMElement.value.scrollTop = 0)
454
+ const resetScrollPosition = () => {
455
+ if (containerDOMElement.value) {
456
+ containerDOMElement.value.scrollTop = 0
457
+ }
458
+ }
415
459
 
416
- const getColumnStyle = (columnPayload) => {
460
+ const getColumnStyle = (columnPayload: ColumnDefinition) => {
417
461
  const formattedWidth = columnPayload?.width && `${columnPayload.width}px`
418
462
 
419
463
  return {
@@ -422,14 +466,14 @@ const getColumnStyle = (columnPayload) => {
422
466
  }
423
467
  }
424
468
 
425
- const getCellStyle = (cellKey, columnIndex) => {
469
+ const getCellStyle = (cellKey: RESERVED_KEYS, cellIndex: number) => {
426
470
  if (isFullWidthCell(cellKey)) return null
427
471
  return {
428
- textAlign: normalizedColumns.value[columnIndex]?.textAlign,
472
+ textAlign: normalizedColumns.value[cellIndex]?.textAlign,
429
473
  }
430
474
  }
431
475
 
432
- const getRowClasses = (rowData, rowIndex) => {
476
+ const getRowClasses = (rowData: Record<string, unknown>, rowIndex: number) => {
433
477
  return {
434
478
  'cpTable__row--isFullWidth': isFullWidthRow(rowData),
435
479
  'cpTable__row--isClickable': !isFullWidthRow(rowData) && props.areRowsClickable,
@@ -437,24 +481,26 @@ const getRowClasses = (rowData, rowIndex) => {
437
481
  }
438
482
  }
439
483
 
440
- const getCellClasses = (cellKey) => {
484
+ const getCellClasses = (cellKey: RESERVED_KEYS) => {
441
485
  return { 'cpTable__cell--isFullWidth': isFullWidthCell(cellKey) }
442
486
  }
443
487
 
444
- const getColspan = (cellKey) => {
488
+ const getColspan = (cellKey: RESERVED_KEYS) => {
445
489
  const numberOfColumnsValue = props.enableRowOptions ? numberOfColumns.value + 1 : numberOfColumns.value
446
- return isFullWidthCell(cellKey) ? numberOfColumnsValue : null
490
+ return isFullWidthCell(cellKey) ? numberOfColumnsValue : undefined
447
491
  }
448
492
 
449
- const getTabindex = (rowData) => (isFullWidthRow(rowData) ? -1 : 0)
450
-
451
- const fullWidthCellKeys = [CpTableConfig.RESERVED_KEYS.FULL_WIDTH, CpTableConfig.RESERVED_KEYS.GROUP_BY]
493
+ const getTabindex = (rowData: Record<string, unknown>) => (isFullWidthRow(rowData) ? -1 : 0)
452
494
 
453
- const isFullWidthCell = (cellKey) => fullWidthCellKeys.includes(cellKey)
454
- const isFullWidthRow = (rowData) => fullWidthCellKeys.some((key) => rowData[key])
495
+ const fullWidthCellKeys = [RESERVED_KEYS.FULL_WIDTH, RESERVED_KEYS.GROUP_BY]
496
+ const isFullWidthCell = (cellKey: RESERVED_KEYS) => fullWidthCellKeys.includes(cellKey)
497
+ const isFullWidthRow = (rowData: Record<string, unknown>) => fullWidthCellKeys.some((key) => rowData[key])
455
498
 
456
- const isRowSelected = (rowIndex) => rawVisibleRows.value[rowIndex][CpTableConfig.RESERVED_KEYS.IS_SELECTED]
457
- const areRowOptionsEnabled = (rowData) => props.enableRowOptions && !isFullWidthRow(rowData)
499
+ const isRowSelected = (rowIndex: number) => {
500
+ const row = rawVisibleRows.value[rowIndex] as Record<string, unknown>
501
+ return row?.[RESERVED_KEYS.IS_SELECTED] || false
502
+ }
503
+ const areRowOptionsEnabled = (rowData: Record<string, unknown>) => props.enableRowOptions && !isFullWidthRow(rowData)
458
504
 
459
505
  const resetPagination = () => (pageNumber.value = 0)
460
506
 
@@ -10,15 +10,12 @@
10
10
  </div>
11
11
  </template>
12
12
 
13
- <script>
14
- export default {
15
- props: {
16
- placeholder: {
17
- type: String,
18
- required: true,
19
- },
20
- },
13
+ <script setup lang="ts">
14
+ interface Props {
15
+ placeholder: string
21
16
  }
17
+
18
+ defineProps<Props>()
22
19
  </script>
23
20
 
24
21
  <style lang="scss">
@@ -27,65 +27,45 @@
27
27
  </div>
28
28
  </template>
29
29
 
30
- <script setup>
30
+ <script setup lang="ts">
31
31
  import { ref, computed } from 'vue'
32
32
 
33
- import BaseInputLabel from '@/components/core/BaseInputLabel.vue'
34
- import TransitionExpand from '@/components/helpers-utilities/TransitionExpand.vue'
33
+ import BaseInputLabel from '@/components/BaseInputLabel.vue'
34
+ import TransitionExpand from '@/components/TransitionExpand.vue'
35
35
 
36
36
  import { randomString, capitalizeFirstLetter } from '@/helpers'
37
37
 
38
- const props = defineProps({
39
- modelValue: {
40
- type: String,
41
- default: '',
42
- required: false,
43
- },
44
- label: {
45
- type: String,
46
- default: '',
47
- required: false,
48
- },
49
- placeholder: {
50
- type: String,
51
- default: '',
52
- required: true,
53
- },
54
- required: {
55
- type: Boolean,
56
- default: false,
57
- required: false,
58
- },
59
- inputId: {
60
- type: String,
61
- default: '',
62
- required: false,
63
- },
64
- disabled: {
65
- type: Boolean,
66
- default: false,
67
- required: false,
68
- },
69
- isInvalid: {
70
- type: Boolean,
71
- default: false,
72
- required: false,
73
- },
74
- errorMessage: {
75
- type: String,
76
- default: '',
77
- required: false,
78
- },
79
- height: {
80
- type: Number,
81
- default: 200,
82
- required: false,
83
- },
38
+ interface Props {
39
+ disabled?: boolean
40
+ errorMessage?: string
41
+ height?: number
42
+ inputId?: string
43
+ isInvalid?: boolean
44
+ label?: string
45
+ modelValue?: string
46
+ placeholder?: string
47
+ required?: boolean
48
+ }
49
+
50
+ const props = withDefaults(defineProps<Props>(), {
51
+ modelValue: '',
52
+ label: '',
53
+ placeholder: '',
54
+ required: false,
55
+ inputId: '',
56
+ disabled: false,
57
+ isInvalid: false,
58
+ errorMessage: '',
59
+ height: 200,
84
60
  })
85
61
 
86
- const emit = defineEmits(['update:modelValue'])
62
+ interface Emits {
63
+ (e: 'update:modelValue', value: string): void
64
+ }
65
+
66
+ const emit = defineEmits<Emits>()
87
67
 
88
- const textareaModel = defineModel({
68
+ const textareaModel = defineModel<string>({
89
69
  type: String,
90
70
  default: '',
91
71
  required: false,
@@ -101,7 +81,7 @@ const capitalizedLabel = computed(() => capitalizeFirstLetter(props.label))
101
81
 
102
82
  const displayErrorMessage = computed(() => props.isInvalid && props.errorMessage.length)
103
83
 
104
- const handleChange = (newValue) => emit('update:modelValue', newValue)
84
+ const handleChange = (newValue: string) => emit('update:modelValue', newValue)
105
85
  </script>
106
86
 
107
87
  <style lang="scss">