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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +1 -1
  3. data/app/pb_kits/playbook/pb_date_picker/docs/example.yml +0 -2
  4. data/app/pb_kits/playbook/pb_date_picker/docs/index.js +0 -1
  5. data/app/pb_kits/playbook/pb_date_picker/plugins/quickPick.tsx +1 -17
  6. data/app/pb_kits/playbook/pb_drawer/_drawer.scss +175 -88
  7. data/app/pb_kits/playbook/pb_drawer/_drawer.tsx +47 -79
  8. data/app/pb_kits/playbook/pb_drawer/drawer.test.jsx +16 -20
  9. data/app/pb_kits/playbook/pb_form/docs/_form_form_with.html.erb +2 -2
  10. data/app/pb_kits/playbook/pb_form/docs/_form_form_with_loading.html.erb +1 -1
  11. data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +12 -63
  12. data/app/pb_kits/playbook/pb_timeline/_timeline.scss +1 -43
  13. data/app/pb_kits/playbook/pb_timeline/_timeline.tsx +2 -6
  14. data/app/pb_kits/playbook/pb_timeline/docs/example.yml +3 -5
  15. data/app/pb_kits/playbook/pb_timeline/docs/index.js +0 -2
  16. data/app/pb_kits/playbook/pb_timeline/timeline.rb +1 -11
  17. data/app/pb_kits/playbook/pb_timeline/timeline.test.js +4 -4
  18. data/app/pb_kits/playbook/pb_typeahead/index.ts +2 -36
  19. data/app/pb_kits/playbook/pb_typeahead/typeahead.html.erb +2 -5
  20. data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +0 -4
  21. data/app/pb_kits/playbook/utilities/_hover.scss +27 -40
  22. data/app/pb_kits/playbook/utilities/globalProps.ts +3 -5
  23. data/dist/chunks/_typeahead-DhLic2Fe.js +22 -0
  24. data/dist/chunks/_weekday_stacked-Mx8TYP5I.js +45 -0
  25. data/dist/chunks/{lib-GRGYd9YR.js → lib-D-mTv-kp.js} +1 -1
  26. data/dist/chunks/{pb_form_validation-CS6rgdtE.js → pb_form_validation-BkWGwJsl.js} +1 -1
  27. data/dist/chunks/vendor.js +1 -1
  28. data/dist/playbook-doc.js +1 -1
  29. data/dist/playbook-rails-react-bindings.js +1 -1
  30. data/dist/playbook-rails.js +1 -1
  31. data/dist/playbook.css +1 -1
  32. data/lib/playbook/forms/builder/typeahead_field.rb +0 -13
  33. data/lib/playbook/hover.rb +1 -1
  34. data/lib/playbook/version.rb +1 -1
  35. metadata +6 -13
  36. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_quick_pick_default_date.html.erb +0 -42
  37. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_quick_pick_default_date.jsx +0 -44
  38. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_quick_pick_default_date.md +0 -1
  39. data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_gap.html.erb +0 -94
  40. data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_gap.jsx +0 -180
  41. data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_gap.md +0 -1
  42. data/app/pb_kits/playbook/utilities/test/globalProps/hover.test.js +0 -79
  43. data/dist/chunks/_typeahead-CA5rhmXa.js +0 -22
  44. data/dist/chunks/_weekday_stacked-9SqFhGPG.js +0 -45
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f74c864e0b28a72c58ed441ea7c3e26d913a0f5d43d478ed4e25a9cdb8305e28
4
- data.tar.gz: f1197937eed8354a6deb1fa7a25903cf2884af86f2f11c080aed2f45b3525f8c
3
+ metadata.gz: eb4670689518bf254b63ee24477971a5e2c1666b7f452199ad898551857bd62a
4
+ data.tar.gz: d334c3d12c391703d725f9a608c454087732ed3beda3cdca6e5b0bbb000dde49
5
5
  SHA512:
