@atlaskit/popup 1.6.0 → 1.6.2

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/popup
2
2
 
3
+ ## 1.6.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`9d00501a414`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9d00501a414) - Ensure legacy types are published for TS 4.5-4.8
8
+
9
+ ## 1.6.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [`41fae2c6f68`](https://bitbucket.org/atlassian/atlassian-frontend/commits/41fae2c6f68) - Upgrade Typescript from `4.5.5` to `4.9.5`
14
+
3
15
  ## 1.6.0
4
16
 
5
17
  ### Minor Changes
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/popup",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "sideEffects": false
5
5
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/popup",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "sideEffects": false
5
5
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/popup",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "sideEffects": false
5
5
  }
@@ -6,8 +6,8 @@ export interface TriggerProps {
6
6
  'aria-expanded': boolean;
7
7
  'aria-haspopup': boolean;
8
8
  }
9
- export declare type PopupRef = HTMLDivElement | null;
10
- export declare type TriggerRef = HTMLElement | HTMLButtonElement | null;
9
+ export type PopupRef = HTMLDivElement | null;
10
+ export type TriggerRef = HTMLElement | HTMLButtonElement | null;
11
11
  export interface ContentProps {
12
12
  /**
13
13
  * Will reposition the popup if any of the content has changed.
@@ -151,16 +151,16 @@ export interface PopupProps extends BaseProps {
151
151
  export interface PopperWrapperProps extends BaseProps {
152
152
  triggerRef: TriggerRef;
153
153
  }
154
- export declare type CloseManagerHook = Pick<PopupProps, 'isOpen' | 'onClose'> & {
154
+ export type CloseManagerHook = Pick<PopupProps, 'isOpen' | 'onClose'> & {
155
155
  popupRef: PopupRef;
156
156
  triggerRef: TriggerRef;
157
157
  shouldUseCaptureOnOutsideClick?: boolean;
158
158
  };
159
- export declare type FocusManagerHook = {
159
+ export type FocusManagerHook = {
160
160
  popupRef: PopupRef;
161
161
  initialFocusRef: HTMLElement | null;
162
162
  };
163
- export declare type RepositionOnUpdateProps = {
163
+ export type RepositionOnUpdateProps = {
164
164
  update: PopperChildrenProps['update'];
165
165
  };
166
166
  export {};
@@ -0,0 +1,4 @@
1
+ import { Popup } from './popup';
2
+ export type { ContentProps, PopupComponentProps, PopupProps, TriggerProps, } from './types';
3
+ export { Popup };
4
+ export default Popup;
@@ -0,0 +1,4 @@
1
+ import { jsx } from '@emotion/react';
2
+ import { PopperWrapperProps } from './types';
3
+ declare function PopperWrapper({ isOpen, id, offset, testId, content, fallbackPlacements, onClose, boundary, rootBoundary, shouldFlip, placement, popupComponent: PopupContainer, autoFocus, triggerRef, shouldUseCaptureOnOutsideClick, }: PopperWrapperProps): jsx.JSX.Element;
4
+ export default PopperWrapper;
@@ -0,0 +1,5 @@
1
+ /** @jsx jsx */
2
+ import { FC } from 'react';
3
+ import { PopupProps } from './types';
4
+ export declare const Popup: FC<PopupProps>;
5
+ export default Popup;
@@ -0,0 +1,3 @@
1
+ import { FC } from 'react';
2
+ import { RepositionOnUpdateProps } from './types';
3
+ export declare const RepositionOnUpdate: FC<RepositionOnUpdateProps>;
@@ -0,0 +1,169 @@
1
+ import React, { ComponentType, CSSProperties, Dispatch, ReactNode, Ref, SetStateAction } from 'react';
2
+ import { Placement, PopperChildrenProps } from '@atlaskit/popper';
3
+ export interface TriggerProps {
4
+ ref: Ref<any>;
5
+ 'aria-controls'?: string;
6
+ 'aria-expanded': boolean;
7
+ 'aria-haspopup': boolean;
8
+ }
9
+ export type PopupRef = HTMLDivElement | null;
10
+ export type TriggerRef = HTMLElement | HTMLButtonElement | null;
11
+ export interface ContentProps {
12
+ /**
13
+ * Will reposition the popup if any of the content has changed.
14
+ * Useful for when positions change and the popup was not aware.
15
+ */
16
+ update: PopperChildrenProps['update'];
17
+ /**
18
+ * Passed through from the parent popup.
19
+ */
20
+ isOpen: boolean;
21
+ /**
22
+ * Passed through from the parent popup.
23
+ */
24
+ onClose?: BaseProps['onClose'];
25
+ /**
26
+ * Escape hatch to set the initial focus for a specific element when the popup is opened.
27
+ */
28
+ setInitialFocusRef: Dispatch<SetStateAction<HTMLElement | null>>;
29
+ }
30
+ export interface PopupComponentProps {
31
+ /**
32
+ * Children passed passed through by the parent popup.
33
+ */
34
+ children: ReactNode;
35
+ /**
36
+ * Placement passed through by the parent popup.
37
+ */
38
+ 'data-placement': Placement;
39
+ /**
40
+ * Test id passed through by the parent popup.
41
+ */
42
+ 'data-testid'?: string;
43
+ /**
44
+ * Id passed through by the parent popup.
45
+ */
46
+ id?: string;
47
+ /**
48
+ * Ref that should be assigned to the root element.
49
+ */
50
+ ref: Ref<HTMLDivElement>;
51
+ /**
52
+ * Style that should be assigned to the root element.
53
+ */
54
+ style: CSSProperties;
55
+ /**
56
+ * Tab index passed through by the parent popup.
57
+ */
58
+ tabIndex: number | undefined;
59
+ }
60
+ interface BaseProps {
61
+ /**
62
+ * Used to either show or hide the popup.
63
+ * When set to `false` popup will not render anything to the DOM.
64
+ */
65
+ isOpen: boolean;
66
+ /**
67
+ * Render props for content that is displayed inside the popup.
68
+ */
69
+ content: (props: ContentProps) => React.ReactNode;
70
+ /**
71
+ * Id that is assigned to the popup container element.
72
+ */
73
+ id?: string;
74
+ /**
75
+ * Distance the popup should be offset from the reference in the format of [along, away] (units in px).
76
+ * Defaults to [0, 8] - which means the popup will be 8px away from the edge of the reference specified
77
+ * by the `placement` prop.
78
+ */
79
+ offset?: [
80
+ number,
81
+ number
82
+ ];
83
+ /**
84
+ * Placement of where the popup should be displayed relative to the trigger element.
85
+ * Defaults to `"auto"`.
86
+ */
87
+ placement?: Placement;
88
+ /**
89
+ * Defines a list of placements to try.
90
+ * When no space is available on the preferred placement,
91
+ * the modifier will test the ones provided in the list, and use the first useful one.
92
+ */
93
+ fallbackPlacements?: Placement[];
94
+ /**
95
+ * The boundary element that the popup will check for overflow.
96
+ * Defaults to `"clippingParents"` which are parent scroll containers,
97
+ * but can be set to any element.
98
+ */
99
+ boundary?: 'clippingParents' | HTMLElement;
100
+ /**
101
+ * The root boundary that the popup will check for overflow.
102
+ * Defaults to `"viewport"` but can be set to `"document"`.
103
+ */
104
+ rootBoundary?: 'viewport' | 'document';
105
+ /**
106
+ * Allows the Popup to be placed on the opposite side of its trigger if it does not fit in the viewport.
107
+ * Defaults to `true`.
108
+ */
109
+ shouldFlip?: boolean;
110
+ /**
111
+ * A `testId` prop is provided for specified elements,
112
+ * which is a unique string that appears as a data attribute `data-testid` in the rendered code,
113
+ * serving as a hook for automated tests.
114
+ */
115
+ testId?: string;
116
+ /**
117
+ * Handler that is called when the popup wants to close itself.
118
+ * Generally this will be either when clicking away from the popup or pressing the escape key.
119
+ * You'll want to use this to set open state accordingly and then pump it back into the `isOpen` prop.
120
+ */
121
+ onClose?(event: Event | React.MouseEvent | React.KeyboardEvent): void;
122
+ /**
123
+ * The element that is shown when `isOpen` prop is `true`.
124
+ * The result of the `content` prop will be placed as children here.
125
+ * Defaults to an element with an elevation of `e200` with _no padding_.
126
+ */
127
+ popupComponent?: ComponentType<PopupComponentProps>;
128
+ /**
129
+ * Controls whether the popup takes focus when opening.
130
+ * This changes the `popupComponent` component tabIndex to `null`.
131
+ * Defaults to `true`.
132
+ */
133
+ autoFocus?: boolean;
134
+ /**
135
+ * Controls if the event which handles clicks outside the popup is be bound with
136
+ * `capture: true`.
137
+ */
138
+ shouldUseCaptureOnOutsideClick?: boolean;
139
+ }
140
+ export interface PopupProps extends BaseProps {
141
+ /**
142
+ * Render props used to anchor the popup to your content.
143
+ * Make this an interactive element,
144
+ * such as an `@atlaskit/button` component.
145
+ */
146
+ trigger: (props: TriggerProps) => React.ReactNode;
147
+ /**
148
+ * Z-index that the popup should be displayed in.
149
+ * This is passed to the portal component.
150
+ * Defaults to `layers.layer()` from `@atlaskit/theme`.
151
+ */
152
+ zIndex?: number;
153
+ }
154
+ export interface PopperWrapperProps extends BaseProps {
155
+ triggerRef: TriggerRef;
156
+ }
157
+ export type CloseManagerHook = Pick<PopupProps, 'isOpen' | 'onClose'> & {
158
+ popupRef: PopupRef;
159
+ triggerRef: TriggerRef;
160
+ shouldUseCaptureOnOutsideClick?: boolean;
161
+ };
162
+ export type FocusManagerHook = {
163
+ popupRef: PopupRef;
164
+ initialFocusRef: HTMLElement | null;
165
+ };
166
+ export type RepositionOnUpdateProps = {
167
+ update: PopperChildrenProps['update'];
168
+ };
169
+ export {};
@@ -0,0 +1,2 @@
1
+ import { CloseManagerHook } from './types';
2
+ export declare const useCloseManager: ({ isOpen, onClose, popupRef, triggerRef, shouldUseCaptureOnOutsideClick: capture, }: CloseManagerHook) => void;
@@ -0,0 +1,2 @@
1
+ import { FocusManagerHook } from './types';
2
+ export declare const useFocusManager: ({ popupRef, initialFocusRef, }: FocusManagerHook) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/popup",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "description": "A popup displays brief content in an overlay.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -12,6 +12,14 @@
12
12
  "module": "dist/esm/index.js",
13
13
  "module:es2019": "dist/es2019/index.js",
14
14
  "types": "dist/types/index.d.ts",
15
+ "typesVersions": {
16
+ ">=4.5 <4.9": {
17
+ "*": [
18
+ "dist/types-ts4.5/*",
19
+ "dist/types-ts4.5/index.d.ts"
20
+ ]
21
+ }
22
+ },
15
23
  "sideEffects": false,
16
24
  "atlaskit:src": "src/index.tsx",
17
25
  "af:exports": {
@@ -31,7 +39,7 @@
31
39
  "@atlaskit/popper": "^5.5.0",
32
40
  "@atlaskit/portal": "^4.3.0",
33
41
  "@atlaskit/theme": "^12.5.0",
34
- "@atlaskit/tokens": "^1.3.0",
42
+ "@atlaskit/tokens": "^1.4.0",
35
43
  "@babel/runtime": "^7.0.0",
36
44
  "@emotion/react": "^11.7.1",
37
45
  "bind-event-listener": "^2.1.1",
@@ -45,7 +53,7 @@
45
53
  "@atlaskit/button": "^16.7.0",
46
54
  "@atlaskit/docs": "*",
47
55
  "@atlaskit/icon": "^21.12.0",
48
- "@atlaskit/menu": "^1.6.0",
56
+ "@atlaskit/menu": "^1.7.0",
49
57
  "@atlaskit/radio": "^5.5.0",
50
58
  "@atlaskit/section-message": "^6.4.0",
51
59
  "@atlaskit/select": "^16.2.0",
@@ -62,7 +70,7 @@
62
70
  "raf-stub": "^2.0.1",
63
71
  "react-dom": "^16.8.0",
64
72
  "storybook-addon-performance": "^0.16.0",
65
- "typescript": "4.5.5",
73
+ "typescript": "~4.9.5",
66
74
  "wait-for-expect": "^1.2.0"
67
75
  },
68
76
  "keywords": [
@@ -6,9 +6,9 @@
6
6
  "sideEffects": false,
7
7
  "types": "../dist/types/types.d.ts",
8
8
  "typesVersions": {
9
- ">=4.0 <4.5": {
9
+ ">=4.5 <4.9": {
10
10
  "*": [
11
- "../dist/types-ts4.0/types.d.ts"
11
+ "../dist/types-ts4.5/types.d.ts"
12
12
  ]
13
13
  }
14
14
  }