playbook_ui 11.0.0.pre.alpha.2 → 11.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_background/_background.scss +8 -1
- data/app/pb_kits/playbook/pb_background/_background.tsx +9 -1
- data/app/pb_kits/playbook/pb_background/background.rb +76 -16
- data/app/pb_kits/playbook/pb_background/docs/_background_status.html.erb +14 -2
- data/app/pb_kits/playbook/pb_background/docs/_background_status.jsx +43 -2
- data/app/pb_kits/playbook/pb_background/docs/_background_status.md +1 -1
- data/app/pb_kits/playbook/pb_badge/_badge.tsx +1 -2
- data/app/pb_kits/playbook/pb_body/_body.scss +4 -4
- data/app/pb_kits/playbook/pb_body/_body.tsx +5 -4
- data/app/pb_kits/playbook/pb_body/_body_mixins.scss +7 -3
- data/app/pb_kits/playbook/pb_body/body.rb +4 -3
- data/app/pb_kits/playbook/pb_body/body.test.js +12 -9
- data/app/pb_kits/playbook/pb_body/docs/_body_light.html.erb +4 -4
- data/app/pb_kits/playbook/pb_body/docs/_body_light.jsx +4 -4
- data/app/pb_kits/playbook/pb_body/docs/_description.md +2 -2
- data/app/pb_kits/playbook/pb_body/docs/_footer.md +1 -1
- data/app/pb_kits/playbook/pb_button/button.rb +5 -5
- data/app/pb_kits/playbook/pb_caption/_caption.tsx +1 -1
- data/app/pb_kits/playbook/pb_caption/_caption_mixin.scss +3 -1
- data/app/pb_kits/playbook/pb_caption/docs/_caption_colors.html.erb +2 -1
- data/app/pb_kits/playbook/pb_caption/docs/_caption_colors.jsx +5 -0
- data/app/pb_kits/playbook/pb_card/_card.tsx +5 -5
- data/app/pb_kits/playbook/pb_checkbox/{_checkbox.jsx → _checkbox.tsx} +33 -29
- data/app/pb_kits/playbook/pb_date_picker/_date_picker.jsx +30 -18
- data/app/pb_kits/playbook/pb_date_picker/_date_picker.scss +3 -0
- data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +12 -1
- data/app/pb_kits/playbook/pb_date_picker/date_picker.test.js +160 -0
- data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.js +37 -11
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_default.html.erb +1 -1
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_month_and_year.html.erb +2 -2
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_month_and_year.jsx +1 -1
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_month_and_year.md +1 -1
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_time.html.erb +6 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_time.jsx +21 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_time.md +1 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_week.html.erb +5 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_week.jsx +18 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_week.md +1 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/example.yml +4 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_date_picker/plugins/timeSelect.js +137 -0
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_day_styles.scss +27 -2
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_flatpickr_styles.scss +1 -5
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_time_selection_styles.scss +63 -0
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_week_styles.scss +127 -0
- data/app/pb_kits/playbook/pb_dialog/_dialog.jsx +60 -14
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_default.jsx +1 -1
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_stacked_alert.jsx +153 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_stacked_alert.md +1 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_status.jsx +130 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_status.md +1 -0
- data/app/pb_kits/playbook/pb_dialog/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_dialog/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_form_pill/{_form_pill.jsx → _form_pill.tsx} +16 -12
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_example.jsx +1 -1
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_size.jsx +1 -1
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_tag.jsx +1 -1
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_user.jsx +1 -1
- data/app/pb_kits/playbook/pb_hashtag/{_hashtag.jsx → _hashtag.tsx} +3 -4
- data/app/pb_kits/playbook/pb_radio/_radio.tsx +86 -0
- data/app/pb_kits/playbook/pb_select/{_select.jsx → _select.tsx} +34 -38
- data/app/pb_kits/playbook/pb_text_input/{_text_input.jsx → _text_input.tsx} +42 -43
- data/app/pb_kits/playbook/tokens/_colors.scss +17 -1
- data/app/pb_kits/playbook/utilities/props.ts +2 -2
- data/lib/playbook/version.rb +1 -1
- metadata +24 -10
- data/app/pb_kits/playbook/pb_radio/_radio.jsx +0 -78
@@ -0,0 +1,137 @@
|
|
1
|
+
export const getTimezoneText = (inputDate) => {
|
2
|
+
const tzAbbr = inputDate.toLocaleDateString('en-US', {
|
3
|
+
day: '2-digit',
|
4
|
+
timeZoneName: 'short',
|
5
|
+
}).slice(4)
|
6
|
+
const tzText = inputDate.toLocaleDateString('en-US', {
|
7
|
+
day: '2-digit',
|
8
|
+
timeZoneName: 'long',
|
9
|
+
}).slice(4)
|
10
|
+
return `${tzAbbr} (${tzText})`
|
11
|
+
}
|
12
|
+
|
13
|
+
function timeSelectPlugin(props) {
|
14
|
+
return function(fp) {
|
15
|
+
|
16
|
+
const generateMeridiemCard = (text) => {
|
17
|
+
const selectableCard = document.createElement('div')
|
18
|
+
selectableCard.className = 'pb_selectable_card_kit_enabled'
|
19
|
+
|
20
|
+
const cardInput = document.createElement('input'),
|
21
|
+
cardInputId = `datePicker${text}`
|
22
|
+
|
23
|
+
cardInput.id = cardInputId
|
24
|
+
cardInput.name = 'datepicker-ampm'
|
25
|
+
cardInput.type = 'radio'
|
26
|
+
cardInput.value = text
|
27
|
+
|
28
|
+
const cardLabel = document.createElement('label'),
|
29
|
+
cardLabelBuffer = document.createElement('div')
|
30
|
+
cardLabel.className = `label-${text.toLowerCase()}`
|
31
|
+
cardLabel.setAttribute('for', cardInputId)
|
32
|
+
cardLabelBuffer.className = 'buffer'
|
33
|
+
cardLabelBuffer.innerHTML = text
|
34
|
+
|
35
|
+
cardLabel.append(cardLabelBuffer)
|
36
|
+
selectableCard.prepend(cardInput)
|
37
|
+
selectableCard.append(cardLabel)
|
38
|
+
|
39
|
+
return selectableCard
|
40
|
+
}
|
41
|
+
|
42
|
+
const generateMeridiemToggle = () => {
|
43
|
+
fp.amPM.style.display = 'none'
|
44
|
+
const formGroupKit = document.createElement('div')
|
45
|
+
formGroupKit.className = 'pb_form_group_kit'
|
46
|
+
|
47
|
+
const amCard = generateMeridiemCard('AM')
|
48
|
+
amCard.addEventListener('click', () => {
|
49
|
+
fp.selectedDates[0].setHours((fp.selectedDates[0].getHours() % 12) + 12 * 0)
|
50
|
+
fp.setDate(fp.selectedDates[0], true)
|
51
|
+
})
|
52
|
+
|
53
|
+
const pmCard = generateMeridiemCard('PM')
|
54
|
+
pmCard.addEventListener('click', () => {
|
55
|
+
fp.selectedDates[0].setHours((fp.selectedDates[0].getHours() % 12) + 12 * 1)
|
56
|
+
fp.setDate(fp.selectedDates[0], true)
|
57
|
+
})
|
58
|
+
|
59
|
+
formGroupKit.prepend(amCard)
|
60
|
+
formGroupKit.append(pmCard)
|
61
|
+
|
62
|
+
const meridiemContainer = document.createElement('div')
|
63
|
+
meridiemContainer.className = 'meridiem'
|
64
|
+
meridiemContainer.append(formGroupKit)
|
65
|
+
document.querySelector('.pb_time_selection').append(meridiemContainer)
|
66
|
+
}
|
67
|
+
|
68
|
+
const getMeridiem = (dateObj) => {
|
69
|
+
return dateObj[0].getHours() < 12 ? 'AM' : 'PM'
|
70
|
+
}
|
71
|
+
|
72
|
+
const updateMeridiemToggle = (forceClick) => {
|
73
|
+
if (!fp.selectedDates.length) return
|
74
|
+
|
75
|
+
const uncheckedClass = 'pb_selectable_card_kit_enabled',
|
76
|
+
checkedClass = 'pb_selectable_card_kit_checked_enabled',
|
77
|
+
pickerAM = document.getElementById('datePickerAM'),
|
78
|
+
pickerPM = document.getElementById('datePickerPM'),
|
79
|
+
meridiem = getMeridiem(fp.selectedDates)
|
80
|
+
|
81
|
+
if (forceClick) {
|
82
|
+
pickerAM.checked = false
|
83
|
+
pickerPM.checked = false
|
84
|
+
pickerPM.checked = meridiem === 'PM'
|
85
|
+
pickerAM.checked = meridiem === 'AM'
|
86
|
+
}
|
87
|
+
|
88
|
+
if (meridiem === 'PM') {
|
89
|
+
pickerPM.parentElement.className = checkedClass
|
90
|
+
pickerAM.parentElement.className = uncheckedClass
|
91
|
+
} else if (meridiem === 'AM') {
|
92
|
+
pickerAM.parentElement.className = checkedClass
|
93
|
+
pickerPM.parentElement.className = uncheckedClass
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
return {
|
98
|
+
onValueUpdate() {
|
99
|
+
updateMeridiemToggle()
|
100
|
+
},
|
101
|
+
onReady() {
|
102
|
+
const id = fp.input.id
|
103
|
+
|
104
|
+
if (!id || !fp?.timeContainer) return
|
105
|
+
|
106
|
+
fp.timeContainer.classList.add('pb_time_selection')
|
107
|
+
|
108
|
+
// allow single minutes
|
109
|
+
fp.minuteElement.step = '1'
|
110
|
+
|
111
|
+
// add caption text
|
112
|
+
if (props.caption) {
|
113
|
+
const captionContainer = document.createElement('div')
|
114
|
+
captionContainer.className = 'pb_caption_kit_md'
|
115
|
+
captionContainer.innerHTML = props?.caption
|
116
|
+
fp.timeContainer.prepend(captionContainer)
|
117
|
+
}
|
118
|
+
|
119
|
+
// add meridiem toggle
|
120
|
+
generateMeridiemToggle()
|
121
|
+
updateMeridiemToggle(true)
|
122
|
+
|
123
|
+
// add timezone text
|
124
|
+
if (props.showTimezone) {
|
125
|
+
const subcaptionContainer = document.createElement('div')
|
126
|
+
subcaptionContainer.className = 'pb_caption_kit_xs'
|
127
|
+
subcaptionContainer.innerHTML = getTimezoneText(fp._initialDate)
|
128
|
+
fp.timeContainer.append(subcaptionContainer)
|
129
|
+
}
|
130
|
+
|
131
|
+
fp.loadedPlugins.push("timeSelectPlugin")
|
132
|
+
}
|
133
|
+
}
|
134
|
+
}
|
135
|
+
}
|
136
|
+
|
137
|
+
export default timeSelectPlugin
|
@@ -4,7 +4,7 @@
|
|
4
4
|
@media (hover: hover) {
|
5
5
|
&:hover {
|
6
6
|
transition-duration: $transition_short;
|
7
|
-
transition-timing-function: $easeIn;
|
7
|
+
transition-timing-function: $easeIn;
|
8
8
|
background-color: #F6FAFF;
|
9
9
|
border-color: #F6FAFF;
|
10
10
|
box-shadow: $shadow_deep;
|
@@ -24,7 +24,7 @@
|
|
24
24
|
background-color: $primary;
|
25
25
|
border-color: $primary;
|
26
26
|
box-shadow: $shadow_deep;
|
27
|
-
font-weight: $bold;
|
27
|
+
font-weight: $bold;
|
28
28
|
}
|
29
29
|
.flatpickr-day.startRange {
|
30
30
|
box-shadow: $space_sm + 1 0 0 #F7FBFF
|
@@ -37,6 +37,31 @@
|
|
37
37
|
border: 2px;
|
38
38
|
box-shadow: -$space_xs + 4 0 0 #F7FBFF, $space_xs - 3 0 0 #F7FBFF;
|
39
39
|
}
|
40
|
+
/*
|
41
|
+
Plugin author didn't consider providing a class context, so
|
42
|
+
instead we have to use the id! ¯\_(ツ)_/¯
|
43
|
+
*/
|
44
|
+
#cal-week-date-picker {
|
45
|
+
.flatpickr-day.inRange:not(.selected) {
|
46
|
+
&:nth-of-type(1),
|
47
|
+
&:nth-of-type(7n+1) {
|
48
|
+
border-radius: 30px 0 0 30px;
|
49
|
+
}
|
50
|
+
&:nth-of-type(7n) {
|
51
|
+
border-radius: 0 30px 30px 0;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
.flatpickr-day.inRange {
|
55
|
+
&.selected {
|
56
|
+
background-color: $primary;
|
57
|
+
box-shadow: none;
|
58
|
+
color: #ffffff;
|
59
|
+
}
|
60
|
+
}
|
61
|
+
.flatpickr-day.selected:hover {
|
62
|
+
transition: none;
|
63
|
+
}
|
64
|
+
}
|
40
65
|
.flatpickr-innerContainer {
|
41
66
|
overflow: visible;
|
42
67
|
}
|
@@ -655,17 +655,13 @@ span.flatpickr-weekday {
|
|
655
655
|
.flatpickr-time {
|
656
656
|
text-align: center;
|
657
657
|
outline: 0;
|
658
|
-
display: block;
|
659
|
-
height: 0;
|
660
658
|
line-height: 40px;
|
661
|
-
max-height: 40px;
|
662
659
|
-webkit-box-sizing: border-box;
|
663
660
|
box-sizing: border-box;
|
664
661
|
overflow: hidden;
|
665
662
|
display: -webkit-box;
|
666
663
|
display: -webkit-flex;
|
667
664
|
display: -ms-flexbox;
|
668
|
-
display: flex;
|
669
665
|
}
|
670
666
|
.flatpickr-time:after {
|
671
667
|
content: "";
|
@@ -677,7 +673,7 @@ span.flatpickr-weekday {
|
|
677
673
|
-webkit-flex: 1;
|
678
674
|
-ms-flex: 1;
|
679
675
|
flex: 1;
|
680
|
-
width:
|
676
|
+
width: 22%;
|
681
677
|
height: 40px;
|
682
678
|
float: left;
|
683
679
|
}
|
@@ -0,0 +1,63 @@
|
|
1
|
+
@import "../../tokens/typography";
|
2
|
+
@import "../../tokens/spacing";
|
3
|
+
@import "../../tokens/colors";
|
4
|
+
|
5
|
+
[class^=pb_date_picker_kit] {
|
6
|
+
.pb_time_selection {
|
7
|
+
color: inherit;
|
8
|
+
text-align: left;
|
9
|
+
margin-left: $space_sm;
|
10
|
+
.numInputWrapper {
|
11
|
+
width: auto;
|
12
|
+
input.numInput {
|
13
|
+
border: 1px solid $border_light !important;
|
14
|
+
border-radius: 5px;
|
15
|
+
text-align: center;
|
16
|
+
width: 60px;
|
17
|
+
margin-left: 0;
|
18
|
+
padding: 0;
|
19
|
+
&:focus {
|
20
|
+
border-color: $primary_action !important;
|
21
|
+
}
|
22
|
+
}
|
23
|
+
span {
|
24
|
+
&.arrowUp, &.arrowDown {
|
25
|
+
display: none;
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
29
|
+
[class^=pb_caption_kit_md], [class^=pb_caption_kit_xs] {
|
30
|
+
line-height: $text_larger;
|
31
|
+
}
|
32
|
+
[class^=pb_caption_kit_xs] {
|
33
|
+
clear: both;
|
34
|
+
display: block;
|
35
|
+
}
|
36
|
+
.flatpickr {
|
37
|
+
&-time-separator {
|
38
|
+
margin: 0 $space_xs;
|
39
|
+
text-align: center;
|
40
|
+
}
|
41
|
+
}
|
42
|
+
.meridiem {
|
43
|
+
[class^=pb_form_group_kit] {
|
44
|
+
margin-left: $space_sm;
|
45
|
+
}
|
46
|
+
|
47
|
+
#datePickerAM, #datePickerPM {
|
48
|
+
display: none;
|
49
|
+
}
|
50
|
+
&:focus, &:hover {
|
51
|
+
background: transparent;
|
52
|
+
}
|
53
|
+
|
54
|
+
[class^=pb_selectable_card_kit] > label {
|
55
|
+
padding: 0;
|
56
|
+
margin: 0;
|
57
|
+
width: 60px;
|
58
|
+
height: 40px;
|
59
|
+
text-align: center;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}
|
63
|
+
}
|
@@ -0,0 +1,127 @@
|
|
1
|
+
@import "../../tokens/colors";
|
2
|
+
|
3
|
+
|
4
|
+
.numInput {
|
5
|
+
border-left: none !important;
|
6
|
+
}
|
7
|
+
|
8
|
+
// Manual Import
|
9
|
+
.flatpickr-monthSelect-months {
|
10
|
+
margin: 10px 1px 3px 1px;
|
11
|
+
flex-wrap: wrap;
|
12
|
+
}
|
13
|
+
|
14
|
+
.flatpickr-monthSelect-month {
|
15
|
+
background: none;
|
16
|
+
border: 1px solid transparent;
|
17
|
+
border-radius: 4px;
|
18
|
+
-webkit-box-sizing: border-box;
|
19
|
+
box-sizing: border-box;
|
20
|
+
color: $text_lt_default;
|
21
|
+
cursor: pointer;
|
22
|
+
display: inline-block;
|
23
|
+
font-weight: 400;
|
24
|
+
margin: 0.5px;
|
25
|
+
justify-content: center;
|
26
|
+
padding: 10px;
|
27
|
+
position: relative;
|
28
|
+
-webkit-box-pack: center;
|
29
|
+
-webkit-justify-content: center;
|
30
|
+
-ms-flex-pack: center;
|
31
|
+
text-align: center;
|
32
|
+
width: 33%;
|
33
|
+
}
|
34
|
+
|
35
|
+
.flatpickr-monthSelect-month.flatpickr-disabled {
|
36
|
+
color: #eee;
|
37
|
+
}
|
38
|
+
|
39
|
+
.flatpickr-monthSelect-month.flatpickr-disabled:hover,
|
40
|
+
.flatpickr-monthSelect-month.flatpickr-disabled:focus {
|
41
|
+
cursor: not-allowed;
|
42
|
+
background: none !important;
|
43
|
+
}
|
44
|
+
|
45
|
+
.flatpickr-monthSelect-theme-dark {
|
46
|
+
background: #3f4458;
|
47
|
+
}
|
48
|
+
|
49
|
+
.flatpickr-monthSelect-theme-dark .flatpickr-current-month input.cur-year {
|
50
|
+
color: #fff;
|
51
|
+
}
|
52
|
+
|
53
|
+
.flatpickr-monthSelect-theme-dark .flatpickr-months .flatpickr-prev-month,
|
54
|
+
.flatpickr-monthSelect-theme-dark .flatpickr-months .flatpickr-next-month {
|
55
|
+
color: #fff;
|
56
|
+
fill: #fff;
|
57
|
+
}
|
58
|
+
|
59
|
+
.flatpickr-monthSelect-theme-dark .flatpickr-monthSelect-month {
|
60
|
+
color: rgba(255, 255, 255, 0.95);
|
61
|
+
}
|
62
|
+
|
63
|
+
.flatpickr-monthSelect-month.today {
|
64
|
+
border-color: #959ea9;
|
65
|
+
}
|
66
|
+
|
67
|
+
.flatpickr-monthSelect-month.inRange,
|
68
|
+
.flatpickr-monthSelect-month.inRange.today,
|
69
|
+
.flatpickr-monthSelect-month:hover,
|
70
|
+
.flatpickr-monthSelect-month:focus {
|
71
|
+
background: $active_light;
|
72
|
+
font-weight: $bold;
|
73
|
+
color: $text_lt_default;
|
74
|
+
cursor: pointer;
|
75
|
+
outline: 0;
|
76
|
+
}
|
77
|
+
|
78
|
+
.flatpickr-monthSelect-theme-dark .flatpickr-monthSelect-month.inRange,
|
79
|
+
.flatpickr-monthSelect-theme-dark .flatpickr-monthSelect-month:hover,
|
80
|
+
.flatpickr-monthSelect-theme-dark .flatpickr-monthSelect-month:focus {
|
81
|
+
background: #646c8c;
|
82
|
+
border-color: #646c8c;
|
83
|
+
}
|
84
|
+
|
85
|
+
.flatpickr-monthSelect-month.today:hover,
|
86
|
+
.flatpickr-monthSelect-month.today:focus {
|
87
|
+
background: #959ea9;
|
88
|
+
border-color: #959ea9;
|
89
|
+
color: #fff;
|
90
|
+
}
|
91
|
+
|
92
|
+
.flatpickr-monthSelect-month.selected,
|
93
|
+
.flatpickr-monthSelect-month.startRange,
|
94
|
+
.flatpickr-monthSelect-month.endRange {
|
95
|
+
background-color: $primary;
|
96
|
+
font-weight: $bold;
|
97
|
+
box-shadow: none;
|
98
|
+
color: #fff;
|
99
|
+
border-color: $primary;
|
100
|
+
}
|
101
|
+
|
102
|
+
.flatpickr-monthSelect-month.startRange {
|
103
|
+
border-radius: 50px 0 0 50px;
|
104
|
+
}
|
105
|
+
|
106
|
+
.flatpickr-monthSelect-month.endRange {
|
107
|
+
border-radius: 0 50px 50px 0;
|
108
|
+
}
|
109
|
+
|
110
|
+
.flatpickr-monthSelect-month.startRange.endRange {
|
111
|
+
border-radius: 50px;
|
112
|
+
}
|
113
|
+
|
114
|
+
.flatpickr-monthSelect-month.inRange {
|
115
|
+
border-radius: 0;
|
116
|
+
box-shadow: -5px 0 0 #e6e6e6, 5px 0 0 #e6e6e6;
|
117
|
+
}
|
118
|
+
|
119
|
+
.flatpickr-monthSelect-theme-dark .flatpickr-monthSelect-month.selected,
|
120
|
+
.flatpickr-monthSelect-theme-dark .flatpickr-monthSelect-month.startRange,
|
121
|
+
.flatpickr-monthSelect-theme-dark .flatpickr-monthSelect-month.endRange {
|
122
|
+
background: #80cbc4;
|
123
|
+
-webkit-box-shadow: none;
|
124
|
+
box-shadow: none;
|
125
|
+
color: #fff;
|
126
|
+
border-color: #80cbc4;
|
127
|
+
}
|
@@ -1,3 +1,5 @@
|
|
1
|
+
/* eslint-disable react/jsx-handler-names */
|
2
|
+
/* eslint-disable react/no-multi-comp */
|
1
3
|
/* @flow */
|
2
4
|
|
3
5
|
import React, { useState } from 'react'
|
@@ -7,13 +9,18 @@ import Modal from 'react-modal'
|
|
7
9
|
import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
|
8
10
|
import { globalProps } from '../utilities/globalProps'
|
9
11
|
|
12
|
+
import Body from '../pb_body/_body'
|
10
13
|
import Button from '../pb_button/_button'
|
11
14
|
import DialogHeader from './child_kits/_dialog_header'
|
12
15
|
import DialogFooter from './child_kits/_dialog_footer'
|
13
16
|
import DialogBody from './child_kits/_dialog_body'
|
17
|
+
import Flex from '../pb_flex/_flex'
|
18
|
+
import IconCircle from '../pb_icon_circle/_icon_circle'
|
19
|
+
import Title from '../pb_title/_title'
|
14
20
|
import { DialogContext } from './_dialog_context'
|
15
21
|
|
16
22
|
type DialogProps = {
|
23
|
+
alertStyle?: "link" | "single" | "stacked" | "default",
|
17
24
|
aria?: object,
|
18
25
|
cancelButton?: string,
|
19
26
|
children: array<React.ReactNode> | React.ReactNode | string,
|
@@ -31,6 +38,7 @@ type DialogProps = {
|
|
31
38
|
portalClassName?: string,
|
32
39
|
shouldCloseOnOverlayClick: boolean,
|
33
40
|
size?: "sm" | "md" | "lg" | "content",
|
41
|
+
status?: "info" | "caution" | "delete" | "error" | "success",
|
34
42
|
text?: string,
|
35
43
|
title?: string,
|
36
44
|
trigger?: string
|
@@ -38,6 +46,7 @@ type DialogProps = {
|
|
38
46
|
|
39
47
|
const Dialog = (props: DialogProps) => {
|
40
48
|
const {
|
49
|
+
alertStyle = "default",
|
41
50
|
aria = {},
|
42
51
|
cancelButton,
|
43
52
|
confirmButton,
|
@@ -53,6 +62,7 @@ const Dialog = (props: DialogProps) => {
|
|
53
62
|
onClose = () => {},
|
54
63
|
portalClassName,
|
55
64
|
shouldCloseOnOverlayClick = true,
|
65
|
+
status,
|
56
66
|
text,
|
57
67
|
title,
|
58
68
|
trigger,
|
@@ -78,15 +88,15 @@ const Dialog = (props: DialogProps) => {
|
|
78
88
|
className
|
79
89
|
)
|
80
90
|
|
91
|
+
const [triggerOpened, setTriggerOpened] = useState(false),
|
92
|
+
modalIsOpened = trigger ? triggerOpened : opened
|
93
|
+
|
81
94
|
const api = {
|
82
95
|
onClose: trigger ? function(){
|
83
96
|
setTriggerOpened(false)
|
84
97
|
} : onClose,
|
85
98
|
}
|
86
99
|
|
87
|
-
const [triggerOpened, setTriggerOpened] = useState(false),
|
88
|
-
modalIsOpened = trigger ? triggerOpened : opened
|
89
|
-
|
90
100
|
if (trigger) {
|
91
101
|
const modalTrigger = document.querySelector(trigger)
|
92
102
|
modalTrigger.addEventListener('click', () => {
|
@@ -97,6 +107,29 @@ const Dialog = (props: DialogProps) => {
|
|
97
107
|
}, { once: true })
|
98
108
|
}
|
99
109
|
|
110
|
+
const sweetAlertStatus = {
|
111
|
+
info: {
|
112
|
+
icon: "exclamation-circle",
|
113
|
+
variant: "default",
|
114
|
+
},
|
115
|
+
caution: {
|
116
|
+
icon: "triangle-warning",
|
117
|
+
variant: "yellow",
|
118
|
+
},
|
119
|
+
delete: {
|
120
|
+
icon: "trash",
|
121
|
+
variant: "red",
|
122
|
+
},
|
123
|
+
error: {
|
124
|
+
icon: "times-circle",
|
125
|
+
variant: "red",
|
126
|
+
},
|
127
|
+
success: {
|
128
|
+
icon: "check-circle",
|
129
|
+
variant: "green",
|
130
|
+
},
|
131
|
+
}
|
132
|
+
|
100
133
|
return (
|
101
134
|
<DialogContext.Provider value={api}>
|
102
135
|
<div
|
@@ -105,6 +138,7 @@ const Dialog = (props: DialogProps) => {
|
|
105
138
|
className={classes}
|
106
139
|
>
|
107
140
|
<Modal
|
141
|
+
alertStyle={alertStyle}
|
108
142
|
ariaHideApp={false}
|
109
143
|
className={dialogClassNames}
|
110
144
|
closeTimeoutMS={200}
|
@@ -115,14 +149,28 @@ const Dialog = (props: DialogProps) => {
|
|
115
149
|
overlayClassName={overlayClassNames}
|
116
150
|
portalClassName={portalClassName}
|
117
151
|
shouldCloseOnOverlayClick={shouldCloseOnOverlayClick}
|
152
|
+
status={status}
|
118
153
|
>
|
119
|
-
<
|
120
|
-
<
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
154
|
+
<Dialog.Body>
|
155
|
+
<Flex align='center'
|
156
|
+
orientation='column'
|
157
|
+
>
|
158
|
+
<If condition = {sweetAlertStatus[status]}>
|
159
|
+
<IconCircle
|
160
|
+
icon={sweetAlertStatus[status].icon}
|
161
|
+
variant={sweetAlertStatus[status].variant}
|
162
|
+
/>
|
163
|
+
</If>
|
164
|
+
<Title marginY='sm'
|
165
|
+
size={3}
|
166
|
+
>
|
167
|
+
{title}
|
168
|
+
</Title>
|
169
|
+
<Body marginY='xs'
|
170
|
+
text={text}
|
171
|
+
/>
|
172
|
+
</Flex>
|
173
|
+
</Dialog.Body>
|
126
174
|
<If condition={cancelButton && confirmButton}>
|
127
175
|
<Dialog.Footer>
|
128
176
|
<Button
|
@@ -131,16 +179,14 @@ const Dialog = (props: DialogProps) => {
|
|
131
179
|
>
|
132
180
|
{confirmButton}
|
133
181
|
</Button>
|
134
|
-
<Button
|
135
|
-
id="cancel-button"
|
182
|
+
<Button id='cancel-button'
|
136
183
|
onClick={onCancel}
|
137
|
-
variant=
|
184
|
+
variant='link'
|
138
185
|
>
|
139
186
|
{cancelButton}
|
140
187
|
</Button>
|
141
188
|
</Dialog.Footer>
|
142
189
|
</If>
|
143
|
-
|
144
190
|
{children}
|
145
191
|
</Modal>
|
146
192
|
</div>
|