@atlaskit/inline-dialog 13.1.6 → 13.2.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 CHANGED
@@ -1,5 +1,30 @@
1
1
  # @atlaskit/inline-dialog
2
2
 
3
+ ## 13.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`2fe0d03807f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/2fe0d03807f) - This removes the preventDefault functionality (reverts it back to the previous version of inline dialog where event listeners were added in the capture phase). It also refactors handleClickOutside so that it is now triggered by a ref.
8
+
9
+ ## 13.1.9
10
+
11
+ ### Patch Changes
12
+
13
+ - [`f460cc7c411`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f460cc7c411) - Builds for this package now pass through a tokens babel plugin, removing runtime invocations of the tokens() function and improving bundle size.
14
+ - Updated dependencies
15
+
16
+ ## 13.1.8
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies
21
+
22
+ ## 13.1.7
23
+
24
+ ### Patch Changes
25
+
26
+ - [`34282240102`](https://bitbucket.org/atlassian/atlassian-frontend/commits/34282240102) - Adds explicit type to button usages components.
27
+
3
28
  ## 13.1.6
4
29
 
5
30
  ### Patch Changes
@@ -31,7 +31,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
31
31
 
32
32
  /** @jsx jsx */
33
33
  var packageName = "@atlaskit/inline-dialog";
34
- var packageVersion = "13.1.6";
34
+ var packageVersion = "13.2.0";
35
35
 
36
36
  var checkIsChildOfPortal = function checkIsChildOfPortal(node) {
37
37
  if (!node) {
@@ -58,12 +58,13 @@ var InlineDialog = /*#__PURE__*/(0, _react.memo)(function InlineDialog(_ref) {
58
58
  content = _ref.content,
59
59
  children = _ref.children;
60
60
  var containerRef = (0, _react.useRef)(null);
61
- var triggerRef = (0, _react.useRef)(null);
62
- var handleClickOutside = (0, _react.useCallback)(function (event) {
63
- if (event.defaultPrevented) {
64
- return;
65
- }
61
+ var triggerRef = (0, _react.useRef)(null); // we put this into a ref to avoid handleClickOutside having this as a dependency
66
62
 
63
+ var onCloseRef = (0, _react.useRef)(onClose);
64
+ (0, _react.useEffect)(function () {
65
+ onCloseRef.current = onClose;
66
+ });
67
+ var handleClickOutside = (0, _react.useCallback)(function (event) {
67
68
  var target = event.target; // checks for when target is not HTMLElement
68
69
 
69
70
  if (!(target instanceof HTMLElement)) {
@@ -89,43 +90,31 @@ var InlineDialog = /*#__PURE__*/(0, _react.memo)(function InlineDialog(_ref) {
89
90
 
90
91
 
91
92
  if (containerRef.current && !containerRef.current.contains(target)) {
92
- onClose && onClose({
93
+ var _onCloseRef$current;
94
+
95
+ (_onCloseRef$current = onCloseRef.current) === null || _onCloseRef$current === void 0 ? void 0 : _onCloseRef$current.call(onCloseRef, {
93
96
  isOpen: false,
94
97
  event: event
95
98
  });
96
99
  }
97
- }, [onClose]);
100
+ }, []);
98
101
  (0, _react.useEffect)(function () {
99
102
  if (!isOpen) {
100
103
  return;
101
104
  }
102
105
 
103
- var unbind; // Under most circumstances, `useEffect` should run after an event has ended
104
- // In this particular case, the popperjs library has a setState inside of a ref,
105
- // which cases `useEffect` to run synchronously instead. To avoid this, we use a
106
- // `setTimeout` so `useEffect` after the event. We only want to start listening
107
- // for clicks after the original click event that triggered the dialog
108
- // has finished. You can see more in the Codesandbox here:
109
- // https://codesandbox.io/s/useeffect-and-event-timing-refs-in-state-5tys3?file=/src/App.tsx
110
-
111
- var timeoutId = setTimeout(function () {
112
- unbind = (0, _bindEventListener.bind)(window, {
113
- type: 'click',
114
- listener: function listener(event) {
115
- return handleClickOutside(event);
116
- },
117
- options: {
118
- capture: false
119
- }
120
- });
106
+ var unbind;
107
+ unbind = (0, _bindEventListener.bind)(window, {
108
+ type: 'click',
109
+ listener: function listener(e) {
110
+ return handleClickOutside(e);
111
+ },
112
+ options: {
113
+ capture: true
114
+ }
121
115
  });
122
- return function () {
123
- var _unbind;
124
-
125
- window.clearTimeout(timeoutId);
126
- (_unbind = unbind) === null || _unbind === void 0 ? void 0 : _unbind();
127
- };
128
- }, [handleClickOutside, isOpen]);
116
+ return unbind;
117
+ }, [isOpen, handleClickOutside]);
129
118
  var popper = isOpen ? (0, _core.jsx)(_popper.Popper, {
130
119
  placement: placement
131
120
  }, function (_ref2) {
@@ -21,8 +21,6 @@ var _components = require("@atlaskit/theme/components");
21
21
 
22
22
  var _constants = require("@atlaskit/theme/constants");
23
23
 
24
- var _tokens = require("@atlaskit/tokens");
25
-
26
24
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
27
25
 
28
26
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -32,16 +30,16 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
32
30
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
33
31
 
34
32
  var themedBackground = (0, _components.themed)({
35
- light: (0, _tokens.token)('color.background.overlay', _colors.N0),
36
- dark: (0, _tokens.token)('color.background.overlay', _colors.DN50)
33
+ light: "var(--ds-background-overlay, ".concat(_colors.N0, ")"),
34
+ dark: "var(--ds-background-overlay, ".concat(_colors.DN50, ")")
37
35
  });
38
36
  var themedColor = (0, _components.themed)({
39
- light: (0, _tokens.token)('color.text.highEmphasis', _colors.N900),
40
- dark: (0, _tokens.token)('color.text.highEmphasis', _colors.DN600)
37
+ light: "var(--ds-text-highEmphasis, ".concat(_colors.N900, ")"),
38
+ dark: "var(--ds-text-highEmphasis, ".concat(_colors.DN600, ")")
41
39
  });
42
40
  var themedBoxShadow = (0, _components.themed)({
43
- light: (0, _tokens.token)('shadow.overlay', "0 4px 8px -2px ".concat(_colors.N50A, ", 0 0 1px ").concat(_colors.N60A)),
44
- dark: (0, _tokens.token)('shadow.overlay', "0 4px 8px -2px ".concat(_colors.DN50A, ", 0 0 1px ").concat(_colors.DN60A))
41
+ light: "var(--ds-overlay, ".concat("0 4px 8px -2px ".concat(_colors.N50A, ", 0 0 1px ").concat(_colors.N60A), ")"),
42
+ dark: "var(--ds-overlay, ".concat("0 4px 8px -2px ".concat(_colors.DN50A, ", 0 0 1px ").concat(_colors.DN60A), ")")
45
43
  });
46
44
  var borderRadius = (0, _constants.borderRadius)();
47
45
  var gridSize = (0, _constants.gridSize)();
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/inline-dialog",
3
- "version": "13.1.6",
3
+ "version": "13.2.0",
4
4
  "sideEffects": false
5
5
  }
@@ -8,7 +8,7 @@ import noop from '@atlaskit/ds-lib/noop';
8
8
  import { Manager, Popper, Reference } from '@atlaskit/popper';
9
9
  import { Container } from './styled/container';
10
10
  const packageName = "@atlaskit/inline-dialog";
11
- const packageVersion = "13.1.6";
11
+ const packageVersion = "13.2.0";
12
12
 
13
13
  const checkIsChildOfPortal = node => {
14
14
  if (!node) {
@@ -30,12 +30,13 @@ const InlineDialog = /*#__PURE__*/memo(function InlineDialog({
30
30
  children
31
31
  }) {
32
32
  const containerRef = useRef(null);
33
- const triggerRef = useRef(null);
34
- const handleClickOutside = useCallback(event => {
35
- if (event.defaultPrevented) {
36
- return;
37
- }
33
+ const triggerRef = useRef(null); // we put this into a ref to avoid handleClickOutside having this as a dependency
38
34
 
35
+ const onCloseRef = useRef(onClose);
36
+ useEffect(() => {
37
+ onCloseRef.current = onClose;
38
+ });
39
+ const handleClickOutside = useCallback(event => {
39
40
  const {
40
41
  target
41
42
  } = event; // checks for when target is not HTMLElement
@@ -63,41 +64,29 @@ const InlineDialog = /*#__PURE__*/memo(function InlineDialog({
63
64
 
64
65
 
65
66
  if (containerRef.current && !containerRef.current.contains(target)) {
66
- onClose && onClose({
67
+ var _onCloseRef$current;
68
+
69
+ (_onCloseRef$current = onCloseRef.current) === null || _onCloseRef$current === void 0 ? void 0 : _onCloseRef$current.call(onCloseRef, {
67
70
  isOpen: false,
68
71
  event: event
69
72
  });
70
73
  }
71
- }, [onClose]);
74
+ }, []);
72
75
  useEffect(() => {
73
76
  if (!isOpen) {
74
77
  return;
75
78
  }
76
79
 
77
- let unbind; // Under most circumstances, `useEffect` should run after an event has ended
78
- // In this particular case, the popperjs library has a setState inside of a ref,
79
- // which cases `useEffect` to run synchronously instead. To avoid this, we use a
80
- // `setTimeout` so `useEffect` after the event. We only want to start listening
81
- // for clicks after the original click event that triggered the dialog
82
- // has finished. You can see more in the Codesandbox here:
83
- // https://codesandbox.io/s/useeffect-and-event-timing-refs-in-state-5tys3?file=/src/App.tsx
84
-
85
- const timeoutId = setTimeout(() => {
86
- unbind = bind(window, {
87
- type: 'click',
88
- listener: event => handleClickOutside(event),
89
- options: {
90
- capture: false
91
- }
92
- });
80
+ let unbind;
81
+ unbind = bind(window, {
82
+ type: 'click',
83
+ listener: e => handleClickOutside(e),
84
+ options: {
85
+ capture: true
86
+ }
93
87
  });
94
- return () => {
95
- var _unbind;
96
-
97
- window.clearTimeout(timeoutId);
98
- (_unbind = unbind) === null || _unbind === void 0 ? void 0 : _unbind();
99
- };
100
- }, [handleClickOutside, isOpen]);
88
+ return unbind;
89
+ }, [isOpen, handleClickOutside]);
101
90
  const popper = isOpen ? jsx(Popper, {
102
91
  placement: placement
103
92
  }, ({
@@ -8,18 +8,17 @@ import { css, jsx } from '@emotion/core';
8
8
  import { DN50, DN50A, DN600, DN60A, N0, N50A, N60A, N900 } from '@atlaskit/theme/colors';
9
9
  import { themed, useGlobalTheme } from '@atlaskit/theme/components';
10
10
  import { borderRadius as getBorderRadius, gridSize as getGridSize, layers } from '@atlaskit/theme/constants';
11
- import { token } from '@atlaskit/tokens';
12
11
  const themedBackground = themed({
13
- light: token('color.background.overlay', N0),
14
- dark: token('color.background.overlay', DN50)
12
+ light: `var(--ds-background-overlay, ${N0})`,
13
+ dark: `var(--ds-background-overlay, ${DN50})`
15
14
  });
16
15
  const themedColor = themed({
17
- light: token('color.text.highEmphasis', N900),
18
- dark: token('color.text.highEmphasis', DN600)
16
+ light: `var(--ds-text-highEmphasis, ${N900})`,
17
+ dark: `var(--ds-text-highEmphasis, ${DN600})`
19
18
  });
20
19
  const themedBoxShadow = themed({
21
- light: token('shadow.overlay', `0 4px 8px -2px ${N50A}, 0 0 1px ${N60A}`),
22
- dark: token('shadow.overlay', `0 4px 8px -2px ${DN50A}, 0 0 1px ${DN60A}`)
20
+ light: `var(--ds-overlay, ${`0 4px 8px -2px ${N50A}, 0 0 1px ${N60A}`})`,
21
+ dark: `var(--ds-overlay, ${`0 4px 8px -2px ${DN50A}, 0 0 1px ${DN60A}`})`
23
22
  });
24
23
  const borderRadius = getBorderRadius();
25
24
  const gridSize = getGridSize();
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/inline-dialog",
3
- "version": "13.1.6",
3
+ "version": "13.2.0",
4
4
  "sideEffects": false
5
5
  }
@@ -8,7 +8,7 @@ import noop from '@atlaskit/ds-lib/noop';
8
8
  import { Manager, Popper, Reference } from '@atlaskit/popper';
9
9
  import { Container } from './styled/container';
10
10
  var packageName = "@atlaskit/inline-dialog";
11
- var packageVersion = "13.1.6";
11
+ var packageVersion = "13.2.0";
12
12
 
13
13
  var checkIsChildOfPortal = function checkIsChildOfPortal(node) {
14
14
  if (!node) {
@@ -35,12 +35,13 @@ var InlineDialog = /*#__PURE__*/memo(function InlineDialog(_ref) {
35
35
  content = _ref.content,
36
36
  children = _ref.children;
37
37
  var containerRef = useRef(null);
38
- var triggerRef = useRef(null);
39
- var handleClickOutside = useCallback(function (event) {
40
- if (event.defaultPrevented) {
41
- return;
42
- }
38
+ var triggerRef = useRef(null); // we put this into a ref to avoid handleClickOutside having this as a dependency
43
39
 
40
+ var onCloseRef = useRef(onClose);
41
+ useEffect(function () {
42
+ onCloseRef.current = onClose;
43
+ });
44
+ var handleClickOutside = useCallback(function (event) {
44
45
  var target = event.target; // checks for when target is not HTMLElement
45
46
 
46
47
  if (!(target instanceof HTMLElement)) {
@@ -66,43 +67,31 @@ var InlineDialog = /*#__PURE__*/memo(function InlineDialog(_ref) {
66
67
 
67
68
 
68
69
  if (containerRef.current && !containerRef.current.contains(target)) {
69
- onClose && onClose({
70
+ var _onCloseRef$current;
71
+
72
+ (_onCloseRef$current = onCloseRef.current) === null || _onCloseRef$current === void 0 ? void 0 : _onCloseRef$current.call(onCloseRef, {
70
73
  isOpen: false,
71
74
  event: event
72
75
  });
73
76
  }
74
- }, [onClose]);
77
+ }, []);
75
78
  useEffect(function () {
76
79
  if (!isOpen) {
77
80
  return;
78
81
  }
79
82
 
80
- var unbind; // Under most circumstances, `useEffect` should run after an event has ended
81
- // In this particular case, the popperjs library has a setState inside of a ref,
82
- // which cases `useEffect` to run synchronously instead. To avoid this, we use a
83
- // `setTimeout` so `useEffect` after the event. We only want to start listening
84
- // for clicks after the original click event that triggered the dialog
85
- // has finished. You can see more in the Codesandbox here:
86
- // https://codesandbox.io/s/useeffect-and-event-timing-refs-in-state-5tys3?file=/src/App.tsx
87
-
88
- var timeoutId = setTimeout(function () {
89
- unbind = bind(window, {
90
- type: 'click',
91
- listener: function listener(event) {
92
- return handleClickOutside(event);
93
- },
94
- options: {
95
- capture: false
96
- }
97
- });
83
+ var unbind;
84
+ unbind = bind(window, {
85
+ type: 'click',
86
+ listener: function listener(e) {
87
+ return handleClickOutside(e);
88
+ },
89
+ options: {
90
+ capture: true
91
+ }
98
92
  });
99
- return function () {
100
- var _unbind;
101
-
102
- window.clearTimeout(timeoutId);
103
- (_unbind = unbind) === null || _unbind === void 0 ? void 0 : _unbind();
104
- };
105
- }, [handleClickOutside, isOpen]);
93
+ return unbind;
94
+ }, [isOpen, handleClickOutside]);
106
95
  var popper = isOpen ? jsx(Popper, {
107
96
  placement: placement
108
97
  }, function (_ref2) {
@@ -14,18 +14,17 @@ import { css, jsx } from '@emotion/core';
14
14
  import { DN50, DN50A, DN600, DN60A, N0, N50A, N60A, N900 } from '@atlaskit/theme/colors';
15
15
  import { themed, useGlobalTheme } from '@atlaskit/theme/components';
16
16
  import { borderRadius as getBorderRadius, gridSize as getGridSize, layers } from '@atlaskit/theme/constants';
17
- import { token } from '@atlaskit/tokens';
18
17
  var themedBackground = themed({
19
- light: token('color.background.overlay', N0),
20
- dark: token('color.background.overlay', DN50)
18
+ light: "var(--ds-background-overlay, ".concat(N0, ")"),
19
+ dark: "var(--ds-background-overlay, ".concat(DN50, ")")
21
20
  });
22
21
  var themedColor = themed({
23
- light: token('color.text.highEmphasis', N900),
24
- dark: token('color.text.highEmphasis', DN600)
22
+ light: "var(--ds-text-highEmphasis, ".concat(N900, ")"),
23
+ dark: "var(--ds-text-highEmphasis, ".concat(DN600, ")")
25
24
  });
26
25
  var themedBoxShadow = themed({
27
- light: token('shadow.overlay', "0 4px 8px -2px ".concat(N50A, ", 0 0 1px ").concat(N60A)),
28
- dark: token('shadow.overlay', "0 4px 8px -2px ".concat(DN50A, ", 0 0 1px ").concat(DN60A))
26
+ light: "var(--ds-overlay, ".concat("0 4px 8px -2px ".concat(N50A, ", 0 0 1px ").concat(N60A), ")"),
27
+ dark: "var(--ds-overlay, ".concat("0 4px 8px -2px ".concat(DN50A, ", 0 0 1px ").concat(DN60A), ")")
29
28
  });
30
29
  var borderRadius = getBorderRadius();
31
30
  var gridSize = getGridSize();
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/inline-dialog",
3
- "version": "13.1.6",
3
+ "version": "13.2.0",
4
4
  "sideEffects": false
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/inline-dialog",
3
- "version": "13.1.6",
3
+ "version": "13.2.0",
4
4
  "description": "An inline dialog is a pop-up container for small amounts of information. It can also contain controls.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -28,7 +28,7 @@
28
28
  "@atlaskit/ds-lib": "^1.3.0",
29
29
  "@atlaskit/popper": "^5.0.0",
30
30
  "@atlaskit/theme": "^12.0.0",
31
- "@atlaskit/tokens": "^0.2.0",
31
+ "@atlaskit/tokens": "^0.4.0",
32
32
  "@babel/runtime": "^7.0.0",
33
33
  "@emotion/core": "^10.0.9",
34
34
  "bind-event-listener": "^1.0.2",
@@ -40,13 +40,12 @@
40
40
  "devDependencies": {
41
41
  "@atlaskit/build-utils": "*",
42
42
  "@atlaskit/button": "^16.1.0",
43
- "@atlaskit/datetime-picker": "^11.0.0",
43
+ "@atlaskit/datetime-picker": "^11.1.0",
44
44
  "@atlaskit/docs": "*",
45
45
  "@atlaskit/icon": "^21.9.0",
46
- "@atlaskit/modal-dialog": "^12.0.1",
46
+ "@atlaskit/modal-dialog": "^12.2.0",
47
47
  "@atlaskit/section-message": "^6.1.0",
48
48
  "@atlaskit/select": "^15.0.0",
49
- "@atlaskit/single-select": "^10.0.0",
50
49
  "@atlaskit/ssr": "*",
51
50
  "@atlaskit/visual-regression": "*",
52
51
  "@atlaskit/webdriver-runner": "*",
@@ -70,10 +69,13 @@
70
69
  "@repo/internal": {
71
70
  "analytics": "analytics-next",
72
71
  "theming": [
73
- "new-theming-api",
72
+ "react-context",
74
73
  "tokens"
75
74
  ],
76
- "styling": "emotion",
75
+ "styling": [
76
+ "static",
77
+ "emotion"
78
+ ],
77
79
  "design-system": "v1",
78
80
  "deprecation": "no-deprecated-imports"
79
81
  }