6
- metadata.gz: fb2220fe41c9c975e651cad80ea071f1b563713d1b037fd7d7b2561113adc6c44f0cdbb51f85ef29cceb2f79aabf1a82b184483eee9ce738be2b7d44e8cae80a
7
- data.tar.gz: 349fd43db3d601210f1cc77adbec7fffa313e5dcef5924aabdee3cf5671e85eabbe201d731f15ed1637c1c19fc3f83f1f400c5e46040df4c9676735fa1eca7ad
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, defaultDate as string))
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, defaultDate: string) => {
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
- @keyframes modalFadeInLeft {
21
- from {
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: translateX(0);
14
+ transform: translate3d(0, -100%, 0);
15
+ opacity: 0;
32
16
  }
33
17
  to {
34
- transform: translateX(-100%);
18
+ transform: translate3d(0, 0, 0);
19
+ opacity: 1;
35
20
  }
36
21
  }
37
22
 
38
- @keyframes modalFadeInRight {
23
+ @keyframes modalFadeOut {
39
24
  from {
40
- transform: translateX(100%);
25
+ transform: translate3d(0, 0, 0);
26
+ opacity: 1;
41
27
  }
42
28
  to {
43
- transform: translateX(0);
29
+ transform: translate3d(0, -50%, 0);
30
+ opacity: 0;
44
31
  }
45
32
  }
46
33
 
47
- @keyframes modalFadeOutRight {
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 modalFadeIn {
36
+ @keyframes overlayFade {
57
37
  from {
58
- transform: translateY(-100%);
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 modalFadeOut {
47
+ @keyframes overlayFadeOut {
66
48
  from {
67
- transform: translateY(0);
49
+ opacity: 1;
68
50
  }
69
51
  to {
70
- transform: translateY(-100%);
52
+ opacity: 0;
71
53
  }
72
54
  }
73
55
 
74
- body.PBDrawer__Body--open {
75
- transition: margin-left $animation-duration ease-in, margin-right $animation-duration ease-in;
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: translate3d(0, 0, 0);
69
+ transform: translateX(0); /* Slide in */
92
70
  }
93
-
94
71
  // Drawer Styles
95
72
  .pb_drawer {
96
- will-change: transform;
97
- backface-visibility: hidden;
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: $z_9;
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
- // General _before_close styles
119
- &[class*="_before_close"] {
120
- animation-name: modalFadeOut;
121
- animation-duration: $animation-duration;
106
+ &.drawer_border_full {
107
+ box-shadow: none;
108
+ border: 2px solid #f3f7fb;
122
109
  }
123
110
 
124
- &[class*="_left"] {
125
- animation-name: modalFadeInLeft;
111
+ &.drawer_border_right {
112
+ border-right: 2px solid #f3f7fb;
126
113
  }
127
114
 
128
- &[class*="_left"][class*="_before_close"] {
129
- animation-name: modalFadeOutLeft;
130
- animation-duration: $animation-duration;
115
+ &.drawer_border_left {
116
+ border-left: 2px solid #f3f7fb;
131
117
  }
132
118
 
133
- &[class*="_right"] {
134
- animation-name: modalFadeInRight;
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"][class*="_before_close"] {
138
- animation-name: modalFadeOutRight;
139
- animation-duration: $animation-duration;
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
- width: $xlarge;
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.PBDrawer--open {
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
- width: $xlarge;
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
- [class*="drawer_header"] {
372
- padding: $space_sm;
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
- [class*="drawer_footer"] {
376
- padding: $space_sm;
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
- "p_",
62
- "pb_",
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 += " p_sm";
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 ? "_overlay" : "_no_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(buildCss("pb_drawer_wrapper"), className);
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["breakpoint"], number> = {
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 === "none") return;
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("resize", handleResize);
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("resize", handleResize);
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["size"], string> = {
161
- xl: "365px",
162
- lg: "300px",
163
- md: "250px",
164
- sm: "200px",
165
- xs: "64px",
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("body");
143
+ const body = document.querySelector('body');
168
144
 
169
- if (modalIsOpened && behavior === "push" && body) {
170
- if (placement === "left") {
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 === "right") {
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("PBDrawer__Body--open");
152
+ body.classList.add('ReactModal__Body--open');
177
153
  } else if (body) {
178
- if (body.classList.contains("PBDrawer__Body--open")) {
179
- body.classList.add("PBDrawer__Body--close");
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
- {isModalVisible && (
203
- <div
204
- className={classnames(overlayClassNames.base, {
205
- [overlayClassNames.afterOpen]: animationState === "afterOpen",
206
- [overlayClassNames.beforeClose]: animationState === "beforeClose",
207
- })}
208
- id={id}
209
- onClick={overlay ? onClose : undefined}
210
- >
211
- <div
212
- className={classnames(drawerClassNames.base, {
213
- [drawerClassNames.afterOpen]: animationState === "afterOpen",
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
- </div>
220
- </div>
221
- )}
222
- </div>
188
+ </>
189
+ </Modal>
190
+ </div>
223
191
  </DialogContext.Provider>
224
192
  );
225
193
  };