@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
@@ -4,42 +4,24 @@
4
4
  </component>
5
5
  </template>
6
6
 
7
- <script>
8
- const headingLevels = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']
7
+ <script setup lang="ts">
8
+ import { HeadingLevels } from '@/constants'
9
9
 
10
- const sizes = [100, 200, 300, 400, 500, 600, 700, 800, 900]
10
+ type HeadingSize = 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
11
11
 
12
- export default {
13
- props: {
14
- headingLevel: {
15
- type: String,
16
- default: headingLevels[0],
17
- validator: (value) => {
18
- return headingLevels.includes(value)
19
- },
20
- required: false,
21
- },
22
- size: {
23
- type: Number,
24
- default: sizes[4],
25
- validator: (value) => {
26
- return sizes.includes(value)
27
- },
28
- required: false,
29
- },
30
- },
31
- data() {
32
- return {
33
- headingLevels,
34
- }
35
- },
12
+ interface Props {
13
+ headingLevel?: HeadingLevels
14
+ size?: HeadingSize
36
15
  }
16
+
17
+ withDefaults(defineProps<Props>(), {
18
+ headingLevel: HeadingLevels.H1,
19
+ size: 500,
20
+ })
37
21
  </script>
38
22
 
39
23
  <style lang="scss">
40
24
  .cpHeading {
41
- color: colors.$neutral-dark;
42
-
43
25
  &:first-letter {
44
26
  text-transform: capitalize;
45
27
  }
@@ -49,14 +31,12 @@ export default {
49
31
  font-weight: 400;
50
32
  line-height: fn.px-to-rem(16);
51
33
  letter-spacing: fn.px-to-em(0.6);
52
- color: colors.$neutral-dark-1;
53
34
  }
54
35
 
55
36
  &--200 {
56
37
  font-size: fn.px-to-rem(12);
57
38
  font-weight: 600;
58
39
  line-height: fn.px-to-rem(16);
59
- color: colors.$neutral-dark-1;
60
40
  }
61
41
 
62
42
  &--300 {
@@ -5,8 +5,9 @@
5
5
  </template>
6
6
 
7
7
  <script setup lang="ts">
8
- import { computed } from 'vue'
9
8
  import * as feather from 'feather-icons'
9
+ import { computed } from 'vue'
10
+
10
11
  import { CustomCpIcons } from '@/constants'
11
12
 
12
13
  interface Props {
@@ -4,7 +4,7 @@
4
4
  {{ capitalizedLabel }} <span v-if="isRequired" class="u-asterisk">*</span>
5
5
  <cp-tooltip v-if="tooltip" :content="tooltip">
6
6
  <button type="button" class="cpInput__tooltip">
7
- <cp-icon class="cpInput__tooltipIcon" type="cp-tooltip" />
7
+ <cp-icon class="cpInput__tooltipIcon" type="tooltip" />
8
8
  </button>
9
9
  </cp-tooltip>
10
10
  </base-input-label>
@@ -56,72 +56,55 @@
56
56
  </div>
57
57
  </template>
58
58
 
59
- <script setup>
59
+ <script setup lang="ts">
60
60
  import { ref, useAttrs, useSlots, computed, nextTick, onMounted, useId } from 'vue'
61
61
 
62
- import BaseInputLabel from '@/components/core/BaseInputLabel.vue'
62
+ import BaseInputLabel from '@/components/BaseInputLabel.vue'
63
63
 
64
64
  import { randomString, capitalizeFirstLetter } from '@/helpers'
65
65
 
66
- const props = defineProps({
67
- modelValue: {
68
- type: [String, Number, Boolean],
69
- default: '',
70
- },
71
- tooltip: {
72
- type: String,
73
- default: '',
74
- },
75
- label: {
76
- type: String,
77
- default: '',
78
- },
79
- inputId: {
80
- type: String,
81
- default: null,
82
- },
83
- isInvalid: {
84
- type: Boolean,
85
- default: false,
86
- },
87
- errorMessage: {
88
- type: String,
89
- default: '',
90
- },
91
- mask: {
92
- type: [String, Object],
93
- default: null,
94
- },
95
- hideInvalidityIcon: {
96
- type: Boolean,
97
- default: false,
98
- },
99
- removeBorder: {
100
- type: Boolean,
101
- default: false,
102
- },
103
- isLarge: {
104
- type: Boolean,
105
- default: false,
106
- },
107
- isSearch: {
108
- type: Boolean,
109
- default: false,
110
- },
111
- help: {
112
- type: String,
113
- default: '',
114
- },
66
+ interface Props {
67
+ errorMessage?: string
68
+ help?: string
69
+ hideInvalidityIcon?: boolean
70
+ inputId?: string | null
71
+ isInvalid?: boolean
72
+ isLarge?: boolean
73
+ isSearch?: boolean
74
+ label?: string
75
+ mask?: string | Record<string, unknown> | null
76
+ modelValue?: string | number | boolean
77
+ removeBorder?: boolean
78
+ tooltip?: string
79
+ }
80
+
81
+ const props = withDefaults(defineProps<Props>(), {
82
+ modelValue: '',
83
+ tooltip: '',
84
+ label: '',
85
+ inputId: null,
86
+ isInvalid: false,
87
+ errorMessage: '',
88
+ mask: null,
89
+ hideInvalidityIcon: false,
90
+ removeBorder: false,
91
+ isLarge: false,
92
+ isSearch: false,
93
+ help: '',
115
94
  })
116
95
 
117
- const emit = defineEmits(['update:modelValue'])
96
+ interface Emits {
97
+ (e: 'update:modelValue', value: string | number | boolean): void
98
+ }
99
+
100
+ const emit = defineEmits<Emits>()
118
101
 
119
102
  defineOptions({ inheritAttrs: false })
120
103
 
121
104
  const attrs = useAttrs()
122
105
 
123
106
  // class is a reserved word, we can't remove 'class' property from attrs
124
- // eslint-disable-next-line
107
+
125
108
  const { ['class']: value, id, ...restAttributes } = attrs
126
109
 
127
110
  const inputIdentifier = ref(id || randomString())
@@ -135,7 +118,7 @@ const slots = useSlots()
135
118
 
136
119
  const capitalizedLabel = computed(() => capitalizeFirstLetter(props.label))
137
120
 
138
- const inputModel = defineModel({
121
+ const inputModel = defineModel<string | number | boolean>({
139
122
  type: [String, Number, Boolean],
140
123
  default: '',
141
124
  set(newValue) {
@@ -181,11 +164,11 @@ const iconInvalidityClasses = computed(() => {
181
164
  const DOMElement = computed(() => cpInputContainer.value.children.namedItem(inputIdentifier.value))
182
165
 
183
166
  const displayErrorMessage = computed(() => isInputInvalid.value && props.errorMessage.length)
184
- const isClearButtonVisible = computed(() => props.isSearch && inputModel.value.length)
167
+ const isClearButtonVisible = computed(() => props.isSearch && inputModel.value.toString().length)
185
168
 
186
169
  const displayHelp = computed(() => props.help?.length && !displayErrorMessage.value)
187
170
 
188
- const handleChange = (newValue) => {
171
+ const handleChange = (newValue: string | number | boolean) => {
189
172
  emit('update:modelValue', newValue)
190
173
  checkInputValidity()
191
174
  }
@@ -203,7 +186,7 @@ const checkInputValidity = () => {
203
186
  (DOMElement.value.validity && DOMElement.value.validity.valueMissing)
204
187
  }
205
188
 
206
- const checkAttribute = (attribute) => attrs[attribute] === '' || attrs[attribute] === true
189
+ const checkAttribute = (attribute: string) => attrs[attribute] === '' || attrs[attribute] === true
207
190
 
208
191
  const clearInputValue = () => emit('update:modelValue', '')
209
192
 
@@ -33,13 +33,12 @@
33
33
  </svg>
34
34
  </template>
35
35
 
36
- <script>
37
- export default {
38
- props: {
39
- color: {
40
- type: String,
41
- default: '#ff6700',
42
- },
43
- },
36
+ <script setup lang="ts">
37
+ interface Props {
38
+ color?: string
44
39
  }
40
+
41
+ withDefaults(defineProps<Props>(), {
42
+ color: '#ff6700',
43
+ })
45
44
  </script>
@@ -67,96 +67,61 @@
67
67
  </div>
68
68
  </template>
69
69
 
70
- <script setup>
71
- import { ref, computed, onMounted } from 'vue'
72
- import AutoComplete from 'primevue/autocomplete'
73
-
70
+ <script setup lang="ts">
74
71
  import { absolutePosition, getOuterWidth } from '@primeuix/utils/dom'
72
+ import AutoComplete from 'primevue/autocomplete'
73
+ import { ref, computed, onMounted } from 'vue'
75
74
 
76
- import BaseInputLabel from '@/components/core/BaseInputLabel.vue'
77
- import TransitionExpand from '@/components/helpers-utilities/TransitionExpand.vue'
78
- import BaseSelectClearButton from '@/components/core/BaseSelectClearButton.vue'
75
+ import BaseInputLabel from '@/components/BaseInputLabel.vue'
76
+ import BaseSelectClearButton from '@/components/BaseSelectClearButton.vue'
77
+ import TransitionExpand from '@/components/TransitionExpand.vue'
79
78
 
80
79
  import { isEmpty } from '@/helpers/object'
81
80
 
82
- const props = defineProps({
83
- label: {
84
- type: String,
85
- required: false,
86
- default: '',
87
- },
88
- required: {
89
- type: Boolean,
90
- required: false,
91
- default: false,
92
- },
93
- name: {
94
- type: String,
95
- required: false,
96
- default: '',
97
- },
98
- placeholder: {
99
- type: String,
100
- required: false,
101
- default: '',
102
- },
103
- isInvalid: {
104
- type: Boolean,
105
- required: false,
106
- default: false,
107
- },
108
- isClearable: {
109
- type: Boolean,
110
- required: false,
111
- default: false,
112
- },
113
- isLoading: {
114
- type: Boolean,
115
- required: false,
116
- default: false,
117
- },
118
- disabled: {
119
- type: Boolean,
120
- required: false,
121
- default: false,
122
- },
123
- multiple: {
124
- type: Boolean,
125
- required: false,
126
- default: false,
127
- },
128
- options: {
129
- type: Array,
130
- required: false,
131
- default: () => [],
132
- },
133
- optionLabel: {
134
- type: String,
135
- required: false,
136
- default: 'name',
137
- },
138
- trackBy: {
139
- type: String,
140
- required: false,
141
- default: 'id',
142
- },
143
- emptyMessage: {
144
- type: String,
145
- required: false,
146
- default: 'No results found',
147
- },
148
- errorMessage: {
149
- type: String,
150
- required: false,
151
- default: '',
152
- },
153
- modelValue: {
154
- type: [Array, Object],
155
- required: false,
156
- },
81
+ interface Props {
82
+ disabled?: boolean
83
+ emptyMessage?: string
84
+ errorMessage?: string
85
+ isClearable?: boolean
86
+ isInvalid?: boolean
87
+ isLoading?: boolean
88
+ label?: string
89
+ modelValue?: Record<string, unknown>[] | Record<string, unknown> | null
90
+ multiple?: boolean
91
+ name?: string
92
+ optionLabel?: string
93
+ options?: unknown[]
94
+ placeholder?: string
95
+ required?: boolean
96
+ trackBy?: string
97
+ }
98
+
99
+ const props = withDefaults(defineProps<Props>(), {
100
+ label: '',
101
+ required: false,
102
+ name: '',
103
+ placeholder: '',
104
+ isInvalid: false,
105
+ isClearable: false,
106
+ isLoading: false,
107
+ disabled: false,
108
+ multiple: false,
109
+ options: () => [],
110
+ optionLabel: 'name',
111
+ trackBy: 'id',
112
+ emptyMessage: 'No results found',
113
+ errorMessage: '',
114
+ modelValue: null,
157
115
  })
158
116
 
159
- const emit = defineEmits(['search', 'select', 'clear'])
117
+ interface Emits {
118
+ (e: 'search', query: string): void
119
+ (e: 'select', option: Record<string, unknown>): void
120
+ (e: 'clear'): void
121
+ (e: 'update:modelValue', value: Record<string, unknown> | Record<string, unknown>[] | null): void
122
+ }
123
+
124
+ const emit = defineEmits<Emits>()
160
125
 
161
126
  const selectModel = computed({
162
127
  get() {
@@ -183,7 +148,7 @@ const passThroughConfig = {
183
148
  loader: { class: 'cpMultiselect__hidden' },
184
149
  }
185
150
 
186
- const multiselect = ref(null)
151
+ const multiselect = ref<InstanceType<typeof AutoComplete> | null>(null)
187
152
 
188
153
  const isDropdownOpen = computed(() => multiselect.value?.overlayVisible)
189
154
 
@@ -203,29 +168,33 @@ const displayClearButton = computed(() => {
203
168
  return props.isClearable && !isEmpty(selectModel.value)
204
169
  })
205
170
 
206
- const handleSearch = (event) => emit('search', event.query)
171
+ const handleSearch = (event: { query: string }) => emit('search', event.query)
207
172
  const handleClear = () => (selectModel.value = null)
208
173
 
209
174
  const toggleDropdown = () => {
210
175
  if (isDropdownOpen.value) {
211
- multiselect.value.hide()
176
+ multiselect.value?.hide()
212
177
  } else {
213
- multiselect.value.show()
178
+ multiselect.value?.show()
214
179
  }
215
180
  }
216
181
 
217
- const handleUpdateModelValue = (value) => {
182
+ const handleUpdateModelValue = (value: Record<string, unknown> | null) => {
218
183
  // Autocomplete will set the model value to the query string if not blocked
219
184
  if (!value || typeof value === 'string') {
220
185
  return
221
186
  }
222
187
  }
223
188
 
224
- const overrideAlignOverlay = () => (multiselect.value.alignOverlay = alignOverlay)
189
+ const overrideAlignOverlay = () => {
190
+ if (multiselect.value) {
191
+ multiselect.value.alignOverlay = alignOverlay
192
+ }
193
+ }
225
194
 
226
195
  const alignOverlay = () => {
227
- const target = multiselect.value.$el
228
- if (!multiselect.value.overlay || !target) return
196
+ const target = multiselect.value?.$el
197
+ if (!multiselect.value?.overlay || !target) return
229
198
 
230
199
  multiselect.value.overlay.style.width = `${getOuterWidth(target)}px`
231
200
 
@@ -6,32 +6,24 @@
6
6
  </div>
7
7
  </template>
8
8
 
9
- <script setup>
9
+ <script setup lang="ts">
10
10
  import { computed } from 'vue'
11
11
 
12
- import { PartnerTypes, Sizes } from '@/utils/constants'
13
-
14
- import IconOta from '@/components/icons/IconOta.vue'
15
12
  import IconAirline from '@/components/icons/IconAirline.vue'
13
+ import IconOta from '@/components/icons/IconOta.vue'
16
14
  import IconSupplier from '@/components/icons/IconSupplier.vue'
17
15
  import IconThirdParty from '@/components/icons/IconThirdParty.vue'
18
16
 
19
- const props = defineProps({
20
- size: {
21
- type: String,
22
- required: false,
23
- default: Sizes.MD,
24
- validator(value) {
25
- return Object.values(Sizes).includes(value)
26
- },
27
- },
28
- type: {
29
- type: String,
30
- required: true,
31
- validator(value) {
32
- return Object.values(PartnerTypes).includes(value)
33
- },
34
- },
17
+ import { PartnerTypes, Sizes } from '@/constants'
18
+
19
+ interface Props {
20
+ size?: Sizes
21
+ type?: PartnerTypes
22
+ }
23
+
24
+ const props = withDefaults(defineProps<Props>(), {
25
+ size: Sizes.MD,
26
+ type: PartnerTypes.THIRDPARTY,
35
27
  })
36
28
 
37
29
  const dynamicBadgeProps = computed(() => {
@@ -28,67 +28,56 @@
28
28
  </div>
29
29
  </template>
30
30
 
31
- <script>
32
- import { capitalizeFirstLetter, randomString } from '@/helpers'
31
+ <script setup lang="ts">
32
+ import { ref } from 'vue'
33
+
33
34
  import { ToggleColors } from '@/constants'
35
+ import { capitalizeFirstLetter, randomString } from '@/helpers'
34
36
 
35
- export default {
36
- props: {
37
- modelValue: {
38
- type: String,
39
- default: '',
40
- required: true,
41
- },
42
- options: {
43
- type: Array,
44
- required: true,
45
- },
46
- groupName: {
47
- type: String,
48
- default: '',
49
- required: false,
50
- },
51
- color: {
52
- type: String,
53
- required: false,
54
- default: ToggleColors.BLUE,
55
- validator: (value) => Object.values(ToggleColors).includes(value),
56
- },
57
- autofocus: {
58
- type: Boolean,
59
- required: false,
60
- default: false,
61
- },
62
- },
63
- emits: ['update:modelValue'],
64
- data() {
65
- return {
66
- radioUniqueId: '',
67
- }
68
- },
69
- mounted() {
70
- this.radioUniqueId = randomString()
71
- },
72
- methods: {
73
- onChange(value) {
74
- this.$emit('update:modelValue', value)
75
- },
76
- getRadioId(index) {
77
- return `${this.radioUniqueId}${index}`
78
- },
79
- isActive(value) {
80
- return value === this.modelValue
81
- },
82
- computedClasses({ value, disabled }) {
83
- return [
84
- {
85
- 'cpRadio--isActive': this.isActive(value),
86
- 'cpRadio--isDisabled': disabled,
87
- },
88
- `cpRadio--is${capitalizeFirstLetter(this.color)}`,
89
- ]
37
+ interface RadioOption {
38
+ additionalData?: string
39
+ description?: string
40
+ disabled?: boolean
41
+ label: string
42
+ value: string
43
+ }
44
+
45
+ interface Props {
46
+ autofocus?: boolean
47
+ color?: string
48
+ groupName?: string
49
+ modelValue: string
50
+ options: RadioOption[]
51
+ }
52
+
53
+ interface Emits {
54
+ (e: 'update:modelValue', value: string): void
55
+ }
56
+
57
+ const props = withDefaults(defineProps<Props>(), {
58
+ groupName: '',
59
+ color: ToggleColors.BLUE,
60
+ autofocus: false,
61
+ })
62
+
63
+ const emit = defineEmits<Emits>()
64
+
65
+ const radioUniqueId = ref(randomString())
66
+
67
+ const onChange = (value: string): void => emit('update:modelValue', value)
68
+
69
+ const getRadioId = (index: number): string => `${radioUniqueId.value}${index}`
70
+
71
+ const isActive = (value: string): boolean => value === props.modelValue
72
+
73
+ const computedClasses = ({ value, disabled }: { disabled?: boolean; value: string }) => {
74
+ return [
75
+ {
76
+ 'cpRadio--isActive': isActive(value),
77
+ 'cpRadio--isDisabled': disabled,
90
78
  },
91
- },
79
+ `cpRadio--is${capitalizeFirstLetter(props.color)}`,
80
+ ]
92
81
  }
93
82
  </script>
94
83