@citizenplane/pimp 8.26.0 → 8.27.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.
- package/dist/{IconAccompaniedMinorEach-DDeSlaA_.js → IconAccompaniedMinorEach-BJYaPpW3.js} +1 -1
- package/dist/{IconAccompaniedMinorNone-BKs1gk1K.js → IconAccompaniedMinorNone-D1JR2Qpd.js} +1 -1
- package/dist/{IconAccompaniedMinorOne-CpL8FNve.js → IconAccompaniedMinorOne-BJ3jzEDZ.js} +1 -1
- package/dist/{IconAddReceipt-DLH3pqjA.js → IconAddReceipt-BX_va94f.js} +1 -1
- package/dist/{IconAirportTerminal-Cc4CU6MC.js → IconAirportTerminal-Dzr98nfc.js} +1 -1
- package/dist/{IconArrival-CdtUsRVo.js → IconArrival-Ced9HrJH.js} +1 -1
- package/dist/{IconBroadcast-QjMZtFA9.js → IconBroadcast-BYX44Wak.js} +1 -1
- package/dist/{IconCabinBag-xVC6mOQF.js → IconCabinBag-D1Qs952U.js} +1 -1
- package/dist/{IconCheckedBaggage-I_1h49TJ.js → IconCheckedBaggage-Q4_SQL9l.js} +1 -1
- package/dist/{IconCheckedBaggage20-CyPcsqrn.js → IconCheckedBaggage20-DVH1-A0V.js} +1 -1
- package/dist/{IconCheckedBaggage30-s5htbUIA.js → IconCheckedBaggage30-DYOAf-7Z.js} +1 -1
- package/dist/{IconChild-DL43kbm1.js → IconChild-BeCLAr8Y.js} +1 -1
- package/dist/{IconContact-FdhTr03q.js → IconContact-B3r39fyI.js} +1 -1
- package/dist/{IconDeparture-DNR3OGPD.js → IconDeparture-BflKZUiE.js} +1 -1
- package/dist/{IconDistribution-Cl8L6177.js → IconDistribution-CBxQ7UWb.js} +1 -1
- package/dist/{IconDistributionClosed-DBT6wR78.js → IconDistributionClosed-BWp_k24K.js} +1 -1
- package/dist/{IconDistributionExclusivePair-CkRG6yNV.js → IconDistributionExclusivePair-erLbcLps.js} +1 -1
- package/dist/{IconDistributionSided-D_wdvDNf.js → IconDistributionSided-y000n4qB.js} +1 -1
- package/dist/{IconDistributionSupplySided-C3VcE8Dw.js → IconDistributionSupplySided-7kCvGwnz.js} +1 -1
- package/dist/{IconDynamicContent-Ct1HRd3s.js → IconDynamicContent-SwBxkPMB.js} +1 -1
- package/dist/{IconFares-dIGVrtE4.js → IconFares-DTm0Q_RI.js} +1 -1
- package/dist/{IconFaresOutlined-bd8kT44f.js → IconFaresOutlined-BFMo_x9Q.js} +1 -1
- package/dist/{IconFemale-CMeYHrDy.js → IconFemale-Ma0KeaEM.js} +1 -1
- package/dist/{IconFindConversation-BdN2Yd3R.js → IconFindConversation-CpsDYPgD.js} +1 -1
- package/dist/{IconFire-obwuluyJ.js → IconFire-DECrDnLM.js} +1 -1
- package/dist/{IconFlight-B_6tJxB3.js → IconFlight-D5M0A0CM.js} +1 -1
- package/dist/{IconFlightReturn-BEO97PwR.js → IconFlightReturn-CTvqEFME.js} +1 -1
- package/dist/{IconHandHeart-hs0yFSEL.js → IconHandHeart-ChgdfXQa.js} +1 -1
- package/dist/{IconHistory-CT-jOMRt.js → IconHistory-DpIXDYI5.js} +1 -1
- package/dist/{IconHourGlass-CF940vmy.js → IconHourGlass-CIRkFUSM.js} +1 -1
- package/dist/{IconIdCard-DKkU58Ix.js → IconIdCard-UD5VZsUi.js} +1 -1
- package/dist/{IconInfant-DIUT-6_4.js → IconInfant-CmLUvWpO.js} +1 -1
- package/dist/{IconItinerary-D7mOGUmj.js → IconItinerary-CY8irele.js} +1 -1
- package/dist/{IconLeave-BExl4uyV.js → IconLeave-C3bpPz6L.js} +1 -1
- package/dist/{IconMale-eHGH5XBz.js → IconMale-x4xdulWB.js} +1 -1
- package/dist/{IconMultiSegments-KkrKiZrK.js → IconMultiSegments-BhTMfvhQ.js} +1 -1
- package/dist/{IconNoPassport-PJ2QqqoI.js → IconNoPassport-_Xm76k6b.js} +1 -1
- package/dist/{IconNoRefund-W47AQisu.js → IconNoRefund-B78s0oyF.js} +1 -1
- package/dist/{IconNotion-CCnhatKK.js → IconNotion-C22PTLTU.js} +1 -1
- package/dist/{IconOffline-3wunTEJG.js → IconOffline-BDzikWE9.js} +1 -1
- package/dist/{IconOneWay-BQ5K41Bu.js → IconOneWay-DlTVxokv.js} +2 -2
- package/dist/{IconPaid-zwDwWzF8.js → IconPaid-DmGERe85.js} +1 -1
- package/dist/{IconPassport-IxhNLS8P.js → IconPassport-6VOlXjxJ.js} +1 -1
- package/dist/{IconPayout-BNSON3dj.js → IconPayout-abr6BXCd.js} +1 -1
- package/dist/{IconReceipt-DOosYtgi.js → IconReceipt-BnTaihcq.js} +1 -1
- package/dist/{IconRecurrence-B8i5kO2Q.js → IconRecurrence-C5TPG2ht.js} +1 -1
- package/dist/{IconRefund-DkjF9lEI.js → IconRefund-Ysv8pyMJ.js} +1 -1
- package/dist/{IconRoundTrip-BZvhS65z.js → IconRoundTrip-CIVDw8LK.js} +1 -1
- package/dist/{IconRouteNoStop-CeSlfnpx.js → IconRouteNoStop-DQrq4gW5.js} +1 -1
- package/dist/{IconRouteOneStop-aP1Mj-Bv.js → IconRouteOneStop-pzisj4i4.js} +1 -1
- package/dist/{IconScheduleChange-QQ4AMAMI.js → IconScheduleChange-BONs1AAT.js} +1 -1
- package/dist/{IconSeatEmpty-DgVBD165.js → IconSeatEmpty-CHij3aGA.js} +1 -1
- package/dist/{IconSeatSold-BGBwNZUa.js → IconSeatSold-QspS_zCh.js} +1 -1
- package/dist/{IconSeatTotal-Dq9uXccZ.js → IconSeatTotal-DTZ1TcAX.js} +1 -1
- package/dist/{IconTemplate-BgruEhjI.js → IconTemplate-BDmmr-9L.js} +1 -1
- package/dist/{IconTicket-BTaYnuPt.js → IconTicket--vVn61Ey.js} +1 -1
- package/dist/{IconTimer-CyJzne5T.js → IconTimer-CspKpwqZ.js} +1 -1
- package/dist/{IconTrafficControl-BeQtpwhK.js → IconTrafficControl-DBamcJNe.js} +1 -1
- package/dist/{index-B8RNa4cx.js → index-C3oHnZQk.js} +9152 -10064
- package/dist/pimp.es.js +1 -1
- package/dist/pimp.umd.js +17 -17
- package/dist/style.css +1 -1
- package/package.json +2 -1
- package/src/components/atomic-elements/CpAirlineLogo.vue +9 -10
- package/src/components/atomic-elements/CpBadge.vue +33 -41
- package/src/components/atomic-elements/CpDialog.vue +14 -9
- package/src/components/atomic-elements/CpPartnerBadge.vue +12 -20
- package/src/components/atomic-elements/CpTooltip.vue +12 -11
- package/src/components/buttons/CpButton.vue +63 -104
- package/src/components/core/BaseInputLabel.vue +9 -15
- package/src/components/core/BaseSelectClearButton.vue +1 -1
- package/src/components/date-pickers/CpCalendar.vue +154 -153
- package/src/components/date-pickers/CpDate.vue +202 -212
- package/src/components/date-pickers/CpDatepicker.vue +112 -138
- package/src/components/feedback-indicators/CpAlert.vue +16 -27
- package/src/components/feedback-indicators/CpLoader.vue +7 -8
- package/src/components/feedback-indicators/CpToaster.vue +197 -192
- package/src/components/helpers-utilities/TransitionExpand.vue +31 -33
- package/src/components/icons/IconOneWay.vue +1 -1
- package/src/components/index.ts +28 -40
- package/src/components/inputs/CpInput.vue +40 -57
- package/src/components/inputs/CpTextarea.vue +30 -50
- package/src/components/lists-and-table/CpTable.vue +165 -114
- package/src/components/lists-and-table/CpTableEmptyState.vue +5 -8
- package/src/components/selects/CpMultiselect.vue +58 -89
- package/src/components/selects/CpSelect.vue +70 -90
- package/src/components/selects/CpSelectMenu.vue +94 -96
- package/src/components/toggles/CpCheckbox.vue +45 -54
- package/src/components/toggles/CpRadio.vue +47 -58
- package/src/components/toggles/CpSwitch.vue +51 -67
- package/src/components/typography/CpHeading.vue +11 -31
- package/src/components/visual/CpIcon.vue +2 -1
- package/src/constants/{src/CpCustomIcons.ts → CpCustomIcons.ts} +1 -1
- package/src/constants/CpTableConfig.ts +12 -0
- package/src/constants/Heading.ts +8 -0
- package/src/{utils/constants/src/Intent.js → constants/Intent.ts} +1 -1
- package/src/constants/PartnerTypes.ts +6 -0
- package/src/constants/Position.ts +10 -0
- package/src/constants/Sizes.ts +5 -0
- package/src/constants/colors/Colors.ts +10 -0
- package/src/constants/colors/ToggleColors.ts +6 -0
- package/src/constants/index.ts +10 -5
- package/src/directives/ClickOutside.ts +17 -0
- package/src/directives/{ResizeSelect.js → ResizeSelect.ts} +3 -3
- package/src/helpers/{dom.js → dom.ts} +13 -9
- package/src/helpers/{index.js → index.ts} +13 -3
- package/src/helpers/object.ts +9 -0
- package/src/helpers/string/src/camelize.ts +6 -0
- package/src/helpers/string/src/{decamelize.js → decamelize.ts} +1 -1
- package/src/libs/CoreDatepicker.vue +4 -4
- package/src/plugins/toaster.ts +71 -0
- package/src/stories/BaseInputLabel.stories.ts +1 -0
- package/src/stories/CpAlert.stories.ts +1 -0
- package/src/stories/CpBadge.stories.ts +18 -0
- package/src/stories/CpCheckbox.stories.ts +3 -1
- package/src/stories/CpDate.stories.ts +3 -1
- package/src/stories/CpDatepicker.stories.ts +3 -1
- package/src/stories/CpDialog.stories.ts +2 -1
- package/src/stories/CpHeading.stories.ts +1 -0
- package/src/stories/CpIcon.stories.ts +2 -0
- package/src/stories/CpInput.stories.ts +3 -1
- package/src/stories/CpLoader.stories.ts +1 -0
- package/src/stories/CpMultiselect.stories.ts +2 -1
- package/src/stories/CpPartnerBadge.stories.ts +1 -1
- package/src/stories/CpRadio.stories.ts +3 -1
- package/src/stories/CpSelect.stories.ts +3 -1
- package/src/stories/CpSelectMenu.stories.ts +3 -1
- package/src/stories/CpSwitch.stories.ts +3 -1
- package/src/stories/CpTable.stories.ts +8 -1
- package/src/stories/CpTableEmptyState.stories.ts +1 -0
- package/src/stories/CpTextarea.stories.ts +3 -1
- package/src/stories/CpToaster.stories.ts +1 -0
- package/src/stories/CpTooltip.stories.ts +1 -0
- package/src/stories/TransitionExpand.stories.ts +3 -1
- package/src/types/luxon.d.ts +1 -0
- package/src/vendors/ff-polyfill.ts +38 -0
- package/vitest.workspace.js +1 -3
- package/src/constants/src/CpTableConfig.ts +0 -14
- package/src/constants/src/Position.ts +0 -10
- package/src/constants/src/colors/Colors.ts +0 -10
- package/src/constants/src/colors/ToggleColors.ts +0 -6
- package/src/directives/ClickOutside.js +0 -13
- package/src/helpers/object.js +0 -9
- package/src/helpers/string/src/camelize.js +0 -6
- package/src/plugins/toaster.js +0 -61
- package/src/utils/constants/index.js +0 -3
- package/src/utils/constants/src/PartnerTypes.js +0 -6
- package/src/utils/constants/src/Sizes.js +0 -5
- package/src/vendors/ff-polyfill.js +0 -36
- /package/src/helpers/string/{index.js → index.ts} +0 -0
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
class="cpSelect__inner"
|
|
16
16
|
@input="handleChange"
|
|
17
17
|
>
|
|
18
|
-
<option :disabled="hideDefaultValue
|
|
18
|
+
<option :disabled="hideDefaultValue" value="">{{ defaultValue }}</option>
|
|
19
19
|
<option v-for="(option, index) in options" :key="index" :value="option.value">{{ option.label }}</option>
|
|
20
20
|
</select>
|
|
21
21
|
</div>
|
|
@@ -32,100 +32,80 @@
|
|
|
32
32
|
</div>
|
|
33
33
|
</template>
|
|
34
34
|
|
|
35
|
-
<script>
|
|
36
|
-
import {
|
|
35
|
+
<script setup lang="ts">
|
|
36
|
+
import { ref, computed, onMounted } from 'vue'
|
|
37
37
|
|
|
38
38
|
import BaseInputLabel from '@/components/core/BaseInputLabel.vue'
|
|
39
39
|
import TransitionExpand from '@/components/helpers-utilities/TransitionExpand.vue'
|
|
40
40
|
|
|
41
|
-
import { capitalizeFirstLetter } from '@/helpers'
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
},
|
|
66
|
-
options: {
|
|
67
|
-
type: Array,
|
|
68
|
-
required: true,
|
|
69
|
-
},
|
|
70
|
-
name: {
|
|
71
|
-
type: String,
|
|
72
|
-
default: null,
|
|
73
|
-
},
|
|
74
|
-
required: {
|
|
75
|
-
type: Boolean,
|
|
76
|
-
default: null,
|
|
77
|
-
},
|
|
78
|
-
disabled: {
|
|
79
|
-
type: Boolean,
|
|
80
|
-
default: null,
|
|
81
|
-
},
|
|
82
|
-
autocomplete: {
|
|
83
|
-
type: String,
|
|
84
|
-
default: 'on',
|
|
85
|
-
},
|
|
86
|
-
isInvalid: {
|
|
87
|
-
type: Boolean,
|
|
88
|
-
default: false,
|
|
89
|
-
},
|
|
90
|
-
errorMessage: {
|
|
91
|
-
type: String,
|
|
92
|
-
default: '',
|
|
93
|
-
},
|
|
94
|
-
isLarge: {
|
|
95
|
-
type: Boolean,
|
|
96
|
-
default: false,
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
emits: ['update:modelValue'],
|
|
100
|
-
data() {
|
|
101
|
-
return {
|
|
102
|
-
selectReferenceId: '',
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
computed: {
|
|
106
|
-
capitalizedLabel() {
|
|
107
|
-
return capitalizeFirstLetter(this.label)
|
|
108
|
-
},
|
|
109
|
-
dynamicClasses() {
|
|
110
|
-
return {
|
|
111
|
-
'cpSelect--isInvalid': this.isInvalid,
|
|
112
|
-
'cpSelect--isDisabled': this.disabled,
|
|
113
|
-
'cpSelect--isLarge': this.isLarge,
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
displayErrorMessage() {
|
|
117
|
-
return this.isInvalid && this.errorMessage.length
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
mounted() {
|
|
121
|
-
this.selectReferenceId = randomString()
|
|
122
|
-
},
|
|
123
|
-
methods: {
|
|
124
|
-
handleChange(e) {
|
|
125
|
-
this.$emit('update:modelValue', e.target.value)
|
|
126
|
-
},
|
|
127
|
-
},
|
|
41
|
+
import { randomString, capitalizeFirstLetter } from '@/helpers'
|
|
42
|
+
|
|
43
|
+
interface SelectOption {
|
|
44
|
+
label: string
|
|
45
|
+
value: string | number
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface Props {
|
|
49
|
+
autocomplete?: string
|
|
50
|
+
defaultValue?: string
|
|
51
|
+
disabled?: boolean
|
|
52
|
+
errorMessage?: string
|
|
53
|
+
hideDefaultValue?: boolean
|
|
54
|
+
isInvalid?: boolean
|
|
55
|
+
isLarge?: boolean
|
|
56
|
+
label?: string
|
|
57
|
+
modelValue?: string | number
|
|
58
|
+
name?: string
|
|
59
|
+
options: SelectOption[]
|
|
60
|
+
required?: boolean
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
interface Emits {
|
|
64
|
+
(e: 'update:modelValue', value: string): void
|
|
128
65
|
}
|
|
66
|
+
|
|
67
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
68
|
+
label: '',
|
|
69
|
+
modelValue: '',
|
|
70
|
+
hideDefaultValue: false,
|
|
71
|
+
defaultValue: 'Select an option',
|
|
72
|
+
name: undefined,
|
|
73
|
+
required: false,
|
|
74
|
+
disabled: false,
|
|
75
|
+
autocomplete: 'on',
|
|
76
|
+
isInvalid: false,
|
|
77
|
+
errorMessage: '',
|
|
78
|
+
isLarge: false,
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
const emit = defineEmits<Emits>()
|
|
82
|
+
|
|
83
|
+
const selectReferenceId = ref('')
|
|
84
|
+
|
|
85
|
+
const capitalizedLabel = computed(() => {
|
|
86
|
+
return capitalizeFirstLetter(props.label)
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
const dynamicClasses = computed(() => {
|
|
90
|
+
return {
|
|
91
|
+
'cpSelect--isInvalid': props.isInvalid,
|
|
92
|
+
'cpSelect--isDisabled': props.disabled,
|
|
93
|
+
'cpSelect--isLarge': props.isLarge,
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
const displayErrorMessage = computed(() => {
|
|
98
|
+
return props.isInvalid && props.errorMessage.length
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
const handleChange = (e: Event): void => {
|
|
102
|
+
const target = e.target as HTMLSelectElement
|
|
103
|
+
emit('update:modelValue', target.value)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
onMounted(() => {
|
|
107
|
+
selectReferenceId.value = randomString()
|
|
108
|
+
})
|
|
129
109
|
</script>
|
|
130
110
|
|
|
131
111
|
<style lang="scss">
|
|
@@ -46,106 +46,104 @@
|
|
|
46
46
|
</div>
|
|
47
47
|
</template>
|
|
48
48
|
|
|
49
|
-
<script>
|
|
49
|
+
<script setup lang="ts">
|
|
50
50
|
import { animate } from 'animejs'
|
|
51
|
+
import { ref, computed, nextTick } from 'vue'
|
|
51
52
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
default: () => [],
|
|
57
|
-
required: true,
|
|
58
|
-
},
|
|
59
|
-
selectedValue: {
|
|
60
|
-
type: Object,
|
|
61
|
-
default: () => {},
|
|
62
|
-
required: true,
|
|
63
|
-
},
|
|
64
|
-
isMultiSelect: {
|
|
65
|
-
type: Boolean,
|
|
66
|
-
default: false,
|
|
67
|
-
required: false,
|
|
68
|
-
},
|
|
69
|
-
hasFilter: {
|
|
70
|
-
type: Boolean,
|
|
71
|
-
default: false,
|
|
72
|
-
required: false,
|
|
73
|
-
},
|
|
74
|
-
dropdownTitle: {
|
|
75
|
-
type: String,
|
|
76
|
-
default: 'Select value',
|
|
77
|
-
required: false,
|
|
78
|
-
},
|
|
79
|
-
dropdownFilterPlaceholder: {
|
|
80
|
-
type: String,
|
|
81
|
-
default: 'Filter...',
|
|
82
|
-
required: false,
|
|
83
|
-
},
|
|
84
|
-
dropdownEmptyViewPlaceholder: {
|
|
85
|
-
type: String,
|
|
86
|
-
default: 'No option found',
|
|
87
|
-
required: false,
|
|
88
|
-
},
|
|
89
|
-
closeOnSelect: {
|
|
90
|
-
type: Boolean,
|
|
91
|
-
default: true,
|
|
92
|
-
required: false,
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
emits: ['update:selectedValue', 'on-close', 'on-filter-change'],
|
|
96
|
-
data() {
|
|
97
|
-
return {
|
|
98
|
-
isDropdownOpen: false,
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
computed: {
|
|
102
|
-
inputType() {
|
|
103
|
-
return (this.isMultiSelect && 'checkbox') || 'radio'
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
methods: {
|
|
107
|
-
enter() {
|
|
108
|
-
animate(this.$refs.dropdownRef, {
|
|
109
|
-
scale: [0.8, 1],
|
|
110
|
-
opacity: [0, 1],
|
|
111
|
-
duration: 200,
|
|
112
|
-
ease: 'cubicBezier(0.175, 0.885, 0.32, 1.175)',
|
|
113
|
-
})
|
|
114
|
-
},
|
|
115
|
-
toggleDropdown() {
|
|
116
|
-
this.isDropdownOpen = !this.isDropdownOpen
|
|
117
|
-
|
|
118
|
-
if (this.isDropdownOpen && this.hasFilter) {
|
|
119
|
-
this.$nextTick(() => this.$refs.dropdownFilterRef.focus())
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
closeDropdown() {
|
|
123
|
-
if (!this.isDropdownOpen) {
|
|
124
|
-
return
|
|
125
|
-
}
|
|
53
|
+
interface SelectValue {
|
|
54
|
+
label: string
|
|
55
|
+
value: string
|
|
56
|
+
}
|
|
126
57
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
58
|
+
interface Props {
|
|
59
|
+
closeOnSelect?: boolean
|
|
60
|
+
dropdownEmptyViewPlaceholder?: string
|
|
61
|
+
dropdownFilterPlaceholder?: string
|
|
62
|
+
dropdownTitle?: string
|
|
63
|
+
hasFilter?: boolean
|
|
64
|
+
isMultiSelect?: boolean
|
|
65
|
+
selectedValue: SelectValue
|
|
66
|
+
values: SelectValue[]
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface Emits {
|
|
70
|
+
(e: 'update:selectedValue', value: SelectValue): void
|
|
71
|
+
(e: 'onClose'): void
|
|
72
|
+
(e: 'onFilterChange', value: string): void
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
76
|
+
isMultiSelect: false,
|
|
77
|
+
hasFilter: false,
|
|
78
|
+
dropdownTitle: 'Select value',
|
|
79
|
+
dropdownFilterPlaceholder: 'Filter...',
|
|
80
|
+
dropdownEmptyViewPlaceholder: 'No option found',
|
|
81
|
+
closeOnSelect: true,
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
const emit = defineEmits<Emits>()
|
|
85
|
+
|
|
86
|
+
const isDropdownOpen = ref(false)
|
|
87
|
+
const dropdownRef = ref<HTMLElement>()
|
|
88
|
+
const dropdownFilterRef = ref<HTMLInputElement>()
|
|
89
|
+
|
|
90
|
+
const inputType = computed(() => {
|
|
91
|
+
return props.isMultiSelect ? 'checkbox' : 'radio'
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
const enter = (): void => {
|
|
95
|
+
if (dropdownRef.value) {
|
|
96
|
+
animate(dropdownRef.value, {
|
|
97
|
+
scale: [0.8, 1],
|
|
98
|
+
opacity: [0, 1],
|
|
99
|
+
duration: 200,
|
|
100
|
+
ease: 'cubicBezier(0.175, 0.885, 0.32, 1.175)',
|
|
101
|
+
})
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const toggleDropdown = (): void => {
|
|
106
|
+
isDropdownOpen.value = !isDropdownOpen.value
|
|
107
|
+
|
|
108
|
+
if (isDropdownOpen.value && props.hasFilter) {
|
|
109
|
+
nextTick(() => {
|
|
110
|
+
if (dropdownFilterRef.value) {
|
|
111
|
+
dropdownFilterRef.value.focus()
|
|
137
112
|
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
113
|
+
})
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const closeDropdown = (): void => {
|
|
118
|
+
if (!isDropdownOpen.value) {
|
|
119
|
+
return
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
isDropdownOpen.value = false
|
|
123
|
+
resetInputValue()
|
|
124
|
+
emit('onClose')
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const onChange = (value: SelectValue): void => {
|
|
128
|
+
if (value.value !== props.selectedValue.value) {
|
|
129
|
+
emit('update:selectedValue', value)
|
|
130
|
+
}
|
|
131
|
+
if (props.closeOnSelect) {
|
|
132
|
+
closeDropdown()
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const updateFilterValue = (event: Event): void => {
|
|
137
|
+
const target = event.target as HTMLInputElement
|
|
138
|
+
emit('onFilterChange', target.value)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const resetInputValue = (): void => {
|
|
142
|
+
emit('onFilterChange', '')
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const isSelectedValue = (value: string): boolean => {
|
|
146
|
+
return value === props.selectedValue.value
|
|
149
147
|
}
|
|
150
148
|
</script>
|
|
151
149
|
|
|
@@ -26,63 +26,36 @@
|
|
|
26
26
|
</label>
|
|
27
27
|
</template>
|
|
28
28
|
|
|
29
|
-
<script setup>
|
|
29
|
+
<script setup lang="ts">
|
|
30
30
|
import { computed, ref, onMounted, useSlots } from 'vue'
|
|
31
31
|
|
|
32
|
-
import { capitalizeFirstLetter, randomString } from '@/helpers'
|
|
33
32
|
import { ToggleColors } from '@/constants'
|
|
33
|
+
import { capitalizeFirstLetter, randomString } from '@/helpers'
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
required: false,
|
|
60
|
-
},
|
|
61
|
-
capitalizeLabel: {
|
|
62
|
-
type: Boolean,
|
|
63
|
-
default: true,
|
|
64
|
-
},
|
|
65
|
-
color: {
|
|
66
|
-
type: String,
|
|
67
|
-
required: false,
|
|
68
|
-
default: ToggleColors.BLUE,
|
|
69
|
-
validator: (value) => Object.values(ToggleColors).includes(value),
|
|
70
|
-
},
|
|
71
|
-
reverseLabel: {
|
|
72
|
-
type: Boolean,
|
|
73
|
-
required: false,
|
|
74
|
-
default: false,
|
|
75
|
-
},
|
|
76
|
-
autofocus: {
|
|
77
|
-
type: Boolean,
|
|
78
|
-
required: false,
|
|
79
|
-
default: false,
|
|
80
|
-
},
|
|
81
|
-
helper: {
|
|
82
|
-
type: String,
|
|
83
|
-
required: false,
|
|
84
|
-
default: '',
|
|
85
|
-
},
|
|
35
|
+
interface Props {
|
|
36
|
+
autofocus?: boolean
|
|
37
|
+
capitalizeLabel?: boolean
|
|
38
|
+
checkboxLabel?: string
|
|
39
|
+
checkboxValue?: string | number
|
|
40
|
+
color?: string
|
|
41
|
+
groupName?: string
|
|
42
|
+
helper?: string
|
|
43
|
+
isDisabled?: boolean
|
|
44
|
+
modelValue?: boolean | unknown[]
|
|
45
|
+
reverseLabel?: boolean
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
49
|
+
modelValue: false,
|
|
50
|
+
checkboxValue: '',
|
|
51
|
+
checkboxLabel: '',
|
|
52
|
+
isDisabled: false,
|
|
53
|
+
groupName: '',
|
|
54
|
+
capitalizeLabel: true,
|
|
55
|
+
color: ToggleColors.BLUE,
|
|
56
|
+
reverseLabel: false,
|
|
57
|
+
autofocus: false,
|
|
58
|
+
helper: '',
|
|
86
59
|
})
|
|
87
60
|
|
|
88
61
|
const emit = defineEmits(['update:modelValue'])
|
|
@@ -92,6 +65,9 @@ const checkboxUniqueId = ref('')
|
|
|
92
65
|
|
|
93
66
|
const isChecked = computed({
|
|
94
67
|
get() {
|
|
68
|
+
if (Array.isArray(props.modelValue)) {
|
|
69
|
+
return props.modelValue.includes(props.checkboxValue)
|
|
70
|
+
}
|
|
95
71
|
return props.modelValue
|
|
96
72
|
},
|
|
97
73
|
set(newValue) {
|
|
@@ -123,7 +99,22 @@ const labelComputedClasses = computed(() => {
|
|
|
123
99
|
|
|
124
100
|
onMounted(() => (checkboxUniqueId.value = randomString()))
|
|
125
101
|
|
|
126
|
-
const onChange = () =>
|
|
102
|
+
const onChange = (value: string | number) => {
|
|
103
|
+
if (Array.isArray(props.modelValue)) {
|
|
104
|
+
const currentValues = [...props.modelValue]
|
|
105
|
+
const valueIndex = currentValues.indexOf(value)
|
|
106
|
+
|
|
107
|
+
if (valueIndex > -1) {
|
|
108
|
+
currentValues.splice(valueIndex, 1)
|
|
109
|
+
} else {
|
|
110
|
+
currentValues.push(value)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
emit('update:modelValue', currentValues)
|
|
114
|
+
} else {
|
|
115
|
+
emit('update:modelValue', !props.modelValue)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
127
118
|
</script>
|
|
128
119
|
|
|
129
120
|
<style lang="scss">
|
|
@@ -28,67 +28,56 @@
|
|
|
28
28
|
</div>
|
|
29
29
|
</template>
|
|
30
30
|
|
|
31
|
-
<script>
|
|
32
|
-
import {
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
|