@citizenplane/pimp 7.0.2 → 7.0.4
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/.eslintrc.js +1 -0
- package/.lintstagedrc.json +2 -2
- package/dist/pimp.es.js +271 -255
- package/dist/pimp.umd.js +4 -4
- package/dist/style.css +1 -1
- package/package-lock.json +2259 -1702
- package/package.json +16 -16
- package/src/App.vue +0 -1
- package/src/assets/styles/base/_base.scss +2 -15
- package/src/assets/styles/helpers/_keyframes.scss +25 -0
- package/src/components/core/playground-sections/SectionDatePickers.vue +25 -0
- package/src/components/date-pickers/CpCalendar.vue +48 -1
- package/src/components/date-pickers/CpDatepicker.vue +49 -2
- package/src/components/feedback-indicators/CpAlert.vue +2 -3
- package/src/components/lists-and-table/CpTable/index.scss +15 -9
- package/src/components/visual/CpIcon.vue +9 -2
- package/src/libs/CoreDatepicker.vue +101 -118
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<transition name="
|
|
2
|
+
<transition :name="transitionName">
|
|
3
3
|
<div
|
|
4
4
|
v-show="showDatepicker"
|
|
5
5
|
:id="wrapperId"
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
class="asd__wrapper"
|
|
8
8
|
:class="wrapperClasses"
|
|
9
9
|
:style="showFullscreen ? undefined : wrapperStyles"
|
|
10
|
+
@keydown.esc="closeDatepicker"
|
|
10
11
|
>
|
|
11
12
|
<div v-if="showFullscreen" class="asd__mobile-header asd__mobile-only">
|
|
12
13
|
<button class="asd__mobile-close" type="button" @click="closeDatepicker">
|
|
@@ -16,10 +17,18 @@
|
|
|
16
17
|
<h3>{{ mobileHeader || mobileHeaderFallback }}</h3>
|
|
17
18
|
</div>
|
|
18
19
|
<div class="asd__datepicker-header">
|
|
19
|
-
<button
|
|
20
|
+
<button
|
|
21
|
+
class="asd__change-month-button asd__change-month-button--previous"
|
|
22
|
+
aria-label="previous month"
|
|
23
|
+
@click="previousMonth"
|
|
24
|
+
>
|
|
20
25
|
<cp-icon type="chevron-left" />
|
|
21
26
|
</button>
|
|
22
|
-
<button
|
|
27
|
+
<button
|
|
28
|
+
class="asd__change-month-button asd__change-month-button--next"
|
|
29
|
+
aria-label="next month"
|
|
30
|
+
@click="nextMonth"
|
|
31
|
+
>
|
|
23
32
|
<cp-icon type="chevron-right" />
|
|
24
33
|
</button>
|
|
25
34
|
<div
|
|
@@ -89,13 +98,8 @@
|
|
|
89
98
|
:ref="`date-${dayDate}`"
|
|
90
99
|
class="asd__day"
|
|
91
100
|
:data-date="dayDate"
|
|
92
|
-
:tabindex="isDateVisible(dayDate) && isSameDate(focusedDate, dayDate) ? 0 : -1"
|
|
93
101
|
:class="getDayClasses(dayNumber, dayDate)"
|
|
94
|
-
@mouseover="
|
|
95
|
-
() => {
|
|
96
|
-
setHoverDate(dayDate)
|
|
97
|
-
}
|
|
98
|
-
"
|
|
102
|
+
@mouseover="setHoverDate(dayDate)"
|
|
99
103
|
>
|
|
100
104
|
<button
|
|
101
105
|
v-if="dayNumber"
|
|
@@ -128,8 +132,6 @@ import ResizeSelect from '@/directives/ResizeSelect'
|
|
|
128
132
|
|
|
129
133
|
import CpIcon from '@/components/visual/CpIcon.vue'
|
|
130
134
|
|
|
131
|
-
const MOBILE_SIZE = 768
|
|
132
|
-
|
|
133
135
|
export default {
|
|
134
136
|
name: 'CoreDatepicker',
|
|
135
137
|
components: {
|
|
@@ -290,22 +292,27 @@ export default {
|
|
|
290
292
|
viewportWidth: undefined,
|
|
291
293
|
isMobile: undefined,
|
|
292
294
|
triggerElement: undefined,
|
|
293
|
-
isInline: this.inline || false,
|
|
294
295
|
}
|
|
295
296
|
},
|
|
296
297
|
computed: {
|
|
298
|
+
transitionName() {
|
|
299
|
+
return this.inline ? '' : 'asd__fade'
|
|
300
|
+
},
|
|
297
301
|
wrapperClasses() {
|
|
298
|
-
return
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
302
|
+
return [
|
|
303
|
+
this.$attrs.class,
|
|
304
|
+
{
|
|
305
|
+
'asd__wrapper--datepicker-open': this.showDatepicker,
|
|
306
|
+
'asd__wrapper--full-screen': this.showFullscreen,
|
|
307
|
+
'asd__wrapper--isInline': this.inline,
|
|
308
|
+
'asd__wrapper--showOneMonth': this.monthsToShow === 1,
|
|
309
|
+
},
|
|
310
|
+
]
|
|
304
311
|
},
|
|
305
312
|
wrapperStyles() {
|
|
306
313
|
return {
|
|
307
314
|
width: this.width * this.showMonths + 'px',
|
|
308
|
-
zIndex: this.
|
|
315
|
+
zIndex: this.inline ? '' : '100',
|
|
309
316
|
}
|
|
310
317
|
},
|
|
311
318
|
innerStyles() {
|
|
@@ -371,7 +378,6 @@ export default {
|
|
|
371
378
|
},
|
|
372
379
|
selectedDate2(newValue) {
|
|
373
380
|
const newDate = !newValue || newValue === '' ? '' : newValue
|
|
374
|
-
if (newValue && this.selectedDate1 && !this.isDateVisible(newDate)) this.nextMonth()
|
|
375
381
|
this.$emit('date-two-selected', newDate)
|
|
376
382
|
},
|
|
377
383
|
mode() {
|
|
@@ -424,7 +430,7 @@ export default {
|
|
|
424
430
|
this.generateMonths()
|
|
425
431
|
this.generateYears()
|
|
426
432
|
|
|
427
|
-
if (this.startOpen || this.
|
|
433
|
+
if (this.startOpen || this.inline) {
|
|
428
434
|
this.openDatepicker()
|
|
429
435
|
}
|
|
430
436
|
|
|
@@ -438,17 +444,10 @@ export default {
|
|
|
438
444
|
methods: {
|
|
439
445
|
handleDatepickerSizing() {
|
|
440
446
|
this.viewportWidth = window.innerWidth + 'px'
|
|
441
|
-
this._isWindowLessThan = (width) => {
|
|
442
|
-
return window.innerWidth <= width || screen.width <= width
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
this.isInline = this.inline || this._isWindowLessThan(MOBILE_SIZE)
|
|
446
|
-
this.$emit('is-inline', this.isInline)
|
|
447
447
|
|
|
448
448
|
this._handleWindowResizeEvent = this.debounce(() => {
|
|
449
|
-
this.
|
|
450
|
-
this
|
|
451
|
-
this.$emit('is-inline', this.isInline)
|
|
449
|
+
this.inline ? this.openDatepicker() : this.closeDatepicker()
|
|
450
|
+
this.$emit('is-inline', this.inline)
|
|
452
451
|
this.positionDatepicker()
|
|
453
452
|
this.setStartDates()
|
|
454
453
|
}, 200)
|
|
@@ -527,7 +526,7 @@ export default {
|
|
|
527
526
|
return null
|
|
528
527
|
},
|
|
529
528
|
handleClickOutside(event) {
|
|
530
|
-
if (event.target.id === this.triggerElementId || !this.showDatepicker || this.
|
|
529
|
+
if (event.target.id === this.triggerElementId || !this.showDatepicker || this.inline || this.isRecurrent) {
|
|
531
530
|
return
|
|
532
531
|
}
|
|
533
532
|
this.closeDatepicker()
|
|
@@ -595,6 +594,12 @@ export default {
|
|
|
595
594
|
}
|
|
596
595
|
},
|
|
597
596
|
setStartDates() {
|
|
597
|
+
// Set dates if initialized
|
|
598
|
+
if (this.mode === 'range') {
|
|
599
|
+
if (this.dateOne) this.selectDate(this.dateOne)
|
|
600
|
+
if (this.dateTwo) this.selectDate(this.dateTwo)
|
|
601
|
+
}
|
|
602
|
+
|
|
598
603
|
let startDate = this.dateOne ? DateTime.fromISO(this.dateOne) : DateTime.local()
|
|
599
604
|
const minDate = DateTime.fromISO(this.minDate)
|
|
600
605
|
|
|
@@ -731,20 +736,12 @@ export default {
|
|
|
731
736
|
const targetMonth = DateTime.fromISO(this.visibleMonths[visibleMonthIdx])
|
|
732
737
|
const monthIdx = targetMonth.month
|
|
733
738
|
const year = targetMonth.year
|
|
734
|
-
this.focusedDate = DateTime.fromISO(this.focusedDate).set({ month: monthIdx
|
|
739
|
+
this.focusedDate = DateTime.fromISO(this.focusedDate).set({ month: monthIdx, year }).toISODate()
|
|
735
740
|
}
|
|
736
741
|
},
|
|
737
742
|
isToday(date) {
|
|
738
743
|
return DateTime.local().toISODate() === date
|
|
739
744
|
},
|
|
740
|
-
isSameDate(date1, date2) {
|
|
741
|
-
if (!date1) {
|
|
742
|
-
return false
|
|
743
|
-
}
|
|
744
|
-
const dtDate1 = typeof date1 === 'object' ? DateTime.fromJSDate(date1) : DateTime.fromISO(date1)
|
|
745
|
-
|
|
746
|
-
return dtDate1.toISODate() === date2
|
|
747
|
-
},
|
|
748
745
|
isSelected(date) {
|
|
749
746
|
if (!date) {
|
|
750
747
|
return
|
|
@@ -918,7 +915,7 @@ export default {
|
|
|
918
915
|
this.initialDate2 = this.dateTwo
|
|
919
916
|
this.$emit('opened')
|
|
920
917
|
this.$nextTick(() => {
|
|
921
|
-
if (!this.
|
|
918
|
+
if (!this.inline) this.setFocusedDate(this.focusedDate)
|
|
922
919
|
})
|
|
923
920
|
},
|
|
924
921
|
closeDatepickerCancel() {
|
|
@@ -930,7 +927,7 @@ export default {
|
|
|
930
927
|
}
|
|
931
928
|
},
|
|
932
929
|
closeDatepicker() {
|
|
933
|
-
if (this.
|
|
930
|
+
if (this.inline) {
|
|
934
931
|
return
|
|
935
932
|
}
|
|
936
933
|
this.showDatepicker = false
|
|
@@ -953,6 +950,7 @@ export default {
|
|
|
953
950
|
|
|
954
951
|
const viewportWidth = document.documentElement.clientWidth || window.innerWidth
|
|
955
952
|
this.viewportWidth = viewportWidth + 'px'
|
|
953
|
+
|
|
956
954
|
this.isMobile = viewportWidth < 768
|
|
957
955
|
|
|
958
956
|
if (this.isMobile) {
|
|
@@ -979,8 +977,11 @@ export default {
|
|
|
979
977
|
},
|
|
980
978
|
}
|
|
981
979
|
</script>
|
|
980
|
+
<style lang="scss">
|
|
981
|
+
@include popover-desktop('asd__fade');
|
|
982
|
+
</style>
|
|
982
983
|
|
|
983
|
-
<style lang="stylus"
|
|
984
|
+
<style lang="stylus">
|
|
984
985
|
$tablet = 768px
|
|
985
986
|
|
|
986
987
|
$background-grey-color = #f7f7f7
|
|
@@ -995,14 +996,6 @@ degrade()
|
|
|
995
996
|
position absolute
|
|
996
997
|
z-index -1
|
|
997
998
|
|
|
998
|
-
// fade in
|
|
999
|
-
.asd__fade-enter-active,
|
|
1000
|
-
.asd__fade-leave-active
|
|
1001
|
-
transition all 0.2s ease
|
|
1002
|
-
|
|
1003
|
-
.asd__fade-enter-from,
|
|
1004
|
-
.asd__fade-leave-active
|
|
1005
|
-
opacity 0
|
|
1006
999
|
// datepicker
|
|
1007
1000
|
.asd__list-complete-enter-from,
|
|
1008
1001
|
.asd__list-complete-leave-to
|
|
@@ -1015,8 +1008,6 @@ degrade()
|
|
|
1015
1008
|
|
|
1016
1009
|
.asd
|
|
1017
1010
|
&__wrapper
|
|
1018
|
-
left: 50%;
|
|
1019
|
-
transform: translateX(-50%);
|
|
1020
1011
|
border-radius 10px
|
|
1021
1012
|
white-space nowrap
|
|
1022
1013
|
text-align center
|
|
@@ -1024,25 +1015,13 @@ degrade()
|
|
|
1024
1015
|
overflow hidden
|
|
1025
1016
|
|
|
1026
1017
|
&:not(&--isInline) {
|
|
1027
|
-
box-shadow 0 24px
|
|
1028
|
-
}
|
|
1029
|
-
|
|
1030
|
-
@media (min-width: $tablet) {
|
|
1031
|
-
position absolute
|
|
1032
|
-
margin-top 10px
|
|
1018
|
+
box-shadow 0 9px 24px rgba(62, 62, 91, 20%), 0 4px 4px rgba(62, 62, 91, 10%);
|
|
1033
1019
|
}
|
|
1034
1020
|
|
|
1035
1021
|
&--isInline {
|
|
1036
|
-
position relative
|
|
1037
|
-
margin-top 16px
|
|
1022
|
+
position relative !important
|
|
1038
1023
|
}
|
|
1039
1024
|
|
|
1040
|
-
@media (max-width: $tablet) {
|
|
1041
|
-
position relative
|
|
1042
|
-
margin-top 16px
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
1025
|
&:before
|
|
1047
1026
|
// Line between the two months
|
|
1048
1027
|
@media (min-width: $tablet)
|
|
@@ -1054,7 +1033,7 @@ degrade()
|
|
|
1054
1033
|
bottom 0
|
|
1055
1034
|
margin auto
|
|
1056
1035
|
width 1px
|
|
1057
|
-
background $neutral-dark-
|
|
1036
|
+
background $neutral-dark-4
|
|
1058
1037
|
z-index -1
|
|
1059
1038
|
|
|
1060
1039
|
&--showOneMonth {
|
|
@@ -1082,6 +1061,13 @@ degrade()
|
|
|
1082
1061
|
&__change-month-button
|
|
1083
1062
|
position absolute
|
|
1084
1063
|
z-index 10
|
|
1064
|
+
top 16px
|
|
1065
|
+
border-radius: 100%;
|
|
1066
|
+
|
|
1067
|
+
&:focus-visible {
|
|
1068
|
+
outline: 2px solid $secondary-color;
|
|
1069
|
+
outline-offset: 2px;
|
|
1070
|
+
}
|
|
1085
1071
|
|
|
1086
1072
|
i
|
|
1087
1073
|
color $neutral-dark
|
|
@@ -1093,32 +1079,40 @@ degrade()
|
|
|
1093
1079
|
@media (min-width: $tablet)
|
|
1094
1080
|
top 22px
|
|
1095
1081
|
|
|
1096
|
-
&--previous
|
|
1097
|
-
left
|
|
1082
|
+
&--previous {
|
|
1083
|
+
left 16px
|
|
1098
1084
|
|
|
1099
|
-
@media (min-width: $tablet)
|
|
1100
|
-
|
|
1085
|
+
@media (min-width: $tablet) {
|
|
1086
|
+
left 24px
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1101
1089
|
|
|
1102
|
-
&--next
|
|
1103
|
-
right
|
|
1090
|
+
&--next {
|
|
1091
|
+
right 16px
|
|
1104
1092
|
|
|
1105
|
-
@media (min-width: $tablet)
|
|
1106
|
-
|
|
1093
|
+
@media (min-width: $tablet) {
|
|
1094
|
+
right 24px
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1107
1097
|
|
|
1108
|
-
&__days-legend
|
|
1098
|
+
&__days-legend {
|
|
1109
1099
|
position absolute
|
|
1110
1100
|
font-size 12px
|
|
1111
1101
|
line-height 15px
|
|
1112
1102
|
user-select none
|
|
1113
1103
|
|
|
1114
|
-
@media (min-width: $tablet)
|
|
1115
|
-
top 60px
|
|
1104
|
+
@media (min-width: $tablet) {
|
|
1116
1105
|
padding 0 24px
|
|
1106
|
+
top 60px
|
|
1107
|
+
}
|
|
1117
1108
|
|
|
1118
|
-
@media (max-width: $tablet)
|
|
1119
|
-
top
|
|
1109
|
+
@media (max-width: $tablet - 1px) {
|
|
1110
|
+
top 56px
|
|
1111
|
+
padding: 0 16px;
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1120
1114
|
|
|
1121
|
-
&__day-title
|
|
1115
|
+
&__day-title {
|
|
1122
1116
|
display inline-block
|
|
1123
1117
|
width percentage(1 / 7)
|
|
1124
1118
|
text-align center
|
|
@@ -1126,23 +1120,38 @@ degrade()
|
|
|
1126
1120
|
font-size 14px
|
|
1127
1121
|
line-height 18px
|
|
1128
1122
|
margin-left -1px
|
|
1123
|
+
}
|
|
1129
1124
|
|
|
1130
|
-
&__month-table
|
|
1125
|
+
&__month-table {
|
|
1131
1126
|
border-spacing 0 6px
|
|
1132
1127
|
width 100%
|
|
1133
1128
|
max-width 100%
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
&__wrapper:not(&__wrapper--isInline) &__month {
|
|
1132
|
+
padding-left: 16px;
|
|
1133
|
+
padding-right: 16px;
|
|
1134
1134
|
|
|
1135
|
-
|
|
1135
|
+
@media (min-width: $tablet) {
|
|
1136
|
+
padding-left: 24px;
|
|
1137
|
+
padding-right: 24px;
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
&__month {
|
|
1136
1142
|
transition all $transition-time ease
|
|
1137
1143
|
display inline-block
|
|
1144
|
+
padding 16px 16px 8px
|
|
1138
1145
|
|
|
1139
|
-
@media (min-width: $tablet)
|
|
1140
|
-
padding 24px
|
|
1141
|
-
|
|
1146
|
+
@media (min-width: $tablet) {
|
|
1147
|
+
padding 24px 24px 12px;
|
|
1148
|
+
}
|
|
1142
1149
|
|
|
1143
|
-
&--hidden
|
|
1150
|
+
&--hidden {
|
|
1144
1151
|
height 275px
|
|
1145
1152
|
visibility hidden
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1146
1155
|
|
|
1147
1156
|
&__month-name
|
|
1148
1157
|
font-size 16px
|
|
@@ -1199,8 +1208,8 @@ degrade()
|
|
|
1199
1208
|
|
|
1200
1209
|
&--hovered
|
|
1201
1210
|
.asd__day--end-week
|
|
1202
|
-
|
|
1203
|
-
|
|
1211
|
+
border-top-right-radius 5px
|
|
1212
|
+
border-bottom-right-radius 5px
|
|
1204
1213
|
|
|
1205
1214
|
.asd__day--start-week
|
|
1206
1215
|
border-top-left-radius 5px
|
|
@@ -1277,8 +1286,8 @@ degrade()
|
|
|
1277
1286
|
&--empty .asd__day-number
|
|
1278
1287
|
color $neutral-dark-3 !important
|
|
1279
1288
|
|
|
1280
|
-
|
|
1281
|
-
|
|
1289
|
+
&--disabled *
|
|
1290
|
+
cursor not-allowed !important
|
|
1282
1291
|
|
|
1283
1292
|
&--today .asd__day-button .asd__day-number
|
|
1284
1293
|
color $primary-color
|
|
@@ -1317,7 +1326,6 @@ degrade()
|
|
|
1317
1326
|
width 35px
|
|
1318
1327
|
height 35px
|
|
1319
1328
|
border none
|
|
1320
|
-
cursor pointer
|
|
1321
1329
|
user-select none
|
|
1322
1330
|
font-size 14px
|
|
1323
1331
|
|
|
@@ -1326,31 +1334,6 @@ degrade()
|
|
|
1326
1334
|
position relative
|
|
1327
1335
|
color $neutral-dark
|
|
1328
1336
|
|
|
1329
|
-
&__action-buttons
|
|
1330
|
-
min-height 50px
|
|
1331
|
-
padding-top 10px
|
|
1332
|
-
margin-bottom 12px
|
|
1333
|
-
|
|
1334
|
-
button
|
|
1335
|
-
display block
|
|
1336
|
-
position relative
|
|
1337
|
-
background transparent
|
|
1338
|
-
border none
|
|
1339
|
-
font-weight bold
|
|
1340
|
-
font-size 15px
|
|
1341
|
-
cursor pointer
|
|
1342
|
-
|
|
1343
|
-
&:hover
|
|
1344
|
-
text-decoration underline
|
|
1345
|
-
|
|
1346
|
-
&:nth-child(1)
|
|
1347
|
-
float left
|
|
1348
|
-
left 15px
|
|
1349
|
-
|
|
1350
|
-
&:nth-child(2)
|
|
1351
|
-
float right
|
|
1352
|
-
right 15px
|
|
1353
|
-
|
|
1354
1337
|
&__mobile-header
|
|
1355
1338
|
border-bottom $border-normal
|
|
1356
1339
|
position relative
|