@atlaskit/flag 15.6.1 → 15.6.3

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,19 @@
1
1
  # @atlaskit/flag
2
2
 
3
+ ## 15.6.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 15.6.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [#113275](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/113275)
14
+ [`b52de02acc0d0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b52de02acc0d0) -
15
+ Add support to delay the screen reader announcement by props
16
+
3
17
  ## 15.6.1
4
18
 
5
19
  ### Patch Changes
@@ -15,7 +15,7 @@ var _flagGroup = require("./flag-group");
15
15
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
16
16
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
17
17
  var packageName = "@atlaskit/flag";
18
- var packageVersion = "15.6.1";
18
+ var packageVersion = "15.6.3";
19
19
  var AUTO_DISMISS_SECONDS = exports.AUTO_DISMISS_SECONDS = 8;
20
20
 
21
21
  /**
package/dist/cjs/flag.js CHANGED
@@ -18,6 +18,7 @@ var _theme = require("./theme");
18
18
  var _flagActions = _interopRequireDefault(require("./flag-actions"));
19
19
  var _flagGroup = require("./flag-group");
20
20
  var _internal = require("./internal");
21
+ var _visuallyHidden = _interopRequireDefault(require("@atlaskit/visually-hidden"));
21
22
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
22
23
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /**
23
24
  * @jsxRuntime classic
@@ -54,7 +55,7 @@ var flagWrapperStyles = (0, _react2.css)({
54
55
  var analyticsAttributes = {
55
56
  componentName: 'flag',
56
57
  packageName: "@atlaskit/flag",
57
- packageVersion: "15.6.1"
58
+ packageVersion: "15.6.3"
58
59
  };
59
60
  var transitionStyles = (0, _react2.css)({
60
61
  flexGrow: 1,
@@ -90,7 +91,12 @@ var Flag = function Flag(props) {
90
91
  onDismissedProp = _props$onDismissed === void 0 ? _noop.default : _props$onDismissed,
91
92
  testId = props.testId,
92
93
  id = props.id,
93
- analyticsContext = props.analyticsContext;
94
+ analyticsContext = props.analyticsContext,
95
+ delayAnnouncement = props.delayAnnouncement;
96
+ var _useState = (0, _react.useState)(false),
97
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
98
+ isDelayToAnnounce = _useState2[0],
99
+ setIsDelayToAnnounce = _useState2[1];
94
100
  var _useFlagGroup = (0, _flagGroup.useFlagGroup)(),
95
101
  onDismissedFromFlagGroup = _useFlagGroup.onDismissed,
96
102
  isDismissAllowed = _useFlagGroup.isDismissAllowed;
@@ -98,10 +104,10 @@ var Flag = function Flag(props) {
98
104
  onDismissedProp(id, analyticsEvent);
99
105
  onDismissedFromFlagGroup(id, analyticsEvent);
100
106
  }, [onDismissedProp, onDismissedFromFlagGroup]);
101
- var _useState = (0, _react.useState)(false),
102
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
103
- isExpanded = _useState2[0],
104
- setIsExpanded = _useState2[1];
107
+ var _useState3 = (0, _react.useState)(false),
108
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
109
+ isExpanded = _useState4[0],
110
+ setIsExpanded = _useState4[1];
105
111
  var onDismissedAnalytics = (0, _usePlatformLeafEventHandler.usePlatformLeafEventHandler)(_objectSpread({
106
112
  fn: onDismissed,
107
113
  action: 'dismissed',
@@ -124,6 +130,14 @@ var Flag = function Flag(props) {
124
130
  setIsExpanded(false);
125
131
  }
126
132
  }, [actions.length, description, isBold, isExpanded]);
133
+ (0, _react.useEffect)(function () {
134
+ if (!delayAnnouncement) {
135
+ return;
136
+ }
137
+ setTimeout(function () {
138
+ setIsDelayToAnnounce(true);
139
+ }, delayAnnouncement);
140
+ }, [delayAnnouncement]);
127
141
  var onFocusAnalytics = (0, _usePlatformLeafEventHandler.usePlatformLeafEventHandler)(_objectSpread({
128
142
  fn: onFocus,
129
143
  action: 'focused',
@@ -144,8 +158,12 @@ var Flag = function Flag(props) {
144
158
  var iconColor = _theme.flagIconColor[appearance];
145
159
  var isDismissable = isBold || isDismissAllowed;
146
160
  var shouldRenderGap = !isBold && (description || actions.length) || isExpanded;
161
+ // when delayAnnouncement is available we will use a hidden content for announcement
162
+ var delayedAnnouncement = delayAnnouncement ? (0, _react2.jsx)(_visuallyHidden.default, {
163
+ role: "alert"
164
+ }, title, description) : undefined;
147
165
  return (0, _react2.jsx)("div", (0, _extends2.default)({
148
- role: "alert",
166
+ role: delayAnnouncement ? undefined : 'alert',
149
167
  css: flagWrapperStyles,
150
168
  "data-testid": testId
151
169
  }, autoDismissProps), (0, _react2.jsx)(_primitives.Box, {
@@ -164,7 +182,7 @@ var Flag = function Flag(props) {
164
182
  css: transitionStyles
165
183
  }, (0, _react2.jsx)(_primitives.Stack, {
166
184
  space: shouldRenderGap ? 'space.100' : 'space.0' // Gap exists even when not expanded due to Expander internals always being in the DOM
167
- }, (0, _react2.jsx)(_primitives.Inline, {
185
+ }, isDelayToAnnounce && delayedAnnouncement, (0, _react2.jsx)(_primitives.Inline, {
168
186
  alignBlock: "stretch",
169
187
  space: "space.100",
170
188
  spread: "space-between"
@@ -5,7 +5,7 @@ import noop from '@atlaskit/ds-lib/noop';
5
5
  import Flag from './flag';
6
6
  import { useFlagGroup } from './flag-group';
7
7
  const packageName = "@atlaskit/flag";
8
- const packageVersion = "15.6.1";
8
+ const packageVersion = "15.6.3";
9
9
  export const AUTO_DISMISS_SECONDS = 8;
10
10
 
11
11
  /**
@@ -15,6 +15,7 @@ import { flagTextColor, flagBackgroundColor, flagIconColor, flagTextColorToken }
15
15
  import Actions from './flag-actions';
16
16
  import { useFlagGroup } from './flag-group';
17
17
  import { Expander, DismissButton } from './internal';
18
+ import VisuallyHidden from '@atlaskit/visually-hidden';
18
19
  const CSS_VAR_ICON_COLOR = '--flag-icon-color';
19
20
 
20
21
  // For cases where a single word is longer than the container (e.g. filenames)
@@ -47,7 +48,7 @@ const flagWrapperStyles = css({
47
48
  const analyticsAttributes = {
48
49
  componentName: 'flag',
49
50
  packageName: "@atlaskit/flag",
50
- packageVersion: "15.6.1"
51
+ packageVersion: "15.6.3"
51
52
  };
52
53
  const transitionStyles = css({
53
54
  flexGrow: 1,
@@ -79,8 +80,10 @@ const Flag = props => {
79
80
  onDismissed: onDismissedProp = noop,
80
81
  testId,
81
82
  id,
82
- analyticsContext
83
+ analyticsContext,
84
+ delayAnnouncement
83
85
  } = props;
86
+ const [isDelayToAnnounce, setIsDelayToAnnounce] = useState(false);
84
87
  const {
85
88
  onDismissed: onDismissedFromFlagGroup,
86
89
  isDismissAllowed
@@ -111,6 +114,14 @@ const Flag = props => {
111
114
  setIsExpanded(false);
112
115
  }
113
116
  }, [actions.length, description, isBold, isExpanded]);
117
+ useEffect(() => {
118
+ if (!delayAnnouncement) {
119
+ return;
120
+ }
121
+ setTimeout(() => {
122
+ setIsDelayToAnnounce(true);
123
+ }, delayAnnouncement);
124
+ }, [delayAnnouncement]);
114
125
  const onFocusAnalytics = usePlatformLeafEventHandler({
115
126
  fn: onFocus,
116
127
  action: 'focused',
@@ -133,8 +144,12 @@ const Flag = props => {
133
144
  const iconColor = flagIconColor[appearance];
134
145
  const isDismissable = isBold || isDismissAllowed;
135
146
  const shouldRenderGap = !isBold && (description || actions.length) || isExpanded;
147
+ // when delayAnnouncement is available we will use a hidden content for announcement
148
+ const delayedAnnouncement = delayAnnouncement ? jsx(VisuallyHidden, {
149
+ role: "alert"
150
+ }, title, description) : undefined;
136
151
  return jsx("div", _extends({
137
- role: "alert",
152
+ role: delayAnnouncement ? undefined : 'alert',
138
153
  css: flagWrapperStyles,
139
154
  "data-testid": testId
140
155
  }, autoDismissProps), jsx(Box, {
@@ -155,7 +170,7 @@ const Flag = props => {
155
170
  css: transitionStyles
156
171
  }, jsx(Stack, {
157
172
  space: shouldRenderGap ? 'space.100' : 'space.0' // Gap exists even when not expanded due to Expander internals always being in the DOM
158
- }, jsx(Inline, {
173
+ }, isDelayToAnnounce && delayedAnnouncement, jsx(Inline, {
159
174
  alignBlock: "stretch",
160
175
  space: "space.100",
161
176
  spread: "space-between"
@@ -5,7 +5,7 @@ import noop from '@atlaskit/ds-lib/noop';
5
5
  import Flag from './flag';
6
6
  import { useFlagGroup } from './flag-group';
7
7
  var packageName = "@atlaskit/flag";
8
- var packageVersion = "15.6.1";
8
+ var packageVersion = "15.6.3";
9
9
  export var AUTO_DISMISS_SECONDS = 8;
10
10
 
11
11
  /**
package/dist/esm/flag.js CHANGED
@@ -19,6 +19,7 @@ import { flagTextColor, flagBackgroundColor, flagIconColor, flagTextColorToken }
19
19
  import Actions from './flag-actions';
20
20
  import { useFlagGroup } from './flag-group';
21
21
  import { Expander, DismissButton } from './internal';
22
+ import VisuallyHidden from '@atlaskit/visually-hidden';
22
23
  var CSS_VAR_ICON_COLOR = '--flag-icon-color';
23
24
 
24
25
  // For cases where a single word is longer than the container (e.g. filenames)
@@ -51,7 +52,7 @@ var flagWrapperStyles = css({
51
52
  var analyticsAttributes = {
52
53
  componentName: 'flag',
53
54
  packageName: "@atlaskit/flag",
54
- packageVersion: "15.6.1"
55
+ packageVersion: "15.6.3"
55
56
  };
56
57
  var transitionStyles = css({
57
58
  flexGrow: 1,
@@ -87,7 +88,12 @@ var Flag = function Flag(props) {
87
88
  onDismissedProp = _props$onDismissed === void 0 ? noop : _props$onDismissed,
88
89
  testId = props.testId,
89
90
  id = props.id,
90
- analyticsContext = props.analyticsContext;
91
+ analyticsContext = props.analyticsContext,
92
+ delayAnnouncement = props.delayAnnouncement;
93
+ var _useState = useState(false),
94
+ _useState2 = _slicedToArray(_useState, 2),
95
+ isDelayToAnnounce = _useState2[0],
96
+ setIsDelayToAnnounce = _useState2[1];
91
97
  var _useFlagGroup = useFlagGroup(),
92
98
  onDismissedFromFlagGroup = _useFlagGroup.onDismissed,
93
99
  isDismissAllowed = _useFlagGroup.isDismissAllowed;
@@ -95,10 +101,10 @@ var Flag = function Flag(props) {
95
101
  onDismissedProp(id, analyticsEvent);
96
102
  onDismissedFromFlagGroup(id, analyticsEvent);
97
103
  }, [onDismissedProp, onDismissedFromFlagGroup]);
98
- var _useState = useState(false),
99
- _useState2 = _slicedToArray(_useState, 2),
100
- isExpanded = _useState2[0],
101
- setIsExpanded = _useState2[1];
104
+ var _useState3 = useState(false),
105
+ _useState4 = _slicedToArray(_useState3, 2),
106
+ isExpanded = _useState4[0],
107
+ setIsExpanded = _useState4[1];
102
108
  var onDismissedAnalytics = usePlatformLeafEventHandler(_objectSpread({
103
109
  fn: onDismissed,
104
110
  action: 'dismissed',
@@ -121,6 +127,14 @@ var Flag = function Flag(props) {
121
127
  setIsExpanded(false);
122
128
  }
123
129
  }, [actions.length, description, isBold, isExpanded]);
130
+ useEffect(function () {
131
+ if (!delayAnnouncement) {
132
+ return;
133
+ }
134
+ setTimeout(function () {
135
+ setIsDelayToAnnounce(true);
136
+ }, delayAnnouncement);
137
+ }, [delayAnnouncement]);
124
138
  var onFocusAnalytics = usePlatformLeafEventHandler(_objectSpread({
125
139
  fn: onFocus,
126
140
  action: 'focused',
@@ -141,8 +155,12 @@ var Flag = function Flag(props) {
141
155
  var iconColor = flagIconColor[appearance];
142
156
  var isDismissable = isBold || isDismissAllowed;
143
157
  var shouldRenderGap = !isBold && (description || actions.length) || isExpanded;
158
+ // when delayAnnouncement is available we will use a hidden content for announcement
159
+ var delayedAnnouncement = delayAnnouncement ? jsx(VisuallyHidden, {
160
+ role: "alert"
161
+ }, title, description) : undefined;
144
162
  return jsx("div", _extends({
145
- role: "alert",
163
+ role: delayAnnouncement ? undefined : 'alert',
146
164
  css: flagWrapperStyles,
147
165
  "data-testid": testId
148
166
  }, autoDismissProps), jsx(Box, {
@@ -161,7 +179,7 @@ var Flag = function Flag(props) {
161
179
  css: transitionStyles
162
180
  }, jsx(Stack, {
163
181
  space: shouldRenderGap ? 'space.100' : 'space.0' // Gap exists even when not expanded due to Expander internals always being in the DOM
164
- }, jsx(Inline, {
182
+ }, isDelayToAnnounce && delayedAnnouncement, jsx(Inline, {
165
183
  alignBlock: "stretch",
166
184
  space: "space.100",
167
185
  spread: "space-between"
@@ -95,6 +95,10 @@ export interface FlagPropsWithoutId extends AutoDismissFlagPropsWithoutId, WithA
95
95
  * Standard onMouseOver event, applied to Flag by AutoDismissFlag.
96
96
  */
97
97
  onMouseOver?: MouseEventHandler;
98
+ /**
99
+ * Milliseconds to delay the screen reader announcement due to announcement conflict.
100
+ */
101
+ delayAnnouncement?: number;
98
102
  }
99
103
  export interface FlagProps extends FlagPropsWithoutId, FlagPropsId {
100
104
  }
@@ -95,6 +95,10 @@ export interface FlagPropsWithoutId extends AutoDismissFlagPropsWithoutId, WithA
95
95
  * Standard onMouseOver event, applied to Flag by AutoDismissFlag.
96
96
  */
97
97
  onMouseOver?: MouseEventHandler;
98
+ /**
99
+ * Milliseconds to delay the screen reader announcement due to announcement conflict.
100
+ */
101
+ delayAnnouncement?: number;
98
102
  }
99
103
  export interface FlagProps extends FlagPropsWithoutId, FlagPropsId {
100
104
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/flag",
3
- "version": "15.6.1",
3
+ "version": "15.6.3",
4
4
  "description": "A flag is used for confirmations, alerts, and acknowledgments that require minimal user interaction, often displayed using a flag group.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -47,14 +47,14 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "@atlaskit/analytics-next": "^9.3.0",
50
- "@atlaskit/button": "^17.22.0",
50
+ "@atlaskit/button": "^18.0.0",
51
51
  "@atlaskit/ds-lib": "^2.3.0",
52
52
  "@atlaskit/icon": "^22.4.0",
53
53
  "@atlaskit/motion": "^1.7.0",
54
54
  "@atlaskit/portal": "^4.6.0",
55
55
  "@atlaskit/primitives": "^8.0.0",
56
- "@atlaskit/theme": "^12.10.0",
57
- "@atlaskit/tokens": "^1.51.0",
56
+ "@atlaskit/theme": "^12.11.0",
57
+ "@atlaskit/tokens": "^1.52.0",
58
58
  "@atlaskit/visually-hidden": "^1.4.0",
59
59
  "@babel/runtime": "^7.0.0",
60
60
  "@emotion/react": "^11.7.1"