playbook_ui 13.34.0.pre.alpha.PLAY14143373 → 13.34.1.pre.alpha.PLAY14043436

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36b22bcec044ccc2dc38617892d16d11d3315798c45ba1c6eb4eb917859c4a11
4
- data.tar.gz: 812f6f8cc2ec0fb4d270fee84a70fd9462dc7aea2ced21591f4592db402e0576
3
+ metadata.gz: a7b3b2595256945a61f10d2d9b0720cee7acfe59d9714a13bc05954b59ed0cbc
4
+ data.tar.gz: 38eb03146799d4a742ec2d42d23d0135f0b1ceab60c2d5b46aa16952756bce75
5
5
  SHA512:
6
- metadata.gz: b34badff8320ee92ed636ca67bd3744933624f58f20811be0e8cc4a575dbc7b9e07fd34a7108675deb87fd126341e5f12e450806e806d5b93dc545b7942b1b8c
7
- data.tar.gz: b6e00cfb7a261f9c9539a9ef976100f22771f00a5a34d483320f24bf445213ae936b5edeb12478f545a0dbf5b841448daceb7fac06ab3107f4dfb1a794650469
6
+ metadata.gz: 9c15cb70edee85bcd089c3540f02d77525e41942dcf81f7d538a603a0656ba91115f509c01e61deb7032ac9a3813b1f45e3c9112e48021407f5b9d8760969772
7
+ data.tar.gz: 8eb55b6abc6e6698faa5918dd00254bc1970382984375a66539c3c9816830dbda1d9def279870b3ef66495fd095a91750fba746f2f5eceb81f69b417994d9a79
@@ -1,7 +1,6 @@
1
1
  import { ensureAccessible, renderKit } from '../utilities/test-utils'
2
2
  import { DateTimeStacked } from 'playbook-ui'
3
3
 
4
- /* eslint-disable jsx-control-statements/jsx-jcs-no-undef */
5
4
  const currentDate = new Date()
6
5
 
7
6
  const datetime = new Date('Wed Mar 31 2021 12:00:00 GMT-0500'),
