@atlaskit/inline-dialog 17.0.2 → 17.1.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,14 @@
1
1
  # @atlaskit/inline-dialog
2
2
 
3
+ ## 17.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#152852](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/152852)
8
+ [`ae720e711e4d2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ae720e711e4d2) -
9
+ Adds `fallbackPlacements` prop for specifying a list of backup placements to try when the main
10
+ `placement` does not have enough space. This matches the API of `Popup`.
11
+
3
12
  ## 17.0.2
4
13
 
5
14
  ### Patch Changes
@@ -68,7 +68,8 @@ var InlineDialog = /*#__PURE__*/(0, _react.memo)(function InlineDialog(_ref2) {
68
68
  strategy = _ref2$strategy === void 0 ? 'fixed' : _ref2$strategy,
69
69
  testId = _ref2.testId,
70
70
  content = _ref2.content,
71
- children = _ref2.children;
71
+ children = _ref2.children,
72
+ fallbackPlacements = _ref2.fallbackPlacements;
72
73
  var containerRef = (0, _react.useRef)(null);
73
74
  var triggerRef = (0, _react.useRef)(null);
74
75
  var onClose = (0, _analyticsNext.usePlatformLeafEventHandler)({
@@ -78,7 +79,7 @@ var InlineDialog = /*#__PURE__*/(0, _react.memo)(function InlineDialog(_ref2) {
78
79
  action: 'closed',
79
80
  componentName: 'inlineDialog',
80
81
  packageName: "@atlaskit/inline-dialog",
81
- packageVersion: "17.0.2"
82
+ packageVersion: "17.1.0"
82
83
  });
83
84
 
84
85
  // we put this into a ref to avoid handleCloseRequest having this as a dependency
@@ -133,9 +134,25 @@ var InlineDialog = /*#__PURE__*/(0, _react.memo)(function InlineDialog(_ref2) {
133
134
  }
134
135
  handleCloseRequest(event);
135
136
  }, [handleCloseRequest, containerRef, triggerRef]);
137
+
138
+ /**
139
+ * Auto-flip is enabled by default in `@atlaskit/popper` and
140
+ * the `InlineDialog` API does not allow disabling it.
141
+ *
142
+ * We only need to override it if there are `fallbackPlacements` specified.
143
+ */
144
+ var modifiers = (0, _react.useMemo)(function () {
145
+ return fallbackPlacements ? [{
146
+ name: 'flip',
147
+ options: {
148
+ fallbackPlacements: fallbackPlacements
149
+ }
150
+ }] : [];
151
+ }, [fallbackPlacements]);
136
152
  var popper = isOpen ? /*#__PURE__*/_react.default.createElement(_popper.Popper, {
137
153
  placement: placement,
138
- strategy: strategy
154
+ strategy: strategy,
155
+ modifiers: modifiers
139
156
  }, function (_ref3) {
140
157
  var _ref4 = _ref3.ref,
141
158
  style = _ref3.style;
@@ -169,7 +186,6 @@ var InlineDialog = /*#__PURE__*/(0, _react.memo)(function InlineDialog(_ref2) {
169
186
  } else {
170
187
  ref.current = node;
171
188
  }
172
- // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
173
189
  },
174
190
  hasNodeResolver: !(0, _platformFeatureFlags.fg)('platform_design_system_team_portal_logic_r18_fix')
175
191
  }, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children));
@@ -1,4 +1,4 @@
1
- import React, { memo, useCallback, useEffect, useRef } from 'react';
1
+ import React, { memo, useCallback, useEffect, useMemo, useRef } from 'react';
2
2
  import { bind } from 'bind-event-listener';
3
3
  import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next';
4
4
  import noop from '@atlaskit/ds-lib/noop';
@@ -53,7 +53,8 @@ const InlineDialog = /*#__PURE__*/memo(function InlineDialog({
53
53
  strategy = 'fixed',
54
54
  testId,
55
55
  content,
56
- children
56
+ children,
57
+ fallbackPlacements
57
58
  }) {
58
59
  const containerRef = useRef(null);
59
60
  const triggerRef = useRef(null);
@@ -62,7 +63,7 @@ const InlineDialog = /*#__PURE__*/memo(function InlineDialog({
62
63
  action: 'closed',
63
64
  componentName: 'inlineDialog',
64
65
  packageName: "@atlaskit/inline-dialog",
65
- packageVersion: "17.0.2"
66
+ packageVersion: "17.1.0"
66
67
  });
67
68
 
68
69
  // we put this into a ref to avoid handleCloseRequest having this as a dependency
@@ -119,9 +120,23 @@ const InlineDialog = /*#__PURE__*/memo(function InlineDialog({
119
120
  }
120
121
  handleCloseRequest(event);
121
122
  }, [handleCloseRequest, containerRef, triggerRef]);
123
+
124
+ /**
125
+ * Auto-flip is enabled by default in `@atlaskit/popper` and
126
+ * the `InlineDialog` API does not allow disabling it.
127
+ *
128
+ * We only need to override it if there are `fallbackPlacements` specified.
129
+ */
130
+ const modifiers = useMemo(() => fallbackPlacements ? [{
131
+ name: 'flip',
132
+ options: {
133
+ fallbackPlacements
134
+ }
135
+ }] : [], [fallbackPlacements]);
122
136
  const popper = isOpen ? /*#__PURE__*/React.createElement(Popper, {
123
137
  placement: placement,
124
- strategy: strategy
138
+ strategy: strategy,
139
+ modifiers: modifiers
125
140
  }, ({
126
141
  ref,
127
142
  style
@@ -154,7 +169,6 @@ const InlineDialog = /*#__PURE__*/memo(function InlineDialog({
154
169
  } else {
155
170
  ref.current = node;
156
171
  }
157
- // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
158
172
  },
159
173
  hasNodeResolver: !fg('platform_design_system_team_portal_logic_r18_fix')
160
174
  }, /*#__PURE__*/React.createElement(React.Fragment, null, children))), isOpen ? /*#__PURE__*/React.createElement(Layering, {
@@ -36,7 +36,6 @@ export const Container = /*#__PURE__*/forwardRef(({
36
36
  [CSS_THEME_COLOR]: `var(--ds-text, ${N900})`,
37
37
  [CSS_THEME_BOX_SHADOW]: `var(--ds-shadow-overlay, ${`0 4px 8px -2px ${N50A}, 0 0 1px ${N60A}`})`,
38
38
  ...style
39
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
40
39
  },
41
40
  className: ax(["_11q7gluh _2rko1sit _vchh1ntv _p12flti4 _c71llti4 _1pbyowjs _16qs1r44 _syazjslb _85i5pxbi _1q51pxbi _y4ti1ejb _bozg1ejb _nt751r31 _49pcglyw _1hvw1o36"])
42
41
  }, typeof children === 'function' ? children() : children);
@@ -1,4 +1,4 @@
1
- import React, { memo, useCallback, useEffect, useRef } from 'react';
1
+ import React, { memo, useCallback, useEffect, useMemo, useRef } from 'react';
2
2
  import { bind } from 'bind-event-listener';
3
3
  import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next';
4
4
  import noop from '@atlaskit/ds-lib/noop';
@@ -58,7 +58,8 @@ var InlineDialog = /*#__PURE__*/memo(function InlineDialog(_ref2) {
58
58
  strategy = _ref2$strategy === void 0 ? 'fixed' : _ref2$strategy,
59
59
  testId = _ref2.testId,
60
60
  content = _ref2.content,
61
- children = _ref2.children;
61
+ children = _ref2.children,
62
+ fallbackPlacements = _ref2.fallbackPlacements;
62
63
  var containerRef = useRef(null);
63
64
  var triggerRef = useRef(null);
64
65
  var onClose = usePlatformLeafEventHandler({
@@ -68,7 +69,7 @@ var InlineDialog = /*#__PURE__*/memo(function InlineDialog(_ref2) {
68
69
  action: 'closed',
69
70
  componentName: 'inlineDialog',
70
71
  packageName: "@atlaskit/inline-dialog",
71
- packageVersion: "17.0.2"
72
+ packageVersion: "17.1.0"
72
73
  });
73
74
 
74
75
  // we put this into a ref to avoid handleCloseRequest having this as a dependency
@@ -123,9 +124,25 @@ var InlineDialog = /*#__PURE__*/memo(function InlineDialog(_ref2) {
123
124
  }
124
125
  handleCloseRequest(event);
125
126
  }, [handleCloseRequest, containerRef, triggerRef]);
127
+
128
+ /**
129
+ * Auto-flip is enabled by default in `@atlaskit/popper` and
130
+ * the `InlineDialog` API does not allow disabling it.
131
+ *
132
+ * We only need to override it if there are `fallbackPlacements` specified.
133
+ */
134
+ var modifiers = useMemo(function () {
135
+ return fallbackPlacements ? [{
136
+ name: 'flip',
137
+ options: {
138
+ fallbackPlacements: fallbackPlacements
139
+ }
140
+ }] : [];
141
+ }, [fallbackPlacements]);
126
142
  var popper = isOpen ? /*#__PURE__*/React.createElement(Popper, {
127
143
  placement: placement,
128
- strategy: strategy
144
+ strategy: strategy,
145
+ modifiers: modifiers
129
146
  }, function (_ref3) {
130
147
  var _ref4 = _ref3.ref,
131
148
  style = _ref3.style;
@@ -159,7 +176,6 @@ var InlineDialog = /*#__PURE__*/memo(function InlineDialog(_ref2) {
159
176
  } else {
160
177
  ref.current = node;
161
178
  }
162
- // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
163
179
  },
164
180
  hasNodeResolver: !fg('platform_design_system_team_portal_logic_r18_fix')
165
181
  }, /*#__PURE__*/React.createElement(React.Fragment, null, children));
@@ -46,4 +46,11 @@ export interface InlineDialogProps extends WithAnalyticsEventsProps {
46
46
  * A `testId` prop is provided for specified elements, which is a unique string that appears as a data attribute `data-testid` in the rendered code, serving as a hook for automated tests
47
47
  */
48
48
  testId?: string;
49
+ /**
50
+ * This is a list of backup placements to try.
51
+ * When the preferred placement doesn't have enough space,
52
+ * the modifier will test the ones provided in the list, and use the first suitable one.
53
+ * If no fallback placements are suitable, it reverts back to the original placement.
54
+ */
55
+ fallbackPlacements?: Placement[];
49
56
  }
@@ -46,4 +46,11 @@ export interface InlineDialogProps extends WithAnalyticsEventsProps {
46
46
  * A `testId` prop is provided for specified elements, which is a unique string that appears as a data attribute `data-testid` in the rendered code, serving as a hook for automated tests
47
47
  */
48
48
  testId?: string;
49
+ /**
50
+ * This is a list of backup placements to try.
51
+ * When the preferred placement doesn't have enough space,
52
+ * the modifier will test the ones provided in the list, and use the first suitable one.
53
+ * If no fallback placements are suitable, it reverts back to the original placement.
54
+ */
55
+ fallbackPlacements?: Placement[];
49
56
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/inline-dialog",
3
- "version": "17.0.2",
3
+ "version": "17.1.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/"
@@ -42,11 +42,11 @@
42
42
  "@atlaskit/analytics-next": "^11.0.0",
43
43
  "@atlaskit/css": "^0.10.0",
44
44
  "@atlaskit/ds-lib": "^4.0.0",
45
- "@atlaskit/layering": "^2.0.0",
45
+ "@atlaskit/layering": "^2.1.0",
46
46
  "@atlaskit/platform-feature-flags": "^1.1.0",
47
47
  "@atlaskit/popper": "^7.0.0",
48
48
  "@atlaskit/theme": "^18.0.0",
49
- "@atlaskit/tokens": "^4.5.0",
49
+ "@atlaskit/tokens": "^4.8.0",
50
50
  "@babel/runtime": "^7.0.0",
51
51
  "@compiled/react": "^0.18.3",
52
52
  "bind-event-listener": "^3.0.0",
@@ -56,19 +56,19 @@
56
56
  "react": "^18.2.0"
57
57
  },
58
58
  "devDependencies": {
59
- "@af/accessibility-testing": "^2.0.0",
60
- "@af/integration-testing": "^0.5.0",
61
- "@af/visual-regression": "^1.3.0",
62
- "@atlaskit/button": "^21.1.0",
63
- "@atlaskit/datetime-picker": "^16.2.0",
59
+ "@af/accessibility-testing": "workspace:^",
60
+ "@af/integration-testing": "workspace:^",
61
+ "@af/visual-regression": "workspace:^",
62
+ "@atlaskit/button": "^23.0.0",
63
+ "@atlaskit/datetime-picker": "^17.0.0",
64
64
  "@atlaskit/docs": "^10.0.0",
65
- "@atlaskit/dropdown-menu": "^13.0.0",
66
- "@atlaskit/link": "^3.0.0",
67
- "@atlaskit/modal-dialog": "^13.4.0",
68
- "@atlaskit/primitives": "^14.2.0",
65
+ "@atlaskit/dropdown-menu": "^14.2.0",
66
+ "@atlaskit/link": "^3.1.0",
67
+ "@atlaskit/modal-dialog": "^14.2.0",
68
+ "@atlaskit/primitives": "^14.7.0",
69
69
  "@atlaskit/section-message": "^8.2.0",
70
- "@atlaskit/select": "^20.0.0",
71
- "@atlaskit/ssr": "^0.4.0",
70
+ "@atlaskit/select": "^20.4.0",
71
+ "@atlassian/ssr-tests": "^0.2.0",
72
72
  "@testing-library/react": "^13.4.0",
73
73
  "@types/react-node-resolver": "^2.0.0",
74
74
  "react-dom": "^18.2.0",