@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.
- package/dist/{IconAccompaniedMinorEach-CUq3oXbX.js → IconAccompaniedMinorEach-MkIJAypb.js} +1 -1
- package/dist/{IconAccompaniedMinorNone-nZ4eSfTj.js → IconAccompaniedMinorNone-DMb-bSCG.js} +1 -1
- package/dist/{IconAccompaniedMinorOne-CDMqq14b.js → IconAccompaniedMinorOne-C9ORHm66.js} +1 -1
- package/dist/{IconAddReceipt-DRpGiWBU.js → IconAddReceipt-CeJlKuX2.js} +1 -1
- package/dist/{IconAirportTerminal-8k-3lKjb.js → IconAirportTerminal-D3p4CRpN.js} +1 -1
- package/dist/{IconArrival-m6HnOVje.js → IconArrival-C3oPAqgQ.js} +1 -1
- package/dist/IconBaggageCabinNone-valcCKfd.js +22 -0
- package/dist/IconBaggageCheckedNone-oq4yx5cO.js +22 -0
- package/dist/IconBaggagePersonalNone-BovIoK0M.js +20 -0
- package/dist/{IconBroadcast-B13UworG.js → IconBroadcast-CqdgVQaO.js} +1 -1
- package/dist/{IconCabinBag-CNnzHz2B.js → IconCabinBag-CMrtn-s6.js} +1 -1
- package/dist/IconCalendar-DmUZ-Du1.js +30 -0
- package/dist/IconCalendarDelay-DHaiharm.js +22 -0
- package/dist/{IconCheckedBaggage-CkxUDHe9.js → IconCheckedBaggage-OeOjHxe7.js} +1 -1
- package/dist/{IconCheckedBaggage20-DEtphLSa.js → IconCheckedBaggage20-CXeWuJgc.js} +1 -1
- package/dist/{IconCheckedBaggage30-CmAddx5h.js → IconCheckedBaggage30-Cartaaei.js} +1 -1
- package/dist/{IconChild-OReHyUco.js → IconChild-ChjkS7Gd.js} +1 -1
- package/dist/{IconContact-D2N23RZ5.js → IconContact-CtOxYQIs.js} +1 -1
- package/dist/{IconDeparture-D10LaXRX.js → IconDeparture-DJxClL94.js} +1 -1
- package/dist/{IconDistribution-SpPiru9I.js → IconDistribution-BmCLzb9p.js} +1 -1
- package/dist/{IconDistributionClosed-Bzqe7nju.js → IconDistributionClosed-BMjqoyt9.js} +1 -1
- package/dist/{IconDistributionExclusivePair-CjPM-_R1.js → IconDistributionExclusivePair-D71kgwyk.js} +1 -1
- package/dist/{IconDistributionSided-DehjCN0D.js → IconDistributionSided-Du56cPXR.js} +1 -1
- package/dist/{IconDistributionSupplySided-DWCyXqd1.js → IconDistributionSupplySided-BY9ACIGQ.js} +1 -1
- package/dist/{IconDynamicContent-BvzbgXvW.js → IconDynamicContent-DoYbB86x.js} +1 -1
- package/dist/IconEndDate-CVABdl-P.js +22 -0
- package/dist/{IconFares-zARDpPNl.js → IconFares-BXnx8WJa.js} +1 -1
- package/dist/{IconFaresOutlined-DLFV8nwg.js → IconFaresOutlined-CjJhZUKX.js} +1 -1
- package/dist/{IconFemale-Ba4uoI-S.js → IconFemale-D4lMoNKt.js} +1 -1
- package/dist/{IconFindConversation-d0pP3wG9.js → IconFindConversation-CYdB5hW8.js} +1 -1
- package/dist/{IconFire-CXzWKoMB.js → IconFire-Bh3vQ1A3.js} +1 -1
- package/dist/{IconFlight-Cof8M5dO.js → IconFlight-RyDIRwoI.js} +1 -1
- package/dist/{IconFlightReturn-CA9iGMcW.js → IconFlightReturn-DN7K5zxX.js} +1 -1
- package/dist/IconFlightSchedule-DAX_cnvF.js +28 -0
- package/dist/{IconHandHeart-CCLKnMOm.js → IconHandHeart-C5jxr29k.js} +1 -1
- package/dist/{IconHistory-DI6WD_3J.js → IconHistory-CuJwcjfY.js} +1 -1
- package/dist/{IconHourGlass-BorNLEca.js → IconHourGlass-DyrZPbXz.js} +1 -1
- package/dist/{IconIdCard-DhbhBkul.js → IconIdCard-lBDLYRPq.js} +1 -1
- package/dist/{IconInfant-D4EztT9g.js → IconInfant-E19ozPuk.js} +1 -1
- package/dist/{IconItinerary-Bhj_lgG2.js → IconItinerary-5AEG0f9f.js} +1 -1
- package/dist/{IconLeave-BvpY7gdD.js → IconLeave-XuFJRd-0.js} +1 -1
- package/dist/{IconMale-RMd_9ZSg.js → IconMale-R2ZgQj0s.js} +1 -1
- package/dist/{IconMultiSegments-DROUj0t5.js → IconMultiSegments-DfiqdUEm.js} +1 -1
- package/dist/IconNoPassport-h-6DjTcc.js +22 -0
- package/dist/{IconNoRefund-yNAZr7uX.js → IconNoRefund-C5R_Zxke.js} +1 -1
- package/dist/IconNoSeat-C-XnWQk8.js +23 -0
- package/dist/{IconNotion-CpZhGILz.js → IconNotion-pdx45QBU.js} +1 -1
- package/dist/{IconOffline-Bf1mw_1N.js → IconOffline-EG6mJ-Fs.js} +1 -1
- package/dist/{IconOneWay-6oGoLo57.js → IconOneWay-CX6CckSB.js} +2 -2
- package/dist/{IconPaid-B3dvioAR.js → IconPaid-BJhBGPy9.js} +1 -1
- package/dist/IconPassport-C6THdLYf.js +37 -0
- package/dist/{IconPayout-b3TcXwjA.js → IconPayout-MS-qRRR0.js} +1 -1
- package/dist/IconPlug-yYpQdJgj.js +22 -0
- package/dist/IconPlugOff-DSGcBog-.js +23 -0
- package/dist/{IconReceipt-Dh454941.js → IconReceipt-ChU6nBry.js} +1 -1
- package/dist/IconRecurrence-DtwCmoXo.js +22 -0
- package/dist/{IconRefund-D-FNjukU.js → IconRefund-D1wQXsZj.js} +1 -1
- package/dist/{IconRoundTrip-BqVPrNwg.js → IconRoundTrip-DhPU15r6.js} +1 -1
- package/dist/{IconRouteNoStop-CZ_QeOIY.js → IconRouteNoStop-C5b0NI9V.js} +1 -1
- package/dist/{IconRouteOneStop-DGpLAQmQ.js → IconRouteOneStop-CDL4AJoN.js} +1 -1
- package/dist/IconScheduleChange-CasvbB9p.js +22 -0
- package/dist/{IconSeatEmpty-BwyVwYQZ.js → IconSeatEmpty-CUDMQzqk.js} +1 -1
- package/dist/{IconSeatSold-B_SNoTs-.js → IconSeatSold-mwtkmlhT.js} +1 -1
- package/dist/{IconSeatTotal-DUEF7k6I.js → IconSeatTotal-BPegCOjA.js} +1 -1
- package/dist/IconStartDate-DoPJpEly.js +22 -0
- package/dist/{IconTemplate-D1ACYaHI.js → IconTemplate-CQH8r3U7.js} +1 -1
- package/dist/{IconTicket-5Z4b83BP.js → IconTicket-mONYGHBg.js} +1 -1
- package/dist/{IconTimer-DbcddAPo.js → IconTimer-BxR1ymxu.js} +1 -1
- package/dist/{IconTrafficControl-CEzhRpZt.js → IconTrafficControl-AcQHu-Dm.js} +1 -1
- package/dist/{index-DbgX3-2I.js → index-CjeXy6n3.js} +17600 -18506
- package/dist/pimp.es.js +1 -1
- package/dist/pimp.umd.js +23 -23
- package/dist/style.css +1 -1
- package/package.json +2 -1
- package/src/components/{core/BaseInputLabel.vue → BaseInputLabel.vue} +9 -15
- package/src/components/{core/BaseSelectClearButton.vue → BaseSelectClearButton.vue} +2 -2
- package/src/components/{atomic-elements/CpAirlineLogo.vue → CpAirlineLogo.vue} +9 -10
- package/src/components/{feedback-indicators/CpAlert.vue → CpAlert.vue} +16 -27
- package/src/components/{atomic-elements/CpBadge.vue → CpBadge.vue} +27 -44
- package/src/components/{buttons/CpButton.vue → CpButton.vue} +63 -104
- package/src/components/{date-pickers/CpCalendar.vue → CpCalendar.vue} +157 -156
- package/src/components/{toggles/CpCheckbox.vue → CpCheckbox.vue} +45 -54
- package/src/components/{date-pickers/CpDate.vue → CpDate.vue} +202 -212
- package/src/components/CpDatepicker.vue +203 -0
- package/src/components/{atomic-elements/CpDialog.vue → CpDialog.vue} +14 -9
- package/src/components/{typography/CpHeading.vue → CpHeading.vue} +11 -31
- package/src/components/{visual/CpIcon.vue → CpIcon.vue} +2 -1
- package/src/components/{inputs/CpInput.vue → CpInput.vue} +41 -58
- package/src/components/{feedback-indicators/CpLoader.vue → CpLoader.vue} +7 -8
- package/src/components/{selects/CpMultiselect.vue → CpMultiselect.vue} +60 -91
- package/src/components/{atomic-elements/CpPartnerBadge.vue → CpPartnerBadge.vue} +12 -20
- package/src/components/{toggles/CpRadio.vue → CpRadio.vue} +47 -58
- package/src/components/{selects/CpSelect.vue → CpSelect.vue} +74 -94
- package/src/components/{selects/CpSelectMenu.vue → CpSelectMenu.vue} +94 -96
- package/src/components/{toggles/CpSwitch.vue → CpSwitch.vue} +51 -67
- package/src/components/{lists-and-table/CpTable.vue → CpTable.vue} +159 -113
- package/src/components/{lists-and-table/CpTableEmptyState.vue → CpTableEmptyState.vue} +5 -8
- package/src/components/{inputs/CpTextarea.vue → CpTextarea.vue} +32 -52
- package/src/components/CpToaster.vue +377 -0
- package/src/components/{atomic-elements/CpTooltip.vue → CpTooltip.vue} +12 -11
- package/src/components/TransitionExpand.vue +70 -0
- package/src/components/icons/IconBaggageCabinNone.vue +24 -0
- package/src/components/icons/IconBaggageCheckedNone.vue +25 -0
- package/src/components/icons/IconBaggagePersonalNone.vue +33 -0
- package/src/components/icons/IconCalendar.vue +17 -0
- package/src/components/icons/IconCalendarDelay.vue +21 -0
- package/src/components/icons/IconEndDate.vue +19 -0
- package/src/components/icons/IconFlightSchedule.vue +23 -0
- package/src/components/icons/IconNoPassport.vue +23 -24
- package/src/components/icons/IconNoSeat.vue +18 -0
- package/src/components/icons/IconOneWay.vue +1 -1
- package/src/components/icons/IconPassport.vue +15 -22
- package/src/components/icons/IconPlug.vue +17 -0
- package/src/components/icons/IconPlugOff.vue +18 -0
- package/src/components/icons/IconRecurrence.vue +17 -8
- package/src/components/icons/IconScheduleChange.vue +17 -26
- package/src/components/icons/IconStartDate.vue +19 -0
- package/src/components/index.ts +43 -55
- package/src/constants/{src/CpCustomIcons.ts → CpCustomIcons.ts} +13 -2
- 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 +2 -1
- package/src/stories/CpAirlineLogo.stories.ts +1 -1
- package/src/stories/CpAlert.stories.ts +2 -1
- package/src/stories/CpBadge.stories.ts +1 -1
- package/src/stories/CpButton.stories.ts +1 -1
- package/src/stories/CpCheckbox.stories.ts +4 -2
- package/src/stories/CpDate.stories.ts +4 -2
- package/src/stories/CpDatepicker.stories.ts +4 -2
- package/src/stories/CpDialog.stories.ts +3 -2
- package/src/stories/CpHeading.stories.ts +2 -1
- package/src/stories/CpIcon.stories.ts +3 -1
- package/src/stories/CpInput.stories.ts +4 -2
- package/src/stories/CpLoader.stories.ts +2 -1
- package/src/stories/CpMultiselect.stories.ts +3 -2
- package/src/stories/CpPartnerBadge.stories.ts +2 -2
- package/src/stories/CpRadio.stories.ts +4 -2
- package/src/stories/CpSelect.stories.ts +4 -2
- package/src/stories/CpSelectMenu.stories.ts +4 -2
- package/src/stories/CpSwitch.stories.ts +4 -2
- package/src/stories/CpTable.stories.ts +9 -2
- package/src/stories/CpTableEmptyState.stories.ts +2 -1
- package/src/stories/CpTextarea.stories.ts +4 -2
- package/src/stories/CpToaster.stories.ts +2 -1
- package/src/stories/CpTooltip.stories.ts +2 -1
- package/src/stories/TransitionExpand.stories.ts +4 -2
- package/src/types/luxon.d.ts +1 -0
- package/src/vendors/ff-polyfill.ts +38 -0
- package/vitest.workspace.js +1 -3
- package/dist/IconNoPassport-DBmaQH_g.js +0 -18
- package/dist/IconPassport-5SwUf6_R.js +0 -20
- package/dist/IconRecurrence-CXVkBJ3i.js +0 -24
- package/dist/IconScheduleChange-CEIGEhU4.js +0 -19
- package/src/components/date-pickers/CpDatepicker.vue +0 -229
- package/src/components/feedback-indicators/CpToaster.vue +0 -372
- package/src/components/helpers-utilities/TransitionExpand.vue +0 -72
- 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/components/{atomic-elements/CpDialogWrapper.vue → CpDialogWrapper.vue} +0 -0
- /package/src/components/{logo/Pimp.vue → Pimp.vue} +0 -0
- /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 {
|
|
37
|
-
|
|
38
|
-
import BaseInputLabel from '@/components/
|
|
39
|
-
import TransitionExpand from '@/components/
|
|
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
|
-
},
|
|
35
|
+
<script setup lang="ts">
|
|
36
|
+
import { ref, computed, onMounted } from 'vue'
|
|
37
|
+
|
|
38
|
+
import BaseInputLabel from '@/components/BaseInputLabel.vue'
|
|
39
|
+
import TransitionExpand from '@/components/TransitionExpand.vue'
|
|
40
|
+
|
|
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
|
|
|
@@ -22,76 +22,60 @@
|
|
|
22
22
|
</label>
|
|
23
23
|
</template>
|
|
24
24
|
|
|
25
|
-
<script>
|
|
26
|
-
import {
|
|
25
|
+
<script setup lang="ts">
|
|
26
|
+
import { ref, computed } from 'vue'
|
|
27
|
+
|
|
27
28
|
import { ToggleColors } from '@/constants'
|
|
29
|
+
import { capitalizeFirstLetter, randomString } from '@/helpers'
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
},
|
|
71
|
-
computed: {
|
|
72
|
-
capitalizedColor() {
|
|
73
|
-
return capitalizeFirstLetter(this.color)
|
|
74
|
-
},
|
|
75
|
-
computedClasses() {
|
|
76
|
-
return [
|
|
77
|
-
{
|
|
78
|
-
'cpSwitch--hasLabel': this.label,
|
|
79
|
-
'cpSwitch--isActive': this.modelValue,
|
|
80
|
-
'cpSwitch--isDisabled': this.disabled,
|
|
81
|
-
'cpSwitch--isReversed': this.reverseLabel,
|
|
82
|
-
},
|
|
83
|
-
`cpSwitch--is${this.capitalizedColor}`,
|
|
84
|
-
]
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
mounted() {
|
|
88
|
-
this.switchUniqueId = randomString()
|
|
89
|
-
},
|
|
90
|
-
methods: {
|
|
91
|
-
handleClick(value) {
|
|
92
|
-
this.$emit('update:modelValue', !value)
|
|
31
|
+
interface Props {
|
|
32
|
+
autofocus?: boolean
|
|
33
|
+
color?: string
|
|
34
|
+
disabled?: boolean
|
|
35
|
+
groupName?: string
|
|
36
|
+
label?: string
|
|
37
|
+
modelValue?: boolean
|
|
38
|
+
reverseLabel?: boolean
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface Emits {
|
|
42
|
+
(e: 'update:modelValue', value: boolean): void
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
46
|
+
modelValue: false,
|
|
47
|
+
label: '',
|
|
48
|
+
disabled: false,
|
|
49
|
+
groupName: '',
|
|
50
|
+
color: ToggleColors.BLUE,
|
|
51
|
+
reverseLabel: false,
|
|
52
|
+
autofocus: false,
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
const emit = defineEmits<Emits>()
|
|
56
|
+
|
|
57
|
+
const switchUniqueId = ref('')
|
|
58
|
+
|
|
59
|
+
switchUniqueId.value = randomString()
|
|
60
|
+
|
|
61
|
+
const capitalizedColor = computed(() => {
|
|
62
|
+
return capitalizeFirstLetter(props.color)
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
const computedClasses = computed(() => {
|
|
66
|
+
return [
|
|
67
|
+
{
|
|
68
|
+
'cpSwitch--hasLabel': props.label,
|
|
69
|
+
'cpSwitch--isActive': props.modelValue,
|
|
70
|
+
'cpSwitch--isDisabled': props.disabled,
|
|
71
|
+
'cpSwitch--isReversed': props.reverseLabel,
|
|
93
72
|
},
|
|
94
|
-
|
|
73
|
+
`cpSwitch--is${capitalizedColor.value}`,
|
|
74
|
+
]
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
const handleClick = (value: boolean): void => {
|
|
78
|
+
emit('update:modelValue', !value)
|
|
95
79
|
}
|
|
96
80
|
</script>
|
|
97
81
|
|