@@ -183,7 +183,7 @@ const Dialog = (props: DialogProps): React.ReactElement => {
183
183
  onRequestClose={onClose}
184
184
  overlayClassName={overlayClassNames}
185
185
  portalClassName={portalClassName}
186
- shouldCloseOnOverlayClick={shouldCloseOnOverlayClick}
186
+ shouldCloseOnOverlayClick={shouldCloseOnOverlayClick && !loading}
187
187
  >
188
188
  <>
189
189
  {title && !status ? <Dialog.Header>{title}</Dialog.Header> : null}
@@ -215,6 +215,7 @@ const Dialog = (props: DialogProps): React.ReactElement => {
215
215
  {cancelButton && confirmButton ? (
216
216
  <Dialog.Footer>
217
217
  <Button
218
+ disabled={loading}
218
219
  htmlType="button"
219
220
  loading={loading}
220
221
  onClick={onConfirm}
@@ -223,6 +224,7 @@ const Dialog = (props: DialogProps): React.ReactElement => {
223
224
  {confirmButton}
224
225
  </Button>
225
226
  <Button
227
+ disabled={loading}
226
228
  htmlType="button"
227
229
  id="cancel-button"
228
230
  onClick={onCancel}
@@ -1,5 +1,5 @@
1
1
  import React, {useState} from 'react'
2
- import { render, cleanup, waitFor, fireEvent } from "../utilities/test-utils";
2
+ import { render, cleanup, waitFor, fireEvent, screen } from "../utilities/test-utils";
3
3
  import { Dialog, Button } from 'playbook-ui'
4
4
 
5
5
  const text="Hello Body Text, Nice to meet ya."
@@ -110,3 +110,22 @@ test("renders the right placement dialog", async () => {
110
110
  cleanup()
111
111
  });
112
112
 
113
+ test('renders loading dialog with disabled buttons', async () => {
114
+
115
+ const { queryByText } = render(<DialogTest />);
116
+
117
+ fireEvent.click(queryByText('Open Dialog'));
118
+
119
+ await waitFor(() => expect(queryByText("Okay")).toHaveTextContent(confirmButton));
120
+ await waitFor(() => expect(queryByText("Cancel Button")).toHaveTextContent(cancelButton));
121
+
122
+ fireEvent.click(queryByText('Okay'));
123
+
124
+ const loadingIconDiv = document.querySelector('.loading-icon');
125
+ expect(loadingIconDiv).toBeInTheDocument();
126
+
127
+ const cancelBtn = screen.getByRole('button', { name: cancelButton });
128
+ expect(cancelBtn).toBeDisabled();
129
+
130
+ cleanup()
131
+ })
@@ -5,21 +5,17 @@ const DialogDefault = () => {
5
5
  const [isOpen, setIsOpen] = useState(false)
6
6
  const close = () => setIsOpen(false)
7
7
  const open = () => setIsOpen(true)
8
- const [isLoading, setIsLoading] = useState(false)
9
8
 
10
9
  return (
11
10
  <>
12
11
  <Button onClick={open}>{'Open Dialog'}</Button>
13
12
  <Dialog
14
13
  cancelButton="Cancel Button"
15
- className="wrapper"
16
14
  confirmButton="Okay"
17
- loading={isLoading}
18
15
  onCancel={close}
19
16
  onClose={close}
20
- onConfirm={() => setIsLoading(!isLoading)}
17
+ onConfirm={close}
21
18
  opened={isOpen}
22
- portalClassName="portal"
23
19
  size="sm"
24
20
  text="Hello Body Text, Nice to meet ya."
25
21
  title="Header Title is the Title Prop"
@@ -0,0 +1,46 @@
1
+ import React, { useState } from 'react'
2
+ import { Button, Dialog } from 'playbook-ui'
3
+
4
+ const DialogLoading = () => {
5
+ const [isOpen, setIsOpen] = useState(false)
6
+ const close = () => {
7
+ if (!isLoading) {
8
+ setIsOpen(false)
9
+ }
10
+ }
11
+ const open = () => setIsOpen(true)
12
+ const [isLoading, setIsLoading] = useState(false)
13
+ const submit = async () => {
14
+ setIsLoading(true)
15
+
16
+ try {
17
+ await new Promise((r) => setTimeout(r, 3000))
18
+ setIsOpen(false)
19
+ } catch (error) {
20
+ console.error("An error occurred.")
21
+ } finally {
22
+ setIsLoading(false)
23
+ }
24
+ }
25
+
26
+ return (
27
+ <>
28
+ <Button onClick={open}>{'Open Dialog'}</Button>
29
+ <Dialog
30
+ cancelButton="Cancel"
31
+ className="wrapper"
32
+ confirmButton="Okay"
33
+ loading={isLoading}
34
+ onCancel={close}
35
+ onClose={close}
36
+ onConfirm={submit}
37
+ opened={isOpen}
38
+ size="sm"
39
+ text="Make a 3 second request?"
40
+ title="Loading Example"
41
+ />
42
+ </>
43
+ )
44
+ }
45
+
46
+ export default DialogLoading
@@ -22,6 +22,7 @@ examples:
22
22
  - dialog_stacked_alert: Stacked Button Alert
23
23
  - dialog_full_height: Full Height
24
24
  - dialog_full_height_placement: Full Height Placement
25
+ - dialog_loading: Loading
25
26
 
26
27
  swift:
27
28
  - dialog_default_swift: Simple
@@ -8,3 +8,4 @@ export { default as DialogStatus } from './_dialog_status.jsx'
8
8
  export { default as DialogStackedAlert } from './_dialog_stacked_alert.jsx'
9
9
  export { default as DialogFullHeight } from './_dialog_full_height.jsx'
10
10
  export { default as DialogFullHeightPlacement } from './_dialog_full_height_placement.jsx'
11
+ export { default as DialogLoading } from './_dialog_loading.jsx'
@@ -8,7 +8,7 @@ $icon_colors: map-merge($merge_kits3, $data_colors);
8
8
 
9
9
  .pb_custom_icon, .pb_icon_kit {
10
10
  @each $color_name, $color_value in $icon_colors {
11
- &[class*="#{$color_name}"] {
11
+ &[class*="color_#{$color_name}"]{
12
12
  color: $color_value;
13
13
  }
14
14
  }
@@ -1,4 +1,3 @@
1
- /* eslint-disable jsx-control-statements/jsx-use-if-tag */
2
1
  import React, { useEffect } from 'react'
3
2
  import Slides from './Slides'
4
3
  import Thumbnails from './Thumbnails'
@@ -1,4 +1,3 @@
1
- /* eslint-disable jsx-control-statements/jsx-use-if-tag */
2
1
  import React, { useState } from 'react'
3
2
  import { Flex, Image } from 'playbook-ui'
4
3
  import Lightbox from '../_lightbox.tsx'
@@ -1,4 +1,3 @@
1
- /* eslint-disable jsx-control-statements/jsx-use-if-tag */
2
1
  import React, { useState } from 'react'
3
2
  import { Flex, Image, Button, Body, FlexItem } from 'playbook-ui'
4
3
  import Lightbox from '../_lightbox.tsx'
@@ -1,4 +1,3 @@
1
- /* eslint-disable jsx-control-statements/jsx-use-if-tag */
2
1
  import React, { useState } from "react";
3
2
  import { Flex, Image, Title, Pill } from "playbook-ui";
4
3
  import Lightbox from "../_lightbox.tsx";
@@ -1,4 +1,3 @@
1
- /* eslint-disable jsx-control-statements/jsx-use-if-tag */
2
1
  import React, { useState } from 'react'
3
2
  import { Flex, Image } from 'playbook-ui'
4
3
  import Lightbox from '../_lightbox.tsx'
@@ -1,4 +1,3 @@
1
- /* eslint-disable jsx-control-statements/jsx-use-if-tag */
2
1
  import React, { useState } from 'react'
3
2
  import { Flex, Image } from 'playbook-ui'
4
3
  import Lightbox from '../_lightbox.tsx'