@atlaskit/popup 1.15.0 → 1.16.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.
- package/CHANGELOG.md +434 -222
- package/dist/cjs/compositional/popup.js +165 -0
- package/dist/cjs/entry-points/experimental/compositional.js +24 -0
- package/dist/cjs/popup.js +2 -28
- package/dist/cjs/use-get-memoized-merged-trigger-ref.js +39 -0
- package/dist/es2019/compositional/popup.js +144 -0
- package/dist/es2019/entry-points/experimental/compositional.js +1 -0
- package/dist/es2019/popup.js +2 -24
- package/dist/es2019/use-get-memoized-merged-trigger-ref.js +28 -0
- package/dist/esm/compositional/popup.js +155 -0
- package/dist/esm/entry-points/experimental/compositional.js +1 -0
- package/dist/esm/popup.js +2 -28
- package/dist/esm/use-get-memoized-merged-trigger-ref.js +33 -0
- package/dist/types/compositional/popup.d.ts +49 -0
- package/dist/types/entry-points/experimental/compositional.d.ts +2 -0
- package/dist/types/use-get-memoized-merged-trigger-ref.d.ts +2 -0
- package/dist/types-ts4.5/compositional/popup.d.ts +49 -0
- package/dist/types-ts4.5/entry-points/experimental/compositional.d.ts +2 -0
- package/dist/types-ts4.5/use-get-memoized-merged-trigger-ref.d.ts +2 -0
- package/experimental/package.json +15 -0
- package/package.json +9 -5
package/dist/esm/popup.js
CHANGED
|
@@ -3,12 +3,12 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
import { memo, useState } from 'react';
|
|
5
5
|
import { jsx } from '@emotion/react';
|
|
6
|
-
import memoizeOne from 'memoize-one';
|
|
7
6
|
import { UNSAFE_LAYERING } from '@atlaskit/layering';
|
|
8
7
|
import { Manager, Reference } from '@atlaskit/popper';
|
|
9
8
|
import Portal from '@atlaskit/portal';
|
|
10
9
|
import { layers } from '@atlaskit/theme/constants';
|
|
11
10
|
import PopperWrapper from './popper-wrapper';
|
|
11
|
+
import { useGetMemoizedMergedTriggerRef } from './use-get-memoized-merged-trigger-ref';
|
|
12
12
|
var defaultLayer = layers.layer();
|
|
13
13
|
export var Popup = /*#__PURE__*/memo(function (_ref) {
|
|
14
14
|
var isOpen = _ref.isOpen,
|
|
@@ -42,33 +42,7 @@ export var Popup = /*#__PURE__*/memo(function (_ref) {
|
|
|
42
42
|
_useState2 = _slicedToArray(_useState, 2),
|
|
43
43
|
triggerRef = _useState2[0],
|
|
44
44
|
setTriggerRef = _useState2[1];
|
|
45
|
-
|
|
46
|
-
/*
|
|
47
|
-
* Get a memoized functional ref for use within this Popup's Trigger.
|
|
48
|
-
* This is still very volatile to change as `prop.isOpen` will regularly change, but it's better than nothing.
|
|
49
|
-
* This is memoized within our component as to not be shared across all Popup instances, just this one.
|
|
50
|
-
*
|
|
51
|
-
* This is complex because the inputs are split across three different scopes:
|
|
52
|
-
* - `props.isOpen`
|
|
53
|
-
* - `useState.setTriggerRef`
|
|
54
|
-
* - `renderProps.ref`
|
|
55
|
-
*/
|
|
56
|
-
var _useState3 = useState(function () {
|
|
57
|
-
return memoizeOne(function (ref, setTriggerRef, isOpen) {
|
|
58
|
-
return function (node) {
|
|
59
|
-
if (node && isOpen) {
|
|
60
|
-
if (typeof ref === 'function') {
|
|
61
|
-
ref(node);
|
|
62
|
-
} else if (ref) {
|
|
63
|
-
ref.current = node;
|
|
64
|
-
}
|
|
65
|
-
setTriggerRef(node);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
});
|
|
69
|
-
}),
|
|
70
|
-
_useState4 = _slicedToArray(_useState3, 1),
|
|
71
|
-
getMergedTriggerRef = _useState4[0];
|
|
45
|
+
var getMergedTriggerRef = useGetMemoizedMergedTriggerRef();
|
|
72
46
|
var renderPopperWrapper = jsx(UNSAFE_LAYERING, {
|
|
73
47
|
isDisabled: false
|
|
74
48
|
}, jsx(PopperWrapper, {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import memoizeOne from 'memoize-one';
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* Get a memoized functional ref for use within a Popup's Trigger.
|
|
7
|
+
* This is still very volatile to change as `prop.isOpen` will regularly change, but it's better than nothing.
|
|
8
|
+
* This is memoized within a component as to not be shared across all Popup instances.
|
|
9
|
+
*
|
|
10
|
+
* This is complex because the inputs are split across three different scopes:
|
|
11
|
+
* - `props.isOpen`
|
|
12
|
+
* - `useState.setTriggerRef`
|
|
13
|
+
* - `renderProps.ref`
|
|
14
|
+
*/
|
|
15
|
+
export var useGetMemoizedMergedTriggerRef = function useGetMemoizedMergedTriggerRef() {
|
|
16
|
+
var _useState = useState(function () {
|
|
17
|
+
return memoizeOne(function (ref, setTriggerRef, isOpen) {
|
|
18
|
+
return function (node) {
|
|
19
|
+
if (node && isOpen) {
|
|
20
|
+
if (typeof ref === 'function') {
|
|
21
|
+
ref(node);
|
|
22
|
+
} else if (ref) {
|
|
23
|
+
ref.current = node;
|
|
24
|
+
}
|
|
25
|
+
setTriggerRef(node);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
}),
|
|
30
|
+
_useState2 = _slicedToArray(_useState, 1),
|
|
31
|
+
getMemoizedMergedTriggerRef = _useState2[0];
|
|
32
|
+
return getMemoizedMergedTriggerRef;
|
|
33
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type ContentProps, type PopupProps as LegacyPopupProps, type TriggerProps } from '../types';
|
|
3
|
+
export type PopupProps = {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
isOpen?: boolean;
|
|
6
|
+
id?: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* __Popup__
|
|
10
|
+
*
|
|
11
|
+
* Popup is a composable component that provides the context for the trigger and content components.
|
|
12
|
+
*
|
|
13
|
+
* Usage example:
|
|
14
|
+
* ```jsx
|
|
15
|
+
* <Popup>
|
|
16
|
+
* <PopupTrigger>
|
|
17
|
+
* {(props) => (
|
|
18
|
+
* <button type="button" {...props}>Click me</button>
|
|
19
|
+
* )}
|
|
20
|
+
* </PopupTrigger>
|
|
21
|
+
* <PopupContent>
|
|
22
|
+
* {(props) => <div>Hello world</div>}
|
|
23
|
+
* </PopupContent>
|
|
24
|
+
* </Popup>
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare const Popup: ({ children, id, isOpen }: PopupProps) => JSX.Element;
|
|
28
|
+
export type PopupTriggerProps = {
|
|
29
|
+
children: (props: TriggerProps) => React.ReactNode;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* __Popup trigger__
|
|
33
|
+
*
|
|
34
|
+
* Popup trigger is the component that renders the trigger for the popup.
|
|
35
|
+
*
|
|
36
|
+
* It must be a child of the Popup component.
|
|
37
|
+
*/
|
|
38
|
+
export declare const PopupTrigger: ({ children }: PopupTriggerProps) => JSX.Element;
|
|
39
|
+
export type PopupContentProps = Pick<LegacyPopupProps, 'boundary' | 'offset' | 'strategy' | 'onClose' | 'testId' | 'placement' | 'fallbackPlacements' | 'popupComponent' | 'shouldFlip' | 'rootBoundary' | 'autoFocus' | 'shouldUseCaptureOnOutsideClick' | 'shouldRenderToParent' | 'shouldDisableFocusLock' | 'zIndex'> & {
|
|
40
|
+
children: (props: ContentProps) => React.ReactNode;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* __Popup content__
|
|
44
|
+
*
|
|
45
|
+
* Popup content is the component that renders the content of the popup.
|
|
46
|
+
*
|
|
47
|
+
* It must be a child of the Popup component.
|
|
48
|
+
*/
|
|
49
|
+
export declare const PopupContent: ({ children, boundary, offset, strategy, onClose, testId, rootBoundary, shouldFlip, placement, fallbackPlacements, popupComponent, autoFocus, zIndex, shouldUseCaptureOnOutsideClick, shouldRenderToParent, shouldDisableFocusLock, }: PopupContentProps) => JSX.Element | null;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
export declare const useGetMemoizedMergedTriggerRef: () => import("memoize-one").MemoizedFn<(ref: React.RefCallback<HTMLElement> | React.MutableRefObject<HTMLElement> | null, setTriggerRef: Dispatch<SetStateAction<HTMLElement | null>>, isOpen: boolean) => (node: HTMLElement | null) => void>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type ContentProps, type PopupProps as LegacyPopupProps, type TriggerProps } from '../types';
|
|
3
|
+
export type PopupProps = {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
isOpen?: boolean;
|
|
6
|
+
id?: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* __Popup__
|
|
10
|
+
*
|
|
11
|
+
* Popup is a composable component that provides the context for the trigger and content components.
|
|
12
|
+
*
|
|
13
|
+
* Usage example:
|
|
14
|
+
* ```jsx
|
|
15
|
+
* <Popup>
|
|
16
|
+
* <PopupTrigger>
|
|
17
|
+
* {(props) => (
|
|
18
|
+
* <button type="button" {...props}>Click me</button>
|
|
19
|
+
* )}
|
|
20
|
+
* </PopupTrigger>
|
|
21
|
+
* <PopupContent>
|
|
22
|
+
* {(props) => <div>Hello world</div>}
|
|
23
|
+
* </PopupContent>
|
|
24
|
+
* </Popup>
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare const Popup: ({ children, id, isOpen }: PopupProps) => JSX.Element;
|
|
28
|
+
export type PopupTriggerProps = {
|
|
29
|
+
children: (props: TriggerProps) => React.ReactNode;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* __Popup trigger__
|
|
33
|
+
*
|
|
34
|
+
* Popup trigger is the component that renders the trigger for the popup.
|
|
35
|
+
*
|
|
36
|
+
* It must be a child of the Popup component.
|
|
37
|
+
*/
|
|
38
|
+
export declare const PopupTrigger: ({ children }: PopupTriggerProps) => JSX.Element;
|
|
39
|
+
export type PopupContentProps = Pick<LegacyPopupProps, 'boundary' | 'offset' | 'strategy' | 'onClose' | 'testId' | 'placement' | 'fallbackPlacements' | 'popupComponent' | 'shouldFlip' | 'rootBoundary' | 'autoFocus' | 'shouldUseCaptureOnOutsideClick' | 'shouldRenderToParent' | 'shouldDisableFocusLock' | 'zIndex'> & {
|
|
40
|
+
children: (props: ContentProps) => React.ReactNode;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* __Popup content__
|
|
44
|
+
*
|
|
45
|
+
* Popup content is the component that renders the content of the popup.
|
|
46
|
+
*
|
|
47
|
+
* It must be a child of the Popup component.
|
|
48
|
+
*/
|
|
49
|
+
export declare const PopupContent: ({ children, boundary, offset, strategy, onClose, testId, rootBoundary, shouldFlip, placement, fallbackPlacements, popupComponent, autoFocus, zIndex, shouldUseCaptureOnOutsideClick, shouldRenderToParent, shouldDisableFocusLock, }: PopupContentProps) => JSX.Element | null;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
export declare const useGetMemoizedMergedTriggerRef: () => import("memoize-one").MemoizedFn<(ref: React.RefCallback<HTMLElement> | React.MutableRefObject<HTMLElement> | null, setTriggerRef: Dispatch<SetStateAction<HTMLElement | null>>, isOpen: boolean) => (node: HTMLElement | null) => void>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/popup/experimental",
|
|
3
|
+
"main": "../dist/cjs/entry-points/experimental/compositional.js",
|
|
4
|
+
"module": "../dist/esm/entry-points/experimental/compositional.js",
|
|
5
|
+
"module:es2019": "../dist/es2019/entry-points/experimental/compositional.js",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"types": "../dist/types/entry-points/experimental/compositional.d.ts",
|
|
8
|
+
"typesVersions": {
|
|
9
|
+
">=4.5 <5.4": {
|
|
10
|
+
"*": [
|
|
11
|
+
"../dist/types-ts4.5/entry-points/experimental/compositional.d.ts"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/popup",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.0",
|
|
4
4
|
"description": "A popup displays brief content in an overlay.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"atlaskit:src": "src/index.tsx",
|
|
25
25
|
"af:exports": {
|
|
26
26
|
".": "./src/index.tsx",
|
|
27
|
-
"./types": "./src/types.tsx"
|
|
27
|
+
"./types": "./src/types.tsx",
|
|
28
|
+
"./experimental": "./src/entry-points/experimental/compositional.tsx"
|
|
28
29
|
},
|
|
29
30
|
"atlassian": {
|
|
30
31
|
"team": "Design System Team",
|
|
@@ -40,17 +41,18 @@
|
|
|
40
41
|
},
|
|
41
42
|
"dependencies": {
|
|
42
43
|
"@atlaskit/ds-lib": "^2.3.0",
|
|
43
|
-
"@atlaskit/layering": "^0.
|
|
44
|
+
"@atlaskit/layering": "^0.3.0",
|
|
44
45
|
"@atlaskit/platform-feature-flags": "^0.2.0",
|
|
45
46
|
"@atlaskit/popper": "^5.5.0",
|
|
46
47
|
"@atlaskit/portal": "^4.4.0",
|
|
47
48
|
"@atlaskit/theme": "^12.7.0",
|
|
48
|
-
"@atlaskit/tokens": "^1.
|
|
49
|
+
"@atlaskit/tokens": "^1.45.0",
|
|
49
50
|
"@babel/runtime": "^7.0.0",
|
|
50
51
|
"@emotion/react": "^11.7.1",
|
|
51
52
|
"bind-event-listener": "^3.0.0",
|
|
52
53
|
"focus-trap": "^2.4.5",
|
|
53
|
-
"memoize-one": "^6.0.0"
|
|
54
|
+
"memoize-one": "^6.0.0",
|
|
55
|
+
"tiny-invariant": "^1.2.0"
|
|
54
56
|
},
|
|
55
57
|
"peerDependencies": {
|
|
56
58
|
"react": "^16.8.0 || ^17.0.0 || ~18.2.0",
|
|
@@ -62,11 +64,13 @@
|
|
|
62
64
|
"@atlaskit/button": "^17.14.0",
|
|
63
65
|
"@atlaskit/icon": "^22.1.0",
|
|
64
66
|
"@atlaskit/ssr": "*",
|
|
67
|
+
"@atlaskit/toggle": "^13.0.0",
|
|
65
68
|
"@atlaskit/visual-regression": "*",
|
|
66
69
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
67
70
|
"@atlassian/feature-flags-test-utils": "*",
|
|
68
71
|
"@testing-library/dom": "^8.17.1",
|
|
69
72
|
"@testing-library/react": "^12.1.5",
|
|
73
|
+
"@testing-library/user-event": "^14.4.3",
|
|
70
74
|
"ast-types": "^0.13.3",
|
|
71
75
|
"jscodeshift": "^0.13.0",
|
|
72
76
|
"raf-stub": "^2.0.1",
|