@citizenplane/pimp 8.26.1 → 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-CUq3oXbX.js → IconAccompaniedMinorEach-BJYaPpW3.js} +1 -1
- package/dist/{IconAccompaniedMinorNone-nZ4eSfTj.js → IconAccompaniedMinorNone-D1JR2Qpd.js} +1 -1
- package/dist/{IconAccompaniedMinorOne-CDMqq14b.js → IconAccompaniedMinorOne-BJ3jzEDZ.js} +1 -1
- package/dist/{IconAddReceipt-DRpGiWBU.js → IconAddReceipt-BX_va94f.js} +1 -1
- package/dist/{IconAirportTerminal-8k-3lKjb.js → IconAirportTerminal-Dzr98nfc.js} +1 -1
- package/dist/{IconArrival-m6HnOVje.js → IconArrival-Ced9HrJH.js} +1 -1
- package/dist/{IconBroadcast-B13UworG.js → IconBroadcast-BYX44Wak.js} +1 -1
- package/dist/{IconCabinBag-CNnzHz2B.js → IconCabinBag-D1Qs952U.js} +1 -1
- package/dist/{IconCheckedBaggage-CkxUDHe9.js → IconCheckedBaggage-Q4_SQL9l.js} +1 -1
- package/dist/{IconCheckedBaggage20-DEtphLSa.js → IconCheckedBaggage20-DVH1-A0V.js} +1 -1
- package/dist/{IconCheckedBaggage30-CmAddx5h.js → IconCheckedBaggage30-DYOAf-7Z.js} +1 -1
- package/dist/{IconChild-OReHyUco.js → IconChild-BeCLAr8Y.js} +1 -1
- package/dist/{IconContact-D2N23RZ5.js → IconContact-B3r39fyI.js} +1 -1
- package/dist/{IconDeparture-D10LaXRX.js → IconDeparture-BflKZUiE.js} +1 -1
- package/dist/{IconDistribution-SpPiru9I.js → IconDistribution-CBxQ7UWb.js} +1 -1
- package/dist/{IconDistributionClosed-Bzqe7nju.js → IconDistributionClosed-BWp_k24K.js} +1 -1
- package/dist/{IconDistributionExclusivePair-CjPM-_R1.js → IconDistributionExclusivePair-erLbcLps.js} +1 -1
- package/dist/{IconDistributionSided-DehjCN0D.js → IconDistributionSided-y000n4qB.js} +1 -1
- package/dist/{IconDistributionSupplySided-DWCyXqd1.js → IconDistributionSupplySided-7kCvGwnz.js} +1 -1
- package/dist/{IconDynamicContent-BvzbgXvW.js → IconDynamicContent-SwBxkPMB.js} +1 -1
- package/dist/{IconFares-zARDpPNl.js → IconFares-DTm0Q_RI.js} +1 -1
- package/dist/{IconFaresOutlined-DLFV8nwg.js → IconFaresOutlined-BFMo_x9Q.js} +1 -1
- package/dist/{IconFemale-Ba4uoI-S.js → IconFemale-Ma0KeaEM.js} +1 -1
- package/dist/{IconFindConversation-d0pP3wG9.js → IconFindConversation-CpsDYPgD.js} +1 -1
- package/dist/{IconFire-CXzWKoMB.js → IconFire-DECrDnLM.js} +1 -1
- package/dist/{IconFlight-Cof8M5dO.js → IconFlight-D5M0A0CM.js} +1 -1
- package/dist/{IconFlightReturn-CA9iGMcW.js → IconFlightReturn-CTvqEFME.js} +1 -1
- package/dist/{IconHandHeart-CCLKnMOm.js → IconHandHeart-ChgdfXQa.js} +1 -1
- package/dist/{IconHistory-DI6WD_3J.js → IconHistory-DpIXDYI5.js} +1 -1
- package/dist/{IconHourGlass-BorNLEca.js → IconHourGlass-CIRkFUSM.js} +1 -1
- package/dist/{IconIdCard-DhbhBkul.js → IconIdCard-UD5VZsUi.js} +1 -1
- package/dist/{IconInfant-D4EztT9g.js → IconInfant-CmLUvWpO.js} +1 -1
- package/dist/{IconItinerary-Bhj_lgG2.js → IconItinerary-CY8irele.js} +1 -1
- package/dist/{IconLeave-BvpY7gdD.js → IconLeave-C3bpPz6L.js} +1 -1
- package/dist/{IconMale-RMd_9ZSg.js → IconMale-x4xdulWB.js} +1 -1
- package/dist/{IconMultiSegments-DROUj0t5.js → IconMultiSegments-BhTMfvhQ.js} +1 -1
- package/dist/{IconNoPassport-DBmaQH_g.js → IconNoPassport-_Xm76k6b.js} +1 -1
- package/dist/{IconNoRefund-yNAZr7uX.js → IconNoRefund-B78s0oyF.js} +1 -1
- package/dist/{IconNotion-CpZhGILz.js → IconNotion-C22PTLTU.js} +1 -1
- package/dist/{IconOffline-Bf1mw_1N.js → IconOffline-BDzikWE9.js} +1 -1
- package/dist/{IconOneWay-6oGoLo57.js → IconOneWay-DlTVxokv.js} +2 -2
- package/dist/{IconPaid-B3dvioAR.js → IconPaid-DmGERe85.js} +1 -1
- package/dist/{IconPassport-5SwUf6_R.js → IconPassport-6VOlXjxJ.js} +1 -1
- package/dist/{IconPayout-b3TcXwjA.js → IconPayout-abr6BXCd.js} +1 -1
- package/dist/{IconReceipt-Dh454941.js → IconReceipt-BnTaihcq.js} +1 -1
- package/dist/{IconRecurrence-CXVkBJ3i.js → IconRecurrence-C5TPG2ht.js} +1 -1
- package/dist/{IconRefund-D-FNjukU.js → IconRefund-Ysv8pyMJ.js} +1 -1
- package/dist/{IconRoundTrip-BqVPrNwg.js → IconRoundTrip-CIVDw8LK.js} +1 -1
- package/dist/{IconRouteNoStop-CZ_QeOIY.js → IconRouteNoStop-DQrq4gW5.js} +1 -1
- package/dist/{IconRouteOneStop-DGpLAQmQ.js → IconRouteOneStop-pzisj4i4.js} +1 -1
- package/dist/{IconScheduleChange-CEIGEhU4.js → IconScheduleChange-BONs1AAT.js} +1 -1
- package/dist/{IconSeatEmpty-BwyVwYQZ.js → IconSeatEmpty-CHij3aGA.js} +1 -1
- package/dist/{IconSeatSold-B_SNoTs-.js → IconSeatSold-QspS_zCh.js} +1 -1
- package/dist/{IconSeatTotal-DUEF7k6I.js → IconSeatTotal-DTZ1TcAX.js} +1 -1
- package/dist/{IconTemplate-D1ACYaHI.js → IconTemplate-BDmmr-9L.js} +1 -1
- package/dist/{IconTicket-5Z4b83BP.js → IconTicket--vVn61Ey.js} +1 -1
- package/dist/{IconTimer-DbcddAPo.js → IconTimer-CspKpwqZ.js} +1 -1
- package/dist/{IconTrafficControl-CEzhRpZt.js → IconTrafficControl-DBamcJNe.js} +1 -1
- package/dist/{index-DbgX3-2I.js → index-C3oHnZQk.js} +9166 -10083
- 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 +27 -44
- 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 +159 -113
- 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/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
|
@@ -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
|
|
|
@@ -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
|
|
|
@@ -4,42 +4,24 @@
|
|
|
4
4
|
</component>
|
|
5
5
|
</template>
|
|
6
6
|
|
|
7
|
-
<script>
|
|
8
|
-
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import { HeadingLevels } from '@/constants'
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
type HeadingSize = 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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 {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineAsyncComponent } from 'vue'
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export const CustomCpIcons = {
|
|
4
4
|
'accompanied-minor-each': defineAsyncComponent(() => import('@/components/icons/IconAccompaniedMinorEach.vue')),
|
|
5
5
|
'accompanied-minor-none': defineAsyncComponent(() => import('@/components/icons/IconAccompaniedMinorNone.vue')),
|
|
6
6
|
'accompanied-minor-one': defineAsyncComponent(() => import('@/components/icons/IconAccompaniedMinorOne.vue')),
|
package/src/constants/index.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
1
|
+
export { Colors } from './colors/Colors'
|
|
2
|
+
export { Position } from './Position'
|
|
3
|
+
export { ToggleColors } from './colors/ToggleColors'
|
|
4
|
+
export { HeadingLevels } from './Heading'
|
|
5
|
+
export { PAGINATION_FORMATS, RESERVED_KEYS, VISIBLE_ROWS_MAX } from './CpTableConfig'
|
|
6
|
+
export { Sizes } from './Sizes'
|
|
7
|
+
export { PartnerTypes } from './PartnerTypes'
|
|
8
|
+
|
|
9
|
+
export { CustomCpIcons } from './CpCustomIcons'
|
|
10
|
+
export { Intent } from './Intent'
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type ClickOutsideBinding = {
|
|
2
|
+
value: (event: MouseEvent, el: HTMLElement) => void
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
beforeMount(el: HTMLElement & { clickOutsideEvent?: (e: MouseEvent) => void }, binding: ClickOutsideBinding) {
|
|
7
|
+
el.clickOutsideEvent = function (event: MouseEvent) {
|
|
8
|
+
if (!(el === event.target || el.contains(event.target as Node))) {
|
|
9
|
+
binding.value(event, el)
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
document.body.addEventListener('click', el.clickOutsideEvent)
|
|
13
|
+
},
|
|
14
|
+
unmounted(el: HTMLElement & { clickOutsideEvent?: (e: MouseEvent) => void }) {
|
|
15
|
+
document.body.removeEventListener('click', el.clickOutsideEvent as (e: MouseEvent) => void)
|
|
16
|
+
},
|
|
17
|
+
}
|
|
@@ -3,13 +3,13 @@ export default {
|
|
|
3
3
|
inserted: resizeSelect,
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
function resizeSelect(el) {
|
|
6
|
+
function resizeSelect(el: HTMLSelectElement) {
|
|
7
7
|
const select = document.createElement('select')
|
|
8
8
|
select.className = el.className
|
|
9
9
|
const option = document.createElement('option')
|
|
10
10
|
option.textContent = el.value
|
|
11
11
|
select.appendChild(option)
|
|
12
|
-
el.parentNode
|
|
12
|
+
el.parentNode?.appendChild(select)
|
|
13
13
|
el.style.width = select.offsetWidth + 'px'
|
|
14
|
-
select.parentNode
|
|
14
|
+
select.parentNode?.removeChild(select)
|
|
15
15
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
export const getKeyboardFocusableElements = (DOMElement = document) => {
|
|
2
|
-
if (DOMElement === null) return []
|
|
1
|
+
export const getKeyboardFocusableElements = (DOMElement: Document | HTMLElement | null = document) => {
|
|
2
|
+
if (DOMElement === null) return [] as (HTMLElement | SVGElement)[]
|
|
3
3
|
|
|
4
|
-
const focusableElements =
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const focusableElements = Array.from(
|
|
5
|
+
(DOMElement as Document | HTMLElement).querySelectorAll<HTMLElement | SVGElement>(
|
|
6
|
+
'a, button, input, textarea, select, details,[tabindex]:not([tabindex="-1"])',
|
|
7
|
+
),
|
|
8
|
+
)
|
|
7
9
|
|
|
8
10
|
if (!focusableElements.length) {
|
|
9
11
|
return DOMElement instanceof HTMLElement ? [DOMElement] : []
|
|
@@ -11,7 +13,7 @@ export const getKeyboardFocusableElements = (DOMElement = document) => {
|
|
|
11
13
|
|
|
12
14
|
return focusableElements.filter((element) => {
|
|
13
15
|
const isElementDisabled = element.hasAttribute('disabled')
|
|
14
|
-
const isElementVisible = element.offsetHeight !== 0 && element.offsetWidth !== 0
|
|
16
|
+
const isElementVisible = (element as HTMLElement).offsetHeight !== 0 && (element as HTMLElement).offsetWidth !== 0
|
|
15
17
|
|
|
16
18
|
const isInputElement = element instanceof HTMLInputElement
|
|
17
19
|
const isElementRadioNotChecked = isInputElement && element.type === 'radio' && element.checked === false
|
|
@@ -20,7 +22,9 @@ export const getKeyboardFocusableElements = (DOMElement = document) => {
|
|
|
20
22
|
})
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
export const handleTrapFocus = (event, DOMElement) => {
|
|
25
|
+
export const handleTrapFocus = (event: KeyboardEvent, DOMElement?: HTMLElement) => {
|
|
26
|
+
if (!DOMElement) return
|
|
27
|
+
|
|
24
28
|
const childFocusableElements = getKeyboardFocusableElements(DOMElement)
|
|
25
29
|
const firstElement = childFocusableElements[0]
|
|
26
30
|
const lastElement = childFocusableElements[childFocusableElements.length - 1]
|
|
@@ -32,10 +36,10 @@ export const handleTrapFocus = (event, DOMElement) => {
|
|
|
32
36
|
// only TAB is pressed, not SHIFT simultaneously
|
|
33
37
|
// Prevent default behavior of keydown on TAB (i.e. focus next element)
|
|
34
38
|
event.preventDefault()
|
|
35
|
-
firstElement
|
|
39
|
+
firstElement?.focus()
|
|
36
40
|
} else if (tabBackwards) {
|
|
37
41
|
// TAB and SHIFT are pressed simultaneously
|
|
38
42
|
event.preventDefault()
|
|
39
|
-
lastElement
|
|
43
|
+
lastElement?.focus()
|
|
40
44
|
}
|
|
41
45
|
}
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { DateTime } from 'luxon'
|
|
2
2
|
|
|
3
|
-
export const randomString = () => {
|
|
3
|
+
export const randomString = (): string => {
|
|
4
4
|
return `_${Math.random().toString(36).substr(2, 9)}`
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
export const formatDates =
|
|
7
|
+
export const formatDates = ({
|
|
8
|
+
dateOne,
|
|
9
|
+
dateTwo,
|
|
10
|
+
format,
|
|
11
|
+
locale,
|
|
12
|
+
}: {
|
|
13
|
+
dateOne?: string
|
|
14
|
+
dateTwo?: string
|
|
15
|
+
format: string
|
|
16
|
+
locale?: string
|
|
17
|
+
}): string => {
|
|
8
18
|
let formattedDates = ''
|
|
9
19
|
|
|
10
20
|
if (dateOne) {
|
|
@@ -17,7 +27,7 @@ export const formatDates = function formatDates({ dateOne, dateTwo, format, loca
|
|
|
17
27
|
return formattedDates
|
|
18
28
|
}
|
|
19
29
|
|
|
20
|
-
export const capitalizeFirstLetter = (rawString) => {
|
|
30
|
+
export const capitalizeFirstLetter = (rawString: unknown): string => {
|
|
21
31
|
if (typeof rawString !== 'string') return ''
|
|
22
32
|
return rawString.charAt(0).toUpperCase() + rawString.slice(1)
|
|
23
33
|
}
|