@atlaskit/popup 1.17.2 → 1.19.0

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.
@@ -7,39 +7,39 @@ import Popup from '../src';
7
7
  import { interactionTasks } from './utils/interaction-tasks';
8
8
 
9
9
  function PopupStoryButton() {
10
- const [isOpen, setIsOpen] = React.useState(false);
11
- return (
12
- <Popup
13
- isOpen={isOpen}
14
- onClose={() => setIsOpen(false)}
15
- content={() => (
16
- <div data-testid="popup">
17
- <Button>Test</Button>
18
- </div>
19
- )}
20
- trigger={(triggerProps) => (
21
- <Button
22
- testId="popup-trigger"
23
- {...triggerProps}
24
- onClick={() => {
25
- setIsOpen(!isOpen);
26
- }}
27
- >
28
- Click to toggle
29
- </Button>
30
- )}
31
- placement="bottom"
32
- />
33
- );
10
+ const [isOpen, setIsOpen] = React.useState(false);
11
+ return (
12
+ <Popup
13
+ isOpen={isOpen}
14
+ onClose={() => setIsOpen(false)}
15
+ content={() => (
16
+ <div data-testid="popup">
17
+ <Button>Test</Button>
18
+ </div>
19
+ )}
20
+ trigger={(triggerProps) => (
21
+ <Button
22
+ testId="popup-trigger"
23
+ {...triggerProps}
24
+ onClick={() => {
25
+ setIsOpen(!isOpen);
26
+ }}
27
+ >
28
+ Click to toggle
29
+ </Button>
30
+ )}
31
+ placement="bottom"
32
+ />
33
+ );
34
34
  }
35
35
 
36
36
  PopupStoryButton.story = {
37
- name: 'Popup @atlaskit/button',
38
- parameters: {
39
- performance: {
40
- interactions: interactionTasks,
41
- },
42
- },
37
+ name: 'Popup @atlaskit/button',
38
+ parameters: {
39
+ performance: {
40
+ interactions: interactionTasks,
41
+ },
42
+ },
43
43
  };
44
44
 
45
45
  export default PopupStoryButton;
@@ -1,6 +1,10 @@
1
+ /**
2
+ * @jsxRuntime classic
3
+ */
1
4
  /** @jsx jsx */
2
5
  import { useState } from 'react';
3
6
 
7
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
4
8
  import { css, jsx } from '@emotion/react';
5
9
 
6
10
  import Button from '@atlaskit/button/custom-theme-button';
@@ -9,26 +13,26 @@ import MediaServicesAddCommentIcon from '@atlaskit/icon/glyph/media-services/add
9
13
  import Popup from '../src';
10
14
 
11
15
  const popupStyles = css({
12
- width: 175,
13
- height: 250,
16
+ width: 175,
17
+ height: 250,
14
18
  });
15
19
  export default () => {
16
- const [isOpen, setIsOpen] = useState(false);
20
+ const [isOpen, setIsOpen] = useState(false);
17
21
 
18
- return (
19
- <Popup
20
- isOpen={isOpen}
21
- onClose={() => setIsOpen(false)}
22
- placement="bottom-start"
23
- content={() => <div css={popupStyles} />}
24
- trigger={(triggerProps) => (
25
- <Button
26
- {...triggerProps}
27
- isSelected={isOpen}
28
- onClick={() => setIsOpen(!isOpen)}
29
- iconBefore={<MediaServicesAddCommentIcon label="Add" />}
30
- />
31
- )}
32
- />
33
- );
22
+ return (
23
+ <Popup
24
+ isOpen={isOpen}
25
+ onClose={() => setIsOpen(false)}
26
+ placement="bottom-start"
27
+ content={() => <div css={popupStyles} />}
28
+ trigger={(triggerProps) => (
29
+ <Button
30
+ {...triggerProps}
31
+ isSelected={isOpen}
32
+ onClick={() => setIsOpen(!isOpen)}
33
+ iconBefore={<MediaServicesAddCommentIcon label="Add" />}
34
+ />
35
+ )}
36
+ />
37
+ );
34
38
  };
package/__perf__/open.tsx CHANGED
@@ -5,32 +5,28 @@ import Button from '@atlaskit/button/new';
5
5
  import Popup from '../src';
6
6
 
7
7
  function PopupStoryButtonOpen() {
8
- const [isOpen, setIsOpen] = React.useState(true);
9
- return (
10
- <Popup
11
- isOpen={true}
12
- onClose={() => setIsOpen(isOpen)}
13
- content={() => (
14
- <div data-testid="popup">
15
- <Button>Test</Button>
16
- </div>
17
- )}
18
- trigger={(triggerProps) => (
19
- <Button
20
- testId="popup-trigger"
21
- {...triggerProps}
22
- onClick={() => setIsOpen(!isOpen)}
23
- >
24
- Click to toggle
25
- </Button>
26
- )}
27
- placement="bottom"
28
- />
29
- );
8
+ const [isOpen, setIsOpen] = React.useState(true);
9
+ return (
10
+ <Popup
11
+ isOpen={true}
12
+ onClose={() => setIsOpen(isOpen)}
13
+ content={() => (
14
+ <div data-testid="popup">
15
+ <Button>Test</Button>
16
+ </div>
17
+ )}
18
+ trigger={(triggerProps) => (
19
+ <Button testId="popup-trigger" {...triggerProps} onClick={() => setIsOpen(!isOpen)}>
20
+ Click to toggle
21
+ </Button>
22
+ )}
23
+ placement="bottom"
24
+ />
25
+ );
30
26
  }
31
27
 
