playbook_ui 14.7.0.pre.alpha.revert3916revert3893PBNTR667railstypeaheadformintegration4523 → 14.7.0.pre.alpha.spacingquickchange4482
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_date_picker/date_picker_helper.ts +1 -1
- data/app/pb_kits/playbook/pb_date_picker/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_date_picker/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_date_picker/plugins/quickPick.tsx +1 -17
- data/app/pb_kits/playbook/pb_drawer/_drawer.scss +175 -88
- data/app/pb_kits/playbook/pb_drawer/_drawer.tsx +47 -79
- data/app/pb_kits/playbook/pb_drawer/drawer.test.jsx +16 -20
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with.html.erb +2 -2
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with_loading.html.erb +1 -1
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +12 -63
- data/app/pb_kits/playbook/pb_timeline/_timeline.scss +1 -43
- data/app/pb_kits/playbook/pb_timeline/_timeline.tsx +2 -6
- data/app/pb_kits/playbook/pb_timeline/docs/example.yml +3 -5
- data/app/pb_kits/playbook/pb_timeline/docs/index.js +0 -2
- data/app/pb_kits/playbook/pb_timeline/timeline.rb +1 -11
- data/app/pb_kits/playbook/pb_timeline/timeline.test.js +4 -4
- data/app/pb_kits/playbook/pb_typeahead/index.ts +2 -36
- data/app/pb_kits/playbook/pb_typeahead/typeahead.html.erb +2 -5
- data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +0 -4
- data/app/pb_kits/playbook/utilities/_hover.scss +27 -40
- data/app/pb_kits/playbook/utilities/globalProps.ts +3 -5
- data/dist/chunks/_typeahead-DhLic2Fe.js +22 -0
- data/dist/chunks/_weekday_stacked-Mx8TYP5I.js +45 -0
- data/dist/chunks/{lib-GRGYd9YR.js → lib-D-mTv-kp.js} +1 -1
- data/dist/chunks/{pb_form_validation-CS6rgdtE.js → pb_form_validation-BkWGwJsl.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +1 -1
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/forms/builder/typeahead_field.rb +0 -13
- data/lib/playbook/hover.rb +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +6 -13
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_quick_pick_default_date.html.erb +0 -42
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_quick_pick_default_date.jsx +0 -44
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_quick_pick_default_date.md +0 -1
- data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_gap.html.erb +0 -94
- data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_gap.jsx +0 -180
- data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_gap.md +0 -1
- data/app/pb_kits/playbook/utilities/test/globalProps/hover.test.js +0 -79
- data/dist/chunks/_typeahead-CA5rhmXa.js +0 -22
- data/dist/chunks/_weekday_stacked-9SqFhGPG.js +0 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb4670689518bf254b63ee24477971a5e2c1666b7f452199ad898551857bd62a
|
4
|
+
data.tar.gz: d334c3d12c391703d725f9a608c454087732ed3beda3cdca6e5b0bbb000dde49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '05496ee6555f50603e6fec1676da0f40c0fc2de7d90869409cd06b2de2d7e7a70896d6129480363fc6f908b22e6413406bbe29177a468480daca64af5f0fae5d'
|
7
|
+
data.tar.gz: bb61330ca3b6dc7340b0773eb0fcb3c7ad5312413c61d82f0ef6b070e7b8db8c044ec504c6ad67358135c8b16888c7615da8793114c715e4da8482879ccee752
|
@@ -143,7 +143,7 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
|
|
143
143
|
|
144
144
|
} else if (selectionType === "quickpick") {
|
145
145
|
//------- QUICKPICK VARIANT PLUGIN -------------//
|
146
|
-
pluginList.push(quickPickPlugin(thisRangesEndToday, customQuickPickDates
|
146
|
+
pluginList.push(quickPickPlugin(thisRangesEndToday, customQuickPickDates))
|
147
147
|
}
|
148
148
|
|
149
149
|
// time selection
|
@@ -12,7 +12,6 @@ examples:
|
|
12
12
|
- date_picker_quick_pick_range_limit: Range (Quick Pick w/ “This” Range limit)
|
13
13
|
- date_picker_quick_pick_custom: Custom Quick Pick Dates
|
14
14
|
- date_picker_quick_pick_custom_override: Custom Quick Pick Dates (append to defaults)
|
15
|
-
- date_picker_quick_pick_default_date: Range (Quick Pick w/ Default Date)
|
16
15
|
- date_picker_format: Format
|
17
16
|
- date_picker_disabled: Disabled Dates
|
18
17
|
- date_picker_min_max: Min Max
|
@@ -43,7 +42,6 @@ examples:
|
|
43
42
|
- date_picker_quick_pick_range_limit: Range (Quick Pick w/ “This” Range limit)
|
44
43
|
- date_picker_quick_pick_custom: Custom Quick Pick Dates
|
45
44
|
- date_picker_quick_pick_custom_override: Custom Quick Pick Dates (append to defaults)
|
46
|
-
- date_picker_quick_pick_default_date: Range (Quick Pick w/ Default Date)
|
47
45
|
- date_picker_format: Format
|
48
46
|
- date_picker_disabled: Disabled Dates
|
49
47
|
- date_picker_min_max: Min Max
|
@@ -25,4 +25,3 @@ export { default as DatePickerQuickPickRangeLimit } from './_date_picker_quick_p
|
|
25
25
|
export { default as DatePickerOnClose } from './_date_picker_on_close.jsx'
|
26
26
|
export { default as DatePickerQuickPickCustom } from './_date_picker_quick_pick_custom'
|
27
27
|
export { default as DatePickerQuickPickCustomOverride } from './_date_picker_quick_pick_custom_override'
|
28
|
-
export { default as DatePickerQuickPickDefaultDate } from './_date_picker_quick_pick_default_date'
|
@@ -26,7 +26,7 @@ type customQuickPickDatesType = {
|
|
26
26
|
|
27
27
|
let activeLabel = ""
|
28
28
|
|
29
|
-
const quickPickPlugin = (thisRangesEndToday: boolean, customQuickPickDates: customQuickPickDatesType | undefined
|
29
|
+
const quickPickPlugin = (thisRangesEndToday: boolean, customQuickPickDates: customQuickPickDatesType | undefined) => {
|
30
30
|
return function (fp: FpTypes & any): any {
|
31
31
|
const today = new Date()
|
32
32
|
const yesterday = DateTime.getYesterdayDate(new Date())
|
@@ -185,8 +185,6 @@ const quickPickPlugin = (thisRangesEndToday: boolean, customQuickPickDates: cust
|
|
185
185
|
return {
|
186
186
|
// onReady is a hook from flatpickr that runs when calendar is in a ready state
|
187
187
|
onReady(selectedDates: Array<Date>) {
|
188
|
-
let defaultDateRange
|
189
|
-
|
190
188
|
// loop through the ranges and create an anchor tag for each range and add an event listener to set the date when user clicks on a date range
|
191
189
|
for (const [label, range] of Object.entries(pluginData.ranges)) {
|
192
190
|
addRangeButton(label).addEventListener('click', function () {
|
@@ -203,14 +201,6 @@ const quickPickPlugin = (thisRangesEndToday: boolean, customQuickPickDates: cust
|
|
203
201
|
fp.close();
|
204
202
|
}
|
205
203
|
});
|
206
|
-
|
207
|
-
// check if there is a default date and set the default date range and label for quick pick
|
208
|
-
if (defaultDate) {
|
209
|
-
if (label.toLowerCase() === defaultDate.toLowerCase()) {
|
210
|
-
activeLabel = label
|
211
|
-
defaultDateRange = range
|
212
|
-
}
|
213
|
-
}
|
214
204
|
}
|
215
205
|
// conditional to check if there is a dropdown to add it to the calendar container and get it the classes it needs
|
216
206
|
if (pluginData.rangesNav.children.length > 0) {
|
@@ -226,12 +216,6 @@ const quickPickPlugin = (thisRangesEndToday: boolean, customQuickPickDates: cust
|
|
226
216
|
// function to give the active button the active class
|
227
217
|
selectActiveRangeButton(selectedDates);
|
228
218
|
}
|
229
|
-
|
230
|
-
// set the default date range if there is one and select the active button
|
231
|
-
if (defaultDateRange) {
|
232
|
-
fp.setDate(defaultDateRange, false);
|
233
|
-
selectActiveRangeButton(defaultDateRange);
|
234
|
-
}
|
235
219
|
},
|
236
220
|
onValueUpdate(selectedDates: Array<Date>) {
|
237
221
|
selectActiveRangeButton(selectedDates)
|
@@ -7,76 +7,54 @@
|
|
7
7
|
@import "../tokens/animation-curves";
|
8
8
|
@import "../tokens/positioning";
|
9
9
|
|
10
|
-
$gutter: $space_lg;
|
11
|
-
$xsmall: 64px;
|
12
|
-
$small: 200px;
|
13
|
-
$medium: 250px;
|
14
|
-
$large: 300px;
|
15
|
-
$xlarge: 365px;
|
16
|
-
$animation-duration: 0.4s;
|
17
|
-
$z-index: $z_7;
|
18
|
-
|
19
10
|
// Drawer animations
|
20
|
-
|
21
|
-
|
22
|
-
transform: translateX(-100%);
|
23
|
-
}
|
24
|
-
to {
|
25
|
-
transform: translateX(0);
|
26
|
-
}
|
27
|
-
}
|
28
|
-
|
29
|
-
@keyframes modalFadeOutLeft {
|
11
|
+
// Drawer animations for fading in and out from the center
|
12
|
+
@keyframes modalFadeIn {
|
30
13
|
from {
|
31
|
-
transform:
|
14
|
+
transform: translate3d(0, -100%, 0);
|
15
|
+
opacity: 0;
|
32
16
|
}
|
33
17
|
to {
|
34
|
-
transform:
|
18
|
+
transform: translate3d(0, 0, 0);
|
19
|
+
opacity: 1;
|
35
20
|
}
|
36
21
|
}
|
37
22
|
|
38
|
-
@keyframes
|
23
|
+
@keyframes modalFadeOut {
|
39
24
|
from {
|
40
|
-
transform:
|
25
|
+
transform: translate3d(0, 0, 0);
|
26
|
+
opacity: 1;
|
41
27
|
}
|
42
28
|
to {
|
43
|
-
transform:
|
29
|
+
transform: translate3d(0, -50%, 0);
|
30
|
+
opacity: 0;
|
44
31
|
}
|
45
32
|
}
|
46
33
|
|
47
|
-
|
48
|
-
from {
|
49
|
-
transform: translateX(0);
|
50
|
-
}
|
51
|
-
to {
|
52
|
-
transform: translateX(100%);
|
53
|
-
}
|
54
|
-
}
|
34
|
+
// Drawer animations for fading in and out from the right side
|
55
35
|
|
56
|
-
@keyframes
|
36
|
+
@keyframes overlayFade {
|
57
37
|
from {
|
58
|
-
|
38
|
+
opacity: 0;
|
39
|
+
transform: translateY(0);
|
59
40
|
}
|
60
41
|
to {
|
42
|
+
opacity: 1;
|
61
43
|
transform: translateY(0);
|
62
44
|
}
|
63
45
|
}
|
64
46
|
|
65
|
-
@keyframes
|
47
|
+
@keyframes overlayFadeOut {
|
66
48
|
from {
|
67
|
-
|
49
|
+
opacity: 1;
|
68
50
|
}
|
69
51
|
to {
|
70
|
-
|
52
|
+
opacity: 0;
|
71
53
|
}
|
72
54
|
}
|
73
55
|
|
74
|
-
body.
|
75
|
-
transition: margin-left
|
76
|
-
}
|
77
|
-
|
78
|
-
body.PBDrawer__Body--close {
|
79
|
-
transition: margin-left $animation-duration ease-out, margin-right $animation-duration ease-out;
|
56
|
+
body.ReactModal__Body--open {
|
57
|
+
transition: margin-left 0.3s ease-in-out, margin-right 0.3s ease-in-out;
|
80
58
|
}
|
81
59
|
|
82
60
|
.pb_drawer_lg_left.pb_drawer {
|
@@ -88,21 +66,28 @@ body.PBDrawer__Body--close {
|
|
88
66
|
}
|
89
67
|
|
90
68
|
.pb_drawer.pb_drawer_after_open {
|
91
|
-
transform:
|
69
|
+
transform: translateX(0); /* Slide in */
|
92
70
|
}
|
93
|
-
|
94
71
|
// Drawer Styles
|
95
72
|
.pb_drawer {
|
96
|
-
|
97
|
-
|
73
|
+
|
74
|
+
// Local Variables
|
75
|
+
$gutter: $space_lg;
|
76
|
+
$xsmall: 64px;
|
77
|
+
$small: 200px;
|
78
|
+
$medium: 250px;
|
79
|
+
$large: 300px;
|
80
|
+
$xlarge: 365px;
|
81
|
+
$animation-duration: .2s;
|
82
|
+
$z-index: 100;
|
83
|
+
$opacity_visible: 1;
|
84
|
+
$opacity_hidden: 0;
|
98
85
|
|
99
86
|
.drawer {
|
100
87
|
position: sticky;
|
101
|
-
will-change: transform;
|
102
|
-
backface-visibility: hidden;
|
103
88
|
top: 0;
|
104
89
|
background-color: $white;
|
105
|
-
z-index: $
|
90
|
+
z-index: $z_8;
|
106
91
|
}
|
107
92
|
|
108
93
|
// @include pb_card;
|
@@ -112,31 +97,41 @@ body.PBDrawer__Body--close {
|
|
112
97
|
max-height: calc(100vh - #{$gutter * 2});
|
113
98
|
max-width: calc(100vw - #{$gutter * 2});
|
114
99
|
overflow: auto;
|
100
|
+
animation-name: modalFadeIn;
|
115
101
|
animation-duration: $animation-duration;
|
116
102
|
outline: none;
|
103
|
+
animation-timing-function: $easeInOutQuint;
|
104
|
+
transition: transform 0.3s ease-in-out;
|
117
105
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
animation-duration: $animation-duration;
|
106
|
+
&.drawer_border_full {
|
107
|
+
box-shadow: none;
|
108
|
+
border: 2px solid #f3f7fb;
|
122
109
|
}
|
123
110
|
|
124
|
-
|
125
|
-
|
111
|
+
&.drawer_border_right {
|
112
|
+
border-right: 2px solid #f3f7fb;
|
126
113
|
}
|
127
114
|
|
128
|
-
|
129
|
-
|
130
|
-
animation-duration: $animation-duration;
|
115
|
+
&.drawer_border_left {
|
116
|
+
border-left: 2px solid #f3f7fb;
|
131
117
|
}
|
132
118
|
|
133
|
-
&[class*="
|
134
|
-
animation-name:
|
119
|
+
&[class*="_left"] {
|
120
|
+
animation-name: modalFadeInLeft;
|
121
|
+
&[class*="_before_close"] {
|
122
|
+
animation-name: modalFadeOutLeft;
|
123
|
+
animation-duration: $animation-duration;
|
124
|
+
opacity: $opacity_hidden;
|
125
|
+
}
|
135
126
|
}
|
136
127
|
|
137
|
-
&[class*="_right"]
|
138
|
-
animation-name:
|
139
|
-
|
128
|
+
&[class*="_right"] {
|
129
|
+
animation-name: modalFadeInRight;
|
130
|
+
&[class*="_before_close"] {
|
131
|
+
animation-name: modalFadeOutRight;
|
132
|
+
animation-duration: $animation-duration;
|
133
|
+
opacity: $opacity_hidden;
|
134
|
+
}
|
140
135
|
}
|
141
136
|
|
142
137
|
&[class*="_xs_"] {
|
@@ -169,25 +164,19 @@ body.PBDrawer__Body--close {
|
|
169
164
|
}
|
170
165
|
|
171
166
|
&_after_open {
|
172
|
-
|
173
|
-
|
174
|
-
&.drawer_border_full {
|
175
|
-
box-shadow: none;
|
176
|
-
border: 2px solid #f3f7fb;
|
177
|
-
}
|
178
|
-
|
179
|
-
&.drawer_border_right {
|
180
|
-
border-right: 2px solid #f3f7fb;
|
181
|
-
}
|
182
|
-
|
183
|
-
&.drawer_border_left {
|
184
|
-
border-left: 2px solid #f3f7fb;
|
167
|
+
opacity: $opacity_visible;
|
185
168
|
}
|
186
169
|
|
187
170
|
&.no-background {
|
188
171
|
background-color: transparent;
|
189
172
|
}
|
190
173
|
|
174
|
+
&[class*="_before_close"] {
|
175
|
+
animation-name: modalFadeOut;
|
176
|
+
animation-duration: $animation-duration;
|
177
|
+
opacity: $opacity_hidden;
|
178
|
+
}
|
179
|
+
|
191
180
|
&_close_icon {
|
192
181
|
cursor: pointer;
|
193
182
|
}
|
@@ -207,10 +196,12 @@ body.PBDrawer__Body--close {
|
|
207
196
|
animation-duration: $animation-duration;
|
208
197
|
|
209
198
|
&_after_open {
|
199
|
+
opacity: $opacity_visible;
|
210
200
|
}
|
211
201
|
&_before_close {
|
212
202
|
animation-name: overlayFadeOut;
|
213
203
|
animation-duration: $animation-duration;
|
204
|
+
opacity: $opacity_hidden;
|
214
205
|
}
|
215
206
|
&[class*="full_height"] {
|
216
207
|
&[class*="_left"]{
|
@@ -267,12 +258,12 @@ body.PBDrawer__Body--close {
|
|
267
258
|
&[class*="_xl_"] {
|
268
259
|
width: $xlarge;
|
269
260
|
.dialog_footer {
|
270
|
-
|
271
|
-
}
|
261
|
+
width: $xlarge;
|
272
262
|
}
|
273
263
|
}
|
274
264
|
}
|
275
265
|
}
|
266
|
+
}
|
276
267
|
|
277
268
|
&_no_overlay {
|
278
269
|
position: fixed;
|
@@ -289,18 +280,20 @@ body.PBDrawer__Body--close {
|
|
289
280
|
overflow: none; /* Ensure body remains scrollable */
|
290
281
|
pointer-events: none; /* Allow interaction inside the drawer itself */
|
291
282
|
|
292
|
-
body.
|
283
|
+
body.ReactModal__Body--open {
|
293
284
|
overflow: none; /* Ensure body remains scrollable */
|
294
285
|
pointer-events: none; /* Allow interaction inside the drawer itself */
|
295
286
|
}
|
296
287
|
|
297
288
|
&_after_open {
|
289
|
+
opacity: $opacity_visible;
|
298
290
|
overflow: none; /* Ensure body remains scrollable */
|
299
291
|
pointer-events: none; /* Allow interaction inside the drawer itself */
|
300
292
|
}
|
301
293
|
&_before_close {
|
302
294
|
animation-name: overlayFadeOut;
|
303
295
|
animation-duration: $animation-duration;
|
296
|
+
opacity: $opacity_hidden;
|
304
297
|
}
|
305
298
|
&[class*="full_height"] {
|
306
299
|
&[class*="_left"]{
|
@@ -357,22 +350,116 @@ body.PBDrawer__Body--close {
|
|
357
350
|
&[class*="_xl_"] {
|
358
351
|
width: $xlarge;
|
359
352
|
.dialog_footer {
|
360
|
-
|
361
|
-
}
|
353
|
+
width: $xlarge;
|
362
354
|
}
|
363
355
|
}
|
364
356
|
}
|
365
357
|
}
|
358
|
+
}
|
359
|
+
|
360
|
+
[class*="drawer_body"] {
|
361
|
+
padding: $space_sm;
|
362
|
+
}
|
363
|
+
|
364
|
+
[class*="drawer_header"] {
|
365
|
+
padding: $space_sm;
|
366
|
+
}
|
367
|
+
|
368
|
+
[class*="drawer_footer"] {
|
369
|
+
padding: $space_sm;
|
370
|
+
}
|
371
|
+
|
372
|
+
//styles specific to rails version of kit
|
373
|
+
// rails version has own wrapper because of the way the overlay functions for the HTML drawer used to create this
|
374
|
+
.pb_drawer_wrapper_rails {
|
375
|
+
$medium: 500px;
|
376
|
+
$large: 800px;
|
377
|
+
$xlarge: 1150px;
|
378
|
+
|
379
|
+
&[class*="full_height"] {
|
380
|
+
&[class*="_left"]{
|
381
|
+
.pb_drawer_rails {
|
382
|
+
margin: unset !important;
|
383
|
+
margin-right: auto !important;
|
384
|
+
}
|
385
|
+
}
|
386
|
+
|
387
|
+
&[class*="_center"]{
|
388
|
+
justify-content: center;
|
389
|
+
}
|
390
|
+
|
391
|
+
&[class*="_right"]{
|
392
|
+
.pb_drawer_rails {
|
393
|
+
margin: unset !important;
|
394
|
+
margin-left: auto !important;
|
395
|
+
}
|
396
|
+
}
|
397
|
+
|
398
|
+
.pb_drawer {
|
399
|
+
height: 100% !important;
|
400
|
+
max-height: 100% !important;
|
401
|
+
max-width: 100%;
|
402
|
+
// This empty div only has height when drawer is full height.
|
403
|
+
// Fix for drawer body content disappearing behind sticky footer
|
404
|
+
.drawer-pseudo-footer {
|
405
|
+
height: $space_xl * 2;
|
406
|
+
}
|
407
|
+
.drawer_footer {
|
408
|
+
position:fixed;
|
409
|
+
bottom: 0;
|
410
|
+
background-color: $white;
|
411
|
+
max-width: 100%;
|
412
|
+
}
|
413
|
+
&[class*="_sm"] {
|
414
|
+
width: $medium;
|
415
|
+
.drawer_footer {
|
416
|
+
width: $medium;
|
417
|
+
}
|
418
|
+
}
|
419
|
+
&[class*="_md"] {
|
420
|
+
width: $large;
|
421
|
+
.drawer_footer {
|
422
|
+
width: $large;
|
423
|
+
}
|
424
|
+
}
|
425
|
+
&[class*="_lg"] {
|
426
|
+
width: $xlarge;
|
427
|
+
.drawer_footer {
|
428
|
+
width: $xlarge;
|
429
|
+
}
|
430
|
+
}
|
431
|
+
}
|
432
|
+
}
|
433
|
+
|
434
|
+
// Fixes for stylesheets in nitro that were conflicting with our kit. DO NOT REMOVE.
|
435
|
+
// Conflicts were only apparent in nitro, not in playbook local env
|
436
|
+
.pb_drawer_rails {
|
437
|
+
position: fixed !important;
|
438
|
+
top: 0 !important;
|
439
|
+
padding: unset !important;
|
440
|
+
margin: auto;
|
366
441
|
|
367
|
-
[class*="drawer_body"] {
|
368
|
-
padding: $space_sm;
|
369
442
|
}
|
370
443
|
|
371
|
-
|
372
|
-
|
444
|
+
// Overlay for rails kit
|
445
|
+
drawer::backdrop {
|
446
|
+
position: fixed;
|
447
|
+
top: 0;
|
448
|
+
left: 0;
|
449
|
+
right: 0;
|
450
|
+
bottom: 0;
|
451
|
+
display: flex;
|
452
|
+
align-items: center;
|
453
|
+
justify-content: center;
|
454
|
+
background-color: rgba($bg_dark, $opacity_4);
|
455
|
+
animation-name: overlayFade;
|
456
|
+
animation-duration: 0.2s;
|
373
457
|
}
|
374
458
|
|
375
|
-
|
376
|
-
|
459
|
+
.drawer-button-class {
|
460
|
+
background-color: unset;
|
461
|
+
border: none;
|
462
|
+
cursor: pointer;
|
377
463
|
}
|
378
464
|
}
|
465
|
+
}
|
@@ -1,12 +1,8 @@
|
|
1
1
|
import React, { useState, useEffect } from "react";
|
2
2
|
import classnames from "classnames";
|
3
|
+
import Modal from "react-modal";
|
3
4
|
|
4
|
-
import {
|
5
|
-
buildAriaProps,
|
6
|
-
buildCss,
|
7
|
-
buildDataProps,
|
8
|
-
buildHtmlProps,
|
9
|
-
} from "../utilities/props";
|
5
|
+
import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from "../utilities/props";
|
10
6
|
import { globalProps } from "../utilities/globalProps";
|
11
7
|
|
12
8
|
import { DialogContext } from "../pb_dialog/_dialog_context";
|
@@ -57,19 +53,13 @@ const Drawer = (props: DrawerProps): React.ReactElement => {
|
|
57
53
|
let globalPropsString: string = globalProps(props);
|
58
54
|
|
59
55
|
// Check if the string contains any of the prefixes
|
60
|
-
const containsPrefix = [
|
61
|
-
|
62
|
-
|
63
|
-
"pt_",
|
64
|
-
"pl_",
|
65
|
-
"pr_",
|
66
|
-
"px_",
|
67
|
-
"py_",
|
68
|
-
].some((prefix) => globalPropsString.includes(prefix));
|
56
|
+
const containsPrefix = ['p_', 'pb_', 'pt_', 'pl_', 'pr_', 'px_', 'py_'].some((prefix) =>
|
57
|
+
globalPropsString.includes(prefix)
|
58
|
+
);
|
69
59
|
|
70
60
|
// If none of the prefixes are found, append 'p_sm' to the string
|
71
61
|
if (!containsPrefix) {
|
72
|
-
globalPropsString +=
|
62
|
+
globalPropsString += ' p_sm';
|
73
63
|
}
|
74
64
|
|
75
65
|
const drawerClassNames = {
|
@@ -77,9 +67,9 @@ const Drawer = (props: DrawerProps): React.ReactElement => {
|
|
77
67
|
"pb_drawer",
|
78
68
|
buildCss("pb_drawer", size, placement),
|
79
69
|
{
|
80
|
-
drawer_border_full: border === "full",
|
81
|
-
drawer_border_right: border === "right",
|
82
|
-
drawer_border_left: border === "left",
|
70
|
+
"drawer_border_full": border === "full",
|
71
|
+
"drawer_border_right": border === "right",
|
72
|
+
"drawer_border_left": border === "left",
|
83
73
|
}
|
84
74
|
)} ${globalPropsString}`,
|
85
75
|
afterOpen: "pb_drawer_after_open",
|
@@ -92,18 +82,19 @@ const Drawer = (props: DrawerProps): React.ReactElement => {
|
|
92
82
|
};
|
93
83
|
|
94
84
|
const overlayClassNames = {
|
95
|
-
base: `pb_drawer${overlay ?
|
96
|
-
fullHeight !== null && fullHeightClassNames()
|
97
|
-
} ${!overlay ? "no-background" : ""}`,
|
85
|
+
base: `pb_drawer${overlay ? '_overlay' : '_no_overlay'} ${fullHeight !== null && fullHeightClassNames()} ${!overlay ? 'no-background' : ''}`,
|
98
86
|
afterOpen: "pb_drawer_overlay_after_open",
|
99
87
|
beforeClose: "pb_drawer_overlay_before_close",
|
100
88
|
};
|
101
89
|
|
102
|
-
const classes = classnames(
|
90
|
+
const classes = classnames(
|
91
|
+
buildCss("pb_drawer_wrapper"),
|
92
|
+
className
|
93
|
+
);
|
103
94
|
|
104
95
|
const [triggerOpened, setTriggerOpened] = useState(false);
|
105
96
|
|
106
|
-
const breakpointWidths: Record<DrawerProps[
|
97
|
+
const breakpointWidths: Record<DrawerProps['breakpoint'], number> = {
|
107
98
|
none: 0,
|
108
99
|
xs: 575,
|
109
100
|
sm: 768,
|
@@ -116,7 +107,7 @@ const Drawer = (props: DrawerProps): React.ReactElement => {
|
|
116
107
|
const [isBreakpointOpen, setIsBreakpointOpen] = useState(false);
|
117
108
|
|
118
109
|
useEffect(() => {
|
119
|
-
if (breakpoint ===
|
110
|
+
if (breakpoint === 'none') return;
|
120
111
|
|
121
112
|
const handleResize = () => {
|
122
113
|
const width = window.innerWidth;
|
@@ -129,57 +120,39 @@ const Drawer = (props: DrawerProps): React.ReactElement => {
|
|
129
120
|
}
|
130
121
|
};
|
131
122
|
|
132
|
-
window.addEventListener(
|
123
|
+
window.addEventListener('resize', handleResize);
|
133
124
|
|
134
125
|
// Call handler once on mount to set initial state
|
135
126
|
handleResize();
|
136
127
|
|
137
128
|
return () => {
|
138
|
-
window.removeEventListener(
|
129
|
+
window.removeEventListener('resize', handleResize);
|
139
130
|
};
|
140
131
|
}, [breakpoint]);
|
141
132
|
|
142
|
-
const modalIsOpened = trigger ? triggerOpened : opened || isBreakpointOpen;
|
143
|
-
|
144
|
-
const [animationState, setAnimationState] = useState("");
|
145
|
-
|
146
|
-
useEffect(() => {
|
147
|
-
if (modalIsOpened) {
|
148
|
-
setAnimationState("afterOpen");
|
149
|
-
} else if (!modalIsOpened && animationState === "afterOpen") {
|
150
|
-
setAnimationState("beforeClose");
|
151
|
-
setTimeout(() => {
|
152
|
-
setAnimationState("");
|
153
|
-
}, 200); // closeTimeoutMS
|
154
|
-
}
|
155
|
-
}, [modalIsOpened]);
|
156
|
-
|
157
|
-
const isModalVisible = modalIsOpened || animationState === "beforeClose";
|
133
|
+
const modalIsOpened = trigger ? triggerOpened : (opened || isBreakpointOpen);
|
158
134
|
|
159
135
|
useEffect(() => {
|
160
|
-
const sizeMap: Record<DrawerProps[
|
161
|
-
xl:
|
162
|
-
lg:
|
163
|
-
md:
|
164
|
-
sm:
|
165
|
-
xs:
|
136
|
+
const sizeMap: Record<DrawerProps['size'], string> = {
|
137
|
+
xl: '365px',
|
138
|
+
lg: '300px',
|
139
|
+
md: '250px',
|
140
|
+
sm: '200px',
|
141
|
+
xs: '64px',
|
166
142
|
};
|
167
|
-
const body = document.querySelector(
|
143
|
+
const body = document.querySelector('body');
|
168
144
|
|
169
|
-
if (modalIsOpened && behavior ===
|
170
|
-
if (placement ===
|
145
|
+
if (modalIsOpened && behavior === 'push' && body) {
|
146
|
+
if (placement === 'left') {
|
171
147
|
body.style.cssText = `margin-left: ${sizeMap[size]} !important; margin-right: '' !important;`;
|
172
|
-
} else if (placement ===
|
148
|
+
} else if (placement === 'right') {
|
173
149
|
body.style.cssText = `margin-right: ${sizeMap[size]} !important; margin-left: '' !important;`;
|
174
150
|
}
|
175
151
|
|
176
|
-
body.classList.add(
|
152
|
+
body.classList.add('ReactModal__Body--open');
|
177
153
|
} else if (body) {
|
178
|
-
|
179
|
-
|
180
|
-
}
|
181
|
-
body.style.cssText = ""; // Clear the styles when modal is closed or behavior is not 'push'
|
182
|
-
body.classList.remove("PBDrawer__Body--open");
|
154
|
+
body.style.cssText = ''; // Clear the styles when modal is closed or behavior is not 'push'
|
155
|
+
body.classList.remove('ReactModal__Body--open');
|
183
156
|
}
|
184
157
|
}, [modalIsOpened, behavior, placement, size]);
|
185
158
|
|
@@ -199,27 +172,22 @@ const Drawer = (props: DrawerProps): React.ReactElement => {
|
|
199
172
|
{...htmlProps}
|
200
173
|
className={classes}
|
201
174
|
>
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
}
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
[drawerClassNames.beforeClose]: animationState === "beforeClose",
|
215
|
-
})}
|
216
|
-
onClick={(e) => e.stopPropagation()}
|
217
|
-
>
|
175
|
+
<Modal
|
176
|
+
ariaHideApp={false}
|
177
|
+
className={drawerClassNames}
|
178
|
+
closeTimeoutMS={200}
|
179
|
+
contentLabel="Minimal Modal Example"
|
180
|
+
id={id}
|
181
|
+
isOpen={modalIsOpened}
|
182
|
+
onRequestClose={onClose}
|
183
|
+
overlayClassName={overlayClassNames}
|
184
|
+
shouldCloseOnOverlayClick={overlay}
|
185
|
+
>
|
186
|
+
<>
|
218
187
|
{children}
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
</div>
|
188
|
+
</>
|
189
|
+
</Modal>
|
190
|
+
</div>
|
223
191
|
</DialogContext.Provider>
|
224
192
|
);
|
225
193
|
};
|