32
28
  PopupStoryButtonOpen.story = {
33
- name: 'Open Popup @atlaskit/button',
29
+ name: 'Open Popup @atlaskit/button',
34
30
  };
35
31
 
36
32
  export default PopupStoryButtonOpen;
@@ -5,35 +5,35 @@ import Popup from '../src';
5
5
  import { interactionTasks } from './utils/interaction-tasks';
6
6
 
7
7
  function PopupStory() {
8
- const [isOpen, setIsOpen] = React.useState(false);
9
- return (
10
- <Popup
11
- isOpen={isOpen}
12
- onClose={() => setIsOpen(false)}
13
- content={() => <div data-testid="popup"> Test</div>}
14
- trigger={(triggerProps) => (
15
- //@ts-ignore https://product-fabric.atlassian.net/browse/DST-1866
16
- <button
17
- type="button"
18
- data-testid="popup-trigger"
19
- {...triggerProps}
20
- onClick={() => setIsOpen(!isOpen)}
21
- >
22
- Click to toggle
23
- </button>
24
- )}
25
- placement="bottom"
26
- />
27
- );
8
+ const [isOpen, setIsOpen] = React.useState(false);
9
+ return (
10
+ <Popup
11
+ isOpen={isOpen}
12
+ onClose={() => setIsOpen(false)}
13
+ content={() => <div data-testid="popup"> Test</div>}
14
+ trigger={(triggerProps) => (
15
+ //@ts-ignore https://product-fabric.atlassian.net/browse/DST-1866
16
+ <button
17
+ type="button"
18
+ data-testid="popup-trigger"
19
+ {...triggerProps}
20
+ onClick={() => setIsOpen(!isOpen)}
21
+ >
22
+ Click to toggle
23
+ </button>
24
+ )}
25
+ placement="bottom"
26
+ />
27
+ );
28
28
  }
29
29
 
30
30
  PopupStory.story = {
31
- name: 'Popup',
32
- parameters: {
33
- performance: {
34
- interactions: interactionTasks,
35
- },
36
- },
31
+ name: 'Popup',
32
+ parameters: {
33
+ performance: {
34
+ interactions: interactionTasks,
35
+ },
36
+ },
37
37
  };
38
38
 
39
39
  export default PopupStory;
@@ -1,57 +1,44 @@
1
1
  import { findByTestId, fireEvent } from '@testing-library/dom';
2
- import {
3
- type InteractionTaskArgs,
4
- type PublicInteractionTask,
5
- } from 'storybook-addon-performance';
2
+ import { type InteractionTaskArgs, type PublicInteractionTask } from 'storybook-addon-performance';
6
3
 
7
4
  export const interactionTasks: PublicInteractionTask[] = [
8
- {
9
- name: 'Click the trigger',
10
- description: 'Recording how long a click event take to be processed',
11
- run: async ({
12
- container,
13
- controls,
14
- }: InteractionTaskArgs): Promise<void> => {
15
- const popup: HTMLElement | null = container.querySelector(
16
- '[data-testid="popup-trigger"]',
17
- );
18
- if (popup == null) {
19
- throw new Error('Could not find popup element');
20
- }
5
+ {
6
+ name: 'Click the trigger',
7
+ description: 'Recording how long a click event take to be processed',
8
+ run: async ({ container, controls }: InteractionTaskArgs): Promise<void> => {
9
+ const popup: HTMLElement | null = container.querySelector('[data-testid="popup-trigger"]');
10
+ if (popup == null) {
11
+ throw new Error('Could not find popup element');
12
+ }
21
13
 
22
- await controls.time(async () => {
23
- // fireEvent.mouseDown(popup);
24
- fireEvent.click(popup);
25
- });
26
- },
27
- },
28
- {
29
- name: 'Open Popup',
30
- description: 'Recording how long the popup takes to appear',
31
- run: async ({
32
- container,
33
- controls,
34
- }: InteractionTaskArgs): Promise<void> => {
35
- const popup: HTMLElement | null = container.querySelector(
36
- '[data-testid="popup-trigger"]',
37
- );
38
- if (popup == null) {
39
- throw new Error('Could not find popup element');
40
- }
41
- const parent: HTMLElement | null = container.parentElement;
42
- if (parent == null) {
43
- throw new Error('Could not find parent element');
44
- }
45
- const existingPopup = parent.querySelector('[data-testid="popup"]');
46
- if (existingPopup != null) {
47
- throw new Error('Unexpected popup found');
48
- }
14
+ await controls.time(async () => {
15
+ // fireEvent.mouseDown(popup);
16
+ fireEvent.click(popup);
17
+ });
18
+ },
19
+ },
20
+ {
21
+ name: 'Open Popup',
22
+ description: 'Recording how long the popup takes to appear',
23
+ run: async ({ container, controls }: InteractionTaskArgs): Promise<void> => {
24
+ const popup: HTMLElement | null = container.querySelector('[data-testid="popup-trigger"]');
25
+ if (popup == null) {
26
+ throw new Error('Could not find popup element');
27
+ }
28
+ const parent: HTMLElement | null = container.parentElement;
29
+ if (parent == null) {
30
+ throw new Error('Could not find parent element');
31
+ }
32
+ const existingPopup = parent.querySelector('[data-testid="popup"]');
33
+ if (existingPopup != null) {
34
+ throw new Error('Unexpected popup found');
35
+ }
49
36
 
50
- await controls.time(async () => {
51
- fireEvent.click(popup);
37
+ await controls.time(async () => {
38
+ fireEvent.click(popup);
52
39
 
53
- await findByTestId(parent, 'popup');
54
- });
55
- },
56
- },
40
+ await findByTestId(parent, 'popup');
41
+ });
42
+ },
43
+ },
57
44
  ];